ZHANGYUXUAN-zR commited on
Commit
2ac8061
·
verified ·
1 Parent(s): ec1bf55

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. README.md +108 -3
  2. manifest.jsonl +0 -0
  3. md/dev/0EXmFzUn5I/0EXmFzUn5I.md +386 -0
  4. md/dev/4XMAzZasId/4XMAzZasId.md +0 -0
  5. md/dev/7B3IJMM1k_M/7B3IJMM1k_M.md +520 -0
  6. md/dev/8XWP2ewX-im/8XWP2ewX-im.md +350 -0
  7. md/dev/98p5x51L5af/98p5x51L5af.md +458 -0
  8. md/dev/9uRS5ysgb9/9uRS5ysgb9.md +361 -0
  9. md/dev/AHvFDPi-FA/AHvFDPi-FA.md +335 -0
  10. md/dev/BlF6CWzWKT7/BlF6CWzWKT7.md +0 -0
  11. md/dev/Bto5a6w06l/Bto5a6w06l.md +426 -0
  12. md/dev/C54V-xTWfi/C54V-xTWfi.md +335 -0
  13. md/dev/DgM7-7eMkq0/DgM7-7eMkq0.md +314 -0
  14. md/dev/EAcWgk7JM58/EAcWgk7JM58.md +235 -0
  15. md/dev/KnCS9390Va/KnCS9390Va.md +334 -0
  16. md/dev/LzQQ89U1qm_/LzQQ89U1qm_.md +443 -0
  17. md/dev/NpsVSN6o4ul/NpsVSN6o4ul.md +438 -0
  18. md/dev/OjDkC57x5sz/OjDkC57x5sz.md +438 -0
  19. md/dev/Pv1GPQzRrC8/Pv1GPQzRrC8.md +498 -0
  20. md/dev/QDE5hzxVpS/QDE5hzxVpS.md +234 -0
  21. md/dev/Re3NjSwf0WF/Re3NjSwf0WF.md +231 -0
  22. md/dev/UHBrWeFWlL/UHBrWeFWlL.md +288 -0
  23. md/dev/Uy6YEI9-6v/Uy6YEI9-6v.md +353 -0
  24. md/dev/WaGvb7OzySA/WaGvb7OzySA.md +296 -0
  25. md/dev/X5S3pEGPZv8/X5S3pEGPZv8.md +421 -0
  26. md/dev/XByg4kotW5/XByg4kotW5.md +347 -0
  27. md/dev/Z1Qlm11uOM/Z1Qlm11uOM.md +400 -0
  28. md/dev/agJEk7FhvKL/agJEk7FhvKL.md +353 -0
  29. md/dev/b9tUk-f_aG/b9tUk-f_aG.md +0 -0
  30. md/dev/dJgYhYKvr1/dJgYhYKvr1.md +371 -0
  31. md/dev/fR-EnKWL_Zb/fR-EnKWL_Zb.md +358 -0
  32. md/dev/fxdvWG4rJe/fxdvWG4rJe.md +332 -0
  33. md/dev/gJLAfO4KUq/gJLAfO4KUq.md +364 -0
  34. md/dev/iulEMLYh1uR/iulEMLYh1uR.md +356 -0
  35. md/dev/jA235JGM09/jA235JGM09.md +0 -0
  36. md/dev/lJWUJWLCJo/lJWUJWLCJo.md +386 -0
  37. md/dev/ls4Pfsl2jZ/ls4Pfsl2jZ.md +408 -0
  38. md/dev/o_HsiMPYh_x/o_HsiMPYh_x.md +0 -0
  39. md/dev/p0LJa6_XHM_/p0LJa6_XHM_.md +346 -0
  40. md/dev/qUKsCztWlKq/qUKsCztWlKq.md +460 -0
  41. md/dev/rmMOupN1Sqp/rmMOupN1Sqp.md +0 -0
  42. md/dev/tyrJsbKAe6/tyrJsbKAe6.md +0 -0
  43. md/dev/u3vEuRr08MT/u3vEuRr08MT.md +364 -0
  44. md/dev/unb1wyXf-aC/unb1wyXf-aC.md +470 -0
  45. md/dev/vcNjibzV3P/vcNjibzV3P.md +466 -0
  46. md/dev/wmwgLEPjL9/wmwgLEPjL9.md +304 -0
  47. md/dev/xxgp42Qz6dL/xxgp42Qz6dL.md +346 -0
  48. md/dev/ySQH0oDyp7/ySQH0oDyp7.md +548 -0
  49. md/dev/ztcfHweENtU/ztcfHweENtU.md +759 -0
  50. split_metadata/test.json +0 -0
README.md CHANGED
@@ -1,3 +1,108 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ pretty_name: RPC-Bench
4
+ task_categories:
5
+ - question-answering
6
+ language:
7
+ - en
8
+ tags:
9
+ - research-paper
10
+ - document-understanding
11
+ - multimodal
12
+ - benchmark
13
+ - llm
14
+ - vlm
15
+ ---
16
+
17
+ <div align="center">
18
+
19
+ # RPC-Bench: A Fine-grained Benchmark for Research Paper Comprehension
20
+
21
+ </div>
22
+
23
+ <p align="center">
24
+ 🌐 <a href="https://rpc-bench.github.io/" target="_blank">Project Page</a> •
25
+ 💻 <a href="https://github.com/RPC-Bench/PRC-Bench" target="_blank">GitHub</a> •
26
+ 📖 <a href="https://arxiv.org/abs/2601.14289" target="_blank">Paper</a>
27
+ <!-- 🤗 <a href="https://arxiv.org/abs/2601.14289" target="_blank">Paper</a> • -->
28
+ <!-- 🧭 <a href="https://community.modelscope.cn/" target="_blank">ModelScope</a> -->
29
+ </p>
30
+
31
+ <div align="center">
32
+ <img src="assets/pipeline.png" width="100%" />
33
+ </div>
34
+
35
+ RPC-Bench is a fine-grained benchmark for research paper comprehension. It is built from review-rebuttal exchanges of high-quality academic papers and supports both text-only and visual evaluation through complementary paper representations.
36
+
37
+ ## Data Structure
38
+
39
+ RPC-Bench is organized into `train`, `dev`, and `test` subsets. Split assignments are recorded in `manifest.jsonl`, and the original split JSON files are provided in `split_metadata/` (`train.json`, `dev.json`, `test.json`).
40
+
41
+ `md/` contains Markdown files parsed from each paper by MinerU. These files provide the text input for LLM-oriented evaluation.
42
+
43
+ `parse/` contains the full MinerU parsing outputs for each paper, including structured layout and content artifacts.
44
+
45
+ `pdf/` contains the original paper PDFs.
46
+
47
+ `vlm/` contains page images rendered from the PDFs with PyMuPDF at 200 DPI for VLM-oriented evaluation.
48
+
49
+ ```text
50
+ RPC-Bench/
51
+ ├── README.md
52
+ ├── manifest.jsonl
53
+ ├── split_metadata/
54
+ │ ├── train.json
55
+ │ ├── dev.json
56
+ │ └── test.json
57
+ ├── parse/
58
+ │ ├── train/
59
+ │ │ └── <paper_id>/
60
+ │ ├── dev/
61
+ │ │ └── <paper_id>/
62
+ │ └── test/
63
+ │ └── <paper_id>/
64
+ ├── md/
65
+ │ ├── train/
66
+ │ │ └── <paper_id>/
67
+ │ │ └── <paper_id>.md
68
+ │ ├── dev/
69
+ │ │ └── <paper_id>/
70
+ │ │ └── <paper_id>.md
71
+ │ └── test/
72
+ │ └── <paper_id>/
73
+ │ └── <paper_id>.md
74
+ ├── pdf/
75
+ │ ├── train/
76
+ │ │ └── <paper_id>.pdf
77
+ │ ├── dev/
78
+ │ │ └── <paper_id>.pdf
79
+ │ └── test/
80
+ │ └── <paper_id>.pdf
81
+ └── vlm/
82
+ ├── train/
83
+ │ └── <paper_id>/
84
+ ├── dev/
85
+ │ └── <paper_id>/
86
+ └── test/
87
+ └── <paper_id>/
88
+ ```
89
+
90
+ ## Practical Uses
91
+
92
+ RPC-Bench can be used to try paper-centric systems that require broader document understanding rather than local snippet matching.
93
+
94
+ - Research paper comprehension: try models on full-paper understanding, including core concepts, methods, and experimental findings.
95
+ - Long-context evaluation: try whether longer context windows or long-context architectures improve document-level reasoning.
96
+ - Multimodal reasoning: try models that combine textual evidence with page-level figures, tables, and diagrams in the original PDF layout.
97
+ - RAG system diagnosis: try retrieval, chunking, and evidence-fusion strategies for paper-centric workflows beyond snippet-level retrieval accuracy.
98
+
99
+ ## Citation
100
+
101
+ ```bibtex
102
+ @article{chen2026rpc,
103
+ title={RPC-Bench: A Fine-grained Benchmark for Research Paper Comprehension},
104
+ author={Chen, Yelin and Zhang, Fanjin and Sun, Suping and Pang, Yunhe and Wang, Yuanchun and Song, Jian and Li, Xiaoyan and Hou, Lei and Zhao, Shu and Tang, Jie and others},
105
+ journal={arXiv preprint arXiv:2601.14289},
106
+ year={2026}
107
+ }
108
+ ```
manifest.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/0EXmFzUn5I/0EXmFzUn5I.md ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PYRAFORMER: LOW-COMPLEXITY PYRAMIDAL AT-TENTION FOR LONG-RANGE TIME SERIES MODELINGAND FORECASTING
2
+
3
+ Shizhan $ { \mathbf { L i u ^ { 1 , 2 * } } }$ , Hang $\mathbf { Y u } ^ { 1 }$ ∗, Cong Liao1, Jianguo $\mathbf { L i } ^ { 1 }$ †, Weiyao Lin2, Alex X. Liu1, and Schahram Dustdar3
4
+
5
+ 1Ant Group, 2Shanghai Jiaotong University, 3 TU Wien, Austria
6
+
7
+ # ABSTRACT
8
+
9
+ Accurate prediction of the future given the past based on time series data is of paramount importance, since it opens the door for decision making and risk management ahead of time. In practice, the challenge is to build a flexible but parsimonious model that can capture a wide range of temporal dependencies. In this paper, we propose Pyraformer by exploring the multi-resolution representation of the time series. Specifically, we introduce the pyramidal attention module (PAM) in which the inter-scale tree structure summarizes features at different resolutions and the intra-scale neighboring connections model the temporal dependencies of different ranges. Under mild conditions, the maximum length of the signal traversing path in Pyraformer is a constant (i.e., $\mathcal { O } ( 1 ) \mathrm { { _ { \it } } }$ ) with regard to the sequence length $L$ , while its time and space complexity scale linearly with $L$ . Extensive experimental results show that Pyraformer typically achieves the highest prediction accuracy in both single-step and long-range multi-step forecasting tasks with the least amount of time and memory consumption, especially when the sequence is $\mathrm { l o n g ^ { 1 } }$ .
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Time series forecasting is the cornerstone for downstream tasks such as decision making and risk management. As an example, reliable prediction of the online traffic for micro-services can yield early warnings of the potential risk in cloud systems. Furthermore, it also provides guidance for dynamic resource allocation, in order to minimize the cost without degrading the performance. In addition to online traffic, time series forecasting has also found vast applications in other fields, including disease propagation, energy management, and economics and finance.
14
+
15
+ The major challenge of time series forecasting lies in constructing a powerful but parsimonious model that can compactly capture temporal dependencies of different ranges. Time series often exhibit both short-term and long-term repeating patterns (Lai et al., 2018), and taking them into account is the key to accurate prediction. Of particular note is the more difficult task of handling long-range dependencies, which is characterized by the length of the longest signal traversing path (see Proposition 2 for the definition) between any two positions in the time series (Vaswani et al., 2017). The shorter the path, the better the dependencies are captured. Additionally, to allow the models to learn these long-term patterns, the historical input to the models should also be long. To this end, low time and space complexity is a priority.
16
+
17
+ Unfortunately, the present state-of-the-art methods fail to accomplish these two objectives simultaneously. On one end, RNN (Salinas et al., 2020) and CNN (Munir et al., 2018) achieve a low time complexity that is linear in terms of the time series length $L$ , yet their maximum length of the signal traversing path is $\mathcal { O } ( L )$ , thus rendering them difficult to learn dependencies between distant positions. On the other extreme, Transformer dramatically shortens the maximum path to be $\mathcal { O } ( 1 )$
18
+
19
+ ![](images/cdf77eb19d8c5bb6faae2ef9f8506ac4c8d47ead1a5b2a18785a17c7a43fae51.jpg)
20
+ Figure 1: Graphs of commonly used neural network models for sequence data.
21
+
22
+ Table 1: Comparison of the complexity and the maximum signal traveling path for different models, where $G$ is the number of global tokens in ETC. In practice, the $G$ increases with $L$ , and so the complexity of ETC is super-linear.
23
+
24
+ <table><tr><td>Method</td><td>Complexityper layer</td><td>Maximum path length</td></tr><tr><td>CNN (Munir et al., 2018)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>RNN (Salinas et al.,2020)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>Full-Attention (Vaswani et al.,2017)</td><td>O(L2)</td><td>0(1)</td></tr><tr><td>ETC (Ainslie et al., 2020)</td><td>O(GL)</td><td>0(1)</td></tr><tr><td>Longformer (Beltagy et al., 2020)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>LogTrans (Li et al., 2019)</td><td>O(L log L)</td><td>O(log L)</td></tr><tr><td>Pyraformer</td><td>O(L)</td><td>0(1)</td></tr></table>
25
+
26
+ at the sacrifice of increasing the time complexity to $\mathcal { O } ( L ^ { 2 } )$ . As a consequence, it cannot tackle very long sequences. To find a compromise between the model capacity and complexity, variants of Transformer are proposed, such as Longformer (Beltagy et al., 2020), Reformer (Kitaev et al., 2019), and Informer (Zhou et al., 2021). However, few of them can achieve a maximum path length less than $\mathcal { O } ( L )$ while greatly reducing the time and space complexity.
27
+
28
+ In this paper, we propose a novel pyramidal attention based Transformer (Pyraformer) to bridge the gap between capturing the long-range dependencies and achieving a low time and space complexity. Specifically, we develop the pyramidal attention mechanism by passing messages based on attention in the pyramidal graph as shown in Figure 1(d). The edges in this graph can be divided into two groups: the inter-scale and the intra-scale connections. The inter-scale connections build a multiresolution representation of the original sequence: nodes at the finest scale correspond to the time points in the original time series (e.g., hourly observations), while nodes in the coarser scales represent features with lower resolutions (e.g., daily, weekly, and monthly patterns). Such latent coarser-scale nodes are initially introduced via a coarser-scale construction module. On the other hand, the intra-scale edges capture the temporal dependencies at each resolution by connecting neighboring nodes together. As a result, this model provides a compact representation for long-range temporal dependencies among far-apart positions by capturing such behavior at coarser resolutions, leading to a smaller length of the signal traversing path. Moreover, modeling temporal dependencies of different ranges at different scales with sparse neighboring intra-scale connections significantly reduces the computational cost. In short, our key contributions comprise:
29
+
30
+ • We propose Pyraformer to simultaneously capture temporal dependencies of different ranges in a compact multi-resolution fashion. To distinguish Pyraformer from the stateof-the-art methods, we summarize all models from the perspective of graphs in Figure 1. • Theoretically, we prove that by choosing parameters appropriately, the maximum path length of $\mathcal { O } ( 1 )$ and the time and space complexity of $\mathcal O ( L )$ can be reached concurrently. To highlight the appeal of the proposed model, we further compare different models in terms of the maximum path and the complexity in Table 1.
31
+
32
+ • Experimentally, we show that the proposed Pyraformer yields more accurate predictions than the original Transformer and its variants on various real-world datasets under the scenario of both single-step and long-range multi-step forecasting, but with lower time and memory cost.
33
+
34
+ # 2 RELATED WORKS
35
+
36
+ # 2.1 TIME SERIES FORECASTING
37
+
38
+ Time series forecasting methods can be roughly divided into statistical methods and neural network based methods. The first group involves ARIMA (Box & Jenkins, 1968) and Prophet (Taylor & Letham, 2018). However, both of them need to fit each time series separately, and their performance pales when it comes to long-range forecasting.
39
+
40
+ More recently, the development of deep learning has spawned a tremendous increase in neural network based time series forecasting methods, including CNN (Munir et al., 2018), RNN (Salinas et al., 2020) and Transformer (Li et al., 2019). As mentioned in the previous section, CNN and RNN enjoy a low time and space complexity (i.e., $\mathcal { O } ( L ) )$ ), but entail a path of $\mathcal O ( L )$ to describe long-range dependence. We refer the readers to Appendix A for a more detailed review on related RNN-based models. By contrast, Transformer (Vaswani et al., 2017) can effectively capture the long-range dependence with a path of $\mathcal { O } ( 1 )$ steps, whereas the complexity increases vastly from $\mathcal O ( L )$ to $\check { \mathcal { O } } ( L ^ { 2 } )$ . To alleviate this computational burden, LogTrans (Li et al., 2019) and Informer (Zhou et al., 2021) are proposed: the former constrains that each point in the sequence can only attend to the point that is $2 ^ { n }$ steps before it, where $n = 1 , 2 , \cdots$ , and the latter utilizes the sparsity of the attention score, resulting in substantial decrease in the complexity (i.e., $\mathcal { O } ( L \log L )$ at the expense of introducing a longer maximum path length.
41
+
42
+ # 2.2 SPARSE TRANSFORMERS
43
+
44
+ In addition to the literature on time series forecasting, a plethora of methods have been proposed for enhancing the efficiency of Transformer in the field of natural language processing (NLP). Similar to CNN, Longformer (Beltagy et al., 2020) computes attention within a local sliding window or a dilated sliding window. Although the complexity is reduced to $\mathcal { O } ( A L )$ , where $A$ is the local window size, the limited window size makes it difficult to exchange information globally. The consequent maximum path length is $\mathcal { O } ( L / A )$ . As an alternative, Reformer (Kitaev et al., 2019) exploits locality sensitive hashing (LSH) to divide the sequence into several buckets, and then performs attention within each bucket. It also employs reversible Transformer to further reduce memory consumption, and so an extremely long sequence can be processed. Its maximum path length is proportional to the number of buckets though, and worse still, a large bucket number is required to reduce the complexity. On the other hand, ETC (Ainslie et al., 2020) introduces an extra set of global tokens for the sake of global information exchange, leading to an $\mathcal { O } ( G L )$ time and space complexity and an $\mathcal { O } ( 1 )$ maximum path length, where $G$ is the number of global tokens. However, $G$ typically increases with $L$ , and the consequent complexity is still super-linear. Akin to ETC, the proposed Pyraformer also introduces global tokens, but in a multiscale manner, successfully reducing the complexity to $\mathcal { O } ( L )$ without increasing the order of the maximum path length as in the original Transformer.
45
+
46
+ # 2.3 HIERARCHICAL TRANSFORMERS
47
+
48
+ Finally, we provide a brief review on methods that improve Transformer’s ability to capture the hierarchical structure of natural language, although they have never been used for time series forecasting. HIBERT (Miculicich et al., 2018) first uses a Sent Encoder to extract the features of a sentence, and then forms the EOS tokens of sentences in the document as a new sequence and input it into the Doc Encoder. However, it is specialized for natural language and cannot be generalized to other sequence data. Multi-scale Transformer (Subramanian et al., 2020) learns the multi-scale representations of sequence data using both the top-down and bottom-up network structures. Such multi-scale representations help reduce the time and memory cost of the original Transformer, but it still suffers from the pitfall of the quadratic complexity. Alternatively, BP-Transformer (Ye et al., 2019) recursively partitions the entire input sequence into two until a partition only contains a single token. The partitioned sequences then form a binary tree. In the attention layer, each upper-scale node can attend to its own children, while the nodes at the bottom scale can attend to the adjacent $A$ nodes at the same scale and all coarser-scale nodes. Note that BP-Transformer initializes the nodes at coarser scale with zeros, whereas Pyraformer introduces the coarser-scale nodes using a construction module in a more flexible manner. Moreover, BP-Transformer is associated with a denser graph than Pyraformer, thus giving rise to a higher complexity of $\mathcal { O } ( L \log L )$ .
49
+
50
+ ![](images/56cd8894c208a5e364b1dc0bb7b398b69c875aae166d907b12cd98ff3ac99fe5.jpg)
51
+ Figure 2: The architecture of Pyraformer: The CSCM summarizes the embedded sequence at different scales and builds a multi-resolution tree structure. Then the PAM is used to exchange information between nodes efficiently.
52
+
53
+ # 3 METHOD
54
+
55
+ The time series forecasting problem can be formulated as predicting the future $M$ steps $z _ { t + 1 : t + M }$ given the previous $L$ steps of observations $z _ { t - L + 1 : t }$ and the associated covariates $\pmb { x } _ { t - L + 1 : t + M }$ (e.g., hour-of-the-day). To move forward to this goal, we propose Pyraformer in this paper, whose overall architecture is summarized in Figure 2. As shown in the figure, we first embed the observed data, the covariates, and the positions separately and then add them together, in the same vein with Informer (Zhou et al., 2021). Next, we construct a multi-resolution $C$ -ary tree using the coarserscale construction module (CSCM), where nodes at a coarser scale summarize the information of $C$ nodes at the corresponding finer scale. To further capture the temporal dependencies of different ranges, we introduce the pyramidal attention module (PAM) by passing messages using the attention mechanism in the pyramidal graph. Finally, depending on the downstream task, we employ different network structures to output the final predictions. In the sequel, we elaborate on each part of the proposed model. For ease of exposition, all notations in this paper are summarized in Table 4.
56
+
57
+ # 3.1 PYRAMIDAL ATTENTION MODULE (PAM)
58
+
59
+ We begin with the introduction of the PAM, since it lies at the heart of Pyraformer. As demonstrated in Figure 1(d), we leverage a pyramidal graph to describe the temporal dependencies of the observed time series in a multiresolution fashion. Such a multiresolution structure has proved itself an effective and efficient tool for long-range interaction modeling in the field of computer vision (Sun et al., 2019; Wang et al., 2021) and statistical signal processing (Choi et al., 2008; Yu et al., 2019). We can decompose the pyramidal graph into two parts: the inter-scale and the intra-scale connections. The inter-scale connections form a $C$ -ary tree, in which each parent has $C$ children. For example, if we associate the finest scale of the pyramidal graph with hourly observations of the original time series, the nodes at coarser scales can be regarded as the daily, weekly, and even monthly features of the time series. As a consequence, the pyramidal graph offers a multi-resolution representation of the original time series. Furthermore, it is easier to capture long-range dependencies (e.g., monthly dependence) in the coarser scales by simply connecting the neighboring nodes via the intra-scale connections. In other words, the coarser scales are instrumental in describing long-range correlations in a manner that is graphically far more parsimonious than could be solely captured with a single, finest scale model. Indeed, the original single-scale Transformer (see Figure 1(a)) adopts a full graph that connects every two nodes at the finest scale so as to model the long-range dependencies, leading to a computationally burdensome model with $\mathcal { O } ( L ^ { 2 } )$ time and space complexity (Vaswani et al., 2017). In stark contrast, as illustrated below, the pyramidal graph in the proposed Pyraformer reduces the computational cost to $\mathcal O ( L )$ without increasing the order of the maximum length of the signal traversing path.
60
+
61
+ Before delving into the PAM, we first introduce the original attention mechanism. Let $\boldsymbol { X }$ and $\mathbf { Y }$ denote the input and output of a single attention head respectively. Note that multiple heads can be introduced to describe the temporal pattern from different perspectives. $\boldsymbol { X }$ is first linearly transformed into three distinct matrices, namely, the query $Q = X W _ { Q }$ , the key $\pmb { K } = \pmb { X } \pmb { W } _ { K }$ , and the value $\pmb { V } = \pmb { X } \pmb { W } _ { V }$ , where $W _ { Q }$ , $W _ { K }$ , $W _ { V } \in \mathbb { R } ^ { L \times D _ { K } }$ . For the $i$ -th row $\pmb q _ { i }$ in $Q$ , it can attend to any rows (i.e., keys) in $\kappa$ . In other words, the corresponding output $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \psi _ { i }$ can be expressed as:
62
+
63
+ $$
64
+ { \pmb y } _ { i } = \sum _ { \ell = 1 } ^ { L } \frac { \mathrm { e x p } ( { \pmb q } _ { i } { \pmb k } _ { \ell } ^ { T } / \sqrt { D _ { K } } ) { \pmb v } _ { \ell } } { \sum _ { \ell = 1 } ^ { L } \mathrm { e x p } ( { \pmb q } _ { i } { \pmb k } _ { \ell } ^ { T } / \sqrt { D _ { K } } ) } ,
65
+ $$
66
+
67
+ where $k _ { \ell } ^ { T }$ denotes the transpose of row $\ell$ in $\kappa$ . We emphasize that the number of query-key dot products (Q-K pairs) that need to be calculated and stored dictates the time and space complexity of the attention mechanism. Viewed another way, this number is proportional to the number of edges in the graph (see Figure 1(a)). Since all Q-K pairs are computed and stored in the full attention mechanism (1), the resulting time and space complexity is $\mathcal { O } ( L ^ { 2 } )$ .
68
+
69
+ As opposed to the above full attention mechanism, every node only pays attention to a limited set of keys in the PAM, corresponding to the pyramidal graph in Figure 1d. Concretely, suppose that $n _ { \ell } ^ { ( s ) }$ denotes the $\ell \cdot$ -th node at scale $s$ , where $s = 1 , \cdots , S$ represents the bottom scale to the top scale sequentially. In general, each node in the graph can attend to a set of neighboring nodes $\mathbb { N } _ { \ell } ^ { ( s ) }$ at three scales: the adjacent $A$ nodes at the same scale including the node itself (denoted as $\mathbb { A } _ { \ell } ^ { ( s ) }$ ), the $C$ children it has in the $C$ -ary tree (denoted as $\mathbb { C } _ { \ell } ^ { ( s ) } .$ ), and the parent of it in the $C$ -ary tree (denoted $\mathbb { P } _ { \ell } ^ { ( s ) } )$ , that is,
70
+
71
+ $$
72
+ \left\{ \begin{array} { l l l l l l l l l l l l l } { \mathbb { N } _ { \ell } ^ { ( s ) } } & { = } & { \mathbb { A } _ { \ell } ^ { ( s ) } \cup \mathbb { C } _ { \ell } ^ { ( s ) } \cup \mathbb { P } _ { l } ^ { ( s ) } } & & & & & \\ { \mathbb { A } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s ) } : | j - \ell | \leq \frac { A - 1 } { 2 } , 1 \leq j \leq \frac { L } { C ^ { s - 1 } } \} } & & & & & \\ { \mathbb { C } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s - 1 ) } : ( \ell - 1 ) C < j \leq \ell C \} } & { \mathrm { i f } s \geq 2 \mathrm { e l s e } \emptyset } & & & \\ { \mathbb { P } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s + 1 ) } : j = \lceil \frac { \ell } { C } \rceil \} } & { \mathrm { i f } s \leq S - 1 \mathrm { e l s e } \emptyset } & & & & \end{array} \right. .
73
+ $$
74
+
75
+ It follows that the attention at node $n _ { \ell } ^ { ( s ) }$ can be simplified as:√
76
+
77
+ $$
78
+ \pmb { y } _ { i } = \sum _ { \ell \in \mathbb { N } _ { \ell } ^ { ( s ) } } \frac { \exp ( \pmb { q } _ { i } \pmb { k } _ { \ell } ^ { T } / \sqrt { d _ { K } } ) \pmb { v } _ { \ell } } { \sum _ { \ell \in \mathbb { N } _ { l } ^ { ( s ) } } \exp ( \pmb { q } _ { i } \pmb { k } _ { \ell } ^ { T } / \sqrt { d _ { K } } ) } ,
79
+ $$
80
+
81
+ We further denote the number of attention layers as $N$ . Without loss of generality, we assume that $L$ is divisible by $C ^ { S - 1 }$ . We can then have the following lemma (cf. Appendix $\mathbf { B }$ for the proof and Table 4 for the meanings of the notations).
82
+
83
+ Lemma 1. Given $A , C , L , N$ , and $S$ that satisfy Equation (4), after $N$ stacked attention layers, nodes at the coarsest scale can obtain a global receptive field.
84
+
85
+ $$
86
+ \frac { L } { C ^ { S - 1 } } - 1 \leq \frac { ( A - 1 ) N } { 2 } .
87
+ $$
88
+
89
+ In addition, when the number of scales $S$ is fixed, the following two propositions summarize the time and space complexity and the order of the maximum path length for the proposed pyramidal attention mechanism. We refer the readers to Appendix C and $\mathrm { D }$ for proof.
90
+
91
+ Proposition 1. The time and space complexity for the pyramidal attention mechanism is $\mathcal { O } ( A L )$ for given $A$ and $L$ and amounts to $\mathcal O ( L )$ when $A$ is a constant w.r.t. $L$ .
92
+
93
+ Proposition 2. Let the signal traversing path between two nodes in a graph denote the shortest path connecting them. Then the maximum length of signal traversing path between two arbitrary nodes in the pyramidal graph is $\mathcal { O } ( S + L / C ^ { S - 1 } / A )$ for given $A$ , $C$ , $L$ , and $S$ . Suppose that $A$ and $S$ are fixed and $C$ satisfies Equation (5), the maximum path length is $\mathcal { O } ( 1 )$ for time series with length $L$ .
94
+
95
+ $$
96
+ \sqrt [ s - 1 ] { L } \geq C \geq \sqrt [ s - 1 ] { \frac { L } { ( A - 1 ) N / 2 + 1 } } .
97
+ $$
98
+
99
+ ![](images/91aa8cb400219056af9686acde2534aae765cbb65f9bf4e842354362211e49b1.jpg)
100
+ Figure 3: Coarser-scale construction module: $B$ is the batch size and $D$ is the dimension of a node.
101
+
102
+ In our experiments, we fix $S$ and $N$ , and $A$ can only take 3 or 5, regardless of the sequence length $L$ . Therefore, the proposed PAM achieves the complexity of $\mathcal { O } ( L )$ with the maximum path length of $\mathcal { O } ( 1 )$ . Note that in the PAM, a node can attend to at most $A + C + 1$ nodes. Unfortunately, such a sparse attention mechanism is not supported in the existing deep learning libraries, such as Pytorch and TensorFlow. A naive implementation of the PAM that can fully exploit the tensor operation framework is to first compute the product between all Q-K pairs, i.e., $\mathbf { \Delta } q _ { i } \mathbf { \Delta } k _ { \ell } ^ { T }$ for $\ell =$ $1 , \cdots , L$ , and then mask out $\ell \notin \mathbb { N } _ { \ell } ^ { ( s ) }$ . However, the resulting time and space complexity of this implementation is still $\mathcal { O } ( L ^ { 2 } )$ . Instead, we build a customized CUDA kernel specialized for the PAM using TVM (Chen et al., 2018), practically reducing the computational time and memory cost and making the proposed model amenable to long time series. Longer historical input is typically helpful for improving the prediction accuracy, as more information is provided, especially when long-range dependencies are considered.
103
+
104
+ # 3.2 COARSER-SCALE CONSTRUCTION MODULE (CSCM)
105
+
106
+ CSCM targets at initializing the nodes at the coarser scales of the pyramidal graph, so as to facilitate the subsequent PAM to exchange information between these nodes. Specifically, the coarse-scale nodes are introduced scale by scale from bottom to top by performing convolutions on the corresponding children nodes $\mathbb { C } _ { \ell } ^ { ( s ) }$ . As demonstrated in Figure 3, several convolution layers with kernel size $C$ and stride $C$ are sequentially applied to the embedded sequence in the dimension of time, yielding a sequence with length $L / C ^ { s }$ at scale $s$ . The resulting sequences at different scales form a $C$ -ary tree. We concatenate these fine-to-coarse sequences before inputting them to the PAM. In order to reduce the amount of parameters and calculations, we reduce the dimension of each node by a fully connected layer before inputting the sequence into the stacked convolution layers and restore it after all convolutions. Such a bottleneck structure significantly reduces the number of parameters in the module and can guard against over-fitting.
107
+
108
+ # 3.3 PREDICTION MODULE
109
+
110
+ For single-step forecasting, we add an end token (by setting $z _ { t + 1 } = 0$ ) to the end of the historical sequence $z _ { t - L + 1 : t }$ before inputting it into the embedding layer. After the sequence is encoded by the PAM, we gather the features given by the last nodes at all scales in the pyramidal graph, concatenate and then input them into a fully connected layer for prediction.
111
+
112
+ For multi-step forecasting, we propose two prediction modules. The first one is the same with the single-step forecasting module, but maps the last nodes at all scales to all $M$ future time steps in a batch. The second one, on the other hand, resorts to a decoder with two full attention layers. Specifically, similar to the original Transformer (Vaswani et al., 2017), we replace the observations at the future $M$ time steps with 0, embed them in the same manner with the historical observations, and refer to the summation of the observation, covariate, and positional embedding as the “prediction token” $F _ { p }$ . The first attention layer then takes the prediction tokens $F _ { p }$ as the query and the output of the encoder $\pmb { F _ { e } }$ (i.e., all nodes in the PAM) as the key and the value, and yields ${ \bf { { F } } } _ { d 1 }$ . The second layer takes ${ \mathbf { } } F _ { d 1 }$ as the query, but takes the concatenated ${ \bf { { F } } } _ { d 1 }$ and $\pmb { F _ { e } }$ as the key and the value. The historical information $\pmb { F _ { e } }$ is fed directly into both attention layers, since such information is vital for accurate long-range forecasting. The final prediction is then obtained through a fully connected layer across the dimension of channels. Again, we output all future predictions together to avoid the problem of error accumulation in the autoregressive decoder of Transformer.
113
+
114
+ Table 2: Single-step forecasting results on three datasets. “Q-K pairs” refer to the number of querykey dot products performed by all attention layers in the network, which encodes the time and space complexity. We write the number of attention layers by $N$ , the number of attention heads by $H$ , the number of scales by $S$ , the dimension of a node by $D$ , the dimension of a key by $D _ { K }$ , the maximum dimension of feed-forward layer by $D _ { F }$ , and the convolution stride by $C$ .
115
+
116
+ <table><tr><td>Methods</td><td>Parameters</td><td>Datasets</td><td>NRMSE</td><td>ND</td><td>Q-K pairs</td></tr><tr><td rowspan="3">Full-attention</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.328</td><td>0.041</td><td>456976</td></tr><tr><td>Wind</td><td>0.175</td><td>0.082</td><td>589824</td></tr><tr><td>App Flow</td><td>0.407</td><td>0.080</td><td>589824</td></tr><tr><td rowspan="3">LogTrans</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.333</td><td>0.041</td><td>50138</td></tr><tr><td>Wind</td><td>0.173</td><td>0.081</td><td>58272</td></tr><tr><td>App Flow</td><td>0.387</td><td>0.073</td><td>58272</td></tr><tr><td rowspan="3">Reformer</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.359</td><td>0.047</td><td>677376</td></tr><tr><td>Wind</td><td>0.183</td><td>0.086</td><td>884736</td></tr><tr><td>AppFlow</td><td>0.463</td><td>0.095</td><td>884736</td></tr><tr><td rowspan="3">ETC</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.324</td><td>0.041</td><td>79536</td></tr><tr><td>Wind</td><td>0.167</td><td>0.074</td><td>102144</td></tr><tr><td>App Flow</td><td>0.397</td><td>0.069</td><td>102144</td></tr><tr><td rowspan="3">Longformer</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.330</td><td>0.041</td><td>41360</td></tr><tr><td>Wind</td><td>0.166</td><td>0.075</td><td>52608</td></tr><tr><td>AppFlow</td><td>0.377</td><td>0.07</td><td>52608</td></tr><tr><td rowspan="3">Pyraformer</td><td rowspan="3">O(N(HDDK+DDF) +(S-1)CD²)</td><td>Electricity</td><td>0.324</td><td>0.041</td><td>17648</td></tr><tr><td>Wind</td><td>0.161</td><td>0.072</td><td>20176</td></tr><tr><td>App Flow</td><td>0.366</td><td>0.067</td><td>20176</td></tr></table>
117
+
118
+ # 4 EXPERIMENTS
119
+
120
+ # 4.1 DATASETS AND EXPERIMENT SETUP
121
+
122
+ We demonstrated the advantages of the proposed Pyraformer on the four real-world datasets, including Wind, App Flow, Electricity, and ETT. The first three datasets were used for single-step forecasting, while the last two for long-range multi-step forecasting. We refer the readers to Appendix E and F for more details regarding the data description and the experiment setup.
123
+
124
+ # 4.2 RESULTS AND ANALYSIS
125
+
126
+ # 4.2.1 SINGLE-STEP FORECASTING
127
+
128
+ We conducted single-step prediction experiments on three datasets: Electricity, Wind and App Flow. The historical length is 169, 192 and 192, respectively, including the end token. We benchmarked Pyraformer against 5 other attention mechanisms, including the original full-attention (Vaswani et al., 2017), the log-sparse attention (i.e., LogTrans) (Li et al., 2019), the LSH attention (i.e., Reformer) (Kitaev et al., 2019), the sliding window attention with global nodes (i.e., ETC) (Ainslie et al., 2020), and the dilated sliding window attention (i.e., Longformer) (Beltagy et al., 2020). In particular for ETC, some nodes with equal intervals at the finest scale were selected as the global nodes. A global node can attend to all nodes across the sequence and all nodes can attend to it in turn(see Figure 1(e)). The training and testing schemes were the same for all models. We further investigated the usefulness of the pretraining strategy (see Appendix G), the weighted sampler, and the hard sample mining on all methods, and the best results were presented. We adopted the NRMSE (Normalized RMSE) and the ND (Normalized Deviation) as the evaluation indicators (see Appendix H for the definitions). The results are summarized in Table 2. For a fair comparison, except for full-attention, the overall dot product number of all attention mechanisms was controlled to the same order of magnitude.
129
+
130
+ Our experimental results show that Pyraformer outperforms Transformer and its variants in terms of NRMSE and ND, with the least number of query-key dot products (a.k.a. Q-K pairs). Concretely, there are three major trends that can be gleaned from Table 2: (1) The proposed Pyraformer yields the most accurate prediction results, suggesting that the pyramidal graph can better explain the temporal interactions in the time series by considering dependencies of different ranges. Interestingly, for the Wind dataset, sparse attention mechanisms, namely, LogTrans, ETC, Longformer and Pyraformer, outperform the original full attention Transformer, probably because the data contains a large number of zeros and the promotion of adequate sparsity can help avoid over-fitting. (2) The number of Q-K pairs in Pyraformer is the smallest. Recall that this number characterizes the time and space complexity. Remarkably enough, it is $6 5 . 4 \%$ fewer than that of LogTrans and $9 6 . 6 \%$ than that of the full attention. It is worth emphasizing that this computational gain will continue to increase for longer time series. (3) The number of parameters for Pyraformer is slightly larger than that of the other models, resulting from the CSCM. However, this module is very lightweight, which incurs merely $5 \%$ overhead in terms of model size compared to other models. Moreover, in practice, we can fix the hyper-parameters $A$ , $S$ and $N$ , and ensure that $C$ satisfies $C > \sqrt [ s - 1 ] { L / ( ( A - 1 ) N / 2 + 1 ) }$ . Consequently, the extra number of parameters introduced by the CSCM is only $\mathcal { O } ( ( S - 1 ) C D _ { K } ^ { 2 } ) \approx \mathcal { O } ( \sqrt [ s ] { L } )$ .
131
+
132
+ Table 3: Long-range multi-step forecasting results.
133
+
134
+ <table><tr><td rowspan="2">Methods</td><td rowspan="2">Metrics</td><td colspan="3">ETTh1</td><td colspan="3">ETTm1</td><td colspan="3">Electricity</td></tr><tr><td>168</td><td>336</td><td>720</td><td>96</td><td>288</td><td>672</td><td>168</td><td>336</td><td>720</td></tr><tr><td rowspan="3">Informer</td><td>MSE</td><td>1.075</td><td>1.329</td><td>1.384</td><td>0.556</td><td>0.841</td><td>0.921</td><td>0.745</td><td>1.579</td><td>4.365</td></tr><tr><td>MAE</td><td>0.801</td><td>0.911</td><td>0.950</td><td>0.537</td><td>0.705</td><td>0.753</td><td>0.266</td><td>0.323</td><td>0.371</td></tr><tr><td>Q-K pairs</td><td>188040</td><td>188040</td><td>423360</td><td>276480</td><td>560640</td><td>560640</td><td>188040</td><td>188040</td><td>423360</td></tr><tr><td rowspan="3">LogTrans</td><td>MSE</td><td>0.983</td><td>1.100</td><td>1.411</td><td>0.554</td><td>0.786</td><td>1.169</td><td>0.791</td><td>1.584</td><td>4.362</td></tr><tr><td>MAE</td><td>0.766</td><td>0.839</td><td>0.991</td><td>0.499</td><td>0.676</td><td>0.868</td><td>0.340</td><td>0.336</td><td>0.366</td></tr><tr><td>Q-K pairs</td><td>74664</td><td>74664</td><td>216744</td><td>254760</td><td>648768</td><td>648768</td><td>74664</td><td>74664</td><td>216744</td></tr><tr><td rowspan="3">Longformer</td><td>MSE</td><td>0.860</td><td>0.975</td><td>1.091</td><td>0.526</td><td>0.767</td><td>1.021</td><td>0.766</td><td>1.591</td><td>4.361</td></tr><tr><td>MAE</td><td>0.710</td><td>0.769</td><td>0.832</td><td>0.507</td><td>0.663</td><td>0.788</td><td>0.311</td><td>0.343</td><td>0.368</td></tr><tr><td>Q-K pairs</td><td>63648</td><td>63648</td><td>249120</td><td>329760</td><td>1007136</td><td>1007136</td><td>63648</td><td>63648</td><td>249120</td></tr><tr><td rowspan="3">Reformer</td><td>MSE</td><td>0.958</td><td>1.044</td><td>1.458</td><td>0.543</td><td>0.924</td><td>0.981</td><td>0.783</td><td>1.584</td><td>4.374</td></tr><tr><td>MAE</td><td>0.741</td><td>0.787</td><td>0.987</td><td>0.528</td><td>0.722</td><td>0.778</td><td>0.332</td><td>0.334</td><td>0.374</td></tr><tr><td>Q-K pairs</td><td>1016064</td><td>1016064</td><td>2709504</td><td>5308416</td><td>14450688</td><td>14450688</td><td>1016064</td><td>1016064</td><td>2709504</td></tr><tr><td rowspan="3">ETC</td><td>MSE</td><td>1.025</td><td>1.084</td><td>1.137</td><td>0.762</td><td>1.227</td><td>1.272</td><td>0.777</td><td>1.586</td><td>4.361</td></tr><tr><td>MAE</td><td>0.771</td><td>0.811</td><td>0.866</td><td>0.653</td><td>0.880</td><td>0.908</td><td>0.326</td><td>0.340</td><td>0.368</td></tr><tr><td>Q-K pairs</td><td>125280</td><td>125280</td><td>288720</td><td>331344</td><td>836952</td><td>836952</td><td>125280</td><td>125280</td><td>288720</td></tr><tr><td rowspan="3">Pyraformer</td><td>MSE</td><td>0.808</td><td>0.945</td><td>1.022</td><td>0.480</td><td>0.754</td><td>0.857</td><td>0.719</td><td>1.533</td><td>4.312</td></tr><tr><td>MAE</td><td>0.683</td><td>0.766</td><td>0.806</td><td>0.486</td><td>0.659</td><td>0.707</td><td>0.256</td><td>0.291</td><td>0.346</td></tr><tr><td>Q-K pairs</td><td>26472</td><td>26472</td><td>74280</td><td>57264</td><td>96384</td><td>96384</td><td>26472</td><td>26472</td><td>74280</td></tr></table>
135
+
136
+ # 4.2.2 LONG-RANGE MULTI-STEP FORECASTING
137
+
138
+ We evaluated the performance of Pyraformer for long-range forecasting on three datasets, that is, Electricity, ETTh1, and ETTm1. In particular for ETTh1 and ETTm1, we predicted the future oil temperature and the 6 power load features at the same time, which is a multivariate time series forecasting problem. Both prediction modules introduced in Section 3.3 were tested for all models and the better results are listed in Table 3.
139
+
140
+ It is evident that Pyraformer still achieves the best performance with the least number of Q-K pairs for all datasets regardless of the prediction length. More precisely, in comparison with Informer (Zhou et al., 2021), the MSE given by Pyraformer for ETTh1 is decreased by $2 4 . 8 \%$ , $2 8 . 9 \%$ , $2 6 . 2 \%$ respectively when the prediction length is 168, 336, and 720. Once again, this bolsters our belief that it is more beneficial to employ the pyramidal graph when describing the temporal dependencies. Interestingly, we notice that for Pyraformer, the results given by the first prediction module are better than those by the second one. One possible explanation is that the second prediction module based on the full attention layers cannot differentiate features with different resolutions, while the first module based on a single fully connected layer can take full advantages of such features in an automated fashion. To better elucidate the modeling capacity of Pyraformer for long-range forecasting, we refer the readers to Appendix I for a detailed example on synthetic data.
141
+
142
+ ![](images/c76b7f33141c4ef44a7a1594f69b85c5196a20fecbd341cd7e0a1ecd285eb186.jpg)
143
+ Figure 4: Comparison of the time and memory consumption between the full, the prob-sparse, and the TVM implementation of the pyramidal attention: (a) computation time; (b) memory occupation.
144
+
145
+ # 4.2.3 SPEED AND MEMORY CONSUMPTION
146
+
147
+ To check the efficiency of the customized CUDA kernel implemented based on TVM, we depicted the empirical computation time and memory cost as a function of the sequence length $L$ in Figure 4. Here we only compared Pyraformer with the full attention and the prob-sparse attention in Informer (Zhou et al., 2021). All the computations were performed on a $1 2 \mathrm { \ G B }$ Titan $\mathrm { X p }$ GPU with Ubuntu 16.04, CUDA 11.0, and TVM 0.8.0. Figure 4 shows that the time and memory cost of the proposed Pyraformer based on TVM is approximately a linear function of $L$ , as expected. Furthermore, the time and memory consumption of the TVM implementation can be several orders of magnitude smaller than that of the full attention and the prob-sparse attention, especially for relatively long time series. Indeed, for a 12GB Titan Xp GPU, when the sequence length reaches 5800, full attention encounters the out-of-memory (OOM) problem, yet the TVM implementation of Pyraformer only occupies 1GB of memory. When it comes to a sequence with 20000 time points, even Informer incurs the OOM problem, whereas the memory cost of Pyraformer is only 1.91GB and the computation time per batch is only 0.082s.
148
+
149
+ # 4.3 ABLATION STUDY
150
+
151
+ We also performed ablation studies to measure the impact of $A$ and $C$ , the CSCM architecture, the history length, and the PAM on the prediction accuracy of Pyraformer. The results are displayed in Tables 7-10. Detailed Discussions on the results can be found in Appendix J. Here, we only provide an overview of the major findings: (1) it is better to increase $C$ with $L$ but fix $A$ to a small constant for the sake of reducing the prediction error; (2) convolution with bottleneck strikes a balance between the prediction accuracy and the number of parameters, and hence, we use it as the CSCM; (3) more history helps increase the accuracy of forecasting; (4) the PAM is essential for accurate prediction.
152
+
153
+ # 5 CONCLUSION AND OUTLOOK
154
+
155
+ In this paper, we propose Pyraformer, a novel model based on pyramidal attention that can effectively describe both short and long temporal dependencies with low time and space complexity. Concretely, we first exploit the CSCM to construct a $C$ -ary tree, and then design the PAM to pass messages in both the inter-scale and the intra-scale fashion. By adjusting $C$ and fixing other parameters when the sequence length $L$ increases, Pyraformer can achieve the theoretical $\mathcal O ( L )$ complexity and $\mathcal { O } ( 1 )$ maximum signal traversing path length. Experimental results show that the proposed model outperforms the state-of-the-art models for both single-step and long-range multi-step prediction tasks, but with less computational time and memory cost. So far we only concentrate on the scenario where $A$ and $S$ are fixed and $C$ increases with $L$ when constructing the pyramidal graph. On the other hand, we have shown in Appendix I that other configurations of the hyper-parameters may further improve the performance of Pyraformer. In the future work, we would like to explore how to adaptively learn the hyper-parameters from the data. Also, it is interesting to extend Pyraformer to other fields, including natural language processing and computer vision.
156
+
157
+ # ACKNOWLEDGEMENT
158
+
159
+ In this work, Prof. Weiyao Lin was supported by Ant Group through Ant Research Program and in part by National Natural Science Foundation of China under grant U21B2013.
160
+
161
+ REFERENCES
162
+ Joshua Ainslie, Santiago Ontanon, Chris Alberti, Vaclav Cvicek, Zachary Fisher, Philip Pham, Anirudh Ravula, Sumit Sanghai, Qifan Wang, and Li Yang. Etc: Encoding long and structured inputs in transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 268–284, 2020.
163
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
164
+ George EP Box and Gwilym M Jenkins. Some recent advances in forecasting and control. Journal of the Royal Statistical Society. Series C (Applied Statistics), 17(2):91–109, 1968.
165
+ Shiyu Chang, Yang Zhang, Wei Han, Mo Yu, Xiaoxiao Guo, Wei Tan, Xiaodong Cui, Michael Witbrock, Mark Hasegawa-Johnson, and Thomas S Huang. Dilated recurrent neural networks. Advances in Neural Information Processing Systems, 2017:77–87, 2017.
166
+ Tianqi Chen, Thierry Moreau, Ziheng Jiang, Lianmin Zheng, Eddie Yan, Haichen Shen, Meghan Cowan, Leyuan Wang, Yuwei Hu, Luis Ceze, et al. $\{ \mathrm { T V M } \}$ : An automated end-to-end optimizing compiler for deep learning. In 13th {USENIX} Symposium on Operating Systems Design and Implementation $\bar { \langle } O S D I \rangle \bar { I } \delta )$ , pp. 578–594, 2018.
167
+ M. J. Choi, V. Chandrasekaran, D. M. Malioutov, J. K. Johnson, and A. S. Willsky. Multiscale stochastic modeling for tractable inference and data assimilation. Computer Methods in Applied Mechanics and Engineering, 197(43-44):3492–3515, 2008.
168
+ Junyoung Chung, Sungjin Ahn, and Yoshua Bengio. Hierarchical multiscale recurrent neural networks. In 5th International Conference on Learning Representations, ICLR 2017, 2019.
169
+ Marta R Costa-jussa and Jos \` e AR Fonollosa. Character-based neural machine translation. In ´ Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 357–361, 2016.
170
+ Jaeyoung Kim, Mostafa El-Khamy, and Jungwon Lee. Residual lstm: Design of a deep recurrent architecture for distant speech recognition. arXiv preprint arXiv:1701.03360, 2017.
171
+ Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In International Conference on Learning Representations, 2019.
172
+ Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long-and short-term temporal patterns with deep neural networks. In The 41st International ACM SIGIR Conference on Research & Development in Information Retrieval, pp. 95–104, 2018.
173
+ Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. Advances in Neural Information Processing Systems, 32:5243–5253, 2019.
174
+ Lesly Miculicich, Dhananjay Ram, Nikolaos Pappas, and James Henderson. Document level neural machine translation with hierarchical attention networks. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), number CONF, 2018.
175
+ Mohsin Munir, Shoaib Ahmed Siddiqui, Andreas Dengel, and Sheraz Ahmed. Deepant: A deep learning approach for unsupervised anomaly detection in time series. Ieee Access, 7:1991–2005, 2018.
176
+ David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. Deepar: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3):1181– 1191, 2020.
177
+
178
+ M. Schuster. Bi-directional recurrent neural networks for speech recognition. In Proceeding of IEEE Canadian Conference on Electrical and ComputerEngineering, pp. 7–12, 1996.
179
+
180
+ Sandeep Subramanian, Ronan Collobert, Marc’Aurelio Ranzato, and Y-Lan Boureau. Multi-scale transformer language models. arXiv preprint arXiv:2005.00581, 2020.
181
+
182
+ Ke Sun, Bin Xiao, Dong Liu, and Jingdong Wang. Deep high-resolution representation learning for human pose estimation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5693–5703, 2019.
183
+
184
+ Sean J Taylor and Benjamin Letham. Forecasting at scale. The American Statistician, 72(1):37–45, 2018.
185
+
186
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
187
+
188
+ W. Wang, E. Xie, X. Li, D. P. Fan, and L. Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. 2021.
189
+
190
+ Zihao Ye, Qipeng Guo, Quan Gan, Xipeng Qiu, and Zheng Zhang. Bp-transformer: Modelling long-range context via binary partitioning. arXiv preprint arXiv:1911.04070, 2019.
191
+
192
+ Hang Yu, Luyin Xin, and Justin Dauwels. Variational wishart approximation for graphical model selection: Monoscale and multiscale models. IEEE Transactions on Signal Processing, 67(24): 6468–6482, 2019. doi: 10.1109/TSP.2019.2953651.
193
+
194
+ Hsiang-Fu Yu, Nikhil Rao, and Inderjit S Dhillon. Temporal regularized matrix factorization for high-dimensional time series prediction. Advances in neural information processing systems, 29: 847–855, 2016.
195
+
196
+ Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of AAAI, 2021.
197
+
198
+ Simiao Zuo, Haoming Jiang, Zichong Li, Tuo Zhao, and Hongyuan Zha. Transformer hawkes process. In International Conference on Machine Learning, pp. 11692–11702. PMLR, 2020.
199
+
200
+ Table 4: Meanings of notations.
201
+
202
+ <table><tr><td>Notation</td><td>Size</td><td>Meaning</td></tr><tr><td>L</td><td>Constant</td><td>The length of historical sequence.</td></tr><tr><td>G</td><td>Constant</td><td>The number of global tokens in ETC.</td></tr><tr><td>M</td><td>Constant</td><td>The length of future sequence to be predicted.</td></tr><tr><td>B</td><td>Constant</td><td>Batch size.</td></tr><tr><td>D</td><td>Constant</td><td>The dimension of each node.</td></tr><tr><td>DK</td><td>Constant</td><td>The dimension of a key.</td></tr><tr><td>X</td><td>B×L×D</td><td>Input of a single attention head.</td></tr><tr><td>Y</td><td>B×L×D</td><td>Output of a single attention head.</td></tr><tr><td>Q</td><td>B×L×Dk</td><td>The query.</td></tr><tr><td>K</td><td>B×L×Dk</td><td>The key.</td></tr><tr><td>V</td><td>B×L×Dk</td><td>The value.</td></tr><tr><td>WQ</td><td>D×Dk</td><td>The weight matrix of the query.</td></tr><tr><td>WK</td><td>D ×Dk</td><td>The weight matrix of the key.</td></tr><tr><td>Wv</td><td>D×Dk</td><td>The weight matrix of the value.</td></tr><tr><td>S</td><td>Constant</td><td>Number of scales.</td></tr><tr><td>A</td><td>Constant</td><td>Number of adjacent nodes at the same scale that a node can attend to.</td></tr><tr><td>C</td><td>Constant</td><td>Number of finer scale nodes that a coarser scale node can summarize.</td></tr><tr><td>N</td><td>Constant</td><td>Number of attention layers.</td></tr><tr><td>n(</td><td>D</td><td>The l-th node at scale s.</td></tr><tr><td>N</td><td>len(N)) × D</td><td></td></tr><tr><td>A</td><td>len(A()) × D</td><td> The adjacent A nodes at the same scale with n(s).</td></tr><tr><td>C</td><td>len(C()) × D</td><td></td></tr><tr><td>P</td><td>len(P(s) × D</td><td> The parent node of n(s).</td></tr><tr><td>Fp</td><td>B×M×D</td><td>The prediction tokens.</td></tr><tr><td>Fe</td><td>B ×Ltot ×D</td><td> The output of the encoder. Ltot represents the output length of the encod</td></tr><tr><td>Fd1</td><td>B×M×D</td><td>The output of the first attention-based decoder layer.</td></tr><tr><td>H</td><td>Constant</td><td>The number of attention heads.</td></tr><tr><td>DF</td><td></td><td></td></tr><tr><td></td><td>Constant</td><td>The maximum dimension of the feed-forward layer.</td></tr></table>
203
+
204
+ # A A BRIEF REVIEW ON RELATED RNN-BASED MODELS
205
+
206
+ In this section, we provide a brief review on the related RNN-based models. Multiscale temporal dependencies are successfully captured in HRNN (Costa-jussa & Fonollosa, 2016) and HM- \` RNN (Chung et al., 2019). The former requires expert knowledge to partition the sequence into different resolutions, while the latter learns the partition automatically from the data. Note that the theoretical maximum length of the signal traversing path in both models is still $\mathcal O ( L )$ . Another line of works aim to shorten the signal traversing path by adding residual connections (Kim et al., 2017) or dilated connections to LSTMs (Chang et al., 2017). However, they do not consider the multiresolution temporal dependencies explicitly. Furthermore, all aforementioned RNNs only propagate information in one direction from the past to the future. An appealing approach that allows bidirectional information exchange is Bi-LSTM (Schuster, 1996). The forward and backward propagation is realized through two different LSTMs though, and so still incurs a long signal traversing path.
207
+
208
+ As opposed to the abovementioned RNN-based models, the proposed Pyraformer enables bidirectional information exchange that can better describe the temporal dependencies, while providing a multiresolution representation of the observed sequence at the same time. We also notice that due to the unidirectional property of RNNs, it is difficult the realize the pyramidal graph in Figure 1d based on RNNs.
209
+
210
+ # B PROOF OF LEMMA 1
211
+
212
+ Proof. Let $S$ denote the number of scales in the pyramidal graph, $C$ the number of children nodes in the finer scale $s - 1$ that a node in the the coarser scale $s$ can summarize for $s = 2 , \cdots , S , A$ the number of adjacent nodes that a node can attend to within each scale, $N$ the number of attention layers, and $L$ the length of the input time series. We define the term “receptive field” of an arbitrary node $n _ { a }$ in a graph as the set of nodes that $n _ { a }$ can receive messages from. We further define the distance between two arbitrary nodes in a graph as the length of the shortest path between them (i.e., the number of steps to travel from one node to another). Note that in each attention layer, the messages can only travel by one step in the graph.
213
+
214
+ Without sacrificing generality, we assume that $L$ is divisible by $C ^ { S - 1 }$ , and then the number of nodes at the coarsest scale $S$ is $L / C ^ { S - 1 }$ . Since every node is connected to $A$ closest nodes at the same scale, the distance between the leftmost and the rightmost node at the coarsest scale is $2 ( L / C ^ { S - 1 } - 1 ) / ( A - 1 )$ . Hence, the leftmost and the rightmost node in the coarsest scale are in the receptive field of each other after the stack of $N \geq 2 ( L / C ^ { S - 1 } - 1 ) / ( A - 1 )$ layers of the pyramidal attention. In addition, owing to the CSCM, nodes at the coarsest scale can be regarded as the summary of the nodes in the finer scales. As a result, when Equation (4) is satisfied, all nodes at the coarsest scale have a global receptive field, which closes the proof. □
215
+
216
+ # C PROOF OF PROPOSITION 1
217
+
218
+ Proof. Suppose that $L ^ { ( s ) }$ denotes the number of nodes at scale $s$ , that is,
219
+
220
+ $$
221
+ L ^ { ( s ) } = \frac { L } { C ^ { s - 1 } } , 1 \leq s \leq S .
222
+ $$
223
+
224
+ For a node $n _ { \ell } ^ { ( s ) }$ in the pyramidal graph, the number of dot products $P _ { \ell } ^ { ( s ) }$ it acts as the query can be decomposed into two parts:
225
+
226
+ $$
227
+ P _ { \ell } ^ { ( s ) } = P _ { \ell } ^ { ( s ) } { } _ { \mathrm { i n t e r } } + P _ { \ell } ^ { ( s ) } { } _ { \mathrm { i n t r a } } ,
228
+ $$
229
+
230
+ where P (s) $P _ { \ell } ^ { ( s ) } { _ { \mathrm { i n t r a } } }$ a and P (s)ℓ int denotes the intra-scale and the inter-scale part respectively. According to the structure of the pyramidal graph, we can have the following inequalities:
231
+
232
+ $$
233
+ \begin{array} { r l } & { P _ { \ell \mathrm { \tiny ~ \min i n t r a } } ^ { ( s ) } \le A , } \\ & { P _ { \ell \mathrm { \tiny ~ \min t e r } } ^ { ( s ) } \le C + 1 . } \end{array}
234
+ $$
235
+
236
+ The first inequality (8) holds since a node typically attends to $A$ most adjacent nodes at the same scale but for the leftmost and the rightmost node, the number of in-scale nodes it can attend to is smaller than $A$ . On the other hand, the second inequality (9) holds because a node typically has $C$ children and 1 parent in the pyramidal graph but nodes at the top and the bottom scale can only attend to fewer than $C + 1$ nodes at adjacent scales.
237
+
238
+ In summary, the number of dot products that need to be calculated for scale $s$ is:
239
+
240
+ $$
241
+ P ^ { ( s ) } = \sum _ { \ell = 1 } ^ { L ^ { ( s ) } } \big ( P _ { \ell \mathrm { \tiny ~ \mathrm { ~ i n t r a } } } ^ { ( s ) } + P _ { \ell \mathrm { \tiny ~ \mathrm { ~ i n t e r } } } ^ { ( s ) } \big ) \le L ^ { ( s ) } ( A + C + 1 ) .
242
+ $$
243
+
244
+ Note that $P ^ { ( 1 ) } \leq L ( A + 1 )$ for the finest scale (i.e., $s = 1$ ) since nodes at this scale do not have any children. It follows that the number of dot products that need to be calculated for the entire pyramidal attention layer is:
245
+
246
+ $$
247
+ P = \sum _ { s = 1 } ^ { S } P ^ { ( s ) }
248
+ $$
249
+
250
+ $$
251
+ \begin{array} { l } { { \le L ( A + 1 ) + L ^ { ( 2 ) } ( A + C + 1 ) + . . . + L ^ { ( S ) } ( A + C + 1 ) } } \\ { { \displaystyle = L ( \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } A + \sum _ { s = 2 } ^ { S } C ^ { - ( s - 1 ) } + \sum _ { s = 1 } ^ { S - 1 } C ^ { - ( s - 1 ) } + 1 ) } } \\ { { \displaystyle < L ( ( A + 2 ) \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } + 1 ) . } } \end{array}
252
+ $$
253
+
254
+ In order to guarantee that the nodes at the coarsest scale have a global receptive field, we choose $C$ such that $\bar { C } \propto \ ^ { s - 1 } \bar { \sqrt { L } }$ . Consequently, the complexity of the proposed pyramidal attention is:
255
+
256
+ $$
257
+ \begin{array} { r l } { { \mathcal { O } ( P ) \leq \mathcal { O } ( L ( ( A + 2 ) \sum _ { s = 1 } ^ { s } C ^ { - ( s - 1 ) } + 1 ) ) } } \\ & { = \mathcal { O } ( L ( A + 2 ) \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } ) } \\ & { = \mathcal { O } ( \frac { ( A + 2 ) L ^ { \frac { S } { s - 1 } } - 1 } { L ^ { \frac { S - 1 } { s - 1 } } - 1 } ) } \\ & { = \mathcal { O } ( \frac { A L ^ { \frac { S - 1 } { s - 1 } } - 1 } { L ^ { \frac { S - 1 } { s - 1 } } - 1 } ) . } \end{array}
258
+ $$
259
+
260
+ When $L$ approaches infinity, the above expression amounts to $\mathcal { O } ( A L )$ . Since $A$ can be fixed when $L$ changes, the complexity can be further reduced to $\mathcal { O } ( L )$ . □
261
+
262
+ # D PROOF OF PROPOSITION 2
263
+
264
+ and Proof. Let $n _ { L } ^ { ( 1 ) }$ ℓ is the largest among all pairs of nodes in the pyramidal graph. The shortest path to travel $n _ { \ell } ^ { ( s ) }$ represent the $\ell$ -th node of the $s$ -th scale. It is evident that the distance between $n _ { 1 } ^ { ( 1 ) }$ from n(1)1 to $n _ { L } ^ { ( s ) }$ i s:
265
+
266
+ $$
267
+ n _ { 1 } ^ { ( 1 ) } \to n _ { 1 } ^ { ( 2 ) } \to \cdots \to n _ { 1 } ^ { ( S ) } \to \cdots \to n _ { L ^ { ( S ) } } ^ { ( S ) } \to n _ { L ^ { ( S - 1 ) } } ^ { ( S - 1 ) } \to \cdots \to n _ { L } ^ { ( 1 ) } .
268
+ $$
269
+
270
+ Correspondingly, the length of the maximum path between two arbitrary nodes in the graph is:
271
+
272
+ $$
273
+ L _ { \mathrm { m a x } } = 2 ( S - 1 ) + \frac { 2 ( L ^ { ( S ) } - 1 ) } { A - 1 } .
274
+ $$
275
+
276
+ When $C$ satisfies Equation (5), that is, $L ^ { ( S ) } - 1 \le ( A - 1 ) N / 2$ , we can obtain:
277
+
278
+ $$
279
+ \begin{array} { l } { \displaystyle \mathcal { O } \big ( L _ { \mathrm { m a x } } \big ) = \mathcal { O } \bigg ( 2 ( S - 1 ) + \frac { 2 \big ( L ^ { ( S ) } - 1 \big ) } { A - 1 } \bigg ) } \\ { \displaystyle \qquad = \mathcal { O } \bigg ( 2 ( S - 1 ) + \frac { 2 \big ( \frac { L } { C ^ { S - 1 } } - 1 \big ) } { A - 1 } \bigg ) } \\ { \displaystyle \qquad = \mathcal { O } \big ( 2 ( S - 1 ) + N \big ) } \\ { \displaystyle \qquad = \mathcal { O } ( S + N ) . } \end{array}
280
+ $$
281
+
282
+ Since $A , S$ and $N$ are invariant with $L$ , the order of the maximum path length $L _ { \mathrm { m a x } }$ can be further simplified as $\mathcal { O } ( 1 )$ .
283
+
284
+ # E DATASETS
285
+
286
+ We demonstrated the advantages of the proposed Pyraformer on the following four datasets. The first three datasets were used for single-step forecasting, while the last two for long-range multi-step forecasting.
287
+
288
+ Wind2: This dataset contains hourly estimation of the energy potential in 28 countries between 1986 and 2015 as a percentage of a power plant’s maximum output. Compared with the remaining datasets, it is more sparse and periodically exhibits a large number of zeros. Due to the large size of this dataset, the ratio between training and testing set was roughly 32:1.
289
+
290
+ App Flow: This dataset was collected at Ant Group3. It consists of hourly maximum traffic flow for 128 systems deployed on 16 logic data centers, resulting in 1083 different time series in total. The length of each series is more than 4 months. Each time series was divided into two segments for training and testing respectively, with a ratio of 32:1.
291
+
292
+ Electricity4 (Yu et al., 2016): This dataset contains time series of electricity consumption recorded every 15 minutes from 370 users. Following DeepAR (Salinas et al., 2020), we aggregated every 4 records to get the hourly observations. This dataset was employed for both single-step and longrange forecasting. We trained with data from 2011-01-01 to 2014-09-01 for single-step forecasting, and from 2011-04-01 to 2014-04-01 for long-range forecasting.
293
+
294
+ $\mathbf { \mathbf { E } } \mathbf { T } \mathbf { T } ^ { 5 }$ (Zhou et al., 2021): This dataset comprises 2 years of 2 electricity transformers collected from 2 stations, including the oil temperature and 6 power load features. Observations every hour (i.e., ETTh1) and every 15 minutes (i.e., ETTm1) are provided. This dataset is typically exploited for model assessment on long-range forecasting. Here, we followed Informer (Zhou et al., 2021) and partitioned the data into 12 and 4 months for training and testing respectively.
295
+
296
+ # F EXPERIMENT SETUP
297
+
298
+ We set $S = 4$ and $N = 4$ for Pyraformer in all experiments. When the historical length $L$ is not divisible by $C$ , we only introduced $\lfloor L / C \rfloor$ nodes in the upper scale, where $\lfloor \cdot \rfloor$ denotes the round down operation. The last $L - ( \lfloor L / \bar { C } \rfloor - \bar { 1 } ) C$ nodes at the bottom scale were all connected to the last node at the upper scale. For single-step forecasting, we set $C = 4$ , $A = 3$ , and $H = 4$ in all experiments. Both training and testing used a fixed-size historical sequence to predict the mean and variance of the Gaussian distribution of a single future value. We chose the MSE loss and the log-likelihood (Zuo et al., 2020) as our loss functions. The ratio between them was set to 100. For optimization, we used Adam with the learning rate starting from $1 0 ^ { - 5 }$ and halving in every epoch. We trained Pyraformer with 10 epochs. Weighted sampler based on each window’s average value and hard sample mining were used to improve the generalization ability of the network. On the other hand, for long-range forecasting, we tested four combinations of $A$ and $C$ in each experiment, and the best results were presented. Specifically, when the prediction length is smaller than 600, we tested $A = 3 , 5$ and $C = 4 , 5$ . When the prediction length is larger than 600, we tested $A = 3 , 5$ and $C = 5 , 6$ . The resulting choice of hyper-parameters for each experiment is listed in Table 5. In addition, the loss function was the MSE loss only. We still used Adam as our optimizer, but the learning rate started from $1 0 ^ { - 4 }$ and was reduced to one-tenth every epoch. We set the number of epochs to be 5.
299
+
300
+ # G PRETRAINING
301
+
302
+ For single-step forecasting, the value to be predicted is usually close to the last value of history. Since we only use the last nodes of all scales to predict, the network tends to focus only on shortterm dependencies. To force the network to capture long-range dependencies, we add additional supervision in the first few epochs of training. Specifically, in the first epoch, we form our network as an auto-encoder, as shown in Figure 5. Apart from predicting future values, the PAM is also trained to recover the input values. Note that we test all methods with and without this pretraining strategy and the better results are displayed in Table 2.
303
+
304
+ Table 5: Hyper-parameter settings of long-range experiments.
305
+
306
+ <table><tr><td>Dataset</td><td>prediction length</td><td>N</td><td>S</td><td>H</td><td>A</td><td>C</td><td>historical length</td></tr><tr><td rowspan="3">ETTh1</td><td>168</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>336</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>720</td><td>4</td><td>4</td><td>6</td><td>5</td><td>4</td><td>336</td></tr><tr><td rowspan="3">ETTm1</td><td>96</td><td>4</td><td>4</td><td>6</td><td>3</td><td>5</td><td>384</td></tr><tr><td>288</td><td>4</td><td>4</td><td>6</td><td>5</td><td>5</td><td>672</td></tr><tr><td>672</td><td>4</td><td>4</td><td>6</td><td>3</td><td>6</td><td>672</td></tr><tr><td rowspan="3">Elect</td><td>168</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>336</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>720</td><td>4</td><td>4</td><td>6</td><td>3</td><td>5</td><td>336</td></tr></table>
307
+
308
+ ![](images/16bca2db6aa268152dfacebb3a8ccf6bd2e2df85f5fcbe3870acda17a4461454.jpg)
309
+ Figure 5: The pretraining strategy for one-step prediction. Features of nodes surrounded by the dashed ellipses are concatenated to recover the corresponding input value.
310
+
311
+ # H METRICS
312
+
313
+ Denote the target value as $z _ { j , t }$ and the predicted value as $\hat { z } _ { j , t }$ , where $j$ is the sample index and $t$ is the time index. Then NRMSE and ND are calculated as follows:
314
+
315
+ $$
316
+ \begin{array} { r l } & { \mathrm { N R M S E } = \frac { \sqrt { \frac { 1 } { N T } \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } ( z _ { j , t } - \hat { z } _ { j , t } ) ^ { 2 } } } { \frac { 1 } { N T } \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } | } , } \\ & { \quad \quad \quad \quad \mathrm { N D } = \frac { \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } - \hat { z } _ { j , t } | } { \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } | } . } \end{array}
317
+ $$
318
+
319
+ # I EXPERIMENTS ON SYNTHETIC DATA
320
+
321
+ To further evaluate Pyraformer’s ability to capture different ranges of temporal dependencies, we synthesized an hourly dataset with multi-range dependencies and carried out experiments on it.
322
+
323
+ Specifically, each time series in the synthetic dataset is a linear combination of three sine functions of different periods: 24, 168 and 720, that is,
324
+
325
+ $$
326
+ f ( t ) = \beta _ { 0 } + \beta _ { 1 } \sin ( \frac { 2 \pi } { 2 4 } t ) + \beta _ { 2 } \sin ( \frac { 2 \pi } { 1 6 8 } t ) + \beta _ { 3 } \sin ( \frac { 2 \pi } { 7 2 0 } t ) .
327
+ $$
328
+
329
+ In the above equation, the coefficients of the three sine functions $\beta _ { 1 } , \beta _ { 2 }$ , and $\beta _ { 3 }$ for each time series are uniformly sampled from [5, 10]. $\beta _ { 0 }$ is a Gaussian process with a covariance function $\Sigma _ { t _ { 1 } , t _ { 2 } } = | t _ { 1 } - t _ { 2 } | ^ { - 1 }$ and $\Sigma _ { t _ { 1 } } = \Sigma _ { t _ { 2 } } = 1$ , where $t _ { 1 }$ and $t _ { 2 }$ denote two arbitrary time stamps. Such polynomially decaying covariance functions are known to have long-range dependence, as oppose to the exponentially decaying covariance functions ( $\mathrm { Y u }$ et al., 2019). The start time of each time series $t _ { 0 }$ is uniformly sampled from [0, 719]. We first generate 60 time series of length 14400, and then split each time series into sliding windows of width 1440 with a stride of 24. In our experiments, we use the historical 720 time points to predict the future 720 points. Since both the deterministic and stochastic parts of the synthetic time series have long-range correlations, such dependencies should be well captured in the model in order to yield accurate predictions of the next 720 points. The results are summarized in Table 6. Here, we consider two different configurations of Pyraformer: 1) $C = 6$ for all scales in the pyramidal graph (denoted as Pyraformer6,6,6); 2) $C = 1 2$ , 7, and 4 for the three layers sequentially from bottom to top (denoted as Pyraformer12,7,4).
330
+
331
+ Table 6: Long-range forecasting results on the synthetic dataset.
332
+
333
+ <table><tr><td>Method</td><td>MSE</td><td>MAE</td></tr><tr><td>Full attention</td><td>3.550</td><td>1.477</td></tr><tr><td>LogTrans</td><td>3.007</td><td>1.366</td></tr><tr><td>ETC</td><td>4.742</td><td>5.509</td></tr><tr><td>Informer</td><td>7.546</td><td>2.092</td></tr><tr><td>Longformer</td><td>2.032</td><td>1.116</td></tr><tr><td>Reformer</td><td>1.538</td><td>3.069</td></tr><tr><td>Pyraformer6,6,6</td><td>1.258</td><td>0.877</td></tr><tr><td>Pyraformer12,7,4</td><td>1.176</td><td>0.849</td></tr></table>
334
+
335
+ It can be observed that Pyraformer6,6,6 with the same $C$ for all scales already outperforms the benchmark methods by a large margin. In particular, the MSE given by Pyraformer is decreased by $1 8 . 2 \%$ compared with Reformer, which produces the smallest MSE among the existing variants of Transformer. On the other hand, by exploiting the information of the known period, Pyraformer12,7,4 performs even better than Pyraformer6,6,6. Note that in Pyraformer $^ { \cdot _ { 1 2 , 7 , 4 } }$ , nodes at scale 2, 3, and 4 characterizes coarser temporal resolutions respectively corresponding to half a day, half a week, and half a month. We also tested Pyraformer24,7,4, but setting $C = 2 4$ in the second scale degrades the performance, probably because the convolution layer with a kernel size of 24 is difficult to train.
336
+
337
+ We further visualized the forecasting results produced by Pyraformer $^ { 1 2 , 7 , 4 }$ in Figure 6. The blue solid curve and red dashed curve denote the true and predicted time series respectively. By capturing the temporal dependencies with different ranges, the prediction resulting from Pyraformer closely follows the ground truth.
338
+
339
+ On the other hand, to check whether Pyraformer can extract features with different temporal resolutions, we depicted the extracted features in a randomly selected channel across time at each scale in the pyramidal graph in Figure 7. It is apparent that the features at the coarser scales can be regarded as a lower resolution version of the features at the finer scales.
340
+
341
+ # J ABLATION STUDY
342
+
343
+ # J.1 IMPACT OF $A$ AND $C$
344
+
345
+ We studied the impact of $A$ and $C$ on the performance of Pyraformer for long-range time series forecasting, and showed the results in Table 7. Here, we focus on the dataset ETTh1. The history length is 336 and the prediction length is 720. From Table 7, we can conclude that the receptive fields of the nodes at the coarsest scale in the PAM play an indispensable role in reducing the prediction error of Pyraformer. For instance, there are 42 nodes at the coarsest scale when $C = 2$ . Without the intra-scale connections, each node can only receive messages from 16 nodes at the finest scale. As the number of adjacent connections $A$ in each scale increases, the receptive fields of the coarsestscale nodes also extend, and therefore, the prediction error decreases accordingly. However, as long as the nodes at the top scale have a global receptive field, further increasing $A$ will not bring large gains. For $C = 5$ , the performance does not improve even though $A$ increases. Such observations indicate that it is better to set $A$ to be small once the uppermost nodes in the PAM have a global receptive field. In practice, we only increase $C$ with the increase of $L$ , but keep $A$ small.
346
+
347
+ ![](images/0e107628896de0c58e44310218af31bad1997b6ef59d90b98d324d9c9992721a.jpg)
348
+ Figure 6: Visualization of prediction results on the synthetic dataset.
349
+
350
+ ![](images/78b6ff45bfe2e9e637686e94056b78164c4a40e9a46ac871d93338b981fb0e83.jpg)
351
+ Figure 7: Visualization of the extracted features across time in second channel at different scales: (a) scale 1; (b) scale 2; (c) scale 3.
352
+
353
+ # J.2 IMPACT OF THE CSCM ARCHITECTURE
354
+
355
+ In addition to convolution, there exist other mechanisms for constructing the $C$ -ary tree, such as max pooling and average pooling. We studied the impact of different CSCM architectures on the performance for long-range forecasting on dataset ETTh1. The history and the prediction length are both 168 and $C = 4$ for all mechanisms. The results are listed in Table 8. From Table 8, we can tell that: (1) Using pooling layers instead of convolution typically degrades the performance. However, the performance of Pyraformer based on max pooling is still superior to that of Informer, demonstrating the advantages of the PAM over the prob-sparse attention in Informer. (2) The MSE of convolution with the bottleneck is only $1 . 5 1 \%$ larger than that without bottleneck, but the number of parameters is reduced by almost $9 0 \%$ . Thus, we adopt the more compact module of convolution with bottleneck as our CSCM.
356
+
357
+ Table 7: Impact of $A$ and $C$ on long-range forecasting. The history length is 336.
358
+
359
+ <table><tr><td rowspan="2"></td><td colspan="3">A=3</td><td colspan="3">A=9</td><td colspan="3">A = 13</td></tr><tr><td>MSE</td><td>MAE</td><td>Q-K pairs</td><td>MSE</td><td>MAE</td><td>Q-K pairs</td><td>MSE MAE</td><td></td><td>Q-K pairs</td></tr><tr><td>C=2</td><td>1.035</td><td>0.811</td><td>73512</td><td>1.029</td><td>0.815</td><td>162648</td><td>1.003</td><td>0.807</td><td>221112</td></tr><tr><td>C=3</td><td>1.029</td><td>0.817</td><td>58992</td><td>1.009</td><td>0.798</td><td>128976</td><td>1.056</td><td>0.805</td><td>174672</td></tr><tr><td>C=4</td><td>1.001</td><td>0.802</td><td>53208</td><td>1.028</td><td>0.806</td><td>115848</td><td>1.027</td><td>0.804</td><td>156696</td></tr><tr><td>C=5</td><td>0.999</td><td>0.796</td><td>49992</td><td>1.005</td><td>0.796</td><td>108744</td><td>1.017</td><td>0.797</td><td>147192</td></tr></table>
360
+
361
+ Table 8: Impact of the CSCM architecture on long-range forecasting. Parameters introduced by the normalization layers are relatively few, and thus, are ignored.
362
+
363
+ <table><tr><td>CSCM</td><td>MSE</td><td>MAE</td><td>Parameters</td></tr><tr><td>Max-pooling</td><td>0.842</td><td>0.700</td><td>0</td></tr><tr><td>Average-pooling</td><td>0.833</td><td>0.693</td><td>0</td></tr><tr><td>Conv.</td><td>0.796</td><td>0.679</td><td>3147264</td></tr><tr><td>Conv.w/bottleneck</td><td>0.808</td><td>0.683</td><td>328704</td></tr></table>
364
+
365
+ Table 9: Impact of history length. The prediction length is 1344.
366
+
367
+ <table><tr><td>History Length</td><td>MSE</td><td>MAE</td></tr><tr><td>84</td><td>1.234</td><td>0.856</td></tr><tr><td>168</td><td>1.226</td><td>0.868</td></tr><tr><td>336</td><td>1.108</td><td>0.835</td></tr><tr><td>672</td><td>1.057</td><td>0.806</td></tr><tr><td>1344</td><td>1.062</td><td>0.806</td></tr></table>
368
+
369
+ Table 10: Impact of the PAM.
370
+
371
+ <table><tr><td>Method</td><td>Metrics</td><td>96</td><td>288</td><td>672</td></tr><tr><td rowspan="2">CSCM Only</td><td>MSE</td><td>0.576</td><td>0.782</td><td>0.883</td></tr><tr><td>MAE</td><td>0.544</td><td>0.683</td><td>0.752</td></tr><tr><td rowspan="2">Pyraformer</td><td>MSE</td><td>0.480</td><td>0.754</td><td>0.857</td></tr><tr><td>MAE</td><td>0.486</td><td>0.659</td><td>0.707</td></tr></table>
372
+
373
+ # J.3 IMPACT OF THE HISTORY LENGTH
374
+
375
+ We also checked the influence of the history length on the prediction accuracy. The dataset is ETTm1, since its granularity is minute and contains more long-range dependencies. We fixed the prediction length to 1344 and changed the history length from 84 to 1344 in Table 9. As expected, a longer history typically improves prediction accuracy. On the other hand, this performance gain starts to level off when introducing more history stops providing new information. As shown in Figure 8, the time series with length 672 contains almost all periodicity information that is essential for prediction, while length 1344 introduces more noise.
376
+
377
+ # J.4 IMPACT OF THE PAM
378
+
379
+ Finally, we investigated the importance of the PAM. We compared the performance of Pyraformer with and without the PAM on the dataset ETTm1. For a fair comparison, the number of parameters of the two methods were controlled to be within the same order of magnitude. More precisely, we increased the bottleneck dimension of ”Conv. w/bottleneck” for the model only with the CSCM. The results are shown in Table 10. Obviously, the PAM is vital to yield accurate predictions.
380
+
381
+ # K DISCUSSION ON THE SELECTION OF HYPER-PARAMETERS
382
+
383
+ We recommend to first determine the number of attention layers $N$ based on the available computing resources, as this number is directly related to the model size. Next, the number of scales $S$ can be determined by the granularity of the time series. For example, for hourly observations, we typically assume that it may also have daily, weekly and monthly periods. Therefore, we can set $S$ to be 4. We then focus on the selection of $A$ and $C$ . According to the ablation study, we typically prefer a small $A$ , such as 3 and 5. Lastly, in order to ensure the network has a receptive field of $L$ , we can select a $C$ that satisfies Equation (5). In practice, we can use a validation set to choose $C$ from its candidates that satisfies (5). It is also worthwhile to check whether choosing different $C$ for different scales based on the granularity of the time series can further improve the performance as we did in Appendix I.
384
+
385
+ ![](images/db2eafc4e603577f0d58166014a0fae825efdf9d45557b4f4357d82edaf6f6ac.jpg)
386
+ Figure 8: Time series with different lengths in the ETTm1 dataset. The sequence length in (a) and (b) is 672, and that in (c) and (d) is 1344. The time series in (a) and (b) corresponds to the latter half of those in (c) and (d) respectively.
md/dev/4XMAzZasId/4XMAzZasId.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/7B3IJMM1k_M/7B3IJMM1k_M.md ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OPTIMAL ANN-SNN CONVERSION FOR HIGHACCURACY AND ULTRA-LOW-LATENCY SPIKING NEURAL NETWORKS
2
+
3
+ Tong $\mathbf { B } \mathbf { u } ^ { 1 }$ , Wei $\mathbf { F a n g } ^ { 1 }$ , Jianhao $\mathbf { D i n g ^ { 1 } }$ , PengLin $\mathbf { D } \mathbf { a } \mathbf { i } ^ { 2 }$ , Zhaofei $\mathbf { V } \mathbf { u } ^ { 1 }$ \*, Tiejun Huang1
4
+ 1 Peking University, 2 Southwest Jiaotong University
5
+ \* Corresponding author: yuzf12@pku.edu.cn
6
+
7
+ # ABSTRACT
8
+
9
+ Spiking Neural Networks (SNNs) have gained great attraction due to their distinctive properties of low power consumption and fast inference on neuromorphic hardware. As the most effective method to get deep SNNs, ANN-SNN conversion has achieved comparable performance as ANNs on large-scale datasets. Despite this, it requires long time-steps to match the firing rates of SNNs to the activation of ANNs. As a result, the converted SNN suffers severe performance degradation problems with short time-steps, which hamper the practical application of SNNs. In this paper, we theoretically analyze ANN-SNN conversion error and derive the estimated activation function of SNNs. Then we propose the quantization clipfloor-shift activation function to replace the ReLU activation function in source ANNs, which can better approximate the activation function of SNNs. We prove that the expected conversion error between SNNs and ANNs is zero, enabling us to achieve high-accuracy and ultra-low-latency SNNs. We evaluate our method on CIFAR-10/100 and ImageNet datasets, and show that it outperforms the stateof-the-art ANN-SNN and directly trained SNNs in both accuracy and time-steps. To the best of our knowledge, this is the first time to explore high-performance ANN-SNN conversion with ultra-low latency (4 time-steps). Code is available at https://github.com/putshua/SNN conversion QCFS
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Spiking neural networks (SNNs) are biologically plausible neural networks based on the dynamic characteristic of biological neurons (McCulloch & Pitts, 1943; Izhikevich, 2003). As the third generation of artificial neural networks (Maass, 1997), SNNs have attracted great attention due to their distinctive properties over deep analog neural networks (ANNs) (Roy et al., 2019). Each neuron transmits discrete spikes to convey information when exceeding a threshold. For most SNNs, the spiking neurons will accumulate the current of the last layer as the output within $T$ inference time steps. The binarized activation has rendered dedicated hardware of neuromorphic computing (Pei et al., 2019; DeBole et al., 2019; Davies et al., 2018). This kind of hardware has excellent advantages in temporal resolution and energy budget. Existing work has shown the potential of tremendous energy saving with considerably fast inference (Stockl & Maass, 2021). ¨
14
+
15
+ In addition to efficiency advantages, the learning algorithm of SNNs has been improved by leaps and bounds in recent years. The performance of SNNs trained by backpropagation through time and ANN-SNN conversion techniques has gradually been comparable to ANNs on large-scale datasets (Fang et al., 2021; Rueckauer et al., 2017). Both techniques benefit from the setting of SNN inference time. Setting longer time-steps in backpropagation can make the gradient of surrogate functions more reliable (Wu et al., 2018; Neftci et al., 2019; Zenke & Vogels, 2021). However, the price is enormous resource consumption during training. Existing platforms such as TensorFlow and PyTorch based on CUDA have limited optimization for SNN training. In contrast, ANN-SNN conversion usually depends on a longer inference time to get comparable accuracy as the original ANN (Sengupta et al., 2019) because it is based on the equivalence of ReLU activation and integrateand-fire model’s firing rate (Cao et al., 2015). Although longer inference time can further reduce the conversion error, it also hampers the practical application of SNNs on neuromorphic chips.
16
+
17
+ The dilemma of ANN-SNN conversion is that there exists a remaining potential in the conversion theory, which is hard to be eliminated in a few time steps (Rueckauer et al., 2016). Although many methods have been proposed to improve the conversion accuracy, such as weight normalization (Diehl et al., 2015), threshold rescaling (Sengupta et al., 2019), soft-reset (Han & Roy, 2020) and threshold shift (Deng & Gu, 2020), tens to hundreds of time-steps in the baseline works are still unbearable. To obtain high-performance SNNs with ultra-low latency (e.g., 4 time-steps), we list the critical errors in ANN-SNN conversion and provide solutions for each error. Our main contributions are summarized as follows:
18
+
19
+ • We go deeper into the errors in the ANN-SNN conversion and ascribe them to clipping error, quantization error, and unevenness error. We find that unevenness error, which is caused by the changes in the timing of arrival spikes and has been neglected in previous works, can induce more spikes or fewer spikes as expected. • We propose the quantization clip-floor-shift activation function to replace the ReLU activation function in source ANNs, which better approximates the activation function of SNNs. We prove that the expected conversion error between SNNs and ANNs is zero, indicating that we can achieve high-performance converted SNN at ultra-low time-steps. • We evaluate our method on CIFAR-10, CIFAR-100, and ImageNet datasets. Compared with both ANN-SNN conversion and backpropagation training methods, the proposed method exceeds state-of-the-art accuracy with fewer time-steps. For example, we reach top-1 accuracy $9 1 . 1 8 \%$ on CIFAR-10 with unprecedented 2 time-steps.
20
+
21
+ # 2 PRELIMINARIES
22
+
23
+ In this section, we first briefly review the neuron models for SNNs and ANNs. Then we introduce the basic framework for ANN-SNN conversion.
24
+
25
+ Neuron model for ANNs. For ANNs, the computations of analog neurons can be simplified as the combination of a linear transformation and a non-linear mapping:
26
+
27
+ $$
28
+ \pmb { a } ^ { l } = h ( \pmb { W } ^ { l } \pmb { a } ^ { l - 1 } ) , l = 1 , 2 , . . . , M
29
+ $$
30
+
31
+ where the vector $\mathbf { \Delta } _ { \mathbf { \alpha } \mathbf { \beta } \mathbf { a } _ { } ^ { l } }$ denotes the output of all neurons in $l$ -th layer, $\mathbf { \Delta } W ^ { l }$ denotes the weight matrix between layer $l$ and layer $l - 1$ , and $h ( \cdot )$ is the ReLU activation function.
32
+
33
+ Neuron model for SNNs. Similar to the previous works (Cao et al., 2015; Diehl et al., 2015; Han et al., 2020), we consider the Integrate-and-Fire (IF) model for SNNs. If the IF neurons in $l$ -th layer receive the input ${ \boldsymbol x } ^ { l - 1 } ( t )$ from last layer, the temporal potential of the IF neurons can be defined as:
34
+
35
+ $$
36
+ \pmb { m } ^ { l } ( t ) = \pmb { v } ^ { l } ( t - 1 ) + \pmb { W } ^ { l } \pmb { x } ^ { l - 1 } ( t ) ,
37
+ $$
38
+
39
+ where $m ^ { l } ( t )$ and ${ \pmb v } ^ { l } ( t )$ represent the membrane potential before and after the trigger of a spike at time-step $t$ . $W ^ { l }$ denote the weight in $l$ -th layer. As soon as any element $m _ { i } ^ { l } ( t )$ of $m ^ { l } ( t )$ exceeds the firing threshold $\theta ^ { l }$ , the neuron will elicit a spike and update the membrane potential $v _ { i } ^ { l } ( t )$ . To avoid information loss, we use the “reset-by-subtraction” mechanism (Rueckauer et al., 2017; Han et al., 2020) instead of the “reset-to-zero” mechanism, which means the membrane potential $v _ { i } ^ { l } ( t )$ is subtracted by the threshold value $\theta ^ { l }$ if the neuron fires. Based on the threshold-triggered firing mechanism and the “reset-by-subtraction” of the membrane potential after firing discussed above, we can write the uplate rule of membrane potential as:
40
+
41
+ $$
42
+ \begin{array} { r } { \pmb { s } ^ { l } ( t ) = H ( \pmb { m } ^ { l } ( t ) - \pmb { \theta } ^ { l } ) , } \\ { \pmb { v } ^ { l } ( t ) = \pmb { m } ^ { l } ( t ) - \pmb { s } ^ { l } ( t ) \theta ^ { l } . } \end{array}
43
+ $$
44
+
45
+ Here $s ^ { l } ( t )$ refers to the output spikes of all neurons in layer $l$ at time $t$ , the element of which equals 1 if there is a spike and 0 otherwise. $H ( \cdot )$ is the Heaviside step function. $\pmb { \theta } ^ { l }$ is the vector of the firing threshold $\mathbf { \dot { \theta } } ^ { l }$ . Similar to Deng $\&$ Gu (2020), we suppose that the postsynaptic neuron in $l$ -th layer receives unweighted postsynaptic potential $\theta ^ { l }$ if the presynaptic neuron in $l - 1$ -th layer fires a spike, that is:
46
+
47
+ $$
48
+ \pmb { x } ^ { l } ( t ) = \pmb { s } ^ { l } ( t ) \pmb { \theta } ^ { l } .
49
+ $$
50
+
51
+ Table 1: Summary of notations in this paper
52
+
53
+ <table><tr><td>Symbol</td><td>Definition</td><td>Symbol</td><td>Definition</td></tr><tr><td>1</td><td>Layer index</td><td>x(t)</td><td>Unweighted PSPl</td></tr><tr><td>i</td><td>Neuron index</td><td>s(t)</td><td>Output spikes</td></tr><tr><td>W</td><td>Weight</td><td>(T)</td><td>Average unweigthed PSP before time T</td></tr><tr><td>al</td><td>ANN activation values</td><td>zl</td><td>Weighted input from l-1layer</td></tr><tr><td>t</td><td>Time-steps</td><td>h()</td><td>ReLU function</td></tr><tr><td>T</td><td>Total time-step</td><td>H()</td><td>Heaviside step function</td></tr><tr><td>0l</td><td>Threshold</td><td>L</td><td>Quantization step for ANN</td></tr><tr><td>又</td><td>Trainable threshold in ANN</td><td>Errl</td><td>Conversion Error</td></tr><tr><td>ml(t)</td><td>Potential before firing</td><td>Err -l</td><td>Estimated conversion Error</td></tr><tr><td>1(t)</td><td>Potential after firing</td><td>6</td><td>Shift of quantization clip-floor function</td></tr></table>
54
+
55
+ 1 Postsynaptic potential
56
+
57
+ ANN-SNN conversion. The key idea of ANN-SNN conversion is to map the activation value of an analog neuron in ANN to the firing rate (or average postsynaptic potential) of a spiking neuron in SNN. Specifically, we can get the potential update equation by combining Equation 2 – Equation 4:
58
+
59
+ $$
60
+ \pmb { v } ^ { l } ( t ) - \pmb { v } ^ { l } ( t - 1 ) = \pmb { W } ^ { l } \pmb { x } ^ { l - 1 } ( t ) - \pmb { s } ^ { l } ( t ) \pmb { \theta } ^ { l } .
61
+ $$
62
+
63
+ Equation 6 describes the basic function of spiking neurons used in ANN-SNN conversion. By summing Equation 6 from time 1 to $T$ and dividing $T$ on both sides, we have:
64
+
65
+ $$
66
+ { \frac { { \pmb v } ^ { l } ( T ) - { \pmb v } ^ { l } ( 0 ) } { T } } = { \frac { { \pmb W } ^ { l } \sum _ { i = 1 } ^ { T } { \pmb x } ^ { l - 1 } ( i ) } { T } } - { \frac { \sum _ { i = 1 } ^ { T } s ^ { l } ( i ) \theta ^ { l } } { T } } .
67
+ $$
68
+
69
+ If we use from 0 to $\begin{array} { r } { \phi ^ { l - 1 } ( T ) = \frac { \sum _ { i = 1 } ^ { T } { \pmb x } ^ { l - 1 } ( i ) } { T } } \end{array}$ to denote the average postsynaptic potential during the period 5 into Equation 7, then we get: $T$
70
+
71
+ $$
72
+ \phi ^ { l } ( T ) = W ^ { l } \phi ^ { l - 1 } ( T ) - \frac { { \pmb v } ^ { l } ( T ) - { \pmb v } ^ { l } ( 0 ) } { T } .
73
+ $$
74
+
75
+ Equation 8 describes the relationship of the average postsynaptic potential of neurons in adjacent layers. Note that $\phi ^ { l } ( T ) \geqslant 0$ . If we set the initial potential $\mathbf { \boldsymbol { v } } ^ { l } ( \mathbf { \bar { 0 } } )$ to zero and neglect the remaining term vl(T )T when the simulation time-steps T is long enough, the converted SNN has nearly the same activation function as source ANN (Equation 1). However, high $T$ would cause long inference latency that hampers the practical application of SNNs. Therefore, this paper aims to implement high-performance ANN-SNN conversion with extremely low latency.
76
+
77
+ # 3 CONVERSION ERROR ANALYSIS
78
+
79
+ In this section, we will analyze the conversion error between the source ANN and the converted SNN in each layer in detail. In the following, we assume that both ANN and SNN receive the same input from the layer $l - 1$ , that is, ${ \pmb a } ^ { l - 1 } = \phi ^ { l - 1 } ( T )$ , and then analyze the error in layer $l$ . For simplicity, we use $z ^ { l } = W ^ { l } \phi ^ { l - 1 } ( T ) = W ^ { l } a ^ { l - 1 }$ to substitute the weighted input from layer $l - 1$ for both ANN and SNN. The absolute conversion error is exactly the outputs from converted SNN subtract the outputs from ANN:
80
+
81
+ $$
82
+ E r r ^ { l } = \phi ^ { l } ( T ) - a ^ { l } = z ^ { l } - \frac { { \pmb v } ^ { l } ( T ) - { \pmb v } ^ { l } ( 0 ) } { T } - h ( z ^ { l } ) ,
83
+ $$
84
+
85
+ where $h ( z ^ { l } ) = \mathrm { R e L U } ( z ^ { l } )$ . It can be found from Equation 9 that the conversion error is nonzero if ${ \pmb v } ^ { l } ( T ) - { \pmb v } ^ { l } ( 0 ) \neq 0$ and $z ^ { l } > 0$ . In fact, the conversion error is caused by three factors.
86
+
87
+ Clipping error. The output ϕl(T ) of SNNs is in the range of [0, θl] as ϕl(T ) = PTi=1 xl(i)T PTi=1 sl(i)T θl (see Equation 5). However, the output al of ANNs is in a much lager range of [0, almax], where $a _ { m a x } ^ { l }$ denotes the maximum value of $\mathbf { \delta } _ { \mathbf { { a } } } l$ . As illustrated in Figure 1a, $\mathbf { \Delta } _ { \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \beta } } \mathbf { \Delta } _ \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathrm \langle \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathrm { \left. \frac { \partial \mathbf { \alpha } \mathbf { \beta } } { \partial \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathrm { \beta \alpha } \mathrm { \beta } } }\right.$ can be mapped to $\phi ^ { l } ( T )$ by the following equation:
88
+
89
+ $$
90
+ \phi ^ { l } ( T ) = \mathrm { c l i p } \left( \frac { \theta ^ { l } } { T } \left\lfloor \frac { { \mathbf { a } } ^ { l } T } { \lambda ^ { l } } \right\rfloor , 0 , \theta ^ { l } \right) .
91
+ $$
92
+
93
+ ![](images/ec97e07b360ac04e2fe752bfcd2992ad416384ac424d157a1b90b9e0eeac50c5.jpg)
94
+ Figure 1: Conversion error between source ANN and converted SNN. $s _ { 1 } ^ { l - 1 }$ and $s _ { 2 } ^ { l - 1 }$ denote the output spikes of two neurons in layer $l - 1$ , and $s _ { 1 } ^ { l }$ denotes the output spikes of a neuron in layer $l$ .
95
+
96
+ Here the clip function sets the upper bound $\theta ^ { l }$ and the lower bound 0. $\lfloor \cdot \rfloor$ denotes the floor function.
97
+ $\lambda ^ { l }$ represents the actual maximum value of output $\mathbf { \delta } _ { \mathbf { { a } } } l$ mapped to the maximum value $\theta ^ { l }$ of $\phi ^ { l } ( T )$ .
98
+
99
+ Considering that nearly $9 9 . 9 \%$ activations of $\mathbf { \Delta } _ { \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \beta } } \mathbf { \Delta } _ \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathrm \langle \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \beta } \mathrm { \left. \frac { \partial \mathbf { \alpha } \mathbf { \beta } } { \partial \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathrm { \beta \alpha } \mathrm { \beta } } }\right.$ in ANN are in the range of $\begin{array} { r } { [ 0 , \frac { a _ { m a x } ^ { l } } { 3 } ] } \end{array}$ , Rueckauer et al. (2016) suggested to choose $\lambda ^ { l }$ according to $9 9 . 9 \%$ activations. The activations between $\lambda ^ { l }$ and $a _ { m a x } ^ { l }$ in ANN are mapped to the same value $\theta ^ { l }$ in SNN, which will cause conversion error called clipping error.
100
+
101
+ Quantization error (flooring error). The output spikes $s ^ { l } ( t )$ are discrete events, thus $\phi ^ { l } ( T )$ are discrete with quantization resolution $\frac { \theta ^ { l } } { T }$ (see Equation 10). When mapping $\mathbf { \delta } _ { \mathbf { { a } } } l$ to $\phi ^ { l } ( T )$ , there exists unavoidable quantization error. For example, as illustrated in Figure 1a, the activations of ANN in the range of $\bigl [ \frac { \lambda ^ { l } } { T } , \frac { 2 \lambda ^ { l } } { T } \bigr )$ are mapped to the same value $\frac { \theta ^ { l } } { T }$ of SNN.
102
+
103
+ Unevenness error. Unevenness error is caused by the unevenness of input spikes. If the timing of arrival spikes changes, the output firing rates may change, which causes conversion error. There are two situations: more spikes as expected or fewer spikes as expected. To see this, in source ANN, we suppose that two analog neurons in layer $l - 1$ are connected to an analog neuron in layer $l$ with weights 2 and $^ { - 2 }$ , and the output vector $\mathbf { a } ^ { l - 1 }$ of neurons in layer $l - 1$ is [0.6, 0.4]. Besides, in converted SNN, we suppose that the two spiking neurons in layer $l - 1$ fire 3 spikes and 2 spikes in 5 time-steps $( \mathrm { T } { = } 5 )$ ), respectively, and the threshold $\theta ^ { l - 1 } = 1$ . Thus, $\begin{array} { r } { \phi ^ { l - 1 } ( T ) = \frac { \sum _ { i = 1 } ^ { T } s ^ { l - 1 } ( i ) } { T } \theta ^ { l - 1 } = } \end{array}$ [0.6, 0.4]. Even though $\phi ^ { l - 1 } ( T ) = \pmb { a } ^ { l - 1 }$ and the weights are same for the ANN and SNN, $\phi ^ { l } ( T )$ can be different from $\mathbf { \delta } _ { \mathbf { { a } } } l$ if the timing of arrival spikes changes. According to Equation 1, the ANN output $\pmb { a } ^ { l } = \pmb { W } ^ { l } \pmb { a } ^ { l - 1 } = [ 2 , - 2 ] [ 0 . 6 , 0 . 4 ] ^ { T } = 0 . 4$ . As for SNN, supposing that the threshold $\theta ^ { l } = 1$ , there are three possible output firing rates, which are illustrated in Figure 1 (b)-(d). If the two presynaptic neurons fires at $t = 1 , 3 , 5$ and $t = 2 , 4$ (red bars) respectively with weights 2 and -2, the postsynaptic neuron will fire two spikes at $t = 1 , 3$ (red bars), and $\begin{array} { r } { \phi ^ { l } ( T ) = \frac { \sum _ { i = 1 } ^ { T } s ^ { l } \bar { ( i ) } } { T } \theta ^ { l } = 0 . 4 = a ^ { l } } \end{array}$ . However, if the presynaptic neurons fires at $t = 1 , 2 , 3$ and $t = 4 , 5$ , respectively, the postsynaptic neuron will fire four spikes at $t = 1 , 2 , 3 , 4$ , and $\phi ^ { l } ( T ) = 0 . 8 > a ^ { l }$ . If the presynaptic neurons fires at $t = 3 , 4 , 5$ and $t = 1 , 2$ , respectively, the postsynaptic neuron will fire only one spikes at $t = 5$ , and $\phi ^ { l } ( T ) = 0 . 2 < a ^ { l }$ .
104
+
105
+ Note that the clipping error and quantization error have been proposed in Li et al. (2021). There exist interdependence between the above three kinds of errors. Specifically, the unevenness error will degenerate to the quantization error if $v ^ { l } ( T )$ is in the range of $[ 0 , \theta ^ { l } ]$ . Assuming that the potential $v ^ { l } \breve { ( T ) }$ falls into $[ 0 , \dot { \theta } ^ { l } ]$ will enable us to estimate the activation function of SNNs ignoring the effect of unevenness error. Therefore, an estimation of the output value $\phi ^ { l } ( T )$ in a converted SNN can be formulated with the combination of clip function and floor function, that is:
106
+
107
+ $$
108
+ \phi ^ { l } ( T ) \approx \theta ^ { l } \exp \left( \frac { 1 } { T } \left\lfloor \frac { z ^ { l } T + v ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor , 0 , 1 \right) .
109
+ $$
110
+
111
+ The detailed derivation is in the Appendix. With the help of this estimation for the SNN output, the estimated conversion error $\widetilde { E r r } ^ { l }$ can be derived from Equation 9:
112
+
113
+ $$
114
+ \widetilde { E r r } ^ { l } = \theta ^ { l } \mathrm { c l i p } \left( \frac { 1 } { T } \left\lfloor \frac { z ^ { l } T + v ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor , 0 , 1 \right) - h ( z ^ { l } ) \approx E r r ^ { l } .
115
+ $$
116
+
117
+ ![](images/db665824bf0d4b31c8f99401b9613f1d2153332bb2e2e0ef3cf82f91d01e5b41.jpg)
118
+ Figure 2: Comparison of SNN output $\phi ^ { l } ( T )$ and ANN output $\mathbf { \delta } _ { \mathbf { { a } } } l$ with same input $z ^ { l }$
119
+
120
+ # 4 OPTIMAL ANN-SNN CONVERSION
121
+
122
+ # 4.1 QUANTIZATION CLIP-FLOOR ACTIVATION FUNCTION
123
+
124
+ According to the conversion error of Equation 12, it is natural to think that if the commonly used ReLU activation function $h ( z ^ { l } )$ is substituted by a clip-floor function with a given quantization steps $L$ (similar to Equation 11), the conversion error at time-steps $T = L$ will be eliminated. Thus the performance degradation problem at low latency will be solved. As shown in Equation 13, we proposed the quantization clip-floor activation function to train ANNs.
125
+
126
+ $$
127
+ a ^ { l } = \bar { h } ( z ^ { l } ) = \lambda ^ { l } \mathrm { c l i p } \left( \frac { 1 } { L } \left\lfloor \frac { z ^ { l } L } { \lambda ^ { l } } \right\rfloor , 0 , 1 \right) ,
128
+ $$
129
+
130
+ where the hyperparameter $L$ denotes quantization steps of ANNs, the trainable $\lambda ^ { l }$ decides the maximum value of $\mathbf { \delta } _ { \mathbf { { a } } } l$ in ANNs mapped to the maximum of $\phi ^ { l } ( T )$ in SNNs. Note that $z ^ { l } =$ $W ^ { l } \phi ^ { l - 1 } ( T ) = W ^ { l } a ^ { l - 1 }$ . With this new activation function, we can prove that the estimated conversion error between SNNs and ANNs is zero, and we have the following Theorem.
131
+
132
+ Theorem 1. An ANN with activation function (13) is converted to an SNN with the same weights. If $T = L$ , $\theta ^ { l } = \lambda ^ { l }$ , and ${ \pmb v } ^ { l } ( 0 ) = { \bf 0 }$ , then:
133
+
134
+ $$
135
+ \widetilde { E r r } ^ { l } = \phi ^ { l } ( T ) - a ^ { l } = 0 .
136
+ $$
137
+
138
+ Proof. According to Equation 12, and the conditions $T = L , \theta ^ { l } = \lambda ^ { l } , \pmb { v } ^ { l } ( 0 ) = \mathbf { 0 }$ , we have $\widetilde { \pmb { E r r } } ^ { l } =$ $\begin{array} { r } { \phi ^ { l } ( T ) - a ^ { l } = \theta ^ { l } \mathrm { c l i p } \left( \frac { 1 } { T } \left\lfloor \frac { z ^ { l } T + v ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor , 0 , 1 \right) - \lambda ^ { l } \mathrm { c l i p } \left( \frac { 1 } { L } \left\lfloor \frac { z ^ { l } L } { \lambda ^ { l } } \right\rfloor , 0 , 1 \right) = 0 . } \end{array}$ .
139
+
140
+ Theorem 1 implies that if the time-steps $T$ of the converted SNN is the same as the quantization steps $L$ of the source ANN, the conversion error will be zero. An example is illustrated in Figure 2a, where $T = L = 4$ , $\theta ^ { l } = \lambda ^ { l }$ . The red curve presents the estimated output $\phi ^ { l } ( T )$ of the converted SNNs with respective to different input $z ^ { l }$ , while the green curve represents the out $\mathbf { \delta } _ { \mathbf { { a } } } l$ of the source ANN with respective to different input $z ^ { l }$ . As the two curve are the same, the estimated conversion error $\widetilde { E r r } ^ { l }$ is zero. Nevertheless, in practical application, we focus on the performance of SNNs at different time-steps. There is no guarantee that the conversion error is zero when $T$ is not equal to $L$ . As illustrated in Figure 2b, where $L = 4$ and $L = 8$ , we can find the conversion error is greater than zero for some $z ^ { l }$ . This error will transmit layer-by-layer and eventually degrading the accuracy of the converted SNN. One way to solve this problem is to train multiple source ANNs with different quantization steps, then convert them to SNNs with different time-steps, but it comes at a considerable cost. In the next section, we propose the quantization clip-floor activation function with a shift term to solve this problem. Such an approach can achieve high accuracy for different time-steps, without extra computation cost.
141
+
142
+ # 4.2 QUANTIZATION CLIP-FLOOR-SHIFT ACTIVATION FUNCTION
143
+
144
+ We propose the quantization clip-floor-shift activation function to train ANNs.
145
+
146
+ $$
147
+ a ^ { l } = \widehat { h } ( z ^ { l } ) = \lambda ^ { l } \mathrm { c l i p } \left( \frac { 1 } { L } \left\lfloor \frac { z ^ { l } L } { \lambda ^ { l } } + \varphi \right\rfloor , 0 , 1 \right) .
148
+ $$
149
+
150
+ Compared with Equation 13, there exists a hyperparameter vector $\varphi$ that controls the shift of the activation function. When $L \neq T$ , we cannot guarantee the conversion error is 0. However, we can estimate the expectation of conversion error. Similar to (Deng & Gu, 2020), we assume that $z _ { i } ^ { l }$ is uniformly distributed within intervals $[ ( t - 1 ) \lambda ^ { l } / T , ( t ) \lambda ^ { l } / T ]$ and $[ ( l - 1 ) \lambda ^ { l } / L , ( l ) \lambda ^ { l } / L ]$ for $t = 1 , 2 , . . . , T$ and $L = 1 , 2 , . . . , L$ , we have the following Theorem.
151
+
152
+ Theorem 2. An ANN with activation function $( I 5 )$ is converted to an SNN with the same weights. $I f \theta ^ { l } = \lambda ^ { l }$ , ${ \pmb v } ^ { l } ( 0 ) = \theta ^ { l } { \pmb \varphi }$ , then for arbitrary $T$ and $L$ , the expectation of conversion error reaches 0 when the shift term $\varphi$ in source ANN is $\frac { \mathbf { 1 } } { \mathbf { 2 } }$
153
+
154
+ $$
155
+ \forall T , L \quad \mathbb { E } _ { z } \left( \widetilde { E r r } ^ { l } \right) \Big | _ { \varphi = \frac { 1 } { 2 } } = \mathbf { 0 } .
156
+ $$
157
+
158
+ The proof is in the Appendix. Theorem 2 indicates that the shift term $\frac { \mathbf { 1 } } { \mathbf { 2 } }$ is able to optimize the expectation of conversion error. By comparing Figure 2b and Figure 2c, we can find that when the shift term $\varphi = \mathbf { 0 . 5 }$ is added, the mean conversion error reaches zero, even though $L \neq T$ . These results indicate we can achieve high-performance converted SNN at ultra-low time-steps.
159
+
160
+ $L$ is the only undetermined hyperparameter of the quantization clip-floor-shift activation. When $T = L$ , the conversion error reaches zero. So we naturally think that the parameter $L$ should be set as small as possible to get better performance at low time-steps. However, a too low quantization of the activation function will decrease the model capacity and further lead to accuracy loss when the time-steps is relatively large. Choosing the proper $L$ is a trade-off between the accuracy at low latency and the best accuracy of SNNs. We will further analyze the effects of quantization steps $L$ in the experiment section.
161
+
162
+ # 4.3 ALGORITHM FOR TRAINING QUANTIZATION CLIP-FLOOR-SHIFT ACTIVATION FUNCTION
163
+
164
+ Training an ANN with quantization clip-floor-shift activation instead of ReLU is also a tough problem. To direct train the ANN, we use the straight-through estimator (Bengio et al., 2013) for the derivative of the floor function, that is ${ \frac { \operatorname { d } \lfloor x \rfloor } { \operatorname { d } x } } = 1$ . The overall derivation rule is given in Equation 17.
165
+
166
+ $$
167
+ \frac { \partial \widehat { h } _ { i } ( z ^ { l } ) } { \partial z _ { i } ^ { l } } = \left\{ \begin{array} { l l } { 1 , \mathrm { ~ i f ~ } - \frac { \lambda ^ { l } } { 2 L } < z _ { i } ^ { l } < \lambda ^ { l } - \frac { \lambda ^ { l } } { 2 L } } \\ { 0 , \mathrm { ~ o t h e r w i s e } } \end{array} \right. , \frac { \partial \widehat { h } _ { i } ( z ^ { l } ) } { \partial \lambda ^ { l } } & = \left\{ \begin{array} { l l } { \frac { 1 } { 2 L } , \mathrm { ~ i f ~ } } & { - \frac { \lambda ^ { l } } { 2 L } < z _ { i } ^ { l } < \lambda ^ { l } - \frac { \lambda ^ { l } } { 2 L } } \\ { - \frac { z _ { i } ^ { l } } { ( \lambda ^ { l } ) ^ { 2 } } , \mathrm { ~ o t h e r w i s e } } \end{array} \right.
168
+ $$
169
+
170
+ Here $z _ { i } ^ { l }$ is the i-th element of $z ^ { l }$ . Then we can train the ANN with quantization clip-floor-shift activation using Stochastic Gradient Descent algorithm (Bottou, 2012).
171
+
172
+ # 5 RELATED WORK
173
+
174
+ The study of ANN-SNN conversion is first launched by Cao et al. (2015). Then Diehl et al. (2015) converted a three-layer CNN to an SNN using data-based and model-based normalization. To obtain high-performance SNNs for complex datasets and deeper networks, Rueckauer et al. (2016) and Sengupta et al. (2019) proposed more accurate scaling methods to normalize weights and scale thresholds respectively, which were later proved to be equivalent (Ding et al., 2021). Nevertheless, the converted deep SNN requires hundreds of time steps to get accurate results due to the conversion error analyzed in Sec. 3. To address the potential information loss, Rueckauer et al. (2016) and Han et al. (2020) suggested using “reset-by-subtraction” neurons rather than “reset-to-zero” neurons. Recently, many methods have been proposed to eliminate the conversion error. Rueckauer et al. (2016) recommended $9 9 . 9 \%$ percentile of activations as scale factors, and Ho & Chang (2020) added the trainable clipping layer. Besides, Han et al. (2020) rescaled the SNN thresholds to avoid the improper activation of spiking neurons. Massa et al. (2020) and Singh et al. (2021) evaluated the performance of converted SNNs on the Loihi Neuromorphic Processor. Our work share similarity with Deng & Gu (2020); Li et al. (2021), which also shed light on the conversion error. Deng & Gu (2020) minimized the layer-wise error by introducing extra bias in addition to the converted SNN biases. Li et al. (2021) further proposed calibration for weights and biases using quantized fine-tuning. They got good results with 16 and 32 time-steps without trails for more extreme time-steps. In comparison, our work aims to fit ANN into SNN with techniques eliminating the mentioned conversion error. The end-to-end training of quantization layers is implemented to get better overall performance. Our shift correction can lead to a single SNN which performs well at both ultra-low and large time-steps. Maintaining SNN performance within extremely few time-steps is difficult even for supervised learning methods like backpropagation through time (BPTT). BPTT usually requires fewer time-steps because of thorough training, yet at the cost of heavy GPU computation (Wu et al., 2018; 2019; Lee et al., 2016; Neftci et al., 2019; Lee et al., 2020; Zenke & Vogels, 2021). The timing-based backpropagation methods (Bohte et al., 2002; Tavanaei et al., 2019; Kim et al., 2020) could train SNNs over a very short temporal window, e.g. over 5-10 time-steps. However, they are usually limited to simple datasets like MNIST (Kheradpisheh & Masquelier, 2020) and CIFAR10 (Zhang & Li, 2020). Rathi et al. (2019) shortened simulation steps by initializing SNN with conversion method and then tuning SNN with STDP. In this paper, the proposed method achieves high-performance SNNs with ultra-low latency (4 time-steps).
175
+
176
+ ![](images/71f45fc75aa973a87550512c764093d0046e5d8cc9006d582b67d81062d4fda4.jpg)
177
+ Figure 3: Compare ANNs accuracy.
178
+
179
+ # 6 EXPERIMENTS
180
+
181
+ In this section, we validate the effectiveness of our method and compare our method with other state-of-the-art approaches for image classification tasks on CIFAR-10 (LeCun et al., 1998), CIFAR100 (Krizhevsky et al., 2009), and ImageNet datasets (Deng et al., 2009). Similar to previous works, we utilize VGG-16 (Simonyan & Zisserman, 2014), ResNet-18 (He et al., 2016), and ResNet-20 network structures for source ANNs. We compare our method with the state-of-the-art ANN-SNN conversion methods, including Hybrid-Conversion (HC) from Rathi et al. (2019), RMP from Han et al. (2020), TSC from Han & Roy (2020), RNL from Ding et al. (2021), ReLUThresholdShift (RTS) from Deng & Gu (2020), and SNN Conversion with Advanced Pipeline (SNNC-AP) from Li et al. (2021). Comparison with different SNN training methods is also included to manifest the superiority of low latency inference, including HybridConversion-STDB (HC-STDB) from Rathi et al. (2019), STBP from Wu et al. (2018), DirectTraining (DT) from Wu et al. (2019), and TSSL from Zhang & Li (2020). The details of the proposed ANN-SNN algorithm and training configurations are provided in the Appendix.
182
+
183
+ # 6.1 TEST ACCURACY OF ANN WITH QUANTIZATION CLIP-FLOOR-SHIFT ACTIVATION
184
+
185
+ We first compare the performance of ANNs with quantization clip-floor activation (green curve), ANNs with quantization clip-floor-shift activation (blue curve), and original ANNs with ReLU activation (black dotted line). Figure 3(a)-(d) report the results about VGG-16 on CIFAR-10, ResNet-20 on CIFAR-10, VGG-16 on CIFAR-100 and ResNet-20 on CIFAR-100. The performance of ANNs with quantization clip-floor-shift activation is better than ANNs with quantization clip-floor activation. These two ANNs can achieve the same performance as original ANNs with ReLU activation when $L > 4$ . These results demonstrate that our quantization clip-floor-shift activation function hardly affects the performance of ANN.
186
+
187
+ # 6.2 COMPARISON WITH THE STATE-OF-THE-ART
188
+
189
+ Table 2 compares our method with the state-of-the-art ANN-SNN conversion methods on CIFAR10. As for low latency inference $\mathrm { ( T \leq 6 4 ) }$ ), our model outperforms all the other methods with the same time-step setting. For $\mathrm { T } = 3 2$ , the accuracy of our method is slightly better than that of ANN $( 9 5 . 5 4 \%$ vs. $9 5 . 5 2 \%$ ), whereas RMP, RTS, RNL, and SNNC-AP methods have accuracy loss of $3 3 . 3 \%$ , $1 9 . 4 8 \%$ , $7 . 4 2 \%$ , and $2 . 0 1 \%$ . Moreover, we achieve an accuracy of $9 3 . 9 6 \%$ using only 4 time-steps, which is 8 times faster than SNNC-AP that takes 32 time-steps. For ResNet-20, we achieve an accuracy of $8 3 . 7 5 \%$ with 4 time-steps. Notably, our ultra-low latency performance is comparable with other state-of-the-art supervised training methods, which is shown in Table S3 of the Appendix.
190
+
191
+ ![](images/95126425a463e43e70bdb2a808a89ade125d9a3014f499e05ecfb28a9caf2fdf.jpg)
192
+ Figure 4: Compare quantization clip-floor activation with/without shift term
193
+
194
+ Table 2: Comparison between the proposed method and previous works on CIFAR-10 dataset.
195
+
196
+ <table><tr><td>Architecture</td><td>Method</td><td>ANN</td><td>T=2</td><td>T=4</td><td>T=8</td><td>T=16</td><td>T=32</td><td>T=64</td><td>T≥512</td></tr><tr><td rowspan="6">VGG-16</td><td>RMP</td><td>93.63%</td><td></td><td>-</td><td>二</td><td>-</td><td>60.30%</td><td>90.35%</td><td>93.63%</td></tr><tr><td>TSC</td><td>93.63%</td><td></td><td>二</td><td>-</td><td>-</td><td>-</td><td>92.79%</td><td>93.63%</td></tr><tr><td>RTS</td><td>95.72%</td><td></td><td>二</td><td>二</td><td>-</td><td>76.24%</td><td>90.64%</td><td>95.73%</td></tr><tr><td>RNL</td><td>92.82%</td><td>-</td><td>二</td><td>二</td><td>57.90%</td><td>85.40%</td><td>91.15%</td><td>92.95%</td></tr><tr><td>SNNC-AP</td><td>95.72%</td><td>-</td><td>-</td><td>-</td><td>-</td><td>93.71%</td><td>95.14%</td><td>95.79%</td></tr><tr><td>Ours</td><td>95.52%</td><td>91.18%</td><td>93.96%</td><td>94.95%</td><td>95.40%</td><td>95.54%</td><td>95.55%</td><td>95.59%</td></tr><tr><td rowspan="3">ResNet-20</td><td>RMP</td><td>91.47%</td><td>=</td><td>二</td><td></td><td>二</td><td>二</td><td></td><td>91.36%</td></tr><tr><td>TSC</td><td>91.47%</td><td>:</td><td>-</td><td>-</td><td>-</td><td>-</td><td>69.38%</td><td>91.42%</td></tr><tr><td>Ours</td><td>91.77%</td><td>73.20%</td><td>83.75%</td><td>89.55%</td><td>91.62%</td><td>92.24%</td><td>92.35%</td><td>92.41%</td></tr><tr><td rowspan="3">ResNet-18</td><td>RTS</td><td>95.46%</td><td>-</td><td>-</td><td>■</td><td>-</td><td>84.06%</td><td>92.48%</td><td>94.42%</td></tr><tr><td>SNNC-AP1</td><td>95.46%</td><td>-</td><td>■</td><td>-</td><td>-</td><td>94.78%</td><td>95.30%</td><td>95.45%</td></tr><tr><td>Ours</td><td>96.04%</td><td>75.44%</td><td>90.43%</td><td>94.82%</td><td>95.92%</td><td>96.08%</td><td>96.06%</td><td>96.06%</td></tr></table>
197
+
198
+ 1 RTS and SNNC-AP use altered ResNet-18, while ours use standard ResNet-18.
199
+
200
+ We further test the performance of our method on the large-scale dataset. Table 3 reports the results on ImageNet, our method also outperforms the others both in terms of high accuracy and ultra-low latency. For ResNet-34, the accuracy of the proposed method is $4 . 8 3 \%$ higher than SNNC-AP and $6 9 . 2 8 \%$ higher than RTS when $T = 3 2$ . When the time-steps is 16, we can still achieve an accuracy of $5 9 . 3 5 \%$ . For VGG-16, the accuracy of the proposed method is $4 . 8 3 \%$ higher than SNNC-AP and $6 8 . 3 5 6 \%$ higher than RTS when $T = 3 2$ . When the time-steps is 16, we can still achieve an accuracy of $5 0 . 9 7 \%$ . These results demonstrate that our method outperforms the previous conversion methods. More experimental results on CIFAR-100 is in Table S4 of the Appendix.
201
+
202
+ # 6.3 COMPARISON OF QUANTIZATION CLIP-FLOOR AND QUANTIZATION CLIP-FLOOR-SHIFT
203
+
204
+ Here we further compare the performance of SNNs converted from ANNs with quantization clipfloor activation and ANN with quantization clip-floor-shift activation. In Sec. 4, we prove that the expectation of the conversion error reaches 0 with quantization clip-floor-shift activation, no matter whether $T$ and $L$ are the same or not. To verify these, we set $L$ to 4 and train ANNs with quantization clip-floor activation and quantization clip-floor-shift activation, respectively. Figure 4 shows how the accuracy of converted SNNs changes with respect to the time-steps $T$ . The accuracy of the converted SNN (green curve) from ANN with quantization clip-floor activation (green dotted line) first increases and then decreases rapidly with the increase of time-steps, because we cannot guarantee that the conversion error is zero when $T$ is not equal to $L$ . The best performance is still lower than source ANN (green dotted line). In contrast, the accuracy of the converted SNN from ANN with quantization clip-floor-shift activation (blue curve) increases with the increase of $T$ . It gets the same accuracy as source ANN (blue dotted line) when the time-steps is larger than 16.
205
+
206
+ # 6.4 EFFECT OF QUANTIZATION STEPS L
207
+
208
+ In our method, the quantization steps $L$ is a hyperparameter, which affects the accuracy of the converted SNN. To analyze the effect of $L$ and better determine the optimal value, we train VGG16/ResNet-20 networks with quantization clip-floor-shift activation using different quantization steps L, including 2,4,8,16 and 32, and then converted them to SNNs. The experimental results on CIFAR-10/100 dataset are shown in Table S2 and Figure 5, where the black dotted line denotes the ANN accuracy and the colored curves represent the accuracy of the converted SNN. In order to balance the trade-off between low latency and high accuracy, we evaluate the performance of converted SNN mainly in two aspects. First, we focus on the SNN accuracy at ultra-low latency (within 4 time-steps). Second, we consider the best accuracy of SNN. It is obvious to find that the SNN accuracy at ultra-low latency decreases as $L$ increases. However, a too small $L$ will decrease the model capacity and further lead to accuracy loss. When $L = 2$ , there exists a clear gap between the best accuracy of SNN and source ANN. The best accuracy of SNN approaches source ANN when $L > 4$ . In conclusion, the setting of parameter $L$ mainly depends on the aims for low latency or best accuracy. The recommend quantization step $L$ is 4 or 8, which leads to high-performance converted SNN at both small time-steps and very large time-steps.
209
+
210
+ ![](images/a0e15e069bb677f5dc4c944811f1eefdec45882c3bc1ae8c1dc7fb8a5b3c2dba.jpg)
211
+ Figure 5: Influence of different quantization steps
212
+
213
+ Table 3: Comparison between the proposed method and previous works on ImageNet dataset.
214
+
215
+ <table><tr><td>Architecture</td><td>Method</td><td>ANN</td><td>T=16</td><td>T=32</td><td>T=64</td><td>T=128</td><td>T=256</td><td>T≥1024</td></tr><tr><td rowspan="5">ResNet-34</td><td>RMP</td><td>70.64%</td><td>-</td><td>二</td><td>二</td><td>二</td><td>-</td><td>65.47%</td></tr><tr><td>TSC</td><td>70.64%</td><td>-</td><td>-</td><td>:</td><td>-</td><td>61.48%</td><td>65.10%</td></tr><tr><td>RTS</td><td>75.66%</td><td>-</td><td>0.09%</td><td>0.12%</td><td>3.19%</td><td>47.11%</td><td>75.08%</td></tr><tr><td>SNNC-AP</td><td>75.66%</td><td>-</td><td>64.54%</td><td>71.12%</td><td>73.45%</td><td>74.61%</td><td>75.45%</td></tr><tr><td>Ours</td><td>74.32%</td><td>59.35%</td><td>69.37%</td><td>72.35%</td><td>73.15%</td><td>73.37%</td><td>73.39%</td></tr><tr><td rowspan="5">VGG-16</td><td>RMP</td><td>73.49%</td><td>-</td><td>-</td><td>-</td><td>-</td><td>48.32%</td><td>73.09%</td></tr><tr><td>TSC</td><td>73.49%</td><td>1</td><td>-</td><td>-</td><td>-</td><td>69.71%</td><td>73.46%</td></tr><tr><td>RTS</td><td>75.36%</td><td>1</td><td>0.114%</td><td>0.118%</td><td>0.122%</td><td>1.81%</td><td>73.88%</td></tr><tr><td>SNNC-AP</td><td>75.36%</td><td>-</td><td>63.64%</td><td>70.69%</td><td>73.32%</td><td>74.23%</td><td>75.32%</td></tr><tr><td>Ours</td><td>74.29%</td><td>50.97%</td><td>68.47%</td><td>72.85%</td><td>73.97%</td><td>74.22%</td><td>74.32%</td></tr></table>
216
+
217
+ # 7 DISCUSSION AND CONCLUSION
218
+
219
+ In this paper, we present ANN-SNN conversion method, enabling high-accuracy and ultra-lowlatency deep SNNs. We propose the quantization clip-floor-shift activation to replace ReLU activation, which hardly affects the performance of ANNs and is closer to SNNs activation. Furthermore, we prove that the expected conversion error is zero, no matter whether the time-steps of SNNs and the quantization steps of ANNs is the same or not. We achieve state-of-the-art accuracy with fewer time-steps on CIFAR-10, CIFAR-100, and ImageNet datasets. Our results can benefit the implementations on neuromorphic hardware and pave the way for the large-scale application of SNNs.
220
+
221
+ Different from the work of Deng & Gu (2020), which adds the bias of the converted SNNs to shift the theoretical ANN-SNN curve to minimize the quantization error, we add the shift term in the quantization clip-floor activation function, and use this quantization clip-floor-shift function to train the source ANN. We show that the shift term can overcome the performance degradation problem when the time-steps and the quantization steps are not matched. Due to the unevenness error, there still exists a gap between ANN accuracy and SNN accuracy, even when $L = T$ . Moreover, it is hard to achieve high-performance ANN-SNN conversion when the time-steps $T = 1$ . All these problems deserve further research. One advantage of conversion-based methods is that they can reduce the overall computing cost while maintaining comparable performance as source ANN. Combining the conversion-based methods and model compression may help significantly reduce the neuron activity and thus reduce energy consumptions without suffering from accuracy loss (Kundu et al., 2021; Rathi & Roy, 2021), which is a promising direction.
222
+
223
+ # ACKNOWLEDGEMENT
224
+
225
+ This work was supported by the National Natural Science Foundation of China under contracts No.62176003 and No.62088102.
226
+
227
+ # REFERENCES
228
+
229
+ Yoshua Bengio, Nicholas Leonard, and Aaron Courville. Estimating or propagating gradients ´ through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013.
230
+
231
+ Sander M Bohte, Joost N Kok, and Han La Poutre. Error-backpropagation in temporally encoded networks of spiking neurons. Neurocomputing, 48(1-4):17–37, 2002.
232
+
233
+ Leon Bottou. Stochastic gradient descent tricks. In ´ Neural networks: Tricks of the trade, pp. 421– 436. Springer, 2012.
234
+
235
+ Yongqiang Cao, Yang Chen, and Deepak Khosla. Spiking deep convolutional neural networks for energy-efficient object recognition. International Journal of Computer Vision, 113(1):54–66, 2015.
236
+
237
+ Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation strategies from data. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 113–123, 2019.
238
+
239
+ Mike Davies, Narayan Srinivasa, Tsung-Han Lin, Gautham Chinya, Yongqiang Cao, Sri Harsha Choday, Georgios Dimou, Prasad Joshi, Nabil Imam, Shweta Jain, et al. Loihi: A neuromorphic manycore processor with on-chip learning. IEEE Micro, 38(1):82–99, 2018.
240
+
241
+ Michael V DeBole, Brian Taba, Arnon Amir, Filipp Akopyan, Alexander Andreopoulos, William P Risk, Jeff Kusnitz, Carlos Ortega Otero, Tapan K Nayak, Rathinakumar Appuswamy, et al. TrueNorth: Accelerating from zero to 64 million neurons in 10 years. Computer, 52(5):20–29, 2019.
242
+
243
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 248–255. Ieee, 2009.
244
+
245
+ Shikuang Deng and Shi Gu. Optimal conversion of conventional artificial neural networks to spiking neural networks. In International Conference on Learning Representations, 2020.
246
+
247
+ Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017.
248
+
249
+ Peter U Diehl, Daniel Neil, Jonathan Binas, Matthew Cook, Shih-Chii Liu, and Michael Pfeiffer. Fast-classifying, high-accuracy spiking deep networks through weight and threshold balancing. In International Joint Conference on Neural Networks, pp. 1–8, 2015.
250
+
251
+ Jianhao Ding, Zhaofei Yu, Yonghong Tian, and Tiejun Huang. Optimal ann-snn conversion for fast and accurate inference in deep spiking neural networks. In International Joint Conference on Artificial Intelligence, pp. 2328–2336, 2021.
252
+
253
+ Wei Fang, Zhaofei Yu, Yanqi Chen, Tiejun Huang, Timothee Masquelier, and Yonghong Tian. Deep ´ residual learning in spiking neural networks. arXiv preprint arXiv:2102.04159, 2021.
254
+
255
+ Bing Han and Kaushik Roy. Deep spiking neural network: Energy efficiency through time based coding. In European Conference on Computer Vision, pp. 388–404, 2020.
256
+
257
+ Bing Han, Gopalakrishnan Srinivasan, and Kaushik Roy. RMP-SNN: Residual membrane potential neuron for enabling deeper high-accuracy and low-latency spiking neural network. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 13558–13567, 2020.
258
+
259
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In IEEE conference on Computer Vision and Pattern Recognition, pp. 770–778, 2016.
260
+
261
+ Nguyen-Dong Ho and Ik-Joon Chang. Tcl: an ann-to-snn conversion with trainable clipping layers. arXiv preprint arXiv:2008.04509, 2020.
262
+
263
+ Eugene M Izhikevich. Simple model of spiking neurons. IEEE Transactions on neural networks, 14(6):1569–1572, 2003.
264
+
265
+ Saeed Reza Kheradpisheh and Timothee Masquelier. Temporal backpropagation for spiking neural ´ networks with one spike per neuron. International Journal of Neural Systems, 30(06):2050027, 2020.
266
+
267
+ Jinseok Kim, Kyungsu Kim, and Jae-Joon Kim. Unifying activation- and timing-based learning rules for spiking neural networks. In Advances in Neural Information Processing Systems, pp. 19534–19544, 2020.
268
+
269
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
270
+
271
+ Souvik Kundu, Gourav Datta, Massoud Pedram, and Peter A Beerel. Spike-thrift: Towards energyefficient deep spiking neural networks by limiting spiking activity via attention-guided compression. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 3953–3962, 2021.
272
+
273
+ Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
274
+
275
+ Chankyu Lee, Syed Shakib Sarwar, Priyadarshini Panda, Gopalakrishnan Srinivasan, and Kaushik Roy. Enabling spike-based backpropagation for training deep neural network architectures. Frontiers in Neuroscience, 14, 2020.
276
+
277
+ Jun Haeng Lee, Tobi Delbruck, and Michael Pfeiffer. Training deep spiking neural networks using backpropagation. Frontiers in Neuroscience, 10:508, 2016.
278
+
279
+ Yuhang Li, Shikuang Deng, Xin Dong, Ruihao Gong, and Shi Gu. A free lunch from ann: Towards efficient, accurate spiking neural networks calibration. In International Conference on Machine Learning, pp. 6316–6325, 2021.
280
+
281
+ Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations, 2016.
282
+
283
+ Wolfgang Maass. Networks of spiking neurons: the third generation of neural network models. Neural Networks, 10(9):1659–1671, 1997.
284
+
285
+ Riccardo Massa, Alberto Marchisio, Maurizio Martina, and Muhammad Shafique. An efficient spiking neural network for recognizing gestures with a DVS camera on the Loihi neuromorphic processor. In International Joint Conference on Neural Networks, pp. 1–9, 2020.
286
+
287
+ Warren S McCulloch and Walter Pitts. A logical calculus of the ideas immanent in nervous activity. The Bulletin of Mathematical Biophysics, 5(4):115–133, 1943.
288
+
289
+ Paul A Merolla, John V Arthur, Rodrigo Alvarez-Icaza, Andrew S Cassidy, Jun Sawada, Filipp Akopyan, Bryan L Jackson, Nabil Imam, Chen Guo, Yutaka Nakamura, et al. A million spikingneuron integrated circuit with a scalable communication network and interface. Science, 345 (6197):668–673, 2014.
290
+
291
+ Emre O Neftci, Hesham Mostafa, and Friedemann Zenke. Surrogate gradient learning in spiking neural networks: Bringing the power of gradient-based optimization to spiking neural networks. IEEE Signal Processing Magazine, 36(6):51–63, 2019.
292
+
293
+ Jing Pei, Lei Deng, Sen Song, Mingguo Zhao, Youhui Zhang, Shuang Wu, Guanrui Wang, Zhe Zou, Zhenzhi Wu, Wei He, et al. Towards artificial general intelligence with hybrid tianjic chip architecture. Nature, 572(7767):106–111, 2019.
294
+
295
+ Ning Qiao, Hesham Mostafa, Federico Corradi, Marc Osswald, Fabio Stefanini, Dora Sumislawska, and Giacomo Indiveri. A reconfigurable on-line learning spiking neuromorphic processor comprising 256 neurons and 128K synapses. Frontiers in neuroscience, 9:141, 2015.
296
+
297
+ Nitin Rathi and Kaushik Roy. Diet-snn: A low-latency spiking neural network with direct input encoding and leakage and threshold optimization. IEEE Transactions on Neural Networks and Learning Systems, 2021.
298
+
299
+ Nitin Rathi, Gopalakrishnan Srinivasan, Priyadarshini Panda, and Kaushik Roy. Enabling deep spiking neural networks with hybrid conversion and spike timing dependent backpropagation. In International Conference on Learning Representations, 2019.
300
+
301
+ Kaushik Roy, Akhilesh Jaiswal, and Priyadarshini Panda. Towards spike-based machine intelligence with neuromorphic computing. Nature, 575(7784):607–617, 2019.
302
+
303
+ Bodo Rueckauer, Iulia-Alexandra Lungu, Yuhuang Hu, and Michael Pfeiffer. Theory and tools for the conversion of analog to spiking convolutional neural networks. arXiv preprint arXiv:1612.04052, 2016.
304
+
305
+ Bodo Rueckauer, Iulia-Alexandra Lungu, Yuhuang Hu, Michael Pfeiffer, and Shih-Chii Liu. Conversion of continuous-valued deep networks to efficient event-driven networks for image classification. Frontiers in Neuroscience, 11:682, 2017.
306
+
307
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
308
+
309
+ Abhronil Sengupta, Yuting Ye, Robert Wang, Chiao Liu, and Kaushik Roy. Going deeper in spiking neural networks: VGG and residual architectures. Frontiers in Neuroscience, 13:95, 2019.
310
+
311
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
312
+
313
+ Sonali Singh, Anup Sarma, Sen Lu, Abhronil Sengupta, Vijaykrishnan Narayanan, and Chita R Das. Gesture-snn: Co-optimizing accuracy, latency and energy of snns for neuromorphic vision sensors. In IEEE/ACM International Symposium on Low Power Electronics and Design, pp. 1–6, 2021.
314
+
315
+ Christoph Stockl and Wolfgang Maass. Optimized spiking neurons can classify images with high ¨ accuracy through temporal coding with two spikes. Nature Machine Intelligence, 3(3):230–238, 2021.
316
+
317
+ Amirhossein Tavanaei, Masoud Ghodrati, Saeed Reza Kheradpisheh, Timothee Masquelier, and ´ Anthony Maida. Deep learning in spiking neural networks. Neural Networks, 111:47–63, 2019.
318
+
319
+ Yujie Wu, Lei Deng, Guoqi Li, Jun Zhu, and Luping Shi. Spatio-temporal backpropagation for training high-performance spiking neural networks. Frontiers in Neuroscience, 12:331, 2018.
320
+
321
+ Yujie Wu, Lei Deng, Guoqi Li, Jun Zhu, Yuan Xie, and Luping Shi. Direct training for spiking neural networks: Faster, larger, better. In AAAI Conference on Artificial Intelligence, pp. 1311– 1318, 2019.
322
+
323
+ Friedemann Zenke and Tim P Vogels. The remarkable robustness of surrogate gradient learning for instilling complex function in spiking neural networks. Neural Computation, 33(4):899–925, 2021.
324
+
325
+ Wenrui Zhang and Peng Li. Temporal spike sequence learning via backpropagation for deep spiking neural networks. In Advances in Neural Information Processing Systems, pp. 12022–12033, 2020.
326
+
327
+ # A APPENDIX
328
+
329
+ # A.1 NETWORK STRUCTURE AND TRAINING CONFIGURATIONS
330
+
331
+ Before training ANNs, we first replace max-pooling with average-pooling and then replace the ReLU activation with the proposed quantization clip-floor-shift activation (Equation 15). After training, we copy all weights from the source ANN to the converted SNN, and set the threshold $\theta ^ { l }$ in each layer of the converted SNN equal to the maximum activation value $\lambda ^ { l }$ of the source ANN in the same layer. Besides, we set the initial membrane potential $\pmb { v } ^ { l } ( 0 )$ in converted SNN as $\theta ^ { l } / 2$ to match the optimal shift $\textstyle \varphi = { \frac { 1 } { 2 } }$ of quantization clip-floor-shift activation in the source ANN.
332
+
333
+ Despite the common data normalization, we use some data pre-processing techniques. For CIFAR datasets, we resize the images into $3 2 \times 3 2$ , and for ImageNet dataset, we resize the image into $2 2 4 \times 2 2 4$ . Besides, we use random crop images, Cutout (DeVries & Taylor, 2017) and AutoAugment (Cubuk et al., 2019) for all datasets.
334
+
335
+ We use the Stochastic Gradient Descent optimizer (Bottou, 2012) with a momentum parameter of 0.9. The initial learning rate is set to 0.1 for CIFAR-10 and ImageNet, and 0.02 for CIFAR-100. A cosine decay scheduler (Loshchilov & Hutter, 2016) is used to adjust the learning rate. We apply a $5 \times 1 0 ^ { - 4 }$ weight decay for CIFAR datasets while applying a $1 \times \mathrm { \bar { 1 0 } ^ { - 4 } }$ weight decay for ImageNet. We train all models for 300 epochs. The quantization steps $L$ is set to 4 when training all the networks on CIFAR-10, and VGG-16, ResNet-18 on CIFAR-100 dataset. When training ResNet-20 on CIFAR-100, the parameter $L$ is set to 8. When training ResNet-34 and VGG-16 on ImageNet, the parameter $L$ is set to 8, 16, respectively. We use constant input when evaluating the converted SNNs.
336
+
337
+ # A.2 INTRODUCTION OF DATASETS
338
+
339
+ CIFAR-10. The CIFAR-10 dataset (Krizhevsky et al., 2009) consists of $6 0 0 0 0 3 2 \times 3 2$ images in 10 classes. There are 50000 training images and 10000 test images.
340
+
341
+ CIFAR-100. The CIFAR-100 dataset (Krizhevsky et al., 2009) consists of $6 0 0 0 0 3 2 \times 3 2$ images in 100 classes. There are 50000 training images and 10000 test images.
342
+
343
+ ImageNet. We use the ILSVRC 2012 dataset (Russakovsky et al., 2015), which consists 1,281,167 training images and 50000 testing images.
344
+
345
+ # A.3 DERIVATION OF EQUATION 12 AND PROOF OF THEOREM 2
346
+
347
+ # Derivation of Equation 11
348
+
349
+ Similar to $z ^ { l } = W ^ { l } \mathbf { a } ^ { l - 1 }$ , We define
350
+
351
+ $$
352
+ \pmb { u } ^ { l } ( t ) = \pmb { W } ^ { l } \pmb { x } ^ { l - 1 } ( t ) .
353
+ $$
354
+
355
+ We use $u _ { i } ^ { l } ( t )$ and $z _ { i } ^ { l }$ to denote the $i$ -th element in vector ${ \pmb u } ^ { l } ( t )$ and $z ^ { l }$ , respectively. To derive Equation 11, some extra assumptions on the relationship between ANN activation value and SNN postsynaptic potentials are needed, which are showed in Equation S2.
356
+
357
+ $$
358
+ \left\{ \begin{array} { l l } & { \mathrm { i f ~ } z _ { i } ^ { l } < 0 , \mathrm { ~ t h e n } \forall t u _ { i } ^ { l } ( t ) < 0 , } \\ & { \mathrm { i f ~ } 0 \leqslant z _ { i } ^ { l } \leqslant \theta _ { l } , \mathrm { ~ t h e n } \forall t 0 \leqslant u _ { i } ^ { l } ( t ) \leqslant \theta _ { l } , } \\ & { \mathrm { i f ~ } z _ { i } ^ { l } > \theta _ { l } , \mathrm { ~ t h e n } \forall t u _ { i } ^ { l } ( t ) > \theta _ { l } . } \end{array} \right.
359
+ $$
360
+
361
+ With the assumption above, we can discuss the firing behavior of the neurons in each time-step. When $z _ { i } ^ { l } < 0$ or $\overline { { z _ { i } ^ { l } } } > \theta _ { l }$ , the neuron will never fire or fire all the time-steps, which means $\phi _ { i } ^ { l } ( T ) = \bar { 0 }$ or $\phi _ { i } ^ { l } ( T ) = \theta ^ { l }$ . In this situation, we can use a clip function to denote $\phi _ { i } ^ { l } ( T )$ .
362
+
363
+ $$
364
+ \phi _ { i } ^ { l } ( T ) = \mathrm { c l i p } ( z _ { i } ^ { l } , 0 , \theta ^ { l } ) .
365
+ $$
366
+
367
+ When $0 < z _ { i } ^ { l } < \theta _ { l }$ , every input from the presynaptic neuron in SNNs falls into $[ 0 , \theta ^ { l } ]$ , then we have $\forall t$ , $v _ { i } ^ { l } ( t ) \in [ 0 , \theta ]$ . We can rewrite Equation 8 into the following equation.
368
+
369
+ $$
370
+ \frac { \phi _ { i } ^ { l } ( T ) T } { \theta ^ { l } } = \frac { z _ { i } ^ { l } T + v _ { i } ^ { l } ( 0 ) } { \theta ^ { l } } - \frac { v _ { i } ^ { l } ( T ) } { \theta ^ { l } } .
371
+ $$
372
+
373
+ Considering that $\begin{array} { r } { \frac { \phi _ { i } ^ { l } ( T ) T } { \theta ^ { l } } = \sum _ { t = 1 } ^ { T } s _ { i } ^ { l } ( t ) \in \mathbb { N } } \end{array}$ and $\begin{array} { r } { 0 < \frac { v _ { i } ^ { l } ( T ) } { \theta ^ { l } } < 1 } \end{array}$ , Equation S4 is changed to:
374
+
375
+ $$
376
+ \phi _ { i } ^ { l } ( T ) = \frac { \theta ^ { l } } { T } \left\lfloor \frac { z _ { i } ^ { l } T + v _ { i } ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor .
377
+ $$
378
+
379
+ We combine these two situations (Equation S3 and Equation S4), and we have:
380
+
381
+ $$
382
+ \phi ^ { l } ( T ) = \theta ^ { l } \mathrm { c l i p } \left( \frac { 1 } { T } \left\lfloor \frac { z ^ { l } T + v ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor , 0 , 1 \right) .
383
+ $$
384
+
385
+ # Proof of Theorem 2
386
+
387
+ Before prove Theorem 2, we first introduce Lemma 1.
388
+
389
+ Lemma 1. If random variable $x \in [ 0 , \theta ]$ is uniformly distributed in every small interval $[ m _ { t } , m _ { t + 1 } ]$ with the probability density function $p _ { t }$ $( t = 0 , 1 , . . . , T )$ , where $\begin{array} { r } { m _ { 0 } = 0 , m _ { T + 1 } = \theta , m _ { t } = \frac { ( t - \frac { 1 } { 2 } ) \theta } { T } } \end{array}$ for $t = 1 , 2 , . . . , T$ , $p _ { 0 } = p _ { T }$ , we can conclude that
390
+
391
+ $$
392
+ \mathbb { E } _ { x } \left( x - { \frac { \theta } { T } } \left\lfloor { \frac { T x } { \theta } } + { \frac { 1 } { 2 } } \right\rfloor \right) = 0 .
393
+ $$
394
+
395
+ Proof.
396
+
397
+ $$
398
+ \begin{array} { l } { { \mathbb { E } _ { x } \left( x - \displaystyle \frac { \theta } { T } \left\lfloor \frac { T x } { \theta } + \frac { 1 } { 2 } \right\rfloor \right) = \int _ { 0 } ^ { \theta / 2 T } p _ { 0 } \left( x - \displaystyle \frac { \theta } { T } \left\lfloor \frac { x T } { \theta } + \frac { 1 } { 2 } \right\rfloor \right) \mathrm { d } x } } \\ { { \displaystyle + \sum _ { t = 1 } ^ { T - 1 } \int _ { ( 2 t - 1 ) \theta / 2 T } ^ { ( 2 t + 1 ) \theta / 2 T } p _ { t } \left( x - \displaystyle \frac { \theta } { T } \left\lfloor \frac { x T } { \theta } + \frac { 1 } { 2 } \right\rfloor \right) \mathrm { d } x } } \\ { { \displaystyle + \int _ { ( 2 T - 1 ) \theta / 2 T } ^ { \theta } p _ { T } \left( x - \displaystyle \frac { \theta } { T } \left\lfloor \frac { x T } { \theta } + \frac { 1 } { 2 } \right\rfloor \right) \mathrm { d } x } } \\ { { \displaystyle = p _ { 0 } \int _ { 0 } ^ { \theta / 2 T } x \mathrm { d } x + \sum _ { t = 1 } ^ { T - 1 } p _ { t } \int _ { ( 2 t - 1 ) \theta / 2 T } ^ { ( 2 t + 1 ) \theta / 2 T } \left( x - \displaystyle \frac { t \theta } { T } \right) \mathrm { d } x + p _ { T } \int _ { ( 2 T - 1 ) \theta / 2 T } ^ { \theta } \left( x - \theta \right) \mathrm { d } x } } \\ { { \displaystyle = p _ { 0 } \displaystyle \frac { \theta ^ { 2 } } { 8 \pi ^ { 2 } } + 0 - p _ { T } \displaystyle \frac { \theta ^ { 2 } } { 8 \pi T ^ { 2 } } = ( p _ { 0 } - p _ { T } ) \displaystyle \frac { \theta ^ { 2 } } { 8 \pi T ^ { 2 } } = 0 . } } \end{array}
399
+ $$
400
+
401
+ Theorem 2. An ANN with activation function (15) is converted to an SNN with the same weights. If $\theta ^ { l } = \lambda ^ { l }$ , ${ \pmb v } ^ { l } ( 0 ) = \theta ^ { l } { \pmb \varphi } ,$ , then for arbitrary $T$ and $L$ , the expectation of conversion error reaches 0 when the shift term $\varphi$ in source ANN is $\frac { \mathbf { 1 } } { \mathbf { 2 } }$ .
402
+
403
+ $$
404
+ \forall T , L \quad \mathbb { E } _ { z } \left( \widetilde { E r r } ^ { l } \right) \Big | _ { \varphi = \frac { 1 } { 2 } } = \mathbf { 0 } .
405
+ $$
406
+
407
+ Proof.
408
+
409
+ $$
410
+ \mathbb { E } _ { z } \left( \widetilde { E r r } ^ { l } \right) \Big | _ { \varphi = \frac { 1 } { 2 } } = \mathbb { E } _ { z } \left( \frac { \theta ^ { l } } { T } \left\lfloor \frac { z ^ { l } T + v ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor - \frac { \lambda ^ { l } } { L } \left\lfloor \frac { z ^ { l } L } { \lambda } + \varphi \right\rfloor \right) .
411
+ $$
412
+
413
+ ![](images/7cf3861caece577400098d510676308fbed5f338860acbffca1d7b84dcf79a1d.jpg)
414
+ Figure S1: More spikes than expected exists for the method of setting the maximum activation.
415
+
416
+ As every element in vector $_ { z }$ is identical, we only need to consider one element.
417
+
418
+ $$
419
+ \begin{array} { r l } & { \mathbb { E } _ { z _ { i } } \left( \displaystyle \frac { \theta ^ { l } } { T } \left\lfloor \displaystyle \frac { z _ { i } ^ { l } T + v _ { i } ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor - \displaystyle \frac { \lambda ^ { l } } { L } \left\lfloor \displaystyle \frac { z _ { i } ^ { l } L } { \lambda } + \varphi _ { i } \right\rfloor \right) } \\ & { = \mathbb { E } _ { z _ { i } } \left( \displaystyle \frac { \theta ^ { l } } { T } \left\lfloor \displaystyle \frac { z _ { i } ^ { l } T + v _ { i } ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor - z _ { i } ^ { l } \right) + \mathbb { E } _ { z _ { i } } \left( z _ { i } ^ { l } - \displaystyle \frac { \lambda ^ { l } } { L } \left\lfloor \displaystyle \frac { z _ { i } ^ { l } L } { \lambda } + \varphi _ { i } \right\rfloor \right) . } \end{array}
420
+ $$
421
+
422
+ According to Lemma 1, we have
423
+
424
+ $$
425
+ \begin{array} { r l } & { \mathbb { E } _ { z _ { i } } \left( \frac { \theta ^ { l } } { T } \left\lfloor \frac { z _ { i } ^ { l } T + v _ { i } ^ { l } ( 0 ) } { \theta ^ { l } } \right\rfloor - z _ { i } ^ { l } \right) \Big | _ { v _ { i } ^ { l } ( 0 ) = 1 / 2 } = 0 , } \\ & { \mathbb { E } _ { z _ { i } } \left( z _ { i } ^ { l } - \frac { \lambda ^ { l } } { L } \left\lfloor \frac { z _ { i } ^ { l } L } { \lambda } + \varphi _ { i } \right\rfloor \right) \Big | _ { \varphi = 1 / 2 } = 0 . } \end{array}
426
+ $$
427
+
428
+ Thus the sum of both terms also equals zero.
429
+
430
+ # A.4 COMPARISON OF THE METHODS WITH OR WITHOUT DYNAMIC THRESHOLD ON THE CIFAR-100 DATASET
431
+
432
+ In this paper we use a training parameter $\lambda ^ { l }$ to decide the maximum value of ANN activation. The previous works suggested to set the maximum value of ANN activation after training as the threshold. If we set $\theta ^ { l } = \operatorname* { m a x } _ { s \in \{ 0 , 1 \} ^ { n } }$ $\left( \operatorname* { m a x } ( \theta ^ { l - 1 } W ^ { l } s ) \right)$ , the situation of fewer spikes as expected never happens, as we can prove that $v ^ { l } ( T ) < \theta ^ { l }$ (see Theorem 3). Despite this, there still exists the situation of more spikes as expected. An example is given in Figure S1. Here we consider the same example as in Figure 1. In source ANN, we suppose that two analog neurons in layer $l - 1$ are connected to an analog neuron in layer $l$ with weights 2 and $^ { - 2 }$ , and the output vector $\mathbf { a } ^ { l - 1 }$ of neurons in layer $l - 1$ is [0.6, 0.4]. Besides, in converted SNN, we suppose that the two spiking neurons in layer $l - 1$ fire 3 spikes and 2 spikes in 5 time-steps $( \mathrm { T } { = } 5 )$ , respectively, and the threshold $\theta ^ { l - 1 } = 1$ . Thus, $\begin{array} { r } { \phi ^ { l - 1 } ( T ) \stackrel { - } { = } \frac { \sum _ { i = 1 } ^ { T } s ^ { l - \bar { 1 } } ( i ) } { T } \theta ^ { l - 1 } = [ 0 . 6 , 0 . 4 ] } \end{array}$ ]. According to Equation 1, the ANN output $\pmb { a } ^ { l } = \pmb { W } ^ { l } \pmb { a } ^ { l - 1 } = [ 2 , - 2 ] [ 0 . \bar { 6 } , 0 . 4 ] ^ { T } = 0 . 4$ . As for SNN, we suppose that the presynaptic neurons fires at $t = 1 , 2 , 3$ and $t = 4 , 5$ , respectively. Even through we set the threshold $\mathbf { \dot { \theta } } ^ { l } = 1$ to the maximum activation 2, the postsynaptic neuron will fire three spikes at $t = 1 , 2 , 3$ , and $\phi ^ { l } ( T ) = 0 . 6 > a ^ { l }$ .
433
+
434
+ Besides, setting $\operatorname* { m a x } _ { s \in \{ 0 , 1 \} ^ { n } }$ $\left( \operatorname* { m a x } ( \theta ^ { l - 1 } W ^ { l } s ) \right)$ as the threshold brings two other problems. First, the spiking neurons will take a long time to fire spikes because of the large value of the threshold, which makes it hard to maintain SNN performance within a few time-steps. Second, the quantization error will be large as it is proportional to the threshold. If the conversion error is not zero for one layer, it will propagate layer by layer and will be magnified by larger quantization errors. We compare our method and the method of setting the maximum activation on the CIFAR-100 dataset. The results are reported in Table S1, where DT represents the dynamic threshold in our method. The results show that our method can achieve better performance.
435
+
436
+ Table S1: Comparison between our method and the method of setting the maximum activation.
437
+
438
+ <table><tr><td></td><td>DT1w/o shift</td><td>T=4</td><td>T=8</td><td>T=16</td><td>T=32</td><td>T=64</td><td>T=128</td><td>T=256</td><td>T≥512</td></tr><tr><td></td><td colspan="9">VGG-16 on CIFAR-100 with L=4</td></tr><tr><td>√</td><td>√</td><td>69.62%</td><td>73.96%</td><td>76.24%</td><td>77.01%</td><td>77.10%</td><td>77.05%</td><td>77.08%</td><td>77.08%</td></tr><tr><td></td><td>&lt;×</td><td>21.57%</td><td>41.13%</td><td>58.92%</td><td>65.38%</td><td>64.19%</td><td>58.60%</td><td>52.99%</td><td>49.41%</td></tr><tr><td>×√</td><td></td><td>1.00%</td><td>0.96%</td><td>1.00%</td><td>1.10%</td><td>2.41%</td><td>13.76%</td><td>51.70%</td><td>77.10%</td></tr><tr><td>×</td><td>×</td><td>1.00%</td><td>1.00%</td><td>0.90%</td><td>1.00%</td><td>1.01%</td><td>2.01%</td><td>19.59%</td><td>70.86%</td></tr></table>
439
+
440
+ 1 Dynamic threshold.
441
+
442
+ Theorem 3. If the threshold is set to the maximum value of ANN activation, that is $\theta ^ { l } \ =$ $\operatorname* { m a x } _ { s \in \{ 0 , 1 \} ^ { n } }$ $\left( \operatorname* { m a x } ( \theta ^ { l - 1 } W ^ { l } s ) \right)$ , and $v _ { i } ^ { l } ( 0 ) < \theta ^ { l }$ . Then at any time-step, the membrane potential of each neuron after spike $v _ { i } ^ { l } ( t )$ will be less than $\theta ^ { l }$ , where $i$ represents the index of each neuron.
443
+
444
+ Proof. We prove it by induction. For $t = 0$ , it is easy to see $v _ { i } ^ { l } ( 0 ) < \theta ^ { l }$ . For $t > 0$ , we suppose that $v _ { i } ^ { l } ( t - 1 ) < \theta ^ { l }$ . Since we have set the threshold to the maximum possible input, and $x _ { i } ^ { l - 1 } ( t )$ represents the input from layer $l - 1$ to the $i$ -th neuron in layer $l$ , $x _ { i } ^ { l - 1 } ( t )$ will be no larger than $\theta ^ { l }$ for arbitrary $t$ . Thus we have
445
+
446
+ $$
447
+ \begin{array} { l } { { m _ { i } ^ { l } ( t ) = v _ { i } ^ { l } ( t - 1 ) + x _ { i } ^ { l - 1 } ( t ) < \theta ^ { l } + \theta ^ { l } = 2 \theta ^ { l } , } } \\ { { s _ { i } ^ { l } ( t ) = H ( m _ { i } ^ { l } ( t ) - \theta ^ { l } ) , } } \\ { { v _ { i } ^ { l } ( t ) = m _ { i } ^ { l } ( t ) - s _ { i } ^ { l } ( t ) \theta ^ { l } . } } \end{array}
448
+ $$
449
+
450
+ If $\theta ^ { l } \leqslant m _ { i } ^ { l } ( t ) < 2 \theta ^ { l }$ , then we have $v _ { i } ^ { l } ( t ) = m _ { i } ^ { l } ( t ) - \theta ^ { l } < \theta ^ { l }$ . If $m _ { i } ^ { l } ( t ) < \theta _ { l }$ , then $v _ { i } ^ { l } ( t ) = m _ { i } ^ { l } ( t ) < \theta _ { l }$ . By mathematical induction, $v _ { i } ^ { l } ( t ) < \mathsf { \bar { \theta } } ^ { l }$ holds for any $t \geqslant 0$ . □
451
+
452
+ # A.5 EFFECT OF QUANTIZATION STEPS L
453
+
454
+ Table S2 reports the performance of converted SNNs with different quantization steps $L$ and different time-steps $T$ . For VGG-16 and quantization steps $L = 2$ , we achieve an accuracy of $8 6 . 5 3 \%$ on CIFAR-10 dataset and an accuracy of $6 1 . 4 1 \%$ on CIFAR-100 dataset with 1 time-steps. When the quantization steps $L = 1$ , we cannot train the source ANN.
455
+
456
+ # A.6 COMPARISON WITH STATE-OF-THE-ART SUPERVISED TRAINING METHODS ON CIFAR-10 DATASET
457
+
458
+ Notably, our ultra-low latency performance is comparable with other state-of-the-art supervised training methods. Table S3 reports the results of hybrid training and backpropagation methods on CIFAR-10. The backpropagation methods require sufficient time-steps to convey discriminate information. Thus, the list methods need at least 5 time-steps to achieve ${ \sim } 9 1 \%$ accuracy. On the contrary, our method can achieve $9 4 . 7 3 \%$ accuracy with 4 time-steps. Besides, the hybrid training method requires 200 time-steps to obtain $9 2 . 0 2 \%$ accuracy because of further training with STDB, whereas our method achieves $9 3 . 9 6 \%$ accuracy with 4 time-steps.
459
+
460
+ # A.7 COMPARISON ON CIFAR-100 DATASET
461
+
462
+ Table S4 reports the results on CIFAR-100, our method also outperforms the others both in terms of high accuracy and ultra-low latency. For VGG-16, the accuracy of the proposed method is $3 . 4 6 \%$ higher than SNNC-AP and $6 9 . 3 7 \%$ higher than RTS when $T = 3 2$ . When the time-steps is only 4, we can still achieve an accuracy of $6 9 . 6 2 \%$ . These results demonstrate that our method outperforms the previous conversion methods.
463
+
464
+ Table S2: Influence of different quantization steps.
465
+
466
+ <table><tr><td rowspan="2">quantization steps</td><td colspan="8"></td></tr><tr><td>T=1</td><td>T=2</td><td>T=4</td><td>T=8</td><td>T=16</td><td>T=32</td><td>T=64</td><td>T=128</td></tr><tr><td colspan="9">VGG-16 on CIFAR-10</td></tr><tr><td>L=2</td><td>86.53%</td><td>91.98%</td><td>93.00%</td><td>93.95%</td><td>94.18%</td><td>94.22%</td><td>94.18%</td><td>94.14%</td></tr><tr><td>L=4</td><td>88.41%</td><td>91.18%</td><td>93.96%</td><td>94.95%</td><td>95.40%</td><td>95.54%</td><td>95.55%</td><td>95.59%</td></tr><tr><td>L=8</td><td>62.89%</td><td>83.93%</td><td>91.77%</td><td>94.45%</td><td>95.22%</td><td>95.56%</td><td>95.74%</td><td>95.79%</td></tr><tr><td>L=16</td><td>61.48%</td><td>76.76%</td><td>89.61%</td><td>93.03%</td><td>93.95%</td><td>94.24%</td><td>94.25%</td><td>94.22%</td></tr><tr><td>L=32</td><td>13.05%</td><td>73.33%</td><td>89.67%</td><td>94.13%</td><td>95.31%</td><td>95.66%</td><td>95.73%</td><td>95.77%</td></tr><tr><td colspan="9">ResNet-20 on CIFAR-10</td></tr><tr><td>L=2</td><td>77.54%</td><td>82.12%</td><td>85.77%</td><td>88.04%</td><td>88.64%</td><td>88.79%</td><td>88.85%</td><td>88.76%</td></tr><tr><td>L=4</td><td>62.43%</td><td>73.2%</td><td>83.75%</td><td>89.55%</td><td>91.62%</td><td>92.24%</td><td>92.35%</td><td>92.35%</td></tr><tr><td>L=8</td><td>46.19%</td><td>58.67%</td><td>75.70%</td><td>87.79%</td><td>92.14%</td><td>93.04%</td><td>93.34%</td><td>93.24%</td></tr><tr><td>L=16</td><td>30.96%</td><td>39.87%</td><td>57.04%</td><td>79.5%</td><td>90.87%</td><td>93.25%</td><td>93.44%</td><td>93.48%</td></tr><tr><td>L=32</td><td>22.15%</td><td>27.83%</td><td>43.56%</td><td>70.15%</td><td>88.81%</td><td>92.97%</td><td>93.48%</td><td>93.48%</td></tr><tr><td colspan="9">VGG-16 on CIFAR-100</td></tr><tr><td>L=2</td><td>61.41%</td><td>64.96%</td><td>68.0%</td><td>70.72%</td><td>71.87%</td><td>72.28%</td><td>72.35%</td><td>72.4%</td></tr><tr><td>L=4</td><td>57.5%</td><td>63.79%</td><td>69.62%</td><td>73.96%</td><td>76.24%</td><td>77.01%</td><td>77.1%</td><td>77.05%</td></tr><tr><td>L=8</td><td>44.98%</td><td>52.46%</td><td>62.09%</td><td>70.71%</td><td>74.83%</td><td>76.41%</td><td>76.73%</td><td>76.73%</td></tr><tr><td>L=16</td><td>33.12%</td><td>41.71%</td><td>53.38%</td><td>65.76%</td><td>72.80%</td><td>75.6%</td><td>76.37%</td><td>76.36%</td></tr><tr><td>L=32</td><td>15.18%</td><td>21.41%</td><td>32.21%</td><td>50.46%</td><td>67.32%</td><td>74.6%</td><td>76.18%</td><td>76.24%</td></tr><tr><td colspan="9">ResNet-20 on CIFAR-100</td></tr><tr><td>L=2</td><td>38.65%</td><td>47.35%</td><td>55.23%</td><td>59.69%</td><td>61.29%</td><td>61.5%</td><td>61.03%</td><td>60.81%</td></tr><tr><td>L=4</td><td>25.62%</td><td>36.33%</td><td>51.55%</td><td>63.14%</td><td>66.70%</td><td>67.47%</td><td>67.47%</td><td>67.41%</td></tr><tr><td>L=8</td><td>13.19%</td><td>19.96%</td><td>34.14%</td><td>55.37%</td><td>67.33%</td><td>69.82%</td><td>70.49%</td><td>70.55%</td></tr><tr><td>L=16</td><td>6.09%</td><td>9.25%</td><td>17.48%</td><td>38.22%</td><td>60.92%</td><td>68.70%</td><td>70.15%</td><td>70.20%</td></tr><tr><td>L=32</td><td>5.44%</td><td>7.41%</td><td>13.36%</td><td>31.66%</td><td>58.68%</td><td>68.12%</td><td>70.12%</td><td>70.27%</td></tr></table>
467
+
468
+ # A.8 ENERGY CONSUMPTION ANALYSIS
469
+
470
+ We evaluate the energy consumption of our method and the compared methods (Li et al., 2021; Deng & Gu, 2020) on CIFAR-100 datasets. Here we use the same network structure of VGG16. Following the analysis in Merolla et al. (2014), we use synaptic operation (SOP) for SNN to represent the required basic operation numbers to classify one image. We utilize 77fJ/SOP for SNN and 12.5pJ/FLOP for ANN as the power consumption baseline, which is reported from the ROLLS neuromorphic processor (Qiao et al., 2015). Note that we do not consider the memory access energy in our study because it depends on the hardware. As shown in Table S5, when the time-steps is the same, the energy consumption of our method is about two times of SNNC-AP. However, to achieve the same accuracy of $7 3 . 5 5 \%$ , our method requires less energy consumption.
471
+
472
+ # A.9 PSEUDO-CODE FOR OVERALL CONVERSION ALGORITHM
473
+
474
+ In this section, we summarize the entire conversion process in Algorithm 1, including training ANNs from scratch and converting ANNs to SNNs. The QCFS in the pseudo-code represents the proposed quantization clip-floor-shift function.
475
+
476
+ Table S3: Compare with state-of-the-art supervised training methods on CIFAR-10 dataset
477
+
478
+ <table><tr><td>Model</td><td>Method</td><td>Architecture</td><td> SNN Accuracy</td><td>Timesteps</td></tr><tr><td></td><td colspan="4">CIFAR-10</td></tr><tr><td>HC</td><td>Hybrid</td><td>VGG-16</td><td>92.02</td><td>200</td></tr><tr><td>STBP</td><td>Backprop</td><td>CIFARNet</td><td>90.53</td><td>12</td></tr><tr><td>DT</td><td>Backprop</td><td>CIFARNet</td><td>90.98</td><td>8</td></tr><tr><td>TSSL</td><td>Backprop</td><td>CIFARNet</td><td>91.41</td><td>5</td></tr><tr><td>DThIR1</td><td>ANN-SNN</td><td>cNet</td><td>77.10</td><td>256</td></tr><tr><td>Ours</td><td>ANN-SNN</td><td>VGG-16</td><td>93.96</td><td>4</td></tr><tr><td>Ours</td><td>ANN-SNN</td><td>CIFARNet2</td><td>94.73</td><td>4</td></tr></table>
479
+
480
+ 1 Implemented on Loihi neuromorphic processor 2 For CIFARNet, we use the same architecture as Wu et al. (2018).
481
+
482
+ Table S4: Comparison between the proposed method and previous works on CIFAR-100 dataset.
483
+
484
+ <table><tr><td>Architecture</td><td>Method</td><td>ANN</td><td>T=2</td><td>T=4</td><td>T=8</td><td>T=16</td><td>T=32</td><td>T=64</td><td>T≥512</td></tr><tr><td rowspan="5">VGG-16</td><td>RMP</td><td>71.22%</td><td>-</td><td>-</td><td>-</td><td>二</td><td>-</td><td>-</td><td>70.93%</td></tr><tr><td>TSC</td><td>71.22%</td><td>-</td><td>1</td><td>二</td><td>二</td><td>-</td><td>-</td><td>70.97%</td></tr><tr><td>RTS</td><td>77.89%</td><td>1</td><td>二</td><td>二</td><td>二</td><td>7.64%</td><td>21.84%</td><td>77.71%</td></tr><tr><td>SNNC-AP</td><td>77.89%</td><td>1</td><td>-</td><td>-</td><td>-</td><td>73.55%</td><td>76.64%</td><td>77.87%</td></tr><tr><td>Ours</td><td>76.28%</td><td>63.79%</td><td>69.62%</td><td>73.96%</td><td>76.24%</td><td>77.01%</td><td>77.10%</td><td>77.08%</td></tr><tr><td rowspan="3">ResNet-20</td><td>RMP</td><td>68.72%</td><td></td><td></td><td>-</td><td>-</td><td>27.64%</td><td>46.91%</td><td>67.82%</td></tr><tr><td>TSC</td><td>68.72%</td><td>1</td><td>-</td><td>1</td><td>:</td><td></td><td>1</td><td>68.18%</td></tr><tr><td>Ours</td><td>69.94%</td><td>19.96%</td><td>34.14%</td><td>55.37%</td><td>67.33%</td><td>69.82%</td><td>70.49%</td><td>70.50%</td></tr><tr><td rowspan="3">ResNet-18</td><td>RTS</td><td>77.16%</td><td></td><td>-</td><td>-</td><td>二</td><td>51.27%</td><td>70.12%</td><td>77.19%</td></tr><tr><td>SNNC-AP</td><td>77.16%</td><td>=</td><td>-</td><td>-</td><td>-</td><td>76.32%</td><td>77.29%</td><td>77.25%</td></tr><tr><td>Ours</td><td>78.80%</td><td>70.79%</td><td>75.67%</td><td>78.48%</td><td>79.48%</td><td>79.62%</td><td>79.54%</td><td>79.61%</td></tr></table>
485
+
486
+ RTS and SNNC-AP use altered ResNet-18, while ours use standard ResNet-18.
487
+
488
+ Table S5: Comparison of the energy consumption with previous works
489
+
490
+ <table><tr><td>Method</td><td></td><td>ANN</td><td>T=2</td><td>T=4</td><td>T=8</td><td>T=16</td><td>T=32</td><td>T=64</td></tr><tr><td rowspan="3">RTS</td><td>Accuracy</td><td>77.89%</td><td>-</td><td>-</td><td></td><td>-</td><td>7.64%</td><td>21.84%</td></tr><tr><td>OP(GFLOP/GSOP)</td><td>0.628</td><td>-</td><td>-</td><td></td><td></td><td>0.508</td><td>0.681</td></tr><tr><td>Energy (mJ)</td><td>7.85</td><td>-</td><td>-</td><td></td><td></td><td>0.039</td><td>0.052</td></tr><tr><td rowspan="3">SNNC-AP</td><td>Accuracy</td><td>77.89%</td><td></td><td>■</td><td></td><td></td><td>73.55%</td><td>76.64%</td></tr><tr><td>OP (GFLOP/GSOP)</td><td>0.628</td><td>-</td><td>■</td><td></td><td></td><td>0.857</td><td>1.22</td></tr><tr><td>Energy (mJ)</td><td>7.85</td><td>-</td><td>-</td><td>-</td><td>-</td><td>0.660</td><td>0.094</td></tr><tr><td rowspan="3">Ours</td><td>Accuracy</td><td>76.28%</td><td>63.79%</td><td>69.62%</td><td>73.96%</td><td>76.24%</td><td>77.01%</td><td>77.10%</td></tr><tr><td>OP (GFLOP/GSOP)</td><td>0.628</td><td>0.094</td><td>0.185</td><td>0.364</td><td>0.724</td><td>1.444</td><td>2.884</td></tr><tr><td>Energy (mJ)</td><td>7.85</td><td>0.007</td><td>0.014</td><td>0.028</td><td>0.056</td><td>0.111</td><td>0.222</td></tr></table>
491
+
492
+ Input: ANN model $M _ { \mathrm { A N N } } ( \pmb { x } ; \pmb { W } )$ with initial weight $W$ ; Dataset $D$ ; Quantization step $L$ ; Initial
493
+ dynamic thresholds $\lambda$ ; Learning rate $\epsilon$ .
494
+ Output: $M _ { \mathrm { S N N } } ( \pmb { x } ; \hat { \pmb { W } } )$
495
+ 1: for $l = 1$ to $M _ { \mathrm { A N N } }$ .layers do
496
+ 2: if is ReLU activation then
497
+ 3: Replace ReLU $( { \pmb x } )$ by $\mathrm { Q C F S } ( \pmb { x } ; L , \lambda ^ { l } )$
498
+ 4: end if
499
+ 5: if is MaxPooling layer then
500
+ 6: Replace MaxPooling layer by AvgPooling layer
501
+ 7: end if
502
+ 8: end for
503
+ 9: for $e = 1$ to epochs do
504
+ 10: for length of Dataset $D$ do
505
+ 11: Sample minibatch $( \boldsymbol { x } ^ { 0 } , \boldsymbol { y } )$ from $D$
506
+ 12: for $l = 1$ to $M _ { \mathrm { A N N } }$ .layers do
507
+ 13: $\pmb { x } ^ { l } = \mathrm { Q C F S } ( \widetilde { \pmb { W } } ^ { l } \pmb { x } ^ { l - 1 } ; L , \lambda ^ { l } )$
508
+ 14: end for
509
+ 15: $\mathrm { L o s s } = \mathrm { C r o s s E n t r o p y } ( \pmb { x } ^ { l } , \pmb { y } )$
510
+ 16: for $l = 1$ to $M _ { \mathrm { A N N } }$ .layers do
511
+ 17: 18: $\begin{array} { r l } & { W ^ { l } W ^ { l } - \epsilon \frac { \partial L \bar { o } s s } { \partial W ^ { l } } } \\ & { \lambda ^ { l } \lambda ^ { l } - \epsilon \frac { \partial L o s s } { \partial \lambda ^ { l } } } \\ & { - \epsilon \frac { } { \partial \lambda ^ { \complement } } } \end{array}$
512
+ 19: end for
513
+ 20: end for
514
+ 21: end for
515
+ 22: for $l = 1$ to $M _ { \mathrm { A N N } }$ .layers do
516
+ 23: $M _ { \mathrm { S N N } } . \hat { W } ^ { l } \gets M _ { \mathrm { A N N } } . W ^ { l }$
517
+ 24: $M _ { \mathrm { S N N } } . \theta ^ { l } M _ { \mathrm { A N N } } . \lambda ^ { l }$
518
+ 25: $M _ { \mathrm { S N N } } . { \pmb v } ^ { l } ( 0 ) M _ { \mathrm { S N N } } . \theta ^ { l } / 2$
519
+ 26: end for
520
+ 27: return MSNN
md/dev/8XWP2ewX-im/8XWP2ewX-im.md ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hidden Progress in Deep Learning: SGD Learns Parities Near the Computational Limit
2
+
3
+ Boaz Barak Harvard University
4
+
5
+ Benjamin L. Edelman Harvard University
6
+
7
+ Surbhi Goel Microsoft Research & University of Pennsylvania
8
+
9
+ Sham Kakade Harvard University
10
+
11
+ Eran Malach Hebrew University of Jerusalem
12
+
13
+ Cyril Zhang Microsoft Research
14
+
15
+ b@boazbarak.org, sham@seas.harvard.edu,
16
+
17
+ bedelman@g.harvard.edu, surbhig@cis.upenn.edu eran.malach@mail.huji.ac.il, cyrilzhang@microsoft.com
18
+
19
+ # Abstract
20
+
21
+ There is mounting evidence of emergent phenomena in the capabilities of deep learning methods as we scale up datasets, model sizes, and training times. While there are some accounts of how these resources modulate statistical capacity, far less is known about their effect on the computational problem of model training. This work conducts such an exploration through the lens of learning a $k$ -sparse parity of $n$ bits, a canonical discrete search problem which is statistically easy but computationally hard. Empirically, we find that a variety of neural networks successfully learn sparse parities, with discontinuous phase transitions in the training curves. On small instances, learning abruptly occurs at approximately $n ^ { O ( k ) }$ iterations; this nearly matches SQ lower bounds, despite the apparent lack of a sparse prior. Our theoretical analysis shows that these observations are not explained by a Langevin-like mechanism, whereby SGD “stumbles in the dark” until it finds the hidden set of features (a natural algorithm which also runs in $n ^ { O ( k ) }$ time). Instead, we show that SGD gradually amplifies the sparse solution via a Fourier gap in the population gradient, making continual progress that is invisible to loss and error metrics.
22
+
23
+ # 1 Introduction
24
+
25
+ In deep learning, performance improvements are frequently observed upon simply scaling up resources (such as data, model size, and training time). While these improvements are often continuous in terms of these resources, some of the most surprising recent advances in the field have been emergent capabilities: at a certain threshold, behavior changes qualitatively and discontinuously. Through a statistical lens, it is well-understood that larger models, trained with more data, can fit more complex and expressive functions. However, far less is known about the analogous computational question: how does the scaling of these resources influence the success of gradient-based optimization?
26
+
27
+ These phase transitions cannot be explained via statistical capacity alone: they can appear even when the amount of data remains fixed, with only model size or training time increasing. A timely example is the emergence of reasoning and few-shot learning capabilities when scaling up language models (Radford et al., 2019; Brown et al., 2020; Chowdhery et al., 2022; Hoffmann et al., 2022); Srivastava et al. (2022) identify various tasks which language models are only able to solve if they are larger than a critical scale. Power et al. (2022) give examples of discontinuous improvements in population accuracy (“grokking”) when running time increases, while dataset and model sizes remain fixed.
28
+
29
+ ![](images/f5f27b7d50a94e0f6d0f12aa5d0ab42e3b151b48c843d58252ce826edbdb6d5f.jpg)
30
+ Figure 1: Main empirical findings at a glance. A variety of neural networks, with standard training and initialization, can solve the $( n , k )$ -parity learning problem, with a number of iterations scaling as $n ^ { O ( k ) }$ . Left: Training curves under various algorithmic choices (architecture, batch size, learning rate) on the $( n = 5 0 , k = 3$ )-parity problem. Right: Median convergence times for small $( n , k )$ .
31
+
32
+ In this work, we analyze the computational aspects of scaling in deep learning, in an elementary synthetic setting which already exhibits discontinuous improvements. Specifically, we consider the supervised learning problem of learning a sparse parity: the label is the parity (XOR) of $k \ll n$ bits in a random length- $^ n$ binary string. This problem is computationally difficult for a range of algorithms, including gradient-based $\mathrm { ( } \bar { \mathrm { K e a r n s } } , \bar { \mathrm { 1 9 9 8 } } \mathrm { ) }$ and streaming $\mathtt { ( K o l e t a l . } \mathtt { \backslash } \mathtt { E 0 1 7 } )$ algorithms. We focus on analyzing the resource measure of training time, and demonstrate that the loss curves for sparse parities display a phase transition across a variety of architectures and hyperparameters (see Figure $\checkmark$ left). Strikingly, we observe that SGD finds the sparse subset (and hence, reaches 0 error) with a variety of activation functions and initialization schemes, even with no over-parameterization.
33
+
34
+ A natural hypothesis to explain SGD’s success in learning parities, with no visible progress in error and loss for most of training, would be that it simply “stumbles in the dark”, performing random search for the unknown target (e.g. via stochastic gradient Langevin dynamics). If that were the case, we might expect to observe a convergence time of $2 ^ { \Omega ( n ) }$ , like a naive search over parameters or subsets of indices. However, Figure $1 ( r i { \bar { g } } h t )$ , already provides some evidence against this “random search” hypothesis: the convergence time adapts to the sparsity parameter $k$ , with a scaling of $n ^ { O ( k ) }$ on small instances. Notably, such a convergence rate implies that SGD is closer to achieving the optimal computation time among a natural class of algorithms (namely, statistical query algorithms).
35
+
36
+ Through an extensive empirical analysis of the scaling behavior of a variety of models, as well as theoretical analysis, we give strong evidence against the “stumbling in the dark” viewpoint. Instead, there is a hidden progress measure under which SGD is steadily improving. Furthermore, and perhaps surprisingly, we show that SGD achieves a computational runtime much closer to the optimal SQ lower bound than simply doing (non-sparse) parameter search. More generally, our investigations reveal a number of notable phenomena regarding the dependence of SGD’s performance on resources: we identify phase transitions when varying data, model size, and training time.
37
+
38
+ # 1.1 Our contributions
39
+
40
+ SGD learns sparse parities. It is known from SQ lower bounds that with a constant noise level, gradient descent on any architecture requires at least $n ^ { \Omega ( k ) }$ computational steps to learn $k$ -sparse $n$ -dimensional parities (for background, see Appendix $\mathbf { A } )$ . We first show a wide variety of positive empirical results, in which neural networks successfully solve the parity problem in a number of iterations which scales near this computational limit:
41
+
42
+ Empirical Finding 1. For all small instances $( n ~ \leq ~ 3 0 , k ~ \leq ~ 4 )$ of the sparse parity problem, architectures $\mathcal { A } \in \{ 2$ -layer MLPs, Transformers1, sinusoidal/oscillating neurons, PolyNets2}, initializations in uniform, Gaussian, Bernoulli , and batch sizes $1 \leq B \leq 1 0 2 4$ , SGD on $\mathcal { A }$ solves the $( n , k )$ -sparse parity problem $( w . p . \ge 0 . 2 )$ within at most $c \cdot n ^ { \alpha k }$ steps, for small constants $c , \alpha$ .
43
+
44
+ Theoretical analyses of sparse feature emergence. Our empirical results suggest that, in a number of computational steps matching the SQ limit, SGD is able to solve the parity problem and identify the influential coordinates, without an explicit sparse prior. We give a theoretical analysis which validates this claim.
45
+
46
+ Informal Theorem 2. On 2-layer MLPs of width $2 ^ { \Theta ( k ) }$ , and with batch size $n ^ { O ( k ) }$ , SGD converges with high probability to a solution with at most ✏ error on the $( n , k )$ -parity problem in at most $2 ^ { O ( k ) } \cdot \mathrm { p o l y } ( 1 / \epsilon )$ iterations.
47
+
48
+ We also present a stronger analysis for an idealized architecture (which we call the disjoint-PolyNet), which allows for any batch size, and captures the phase transitions observed in the error curves.
49
+
50
+ Informal Theorem 3. On disjoint-PolyNets, SGD (with any batch size $B \geq 1$ ) converges with high probability to a solution with at most ✏ error on the $( n , k )$ -parity problem in at most $n ^ { O ( k ) } \cdot \log ( 1 / \epsilon )$ iterations. Continuous-time gradient flow exhibits a phase transition: it spends a $1 - o ( 1 )$ fraction of its time before convergence with error $\geq 4 9 \%$ .
51
+
52
+ Our theoretical and empirical results hold in non-overparameterized regimes (including with a width-1 sinusoidal neuron), in which no fixed kernel, including the neural tangent kernel (NTK) (Jacot et al., 2018), is sufficiently expressive to fit all sparse parities with a large margin. Thus, our findings comprise an elementary example of combinatorial feature learning: SGD can only successfully converge by learning a low-width sparse representation.
53
+
54
+ Further empirical explorations. Building upon our core positive results, we provide a wide variety of preliminary experiments, showing sparse parity learning to be a versatile testbed for understanding the challenges and surprises in solving combinatorial problems with neural networks. These include quantities which reveal the continual hidden progress behind uninformative training curves (as predicted by the theory), experiments at small sample sizes which exhibit grokking (Power et al., $\boxed { 2 0 2 2 }$ , as well as an example where greedy layer-wise learning is impossible but end-to-end SGD can learn the layers jointly.
55
+
56
+ # 1.2 Related work
57
+
58
+ We present the most directly related work on feature learning, and learning parities with neural nets.
59
+ A broader discussion can be found in Appendix A.3.
60
+
61
+ SGD and feature learning. Theoretical analysis of gradient descent on neural networks is notoriously hard, due to the non-convex nature of the optimization problem. That said, it has been established that in some settings, the dynamics of GD keep the weights close to their initialization, thus behaving like convex optimization over the Neural Tangent Kernel (see, for example, $\left( \mathrm { J a c o t \thinspace e t \ a l . } \right)$ 2018; Allen-Zhu et al., 2019; Du et al., 2018)). In contrast, it has been shown that in various tasks, moving away from the fixed features of the NTK is essential for the success of neural networks trained with GD (for example (Yehudai and Shamir, 2019; Allen-Zhu and Li, 2019; Wei et al., 2019) and the review in $( \mathbf { \underline { { M a l a c h \ e t \ a l . } } } ) \mathbf { \underline { { 2 0 2 1 } } } ) )$ . These results demonstrate that feature learning is an important part of the GD optimization process. Our work also focuses on a setting where feature learning is essential for the target task. In our theoretical analysis, we show that the initial population gradient encodes the relevant features for the problem. The importance of the first gradient step for feature learning has been recently studied in $\left( \overline { { \mathbf { B a } \operatorname { e t } \mathrm { { a l . } } } } \right) , \left. 2 0 2 2 \right)$
62
+
63
+ Learning parities with neural networks. The problem of learning parities using neural networks has been investigated in prior works from various perspectives. It has been demonstrated that parities are hard for gradient-based algorithms, using similar arguments as in the SQ analysis (Shalev-Shwartz et al., 2017; Abbe and Sandon, 2020). One possible approach for overcoming the computational hardness is to make favorable assumptions on the input distribution. Indeed, recent works show that under various assumptions on the input distribution, neural networks can be efficiently trained to learn parities (XORs) (Daniely and Malach, 2020; Shi et al., 2021; Frei et al., 2022; Malach et al., $\boxed { 2 0 2 1 }$ . In contrast to these results, this work takes the approach of intentionally focusing on a hard benchmark task, without assuming that the distribution has some favorable (namely, non-uniform) structure. This setting allows us to probe the performance of deep learning at a known computational limit. Notably, the work of Andoni et al. (2014) provides analysis for learning polynomials (and in particular, parities) under the uniform distribution. However, their main results require a network of size $n ^ { O ( \hat { k } ) }$ (i.e., extremely overparameterized network), and provides only partial theoretical and empirical evidence for the success of smaller networks. Studying a related subject, some works have shown that neural networks display a spectral bias, learning to fit low-frequency coefficients before high-frequency ones (Rahaman et al., 2019; Cao et al., 2019).
64
+
65
+ # 2 Preliminaries
66
+
67
+ We provide an expanded discussion of background and related work in Appendix A.
68
+
69
+ Sparse parities. For integer $n \geq 1$ and non-empty set $S \subseteq [ n ]$ , the $( n , S )$ -parity function $\chi _ { S } :$ $\{ \pm 1 \} ^ { n } \{ \pm 1 \}$ is defined as $\begin{array} { r } { \chi _ { S } ( x ) = \prod _ { i \in S } x _ { i } } \end{array}$ . We define the $( n , S )$ -parity distribution $\mathcal { D } _ { S }$ as the joint distribution over $( x , y ) ^ { 3 }$ where $x$ is drawn from $\operatorname { U n i f } ( \{ \pm 1 \} ^ { n } )$ , the uniform distribution over random length- $\mathbf { \nabla } \cdot n$ sign vectors, and $y : = \chi _ { S } ( x )$ is the product of the inputs at the indices given by the “relevant features” $S$ (thus, $\pm 1$ , depending on whether the number of relevant $- 1$ inputs is even or odd). We define the $( n , k )$ -parity learning problem as the task of recovering the $S$ using samples from $\mathcal { D } _ { S }$ , where $S$ is chosen at random from $\binom { [ n ] } { k }$ .
70
+
71
+ A key fact about parities is that they are orthogonal under the correlation inner product: for $S ^ { \prime } \subseteq [ n ]$
72
+
73
+ $$
74
+ \underset { x \sim \mathrm { U n i f } ( \{ \pm 1 \} ^ { n } ) } { \mathbb { E } } \left[ \chi _ { S } ( x ) \chi _ { S ^ { \prime } } ( x ) \right] = \underset { ( x , y ) \sim \mathcal { D } _ { S } } { \mathbb { E } } \left[ \chi _ { S ^ { \prime } } ( x ) y \right] = \left. \begin{array} { l l } { 1 } & { S ^ { \prime } = S } \\ { 0 } & { \mathrm { o t h e r w i s e } } \end{array} \right. .
75
+ $$
76
+
77
+ That is, a learner who guesses indices $S ^ { \prime }$ cannot use correlations (equivalently, the accuracy of the hypothesis $\chi _ { S ^ { \prime } }$ ) as feedback to reveal which indices in $S ^ { \prime }$ are correct, unless $S ^ { \prime }$ is exactly the correct subset. This notion of indistinguishability leads to a computational lower bound in the statistical query (SQ) model $\scriptstyle ( \left| \mathrm { K e a r n s } \right| , \left[ 1 9 9 8 \right) : \Omega ( n ^ { k } )$ constant-noise queries are necessary, which is far greater than the statistical limit of $\begin{array} { r } { \overline { { \Theta ( \log \left( \binom { n } { k } \right) ) } } \approx k \log n } \end{array}$ samples. The hardness of parity has been used to derive computational hardness results for other settings, like agnostically learning halfspaces (Klivans and Kothari, $\boxed { 2 0 1 4 }$ and MLPs $\pmb { \mathrm { \ [ G o e l ~ e t ~ a l . } , \pmb { \mathrm { [ 2 0 1 9 ) } } }$ . Beyond the restricted computational model of statistical queries, noiseless parities can be learned in poly $( n )$ time via Gaussian elimination. However, learning sparse noisy parities, even at a very small noise level (i.e., $o ( 1 )$ or $n ^ { - \delta }$ ), is believed to inherently require $n ^ { \Omega ( k ) }$ computational steps $\cdot ^ { 4 }$ In all, learning sparse parities is a well-studied combinatorial problem which exemplifies the computational difficulty of learning a joint dependence on multiple relevant features.
78
+
79
+ Notation for neural networks and training. Our main results are presented in the online learning setting, with a stream of i.i.d. batches of examples. At each iteration $t = 1 , \dots , T$ , a learning algorithm $\mathcal { A }$ receives a batch of $B$ examples $\{ ( x _ { t , i } , y _ { t , i } ) \} _ { i = 1 } ^ { B }$ drawn i.i.d. from $\mathcal { D } _ { S }$ , then outputs a classifier $\widehat { y } _ { t } : \{ \pm 1 \} ^ { n } \{ \pm 1 \}$ . We say that $\mathcal { A }$ solves the parity task in $t$ steps (with error $\epsilon$ ) if
80
+
81
+ $$
82
+ \operatorname* { P r } _ { ( x , y ) \sim \mathcal { D } _ { S } } [ \widehat { y } _ { t } ( x ) = y ] \geq 1 - \epsilon .
83
+ $$
84
+
85
+ We will focus on the case that $\widehat { y } _ { t } = \mathrm { s i g n } ( f ( x ; \theta _ { t } ) )$ for some parameters $\theta _ { t }$ in a continuous domain $\Theta$ and for a continuous function $f : \{ \pm 1 \} ^ { n } \times \Theta \mathbb { R } \mathbb { P } \} ,$ updated with the ubiquitous online learning algorithm of gradient descent (GD), whose update rule is given by
86
+
87
+ $$
88
+ \theta _ { t + 1 } \gets ( 1 - \lambda _ { t } ) \theta _ { t } - \eta _ { t } \cdot \nabla _ { \theta } \left( \frac { 1 } { B } \sum _ { i = 1 } ^ { B } \ell ( y _ { t , i } , f ( x _ { t , i } ; \theta _ { t } ) ) \right) ,
89
+ $$
90
+
91
+ for a loss function $\ell : \{ \pm 1 \} \times \mathbb { R } \to \mathbb { R }$ , learning rate schedule $\{ \eta _ { t } \} _ { t = 1 } ^ { T }$ , and weight decay schedule $\{ \lambda _ { t } \} _ { t = 1 } ^ { T } { } ^ { 6 } .$ The initialization $\theta _ { 0 }$ is drawn randomly from a chosen distribution.
92
+
93
+ ![](images/dd61b61a588a20721322d0a3217d2b5b6e9a58644d35f8e1586921209e35ce16.jpg)
94
+ Figure 2: Black-box observations on the training dynamics. Left: Histograms of convergence times over $1 0 ^ { 6 }$ random trials, with heavy upper tails but no observed successes near $t = 0$ (unlike random search). Center: Loss curves (and thus, convergence time) depend heavily on initialization, not the randomness of SGD; $B = 1 2 8$ , $\eta = 0 . 0 1$ are shown here. Right: The power-law exponent ( $\alpha$ such that $t _ { c } \propto n ^ { \alpha }$ ) eventually worsens on larger problem instances.
95
+
96
+ # 3 Empirical findings
97
+
98
+ # 3.1 SGD on neural networks learns sparse parities
99
+
100
+ The central phenomenon of study in this work is the empirical observation that neural networks, with standard initialization and training, can solve the $( n , k )$ -parity problem in a number of iterations scaling as $n ^ { O ( k ) }$ on small instances. We observed robust positive results for randomly-initialized SGD on the following architectures, indexed by Roman numerals:
101
+
102
+ • 2-layer MLPs: ReLU $( \sigma ( z ) = ( z ) _ { + } )$ or polynomial $( \sigma ( z ) = z ^ { k } ) ,$ ) activation, in a wide variety of width regimes $r \geq k$ . Settings (i), (ii), (iii) (resp. (iv), (v), (vi)) use $r = \{ 1 0 , 1 0 0 , 1 0 0 0 \}$ ReLU (resp. polynomial) activations. We also consider $r = k$ (exceptional settings $( { } ^ { * } { \bf i } ) , ( { } ^ { * } { \bf i } ) \mathrm { ~ , ~ }$ ), the minimum width for representing a $k$ -wise parity for both activations. 1-neuron networks: Next, we consider non-standard activation functions $\sigma$ which allow a one-neuron architecture $f ( x ; w ) = \sigma ( w ^ { \top } x )$ to realize $k$ -wise parities. The constructions stem from letting $\begin{array} { r } { w ^ { \ast } = \sum _ { i \in S } \dot { e } _ { i } } \end{array}$ , and constructing $\sigma ( \cdot )$ to interpolate (the appropriate scaling of) $\frac { k - w ^ { * \top } x } { 2 }$ mod 2 with a piecewise linear $k$ -zigzag activation (vii), or a degree- $k$ polynomial (viii). Going a step further, a single $\infty$ -zigzag (ix) or sinusoidal $\mathbf { \tau } ( \mathbf { x } )$ neuron can represent all $k$ -wise parities. In settings (xi), (xii), (xiii), (xiv), we remove the second trainable layer (setting $u = 1$ ). We find that wider architectures with these activations also train successfully. Transformers: There is growing interest in using parity as a benchmark for combinatorial function learning, long-range dependency learning, and length generalization in Transformers (Lu et al., 2021; Edelman et al., 2021; Hahn, 2020; Anil et al., 2022; Liu et al., 2022). Motivated by these recent theoretical and empirical works, we consider a simplified specialization of the Transformer architecture to this sequence classification problem. This is the less-robust setting $( ^ { * } \mathrm { i i i } )$ ; the architecture and optimizer are described in Appendix D.1.3. • PolyNets: Our final setting (xv) is the PolyNet, a slightly modified version of the parity machine architecture. Parity machines have been studied extensively in the statistical mechanics of ML literature (see the related work section) as well as in a line of work on ‘neural cryptography’ $\left( [ \mathrm { R o s e n - Z v i e t a l . } ] , [ \mathrm { 2 0 0 2 } ] \right)$ . A parity machine outputs the sign of the product of $k$ linear functions of the input. A PolyNet simply outputs the product itself. Both architectures can clearly realize $k$ - sparse parities. The PolyNet architecture was originally motivated by the search for an idealized setting where an end-to-end optimization trajectory analysis is tractable (see Section $4 . 1 )$ we found in these experiments that this architecture trains very stably and sample-efficiently.
103
+
104
+ Robust space of positive results. All of the networks listed above were observed to successfully learn sparse parities in a variety of settings. We summarize our findings as follows: for all combinations of $\bar { n } \in \{ 1 0 , 2 0 , 3 0 \}$ , $\bar { k } \in \{ 2 , 3 , 4 \}$ , batch sizes $B \in \{ 1 , 2 , 4 , \bar { \ldots } , 1 0 2 4 \}$ , initializations {uniform, Gaussian, Bernoulli}, loss functions $\{ { \mathrm { h i n g e } }$ , square, cross entropy}, and architecture configurations $\{ ( \mathrm { i } ) , ( \mathrm { i } \mathrm { i } ) , \dots , ( \mathrm { x } \mathrm { v } ) \}$ , SGD solved the parity problem (with $1 0 0 \%$ accuracy, validated on a batch of $2 ^ { 1 3 }$ samples) in at least $2 0 \%$ of 25 random trials, for at least one choice of learning rate $\eta \in \{ 0 . 0 0 1 , 0 . 0 1 , 0 . 1 , 1 \}$ . The models converged in $t _ { c } \le c \cdot n ^ { \alpha k } \le 1 0 ^ { 5 }$ steps, for small architecture-dependent constants $c , \alpha$ (see Appendix $\bar { \mathbf { C } ) }$ . Figure 1 (left) shows some representative training curves.
105
+
106
+ Less robust configurations. Settings $( ^ { * } \mathrm { { i } ) }$ and $( ^ { * } \mathrm { { i i } ) }$ , where the MLP just barely represents a $k$ -sparse parity, and the Transformer setting $( ^ { * } \mathrm { i i i } )$ , are less robust to small batch sizes. In these settings, the same positive results as above only held for sufficiently large batch sizes: $B \geq 1 6$ . Also, setting $( \romannumeral 1 )$ used the Adam optimizer (which is standard for Transformers); see Appendix $_ { \mathrm { D } . 1 . 3 }$ for details.
107
+
108
+ Phase transitions in training curves. For almost all of the architectures, we find that that the training curves exhibit phase transitions in terms of running time (and thus, in the online learning setting, dataset size as well): long durations of seemingly no progress, followed by periods of rapid decrease in the validation error. Strikingly, for architectures (v) and (vi), this plateau is absent: the error in the initial phase appears to decrease with a linear slope. See Appendix $\mathrm { i } _ { \mathrm { C } . 8 }$ for more plots.
109
+
110
+ # 3.2 Random search or hidden progress?
111
+
112
+ The remainder of this paper seeks to answer the question: “By what mechanism does deep learning solve these emblematic computationally-hard optimization problems?”
113
+
114
+ A natural hypothesis would be that SGD somehow implicitly performs Monte Carlo random search, “bouncing around” the loss landscape in the absence of a useful gradient signal. Upon closer inspection, several empirical observations clash with this hypothesis:
115
+
116
+ • Scaling of convergence times: Without an explicit sparsity prior in the architecture or initialization, it is unclear how to account for the runtimes observed in experiments, which adapt to the sparsity $k$ . The initializations, which certainly do not prefer sparse functions $\bigstar$ are close to the correct solutions with probability $2 ^ { - \Omega ( n ) } \ll \dot { n } ^ { - k }$ .
117
+ • No early convergence: Over a large number of random trials, no copies of this randomized algorithm get “lucky” (i.e. solve the problem in significantly fewer than the median number of iterations); see Figure $2 \ ( l e f t )$ . The success times of random exhaustive search would be distributed as $\mathrm { G e o m } ( 1 / { \overline { { ( } } } _ { k } ^ { n } ) )$ , whose probability mass is highest at $t = 0$ and decreases monotonically with $t$ .
118
+ • Sensitivity to initialization, not SGD samples: Running these training setups over multiple stochastic batches from a common initialization, we find that loss curves and convergence times are highly correlated with the architecture’s random initialization, and are quite concentrated conditioned on initialization; see Figure 2 (center).
119
+ • Elbows in the scaling curves: For larger $n$ , the power-law scaling ceases to hold: the exponent worsens (see Figure $\hat { 2 } \left( r i g h t \right)$ , as well as the discussion in Appendix ${ \bf C } . 2 )$ . This would not be true for random exhaustive search.
120
+
121
+ Even these observations, which do not probe the internal state of the algorithm, suggest that exhaustive search is an insufficient picture of the training dynamics, and a different mechanism is at play.
122
+
123
+ # 4 Theoretical analyses
124
+
125
+ # 4.1 Provable emergence of the parity indices in high-precision gradients
126
+
127
+ We now provide a theoretical account for the success of SGD in solving the $( n , k )$ -parity problem. Our main theoretical observation is that, in many cases, the population gradient of the weights at initialization contains enough “information” for solving the parity problem. That is, given an accurate enough estimate of the initial gradient (by e.g. computing the gradient over a large enough batch size), the relevant subset $S$ can be found.
128
+
129
+ ![](images/8e047a5239904342d313535d0804e98f802e0d064070cb0e03abb9a0c461744e.jpg)
130
+ Figure 3: Hidden progress when learning parities with neural networks. Left, center: Black-box losses and accuracies exhibit a long plateau and sharp phase transition (top), hiding gradual progress in the SGD iterates (bottom). Right: A hidden progress measure which distinguishes gradual feature amplification (top) from training on noise (bottom).
131
+
132
+ As a warm-up example, consider training a single ReLU neuron $\widehat { y } ( x ; w ) = ( w ^ { \top } x ) _ { + }$ with the correlation loss $\ell ( y , \widehat { y } ) = - y \widehat { y }$ over $\mathcal { D } _ { S }$ , from an all-ones initialization $w = [ 1 \ \dots \ 1 ] \in \mathbb { R } ^ { n }$ . While a single neuron cannot express the parity, we observe that the correct subset can be extracted from the population gradient at initialization:
133
+
134
+ $$
135
+ \underset { x , y \rangle \sim \mathcal { D } _ { S } } { \mathbb { E } } \left[ \nabla _ { w _ { i } } \ell ( y , \widehat { y } ( x ; w ) ) \right] = \underset { ( x , y ) \sim \mathcal { D } _ { S } } { \mathbb { E } } \left[ - y \nabla _ { w _ { i } } ( w ^ { \top } x ) _ { + } \right] = \underset { ( x , y ) \sim \mathcal { D } _ { S } } { \mathbb { E } } \left[ - \chi _ { S } x _ { i } \mathbb { 1 } \left[ \sum _ { i } x _ { i } \geq 0 \right] \right] .
136
+ $$
137
+
138
+ The key insight is that each coordinate in the above expression is a correlation between a parity and the function $x \mapsto - \mathbb { 1 } [ \sum _ { i } x _ { i } \geq 0 ]$ , and thus a Fourier coefficient of this Boolean function. At each relevant coordinate $( i \in S$ ), the population gradient is the order- $( k - 1 )$ Fourier coefficient $S \setminus \{ i \}$ ; for the irrelevant features $( i \notin S )$ , it is instead the order- $( k + 1 )$ coefficient $S \cup \{ i \}$ . All we require is a detectable gap between these quantities. Formally, letting $f ( x ; w ) = \sigma ( w ^ { \top } x )$ , letting ${ \widehat { f } } ( S ) : = \mathbb { E } \left[ f ( x ) \chi _ { S } ( x ) \right]$ denote the Fourier coefficient of $f$ at $S$ , we isolate the desired property:
139
+
140
+ Definition 1 (Fourier gap). For a function $f : \{ \pm 1 \} ^ { n } \to \mathbb { R }$ and $S \subseteq [ n ]$ of size $k$ , we say that $f$ has a $\gamma$ -Fourier gap at $S$ if, for every $\left( k - 1 \right)$ -element subset $S ^ { - } \subset S$ and $( k + 1 )$ -element superset $S ^ { + } \supset S$ , it holds that $| { \widehat { f } } ( S ^ { - } ) | \geq | { \widehat { f } } ( S ^ { + } ) | + \gamma .$ .
141
+
142
+ For the all-ones initialization, observe $\begin{array} { r } { \mathbb { 1 } [ \sum _ { i } x _ { i } \ge 0 ] = \frac { 1 + \mathrm { s i g n } \left( \sum _ { i } x _ { i } \right) } { 2 } } \end{array}$ is just an affine transformation of the majority function of $x$ , for which a Fourier gap can be established, with $\gamma = \Theta ( n ^ { - ( k - 1 ) / 2 } )$ . This arises from closed-form formulas for the Fourier spectrum of majority (see Lemma $2$ i n Appendix $\mathbf { \underline { { B . l } } } \mathbf { \underline { { \Omega } } }$ , a landmark result from the harmonic analysis of Boolean functions (Titsworth, 1962; O’Donnell, 2014). Thus, the coordinates in $S$ can be recovered from $\widetilde { \cal O } ( 1 / \gamma ^ { 2 } ) = \widetilde { \cal O } \overline { { ( n ^ { k - 1 } ) } }$ samples; see Proposition 9 in Appendix ${ \bf B } . 2$ for a formal argument.
143
+
144
+ Carefully extending this insight, we obtain an end-to-end convergence result for ReLU-activation MLP networks with a particular symmetric choice of $\pm 1$ initialization, trained with the hinge loss:
145
+
146
+ Theorem 4 (SGD on MLPs learns sparse parities). Let $\epsilon \in ( 0 , 1 )$ . Let $k \geq 2$ an even integer, and let $n = \Omega ( k ^ { 4 } \log ( n k / \epsilon ) )$ be an odd integer. Then, there exist a random initialization scheme, $\eta _ { t }$ , and $\lambda _ { t }$ such that for every $S \subseteq [ n ]$ of size $k$ , SGD on a ReLU MLP of width $r = \Omega ( 2 ^ { k } k \log ( k / \epsilon ) )$ , with batch size $B = \Omega ( n ^ { k } \log ( n / \epsilon ) )$ on $\mathcal { D } _ { S }$ with the hinge loss, outputs a network $f ( x ; \theta _ { t } )$ with expected8 loss $\mathbb { E } \left[ \ell ( f ( x ; \theta _ { t } ) , y ) \right] \leq \epsilon$ in at most $O ( k ^ { 3 } r ^ { 2 } n / \epsilon ^ { 2 } )$ iterations.
147
+
148
+ This does not capture the full range of settings in which we empirically observe successful convergence. First, it requires a sign vector initialization, while we observe convergence with other random initialization schemes (namely, uniform and Gaussian). Second, it requires the batch size to scale with $n ^ { \Omega ( k ) } \big \triangledown$ while we also obtain positive results when $B$ is small (even $B = 1$ ). Analogous statements for these cases (as well as other activations and losses) would require Fourier gaps for population gradient functions other than majority; lower bounds on the degree- $\left( k - 1 \right)$ coefficients (“Fourier anti-concentration”) are particularly elusive in the literature, and we leave it as an open challenge to establish them in more general settings. We provide preliminary empirics in Appendix $\mathrm { C . l } ,$ suggesting that the Fourier gaps in our empirical settings are sufficiently large. 10
149
+
150
+ Low width necessitates feature learning. We note that in the low-width (non-overparameterized) regimes considered in this work, no fixed kernel (including the neural tangent kernel (Jacot et al., $\boxed { 2 0 1 8 }$ , whose dimensionality is the network’s parameter count) can solve the sparse parity problem. The following is a consequence of results in (Kamath et al., 2020; Malach and Shalev-Shwartz, 2022): Theorem 5 (Low-width NTK cannot fit all parities). Let $\Psi : \{ \pm 1 \} ^ { n } \to \mathbb { R } ^ { D }$ be any $D$ -dimensional embedding with $\mathrm { s u p } _ { x } \| \Psi ( x ) \| _ { 2 } \leq 1$ . Let $R , \epsilon > 0$ , and let $\ell$ denote the 0-1 loss or hinge loss. If $D R ^ { 2 } < \epsilon ^ { 2 } \cdot \binom { n } { k }$ , then there exists some $S \subseteq [ n ]$ of size $k$ such that
151
+
152
+ $$
153
+ \operatorname* { i n f } _ { \| w \| \leq R } \operatorname* { \mathbb { E } } _ { ( x , y ) \sim \mathcal { D } _ { S } } \left[ \ell ( \Psi ( x ) ^ { \top } w , y ) \right] > 1 - \epsilon .
154
+ $$
155
+
156
+ Thus, our low-width results lie outside the NTK regime, which requires far larger models (size $n ^ { \Omega ( k ) }$ ) to express parities. However, we note that better sample complexity bounds are possible in the NTK regime, with an algorithm more similar to standard SGD (see (Telgarsky, $\boxed { 2 0 2 2 }$ and Appendix $\mathbf { A } . 3 )$ .
157
+
158
+ # 4.2 Disjoint-PolyNet: exact trajectory analysis for an idealized architecture
159
+
160
+ In this section, we present an architecture (a version of PolyNets (xv)) which empirically exhibits similar behavior to MLPs and bypasses the difficulty of analyzing Fourier gaps. The disjointPolyNet takes a product over $k$ linear functions of an equal-sized11 partition $P _ { 1 } , \ldots , P _ { k }$ of the input coordinates: $\begin{array} { r } { f ( x ; w _ { 1 : k } ) : = \prod _ { i = 1 } ^ { k } \langle w _ { i } , x _ { P _ { i } } \rangle } \end{array}$ . As noted in the Section $\boxed { 1 . 2 }$ this is equivalent to a tree parity machine, with real-valued (instead of $\pm 1$ ) outputs.
161
+
162
+ This architecture also requires us to assume that the set $S$ of size $k$ in the $( n , k )$ -parity problem is selected such that exactly one index belongs to each disjoint partition, that is, for all $i \in [ k ]$ , $S \cap P _ { i } = 1$ . We refer to this problem as the $( n , k )$ -disjoint parity problem. Note that there are still $( n ^ { \prime } ) ^ { k } = ( n / k ) ^ { k }$ different possibilities for set $S$ under this restriction. For fixed $k$ , these represent a constant fraction of the ${ \binom { n } { k } } \approx ( n e / k ) ^ { k }$ (by Stirling’s approximation) possibilities for $S$ in the general non-disjoint case.
163
+
164
+ Consider training a disjoint-PolyNet w.r.t. the correlation loss. Without loss of generality, assume that each relevant coordinate in $S$ is the first element $P _ { i }$ . Then, the population gradient is non-zero only at indices $i \in S$ :
165
+
166
+ $$
167
+ g _ { i } ( w _ { 1 : k } ) = \mathbb { E } \left[ \nabla _ { w _ { i } } \ell ( f ( x ; w _ { 1 : k } ) , y ) \right] = - \mathbb { E } \left[ y \left( \prod _ { j \neq i } \langle w _ { j } , x _ { P _ { j } } \rangle \right) x _ { P _ { i } } \right] = - \left( \prod _ { j \neq i } w _ { j , 1 } \right) e _ { 1 } .
168
+ $$
169
+
170
+ This allows us to analyze the gradient flow dynamics of the disjoint-PolyNet, without needing to establish Fourier gaps. For each $i \in [ k ]$ , in this section we treat $w _ { i }$ as a function from $\mathbb { R } _ { \geq 0 } \to \mathbb { R } ^ { n ^ { \prime } }$ which satisfies the following differential equation: $\dot { w } _ { i } = - g _ { i } ( w _ { 1 : k } ( t ) )$ . For clarity of exposition, assume all-ones initialization $\bigstar$ Then, all of the relevant weights $\{ w _ { i , 1 } : i \in [ k ] \}$ follow the same trajectory. By analyzing the resulting differential equations, we can formally exhibit “phase transition”-like behavior in the fully deterministic gradient flow setting.
171
+
172
+ Theorem 6 (Loss plateau for gradient flow on disjoint-PolyNets). Suppose $k \geq 3$ . Let $T ( \epsilon )$ denote the smallest time at which the error is at most ✏. Then,
173
+
174
+ $$
175
+ { \frac { T ( 0 . 4 9 ) } { T ( 0 ) } } \geq 1 - O \left( ( n ^ { \prime } ) ^ { 1 - k / 2 } \right) .
176
+ $$
177
+
178
+ ![](images/605608856e9419b3a654be1d6be05e1461079cfe14cf29e8c5dea54f56b4dcf9.jpg)
179
+ Figure 4: Parity as a sandbox for understanding the effects of model size and dataset size. Left: Success times vs. network width $r$ on a fixed $( 4 0 , 3 )$ -parity task: in accordance with the theory, parallelization experiences diminishing returns (unlike expected success times for random search, shown in green). Underparameterized models $( r = 1 , 2$ ) were considered successful upon reaching $5 5 \%$ accuracy. Right: Training curves where only the sample size $m$ is varied. The two center panels display “grokking”: a large gap between the time to zero train error vs. zero test error.
180
+
181
+ Informally, the network takes much longer to reach slightly-better-than-trivial accuracy than it takes to go from slightly better than trivial to perfect accuracy. Returning to discrete time, we also analyze the trajectory of disjoint-PolyNets trained with online SGD at any batch size, confirming that a neural network can learn $k$ -sparse disjoint parities within $n ^ { O ( k ) }$ iterations.
182
+
183
+ Theorem 7 (SGD on disjoint-PolyNets learns disjoint parities). Suppose we train a disjoint-PolyNet, initialized as above, with online SGD. Then there exists an adaptive learning rate schedule such that for any $\epsilon > 0$ , with probability 0.99, the error falls below ✏ within $\tilde { O } \left( ( n ^ { \prime } ) ^ { ( \bar { 2 } k - 1 ) } \log ( 1 / \epsilon ) \right)$ steps.
184
+
185
+ Extended versions of these theorems, along with proofs, can be found in Appendix B.3.
186
+
187
+ # 5 Hidden progress: discussion and additional experiments
188
+
189
+ So far, we have shown that sparse parity learning provides an idealized setting in which neural networks successfully learn sparse combinatorial features, with a mechanism of continual progress hiding behind discontinuous training curves. In this section, we outline preliminary explorations on a broader range of interesting phenomena which arise in this setting. Details are provided in Appendix $\boxed { \mathbf { C } }$ while more systematic investigations are deferred to future work.
190
+
191
+ Hidden progress measures for learning parities. The theoretical and (black-box) empirical results suggest that SGD does not learn parities via the memoryless process of random exhaustive search. This suggests the existence of progress measures: scalar quantities which are functions of the training algorithm’s state (i.e. the model weights $w _ { t }$ ) and are predictive of the time to successful convergence. We provide some white-box investigations which further support the hypothesis of hidden progress, by examining the gradual improvement in quantities other than the training loss. In Appendix $\checkmark$ we directly plot the Fourier gaps of the population gradient, as a function of $t$ , finding that they are large (within a small constant factor of those of majority) in practice. In Figure $\textcircled { 3 }$ and Appendix $\underline { { \overline { { \mathbf { C . 3 } } } } } \}$ we examine the weight movement norm $\rho ( w _ { 0 : t } ) : = \| w _ { t } - w _ { 0 } \| _ { \infty }$ to reveal hidden progress, motivated by the fact that $w _ { t } - w _ { 0 }$ is a linearized estimate for the initial population gradient.
192
+
193
+ Roles of overparameterization vs. oversampling. An interesting consequence of our analysis is that it illuminates scaling behaviors with respect to a third fundamental resource parameter: model size, which we study in terms of network width $r$ . If SGD operated by a “random search” mechanism, one would expect width to provide a parallel speedup. Instead, we find that SGD sequentially amplifies progress. The sharp lower tails in Figure $2 ( \bar { l e } \hat { f } t )$ imply that running $r$ identical copies of SGD does not give $( 1 / r ) \times$ speedups; more directly, in Appendix $\boxed { C . 4 }$ (previewed in Figure $\boxed { 4 } ( l e f t )$ , we find that convergence times for sparse parities empirically plateau at large model sizes.
194
+
195
+ Emergence of grokking in the finite-sample (multi-pass) setting. Our main results are presented in the online learning setting (fresh minibatches from $\mathcal { D } _ { S }$ at each iteration). While this mitigates the confounding factor of overfitting, it couples the resources of training time and independent samples in a suboptimal way, due to the computational-statistical gap for parity learning. In Appendix C.5, we find empirically that minibatch SGD (with weight decay) can learn sparse parities, even with smaller sample sizes $m \ll n ^ { k }$ . We reliably observe the grokking phenomenon $\pm { \sqrt { \mathrm { P o w e r ~ e t ~ a l . } } } \left[ { \overline { { 2 0 2 2 } } } \right)$ : an initial overfitting phase, then a delayed phase transition in the generalization error; see the two center panels of Figure $\mathbb { E } ( r i g h t )$ . These results complement and corroborate the findings of Nanda and Lieberum $\underline { { \left( \overline { { 2 0 2 2 } } \right) } }$ , who analyze the hidden progress of Transformers trained on arithmetic tasks (a setting which also exhibits grokking).
196
+
197
+ Deeper networks. It is a significant challenge (and generally outside the scope of this work) to understand the interactions between network depth and computational/statistical efficiency. In Appendix $\mathbf { C . 7 } ,$ we show that learning parities with deeper polynomial-activation MLPs comprises a simple counterexample to the “deep only works if shallow is good” principle of Malach and Shalev-Shwartz (2019): a deep network can get near-perfect accuracy, even when greedy layer-wise training (e.g. (Belilovsky et al., $\boxed { 2 0 1 9 } ,$ ) cannot beat trivial performance. By providing positive theory and empirics which elude these simplified explanations of SGD, we hope to point the way to a more complete understanding of learning dynamics in the challenging cases where no apparent progress is made for extended periods of time.
198
+
199
+ # 6 Conclusion
200
+
201
+ This work puts forward sparse parity learning as an elementary test case to explore the puzzling features of the role of computational (as opposed to statistical) resources in deep learning. In particular, we have shown that a variety of neural architectures solve this combinatorial search problem, with a number of computational steps nearly matching the sparsity-dependent SQ lower bound. Furthermore, we have shown that despite abrupt phase transitions in the loss and accuracy curves, SGD works by gradually amplifying the sparse features “under the hood”.
202
+
203
+ Even in this simple setting, there are several open experimental and theoretical questions. This work largely focuses on the online learning case, which couples training iterations with fresh i.i.d. samples. We believe it would be instructive to investigate parity learning when the three resources of samples, time, and model size are scaled separately. Some very preliminary findings along these lines are presented in Section $\textcircled { 3 }$ It is an open problem to extend our theoretical results to the small-batch setting, as well as to the full range of architectures and losses in our experiments. Resolving these questions would require a better understanding of the anti-concentration behavior of Boolean Fourier coefficients, which is much less studied than the analogous concentration phenomena.
204
+
205
+ Another important follow-up direction is understanding the extent to which these insights extend from parity learning to more complex (including real-world) combinatorial problem settings, as well as the extent to which non-synthetic tasks (in, e.g., natural language processing and program synthesis) embed within them parity-like subtasks of exhaustive combinatorial search. We hope that our results will lead to further progress towards understanding and improving the optimization dynamics behind the recent slew of dramatic empirical successes of deep learning in these types of domains.
206
+
207
+ Broader impact. This work seeks to contribute to the foundational understanding of computational scaling behaviors in deep learning. Our theoretical and empirical analyses are in a heavily-idealized synthetic problem setting. Hence, we see no direct societal impacts of the results in this study.
208
+
209
+ Acknowledgements. We would like to thank Lenka Zdeborová for providing us with references to the statistical physics literature on phase transitions in the learning curves of neural networks, and Matus Telgarsky for bringing to our attention the better sample complexity guarantees of 2-sparse parity learning in the NTK regime. Sham Kakade acknowledges funding from the Office of Naval Research under award N00014-22-1-2377.
210
+
211
+ References
212
+ Emmanuel Abbe and Colin Sandon. Poly-time universality and limitations of deep learning. arXiv preprint arXiv:2001.02992, 2020.
213
+ Emmanuel Abbe, Pritish Kamath, Eran Malach, Colin Sandon, and Nathan Srebro. On the power of differentiable learning versus PAC and SQ learning. Advances in Neural Information Processing Systems, 34, 2021.
214
+ Emmanuel Abbe, Elisabetta Cornacchia, Jan H ˛azła, and Christopher Marquis. An initial alignment between neural network and target is needed for gradient descent to learn. arXiv preprint arXiv:2202.12846, 2022.
215
+ Naman Agarwal, Rohan Anil, Elad Hazan, Tomer Koren, and Cyril Zhang. Disentangling adaptive gradient methods from learning rates. arXiv preprint arXiv:2002.11803, 2020.
216
+ Michael Alekhnovich. More on average case vs approximation complexity. In 44th Annual IEEE Symposium on Foundations of Computer Science, 2003. Proceedings., pages 298–307. IEEE, 2003.
217
+ Zeyuan Allen-Zhu and Yuanzhi Li. What can ResNet learn efficiently, going beyond kernels? Advances in Neural Information Processing Systems, 32, 2019.
218
+ Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. In International Conference on Machine Learning, pages 242–252. PMLR, 2019.
219
+ Alexandr Andoni, Rina Panigrahy, Gregory Valiant, and Li Zhang. Learning polynomials with neural networks. In International Conference on Machine Learning, pages 1908–1916. PMLR, 2014.
220
+ Cem Anil, Yuhuai Wu, Anders Andreassen, Aitor Lewkowycz, Vedant Misra, Vinay Ramasesh, Ambrose Slone, Guy Gur-Ari, Ethan Dyer, and Behnam Neyshabur. Exploring length generalization in large language models. arXiv preprint arXiv:2207.04901, 2022.
221
+ Benny Applebaum, David Cash, Chris Peikert, and Amit Sahai. Fast cryptographic primitives and circular-secure encryption based on hard learning problems. In Annual International Cryptology Conference, pages 595–618. Springer, 2009.
222
+ Benny Applebaum, Boaz Barak, and Avi Wigderson. Public-key cryptography from different assumptions. In Proceedings of the forty-second ACM symposium on Theory of computing, pages 171–180, 2010.
223
+ Gerard Ben Arous, Reza Gheissari, and Aukosh Jagannath. Online stochastic gradient descent on non-convex losses from high-dimensional inference. J. Mach. Learn. Res., 22:106–1, 2021.
224
+ Jimmy Ba, Murat A Erdogdu, Taiji Suzuki, Zhichao Wang, Denny Wu, and Greg Yang. Highdimensional asymptotics of feature learning: How one gradient step improves the representation. arXiv preprint arXiv:2205.01445, 2022.
225
+ Eugene Belilovsky, Michael Eickenberg, and Edouard Oyallon. Greedy layerwise learning can scale to imagenet. In International conference on machine learning, pages 583–593. PMLR, 2019.
226
+ Andrew C Berry. The accuracy of the gaussian approximation to the sum of independent variates. Transactions of the American Mathematical Society, 49(1):122–136, 1941.
227
+ Andrej Bogdanov, Manuel Sabin, and Prashant Nalini Vasudevan. Xor codes and sparse learning parity with noise. Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 986–1004, 2019.
228
+ Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
229
+ Yuan Cao, Zhiying Fang, Yue Wu, Ding-Xuan Zhou, and Quanquan Gu. Towards understanding the spectral bias of deep learning. arXiv preprint arXiv:1912.01198, 2019.
230
+ 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.
231
+ Alexandru Damian, Jason Lee, and Mahdi Soltanolkotabi. Neural networks can learn representations with gradient descent. In Conference on Learning Theory, pages 5413–5452. PMLR, 2022.
232
+
233
+ Amit Daniely and Eran Malach. Learning parities with neural networks. Advances in Neural Information Processing Systems, 33:20356–20365, 2020.
234
+
235
+ Ilias Diakonikolas, Surbhi Goel, Sushrut Karmalkar, Adam R Klivans, and Mahdi Soltanolkotabi. Approximation schemes for relu regression. In Conference on Learning Theory, pages 1452–1485. PMLR, 2020.
236
+ Simon S Du, Xiyu Zhai, Barnabas Poczos, and Aarti Singh. Gradient descent provably optimizes over-parameterized neural networks. arXiv preprint arXiv:1810.02054, 2018.
237
+ Benjamin L Edelman, Surbhi Goel, Sham Kakade, and Cyril Zhang. Inductive biases and variable creation in self-attention mechanisms. arXiv preprint arXiv:2110.10090, 2021.
238
+ Andreas Engel and Christian Van den Broeck. Statistical mechanics of learning. Cambridge University Press, 2001.
239
+ Carl-Gustav Esseen. On the Liapunov limit error in the theory of probability. Ark. Mat. Astr. Fys., 28: 1–19, 1942.
240
+ Spencer Frei, Yuan Cao, and Quanquan Gu. Agnostic learning of a single neuron with gradient descent. Advances in Neural Information Processing Systems, 33:5417–5428, 2020.
241
+ Spencer Frei, Niladri S Chatterji, and Peter L Bartlett. Random feature amplification: Feature learning and generalization in neural networks. arXiv preprint arXiv:2202.07626, 2022.
242
+ Elizabeth Gardner and Bernard Derrida. Three unfinished works on the optimal storage capacity of networks. Journal of Physics A: Mathematical and General, 22(12):1983, 1989.
243
+ Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pages 249–256. JMLR Workshop and Conference Proceedings, 2010.
244
+ Surbhi Goel, Sushrut Karmalkar, and Adam Klivans. Time/accuracy tradeoffs for learning a ReLU with respect to Gaussian marginals. Advances in Neural Information Processing Systems, 32, 2019.
245
+ Oded Goldreich and Leonid A Levin. A hard-core predicate for all one-way functions. In Proceedings of the twenty-first annual ACM symposium on Theory of computing, pages 25–32, 1989.
246
+ Sebastian Goldt, Madhu Advani, Andrew M Saxe, Florent Krzakala, and Lenka Zdeborová. Dynamics of stochastic gradient descent for two-layer neural networks in the teacher-student setup. Advances in neural information processing systems, 32, 2019.
247
+ Michael Hahn. Theoretical limitations of self-attention in neural sequence models. Transactions of the Association for Computational Linguistics, 8:156–171, 2020.
248
+ D Hansel, G Mato, and C Meunier. Memorization without generalization in a multilayered neural network. EPL (Europhysics Letters), 20(5):471, 1992.
249
+ Godfrey Harold Hardy, John Edensor Littlewood, George Pólya, György Pólya, et al. Inequalities. Cambridge University Press, 1952.
250
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of the IEEE international conference on computer vision, pages 1026–1034, 2015.
251
+ Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022.
252
+ Yuval Ishai, Eyal Kushilevitz, Rafail Ostrovsky, and Amit Sahai. Cryptography with constant computational overhead. In Proceedings of the 40th Annual ACM Symposium on the Theory of Computing, pages 433–442, 2008.
253
+ Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. Advances in neural information processing systems, 31, 2018.
254
+ Ziwei Ji and Matus Telgarsky. Polylogarithmic width suffices for gradient descent to achieve arbitrarily small test error with shallow relu networks. arXiv preprint arXiv:1909.12292, 2019.
255
+ Y Kabashima. Perfect loss of generalization due to noise in ${ \bf k } = 2$ parity machines. Journal of Physics A: Mathematical and General, 27(6):1917, 1994.
256
+
257
+ Pritish Kamath, Omar Montasser, and Nathan Srebro. Approximate is good enough: Probabilistic variants of dimensional and margin complexity. In Conference on Learning Theory, pages 2236– 2262. PMLR, 2020.
258
+
259
+ Michael Kearns. Efficient noise-tolerant learning from statistical queries. Journal of the ACM (JACM), 45(6):983–1006, 1998.
260
+
261
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
262
+
263
+ Adam Klivans and Pravesh Kothari. Embedding hard learning problems into gaussian space. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM 2014). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2014.
264
+
265
+ Adam R Klivans, Ryan O’Donnell, and Rocco A Servedio. Learning intersections and thresholds of halfspaces. Journal of Computer and System Sciences, 68(4):808–840, 2004.
266
+
267
+ Gillat Kol, Ran Raz, and Avishay Tal. Time-space hardness of learning sparse parities. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, pages 1067–1080, 2017.
268
+
269
+ Eyal Kushilevitz and Yishay Mansour. Learning decision trees using the fourier spectrum. SIAM Journal on Computing, 22(6):1331–1348, 1993.
270
+
271
+ Beatrice Laurent and Pascal Massart. Adaptive estimation of a quadratic functional by model selection. Annals of Statistics, pages 1302–1338, 2000.
272
+
273
+ Bingbin Liu, Jordan T Ash, Surbhi Goel, Akshay Krishnamurthy, and Cyril Zhang. Transformers learn shortcuts to automata. arXiv preprint arXiv:2210.10749, 2022.
274
+
275
+ Kevin Lu, Aditya Grover, Pieter Abbeel, and Igor Mordatch. Pretrained transformers as universal computation engines. arXiv preprint arXiv:2103.05247, 2021.
276
+
277
+ Eran Malach and Shai Shalev-Shwartz. Is deeper better only when shallow is good? Advances in Neural Information Processing Systems, 32, 2019.
278
+
279
+ Eran Malach and Shai Shalev-Shwartz. When hardness of approximation meets hardness of learning. Journal of Machine Learning Research, 23(91):1–24, 2022.
280
+
281
+ Eran Malach, Pritish Kamath, Emmanuel Abbe, and Nathan Srebro. Quantifying the benefit of using differentiable learning over tangent kernels. In International Conference on Machine Learning, pages 7379–7389. PMLR, 2021.
282
+
283
+ GJ Mitchison and RM Durbin. Bounds on the learning capacity of some multi-layer networks. Biological Cybernetics, 60(5):345–365, 1989.
284
+
285
+ Neel Nanda and Tom Lieberum. A mechanistic interpretability analysis of grokking. Alignment Forum, 2022. URL https://www.alignmentforum.org/posts/N6WM6hs7RQMKDhYjB/ a-mechanistic-interpretability-analysis-of-grokking.
286
+
287
+ Ryan O’Donnell. Analysis of Boolean functions. Cambridge University Press, 2014.
288
+
289
+ Manfred Opper. Learning and generalization in a two-layer neural network: The role of the vapnikchervonvenkis dimension. Physical review letters, 72(13):2113, 1994.
290
+
291
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. PyTorch: An imperative style, high-performance deep learning library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché- Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 8024–8035. Curran Associates, Inc., 2019. URL http://papers.neurips.cc/paper/ 9015-pytorch-an-imperative-style-high-performance-deep-learning-library. pdf.
292
+
293
+ Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets. arXiv preprint arXiv:2201.02177, 2022.
294
+
295
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
296
+
297
+ Nasim Rahaman, Aristide Baratin, Devansh Arpit, Felix Draxler, Min Lin, Fred Hamprecht, Yoshua Bengio, and Aaron Courville. On the spectral bias of neural networks. In International Conference on Machine Learning, pages 5301–5310. PMLR, 2019.
298
+ Maria Refinetti, Sebastian Goldt, Florent Krzakala, and Lenka Zdeborová. Classifying highdimensional gaussian mixtures: Where kernel methods fail and neural networks succeed. In International Conference on Machine Learning, pages 8936–8947. PMLR, 2021.
299
+ Michal Rosen-Zvi, Einat Klein, Ido Kanter, and Wolfgang Kinzel. Mutual learning in a tree parity machine and its application to cryptography. Physical Review E, 66(6):066135, 2002.
300
+ David Saad and Sara Solla. Dynamics of on-line gradient descent learning for multilayer neural networks. Advances in neural information processing systems, 8, 1995a.
301
+ David Saad and Sara A Solla. On-line learning in soft committee machines. Physical Review E, 52 (4):4225, 1995b.
302
+ Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
303
+ Shai Shalev-Shwartz, Ohad Shamir, and Shaked Shammah. Failures of gradient-based deep learning. In International Conference on Machine Learning, pages 3067–3075. PMLR, 2017.
304
+ Zhenmei Shi, Junyi Wei, and Yingyu Liang. A theoretical analysis on feature learning in neural networks: Emergence from inputs and advantage over fixed features. In International Conference on Learning Representations, 2021.
305
+ Roberta Simonetti and Nestor Caticha. On-line learning in parity machines. Journal of Physics A: Mathematical and General, 29(16):4859, 1996.
306
+ Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint arXiv:2206.04615, 2022.
307
+ Matus Telgarsky. Feature selection with gradient descent on two-layer networks in low-rotation regimes. arXiv preprint arXiv:2208.02789, 2022.
308
+ Robert C Titsworth. Correlation properties of cyclic sequences. PhD thesis, California Institute of Technology, 1962.
309
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
310
+ Martin J Wainwright. High-dimensional statistics: A non-asymptotic viewpoint, volume 48. Cambridge University Press, 2019.
311
+ Timothy LH Watkin, Albrecht Rau, and Michael Biehl. The statistical mechanics of learning a rule. Reviews of Modern Physics, 65(2):499, 1993.
312
+ Colin Wei, Jason D Lee, Qiang Liu, and Tengyu Ma. Regularization matters: generalization and optimization of neural nets vs their induced kernel. Advances in Neural Information Processing Systems, 32, 2019.
313
+ Gilad Yehudai and Shamir Ohad. Learning a single neuron with gradient methods. In Conference on Learning Theory, pages 3756–3786. PMLR, 2020.
314
+ Gilad Yehudai and Ohad Shamir. On the power and limitations of random features for understanding neural networks. Advances in Neural Information Processing Systems, 32, 2019.
315
+ Jingzhao Zhang, Sai Praneeth Karimireddy, Andreas Veit, Seungyeon Kim, Sashank Reddi, Sanjiv Kumar, and Suvrit Sra. Why are adaptive methods good for attention models? Advances in Neural Information Processing Systems, 33:15383–15393, 2020.
316
+
317
+ # Checklist
318
+
319
+ 1. For all authors...
320
+
321
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
322
+
323
+ (b) Did you describe the limitations of your work? [Yes]
324
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
325
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
326
+
327
+ 2. If you are including theoretical results...
328
+
329
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
330
+
331
+ 3. If you ran experiments...
332
+
333
+ (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]
334
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
335
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
336
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
337
+
338
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
339
+
340
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
341
+ (b) Did you mention the license of the assets? [N/A]
342
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
343
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
344
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
345
+
346
+ 5. If you used crowdsourcing or conducted research with human subjects...
347
+
348
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
349
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
350
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/98p5x51L5af/98p5x51L5af.md ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PROMPTING GPT-3 TO BE RELIABLE
2
+
3
+ Chenglei $\mathbf { S i } ^ { 1 : }$ ∗, Zhe $\mathbf { G a n ^ { 2 } }$ , Zhengyuan Yang2, Shuohang Wang2
4
+ Jianfeng $\mathbf { W a n g ^ { 2 } }$ , Jordan Boyd-Graber1, Lijuan Wang2
5
+
6
+ University of Maryland 2 Microsoft clsi@umd.edu pkuganzhe@gmail.com lijuanw@microsoft.com
7
+
8
+ # ABSTRACT
9
+
10
+ Large language models (LLMs) show impressive abilities via few-shot prompting. Commercialized APIs such as OpenAI GPT-3 further increase their use in real-world language applications. However, the crucial problem of how to improve the reliability of GPT-3 is still under-explored. While reliability is a broad and vaguely defined term, we decompose reliability into four main facets that correspond to the existing framework of ML safety and are well-recognized to be important: generalizability, social biases, calibration, and factuality. Our core contribution is to establish simple and effective prompts that improve GPT-3’s reliability as it: 1) generalizes out-of-distribution, 2) balances demographic distribution and uses natural language instructions to reduce social biases, 3) calibrates output probabilities, and 4) updates the LLM’s factual knowledge and reasoning chains. With appropriate prompts, GPT-3 is more reliable than smaller-scale supervised models on all these facets. We release all processed datasets, evaluation scripts, and model predictions.1 Our systematic empirical study not only sheds new insights on the reliability of prompting LLMs, but more importantly, our prompting strategies can help practitioners more reliably use LLMs like GPT-3.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ NLP is dominated by large language models (LLMs) — pretrained on large, unlabeled text data — that are then used for downstream tasks (Devlin et al., 2019a; Brown et al., 2020). Scaling the model and data size often brings gains on downstream tasks (Kaplan et al., 2020; BIG-Bench, 2022), allowing what some call emergent abilities (Wei et al., 2022a). These emergent behaviors are accomplished through prompting—a crafted, natural language text to shape predictions or offer relevant information without expensive supervised data. Among all the existing LLMs, GPT-3 (Brown et al., 2020) is particularly popular due to its flexibility and ease of use from the OpenAI API 2.
15
+
16
+ Existing empirical studies investigate GPT-3 on specific tasks such as mathematical reasoning (Hendrycks et al., 2021a), multi-hop reasoning (Wei et al., 2022b; Kojima et al., 2022), and code generation (Chen et al., 2021a). However, rising numbers on these evaluations do not ensure LLM reliability. For example, LLMs (including GPT-3) produce biased (Lucy & Bamman, 2021) generations, false statements (Lin et al., 2022b), and outdated information (Chen et al., 2021b; Kasai et al., 2022). Deploying such models in the real world could result in catastrophic harm.
17
+
18
+ In the context of prompting LLMs, several previous works have explored their reliability. For example, in the release reports of GPT-3 (Brown et al., 2020), OPT (Zhang et al., 2022), Gopher (Rae et al., 2021) and PaLM (Chowdhery et al., 2022), there are dedicated experiments evaluating these LLMs’ representational bias and toxicity. Another line of work has evaluated calibration (Lin et al., 2022a; Kadavath et al., 2022) of prompting-based LLMs on math questions or multiple-choice questions. We differ from these prior works in two key aspects: (i) We perform a more comprehensive study of four core facets of reliability, serving as a meta-analysis. (ii) We focus particularly on finding prompting strategies that are effective under these reliability facets, rather than just evaluating intrinsic model characteristics (Figure 1).
19
+
20
+ ![](images/849363f45ae6dda5e85df4463edea45cf80803707bdb59573839e7278a9e661b.jpg)
21
+ Figure 1: Four main reliability factors we examined and the core findings.
22
+
23
+ Our reliability testing framework takes inspiration from the survey of unsolved problems in ML safety (Hendrycks et al., 2021b): withstanding hazards (generalizability), identifying hazards (calibration), steering ML systems and reducing deployment hazards (reducing social biases and improving factuality). These facets also aim to address the risks of ML systems identified in existing conceptual frameworks (Tan et al., 2022; 2021). We have a more extensive discussion of related works in Appendix Section A.
24
+
25
+ As summarized in Figure 1, our simple prompting strategies beat smaller-scale supervised models on all reliability metrics we consider: 1) prompting with randomly sampled examples from the source domain allows GPT-3 to generalize robustly on unseen domains and challenge examples; 2) examples sampled from a balanced demographic distribution and natural language intervention reduce social biases; 3) language model probabilities are calibrated to reflect accuracy; and 4) appending up-to-date knowledge can supplant GPT-3’s memorized knowledge or reasoning chains.
26
+
27
+ # 2 FACET 1: GENERALIZABILITY
28
+
29
+ LLMs are often criticized for missing the forest for the trees. They overfit training data from a particular domain (domain shift), are not robust to minor changes in a text (perturbations), or use shortcuts to make predictions (spurious correlations). These pathologies make models unreliable since these distribution shifts happen all the time in real-world data and could incur significant performance drops. In this section, we study whether GPT-3 can stay robust when the test data come from different distributions than the demo examples in the prompt, and how their generalization compares to supervised models.
30
+
31
+ Experiment Setup We study all three types of distribution shifts mentioned above. For each of them, researchers have created datasets that target modern language models’ weaknesses which we adopt for evaluation. For domain shift, MRQA (Fisch et al., 2019) trains on six machine reading datasets from the source domain and tests on six different target domains; for perturbations, AdvGLUE (Wang et al., 2021) craft adversarial versions of GLUE (Wang et al., 2018) based on automatic adversarial perturbations and human filtering, and Contrast Sets (Gardner et al., 2020) are expert-authored minimal edits that change the label; for spurious correlation, HANS (McCoy et al., 2019) and PAWS (Zhang et al., 2019) are challenge sets designed for models trained on MNLI and
32
+
33
+ <table><tr><td></td><td colspan="3">MRQA</td><td colspan="3">AdvGLUE</td><td colspan="3">Contrast Set</td></tr><tr><td></td><td>Source↑</td><td>Target↑</td><td>Gap↓</td><td>|Original↑</td><td>Perturbed个</td><td>Gap↓</td><td>|Original↑</td><td>Perturbed↑</td><td>Gap↓</td></tr><tr><td>RoBERTa</td><td>81.6</td><td>62.1</td><td>19.5</td><td>91.7</td><td>51.7</td><td>40.0</td><td>86.1</td><td>71.1</td><td>15.0</td></tr><tr><td>GPT-3</td><td>79.8</td><td>77.2 (S)/77.2 (T)</td><td>2.6</td><td>84.2</td><td>69.3</td><td>14.9</td><td>85.5</td><td>80.0</td><td>5.5</td></tr></table>
34
+
35
+ Table 1: For GPT-3 on MRQA target domain test sets, we report results for using both demos from the source (S) and target (T) domains, which surprisingly achieve the same F1 on the target domains (77.2). For AdvGLUE and Contrast Set, we use accuracy as the metric and we use demos from the clean data as the prompt. In all cases, GPT-3 few-shot prompting incurs much smaller performance gaps on the OOD or challenge test sets than the supervised RoBERTa (123M) baseline. We include the comparison with many other supervised baselines in Appendix B and GPT-3 exhibits better generalization than all of them.
36
+
37
+ QQP where the lexical overlap feature in the training data does not hold during testing. For each of these settings, we evaluate a simple prompting strategy by sampling examples from the source domains (for MRQA, we use a fixed prompt consisting of eight randomly sampled examples from the source domain on all target datasets; for perturbations and spurious correlation, we randomly sample 16 demos from the original clean training data from GLUE, MNLI, and QQP respectively). In addition, for domain shift, we also consider a prompt where we sample eight examples from the training set of each target domain to ablate the impact of the distribution of the demo examples.
38
+
39
+ Results Table 1 and Table 2 compare supervised RoBERTa (Liu et al., 2019) and BERT (Devlin et al., 2019b) models trained on the source domain datasets or the clean training data with GPT-3 that uses examples sampled from the same training data as in the supervised models. 3 GPT-3 achieves higher accuracy on the OOD tests even when it is slightly worse on the in-domain test sets than the supervised baselines, leading to smaller generalization gaps. This shows that prompting GPT-3 can be more robust than supervised finetuning of smaller-scale language models. Surprisingly, we compare using demo examples sampled from the source domains versus target domains on MRQA, and both prompting methods give the same OOD generalization results, indicating that GPT-3 prompts can directly generalize to OOD test sets where the test examples are from a different distribution than the prompt demo distribution, possibly because the role of demonstration examples is more in specifying the task rather than informing the input distribution (Min et al., 2022).
40
+
41
+ Table 2: When using demos sampled from MNLI and QQP, GPT-3 few-shot prompting achieves much better generalization than smaller supervised models (BERT and RoBERTa) on the OOD test sets HANS and PAWS.
42
+
43
+ <table><tr><td>BERT (340M)</td><td>RoBERTa GPT-3 (354M)</td></tr><tr><td>MNLI</td><td>→HANS</td></tr><tr><td>MNLI个 86.2 HANS个 71.4 Gap↓ 14.8</td><td>89.1 77.6 77.1 75.3</td></tr><tr><td>QQP →PAWS</td><td>12.0 2.3</td></tr><tr><td>QQP↑ 91.3</td><td>89.0</td></tr><tr><td>PAWS个 40.1</td><td>83.5 39.5 73.7</td></tr><tr><td>Gap↓ 51.2</td><td>49.5 9.8</td></tr></table>
44
+
45
+ Takeaway (i) Few-shot prompting of GPT-3 is more robust than supervised models such as finetuned BERT and RoBERTa, under all three settings (domain shift, perturbations, spurious correlation). (ii) Using randomly sampled demos from the source datasets is a simple but strong baseline, in fact, it performs the same as using demos sampled from the target distributions.
46
+
47
+ # 3 FACET 2: SOCIAL BIAS AND FAIRNESS
48
+
49
+ Apart from high performance on in-domain and OOD datasets, the second key facet of reliability is that we expect models to be fair to different demographic groups. Biased models cause severe harm when deployed in real-world applications, especially to the minority groups being discriminated against (Cao et al., 2022). In this section, we examine whether GPT-3 produces biased predictions in two downstream tasks - coreference resolution and question answering.
50
+
51
+ Table 3: GPT-3 results on WinoBias. The bias gap between Pro-Bias subsets and Anti-Bias subsets indicates the extent of gender biases exhibited by the model (smaller-scale gap is better). Results of the baseline ECE model (Lee et al., 2017) are taken from the WinoBias paper (Zhao et al., 2018). Prompt with balanced pro-bias and anti-bias answers best shrinks the bias gap, and randomly shuffling the demos is better than putting one group at the end.
52
+
53
+ <table><tr><td>Prompt</td><td>Type IPro↑</td><td>Type I Anti↑</td><td>Gap|</td><td>Type II Pro↑</td><td>Type II Anti个</td><td>Gap|</td></tr><tr><td colspan="7">Supervised Baseline</td></tr><tr><td>E2E (Lee et al.,2017)</td><td>74.9</td><td>47.4</td><td>27.2</td><td>88.6</td><td>77.3</td><td>11.3</td></tr><tr><td colspan="7">GPT-3Few-Shot: Bias Distribution in the Prompt (16 shots)</td></tr><tr><td>Balanced</td><td>89.2</td><td>81.1</td><td>8.1</td><td>99.2</td><td>95.5</td><td>3.7</td></tr><tr><td>Type I - Pro</td><td>93.4</td><td>42.4</td><td>51.0</td><td>91.1</td><td>78.9</td><td>12.2</td></tr><tr><td>Type II - Pro</td><td>87.6</td><td>59.5</td><td>28.1</td><td>100.0</td><td>98.7</td><td>1.3</td></tr><tr><td>Type I - Anti</td><td>50.8</td><td>80.8</td><td>-30.0</td><td>57.4</td><td>51.1</td><td>6.3</td></tr><tr><td>Type II - Anti</td><td>85.5</td><td>68.2</td><td>17.3</td><td>100.0</td><td>99.5</td><td>0.5</td></tr><tr><td colspan="7">GPT-3 Few-Shot: Prompt Ordering (16 shots, Balanced)</td></tr><tr><td>Randomly Shuffled</td><td>89.2</td><td>81.1</td><td>8.1</td><td>99.2</td><td>95.5</td><td>3.7</td></tr><tr><td>Pro in the end</td><td>89.5</td><td>76.3</td><td>13.2</td><td>93.7</td><td>81.8</td><td>11.9</td></tr><tr><td>Anti in the end</td><td>94.2</td><td>73.2</td><td>21.0</td><td>95.5</td><td>87.1</td><td>8.4</td></tr></table>
54
+
55
+ # 3.1 THE CASE OF GENDER BIAS: WINOBIAS
56
+
57
+ Dataset We start with the WinoBias dataset (Zhao et al., 2018) which uses templates to check whether models are more likely to assign gender pronouns to stereotypical occupations. WinoBias has two types of examples: Type I are ambiguous, challenging examples that require world knowledge; Type II can be resolved using only syntactic information. For each type, examples either confirm (pro-bias) or challenge (anti-bias) societal biases. Ideally, coreference accuracy should be similar on the pro-bias and anti-bias subsets (small gaps).
58
+
59
+ Prompt Design For ease of evaluation, we re-format the WinoBias dataset into a questionanswering format where we provide the original sentence and then add a question “What does the pronoun refer to in the above sentence?” (“the pronoun” is replaced with the actual pronoun in the sentence) and we use the answer exact match as the evaluation metric. We randomly sample examples from the training set as the prompt and then evaluate on the Pro and Anti test sets.
60
+
61
+ Which Examples Should be in the Prompt We compare: 1) sampling four demo examples from each of the Type I-Pro, Type I-Anti, Type II-Pro, and Type II-Anti subsets (Balanced), which results in a total of 16 demos; 2) sampling 16 demo examples from a single subset. The balanced prompt induces the least biased predictions (Table 3, second block). In particular, if we only keep Pro-Bias examples, the model will favor Pro-Bias predictions (especially on Type I test examples because they are more ambiguous while Type II examples have clear syntax cues).
62
+
63
+ How Should Examples be Ordered We compare: 1) randomly shuffling the demo examples; and 2) putting all Pro-Bias or Anti-Bias examples at the end of the prompt. Random shuffling reduces bias gaps most (Table 3, third block). Interestingly, putting either Pro-Bias or Anti-Bias examples at the end increases bias gaps.
64
+
65
+ # 3.2 BROADER SOCIAL DIMENSIONS: BBQ
66
+
67
+ Dataset We now explore additional social dimensions using BBQ (Parrish et al., 2022), which tests social biases against people from nine protected classes (age, disability status, gender identity, nationality, physical appearance, race, religion, socio-economic status, sexual orientation). BBQ examples are in sets of four multiple-choice questions. Two questions are ambiguous—the context lacks evidence to point to an answer. Two other questions in each set have a context that points to an unambiguous answer: the model should choose the correct answer rather than abstaining. Each question has three options: a pro-bias answer that supports the stereotype, an anti-bias answer that counters the stereotype, and a neutral answer (e.g., “Cannot be determined.”). When reporting results, we report: 1) accuracy on ambiguous and unambiguous questions (higher is better); 2) bias scores on ambiguous and disambiguated questions (smaller scale is better). Intuitively, the bias score measures the frequency of the model predicting a pro-bias answer when it makes a non-unknown prediction, where $0 \%$ means no bias and $100 \%$ means always following the bias.
68
+
69
+ Table 4: Results on the BBQ dataset. For GPT-3 prompting, apart from the zero-shot result, others use 8-shots. For accuracy (Acc), higher value is better; for bias score, lower magnitude is better. The balanced prompt best trades-off accuracy and bias for GPT-3.
70
+
71
+ <table><tr><td>Prompt</td><td>Ambig Acc↑</td><td>DisAmbig Acc↑</td><td>Ambig Bias ScoreI</td><td>DisAmbig Bias Score|l</td></tr><tr><td colspan="5">Supervised Baselines</td></tr><tr><td>RoBERTa-Base (123M)</td><td>61.2</td><td>52.7</td><td>4.9</td><td>4.7</td></tr><tr><td>RoBERTa-Large (354M)</td><td>49.4</td><td>87.3</td><td>10.4</td><td>1.2</td></tr><tr><td>DeBERTa-Base (184M)</td><td>47.6</td><td>90.4</td><td>12.8</td><td>2.9</td></tr><tr><td>DeBERTa-Large (435M)</td><td>30.1</td><td>95.5</td><td>24.7</td><td>-1.0</td></tr><tr><td colspan="5">GPT-3Few-Shot Prompting</td></tr><tr><td>0-shot</td><td>60.5</td><td>43.2</td><td>3.7</td><td>4.4</td></tr><tr><td>BBQBalanced</td><td>96.8</td><td>76.0</td><td>2.4</td><td>1.5</td></tr><tr><td>BBQ Ambig-Neutral</td><td>99.9</td><td>13.2</td><td>0.0</td><td>-3.5</td></tr><tr><td>BBQ Ambig-Pro-Bias</td><td>2.6</td><td>97.3</td><td>24.7</td><td>3.2</td></tr><tr><td>BBQ Ambig-Anti-Bias</td><td>2.5</td><td>97.0</td><td>23.6</td><td>3.1</td></tr></table>
72
+
73
+ Table 5: The impact of adding natural language intervention to a biased prompt on GPT-3. Adding an instruction leads the model to make more neutral predictions and reduce bias scores.
74
+
75
+ <table><tr><td>Prompt</td><td>Ambig Acc↑</td><td>DisAmbig Acc↑</td><td>Ambig Bias Score</td><td>DisAmbig Bias Score↓</td></tr><tr><td>Before Intervention</td><td>2.6</td><td>97.3</td><td>24.7</td><td>3.2</td></tr><tr><td>After Intervention</td><td>96.6</td><td>51.5</td><td>1.9</td><td>3.8</td></tr></table>
76
+
77
+ Answer Distribution Affects Biases We sample the same number of demo examples with different answer distributions (Table 4). With zero-shot inference, GPT-3’s low bias is balanced by low accuracy. A balanced prompt—where we sample both ambiguous and disambiguated questions with pro-bias and anti-bias answers—increases accuracy while maintaining low bias scores. Next, when we only present ambiguous questions with neutral answers in the prompt, GPT-3 can easily pick up this pattern to always predict the neutral answer, resulting in extremely low bias scores and high accuracy on ambiguous questions, but sacrificing accuracy on the disambiguated questions. Lastly, we experiment with using biased prompts where we only sample ambiguous questions in the prompt, and we set their answers to either all bias-supporting or bias-countering. As shown in the last two rows in Table 4, both cases lead to a biased model that gets high bias scores on ambiguous questions. This shows that when the demo examples are biased towards certain demographic groups, GPT-3 will pick up such biases, and thus one should prefer a balanced prompt in downstream applications.
78
+
79
+ Natural Language Intervention Mitigates Biases Lastly, we explore the possibility of using natural language instructions to guide the predictions of GPT-3 towards better fairness. We use the Ambig-Pro-Bias prompt and prepend the additional instruction: “We should treat people from different socioeconomic statuses, sexual orientations, religions, races, physical appearances, nationalities, gender identities, disabilities, and ages equally. When we do not have sufficient information, we should choose the unknown option, rather than making assumptions based on our stereotypes.” to every test question. In Table 5, after adding this intervention, GPT-3 prefers the neutral answer much more often, leading to a much higher accuracy on the ambiguous questions, and at the same time significantly reducing the bias scores. This shows that GPT-3 is sensitive to such natural language intervention. This is in contrast with smaller language models such as RoBERTa (Zhao et al., 2021a), which is more rigid. This finding offers a new way for effectively reducing social biases.
80
+
81
+ Takeaway (i) Demographic distribution of answers has huge impact on models’ biases, sampling balanced prompt best reduces biases. (ii) Randomly shuffling the demos leads to smaller biases than putting all pro-bias or anti-bias examples in the end. (iii) Specifying intended model behaviors such as being fair via instructions in the prompt can effectively guide model predictions.
82
+
83
+ # 4 FACET 3: UNCERTAINTY CALIBRATION
84
+
85
+ No language model can ever be perfect, and to safely use these imperfect models, users must decide when to trust model predictions to avoid mistrusting wrong predictions, especially in high-stake settings. This requires another facet of reliability - uncertainty calibration: providing confidence scores for each model prediction that accurately reflects the likelihood of the predicted answer being correct.
86
+
87
+ # 4.1 EVALUATION SETUP
88
+
89
+ Experiment Setup We study the setting of freeform answer generation: given a test question, we prompt the model to generate an answer string and obtain its confidence score (more below), and we evaluate the correctness of the generated answer based on exact match with the gold answer. We experiment with three QA datasets: NQ, TriviaQA, and HotpotQA. In all cases, we adopt the closedbook setting (i.e., no additional evidence passages). We focus on intrinsic calibration results: using raw confidence scores rather than post-hoc calibration, which requires an additional dev set for parametertuning. We report the standard calibration metric expected calibration error (ECE), the reliability diagram,4 and selective prediction results where we rank all predictions by their confidence and see if the accuracy of the most confident predictions is significantly higher than the average accuracy. Because of ECE’s known flaws due to its bucketing mechanism (Si et al., 2022), so we also report the Brier score (Brier, 1950). Our baseline is a supervised QA model—DPR-BERT (Si et al., 2022)— with a dense passage retriever (DPR; Karpukhin et al., 2020) to feed the top passages into a BERT reader model for answer extraction. We follow their joint calibration setup for scoring predictions of DPR-BERT.
90
+
91
+ <table><tr><td colspan="4">AcC↑ ECE↓</td></tr><tr><td colspan="2">NQ</td><td></td><td>Brier</td></tr><tr><td>DPR-BERT (110M)</td><td>36.1</td><td>29.4</td><td>33.5</td></tr><tr><td>GPT-3LMProb</td><td>40.5</td><td>18.9</td><td>23.3</td></tr><tr><td>GPT-3 Self-Con</td><td>40.2</td><td>14.3</td><td>20.1</td></tr><tr><td colspan="4">TriviaQA (TQA)</td></tr><tr><td>GPT-3 LMProb</td><td>73.8</td><td>3.8</td><td>15.9</td></tr><tr><td>GPT-3 Self-Con</td><td>73.2</td><td>11.9</td><td>16.5</td></tr><tr><td colspan="4">HotpotQA</td></tr><tr><td>GPT-3 LMProb</td><td>(HQA) 29.8</td><td>25.0</td><td>23.5</td></tr><tr><td>GPT-3 Self-Con</td><td>28.5</td><td>20.7</td><td>19.9</td></tr><tr><td colspan="4">Different Prompts on NQ w/l /LM-Prob</td></tr><tr><td>GPT-3 2-shot</td><td>37.0</td><td>11.7</td><td>20.8</td></tr><tr><td>GPT-3 4-shot</td><td>38.3</td><td>13.4</td><td>21.0</td></tr><tr><td>GPT-3 8-shot</td><td>38.8</td><td>24.4</td><td>25.5</td></tr><tr><td>GPT-3 16-shot</td><td>40.5</td><td>18.9</td><td>23.3</td></tr><tr><td>GPT-3 64-shot</td><td>42.8</td><td>13.4</td><td>22.1</td></tr><tr><td colspan="4">OOD Prompts w/ LM-Prob</td></tr><tr><td>TQA i.i.d. Prompt</td><td>73.8</td><td>3.8</td><td>15.9</td></tr><tr><td>NQ Prompt on TQA</td><td>73.0</td><td>1.6</td><td>15.2</td></tr><tr><td>DPR-BERT NQ→TQA</td><td>33.1</td><td>33.1</td><td>35.2</td></tr><tr><td>HQA i.i.d. Prompt</td><td>29.8</td><td>25.0</td><td>23.5</td></tr><tr><td>NQ Prompt on HQA</td><td>27.7</td><td>24.1</td><td>25.2</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>DPR-BERT NQ→HQA</td><td>23.6</td><td>45.7</td><td>42.4</td></tr></table>
92
+
93
+ Table 6: Accuracy, ECE, and Brier scores of GPT-3 and the DPR-BERT baseline. GPT-3 is better calibrated than supervised DPR-BERT on both in-domain and OOD settings.
94
+
95
+ Confidence Scoring We compare two ways of estimating confidence for GPT-3 predictions. LMProb: the (normalized) language model probability, also equivalent to the reciprocal of perplexity, is $C o n f \equiv P ( w _ { 1 } w _ { 2 } \dots w _ { n } ) ^ { \frac { 1 } { N } }$ where $w _ { 1 } w _ { 2 } \ldots w _ { n }$ are the generated tokens in the answer. SelfCon: We also explore using self-consistency (Wang et al., 2023) to obtain confidence measures. Following Wang et al. (2023), during decoding we set a high temperature value (0.7) and sample 10 times for a set of different predictions. Among all the generated answers, we take the most frequent answer as the final prediction and its frequency as the confidence score.
96
+
97
+ <table><tr><td></td><td>DPR-BERT NQ</td><td>LM-Prob NQ</td><td>Self-Con NQ</td><td>LM-Prob TriviaQA</td><td>LM-Prob HotpotQA</td></tr><tr><td>100%</td><td>36.1</td><td>40.5</td><td>40.2</td><td>73.8</td><td>29.8</td></tr><tr><td>50%</td><td>41.9</td><td>58.8</td><td>62.0</td><td>88.5</td><td>47.6</td></tr><tr><td>10%</td><td>60.1</td><td>83.1</td><td>77.0</td><td>95.4</td><td>68.1</td></tr></table>
98
+
99
+ Table 7: Selective prediction results. All numbers represent the accuracy (EM) at the corresponding coverage thresholds. For example, $100 \%$ means performance on the entire test set while $10 \%$ means the performance on the most confident $10 \%$ predictions. Both LM-Prob and Self-Con allow effective selective prediction with high accuracy on the most confident subsets. More results in Appendix D.
100
+
101
+ # 4.2 RESULTS
102
+
103
+ While still imperfect, GPT-3 (with either LM-Prob or Self-Con) is better calibrated than supervised DPR-BERT (Table 6). Most calibration errors come from overconfidence where the predictions’ confidence is higher than expected accuracy. Interestingly, while increasing the number of examples in the prompt improves accuracy, the calibration does not improve. For example, the 2-shot accuracy is 5.8 points worse than 64-shot but better calibrated. Moreover, while OOD transfer is a challenge for supervised models’ calibration (tends to be overconfident on OOD test sets), GPT-3 has similar calibration regardless of the source of examples.
104
+
105
+ The selective prediction results show confidence scores can rank model predictions (Table 7): the most confident predictions have much higher accuracy. Moreover, GPT-3’s confidence scores are more discriminative. For example, while the average accuracy on NQ is similar between GPT-3 and DPR-BERT, the top $10 \%$ predictions get an accuracy of $8 3 . 1 \%$ while for DPR-BERT it is only $6 0 . 1 \%$ . Such selective prediction can be very useful in practical settings, for example, we only trust the most confident predictions from the model and ask humans to verify the rest, making the use of GPT-3 more reliable.
106
+
107
+ Takeaway $( i )$ Language model probability and self-consistency frequency can produce better calibration on GPT-3 than a supervised DPR-BERT model, especially on OOD test sets. $( i i )$ Increasing the number of demos in the prompt improves accuracy but not necessarily calibration. (iii) We can perform effective selective prediction based on GPT-3 confidence scores.
108
+
109
+ # 5 FACET 4: FACTUALITY VIA KNOWLEDGE UPDATING
110
+
111
+ Although large language models store vast knowledge in their parameters (Petroni et al., 2019), the model is sometimes wrong or out of date, rendering them unreliable for knowledge-intensive tasks. In this section, we improve this factuality aspect of reliability by improving the prompting methods.
112
+
113
+ # 5.1 MEMORIZATION VS UPDATING
114
+
115
+ The larger a model, the more it can memorize (Carlini et al., 2023), this raises the concern of whether large models like GPT-3 can forget memorized knowledge when needed and update its knowledge.
116
+
117
+ Experiment Setup Our evaluation setup is inspired by Longpre et al. (2021), who reason about counterfactual scenarios. Specifically, we sample 36K and 18K questions from NQ and SQuAD’s training splits (respectively, using the splits provided by MRQA). We use 16 demo examples from each dataset as the prompt for closed-book QA first. We assume that if GPT-3 gets the answer to the question right in the closed-book setting, then it has already memorized that piece of knowledge. We keep the set of questions where GPT-3 got right in the closed-book setting (for NQ, 21188 questions; for SQuAD, 7035 questions), and for these questions, we append a counterfactual passage supporting an alternative answer. We construct these counterfactual using the entity-swap from Longpre et al. (2021): for each question, take its gold passage and replace the gold answer entity with another entity with the same type sampled from the same QA corpus. After such entity substitution, the counterfactual passages support the substituted answer instead of the original answer. Our expectation is that the model should generate this updated answer given this counterfactual passage, instead of its original memorized answer. We randomly sample 16 demo examples as the prompt and we use triples of the answer-substituted passage, the question, and the substitution answers ( $\langle P$ ’, $ { \boldsymbol { Q } } , { \boldsymbol { A } } ^ { \prime } \rangle$ ) in the prompt to specify the task of performing reading comprehension based on the passage.
118
+
119
+ Table 9: GPT-3 16-shot prompting results on open-domain QA datasets. We use Exact Match as the metric. For Contriever results, we additionally show the retriever’s recall in brackets. Adding retrieval to GPT-3 consistently improves QA accuracy.
120
+
121
+ <table><tr><td></td><td>NQ</td><td>TriviaQA</td><td>SQuAD</td></tr><tr><td>DPR-BERT (supervised)</td><td>41.5</td><td>56.8</td><td>24.1</td></tr><tr><td>Atlas-11B (64-shot)</td><td>42.4</td><td>74.5</td><td>1</td></tr><tr><td>GPT-3 Closed-Book</td><td>40.6</td><td>73.6</td><td>20.2</td></tr><tr><td>+ Contriever top-5</td><td>43.3 (61.8%)</td><td>75.6 (69.6%)</td><td>31.7 (48.8%)</td></tr><tr><td>+ Contriever top-10</td><td>44.2 (70.5%)</td><td>76.0 (75.1%)</td><td>34.0 (57.7%)</td></tr></table>
122
+
123
+ Measuring How Well can GPT-3 Update its Knowledge There are three possible outcomes: 1) the model retains the memorized answer; 2) the model predicts the updated answer (i.e., the substitution entity in the counterfactual passage); 3) the model predicts some other answer. We measure the proportion of those outcomes and hope models to update answers more often. For a baseline, we include results from Longpre et al. (2021): a fine-tuned T5 reader—trained on NQ and NewsQA—model with a DPR retriever.
124
+
125
+ Results As shown in Table 8, we find that when prompting with counterfactual triples $( \langle P ^ { \prime } , Q , A ^ { \prime } \rangle )$ , GPT-3 can update about $85 \%$ of the time, much higher than the supervised baseline (Table 8). Comparing Text-Davinci-001 and Text-Curie001, the larger model also updates better to new answers in counterfactual passages
126
+
127
+ <table><tr><td colspan="3">Retain Update↑Other↓</td></tr><tr><td>NQ with Code-Davinci-002</td><td></td><td></td></tr><tr><td>T5 (770M, supervised) 20% GPT-3 4.5%</td><td>33% 85.4%</td><td>47% 10.2%</td></tr><tr><td>SQuAD with Code-Davinci-002</td><td></td><td></td></tr><tr><td>GPT-3 7.1%</td><td>84.8%</td><td>8.1%</td></tr><tr><td>NQ with different GPT-3 models</td><td></td><td></td></tr><tr><td>Text-Davinci-00l (175B) 7.2%</td><td>57.9%</td><td>34.9%</td></tr><tr><td>Text-Curie-001 (6.7B) 14.8%</td><td>40.0%</td><td>45.2%</td></tr></table>
128
+
129
+ Table 8: In-context knowledge updating results for memorized answers in NQ and SQuAD. When giving counterfactual examples in the prompt, GPT-3 updates its answers around $85 \%$ of the time, much higher compared to the supervised model. Moreover, larger models are better at in-context knowledge updating.
130
+
131
+ # 5.2 RETRIEVAL-AUGMENTED OPEN-DOMAIN QA
132
+
133
+ Large language models can answer closed-book QA from the model’s stored knowledge (Roberts et al., 2020). However, a prompt can judiciously add more relevant information especially given our findings from the previous section that GPT-3 can update its knowledge with information in the prompt. We thus explore improving factual QA via retrieval-augmented prompts.
134
+
135
+ Approach We use the unsupervised Contriever model (Izacard et al., 2022a): for a test question, retrieve the top passages from the Wikipedia dump, concatenate them, and prepend them to the test question. Since the context is length-limited, we only prepend retrieved passages to the test question, not the demo examples, so the demo examples are only in the form of question-answer pairs. We compare this retriever-augmented approach with a closed-book baseline where we do not add the retrieved passages in the prompt. The demo examples used for both the retrieval-augmented prompting and closed-book prompting are exactly the same.
136
+
137
+ Results Adding retrieved passages into the prompt consistently boosts GPT-3 performance on all three open-domain QA datasets (Table 9), with particularly large gains on SQuAD (possibly because answers in SQuAD are spans from Wikipedia passages rather than free-form answers). Moreover, having better recall for retrieval gives better performance.
138
+
139
+ <table><tr><td></td><td>Overall</td><td>Sub-Q1</td><td>Sub-Q2</td></tr><tr><td>Standard Prompting</td><td>18.0/28.1</td><td>40.1 /49.6</td><td>43.3 / 58.4</td></tr><tr><td>CoT</td><td>25.2/35.2</td><td>30.3 /37.4</td><td>1</td></tr><tr><td>CoT+ Human Sub-Q1</td><td>30.0 / 42.3</td><td>44.2 / 54.1</td><td>1</td></tr><tr><td>CoT+Human Sub-Q1 +Gold Sub-A1</td><td>44.3 / 59.0</td><td>1</td><td>1</td></tr></table>
140
+
141
+ Table 10: Results on HotpotQA as well as the decomposed sub-questions (we report EM / F1). Incorporating decomposed sub-questions in the prompt makes the model adjust its follow-up step predictions and significantly improves the overall answer accuracy.
142
+
143
+ # 5.3 REASONING-AUGMENTED MULTI-HOP QA
144
+
145
+ The above experiments demonstrate the effectiveness of ensuring GPT-3’s factuality via in-context knowledge updating; however, it is mostly constrained on simple single-hop factual questions. In real-world applications, many user queries are multi-hop - they require multiple steps of reasoning over factual knowledge. Ensuring factuality in multi-hop questions involves additional challenges: models may fail because they derive the reasoning steps wrongly. To tackle this more challenging multi-hop setting, we study whether it is possible to improve GPT-3’s multi-hop reasoning by incorporating human-written question decomposition in the prompt.
146
+
147
+ HotpotQA and Decomposed Sub-Questions We use the HotpotQA dataset (Yang et al., 2018) for our experiments, which consists of multi-hop questions that require at least two steps of reasoning. We use the question decomposition from Tang et al. (2021), where HotpotQA questions are annotated as decomposed (single-hop) sub-questions with corresponding intermediate answers.
148
+
149
+ Baseline: Chain-of-Thought Prompting Chain-of-Thought (CoT) prompting (Wei et al., 2022b) is a new prompting method tailored to multi-step questions, which we adopt in our experiments as a baseline, where we provide human-written reasoning steps for all demo examples to induce similar reasoning on test examples. We measure accuracy of GPT-3’s final answer predictions on HotpotQA (Overall) as well as on the decomposed single-hop sub-questions. From the first row of Table 10, we see that standard prompting achieves higher accuracy on the single-hop sub-questions than the entire multi-hop questions as expected. CoT generates the entire reasoning chain along with its decomposed sub-questions and the intermediate answers to sub-questions, where the accuracy on the multi-hop questions is higher than standard prompting (second row of Table 10).
150
+
151
+ Incorporating Human Decomposition Instead of relying on GPT-3 itself to generate reasoning chains, we add the human-written question decomposition into the prompt. When adding the human-written sub-questions for the first step of reasoning (second last row of Table 10), we see a clear improvement in both the overall multi-hop QA accuracy as well as the sub-question accuracy. Moreover, when we further add the human-written QA pair of the first decomposed question in the reasoning chain (last row of Table 10), there is an even larger performance gain on the multi-hop QA performance. This shows that GPT-3 is able to adapt to the question decomposition information from humans and deduce the subsequent reasoning steps to eventually obtain the correct answers, offering better control and reliability.
152
+
153
+ Takeaway $( i )$ Adding retrieved evidence passages can improve GPT-3 performance on factual QA. (ii) GPT-3 can update its knowledge when provided passages conflicting with its memorized knowledge. $( i i i )$ Incorporating human-written question decomposition corrects the reasoning chains of GPT-3 and improves performance on multi-hop QA.
154
+
155
+ # 6 CONCLUSION
156
+
157
+ Our work systematically studies the reliability of GPT-3 from four key facets: generalizability, fairness, calibration, and factuality. We develop effective prompting strategies to make GPT-3 outperform supervised models by large margins on these facets. Our work reveals new insights of LLMs and provides practical recommendations for users of GPT-3. We hope our work can inspire more future work to: (1) examine more facets of reliability, such as avoiding harmful generations; (2) apply the prompting methods in this paper to more real-world applications, such as incorporating human feedback for collaborative multi-step planning; (3) further explore more effective prompting strategies to improve reliability, such as post-hoc calibration on language model probabilities.
158
+
159
+ # ETHICAL STATEMENT
160
+
161
+ Ethical Use of GPT-3 The goal of this project is to avoid the potential harm of GPT-3 and all of our GPT-3 experiments are motivated to better study and improve reliability. We believe our experiments and findings can improve the reliability and allow safer use of the model. In particular, our section on social biases and fairness is a key aspect of the ethical use of GPT-3. We presented evidence that the model exhibits biased predictions, especially when the demo examples in the prompt have a skewed demographic distribution. Although we explored ways of mitigating these biases, the model is still far from perfect, and there is much more work needed to further improve its fairness. We take our work as an initial step towards more ethical use of GPT-3.
162
+
163
+ Limitations of This Work We note several limitations of this work and suggest a list of open questions for future work.
164
+
165
+ • Other reliability facets: In this work, we covered four key facets of reliability, but there are surely other facets that we may have missed. For example, combatting adversarial examples identified via human or AI red-teaming (Ganguli et al., 2022; Branch et al., 2022; Perez et al., 2022), detecting and handling malicious prompts such as prompt injection 5, and avoiding toxic and hallucinated generations (Gehman et al., 2020; Gao et al., 2022). • Methods for improving reliability: Although we have taken initial steps and discovered some effective prompting strategies for these reliability facets, readers should not take this work as evidence that GPT-3 is already reliable and ready for deployment. In fact, our experiments indicate ample room for further improvement, for example in reducing social biases and improving calibration. We hope this work inspires more future work that develops more effective strategies to make LLMs reliable. • Analysis to understand model behaviors: While we have found interesting properties of GPT-3, it remains unclear what exactly caused these behaviors. For example, if the small generalization gap due to the use of prompting, or the training data, or the training objectives or model architecture? When GPT-3 is sensitive to the prompt in debiasing, is it triggered by certain keywords or phrases? Why ordering anti-bias examples at the end of the prompt does not lead to the recency bias (Zhao et al., 2021b) but rather still incurs strong biases against minority groups? Can we attribute model behaviors to the pretraining data or interpret model attention patterns? These analysis can potentially help us better understand how and why prompting works and therefore allow us to better leverage LLMs.
166
+
167
+ # ACKNOWLEDGMENT
168
+
169
+ We thank Jason Phang, Ziyi Yang, Dan Friedman, Sewon Min, Jieyu Zhao, He He, Alicia Parrish, Chen Zhao, Shi Feng, Han Guo, Weijia Shi, Jungo Kasai, Xi Ye, Su Lin Blodgett, Trista Cao, Ekin Akyurek, Leo Boytsov, Aishwarya Kamath, Weijia Xu, Yankai Lin, Xiaozhi Wang, Zhengyan ¨ Zhang, and many other friends from UMD CLIP and the Azure AI team at Microsoft for their helpful discussion and feedback.
170
+
171
+ # REFERENCES
172
+
173
+ Udit Arora, William Huang, and He He. Types of out-of-distribution texts and how to detect them. In EMNLP, 2021.
174
+
175
+ Emily M. Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big? Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, 2021.
176
+
177
+ BIG-Bench. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. ArXiv, 2022. URL https://arxiv.org/abs/2206.04615.
178
+
179
+ Ben Bogin, Shivanshu Gupta, and Jonathan Berant. Unobserved local structures make compositional generalization hard. In EMNLP, 2022.
180
+
181
+ Hezekiah J. Branch, Jonathan Rodriguez Cefalu, Jeremy McHugh, Leyla Hujer, Aditya Bahl, Daniel del Castillo Iglesias, Ron Heichman, and Ramesh Darwishi. Evaluating the susceptibility of pretrained language models via handcrafted adversarial examples. ArXiv, 2022. URL https: //arxiv.org/abs/2209.02128.
182
+
183
+ Glenn W. Brier. Verification of forecasts expressed in terms of probability. Monthly Weather Review, 78:1–3, 1950.
184
+
185
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS, 2020.
186
+
187
+ Nicola De Cao, Wilker Aziz, and Ivan Titov. Editing factual knowledge in language models. In EMNLP, 2021.
188
+
189
+ Yang Trista Cao, Yada Pruksachatkun, Kai-Wei Chang, Rahul Gupta, Varun Kumar, J. Dhamala, and Aram Galstyan. On the intrinsic and extrinsic fairness evaluation metrics for contextualized language representations. In ACL, 2022.
190
+
191
+ Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan \` Zhang. Quantifying memorization across neural language models. In ICLR, 2023.
192
+
193
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harrison Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, David W. Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William H. Guss, Alex Nichol, Igor Babuschkin, S. Arun Balaji, Shantanu Jain, Andrew Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew M. Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evaluating large language models trained on code. ArXiv, 2021a. URL https: //arxiv.org/abs/2107.03374.
194
+
195
+ Wenhu Chen, Xinyi Wang, and William Yang Wang. A dataset for answering time-sensitive questions. In NeurIPS, 2021b.
196
+
197
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek B Rao, Parker Barnes, Yi Tay, Noam M. Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Benton C. Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garc´ıa, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim,
198
+
199
+ Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark D´ıaz, Orhan Firat, Michele Catasta, Jason Wei, Kathleen S. Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways. ArXiv, 2022. URL https://arxiv.org/abs/2204.02311.
200
+
201
+ Shrey Desai and Greg Durrett. Calibration of pre-trained transformers. In EMNLP, 2020.
202
+
203
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. ArXiv, abs/1810.04805, 2019a.
204
+
205
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019b.
206
+
207
+ Adam Fisch, Alon Talmor, Robin Jia, Minjoon Seo, Eunsol Choi, and Danqi Chen. MRQA 2019 shared task: Evaluating generalization in reading comprehension. In Workshop on Machine Reading for Question Answering, 2019.
208
+
209
+ Dan Friedman, Ben Dodge, and Danqi Chen. Single-dataset experts for multi-dataset question answering. In EMNLP, 2021.
210
+
211
+ Deep Ganguli, Liane Lovitt, John Kernion, Amanda Askell, Yushi Bai, Saurav Kadavath, Benjamin Mann, Ethan Perez, Nicholas Schiefer, Kamal Ndousse, Andy Jones, Sam Bowman, Anna Chen, Tom Conerly, Nova DasSarma, Dawn Drain, Nelson Elhage, Sheer El-Showk, Stanislav Fort, Zachary Dodds, T. J. Henighan, Danny Hernandez, Tristan Hume, Josh Jacobson, Scott Johnston, Shauna Kravec, Catherine Olsson, Sam Ringer, Eli Tran-Johnson, Dario Amodei, Tom B. Brown, Nicholas Joseph, Sam McCandlish, Christopher Olah, Jared Kaplan, and Jack Clark. Red teaming language models to reduce harms: Methods, scaling behaviors, and lessons learned. ArXiv, 2022. URL https://arxiv.org/abs/2209.07858.
212
+
213
+ Luyu Gao, Zhuyun Dai, Panupong Pasupat, Anthony Chen, Arun Tejasvi Chaganty, Yicheng Fan, Vincent Zhao, N. Lao, Hongrae Lee, Da-Cheng Juan, and Kelvin Guu. Attributed text generation via post-hoc research and revision. ArXiv, 2022. URL https://arxiv.org/abs/2210. 08726.
214
+
215
+ Matt Gardner, Yoav Artzi, Jonathan Berant, Ben Bogin, Sihao Chen, Dheeru Dua, Yanai Elazar, Ananth Gottumukkala, Nitish Gupta, Hannaneh Hajishirzi, Gabriel Ilharco, Daniel Khashabi, Kevin Lin, Jiangming Liu, Nelson F. Liu, Phoebe Mulcaire, Qiang Ning, Sameer Singh, Noah A. Smith, Sanjay Subramanian, Eric Wallace, Ally Zhang, and Ben Zhou. Evaluating models’ local decision boundaries via contrast sets. In Findings of EMNLP, 2020.
216
+
217
+ Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A. Smith. Realtoxicityprompts: Evaluating neural toxic degeneration in language models. In Findings of EMNLP, 2020.
218
+
219
+ Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger. On calibration of modern neural networks. In ICML, 2017.
220
+
221
+ Suchin Gururangan, Swabha Swayamdipta, Omer Levy, Roy Schwartz, Samuel R. Bowman, and Noah A. Smith. Annotation artifacts in natural language inference data. In NAACL, 2018.
222
+
223
+ Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. REALM: Retrievalaugmented language model pre-training. In ICML, 2020.
224
+
225
+ Camille Harris, Matan Halevy, Ayanna M. Howard, Amy Bruckman, and Diyi Yang. Exploring the role of grammar and word choice in bias toward african american english (aae) in hate speech classification. 2022 ACM Conference on Fairness, Accountability, and Transparency, 2022.
226
+
227
+ Dan Hendrycks, Xiaoyuan Liu, Eric Wallace, Adam Dziedzic, Rishabh Krishnan, and Dawn Xiaodong Song. Pretrained transformers improve out-of-distribution robustness. In ACL, 2020.
228
+
229
+ Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Xiaodong Song, and Jacob Steinhardt. Measuring mathematical problem solving with the math dataset. In NeurIPS, 2021a.
230
+
231
+ Dan Hendrycks, Nicholas Carlini, John Schulman, and Jacob Steinhardt. Unsolved problems in ml safety. ArXiv, 2021b. URL https://arxiv.org/abs/2109.13916.
232
+
233
+ Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, and Edouard Grave. Unsupervised dense information retrieval with contrastive learning. Transactions on Machine Learning Research, 2022a. URL https://openreview.net/ pdf?id $\cdot ^ { = }$ jKN1pXi7b0.
234
+
235
+ Gautier Izacard, Patrick Lewis, Maria Lomeli, Lucas Hosseini, Fabio Petroni, Timo Schick, Jane A. Yu, Armand Joulin, Sebastian Riedel, and Edouard Grave. Few-shot learning with retrieval augmented language models. ArXiv, 2022b. URL https://arxiv.org/abs/2208.03299.
236
+
237
+ Robin Jia and Percy Liang. Adversarial examples for evaluating reading comprehension systems. In EMNLP, 2017.
238
+
239
+ Zhengbao Jiang, J. Araki, Haibo Ding, and Graham Neubig. How can we know when language models know? on the calibration of language models for question answering. Transactions of the Association for Computational Linguistics, 9:962–977, 2021.
240
+
241
+ Di Jin, Zhijing Jin, Joey Tianyi Zhou, and Peter Szolovits. Is bert really robust? a strong baseline for natural language attack on text classification and entailment. In AAAI, 2020.
242
+
243
+ Saurav Kadavath, Tom Conerly, Amanda Askell, T. J. Henighan, Dawn Drain, Ethan Perez, Nicholas Schiefer, Zachary Dodds, Nova DasSarma, Eli Tran-Johnson, Scott Johnston, Sheer El-Showk, Andy Jones, Nelson Elhage, Tristan Hume, Anna Chen, Yushi Bai, Sam Bowman, Stanislav Fort, Deep Ganguli, Danny Hernandez, Josh Jacobson, John Kernion, Shauna Kravec, Liane Lovitt, Kamal Ndousse, Catherine Olsson, Sam Ringer, Dario Amodei, Tom B. Brown, Jack Clark, Nicholas Joseph, Benjamin Mann, Sam McCandlish, Christopher Olah, and Jared Kaplan. Language models (mostly) know what they know. ArXiv, 2022. URL https://arxiv.org/ abs/2207.05221.
244
+
245
+ Jared Kaplan, Sam McCandlish, T. J. Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeff Wu, and Dario Amodei. Scaling laws for neural language models. ArXiv, 2020. URL https://arxiv.org/abs/2001.08361.
246
+
247
+ Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Yu Wu, Sergey Edunov, Danqi ˘ Chen, and Wen tau Yih. Dense passage retrieval for open-domain question answering. In EMNLP, 2020.
248
+
249
+ Jungo Kasai, Keisuke Sakaguchi, Yoichi Takahashi, Ronan Le Bras, Akari Asai, Xinyan Yu, Dragomir Radev, Noah A. Smith, Yejin Choi, and Kentarou Inui. RealTime QA: What’s the answer right now? ArXiv, 2022. URL https://arxiv.org/abs/2207.13332.
250
+
251
+ Daniel Keysers, Nathanael Scharli, Nathan Scales, Hylke Buisman, Daniel Furrer, Sergii Kashubin, ¨ Nikola Momchev, Danila Sinopalnikov, Lukasz Stafiniak, Tibor Tihon, Dmitry Tsarkov, Xiao Wang, Marc van Zee, and Olivier Bousquet. Measuring compositional generalization: A comprehensive method on realistic data. In ICLR, 2020.
252
+
253
+ Najoung Kim and Tal Linzen. COGS: A compositional generalization challenge based on semantic interpretation. In EMNLP, 2020.
254
+
255
+ Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard L. Phillips, Sara Beery, Jure Leskovec, Anshul Kundaje, Emma Pierson, Sergey Levine, Chelsea Finn, and Percy Liang. WILDS: A benchmark of in-the-wild distribution shifts. In ICML, 2021.
256
+
257
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. In NeurIPS, 2022.
258
+
259
+ Kenton Lee, Luheng He, Mike Lewis, and Luke Zettlemoyer. End-to-end neural coreference resolution. In EMNLP, 2017.
260
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In EMNLP, 2021.
261
+ Omer Levy, Minjoon Seo, Eunsol Choi, and Luke Zettlemoyer. Zero-shot relation extraction via reading comprehension. In CoNLL, 2017.
262
+ Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Kuttler, Mike Lewis, Wen tau Yih, Tim Rocktaschel, Sebastian Riedel, and Douwe ¨ Kiela. Retrieval-augmented generation for knowledge-intensive nlp tasks. In NeurIPS, 2020.
263
+ Hongyu Li, Xiyuan Zhang, Y. Liu, Yiming Zhang, Xiangyang Zhou, and Jing Liu. D-net: A pretraining and fine-tuning framework for improving the generalization of machine reading comprehension. In EMNLP, 2019.
264
+ Linyang Li, Ruotian Ma, Qipeng Guo, X. Xue, and Xipeng Qiu. Bert-attack: Adversarial attack against bert using bert. In EMNLP, 2020.
265
+ Stephanie C. Lin, Jacob Hilton, and Owain Evans. Teaching models to express their uncertainty in words. ArXiv, 2022a. URL https://arxiv.org/abs/2205.14334.
266
+ Stephanie C. Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. In ACL, 2022b.
267
+ 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, 2019. URL https://arxiv.org/abs/1907.11692.
268
+ Shayne Longpre, Yi Lu, Zhucheng Tu, and Christopher DuBois. An exploration of data augmentation and sampling techniques for domain-agnostic question answering. In EMNLP, 2019.
269
+ Shayne Longpre, Kartik Kumar Perisetla, Anthony Chen, Nikhil Ramesh, Chris DuBois, and Sameer Singh. Entity-based knowledge conflicts in question answering. In EMNLP, 2021.
270
+ Li Lucy and David Bamman. Gender and representation bias in gpt-3 generated stories. In NUSE, 2021.
271
+ R. Thomas McCoy, Ellie Pavlick, and Tal Linzen. Right for the wrong reasons: Diagnosing syntactic heuristics in natural language inference. In ACL, 2019.
272
+ Sabrina J. Mielke, Arthur D. Szlam, Emily Dinan, and Y-Lan Boureau. Reducing conversational agents’ overconfidence through linguistic calibration. Transactions of the Association for Computational Linguistics, 10:857–872, 2022.
273
+ Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? In EMNLP, 2022.
274
+ Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D. Manning. Fast model editing at scale. In ICLR, 2021.
275
+ Eric Mitchell, Charles Lin, Antoine Bosselut, Christopher D. Manning, and Chelsea Finn. Memorybased model editing at scale. In ICML, 2022.
276
+ Moin Nadeem, Anna Bethke, and Siva Reddy. Stereoset: Measuring stereotypical bias in pretrained language models. In ACL, 2021.
277
+ Mahdi Pakdaman Naeini, Gregory F. Cooper, and Milos Hauskrecht. Obtaining well calibrated probabilities using bayesian binning. Proceedings of the AAAI Conference on Artificial Intelligence. AAAI Conference on Artificial Intelligence, 2015:2901–2907, 2015.
278
+ Nikita Nangia, Clara Vania, Rasika Bhalerao, and Samuel R. Bowman. Crows-pairs: A challenge dataset for measuring social biases in masked language models. In EMNLP, 2020.
279
+
280
+ Alicia Parrish, Angelica Chen, Nikita Nangia, Vishakh Padmakumar, Jason Phang, Jana Thompson, Phu Mon Htut, and Sam Bowman. BBQ: A hand-built bias benchmark for question answering. In Findings of ACL, 2022.
281
+
282
+ Ethan Perez, Saffron Huang, Francis Song, Trevor Cai, Roman Ring, John Aslanides, Amelia Glaese, Nathan McAleese, and Geoffrey Irving. Red teaming language models with language models. ArXiv, 2022. URL https://arxiv.org/abs/2202.03286.
283
+
284
+ Fabio Petroni, Tim Rocktaschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H. Miller, ¨ and Sebastian Riedel. Language models as knowledge bases? In EMNLP, 2019.
285
+
286
+ Fabio Petroni, Aleksandra Piktus, Angela Fan, Patrick Lewis, Majid Yazdani, Nicola De Cao, James Thorne, Yacine Jernite, Vassilis Plachouras, Tim Rocktaschel, and Sebastian Riedel. Kilt: a benchmark for knowledge intensive language tasks. In NAACL, 2021.
287
+
288
+ John Platt. Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods. Advances in Large Margin Classifiers, 1999.
289
+
290
+ Adam Poliak, Jason Naradowsky, Aparajita Haldar, Rachel Rudinger, and Benjamin Van Durme. Hypothesis only baselines in natural language inference. In SemEval, 2018.
291
+
292
+ Jack W. Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, Eliza Rutherford, Tom Hennigan, Jacob Menick, Albin Cassirer, Richard Powell, George van den Driessche, Lisa Anne Hendricks, Maribeth Rauh, Po-Sen Huang, Amelia Glaese, Johannes Welbl, Sumanth Dathathri, Saffron Huang, Jonathan Uesato, John F. J. Mellor, Irina Higgins, Antonia Creswell, Nathan McAleese, Amy Wu, Erich Elsen, Siddhant M. Jayakumar, Elena Buchatskaya, David Budden, Esme Sutherland, Karen Simonyan, Michela Paganini, L. Sifre, Lena Martens, Xiang Lorraine Li, Adhiguna Kuncoro, Aida Nematzadeh, Elena Gribovskaya, Domenic Donato, Angeliki Lazaridou, Arthur Mensch, Jean-Baptiste Lespiau, Maria Tsimpoukelli, N. K. Grigorev, Doug Fritz, Thibault Sottiaux, Mantas Pajarskas, Tobias Pohlen, Zhitao Gong, Daniel Toyama, Cyprien de Masson d’Autume, Yujia Li, Tayfun Terzi, Vladimir Mikulik, Igor Babuschkin, Aidan Clark, Diego de Las Casas, Aurelia Guy, Chris Jones, James Bradbury, Matthew G. Johnson, Blake A. Hechtman, Laura Weidinger, Iason Gabriel, William S. Isaac, Edward Lockhart, Simon Osindero, Laura Rimell, Chris Dyer, Oriol Vinyals, Kareem W. Ayoub, Jeff Stanway, L. L. Bennett, Demis Hassabis, Koray Kavukcuoglu, and Geoffrey Irving. Scaling language models: Methods, analysis & insights from training gopher. ArXiv, 2021. URL https://arxiv.org/abs/2112.11446.
293
+
294
+ Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Semantically equivalent adversarial rules for debugging nlp models. In ACL, 2018.
295
+
296
+ Adam Roberts, Colin Raffel, and Noam M. Shazeer. How much knowledge can you pack into the parameters of a language model? In EMNLP, 2020.
297
+
298
+ Rachel Rudinger, Jason Naradowsky, Brian Leonard, and Benjamin Van Durme. Gender bias in coreference resolution. In NAACL, 2018.
299
+
300
+ Chenglei Si, Shuohang Wang, Min-Yen Kan, and Jing Jiang. What does bert learn from multiplechoice reading comprehension datasets? ArXiv, abs/1910.12391, 2019. URL https:// arxiv.org/abs/1910.12391.
301
+
302
+ Chenglei Si, Ziqing Yang, Yiming Cui, Wentao Ma, Ting Liu, and Shijin Wang. Benchmarking robustness of machine reading comprehension models. In Findings of ACL, 2021a.
303
+
304
+ Chenglei Si, Zhengyan Zhang, Fanchao Qi, Zhiyuan Liu, Yasheng Wang, Qun Liu, and Maosong Sun. Better robustness by more coverage: Adversarial training with mixup augmentation for robust fine-tuning. In Findings of ACL, 2021b.
305
+
306
+ Chenglei Si, Chen Zhao, Sewon Min, and Jordan L. Boyd-Graber. Revisiting calibration for question answering. In Findings of EMNLP, 2022.
307
+
308
+ Irene Solaiman and Christy Dennison. Process for adapting language models to society (palms) with values-targeted datasets. In NeurIPS, 2021.
309
+
310
+ Alon Talmor and Jonathan Berant. MultiQA: An empirical investigation of generalization and transfer in reading comprehension. In ACL, 2019.
311
+
312
+ Samson Tan, Shafiq R. Joty, Min-Yen Kan, and Richard Socher. It’s morphin’ time! combating linguistic discrimination with inflectional perturbations. In ACL, 2020.
313
+
314
+ Samson Tan, Shafiq R. Joty, K. Baxter, Araz Taeihagh, G. Bennett, and Min-Yen Kan. Reliability testing for natural language processing systems. In ACL, 2021.
315
+
316
+ Samson Tan, Araz Taeihagh, and Kathy Baxter. The risks of machine learning systems. ArXiv, 2022. URL https://arxiv.org/abs/2204.09852.
317
+
318
+ Yixuan Tang, Hwee Tou $\mathrm { N g }$ , and Anthony K. H. Tung. Do multi-hop question answering systems know how to answer the single-hop sub-questions? In EACL, 2021.
319
+
320
+ James Thorne, Andreas Vlachos, Christos Christodoulopoulos, and Arpit Mittal. FEVER: a largescale dataset for fact extraction and verification. In NAACL, 2018.
321
+
322
+ Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In BlackboxNLP@EMNLP, 2018.
323
+
324
+ Boxin Wang, Chejian Xu, Shuohang Wang, Zhe Gan, Yu Cheng, Jianfeng Gao, Ahmed Hassan Awadallah, and Bo Li. Adversarial GLUE: A multi-task benchmark for robustness evaluation of language models. In NeurIPS, 2021.
325
+
326
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. In ICLR, 2023.
327
+
328
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. Emergent abilities of large language models. Transactions on Machine Learning Research, 2022a.
329
+
330
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. In NeurIPS, 2022b.
331
+
332
+ Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William W. Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In EMNLP, 2018.
333
+
334
+ Xi Ye and Greg Durrett. Can explanations be useful for calibrating black box models? In ACL, 2022.
335
+
336
+ Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. OPT: Open pre-trained transformer language models. ArXiv, 2022. URL https: //arxiv.org/abs/2205.01068.
337
+
338
+ Yuan Zhang, Jason Baldridge, and Luheng He. PAWS: Paraphrase adversaries from word scrambling. In NAACL, 2019.
339
+
340
+ Jieyu Zhao, Tianlu Wang, Mark Yatskar, Vicente Ordonez, and Kai-Wei Chang. Gender bias in coreference resolution: Evaluation and debiasing methods. In NAACL, 2018.
341
+
342
+ Jieyu Zhao, Daniel Khashabi, Tushar Khot, Ashish Sabharwal, and Kai-Wei Chang. Ethical-advice taker: Do language models understand natural language interventions? In Findings of ACL, 2021a.
343
+
344
+ Tony Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In ICML, 2021b.
345
+
346
+ Caleb Ziems, Jiaao Chen, Camille Harris, Jessica Brooke Anderson, and Diyi Yang. Value: Understanding dialect disparity in nlu. In ACL, 2022.
347
+
348
+ # APPENDIX
349
+
350
+ # A MORE RELATED WORK
351
+
352
+ Robustness to Distribution Shifts. Machine learning models are known to overfit their training distribution and often suffer performance degradation when the test distribution differs from the training distribution. In the case of language models, various forms of distribution shifts have been studied. For example, domain shifts pose great challenges for LLMs on question answering (Talmor & Berant, 2019; Fisch et al., 2019) and text classification (Hendrycks et al., 2020; Arora et al., 2021); various forms of adversarial attacks can break LLMs even by just strategic synonym substitution, paraphrase, or distractor insertion (Jin et al., 2020; Li et al., 2020; Ribeiro et al., 2018; Si et al., 2019; 2021a; Jia & Liang, 2017; Si et al., 2021b); LLMs have been shown to exploit shortcuts or spurious correlations in the training data which fail on counter test examples (McCoy et al., 2019; Zhang et al., 2019; Poliak et al., 2018; Gururangan et al., 2018); LLMs also fail on new compositional structures that are not observed during traing (Kim & Linzen, 2020; Keysers et al., 2020; Bogin et al., 2022). In real-world settings, various forms of distribution shifts can happen and reliable models should perform well even when encountering such out-of-distribution (OOD) examples. Intuitively, incontext few-shot prompting should suffer less OOD degradation since the pretrained parameters are preserved, unlike the case of supervised finetuning. We perform a series of empirical evaluations on domain shift, curated challenge sets, and spurious correlation to validate this hypothesis.
353
+
354
+ Bias and Fairness. Language models producing toxic or biased content can cause severe harm especially to the groups being biased against (Bender et al., 2021). A series of benchmarks have been developed to show that LLMs can generate toxic outputs (Gehman et al., 2020), contain gender biases (Rudinger et al., 2018; Zhao et al., 2018) and other categories of social biases (Nangia et al., 2020; Nadeem et al., 2021; Parrish et al., 2022), perform poorly against minority demographic groups (Koh et al., 2021; Harris et al., 2022) or dialectical variations (Ziems et al., 2022; Tan et al., 2020). Ideally, LLMs should not exhibit biased behaviors and not discriminate against any group. While many of these evaluations focus on evaluating the internal representation of LLMs in a zeroshot setting or evaluating the biases on specific downstream applications in a supervised setting, it remains unclear how these biases change under different prompting schemes in the few-shot setting, which will be the focus of our analysis. A closely related work is Lucy & Bamman (2021) which study representation biases in GPT-3 generated stories. We instead evaluate on the downstream tasks of coreferece resolution and question answering. Apart from few-shot prompting, Solaiman & Dennison (2021) proposed a general method to align language models with human values, but it involves expensive iterative training.
355
+
356
+ Uncertainty Calibration. No model can ever be perfect, and so it is crucial for users to be able to identify model mistakes, especially in high-stage settings where trusting wrong model predictions can cause severe harm. One important way to help identify wrong model predictions is by obtaining well-calibrated confidence scores for model predictions. By definition, a calibrated confidence (probability) score should match the expected accuracy of the prediction (Platt, 1999; Naeini et al., 2015; Guo et al., 2017). In this way, users can put more trust in highly-confidence predictions and discard low-confidence predictions. While various methods have been proposed to obtain confidence scores and perform post-hoc calibration for language models (Jiang et al., 2021; Desai & Durrett, 2020; Ye & Durrett, 2022), they are mostly focused on classification settings rather than free-form generation, which is more common for the use of GPT-3. In this work, we explore two simple (but surprisingly effective) ways of obtaining confidence scores for GPT-3’s generated answers and we analyse the impact of scaling as well as prompt design. For studying calibration of GPT-3 style LLMs, Lin et al. (2022a) explore the idea of expressing uncertainty in verbal words but is restricted to math questions. Mielke et al. (2022) study linguistic calibration on conversational models. Kadavath et al. (2022) study adopting a multiple-choice setting in which case obtaining a confidence score is much easier (since the model only needs to predict one token to indicate which option to choose rather than generating the entire answer string). We differ from them in: 1) we focus on obtaining probabilistic confidence scores rather than verbal uncertainty expressions; 2) we study the more general and realistic free-form answer generation setting; and 3) we do not involve finetuning or any additional training of the language model.
357
+
358
+ <table><tr><td></td><td>SQuAD</td><td>HotpotQA</td><td>TriviaQA</td><td>NewsQA</td><td>SearchQA</td><td>NQ</td><td>Average</td></tr><tr><td>D-Net</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>84.1</td></tr><tr><td>Delphi</td><td>1</td><td>1</td><td>一</td><td>一</td><td></td><td></td><td>82.3</td></tr><tr><td>MultiFT</td><td>91.8</td><td>81.0</td><td>80.1</td><td>72.3</td><td>84.7</td><td>79.5</td><td>81.6</td></tr><tr><td>MADE</td><td>91.9</td><td>80.7</td><td>80.1</td><td>71.8</td><td>84.5</td><td>79.5</td><td>81.4</td></tr><tr><td>T5-Finetune</td><td>94.9</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>T5-PromptTune</td><td>94.8</td><td>1</td><td></td><td>1</td><td>1</td><td>1</td><td></td></tr><tr><td>GPT-3 Source-P</td><td>87.8</td><td>78.9</td><td>88.6</td><td>60.1</td><td>87.3</td><td>76.2</td><td>79.8</td></tr></table>
359
+
360
+ Table 11: Results on MRQA in-domain datasets. We use the F1 metric for all datasets. D-Net and Delphi results are taken from the MRQA system report (Fisch et al., 2019) which only reported the average performance. MultiFT and MADE results are taken from Friedman et al. (2021). T5- Finetune and T5-PromptTune results are from the prompt tuning paper (Lester et al., 2021) which only trained on the SQuAD datsaet. GPT-3 few-shot performance slightly lags behind these supervised baselines in the in-domain setting.
361
+
362
+ Knowledge Updating. Despite the fact that LLMs like GPT-3 are pretrained on very large corpora, they are still far from perfect in terms of factual knowledge. On one hand, they still make factual mistakes even on domains that have seen before during pretraining (e.g., Wikipedia); on the other hand, they are pretrained on static corpora and hence their knowledge can become outdated. In order for LLMs to serve as reliable knowledge bases (Petroni et al., 2019) or power knowledgeintensive downstream applications (Petroni et al., 2021), it is important to keep LLMs’ knowledge factually correct and up-to-update. A recent line of work attempts to edit factual knowledge in LLMs by making targeted modifications of the model’s neurons (Cao et al., 2021; Mitchell et al., 2021; 2022). However, these methods are hard to be applied on GPT-3 since it is much larger in size and often treated as a black box without access to internal parameters. To address this issue, in this paper we explore the feasibility of performing in-context knowledge updating by directly appending relevant knowledge pieces in the prompt to guide model predictions. Since it has been shown that larger models are better at memorization (Carlini et al., 2023), we analyze whether it is possible to make larger models forget their memorized knowledge and adapt to the new information presented in the prompt, especially when these two are in conflict. The idea of adding retrieved passages is conceptually similar to the line of work on retrieval-augmented methods for knowledgeintensive NLP (Lewis et al., 2020; Izacard et al., 2022b; Guu et al., 2020). However, these methods still require supervised training while we focus on the setting of few-shot prompting with all the language model’s parameters being frozen.
363
+
364
+ # B ADDITIONAL RESULTS: GENERALIZABILITY
365
+
366
+ We provide full experimental results and comparisons with more baselines.
367
+
368
+ MRQA Table 11 and Table 12 present detailed results on MRQA. For baselines, we include results from the top-performing systems of the MRQA competition: D-Net (Li et al., 2019) and Delphi (Longpre et al., 2019), a recent adapter-based robust tuning method MADE (Friedman et al., 2021) as well as their multi-dataset finetuning baseline. We also report the finetuning and prompt tuning Lester et al. (2021) result of using T5, which achieves state-of-the-art OOD transfer results on MRQA. Note that this T5 baseline only uses SQuAD as the in-domain training data.
369
+
370
+ AdvGLUE and Contrast Sets Table 13 and Table 14 present detailed results on AdvGLUE and Contrast Sets, where GPT-3 shows better generalization than supervised baselines.
371
+
372
+ Spurious Correlation Table 16 shows full the performance breakdown on HANS based on the three spurious features. We can see that for the subsequence and constituent features in HANS, GPT-3 still suffers significant performance gaps between the bias-supporting and bias-countering subsets. This leaves curious questions like why such gaps only occur for certain bias features but not others, and how such spurious biases arise (most likely due to pretraining), and we leave a more thorough analysis of these questions to future work.
373
+
374
+ Table 12: Results on MRQA OOD datasets. ID-P (second last row) uses a fixed set of sampled demo examples from the in-domain datasets and evaluates on these OOD datasets, while OOD-P (last row) uses sampled demo examples from each of these OOD datasets for evaluation. GPT-3 significantly outperforms all other supervised baselines on these OOD datasets, moreover, using the in-domain prompt successfully transfers to OOD test data, achieving the same average performance as using demos examples drawn from these OOD datasets as the prompt.
375
+
376
+ <table><tr><td></td><td>BioASQ</td><td>DROP</td><td>DuoRC</td><td>RACE</td><td>RE</td><td>TextbookQA</td><td>Average</td></tr><tr><td>D-Net</td><td></td><td>1</td><td>一</td><td>1</td><td>1</td><td></td><td>69.7</td></tr><tr><td>Delphi</td><td></td><td>一</td><td></td><td>一</td><td>一</td><td>一</td><td>68.5</td></tr><tr><td>MultiFT</td><td>64.1</td><td>51.5</td><td>63.0</td><td>47.6</td><td>87.3</td><td>59.0</td><td>62.1</td></tr><tr><td>MADE</td><td>66.5</td><td>50.9</td><td>67.2</td><td>47.8</td><td>86.7</td><td>58.5</td><td>62.9</td></tr><tr><td>T5-Finetune</td><td>77.9</td><td>68.9</td><td>68.9</td><td>59.8</td><td>88.4</td><td>54.3</td><td>69.7</td></tr><tr><td>T5-PromptTune</td><td>79.1</td><td>67.1</td><td>67.7</td><td>60.7</td><td>88.8</td><td>66.8</td><td>71.7</td></tr><tr><td>GPT-3 Source-P</td><td>86.2</td><td>67.7</td><td>70.5</td><td>69.0</td><td>89.3</td><td>84.8</td><td>77.2</td></tr><tr><td>GPT-3 Target-P</td><td>85.9</td><td>68.9</td><td>69.7</td><td>65.4</td><td>91.0</td><td>82.1</td><td>77.2</td></tr></table>
377
+
378
+ <table><tr><td></td><td>SST-2</td><td>MNLI</td><td>RTE</td><td>QNLI</td><td>QQP</td><td>Average</td></tr><tr><td colspan="7">Clean Test Sets</td></tr><tr><td>RoBERTa</td><td>96.0</td><td>89.8</td><td>86.6</td><td>94.1</td><td>92.0</td><td>91.7</td></tr><tr><td>ALBERT</td><td>95.2</td><td>89.6</td><td>88.4</td><td>95.3</td><td>92.3</td><td>92.2</td></tr><tr><td>DeBERTa</td><td>96.3</td><td>90.9</td><td>90.2</td><td>94.9</td><td>92.3</td><td>92.9</td></tr><tr><td>GPT-3</td><td>96.1</td><td>78.1</td><td>83.4</td><td>79.8</td><td>83.5</td><td>84.2</td></tr><tr><td colspan="7">Adversarial Test Sets</td></tr><tr><td>RoBERTa</td><td>58.5</td><td>45.2</td><td>45.4</td><td>52.5</td><td>57.1</td><td>51.7</td></tr><tr><td>ALBERT</td><td>66.8</td><td>48.0</td><td>73.0</td><td>63.8</td><td>56.4</td><td>61.6</td></tr><tr><td>DeBERTa</td><td>57.9</td><td>55.5</td><td>78.9</td><td>57.9</td><td>60.4</td><td>62.1</td></tr><tr><td>GPT-3</td><td>78.4</td><td>56.4</td><td>87.7</td><td>57.4</td><td>66.7</td><td>69.3</td></tr></table>
379
+
380
+ Table 13: Results on the clean and adversarial test sets of AdvGLUE, we use accuracy as the metric for all datasets. For MNLI, we report the average performance on the matched and mismatched dev sets. The supervised baselines are trained on the clean training data, and GPT-3 uses few-shot prompts sampled from the clean training data. While GPT-3 few-shot prompting lags behind supervised models on clean test sets, it significantly outperforms the supervised models on the adversarial sets. That being said, we still note a performance drop of GPT-3 on the adversarial test sets when using clean demo examples.
381
+
382
+ In Table 15, we perform additional ablation on the impact of the number of demos and the different GPT-3 variants. With fewer demo examples from QQP, despite a slight drop on the QQP test set, GPT-3 actually remains robust (even higher accuracy on PAWS than the 16-shot results). On the other hand, using the Text-Davinci-001 (175B) and the smaller Text-Curie-001 (6.7B) performs far worse on both the QQP test set and the PAWS challenge test set.
383
+
384
+ # C ADDITIONAL RESULTS: SOCIAL BIASES
385
+
386
+ We also break down the accuracy and bias scores of using different prompts in Table 17 by the different bias categories. We observe that there can be large differences across different categories. Moreover, we underlined the categories from which the demo examples come, and we observe that having same-category demos in the prompt does not correlate with the bias scores. For instance, we have bias-supporting examples from the Nationality category in the Ambig-Pro case but the bias score remains low, while the bias score for the Physical Appearance and Disability categories becomes much higher even when the biased examples are not from these categories.
387
+
388
+ Table 14: Results on Contrast Sets. For IMDB and BoolQ, we report accuracy; for QuoREF, we report F1. Apart from the performance on the original and contrast sets of the three datasets, we also note the gap between performance on the original and contrast sets. We see a clear trend that GPT-3 incurs a smaller gap than the supervised models.
389
+
390
+ <table><tr><td></td><td>IMDB - Original</td><td>IMDB - Contrast</td><td>Gap↓</td></tr><tr><td>BERT</td><td>93.8</td><td>84.2</td><td>9.6</td></tr><tr><td>GPT-3</td><td>94.1</td><td>93.6</td><td>0.5</td></tr><tr><td></td><td>QuoREF - Original</td><td>QuoREF - Contrast</td><td>Gap↓</td></tr><tr><td>XLNet</td><td>70.5</td><td>55.4</td><td>15.1</td></tr><tr><td>GPT-3</td><td>86.1</td><td>77.0</td><td>9.1</td></tr><tr><td></td><td>BoolQ - Original</td><td>BoolQ - Contrast</td><td>Gap↓</td></tr><tr><td>RoBERTa</td><td>86.1</td><td>71.1</td><td>15.0</td></tr><tr><td>GPT-3</td><td>85.5</td><td>80.0</td><td>5.5</td></tr></table>
391
+
392
+ Table 15: Ablation for the impact of the number of demos and different GPT-3 model variants on MNLI-HANS.
393
+
394
+ <table><tr><td></td><td>QQP (ID)</td><td>PAWS (OOD)</td><td>Gap</td></tr><tr><td>BERT (supervised)</td><td>91.3</td><td>40.1</td><td>51.2</td></tr><tr><td>RoBERTa (supervised)</td><td>89.0</td><td>39.5</td><td>49.5</td></tr><tr><td>Code-Davinci-002 (4-shots)</td><td>78.2</td><td>80.5</td><td>-2.3</td></tr><tr><td>Code-Davinci-002 (16-shots)</td><td>83.5</td><td>73.7</td><td>9.8</td></tr><tr><td>Text-Davinci-001 (16-shots)</td><td>72.4</td><td>42.4</td><td>30.0</td></tr><tr><td>Text-Curie-001 (16-shots)</td><td>40.1</td><td>32.1</td><td>8.0</td></tr></table>
395
+
396
+ # D ADDITIONAL RESULTS: CALIBRATION
397
+
398
+ The full selective prediction results in Table 18 show that the confidence scores can be used to rank model predictions. We see a clear trend that the most confident predictions have much higher accuracy.
399
+
400
+ The reliability diagrams in Figure 2 show that in most cases the calibration errors come from overconfidence where the predictions’ confidence is higher than the expected accuracy. It is also worth noting while OOD transfer is a big challenge for the calibration of supervised models where there tends to be overconfidence on the OOD test sets, GPT-3 exhibits similar calibration results when using in-domain or OOD demo examples as the prompt (bottom-left plot in Figure 2).
401
+
402
+ To further disentangle the impact of better accuracy and better calibration, we perform a controlled evaluation of selective prediction in Table 19 where we sub-sample the NQ test set so that the three calibration methods achieve the same accuracy on the test set. We see a clear trend that despite DPR-BERT and GPT-3 get same accuracy on this sub-sampled test set, DPR-BERT gets much higher accuracy on the most confident predictions indicating the usefulness of better calibration.
403
+
404
+ E ADDITIONAL RESULTS: KNOWLEDGE UPDATING
405
+
406
+ E.1 IMPACT OF PROMPTS FOR MEMORIZATION VS UPDATING
407
+
408
+ For knowledge updating, we compare several different prompt designs as detailed below, for all cases, we randomly sample 16 demo examples as the prompt.
409
+
410
+ • $\langle Q , A \rangle$ : We use the original question-answer pairs in the prompt.
411
+ • $\langle P , \ Q , A \rangle$ : We use the original passage-question-answer triples in the prompt (i.e., the answer in the passage remains the original gold answer).
412
+ • $\langle Q , A ^ { \prime } \rangle$ : We use the question-answer pairs, but with the substitution entities as gold answers in the prompt.
413
+ • $\langle P ^ { \prime } , Q , A ^ { \prime } \rangle$ : We use triples of the answer-substituted passage, the question, and the substitution answers in the prompt.
414
+
415
+ Table 16: Breakdown of GPT-3 results on HANS by categories. All demo examples in the prompt are from MNLI. GPT-3 still suffers significant performance gaps between the entailment (biassupporting) and non-entailment (bias-countering) subsets for the subsequence and constituent features in HANS.
416
+
417
+ <table><tr><td>HANS Category</td><td>GPT-3 Acc.</td></tr><tr><td>Lexical Overlap -Entailment</td><td>87.9</td></tr><tr><td>Lexical Overlap-Non-Entailment</td><td>96.9</td></tr><tr><td>Subsequence - Entailment</td><td>84.0</td></tr><tr><td>Subsequence -Non-Entailment</td><td>53.7</td></tr><tr><td>Constituent - Entailment</td><td>87.2</td></tr><tr><td>Constituent -Non-Entailment</td><td>42.2</td></tr></table>
418
+
419
+ Table 17: Breakdown of accuracy and bias score results on BBQ. For accuracy and bias scores, the first number represents the ambiguous set and the second number represents the disambiguated set. Underlined numbers indicate that there are demo examples in the prompt from the same bias category.
420
+
421
+ <table><tr><td rowspan="2"></td><td colspan="2">Balanced</td><td colspan="2">Ambig-Pro</td><td colspan="2">Ambig-Anti</td></tr><tr><td>Acc↑</td><td>Bias↓</td><td>Acc↑</td><td>Bias↓</td><td>Acc↑</td><td>Bias↓</td></tr><tr><td>SES</td><td>96.4 /74.2</td><td>3.2/0.0</td><td>14.2/99.2</td><td>-12.6 /0.0</td><td>8.4 /99.6</td><td>-6.4/0.0</td></tr><tr><td>Sexual orientation</td><td>97.4 /76.3</td><td>1.6/1.2</td><td>1.9 /98.4</td><td>19.1/ -0.9</td><td>2.8 /97.2</td><td>17.2/ -0.9</td></tr><tr><td>Religion</td><td>97.0 / 75.8</td><td>1.8/0.5</td><td>0.4 /98.0</td><td>35.2/1.2</td><td>1.0 /97.2</td><td>24.6/1.6</td></tr><tr><td>Race</td><td>99.8 / 85.1</td><td>-0.1/-0.5</td><td>1.2 /99.0</td><td>4.0/0.1</td><td>2.7 /98.9</td><td>3.7/0.1</td></tr><tr><td>Physical Appearance</td><td>97.4 / 56.0</td><td>2.6 /18.8</td><td>1.4 / 87.8</td><td>75.0 / 14.8</td><td>0.6 /86.2</td><td>77.0/14.8</td></tr><tr><td>Nationality</td><td>98.2/80.8</td><td>1.4 / -11.6</td><td>1.0 / 99.0</td><td>-0.2/0.0</td><td>1.0 /98.6</td><td>0.6/0.0</td></tr><tr><td>Gender identity</td><td>99.0 / 66.8</td><td>0.6/ -3.9</td><td>6.0 /98.6</td><td>5.6/0.4</td><td>4.6 /98.8</td><td>3.8/0.4</td></tr><tr><td>Disability</td><td>97.4/74.2</td><td>2.2 /8.5</td><td>0.0 /96.6</td><td>85.2/6.0</td><td>0.2 /97.2</td><td>82.6/4.8</td></tr><tr><td>Age</td><td>82.2 /76.6</td><td>13.0/8.1</td><td>0.0 /95.4</td><td>52.0 /12.4</td><td>0.4 /95.6</td><td>48.4 /12.0</td></tr></table>
422
+
423
+ As shown in Table 20, we find that the prompt design has a big impact on the knowledge updating behavior. In particular, showing only the original passage-question-answer triples $( \langle P , Q , A \rangle )$ still causes high memorization ratios, however, when prompting with counterfactual triples $( \langle P ^ { \prime } , Q , A ^ { \prime } \rangle )$ , GPT-3 can update $85 \%$ of the time with much lower memorization ratios than a supervised model.
424
+
425
+ # E.2 TARGETED IN-CONTEXT KNOWLEDGE UPDATING
426
+
427
+ The experiments in the previous section showed promise that GPT-3 can adapt to new knowledge given in the prompt when there is a conflict with its memorized knowledge. One missing aspect from the above analysis is whether we can perform targeted knowledge update: when given a piece of knowledge update, we expect the model to predict the updated answer for all questions related to that knowledge, but not change its answer for other unrelated questions. To assess model behavior on this front, we adopt an evaluation setup closer to recent knowledge updating literature (Cao et al., 2021; Mitchell et al., 2021).
428
+
429
+ Experiment Setup We use two evaluation datasets from Mitchell et al. (2021): 1) We first use the fact checking dataset FEVER (Thorne et al., 2018): each claim requires a binary true / false judgement. We create the edited label which is opposite to the originally predicted label from GPT3. For example, for a test example, if the original GPT-3 prediction is true, then the new label for editing would be false. We present the knowledge update in the form of a natural sentence that supports the target label for editing. We then test whether GPT-3 predicts the target label for a paraphrase of the original test claim. We measure accuracy on these paraphrases as the editing success rate. We sample a same-sized set from the training data that do not overlap with the test set as the set of unrelated questions. The intended behavior is that adding knowledge updates in the prompt does not impact performance on these unrelated questions. We measure performance drop on this unrelated set after and before adding knowledge updates as the accuracy drawdown. 2) We also use the zsRE question-answering dataset (Levy et al., 2017). For each test question, the target label for editing is randomly sampled from predictions by a smaller QA model which is different from the original GPT-3 prediction. Similarly, we measure accuracy on paraphrased test questions as success rate, and accuracy drop on a set of randomly sampled non-overlapping training questions as the accuracy drawdown.
430
+
431
+ Table 18: Selective prediction results. All numbers represent the accuracy (EM) at the corresponding coverage thresholds. For example, $100 \%$ means performance on the entire test set while $10 \%$ means the performance on the most confident $10 \%$ predictions.
432
+
433
+ <table><tr><td></td><td>DPR-BERTNQ</td><td>LM-Prob NQ</td><td>Self-Con NQ</td><td>LM-Prob TriviaQA</td><td>LM-Prob HotpotQA</td></tr><tr><td>100%</td><td>36.1</td><td>40.5</td><td>40.2</td><td>73.8</td><td>29.8</td></tr><tr><td>90%</td><td>38.0</td><td>43.7</td><td>44.3</td><td>78.3</td><td>32.7</td></tr><tr><td>80%</td><td>39.5</td><td>46.8</td><td>48.7</td><td>81.7</td><td>36.0</td></tr><tr><td>70%</td><td>40.6</td><td>50.2</td><td>53.1</td><td>84.1</td><td>39.7</td></tr><tr><td>60%</td><td>41.2</td><td>53.7</td><td>57.8</td><td>86.5</td><td>43.5</td></tr><tr><td>50%</td><td>41.9</td><td>58.8</td><td>62.0</td><td>88.5</td><td>47.6</td></tr><tr><td>40%</td><td>43.3</td><td>63.3</td><td>66.0</td><td>90.5</td><td>52.1</td></tr><tr><td>30%</td><td>46.1</td><td>70.2</td><td>71.2</td><td>92.5</td><td>56.5</td></tr><tr><td>20%</td><td>49.2</td><td>77.4</td><td>74.7</td><td>93.7</td><td>61.6</td></tr><tr><td>10%</td><td>60.1</td><td>83.1</td><td>77.0</td><td>95.4</td><td>68.1</td></tr></table>
434
+
435
+ Table 19: Selective prediction results on a controlled set sampled from the original test set so that the accuracy on the sub-sampled test set is the same.
436
+
437
+ <table><tr><td></td><td>DPR-BERT NQ</td><td>LM-Prob NQ</td><td>Self-Con NQ</td></tr><tr><td>100%</td><td>35.0</td><td>35.0</td><td>35.0</td></tr><tr><td>90%</td><td>37.6</td><td>37.9</td><td>38.2</td></tr><tr><td>80%</td><td>39.0</td><td>40.8</td><td>42.8</td></tr><tr><td>70%</td><td>40.9</td><td>44.1</td><td>46.1</td></tr><tr><td>60%</td><td>41.6</td><td>47.8</td><td>51.6</td></tr><tr><td>50%</td><td>43.1</td><td>52.9</td><td>55.1</td></tr><tr><td>40%</td><td>44.1</td><td>58.0</td><td>60.6</td></tr><tr><td>30%</td><td>45.4</td><td>65.3</td><td>63.5</td></tr><tr><td>20%</td><td>49.5</td><td>75.3</td><td>71.5</td></tr><tr><td>10%</td><td>59.2</td><td>82.5</td><td>70.5</td></tr></table>
438
+
439
+ Prompt Design We compare several prompt designs (in particular what types of demo examples to use). For all cases, we sample 16 demos to use in the prompt.
440
+
441
+ • Original Examples Only: We only sample the original QA pairs (without editing information).
442
+ • Original $^ +$ Edited Relevant Examples: We include demos examples for both original QA pairs as well as for questions with edited answers.
443
+ • Original $^ +$ Edited Relevant $^ +$ Edited Irrelevant Examples: We include demo examples covering all possible cases: the original QA pairs, QA pairs with knowledge update and updated answer, as well as QA pairs with knowledge update but original answer (where the question is unrelated to the knowledge update).
444
+
445
+ Results From Table 21, we see that different prompts give vastly different results. Specifically, using only the original examples in the prompt leads to relatively poor success rate (especially on
446
+
447
+ ![](images/77cac1f77409c2c61ea4bdc89c74ea6498ab259ef21437a229894dfe875f4637.jpg)
448
+ Figure 2: Reliability diagrams for different calibration setups. $\mathbf { X }$ -axis: confidence of each bucket; y-axis: accuracy of each bucket.
449
+
450
+ <table><tr><td></td><td>Retain</td><td>Update</td><td>Other</td><td>Memorization Ratio</td></tr><tr><td colspan="5">NQ with Code-Davinci-002</td></tr><tr><td>T5 (supervised)</td><td>20%</td><td>33%</td><td>47%</td><td>30%</td></tr><tr><td>GPT-3 Prompt (Q, A)</td><td>60.8%</td><td>25.8%</td><td>13.4%</td><td>70.2%</td></tr><tr><td>GPT-3 Prompt (P, Q, A)</td><td>59.1%</td><td>25.4%</td><td>15.5%</td><td>70.0%</td></tr><tr><td>GPT-3 Prompt (Q,A&quot;)</td><td>10.4%</td><td>56.6%</td><td>32.9%</td><td>15.6%</td></tr><tr><td>GPT-3 Prompt (P&#x27;, Q, A&quot;)</td><td>4.5%</td><td>85.4%</td><td>10.2%</td><td>5.0%</td></tr><tr><td colspan="5">SQuAD with Code-Davinci-002</td></tr><tr><td>GPT-3 Prompt (Q,A)</td><td>58.0%</td><td>29.1%</td><td>12.9%</td><td>66.6%</td></tr><tr><td>GPT-3 Prompt (P, Q, A)</td><td>32.8%</td><td>52.9%</td><td>14.3%</td><td>38.2%</td></tr><tr><td>GPT-3 Prompt (Q, A&quot;)</td><td>15.4%</td><td>48.1%</td><td>36.5%</td><td>24.3%</td></tr><tr><td>GPT-3 Prompt (P&#x27;, Q, A&quot;)</td><td>7.1%</td><td>84.8%</td><td>8.1%</td><td>7.8%</td></tr><tr><td colspan="5">NQ with different versions of GPT-3</td></tr><tr><td>Text-Davinci-001 (175B)</td><td>7.2%</td><td>57.9%</td><td>34.9%</td><td>11.0%</td></tr><tr><td>Text-Curie-001 (6.7B)</td><td>14.8%</td><td>40.0%</td><td>45.2%</td><td>26.9%</td></tr></table>
451
+
452
+ Table 20: In-context knowledge updating results for memorized answers in NQ and $\mathrm { S Q u A D }$ . When giving counter-factual demo examples in the prompt, GPT-3 can update its answers around $85 \%$ of the time with low memorization ratio (as compared to supervised models). Moreover, we find that larger models are better at in-context knowledge updating.
453
+
454
+ FEVER), while adding edited relevant examples in the prompt leads to better success rate, it leads the model to over-rely on the knowledge updates even on irrelevant questions. However, when incorporating all cases of original examples, edited relevant and irrelevant examples in the prompt, GPT-3 is able to achieve high editing success rate and low drawdown on irrelevant questions.
455
+
456
+ Table 21: Targeted in-context knowledge updating results for FEVER and zsRE. From the last block of results, we see that when using a mixture of all three types of demo examples, GPT-3 is able to achieve very high knowledge edit success rate $( 9 9 . 9 \%$ and $9 8 . 8 \%$ ) while incurring minimal drawdown $( 0 . 5 \% )$ on irrelevant questions.
457
+
458
+ <table><tr><td colspan="2">Success Rate (Relevant Paraphrases)Acc.Drawdown (Irrelevant Questions)</td></tr><tr><td colspan="2">Prompt: Original Examples Only</td></tr><tr><td>FEVER zsRE QA</td><td>44.2 85.1 - 84.9= 0.2</td></tr><tr><td>92.9</td><td>40.0 - 39.7= 0.3</td></tr><tr><td colspan="2">Prompt: Original Examples + Edited Relevant Examples</td></tr><tr><td rowspan="2">FEVER zsRE QA</td><td></td><td>83.9 - 48.6= 35.3</td></tr><tr><td>100.0 99.9</td><td>39.7 - 11.6 = 28.1</td></tr><tr><td colspan="2">Prompt: Original Examples +Edited Relevant Examples + Edited Irrelevant Examples</td></tr><tr><td rowspan="2">FEVER zsRE QA</td><td>99.9</td><td>84.0 - 83.5 = 0.5</td></tr><tr><td>98.8</td><td>40.6 - 40.1 = 0.5</td></tr></table>
md/dev/9uRS5ysgb9/9uRS5ysgb9.md ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Zero-Shot Video Question Answering via Frozen Bidirectional Language Models
2
+
3
+ Antoine $\mathbf { Y a n g ^ { 1 , 2 } }$ , Antoine Miech3, Josef Sivic4, Ivan Laptev1,2, Cordelia Schmid1,2
4
+ 1Inria Paris 2Département d’informatique de l’ENS, CNRS, PSL Research University 3DeepMind 4CIIRC CTU Prague https://antoyang.github.io/frozenbilm.html
5
+
6
+ # Abstract
7
+
8
+ Video question answering (VideoQA) is a complex task that requires diverse multimodal data for training. Manual annotation of questions and answers for videos, however, is tedious and prohibits scalability. To tackle this problem, recent methods consider zero-shot settings with no manual annotation of visual question-answer. In particular, a promising approach adapts frozen autoregressive language models pretrained on Web-scale text-only data to multi-modal inputs. In contrast, we here build on frozen bidirectional language models (BiLM) and show that such an approach provides a stronger and cheaper alternative for zero-shot VideoQA. In particular, (i) we combine visual inputs with the frozen BiLM using light trainable modules, (ii) we train such modules using Web-scraped multi-modal data, and finally (iii) we perform zero-shot VideoQA inference through masked language modeling, where the masked text is the answer to a given question. Our proposed approach, FrozenBiLM, outperforms the state of the art in zero-shot VideoQA by a significant margin on a variety of datasets, including LSMDC-FiB, iVQA, MSRVTT-QA, MSVD-QA, ActivityNet-QA, TGIF-FrameQA, How2QA and TVQA. It also demonstrates competitive performance in the few-shot and fully-supervised setting. Our code and models are publicly available at [1].
9
+
10
+ ![](images/5b922eb945c16caa4b7b44122af383f9a3345e9882c5cc2a8e9966a3f8398918.jpg)
11
+ Figure 1: Our model FrozenBiLM builds on a pretrained and frozen bidirectional language model (BiLM), and is trained from Web-scraped video-caption pairs. FrozenBiLM excels in the zero-shot video question answering task without using any explicit visual question-answer supervision.
12
+
13
+ # 1 Introduction
14
+
15
+ Video question answering (VideoQA) is a challenging task that requires fine-grained multi-modal understanding. State-of-the-art approaches to VideoQA [43, 107, 109] rely on large video datasets manually annotated with question-answer pairs. Yet, collecting such annotations is time consuming, expensive and therefore not scalable. This has motivated the development of zero-shot VideoQA approaches [101, 102, 110], that use no visual question-answer annotation for training, see Figure 1.
16
+
17
+ Recently, a promising line of work builds on frozen large autoregressive language models [19, 68, 91, 96, 104, 111] for zero-shot visual question answering. This has been motivated by the findings from GPT-3 [8] which exhibits strong zero-shot text-only question answering abilities from large autoregressive language models. Such models [8, 72, 82, 92] can predict an arbitrarily long sequence of text, one token at each step from left to right. However, they usually require billion parameters to work well, making them computationally expensive to train, and challenging to deploy in practice.
18
+
19
+ In contrast, recent work in natural language [65, 76, 77, 87] demonstrates strong zero-shot performance for lighter bidirectional language models (BiLM). Such models [17, 25, 35, 42, 61, 75] can predict a few masked tokens in an input sequence given left and right context in a single forward pass. These works cast downstream tasks in cloze form1 [90], similar to the masked language modeling task (MLM) [17] solved by these models at pretraining. This motivates us to tackle diverse zero-shot multimodal tasks (open-ended VideoQA [98], multiple-choice VideoQA [46] and fill-in-the-blank [66]) by formulating them in cloze form and leveraging the text-only knowledge of pretrained BiLM.
20
+
21
+ To adapt a pretrained BiLM to multi-modal inputs, we combine it with a frozen pretrained visual backbone and a set of lightweight additional modules including adapters [28]. We train these modules on Web-scraped video-text data using a simple visually-conditioned MLM loss. We preserve the uni-modal knowledge of a BiLM by freezing its weights. To our knowledge, our approach is the first to explore the zero-shot visual-linguistic capabilities of frozen non-autoregressive language models.
22
+
23
+ We show that our approach largely improves the state of the art on various zero-shot VideoQA benchmarks. Furthermore, we demonstrate that frozen bidirectional language models perform better while being cheaper to train than frozen autoregressive language models [91]. Moreover, our ablation studies show (i) the ability of our model to effectively perform zero-shot multi-modal reasoning using both visual cues and speech transcripts, (ii) the importance of adapters combined with frozen pretrained language models, (iii) the impact of multi-modal data scale, (iv) the impact of the language model size and of bidirectional modeling. Our approach also performs competitively in the fullysupervised setting. Indeed, we show the benefits of freezing the weights of a BiLM when using VideoQA training data, while updating considerably less parameters compared to alternative methods. Finally, we introduce a new few-shot VideoQA task in which we finetune our pretrained model on a small fraction of the downstream training dataset, and show promising results in this setting.
24
+
25
+ In summary, our contributions are three-fold:
26
+
27
+ (i) We present FrozenBiLM, a framework that handles multi-modal inputs using frozen bidirectional language models and enables zero-shot VideoQA through masked language modeling.
28
+ (ii) We provide an extensive ablation study and demonstrate the superior performance of our framework in the zero-shot setting when compared to previous autoregressive models.
29
+ (iii) Our approach improves the state of the art in zero-shot VideoQA by a significant margin. FrozenBiLM also demonstrates competitive performance in the fully-supervised setting and shows strong results in the few-shot VideoQA setting which we introduce.
30
+
31
+ Our code and trained models are publicly available at [1].
32
+
33
+ # 2 Related Work
34
+
35
+ Zero-shot VideoQA. A vast majority of VideoQA approaches rely on relatively small, manually annotated VideoQA datasets [3, 9, 10, 13–15, 20, 23, 24, 30, 33, 34, 36–39, 43, 44, 47, 58, 60, 69, 70, 74, 78, 79, 83, 89, 97, 100, 103, 105, 112, 116]. Recently, a few work [101, 110] have explored zero-shot approaches for VideoQA, where models are only trained on automatically mined video clips with short text descriptions. In contrast to VideoQA annotations, such video-text pairs are readilyavailable at scale on the Web [6, 67, 109]. In particular, Yang et al. [101] automatically generate VideoQA training data using language models [72] pretrained on a manually annotated text-only question-answer corpus [73]. Reserve [110] uses GPT-3 [8] to rephrase questions into sentences completed by a multi-modal model. In contrast to these prior works [101, 110], our method does not require any kind of explicitly annotated language dataset or the use of data generation pipelines for zero-shot VideoQA. Note that BLIP [53] studies a related setting where a model trained on manually annotated image-question-answer triplets is transferred to VideoQA, which is a less challenging task. Also note that VideoCLIP [99] considers a related zero-shot multiple-choice video-to-text retrieval task as VideoQA, but in this setting the model is not provided with natural language questions.
36
+
37
+ Visual language models. As language models require large amounts of training data to perform well [27], recent works have studied transferring pretrained language models [8, 94] to image-text tasks. VisualGPT [11] and VC-GPT [64] showed the benefit of initializing the weights of an image captioning model with a pretrained autoregressive language-only model. Recent work pushed this idea further by freezing the weights of a pretrained autoregressive language model for tackling vision and language tasks [2, 19, 68, 91, 96, 104, 111]. Our approach also leverages a frozen pretrained language model. Similar to MAGMA [19], we also use adapter layers [28, 29]. However, we differ from these approaches as we propose to instead use lighter bidirectional masked language models, instead of autoregressive ones, and rely on a masked language modeling objective (MLM) instead of an autoregressive one. Moreover, our model is specifically designed for videos, for which high-quality visual question answering annotation is even more scarce compared to still images [19, 68, 91, 104]. We also explore the use of the speech modality, and tackle tasks which are challenging for autoregressive language models such as video-conditioned fill-in-the-blank [66]. Finally we show in Section 4.3 the superior performance of frozen bidirectional language models in comparison with autoregressive ones [91].
38
+
39
+ Masked Language Modeling in vision and language. The MLM objective was initially introduced in natural language [17, 42, 61] to pretrain bidirectional transformers and learn generic representations. This approach achieved state-of-the-art results in many language tasks after finetuning on downstream datasets. Its success inspired numerous works to adapt it to train multi-modal transformer models on paired visual-linguistic data [12, 21, 22, 26, 31, 40, 48, 51, 56, 54, 59, 52, 50, 62, 63, 80, 81, 85, 86, 88, 93, 95, 106, 109, 114, 115]. However, these works typically use it to learn generic visual-linguistic representations by updating the transformer weights, and then use expensive manual supervision to train randomly initialized task-specific answer classifiers for VQA [12, 22, 51, 52, 59, 62, 80, 81, 85, 88, 95, 106] or VideoQA [21, 48, 50, 93, 109]. In contrast, we tackle zero-shot VideoQA, i.e. without using any manual annotation. Moreover, we do not update the transformer weights during cross-modal training, but instead exhibit the benefits of freezing these weights after text-only pretraining, for both zero-shot and fully-supervised VideoQA (see Sections 4.2 and 4.5).
40
+
41
+ # 3 Method
42
+
43
+ This section presents our approach to tackle zero-shot video question answering. Here, zero-shot means that we do not use any visual question answering annotation and only rely on scalable data from the Web. Our approach starts with two strong pretrained components: (i) a text-only bidirectional masked language model (BiLM) pretrained on data from the Internet, which has the capability of zeroshot question answering but is not capable of visual reasoning, and (ii) a vision encoder pretrained to map images to text descriptions, but which does not have the ability to perform visual question answering. We aim at connecting these two components while keeping the language component frozen to avoid catastrophic forgetting [16], where the large language model would specialize to a new task while forgetting its initial capabilities. The end-goal is to design a unified model having the best of both worlds: visual understanding capabilities of a powerful visual encoder and question answering capabilities of a powerful language model. This requires several technical innovations, which are described in the rest of this section. First, we explain in Section 3.1 how we augment a frozen pretrained bidirectional masked language model with new layers to enable joint video and language reasoning, see Figure 2. Second, we present in Section 3.2 how we train these layers on video-text data scraped from the Web [6]. Finally, we describe in Section 3.3 how we enable zero-shot predictions for several video-language downstream tasks, including open-ended VideoQA, by casting them in a cloze form, similar to the masked language modeling task solved during training.
44
+
45
+ # 3.1 Architecture
46
+
47
+ The proposed architecture, illustrated in Figure 2, brings together a powerful frozen pretrained bidirectional language model with a strong visual encoder. The difficulty lies in enabling multi-modal reasoning while keeping the large language model frozen. To address this challenge, we unify these two models via a visual-to-text projection module together with small adapter modules inserted within the frozen language model. Next, we describe in more detail the three main components of the architecture: (i) the frozen pretrained bidirectional language model, (ii) the pretrained video encoder and (iii) the lightweight modules that seamlessly connect the two components.
48
+
49
+ ![](images/da4998bc23389f6df2512772fded64c3ab160004c8e4a743977d3a26c516272a.jpg)
50
+ Figure 2: Our training architecture consists of a large frozen bidirectional language model (BiLM) and a frozen pretrained visual encoder (in blue), complemented with additional lightweight trainable modules (in orange): (1) a visual-to-text projection module $P$ (on the left), which maps the frozen visual features to the joint visual-text embedding space and (2) a set of small adapter modules $A$ (on the right) in between the frozen transformer blocks. The pretrained normalization layers in the BiLM (on the right) are also finetuned.
51
+
52
+ Frozen Bidirectional Masked Language Model. Our method starts from a pretrained bidirectional language model based on a Transformer encoder [92]. The input text is decomposed into a sequence of tokens $x = \{ x _ { i } \} _ { 1 } ^ { L } \in [ 1 , V ] ^ { L }$ by a tokenizer of a vocabulary size $V$ . The language model, parameterized by $\theta$ , makes use of an embedding function $g _ { \theta }$ which independently transforms each token into a $D$ -dimensional continuous embedding $t = \bar { \{ t _ { i } \} } _ { 1 } ^ { L } : = \{ g _ { \theta } \dot { ( } x _ { i } ) \} _ { 1 } ^ { L } \ \bar { \in } \ \mathbb { R } ^ { L \times D }$ , a Transformer encoder $f _ { \theta }$ which computes interactions between all input tokens and outputs contextualized representations $t ^ { \prime } = \{ t _ { i } ^ { \prime } \} _ { 1 } ^ { L }$ , and a masked language modeling (MLM) classifier head $m _ { \theta }$ which independently maps the $D$ -dimensional continuous embedding for each token $t _ { i } ^ { \prime }$ to a vector of logits parameterizing a categorical distribution over the vocabulary $V$ . This distribution is referred to by $\operatorname { \bar { l o g } } p _ { \theta } ( x ) : = \operatorname { \bar { \{ } } m _ { \theta } ( t _ { i } ^ { \prime } ) \overset { \_ } \} _ L ^ { } \in \mathbb { R } ^ { L \times V }$ . We assume that the language model is pretrained, i.e. $\theta$ has been optimised with a standard MLM objective [17] on a large dataset of text from the Web. We show in Section 4.2 that this text-only pretraining has a crucial importance for zero-shot VideoQA.
53
+
54
+ Pretrained Video Encoder. The video is represented by a sequence of frames $y = \{ y _ { i } \} _ { 1 } ^ { T }$ . Each frame is forwarded separately through a visual backbone $h _ { \phi }$ , which outputs one feature vector per frame $\boldsymbol { u } = \{ u _ { i } \} _ { 1 } ^ { T } : = \{ h _ { \phi } ( y _ { i } ) \} _ { 1 } ^ { T } \in \mathbb { R } ^ { T \times D _ { u } }$ . In detail, the visual backbone is CLIP ViT-L/14 [18, 71] at resolution $2 2 4 \times 2 2 4$ pixels, pretrained to map images to text descriptions with a contrastive loss on 400M Web-scraped image-text pairs. The backbone is kept frozen throughout our experiments. Note that a CLIP-baseline for zero-shot VideoQA results in poor performance, see Section 4.4.
55
+
56
+ Connecting the Frozen Language and Frozen Vision components. The video features are incorporated into the language model as a prompt [49, 57, 113] $v$ of length $T$ (Figure 2, left). This prompt is obtained by linearly mapping the visual features $u$ to the text token embedding space via a visual-to-text projection $\boldsymbol { P } ^ { \check { \mathbf { \check { \tau } } } } \in \mathbb { R } ^ { \pmb { \check { D } _ { u } } \times \pmb { \check { D } } }$ , i.e. $v = \{ v _ { i } \} _ { 1 } ^ { T } : = \{ P ( u _ { i } ) \} _ { 1 } ^ { T }$ . The prompt is then concatenated with the text embeddings before being forwarded to the transformer encoder that models joint visual-linguistic interactions. We show in Section 4.2 that incorporating the input video considerably improves zero-shot VideoQA results. In addition, to learn powerful multi-modal interactions while keeping the transformer encoder weights frozen, we equip the transformer encoder with lightweight adapter modules $A$ [28] (Figure 2, right). We use an adapter which transforms the hidden state $z$ with a multi-layer perceptron transformation and a residual connection, i.e. $A ( z ) = z + W ^ { u p } \psi ( W ^ { d o w n } z )$ with $W ^ { d o w n } \in \mathbb { R } ^ { \bar { D } \times D _ { h } }$ , $W ^ { u p } \in \mathbb { R } ^ { D _ { h } \times D }$ , $D$ the hidden dimension of the transformer, $D _ { h }$ the bottleneck dimension, and $\psi$ a ReLU activation function. $D _ { h }$ is typically set to be smaller than $D$ such that the adapters are lightweight. In detail, we add an adapter module before the layer normalization, after each self-attention layer and each feed-forward layer of the transformer encoder.
57
+
58
+ # 3.2 Cross-modal training
59
+
60
+ We wish to train the newly added modules introduced in the previous section (shown in orange in Figure 2) for the VideoQA task. This is hard because we assume that no explicit manual annotation for the VideoQA task is available, such annotations being expensive and therefore hard to obtain at scale. Instead we train our architecture using only readily-available video-caption pairs scraped from the Web. Such data is easy to obtain [6, 67, 109], ensuring the scalability of our approach.
61
+
62
+ During training, we keep the weights of the pretrained BiLM and pretrained visual backbone frozen as previously explained. We train from scratch the parameters of (i) the visual-to-text projection module $P$ and (ii) the adapter modules $A$ . We show in Section 4.2 the importance of freezing the BiLM weights combined with training the adapter modules. Note that all normalization layers [5] of the pretrained BiLM are also updated to adjust to the new distribution of the training data. We denote all the trainable parameters of our model by the subscript $\mu$ . In practice, they sum up to about $5 \%$ of the BiLM parameters, hence the training of our model is computationally efficient.
63
+
64
+ We use a visually-conditioned masked language modeling objective (MLM), in which some text tokens $\{ x _ { m } \}$ are randomly masked and the model has to predict these tokens based on the surrounding text tokens and the video input. Formally, we minimize the following loss:
65
+
66
+ $$
67
+ \mathcal { L } _ { \mu } ( x , y ) = - \frac { 1 } { M } \sum _ { m } \log p _ { \mu } ( \tilde { x } , y ) _ { m } ^ { x _ { m } } ,
68
+ $$
69
+
70
+ where $\tilde { x }$ is the corrupted text sequence, $y$ is the sequence of video frames, $p _ { \mu } ( \tilde { x } , y ) _ { m } ^ { x _ { m } }$ is the probability for the (masked) $m$ -th token in $\tilde { x }$ to be $x _ { m }$ , and $M$ is the number of masks in the sequence $\tilde { x }$ . In detail, we follow [17] and corrupt $15 \%$ of text tokens, replacing them $80 \%$ of the time with a mask token, $10 \%$ of the time with the same token and $10 \%$ of the time with a randomly sampled token.
71
+
72
+ # 3.3 Adapting to downstream tasks
73
+
74
+ After training, our model is able to fill gaps in the input text given an input video together with left and right textual context as part of the input text. We wish to apply our model out-of-the-box to predict an answer given a question about a video. The video can optionally come with textual subtitles obtained using automatic speech recognition. To avoid using manual supervision, we formulate the downstream tasks in cloze form [76, 90], i.e. such that the model only has to fill-in a mask token in the input prompt similarly to the MLM objective optimized during training. The adaptation to the downstream tasks brings several challenges, as described next. First, we describe how we formulate the input text prompts for several downstream tasks. Then, we explain how we map the mask token from the input text prompt to an answer via a frozen answer embedding module. Finally, we present how we finetune our architecture in a supervised setting.
75
+
76
+ Input prompt engineering. We describe how we design the input text prompts for several downstream video-language tasks. Each downstream task is formulated as a masked language modeling problem. This allows us to apply FrozenBiLM out-of-the-box. A [CLS] token and a [SEP] token are respectively inserted at the start and the end of each sequence following [17].
77
+
78
+ Open-ended VideoQA. Given a question and a video, the task is to find the correct answer in a large vocabulary $\mathcal { A }$ of about 1K answers. Answers are concise, i.e. the great majority of answers consist of one word [32, 98, 101, 108]. We design the following prompt:
79
+
80
+ “[CLS] Question: <Question>? Answer: [MASK]. Subtitles: <Subtitles> [SEP]”
81
+
82
+ Multiple-choice VideoQA. Given a question and a video, the task is to find the correct answer in a small number of candidates $C$ , typically up to 5 choices [46, 54]. We set the vocabulary to $\mathcal { A } = [ \mathrm { Y e s } , \mathrm { N o } ]$ and compute a confidence score for each candidate by using the following prompt:
83
+
84
+ “[CLS] Question: <Question>? Is it ’<Answer Candidate>’? [MASK]. Subtitles: <Subtitles> [SEP]”
85
+
86
+ We choose the best option by selecting the candidate with the highest Yes logit value.
87
+
88
+ Video-conditioned fill-in-the-blank task. Given a video and a sentence with a blank space, the task is to fill in the blank with the correct word from a vocabulary $\mathcal { A }$ of about 1K answers. We replace the blank in the sentence with a mask token, and design the following prompt:
89
+
90
+ Note that all prompts are prepended with the video prompt (see Section 3.1) before being forwarded to the transformer encoder.
91
+
92
+ Answer embedding module. For each downstream task, we wish to map the mask token in the input text prompt to an actual answer prediction in the set of possible answers $\mathcal { A }$ , as described above. For this we use the frozen MLM classifier head $m _ { \theta }$ . However, $m _ { \theta } \in \mathbb { R } ^ { V \times D }$ covers $V$ different tokens where $V > > N$ and $N \approx 1 , 0 0 0$ is the size of $\mathcal { A }$ . Therefore, we introduce a task-specific answer classification head $l$ which linearly maps a contextualized mask representation $t _ { i } ^ { \prime }$ to a vector of logits parameterizing a categorical distribution over the vocabulary $\mathcal { A }$ , i.e. $\boldsymbol { l } \in \mathbb { R } ^ { N \times D }$ . We set the weights of this answer module $l$ with the corresponding weights of the pretrained MLM classifier $m _ { \theta }$ for one-token answers. In the case of multi-token answers, we average the weights of their different tokens. We, hence, enable zero-shot inference at test time. We also discuss other alternative strategies to handle multi-token answers in the Supplementary Material.
93
+
94
+ Fully-supervised training. To evaluate our approach on fully-supervised benchmarks, we also explore finetuning of our model on datasets that provide manual annotations for the target task. To this end, we train the same parameters as explained in Section 3.2, while keeping the transformer weights and the answer embedding module frozen. For open-ended VideoQA and video-conditioned fill-in-theblank, we use a cross-entropy loss on the task-specific vocabulary $\mathcal { A }$ . For multiple-choice VideoQA, we use a binary cross-entropy loss applied to each answer candidate. We show in Section 4.5 the benefit of freezing the language model weights during fully-supervised training.
95
+
96
+ # 4 Experiments
97
+
98
+ This section demonstrates the benefits of our FrozenBiLM framework and compares our method to the state of the art. We first outline our experimental setup in Section 4.1. We then present ablation studies in Section 4.2. Next we compare our bidirectional framework to its autoregressive variant in Section 4.3. The comparison to the state of the art in zero-shot VideoQA and qualitative results are presented in Section 4.4. Finally, we finetune our model on the VideoQA task in Section 4.5, where we show few-shot and fully-supervised results.
99
+
100
+ # 4.1 Experimental setup
101
+
102
+ Frozen bidirectional language model. We use a tokenizer based on SentencePiece [41] with $V = 1 2 8$ , 000, and a bidirectional language model with 900M parameters, DeBERTa-V2-XLarge [25], trained with the MLM objective on a corpus of 160G text data. We also show how our approach generalizes to other MLM-pretrained bidirectional language models such as BERT [17] in Section 4.2.
103
+
104
+ Datasets. For training we use the publicly available WebVid10M dataset [6], which consists of 10 million of video-text pairs scraped from the Shutterstock website where video captions are obtained from readily-available alt-text descriptions. We evaluate results on eight downstream datasets covering a wide range of textual and video domains (e.g. GIFs, YouTube videos, TV shows, movies), and multiple VideoQA paradigms: open-ended VideoQA (iVQA [101], MSRVTTQA [98], MSVD-QA [98], ActivityNet-QA [108] and TGIF-QA FrameQA [32]), multiple-choice VideoQA (How2QA [54] and TVQA [46]) and video-conditioned fill-in-the-blank (LSMDC-Fillin-the-blank [66]). Unless stated otherwise, we report top-1 test accuracy using the original splits for training, validation and test. For How2QA, we report results on the public validation set for comparison with prior work [78, 101, 107]. For TVQA, we report results on the validation set for the ablation studies and on the hidden test set for the comparison to the state of the art. More details are included in the Supplementary Material.
105
+
106
+ Implementation Details. The training for 2 epochs on WebVid10M lasts 20 hours on 8 Tesla V100 GPUs. We give further details in the Supplementary Material.
107
+
108
+ # 4.2 Ablation studies
109
+
110
+ In this section, we evaluate the zero-shot performance of different variants of our method. By default, we use the frozen pretrained DeBERTa-V2-XLarge language model and train the visual-to-textprojection layer together with adapters for 2 epochs on WebVid10M. We refer to this default model as FrozenBiLM. This model uses three input modalities in terms of video, question, and speech.
111
+
112
+ <table><tr><td colspan="2">LM</td><td rowspan="2">Frozen</td><td rowspan="2">Adapters</td><td rowspan="2">Fill-in-the-blank</td><td colspan="5">Open-ended</td><td colspan="2">Multiple-choice</td></tr><tr><td>Pretraining</td><td>LM</td><td>LSMDC</td><td></td><td>iVQA MSRVTT-QA MSVD-QA ActivityNet-QA TGIF-QA</td><td></td><td></td><td></td><td>How2QA TVQA</td></tr><tr><td>1.</td><td>X</td><td>X</td><td>X</td><td>0.5</td><td>0.3</td><td>0.1</td><td>0.0</td><td>0.5</td><td>0.0</td><td>32.4</td><td>20.7</td></tr><tr><td></td><td>√</td><td></td><td>×</td><td>37.1</td><td>21.0</td><td>17.6</td><td>31.9</td><td>20.7</td><td>30.7</td><td>45.7</td><td>45.6</td></tr><tr><td>2</td><td>√</td><td>×</td><td>X</td><td>50.7</td><td>27.3</td><td>16.8</td><td>32.2</td><td>24.7</td><td>41.0</td><td>53.5</td><td>53.4</td></tr><tr><td>4.</td><td>√</td><td>√</td><td>√</td><td>51.5</td><td>26.8</td><td>16.7</td><td>33.8</td><td>25.9</td><td>41.9</td><td>58.4</td><td>59.2</td></tr></table>
113
+
114
+ Table 1: The effect of initializing and training various parts of our model evaluated on zero-shot VideoQA. All models are trained on WebVid10M and use multi-modal inputs (video, speech and question) at inference.
115
+
116
+ <table><tr><td rowspan="2"></td><td rowspan="2">Visual</td><td rowspan="2">Speech</td><td rowspan="2">Fill-in-the-blank LSMDC</td><td colspan="5">Open-ended</td><td colspan="2">Multiple-choice</td></tr><tr><td>iVQA</td><td>MSRVTT-QA</td><td></td><td>MSVD-QA ActivityNet-QA</td><td>TGIF-QA</td><td>How2QA</td><td>TVQA</td></tr><tr><td>1.</td><td>X</td><td>X</td><td>47.9</td><td>11.0</td><td>6.4</td><td>11.3</td><td>22.6</td><td>32.3</td><td>29.6</td><td>23.2</td></tr><tr><td></td><td></td><td>√</td><td>49.8</td><td>13.2</td><td>6.5</td><td>11.7</td><td>23.1</td><td>32.3</td><td>45.9</td><td>44.1</td></tr><tr><td>2</td><td>X</td><td>X</td><td>50.9</td><td>26.2</td><td>16.9</td><td>33.7</td><td>25.9</td><td>41.9</td><td>41.9</td><td>29.7</td></tr><tr><td>4.</td><td>√</td><td>√</td><td>51.5</td><td>26.8</td><td>16.7</td><td>33.8</td><td>25.9</td><td>41.9</td><td>58.4</td><td>59.2</td></tr></table>
117
+
118
+ Table 2: Impact of the visual and speech modalities on zero-shot VideoQA. Rows 1 and 2 report results for a pretrained language model without any visual input. Rows 3 and 4 give results for a FrozenBiLM model pretrained on WebVid10M.
119
+
120
+ Ablation of the model training. We ablate the effect of initializing parameters of the language model, freezing its weights and training adapters in Table 1. We observe that the language model pretraining is crucial. Indeed, a model with randomly initialized language weights (row 1) performs poorly compared to models initialized with language pretrained weights (rows 2 to 4). Moreover, the model which updates the language model weights (row 2) during cross-modal training performs considerably worse compared to variants that freeze them (rows 3 and 4). This shows the benefit of freezing the language model for zero-shot VideoQA. We also notice the benefit of the adapter layers by comparing rows 3 and 4, especially for multiple-choice datasets. Finally, we note that training variants with the frozen language model is twice faster compared to updating all parameters, as there is a significantly lower number of parameters to be trained.
121
+
122
+ Impact of modalities. Table 2 shows the impact of the visual and speech modalities on the zero-shot performance of our model. First, we evaluate the text-only performance of our model using neither visual input nor speech input in row 1. We can observe that adding speech (row 2) marginally improves the results and that the importance of speech highly depends on the dataset. When adding vision (rows 3 and 4), the performance increases significantly, e.g. $+ 1 3 . 6 \%$ accuracy on iVQA and $+ 2 2 . 1 \%$ on MSVD-QA between rows 4 and 2. Finally, the model with vision also benefits from the speech, e.g. $+ 1 6 . 5 \%$ accuracy on How2QA and $+ 2 9 . 5 \%$ accuracy on TVQA (compare rows 3 and 4).
123
+
124
+ Note that in practice, speech is missing for many videos, as we obtain the speech directly from the YouTube API and many videos are no longer available. Exceptions are How2QA and TVQA for which the authors [46, 55] provide speech for all videos. Consequently, we have speech data for only $4 4 . 3 \%$ , $1 4 . 2 \%$ , $8 . 2 \%$ , $7 . 1 \%$ and $2 5 . 3 \%$ of test samples in LSMDC-FiB, iVQA, MSRVTT-QA, MSVD-QA and ActivityNet-QA respectively. GIFs in TGIF-QA do not contain speech.
125
+
126
+ Size of the cross-modal training dataset. Zero-shot results of FrozenBiLM after training for a fixed number of iterations on different fractions of WebVid10M are shown in Table 3. We construct these subsets such that larger subsets include the smaller ones. We find that performance increases monotonically with more multi-modal training data.
127
+
128
+ Size of the language model. In Table 4, we ablate the importance of the language model size for the zero-shot performance. Note that when comparing different language models, we use no adapters to avoid biases related to the choice of the bottleneck dimension hyperparameter [28]. We find that using the 900M-parameter DeBERTA-V2-XLarge (row 6) outperforms the 300M-parameter BERT-Large (row 5) which also improves over the 100M-parameter BERT-Base (row 4).
129
+
130
+ Table 3: Dependency on the size of the training set. Zero-shot results are presented for different fractions of the WebVid10M dataset used for training.
131
+
132
+ <table><tr><td></td><td>Training Data</td><td>MSVD-QA</td><td>How2QA</td></tr><tr><td>1.</td><td>WebVid1K</td><td>13.6</td><td>53.0</td></tr><tr><td>2.</td><td>WebVid10K</td><td>22.7</td><td>54.9</td></tr><tr><td>3.</td><td>WebVid200K</td><td>27.8</td><td>56.0</td></tr><tr><td>4.</td><td>WebVid2M</td><td>30.1</td><td>57.4</td></tr><tr><td>5.</td><td>WebVid10M</td><td>33.8</td><td>58.4</td></tr></table>
133
+
134
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Language Model</td><td colspan="2">#LM params Train timel</td><td colspan="5">iVQA MSRVTT-QA MSVD-QA ActivityNet-QA TGIF-QA</td></tr><tr><td></td><td>(GPUH) 200</td><td></td><td>4.2</td><td>10.1</td><td>17.8</td><td>14.4</td></tr><tr><td rowspan="3"></td><td>1. GPT-Neo-1.3B Autoregressive 2.GPT-Neo-2.7B</td><td>1.3B 2.7B</td><td>360</td><td>6.6 9.1</td><td>7.7</td><td>17.8</td><td>17.4</td><td>20.1</td></tr><tr><td>3.GPT-J-6B</td><td>6B</td><td>820</td><td>21.4</td><td>9.6</td><td>26.7</td><td>24.5</td><td>37.3</td></tr><tr><td>4.BERT-Base</td><td>110M</td><td>24</td><td>12.4</td><td>6.4</td><td>11.7</td><td>16.7</td><td>23.1</td></tr><tr><td rowspan="3">Bidirectional</td><td></td><td>340M</td><td>60</td><td>12.9</td><td>7.1</td><td>13.0</td><td>19.0</td><td>21.5</td></tr><tr><td>5.BERT-Large</td><td></td><td></td><td>27.3</td><td>16.8</td><td>32.2</td><td>24.7</td><td>41.0</td></tr><tr><td>6.DeBERTa-V2-XLarge</td><td>890M</td><td>160</td><td></td><td></td><td></td><td></td><td></td></tr></table>
135
+
136
+ Table 4: Comparison of autoregressive language models (top) and bidirectional language models (bottom) for zero-shot VideoQA. All variants are trained on WebVid10M for the same number of epochs.
137
+
138
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Training Data</td><td rowspan="2">Speech</td><td>|Fill-in-the-blank|</td><td colspan="4">Open-ended</td><td colspan="2">Multiple-choice How2QATVQA</td></tr><tr><td>LSMDC</td><td>iVQA MSRVTT-QA MSVD-QA ActivityNet-QA TGIF-QA</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Random</td><td></td><td></td><td>0.1</td><td>0.1</td><td>0.1 0.1 7.2</td><td></td><td>0.1</td><td>0.1</td><td>20</td></tr><tr><td>CLIP ViT-L/14 [71] 400M image-textsX</td><td></td><td></td><td>1.2</td><td>9.2</td><td>2.1</td><td></td><td>1.2</td><td>3.6 47.7</td><td>26.1</td></tr><tr><td>Just Ask [102]</td><td>HowToVQA69M+ WebVidVQA3M</td><td>X</td><td></td><td>13.3</td><td>5.6</td><td>13.5</td><td>12.3</td><td></td><td></td></tr><tr><td>Reserve [110]</td><td>YT-Temporal-1B</td><td>X</td><td>31.0</td><td></td><td>5.8</td><td></td><td></td><td>53.1</td><td></td></tr><tr><td>FrozenBiLM(Ours) WebVid10M</td><td></td><td>X</td><td>50.9</td><td>26.2</td><td>16.9</td><td></td><td></td><td></td><td>29.7</td></tr><tr><td>FrozenBiLM(Ours)WebVid10M</td><td></td><td>√</td><td>51.5</td><td>26.8</td><td>33.7 16.7 33.8</td><td>25.9 25.9</td><td>41.9 41.9</td><td>41.9 58.4</td><td>59.7</td></tr></table>
139
+
140
+ Table 5: Comparison with the state of the art for zero-shot VideoQA.
141
+
142
+ Importance of the suffix. Our text input prompts include a suffix just to the right of the mask token which consists in a point and an end-of-sentence token for the variant without speech (or a point followed by the speech subtitles for the variant with speech). We found that removing this suffix leads to a considerable drop of performance (e.g. the test accuracy on MSVD-QA in the row 3 of Table 2 drops from $3 3 . 7 \%$ to $2 . 8 \%$ ). Note that we do not observe such a large drop in performance when removing the [CLS] token e.g. the accuracy on MSVD-QA drops only from $3 3 . 8 \%$ to $3 3 . 2 \%$ . This shows that the bidirectional nature of our framework is a key factor for the performance. Intuitively, this suffix forces the model to provide a concise answer. Such a hard constraint cannot be given to unidirectional autoregressive models compared next in Section 4.3. We further ablate the importance of the prompt design in the Supplementary Material.
143
+
144
+ # 4.3 Comparison with frozen autoregressive models
145
+
146
+ In this section, we compare our bidirectional framework using language models of various sizes to the larger, autoregressive GPT-based counterparts recently used for zero-shot image question answering [91, 104]. For fair comparison, we adapt autoregressive models to video and language inputs similarly as our bidirectional models. In detail, autoregressive variants train a similar visual-totext projection by using a left-to-right language modeling loss [91]. All models in our comparison are trained on WebVid10M for the same number of epochs. At inference, autoregressive variants use the same template as [91] to which we prepend speech subtitles, greedily decode sequences as [91], and use the same answer vocabulary as bidirectional models. Autoregressive variants select the top answer that maximizes the log-likelihood when appended to the question prompt. Here also, we use no adapters for all models, such that the architecture of autoregressive models closely follows [91]. This is to avoid biases related to the tuning of the bottleneck reduction hyperparameter in the adapters [28].
147
+
148
+ We compare autoregressive and bidirectional language models in terms of accuracy and efficiency in Table 4. We observe that our bidirectional framework (rows 4-6) achieves significantly better zero-shot performance-efficiency trade-off compared to its autoregressive counterpart (rows 1-3). For instance, our framework with BERT-Base [17] (row 4) outperforms the autoregressive variant based on GPT-Neo-1.3B [7] (row 1) which uses 12 times more parameters and 8 times more training time. Likewise, our framework with DeBERTa-V2-XLarge [25] (row 6) improves over the autoregressive variant based on GPT-J-6B [94] (row 3) that has 7 times more parameters and requires 5 times more training time, showing the efficiency of our bidirectional framework for zero-shot VideoQA.
149
+
150
+ # 4.4 Comparison to the state of the art for zero-shot VideoQA
151
+
152
+ Quantitative comparison. Table 5 presents results of our method in comparison to the state of the art in zero-shot VideoQA settings [101], i.e. when using no manually annotated visual data for training. Our approach outperforms previous methods by a significant margin on all 8 datasets. In
153
+
154
+ ![](images/b49b62f4806b31a8cbb7428319bfc2f97b769ef3bb39adaf999b69eb7f6c7442.jpg)
155
+
156
+ ![](images/94c2be5581307ef3dd7a4aa94a366db797ffef89c606b6a0d5dadadda100607b.jpg)
157
+
158
+ ![](images/ebb260bdef7892c31c6fe6a378ce2e8025b64d1a44e5ed8b738e222cc37bc540.jpg)
159
+
160
+ ![](images/665bbb654b07ca684b2cdf215cd247ac12e0b881c212e011c6270e4807b38481.jpg)
161
+
162
+ ![](images/48e0243ccbfb3d468d1ce1701aa0fff58d0e4816da8958e505398ad01558a32d.jpg)
163
+
164
+ Question: What is the man holding at the start of the video? GT Answer: guitar, electric guitar Just Ask: typewriter UnFrozenBiLM: beer FrozenBiLM (text-only): scissors FrozenBiLM (ours): guitar
165
+
166
+ Question: What item hanging on the wall features a tree? GT Answer: quilt Just Ask: christmas sock UnFrozenBiLM: fabric FrozenBiLM (text-only): tree FrozenBiLM (ours): quilt
167
+
168
+ Question: What is the sitting
169
+ man doing?
170
+ GT Answer: knit sweater
171
+ Just Ask: tie cow
172
+ UnFrozenBiLM: swimming
173
+ FrozenBiLM (text-only): eating
174
+ FrozenBiLM (ours): knit sweater
175
+ Question: Where is the woma
176
+ sitting on?
177
+ GT Answer: camel
178
+ Just Ask: horse yard
179
+ UnFrozenBiLM: desert
180
+ FrozenBiLM (text-only): chair
181
+ FrozenBiLM (ours): camel
182
+ Question: What is the color of the
183
+ cabinet door in the video?
184
+ GT Answer: red
185
+ Just Ask: dresser
186
+ UnFrozenBiLM: blue
187
+ FrozenBiLM (text-only): black
188
+ FrozenBiLM (ours): red
189
+
190
+ Figure 3: Zero-Shot VideoQA. Qualitative comparison between Just Ask [102] (row 3 in Table 5), our model (row 4 in Table 5), its unfrozen variant (row 2 in Table 1) and its text-only variant (row 2 in Table 2). The first two examples are from iVQA [101] and the last three examples are from ActivityNet-QA [108].
191
+
192
+ <table><tr><td rowspan="2">Method</td><td colspan="2">#Trained|Fill-in-the-blank|</td><td colspan="5">Open-ended</td><td colspan="2">Multiple-choice</td></tr><tr><td>Params</td><td>LSMDC</td><td></td><td>iVQA MSRVTT-QA MSVD-QA ActivityNet-QA TGIF-QA|How2QA TVQA</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>HCRN [45]</td><td>44M</td><td></td><td></td><td>35.4</td><td>36.8</td><td></td><td>57.9</td><td></td><td>71.4*</td></tr><tr><td>HERO [54]</td><td>119M</td><td></td><td></td><td></td><td></td><td></td><td></td><td>74.1*</td><td>73.6*</td></tr><tr><td>ClipBERT[48]</td><td>114M</td><td></td><td></td><td>37.4</td><td></td><td></td><td>60.3</td><td></td><td></td></tr><tr><td>Just Ask [102]</td><td>157M</td><td></td><td>35.4</td><td>41.8</td><td>47.5</td><td>39.0</td><td></td><td>85.3</td><td></td></tr><tr><td>SiaSamRea [107]</td><td></td><td></td><td></td><td>41.6</td><td>45.5</td><td>39.8</td><td>60.2</td><td>84.1</td><td></td></tr><tr><td>MERLOT[109]</td><td>223M</td><td>52.9</td><td></td><td>43.1</td><td></td><td>41.4</td><td>69.5</td><td></td><td>78.7*</td></tr><tr><td>Reserve [110]</td><td>644M</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>86.1*</td></tr><tr><td>VIOLET[21]</td><td>198M</td><td>53.7</td><td></td><td>43.9</td><td>47.9</td><td></td><td>68.9</td><td></td><td></td></tr><tr><td>All-in-one [93]</td><td>110M</td><td></td><td></td><td>46.8</td><td>48.3</td><td></td><td>66.3</td><td></td><td></td></tr><tr><td>UnFrozenBiLM(Ours)</td><td>890M</td><td>58.9*</td><td>37.7*</td><td>45.0*</td><td>53.9*</td><td>43.2*</td><td>66.9</td><td>87.5*</td><td>79.6*</td></tr><tr><td>FrozenBiLM w/o speech (Ours) 30M</td><td></td><td>58.6</td><td>39.7</td><td>47.0</td><td>54.4</td><td>43.2</td><td>68.6</td><td>81.5</td><td>57.5</td></tr><tr><td>FrozenBiLM(Ours)</td><td>30M</td><td>63.5*</td><td>39.6*</td><td>47.0*</td><td>54.8*</td><td>43.2*</td><td>68.6</td><td>86.7*</td><td>82.0*</td></tr></table>
193
+
194
+ Table 6: Comparison with the state of the art, and the variant UnFrozenBiLM which does not freeze the language model weight, on fully-supervised benchmarks. \* denotes results obtained with speech input.
195
+
196
+ <table><tr><td rowspan="2">Supervision</td><td rowspan="2"></td><td rowspan="2">Fill-in-the-blank LSMDC</td><td colspan="4">Open-ended</td><td rowspan="2">Multiple-choice</td></tr><tr><td></td><td>iVQA MSRVTT-QA MSVD-QA ActivityNet-QA TGIF-QA</td><td></td><td>How2QA TVQA</td></tr><tr><td>1.</td><td>0% (zero-shot)</td><td>51.5</td><td>26.8</td><td>16.7 33.8</td><td>25.9</td><td>41.9</td><td>58.4</td><td>59.7</td></tr><tr><td>2.</td><td>1% (few-shot)</td><td>56.9</td><td>31.1</td><td>36.0</td><td>46.5</td><td>33.2 55.1</td><td>71.7</td><td>72.5</td></tr><tr><td>3.</td><td>10% (few-shot)</td><td>59.9</td><td>35.3</td><td>41.7</td><td>51.0</td><td>37.4</td><td>61.2 75.8</td><td>77.6</td></tr><tr><td></td><td>4.100% (fully-supervised)</td><td>63.5</td><td>39.6</td><td>47.0</td><td>54.8</td><td>43.2</td><td>68.6 86.7</td><td>82.0</td></tr></table>
197
+
198
+ Table 7: Few-shot results, by finetuning FrozenBiLM using a small fraction of the downstream training dataset.
199
+
200
+ particular, FrozenBiLM outperforms Reserve [110], which is trained on one billion YouTube video clips jointly with vision, language and sound, Just Ask [102], which uses large-scale automatically generated VideoQA data, and a CLIP baseline [71] matching the text concatenating question and answer to the middle frame of the video. Note that FrozenBiLM performs competitively even when using no speech input. Finally, we note that BLIP [53] has a different definition of zero-shot where a network finetuned on the image-VQA dataset [4] is evaluated directly on VideoQA datasets. Our Supplementary Material presents results where we outperform BLIP [53] in their settings and also includes an analysis of results by question type. In summary, our evaluation shows the excellent performance of our model in the challenging zero-shot setup.
201
+
202
+ Qualitative results. Figure 3 illustrates qualitative results of zero-shot VideoQA for our FrozenBiLM model and compares them to Just Ask [102], as well as to variants of our approach that do not freeze the language model (UnFrozenBiLM) and use no visual modality (text-only), as evaluated in Section 4.2. We observe that the unfrozen variant can predict answers that lack text-only commonsense reasoning, e.g. in the third example, it is unlikely that a sitting man is swimming. The text-only variant does have strong language understanding, but makes visually-unrelated predictions. In contrast, consistently with our quantitative results, our model FrozenBiLM is able to correctly answer various questions, showing both a strong textual commonsense reasoning and a complex multi-modal understanding. We show additional qualitative results in the Supplementary Material.
203
+
204
+ # 4.5 Freezing the BiLM is also beneficial in supervised settings
205
+
206
+ Fully-supervised VideoQA. We next present an evaluation in a supervised setup where we finetune FrozenBiLM on a downstream VideoQA task. We emphasize that we also keep our pretrained language model weights frozen all throughout finetuning. As shown in Table 6, our approach improves the state of the art on LSMDC-FiB, iVQA, MSRVTT-QA, MSVD-QA, ActivityNet-QA and How2QA. In particular, FrozenBiLM outperforms strong recent baselines such as All-in-one [93] on 2/3 datasets, VIOLET [21] on 3/4 datasets and MERLOT [109] on 4/5 datasets. Our approach has significantly less trainable parameters compared to the state of the art [21, 93, 109] as we freeze the weights of the pretrained language model. We ablate this major difference in Table 6, and find that our FrozenBiLM with the frozen language model performs better and trains twice faster compared to UnFrozenBiLM where we update the language model during training. This shows that freezing the language model is not only beneficial for zero-shot but also in fully-supervised settings, therefore suggesting that our FrozenBiLM framework also provides a parameter-efficient solution for VideoQA training. Finally, we note that FrozenBiLM performs competitively even without speech input, although speech helps significantly for the performance on LSMDC, How2QA and TVQA.
207
+
208
+ Few-shot VideoQA. The low number of trainable parameters when training FrozenBiLM makes it particularly well-suited in the low data regime. To verify this, we explore a few-shot VideoQA setting where we finetune our pretrained model using varying fractions of VideoQA training data. From Table 7 we observe significant improvements over zero-shot when using only $1 \%$ of training data. Finally, we show in Supplementary Material that freezing the BiLM highly benefits the few-shot performance, consistently with the results in the zero-shot and fully-supervised settings.
209
+
210
+ # 5 Conclusion
211
+
212
+ We have presented FrozenBiLM, a framework that extends frozen bidirectional language models to multi-modal inputs by training additional modules on Web-scraped data, and that tackles zero-shot VideoQA through masked language modeling. We have provided extensive ablation studies and shown the efficiency of our framework compared to its autoregressive variant. FrozenBiLM improves the state-of-the-art zero-shot VideoQA on various datasets, performs competitively in fully-supervised settings and exhibits strong performance in the few-shot VideoQA setting we newly introduce.
213
+
214
+ Limitations. Promising directions not explored in this work include scaling the size of a bidirectional language model to several billion parameters, and additional training on large datasets of YouTube videos with accompanying speech transcripts and/or audio [110]. Also, our model cannot be applied out-of-the-box to complex multi-modal text generation tasks such as video captioning.
215
+
216
+ Broader Impact. We have showed the superior compute-efficiency of our bidirectional framework compared to autoregressive models for zero-shot VideoQA, and believe it is a step towards reducing the environmental impact of such research and its applications [84]. In addition, our models might reflect biases present in videos and captions from Shutterstock used to train our model, the text data used to train the language model or the images and captions used to train the visual backbone. It is important to keep this in mind when deploying, analysing and building upon these models.
217
+
218
+ Acknowledgements. This work was granted access to the HPC resources of IDRIS under the allocation 2022-AD011011670R2 made by GENCI. The work was funded by a Google gift, the French government under management of Agence Nationale de la Recherche as part of the "Investissements d’avenir" program, reference ANR-19-P3IA-0001 (PRAIRIE 3IA Institute), the Louis Vuitton ENS Chair on Artificial Intelligence, the European Regional Development Fund under project IMPACT (reg. no. CZ.02.1.01/0.0/0.0/15 003/0000468). We thank anonymous reviewers for giving interesting feedback. We thank Gaspard Beugnot, Clémence Bouvier and Pierre-Louis Guhur for proofreading.
219
+
220
+ References [1] FrozenBiLM project webpage. https://antoyang.github.io/frozenbilm.html. [2] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. In NeurIPS, 2022. [3] Elad Amrani, Rami Ben-Ari, Daniel Rotman, and Alex Bronstein. Noise estimation using density estimation for self-supervised multimodal learning. In AAAI, 2021. [4] Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C Lawrence Zitnick, and Devi Parikh. VQA: Visual question answering. In ICCV, 2015. [5] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. [6] Max Bain, Arsha Nagrani, Gül Varol, and Andrew Zisserman. Frozen in time: A joint video and image encoder for end-to-end retrieval. In ICCV, 2021. [7] Sid Black, Gao Leo, Phil Wang, Connor Leahy, and Stella Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, 2021. [8] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. In NeurIPS, 2020. [9] Santiago Castro, Mahmoud Azab, Jonathan Stroud, Cristina Noujaim, Ruoyao Wang, Jia Deng, and Rada Mihalcea. LifeQA: A real-life dataset for video question answering. In LREC, 2020.
221
+ [10] Aman Chadha, Gurneet Arora, and Navpreet Kaloty. iPerceive: Applying common-sense reasoning to multi-modal dense video captioning and video question answering. In WACV, 2021.
222
+ [11] Jun Chen, Han Guo, Kai Yi, Boyang Li, and Mohamed Elhoseiny. VisualGPT: Dataefficient adaptation of pretrained language models for image captioning. arXiv preprint arXiv:2102.10407, 2021.
223
+ [12] Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. UNITER: Universal image-text representation learning. In ECCV, 2020.
224
+ [13] Seongho Choi, Kyoung-Woon On, Yu-Jung Heo, Ahjeong Seo, Youwon Jang, Seungchan Lee, Minsu Lee, and Byoung-Tak Zhang. DramaQA: Character-centered video story understanding with hierarchical qa. In AAAI, 2021.
225
+ [14] Anthony Colas, Seokhwan Kim, Franck Dernoncourt, Siddhesh Gupte, Daisy Zhe Wang, and Doo Soon Kim. TutorialVQA: Question answering dataset for tutorial videos. In LREC, 2020.
226
+ [15] Long Hoang Dang, Thao Minh Le, Vuong Le, and Truyen Tran. Object-centric representation learning for video question answering. In IJCNN, 2021.
227
+ [16] Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, ˆ Gregory Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. IEEE TPAMI, 2021.
228
+ [17] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
229
+ [18] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
230
+ [19] Constantin Eichenberg, Sidney Black, Samuel Weinbach, Letitia Parcalabescu, and Anette Frank. MAGMA–multimodal augmentation of generative models through adapter-based finetuning. arXiv preprint arXiv:2112.05253, 2021.
231
+ [20] Chenyou Fan, Xiaofan Zhang, Shu Zhang, Wensheng Wang, Chi Zhang, and Heng Huang. Heterogeneous memory enhanced multimodal attention model for video question answering. In CVPR, 2019.
232
+ [21] Tsu-Jui Fu, Linjie Li, Zhe Gan, Kevin Lin, William Yang Wang, Lijuan Wang, and Zicheng Liu. VIOLET: End-to-end video-language transformers with masked visual-token modeling. arXiv preprint arXiv:2111.12681, 2021.
233
+ [22] Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. In NeurIPS, 2020.
234
+ [23] Jiyang Gao, Runzhou Ge, Kan Chen, and Ram Nevatia. Motion-appearance co-memory networks for video question answering. In CVPR, 2018.
235
+ [24] Noa Garcia, Mayu Otani, Chenhui Chu, and Yuta Nakashima. KnowIT VQA: Answering knowledge-based questions about videos. In AAAI, 2020.
236
+ [25] Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. DeBERTa: Decodingenhanced BERT with disentangled attention. In ICLR, 2021.
237
+ [26] Lisa Anne Hendricks, John Mellor, Rosalia Schneider, Jean-Baptiste Alayrac, and Aida Nematzadeh. Decoupling the role of data, attention, and losses in multimodal transformers. In TACL, 2021.
238
+ [27] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022.
239
+ [28] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In ICML, 2019.
240
+ [29] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In ICLR, 2022.
241
+ [30] Deng Huang, Peihao Chen, Runhao Zeng, Qing Du, Mingkui Tan, and Chuang Gan. Locationaware graph convolutional networks for video question answering. In AAAI, 2020.
242
+ [31] Zhicheng Huang, Zhaoyang Zeng, Bei Liu, Dongmei Fu, and Jianlong Fu. Pixel-BERT: Aligning image pixels with text by deep multi-modal transformers. arXiv preprint arXiv:2004.00849, 2020.
243
+ [32] Yunseok Jang, Yale Song, Youngjae Yu, Youngjin Kim, and Gunhee Kim. TGIF-QA: Toward spatio-temporal reasoning in visual question answering. In CVPR, 2017.
244
+ [33] Jianwen Jiang, Ziqiang Chen, Haojie Lin, Xibin Zhao, and Yue Gao. Divide and conquer: Question-guided spatio-temporal contextual attention for video question answering. In AAAI, 2020.
245
+ [34] Pin Jiang and Yahong Han. Reasoning with heterogeneous graph alignment for video question answering. In AAAI, 2020.
246
+ [35] Mandar Joshi, Danqi Chen, Yinhan Liu, Daniel S Weld, Luke Zettlemoyer, and Omer Levy. SpanBERT: Improving pre-training by representing and predicting spans. In TACL, 2020.
247
+ [36] Hyounghun Kim, Zineng Tang, and Mohit Bansal. Dense-caption matching and frame-selection gating for temporal localization in VideoQA. In ACL, 2020.
248
+ [37] Junyeong Kim, Minuk Ma, Trung Pham, Kyungsu Kim, and Chang D Yoo. Modality shifting attention network for multi-modal video question answering. In CVPR, 2020.
249
+ [38] Kyung-Min Kim, Min-Oh Heo, Seong-Ho Choi, and Byoung-Tak Zhang. Deepstory: Video story qa by deep embedded memory networks. In IJCAI, 2017.
250
+ [39] Seonhoon Kim, Seohyeong Jeong, Eunbyul Kim, Inho Kang, and Nojun Kwak. Self-supervised pre-training and contrastive representation learning for multiple-choice video qa. In AAAI, 2021.
251
+ [40] Wonjae Kim, Bokyung Son, and Ildoo Kim. ViLT: Vision-and-language transformer without convolution or region supervision. In ICML, 2021.
252
+ [41] Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In ACL, 2018.
253
+ [42] Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. ALBERT: A lite BERT for self-supervised learning of language representations. In ICLR, 2020.
254
+ [43] Thao Minh Le, Vuong Le, Svetha Venkatesh, and Truyen Tran. Hierarchical conditional relation networks for video question answering. In CVPR, 2020.
255
+ [44] Thao Minh Le, Vuong Le, Svetha Venkatesh, and Truyen Tran. Neural reasoning, fast and slow, for video question answering. In IJCNN, 2020.
256
+ [45] Thao Minh Le, Vuong Le, Svetha Venkatesh, and Truyen Tran. Hierarchical conditional relation networks for multimodal video question answering. In IJCV, 2021.
257
+ [46] Jie Lei, Licheng Yu, Mohit Bansal, and Tamara L Berg. TVQA: Localized, compositional video question answering. In EMNLP, 2018.
258
+ [47] Jie Lei, Licheng Yu, Tamara L Berg, and Mohit Bansal. TVQA $^ +$ : Spatio-temporal grounding for video question answering. In ACL, 2020.
259
+ [48] Jie Lei, Linjie Li, Luowei Zhou, Zhe Gan, Tamara L Berg, Mohit Bansal, and Jingjing Liu. Less is more: ClipBERT for video-and-language learning via sparse sampling. In CVPR, 2021.
260
+ [49] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In EMNLP, 2021.
261
+ [50] Dongxu Li, Junnan Li, Hongdong Li, Juan Carlos Niebles, and Steven CH Hoi. Align and prompt: Video-and-language pre-training with entity prompts. arXiv preprint arXiv:2112.09583, 2021.
262
+ [51] Gen Li, Nan Duan, Yuejian Fang, Ming Gong, Daxin Jiang, and Ming Zhou. Unicoder-VL: A universal encoder for vision and language by cross-modal pre-training. In AAAI, 2020.
263
+ [52] Junnan Li, Ramprasaath Selvaraju, Akhilesh Gotmare, Shafiq Joty, Caiming Xiong, and Steven Chu Hong Hoi. Align before fuse: Vision and language representation learning with momentum distillation. In NeurIPS, 2021.
264
+ [53] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. BLIP: Bootstrapping languageimage pre-training for unified vision-language understanding and generation. arXiv preprint arXiv:2201.12086, 2022.
265
+ [54] Linjie Li, Yen-Chun Chen, Yu Cheng, Zhe Gan, Licheng Yu, and Jingjing Liu. HERO: Hierarchical encoder for video+language omni-representation pre-training. In EMNLP, 2020.
266
+ [55] Linjie Li, Jie Lei, Zhe Gan, Licheng Yu, Yen-Chun Chen, Rohit Pillai, Yu Cheng, Luowei Zhou, Xin Eric Wang, William Yang Wang, et al. VALUE: A multi-task benchmark for video-and-language understanding evaluation. In NeurIPS Track on Datasets and Benchmarks, 2021.
267
+ [56] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. VisualBERT: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
268
+ [57] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In ACL, 2021.
269
+ [58] Xiangpeng Li, Jingkuan Song, Lianli Gao, Xianglong Liu, Wenbing Huang, Xiangnan He, and Chuang Gan. Beyond RNNs: Positional self-attention with co-attention for video question answering. In AAAI, 2019.
270
+ [59] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In ECCV, 2020.
271
+ [60] Xudong Lin, Gedas Bertasius, Jue Wang, Shih-Fu Chang, Devi Parikh, and Lorenzo Torresani. VX2TEXT: End-to-end learning of video-based text generation from multimodal inputs. In CVPR, 2021.
272
+ [61] 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.
273
+ [62] Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. ViLBERT: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In NeurIPS, 2019.
274
+ [63] Jiasen Lu, Vedanuj Goswami, Marcus Rohrbach, Devi Parikh, and Stefan Lee. 12-in-1: Multi-task vision and language representation learning. In CVPR, 2020.
275
+ [64] Ziyang Luo, Yadong Xi, Rongsheng Zhang, and Jing Ma. VC-GPT: Visual conditioned GPT for end-to-end generative vision-and-language pre-training. arXiv preprint arXiv:2201.12723, 2022.
276
+ [65] Rabeeh Karimi Mahabadi, Luke Zettlemoyer, James Henderson, Marzieh Saeidi, Lambert Mathias, Veselin Stoyanov, and Majid Yazdani. PERFECT: Prompt-free and efficient few-shot learning with language models. In ACL, 2022.
277
+ [66] Tegan Maharaj, Nicolas Ballas, Anna Rohrbach, Aaron Courville, and Christopher Pal. A dataset and exploration of models for understanding video data through fill-in-the-blank question-answering. In CVPR, 2017.
278
+ [67] Antoine Miech, Dimitri Zhukov, Jean-Baptiste Alayrac, Makarand Tapaswi, Ivan Laptev, and Josef Sivic. HowTo100M: Learning a text-video embedding by watching hundred million narrated video clips. In ICCV, 2019.
279
+ [68] Ron Mokady, Amir Hertz, and Amit H Bermano. ClipCap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021.
280
+ [69] Jonghwan Mun, Paul Hongsuck Seo, Ilchae Jung, and Bohyung Han. MarioQA: Answering questions by watching gameplay videos. In CVPR, 2017.
281
+ [70] Jungin Park, Jiyoung Lee, and Kwanghoon Sohn. Bridge to answer: Structure-aware graph interaction network for video question answering. In CVPR, 2021.
282
+ [71] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. arXiv preprint arXiv:2103.00020, 2021.
283
+ [72] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. JMLR, 2020.
284
+ [73] Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250, 2016.
285
+ [74] Arka Sadhu, Kan Chen, and Ram Nevatia. Video question answering with phrases via semantic roles. In NAACL, 2021.
286
+ [75] Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
287
+ [76] Timo Schick and Hinrich Schütze. Exploiting cloze questions for few shot text classification and natural language inference. In EACL, 2021.
288
+ [77] Timo Schick and Hinrich Schütze. It’s not just size that matters: Small language models are also few-shot learners. In NAACL, 2021.
289
+ [78] Paul Hongsuck Seo, Arsha Nagrani, and Cordelia Schmid. Look before you speak: Visually contextualized utterances. In CVPR, 2021.
290
+ [79] Paul Hongsuck Seo, Arsha Nagrani, Anurag Arnab, and Cordelia Schmid. End-to-end generative pretraining for multimodal video captioning. In CVPR, 2022.
291
+ [80] Sheng Shen, Liunian Harold Li, Hao Tan, Mohit Bansal, Anna Rohrbach, Kai-Wei Chang, Zhewei Yao, and Kurt Keutzer. How much can clip benefit vision-and-language tasks? arXiv preprint arXiv:2107.06383, 2021.
292
+ [81] Amanpreet Singh, Ronghang Hu, Vedanuj Goswami, Guillaume Couairon, Wojciech Galuba, Marcus Rohrbach, and Douwe Kiela. Flava: A foundational language and vision alignment model. In CVPR, 2022.
293
+ [82] David R So, Wojciech Manke, Hanxiao Liu, Zihang Dai, Noam Shazeer, and Quoc V ´ Le. Primer: Searching for efficient transformers for language modeling. arXiv preprint arXiv:2109.08668, 2021.
294
+ [83] Xiaomeng Song, Yucheng Shi, Xin Chen, and Yahong Han. Explore multi-step reasoning in video question answering. In ACM international conference on Multimedia, 2018.
295
+ [84] Emma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in nlp. In ACL, 2019.
296
+ [85] Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. VL-BERT: Pre-training of generic visual-linguistic representations. In ICLR, 2019.
297
+ [86] Chen Sun, Austin Myers, Carl Vondrick, Kevin Murphy, and Cordelia Schmid. VideoBERT: A joint model for video and language representation learning. In ICCV, 2019.
298
+ [87] Derek Tam, Rakesh R Menon, Mohit Bansal, Shashank Srivastava, and Colin Raffel. Improving and simplifying pattern exploiting training. In EMNLP, 2021.
299
+ [88] Hao Tan and Mohit Bansal. LXMERT: Learning cross-modality encoder representations from transformers. In EMNLP, 2019.
300
+ [89] Makarand Tapaswi, Yukun Zhu, Rainer Stiefelhagen, Antonio Torralba, Raquel Urtasun, and Sanja Fidler. MovieQA: Understanding stories in movies through question-answering. In CVPR, 2016.
301
+ [90] Wilson L Taylor. “cloze procedure”: A new tool for measuring readability. Journalism quarterly, 30(4):415–433, 1953.
302
+ [91] Maria Tsimpoukelli, Jacob Menick, Serkan Cabi, SM Eslami, Oriol Vinyals, and Felix Hill. Multimodal few-shot learning with frozen language models. In NeurIPS, 2021.
303
+ [92] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
304
+ [93] Alex Jinpeng Wang, Yixiao Ge, Rui Yan, Yuying Ge, Xudong Lin, Guanyu Cai, Jianping Wu, Ying Shan, Xiaohu Qie, and Mike Zheng Shou. All in one: Exploring unified video-language pre-training. arXiv preprint arXiv:2203.07303, 2022.
305
+ [94] Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model, 2021.
306
+ [95] Jianfeng Wang, Xiaowei Hu, Zhe Gan, Zhengyuan Yang, Xiyang Dai, Zicheng Liu, Yumao Lu, and Lijuan Wang. UFO: A unified transformer for vision-language representation learning. arXiv preprint arXiv:2111.10023, 2021.
307
+ [96] Zhenhailong Wang, Manling Li, Ruochen Xu, Luowei Zhou, Jie Lei, Xudong Lin, Shuohang Wang, Ziyi Yang, Chenguang Zhu, Derek Hoiem, et al. Language models with image descriptors are strong few-shot video-language learners. In NeurIPS, 2022.
308
+ [97] Junbin Xiao, Xindi Shang, Angela Yao, and Tat-Seng Chua. NExT-QA: Next phase of question-answering to explaining temporal actions. In CVPR, 2021.
309
+ [98] Dejing Xu, Zhou Zhao, Jun Xiao, Fei Wu, Hanwang Zhang, Xiangnan He, and Yueting Zhuang. Video question answering via gradually refined attention over appearance and motion. In ACM international conference on Multimedia, 2017.
310
+ [99] Hu Xu, Gargi Ghosh, Po-Yao Huang, Dmytro Okhonko, Armen Aghajanyan, Florian Metze, Luke Zettlemoyer, and Christoph Feichtenhofer. Videoclip: Contrastive pre-training for zero-shot video-text understanding. In EMNLP, 2021.
311
+ [100] Hongyang Xue, Wenqing Chu, Zhou Zhao, and Deng Cai. A better way to attend: Attention with trees for video question answering. IEEE Transactions on Image Processing, 2018.
312
+ [101] Antoine Yang, Antoine Miech, Josef Sivic, Ivan Laptev, and Cordelia Schmid. Just ask: Learning to answer questions from millions of narrated videos. In ICCV, 2021.
313
+ [102] Antoine Yang, Antoine Miech, Josef Sivic, Ivan Laptev, and Cordelia Schmid. Learning to answer visual questions from web videos. IEEE TPAMI, 2022.
314
+ [103] Zekun Yang, Noa Garcia, Chenhui Chu, Mayu Otani, Yuta Nakashima, and Haruo Takemura. BERT representations for video question answering. In WACV, 2020.
315
+ [104] Zhengyuan Yang, Zhe Gan, Jianfeng Wang, Xiaowei Hu, Yumao Lu, Zicheng Liu, and Lijuan Wang. An empirical study of GPT-3 for few-shot knowledge-based VQA. arXiv preprint arXiv:2109.05014, 2021.
316
+ [105] Yunan Ye, Zhou Zhao, Yimeng Li, Long Chen, Jun Xiao, and Yueting Zhuang. Video question answering via attribute-augmented attention network learning. In ACM SIGIR, 2017.
317
+ [106] Fei Yu, Jiji Tang, Weichong Yin, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. Ernie-vil: Knowledge enhanced vision-language representations through scene graph. In AAAI, 2020.
318
+ [107] Weijiang Yu, Haoteng Zheng, Mengfei Li, Lei Ji, Lijun Wu, Nong Xiao, and Nan Duan. Learning from inside: Self-driven siamese sampling and reasoning for video question answering. In NeurIPS, 2021.
319
+ [108] Zhou Yu, Dejing Xu, Jun Yu, Ting Yu, Zhou Zhao, Yueting Zhuang, and Dacheng Tao. ActivityNet-QA: A dataset for understanding complex web videos via question answering. In AAAI, 2019.
320
+ [109] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. MERLOT: Multimodal neural script knowledge models. In NeurIPS, 2021.
321
+ [110] Rowan Zellers, Jiasen Lu, Ximing Lu, Youngjae Yu, Yanpeng Zhao, Mohammadreza Salehi, Aditya Kusupati, Jack Hessel, Ali Farhadi, and Yejin Choi. MERLOT Reserve: Neural script knowledge through vision and language and sound. In CVPR, 2022.
322
+ [111] Andy Zeng, Adrian Wong, Stefan Welker, Krzysztof Choromanski, Federico Tombari, Aveek Purohit, Michael Ryoo, Vikas Sindhwani, Johnny Lee, Vincent Vanhoucke, et al. Socratic models: Composing zero-shot multimodal reasoning with language. arXiv preprint arXiv:2204.00598, 2022.
323
+ [112] Zheng-Jun Zha, Jiawei Liu, Tianhao Yang, and Yongdong Zhang. Spatiotemporal-textual coattention network for video question answering. ACM Transactions on Multimedia Computing, Communications, and Applications (TOMM), 2019.
324
+ [113] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134, 2021.
325
+ [114] Luowei Zhou, Hamid Palangi, Lei Zhang, Houdong Hu, Jason J Corso, and Jianfeng Gao. Unified vision-language pre-training for image captioning and VQA. In AAAI, 2020.
326
+ [115] Linchao Zhu and Yi Yang. ActBERT: Learning global-local video-text representations. In CVPR, 2020.
327
+ [116] Yueting Zhuang, Dejing Xu, Xin Yan, Wenzhuo Cheng, Zhou Zhao, Shiliang Pu, and Jun Xiao. Multichannel attention refinement for video question answering. ACM Transactions on Multimedia Computing, Communications, and Applications (TOMM), 2020.
328
+
329
+ # Checklist
330
+
331
+ 1. For all authors...
332
+
333
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 3 for contribution (i), Sections 4.2 and 4.3 for contribution (ii), and Sections 4.4 and 4.5 for contribution (iii).
334
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
335
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5.
336
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
337
+
338
+ 2. If you are including theoretical results...
339
+
340
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] No theoretical results. (b) Did you include complete proofs of all theoretical results? [N/A] No theoretical results.
341
+
342
+ 3. If you ran experiments...
343
+
344
+ (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] Our code, together with instructions needed to download and process the datasets we use, and instructions needed to reproduce the main experimental results, is open-sourced at [1].
345
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4.1 and Supplementary Material.
346
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We report them in the Supplementary Material, as error bars are in general not reported [101, 107, 109, 110].
347
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.1 and Supplementary Material.
348
+
349
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
350
+
351
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 4.1.
352
+ (b) Did you mention the license of the assets? [Yes] See Supplementary Material.
353
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We provide code and trained models at [1].
354
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] The datasets we use are publicly available and released for non-commercial use only, and this is already specified in the license.
355
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] The datasets we use are based on websites such as YouTube which strictly remove videos that contain offensive content or do not follow their community guidelines.
356
+
357
+ 5. If you used crowdsourcing or conducted research with human subjects...
358
+
359
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] No crowdsourcing or conducted research with human subjects.
360
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] No crowdsourcing or conducted research with human subjects.
361
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] No crowdsourcing or conducted research with human subjects.
md/dev/AHvFDPi-FA/AHvFDPi-FA.md ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DIFFUSION POLICIES AS AN EXPRESSIVE POLICY CLASS FOR OFFLINE REINFORCEMENT LEARNING
2
+
3
+ Zhendong Wang1,∗ , Jonathan J $\mathbf { H u n t } ^ { 2 , \dagger }$ , Mingyuan Zhou1,†
4
+
5
+ 1The University of Texas at Austin, 2 Twitter zhendong.wang@utexas.edu, jhunt@twitter.com mingyuan.zhou@mccombs.utexas.edu
6
+
7
+ # ABSTRACT
8
+
9
+ Offline reinforcement learning (RL), which aims to learn an optimal policy using a previously collected static dataset, is an important paradigm of RL. Standard RL methods often perform poorly in this regime due to the function approximation errors on out-of-distribution actions. While a variety of regularization methods have been proposed to mitigate this issue, they are often constrained by policy classes with limited expressiveness that can lead to highly suboptimal solutions. In this paper, we propose representing the policy as a diffusion model, a recent class of highly-expressive deep generative models. We introduce Diffusion Qlearning (Diffusion-QL) that utilizes a conditional diffusion model to represent the policy. In our approach, we learn an action-value function and we add a term maximizing action-values into the training loss of the conditional diffusion model, which results in a loss that seeks optimal actions that are near the behavior policy. We show the expressiveness of the diffusion model-based policy, and the coupling of the behavior cloning and policy improvement under the diffusion model both contribute to the outstanding performance of Diffusion-QL. We illustrate the superiority of our method compared to prior works in a simple 2D bandit example with a multimodal behavior policy. We then show that our method can achieve state-of-the-art performance on the majority of the D4RL benchmark tasks.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Offline reinforcement learning (RL), also known as batch RL, aims at learning effective policies entirely from previously collected data without interacting with the environment (Lange et al., 2012; Fujimoto et al., 2019). Eliminating the need for online interaction with the environment makes offline RL attractive for a wide array of real-world applications, such as autonomous driving and patient treatment planning, where real-world exploration with an untrained policy is risky, expensive, or time-consuming. Instead of relying on real-world exploration, offline RL emphasizes the use of prior data, such as human demonstration, that is often available at a much lower cost than online interactions. However, relying only on previously collected data makes offline RL a challenging task. Applying standard policy improvement approaches to an offline dataset typically leads to relying on evaluating actions that have not been seen in the dataset, and therefore their values are unlikely to be estimated accurately. For this reason, naive approaches to offline RL typically learn poor policies that prefer out-of-distribution actions whose values have been overestimated, resulting in unsatisfactory performance (Fujimoto et al., 2019).
14
+
15
+ Previous work on offline RL generally addressed this problem in one of four ways: 1) regularizing how far the policy can deviate from the behavior policy (Fujimoto et al., 2019; Fujimoto & Gu, 2021; Kumar et al., 2019; Wu et al., 2019; Nair et al., 2020; Lyu et al., 2022); 2) constraining the learned value function to assign low values to out-of-distribution actions (Kostrikov et al., 2021a; Kumar et al., 2020); 3) introducing model-based methods, which learn a model of the environment dynamics and perform pessimistic planning in the learned Markov decision process (MDP) (Kidambi et al., 2020; Yu et al., 2021); 4) treating offline RL as a problem of sequence prediction with return guidance (Chen et al., 2021; Janner et al., 2021; 2022). Our approach falls into the first category.
16
+
17
+ Empirically, the performance of policy-regularized offline RL methods is typically slightly worse than that of other approaches, and here we show that this is largely because the policy regularization methods perform poorly due to their limited ability to accurately represent the behavior policy. This results in the regularization adversely affecting the policy improvement. For example, the policy regularization may limit the exploration space of the agent to a small region with only suboptimal actions and then the Q-learning will be induced to converge towards a suboptimal policy.
18
+
19
+ The inaccurate policy regularization occurs for two main reasons: 1) policy classes are not expressive enough; 2) the regularization methods are improper. In most prior work, the policy is a Gaussian distribution with mean and diagonal covariance specified by the output of a neural network. However, as offline datasets are often collected by a mixture of policies, the true behavior policy may exhibit strong multi-modalities, skewness, or dependencies between different action dimensions, which cannot be well modeled by diagonal Gaussian policies (Shafiullah et al., 2022). In a particularly extreme, but not uncommon example, a Gaussian policy is used to fit bimodal training data by minimizing the Kullback–Leibler (KL) divergence from the data distribution to the policy distribution. This will result in the policy exhibiting mode-covering behavior and placing high density in the middle area of the two modes, which is actually the low-density region of the training data. In such cases, regularizing a new policy towards the behavior-cloned policy is likely to make the policy learning substantially worse. Second, the regularization, such as the KL divergence and maximum mean discrepancy (MMD) (Kumar et al., 2019), is often not well suited for offline RL. The KL divergence needs access to explicit density values and MMD needs multiple action samples at each state for optimization. These methods require an extra step by first learning a behavior cloned policy to provide density values for KL optimization or random action samples for MMD optimization. Regularizing the current policy towards the behavior cloned policy can further induce approximation errors, since the cloned behavior policy may not model the true behavior policy well, due to limitations in the expressiveness of the policy class. We conduct a simple bandit experiment in Section 4, which illustrates these issues can occur even on a simple bandit task.
20
+
21
+ In this work, we propose a method to perform policy regularization using diffusion (or score-based) models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020). Specifically, we use a multilayer perceptron (MLP) based denoising diffusion probabilistic model (DDPM) (Ho et al., 2020) as our policy. We construct an objective for the diffusion loss which contains two terms: 1) a behavior-cloning term that encourages the diffusion model to sample actions in the same distribution as the training set, and 2) a policy improvement term that attempts to sample high-value actions (according to a learned Q-value). Our diffusion model is a conditional model with states as the condition and actions as the outputs. Applying a diffusion model here has several appealing properties. First, diffusion models are very expressive and can well capture multi-modal distributions. Second, the diffusion model loss constitutes a strong distribution matching technique and hence it could be seen as a powerful sample-based policy regularization method without the need for extra behavior cloning. Third, diffusion models perform generation via iterative refinement, and the guidance from maximizing the Q-value function can be added at each reverse diffusion step.
22
+
23
+ In summary, our contribution is Diffusion-QL, a new offline RL algorithm that leverages diffusion models to do precise policy regularization and successfully injects the Q-learning guidance into the reverse diffusion chain to seek optimal actions. We test Diffusion-QL on the D4RL benchmark tasks for offline RL and show this method outperforms prior methods on the majority of tasks. We also visualize the method on a simple bandit task to illustrate why it can outperform prior methods. Code is available at https://github.com/Zhendong-Wang/ Diffusion-Policies-for-Offline-RL.
24
+
25
+ # 2 PRELIMINARIES AND RELATED WORK
26
+
27
+ Offline RL. The environment in RL is typically defined by a Markov decision process (MDP): $M = \{ S , A , P , R , \gamma , d _ { 0 } \}$ , with state space $S$ , action space $\mathcal { A }$ , environment dynamics ${ \mathcal { P } } ( s ^ { \prime } \mid s , a ) :$ $S \times S \times \mathcal { A } [ 0 , 1 ]$ , reward function $R : S \times \mathcal { A } \mathbb { R }$ , discount factor $\gamma \in [ 0 , 1 )$ , and initial state distribution (Sutton & Barto, 2018). The goal is to learn policy $\pi _ { \boldsymbol { \theta } } ( \mathbf { a } \mid s )$ , parameterized by $\theta$ , that 0 maximizes the cumulative discounted reward $\begin{array} { r } { \mathbb { E } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r \overline { { \left( \pmb { s } _ { t } , \dot { \pmb { a } } _ { t } \right) } } \right] } \end{array}$ θ . The action-value or $\mathrm { Q }$ -value of a policy $\pi$ is defined as $\begin{array} { r } { Q ^ { \pi } ( s _ { t } , a _ { t } ) = \mathbb { E } _ { a _ { t + 1 } , a _ { t + 2 } , \dots \sim \pi } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r ( s _ { t } , a _ { t } ) \right] . } \end{array}$ . In the offline setting $\operatorname { F u }$ et al., 2020), instead of the environment, a static dataset $\mathcal { D } \triangleq \{ ( \pmb { s } , \pmb { a } , r , \pmb { s } ^ { \prime } ) \}$ , collected by a behavior policy $\pi _ { b }$ , is provided. Offline RL algorithms learn a policy entirely from this static offline dataset $\mathcal { D }$ , without online interactions with the environment.
28
+
29
+ Diffusion Model. Diffusion-based generative models (Ho et al., 2020; Sohl-Dickstein et al., 2015; Song & Ermon, 2019) assume $\begin{array} { r } { p _ { \theta } ( \pmb { x } _ { 0 } ) : = \int p _ { \theta } ( \pmb { x } _ { 0 : T } ) d \pmb { x } _ { 1 : T } } \end{array}$ , where $\pmb { x } _ { 1 } , \ldots , \pmb { x } _ { T }$ are latent variables of the same dimensionality as the data ${ \pmb x } _ { 0 } \sim p ( { \pmb x } _ { 0 } )$ . A forward diffusion chain gradually adds noise to the data ${ \pmb x } _ { 0 } \sim { \pmb q } ( { \pmb x } _ { 0 } )$ in $T$ steps with a pre-defined variance schedule $\beta _ { i }$ , expressed as
30
+
31
+ $$
32
+ \begin{array} { r } { q ( { \pmb x } _ { 1 : T } \mid { \pmb x } _ { 0 } ) : = \prod _ { t = 1 } ^ { T } q ( { \pmb x } _ { t } \mid { \pmb x } _ { t - 1 } ) , \quad q ( { \pmb x } _ { t } \mid { \pmb x } _ { t - 1 } ) : = \mathcal { N } ( { \pmb x } _ { t } ; \sqrt { 1 - \beta _ { t } } { \pmb x } _ { t - 1 } , \beta _ { t } I ) . } \end{array}
33
+ $$
34
+
35
+ A reverse diffusion chain, constructed as $\begin{array} { r } { p _ { \theta } ( { \pmb x } _ { 0 : T } ) : = \mathcal { N } ( { \pmb x } _ { T } ; { \bf 0 } , { \pmb I } ) \prod _ { t = 1 } ^ { T } p _ { \theta } ( { \pmb x } _ { t - 1 } \mid { \pmb x } _ { t } ) } \end{array}$ , is then optimized by maximizing the evidence lower bound defined as $\begin{array} { r } { \mathbb { E } _ { q } [ \ln { \frac { p _ { \theta } ( { \pmb x } _ { 0 : T } ) } { q ( { \pmb x } _ { 1 : T } \mid { \pmb x } _ { 0 } ) } } ] } \end{array}$ (Jordan et al., 1999; Blei et al., 2017). After training, sampling from the diffusion model consists of sampling ${ \pmb x } _ { T } \sim p ( { \pmb x } _ { T } )$ and running the reverse diffusion chain to go from $t = T$ to $t = 0$ . Diffusion models can be straightforwardly extended to conditional models by conditioning $p _ { \theta } ( \pmb { x } _ { t - 1 } \mid \pmb { x } _ { t } , c )$ .
36
+
37
+ Related Work: Policy Regularization. Most prior methods for offline RL in the class of regularized policies rely on behavior cloning for policy regularization: BCQ (Fujimoto et al., 2019) constructs the policy as a learnable and maximum-value-constrained deviation from a separately learned Conditional-VAE (CVAE, Sohn et al. (2015)) behavior-cloning model; BEAR (Kumar et al., 2019) adds a weighted behavior-cloning loss via minimizing MMD into the policy improvement step; $\mathrm { T D } 3 { + } \mathrm { B C }$ (Fujimoto & Gu, 2021) applies the same trick as BEAR via maximum likelihood estimation (MLE); BRAC (Wu et al., 2019) evaluates multiple methods for behavior-cloning regularization, such as the KL divergence, MMD, and Wasserstein dual form; IQL (Kostrikov et al., 2021b) is an advantage weighted behavior-cloning method with “in-sample” learned Q-value functions. Goo & Niekum (2022) emphasize the necessity of conducting explicit behavioral cloning in offline RL, while Ajay et al. (2022) admit the power of conditional generative models for decision making.
38
+
39
+ Related Work: Diffusion Models in RL. Pearce et al. (2023) propose to better imitate human behaviors via diffusion models which are expressive and stable. Diffuser (Janner et al., 2022) applies a diffusion model as a trajectory generator. The full trajectory of state-action pairs form a single sample for the diffusion model. A separate return model is learned to predict the cumulative rewards of each trajectory sample. The guidance of the return model is then injected into the reverse sampling stage. This approach is similar to Decision Transformer (Chen et al., 2021), which also learns a trajectory generator through GPT2 (Radford et al., 2019) with the help of the true trajectory returns. When used online, sequence models can no longer predict actions from states autoregressively (since the states are an outcome of the environment). Thus, in the evaluation stage, a whole trajectory is predicted for each state while only the first action is applied, which incurs a large computational cost. Our approach employs diffusion models for RL in a distinct manner.
40
+
41
+ We apply the diffusion model to the action space and we form it as a conditional diffusion model with states as the condition. This approach is model-free and the diffusion model is sampling a single action at a time. Further, our Q-value function guidance is injected during training, which provides good empirical performance in our case. While both Diffuser (Janner et al., 2022) and our work apply diffusion models in Offline RL, Diffuser is from the model-based trajectory-planning perspective while our method is from the offline model-free policy-optimization perspective.
42
+
43
+ # 3 DIFFUSION Q-LEARNING
44
+
45
+ Below we explain how we apply a conditional diffusion model as an expressive policy for behavior cloning. Then, we introduce how we add Q-learning guidance into the learning of our diffusion model in the training stage with the behavior cloning term acting as a form of policy regularization.
46
+
47
+ # 3.1 DIFFUSION POLICY
48
+
49
+ Notation: Since there are two different types of timesteps in this work, one for the diffusion process and one for reinforcement learning we use superscripts $i \in \{ 1 , \ldots , N \}$ to denote diffusion timestep and subscripts $t \in \{ 1 , \ldots , T \}$ to denote trajectory timestep.
50
+
51
+ We represent our RL policy via the reverse process of a conditional diffusion model as
52
+
53
+ $$
54
+ \begin{array} { r } { \pi _ { \boldsymbol { \theta } } ( \boldsymbol { a } | \boldsymbol { s } ) = p _ { \boldsymbol { \theta } } ( \boldsymbol { a } ^ { 0 : N } | \boldsymbol { s } ) = \mathcal { N } ( \boldsymbol { a } ^ { N } ; \mathbf { 0 } , I ) \prod _ { i = 1 } ^ { N } p _ { \boldsymbol { \theta } } ( \boldsymbol { a } ^ { i - 1 } | \boldsymbol { a } ^ { i } , \boldsymbol { s } ) } \end{array}
55
+ $$
56
+
57
+ where the end sample of the reverse chain, $\mathbf { \delta } _ { \mathbf { { a } } } ^ { 0 }$ , is the action used for RL evaluation. Generally, $p _ { \theta } ( \pmb { a } ^ { i - 1 } | \pmb { a } ^ { i } , \pmb { s } )$ could be modeled as a Gaussian distribution $\begin{array} { r } { \mathcal { N } ( { \pmb a } ^ { i - 1 } ; \pmb { \mu } _ { \boldsymbol { \theta } } ( { \pmb a } ^ { i } , { \pmb s } , i ) , \pmb { \Sigma } _ { \boldsymbol { \theta } } ( { \pmb a } ^ { i } , { \pmb s } , i ) ) } \end{array}$ . We follow Ho et al. (2020) to parameterize $p _ { \theta } ( \pmb { a } ^ { i - 1 } | \pmb { a } ^ { i } , \pmb { s } )$ as a noise prediction model with the covariance matrix fixed as $\Sigma _ { \theta } ( \bar { \pmb { a } ^ { i } } , \pmb { s } , i ) = \beta _ { i } \bar { \pmb { I } }$ and mean constructed as
58
+
59
+ $$
60
+ \begin{array} { r } { \mu _ { \theta } ( { \pmb a } ^ { i } , { \pmb s } , i ) = \frac { 1 } { \sqrt { \alpha _ { i } } } \big ( { \pmb a } ^ { i } - \frac { \beta _ { i } } { \sqrt { 1 - \bar { \alpha } _ { i } } } { \pmb \epsilon } _ { \theta } ( { \pmb a } ^ { i } , { \pmb s } , i ) \big ) . } \end{array}
61
+ $$
62
+
63
+ We first sample $\pmb { a } ^ { N } \sim \mathcal { N } ( \mathbf { 0 } , I )$ and then from the reverse diffusion chain parameterized by $\theta$ as
64
+
65
+ $$
66
+ \begin{array} { r } { { \pmb a } ^ { i - 1 } \parallel { \pmb a } ^ { i } = \frac { { \pmb a } ^ { i } } { \sqrt { \alpha _ { i } } } - \frac { \beta _ { i } } { \sqrt { \alpha _ { i } ( 1 - \bar { \alpha } _ { i } ) } } \epsilon _ { \theta } ( { \pmb a } ^ { i } , { \pmb s } , i ) + \sqrt { \beta _ { i } } \epsilon , \ { \epsilon } \sim \mathcal { N } ( \mathbf { 0 } , I ) , \ \mathrm { f o r } \ i = N , \dots , 1 . } \end{array}
67
+ $$
68
+
69
+ Following DDPM (Ho et al., 2020), when $i = 1$ , $\epsilon$ is set as $\mathbf { 0 }$ to improve the sampling quality.
70
+
71
+ We mimic the simplified objective proposed by $\mathrm { H o }$ et al. (2020) to train our conditional $\epsilon$ -model v
72
+
73
+ $$
74
+ \mathcal { L } _ { d } ( \theta ) = \mathbb { E } _ { i \sim \mathcal { U } , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) , ( s , a ) \sim \mathcal { D } } \left[ | | \epsilon - \epsilon _ { \theta } \big ( \sqrt { \bar { \alpha } _ { i } } a + \sqrt { 1 - \bar { \alpha } _ { i } } \epsilon , s , i \big ) | | ^ { 2 } \right] ,
75
+ $$
76
+
77
+ where $\mathcal { U }$ is a uniform distribution over the discrete set as $\{ 1 , \ldots , N \}$ and $\mathcal { D }$ denotes the offline dataset, collected by behavior policy $\pi _ { b }$ . This diffusion model loss $\dot { \mathcal { L } } _ { d } ( \theta )$ is a behavior-cloning loss, which aims to learn the behavior policy $\pi _ { b } ( { \pmb a } | { \pmb s } )$ (i.e. it seeks to sample actions from the same distribution as the training data). Note the marginal of the reverse diffusion chain provides an implicit, expressive distribution that can capture complex distribution properties, such as skewness and multi-modality, exhibited by the offline datasets. In addition, the regularization is sampling-based that only requires taking random samples from both $\mathcal { D }$ and the current policy (i.e. this method does not require us to know the behavior policy, which may be infeasible when the dataset is collected by human demonstrations). Different from the usual two-step strategy, our strategy provides a clean and effective way of applying regularization on a flexible policy.
78
+
79
+ $\mathcal { L } _ { d } ( \theta )$ can efficiently be optimized by sampling a single diffusion step $i$ for each data point, but the reverse sampling in Equation (1), which requires iteratively computing $\epsilon _ { \theta }$ networks $N$ times, can become a bottleneck for the running time. Thus we may want to limit $N$ to a relatively small value. To work with small $N$ , with $\beta _ { \mathrm { m i n } } = 0 . 1$ and $\beta _ { \mathrm { m a x } } = 1 0 . 0$ , we follow Xiao et al. (2021) to define
80
+
81
+ $$
82
+ \begin{array} { r } { \beta _ { i } = 1 - \alpha _ { i } = 1 - e ^ { - \beta _ { \mathrm { m i n } } \left( \frac { 1 } { N } \right) - 0 . 5 \left( \beta _ { \mathrm { m a x } } - \beta _ { \mathrm { m i n } } \right) \frac { 2 i - 1 } { N ^ { 2 } } } , } \end{array}
83
+ $$
84
+
85
+ which is a noise schedule obtained under the variance preserving SDE of Song et al. (2021).
86
+
87
+ # 3.2 Q-LEARNING
88
+
89
+ The policy-regularization loss $\mathcal { L } _ { d } ( \theta )$ is a behavior-cloning term, but would not result in learning a policy that can outperform the behavior policy that generated the training data. To improve the policy, we inject Q-value function guidance into the reverse diffusion chain in the training stage in order to learn to preferentially sample actions with high values. The final policy-learning objective is a linear combination of policy regularization and policy improvement:
90
+
91
+ $$
92
+ \pi = \underset { \pi _ { \theta } } { \arg \operatorname* { m i n } } \ : \mathcal { L } ( \theta ) = \mathcal { L } _ { d } ( \theta ) + \mathcal { L } _ { q } ( \theta ) = \mathcal { L } _ { d } ( \theta ) - \alpha \cdot \mathbb { E } _ { s \sim \mathcal { D } , a ^ { 0 } \sim \pi _ { \theta } } \left[ Q _ { \phi } ( s , a ^ { 0 } ) \right] .
93
+ $$
94
+
95
+ Note that $\mathbf { \delta } _ { \mathbf { { a } } ^ { 0 } }$ is reparameterized by Equation (1) and hence the gradient of the Q-value function with respect to the action is backpropagated through the whole diffusion chain.
96
+
97
+ As the scale of the Q-value function varies in different offline datasets, to normalize it, we follow Fujimoto & Gu (2021) to set $\alpha$ as $\begin{array} { r } { \alpha = \frac { \eta } { \mathbb { E } _ { ( s , a ) \sim \mathcal { D } } \left[ | Q _ { \phi } ( s , a ) | \right] } } \end{array}$ , where $\eta$ is a hyperparameter that balances the two loss terms and the $\mathrm { Q }$ in the denominator is for normalization only and not differentiated over.
98
+
99
+ The Q-value function itself is learned in a conventional way, minimizing the Bellman operator (Lillicrap et al., 2015; Fujimoto et al., 2019) with the double Q-learning trick (Hasselt, 2010). We built two Q-networks, $Q _ { \phi _ { 1 } }$ , $Q _ { \phi _ { 2 } }$ , and target networks $Q _ { \phi _ { 1 } ^ { \prime } }$ , $Q _ { \phi _ { 2 } ^ { \prime } }$ and $\pi _ { \theta ^ { \prime } }$ . We then optimize $\phi _ { i }$ for $i = \{ 1 , 2 \}$ by minimizing the objective,
100
+
101
+ $$
102
+ \begin{array} { r } { \mathbb { E } _ { ( s _ { t } , a _ { t } , s _ { t + 1 } ) \sim \mathcal { D } , a _ { t + 1 } ^ { 0 } \sim \pi _ { \theta ^ { \prime } } } \left[ \left| \left| \left( r ( s _ { t } , a _ { t } ) + \gamma \operatorname* { m i n } _ { i = 1 , 2 } Q _ { \phi _ { i } ^ { \prime } } ( s _ { t + 1 } , a _ { t + 1 } ^ { 0 } ) \right) - Q _ { \phi _ { i } } ( s _ { t } , a _ { t } ) \right| \right| ^ { 2 } \right] . } \end{array}
103
+ $$
104
+
105
+ We conduct extensive experiments in Sections 4 and 5 and show that $\mathcal { L } _ { d }$ and $\mathcal { L } _ { q }$ work together to achieve the best performance. We summarize our implementation in Algorithm 1.
106
+
107
+ Algorithm 1 Diffusion Q-learning
108
+
109
+ <table><tr><td>Initialize policy network πθ, critic networks Q𝜙1 and Q, and target networks Tθ, Q1 and Q2 for each iteration do</td></tr><tr><td>Sample transition mini-batch B = {(st, at,rt, St+1)} ~ D. # Q-value function learning</td></tr><tr><td>Sample at+1 ~ πθ(at+1|St+1) by Equation (1).</td></tr><tr><td>Update Qφ1 and QΦ2 by Equation (4). (max Q backup by Kumar et al. (202O) could be added)</td></tr><tr><td>#Policy learning Sample a𝑙 ~ πθ(at |St) by Equation (1).</td></tr><tr><td>Update policy by minimizing Equation (3).</td></tr><tr><td># Update target networks</td></tr><tr><td>0&#x27;=p0&#x27;+(1-p)0,Φ²=pΦ+(1-p)Φifori={1,2}. end for</td></tr></table>
110
+
111
+ # 4 POLICY REGULARIZATION
112
+
113
+ In this section, we illustrate how the previous policy regularization methods work compared to our conditional diffusion-based approach on a simple bandit task with a 2D continuous action space. Below we first provide a brief review of prior methods.
114
+
115
+ BC-MLE. The policy $\pi _ { \boldsymbol { \theta } } ( \mathbf { a } \mid s )$ is modeled by a Gaussian distribution $\mathcal { N } ( \pmb { a } ; \pmb { \mu } _ { \theta } ( \pmb { s } _ { t } ) , \pmb { \Sigma } _ { \theta } ( \pmb { s } ) )$ , where usually $\pmb { \mu } _ { \theta }$ and $\Sigma _ { \theta }$ are parameterized by multi-layer perceptrons (MLPs) and for simplicity $\Sigma _ { \theta }$ is assumed to be a diagonal matrix. The policy is optimized by maximizing $\mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ \log \pi _ { \theta } ( { \pmb a } \mid s ) ]$ . $\mathrm { T D } 3 { + } \mathrm { B C }$ (Fujimoto & Gu, 2021) directly add the behavior-cloning (BC) loss as an additional term in policy learning, while IQL (Kostrikov et al., 2021b) proposes using “in-sample” learned advantage functions to reweigh the log term inside the expectation.
116
+
117
+ BC-CVAE. The policy $\pi _ { \boldsymbol { \theta } } ( \mathbf { a } \mid s )$ is modeled by a CVAE model with an encoder network $q _ { \theta } ( z \mid s , \mathbf { a } )$ and a decoder network $p _ { \theta } ( \pmb { a } | \pmb { s } , \pmb { z } )$ . The two networks are optimized by maximizing the evidence lower bound $\mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ \mathbb { E } _ { z \sim q ( \cdot \mid s , a ) } [ \log p ( a \mid s , z ) ] - \mathrm { K L } ( q ( \bar { \boldsymbol { z } } \mid s , a ) | | p ( \boldsymbol { z } ) ) ]$ , where $p ( z )$ is a prior distribution that is usually set as standard Gaussian. BCQ (Fujimoto et al., 2019) trains a CVAE model as an approximation of the behavior policy and trains another deviation model to guide the actions drawn from the CVAE approximation towards the regions with high learned $\mathrm { Q }$ -values.
118
+
119
+ BC-MMD. BEAR (Kumar et al., 2019) also mimics the behavior policy via a CVAE model and proposes to limit the current policy $\pi _ { \boldsymbol { \theta } } ( \mathbf { a } \vert \mathbf { \boldsymbol { s } } )$ to be close to the cloned behavior policy via MMD minimization. A Tanh-Gaussian policy is used, which is a Gaussian network with a Tanh activation function at the output layer.
120
+
121
+ BCQ and BEAR can be seen as a two-step regularization: First, an approximation of the behavior policy is learned (behavior cloning), and then the policy learned by policy improvement is regularized towards the cloned behavior policy. However, such a two-step approach means that the efficacy of the second-step policy regularization heavily depends on the cloning quality, and an inaccurate regularization could misguide the subsequent policy improvement step. We illustrate this weakness in a 2D continuous action space bandit example.
122
+
123
+ Example. We consider a simple bandit task with real-valued actions in a 2D space, $\pmb { a } \in [ - 1 , 1 ] ^ { 2 }$ . We construct an offline dataset $\mathcal { D } \ : = \ : \{ ( \boldsymbol { a } _ { j } ) \} _ { j = 1 } ^ { M }$ with $M \ : = \ : 1 0 0 0 0$ action examples, where the actions are collected from an equal mixture of four Gaussian distributions with centers $\mu \in$ $\{ ( 0 . 0 , 0 . 8 ) , ( 0 . 8 , 0 . 0 ) , ( 0 . 0 , - 0 . 8 ) , ( - 0 . 8 , 0 . 0 ) \}$ and standard deviations ${ \pmb \sigma } _ { d } = ( 0 . 0 5 , 0 . 0 5 )$ , as depicted in the first panel of Figure 1. Note that this example exhibits strong multi-modality in the behavior policy distribution, which is often the case when the dataset is collected by different policies. For example, if multiple humans are involved, some may be experts and choose actions from a different mode from amateur demonstrators.
124
+
125
+ To evaluate the strength of prior regularization methods, we first compare them to our diffusionbased approach on a behavior-cloning task, where the goal is to just clone the behavior policy that generated the data, not improve on it. As shown in the first row of Figure 1, we observe that the diffusion model captures all the four density modes of the behavior policy. The policy of BC-MLE is limited to a single mode and hence exhibits a strong mode-covering behavior. It fits the four density modes by one Gaussian distribution with a large standard deviation, whose high-density regions are actually the low-density regions of the true behavior policy. The CVAE model is shown to exhibit mode-covering behavior even though it itself is an implicit model with enough expressiveness: We see that CVAE captures the four modes but high densities are assigned between them to cover all the modes. Note we also observe the CVAE model sometimes fails to capture all four modes with different random seeds. The Tanh-Gaussian policy optimized under MMD learns to align the densities near the boundary lines and, due to its limited policy expressiveness, fails to capture the true distribution. These observed failures on behavior cloning in this simple example illustrate the limitations of prior regularization methods in the common case of multi-modal behavior policies.
126
+
127
+ ![](images/ed09db3bbd86938ac9aa97c248e0496269d39170d15a159ad90b289acd4865ff.jpg)
128
+ Figure 1: Offline RL experiments on a simple bandit task. The first row shows the comparison of behavior cloning between our method (BC-Diffusion, $N = 5 0$ ) and prior methods. Prior methods struggle to capture the multi-modal behavior policy (ground truth). The second row shows the comparison results when policy improvement is added (first figure shows the rewards). The policy regularization of prior methods results in a poor policy, since the behavior-cloning step fails to capture the multi-modal behavior policy, while our method (Diffusion-QL) correctly identifies the high reward behavior mode.
129
+
130
+ ![](images/bb1968b51077654b97fd926738cfa357f9929a9f4a3cdb3c7aaf5dfa991f785a.jpg)
131
+ Figure 2: Experiment examining the effect of varying the number of diffusion steps $N$ on the simple bandit talks. The first row shows the ablation study of $N$ for BC-Diffusion. The second row shows the ablation study of $N$ for Diffusion-QL. Large $N$ results in a better fit to the data distribution, but leads to a higher computational cost. By combining the behavior cloning and Q-value losses during training, we are able to learn near-optimal policies with fewer diffusion steps.
132
+
133
+ Next, we investigate how the policy improvement will be impacted by the corresponding policy regularization. We assign each data point a reward sampled from a Gaussian distribution, whose mean is determined by the data center and standard deviation is fixed as 0.5, as shown in the second row of Figure 1. Note here we mimic the offline RL setting, under which the underlying reward function is unknown and needs to be learned. We compare Diffusion Q-learning (QL) with prior methods, including $\mathrm { T D } 3 { + } \mathrm { B C }$ , BCQ, and BEAR-MMD. We train all methods with 1000 epochs to ensure convergence. Due to the strong policy constraint applied by each method, we observe that the policy improvement of prior methods is constrained to suboptimal or even wrong exploration regions, induced by the corresponding behavior-cloning regularization. $\mathrm { T D } 3 { + } \mathrm { B C }$ cannot converge to the optimal mode since the behavior policy places most density in the region where no offline data exists. BCQ learns to place major actions on the four diagonal corners discovered by its CVAE-based behavior cloning. The policy of BEAR-MMD learns to place actions randomly since the exploration region is constrained by inaccurate policy regularization. We observe that the prior regularizations typically push the policy to converge to sub-optimal solutions, such as BCQ, or prevent the policy from being concentrated on the optimal corner, such as $\mathrm { T D } 3 { + } \mathrm { B C }$ and BEAR-MMD. By contrast, the policy of Diffusion-QL successfully converges to the optimal bottom corner. This is because 1) diffusion policy is expressive enough to recover the behavior policy, which covers all modes for further exploration; 2) the Q-learning guidance, directly through linearly combined loss functions in Equation (3), helps diffusion policy seek optimal actions in the region. The two components are working together to produce good performance.
134
+
135
+ Diffusions steps. We further investigated how the diffusion policy performs as the number of diffusion timesteps $N$ is varied. As expected, the first row of Figure 2 shows that as $N$ increases, the diffusion model becomes more expressive and learns more details about the underlying data distribution. When $N$ is increased to 50, the true data distribution is accurately recovered. The second row shows that with Q-learning applied, a moderately small $N$ is able to deliver good performance due to our loss coupling defined in Equation (3). However, we can see with a larger $N$ the policy regularization imposed by the diffusion model-based cloning becomes stronger. For example, when $N = 2$ , there are still a few action points sampled near regions with no training data, whereas when $N = 5 0$ , the policy is constrained in the correct data region for further exploration. The number of timesteps $N$ serves as a trade-off between policy expressiveness and computational cost for Diffusion-QL. We found $N = 5$ performs well on D4RL (Fu et al., 2020) datasets, which is also a small enough value for cost-effective training and deployment.
136
+
137
+ # 5 EXPERIMENTS
138
+
139
+ We evaluate our method on the popular D4RL (Fu et al., 2020) benchmark. Further, we conduct empirical studies on the number of timesteps required for our diffusion model and also perform an ablation study for analyzing the contribution of the two main components of Diffusion-QL.
140
+
141
+ Datasets. We consider four different domains of tasks in D4RL benchmark: Gym, AntMaze, Adroit, and Kitchen. The Gym-MuJoCo locomotion tasks are the most commonly used standard tasks for evaluation and are relatively easy, since they usually include a significant fraction of near-optimal trajectories in the dataset and the reward function is quite smooth. AntMaze consists of more challenging tasks, which have sparse rewards and explicitly need the agent to stitch various sub-optimal trajectories to find a path towards the goal of the maze (Fu et al., 2020). Adroit datasets are mostly collected by human behavior and the state-action region reflected by the offline data is often very narrow, so strong policy regularization is needed to ensure that the agent stays in the expected region. The Kitchen environment requires the agent to complete 4 target subtasks in order to reach a desired state configuration, and hence long-term value optimization is important for it.
142
+
143
+ Baselines. We consider different classes of baselines that perform well in each domain of tasks. For policy regularization-based methods, we include the classic BC, BEAR (Kumar et al., 2019), BRAC (Wu et al., 2019), BCQ (Fujimoto et al., 2019), $\mathrm { T D } 3 { + } \mathrm { B C }$ (Fujimoto & Gu, 2021), AWR (Peng et al., 2019), AWAC (Nair et al., 2020), and IQL (Kostrikov et al., 2021b), along with the Onestep RL (Brandfonbrener et al., 2021), which is based on single-step improvement. For Q-value constraint methods, we include REM (Agarwal et al., 2020) and CQL (Kumar et al., 2020). For model-based offline RL, we consider MoRel (Kidambi et al., 2020). For sequence modelling approaches, we compare with Decision Transformer (DT) (Chen et al., 2021) and Diffuser (Janner et al., 2022). We report the performance of baseline methods either using the best results reported from their own paper, Fu et al. (2020) or Kostrikov et al. (2021b).
144
+
145
+ Experimental details. We train for 1000 epochs (2000 for Gym tasks). Each epoch consists of 1000 gradient steps with batch size 256. The training is usually quite stable as shown in Figure 3 except that we observe the training for AntMaze tasks has variations due to its sparse reward setting and lack of optimal trajectories in the offline datasets. Hence, we save multiple model checkpoints during training and use a completely offline method, as described in Appendix D, to select the best checkpoint for performance evaluation. Using $\mathcal { L } _ { d }$ loss as a lagging indicator of online performance, we perform early stopping and select the checkpoint with the second or third lowest $\mathcal { L } _ { d }$ value. The results in our main paper are all based on the offline model selection. When a small amount of online interaction can be used for model selection, we can achieve even better results (Appendix Table 4).
146
+
147
+ Effect of hyperparameter $N$ . We conduct an empirical study on the effect of the number of timesteps $N$ of our diffusion model on real tasks. As shown in Figure 3, empirically we find as
148
+
149
+ ![](images/f343b16b9f8b5deebcda6772a764fdb500a4ec4932c81a38841b7e83ebe90d12.jpg)
150
+ Figure 3: Ablation study of $N$ on selected Gym tasks. We consider a $N$ grid [2, 5, 10, 20] and we find that $N = 5$ is good enough for the selected tasks.
151
+
152
+ Table 1: The performance of Diffusion-QL and SOTA baselines on D4RL Gym, AntMaze, Adroit, and Kitchen tasks. Results for Diffusion-QL correspond to the mean and standard errors of normalized scores over 50 random rollouts (5 independently trained models and 10 trajectories per model) for Gym tasks, which generally exhibit low variance in performance, and over 500 random rollouts (5 independently trained models and 100 trajectories per model) for the other tasks. Note the standard error of AntMaze is usually large since the return of trajectories is binomial (1 for success while 0 for failure). Our method outperforms all prior methods by a clear margin on all domain, even on the challenging AntMaze, for which behavior cloning methods would fail and some form of policy improvement is essential.
153
+
154
+ <table><tr><td>Gym Tasks</td><td>BC</td><td>AWAC</td><td>Diffuser</td><td>MoRel</td><td>Onestep RL</td><td>TD3+BC</td><td>DT</td><td>CQL</td><td>IQL</td><td>Diffusion-QL</td></tr><tr><td>halfcheetah-medium-v2</td><td>42.6</td><td>43.5</td><td>44.2</td><td>42.1</td><td>48.4</td><td>48.3</td><td>42.6</td><td>44.0</td><td>47.4</td><td>51.1 ± 0.5</td></tr><tr><td>hopper-medium-v2</td><td>52.9</td><td>57.0</td><td>58.5</td><td>95.4</td><td>59.6</td><td>59.3</td><td>67.6</td><td>58.5</td><td>66.3</td><td>90.5 ±4.6</td></tr><tr><td>walker2d-medium-v2</td><td>75.3</td><td>72.4</td><td>79.7</td><td>77.8</td><td>81.8</td><td>83.7</td><td>74.0</td><td>72.5</td><td>78.3</td><td>87.0±0.9</td></tr><tr><td>halfcheetah-medium-replay-v2</td><td>36.6</td><td>40.5</td><td>42.2</td><td>40.2</td><td>38.1</td><td>44.6</td><td>36.6</td><td>45.5</td><td>44.2</td><td>47.8 ± 0.3</td></tr><tr><td>hopper-medium-replay-v2</td><td>18.1</td><td>37.2</td><td>96.8</td><td>93.6</td><td>97.5</td><td>60.9</td><td>82.7</td><td>95.0</td><td>94.7</td><td>101.3 ± 0.6</td></tr><tr><td>walker2d-medium-replay-v2</td><td>26.0</td><td>27.0</td><td>61.2</td><td>49.8</td><td>49.5</td><td>81.8</td><td>66.6</td><td>77.2</td><td>73.9</td><td>95.5 ± 1.5</td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>55.2</td><td>42.8</td><td>79.8</td><td>53.3</td><td>93.4</td><td>90.7</td><td>86.8</td><td>91.6</td><td>86.7</td><td>96.8 ± 0.3</td></tr><tr><td>hopper-medium-expert-v2</td><td>52.5</td><td>55.8</td><td>107.2</td><td>108.7</td><td>103.3</td><td>98.0</td><td>107.6</td><td>105.4</td><td>91.5</td><td>111.1 ± 1.3</td></tr><tr><td>walker2d-medium-expert-v2</td><td>107.5</td><td>74.5</td><td>108.4</td><td>95.6</td><td>113.0</td><td>110.1</td><td>108.1</td><td>108.8</td><td>109.6</td><td>110.1 ± 0.3</td></tr><tr><td>Average</td><td>51.9</td><td>50.1</td><td>75.3</td><td>72.9</td><td>76.1</td><td>75.3</td><td>74.7</td><td>77.6</td><td>77.0</td><td>88.0</td></tr><tr><td>AntMaze Tasks</td><td>BC</td><td>AWAC</td><td>BCQ</td><td>BEAR</td><td>Onestep RL</td><td>TD3+BC</td><td>DT</td><td>CQL</td><td>IQL</td><td>Diffusion-QL</td></tr><tr><td>antmaze-umaze-v0</td><td>54.6</td><td>56.7</td><td>78.9</td><td>73.0</td><td>64.3</td><td>78.6</td><td>59.2</td><td>74.0</td><td>87.5</td><td>93.4±3.4</td></tr><tr><td>antmaze-umaze-diverse-v0</td><td>45.6</td><td>49.3</td><td>55.0</td><td>61.0</td><td>60.7</td><td>71.4</td><td>53.0</td><td>84.0</td><td>62.2</td><td>66.2± 8.6</td></tr><tr><td>antmaze-medium-play-v0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.3</td><td>10.6</td><td>0.0</td><td>61.2</td><td>71.2</td><td>76.6 ± 10.8</td></tr><tr><td>antmaze-medium-diverse-v0</td><td>0.0</td><td>0.7</td><td>0.0</td><td>8.0</td><td>0.0</td><td>3.0</td><td>0.0</td><td>53.7</td><td>70.0</td><td>78.6 ± 10.3</td></tr><tr><td>antmaze-large-play-v0</td><td>0.0</td><td>0.0</td><td>6.7</td><td>0.0</td><td>0.0</td><td>0.2</td><td>0.0</td><td>15.8</td><td>39.6</td><td>46.4 ± 8.3</td></tr><tr><td>antmaze-large-diverse-v0</td><td>0.0</td><td>1.0</td><td>2.2</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>14.9</td><td>47.5</td><td>56.6± 7.6</td></tr><tr><td>Average</td><td>16.7</td><td>18.0</td><td>23.8</td><td>23.7</td><td>20.9</td><td>27.3</td><td>18.7</td><td>50.6</td><td>63.0</td><td>69.6</td></tr><tr><td>Adroit Tasks</td><td>BC</td><td>SAC</td><td>BCQ</td><td>BEAR</td><td>BRAC-p</td><td>BRAC-v</td><td>REM</td><td>CQL</td><td>IQL</td><td>Diffusion-QL</td></tr><tr><td>pen-human-v1</td><td>25.8</td><td>4.3</td><td>68.9</td><td>-1.0</td><td>8.1</td><td>0.6</td><td>5.4</td><td>35.2</td><td>71.5</td><td>72.8± 9.6</td></tr><tr><td>pen-cloned-v1</td><td>38.3</td><td>-0.8</td><td>44.0</td><td>26.5</td><td>1.6</td><td>-2.5</td><td>-1.0</td><td>27.2</td><td>37.3</td><td>57.3 ± 11.9</td></tr><tr><td>Average</td><td>32.1</td><td>1.8</td><td>56.5</td><td>12.8</td><td>4.9</td><td>-1.0</td><td>2.2</td><td>31.2</td><td>54.4</td><td>65.1</td></tr><tr><td>Kitchen Tasks</td><td>BC</td><td>SAC</td><td>BCQ</td><td>BEAR</td><td>BRAC-p</td><td>BRAC-v</td><td>AWR</td><td>CQL</td><td>IQL</td><td>Diffusion-QL</td></tr><tr><td>kitchen-complete-v0</td><td>33.8</td><td>15.0</td><td>8.1</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>43.8</td><td>62.5</td><td>84.0 ± 7.4</td></tr><tr><td>kitchen-partial-vo</td><td>33.8</td><td>0.0</td><td>18.9</td><td>13.1</td><td>0.0</td><td>0.0</td><td>15.4</td><td>49.8</td><td>46.3</td><td>60.5 ± 6.9</td></tr><tr><td>kitchen-mixed-v0</td><td>47.5</td><td>2.5</td><td>8.1</td><td>47.2</td><td>0.0</td><td>0.0</td><td>10.6</td><td>51.0</td><td>51.0</td><td>62.6 ± 5.1</td></tr><tr><td>Average</td><td>38.4</td><td>5.8</td><td>11.7</td><td>20.1</td><td>0.0</td><td>0.0</td><td>8.7</td><td>48.2</td><td>53.3</td><td>69.0</td></tr></table>
155
+
156
+ the $N$ increases, the model converges faster and the performance becomes more stable. In the following D4RL tasks, we set a moderate value, $N = 5$ , to balance the performance and computational cost. With $N = 5$ , the training time of our method is similar to that of CQL (Kumar et al., 2020). The other hyperparameters, such as the learning rate and $\eta$ , are provided in Appendix E.
157
+
158
+ # 5.1 COMPARISON TO OTHER METHODS
159
+
160
+ We compare our Diffusion-QL with the baselines on four domains of tasks and report the results in Table 1. We give the analysis based on each specific domain.
161
+
162
+ Results for Gym Domain. We can see while most baselines already work well on the Gym tasks, Diffusion-QL can often further improve their performance by a clear margin, especially in ‘medium’ and ‘medium-replay’ tasks. Note the ‘medium’ datasets include the trajectories collected by an online SAC (Haarnoja et al., 2018) agent trained to approximately 1/3 the performance of the expert. Hence, the Tanh-Gaussian policy at that time is usually exploratory and not concentrated, which makes the collected data distribution hard to learn. As shown in Section 4, the diffusion model has the expressivity to mimic the behavior policy even in complicated cases and then the policy improvement term will guide the policy to converge to the optimal actions in the subset of explored action space. These two components are key to the good empirical performance of Diffusion-QL.
163
+
164
+ Table 2: Ablation study. We conduct an ablation study to compare our diffusion model with CVAE models, and our Q-learning method with BCQ policy improvement.
165
+
166
+ <table><tr><td>Gym Tasks</td><td>BC-CVAE</td><td>BC-Diffusion</td><td>BCQ-CVAE</td><td>BCQ-Diffusion</td><td>CVAE-QL</td><td>Diffusion-QL</td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>67.3± 7.4</td><td>76.6± 7.0</td><td>96.1 ± 0.5</td><td>94.6±1.0</td><td>70.3± 5.5</td><td>97.2 ± 0.4</td></tr><tr><td>hopper-medium-expert-v2</td><td>69.9 ± 8.6</td><td>78.0±8.9</td><td>108.5 ±0.6</td><td>109.3 ± 0.9</td><td>109.2 ± 4.6</td><td>112.3 ± 0.8</td></tr><tr><td>walker2d-medium-expert-v2</td><td>102.5 ± 4.4</td><td>103.1 ± 4.4</td><td>110.7 ± 0.2</td><td>114.0 ± 0.5</td><td>50.5 ±38.2</td><td>111.2 ± 0.9</td></tr><tr><td>Average</td><td>79.9</td><td>85.9</td><td>105.1</td><td>106.0</td><td>76.6</td><td>106.9</td></tr></table>
167
+
168
+ Results for AntMaze Domain. The sparse reward and large amount of sub-optimal trajectories make the AntMaze tasks especially difficult. Strong and stable Q-learning is required to achieve good performance. For example, BC-based methods could easily fail on ‘medium’ and ‘large’ tasks. We show that the proposed Q-learning guidance added during the training of a conditional diffusion model is stable and effective. Empirically, with a proper $\eta$ , we find Diffusion-QL outperforms the prior methods by a clear margin, especially in harder tasks, such as ‘large-diverse’.
169
+
170
+ Results for Adroit and Kitchen Domain. We find the Adroit domain needs strong policy regularization to overcome the extrapolation error (Fujimoto et al., 2019) in offline RL, due to the narrowness of the human demonstrations. With a smaller $\eta$ , Diffusion-QL easily beats the other baselines by its reverse diffusion-based policy, which has high expressiveness and better policy regularization. Moreover, long-term value optimization is required for the Kitchen tasks, and we find Diffusion-QL also performs very well in this domain.
171
+
172
+ # 5.2 ABLATION STUDY
173
+
174
+ In this section, we analyze why Diffusion-QL outperforms the other policy-constraint based methods quantitatively on D4RL tasks. We conduct an ablation study on the two main components of Diffusion-QL: use of a diffusion model as an expressive policy and Q-learning guidance. For the policy part, we compare our diffusion model with the popular CVAE model for behavior cloning. For the Q-learning component, we compare with the BCQ approach on policy improvement.
175
+
176
+ As shown in Table 2, BC-Diffusion model outperforms BC-CVAE, validating that our diffusionbased policy is more expressive and better at capturing the data distributions (as we would expect from the results in figure 1). Under the same BCQ framework, which explicitly limits how far the action samples from polices could deviate from the cloned action samples, BCQ-Diffusion still works better than BCQ-CVAE. The hard and physical value constraints on the deviation by BCQ actually limits the policy improvement, as we can see that, Diffusion-QL further boosts the performance. Note Diffusion-QL applies the diffusion model learning itself as a soft policy regularization and guides the policy optimization via additive Q-learning. The weak expressiveness and poor cloning behavior of CVAE makes it fail when coupling with a free Q-learning guidance, as shown by the results of CVAE-QL. In a nutshell, the ablation study shows that the two components of Diffusion-QL are working together to produce good performance.
177
+
178
+ # 6 CONCLUSION
179
+
180
+ In this work, we present Diffusion-QL, which is a conditional diffusion-based offline RL algorithm. First, its policy is built by the reverse chain of a conditional diffusion model, which allows for a highly expressive policy class and whose learning itself acts as a strong policy regularization method. Second, Q-learning guidance through a jointly learned Q-value function is injected in the learning of the diffusion policy, which guides the denoising sampling towards the optimal region in its exploration area. The two key components contribute to its state-of-the-art performance across all tasks in the D4RL benchmark.
181
+
182
+ # ACKNOWLEDGEMENTS
183
+
184
+ Z. Wang and M. Zhou acknowledge the support of NSF-IIS 2212418 and the Texas Advanced Computing Center (TACC) for providing HPC resources that have contributed to the research results reported within this paper.
185
+
186
+ # REFERENCES
187
+
188
+ Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning, pp. 104–114. PMLR, 2020.
189
+
190
+ Anurag Ajay, Yilun Du, Abhi Gupta, Joshua Tenenbaum, Tommi Jaakkola, and Pulkit Agrawal. Is conditional generative modeling all you need for decision-making? arXiv preprint arXiv:2211.15657, 2022.
191
+
192
+ Christopher M Bishop. Mixture density networks. 1994.
193
+
194
+ David M Blei, Alp Kucukelbir, and Jon D McAuliffe. Variational inference: A review for statisticians. Journal of the American statistical Association, 112(518):859–877, 2017.
195
+
196
+ David Brandfonbrener, Will Whitney, Rajesh Ranganath, and Joan Bruna. Offline RL without offpolicy evaluation. Advances in Neural Information Processing Systems, 34:4933–4946, 2021.
197
+
198
+ Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Misha Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34, 2021.
199
+
200
+ Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4RL: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
201
+
202
+ Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021.
203
+
204
+ Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052–2062. PMLR, 2019.
205
+
206
+ Wonjoon Goo and Scott Niekum. Know your boundaries: The necessity of explicit behavioral cloning in offline rl. arXiv preprint arXiv:2206.00695, 2022.
207
+
208
+ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International conference on machine learning, pp. 1861–1870. PMLR, 2018.
209
+
210
+ Hado Hasselt. Double Q-learning. Advances in neural information processing systems, 23, 2010.
211
+
212
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
213
+
214
+ Michael Janner, Qiyang Li, and Sergey Levine. Offline reinforcement learning as one big sequence modeling problem. Advances in neural information processing systems, 34, 2021.
215
+
216
+ Michael Janner, Yilun Du, Joshua B Tenenbaum, and Sergey Levine. Planning with diffusion for flexible behavior synthesis. arXiv preprint arXiv:2205.09991, 2022.
217
+
218
+ Michael I Jordan, Zoubin Ghahramani, Tommi S Jaakkola, and Lawrence K Saul. An introduction to variational methods for graphical models. Machine learning, 37(2):183–233, 1999.
219
+
220
+ Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel: Modelbased offline reinforcement learning. Advances in neural information processing systems, 33: 21810–21823, 2020.
221
+
222
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
223
+
224
+ Ilya Kostrikov, Rob Fergus, Jonathan Tompson, and Ofir Nachum. Offline reinforcement learning with fisher divergence critic regularization. In International Conference on Machine Learning, pp. 5774–5783. PMLR, 2021a.
225
+
226
+ Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit Qlearning. arXiv preprint arXiv:2110.06169, 2021b.
227
+
228
+ Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy Qlearning via bootstrapping error reduction. Advances in Neural Information Processing Systems, 32, 2019.
229
+
230
+ Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative Q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020.
231
+
232
+ Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pp. 45–73. Springer, 2012.
233
+
234
+ Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
235
+
236
+ Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. arXiv preprint arXiv:2206.00927, 2022.
237
+
238
+ Jiafei Lyu, Xiaoteng Ma, Xiu Li, and Zongqing Lu. Mildly conservative Q-learning for offline reinforcement learning. arXiv preprint arXiv:2206.04745, 2022.
239
+
240
+ Ashvin Nair, Abhishek Gupta, Murtaza Dalal, and Sergey Levine. Awac: Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359, 2020.
241
+
242
+ Tim Pearce, Tabish Rashid, Anssi Kanervisto, Dave Bignell, Mingfei Sun, Raluca Georgescu, Sergio Valcarcel Macua, Shan Zheng Tan, Ida Momennejad, Katja Hofmann, et al. Imitating human behaviour with diffusion models. arXiv preprint arXiv:2301.10677, 2023.
243
+
244
+ Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019.
245
+
246
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
247
+
248
+ Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022.
249
+
250
+ Nur Muhammad Mahi Shafiullah, Zichen Jeff Cui, Ariuntuya Altanzaya, and Lerrel Pinto. Behavior transformers: Cloning $k$ modes with one stone. arXiv preprint arXiv:2206.11251, 2022.
251
+
252
+ Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. ArXiv, abs/1503.03585, 2015.
253
+
254
+ Kihyuk Sohn, Honglak Lee, and Xinchen Yan. Learning structured output representation using deep conditional generative models. Advances in neural information processing systems, 28, 2015.
255
+
256
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
257
+
258
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems, pp. 11918–11930, 2019.
259
+
260
+ Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021. URL https://openreview.net/ forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ PxTIG12RRHS.
261
+
262
+ Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
263
+ Zhendong Wang, Huangjie Zheng, Pengcheng He, Weizhu Chen, and Mingyuan Zhou. DiffusionGAN: Training gans with diffusion. arXiv preprint arXiv:2206.02262, 2022.
264
+ Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019.
265
+ Zhisheng Xiao, Karsten Kreis, and Arash Vahdat. Tackling the generative learning trilemma with denoising diffusion gans. arXiv preprint arXiv:2112.07804, 2021.
266
+ Tianhe Yu, Aviral Kumar, Rafael Rafailov, Aravind Rajeswaran, Sergey Levine, and Chelsea Finn. Combo: Conservative offline model-based policy optimization. Advances in neural information processing systems, 34:28954–28967, 2021.
267
+ Huangjie Zheng, Pengcheng He, Weizhu Chen, and Mingyuan Zhou. Truncated diffusion probabilistic models and diffusion-based adversarial auto-encoders. arXiv preprint arXiv:2202.09671, 2022.
268
+
269
+ # Appendix
270
+
271
+ # A MORE TOY EXPERIMENTS
272
+
273
+ Here we describe an additional toy experiment on a bandit task. Actions are again in a real-valued 2D space, $\begin{array} { r l r } { { \bf a } } & { { } \in } & { [ - 1 , 1 ] ^ { 2 } } \end{array}$ . The offline data $\begin{array} { r c l } { \mathcal { D } } & { = } & { \{ ( { \bf a } _ { i } ) \} _ { i = 1 } ^ { 1 0 0 0 0 } } \end{array}$ are collected by sampling actions equally from four Gaussian distributions with centers $\mu \in$ $\{ ( - 0 . 8 , \bar { 0 } . 8 ) , ( \bar { 0 . 8 } , \bar { 0 . 8 } ) , ( 0 . 8 , - 0 . \bar { 8 } ) , ( - 0 . 8 , - 0 . 8 ) \}$ and standard deviations ${ \pmb \sigma } _ { d } = ( 0 . 0 5 , 0 . 0 5 )$ , as depicted in the first panel of Figure 4. We conduct the same experiments as the ones in our main paper (see figure 1) and show the performance in Figure 4. The only difference in this experiment is that the samples are now in the corners of the ation space.
274
+
275
+ For behavior-cloning experiments, we observe that only our diffusion model could recover the original data distribution while the prior regularization methods fail in some way. For example, CVAE could only capture the two diagonal modes and place density between them, while MMD tends to align density around the boundaries because of its Tanh-Gaussian policy. For Q-learning experiments, we observe that the prior regularization methods typically push the policy to converge to sub-optimal solutions in BCQ and BEAR while preventing the policy of $\mathrm { T D } 3 { + } \mathrm { B C }$ from being concentrated on the right corner. However, the policy of Diffusion-QL successfully converges to the optimal bottom corner. The ablation study experiments are consistent with our conclusion in the main paper.
276
+
277
+ ![](images/181d726c98a3785888a1597f23d5e1c8bef7ef5621f2032a76f6096ceb356228.jpg)
278
+ Figure 4: Bandit experiment with a strong multi-modal behavior policy. The first row shows the comparison of behavior-cloning results between our method and prior methods. The second row shows the comparison results with Q-learning involved. The third row shows the ablation study of $N$ for BC-Diffusion. The fourth row shows the learned reward function and the ablation study of $N$ for Diffusion-QL.
279
+
280
+ # B IMPLEMENTATION DETAILS
281
+
282
+ Diffusion policy. We build our policy as an MLP-based conditional diffusion model. Following the parameterization of Ho et al. (2020), the model itself is a residual model, $\epsilon _ { \theta } ( a ^ { i } , s , i )$ , where the $i$ is the last timestep and $\pmb { s }$ is the state condition. We model $\epsilon _ { \theta }$ as a 3-layer MLPs with Mish activations and we use 256 hidden units for all networks. The input of $\epsilon _ { \theta }$ is the concatenation of the last step action vector, the current state vector, and the sinusoidal positional embedding of timestep $i$ . The output of $\epsilon _ { \theta }$ is the predicted residual at diffusion timestep $i$ .
283
+
284
+ Q networks. We build two Q networks with the same MLP setting as our diffusion policy, which has 3-layer MLPs with Mish activations and 256 hidden units for all networks.
285
+
286
+ We use the Adam (Kingma & Ba, 2014) optimizer for the training of both Diffusion policy and Q networks.
287
+
288
+ # C EXPERIMENTAL DETAILS
289
+
290
+ We train our algorithm with 2000 epochs for Gym tasks and 1000 epochs for the other tasks, where each epoch consists of 1000 gradient steps. For the Gym locomotion tasks, we average mean returns over 6 independently trained models and 10 trajectories per mode. For the other tasks, we average over 6 independently trained models and 100 evaluation trajectories.
291
+
292
+ We investigate two model selection methods, online and offline model selection. For online model selection, following the convention of supervised learning, the best-performed model is saved during training and used for final evaluation. For offline case, we select the model based on our lagging indicator $\mathcal { L } _ { d }$ and more details are in Appendix D.
293
+
294
+ We use the original task rewards from MuJoCo Gym and Kitchen tasks. We standardize Adroit task rewards for training stability. We modify the rewards according to the suggestion of CQL (Kumar et al., 2020) for the AntMaze datasets.
295
+
296
+ # D OFFLINE MODEL SELECTION
297
+
298
+ For reducing the training cost and picking the best model during training without any interaction with the real environment, we provide a way to properly conduct early stopping for DiffusionQL. Empirically, we found that $\mathcal { L } _ { d }$ loss is a lagging indicator of online performance. Note $\mathcal { L } _ { d }$ is the behavior cloning loss of our diffusion model-based policy and measures how close the current policy is to the behavior policy. For offline RL, we want $\mathcal { L } _ { d }$ to be small to get rid of the OOD issue but we also don’t expect $\mathcal { L } _ { d }$ to be the smallest since our goal is policy learning while not behavior cloning. Hence, we monitor the $\mathcal { L } _ { d }$ and save multiple model checkpoints during training. We stop the training whenever $\mathcal { L } _ { d }$ increases in our evaluation stage for early stopping. When the training stopped, we picked the checkpoint according to our metric, the second or third lowest $\mathcal { L } _ { d }$ value. Note our model selection part is totally offline and only based on $\mathcal { L } _ { d }$ without any access to the environment. The selection of the $\mathcal { L } _ { d }$ is not very sensitive. Always using the 2nd smallest checkpoints doesn’t impact the performance much. For example, with 2nd checkpoints selected, for the Gym domain, the average score is 87.6, and for the AntMaze domain, the average score is 69.1.
299
+
300
+ # E HYPERPARAMETERS
301
+
302
+ For Diffusion- $\mathrm { Q L }$ , we consider three hyperparameters in total: learning rate, Q-learning weight $\eta$ , and whether to use max Q backup from CQL (Kumar et al., 2020). For the learning rate of Adam, we consider values in the grid $\{ 1 \tilde { \times } 1 0 ^ { - 3 } , \bar { 3 \times } 1 0 ^ { - 4 } , 3 \times 1 0 ^ { - 5 } \}$ for the policy, while we use a fixed learning rate, $3 \times 1 0 ^ { - 4 }$ , for Q-networks. For $\eta$ , we consider values according to the characteristics of different domains, as we mentioned in the description of datasets that the Adroit and Kitchen tasks require more policy regularization and the AntMaze tasks require more Q-learning. For max Q backup, we only apply it on the AntMaze tasks. Based on these considerations, we provide our hyperparameter setting in Table 3.
303
+
304
+ Table 3: Hyperparameter settings of all selected tasks.
305
+
306
+ <table><tr><td>Tasks</td><td>learning rate</td><td>n</td><td>max Qbackup</td></tr><tr><td>halfcheetah-medium-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>hopper-medium-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>walker2d-medium-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>halfcheetah-medium-replay-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>hopper-medium-replay-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>walker2d-medium-replay-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>hopper-medium-expert-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>walker2d-medium-expert-v2</td><td>3×10-4</td><td>1.0</td><td>False</td></tr><tr><td>antmaze-umaze-vo</td><td>3×10-4</td><td>0.5</td><td>False</td></tr><tr><td>antmaze-umaze-diverse-v0</td><td>3×10-4</td><td>2.0</td><td>True</td></tr><tr><td>antmaze-medium-play-v0</td><td>1×10-3</td><td>2.0</td><td>True</td></tr><tr><td>antmaze-medium-diverse-vO</td><td>3×10-4</td><td>3.0</td><td>True</td></tr><tr><td>antmaze-large-play-vo</td><td>3×10-4</td><td>4.5</td><td>True</td></tr><tr><td>antmaze-large-diverse-vO</td><td>3×10-4</td><td>3.5</td><td>True</td></tr><tr><td>pen-human-v1</td><td>3×10-5</td><td>0.15</td><td>False</td></tr><tr><td>pen-cloned-v1</td><td>3×10-5</td><td>0.1</td><td>False</td></tr><tr><td>kitchen-complete-v0</td><td>3×10-4</td><td>0.005</td><td>False</td></tr><tr><td>kitchen-partial-vo</td><td>3×10-4</td><td>0.005</td><td>False</td></tr><tr><td>kitchen-mixed-v0</td><td>3×10-4</td><td>0.005</td><td>False</td></tr></table>
307
+
308
+ # F OPTIMAL RESULTS
309
+
310
+ If a small amount of online experience is provided during the evaluation stage for model selection, we can pick the best models during training via online evaluations (similar to early stopping in supervised learning). This regime provides a further boost in the performance of Diffusion-QL as shown in Table 4.
311
+
312
+ # G LIMITATIONS AND FUTURE WORK
313
+
314
+ Diffusion policies are highly expressive and hence they can capture multi-modal distributions well. We have shown this results in learning better policies in offlineRL. However, at the inference time, the reverse sampling defined in Equation (1) requires iteratively computing $\epsilon _ { \theta }$ networks $N$ times, and this can become a bottleneck for the running time. In our case, we couple the learning of diffusion policies with Q-learning, and achieve good performance with small $N = 5$ . Diffusion policies with $N = 5$ could be four to five times slower in action inference compared to previous one-step feedforward policies, and hence the inference cost could prevent the approach from deployment in some real-world scenarios, where fast response is necessary.
315
+
316
+ This motivates potential future works. There have been many recent works focusing on improving the sampling speed of diffusion models (Lu et al., 2022; Wang et al., 2022; Xiao et al., 2021; Salimans & Ho, 2022; Song et al., 2020; Zheng et al., 2022), which could be applied to improve the sampling efficiency of Diffusion-QL. For example, the diffusion policy may be able to be distilled into a simpler feedforward policy after training.
317
+
318
+ # H GAUSSIAN MIXTURE POLICY
319
+
320
+ We test a Gaussian Mixture policy as a classic policy class that can capture multi-modal distributions as an additional baseline. We modify $\mathrm { T D } 3 { + } \mathrm { B C }$ (Fujimoto & Gu, 2021) by replacing the original deterministic actor with a mixture density network (Bishop, 1994), where each mixture component is a Gaussian. Since a Gaussian mixture policy is applied, we replaced minimizing the L2 loss (from $\mathrm { T D } 3 { + } \mathrm { B C } )$ between predicted actions and real actions, with maximizing the likelihood estimate of Gaussian mixtures on real state-action pairs. We keep all the other parts the same as $\mathrm { T D } 3 { + } \mathrm { B C }$ .
321
+
322
+ Table 4: Performance comparison with online model selection and offline model selection.
323
+
324
+ <table><tr><td>Gym Tasks</td><td>Diffusion-QL (Offline)</td><td>Diffusion-QL (Online)</td></tr><tr><td>halfcheetah-medium-v2</td><td>51.1 ± 0.5</td><td>51.5 ± 0.3</td></tr><tr><td>hopper-medium-v2</td><td>90.5 ± 4.6</td><td>96.6 ± 3.4</td></tr><tr><td>walker2d-medium-v2</td><td>87.0 ± 0.9</td><td>87.3 ± 0.5</td></tr><tr><td>halfcheetah-medium-replay-v2</td><td>47.8 ± 0.3</td><td>48.3 ± 0.2</td></tr><tr><td>hopper-medium-replay-v2</td><td>101.3 ± 0.6</td><td>102.0 ± 0.4</td></tr><tr><td>walker2d-medium-replay-v2</td><td>95.5 ± 1.5</td><td>98.0 ± 0.5</td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>96.8 ± 0.3</td><td>97.2 ± 0.4</td></tr><tr><td>hopper-medium-expert-v2</td><td>111.1 ± 1.3</td><td>112.3 ± 0.8</td></tr><tr><td>walker2d-medium-expert-v2</td><td>110.1 ± 0.3</td><td>111.2 ± 0.9</td></tr><tr><td>Average</td><td>88.0</td><td>89.3</td></tr><tr><td>AntMaze Tasks</td><td>Diffusion-QL (Offline)</td><td>Diffusion-QL (Online)</td></tr><tr><td>antmaze-umaze-vo</td><td>93.4 ± 3.4</td><td>96.0 ± 3.3</td></tr><tr><td>antmaze-umaze-diverse-v0</td><td>66.2 ± 8.6</td><td>84.0 ± 10.1</td></tr><tr><td>antmaze-medium-play-v0</td><td>76.6 ± 10.8</td><td>79.8 ± 8.7</td></tr><tr><td>antmaze-medium-diverse-v0</td><td>78.6 ± 10.3</td><td>82.0 ± 9.5</td></tr><tr><td>antmaze-large-play-v0</td><td>46.4 ± 8.3</td><td>49.0 ± 9.4</td></tr><tr><td>antmaze-large-diverse-v0</td><td>56.6 ± 7.6</td><td>61.7 ± 8.2</td></tr><tr><td>Average</td><td>69.6</td><td>75.4</td></tr><tr><td>Adroit Tasks</td><td>Diffusion-QL (Offline)</td><td>Diffusion-QL (Online)</td></tr><tr><td>pen-human-v1</td><td>72.8 ± 9.6</td><td>75.7± 9.0</td></tr><tr><td>pen-cloned-v1</td><td>57.3 ± 11.9</td><td>60.8 ± 11.8</td></tr><tr><td>Average</td><td>65.1</td><td>68.3</td></tr><tr><td>Kitchen Tasks</td><td>Diffusion-QL (Offline)</td><td>Diffusion-QL (Online)</td></tr><tr><td>kitchen-complete-v0</td><td>84.0 ± 7.4</td><td>84.5 ± 6.1</td></tr><tr><td>kitchen-partial-v0</td><td>60.5 ± 6.9</td><td>63.7 ± 5.2</td></tr><tr><td>kitchen-mixed-v0</td><td>62.6 ± 5.1</td><td>66.6 ± 3.3</td></tr><tr><td>Average</td><td>69.0</td><td>71.6</td></tr></table>
325
+
326
+ Table 5: Performance comparison for Gaussian Mixture ablation study.
327
+
328
+ <table><tr><td>Gym Tasks</td><td>TD3+BC</td><td>TD3+BC-GM</td><td>Diffusion-QL</td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>90.4</td><td>49.0</td><td>96.8</td></tr><tr><td>hopper-medium-expert-v2</td><td>98.0</td><td>40.0</td><td>111.1</td></tr><tr><td>walker2d-medium-expert-v2</td><td>110.1</td><td>66.5</td><td>110.1</td></tr></table>
329
+
330
+ We evaluated the model (we call it $\mathrm { T D } 3 { + } \mathrm { B C } { \cdot } \mathrm { G M } \rangle$ ) on both our bandit toy experiment and selected D4RL tasks. As shown in Figure 5, with a properly selected number of mixtures, the Gaussian mixture could capture the multi-modal distribution in our behavior cloning experiment. However, in the Q-learning experiment, it fails to converge to the optimal target location, and always places some density on the suboptimal modes, resulting in a suboptimal policy with multi-modes. For D4RL experiments, we set the number of mixtures to be 3, and seen in Table 5, we observed that $\mathrm { T D } 3 { + } \mathrm { B C } { - } \mathrm { G M }$ does not perform well on the three D4RL tasks, which is consistent with our previous observation that $\mathrm { T D } 3 { + } \mathrm { B C } { - } \mathrm { G M }$ is prone to have suboptimal actions.
331
+
332
+ One reason for the poor performance could be that Gaussian mixture models are challenging to fit well, particularly in higher dimensional spaces. We are also forced to choose the number of mixture components, which for the D4RL experiments we don’t know a priori how many components there are. Moreover, each mixture component is often parameterized with a diagonal Gaussian that has limited ability in capturing the dependence between different dimensions.
333
+
334
+ ![](images/bb9d33f44ed325e7df174e40e32ef904e23fcb4b55194a931d7cb5f3c2def080.jpg)
335
+ Figure 5: Gaussian Mixture ablation study. The first row shows the behavior cloning experiment and the second row shows the Q-learning experiment, which are the same set of experiments described in Section 4. Here, $K$ is the number of Gaussian mixtures.
md/dev/BlF6CWzWKT7/BlF6CWzWKT7.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/Bto5a6w06l/Bto5a6w06l.md ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # On Architectural Compression of Text-to-Image Diffusion Models
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Exceptional text-to-image (T2I) generation results of Stable Diffusion models
11
+ 2 (SDMs) come with substantial computational demands. To resolve this issue, re
12
+ 3 cent research on efficient SDMs has prioritized reducing the number of sampling
13
+ 4 steps and utilizing network quantization. Orthogonal to these directions, this study
14
+ 5 highlights the power of classical architectural compression for general-purpose T2I
15
+ 6 synthesis by introducing a block-removed knowledge-distilled SDM (BK-SDM).
16
+ 7 We eliminate several residual and attention blocks from the U-Net of SDMs, obtain
17
+ 8 ing over a $30 \%$ reduction in the number of parameters, MACs per sampling step,
18
+ 9 and latency. We conduct distillation-based pretraining with only 0.22M LAION
19
+ 10 pairs (fewer than $0 . 1 \%$ of the full training pairs) on a single A100 GPU. Despite
20
+ 11 being trained with limited resources, our compact models can imitate the original
21
+ 12 SDM by benefiting from transferred knowledge and achieve competitive results
22
+ 13 against larger multi-billion parameter models on the zero-shot MS-COCO bench
23
+ 14 mark. Moreover, we demonstrate the applicability of our lightweight pretrained
24
+ 15 models in personalized generation with DreamBooth finetuning.
25
+ 17 Large diffusion models [44, 51, 38, 47] have showcased groundbreaking results in text-to-image (T2I)
26
+ 18 synthesis tasks, which aim to create photorealistic images from textual descriptions. Stable Diffusion
27
+ 19 models (SDMs) [46, 47] are one of the most renowned open-source models, and their exceptional
28
+ 20 capability has begun to be leveraged as a backbone in several text-guided vision applications, e.g.,
29
+ 21 text-driven image editing [2, 23] and 3D object creation [67], text-to-video generation [1, 68], and
30
+ 22 subject-driven [50, 25] and controllable [37, 71] T2I.
31
+ 23 SDMs are T2I-specialized latent diffusion mod
32
+ 24 els (LDMs) [47], which employ diffusion oper
33
+ 25 ations [17, 59, 30] in a latent space to improve
34
+ 26 compute efficiency. Within a SDM, a U-Net
35
+ 27 [49, 6] conducts an iterative sampling procedure
36
+ 28 to gradually eliminate noise from random la
37
+ 29 tents and is assisted by a text encoder [42] and
38
+ 30 an image decoder [9, 64] to produce text-aligned
39
+ 31 images. This inference process still involves ex
40
+ 32 cessive computational requirements (see Figure
41
+ 33 2), which often hinder the utilization of SDMs
42
+ 34 despite their rapidly growing usage.
43
+ 35 To alleviate this issue, numerous approaches
44
+ 36 toward efficient SDMs have been introduced.
45
+ 37 Meng et al. [35, 34] reduce the number of denoising steps by distilling a pretrained diffusion model
46
+ 38 to guide an identically architectured model with fewer sampling steps. Li et al. [28], Hou and Asghar
47
+ 39 [19], Shen et al. [57] employ post-training quantization techniques, and Chen et al. [4] enhance the
48
+ 40 implementation of SDMs for better compatibility with GPUs. However, the removal of architectural
49
+ 41 elements in diffusion models has not been investigated in spite of the established efficacy of structured
50
+ 42 pruning across discriminative models [26, 69] and generative adversarial networks (GANs) [31, 24].
51
+ 43 This study unlocks the immense potential of classical architectural compression in attaining smaller
52
+ 44 and faster diffusion models. We eliminate multiple residual and attention blocks from the U-Net of a
53
+ 45 SDM and pretrain it with feature-level knowledge distillation (KD) [48, 13] for general-purpose T2I
54
+ 46 synthesis. Despite being trained with only 0.22M LAION pairs (less than $0 . 1 \%$ of the entire training
55
+ 47 pairs) [55] on a single A100 GPU, our compact models can mimic the original SDM by leveraging
56
+ 48 transferred knowledge. On the popular zero-shot MS-COCO benchmark [29], our work achieves a
57
+ 49 FID [15] score of 15.76 with 0.76B parameters and 16.98 with 0.66B parameters, which are on par
58
+ 50 with multi-billion parameter models [43, 7, 8]. Furthermore, we present the practical application of
59
+ 51 our lightweight pretrained models in customized T2I with DreamBooth finetuning [50].
60
+
61
+ ![](images/86ad1fd386202b89de94b177adbb4d0f0779ea1660d2e2d10754c1687d2c0e67.jpg)
62
+ Figure 1: Our compressed stable diffusion enables efficient (a) zero-shot general-purpose text-toimage generation and (b) personalized synthesis. Selected samples from our lightest BK-SDM-Small with $36 \%$ reduced parameters and latency are shown.
63
+
64
+ ![](images/36ba29cbb3381a7748f6e769babb7e37e12601f0a49c4e49a4eaee1491469745.jpg)
65
+ Figure 2: Computation of the major components in Stable Diffusion v1. The denoising U-Net is the main processing bottleneck. THOP [75] is used to measure MACs in generating a $5 1 2 { \times } 5 1 2$ image.
66
+
67
+ 52 Our contributions are summarized as follows:
68
+
69
+ ◦ To the best of our knowledge, this is the first study to architecturally compress large-scale diffusion models. Our work is orthogonal to prior directions for efficient diffusion, e.g., enabling less sampling steps and employing quantization, and can be readily integrated with them. ◦ We compress SDMs by removing architectural blocks from the U-Net and achieve more than $30 \%$ reduction in model size and inference speed. We also introduce an interesting finding on the minor role of innermost blocks. $\circ$ We demonstrate the advantage of distillation-based pretraining, which allows us to attain competitive zero-shot T2I results even with very limited training resources. ◦ We highlight the capability of our light pretrained backbones in customized generation. Our models can lower the finetuning cost by $30 \%$ while retaining $9 7 \%$ scores of the original SDM.
70
+
71
+ # 63 2 Related work
72
+
73
+ 64 Large T2I diffusion models. By gradually removing noise from corrupted data, diffusion-based
74
+ 65 generative models [18, 59, 6] enable high-fidelity synthesis with broad mode coverage. Integrating
75
+ 66 these merits with the advancement of pretrained language models [42, 41, 5] has significantly
76
+ 67 improved the quality of T2I synthesis. In GLIDE [38] and Imagen [51], a text-conditional diffusion
77
+ 68 model generates a $6 4 { \times } 6 4$ image, which is upsampled via super-resolution modules. In DALL·E-2 [44],
78
+ 69 a text-conditional prior network produces an image embedding, which is transformed into a $6 4 { \times } 6 4$
79
+ 70 image via a diffusion decoder and further upscaled into higher resolutions. SDMs [46, 47] perform
80
+ 71 the diffusion modeling in a $6 4 { \times } 6 4$ latent space constructed through a pixel-space autoencoder. We use
81
+ 72 SDM as our baseline because of its open-access and gaining popularity over numerous downstream
82
+ 73 tasks [2, 67, 1, 50].
83
+ 74 Efficient diffusion models. Several studies have addressed the slow sampling process of diffusion
84
+ 75 models. Diffusion-tailored distillation approaches [35, 34, 52] progressively transfer knowledge from
85
+ 76 a pretrained diffusion model to a fewer-step model with the same architecture. Fast high-order solvers
86
+ 77 [32, 33, 73] for diffusion ordinary differential equations boost the sampling speed. Orthogonal
87
+ 78 to these directions for less sampling steps, our network compression approach reduces per-step
88
+ 79 computation and can be easily integrated with them. Leveraging quantization techniques [28, 19, 57]
89
+ 80 and implementation optimizations [4] has been applied for SDMs and also can be combined with our
90
+ 81 models for further efficiency gains.
91
+ 82 Distillation-based compression. KD enhances the performance of small-size models by exploiting
92
+ 83 output-level [16, 39] and feature-level [48, 13, 70] information of large source models. Although
93
+ 84 this classical distillation has been actively used toward efficient GANs [27, 45, 31, 22, 72], its power
94
+ 85 has not been explored for structurally compressed diffusion models. Distillation-based pretraining
95
+ 86 enables small yet capable general-purpose language models [54, 61, 21] and vision transformers
96
+ 87 [63, 11]. Beyond such models, we show that its success can be extended to diffusion models with
97
+ 88 iterative sampling steps. Concurrently with our study, a recently released small SDM without paper
98
+ 89 evidence [40] similarly utilizes KD pretraining for a block-eliminated architecture, but it relies on
99
+ 90 significantly more training resources along with multi-stage distillation. In contrast, our lightest
100
+ 91 model achieves further reduced computation, and we show that competitive results can be obtained
101
+ 92 even with much less data and single-stage distillation.
102
+
103
+ ![](images/43624dd4c725599e123d3b281d52b082259e63dec09da444252907926157f73e.jpg)
104
+ Figure 3: U-Net architectures of SDMs and KD-based pretraining process. The compact U-Net student is built by eliminating several residual and attention blocks from the original U-Net teacher. Through the feature and output distillation from the teacher, the student can be trained effectively yet rapidly. See Appendix for the details of block components.
105
+
106
+ # 93 3 BK-SDM: block-removed knowledge-distilled SDM
107
+
108
+ We compress the U-Net [49] of a SDM [46, 47], which is the most compute-heavy component (see Figure 2). Conditioned on the text and time-step embeddings, the U-Net performs multiple denoising steps on latent representations. At each denoising step, the U-Net produces the noise residual to compute the latent for the next step (see the top part of Figure 3). We reduce this per-step computation by exploiting block-level elimination and feature distillation.
109
+
110
+ # 3.1 Compressed U-Net architecture
111
+
112
+ The proposed models are referred to as:
113
+
114
+ $\circ$ BK-SDM-Base (0.76B parameters) obtained with Section 3.1.1 (fewer blocks in outer stages).
115
+ $\circ$ BK-SDM-Small (0.66B) with Section 3.1.1 (fewer blocks) and Section 3.1.2 (mid-stage removal).
116
+
117
+ Table 1: Minor impact of eliminating the mid-stage from the U-Net of SDM on zero-shot MS-COCO performance. Any retraining is not performed for the midstage removed model. For evaluation details, see Section 5.1.1.
118
+
119
+ <table><tr><td>Model</td><td>Performance FID↓ IS↑</td><td>#Params</td><td>Whole</td></tr><tr><td>SDM-v1.4 [46]</td><td>13.05 36.76</td><td>U-Net 859.5M</td><td>1032.1M</td></tr><tr><td>Mid-Stage Removal</td><td>32.33 15.60</td><td>762.5M (-11.3%)</td><td>935.1M (-9.4%)</td></tr></table>
120
+
121
+ ![](images/8cac4c5956a8c681f4addd1e4257e5c5d70d11748013b5f130220a489ddb4a36.jpg)
122
+ Figure 4: Visual results of the mid-stage removed U-Net without retraining.
123
+
124
+ # 103 3.1.1 Fewer blocks in the down and up stages
125
+
126
+ Our design philosophy is closely aligned with that of DistilBERT [54] which halves the number of layers for improved computational efficiency and initializes the compact model with the original weights by benefiting from the shared dimensionality. In the original U-Net, each stage with a common spatial size consists of multiple blocks, and most stages contain pairs of residual (R) [12] and cross-attention (A) [65, 20] blocks. We hypothesize the existence of some unnecessary pairs and use the following removal strategies, as shown in Figure 3.
127
+
128
+ 110 For the down stages, we maintain the first R-A pairs while eliminating the second pairs, because the
129
+ 111 first pairs process the changed spatial information and would be more important than the second pairs.
130
+ 112 This design choice does not harm the dimensionality of the original U-Net, enabling the use of the
131
+ 113 corresponding pretrained weights for initialization [54].
132
+ 114 For the up stages, while adhering to the aforementioned scheme, we retain the third R-A pairs. This
133
+ 115 allows us to utilize the output feature maps at the end of each down stage and the corresponding skip
134
+ 116 connections between the down and up stages. The same process is applied to the innermost down and
135
+ 117 up stages that contain only R blocks.
136
+
137
+ # 3.1.2 Removal of the entire mid-stage
138
+
139
+ 119 Surprisingly, removing the entire mid-stage from the original U-Net (marked with red in Figure 3)
140
+ 120 does not noticeably degrade the generation quality for many text prompts while effectively reducing
141
+ 121 the number of parameters (see Table 1 and Figure 4). This observation is consistent with the minor
142
+ 122 role of inner layers in the U-Net generator of GANs [24].
143
+ 123 Integrating the mid-stage removal with fewer blocks in Section 3.1.1 further decreases computational
144
+ 124 burdens (Table 3) at the cost of a slight decline in performance (Table 2). Therefore, we offer
145
+ 125 this mid-stage elimination as an option, depending on the priority between compute efficiency and
146
+ 126 generation quality.
147
+
148
+ # 3.2 Distillation-based pretraining
149
+
150
+ 128 For general-purpose T2I generation, we train the compact U-Net to mimic the behavior of the original
151
+ 129 U-Net. Following Rombach et al. [47], we use the pretrained-and-frozen encoders to obtain the inputs
152
+ 130 of the U-Net.
153
+ 131 Given the latent representation $z$ of an image and its paired text embedding $y$ , the task loss for the
154
+ 132 reverse denoising process [18, 47] is computed as:
155
+
156
+ $$
157
+ \mathcal { L } _ { \mathrm { T a s k } } = \mathbb { E } _ { z , \epsilon , y , t } \Big [ | | \epsilon - \epsilon _ { \mathrm { S } } ( z _ { t } , y , t ) | | _ { 2 } ^ { 2 } \Big ] ,
158
+ $$
159
+
160
+ 133 where $\epsilon { \sim } N ( 0 , I )$ and $t { \sim } \mathrm { U n i f o r m } ( 1 , T )$ denote the noise and time step sampled from the diffusion
161
+ 134 process, respectively, and $\epsilon _ { \mathrm { { S } } } ( \circ )$ indicates the output of our compact U-Net student. For brevity, we
162
+ 135 omit the subscripts of $\mathbb { E } _ { z , \epsilon , y , t } [ \circ ]$ in the following notations.
163
+ 136 The compact student is also trained to imitate the outputs of the original U-Net teacher, $\epsilon _ { \mathrm { T } } ( \circ )$ ,with
164
+ 137 the following output-level KD objective [16]:
165
+
166
+ $$
167
+ \mathcal { L } _ { \mathrm { O u t K D } } = \mathbb { E } \Big [ | | \epsilon _ { \mathrm { T } } ( z _ { t } , y , t ) - \epsilon _ { \mathrm { S } } ( z _ { t } , y , t ) | | _ { 2 } ^ { 2 } \Big ] .
168
+ $$
169
+
170
+ 138 A key to our approach is the utilization of feature-level KD [48, 13] that provides abundant guidance
171
+ 139 for the student’s training:
172
+
173
+ $$
174
+ \mathcal { L } _ { \mathrm { F e a t K D } } = \mathbb { E } \Big [ \sum _ { l } | | f _ { \mathrm { T } } ^ { l } ( z _ { t } , y , t ) - f _ { \mathrm { S } } ^ { l } ( z _ { t } , y , t ) | | _ { 2 } ^ { 2 } \Big ] ,
175
+ $$
176
+
177
+ 140 where $f _ { \mathrm { T } } ^ { l } ( \mathrm { \circ } )$ and $f _ { \mathrm { S } } ^ { l } ( \mathrm { \mathrm { { o } } ) }$ represent the feature maps of the $l$ -th layer in a predefined set of distilled layers
178
+ 141 from the teacher and the student, respectively. While learnable regressors (e.g., $1 \times 1$ convolutions
179
+ 142 to match the number of channels) have been commonly used in existing studies [58, 45, 48], our
180
+ 143 approach circumvents this requirement. By applying distillation at the end of each stage in both
181
+ 144 models, we ensure that the dimensionality of the feature maps already matches, thus eliminating the
182
+ 145 need for additional regressors.
183
+ 146 The final objective is formalized as below, and we simply set the loss weights $\lambda _ { \mathrm { O u t K D } }$ and λFeatKD
184
+ 147 as 1. Without any hyperparameter tuning, our approach is effective in empirical validation.
185
+
186
+ $$
187
+ \mathcal { L } = \mathcal { L } _ { \mathrm { T a s k } } + \lambda _ { \mathrm { O u t K D } } \mathcal { L } _ { \mathrm { O u t K D } } + \lambda _ { \mathrm { F e a t K D } } \mathcal { L } _ { \mathrm { F e a t K D } } .
188
+ $$
189
+
190
+ # 148 3.3 Application: faster and smaller personalized SDMs
191
+
192
+ 149 To emphasize the benefit of our lightweight pretrained SDMs, we use a popular finetuning scenario
193
+ 150 for personalized generation. DreamBooth [50] enables T2I diffusion models to create contents about
194
+ 151 a particular subject using just a few input images. Our compact models not only accelerate inference
195
+ 152 speed but also reduce finetuning cost. Moreover, they produce high-quality images based on the
196
+ 153 inherited capability of the original SDM.
197
+
198
+ # 4 Experimental setup
199
+
200
+ # 4.1 Datasets and evaluation metrics
201
+
202
+ Pretraining. We train our compact SDM with only 0.22M image-text pairs from LAION-Aesthetics V2 $6 . 5 +$ [55, 56], which are significantly fewer than the original training data used for SDM-v1.4 [46] (i.e., 600M pairs of LAION-Aesthetics ${ \mathrm { V } } 2 5 +$ [55] for the resumed training).
203
+
204
+ 159 Zero-shot T2I evaluation. Following the popular protocol [43, 47, 51] to assess general-purpose T2I
205
+ 160 with pretrained models, we use 30K prompts from the MS-COCO validation split [29] and compare
206
+ 161 the generated images to the whole validation set. We compute Fréchet Inception Distance (FID) [15]
207
+ 162 and Inception Score (IS) [53] to assess visual quality. Moreover, we measure CLIP score [42, 14]
208
+ 163 with CLIP-ViT-g/14 model to assess text-image correspondence.
209
+
210
+ Finetuning for personalized generation. We use the DreamBooth dataset [50] that covers 30 subjects, each of which is associated with 25 prompts and $4 { \sim } 6$ images. Through individual finetuning for each subject, 30 personalized models are obtained. For evaluation, we follow the protocol of Ruiz et al. [50] based on four synthesized images per subject and per prompt. We consider CLIP-I and DINO scores to measure how well subject details are maintained in generated images (i.e., subject fidelity) and CLIP-T scores to measure text-image alignment (i.e., text fidelity). We use ViT-S/16 embeddings [3] for DINO scores and CLIP-ViT- $\mathrm { g } / 1 4$ embeddings for CLIP-I and CLIP-T.
211
+
212
+ # 71 4.2 Implementation
213
+
214
+ 172 We use the released version v1.4 of SDM [46] as our compression target. We remark that our approach
215
+ 173 is also applicable to other versions in v1.1–v1.5 with the same architecture and to SDM-v2 with a
216
+ 174 similarly designed architecture.
217
+ 175 We adjust the codes in Diffusers library [66] for pretraining our models and those in PEFT library
218
+ 176 [60] for DreamBooth-finetuning, both of which adopt the training process of DDPM [18] in latent
219
+ 177 spaces. We use a single NVIDIA A100 80G GPU for 50K-iteration pretraining with a constant
220
+ 178 learning rate of 5e-5. For DreamBooth, we use a single NVIDIA GeForce RTX 3090 GPU to finetune
221
+ 179 each personalized model for 800 iterations with a constant learning rate of 1e-6.
222
+ 180 Following the default inference setup, we use PNDM scheduler [30] for zero-shot T2I generation
223
+ 181 and DPM-Solver [32, 33] for DreamBooth results. For compute efficiency, we always opt for 25
224
+ 182 denoising steps of the U-Net at the inference phase. The classifier-free guidance scale [17, 51] is set
225
+ 183 to the default value of 7.5, except the analysis in Figure 7.
226
+
227
+ Table 2: Zero-shot results on 30K prompts from MS-COCO validation set [29] at $2 5 6 \times 2 5 6$ resolution. Despite being trained with a smaller dataset and having fewer parameters, our compressed models achieve results on par with prior approaches for general-purpose T2I. For our models, the results with the minimum FID and the final 50K-th iteration are reported (see Section 5.1.3 for detailed analysis).
228
+
229
+ <table><tr><td>Model</td><td>Type</td><td>FID↓</td><td>IS↑</td><td>#Params</td><td>Data Size</td></tr><tr><td>SDM-v1.4 [47]</td><td>DF</td><td>13.05</td><td>36.76</td><td>1.04B</td><td>600M</td></tr><tr><td>Small Stable Diffusion [40]</td><td>DF</td><td>12.76</td><td>32.33</td><td>0.76B</td><td>229M</td></tr><tr><td>BK-SDM-Base (Ours) @ Min FID</td><td>DF</td><td>13.57</td><td>29.22</td><td>0.76B</td><td>0.22M</td></tr><tr><td>BK-SDM-Base (Ours) @ Final Iter</td><td>DF</td><td>15.76</td><td>33.79</td><td>0.76B</td><td>0.22M</td></tr><tr><td>BK-SDM-Small (Ours) @ Min FID</td><td>DF</td><td>15.93</td><td>29.61</td><td>0.66B</td><td>0.22M</td></tr><tr><td>BK-SDM-Small (Ours) @ Final Iter</td><td>DF</td><td>16.98</td><td>31.68</td><td>0.66B</td><td>0.22M</td></tr><tr><td>DALL·Et* [43]</td><td>AR</td><td>27.5</td><td>17.9</td><td>12B</td><td>250M</td></tr><tr><td>CogView+*[7]</td><td>AR</td><td>27.1</td><td>18.2</td><td>4B</td><td>30M</td></tr><tr><td>CogView2t* [8]</td><td>AR</td><td>24.0</td><td>22.4</td><td>6B</td><td>30M</td></tr><tr><td>Make-A-Scene [10]</td><td>AR</td><td>11.84</td><td>=</td><td>4B</td><td>35M</td></tr><tr><td>LAFITE‡# [74]</td><td>GAN</td><td>26.94</td><td>26.02</td><td>0.23B</td><td>3M</td></tr><tr><td>GALIP (CC3M)+ [62]</td><td>GAN</td><td>16.12</td><td>1</td><td>0.32B</td><td>3M</td></tr><tr><td>GALIP (CC12M)† [62]</td><td>GAN</td><td>12.54</td><td>=</td><td>0.32B</td><td>12M</td></tr><tr><td>GLIDE‡ [38]</td><td>DF</td><td>12.24</td><td></td><td>5B</td><td>250M</td></tr><tr><td>LDM-KL-8-G+# [47]</td><td>DF</td><td>12.63</td><td>30.29</td><td>1.45B</td><td>400M</td></tr><tr><td>DALL·E-2† [44]</td><td>DF</td><td>10.39</td><td>1</td><td>5.2B</td><td>250M</td></tr></table>
230
+
231
+ † and ‡: FID from [62] and [47], respectively. ⋆ and ♯: IS from [8] and [47], respectively. DF and AR: diffusion and autoregressive models. $\downarrow$ and $\uparrow$ : lower and higher values are better.
232
+
233
+ # 5 Results
234
+
235
+ # 5.1 General-purpose T2I generation
236
+
237
+ # 5.1.1 Main results
238
+
239
+ Table 2 shows the zero-shot T2I results on 30K samples from the MS-COCO $2 5 6 \times 2 5 6$ validation set. Despite being trained with only 0.22M samples and having fewer than 1B parameters, our compressed models demonstrate competitive performance on par with previous large pretrained models. Despite the absence of a paper support, we include the model [40] that is identical in structure to BK-SDM-Base for comparison. This model benefits from far more training resources, i.e., two-stage KD relied on two teachers (SDM-v1.4 and v1.5) and a much larger volume of data with significantly longer iterations.
240
+
241
+ Figure 5 depicts synthesized images of different models with some MS-COCO captions. Our compressed models inherit the superior ability of SDM and produce more photorealistic images compared to the AR-based [8] and GAN-based [74, 62] baselines. Noticeably, the same latent code results in a shared visual style between the original and our compact SDMs (4th–6th columns in Figure 5), similar to the observation in transfer learning for GANs [36].
242
+
243
+ 199 Table 3 summarizes how the computational reduction for each sampling step of the U-Net impacts the
244
+ 200 overall compute of the entire SDM. The per-step reduction effectively decreases MACs and inference
245
+ 201 time by more than $30 \%$ as well as the number of parameters.
246
+
247
+ ![](images/069ef2f522593df8e9eeb455481c10d06a98e10fceb44b140c112b247cab5117.jpg)
248
+ Figure 5: Visual comparison on zero-shot MS-COCO benchmark. The results of previous studies [8, 74, 62] were obtained with their official codes and released models. We do not apply any CLIPbased reranking for SDM and our models.
249
+
250
+ Table 3: The impact of per-step compute reduction of the U-Net on the entire SDM. The number of sampling steps is indicated with the parentheses, e.g., U-Net (1) for one step. The full computation (denoted by “Whole”) covers the text encoder, U-Net, and image decoder. All corresponding values are obtained on the generation of a single $5 1 2 { \times } 5 1 2$ image with 25 denoising steps. The latency was measured on Xeon Silver 4210R CPU 2.40GHz and NVIDIA GeForce RTX 3090 GPU.
251
+
252
+ <table><tr><td rowspan="2">Model</td><td colspan="2">#Params</td><td colspan="3">MACs</td><td colspan="3">CPU Latency</td><td colspan="3">GPU Latency</td></tr><tr><td>U-Net</td><td>Whole</td><td>U-Net (1)</td><td>U-Net (25)</td><td>Whole</td><td>U-Net (1)</td><td>U-Net (25)</td><td>Whole</td><td>U-Net (1)</td><td>U-Net (25)</td><td>Whole</td></tr><tr><td>SDM-v1.4 [46]</td><td>860M</td><td>1033M</td><td>339G</td><td>8469G</td><td>9716G</td><td>5.63s</td><td>146.28s</td><td>153.02s</td><td>0.049s</td><td>1.28s</td><td>1.41s</td></tr><tr><td>BK-SDM-</td><td>580M</td><td>752M</td><td>224G</td><td>5594G</td><td>6841G</td><td>3.84s</td><td>99.95s</td><td>106.62s</td><td>0.032s</td><td>0.83s</td><td>0.96s</td></tr><tr><td>Base (Ours)</td><td>(-32.6%)</td><td>(-27.1%)</td><td>(-33.9%)</td><td>(-33.9%)</td><td>(-29.5%)</td><td>(-31.8%)</td><td>(-31.7%)</td><td>(-30.3%)</td><td>(-34.6%)</td><td>(-35.2%)</td><td>(-31.9%)</td></tr><tr><td>BK-SDM-</td><td>483M</td><td>655M</td><td>218G</td><td>5444G</td><td>6690G</td><td>3.45s</td><td>89.78s</td><td>96.52s</td><td>0.030s</td><td>0.77s</td><td>0.90s</td></tr><tr><td>Small (Ours)</td><td>(-43.9%)</td><td>(-36.5%)</td><td>(-35.7%)</td><td>(-35.7%)</td><td>(-31.1%)</td><td>(-38.7%)</td><td>(-38.6%)</td><td>(-36.9%)</td><td>(-38.7%)</td><td>(-39.8%)</td><td>(-36.1%)</td></tr></table>
253
+
254
+ # 5.1.2 Ablation study
255
+
256
+ Table 4 presents the ablation study with the zero-shot MS-COCO benchmark dataset. The common default settings for the models N1–N7 involve the usage of fewer blocks in the down and up stages (Section 3.1.1) and the denoising task loss (Eq. 1). All the models are drawn at the 50K-th training iteration. We made the following observations.
257
+
258
+ N1 vs. N2. Importing the pretrained weights for initialization clearly improves the performance of block-removed SDMs. Transferring knowledge from well-trained models, a popularized practice in machine learning, is also beneficial for T2I generation with SDMs.
259
+
260
+ N2 vs. N3 vs. N4. Exploiting output-level KD (Eq. 2) effectively boosts the generation quality compared to using only the denoising task loss. Leveraging feature-level KD (Eq. 3) further improves the performance by offering sufficient guidance over multiple stages in the student.
261
+
262
+ N4 vs. N5. An increased batch size leads to a better IS and CLIP score but with a minor drop in FID. We opt for a batch size of 256 based on the premise that more samples per batch would enhance the model’s understanding ability.
263
+
264
+ 216 N6 and N7. Despite slight performance drop, the models N6 and N7 with the mid-stage removal
265
+ 217 have fewer parameters (0.66B) than N4 and N5 (0.76B), offering improved compute efficiency.
266
+
267
+ Table 4: Ablation study on zero-shot MS-COCO $2 5 6 \times 2 5 6$ 30K. The common settings include fewer blocks in the down and up stages and the denoising task loss. N5 and N7 correspond to BK-SDMBase and BK-SDM-Small, respectively
268
+
269
+ <table><tr><td colspan="6">Model</td><td colspan="3">Performance</td></tr><tr><td>No.</td><td>Initialize Weights</td><td>Output KD</td><td>Feature KD</td><td>Batch Size</td><td>Remove Mid</td><td>FID↓</td><td>IS↑</td><td>CLIP score↑</td></tr><tr><td>N1</td><td>Random</td><td>X</td><td>X</td><td>64</td><td>X</td><td>43.80</td><td>13.61</td><td>0.1622</td></tr><tr><td>N2</td><td>Pretrained</td><td></td><td>X</td><td>64</td><td>X</td><td>20.45</td><td>22.68</td><td>0.2444</td></tr><tr><td>N3</td><td>Pretrained</td><td>x√</td><td></td><td>64</td><td>X</td><td>16.48</td><td>27.30</td><td>0.2620</td></tr><tr><td>N4</td><td>Pretrained</td><td></td><td>x√</td><td>64</td><td>×</td><td>14.61</td><td>31.44</td><td>0.2826</td></tr><tr><td>N5</td><td>Pretrained</td><td>√</td><td>√</td><td>256</td><td>X</td><td>15.76</td><td>33.79</td><td>0.2878</td></tr><tr><td>N6</td><td>Pretrained</td><td></td><td>7</td><td>64</td><td></td><td>16.87</td><td>29.51</td><td>0.2644</td></tr><tr><td>N7</td><td>Pretrained</td><td>√</td><td>√</td><td>256</td><td>√</td><td>16.98</td><td>31.68</td><td>0.2677</td></tr><tr><td colspan="5">Original SDM-v1.4 [46, 47]</td><td></td><td>13.05</td><td>36.76</td><td>0.2958</td></tr></table>
270
+
271
+ ![](images/1667705cbdf28a65f2e8574b6fbf08f3803d9060e9473009910a5588b67823fa.jpg)
272
+ Figure 6: Results on zero-shot MS-COCO $2 5 6 \times 2 5 6$ 30K over training progress. For our models, the architecture size, usage of KD, and batch size are denoted.
273
+
274
+ ![](images/f605bbd107c1aef85a6af46f35f45461ce24a3c076af291bbc9bd225c7d32e77.jpg)
275
+ Figure 7: Effect of different classifier-free guidance scales on MS-COCO $5 1 2 { \times } 5 1 2 5 \mathrm { K }$ .
276
+
277
+ # 218 5.1.3 Impact of distillation on pretraining phase
278
+
279
+ 219 We further analyze the merits of transferred knowledge via distillation, with the models from the
280
+ 220 pretrained weight initialization. Figure 6 shows zero-shot T2I performance over training iterations.
281
+ 221 Compared to the absence of KD (indicated with green), distillation (purple and pink) accelerates the
282
+ 222 training process and leads to improved generation scores, demonstrating the benefits of providing
283
+ 223 sufficient hints for training guidance. Notably, our small-size model trained with KD (yellow)
284
+ 224 outperforms the bigger base-size model without KD (green). Additionally, while the best FID score
285
+ 225 is observed early on for our models, IS and CLIP score exhibit ongoing improvement, implying that
286
+ 226 judging models solely with FID may be suboptimal.
287
+
288
+ Figure 7 shows the trade-off curves from different classifier-free guidance scales [17, 51] $\{ 2 . 0 , 2 . 5 , 3 . 0 , 3 . 5 , 4 . 5 , 5 . 5 , 6 . 5 , 7 . 5 , 8 . 5 , 9 . 5 \}$ . For the analysis, we use 5K samples from the MSCOCO validation set and our base-size models from the 50K-th iteration. Higher guidance scales lead to better text-aligned images at the cost of less diversity. Compared to the baseline trained only with the denoising task loss, distillation-based pretraining leads to much better trade-off curves.
289
+
290
+ # 232 5.2 Personalized T2I with DreamBooth
291
+
292
+ Table 5 compares the results of DreamBooth finetuning [50] with different pretrained models. BKSDM-Small can preserve over $9 7 \%$ performance of the original SDM with the reduced finetuning time and number of parameters. Figure 8 depicts that our models can accurately capture the subject details and generate various scenes. Over the models pretrained with a batch size of 64, we observe the impact of KD pretraining on personalized synthesis. The baselines without KD fail to generate the subjects entirely or cannot maintain the identity details.
293
+
294
+ Table 5: Personalized generation with finetuning over different pretrained models. Our compact models can preserve subject fidelity (DINO and CLIP-I) and prompt fidelity (CLIP-T) of the original SDM with reduced finetuning (FT) time and fewer parameters.
295
+
296
+ <table><tr><td>Pretrained Model</td><td>DINO ↑</td><td>CLIP-I↑</td><td>CLIP-T↑</td><td>FT Time†</td><td>#Params</td></tr><tr><td>SDM-v1.4 [46, 47]</td><td>0.728</td><td>0.725</td><td>0.263</td><td>881.3s</td><td>1.04B</td></tr><tr><td>BK-SDM-Base (Ours) BK-SDM-Small (Ours)</td><td>0.723 0.720</td><td>0.717 0.705</td><td>0.260 0.259</td><td>622.3s 603.6s</td><td>0.76B 0.66B</td></tr><tr><td>BK-SDM-Base,Batch Size 64 - Without KD &amp; Random Init. - Without KD &amp; Pretrained Init.</td><td>0.718 0.594</td><td>0.708 0.465</td><td>0.262 0.191 0.258</td><td>622.3s 622.3s</td><td>0.76B 0.76B</td></tr></table>
297
+
298
+ † Per-subject finetuning time for 800 iterations on NVIDIA GeForce RTX 3090 GPU.
299
+
300
+ ![](images/1829a69d94723bc45a8e80c8a1d0a2e5f8a053451406fe17f4e60d4916051d67.jpg)
301
+ Figure 8: Visual results of personalized generation. Each subject is marked as “a [identifier] [class noun]” (e.g., “a [V] dog"). Similar to the original SDM, our compact models can synthesize the images of input subjects in different backgrounds while preserving their appearance.
302
+
303
+ # 239 6 Conclusion and discussion
304
+
305
+ This study uncovers the potential of architectural compression for general-purpose text-to-image synthesis with a renowned model, Stable Diffusion. Our block-removed lightweight models are effective for zero-shot generation, achieving competitive performance against large-scale baselines. Distillation is a key aspect of our method, leading to effective pretraining even under very constrained resources. Moreover, our smaller and faster pretrained models are successfully applied in personalized generation. Our work is orthogonal to previous directions for efficient diffusion models, e.g., enabling fewer sampling steps, and can be readily combined with them. We hope our study can facilitate future research on structural compression of large diffusion models.
306
+
307
+ Limitations and future works. Our compact models inherit the capability of the source model for high-fidelity image generation, but they have shortcomings such as inaccurate generation of full-body human appearance. While we show that distillation pretraining is powerful even with very limited resources, increasing the volume of data and analyzing its effects would be promising.
308
+
309
+ Negative social impacts. Because recent large generative models are capable of creating high-quality plausible content, they also involve potential risks of malicious use. To avoid causing unintended social bias, researchers should take steps to ensure the appropriateness of training data. Moreover, the release of resulting models should be accompanied by strong and reliable safeguards.
310
+
311
+ # References
312
+
313
+ High-resolution video synthesis with latent diffusion models. In CVPR, 2023. [2] T. Brooks, A. Holynski, and A. A. Efros. Instructpix2pix: Learning to follow image editing instructions. In CVPR, 2023. [3] M. Caron, H. Touvron, I. Misra, H. Jégou, J. Mairal, P. Bojanowski, and A. Joulin. Emerging properties in self-supervised vision transformers. In ICCV, 2021.
314
+ [4] Y.-H. Chen, R. Sarokin, J. Lee, J. Tang, C.-L. Chang, A. Kulik, and M. Grundmann. Speed is all you need: On-device acceleration of large diffusion models via gpu-aware optimizations. In CVPR Workshop, 2023. [5] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019. [6] P. Dhariwal and A. Nichol. Diffusion models beat gans on image synthesis. In NeurIPS, 2021. [7] M. Ding, Z. Yang, W. Hong, W. Zheng, C. Zhou, D. Yin, J. Lin, X. Zou, Z. Shao, H. Yang, et al. Cogview: Mastering text-to-image generation via transformers. In NeurIPS, 2021. [8] M. Ding, W. Zheng, W. Hong, and J. Tang. Cogview2: Faster and better text-to-image generation via hierarchical transformers. In NeurIPS, 2022. [9] P. Esser, R. Rombach, and B. Ommer. Taming transformers for high-resolution image synthesis. In CVPR, 2021.
315
+ [10] O. Gafni, A. Polyak, O. Ashual, S. Sheynin, D. Parikh, and Y. Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. In ECCV, 2022.
316
+ [11] Z. Hao, J. Guo, D. Jia, K. Han, Y. Tang, C. Zhang, H. Hu, and Y. Wang. Learning efficient vision transformers via fine-grained manifold distillation. In NeurIPS, 2022.
317
+ [12] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016.
318
+ [13] B. Heo, J. Kim, S. Yun, H. Park, N. Kwak, and J. Y. Choi. A comprehensive overhaul of feature distillation. In ICCV, 2019.
319
+ [14] J. Hessel, A. Holtzman, M. Forbes, R. Le Bras, and Y. Choi. CLIPScore: A reference-free evaluation metric for image captioning. In EMNLP, 2021.
320
+ [15] M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler, and S. Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In NeurIPS, 2017.
321
+ [16] G. Hinton, O. Vinyals, and J. Dean. Distilling the knowledge in a neural network. In NeurIPS Workshop, 2014.
322
+ [17] J. Ho and T. Salimans. Classifier-free diffusion guidance. In NeurIPS Workshop, 2021.
323
+ [18] J. Ho, A. Jain, and P. Abbeel. Denoising diffusion probabilistic models. In NeurIPS, 2020.
324
+ [19] J. Hou and Z. Asghar. World’s first on-device demonstration of stable diffusion on an android phone. https://www.qualcomm.com/news, 2023.
325
+ [20] A. Jaegle, F. Gimeno, A. Brock, O. Vinyals, A. Zisserman, and J. Carreira. Perceiver: General perception with iterative attention. In ICML, 2021.
326
+ [21] X. Jiao, Y. Yin, L. Shang, X. Jiang, X. Chen, L. Li, F. Wang, and Q. Liu. Tinybert: Distilling bert for natural language understanding. In Findings of EMNLP, 2020.
327
+ [22] Q. Jin, J. Ren, O. J. Woodford, J. Wang, G. Yuan, Y. Wang, and S. Tulyakov. Teachers do more than teach: Compressing image-to-image models. In CVPR, 2021.
328
+ [23] B. Kawar, S. Zada, O. Lang, O. Tov, H. Chang, T. Dekel, I. Mosseri, and M. Irani. Imagic: Text-based real image editing with diffusion models. In CVPR, 2023.
329
+ [24] B.-K. Kim, S. Choi, and H. Park. Cut inner layers: A structured pruning strategy for efficient u-net gans. In ICML Workshop, 2022.
330
+
331
+ 302 diffusion. In CVPR, 2023.
332
+ 303 [26] H. Li, A. Kadav, I. Durdanovic, H. Samet, and H. P. Graf. Pruning filters for efficient convnets. In ICLR,
333
+ 304 2017.
334
+ 305 [27] M. Li, J. Lin, Y. Ding, Z. Liu, J.-Y. Zhu, and S. Han. Gan compression: Efficient architectures for
335
+ 306 interactive conditional gans. In CVPR, 2020.
336
+ 307 [28] X. Li, L. Lian, Y. Liu, H. Yang, Z. Dong, D. Kang, S. Zhang, and K. Keutzer. Q-diffusion: Quantizing
337
+ 308 diffusion models. arXiv preprint arXiv:2302.04304, 2023.
338
+ 309 [29] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft
339
+ 310 coco: Common objects in context. In ECCV, 2014.
340
+ 311 [30] L. Liu, Y. Ren, Z. Lin, and Z. Zhao. Pseudo numerical methods for diffusion models on manifolds. In
341
+ 312 ICLR, 2022.
342
+ 313 [31] Y. Liu, Z. Shu, Y. Li, Z. Lin, F. Perazzi, and S.-Y. Kung. Content-aware gan compression. In CVPR, 2021.
343
+ 314 [32] C. Lu, Y. Zhou, F. Bao, J. Chen, C. Li, and J. Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic
344
+ 315 model sampling in around 10 steps. In NeurIPS, 2022.
345
+ 316 [33] C. Lu, Y. Zhou, F. Bao, J. Chen, C. Li, and J. Zhu. Dpm-solver $^ { + + }$ : Fast solver for guided sampling of
346
+ 317 diffusion probabilistic models. arXiv preprint arXiv:2211.01095, 2022.
347
+ 318 [34] C. Meng, R. Gao, D. P. Kingma, S. Ermon, J. Ho, and T. Salimans. On distillation of guided diffusion
348
+ 319 models. In NeurIPS Workshop, 2022.
349
+ 320 [35] C. Meng, R. Gao, D. P. Kingma, S. Ermon, J. Ho, and T. Salimans. On distillation of guided diffusion
350
+ 321 models. In CVPR, 2023.
351
+ 322 [36] S. Mo, M. Cho, and J. Shin. Freeze the discriminator: a simple baseline for fine-tuning gans. In CVPR
352
+ 323 Workshop, 2020.
353
+ 324 [37] C. Mou, X. Wang, L. Xie, J. Zhang, Z. Qi, Y. Shan, and X. Qie. T2i-adapter: Learning adapters to dig out
354
+ 325 more controllable ability for text-to-image diffusion models. arXiv preprint arXiv:2302.08453, 2023.
355
+ 326 [38] A. Nichol, P. Dhariwal, A. Ramesh, P. Shyam, P. Mishkin, B. McGrew, I. Sutskever, and M. Chen. Glide:
356
+ 327 Towards photorealistic image generation and editing with text-guided diffusion models. In ICML, 2022.
357
+ 328 [39] W. Park, D. Kim, Y. Lu, and M. Cho. Relational knowledge distillation. In CVPR, 2019.
358
+ 329 [40] J. Pinkney. Small stable diffusion. https://huggingface.co/OFA-Sys/
359
+ 330 small-stable-diffusion-v0, 2023.
360
+ 331 [41] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, I. Sutskever, et al. Language models are unsupervised
361
+ 332 multitask learners. OpenAI blog, 2019.
362
+ 333 [42] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin,
363
+ 334 J. Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
364
+ 335 [43] A. Ramesh, M. Pavlov, G. Goh, S. Gray, C. Voss, A. Radford, M. Chen, and I. Sutskever. Zero-shot
365
+ 336 text-to-image generation. In ICML, 2020.
366
+ 337 [44] A. Ramesh, P. Dhariwal, A. Nichol, C. Chu, and M. Chen. Hierarchical text-conditional image generation
367
+ 338 with clip latents. arXiv preprint arXiv:2204.06125, 2022.
368
+ 339 [45] Y. Ren, J. Wu, X. Xiao, and J. Yang. Online multi-granularity distillation for gan compression. In ICCV,
369
+ 340 2021.
370
+ 341 [46] R. Rombach and P. Esser. Stable diffusion v1-4. https://huggingface.co/CompVis/
371
+ 342 stable-diffusion-v1-4, 2022.
372
+ 343 [47] R. Rombach, A. Blattmann, D. Lorenz, P. Esser, and B. Ommer. High-resolution image synthesis with
373
+ 344 latent diffusion models. In CVPR, 2022.
374
+ 345 [48] A. Romero, N. Ballas, S. E. Kahou, A. Chassang, C. Gatta, and Y. Bengio. Fitnets: Hints for thin deep
375
+ 346 nets. In ICLR, 2015.
376
+ 347 [49] O. Ronneberger, P. Fischer, and T. Brox. U-net: Convolutional networks for biomedical image segmentation.
377
+ 348 In MICCAI, 2015.
378
+ 349 [50] N. Ruiz, Y. Li, V. Jampani, Y. Pritch, M. Rubinstein, and K. Aberman. Dreambooth: Fine tuning
379
+ 350 text-to-image diffusion models for subject-driven generation. In CVPR, 2023.
380
+ 351 [51] C. Saharia, W. Chan, S. Saxena, L. Li, J. Whang, E. L. Denton, K. Ghasemipour, R. Gontijo Lopes,
381
+ 352 B. Karagol Ayan, T. Salimans, et al. Photorealistic text-to-image diffusion models with deep language
382
+ 353 understanding. In NeurIPS, 2022.
383
+ 354 [52] T. Salimans and J. Ho. Progressive distillation for fast sampling of diffusion models. In ICLR, 2022.
384
+ 355 [53] T. Salimans, I. Goodfellow, W. Zaremba, V. Cheung, A. Radford, and X. Chen. Improved techniques for
385
+ 356 training gans. In NeurIPS, 2016.
386
+ 357 [54] V. Sanh, L. Debut, J. Chaumond, and T. Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper
387
+ 358 and lighter. In NeurIPS Workshop, 2019.
388
+ 359 [55] C. Schuhmann and R. Beaumont. Laion-aesthetics. https://laion.ai/blog/laion-aesthetics,
389
+ 360 2022.
390
+ 361 [56] C. Schuhmann, R. Beaumont, R. Vencu, C. Gordon, R. Wightman, M. Cherti, T. Coombes, A. Katta,
391
+ 362 C. Mullis, M. Wortsman, et al. Laion-5b: An open large-scale dataset for training next generation
392
+ 363 image-text models. In NeurIPS Workshop, 2022.
393
+ 364 [57] H. Shen, P. Cheng, X. Ye, W. Cheng, and H. Abidi. Accelerate stable diffusion with intel neural compressor.
394
+ 365 https://medium.com/intel-analytics-software, 2022.
395
+ 366 [58] C. Shu, Y. Liu, J. Gao, Z. Yan, and C. Shen. Channel-wise knowledge distillation for dense prediction. In
396
+ 367 ICCV, 2021.
397
+ 368 [59] J. Song, C. Meng, and S. Ermon. Denoising diffusion implicit models. In ICLR, 2021.
398
+ 369 [60] L. D. Y. B. S. P. Sourab Mangrulkar, Sylvain Gugger. Peft: State-of-the-art parameter-efficient fine-tuning
399
+ 370 methods. https://github.com/huggingface/peft, 2022.
400
+ 371 [61] Z. Sun, H. Yu, X. Song, R. Liu, Y. Yang, and D. Zhou. Mobilebert: a compact task-agnostic bert for
401
+ 372 resource-limited devices. In ACL, 2020.
402
+ 373 [62] M. Tao, B.-K. Bao, H. Tang, and C. Xu. Galip: Generative adversarial clips for text-to-image synthesis. In
403
+ 374 CVPR, 2023.
404
+ 375 [63] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jegou. Training data-efficient image
405
+ 376 transformers amp; distillation through attention. In ICML, 2021.
406
+ 377 [64] A. Van Den Oord, O. Vinyals, et al. Neural discrete representation learning. In NeurIPS, 2017.
407
+ 378 [65] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin.
408
+ 379 Attention is all you need. In NeurIPS, 2017.
409
+ 380 [66] P. von Platen, S. Patil, A. Lozhkov, P. Cuenca, N. Lambert, K. Rasul, M. Davaadorj, and T. Wolf. Diffusers:
410
+ 381 State-of-the-art diffusion models. https://github.com/huggingface/diffusers, 2022.
411
+ 382 [67] H. Wang, X. Du, J. Li, R. A. Yeh, and G. Shakhnarovich. Score jacobian chaining: Lifting pretrained 2d
412
+ 383 diffusion models for 3d generation. In CVPR, 2023.
413
+ 384 [68] J. Z. Wu, Y. Ge, X. Wang, W. Lei, Y. Gu, W. Hsu, Y. Shan, X. Qie, and M. Z. Shou. Tune-a-video: One-shot
414
+ 385 tuning of image diffusion models for text-to-video generation. arXiv preprint arXiv:2212.11565, 2022.
415
+ 386 [69] Z. Xie, L. Zhu, L. Zhao, B. Tao, L. Liu, and W. Tao. Localization-aware channel pruning for object
416
+ 387 detection. Neurocomputing, 403:400–408, 2020.
417
+ 388 [70] S. Zagoruyko and N. Komodakis. Paying more attention to attention: Improving the performance of
418
+ 389 convolutional neural networks via attention transfer. In ICLR, 2017.
419
+ 390 [71] L. Zhang and M. Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint
420
+ 391 arXiv:2302.05543, 2023.
421
+ 392 [72] L. Zhang, X. Chen, X. Tu, P. Wan, N. Xu, and K. Ma. Wavelet knowledge distillation: Towards efficient
422
+ 393 image-to-image translation. In CVPR, 2022.
423
+ 94 [73] Q. Zhang and Y. Chen. Fast sampling of diffusion models with exponential integrator. In ICLR, 2023.
424
+ 95 [74] Y. Zhou, R. Zhang, C. Chen, C. Li, C. Tensmeyer, T. Yu, J. Gu, J. Xu, and T. Sun. Towards language-free
425
+ 96 training for text-to-image generation. In CVPR, 2022.
426
+ 97 [75] L. Zhu. Thop: Pytorch-opcounter. https://github.com/Lyken17/pytorch-OpCounter, 2018.
md/dev/C54V-xTWfi/C54V-xTWfi.md ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MONODISTILL: LEARNING SPATIAL FEATURES FOR MONOCULAR 3D OBJECT DETECTION
2
+
3
+ Zhiyu Chong∗1, Xinzhu $\mathbf { M _ { a } } { ^ { * 2 } }$ , Hong Zhang1, Yuxin Yue1, Haojie $\mathbf { L i } ^ { 1 }$ , Zhihui Wang1, and Wanli Ouyang2
4
+
5
+ 1Dalian University of Technology 2The University of Sydney {czydlut, jingshui, 22017036}@mail.dlut.edu.cn {xinzhu.ma, wanli.ouyang}@sydney.edu.au {hjli, zhwang}@dlut.edu.cn
6
+
7
+ # ABSTRACT
8
+
9
+ 3D object detection is a fundamental and challenging task for 3D scene understanding, and the monocular-based methods can serve as an economical alternative to the stereo-based or LiDAR-based methods. However, accurately detecting objects in the 3D space from a single image is extremely difficult due to the lack of spatial cues. To mitigate this issue, we propose a simple and effective scheme to introduce the spatial information from LiDAR signals to the monocular 3D detectors, without introducing any extra cost in the inference phase. In particular, we first project the LiDAR signals into the image plane and align them with the RGB images. After that, we use the resulting data to train a 3D detector (LiDAR Net) with the same architecture as the baseline model. Finally, this LiDAR Net can serve as the teacher to transfer the learned knowledge to the baseline model. Experimental results show that the proposed method can significantly boost the performance of the baseline model and ranks the $1 ^ { s t }$ place among all monocularbased methods on the KITTI benchmark. Besides, extensive ablation studies are conducted, which further prove the effectiveness of each part of our designs and illustrate what the baseline model has learned from the LiDAR Net. Our code will be released at https://github.com/monster-ghost/MonoDistill.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ 3D object detection is an indispensable component for 3D scene perception, which has wide applications in the real world, such as autonomous driving and robotic navigation. Although the algorithms with stereo (Li et al., 2019b; Wang et al., 2019; Chen et al., 2020a) or LiDAR sensors (Qi et al., 2018; Shi et al., 2019; 2020) show promising performances, the heavy dependence on the expensive equipment restricts the application of these algorithms. Accordingly, the methods based on the cheaper and more easy-to-deploy monocular cameras (Xu & Chen, 2018; Ma et al., 2019; 2021; Brazil & Liu, 2019; Ding et al., 2020) show great potentials and have attracted lots of attention.
14
+
15
+ As shown in Figure 1 (a), some prior works (Brazil & Liu, 2019; Simonelli et al., 2019; Chen et al., 2020b) directly estimate the 3D bounding boxes from monocular images. However, because of the lack of depth cues, it is extremely hard to accurately detect the objects in the 3D space, and the localization error is the major issue of these methods (Ma et al., 2021). To mitigate this problem, an intuitive idea is to estimate the depth maps from RGB images, and then use them to augment the input data (Figure 1 (b)) (Xu & Chen, 2018; Ding et al., 2020) or directly use them as the input data (Figure 1 (c)) (Wang et al., 2019; Ma et al., 2019). Although these two strategies have made significant improvement in performance, the drawbacks of them can not be ignored: (1) These methods generally use an off-the-shelf depth estimator to generate the depth maps, which introduce lots of computational cost (e.g. the most commonly used depth estimator (Fu et al., 2018) need about $4 0 0 \mathrm { m s }$ to process a standard KITTI image). (2) The depth estimator and detector are trained separately, which may lead to a sub-optimal optimization. Recently, Reading et al. (2021) propose an end-to-end framework (Figure 1 (d)) for monocular 3D detection, which can also leverage depth estimator to provide depth cues. Specifically, they introduce a sub-network to estimate the depth distribution and use it to enrich the RGB features. Although this model can be trained end-to-end and achieves better performance, it still suffer from the low inference speed (630ms per image), mainly caused by the depth estimator and the complicated network architecture. Note that the welldesigned monocular detectors, like Ma et al. (2021); Zhang et al. (2021b); Lu et al. (2021), only take about $4 0 \mathrm { m s }$ per image.
16
+
17
+ ![](images/3fa330cfff050e5dc2ed89024e93f34bd6cce756c45abec7b51ede2082a6377c.jpg)
18
+ Figure 1: Comparison on the high-level paradigms of monocular 3D detectors.
19
+
20
+ In this paper, we aim to introduce the depth cues to the monocular 3D detectors without introducing any extra cost in the inference phase. Inspired by the knowledge distillation (Hinton et al.), which can transfer the learned knowledge from a well-trained CNN to another one without any changes in the model design, we propose that the spatial cues may also be transferred by this way from the LiDAR-based models. However, the main problem for this proposal is the difference of the feature representations used in these two kinds of methods (2D images features vs. 3D voxel features). To bridge this gap, we propose to project the LiDAR signals into the image plane and use the 2D CNN, instead of the commonly used 3D CNN or point-wise CNN, to train a ‘image-version’ LiDAR-based model. After this alignment, the knowledge distillation can be friendly applied to enrich the features of our monocular detector.
21
+
22
+ Based on the above-mentioned motivation and strategy, we propose the distillation based monocular 3D detector (MonoDistill): We first train a teacher net using the projected LiDAR maps (used as the ground truths of the depth estimator in previous works), and then train our monocular 3D detector under the guidance of the teacher net. We argue that, compared with previous works, the proposed method has the following two advantages: First, our method directly learn the spatial cues from the teacher net, instead of the estimated depth maps. This design performs better by avoiding the information loss in the proxy task. Second, our method does not change the network architecture of the baseline model, and thus no extra computational cost is introduced.
23
+
24
+ Experimental results on the most commonly used KITTI benchmark, where we rank the $1 ^ { s t }$ place among all monocular based models by applying the proposed method on a simple baseline, demonstrate the effectiveness of our approach. Besides, we also conduct extensive ablation studies to present each design of our method in detail. More importantly, these experiments clearly illustrate the improvements are achieved by the introduction of spatial cues, instead of other unaccountable factors in CNN.
25
+
26
+ # 2 RELATED WORKS
27
+
28
+ 3D detection from only monocular images. 3D detection from only monocular image data is challenging due to the lack of reliable depth information. To alleviate this problem, lots of scholars propose their solutions in different ways, including but not limited to network design (Roddick et al., 2019; Brazil & Liu, 2019; Zhou et al., 2019; Liu et al., 2020; Luo et al., 2021), loss formulation (Simonelli et al., 2019; Ma et al., 2021), 3D prior (Brazil & Liu, 2019), geometric constraint (Mousavian et al., 2017; Qin et al., 2019; Li et al., 2019a; Chen et al., 2020b), or perspective modeling (Zhang et al., 2021a; Lu et al., 2021; Shi et al., 2021).
29
+
30
+ Depth augmented monocular 3D detection. To provide the depth information to the 3D detectors, several works choose to estimate the depth maps from RGB images. According to the usage of the estimated depth maps, these methods can be briefly divided into three categories. The first class of these methods use the estimated depth maps to augment the RGB images (Figure 1 (b)). In particular, Xu & Chen (2018) propose three fusion strategies of the RGB images and depth maps, while Ding et al. (2020) and Wang et al. (2021a) focus on how to enrich the RGB features with depth maps in the latent feature space. Besides, Wang et al. (2019); Ma et al. (2019) propose another pipeline (Figure 1 (c)): They back-project the depth maps into the 3D space, and then train a LiDAR-based model and use the resulting data (pseudo-LiDAR signal) to predict the 3D boxes. This framework shows promising performance, and lots of works (Weng & Kitani, 2019; Cai et al., 2020; Wang et al., 2020a; Chu et al., 2021) are built on this solid foundation. Recently, Reading et al. (2021) propose another way to leverage the depth cues for monocular 3D detection (Figure 1 (d)). Particularly, they first estimate the depth distribution using a sub-network, and then use it to lift the 2D features into 3D features, which is used to generate the final results. Compared with the previous two families, this model can be trained in the end-to-end manner, avoiding the sub-optimal optimization. However, a common disadvantage of these methods is that they inevitably increase the computational cost while introducing depth information. Unlike these methods, our model chooses to learn the feature representation under the guidance of depth maps, instead of integrating them. Accordingly, the proposed model not only introduces rich depth cues but also maintains high efficiency.
31
+
32
+ ![](images/5dde672b08f0974af574d0d2d4a04bd72aaacc58bf342a1fc846bdc6022a2a76.jpg)
33
+ Figure 2: Visualization of the sparse LiDAR maps (left) and the dense LiDAR maps (right).
34
+
35
+ Knowledge distillation. Knowledge distillation (KD) is initially proposed by Hinton et al. for model compression, and the main idea of this mechanism is transferring the learned knowledge from large CNN models to the small one. This strategy has been proved in many computer vision tasks, such as 2D object detection (Dai et al., 2021; Chen et al., 2017; Gupta et al., 2016), semantic semantic segmentation (Hou et al., 2020; Liu et al., 2019). However, few work explore it in monocular 3D detection. In this work, we design a KD-based paradigm to efficiently introduce depth cues for monocular 3D detectors.
36
+
37
+ LIGA Stereo. We found a recent work LIGA Stereo (Guo et al., 2021) (submitted to arXiv on 18 Aug. 2021) discusses the application of KD for stereo 3D detection under the guidance of LiDAR signals. Here we discuss the main differences of LIGA Stereo and our work. First, the tasks and underlying data are different (monocular vs. stereo), which leads to different conclusions. For example, Guo et al. (2021) concludes that using the predictions of teacher net as ‘soft label’ can not bring benefits. However, our experimental results show the effectiveness of this design. Even more, in our task, supervising the student net in the result space is more effective than feature space. Second, they use an off-the-shelf LiDAR-based model to provide guidance to their model. However, we project the LiDAR signals into image plane and use the resulting data to train the teacher net. Except for the input data, the teacher net and student net are completely aligned, including network architecture, hyper-parameters, and training schedule. Third, to ensure the consistent shape of features, LIGA Stereo need to generate the cost volume from stereo images, which is time-consuming (it need about $3 5 0 \mathrm { m s }$ to estimate 3D boxes from a KITTI image) and hard to achieve for monocular images. In contrast, our method align the feature representations by adjusting the LiDAR-based model, instead of the target model. This design makes our method more efficient (about $3 5 \mathrm { m s }$ per image) and can generalize to all kinds of image-based models in theory.
38
+
39
+ # 3 METHOD
40
+
41
+ # 3.1 OVERVIEW
42
+
43
+ Figure 3 presents the framework of the proposed MonoDistill, which mainly has three components: a monocular 3D detector, an aligned LiDAR-based detector, and several side branches which build
44
+
45
+ ![](images/21d6ed0b66761b9e1a051bfa6abcdee0ef3180df8a9a46cb1f79def5f9635a05.jpg)
46
+ Figure 3: Illustration of the proposed MonoDistill. We first generate the ‘image-like’ LiDAR maps from the LiDAR signals and then train a teacher model using an identical network to the student model. Finally, we propose three distillation schemes to train the student model under the guidance of the well-trained teacher net. In the inference phase, only the student net is used.
47
+
48
+ the bridge to provide guidance from the LiDAR-based detector to our monocular 3D detector. We will introduce the how to build these parts one by one in the rest of this section.
49
+
50
+ # 3.2 BASELINE MODEL
51
+
52
+ Student model. We use the one-stage monocular 3D detector MonoDLE (Ma et al., 2021) as our baseline model. Particularly, this baseline model adopts DLA-34 (Yu et al., 2017) as the backbone and uses several parallel heads to predict the required items for 3D object detection. Due to this clean and compact design, this model achieves good performance with high efficiency. Besides, we further normalize the confidence of each predicted object using the estimated depth uncertainty (see Appendix A.1 for more details), which brings about 1 AP improvement
53
+
54
+ Teacher model. Existing LiDAR-based models are mainly based on the 3D CNN or point-wise CNN. To align the gap between the feature representations of the monocular detector and the LiDAR-based detector, we project the LiDAR points into the image plane to generate the sparse depth map. Further, we also use the interpolation algorithm (Ku et al., 2018) to generate the dense depth, and see Figure 2 for the visualization of generated data. Then, we use these ‘image-like LiDAR maps’ to train a LiDAR-based detector using the identical network with our student model.
55
+
56
+ # 3.3 MONODISTILL
57
+
58
+ In order to transfer the spatial cues from the well-trained teacher model to the student model, we design three complementary distillation schemes to provide additional guidance to the baseline model.
59
+
60
+ Scene-level distillation in the feature space. First, we think directly enforcing the image-based model learns the feature representations of the LiDAR-based models is sub-optimal, caused by the different modalities. The scene level knowledge can help the monocular 3D detectors build a highlevel understanding for the given image by encoding the relative relations of the features, keeping the knowledge structure and alleviating the modality gap. Therefore, we train our student model under the guidance of the high-level semantic features provided by the backbone of the teacher model. To better model the structured cues, we choose to learn the affinity map (Hou et al., 2020) of high-level features, instead of the features themselves. Specifically, we first generate the affinity map, which encodes the similarity of each feature vector pair, for both the teacher and student network, and each element $\mathrm { A } _ { \mathrm { i , j } }$ in this affinity map can be computed by:
61
+
62
+ $$
63
+ \mathrm { { A } _ { i , j } = \frac { \mathbf { f _ { i } ^ { T } } \mathbf { f _ { j } } } { | | \mathbf { f _ { i } } | | _ { 2 } \cdot | | \mathbf { f _ { j } } | | _ { 2 } } , }
64
+ $$
65
+
66
+ where $\mathbf { f _ { j } }$ and $\mathbf { f _ { j } }$ denote the $\mathbf { i } ^ { t h }$ and $\mathbf { j } ^ { t h }$ feature vector. After that, we use the L1 norm to enforce the student net to learn the structured information from the teacher net:
67
+
68
+ $$
69
+ \mathcal { L } _ { \mathbf { s f } } = \frac { 1 } { \mathrm { K } \times \mathrm { K } } \sum _ { i = 1 } ^ { K } \sum _ { j = 1 } ^ { K } | | \mathrm { A } _ { \mathbf { i } , \mathbf { j } } ^ { \mathbf { t } } - \mathrm { A } _ { \mathbf { i } , \mathbf { j } } ^ { \mathbf { s } } | | _ { 1 } ,
70
+ $$
71
+
72
+ where K is the number of the feature vectors. Note the computational/storage complexity is quadratically related to K. To reduce the cost, we group all features into several local regions and generate the affinity map using the features of local regions. This makes the training of the proposed model more efficient, and we did not observe any performance drop caused by this strategy.
73
+
74
+ Object-level distillation in the feature space. Second, except for the affinity map, directly using the features from teacher net as guidance may also provide valuable cues to the student. However, there is much noise in feature maps, since the background occupies most of the area and is less informative. Distilling knowledge from these regions may make the network deviate from the right optimization direction. To make the knowledge distillation more focused, limiting the distillation area is necessary. Particularly, the regions in the ground-truth 2D bounding boxes are used for knowledge transfer to mitigate the effects of noise. Specifically, given the feature maps of the teacher model and student model $\{ \mathbf { F ^ { t } } , \mathbf { F ^ { s } } \}$ , our second distillation loss can be formulated as.
75
+
76
+ $$
77
+ \mathcal { L } _ { \mathbf { o f } } = \frac { 1 } { \mathrm { N } _ { \mathrm { p o s } } } | | \mathrm { M } _ { \mathbf { o f } } ( \mathrm { F } _ { \mathbf { s } } - \mathrm { F } _ { \mathbf { t } } ) | | _ { 2 } ^ { 2 } ,
78
+ $$
79
+
80
+ where $\mathrm { M _ { o f } }$ is the mask generated from the center point and the size of 2D bounding box and $\mathrm { N _ { p o s } }$ is the number of valid feature vectors.
81
+
82
+ Object-level distillation in the result space. Third, similar to the traditional KD, we use the predictions from the teacher net as extra ‘soft label’ for the student net. Note that in this scheme, only the predictions on the foreground region should be used, because the predictions on the background region are usually false detection. As for the definition of the ‘foreground regions’, inspired by CenterNet (Zhou et al., 2019), a simple baseline is regarding the center point as the foreground region. Furtherly, we find that the quality of the predicted value of the teacher net near the center point is good enough to guide the student net. Therefore, we generate a Gaussian-like mask (Tian et al., 2019; Wang et al., 2021b) based on the position of the center point and the size of 2D bounding box and the pixels whose response values surpass a predefined threshold are sampled, and then we train these samples with equal weights (see Figure 4 for the visualization). After that, our third distillation loss can be formulated as:
83
+
84
+ $$
85
+ \mathcal { L } _ { \mathbf { o r } } = \sum _ { k = 1 } ^ { N } | | \mathbf { M _ { o r } ( y _ { k } ^ { s } - y _ { k } ^ { t } ) } | | _ { 1 } ,
86
+ $$
87
+
88
+ where $\mathrm { M } _ { \mathbf { o r } }$ is the mask which represents positive and negative samples, $\mathbf { y _ { k } }$ is the output of the $k ^ { t h }$ detection head and $N$ is the number of detection heads.
89
+
90
+ Additional strategies. We further propose some strategies for our method. First, for the distillation schemes in the feature space (i.e. $\mathcal { L } _ { \mathrm { s f } }$ and $\mathcal { L } _ { \mathbf { o f } } ^ { \mathrm { ~ ~ } }$ ), we only perform them on the last three blocks of the backbone. The main motivation of this strategy is: The first block usually is rich in the low-level features (such as edges, textures, etc.). The expression forms of the low-level features for LiDAR and image data may be completely different, and enforcing the student net to learn these features in a modality-across manner may mislead it. Second, in order to better guide the student to learn spatial-aware feature representations, we apply the attention based fusion module (FF in Table 1) proposed by Chen et al. (2021b) in our distillation schemes in the feature space ( i.e. $\mathcal { L } _ { \mathrm { s f } }$ and $\mathcal { L } _ { \mathbf { o f } }$ ).
91
+
92
+ Loss function. We train our model in an end-to-end manner using the following loss function:
93
+
94
+ $$
95
+ { \mathcal { L } } = { \mathcal { L } } _ { \mathbf { s r c } } + \lambda _ { 1 } \cdot { \mathcal { L } } _ { \mathbf { s f } } + \lambda _ { 2 } \cdot { \mathcal { L } } _ { \mathbf { o f } } + \lambda _ { 3 } \cdot { \mathcal { L } } _ { \mathbf { o r } } ,
96
+ $$
97
+
98
+ where $\mathcal { L } _ { \mathrm { s r c } }$ denotes the loss function used in the MonoDLE (Ma et al., 2021). $\lambda _ { 1 } , \lambda _ { 2 } , \lambda _ { 3 }$ are the hyper-parameters to balance each loss. For the teacher net, only $\mathcal { L } _ { \mathrm { s r c } }$ is adopted.
99
+
100
+ ![](images/f461b5ed95d7a231a3d707af2b5eec44ac7197d01ed736d51fa6c546069e9f8a.jpg)
101
+ Figure 4: Left: Regard the center point as the foreground region. Right: Generate foreground region from the center point and the size of bounding box. Besides, the 2D bounding boxes are used as the foreground region for $\mathcal { L } _ { \mathbf { o f } }$ .
102
+
103
+ # 4 EXPERIMENTS
104
+
105
+ # 4.1 SETUP
106
+
107
+ Dataset and metrics. We conduct our experiments on the KITTI (Geiger et al., 2012), which is most commonly used dataset in 3D detection task. Specifically, this dataset provides 7,481 training samples and 7,518 testing samples, and we further divide the training data into a train set (3,712 samples) and a validation set (3,769 samples), following prior works (Chen et al., 2015). Both 3D detection and Bird’s Eye View (BEV) detection are evaluated using $\mathrm { { A P } | _ { R _ { 4 0 } } }$ (Simonelli et al., 2019) as metric. We report our final results on the testing set, while the ablation studies are conducted on the validation set. Besides, we mainly focus on the Car category, while also present the performances of Pedestrian and Cyclist in Appendix A.2 for reference.
108
+
109
+ Implementation. We provide the implementation details in Appendix A.1. Besides, our code will be open-sourced for the reproducibility.
110
+
111
+ # 4.2 MAIN RESULTS
112
+
113
+ Ablation studies. Table 1 shows the ablation studies of the proposed methods. Specifically, we found that all three distillation schemes can improve the accuracy of the baseline model, and the improvements of them are complementary. Besides, the feature fusion strategy can also boost the accuracy. Compared with the baseline, our full model improves 3D detection performance by 3.34, 5.02, 2.98 and improve BEV performance by 5.16, 6.62, 3.87 on the moderate, easy and hard settings respectively.
114
+
115
+ Table 1: Ablation studies on the KITTI validation set. SF, OF, and OR denote the scene-level distillation in feature space, the object-level distillation in feature space, and the object-level distillation in result space, respectively. Besides, FF means the attention based feature fusion strategy.
116
+
117
+ <table><tr><td rowspan="3"></td><td rowspan="3">SF</td><td rowspan="3">OF</td><td rowspan="3">OR</td><td rowspan="3">FF</td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV@IOU=0.7</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>15.13</td><td>19.29</td><td>12.78</td><td>20.24</td><td>26.47</td><td>18.29</td></tr><tr><td>a. b.</td><td>√</td><td></td><td></td><td></td><td>16.96</td><td>21.99</td><td>14.42</td><td>22.79</td><td>29.76</td><td>19.78</td></tr><tr><td>c.</td><td></td><td>√</td><td></td><td></td><td>16.85</td><td>21.76</td><td>14.36</td><td>22.30</td><td>28.93</td><td>19.31</td></tr><tr><td>d.</td><td></td><td></td><td>√</td><td></td><td>17.24</td><td>21.63</td><td>14.71</td><td>23.47</td><td>30.52</td><td>20.33</td></tr><tr><td>e.</td><td></td><td>√</td><td></td><td></td><td>17.33</td><td>22.34</td><td>14.63</td><td>22.90</td><td>30.02</td><td>19.84</td></tr><tr><td>f.</td><td>广</td><td></td><td>√</td><td></td><td>17.70</td><td>22.59</td><td>15.17</td><td>23.59</td><td>31.07</td><td></td></tr><tr><td></td><td></td><td>!</td><td>√</td><td></td><td>17.98</td><td>22.58</td><td>15.26</td><td>23.76</td><td>30.98</td><td>20.46 20.52</td></tr><tr><td>g. h.</td><td></td><td>1</td><td></td><td></td><td>18.24</td><td>23.82</td><td>15.49</td><td>25.06</td><td>32.66</td><td>21.88</td></tr><tr><td>i.</td><td></td><td>厂</td><td>厂</td><td>!</td><td>18.47</td><td>24.31</td><td>15.76</td><td>25.40</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>33.09</td><td>22.16</td></tr></table>
118
+
119
+ Detailed design choice. We provide additional experiments in Table 2 for our method. First, as for object-level distillation in the feature space, we investigate the different effects of applying distillation on the whole image and foreground regions. Due to the noise in the background, guiding the foreground regions is more effective than the whole image, which improves the accuracy by 0.72 on the moderate settings in 3D detection. Second, as for object-level distillation in the result space, we compare the different effects of point label and region label. It can be observed that the generated region can significantly increase performance while guiding only in sparse point label brings limited improvements. Our proposed label diffusion strategy can increase the number of positive samples for supervision, thus improving performance.
120
+
121
+ Table 2: Evaluation on the KITTI validation set for detailed design choice. OF and OR represent the object-level distillation in feature space and the object-level distillation in result space.
122
+
123
+ <table><tr><td rowspan="2">Guidance</td><td rowspan="2">Choice</td><td colspan="3">3D@I0U=0.7</td><td colspan="3">BEV@IOU=0.7</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td rowspan="2">OF</td><td>full</td><td>16.13</td><td>21.52</td><td>14.18</td><td>22.04</td><td>27.85</td><td>19.04</td></tr><tr><td>foreground</td><td>16.85</td><td>21.76</td><td>14.36</td><td>22.30</td><td>28.93</td><td>19.31</td></tr><tr><td rowspan="2">OR</td><td>sparse label</td><td>15.51</td><td>20.58</td><td>13.70</td><td>21.47</td><td>27.16</td><td>18.60</td></tr><tr><td>diffused label</td><td>17.24</td><td>21.63</td><td>14.71</td><td>23.47</td><td>30.52</td><td>20.33</td></tr></table>
124
+
125
+ Comparison with state-of-the-art methods. Table 3 and Table 4 compare the proposed method with other state-of-the-art methods on the KITTI test and validation sets. On the test set, the proposed method outperforms existing methods in all metrics. We note that, compared with previous best results, we can obtain 1.83, 0.50, 1.53 improvements on the moderate, easy and hard settings in 3D detection. Furthermore, our method achieves more significant improvements in BEV detection, increasing upon the prior work by 2.51, 1.21, 2.46 on the moderate, easy and hard settings. Moreover, compared with the depth-based methods, our method outperforms them in performance by a margin and is superior to theirs in the inference speed. By contrast, our method only takes 40ms to process a KITTI image, tested on a single NVIDIA GTX 1080Ti, while the Fastest of the depth-based methods (Ma et al., 2019; 2020; Ding et al., 2020; Wang et al., 2021a; Reading et al., 2021) need $1 8 0 \mathrm { m s }$ . On the validation set, the proposed also performs best, both for the $0 . 7 \ \mathrm { I o U }$ threshold and 0.5 IoU threshold. Besides, we also present the performance of the baseline model to better show the effectiveness of the proposed method. Note that we do not report the performances of some depth-based methods (Ma et al., 2019; 2020; Ding et al., 2020; Wang et al., 2021a) due to the data leakage problem \*
126
+
127
+ # 4.3 MORE DISCUSSIONS
128
+
129
+ What has the student model learned from the teacher model? To locate the source of improvement, we use the items predicted from the baseline model to replace that from our full model, and Table 5 summarizes the results of the cross-model evaluation. From these results, we can see that the teacher model provides effective guidance to the location estimation $( \mathsf { b { } f } )$ , and improvement of dimension part is also considerable $( \mathrm { c } \to \mathrm { f } )$ . Relatively, the teacher model provides limited valuable cues to the classification and orientation part. This phenomenon suggests the proposed methods boost the performance of the baseline model mainly by introducing the spatial-related information, which is consistent with our initial motivation. Besides, we also show the errors of depth estimation, see Appendix A.3 for the results.
130
+
131
+ Is the effectiveness of our method related to the performance of the teacher model? An intuitive conjecture is the student can learn more if the teacher network has better performance. To explore this problem, we also use the sparse LiDAR maps to train a teacher net to provide guidance to the student model (see Figure 2 for the comparison of the sparse and dense data). As shown in Table 6, the performance of the teacher model trained from the sparse LiDAR maps is largely behind by that from dense LiDAR maps (drop to $2 2 . 0 5 \%$ from $4 2 . 4 5 \%$ , moderate setting), while both of them provides comparable benefits to the student model. Therefore, for our task, the performance of the teacher model is not directly related to the performance improvement, while the more critical factor is whether the teacher network contains complementary information to the student network.
132
+
133
+ Do we need depth estimation as an intermediate task? As shown in Figure 1, most previous methods choose to estimate the depth maps to provide depth information for monocular 3D detection (information flow: LiDAR data estimated depth map $ 3 \mathrm { D }$ detector). Compared with this scheme, our method directly learns the depth cues from LiDAR-based methods (information flow: LiDAR data $ 3 \mathrm { D }$ detector), avoiding the information loss in the depth estimation step. Here we quantitatively show the information loss in depth estimation using a simple experiment. Specifically, we use DORN $\mathrm { F u }$ et al., 2018) (same as most previous depth augmented methods) to generate the depth maps, and then use them to train the teacher net. Table 7 shows the results of this experiment. Note that, compared with setting c, setting b’s teacher net is trained from a larger training set (23,488 vs. 3,712) with ground-truth depth maps (ground truth depth maps vs. noisy depth maps). Nevertheless, this scheme still lags behind our original method, which means that there is serious information loss in monocular depth estimation (stereo image performs better, which is discussed in Appendix A.4).
134
+
135
+ Table 3: Comparison of state-of-the-art methods on the KITTI test set. Methods are ranked by moderate setting. We highlight the best results in bold and the second place in underlined. Only RGB images are required as input in the inference phase for all listed methods. \*: need dense depth maps or LiDAR signals for training. $^ \dagger$ : our baseline model without confidence normalization.
136
+
137
+ <table><tr><td rowspan="2">Method</td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV@IOU=0.7</td><td rowspan="2">Runtime</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>M3D-RPN (Brazil &amp; Liu, 2019)</td><td>9.71</td><td>14.76</td><td>7.42</td><td>13.67</td><td>21.02</td><td>10.23</td><td>160 ms</td></tr><tr><td>SMOKE (Liu et al., 2020)</td><td>9.76</td><td>14.03</td><td>7.84</td><td>14.49</td><td>20.83</td><td>12.75</td><td>30 ms</td></tr><tr><td>MonoPair (Chen et al., 2020b)</td><td>9.99</td><td>13.04</td><td>8.65</td><td>14.83</td><td>19.28</td><td>12.89</td><td>60 ms</td></tr><tr><td>RTM3D (Li et al., 2020)</td><td>10.34</td><td>14.41</td><td>8.77</td><td>14.20</td><td>19.17</td><td>11.99</td><td>50 ms</td></tr><tr><td>AM3D* (Ma et al., 2019)</td><td>10.74</td><td>16.50</td><td>9.52</td><td>17.32</td><td>25.03</td><td>14.91</td><td>400 ms</td></tr><tr><td>PatchNet* (Ma et al., 2020)</td><td>11.12</td><td>15.68</td><td>10.17</td><td>16.86</td><td>22.97</td><td>14.97</td><td>400 ms</td></tr><tr><td>D4LCN* (Ding et al., 2020)</td><td>11.72</td><td>16.65</td><td>9.51</td><td>16.02</td><td>22.51</td><td>12.55</td><td>200 ms</td></tr><tr><td>MonoDLE† (Ma et al., 2021)</td><td>12.26</td><td>17.23</td><td>10.29</td><td>18.89</td><td>24.79</td><td>16.00</td><td>40 ms</td></tr><tr><td>MonoRUn*(Chen et al., 2021a)</td><td>12.30</td><td>19.65</td><td>10.58</td><td>17.34</td><td>27.94</td><td>15.24</td><td>70 ms</td></tr><tr><td>GrooMeD-NMS (Kumar et al., 2021)</td><td>12.32</td><td>18.10</td><td>9.65</td><td>18.27</td><td>16.19</td><td>14.05</td><td>120 ms</td></tr><tr><td>DDMP-3D* (Wang et al., 2021a)</td><td>12.78</td><td>19.71</td><td>9.80</td><td>17.89</td><td>28.08</td><td>13.44</td><td>180 ms</td></tr><tr><td>CaDDN* (Reading et al., 2021)</td><td>13.41</td><td>19.17</td><td>11.46</td><td>18.91</td><td>27.94</td><td>17.19</td><td>630 ms</td></tr><tr><td>MonoEF (Zhou et al., 2021)</td><td>13.87</td><td>21.29</td><td>11.71</td><td>19.70</td><td>29.03</td><td>17.26</td><td>30 ms</td></tr><tr><td>MonoFlex (Zhang et al., 2021b)</td><td>13.89</td><td>19.94</td><td>12.07</td><td>19.75</td><td>28.23</td><td>16.89</td><td>30 ms</td></tr><tr><td>Autoshape (Liu et al., 2021)</td><td>14.17</td><td>22.47</td><td>11.36</td><td>20.08</td><td>30.66</td><td>15.59</td><td>50 ms</td></tr><tr><td>GUPNet (Lu et al., 2021)</td><td>14.20</td><td>20.11</td><td>11.77</td><td>1</td><td>1</td><td>1</td><td>35ms</td></tr><tr><td>Ours*</td><td>16.03</td><td>22.97</td><td>13.60</td><td>22.59</td><td>31.87</td><td>19.72</td><td>40 ms</td></tr><tr><td>Improvements</td><td>+1.83</td><td>+0.50</td><td>+1.53</td><td>+2.51</td><td>+1.21</td><td>+2.46</td><td>-</td></tr></table>
138
+
139
+ Table 4: Performance of the Car category on the KITTI validation set. We highlight the best results in bold and the second place in underlined. †: our baseline model without confidence normalization.
140
+
141
+ <table><tr><td rowspan="2">Method</td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV@IOU=0.7</td><td colspan="3">3D@IOU=0.5</td><td colspan="3">BEV@IOU=0.5</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>M3D-RPN</td><td>11.07</td><td>14.53</td><td>8.65</td><td>15.62</td><td>20.85</td><td>11.88</td><td>35.94</td><td>48.53</td><td>28.59</td><td>39.60</td><td>53.35</td><td>31.76</td></tr><tr><td>MonoPair</td><td>12.30</td><td>16.28</td><td>10.42</td><td>18.17</td><td>24.12</td><td>15.76</td><td>42.39</td><td>55.38</td><td>37.99</td><td>47.63</td><td>61.06</td><td>41.92</td></tr><tr><td>MonoDLEt</td><td>13.66</td><td>17.45</td><td>11.68</td><td>19.33</td><td>24.97</td><td>17.01</td><td>43.42</td><td>55.41</td><td>37.81</td><td>46.87</td><td>60.73</td><td>41.89</td></tr><tr><td>GrooMeD-NMS</td><td>14.32</td><td>19.67</td><td>11.27</td><td>19.75</td><td>27.38</td><td>15.92</td><td>41.07</td><td>55.62</td><td>32.89</td><td>44.98</td><td>61.83</td><td>36.29</td></tr><tr><td>MonoRUn</td><td>14.65</td><td>20.02</td><td>12.61</td><td>-</td><td>=</td><td>■</td><td>43.39</td><td>59.71</td><td>38.44</td><td>-</td><td>■</td><td>■</td></tr><tr><td>GUPNet</td><td>16.46</td><td>22.76</td><td>13.72</td><td>22.94</td><td>31.07</td><td>19.75</td><td>42.33</td><td>57.62</td><td>37.59</td><td>47.06</td><td>61.78</td><td>40.88</td></tr><tr><td>MonoFlex</td><td>17.51</td><td>23.64</td><td>14.83</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr><tr><td>Baseline</td><td>15.13</td><td>19.29</td><td>12.78</td><td>20.24</td><td>26.47</td><td>18.29</td><td>43.54</td><td>57.43</td><td>39.22</td><td>48.49</td><td>63.56</td><td>42.81</td></tr><tr><td>Ours</td><td>18.47</td><td>24.31</td><td>15.76</td><td>25.40</td><td>33.09</td><td>22.16</td><td>49.35</td><td>65.69</td><td>43.49</td><td>53.11</td><td>71.45</td><td>46.94</td></tr></table>
142
+
143
+ Table 5: Cross-model evaluation on the KITTI validation set. We extract each required item (location, dimension, orientation, and confidence) from the baseline model (B) and the full model (O), and evaluate them in a cross-model manner.
144
+
145
+ <table><tr><td rowspan="3"></td><td rowspan="3">loc.</td><td rowspan="3">dim.</td><td rowspan="3">ori.</td><td rowspan="3">con.</td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV@IOU=0.7</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>a.</td><td>B</td><td>B</td><td>B</td><td>B</td><td>15.13</td><td>19.29</td><td>12.78</td><td>20.24</td><td>26.47</td><td>18.29</td></tr><tr><td>b.</td><td>B</td><td>0</td><td>0</td><td>0</td><td>16.05</td><td>20.07</td><td>13.47</td><td>21.31</td><td>27.77</td><td>19.14</td></tr><tr><td>c.</td><td>0</td><td>B</td><td>0</td><td>0</td><td>17.91</td><td>22.87</td><td>15.29</td><td>25.09</td><td>32.78</td><td>21.93</td></tr><tr><td>d.</td><td>0</td><td>0</td><td>B</td><td>0</td><td>18.12</td><td>24.02</td><td>15.34</td><td>25.02</td><td>32.85</td><td>21.84</td></tr><tr><td>e.</td><td>0</td><td>0</td><td>0</td><td>B</td><td>18.41</td><td>24.27</td><td>15.55</td><td>24.98</td><td>32.78</td><td>21.81</td></tr><tr><td>f.</td><td>0</td><td>0</td><td>0</td><td>0</td><td>18.47</td><td>24.31</td><td>15.76</td><td>25.40</td><td>33.09</td><td>22.16</td></tr></table>
146
+
147
+ Table 6: Performance of the student model under the guidance of different teacher models. Metric is the $\mathrm { A P } | _ { 4 0 }$ for the 3D detection task on the KITTI validation set. We also show the performance improvements of the student model to the baseline model for better comparison.
148
+
149
+ <table><tr><td rowspan="2"></td><td colspan="2">Teacher Model</td><td colspan="2">Student Model</td><td colspan="4">Improvement</td></tr><tr><td>Mod.</td><td>Easy Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>sparse maps</td><td>22.05</td><td>31.67</td><td>18.72 18.07</td><td>23.61</td><td>15.36</td><td>+2.94</td><td>+4.32</td><td>+2.58</td></tr><tr><td>dense maps</td><td>42.57</td><td>58.06</td><td>37.07 18.47</td><td>24.31</td><td>15.76</td><td>+3.34</td><td>+5.02</td><td>+2.98</td></tr></table>
150
+
151
+ Table 7: Comparison of using depth estimation as intermediate task or not. Setting a. and c. denote the baseline model and our full model. Setting b. uses the depth maps generated from DORN (Fu et al., 2018) to train the teacher model. Experiments are conducted on the KITTI validation set.
152
+
153
+ <table><tr><td></td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV @IOU=0.7</td><td colspan="2">AOS@IOU=0.7</td><td colspan="3">2D@IOU=0.7</td></tr><tr><td></td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod. Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>a.</td><td>15.13</td><td>19.29</td><td>12.78</td><td>20.24</td><td>26.47</td><td>18.29</td><td>90.95 97.46</td><td>83.02</td><td>92.18</td><td>98.37</td><td>85.05</td></tr><tr><td>b.</td><td>17.70</td><td>23.21</td><td>15.02</td><td>23.34</td><td>31.20</td><td>20.40</td><td>91.50 97.77</td><td>83.49</td><td>92.51</td><td>98.54</td><td>85.38</td></tr><tr><td>c.</td><td>18.47</td><td>24.31</td><td>15.76</td><td>25.40</td><td>33.09</td><td>22.16</td><td>91.67 97.88</td><td>83.59</td><td>92.71</td><td>98.58</td><td>85.56</td></tr></table>
154
+
155
+ # 4.4 QUALITATIVE RESULTS
156
+
157
+ In Figure 5, we show the qualitative comparison of detection results. We can see that the proposed method shows better localization accuracy than the baseline model. See Appendix A.7 for more detailed qualitative results.
158
+
159
+ ![](images/887a97c282d6cc6b7c869d15ef95deb2c6188122430cf03d43e8ce8b70feba9b.jpg)
160
+ Figure 5: Qualitative results. We use green, blue and red boxes to denote the results from baseline, our method, and ground truth. Besides, we use red circle to highlight the main differences.
161
+
162
+ # 5 CONCLUSION
163
+
164
+ In this work, we propose the MonoDistill, which introduces spatial cues to the monocular 3D detector based on the knowledge distillation mechanism. Compared with previous schemes, which share the same motivation, our method avoids any modifications on the target model and directly learns the spatial features from the model rich in these features. This design makes the proposed method perform well in both performance and efficiency. To show an all-around display of our model, extensive experiments are conducted on the KITTI dataset, where the proposed method ranks $1 ^ { s t }$ at 25 FPS among all monocular 3D detectors.
165
+
166
+ # ACKNOWLEDGEMENTS
167
+
168
+ This work was supported in part by the National Natual Science Foundation of China (NSFC) under Grants No.61932020, 61976038, U1908210 and 61772108. Wanli Ouyang was supported by the Australian Research Council Grant DP200103223, FT210100228, and Australian Medical Research Future Fund MRFAI000085.
169
+
170
+ # REFERENCES
171
+
172
+ Garrick Brazil and Xiaoming Liu. M3d-rpn: Monocular 3d region proposal network for object detection. In ICCV, 2019.
173
+
174
+ Yingjie Cai, Buyu Li, Zeyu Jiao, Hongsheng Li, Xingyu Zeng, and Xiaogang Wang. Monocular 3d object detection with decoupled structured polygon estimation and height-guided depth estimation. In AAAI, 2020.
175
+
176
+ Jia-Ren Chang and Yong-Sheng Chen. Pyramid stereo matching network. In CVPR, 2018.
177
+
178
+ Guobin Chen, Wongun Choi, Xiang Yu, Tony X. Han, and Manmohan Chandraker. Learning effi cient object detection models with knowledge distillation. In NeurIPS, 2017.
179
+
180
+ Hansheng Chen, Yuyao Huang, Wei Tian, Zhong Gao, and Lu Xiong. Monorun: Monocular 3d object detection by reconstruction and uncertainty propagation. In CVPR, 2021a.
181
+
182
+ Pengguang Chen, Shu Liu, Hengshuang Zhao, and Jiaya Jia. Distilling knowledge via knowledge review. In CVPR, 2021b.
183
+
184
+ Xiaozhi Chen, Kaustav Kundu, Yukun Zhu, Andrew G. Berneshawi, Huimin Ma, Sanja Fidler, and Raquel Urtasun. 3d object proposals for accurate object class detection. In NeurIPS, 2015.
185
+
186
+ Yilun Chen, Shu Liu, Xiaoyong Shen, and Jiaya Jia. DSGN: deep stereo geometry network for 3d object detection. In CVPR, 2020a.
187
+
188
+ Yongjian Chen, Lei Tai, Kai Sun, and Mingyang Li. Monopair: Monocular 3d object detection using pairwise spatial relationships. In CVPR, 2020b.
189
+
190
+ Xiaomeng Chu, Jiajun Deng, Yao Li, Zhenxun Yuan, Yanyong Zhang, Jianmin Ji, and Yu Zhang. Neighbor-vote: Improving monocular 3d object detection through neighbor distance voting. In ACM MM, 2021.
191
+
192
+ Xing Dai, Zeren Jiang, Zhao Wu, Yiping Bao, Zhicheng Wang, Si Liu, and Erjin Zhou. General instance distillation for object detection. In CVPR, 2021.
193
+
194
+ Mingyu Ding, Yuqi Huo, Hongwei Yi, Zhe Wang, Jianping Shi, Zhiwu Lu, and Ping Luo. Learning depth-guided convolutions for monocular 3d object detection. In CVPR, 2020.
195
+
196
+ Huan Fu, Mingming Gong, Chaohui Wang, Kayhan Batmanghelich, and Dacheng Tao. Deep ordinal regression network for monocular depth estimation. In CVPR, 2018.
197
+
198
+ Andreas Geiger, Philip Lenz, and Raquel Urtasun. Are we ready for autonomous driving? the KITTI vision benchmark suite. In CVPR, 2012.
199
+
200
+ Xiaoyang Guo, Shaoshuai Shi, Xiaogang Wang, and Hongsheng Li. Liga-stereo: Learning lidar geometry aware representations for stereo-based 3d detector. arXiv preprint arXiv:2108.08258, 2021.
201
+
202
+ Saurabh Gupta, Judy Hoffman, and Jitendra Malik. Cross modal distillation for supervision transfer. In CVPR, 2016.
203
+
204
+ Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. CoRR, abs/1503.02531.
205
+
206
+ Yuenan Hou, Zheng Ma, Chunxiao Liu, Tak-Wai Hui, and Chen Change Loy. Inter-region affinity distillation for road marking segmentation. In CVPR, 2020.
207
+
208
+ Jason Ku, Ali Harakeh, and Steven L Waslander. In defense of classical image processing: Fast depth completion on the cpu. In CRV, 2018.
209
+ Abhinav Kumar, Garrick Brazil, and Xiaoming Liu. Groomed-nms: Grouped mathematically differentiable nms for monocular 3d object detection. In CVPR, 2021.
210
+ Buyu Li, Wanli Ouyang, Lu Sheng, Xingyu Zeng, and Xiaogang Wang. Gs3d: An efficient 3d object detection framework for autonomous driving. In CVPR, 2019a.
211
+ Peiliang Li, Xiaozhi Chen, and Shaojie Shen. Stereo r-cnn based 3d object detection for autonomous driving. In CVPR, 2019b.
212
+ Peixuan Li, Huaici Zhao, Pengfei Liu, and Feidao Cao. RTM3D: real-time monocular 3d detection from object keypoints for autonomous driving. In ECCV, 2020.
213
+ Yifan Liu, Ke Chen, Chris Liu, Zengchang Qin, Zhenbo Luo, and Jingdong Wang. Structured knowledge distillation for semantic segmentation. In CVPR, 2019.
214
+ Zechen Liu, Zizhang Wu, and Roland Toth. SMOKE: single-stage monocular 3d object detection ´ via keypoint estimation. In CVPRW, 2020.
215
+ Zongdai Liu, Dingfu Zhou, Feixiang Lu, Jin Fang, and Liangjun Zhang. Autoshape: Real-time shape-aware monocular 3d object detection. In ICCV, 2021.
216
+ Yan Lu, Xinzhu Ma, Lei Yang, Tianzhu Zhang, Yating Liu, Qi Chu, Junjie Yan, and Wanli Ouyang. Geometry uncertainty projection network for monocular 3d object detection. In ICCV, 2021.
217
+ Shujie Luo, Hang Dai, Ling Shao, and Yong Ding. M3dssd: Monocular 3d single stage object detector. In CVPR, 2021.
218
+ Xinzhu Ma, Zhihui Wang, Haojie Li, Pengbo Zhang, Wanli Ouyang, and Xin Fan. Accurate monocular 3d object detection via color-embedded 3d reconstruction for autonomous driving. In ICCV, 2019.
219
+ Xinzhu Ma, Shinan Liu, Zhiyi Xia, Hongwen Zhang, Xingyu Zeng, and Wanli Ouyang. Rethinking pseudo-lidar representation. In ECCV, 2020.
220
+ Xinzhu Ma, Yinmin Zhang, Dan Xu, Dongzhan Zhou, Shuai Yi, Haojie Li, and Wanli Ouyang. Delving into localization errors for monocular 3d object detection. In CVPR, 2021.
221
+ Arsalan Mousavian, Dragomir Anguelov, John Flynn, and Jana Kosecka. 3d bounding box estimation using deep learning and geometry. In CVPR, 2017.
222
+ Charles R Qi, Wei Liu, Chenxia Wu, Hao Su, and Leonidas J Guibas. Frustum pointnets for 3d object detection from rgb-d data. In CVPR, 2018.
223
+ Zengyi Qin, Jinglu Wang, and Yan Lu. Monogrnet: A geometric reasoning network for monocular 3d object localization. In AAAI, 2019.
224
+ Cody Reading, Ali Harakeh, Julia Chae, and Steven L. Waslander. Categorical depth distribution network for monocular 3d object detection. In CVPR, 2021.
225
+ Thomas Roddick, Alex Kendall, and Roberto Cipolla. Orthographic feature transform for monocular 3d object detection. In BMVC, 2019.
226
+ Shaoshuai Shi, Xiaogang Wang, and Hongsheng Li. Pointrcnn: 3d object proposal generation and detection from point cloud. In CVPR, 2019.
227
+ Shaoshuai Shi, Chaoxu Guo, Li Jiang, Zhe Wang, Jianping Shi, Xiaogang Wang, and Hongsheng Li. PV-RCNN: point-voxel feature set abstraction for 3d object detection. In CVPR, 2020.
228
+ Xuepeng Shi, Qi Ye, Xiaozhi Chen, Chuangrong Chen, Zhixiang Chen, and Tae-Kyun Kim. Geometry-based distance decomposition for monocular 3d object detection. In ICCV, 2021.
229
+
230
+ Andrea Simonelli, Samuel Rota Bulo, Lorenzo Porzi, Manuel Lopez-Antequera, and Peter \` Kontschieder. Disentangling monocular 3d object detection. In CVPR, 2019.
231
+
232
+ Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. FCOS: fully convolutional one-stage object detection. In ICCV, 2019.
233
+
234
+ Li Wang, Liang Du, Xiaoqing Ye, Yanwei Fu, Guodong Guo, Xiangyang Xue, Jianfeng Feng, and Li Zhang. Depth-conditioned dynamic message propagation for monocular 3d object detection. In CVPR, 2021a.
235
+
236
+ Tai Wang, Xinge Zhu, Jiangmiao Pang, and Dahua Lin. FCOS3D: fully convolutional one-stage monocular 3d object detection. CoRR, abs/2104.10956, 2021b.
237
+
238
+ Xinlong Wang, Wei Yin, Tao Kong, Yuning Jiang, Lei Li, and Chunhua Shen. Task-aware monocular depth estimation for 3d object detection. In AAAI, 2020a.
239
+
240
+ Yan Wang, Wei-Lun Chao, Divyansh Garg, Bharath Hariharan, Mark E. Campbell, and Kilian Q. Weinberger. Pseudo-lidar from visual depth estimation: Bridging the gap in 3d object detection for autonomous driving. In CVPR, 2019.
241
+
242
+ Yan Wang, Xiangyu Chen, Yurong You, Li Erran Li, Bharath Hariharan, Mark Campbell, Kilian Q. Weinberger, and Wei-Lun Chao. Train in germany, test in the usa: Making 3d object detectors generalize. In CVPR, 2020b.
243
+
244
+ Xinshuo Weng and Kris Kitani. Monocular 3d object detection with pseudo-lidar point cloud. In ICCVW, 2019.
245
+
246
+ Bin Xu and Zhenzhong Chen. Multi-level fusion based 3d object detection from monocular images. In CVPR, 2018.
247
+
248
+ Jihan Yang, Shaoshuai Shi, Zhe Wang, Hongsheng Li, and Xiaojuan Qi. St3d: Self-training for unsupervised domain adaptation on 3d object detection. In CVPR, June .
249
+
250
+ Yurong You, Yan Wang, Wei-Lun Chao, Divyansh Garg, Geoff Pleiss, Bharath Hariharan, Mark E. Campbell, and Kilian Q. Weinberger. Pseudo-lidar++: Accurate depth for 3d object detection in autonomous driving. In ICLR, 2020.
251
+
252
+ Fisher Yu, Dequan Wang, and Trevor Darrell. Deep layer aggregation. CoRR, abs/1707.06484, 2017.
253
+
254
+ Yinmin Zhang, Xinzhu Ma, Shuai Yi, Jun Hou, Zhihui Wang, Wanli Ouyang, and Dan Xu. Learning geometry-guided depth via projective modeling for monocular 3d object detection. arXiv preprint arXiv:2107.13931, 2021a.
255
+
256
+ Yunpeng Zhang, Jiwen Lu, and Jie Zhou. Objects are different: Flexible monocular 3d object detection. In CVPR, 2021b.
257
+
258
+ Xingyi Zhou, Dequan Wang, and Philipp Krahenb ¨ uhl. Objects as points. ¨ CoRR, abs/1904.07850, 2019.
259
+
260
+ Yunsong Zhou, Yuan He, Hongzi Zhu, Cheng Wang, Hongyang Li, and Qinhong Jiang. Monocular 3d object detection: An extrinsic parameter free approach. In CVPR, 2021.
261
+
262
+ # A APPENDIX
263
+
264
+ # A.1 MORE DETAILS OF THE BASELINE MODEL
265
+
266
+ Network architecture. The baseline network is extended from the anchor-free 2D object detection framework, which consists of a feature extraction network and seven detection subheads. We employ DLA-34 (Yu et al., 2017) without deformable convolutions as our backbone. The feature maps are downsampled by 4 times and then we take the image features as input and use 3x3 convolution, ReLU, and 1x1 convolution to output predictions for each detection head. Detection head branches include three for 2D components and four for 3D components. Specifically, 2D detection heads include heatmap, offset between the 2D key-point and the 2D box center, and size of 2D box. 3D components include offset between the 2D key-point and the projected 3D object center, depth, dimensions, and orientations. As for objective functions, we train the heatmap with focal loss. The other loss items adopt L1 losses except for depth and orientation. The depth branch employs a modified L1 loss with the assist of heteroscedastic aleatoric uncertainty. Common MultiBin loss is used for the orientation branch. Besides, we propose a strategy to improve the accuracy of baseline. Inspire by (Lu et al., 2021), estimated depth uncertainty can provide confidence for each projection depth. Therefore, we normalize the confidence of each predicted box using depth uncertainty. In this way, the score has capability of indicating the uncertainty of depth.
267
+
268
+ Training details. Our model is trained on 2 NVIDIA 1080Ti GPUs in an end-to-end manner for 150 epochs. We employ the common Adam optimizer with initial learning rate $1 . 2 5 e ^ { - 4 }$ , and decay it by ten times at 90 and 120 epochs. To stabilize the training process, we also applied the warm-up strategy (5 epochs). As for data augmentations, only random random flip and center crop are applied. Same as the common knowledge distillation scheme, we first train teacher network in advance, and then fix the teacher network. As for student network, we simply train the detection model to give a suitable initialization. We implemented our method using PyTorch. And our code is based on Ma et al. (2021).
269
+
270
+ # A.2 PEDESTRIAN/CYCLIST DETECTION.
271
+
272
+ Due to the small sizes, non-rigid structures, and limited training samples, the pedestrians and cyclists are much more challenging to detect than cars. We first report the detection results on test set in Table 8. It can be seen that our proposed method is also competitive with current state-of-the-art methods on the KITTI test set, which increases $0 . 6 9 \mathrm { A P }$ on hard difficulty level of pedestrian category. Note that, the accuracy of these difficult categories fluctuates greatly compared with Car detection due to insufficient training samples (see Table 10 for the details). Due the access to the test server is limited, we conduct more experiments for pedestrian/cyclist on the validation set for general conclusions (we run the proposed method three times with different random seeds), and the experimental results are summarized in Table 9. According to these results, we can find that the proposed method can effectively boost the accuracy of the baseline model for pedestrian/cyclist detection.
273
+
274
+ Table 8: Performance of Pedestrian/Cyclist detection on the KITTI test set. We highlight the best results in bold and the second place in underlined.
275
+
276
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Pedestrian</td><td colspan="3">Cyclist</td></tr><tr><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td></tr><tr><td>M3D-RPN D4LCN</td><td>4.92 4.55</td><td>3.48 3.42</td><td>2.94 2.83</td><td>0.94 2.45</td><td>0.65 1.67</td><td>0.47 1.36</td></tr><tr><td>MonoPair</td><td>10.02</td><td>6.68</td><td>5.53</td><td>3.79</td><td>2.21</td><td>1.83</td></tr><tr><td>MonoFlex</td><td>9.43</td><td>6.31</td><td>5.26</td><td>4.17</td><td>2.35</td><td>2.04</td></tr><tr><td>MonoDLE</td><td>9.64</td><td>6.55</td><td>5.44</td><td>4.59</td><td>2.66</td><td>2.45</td></tr><tr><td>CaDDN</td><td>12.87</td><td>8.14</td><td>6.76</td><td>7.00</td><td>3.14</td><td>3.30</td></tr><tr><td>DDMP-3D</td><td>4.93</td><td>3.55</td><td>3.01</td><td>4.18</td><td>2.50</td><td>2.32</td></tr><tr><td>AutoShape</td><td>5.46</td><td>3.74</td><td>3.03</td><td>5.99</td><td>3.06</td><td>2.70</td></tr><tr><td>Ours</td><td>12.79</td><td>8.17</td><td>7.45</td><td>5.53</td><td>2.81</td><td>2.40</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
277
+
278
+ Table 9: Performance of Pedestrian/Cyclist detection on the KITTI validation set. Both 0.25 and $0 . 5 \mathrm { I o U }$ thresholds are considered. We report the mean of several experiments for the proposed methods. $\pm$ captures the standard deviation over random seeds.
279
+
280
+ <table><tr><td rowspan="2"></td><td rowspan="2">Method</td><td colspan="3">3D@IoU=0.25</td><td colspan="3">3D@IoU=0.5</td></tr><tr><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td></tr><tr><td rowspan="2">Pedestrian</td><td>Baseline</td><td>29.07±0.21</td><td>23.77±0.15</td><td>19.85±0.14</td><td>6.8±0.28</td><td>5.17±0.08</td><td>4.37±0.15</td></tr><tr><td>Ours</td><td>32.09±0.71</td><td>25.53±0.55</td><td>21.15±0.79</td><td>8.95±1.26</td><td>6.84±0.81</td><td>5.32±0.75</td></tr><tr><td rowspan="2">Cyclist</td><td>Baseline</td><td>21.06±0.46</td><td>11.87±0.19</td><td>10.77±0.02</td><td>3.71±0.49</td><td>1.88±0.23</td><td>1.64±0.04</td></tr><tr><td>Ours</td><td>24.26±1.29</td><td>13.04±0.44</td><td>12.08±0.68</td><td>5.38±0.91</td><td>2.67±0.40</td><td>2.53±0.38</td></tr></table>
281
+
282
+ Table 10: Training samples of each category on the KITTI training set.
283
+
284
+ <table><tr><td></td><td>cars</td><td>pedestrians</td><td>cyclists</td></tr><tr><td>#instances</td><td>14,357</td><td>2,207</td><td>734</td></tr></table>
285
+
286
+ # A.3 DEPTH ERROR ANALYSIS
287
+
288
+ As shown in Figure 6, we compare the depth error between baseline and our method. Specifically, we project all valid samples of the Car category into the image plane to get the corresponding predicted depth values. Then we fit the depth errors between ground truths and predictions as a linear function by least square method. According to the experimental results, we can find that our proposed method can boost the accuracy of depth estimation at different distances.
289
+
290
+ ![](images/9b43a6ba991c5a0e9121d360ec5db7380b63da90ccd4da60004f2ed0feaac777.jpg)
291
+ Figure 6: Errors of depth estimation. We show the errors of depth estimation as a function of the depth ( $\mathbf { X }$ -axis) for the baseline model (left) and our full model (right).
292
+
293
+ # A.4 THE EFFECTS OF STEREO DEPTH
294
+
295
+ We also explored the changes in performance under the guidance of estimated stereo depth (Chang & Chen, 2018), and show the results in Table 11. Stereo depth estimation exploits geometric constraints in stereo images to obtain the absolute depth value through pixel-wise matching, which is more accurate compared with monocular depth estimation. Therefore, under the guidance of stereo depth, the model achieves almost the same accuracy as LiDAR signals guidance at $0 . 5 \ \mathrm { I o U }$ threshold, and there is only a small performance drop at 0.7 IoU threshold.
296
+
297
+ # A.5 GENERALIZATION OF THE PROPOSED METHOD
298
+
299
+ In the main paper, we introduced the proposed method based on MonoDLE (Ma et al., 2021). Here we discuss the generalization ability of the proposed method.
300
+
301
+ Generalizing to other baseline models. To show the generalization ability of the proposed method, we apply our method on another monocular detector GUPNet (Lu et al., 2021), which is a two-stage detection method. Experimental results are shown in the Table 12. We can find that the proposed method can also boosts the performances of GUPNet, which confirms the generalization of our method.
302
+
303
+ Table 11: Effects of stereo depth estimation. Baseline denotes the baseline model without guidance of teacher network. Stereo Depth and LiDAR Depth denote under the guidance of stereo depth maps and LiDAR signals. Experiments are conducted on the KITTI validation set.
304
+
305
+ <table><tr><td rowspan="2"></td><td colspan="3">3D@IOU=0.7</td><td colspan="3">BEV@IOU=0.7</td><td colspan="3">3D@IOU=0.5</td><td colspan="3">BEV@IOU=0.5</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>Baseline</td><td>15.13</td><td>19.29</td><td>12.78</td><td>20.24</td><td>26.47</td><td>18.29</td><td>43.54</td><td>57.43</td><td>39.22</td><td>48.49</td><td>63.56</td><td>42.81</td></tr><tr><td>Stereo Depth</td><td>18.18</td><td>23.54</td><td>15.42</td><td>24.89</td><td>32.26</td><td>21.64</td><td>49.13</td><td>65.18</td><td>43.29</td><td>52.88</td><td>69.47</td><td>46.72</td></tr><tr><td>LiDAR Depth</td><td>18.47</td><td>24.31</td><td>15.76</td><td>25.40</td><td>33.09</td><td>22.16</td><td>49.35</td><td>65.69</td><td>43.49</td><td>53.11</td><td>71.45</td><td>46.94</td></tr></table>
306
+
307
+ Table 12: MonoDistill on GUPNet. Experiments are conducted on the KITTI validation set.
308
+
309
+ <table><tr><td rowspan="2"></td><td colspan="3">3D@IOU=0.7</td><td colspan="3">3D@IOU=0.5</td></tr><tr><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td></tr><tr><td>GUPNet-Baseline</td><td>22.76</td><td>16.46</td><td>13.72</td><td>57.62</td><td>42.33</td><td>37.59</td></tr><tr><td>GUPNet-Ours</td><td>24.43</td><td>16.69</td><td>14.66</td><td>61.72</td><td>44.49</td><td>40.07</td></tr></table>
310
+
311
+ Generalizing to sparse LiDAR signals. We also explore the changes in performance under different resolution of LiDAR signals. In particular, following Pseudo-LiDAR $^ { + + }$ (You et al., 2020), we generate the simulated 32-beam/16-beam LiDAR signals and use them to train our teacher model (in the ‘sparse’ setting). We show the experimental results, based on MonoDLE, in the Table 13. We can see that, although the improvement is slightly reduced due to the decrease of the resolution of LiDAR signals, the proposed method significantly boost the performances of baseline model under all setting.
312
+
313
+ Table 13: Effects of the resolution of LiDAR signals. Experiments are conducted on the KITTI validation set.
314
+
315
+ <table><tr><td rowspan="2"></td><td colspan="3">3D@IOU=0.7</td><td colspan="3">3D@I0U=0.5</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>Baseline</td><td>19.29</td><td>15.13</td><td>12.78</td><td>43.54</td><td>57.43</td><td>39.22</td></tr><tr><td>Ours - 16-beam</td><td>22.49</td><td>17.66</td><td>15.08</td><td>49.39</td><td>65.45</td><td>43.60</td></tr><tr><td>Ours - 32-beam</td><td>23.24</td><td>17.71</td><td>15.19</td><td>49.41</td><td>65.61</td><td>43.46</td></tr><tr><td>Ours - 64-beam</td><td>23.61</td><td>18.07</td><td>15.36</td><td>49.67</td><td>65.97</td><td>43.74</td></tr></table>
316
+
317
+ More discussion. Besides, note that the camera parameters of the images on the KITTI test set are different from these of the training/validation set, and the good performance on the test set suggests the proposed method can also generalize to different camera parameters. However, generalizing to the new scenes with different statistical characteristics is a hard task for existing 3D detectors (Yang et al.; Wang et al., 2020b), including the image-based models and LiDAR-based models, and deserves further investigation by future works. We also argue that the proposed method can generalize to the new scenes better than other monocular models because ours model learns the stronger features from the teacher net. These results and analysis will be included in the revised version.
318
+
319
+ # A.6 COMPARISON WITH DIRECT DENSE DEPTH SUPERVISION.
320
+
321
+ According to the ablation studies in the main paper, we can find that depth cues are the key factor to affect the performance of the monocular 3D models. However, dense depth supervision in the student model without KD may also introduce depth cues to the monocular 3D detectors. Here we conduct the control experiment by adding a new depth estimation branch, which is supervised by the dense LiDAR maps. Note that, this model is trained without KD. Table 14 compares the performances of the baseline model, the new control experiment, and the proposed method. From these results, we can get the following conclusions: (i) additional depth supervision can introduce the spatial cues to the models, thereby improving the overall performance; (ii) the proposed KDbased method significantly performs better than the baseline model and the new control experiment, which demonstrates the effectiveness of our method.
322
+
323
+ Table 14: Comparison with direct dense depth supervision. Experiments are conducted on the KITTI validation set.
324
+
325
+ <table><tr><td rowspan="3"></td><td colspan="3">3D@IOU=0.7</td><td colspan="3">3D@IOU=0.5</td></tr><tr><td>Mod.</td><td>Easy</td><td>Hard</td><td>Mod.</td><td>Easy</td><td>Hard</td></tr><tr><td>Baseline</td><td>15.13</td><td>19.29</td><td>12.78</td><td>43.54</td><td>57.43</td><td>39.22</td></tr><tr><td>Baseline + depth supv.</td><td>17.05</td><td>21.85</td><td>14.54</td><td>46.19</td><td>60.42</td><td>41.88</td></tr><tr><td>Ours</td><td>18.47</td><td>24.31</td><td>15.76</td><td>49.35</td><td>65.69</td><td>43.49</td></tr></table>
326
+
327
+ # A.7 MORE QUALITATIVE RESULTS
328
+
329
+ In Figure 7, we show more qualitative results on the KITTI dataset. We use orange box, green, and purple boxes for cars, pedestrians, and cyclists, respectively. In Figure 8, we show comparison of detection results in the 3D space. It can be found that our method can significantly improve the accuracy of depth estimation compared with the baseline.
330
+
331
+ ![](images/9efa6269e04e1f1776fb3a61cd66a2525d62b1b255e0b6b85422f6bdb89b37c6.jpg)
332
+ Figure 7: Qualitative results for multi-class 3D object detection. The boxes’ color of cars, pedestrian, and cyclist are in orange, green, and purple, respectively.
333
+
334
+ ![](images/ff8ebd28258b37441ea96db3473b8f4a94df501990fefe4bb7ce90d0d8bd18ec.jpg)
335
+ Figure 8: Qualitative results of our method for 3D space. The boxes’ color of ground truth, baseline, and ours are in red, green, and blue, respectively.
md/dev/DgM7-7eMkq0/DgM7-7eMkq0.md ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Decoupling Features in Hierarchical Propagation for Video Object Segmentation
2
+
3
+ Zongxin Yang1,2, Yi Yang1†
4
+
5
+ 1 CCAI, College of Computer Science and Technology, Zhejiang University 2 Baidu Research {yangzongxin, yangyics}@zju.edu.cn
6
+
7
+ # Abstract
8
+
9
+ This paper focuses on developing a more effective method of hierarchical propagation for semi-supervised Video Object Segmentation (VOS). Based on vision transformers, the recently-developed Associating Objects with Transformers (AOT) approach introduces hierarchical propagation into VOS and has shown promising results. The hierarchical propagation can gradually propagate information from past frames to the current frame and transfer the current frame feature from object-agnostic to object-specific. However, the increase of object-specific information will inevitably lead to the loss of object-agnostic visual information in deep propagation layers. To solve such a problem and further facilitate the learning of visual embeddings, this paper proposes a Decoupling Features in Hierarchical Propagation (DeAOT) approach. Firstly, DeAOT decouples the hierarchical propagation of object-agnostic and object-specific embeddings by handling them in two independent branches. Secondly, to compensate for the additional computation from dual-branch propagation, we propose an efficient module for constructing hierarchical propagation, i.e., Gated Propagation Module, which is carefully designed with single-head attention. Extensive experiments show that DeAOT significantly outperforms AOT in both accuracy and efficiency. On YouTube-VOS, DeAOT can achieve $8 6 . 0 \%$ at 22.4fps and $8 2 . 0 \%$ at 53.4fps. Without test-time augmentations, we achieve new state-of-the-art performance on four benchmarks, i.e., YouTubeVOS $( 8 6 . 2 \% )$ , DAVIS 2017 $( 8 6 . 2 \% )$ , DAVIS 2016 $( 9 2 . 9 \% )$ , and VOT 2020 (0.622). Project page: https://github.com/z-x-yang/AOT.
10
+
11
+ # 1 Introduction
12
+
13
+ Video Object Segmentation (VOS), which aims at recognizing and segmenting one or multiple objects of interest in a given video, has attracted much attention as a fundamental task of video understanding. This paper focuses on semi-supervised VOS, which requires algorithms to track and segment objects throughout a video sequence given objects’ annotated masks at one or several frames.
14
+
15
+ Early VOS methods are mainly based on finetuning segmentation networks on the annotated frames [7, 32, 51] or constructing pixel-wise matching maps [10, 50]. Based on the advance of attention mechanisms [5,48,53], many attention-based VOS algorithms have been proposed in recent years and achieved significant improvement. STM [34] and the following works [11, 43, 44] leverage a memory network to store and read the target features of predicted past frames and apply a non-local attention mechanism to match the target in the current frame. Furthermore, AOT [61, 63, 65] introduces hierarchical propagation into VOS based on transformers [8, 48] and can associate multiple objects collaboratively by utilizing the IDentification (ID) mechanism [63]. The hierarchical propagation can gradually propagate ID information from past frames to the current frame and has shown promising VOS performance with remarkable scalability.
16
+
17
+ ![](images/7279e4da2ad23e730d4becab10d7af16fa0af683220cb0e802e708d751058ce5.jpg)
18
+ Figure 1: (a) AOT [63] hierarchically propagates (Prop) object-specific information (i.e., specific to the given object(s)) into the object-agnostic visual embedding. (b) By contrast, DeAOT decouples the propagation of visual and ID embeddings in two branches. (c) Speed-accuracy comparison. All the results were fairly recorded on the same device, 1 Tesla V100 GPU.
19
+
20
+ Fig. 1a shows that AOT’s hierarchical propagation can transfer the current frame feature from an object-agnostic visual embedding to an object-specific ID embedding by hierarchically propagating the reference information into the current frame. The hierarchical structure enables AOT to be structurally scalable between state-of-the-art performance and real-time efficiency. Intuitively, the increase of ID information will inevitably lead to the loss of initial visual information since the dimension of features is limited. However, matching objects’ visual features, the only clues provided by the current frame, is crucial for attention-based VOS solutions. To avoid the loss of visual information in deeper propagation layers and facilitate the learning of visual embeddings, a desirable manner (Fig. 1b) is to decouple object-agnostic and object-specific embeddings in the propagation.
21
+
22
+ Based on the above motivation, this paper proposes a novel hierarchical propagation approach for VOS, i.e., Decoupling Features in Hierarchical Propagation (DeAOT). Unlike AOT, which shares the embedding space for visual (object-agnostic) and ID (object-specific) embeddings, DeAOT decouples them into different branches using individual propagation processes while sharing their attention maps. To compensate for the additional computation from the dual-branch propagation, we propose a more efficient module for constructing hierarchical propagation, i.e., Gated Propagation Module (GPM). By carefully designing GPM for VOS, we are able to use single-head attention to match objects and propagate information instead of the stronger multi-head attention [48], which we found to be an efficiency bottleneck of AOT [63].
23
+
24
+ To evaluate the proposed DeAOT approach, a series of experiments are conducted on three VOS benchmarks (YouTube-VOS [57], DAVIS 2017 [39], and DAVIS 2016 [38]) and one Visual Object Tracking (VOT) benchmark (VOT 2020 [24]). On the large-scale VOS benchmark, YouTube-VOS, the DeAOT variant networks remarkably outperform AOT counterparts in both accuracy and run-time speed as shown in Fig. 1c. Particularly, our R50-DeAOT-L can achieve $8 6 . 0 \%$ at a nearly real-time speed, 22.4fps, and our DeAOT-T can achieve $8 2 . 0 \%$ at 53.4fps, which is superior compared to AOTT [63] $8 0 . 2 \%$ , 41.0fps). Without any test-time augmentations, our SwinB-DeAOT-L achieves topranked performance on four VOS/VOT benchmarks, i.e., YouTube-VOS 2018/2019 $( 8 6 . 2 \% / 8 6 . 1 \%$ ), DAVIS 2017 Val/Test $( 8 6 . 2 \% / 8 2 . 8 \% )$ ), DAVIS 2016 $( 9 2 . 9 \% )$ , and VOT 2020 (0.622 EAO).
25
+
26
+ Overall, our contributions are summarized below:
27
+
28
+ • We propose a highly-effective VOS framework, DeAOT, by decoupling object-agnostic and objectspecific features in hierarchical propagation. DeAOT achieves top-ranked performance and efficiency on four VOS/VOT benchmarks [24, 38, 39, 57].
29
+ • We design an efficient module, GPM, for constructing hierarchical matching and propagation. By using GPM, DeAOT variants are consistently faster than AOT counterparts, although DeAOT’s propagation processes are twice as AOT’s.
30
+
31
+ # 2 Related Work
32
+
33
+ Semi-supervised Video Object Segmentation. Given a video with one or several annotated frames (the first frame in general), semi-supervised VOS [52] requires algorithms to propagate the mask annotations to the entire video. Traditional methods often solve an optimization problem with an energy defined over a graph structure [2, 4, 49]. Based on deep neural networks (DNN), deep learning based VOS methods have achieved significant progress and dominated the field in recent years.
34
+
35
+ Finetuning-based Methods. Early DNN-based methods rely on fine-tuning pre-trained segmentation networks at test time to make the networks focus on the given object. Among them, OSVOS [7] and MoNet [56] propose to fine-tune pre-trained networks on the first-frame annotation. OnAVOS [51] extends the first-frame fine-tuning by introducing an online adaptation mechanism. Following these approaches, MaskTrack [37] and PReM [32] further utilize optical flow to help propagate the segmentation mask from one frame to the next.
36
+
37
+ Template-based Methods. To avoid using the test-time fine-tuning, many researchers regard the annotated frames as templates and investigate how to match with them. For example, OSMN [60] employs a network to extract object embedding and another one to predict segmentation based on the embedding. PML [10] learns pixel-wise embedding with the nearest neighbor classifier, and VideoMatch [22] uses a matching layer to map the pixels of the current frame to the annotated frame in a learned embedding space. Following these methods, FEELVOS [50] and $\mathrm { C F B I ( + ) }$ [62, 64] extend the pixel-level matching mechanism by additionally doing local matching with the previous frame, and RPCM [58] proposes a correction module to improve the reliability of pixel-level matching. Instead of using matching mechanisms, LWL [6] proposes to use an online few-shot learner to learn to decode object segmentation.
38
+
39
+ Attention-based Methods. Based on the advance of attention mechanisms [5,48,53], STM [34] and the following works (e.g., KMN [43] and STCN [11]) leverage a memory network to embed past-frame predictions into memory and apply a non-local attention mechanism on the memory to propagate mask information to the current frame. Differently, SST [17] proposes to calculate pixel-level matching maps based on the attention maps of transformer blocks [48]. Recently, AOT [61, 63, 65] introduces hierarchical propagation into VOS and can associate multiple objects collaboratively with the proposed ID mechanism.
40
+
41
+ Visual Transformers. Transformers [48] was initially proposed to build hierarchical attention-based networks for natural language processing (NLP). Compared to RNNs, transformer networks model global correlation or attention in parallel, leading to better memory efficiency, and thus have been widely used in NLP tasks [15, 40, 46]. Similar to Non-local Neural Networks [53], transformer blocks compute correlation with all the input elements and aggregate their information by using attention mechanisms [5]. Recently, transformer blocks were introduced to computer vision and have shown promising performance in many tasks, such as image classification [16, 30, 47], object detection [8]/segmentation [25, 35, 54, 66], image generation [36], and video understanding [1, 26, 31].
42
+
43
+ Based on transformers, AOT [63] proposes a Long Short-Term Transformer (LSTT) structure for constructing hierarchical propagation. By hierarchically propagating object information, AOT variants [63] have shown promising performance with remarkable scalability. Unlike AOT, which shares the embedding space for object-agnostic and object-specific embeddings, we propose to decouple them into different branches using individual propagation processes. Such a dual-branch paradigm avoids the loss of object-agnostic information and achieves significant improvement. Besides, a more efficient structure, GPM, is proposed for hierarchical propagation.
44
+
45
+ # 3 Rethinking Hierarchical Propagation for VOS
46
+
47
+ Attention-based VOS methods [11, 34, 43, 63] are dominating the field of VOS. In these methods, STM [34] and following algorithms [11, 43] uses a single attention layer to propagate mask information from memorized frames to the current frame. The use of only a single attention layer restricts the scalability of algorithms. Hence, AOT [63] introduces hierarchical propagation into VOS by proposing the Long Short-term Transformer (LSTT) structure, which can propagate the mask information in a hierarchical coarse-to-fine manner. By adjusting the layer number of LSTT, AOT variants can be ranged from state-of-the-art performance to real-time run-time speed.
48
+
49
+ Let $Q \in \mathbb { R } ^ { H W \times C }$ and $K , V \in \mathbb { R } ^ { T H W \times C }$ denote the query embedding of the current frame, the key embedding, and the value embedding of the memorized frames respectively, where $T , H$ , $W$ , $C$ represent the temporal, height, width, and channel dimensions. The formula of a common attention-based VOS propagation is,
50
+
51
+ $$
52
+ A t t ( Q , K , V ) = C o r r ( Q , K ) V = s o f t m a x ( \frac { Q K ^ { t r } } { \sqrt { C } } ) V ,
53
+ $$
54
+
55
+ where the matching (or attention) map is calculated by the correlation function, $C o r r ( * , * )$ .
56
+
57
+ To formulate a hierarchical propagation with $L$ layers, we further define $X _ { l } ^ { t } \in \mathbb { R } ^ { H W \times C }$ as the input feature embedding of $l$ -th propagation layer $( l \in \{ 1 , 2 , . . . , L \} )$ at $t$ frame. Moreover, $X _ { l } ^ { \mathbf { m } } =$ $\bar { C o n c a t } ( X _ { l } ^ { m _ { 1 } } , . . . , X _ { l } ^ { m _ { T } } )$ and $Y ^ { \mathbf { m } } = { C o n c a t ( Y ^ { m _ { 1 } } , . . . , Y ^ { m _ { T } } ) }$ stands for the feature embeddings and object masks in the memorized frames with indices $\mathbf { m } = \{ m _ { 1 } , . . . , m _ { T } \}$ . Then, the formulation of $l$ -th propagation layer in AOT’s hierarchical propagation can be simplified as,
58
+
59
+ $$
60
+ \widetilde { X } _ { l } ^ { t } = A t t ( X _ { l } ^ { t } W _ { l } ^ { K } , X _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } , X _ { l } ^ { \mathbf { m } } W _ { l } ^ { V } + I D ( Y ^ { \mathbf { m } } ) ) ,
61
+ $$
62
+
63
+ where $I D ( * )$ denotes the IDentification (ID) embedding [63] function used to encode masks. Besides, $W _ { l } ^ { K } \in \mathbb { R } ^ { \tilde { C } \times C _ { k } }$ and $W _ { l } ^ { V } \in \mathbb { R } ^ { C \times C _ { v } }$ are trainable parameters for projecting features into matching space and propagation space, respectively. For simplicity, the formulation keeps only the parts related to mask propagation in LSTT.
64
+
65
+ Obviously, before all the propagation layers, the current frame feature, $X _ { 1 } ^ { t }$ , is an object-agnostic feature extracted from an image encoder (e.g., ResNet-50 [21]). Nevertheless, the mask information $I D ( Y ^ { \mathbf { m } } )$ will be gradually and hierarchically propagated into the current frame, and the output feature, $\smash { \widetilde { X } _ { L } ^ { t } }$ , will become object-specific and can be decoded into the ID/mask prediction by a decoder network (e.g., FPN [27]). In other words, step by step, the hierarchical propagation transfers the current frame feature, $X _ { l } ^ { t }$ , from an object-agnostic visual embedding to an object-specific ID embedding, as demonstrated in Fig. 1a.
66
+
67
+ Intuitively, the absorption of object-specific ID information will inevitably lead to the oblivion of object-agnostic visual information within $X _ { 1 } ^ { t }$ since the channel dimension of $X _ { l } ^ { t }$ is limited. Such a phenomenon can also be observed by increasing the ID information directly. As shown in Fig. 2, the performance of AOT heavily drops as we increase the information amount of $I D ( Y ^ { \mathbf { m } } )$ by containing more IDs inside. On the other hand, the significant progress of VOS in recent years is mainly based on matching object-agnostic visual embeddings (e.g., pixel-level matching methods [58, 62, 64] and single-layer attention-based methods [11, 34, 43] mentioned above). Hence, we argue that the loss of visual information in deeper propagation layers limits the performance of hierarchical propagation.
68
+
69
+ How to design a hierarchical propagation structure which can keep or even refine the initial object-agnostic visual information? Fig. 1b shows a simple, straightforward, and desirable approach, i.e., propagating object-agnostic and object-specific information in two different branches (Visual Branch and ID Branch). The object-agnostic branch is responsible for gathering visual information, refining visual features, and matching objects. By contrast, the object-specific branch is responsible for absorbing ID information propagated from memorized frames. These two branches share the attention maps used to match objects and propagate features. Compared to the singlebranch LSTT, our dual-branch approach can keep and further refine visual features in the hierarchical propagation and thus can further facilitate the learning of visual embeddings.
70
+
71
+ ![](images/21db22f8b0e573ba55b2535d32bb447a29475416a0a891369472f8fd92b4fcd1.jpg)
72
+ Figure 2: The performance of AOT [63] will be degraded by increasing ID’s maximum number.
73
+
74
+ # 4 Decoupling Features in Hierarchical Propagation
75
+
76
+ This section will introduce a new framework, Decoupling Features in Hierarchical Propagation (DeAOT), for solving semi-supervised video object segmentation. We show an overview of DeAOT in Fig. 3a. Given a video with a reference frame annotation, DeAOT propagates the annotation to the entire video frame-by-frame. The multi-object annotation is encoded by the IDentification (ID) mechanism [63]. Different from AOT, DeAOT decouples the hierarchical propagation of visual embedding and ID embedding, i.e., DeAOT propagates these two embeddings in two branches. Furthermore, DeAOT constructs the hierarchical propagation by using the proposed Gated Propagation Module (GPM), which is more efficient and effective than the LSTT block used in AOT.
77
+
78
+ ![](images/6e1cf58d895dd54d6318244e298b354bd91f5db091f3236699bfcce74b6a985d.jpg)
79
+ Figure 3: (a) Overview. Decoupling Features in Hierarchical Propagation (DeAOT) decouples the propagation of visual embedding and IDentification (ID) embedding [63] in two branches, i.e., Visual Branch and ID Branch. The propagation module is the proposed efficient GPM module. (b) A demonstration of the Gated Propagation Module (GPM) in both Visual and ID branches. LN: Layer Normalization [3]. (c) We propose to use the Gated Propagation (GP) function to construct GPM. DW-Conv: depth-wise convolution. Mul: matrix multiplication.
80
+
81
+ # 4.1 Hierarchical Dual-branch Propagation
82
+
83
+ Different from the previous attention-based VOS methods [34,43, 44, 63], DeAOT propagates objects’ visual features and mask features in two parallel branches. In detail, the visual branch is responsible for matching objects, gathering past visual information, and refining object features. To re-identify the objects, the ID branch reuses the matching maps (attention maps) calculated by the visual branch to propagate the ID embedding (encoded by the ID mechanism [63]) from past frames to the current frame. Both the branches share the same hierarchical structure with $L$ propagation layers.
84
+
85
+ Visual Branch is responsible for matching objects by calculating attention maps on patch-wise visual embeddings. The visual embeddings in the memorized frames will be propagated to the current frame regarding the attention maps. Since the propagation is not directly related to the object-specific ID embedding, the visual branch can learn to refine visual embeddings to be more contrastive but avoid being biased toward the given object-specific information. Let $I$ denote visual embeddings, we modify Eq. 2 into a layer of object-agnostic visual propagation,
86
+
87
+ $$
88
+ \begin{array} { r } { \widetilde { I } _ { l } ^ { t } = A t t ( I _ { l } ^ { t } { W } _ { l } ^ { K } , { I } _ { l } ^ { \mathbf { m } } { W } _ { l } ^ { K } , { I } _ { l } ^ { \mathbf { m } } { W } _ { l } ^ { V } ) } \\ { = C o r r ( I _ { l } ^ { t } { W } _ { l } ^ { K } , { I } _ { l } ^ { \mathbf { m } } { W } _ { l } ^ { K } ) { I } _ { l } ^ { \mathbf { m } } { W } _ { l } ^ { I } , } \end{array}
89
+ $$
90
+
91
+ which doesn’t leverage the object-specific ID embedding, $I D ( Y ^ { \mathbf { m } } )$ . Thus, the visual branch can learn to keep and refine the visual embedding in the hierarchical propagation.
92
+
93
+ ID Branch is designed for propagating the object-specific information from past frames to the current frame. The prediction of object-specific segmentation is essential for VOS and can not be processed by the above object-agnostic visual propagation branch. Let $M$ denote the object-specific embeddings in our identification branch, the formulation of our object-specific ID propagation is,
94
+
95
+ $$
96
+ \begin{array} { r l } & { \widetilde { M } _ { l } ^ { t } = A t t ( I _ { l } ^ { t } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } , M _ { l } ^ { \mathbf { m } } W _ { l } ^ { \overline { { V } } } + I D ( Y ^ { \mathbf { m } } ) ) } \\ & { \qquad = C o r r ( I _ { l } ^ { t } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } ) ( M _ { l } ^ { \mathbf { m } } W _ { l } ^ { \overline { { V } } } + I D ( Y ^ { \mathbf { m } } ) ) , } \end{array}
97
+ $$
98
+
99
+ where $W _ { l } ^ { \overline { { V } } } \in \mathbb { R } ^ { C \times C _ { v } }$ is a trainable projection matrix for the identification propagation. Particularly, the identification propagation shares the same attention maps, $C o r r ( I _ { l } ^ { t } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } )$ , from the visual branch, since the identification of objects is mainly based on objects’ visual features instead of their ID indices. Without the visual information, the tracking of objects is inapplicable.
100
+
101
+ # 4.2 Gated Propagation Module
102
+
103
+ Instead of using the LSTT block [63], which employs multi-head attention in propagation, we stack the hierarchical propagation based on the proposed Gated Propagation Module (GPM), which is designed based on more efficient single-head attention.
104
+
105
+ LSTT Block [63] includes four parts, i.e., a long-term attention responsible for propagating information from the memorized frames (in m), a short-term attention responsible for propagating information from a spatial neighborhood in the previous $( t - 1 )$ frame, a self-attention module for associating objects in the current $\mathbf { \rho } ( t )$ frame, and a feed-forward module. The three kinds of attention modules are built on the multi-head [48] extension of Eq. 1 or Eq. 2. According to the experiments in Table 3b, reducing the head number from multiple heads (8 heads in default) to a single head will decrease the performance of AOT but can significantly improve the run-time speed, which means the multi-head attention is an efficiency bottleneck of LSTT. Concretely, the computational complexity of long-term attention is $\mathcal { O } ( N T \bar { H ^ { 2 } } W ^ { 2 } )$ , which is proportional to the head number $N$ since each head contains a correlation function, $C o r r ( Q , K )$ .
106
+
107
+ Gated Propagation Function. To avoid using multiple attention heads but not decrease the network performance, we redesign the attention-based VOS propagation defined in Eq. 1 and propose a gated propagation function as demonstrated in Fig. 3c. Let $\overset { \cdot } { U } \in \mathbb { R } ^ { H W \times C }$ denotes a gating embedding, the function is
108
+
109
+ $$
110
+ G P ( U , Q , K , V ) = { \mathcal { F } } _ { d w } ( \sigma ( U ) \odot C o r r ( Q , K ) V ) W ^ { O } ,
111
+ $$
112
+
113
+ where $\sigma$ is a non-linear gating function, $\odot$ denotes element-wise multiplication, $\mathcal { F } _ { d w } ( * )$ stands for a depth-wise 2D convolution layer [13], and $W ^ { O } \in \mathbb { R } ^ { C _ { v } \times C }$ is the trainable weight of output projection. Firstly, we augment the attention-based propagation (Eq. 1) by using a conditional gate, $\sigma ( U )$ , which we empirically found to be effective in VOS. Notably, the presence of gating in weak attention mechanisms (e.g., single-head attention) is also beneficial in some transformer-based methods [23,29] for NLP. Moreover, we leverage a depth-wise convolution $\mathcal { F } _ { d w } ( * )$ to enhance the modeling of local spatial context in a lightweight manner.
114
+
115
+ Gated Propagation Module consists of three kinds of gated propagation, self-propagation, long-term propagation, and short-term propagation. Compared with LSTT, GPM removes the feed-forward module for further saving computation and parameters. All the propagation processes employ the gated propagation function defined in Eq. 5. In DeAOT, both the propagation branches (i.e., visual branch and identification branch) are stacked by GPM as shown in Fig. 3b.
116
+
117
+ Based on the formulation of visual propagation (Eq. 3) and ID propagation (Eq. 4), the Long-term Propagation can be formulated as
118
+
119
+ $$
120
+ G P _ { l t } ^ { v i s } ( I _ { l } ^ { t } , I _ { l } ^ { t } , I _ { l } ^ { \mathbf { m } } , I _ { l } ^ { \mathbf { m } } ) = G P ( I _ { l } ^ { t } W _ { l } ^ { U } , I _ { l } ^ { t } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { V } ) ,
121
+ $$
122
+
123
+ $$
124
+ G P _ { l t } ^ { i d } ( M _ { l } ^ { t } , I _ { l } ^ { t } , I _ { l } ^ { \mathbf { m } } , M _ { l } ^ { \mathbf { m } } , Y ^ { \mathbf { m } } ) = G P ( M _ { l } ^ { t } W _ { l } ^ { \overline { { U } } } , I _ { l } ^ { t } W _ { l } ^ { K } , I _ { l } ^ { \mathbf { m } } W _ { l } ^ { K } , M _ { l } ^ { \mathbf { m } } W _ { l } ^ { \overline { { V } } } + I D ( Y ^ { \mathbf { m } } ) )
125
+ $$
126
+
127
+ for the visual branch and ID branch, respectively. The ID propagation reuses the attention maps of the visual propagation as discussed in Eq. 4. Based on the long-term propagation, we can formulate the Short-term Propagation at spatial location $p$ to be
128
+
129
+ $$
130
+ G P _ { s t } ^ { v i s } ( I _ { l } ^ { t } , I _ { l } ^ { t } , I _ { l } ^ { t - 1 } , I _ { l } ^ { t - 1 } | p ) = G P _ { l t } ^ { v i s } ( I _ { l , p } ^ { t } , I _ { l , p } ^ { t } , I _ { l , N ( p ) } ^ { t - 1 } , I _ { l , N ( p ) } ^ { t - 1 } ) ,
131
+ $$
132
+
133
+ $$
134
+ G P _ { s t } ^ { i d } ( M _ { l } ^ { t } , I _ { l } ^ { t } , I _ { l } ^ { t - 1 } , M _ { l } ^ { t - 1 } , Y ^ { t - 1 } | p ) = G P _ { l t } ^ { i d } ( M _ { l , p } ^ { t } , I _ { l , p } ^ { t } , I _ { l , N ( p ) } ^ { t - 1 } , M _ { l , N ( p ) } ^ { t - 1 } | Y _ { N ( p ) } ^ { t - 1 } ) ,
135
+ $$
136
+
137
+ where $I _ { l , p } ^ { t } , M _ { l , p } ^ { t } \in \mathbb { R } ^ { 1 \times C }$ are the feature of $I _ { l } ^ { t } , M _ { l } ^ { t }$ at location $p$ respectively, and $\mathcal { N } ( \boldsymbol { p } )$ stands for a $\lambda \times \lambda$ n o $p$ rt-term propagat of the previous each location frame. Since $p$ is he restricted in its spatial neighbourhood (It−1l,N (p) $M _ { l , \mathcal { N } ( p ) } ^ { t - 1 } )$ $( t - 1 )$ object motions across several contiguous video frames are always smooth, non-local propagation processes becomes inefficient and not necessary in short-term information propagation [62].
138
+
139
+ Finally, the Self-Propagation can also be formulated similar to the long-term propagation, i.e.,
140
+
141
+ $$
142
+ G P _ { s e l f } ^ { v i s } ( I _ { l } ^ { t } | M _ { l } ^ { t } ) = G P ( I _ { l } ^ { t } W _ { l } ^ { U } , ( I _ { l } ^ { t } \oplus M _ { l } ^ { t } ) W _ { l } ^ { K } , ( I _ { l } ^ { t } \oplus M _ { l } ^ { t } ) W _ { l } ^ { K } , I _ { l } ^ { t } W _ { l } ^ { V } ) ,
143
+ $$
144
+
145
+ $$
146
+ G P _ { s e l f } ^ { i d } ( M _ { l } ^ { t } | I _ { l } ^ { t } ) = G P ( M _ { l } ^ { t } W _ { l } ^ { \overline { { U } } } , ( I _ { l } ^ { t } \oplus M _ { l } ^ { t } ) W _ { l } ^ { K } , ( I _ { l } ^ { t } \oplus M _ { l } ^ { t } ) W _ { l } ^ { K } , M _ { l } ^ { t } W _ { l } ^ { \overline { { V } } } ) ,
147
+ $$
148
+
149
+ ![](images/3456830cdbf2b5c330f65a6caf78aa7bc5b6c0c0a41f390209f71d29ddae1182.jpg)
150
+ Figure 4: Qualitative results. (top) DeAOT performs better than AOT [63] on tiny or scale-changing objects. (bottom) DeAOT fails to track highly similar objects when serious occlusion happens.
151
+
152
+ where $\oplus$ is a concatenation process on the channel dimension. In the self-propagations, both the visual embedding $I _ { l } ^ { t }$ and ID embedding $M _ { l } ^ { t }$ are used in the calculation of attention maps (i.e., $C o r r ( Q , K ) )$ . Here, the object-specific $M _ { l } ^ { t }$ performs like a positional embedding [48] additional to the visual embedding $I _ { l } ^ { \bar { t } }$ . We found that such a process can help associate the objects in the current frame more effectively. Apart from this, the current frame segmentation $Y ^ { t }$ is unavailable before being decoded and is not used in the ID self-propagation $G P _ { s e l f } ^ { i d }$ . For simplicity, we reuse the parameter symbols in Eq. 6 and 7, but the trainable parameters are not shared with long-term propagation.
153
+
154
+ # 5 Implementation Details
155
+
156
+ Network Details: Consistent with AOT [63], three kinds of encoders are used in our experiments, i.e., MobileNet-V2 [42] (in default), ResNet-50 (R50) [21], and Swin-B [30]. The decoder is the same FPN [27] network. Besides, the spatial neighborhood size $\lambda$ is set to 15, and the maximum object number within the ID embedding is 10. In our GPM module, the channel dimension $C$ of visual and ID embeddings is 256, the matching features’ dimension $C _ { k }$ is 128, and the propagation features’ dimension $C _ { v }$ is 512. Moreover, the kernel size of $\mathcal { F } _ { d w }$ is 5, and the gating function $\sigma ( * )$ is SiLU/Swish [18, 41].
157
+
158
+ To make fair comparisons with AOT’s variants [63], we build corresponding DeAOT variants with different GPM number $L$ or long-term memory size m. The hyper-parameters of these variants are: DeAOT-T: $L = 1$ , $\mathbf { m } = \{ 1 \}$ ; DeAOT-S: $L = 2$ , $\mathbf { m } = \{ 1 \}$ ; DeAOT-B: $L = 3$ , $\mathbf { m } = \{ 1 \}$ ; DeAOT-L: $L = 3$ , ${ \bf m } = \{ 1 , 1 + \delta , 1 + \bar { 2 } \delta , \ldots \}$ . DeAOT-T/S/B considers only the reference frame as the long-term memory, leading to consistent run-time speeds. DeAOT-L updates the long-term memory per $\delta$ (set to 2/5 for training/testing) frames as AOT-L [63].
159
+
160
+ Training Details: Following [34, 43, 44, 55, 63], we first pre-train DeAOT on synthetic video sequence generated from static image datasets [12, 19, 20, 28, 45] by randomly applying multiple image augmentations [55]. Then, we do main training on the VOS benchmarks [39, 57] by randomly applying video augmentations [62, 63]. Besides, we keep our optimization strategies and related hyper-parameters the same as AOT. More details are supplied in Supplementary.
161
+
162
+ # 6 Experimental Results
163
+
164
+ We conduct experiments on three popular VOS benchmarks (YouTube-VOS [57], DAVIS 2017 [39], and DAVIS 2016 [38]) and one challenging Visual Object Tracking (VOT) benchmark (VOT 2020 [24]), which gives segmentation annotations and can be used to evaluate VOS algorithms.
165
+
166
+ To validate DeAOT’s generalization ability, all the benchmarks share the same model parameters. When evaluating YouTube-VOS, we use the default 6fps videos, which are restricted to be smaller than $1 . 3 \times 4 8 0 p$ resolution. On DAVIS, the default 480p 24fps videos are used. For evaluating VOT 2020, more details can be found in the supplementary material.
167
+
168
+ The evaluation metrics for VOS benchmarks include the $\mathcal { I }$ score (calculated as the average IoU score between the prediction and the ground truth mask), the $\mathcal { F }$ score (calculated as an average boundary similarity measure between the boundary of the prediction and the ground truth), and their mean value (denoted as $\mathcal { I } \& \mathcal { F } )$ . As to VOT 2020, we use the official EAO criteria [24]. We evaluate all the results on official evaluation servers or with official tools.
169
+
170
+ Table 1: The quantitative evaluation on multi-object benchmarks, YouTube-VOS [57] and DAVIS 2017 [39]. ${ \mathcal { I } } _ { S } / { \mathcal { F } } _ { S } / { \mathcal { I } } _ { U } / { \mathcal { F } } _ { U }$ : $\mathcal { T } / \mathcal { F }$ on seen/unseen classes. $^ \ddag$ : timing extrapolated from single-object speed assuming linear scaling in the number of objects. $\star$ : recorded on our device.
171
+
172
+ <table><tr><td></td><td colspan="5">YouTube-VOS 2018 Val</td><td colspan="5">YouTube-VOS 2019 Val</td><td colspan="4">DAVIS-17 Val</td><td colspan="4">DAVIS-17 Test</td></tr><tr><td>Method</td><td>Avg</td><td>Js</td><td>Fs</td><td>JuFu</td><td></td><td></td><td></td><td>AvgJsFs</td><td>Ju</td><td>Fu</td><td>fps</td><td>Avg</td><td>J</td><td>F</td><td>Avg</td><td>J</td><td>F</td><td>fps</td></tr><tr><td>KMN[ECCV20][43]</td><td>81.4</td><td>81.4</td><td>85.6</td><td>75.3</td><td>83.3</td><td>-</td><td></td><td>-</td><td>-</td><td>=</td><td></td><td>82.8</td><td>80.0</td><td>85.6</td><td>77.2</td><td>74.1 80.3</td><td></td><td>1</td></tr><tr><td>CFBI[ECCV20][62]</td><td>81.4</td><td>81.1</td><td>85.875.3</td><td></td><td>83.4</td><td></td><td></td><td>81.0 80.685.1</td><td>75.283.0</td><td></td><td>3.4</td><td>81.9</td><td>79.3</td><td>84.5</td><td></td><td>76.673.080.1</td><td></td><td>2.9</td></tr><tr><td>SST[CVPR21][17]</td><td>81.7</td><td>81.2</td><td>-</td><td>76.0</td><td>,</td><td></td><td>81.880.9</td><td>1</td><td>76.6</td><td>-</td><td>1</td><td>82.5</td><td>79.9</td><td>85.1</td><td>-</td><td>1</td><td>-</td><td>,</td></tr><tr><td>HMMN[ICCV21] [44]</td><td>82.682.1</td><td></td><td>87.076.8</td><td></td><td>84.6</td><td></td><td>82.581.7</td><td></td><td>86.1 77.3 85.0</td><td></td><td>1</td><td>84.7</td><td>81.9</td><td>87.5</td><td></td><td>78.674.7</td><td>82.5</td><td>3.4</td></tr><tr><td>CFBI+[TPAMI21][64]</td><td>82.881.8</td><td></td><td>86.677.1</td><td></td><td>85.6</td><td></td><td>82.681.7</td><td>86.2</td><td>77.1</td><td>85.2</td><td>4.0</td><td>82.9</td><td>80.1</td><td>85.7</td><td>78.0</td><td>74.481.6</td><td></td><td>3.4</td></tr><tr><td>STCN[NeurIPS21] [11]</td><td>83.0</td><td>81.9</td><td></td><td>86.577.9</td><td>85.7</td><td>82.7</td><td>81.1</td><td>85.4</td><td>78.285.9</td><td></td><td>8.4*</td><td>85.4</td><td>82.2</td><td>88.6</td><td>76.1</td><td>72.779.6</td><td></td><td>19.5*</td></tr><tr><td>RPCM[AAAI22] [58]</td><td>84.0</td><td>83.1</td><td>87.7</td><td>78.5</td><td>86.7</td><td>83.9</td><td>82.6</td><td>86.9</td><td>79.1</td><td>87.1</td><td>-</td><td>83.7</td><td>81.3</td><td>86.0</td><td>79.2</td><td>75.882.6</td><td></td><td>-</td></tr><tr><td>AOT-T[63]</td><td>80.2</td><td>80.1</td><td>84.5</td><td></td><td>82.2</td><td>79.7</td><td>79.6</td><td>83.8</td><td>73.7</td><td>81.8</td><td>41.0</td><td>79.9</td><td>77.4</td><td>82.3</td><td>72.0</td><td></td><td></td><td>51.4</td></tr><tr><td>DeAOT-T</td><td>82.0</td><td>81.6</td><td>86.3</td><td>74.0 75.8</td><td>84.2</td><td>82.0</td><td>81.2</td><td>85.6</td><td>76.4</td><td>84.7</td><td>53.4</td><td>80.5</td><td>77.7</td><td>83.3</td><td>73.7</td><td>68.3 70.077.3</td><td>75.7</td><td>63.5</td></tr><tr><td>AOT-S [63]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>78.7</td><td></td><td></td><td></td><td></td><td>40.0</td></tr><tr><td>DeAOT-S</td><td>82.6</td><td>82.0 83.3</td><td>86.7 88.3</td><td>76.6</td><td>85.0</td><td>82.2</td><td>81.3</td><td>85.9</td><td>76.6</td><td>84.9</td><td>27.1</td><td>81.3</td><td></td><td>83.9</td><td>73.9</td><td>70.3</td><td>77.5</td><td>49.2</td></tr><tr><td>AOT-B [63]</td><td>84.0</td><td></td><td></td><td>77.9</td><td>86.6</td><td>83.8</td><td>82.8</td><td>87.5</td><td>78.1</td><td>86.8</td><td>38.7</td><td>80.8</td><td>77.8</td><td>83.8</td><td>75.4</td><td>71.9</td><td>79.0</td><td></td></tr><tr><td></td><td>83.5</td><td>82.6</td><td>87.5</td><td>77.7</td><td>86.0</td><td>83.3</td><td>82.4</td><td>87.1</td><td>77.8</td><td>86.0</td><td>20.5</td><td>82.5</td><td>79.7</td><td>85.2</td><td>75.5</td><td>71.6</td><td>79.3</td><td>29.6</td></tr><tr><td>DeAOT-B</td><td>84.6</td><td>83.9</td><td>88.9</td><td>78.5</td><td>87.0</td><td>84.6</td><td>83.5</td><td>88.3</td><td>79.1</td><td>87.5</td><td>30.4</td><td>82.2</td><td>79.2</td><td>85.1</td><td>76.2</td><td>72.5</td><td>79.9</td><td>40.9</td></tr><tr><td>AOT-L [63]</td><td>83.8</td><td>82.9</td><td>87.9</td><td>77.7</td><td>86.5</td><td>83.7</td><td>82.8</td><td>87.5</td><td>78.0</td><td>86.7</td><td>16.0</td><td>83.8</td><td>81.1</td><td>86.4</td><td>78.3</td><td>74.3</td><td>82.3</td><td>18.7</td></tr><tr><td>DeAOT-L</td><td>84.8</td><td>84.2</td><td>89.4</td><td>78.6</td><td>87.0</td><td>84.7</td><td>83.8</td><td>88.8</td><td>79.0</td><td>87.2</td><td>24.7</td><td>84.1</td><td>81.0</td><td>87.1</td><td>77.9</td><td>74.1</td><td>81.7</td><td>28.5</td></tr><tr><td>R50-AOT-L [63]</td><td>84.1</td><td>83.7</td><td>88.5</td><td>78.1</td><td>86.1</td><td>84.1</td><td>83.5</td><td>88.1</td><td>78.4</td><td>86.3</td><td>14.9</td><td>84.9</td><td>82.3</td><td>87.5</td><td>79.6</td><td>75.983.3</td><td></td><td>18.0</td></tr><tr><td>R50-DeAOT-L</td><td>86.0</td><td>84.9</td><td>89.9</td><td>80.4</td><td>88.7</td><td>85.9</td><td>84.6</td><td>89.4</td><td>80.8</td><td>88.9</td><td>22.4</td><td></td><td>85.282.288.2</td><td></td><td>80.7</td><td>76.9</td><td>84.5</td><td>27.0</td></tr><tr><td>SwinB-AOT-L [63]</td><td>84.5</td><td>84.3</td><td>89.3</td><td>77.9</td><td>86.4</td><td>84.5</td><td>84.0</td><td>88.8</td><td>78.4</td><td>86.7</td><td>9.3</td><td>85.4</td><td>82.4</td><td>88.4</td><td>81.2</td><td>77.3 82.878.9 86.7</td><td>85.1</td><td>12.1</td></tr><tr><td>SwinB-DeAOT-L</td><td>86.2 85.6 90.6 80.0 88.4</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>86.1 85.3 90.2 80.4</td><td>88.6</td><td>11.9</td><td></td><td>86.2 83.1 89.2</td><td></td><td></td><td></td><td></td><td>15.4</td></tr></table>
173
+
174
+ # 6.1 Compare with the State-of-the-art Methods
175
+
176
+ YouTube-VOS [57] is a large-scale multi-object VOS benchmark, which contains 3471 videos in the training split with 65 categories and 474/507 videos in the Validation 2018/2019 split with additional 26 unseen categories. Table 1 shows that DeAOT variants remarkably outperforms AOT counterparts in both accuracy and run-time speed on YouTube-VOS 2018/2019. For example, our R50-DeAOT-L achieves $\mathbf { 8 6 . 0 \% / 8 5 . 9 \% }$ $( \mathcal { I } \& \mathcal { F } )$ at 22.4fps, which is superior compared to R50-AOTL [63] $( 8 4 . 1 \% / 8 4 . 1 \%$ at 14.9fps). Particularly, our SwinB-DeAOT-L achieves new state-of-the-art performance $( 8 6 . 2 \% / 8 6 . 1 \% )$ ), surpassing previous methods by more than $1 . 7 \% / 1 . 6 \%$ . In addition, our smallest variant, DeAOT-T, precedes SST [17] $( 8 2 . 0 \% / 8 2 . \dot { 0 } \%$ vs $8 1 . 7 \% / 8 1 . 8 \% )$ ) and runs about $1 5 \times$ faster than CFBI [62] (53.4fps vs 3.4fps).
177
+
178
+ DAVIS 2017 [39] is a multi-object extension of DAVIS 2016. The training/validation split consists of 60/30 videos with 138/59 objects, and the test split contains 30 more challenging videos with 89 objects. As shown in Table 1, DeAOT variants can generalize to DAVIS 2017 well. R50- DeAOT-L achieves $8 5 . 2 \% / 8 0 . 7 \%$ on the validation/test split at a real-time speed (27fps), surpassing R50-AOT-L in accuracy and efficiency. Also, SwinB-DeAOT-L achieves the top-ranked performance on DAVIS 2017 $( 8 6 . 2 \% / 8 2 . 8 \% )$ ).
179
+
180
+ DAVIS 2016 [38] is a single-object benchmark containing 20 videos in the validation split, and we show related experiments in Table 2. Although AOT-like methods focus on multi-object scenarios, our DeAOT-L is faster and more robust than STCN [11], whose architecture was designed for single-object VOS. Besides, SwinBDeAOT-L achieves $9 2 . 9 \%$ and outperforms all the VOS methods as well.
181
+
182
+ Table 2: The quantitative evaluation on the singleobject benchmarks, DAVIS 2016 [38] and VOT 2020 [24]. $\mathrm { E A O } ^ { R T }$ : real-time EAO metric [24].
183
+
184
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>DAVIS 2016</td><td rowspan=1 colspan=2>VOT 2020</td></tr><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=2>AvgJ F fps</td><td rowspan=1 colspan=2>EAOEAORT</td></tr><tr><td rowspan=1 colspan=1>CFBI+ [64]RPCM [58]HMMN [44]STCN[11]</td><td rowspan=1 colspan=1>89.988.791.190.687.194.090.889.692.091.690.892.5</td><td rowspan=1 colspan=1>5.95.810.027.2*</td><td rowspan=1 colspan=1>“---</td><td rowspan=1 colspan=1>-=--</td></tr><tr><td rowspan=1 colspan=1>AlphaRef [59]RPT[33]MixFormer-L [14]</td><td rowspan=1 colspan=1>- 1 ·- 1 11 - 1</td><td rowspan=1 colspan=1>--1</td><td rowspan=1 colspan=1>0.4820.5300.555</td><td rowspan=1 colspan=1>0.4860.290-</td></tr><tr><td rowspan=1 colspan=1>AOT-T [63]DeAOT-T</td><td rowspan=1 colspan=1>86.886.187.488.987.889.9</td><td rowspan=1 colspan=1>51.463.5</td><td rowspan=1 colspan=1>0.4350.472</td><td rowspan=1 colspan=1>0.4330.463</td></tr><tr><td rowspan=1 colspan=1>AOT-S [63]DeAOT-S</td><td rowspan=1 colspan=1>89.488.690.289.387.690.9</td><td rowspan=1 colspan=1>40.049.2</td><td rowspan=1 colspan=1>0.5120.593</td><td rowspan=1 colspan=1>0.4990.559</td></tr><tr><td rowspan=1 colspan=1>AOT-B [63]DeAOT-B</td><td rowspan=1 colspan=1>89.988.791.191.089.492.5</td><td rowspan=1 colspan=1>29.640.9</td><td rowspan=1 colspan=1>0.5410.571</td><td rowspan=1 colspan=1>0.5330.542</td></tr><tr><td rowspan=1 colspan=1>AOT-L [63]DeAOT-L</td><td rowspan=1 colspan=1>90.489.691.192.090.393.7</td><td rowspan=1 colspan=1>18.728.5</td><td rowspan=1 colspan=1>0.5740.591</td><td rowspan=1 colspan=1>0.5600.554</td></tr><tr><td rowspan=1 colspan=1>R50-AOT-L [63]R50-DeAOT-L</td><td rowspan=1 colspan=1>91.190.192.192.390.594.0</td><td rowspan=1 colspan=1>18.027.0</td><td rowspan=1 colspan=1>0.5690.613</td><td rowspan=1 colspan=1>0.5400.571</td></tr><tr><td rowspan=1 colspan=1>SwinB-AOT-L[63]SwinB-DeAOT-L</td><td rowspan=1 colspan=1>92.090.793.392.991.194.7</td><td rowspan=1 colspan=1>12.115.4</td><td rowspan=1 colspan=1>0.5860.622</td><td rowspan=1 colspan=1>0.5230.559</td></tr></table>
185
+
186
+ Table 3: Ablation study. The experiments are conducted on YouTube-VOS 2018 [57] and based on DeAOT-S without pre-training on static images. De: decoupling features. $C$ : the channel dimension. Prop: propagation type. LT/ST: long-term/short-term. $k s$ : kernel size.
187
+
188
+ <table><tr><td colspan="5">(a)Propagation module</td><td colspan="9">(b) Head number (Nh)</td><td colspan="5"></td><td colspan="5">(d) ks of Fdw</td></tr><tr><td>Module|</td><td>IC|J&amp;F</td><td></td><td></td><td>Js Ju</td><td>Model|Nh|J&amp;F</td><td></td><td></td><td></td><td>JsJulfps</td><td></td><td></td><td></td><td>Prop</td><td>Vis ID|J&amp;F Js Ju</td><td></td><td></td><td></td><td></td><td>ks|J&amp;F Js Ju</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GPM</td><td>256</td><td>82.5</td><td></td><td>82.3 76.1</td><td>DeAOT</td><td></td><td>1</td><td>82.5</td><td></td><td>82.3 76.1</td><td></td><td>38.7</td><td>LT/ST</td><td>√</td><td></td><td>82.5</td><td></td><td>82.3 76.1 5</td><td></td><td></td><td></td><td>82.5</td><td></td><td>82.3 76.1</td></tr><tr><td>w/oDe</td><td>256</td><td>81.5</td><td></td><td>81.4 75.0</td><td>DeAOT</td><td></td><td>8</td><td>82.5</td><td>82.3 75.8</td><td></td><td></td><td>24.7</td><td>LT/ST</td><td>&lt;√</td><td></td><td>82.1</td><td>82.2 75.7</td><td></td><td>0</td><td></td><td>81.1</td><td></td><td>81.574.2</td><td></td></tr><tr><td>w/o De</td><td>512</td><td>82.0</td><td></td><td>82.1 75.4</td><td>AOT</td><td></td><td>1</td><td>79.6</td><td>80.1 72.6</td><td></td><td></td><td>44.6</td><td>Self</td><td></td><td></td><td>82.5</td><td></td><td>82.3 76.1</td><td>3</td><td></td><td>82.2</td><td>82.4</td><td>82.2 76.1</td><td>82.2 75.8</td></tr><tr><td>LSTT</td><td>[256</td><td>80.3</td><td></td><td>80.673.7</td><td>AOT</td><td></td><td></td><td>80.3</td><td>80.6 73.7</td><td></td><td></td><td>27.1</td><td>Self</td><td></td><td></td><td>82.2</td><td>82.1 75.7</td><td></td><td>9</td><td></td><td></td><td></td><td></td><td></td></tr></table>
189
+
190
+ VOT 2020 [24] consists of 60 single-object videos with challenging scenarios including fast motion, occlusion, etc. The average frame number of VOT 2020 is 327, which is much longer than the maximum video length of the above VOS benchmarks. DeAOT shows superior performance on VOT 2020 in Table 2. The DeAOT variants larger than DeAOT-T outperform MixFormer-L [14] (the state-of-the-art tracker), RPT [33] (VOT 2020 short-term challenge winner), and AlphaRef [59] (VOT 2020 real-time challenge winner) in both EAO and real-time EAO scores. Specifically, SwinBDeAOT-L achieves 0.622 EAO, outstandingly exceeding MixFormer-L by 0.067, and R50-DeAOT-L achieves 0.571 EAO under a real-time requirement, impressively overtaking AlphaRef by 0.085.
191
+
192
+ Qualitative results: Fig. 4 give qualitative comparisons to AOT. By introducing the dual-branch propagation, R50-DeAOT-L performs better than R50-AOT-L on tiny or scale-changing objects $s k i$ poles or ski board). Nevertheless, R50-DeAOT-L still may fails to track multiple highly similar objects (dancer and cow) when serious occlusion happens.
193
+
194
+ # 6.2 Ablation Study
195
+
196
+ This section analyzes the necessity of dual-branch propagation and GPM of DeAOT in Table 3.
197
+
198
+ Propagation module: Table 3a shows that the performance of DeAOT drops from $8 2 . 5 \%$ to $8 1 . 5 \%$ by coupling the propagation of visual and ID embeddings (w/o De) like AOT. Furthermore, doubling the channel dimensions only partially relieves the performance loss. Moreover, the performance will be seriously degraded to $8 0 . 3 \%$ by replacing our GPM with the LSTT module of AOT. In conclusion, the dual-branch propagation approach and the GPM module are crucial in improving VOS performance.
199
+
200
+ Head number: According to the results in Table 3b, the head number $( N _ { h } )$ of attention-based modules is negatively correlated with the efficiency of AOT/De-AOT. The single-head AOT (44.6fps) runs much faster than the default AOT $N _ { h } { = } 8$ , 27.1fps) but loses $0 . 7 \%$ accuracy. By contrast, DeAOT is robust to the head number by using our proposed GPM module.
201
+
202
+ Attention map: Our DeAOT shares the attention maps between two propagation branches. Table 3c shows the study of different kinds of attention maps. Concretely, visual embeddings are essential in building attention maps in the long-term/short-term propagation, whose attention maps are used to match objects. Introducing ID embeddings does not help learn better visual embeddings and will decrease the performance $8 2 . 5 \%$ vs $8 2 . 1 \%$ ). In the self-propagation, however, utilizing the ID embedding as a positional embedding will facilitate the association of objects $8 2 . 2 \%$ vs $8 2 . 5 \%$ ) in the current frame.
203
+
204
+ Kernel size of $\mathcal { F } _ { d w }$ : Large receptive fields have been proved to be critical in segmentation-related tasks [9]. The depth-wise convolution, $\mathcal { F } _ { d w }$ , is an important part of GPM for enlarging the receptive fields. Without $\mathcal { F } _ { d w }$ , the performance of DeAOT drops from $8 2 . 5 \%$ to $8 1 . 1 \%$ , as shown in Table 3d. We empirically found the best kernel size of $\mathcal { F } _ { d w }$ is 5 among $\{ 3 , 5 , 9 \}$ .
205
+
206
+ # 7 Conclusion
207
+
208
+ This paper proposes a highly effective and efficient framework, Decoupling Features in Hierarchical Propagation (DeAOT), for video object segmentation. Based on the rethinking of AOT-like hierarchical propagation, we propose to decouple the propagation of visual and ID embeddings into two network branches and thus avoid the loss of visual information in deep propagation layers. Besides, we propose the Gated Propagation Module (GPM), an efficient module for constructing hierarchical VOS propagation. Applying GPM to the dual-branch propagation, our DeAOT variant networks achieve new state-of-the-art performance on four VOS/VOT benchmarks with superior run-time speed compared to previous solutions.
209
+
210
+ Acknowledgements. This work is partly supported by the Fundamental Research Funds for the Central Universities (No. 226-2022-00051).
211
+
212
+ # References
213
+
214
+ [1] Arnab, A., Dehghani, M., Heigold, G., Sun, C., Luciˇ c, M., Schmid, C.: Vivit: A video vision ´ transformer. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 6836–6846 (2021)
215
+ [2] Avinash Ramakanth, S., Venkatesh Babu, R.: Seamseg: Video object segmentation using patch seams. In: CVPR. pp. 376–383 (2014)
216
+ [3] Ba, J.L., Kiros, J.R., Hinton, G.E.: Layer normalization. In: NIPS Workshops (2016)
217
+ [4] Badrinarayanan, V., Galasso, F., Cipolla, R.: Label propagation in video sequences. In: CVPR. pp. 3265–3272. IEEE (2010)
218
+ [5] Bahdanau, D., Cho, K., Bengio, Y.: Neural machine translation by jointly learning to align and translate. In: ICLR (2015)
219
+ [6] Bhat, G., Lawin, F.J., Danelljan, M., Robinson, A., Felsberg, M., Van Gool, L., Timofte, R.: Learning what to learn for video object segmentation. In: ECCV (2020)
220
+ [7] Caelles, S., Maninis, K.K., Pont-Tuset, J., Leal-Taixé, L., Cremers, D., Van Gool, L.: One-shot video object segmentation. In: CVPR. pp. 221–230 (2017)
221
+ [8] Carion, N., Massa, F., Synnaeve, G., Usunier, N., Kirillov, A., Zagoruyko, S.: End-to-end object detection with transformers. In: ECCV. pp. 213–229. Springer (2020)
222
+ [9] Chen, L.C., Zhu, Y., Papandreou, G., Schroff, F., Adam, H.: Encoder-decoder with atrous separable convolution for semantic image segmentation. In: ECCV. pp. 801–818 (2018)
223
+ [10] Chen, Y., Pont-Tuset, J., Montes, A., Van Gool, L.: Blazingly fast video object segmentation with pixel-wise metric learning. In: CVPR. pp. 1189–1198 (2018)
224
+ [11] Cheng, H.K., Tai, Y.W., Tang, C.K.: Rethinking space-time networks with improved memory coverage for efficient video object segmentation. In: NeurIPS (2021)
225
+ [12] Cheng, M.M., Mitra, N.J., Huang, X., Torr, P.H., Hu, S.M.: Global contrast based salient region detection. TPAMI 37(3), 569–582 (2014)
226
+ [13] Chollet, F.: Xception: Deep learning with depthwise separable convolutions. In: CVPR. pp. 1251–1258 (2017)
227
+ [14] Cui, Y., Cheng, J., Wang, L., Wu, G.: Mixformer: End-to-end tracking with iterative mixed attention. In: CVPR (2022)
228
+ [15] Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. In: NAACL. pp. 4171—-4186 (2019)
229
+ [16] Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al.: An image is worth 16x16 words: Transformers for image recognition at scale. In: ICLR (2021)
230
+ [17] Duke, B., Ahmed, A., Wolf, C., Aarabi, P., Taylor, G.W.: Sstvos: Sparse spatiotemporal transformers for video object segmentation. In: CVPR (2021)
231
+ [18] Elfwing, S., Uchibe, E., Doya, K.: Sigmoid-weighted linear units for neural network function approximation in reinforcement learning. Neural Networks 107, 3–11 (2018)
232
+ [19] Everingham, M., Van Gool, L., Williams, C.K., Winn, J., Zisserman, A.: The pascal visual object classes (voc) challenge. IJCV 88(2), 303–338 (2010)
233
+ [20] Hariharan, B., Arbeláez, P., Bourdev, L., Maji, S., Malik, J.: Semantic contours from inverse detectors. In: ICCV. pp. 991–998. IEEE (2011)
234
+ [21] He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: CVPR (2016)
235
+ [22] Hu, Y.T., Huang, J.B., Schwing, A.G.: Videomatch: Matching based video object segmentation. In: ECCV. pp. 54–70 (2018)
236
+ [23] Hua, W., Dai, Z., Liu, H., Le, Q.V.: Transformer quality in linear time. arXiv preprint arXiv:2202.10447 (2022)
237
+ [24] Kristan, M., Leonardis, A., Matas, J., Felsberg, M., Pflugfelder, R., Kämäräinen, J.K., Danelljan, M., Zajc, L.C., Lukeži ˇ c, A., Drbohlav, O., et al.: The eighth visual object tracking vot2020 ˇ challenge results. In: ECCV. pp. 547–601. Springer (2020)
238
+ [25] Liang, C., Wang, W., Zhou, T., Miao, J., Luo, Y., Yang, Y.: Local-global context aware transformer for language-guided video segmentation. arXiv preprint arXiv:2203.09773 (2022)
239
+ [26] Liang, C., Wang, W., Zhou, T., Yang, Y.: Visual abductive reasoning. In: CVPR. pp. 15565– 15575 (June 2022)
240
+ [27] Lin, T.Y., Dollár, P., Girshick, R., He, K., Hariharan, B., Belongie, S.: Feature pyramid networks for object detection. In: CVPR. pp. 2117–2125 (2017)
241
+ [28] Lin, T.Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., Zitnick, C.L.: Microsoft coco: Common objects in context. In: ECCV. pp. 740–755. Springer (2014)
242
+ [29] Liu, H., Dai, Z., So, D., Le, Q.V.: Pay attention to mlps. In: NeurIPS. vol. 34, pp. 9204–9215 (2021)
243
+ [30] Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., Guo, B.: Swin transformer: Hierarchical vision transformer using shifted windows. In: ICCV (2021)
244
+ [31] Liu, Z., Ning, J., Cao, Y., Wei, Y., Zhang, Z., Lin, S., Hu, H.: Video swin transformer. arXiv preprint arXiv:2106.13230 (2021)
245
+ [32] Luiten, J., Voigtlaender, P., Leibe, B.: Premvos: Proposal-generation, refinement and merging for video object segmentation. In: ACCV. pp. 565–580 (2018)
246
+ [33] Ma, Z., Wang, L., Zhang, H., Lu, W., Yin, J.: Rpt: Learning point set representation for siamese visual tracking. In: ECCV. pp. 653–665. Springer (2020)
247
+ [34] Oh, S.W., Lee, J.Y., Xu, N., Kim, S.J.: Video object segmentation using space-time memory networks. In: ICCV (2019)
248
+ [35] Pan, X., Li, P., Yang, Z., Zhou, H., Zhou, C., Yang, H., Zhou, J., Yang, Y.: In-n-out generative learning for dense unsupervised video segmentation. In: ACM MM (2022)
249
+ [36] Parmar, N., Vaswani, A., Uszkoreit, J., Kaiser, L., Shazeer, N., Ku, A., Tran, D.: Image transformer. In: ICCV. pp. 4055–4064. PMLR (2018)
250
+ [37] Perazzi, F., Khoreva, A., Benenson, R., Schiele, B., Sorkine-Hornung, A.: Learning video object segmentation from static images. In: CVPR. pp. 2663–2672 (2017)
251
+ [38] Perazzi, F., Pont-Tuset, J., McWilliams, B., Van Gool, L., Gross, M., Sorkine-Hornung, A.: A benchmark dataset and evaluation methodology for video object segmentation. In: CVPR. pp. 724–732 (2016)
252
+ [39] Pont-Tuset, J., Perazzi, F., Caelles, S., Arbeláez, P., Sorkine-Hornung, A., Van Gool, L.: The 2017 davis challenge on video object segmentation. arXiv preprint arXiv:1704.00675 (2017)
253
+ [40] Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., Sutskever, I.: Language models are unsupervised multitask learners. OpenAI blog 1(8), 9 (2019)
254
+ [41] Ramachandran, P., Zoph, B., Le, Q.V.: Searching for activation functions. arXiv preprint arXiv:1710.05941 (2017)
255
+ [42] Sandler, M., Howard, A., Zhu, M., Zhmoginov, A., Chen, L.C.: Mobilenetv2: Inverted residuals and linear bottlenecks. In: CVPR. pp. 4510–4520 (2018)
256
+ [43] Seong, H., Hyun, J., Kim, E.: Kernelized memory network for video object segmentation. In: ECCV (2020)
257
+ [44] Seong, H., Oh, S.W., Lee, J.Y., Lee, S., Lee, S., Kim, E.: Hierarchical memory matching network for video object segmentation. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 12889–12898 (2021)
258
+ [45] Shi, J., Yan, Q., Xu, L., Jia, J.: Hierarchical image saliency detection on extended cssd. TPAMI 38(4), 717–729 (2015)
259
+ [46] Synnaeve, G., Xu, Q., Kahn, J., Likhomanenko, T., Grave, E., Pratap, V., Sriram, A., Liptchinsky, V., Collobert, R.: End-to-end asr: from supervised to semi-supervised learning with modern architectures. In: ICML Workshops (2020)
260
+ [47] Vaswani, A., Ramachandran, P., Srinivas, A., Parmar, N., Hechtman, B., Shlens, J.: Scaling local self-attention for parameter efficient visual backbones. In: CVPR. pp. 12894–12904 (2021)
261
+ [48] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., Polosukhin, I.: Attention is all you need. In: NIPS (2017)
262
+ [49] Vijayanarasimhan, S., Grauman, K.: Active frame selection for label propagation in videos. In: ECCV. pp. 496–509. Springer (2012)
263
+ [50] Voigtlaender, P., Chai, Y., Schroff, F., Adam, H., Leibe, B., Chen, L.C.: Feelvos: Fast end-to-end embedding learning for video object segmentation. In: CVPR. pp. 9481–9490 (2019)
264
+ [51] Voigtlaender, P., Leibe, B.: Online adaptation of convolutional neural networks for video object segmentation. In: BMVC (2017)
265
+ [52] Wang, W., Zhou, T., Porikli, F., Crandall, D., Van Gool, L.: A survey on deep learning technique for video segmentation. arXiv preprint arXiv:2107.01153 (2021)
266
+ [53] Wang, X., Girshick, R., Gupta, A., He, K.: Non-local neural networks. In: CVPR. pp. 7794– 7803 (2018)
267
+ [54] Wang, Y., Xu, Z., Wang, X., Shen, C., Cheng, B., Shen, H., Xia, H.: End-to-end video instance segmentation with transformers. In: CVPR. pp. 8741–8750 (2021)
268
+ [55] Wug Oh, S., Lee, J.Y., Sunkavalli, K., Joo Kim, S.: Fast video object segmentation by referenceguided mask propagation. In: CVPR. pp. 7376–7385 (2018)
269
+ [56] Xiao, H., Feng, J., Lin, G., Liu, Y., Zhang, M.: Monet: Deep motion exploitation for video object segmentation. In: CVPR. pp. 1140–1148 (2018)
270
+ [57] Xu, N., Yang, L., Fan, Y., Yue, D., Liang, Y., Yang, J., Huang, T.: Youtube-vos: A large-scale video object segmentation benchmark. arXiv preprint arXiv:1809.03327 (2018)
271
+ [58] Xu, X., Wang, J., Li, X., Lu, Y.: Reliable propagation-correction modulation for video object segmentation. In: AAAI (2022)
272
+ [59] Yan, B., Zhang, X., Wang, D., Lu, H., Yang, X.: Alpha-refine: Boosting tracking performance by precise bounding box estimation. In: CVPR. pp. 5289–5298 (2021)
273
+ [60] Yang, L., Wang, Y., Xiong, X., Yang, J., Katsaggelos, A.K.: Efficient video object segmentation via network modulation. In: CVPR. pp. 6499–6507 (2018)
274
+ [61] Yang, Z., Miao, J., Wang, X., Wei, Y., Yang, Y.: Associating objects with scalable transformers for video object segmentation. arXiv preprint arXiv:2203.11442 (2022)
275
+ [62] Yang, Z., Wei, Y., Yang, Y.: Collaborative video object segmentation by foreground-background integration. In: ECCV (2020)
276
+ [63] Yang, Z., Wei, Y., Yang, Y.: Associating objects with transformers for video object segmentation. In: NeurIPS (2021)
277
+ [64] Yang, Z., Wei, Y., Yang, Y.: Collaborative video object segmentation by multi-scale foregroundbackground integration. TPAMI (2021)
278
+ [65] Yang, Z., Zhang, J., Wang, W., Han, W., Yu, Y., Li, Y., Wang, J., Wei, Y., Sun, Y., Yang, Y.: Towards multi-object association from foreground-background integration. In: CVPR Workshops (2021)
279
+ [66] Zhu, F., Yang, Z., Yu, X., Yang, Y., Wei, Y.: Instance as identity: A generic online paradigm for video instance segmentation. In: ECCV (2022)
280
+
281
+ # Checklist
282
+
283
+ 1. For all authors...
284
+
285
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] see the end of Sec. 1
286
+ (b) Did you describe the limitations of your work? [Yes] we discuss the failure cases in Sec. 6, and demonstrate them in Fig. 4.
287
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] see the supplementary material.
288
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
289
+
290
+ 2. If you are including theoretical results...
291
+
292
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] the paper does not contain any theoretical assumptions.
293
+ (b) Did you include complete proofs of all theoretical results? [N/A] the paper does not contain any theoretical proofs.
294
+
295
+ 3. If you ran experiments...
296
+
297
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] the instructions and details needed to reproduce the main results are supplied in Sec. 5 and the supplementary material.
298
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] see Sec. 5 and the supplementary materials.
299
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] we follow the usual format used in previous state-ofthe-art methods [6, 11, 34, 43, 62, 63] to report and compare the results. Besides, all the networks are simultaneously evaluated on four benchmarks without re-training or checkpoint selection.
300
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] Sec. 5 and the supplementary materials.
301
+
302
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
303
+
304
+ (a) If your work uses existing assets, did you cite the creators? [Yes] we cite the creators or original papers of all the related code, data, and models used in this paper.
305
+ (b) Did you mention the license of the assets? [No] all the assets are free for research study and widely used in previous related works.
306
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] but the code of our proposed approach will be made publicly available as soon as the paper is accepted.
307
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] all the datasets are publicly available, free for research study, and commonly used in previous related works.
308
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] all the datasets are commonly used in previous research works.
309
+
310
+ 5. If you used crowdsourcing or conducted research with human subjects...
311
+
312
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] we didn’t use crowdsourcing or conduct research with human subjects.
313
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] we didn’t use crowdsourcing or conduct research with human subjects.
314
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] we didn’t use crowdsourcing or conduct research with human subjects.
md/dev/EAcWgk7JM58/EAcWgk7JM58.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PointNeXt: Revisiting PointNet++ with Improved Training and Scaling Strategies
2
+
3
+ Guocheng $\mathbf { Q i a n ^ { 1 * } }$ , Yuchen $\mathbf { L i } ^ { 1 } \mathbf { \dot { \mu } }$ ∗, Houwen Peng2†, Jinjie $\mathbf { M a i } ^ { 1 }$ , Hasan Abed Al Kader Hammoud1, Mohamed Elhoseiny1, Bernard Ghanem1† 1King Abdullah University of Science and Technology (KAUST), 2Microsoft Research
4
+
5
+ # Abstract
6
+
7
+ PointNet++ is one of the most influential neural architectures for point cloud understanding. Although the accuracy of PointNet $^ { + + }$ has been largely surpassed by recent networks such as PointMLP and Point Transformer, we find that a large portion of the performance gain is due to improved training strategies, i.e. data augmentation and optimization techniques, and increased model sizes rather than architectural innovations. Thus, the full potential of PointNet+ $^ { \cdot + }$ has yet to be explored. In this work, we revisit the classical PointNet+ $^ +$ through a systematic study of model training and scaling strategies, and offer two major contributions. First, we propose a set of improved training strategies that significantly improve PointNet+ $^ +$ performance. For example, we show that, without any change in architecture, the overall accuracy (OA) of PointNet $^ { + + }$ on ScanObjectNN object classification can be raised from $7 7 . 9 \%$ to $8 6 . 1 \%$ , even outperforming state-of-theart PointMLP. Second, we introduce an inverted residual bottleneck design and separable MLPs into PointNet $^ { + + }$ to enable efficient and effective model scaling and propose PointNeXt, the next version of PointNets. PointNeXt can be flexibly scaled up and outperforms state-of-the-art methods on both 3D classification and segmentation tasks. For classification, PointNeXt reaches an overall accuracy of $8 7 . 7 \%$ on ScanObjectNN, surpassing PointMLP by $2 . 3 \%$ , while being $1 0 \times$ faster in inference. For semantic segmentation, PointNeXt establishes a new state-of-theart performance with $7 4 . 9 \%$ mean IoU on S3DIS (6-fold cross-validation), being superior to the recent Point Transformer. The code and models are available at https://github.com/guochengqian/pointnext.
8
+
9
+ # 1 Introduction
10
+
11
+ Recent advances in 3D data acquisition have led to a surge in interest for point cloud understanding. With the rise of PointNet [27] and PointNet+ $^ +$ [28], processing point clouds in their unstructured format using deep CNNs become possible. Subsequent to “PointNets”, many point-based networks are introduced with the majority focusing on developing new and sophisticated modules to extract local structures, e.g. the pseudo-grid convolution in KPConv [41] and the self-attention layer in Point Transformer [54]. These newly proposed methods outperform PointNet++ by a large margin in a variety of tasks, leaving the impression that the PointNet++ architecture is too simple to learn complex point cloud representations. In this work, we revisit PointNet++, the classical and widely used network, and find that its full potential has yet to be explored, mainly due to two factors that were not present at the time of PointNet+ $^ +$ : (1) superior training strategies and (2) effective model scaling strategies.
12
+
13
+ Through a comprehensive empirical study on various benchmarks, e.g., ScanObjecNN [42] for object classification and S3DIS [1] for semantic segmentation, we discover that training strategies, i.e., data augmentation and optimization techniques, play an important role in the network’s performance. In fact, a large part of the performance gain of state-of-the-art (SOTA) methods [44, 41, 54] over Point$\mathrm { N e t } { + + }$ [28] is due to improved training strategies that are, unfortunately, less publicized compared to architectural changes. For example, randomly dropping colors during training can unexpectedly boost the testing performance of PointNet $^ { + + }$ by $5 . 9 \%$ mean IoU (mIoU) on S3DIS [1], as demonstrated in Tab. 5. In addition, adopting label smoothing [37] can improve the overall accuracy (OA) on ScanObjectNN [42] by $1 . 3 \%$ . These findings inspire us to revisit PointNet $^ { + + }$ and equip it with new advanced training strategies that are widely used today. Surprisingly, as shown in Fig. 1, utilizing the improved training strategies alone improves the OA of PointNet $^ { + + }$ by $8 . 2 \%$ on ScanObjectNN (from $7 7 . 9 \%$ to $8 6 . 1 \%$ ), establishing a new SOTA without introducing any changes to the architecture (refer to Sec. 4.4.1 for details). For the S3DIS segmentation benchmark, the mIoU evaluated in all areas by 6-fold cross-validation can increase by $1 3 . 6 \%$ (from $5 4 . 5 \%$ to $6 8 . 1 \%$ ), outperforming many modern architectures that are subsequent to PointNet++, such as PointCNN [21] and DeepGCN [20].
14
+
15
+ ![](images/5c053181f1c626125a021ca2dc7b6c5a5cb9faac88bdf59db1fe38a9052f51a6.jpg)
16
+ Figure 1: Effects of training strategies and model scaling on PointNet+ $^ +$ [28]. We show that improved training strategies (data augmentation and optimization techniques) and model scaling can significantly boost PointNet+ $^ { - + }$ performance. The average overall accuracy and mIoU (6-fold cross-validation) are reported on ScanObjectNN [42] and S3DIS [1].
17
+
18
+ Moreover, we observe that the current prevailing models [19, 41, 54] for point cloud analysis have employed many more parameters than the original PointNets [27, 28]. Effectively expanding PointNet++ from its original small scale to a larger scale is a topic worth studying because larger models are generally expected to enable richer representations and perform better [2, 18, 53]. However, we find that the naive way of using more building blocks or increasing the channel size in PointNet $^ { + + }$ only leads to an overhead in latency and no significant improvement in accuracy (see Sec. 4.4.2). For effective and efficient model scaling, we introduce residual connections [12], an inverted bottleneck design [34], and separable MLPs [30] into PointNet++. The modernized architecture is named PointNeXt, the next version of PointNets. PointNeXt can be scaled up flexibly and outperforms SOTA on various benchmarks. As demonstrated in Fig. 1, PointNeXt improves the original PointNet++ by $2 0 . 4 \%$ mIoU (from $5 4 . 5 \%$ to $7 4 . 9 \%$ ) on S3DIS [1] 6-fold and achieves $9 . 8 \%$ OA gains on ScanObjecNN [42], surpassing SOTA Point Transformer [54] and PointMLP [26]. We summarize our contributions next:
19
+
20
+ • We present the first systematic study of training strategies in the point cloud domain and show that PointNet $^ { \cdot + + }$ strikes back $+ 8 . 2 \%$ OA on ScanObjectNN and $+ 1 3 . 6 \%$ mIoU on S3DIS) by simply adopting improved training strategies alone. The improved training strategies are general and can be easily applied to improve other methods [27, 44, 26].
21
+
22
+ • We propose PointNeXt, the next version of PointNets. PointNeXt is scalable and surpasses SOTA on all tasks studied, including object classification [42, 47], semantic segmentation [1, 5], and part segmentation [51], while being faster than SOTA in inference.
23
+
24
+ # 2 Preliminary: A Review of PointNet++
25
+
26
+ Our PointNeXt is built upon PointNet+ $^ +$ [28], which uses a U-Net [33] like architecture with an encoder and a decoder, as visualized in Figure 2. The encoder part hierarchically abstracts features of point clouds using a number of set abstraction (SA) blocks, while the decoder gradually interpolates the abstracted features by the same number of feature propagation blocks. The SA block consists of a subsampling layer to downsample the incoming points, a grouping layer to query neighbors for each point, a set of shared multilayer perceptrons $( M L P s )$ to extract features, and a reduction layer to aggregate features within the neighbors. The combination of the grouping layer, MLPs, and the reduction layer is formulated as:
27
+
28
+ $$
29
+ \mathbf { x } _ { i } ^ { l + 1 } = \mathcal { R } _ { j : ( i , j ) \in N } \left\{ h _ { \Theta } \left( [ \mathbf { x } _ { j } ^ { l } ; \mathbf { p } _ { j } ^ { l } - \mathbf { p } _ { i } ^ { l } ] \right) \right\} ,
30
+ $$
31
+
32
+ where $\mathcal { R }$ is the reduction layer (e.g. max-pooling) that aggregates features for point $i$ from its neighbors denoted as $\{ j : ( i , { \dot { \jmath } } ) \in { \dot { N } } \}$ . $\mathbf { p } _ { i } ^ { l } , \dot { \mathbf { x } } _ { i } ^ { l }$ , $\mathbf { x } _ { j } ^ { l }$ are the input coordinates, the input features, and the features of neighbor $j$ in the ${ { l } ^ { t h } }$ layer of the network, respectively. $h _ { \Theta }$ denotes the shared MLPs that take the concatenation of $\mathbf { x } _ { j } ^ { l }$ and the relative coordinates $( \mathbf { p } _ { j } ^ { l } - \mathbf { p } _ { i } ^ { l } )$ as input. Note that, since PointNet $^ { + + }$ with single-scale grouping that uses one SA block per stage is the default architecture used in the original paper [28], we refer to it as PointNet+ $^ +$ throughout and use it as our baseline.
33
+
34
+ # 3 Methodology: From PointNet $^ { + + }$ to PointNeXt
35
+
36
+ In this section, we present how to modernize the classical architecture PointNet+ $^ +$ [28] into PointNeXt, the next version of PointNet $^ { + + }$ with SOTA performance. Our exploration mainly focuses on two aspects: (1) training modernization to improve data augmentation and optimization techniques, and (2) architectural modernization to probe receptive field scaling and model scaling. Both aspects have important impact on the model’s performance, but were under-explored by previous studies.
37
+
38
+ # 3.1 Training Modernization: PointNet+ $^ +$ Strikes Back
39
+
40
+ We conduct a systematic study to quantify the effect of each data augmentation and optimization technique used by modern point cloud networks [44, 41, 54] and propose a set of improved training strategies. The potential of PointNe $^ { + + }$ can be unveiled by adopting our proposed training strategies.
41
+
42
+ # 3.1.1 Data Augmentation
43
+
44
+ Data augmentation is one of the most important strategies to boost the performance of a neural network; thus we start our modernization from there. The original PointNet $^ { + + }$ used simple combinations of data augmentations from random rotation, scaling, translation, and jittering for various benchmarks [28]. Recent methods adopt stronger augmentations than those used in PointNet $^ { + + }$ . For example, KPConv [41] randomly drops colors during training, Point-BERT [52] uses a common point resampling strategy to randomly sample 1, 024 points from the original point cloud for data scaling, while RandLA-Net [14] and Point Transformer [54] load the entire scene as input in segmentation tasks. In this paper, we quantify the effect of each data augmentation through an additive study.
45
+
46
+ We start our study with PointNet $^ { + + }$ [28] as the baseline, which is trained with the original data augmentations and optimization techniques. We remove each data augmentation to check whether it is necessary or not. We add back the useful augmentations but remove the unnecessary ones. We then systematically study all the data augmentations used in the representative works [44, 41, 30, 54, 26, 52], including data scaling such as point resampling [52] and loading the entire scene as input [14], random rotation, random scaling, translation to shift point clouds, jittering to add independent noise to each point, height appending [41] (i.e., appending the measurement of each point along the gravity direction of objects as additional input features), color auto-contrast to automatically adjust color contrast [54], and color drop that randomly replaces colors with zero values. We verify the effectiveness of data augmentation incrementally and only keep the augmentations that give a better validation accuracy. At the end of this study, we provide a collection of data augmentations for each task that allow for the highest boost in the model’s performance. Sec. 4.4.1 presents and analyzes in detail the uncovered findings.
47
+
48
+ # 3.1.2 Optimization Techniques
49
+
50
+ Optimization techniques including loss functions, optimizers, learning rate schedulers, and hyperparameters are also vital to the performance of a neural network. PointNet++ uses the same optimization techniques throughout its experiments: CrossEntropy loss, Adam optimizer [15], exponential learning rate decay (Step Decay), and the same hyperparmeters. Owing to the development of machine learning theory, modern neural networks can be trained with theoretically better optimizers (e.g. AdamW [25] vs. Adam [15]) and more advanced loss functions (CrossEntropy with label smoothing [37]). Similarly to our study on data augmentations, we also quantify the effect of each modern optimization technique on PointNet++. We first perform a sequential hyperparameter search for the learning rate and weight decay. We then conduct an additive study on label smoothing, optimizer, and learning rate scheduler. We discover a set of improved optimization techniques that further boost performance by a decent margin. In general, CrossEntropy with label smoothing, AdamW, and Cosine Decay can decently optimize models in various tasks. See Sec. 4.4.1 for detailed findings.
51
+
52
+ ![](images/8e5e89bc977593daea22b8abeeaafc1f96128d4dc35decb746690481670f7b3e.jpg)
53
+ Figure 2: PointNeXt architecture. PointNeXt shares the same Set Abstraction and Feature Propagation blocks as PointNet $^ { - + }$ [28], while adding an additional MLP layer at the beginning and scaling the architecture with the proposed Inverted Residual MLP (InvResMLP) blocks.
54
+
55
+ # 3.2 Architecture Modernization: Small Modifications Big Improvements
56
+
57
+ In this subsection, we modernize PointNet+ $^ +$ [28] into the proposed PointNeXt. The modernization consists of two aspects: (1) receptive field scaling and (2) model scaling.
58
+
59
+ # 3.2.1 Receptive Field Scaling
60
+
61
+ The receptive field is a significant factor in the design space of a neural network [36, 6]. There are at least two ways to scale the receptive field in point cloud processing: (1) adopting a larger radius to query the neighborhood, and (2) adopting a hierarchical architecture. Since the hierarchical architecture has been adopted in the original PointNet++, we mainly study (1) in this subsection. Note that the radius of PointNet++ is set to an initial value $r$ that doubles when the point cloud is downsampled. We study a different initial value in each benchmark and discover that the radius is dataset-specific and can have significant influence on performance. This is elaborated in Sec. 4.4.2.
62
+
63
+ Furthermore, we find that the relative coordinates $\Delta _ { p } = { \bf p } _ { j } ^ { l } - { \bf p } _ { i } ^ { l }$ in Eq. (1) make network optimization harder, leading to a decrease in performance. Thus, we propose relative position normalization $( \Delta _ { p }$ normalization) to divide relative position by the neighborhood query radius:
64
+
65
+ $$
66
+ \mathbf { x } _ { i } ^ { l + 1 } = \mathcal { R } _ { j : ( i , j ) \in \mathcal { N } } \left\{ h _ { \Theta } \left( [ \mathbf { x } _ { j } ^ { l } ; ( \mathbf { p } _ { j } ^ { l } - \mathbf { p } _ { i } ^ { l } ) / r ^ { l } ] \right) \right\} .
67
+ $$
68
+
69
+ Without normalization, values of relative positions $( \Delta _ { p } = \mathbf { p } _ { j } ^ { l } - \mathbf { p } _ { i } ^ { l } )$ are considerably small (less than the radius), requiring the network to learn a larger weight to apply on $\Delta _ { p }$ . This makes the optimization non-trivial, especially since weight decay is used to reduce the weights of the network and thus tends to ignore the effects of relative position. The proposed normalization alleviates this issue by rescaling and in the meantime reduces the variance of $\Delta _ { p }$ among different stages.
70
+
71
+ # 3.2.2 Model Scaling
72
+
73
+ PointNe $^ { + + }$ is a relatively small network, where the encoder consists of only 2 stages in the classification architecture and 4 stages for segmentation. Each stage consists of only 1 SA block, and each block contains 3 layers of MLP. The model sizes of PointNe $^ { + + }$ for both classification and segmentation are less than 2M, which is much smaller compared to modern networks that typically use more than 10M parameters [41, 26, 30]. Interestingly, we find that neither appending more SA blocks nor using more channels leads to a noticeable improvement in accuracy, while causing a significant drop in throughput (refer to Sec. 4.4.2), mainly due to vanishing gradient and overfitting. Therefore, in this subsection, we study how to scale up PointNet+ $^ +$ in an effective and efficient way.
74
+
75
+ We propose an Inverted Residual MLP (InvResMLP) block to be appended after the first SA block, per stage, for effective and efficient model scaling. InvResMLP is built on the SA block and is illustrated at the bottom middle of Fig. 2. There are three differences between InvResMLP and SA. (1) A residual connection between the input and the output is added to alleviate the vanishing gradient problem [12], especially when the network goes deeper. (2) Separable MLPs are introduced to reduce computation and reinforce pointwise feature extraction. While all 3 layers of MLPs in the original SA block are computed on the neighborhood features, InvResMLP separates the MLPs into a single layer computed on the neighborhood features (between the grouping and reduction layers) and two layers for point features (after reduction), as inspired by MobileNet [13] and ASSANet [30]. (3) The inverted bottleneck design [34] is leveraged to expand the output channels of the second MLP by 4 times to enrich feature extraction. Appending InvResMLP blocks is proven to significantly improve performance compared to the appending of the original SA blocks (see Sec. 4.4.2).
76
+
77
+ In addition to InvResMLP, we present three changes in the macro architecture. (1) We unify the design of PointNe $^ { + + }$ encoder for classification and segmentation, i.e., scaling the number of SA blocks for classification from 2 to 4 while keeping the original number (4 blocks) for segmentation at each stage. (2) We utilize a symmetric decoder in which its channel size is changed to match the encoder. (3) We add a stem MLP, an additional MLP layer inserted at the beginning of the architecture, to map the input point cloud to a higher dimension.
78
+
79
+ In summary, we present PointNeXt, the next version of PointNets [27, 50], modified from PointNet+ $^ +$ by incorporating the proposed InvResMLP and the aforementioned macro-architectural changes. The architecture of PointNeXt is illustrated in Fig. 2. We denote the channel size of the stem MLP as $C$ and the number of InvResMLP blocks as $B$ . A larger $C$ leads to an increase in the width of the network (i.e., width scaling), while a larger $B$ leads to an increase in the depth of the network (i.e., depth scaling). Note that when $B = 0$ , only one SA block and no InvResMLP blocks are used at each stage. The number of MLP layers in the SA block is set to 2, and a residual connection is added inside each SA block. When $B \neq 0$ , InvResMLP blocks are appended after the original SA block. The number of MLP layers in the SA block in this case is set to 1 to save computation cost. The configuration of our PointNeXt family is summarized as follows:
80
+
81
+ • PointNeXt-S: $C = 3 2 , B = 0$ • PointNeXt-B: $C = 3 2 , B = ( 1 , 2 , 1 , 1 )$
82
+
83
+ • PointNeXt-L: $C = 3 2$ , $B = ( 2 , 4 , 2 , 2 )$ • PointNeXt-XL: $C = 6 4 , B = ( 3 , 6 , 3 , 3 )$
84
+
85
+ # 4 Experiments
86
+
87
+ We evaluate PointNeXt on five standard benchmarks: S3DIS [1] and ScanNet [5] for semantic segmentation, ScanObjectNN [42] and ModelNet40 [47] for object classification, and ShapeNetPart [3] for object part segmentation.
88
+
89
+ Experimental Setups. We train PointNeXt using CrossEntropy loss with label smoothing [37], AdamW optimizer [25], an initial learning rate $l r = 0 . 0 0 1$ , weight decay $1 0 ^ { - 4 }$ , with Cosine Decay, and a batch size of 32, with a 32G V100 GPU, for all tasks, unless otherwise specified. The best model on the validation set is selected for testing. For S3DIS segmentation, point clouds are voxel downsampled with a voxel size of $0 . 0 4 \mathrm { { m } }$ following common practice [41, 30, 54]. PointNeXt is trained with an initial $l r = 0 . 0 1$ , for 100 epochs (training set is repeated by 30 times), using a fixed number of points (24, 000) per batch with a batch size of 8 as input. During training, the input points are obtained by querying the nearest neighbors of a random point in each iteration. Following Point Transformer [54], we evaluate PointNeXt using the entire voxel-downsampled scene as input. For ScanNet scene segmentation, we follow the Stratified Transformer [16] and train PointNeXt with multi-step learning rate decay and decay at [70,90] epochs with a decay rate of 0.1 without label smoothing. The voxel size is set to $0 . 0 2 \mathrm { m }$ and input number of points in training is set to 64, 000. We train the model for 100 epochs (training set is repeated for 6 times) with a batch size of 2 per GPU with 8 GPUs. For ScanObjectNN classification, PointNeXt is trained with a weight decay of 0.05 for 250 epochs. Following Point-BERT [52], the number of input points is set to 1, 024, where the points are randomly sampled during training and uniformly sampled during testing (denoted as point resampled augmentation). For ModelNet40 classification, PointNeXt is trained similarly as ScanObjectNN but for 600 epochs. For ShapeNetPart part segmentation, we train PointNeXt using a batch size of 8 per GPU with 4 GPUs, and Poly FocalLoss [17] as criterion, for 400 epochs. Following PointNet++, 2,048 randomly sampled points with normals are used as input for training and testing. The details of data augmentations used in S3DIS, ScanNet, ScanObjectNN, ModelNet40 and ShapeNetPart are detailed in Sec. 4.4.1.
90
+
91
+ Table 1: 3D semantic segmentation in S3DIS (evaluation by 6-Fold or in Area 5) and ScanNet V2. For PointNeXt in S3DIS Area 5, the average results without voting in three random runs are reported. The improvements of PointNeXt over the original performance reported by PointNet $^ { - + }$ [28] are highlighted in green color. PointNet+ $^ { \cdot + }$ (ours) denotes PointNet++ trained using our improved data augmentation and optmization techniques. Methods are in chronological order.
92
+
93
+ <table><tr><td rowspan="2">Method</td><td colspan="2">S3DIS 6-Fold</td><td colspan="2">S3DIS Area-5</td><td colspan="2">ScanNet V2</td><td rowspan="2"></td><td rowspan="2">Params.FLOPs Throughput</td><td rowspan="2"></td></tr><tr><td>mIoU</td><td>OA</td><td>mIoU</td><td>OA</td><td>Val mIoU</td><td>Test mIoU</td></tr><tr><td></td><td>(%)</td><td>(%)</td><td>(%)</td><td>(%)</td><td>(%)</td><td>(%)</td><td>M</td><td>G</td><td>(ins./sec.)</td></tr><tr><td>PointNet [27]</td><td>47.6</td><td>78.5</td><td>41.1</td><td></td><td>-</td><td>■</td><td>3.6</td><td>35.5</td><td>162</td></tr><tr><td>PointCNN [21]</td><td>65.4</td><td>88.1</td><td>57.3</td><td>85.9</td><td>■</td><td>45.8</td><td>0.6</td><td>=</td><td>-</td></tr><tr><td>DGCNN [44]</td><td>56.1</td><td>84.1</td><td>47.9</td><td>83.6</td><td>■</td><td>=</td><td>1.3</td><td>=</td><td>8</td></tr><tr><td>DeepGCN[20]</td><td>60.0</td><td>85.9</td><td>52.5</td><td>■</td><td>■</td><td></td><td>3.6</td><td></td><td>3</td></tr><tr><td>KPConv [41]</td><td>70.6</td><td></td><td>67.1</td><td>=</td><td>69.2</td><td>68.6</td><td>15.0</td><td>=</td><td>30</td></tr><tr><td>RandLA-Net [14]</td><td>70.0</td><td>88.0 88.9</td><td></td><td>=</td><td>=</td><td>64.5</td><td>1.3</td><td>5.8</td><td>159</td></tr><tr><td>BAAF-Net [31] Point Transformer [54]</td><td>72.2 73.5</td><td>90.2</td><td>65.4 70.4</td><td>88.9 90.8</td><td>70.6</td><td>=</td><td>5.0 7.8</td><td>=</td><td>10</td></tr><tr><td>CBL [39]</td><td>73.1</td><td>89.6</td><td>69.4</td><td>90.6</td><td>■</td><td>= 70.5</td><td>18.6</td><td>5.6</td><td>34</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>-</td><td>-</td></tr><tr><td>PointNet++ [28]</td><td>54.5</td><td>81.0 87.6(+6.2)</td><td>53.5</td><td>83.0</td><td>53.5</td><td>55.7</td><td>1.0</td><td>7.2</td><td>186</td></tr><tr><td>PointNet++ (ours)</td><td>68.1(+13.6)</td><td>87.4(+6.4)</td><td>63.2±0.4(+9.7)</td><td>87.5±0.2(+4.5)</td><td>57.2(+3.7) 64.5(+11.0)</td><td></td><td>1.0</td><td>7.2</td><td>186</td></tr><tr><td>PointNeXt-S (ours)</td><td>68.0(+13.5) 71.5(+17.0)</td><td>88.8(+7.8)</td><td>63.4±0.8(+9.9)</td><td>87.9±0.3(+4.9)</td><td>68.4(±14.9)</td><td></td><td>0.8 3.8</td><td>3.6</td><td>227</td></tr><tr><td>PointNeXt-B (ours)</td><td>73.9(+19.4)</td><td>89.8(+8.8)</td><td>67.3±0.2(+13.8) 69.0±0.5(±15.5)</td><td>89.4±0.1(+6.4)</td><td>69.4(+15.9)</td><td></td><td>7.1</td><td>8.9 15.2</td><td>158</td></tr><tr><td>PointNeXt-L (ours)</td><td></td><td></td><td></td><td>90.0±0.1(+7.0)</td><td></td><td></td><td></td><td></td><td>115</td></tr><tr><td>PointNeXt-XL (ours)</td><td>74.9 (+20.4)</td><td>90.3 (+9.3)</td><td>70.5±0.3(±17.0)</td><td>90.6±0.1(+7.6)</td><td>71.5(+18.0)</td><td>71.2(+15.5)</td><td>41.6</td><td>84.8</td><td>46</td></tr></table>
94
+
95
+ For all experiments except ShapeNetPart segmentation, we do not conduct any voting $[ 2 2 ]$ , since it is more standard to compare the performance without using any ensemble methods as suggested by SimpleView [8]. However, we found that the performance in ShapeNetPart of nearly all models is quite close to each other, where it is hard to achieve state-of-the-art IoUs without voting. We also provide model parameters (Params.) and inference throughput (instances per second) for comparison. The throughput of all methods is measured using $1 2 8 \times 1 0 2 4$ (batch size 128, number of points 1024) as input in ScanObjectNN and ModelNet40 and $6 4 \times 2 0 4 8$ in ShapeNetPart. In S3DIS, $1 6 \times 1 5$ , 000 points are used to measure throughput following [30], since some methods [44, 19] could not process the whole scene due to memory constraints. The throughput of all methods is measured using an NVIDIA Tesla V100 32GB GPU and a 32 core Intel Xeon $@$ 2.80GHz CPU.
96
+
97
+ # 4.1 3D Semantic Segmentation in S3DIS and ScanNet
98
+
99
+ S3DIS [1] (Stanford Large-Scale 3D Indoor Spaces) is a challenging benchmark composed of 6 large-scale indoor areas, 271 rooms, and 13 semantic categories in total. The standard 6-fold cross-validation results in S3DIS are reported in Tab. 1. Note that the official PointNet+ $^ +$ [28] did not conduct experiments in S3DIS. Here, we use the results reported by PointCNN [21] for comparison. Our PointNeXt-S, the smallest variant, outperforms PointNe $^ { + + }$ by $1 3 . 5 \%$ , $6 . 4 \%$ , and $1 0 . 2 \%$ in terms of mean IoU (mIoU), overall accuracy (OA), and mean accuracy (mAcc), respectively, while being faster in terms of throughput. The increased speed is due to the reduced number of layers in the SA block for PointNeXt-S (see Sec. 3.2.2). With the proposed model scaling, the performance of PointNeXt can be gradually boosted. For example, PointNeXt-L outperforms SOTA Point Transformer [54] by $0 . 4 \%$ in mIoU while being $3 \times$ faster. Note that Point Transformer utilizes most of the improved training strategies of ours. PointNeXt-XL, the extra large variant, achieves mIoU/OA/mAcc of $7 4 . 9 \% / 9 0 . 3 \% / 8 3 . 0 \%$ , while running faster than Point Transformer. As a limitation, our PointNeXt-XL consists of more parameters and is more computationally expensive in terms of FLOPs, mainly due to channel expansion $( \times 4 )$ in the inverted bottleneck and doubled initial channel size $C = 6 4$ ). We also provide the results of PointNeXt in S3DIS area 5 in the Tab. 1 with mean±std in three random runs, where PointNeXt achieves similar improvements as the 6-fold experiments.
100
+
101
+ ScanNet [5], another well-known large-scale segmentation dataset, contains 3D indoor scenes of various rooms with 20 semantic categories. We follow the public training, validation, and test splits, with 1201, 312 and 100 scans, respectively. For PointNet $^ { + + }$ , we use the results reported from the Stratified Transformer [16] for comparison. As shown in Tab. 1, we improve PointNet+ $^ { - + }$ from $5 3 . 5 \%$ mIou to $5 7 . 2 \%$ mIoU in the validation set by adopting the improved training strategies (detailed in supplementary material). PointNeXt-S further gains $+ 1 1 . 0$ in val mIoU over the original PointNet++ mostly due to the use of a smaller radius $\mathrm { 0 . 1 m \to 0 . 0 5 m } )$ and relative position normalization. The performance in ScanNet improves steadily with the increase in model sizes. Our largest variant,
102
+
103
+ Table 2: 3D object classification in ScanObjectNN and ModelNet40. Averaged results in three random runs using 1024 points as input without normals and without voting are reported.
104
+
105
+ <table><tr><td rowspan="2">Method</td><td colspan="2">ScanObjectNN (PB_T50_RS)</td><td colspan="2">ModelNet40</td><td rowspan="2">Params. M</td><td rowspan="2">FLOPs G</td><td rowspan="2">Throughput (ins./sec.)</td></tr><tr><td>OA (%)</td><td>mAcc (%)</td><td>OA (%)</td><td>mAcc (%)</td></tr><tr><td>PointNet [27]</td><td>68.2</td><td>63.4</td><td>89.2</td><td>86.2</td><td>3.5</td><td>0.9</td><td>4212</td></tr><tr><td>PointCNN [21]</td><td>78.5</td><td>75.1</td><td>92.2</td><td>88.1</td><td>0.6</td><td>=</td><td>44</td></tr><tr><td>DGCNN [44]</td><td>78.1</td><td>73.6</td><td>92.9</td><td>90.2</td><td>1.8</td><td>4.8</td><td>402</td></tr><tr><td>DeepGCN[19]</td><td></td><td>-</td><td>93.6</td><td>90.9</td><td>2.2</td><td>3.9</td><td>263</td></tr><tr><td>KPConv [41]</td><td></td><td></td><td>92.9</td><td>1</td><td>14.3</td><td>1</td><td>-</td></tr><tr><td>ASSANet-L [30]</td><td>=</td><td>=</td><td>92.9</td><td>-</td><td>118.4</td><td>1</td><td>153</td></tr><tr><td>SimpleView [8]</td><td>80.5±0.3</td><td></td><td>93.0±0.4</td><td>90.5±0.8</td><td>0.8</td><td>-</td><td>-</td></tr><tr><td>MVTN</td><td>82.8</td><td></td><td>93.5</td><td>92.2</td><td>3.5</td><td>1.8</td><td>236</td></tr><tr><td>Point Cloud Transformer [10]</td><td></td><td></td><td>93.2</td><td>-</td><td>2.9</td><td>2.3</td><td></td></tr><tr><td>CurveNet [48] PointMLP [26]</td><td>85.4±1.3</td><td>83.9±1.5</td><td>93.8 94.1</td><td>91.3</td><td>2.0 13.2</td><td>- 31.3</td><td>22</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>191</td></tr><tr><td>PointNet++ [28] PointNet++ (ours)</td><td>77.9 86.1±0.7(+8.2)</td><td>75.4 84.2±0.9(+8.8)</td><td>91.9</td><td>89.9±0.8</td><td>1.5 1.5</td><td>1.7 1.7</td><td>1872</td></tr><tr><td></td><td></td><td></td><td>92.8±0.1(+0.9)</td><td></td><td></td><td></td><td>1872</td></tr><tr><td>PointNeXt-S (ours)</td><td>87.7±0.4(+9.8)</td><td>85.8±0.6(+10.4)</td><td>93.2±0.1(+1.3)</td><td>90.8±0.2</td><td>1.4</td><td>1.6</td><td>2040</td></tr></table>
106
+
107
+ PointNeXt-XL outperforms PointNet+ $^ +$ by $1 8 . 0 \%$ mIoU in validation and achieves $7 1 . 2 \%$ mIoU in testing, beating the recent methods Point Transformer [54] and CBL [39].
108
+
109
+ # 4.2 3D Object Classification in ScanObjectNN and ModelNet40
110
+
111
+ ScanObjectNN [42] contains about 15, 000 real scanned objects that are categorized into 15 classes with 2, 902 unique object instances. Due to occlusions and noise, ScanObjectNN poses significant challenges to existing point cloud analysis methods. Following PointMLP [26], we experiment on PB_T50_RS, the hardest and most commonly used variant of ScanObjectNN. As reported in Tab. 2, the proposed PointNeXt-S surpasses existing methods by non-trivial margins in terms of both OA and mAcc, while using much fewer model parameters and running much faster. Built upon PointNet+ $^ +$ [28], PointNeXt achieves significant improvements over the originally reported performance of PointNe $^ { [ + + }$ , i.e. $+ 9 . 8 \%$ OA and $+ 1 0 . 4 \%$ mACC. This demonstrates the efficacy of the proposed training and model scaling strategies. PointNeXt also outperforms SOTA PointMLP [26] (i.e. $+ 2 . 3 \%$ OA, $+ 1 . 9 \%$ mACC), while running $1 0 \times$ faster. This shows that PointNeXt is a simple, yet effective, and efficient baseline. Note that we did not experiment with upscaled variants of PointNeXt on this benchmark, since we found that the performance had saturated using PointNeXt-S mostly due to the limited scale of the dataset.
112
+
113
+ ModelNet40 [47] was a commonly used 3D object classification dataset, which has 40 object categories, each of which contains 100 unique CAD models. However, recent works [11, 26, 32] show an increasing interest in the real-world scanned dataset ScanObejectNN compared to this synthesized dataset. Following this trend, we mainly benchmarked PointNeXt in ScanObjectNN. Here, we also provide our results in ModelNet40. Tab. 2 shows that advanced training strategies improve PointNet++ from $9 1 . 9 \%$ OA to $9 2 . 8 \%$ OA without any architecture change. PointNeXt-S $C = 3 2$ ) outperforms the original reported PointNet $^ { + + }$ by $1 . 3 \%$ OA, while being faster. Note that PointNeXt-S with a larger width $C = 6 4$ can achieve a higher overall accuracy $( 9 4 . 0 \% )$ .
114
+
115
+ # 4.3 3D Object Part Segmentation in ShapeNetPart
116
+
117
+ ShapeNetPart [51] is a widely-used dataset for object-level part segmentation. It consists of 16, 880 models from 16 different shape categories, 2-6 parts for each category, and 50 part labels in total. As shown in Tab. 3, our PointNeXt-S with default width $C = 3 2$ ) obtains a performance comparable
118
+
119
+ Table 3: Part segmentation in ShapeNetPart.
120
+
121
+ <table><tr><td>Method</td><td>ins.mIoU</td><td>cls.mloU</td><td>Params.</td><td>FLOPs</td><td>Throughput</td></tr><tr><td>PointNet [27]</td><td>83.7</td><td>80.4</td><td>3.6</td><td>4.9</td><td>1184</td></tr><tr><td>DGCNN [44]</td><td>85.2</td><td>82.3</td><td>1.3</td><td>12.4</td><td>147</td></tr><tr><td>KPConv [41]</td><td>86.4</td><td>85.1</td><td>-</td><td>-</td><td>44</td></tr><tr><td>CurveNet [48]</td><td>86.8</td><td>-</td><td>-</td><td></td><td>97</td></tr><tr><td>ASSANet-L [30]</td><td>86.1</td><td>-</td><td>-</td><td>=</td><td>640</td></tr><tr><td>Point Transformer [54]</td><td>86.6</td><td>83.7</td><td>7.8</td><td></td><td>297</td></tr><tr><td>PointMLP[26]</td><td>86.1</td><td>84.6</td><td>-</td><td></td><td>270</td></tr><tr><td>Stratifiedformer[16]</td><td>86.6</td><td>85.1</td><td>-</td><td>-</td><td>398</td></tr><tr><td>PointNet++ [28]</td><td>85.1</td><td>81.9</td><td>1.0</td><td>4.9</td><td>708</td></tr><tr><td>PointNeXt-S</td><td>86.7±0.0(+1.6)</td><td>84.4±0.2(+2.5)</td><td>1.0</td><td>4.5</td><td>782</td></tr><tr><td>PointNeXt-S (C=64)</td><td>86.9±0.1(+1.8)</td><td>84.8±0.5(+2.9)</td><td>3.7</td><td>17.8</td><td>331</td></tr><tr><td>PointNeXt-S (C=160)</td><td>87.0±0.1(+1.9)</td><td>85.2±0.1(+3.3)</td><td>22.5</td><td>110.2</td><td>76</td></tr></table>
122
+
123
+ to that of the SOTA CurveNet [48] and outperforms a large number of representative networks, such as KPConv [41] and ASSANet [30] in terms of both instance mean IoU (ins. mIoU) and throughput. Due to the small scale of ShapeNetPart, the model would overfit after being depth scaled. However, we find by increasing the width from 32 to 64 instead, PointNeXt can outperform CurveNet, while being over $4 \times$ faster. It is also worth highlighting that PointNeXt with an even larger width ( $C = 1 6 0$ ) reaches $8 7 . 0 \%$ Ins. mIoU, whereas the performance of point-based methods has saturated below this value for years. We highlight that we used voting only in ShapeNetPart by averaging the results of 10 randomly scaled input point clouds, with scaling factors equal to [0.8,1.2]. Without voting, we notice a performance drop around 0.5 instance mIoU.
124
+
125
+ # 4.4 Ablation and Analysis
126
+
127
+ Tab. 4 and Tab. 5 present additive studies for the proposed training and scaling strategies in ScanObjectNN [42] and S3DIS [1], respectively. We adopt the original PointNet+ $^ { - + }$ as the baseline. In ScanObjectNN, PointNet+ $^ +$ was trained by [42] with CrossEntropy loss, Adam optimizer, a learning rate 1e-3, a weight decay of 1e-4, a step decay of 0.7 for every 20 epochs, and a batch size of 16, for 250 epochs, while using random rotation and jittering as data augmentations. The official PointNet $^ { + + }$ did not conduct experiments in S3DIS dataset. We refer to the widely used reimplementation [50], where PointNet $^ { + + }$ was trained with the same settings as ScanObjectNN except that only random rotation was used as augmentation. Note that for all experiments, we train all our models for 250 epochs in ScanObjectNN and for 100 epochs in S3DIS.
128
+
129
+ # 4.4.1 Training Strategies
130
+
131
+ Data augmentation is the first aspect that we study to modernize PointNet+ $^ +$ . We draw four conclusions based on observations in Tab. 4 and 5. (1) Data scaling improves performance for both classification and segmentation tasks. For example, point resampling is shown to boost the performance by $2 . 5 \%$ OA in ScanObjectNN. Taking the entire scene as input instead of using the block or sphere subsampled input as done in PointNet+ $^ { - + }$ [28] and other previous works [41, 20, 30] improves the segmentation result by $1 . 1 \%$ mIoU. (2) Height appending improves performance, especially for object classification. Height appending makes the network aware of the actual size of the objects, thus leading to an increase in accuracy $( + 1 . 1 \%$ OA). (3) Color drop is a strong augmentation that significantly improves the performance of tasks where colors are available. Adopting color drop alone adds $5 . 9 \%$ mIoU in S3DIS area 5. We hypothesize that color drop forces the network to focus more on the geometric relationships between points, which in turn improves performance. (4) Larger models favor stronger data augmentation. Whereas random rotation drops the performance of PointNet+ $^ +$ by $0 . 3 \%$ mIoU in S3DIS $2 ^ { n d }$ row in Tab. 5 data augmentation part), it is shown to be beneficial for larger-scale models (e.g. raises $1 . 5 \%$ mIoU on PointNeXt-B). Another example in ScanObjectNN shows that the removal of random jittering also adds $1 . 1 \%$ OA. In general, with the improved data augmentations, the OA of PointNet+ $^ +$ in ScanObjectNN and the mIoU in S3DIS area 5 are increased by $5 . 8 \%$ and $9 . 5 \%$ , respectively.
132
+
133
+ Table 4: Additive study of sequentially applying training and scaling strategies for classification on ScanObjectNN. We use light green, purple, yellow, and pink background colors to denote data augmentation, optimization techniques, receptive field scaling, and model scaling, respectively.
134
+
135
+ <table><tr><td rowspan=1 colspan=5>Improvements</td><td rowspan=1 colspan=1>OA (%)</td><td rowspan=1 colspan=1>A</td></tr><tr><td rowspan=1 colspan=5>PointNet++</td><td rowspan=1 colspan=1>77.9</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=6 colspan=5>+ Point resampling- Jittering + Height appending+ Random scaling+ Label Smoothing+ Adam → AdamW+ AdamW → SGD + Step Decay → Cosine Decay</td><td rowspan=1 colspan=1>81.4± 0.6</td><td rowspan=1 colspan=1>+3.5</td></tr><tr><td rowspan=1 colspan=1>g</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>82.5 ± 0.4</td><td rowspan=3 colspan=1>+1.1+1.1+0.1+1.3</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>83.6 ± 0.4</td></tr><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1>83.7± 0.285.0 ± 0.5</td></tr><tr><td rowspan=1 colspan=1>85.6 ± 0.1</td><td rowspan=1 colspan=1>+0.6</td></tr><tr><td rowspan=1 colspan=1>84.8 ± 0.186.1 ± 0.7</td><td rowspan=1 colspan=1>-0.8+0.5</td></tr><tr><td rowspan=1 colspan=5>+ Radius 0.2 → 0.15+ Normalizing △p (Eqn. (2)+ Scale up (PointNeXt-S)</td><td rowspan=1 colspan=1>86.4± 0.386.7 ± 0.387.7 ± 0.4</td><td rowspan=1 colspan=1>+0.3+0.3+1.0</td></tr></table>
136
+
137
+ Table 5: Additive study of sequentially applying training and scaling strategies for segmentation on S3DIS area 5. $+ / -$ denote adopting/removing the strategy.
138
+
139
+ <table><tr><td rowspan=1 colspan=2>Improvements</td><td rowspan=1 colspan=1>mIoU (%)</td><td rowspan=1 colspan=1>△</td></tr><tr><td rowspan=1 colspan=2>PointNet++</td><td rowspan=1 colspan=1>51.5</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=9 colspan=2>+ Entire scene as input-Rotation+ Height appending+ Color drop+ Color auto-contrast+ lr = 0.001 -→ 0.01+ Label Smoothing+ Adam → AdamW+ AdamW → SGD + Step Decay → Cosine Decay</td><td rowspan=1 colspan=1>52.6 ± 0.5</td><td rowspan=1 colspan=1>+1.1</td></tr><tr><td rowspan=1 colspan=1>52.9 ± 0.6</td><td rowspan=1 colspan=1>+0.3</td></tr><tr><td rowspan=1 colspan=1>53.4 ± 0.4</td><td rowspan=1 colspan=1>+0.5</td></tr><tr><td rowspan=1 colspan=1>59.3 ± 0.7</td><td rowspan=1 colspan=1>+5.9</td></tr><tr><td rowspan=1 colspan=1>61.0 ± 0.4</td><td rowspan=1 colspan=1>+1.7</td></tr><tr><td rowspan=1 colspan=1>61.5 ± 0.5</td><td rowspan=1 colspan=1>+0.5</td></tr><tr><td rowspan=1 colspan=1>61.9 ± 0.1</td><td rowspan=1 colspan=1>+0.4</td></tr><tr><td rowspan=1 colspan=1>62.5 ± 0.6</td><td rowspan=2 colspan=1>+0.6-3.1+0.7</td></tr><tr><td rowspan=1 colspan=1>59.4 ± 0.563.2 ± 0.4</td></tr><tr><td rowspan=1 colspan=2>+ Normalize△p</td><td rowspan=1 colspan=1>63.6 ± 0.4</td><td rowspan=1 colspan=1>+0.4</td></tr><tr><td rowspan=3 colspan=2>+ Scale down (PointNeXt-S)+ Scale up (PointNeXt-B)+ Rotation+ Scale up (PointNeXt-L)+ Scale up (PointNeXt-XL)</td><td rowspan=1 colspan=1>63.4± 0.8</td><td rowspan=3 colspan=1>-0.2+2.4 +1.5 +1.7+1.5</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>65.8 ± 0.5</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>67.3 ± 0.269.0 ± 0.570.5 ± 0.3</td></tr></table>
140
+
141
+ Optimization techniques involve loss functions, optimizers, learning rate schedulers, and hyperparameters. As shown in Tab. 4 and 5, Label Smoothing, AdamW [25] optimizer, and Cosine Decay consistently boost performance in both classification and segmentation tasks. This reveals that the more developed optimization methods such as label smoothing and AdamW are generally good for optimizing a neural network. Compared to Step Decay, Cosine Decay is also easier to tune (usually only the initial and minimum learning rates are required) and can achieve a performance similar to Step Decay. Regarding hyperparameters, using a learning rate greater than that used in PointNet++ improves the segmentation performance in S3DIS.
142
+
143
+ In general, our training strategies consisted of stronger data augmentation and modern optimization techniques can increase the performance of PointNet $^ { - + }$ from $7 7 . 9 \%$ to $8 6 . 1 \%$ OA in ScanObjectNN dataset, impressively surpassing SOTA PointMLP by $0 . 7 \%$ . The mIoUs in S3DIS area 5 and S3DIS 6-fold (illustrated in Fig. 1) are boosted by 11.7 and 13.6 absolute percentage points, respectively. Our observations imply that a significant portion of the performance gap between classical PointNet+ $^ +$ and SOTA is due to the training strategies.
144
+
145
+ Generalize to other networks. Although the training strategies are proposed for PointNet+ $^ { \cdot + }$ [28], we find that they can be applied to other methods such as PointNet [27], DGCNN [44], and PointMLP [26], and also improve their performance. Such generalizability is validated in ScanObjectNN [42]. As shown in Tab. 6, the OA of the representative methods can all be improved when equipped with our training strategies.
146
+
147
+ Table 6: The generalizability of improved training strategies. OA on ScanObjectNN of networks trained with improved training strategies is reported.
148
+
149
+ <table><tr><td>Method</td><td>ours</td><td>△</td></tr><tr><td>PointNet [27]</td><td>74.4±0.9</td><td>+6.2</td></tr><tr><td>DGCNN [44]</td><td>86.0± 0.5</td><td>+7.9</td></tr><tr><td>PointMLP[26]</td><td>87.1± 0.7</td><td>+1.7</td></tr></table>
150
+
151
+ # 4.4.2 Model Scaling
152
+
153
+ Receptive field scaling includes both radius scaling and normalizing $\Delta _ { p }$ defined in Eqn. (2), which are also validated in Tab. 4 and 5. The radius is dataset specific, while down-scaling the radius from 0.2 to 0.15 improves $0 . 3 \%$ OA in ScanObjectNN, keeping the radius the same as 0.1 achieves the best performance in S3DIS. Regarding normalizing $\Delta _ { p }$ , it improves the performance in ScanObjectNN and S3DIS by $0 . 3 0 \mathrm { A }$ and $\mathrm { 0 . 4 ~ m I o U }$ , respectively. Furthermore, in Tab. 7, we show that normalizing $\Delta _ { p }$ has a larger impact (2.3 mIoU in S3DIS dataset) on the bigger model PointNext-XL.
154
+
155
+ Model scaling scales PointNet $^ { + + }$ by the proposed InvResMLP and some macro-architectural changes (see Sec. 3.2.2). In Tab. 4, we show that PointNeXt-S using the stem MLP, the symmetric decoder, and the residual connection in the SA block improves $1 . 0 \%$ OA in ScanObjectNN. Performance in the large-scale S3DIS dataset can be further unveiled (from $6 3 . 8 \%$ to $7 0 . 5 \%$ mIoU) by upscaling PointNeXt-S using more blocks of the proposed InvResMLP, as demonstrated in Tab. 5.
156
+
157
+ Furthermore, in Tab. 7,we ablate each component of the proposed InvResMLP block and different stage ratios in S3DIS area 5 using the best-performed model PointNeXt-XL as the baseline. As observed, each architectural change indeed contributes to increased performance. Among all changes, the residual connection is the most essential, without which the mIoU will drop from $7 0 . 5 \%$ to only $6 4 . 0 \%$ . The separable MLPs increase $3 . 9 \%$ mIoU while speeding up the network 3 times. Removing the inverted bottleneck from the baseline leads to a drop of $1 . 5 \%$ mIoU with less than a $1 \%$ gain in speed. Adding more blocks inside each stage after removing inverted bottleneck can improve its performance to $6 9 . 7 \pm 0 . 3$ but is still lower than the baseline. Another possibility is to use
158
+
159
+ Table 7: Ablate architectural changes on S3DIS. − and TP denote removing from baseline and throughput.
160
+
161
+ <table><tr><td rowspan=1 colspan=2>Ablate</td><td rowspan=1 colspan=1>mIoU △ TP</td></tr><tr><td rowspan=1 colspan=2>baseline (PointNeXt-XL)</td><td rowspan=1 colspan=1>70.5 ± 0.3 - 45</td></tr><tr><td rowspan=7 colspan=2>- normalizing△p- residual connection- stem MLPSeparable MLPs-Inverted bottleneck一Inverted bottleneck</td><td rowspan=1 colspan=1>68.2±0.7 -2.3 45</td></tr><tr><td rowspan=2 colspan=1>on</td><td></td></tr><tr><td rowspan=1 colspan=1></td><td></td></tr><tr><td rowspan=1 colspan=1>64.0 ±1.0 -6.5 4570.1 ±0.4 -0.4 46</td></tr><tr><td rowspan=1 colspan=1>66.6 ±0.8 -3.9 15</td></tr><tr><td rowspan=1 colspan=1>69.0± 0.4 -1.5 48</td></tr><tr><td rowspan=1 colspan=1>69.7 ± 0.3 -0.8 43</td></tr><tr><td rowspan=2 colspan=2>stage ratio→(1:1:1:1)stage ratio →→ (2:1:1:1)</td><td rowspan=1 colspan=1>69.8±0.6 -0.7 52</td></tr><tr><td rowspan=1 colspan=1>69.4±0.4 -1.1 41</td></tr><tr><td rowspan=2 colspan=2>stage ratio → (1:1:2:1)stage ratio → (1:1:1:2)stage ratio →→(1:3:1:1)</td><td rowspan=1 colspan=1>69.9 ±0.6 -0.6 47</td></tr><tr><td rowspan=1 colspan=1>69.5 ± 0.4 -1.0 4870.1 ± 0.4 -0.4 39</td></tr><tr><td rowspan=3 colspan=2>naive width scalingnaive depth scalingnaive compound scaling</td><td rowspan=1 colspan=1>59.4±0.1 -11.1 43</td></tr><tr><td rowspan=1 colspan=1>63.4± 0.5 -7.1 53</td></tr><tr><td rowspan=1 colspan=1>62.3 ± 1.2 -8.2 24</td></tr></table>
162
+
163
+ bottleneck design to shrink the channel size by 4 times in the middle of the module, and expand the network width or depth to achieve the same speed as the baseline. However, the best performance of bottleneck design only achieves $1 . 4 \%$ less mIoU compared to inverted bottleneck. Tab. 7 also shows the performance of naive width scaling that increases the width of PointNet $^ { + + }$ from 32 to 256 to match the throughput of PointNeXt-XL, naive depth scaling to append more SA blocks in PointNet+ $^ { \cdot + }$ to obtain the same number of blocks of PointNext-XL whose $\bar { B ^ { \prime } } = ( 3 , 6 , 3 , 3 )$ , and naive compound scaling to double the width of the naive depth scaled model to the same width as PointNeXt-XL $C = 6 4$ ). Our proposed model scaling strategy achieves much higher performance than these naive scaling strategies, while being much faster.
164
+
165
+ # 5 Related Work
166
+
167
+ Point-based methods process point clouds directly using their unstructured format compared to voxel-based methods [9, 4] and multi view-based methods [35, 11, 8]. PointNet [27], the pioneering work of point-based methods, proposes to model the permutation invariance of points with shared MLPs by restricting feature extraction to be pointwise. PointNet $^ { + + }$ [28] is presented to improve PointNet by capturing local geometric structures. Currently, most point-based methods focus on the design of local modules. [44, 43, 29] rely on graph neural networks. [49, 21, 41, 40] project point clouds onto pseudo grids to allow for regular convolutions. [46, 22, 23] adaptively aggregate neighborhood features through weights determined by the local structure. In addition, very recent methods leverage Transformer-like networks [54, 16] to extract local information through self-attention. Our work does not follow this trend in local module design. In contrast, we shift our attention to another important but largely under-explored aspect, i.e., the training and scaling strategies.
168
+
169
+ Training strategies are studied recently in [2, 45, 24] on image classification. In the point cloud domain, SimpleView [8] is the first work to show that training strategies have a large impact on the performance of a neural network. However, SimpleView simply adopts the same training strategies as DGCNN [44]. On the contrary, we conducted a systematic study to quantify the effect of each data augmentation and optimization technique, and propose a set of improved training strategies that boost the performance of PointNet+ $^ { \cdot + }$ [28] and other representative works [27, 44, 26].
170
+
171
+ Model scaling can significantly improve the performance of a network, as shown in pioneering works in various domains [38, 53, 20]. Compared to PointNet $^ { - + }$ [28] that uses parameters less than 2M, most current prevailing networks consist of parameters greater than $1 0 \ \mathbf { M } \ \mathbf { \Omega }$ , such as KPConv [41] (15M) and PointMLP [26] (13M). In our work, we explore model scaling strategies that can scale up PointNet++ in an effective and efficient manner. We offer practical suggestions on scaling technologies that improve performance, namely using residual connections and an inverted bottleneck design, while maintaining throughput by using separable MLPs.
172
+
173
+ # 6 Conclusion and Discussion
174
+
175
+ In this paper, we demonstrate that with improved training and scaling strategies, the performance of PointNet $^ { + + }$ can be increased to exceed the current state of the art. More specifically, we quantify the effect of each data augmentation and optimization technique that are widely used today, and propose a set of improved training strategies. These strategies can be easily applied to boost the performance of PointNet $^ { + + }$ and other representative works. We also introduce the Inverted Residual MLP block into PointNet+ $^ +$ to develop PointNeXt. We demonstrate that PointNeXt has superior performance and scalability over PointNe $^ { + + }$ on various benchmarks while maintaining high throughput. This work aims to guide researchers toward paying more attention to the effects of training and scaling strategies and motivate future work in this direction.
176
+
177
+ Limitation. Even though PointNeXt-XL is one of the largest models among all representative point-based networks, its number of parameters (44M) is still below that of small networks in image classification such as ConNeXt-S [24] (50M) and ViT-B [7] (87M), and is far from their large variants, including ConvNeXt-XL (350M) and ViT-L (305M). We do not push the model size further, mainly due to the smaller-scale nature of point cloud datasets. Moreover, our work is limited to existing modules since the focus is not on introducing new architectural changes.
178
+
179
+ Acknowledgement The authors would like to thank the reviewers of NeurIPS’22 for their constructive suggestions. This work was supported by the KAUST Office of Sponsored Research through the Visual Computing Center (VCC) funding, as well as, the SDAIA-KAUST Center of Excellence in Data Science and Artificial Intelligence (SDAIA-KAUST AI).
180
+
181
+ References
182
+ [1] Iro Armeni, Ozan Sener, Amir R Zamir, Helen Jiang, Ioannis Brilakis, Martin Fischer, and Silvio Savarese. 3d semantic parsing of large-scale indoor spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 1534–1543, 2016.
183
+ [2] Irwan Bello, William Fedus, Xianzhi Du, Ekin Dogus Cubuk, Aravind Srinivas, Tsung-Yi Lin, Jonathon Shlens, and Barret Zoph. Revisiting resnets: Improved training and scaling strategies. Advances in Neural Information Processing Systems (NeurIPS), 34, 2021.
184
+ [3] Angel X Chang, Thomas Funkhouser, Leonidas Guibas, Pat Hanrahan, Qixing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, et al. Shapenet: An information-rich 3d model repository. arXiv preprint arXiv:1512.03012, 2015.
185
+ [4] Christopher Choy, JunYoung Gwak, and Silvio Savarese. 4d spatio-temporal convnets: Minkowski convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 3075–3084, 2019.
186
+ [5] Angela Dai, Angel X. Chang, Manolis Savva, Maciej Halber, Thomas Funkhouser, and Matthias Nießner. ScanNet: Richly-annotated 3D reconstructions of indoor scenes. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
187
+ [6] Xiaohan Ding, Xiangyu Zhang, Yizhuang Zhou, Jungong Han, Guiguang Ding, and Jian Sun. Scaling up your kernels to 31x31: Revisiting large kernel design in cnns. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
188
+ [7] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.
189
+ [8] Ankit Goyal, Hei Law, Bowei Liu, Alejandro Newell, and Jia Deng. Revisiting point cloud shape classification with a simple and effective baseline. In Proceedings of the International Conference on Machine Learning (ICML), pages 3809–3820. PMLR, 2021.
190
+ [9] Benjamin Graham, Martin Engelcke, and Laurens Van Der Maaten. 3d semantic segmentation with submanifold sparse convolutional networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 9224–9232, 2018.
191
+ [10] Meng-Hao Guo, Jun-Xiong Cai, Zheng-Ning Liu, Tai-Jiang Mu, Ralph R Martin, and Shi-Min Hu. Pct: Point cloud transformer. Computational Visual Media, 7(2):187–199, 2021.
192
+ [11] Abdullah Hamdi, Silvio Giancola, and Bernard Ghanem. Mvtn: Multi-view transformation network for 3d shape recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 1–11, 2021.
193
+ [12] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 770–778, 2016.
194
+ [13] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
195
+ [14] Qingyong Hu, Bo Yang, Linhai Xie, Stefano Rosa, Yulan Guo, Zhihua Wang, Niki Trigoni, and Andrew Markham. Randla-net: Efficient semantic segmentation of large-scale point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 11108–11117, 2020.
196
+ [15] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
197
+ [16] Xin Lai, Jianhui Liu, Li Jiang, Liwei Wang, Hengshuang Zhao, Shu Liu, Xiaojuan Qi, and Jiaya Jia. Stratified transformer for 3d point cloud segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
198
+ [17] Zhaoqi Leng, Mingxing Tan, Chenxi Liu, Ekin Dogus Cubuk, Xiaojie Shi, Shuyang Cheng, and Drago Anguelov. Polyloss: A polynomial expansion perspective of classification loss functions. In International Conference on Learning Representations (ICLR), 2022.
199
+ [18] Guohao Li, Matthias Müller, Bernard Ghanem, and Vladlen Koltun. Training graph neural networks with 1000 layers. In Proceedings of the International Conference on Machine Learning (ICML), volume 139, pages 6437–6449. PMLR, 2021.
200
+ [19] Guohao Li, Matthias Müller, Guocheng Qian, Itzel C. Delgadillo, Abdulellah Abualshour, Ali K. Thabet, and Bernard Ghanem. Deepgcns: Making gcns go as deep as cnns. IEEE transactions on pattern analysis and machine intelligence (T-PAMI), PP, 2021.
201
+ [20] Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 9267–9276, 2019.
202
+ [21] Yangyan Li, Rui Bu, Mingchao Sun, Wei Wu, Xinhan Di, and Baoquan Chen. Pointcnn: Convolution on $\mathcal { X }$ -transformed points. Advances in Neural Information Processing Systems (NeurIPS), 31, 2018.
203
+ [22] Yongcheng Liu, Bin Fan, Shiming Xiang, and Chunhong Pan. Relation-shape convolutional neural network for point cloud analysis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 8887–8896, 2019.
204
+ [23] Ze Liu, Han Hu, Yue Cao, Zheng Zhang, and Xin Tong. A closer look at local aggregation operators in point cloud analysis. In Proceedings of the European Conference on Computer Vision (ECCV), pages 326–342. Springer, 2020.
205
+ [24] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
206
+ [25] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
207
+ [26] Xu Ma, Can Qin, Haoxuan You, Haoxi Ran, and Yun Fu. Rethinking network design and local geometry in point cloud: A simple residual MLP framework. In International Conference on Learning Representations (ICLR), 2022.
208
+ [27] Charles Ruizhongtai Qi, Hao Su, Kaichun Mo, and Leonidas J. Guibas. Pointnet: Deep learning on point sets for 3d classification and segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
209
+ [28] Charles Ruizhongtai Qi, Li Yi, Hao Su, and Leonidas J. Guibas. Pointnet++: Deep hierarchical feature learning on point sets in a metric space. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
210
+ [29] Guocheng Qian, Abdulellah Abualshour, Guohao Li, Ali Thabet, and Bernard Ghanem. Pu-gcn: Point cloud upsampling using graph convolutional networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 11683–11692, June 2021.
211
+ [30] Guocheng Qian, Hasan Hammoud, Guohao Li, Ali Thabet, and Bernard Ghanem. Assanet: An anisotropic separable set abstraction for efficient point cloud representation learning. volume 34, 2021.
212
+ [31] Shi Qiu, Saeed Anwar, and Nick Barnes. Semantic segmentation for real point cloud scenes via bilateral augmentation and adaptive fusion. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 1757–1767, 2021.
213
+ [32] Haoxi Ran, Jun Liu, and Chengjie Wang. Surface representation for point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
214
+ [33] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention (MICCAI), 2015.
215
+ [34] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 4510–4520, 2018.
216
+ [35] Hang Su, Subhransu Maji, Evangelos Kalogerakis, and Erik G. Learned-Miller. Multi-view convolutional neural networks for 3d shape recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2015.
217
+ [36] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott E. Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2015.
218
+ [37] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
219
+ [38] Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In Proceedings of the International Conference on Machine Learning (ICML), volume 97, pages 6105–6114. PMLR, 2019.
220
+ [39] Liyao Tang, Yibing Zhan, Zhe Chen, Baosheng Yu, and Dacheng Tao. Contrastive boundary learning for point cloud segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
221
+ [40] Maxim Tatarchenko, Jaesik Park, V. Koltun, and Qian-Yi Zhou. Tangent convolutions for dense prediction in 3d. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 3887–3896, 2018.
222
+ [41] Hugues Thomas, Charles R Qi, Jean-Emmanuel Deschaud, Beatriz Marcotegui, François Goulette, and Leonidas J Guibas. Kpconv: Flexible and deformable convolution for point clouds. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019.
223
+ [42] Mikaela Angelina Uy, Quang-Hieu Pham, Binh-Son Hua, Duc Thanh Nguyen, and Sai-Kit Yeung. Revisiting point cloud classification: A new benchmark dataset and classification model on real-world data. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019.
224
+ [43] Lei Wang, Yuchun Huang, Yaolin Hou, Shenman Zhang, and Jie Shan. Graph attention convolution for point cloud semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
225
+ [44] Yue Wang, Yongbin Sun, Ziwei Liu, Sanjay E. Sarma, Michael M. Bronstein, and Justin M. Solomon. Dynamic graph cnn for learning on point clouds. ACM Transactions on Graphics (TOG), 2019.
226
+ [45] Ross Wightman, Hugo Touvron, and Hervé Jégou. Resnet strikes back: An improved training procedure in timm. arXiv preprint arXiv:2110.00476, 2021.
227
+ [46] Wenxuan Wu, Zhongang Qi, and Li Fuxin. Pointconv: Deep convolutional networks on 3d point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
228
+ [47] Zhirong Wu, Shuran Song, Aditya Khosla, Fisher Yu, Linguang Zhang, Xiaoou Tang, and Jianxiong Xiao. 3d shapenets: A deep representation for volumetric shapes. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2015.
229
+ [48] Tiange Xiang, Chaoyi Zhang, Yang Song, Jianhui Yu, and Weidong Cai. Walk in the cloud: Learning curves for point clouds shape analysis. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 915–924, 2021.
230
+ [49] Yifan Xu, Tianqi Fan, Mingye Xu, L. Zeng, and Yu Qiao. Spidercnn: Deep learning on point sets with parameterized convolutional filters. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
231
+ [50] Xu Yan. Pointnet/pointnet++ pytorch. https://github.com/yanx27/Pointnet_Pointnet2_ pytorch, 2019.
232
+ [51] Li Yi, Vladimir G Kim, Duygu Ceylan, I Shen, Mengyan Yan, Hao Su, ARCewu Lu, Qixing Huang, Alla Sheffer, Leonidas Guibas, et al. A scalable active framework for region annotation in 3d shape collections. ACM Transactions on Graphics (TOG), 35(6):210, 2016.
233
+ [52] Xumin Yu, Lulu Tang, Yongming Rao, Tiejun Huang, Jie Zhou, and Jiwen Lu. Point-bert: Pre-training 3d point cloud transformers with masked point modeling. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
234
+ [53] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 12104–12113, 2022.
235
+ [54] Hengshuang Zhao, Li Jiang, Jiaya Jia, Philip HS Torr, and Vladlen Koltun. Point transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 16259–16268, 2021.
md/dev/KnCS9390Va/KnCS9390Va.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Delving into Out-of-Distribution Detection with Vision-Language Representations
2
+
3
+ Yifei Ming1 Ziyang Cai1 Jiuxiang $\mathbf { G u ^ { 2 } }$ Yiyou Sun1 Wei $\mathbf { L i ^ { 3 } }$ Yixuan Li1
4
+
5
+ 1Department of Computer Sciences, University of Wisconsin-Madison 2Adobe 3Google Research {alvinming,ziyangc,sunyiyou,sharonli}@cs.wisc.edu jigu@adobe.com mweili@google.com
6
+
7
+ # Abstract
8
+
9
+ Recognizing out-of-distribution (OOD) samples is critical for machine learning systems deployed in the open world. The vast majority of OOD detection methods are driven by a single modality (e.g., either vision or language), leaving the rich information in multi-modal representations untapped. Inspired by the recent success of vision-language pre-training, this paper enriches the landscape of OOD detection from a single-modal to a multi-modal regime. Particularly, we propose Maximum Concept Matching (MCM), a simple yet effective zero-shot OOD detection method based on aligning visual features with textual concepts. We contribute in-depth analysis and theoretical insights to understand the effectiveness of MCM. Extensive experiments demonstrate that MCM achieves superior performance on a wide variety of real-world tasks. MCM with vision-language features outperforms a common baseline with pure visual features on a hard OOD task with semantically similar classes by $1 3 . 1 \%$ (AUROC). Code is available at https://github.com/ deeplearning-wisc/MCM.
10
+
11
+ # 1 Introduction
12
+
13
+ Out-of-distribution (OOD) detection is critical for deploying machine learning models in the wild, where samples from novel classes can naturally emerge and should be flagged for caution. Despite increasing attention, the vast majority of OOD detection methods are driven by single-modal learning [26, 29, 34, 68, 89, 93, 95, 98]. For example, labels are typically encoded as one-hot vectors in image classification, leaving the semantic information encapsulated in texts largely unexploited. OOD detection relying on pure visual information can inherit the limitations, e.g., when an OOD input may be visually similar to in-distribution (ID) data yet semantically different from any ID class.
14
+
15
+ In this paper, we delve into a new landscape for OOD detection, departing from the classic singlemodal toward a multi-modal regime. While the motivation is appealing, a core challenge remains: how to effectively utilize joint vision-language features for OOD detection? In the visual domain, existing methods typically require good feature representations $\boxed { 6 6 } \boxed { 7 2 } \qquad $ , and a distance metric under which OOD data points are relatively far away from the in-distribution (ID) data [42, 71]. These approaches, however, do not directly translate into the multi-modal regime. On the representation learning side, recent vision-language pre-training schemes such as CLIP $\pmb { \Vert 5 9 \Vert }$ and ALIGN $\pmb { \mathbb { B 3 } }$ have emerged as promising alternatives for visual representation learning. The main idea is to align an image with its corresponding textual description in the feature space. While the resulting representations are powerful, OOD detection based on such aligned multi-modal features is still in its infancy.
16
+
17
+ We bridge the gap by exploring a distance-based OOD detection approach, leveraging the joint vision-language representations. Our method capitalizes on the compatibility between visual features and textual features. By defining the textual features as the “concept prototypes” for each ID class, we characterize OOD uncertainty by the distance from the visual feature to the closest ID prototype. That is, images closer to one of the textual embeddings of ID classes are more likely to be ID and vice versa. By a proper scaling of the distance, our proposed Maximum Concept Matching (MCM) score achieves strong ID-OOD separability (see Figure 1). MCM stands in contrast with the previous distance-based approaches, such as Mahalanobis $[ \mathbb { A } 2 ]$ , which defines class prototypes based on pure visual embeddings. Indeed, we show later in Section 5 that MCM (with multi-modal vision-language features) is far more competitive than Mahalanobis (with single-modal visual features). Moreover, while prior works of CLIP-based OOD detection $\dot { \lVert 1 6 \rVert } , \dot { \lVert 9 \rVert }$ rely on a set of candidate OOD labels, MCM is OOD-agnostic and alleviates the need for any prior information about test inputs.
18
+
19
+ ![](images/592a2c9711f86ff74cf96fa04194436c44c749243456a7aae8e8b03b8e309ed0.jpg)
20
+ Figure 1: Overview of the proposed zero-shot OOD detection framework. The ID classification task is defined by a set of class labels $\mathcal { V } _ { \mathrm { i n } }$ . The goal of OOD detection is to detect samples that do not belong to $\mathcal { V } _ { \mathrm { i n } }$ . We view the textual embeddings of ID classes (wrapped by text templates) as concept prototypes. The OOD uncertainty of an input image can be characterized by the distance from visual features to the closest ID prototype. By properly scaling the distance, the MCM score achieves strong ID-OOD separability. See Section $^ 3$ for details.
21
+
22
+ Our work also advances the field by showcasing the promise of zero-shot OOD detection, which offers strong performance and generality without training on the ID samples. In particular, classic OOD detection methods often require training from scratch $\mathbb { P } , \mathbb { Z } \mathbb { Z }$ or fine-tuning [19, 32] on a given ID dataset. In this setting, a classifier and its companion OOD detector are good at only one task. Every new task (ID dataset) requires additional training and brings additional computation and storage costs. In contrast, we show for the first time that: (1) MCM achieves superior performance across a wide variety of real-world tasks—with just one single pre-trained model. This is encouraging given that there is no training or any OOD information involved. (2) On the challenging ImageNet-1k benchmark, MCM’s zero-shot OOD detection performance favorably matches and even outperforms strong task-specific baselines fine-tuned on BiT $\mathbb { \lVert 3 2 \rVert }$ and ViT models [19]. (3) MCM remains robust against hard OOD inputs, including both semantically hard OODs $[ \sqrt { 8 5 } ]$ and spurious OODs $\pmb { \mathbb { B } } \pmb { \mathrm { O } } \Vert$
23
+
24
+ We summarize our main contributions as follows:
25
+
26
+ 1. We propose MCM, a simple yet effective OOD detection method based on aligned visionlanguage features. MCM offers several compelling advantages over other OOD detection methods: generalizable (one model supports many tasks), OOD-agnostic (no information required from OOD data), training-free (no downstream fine-tuning required), and scalable to large real-world tasks.
27
+ 2. We conduct extensive experiments and show that MCM achieves superior performance on a wide range of real-world tasks. On ImageNet-1k, MCM achieves an average AUROC of $9 1 . 4 9 \%$ , outperforming methods that require training. Moreover, we show that MCM remains competitive under challenging hard OOD evaluation tasks.
28
+ 3. We provide in-depth empirical and theoretical analysis, providing insights to understand the effectiveness of MCM. We hope that this work will serve as a springboard for future works on OOD detection with multi-modal features.
29
+
30
+ # 2 Preliminaries
31
+
32
+ Contrastive vision-language pre-training. Compared to visual representation learning models such as ViT $[ \overbrace { \lVert \boldsymbol { 1 3 } \rVert }$ , vision-language representation learning demonstrates superior performance on image classification tasks. For instance, CLIP $\mathbb { \left[ \left. 5 9 \right] \right. }$ adopts a self-supervised contrastive objective (i.e., InfoNCE loss $\pm \mathbb { Z } 5 \mathbb { I }$ ) to align an image with its corresponding textual description in the feature space. Specifically, CLIP adopts a simple dual-stream architecture with one text encoder $\mathcal { T } : t \mathbb { R } ^ { d }$ (e.g., Transformer $\mathbb { \left[ \bigcirc \mathrm { { Z } } \mathrm { { Z } } \right] } )$ and one image encoder $\mathcal { I } : \mathbf { x } \mathbb { R } ^ { d }$ (e.g., ViT $\mathbb { L } 3 \mathbb { I } .$ ). After pre-training on a dataset of 400 million text-image pairs, the joint vision-language embeddings of CLIP well associate objects in different modalities. Despite the promise, existing CLIP-like models perform zero-shot classification in a closed-world setting. That is, it will match an input into a fixed set of categories, even if it is irrelevant (e.g., a tree being predicted as a bird in Figure $\blacktriangleleft$ . This motivates our work to leverage the multi-modal representation for OOD detection, which is largely unexplored.
33
+
34
+ Zero-shot OOD detection. Given a pre-trained model, a classification task of interest is defined by a set of class labels/names ${ \mathcal { N } } _ { \mathrm { i n } }$ , which we refer to as the known (ID) classes. Here ID classes are defined w.r.t. the classification task of interest, instead of the classes used in pre-training. Accordingly, OOD is defined w.r.t. the ID classes, not the data distribution during pre-training. The goal of OOD detection is to (1) detect samples that do not belong to any of the known classes; (2) otherwise, assign test samples to one of the known classes. Therefore, the OOD detector can be viewed as a “safeguard” for the classification model. Formally, we denote the OOD detector as a binary function: $G ( \mathbf { x } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathbb { Z } ) : \mathcal { X } \to \{ \mathrm { i n } , \mathrm { o u t } \}$ , where $\mathbf { x } \in \mathcal { X }$ denotes a test image. Our method is based on only the names of the given classes in ${ \mathcal { N } } _ { \mathrm { i n } }$ , and a pre-trained model. Different from standard supervised learning, there is no training on the ID samples involved, hence zero-shot.
35
+
36
+ # 3 OOD Detection via Concept Matching
37
+
38
+ We illustrate our approach in Figure $\bigstar \bigstar$ which derives the OOD detector $G ( \cdot )$ based on concept matching. For a given task with label set $\mathcal { V } _ { \mathrm { i n } } = \{ y _ { 1 } , y _ { 2 } , . . . , y _ { K } \}$ , we can construct a collection of concept vectors $\mathcal { T } ( t _ { i } ) , i \in \{ 1 , 2 , . . . , K \}$ , where $t _ { i }$ is the text prompt “this is a photo of a $\langle y _ { i } \rangle ^ { \flat }$ for a label $y _ { i }$ . The concept vectors are represented by the embeddings of the text prompts.
39
+
40
+ For any test input image $\mathbf { x } ^ { \prime }$ , we can calculate the label-wise matching score based on the cosine similarity between the image feature $\mathcal { T } ( \mathbf { x } ^ { \prime } )$ and the concept vector $\begin{array} { r } { \bar { T ( t _ { i } ) } \colon s _ { i } ( \mathbf { x } ^ { \prime } ) = \frac { \bar { \mathcal { T } } ( \mathbf { x } ^ { \prime } ) \cdot \bar { \mathcal { T } } ( t _ { i } ) } { \| \bar { \mathcal { T } } ( \mathbf { x } ^ { \prime } ) \| \cdot \| \bar { \mathcal { T } } ( t _ { i } ) \| } } \end{array}$ . Formally, we define the maximum concept matching (MCM) score as:
41
+
42
+ $$
43
+ S _ { \mathrm { M C M } } ( \mathbf { x } ^ { \prime } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathbb { Z } ) = \operatorname* { m a x } _ { i } \frac { e ^ { s _ { i } ( \mathbf { x } ^ { \prime } ) / \tau } } { \sum _ { j = 1 } ^ { K } e ^ { s _ { j } ( \mathbf { x } ^ { \prime } ) / \tau } } ,
44
+ $$
45
+
46
+ where $\tau$ is the temperature. For ID data, it will be matched to one of the concept vectors (textual prototypes) with a high score; and vice versa. Formally, our OOD detection function can be formulated as:
47
+
48
+ $$
49
+ G ( \mathbf { x } ^ { \prime } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathcal { Z } ) = \left\{ \begin{array} { r l } { 1 } & { S _ { \mathrm { M C M } } ( \mathbf { x } ^ { \prime } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathcal { Z } ) \ge \lambda } \\ { 0 } & { S _ { \mathrm { M C M } } ( \mathbf { x } ^ { \prime } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathcal { Z } ) < \lambda } \end{array} , \right.
50
+ $$
51
+
52
+ where by convention 1 represents the positive class (ID) and 0 indicates OOD. $\lambda$ is chosen so that a high fraction of ID data (e.g., $9 5 \%$ ) is above the threshold. For samples that are classified as ID, one can obtain the class prediction based on the closest concept: ${ \hat { y } } = \operatorname { a r g m a x } _ { i \in [ K ] } s _ { i } .$
53
+
54
+ Remark: (1) Our work differs from (and is complementary to) CLIP by focusing on OOD detection rather than (closed-world) zero-shot classification. We show new theoretical insights that softmax scaling plays a unique role in zero-shot OOD detection—improving the separability between ID and OOD data. This role has not been studied rigorously for zero-shot OOD detection. Readers familiar with CLIP may notice that MCM can be used for zero-shot classification in the closed world. This also makes MCM practically convenient for dual goals: detect OOD samples and assign ID data to one of the known classes. (2) Our method in principle is not limited to CLIP; it can be generally applicable for contrastive vision-language pre-training models that promote multi-modal feature alignment.
55
+
56
+ New insights on softmax scaling for zero-shot OOD detection. We provide theoretical justifications that softmax scaling improves the separability between ID and OOD data for CLIP-based OOD detection, which is contrary to models trained with cross-entropy (CE) loss. In particular, CLIP-like models are trained with a multi-modal contrastive loss, which maximizes the cosine similarity between an image and its textual description in the feature space. The resulting cosine similarity scores display strong uniformity1 across labels, as evidenced in Figure 2 (right). Compared to OOD inputs, the gap between the maximum cosine similarity and the average is larger for ID inputs. However, the gap can be small when the number of ID classes increases where ID samples occur with lower highest cosine similarity. As a result, the highest cosine similarity for ID samples and OOD samples can be highly close (c.f. Figure 2 (left)).
57
+
58
+ Motivated by these observations, MCM employs softmax as a post hoc mechanism to magnify the difference. This is fundamentally different from the softmax score derived from a model trained with cross-entropy loss, which inherently maximizes the posterior $p ( \boldsymbol { y } | \mathbf { x } )$ for the ground-truth label, and minimizes the probability for other labels. Unlike CLIPlike models, logit scores displaying uniformity would be heavily penalized by the CE loss. As a result, the logit score corresponding to the ground-truth label can already be significantly higher than other labels. Applying softmax on the logit scores can exacerbate overconfident predictions, and reduce the separability between ID and OOD data $\left[ \left[ 4 6 \right] \right]$ . Indeed, for a
59
+
60
+ model trained with cross-entropy loss, a logit-based score such as Energy $[ \overline { { | 4 8 | } }$ is shown to be much more effective than the softmax score.
61
+
62
+ ![](images/327fa0adf2e4d57afdc07b4e09472284968e9acfdf761304c15d322294701bb3.jpg)
63
+ Figure 2: Left: Maximum cosine similarity for ID and OOD inputs. There exists overlapping regions (shown in yellow); Right: Cosine similarities between OOD inputs and ID concept vectors. For OOD inputs, the cosine similarities display uniformity.
64
+
65
+ Interestingly, for CLIP-like models, the trend is the opposite—applying softmax helps sharpen the uniform-like inner product scores, and increases the separability between ID and OOD data. To help readers better understand the insights, we first formalize our observations that OOD inputs trigger similar cosine similarities across ID concepts (Figure $\triangledown$ right) as the following assumption:
66
+
67
+ Assumption 3.1. Let $z : = \mathbb { 1 } \{ y \in \mathcal { V } _ { \mathrm { i n } } \}$ . $Q _ { \mathbf { x } }$ denotes the out-of-distribution $\mathbb { P } _ { \mathbf { x } | \boldsymbol { z } = 0 }$ (marginal distribution of $\mathbf { x }$ conditioned on $z = 0$ ). Assume $\exists \delta > 0$ such that
68
+
69
+ $$
70
+ Q _ { \mathbf { x } } \left( \frac { 1 } { K - 1 } \sum _ { i \neq j } \lbrack s _ { \hat { y } _ { 2 } } ( \mathbf { x } ) - s _ { i } ( \mathbf { x } ) \rbrack < \delta \right) = 1 ,
71
+ $$
72
+
73
+ where $\hat { y } : = \mathrm { a r g m a x } _ { i \in [ K ] } s _ { i } ( { \bf x } )$ and $\hat { y } _ { 2 } : = \mathrm { a r g m a x } _ { i \neq \hat { y } , i \in [ K ] } s _ { i } ( \mathbf { x } )$ denote the indices of the largest and second largest cosine similarities for an OOD input x.
74
+
75
+ Now we provide formal guarantees that using softmax can provably reduce the false positive rate (FPR) compared to that without softmax.
76
+
77
+ Theorem 3.1. Given a task with ID label set $\mathcal { V } _ { \mathrm { i n } } = \{ y _ { 1 } , y _ { 2 } , . . . , y _ { K } \}$ and a pre-trained CLIP-like model $( \mathcal { T } , \mathcal { T } )$ . If $Q _ { \mathbf { x } }$ satisfies Assumption $\boxed { 3 . 1 }$ then there exists a constant $\begin{array} { r } { T = \frac { \lambda ( K - 1 ) \left( \lambda ^ { \mathrm { w o } } + \delta - s _ { \hat { y } _ { 2 } } \right) } { K \lambda - 1 } } \end{array}$ such that for any temperature $\tau > T$ , we have
78
+
79
+ $$
80
+ \mathrm { F P R } ( \tau , \lambda ) \le \mathrm { F P R } ^ { \mathrm { w o } } ( \lambda ^ { \mathrm { w o } } ) ,
81
+ $$
82
+
83
+ where $\mathrm { { F P R } } ( \tau , \lambda )$ is the false positive rate based on softmax scaling with temperature $\tau$ and detection threshold $\lambda$ $\therefore \mathrm { F P R } ^ { \mathrm { w o } } ( \lambda ^ { \mathrm { w o } } )$ is the false positive rate without softmax scaling based on threshold $\lambda ^ { \mathrm { w o } }$ .
84
+
85
+ This suggests that applying softmax scaling with a moderate temperature results in superior OOD detection performance compared to that without softmax scaling. The proof is in Appendix $\boxed { \mathrm { A } }$ Later in Section $\Xi ,$ we empirically verify on a real-world ImageNet dataset that our bound can indeed be satisfied in CLIP where the thresholds are chosen at $9 5 \%$ true positive rate.
86
+
87
+ What MCM offers: Beyond theoretical insights, we would like to highlight several compelling advantages of our zero-shot OOD detection approach, owing to the strong pre-trained CLIP model:
88
+
89
+ • Generalizable to many tasks: Traditional OOD detection methods are based on a task-specific model. As a result, the OOD detector is not suitable for a realistic online scenario where the task changes from one to another. In contrast, we will show in Section $\boxplus$ that MCM can perform a wide variety of OOD detection tasks, with just one single model. For a new task, only the names of the task’s visual concepts ${ \mathcal { N } } _ { \mathrm { i n } }$ are required. OOD-agnostic: Our method does not rely on any OOD information, and thus suits many realworld scenarios where one cannot anticipate what the unknowns would be ahead of time. This also mitigates the shortcoming of a recent approach $\mathbb { \lVert 1 9 \rVert }$ , which assumes that a set of unseen labels are given as some weak information about OOD data.
90
+ • Training-free: MCM enables OOD detection in a zero-shot fashion. This stands in contrast to the vast majority of OOD detection literature, which often requires training from scratch or fine-tuning to achieve competitive performance.
91
+ • Scalable: The contrastive vision-language pre-training paradigm makes MCM scalable to a large number of class labels and realistic high-resolution images.
92
+
93
+ We now proceed to the experimental results, demonstrating these advantages on real-world tasks.
94
+
95
+ # 4 A Comprehensive Analysis of MCM
96
+
97
+ # 4.1 Datasets and Implementation Details
98
+
99
+ Datasets. Most previous works on OOD detection only focus on small-scale datasets with blurry images such as CIFAR $\mathbb { H O }$ and TinyImageNet [41]. With pre-trained models such as CLIP, OOD detection can be extended to more realistic and complex datasets. In this work, we scale up evaluations in terms of (1) image resolution, (2) dataset variety, and (3) number of classes. We consider the following ID datasets: CUB-200 $\pmb { \Vert 8 0 \Vert }$ , STANFORD-CARS [39], FOOD-101 [6], OXFORD-PET [57] and variants of IMAGENET [11]. For OOD test datasets, we use the same ones in $\pmb { \mathbb { B 2 } }$ , including subsets of iNaturalist $\left[ \left[ 7 6 \right] \right]$ , SUN [86], PLACES $\mathbb { \left[ \left[ 9 6 \right] \right] }$ , and TEXTURE [10]. For each OOD dataset, the categories are not overlapping with the ID dataset. We also use subsets of ImageNet-1k for fine-grained analysis. For example, we construct ImageNet-10 that mimics the class distribution of CIFAR-10 but with high-resolution images. For hard OOD evaluation, we curate ImageNet-20, which consists of 20 classes semantically similar to ImageNet-10 (e.g., dog (ID) vs. wolf (OOD)).
100
+
101
+ Model. In our experiments, we adopt CLIP $\mathbb { \lVert 5 9 \rVert }$ as the target pre-trained model, which is one of the most popular and publicly available vision-language models. Note that our method is not limited to CLIP; it can generally be applicable for contrastive vision-language pre-training models that promote multi-modal feature alignment. Specifically, we mainly use CLIP-B/16, which consists of a ViT-B/16 Transformer as the image encoder and a masked self-attention Transformer $ { \mathbb { Z } } { \ b { 7 } } { \mathbb { I } }$ as the text encoder. To indicate the input patch size in ViT models, we append $\mathbf { \ddot { \mu } } ^ { 6 6 } / \mathbf { \vec { X } } ^ { 3 }$ to model names. We prepend -B, -L to indicate Base and Large versions of the corresponding architecture. For instance, ViT-B/16 implies the Base variant with an input patch resolution of $1 6 \times 1 6$ . We also use CLIP-L/14 which is based on ViT-L/14 as a representative of large models. Unless specified otherwise, the temperature $\tau$ is 1 for all experiments. Details of the datasets, experimental setup, and hyperparameters are provided in Appendix B.
102
+
103
+ Metrics. For evaluation, we use the following metrics: (1) the false positive rate (FPR95) of OOD samples when the true positive rate of in-distribution samples is at $9 5 \%$ , (2) the area under the receiver operating characteristic curve (AUROC), and (3) ID classification accuracy (ID ACC).
104
+
105
+ Table 1: Zero-shot OOD detection with MCM score based on CLIP-B/16 with various ID datasets.
106
+
107
+ <table><tr><td rowspan="3">ID Dataset</td><td colspan="8">OODDataset</td><td rowspan="2" colspan="2">Average</td></tr><tr><td colspan="2">iNaturalist</td><td colspan="2">SUN</td><td colspan="2">Places</td><td colspan="2">Texture</td></tr><tr><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td></tr><tr><td>CUB-200|801</td><td>9.83</td><td>98.24</td><td>4.93</td><td>99.10</td><td>6.65</td><td>98.57</td><td>6.97</td><td>98.75</td><td>7.09</td><td>98.66</td></tr><tr><td>Stanford-Cars 四</td><td>0.05</td><td>99.77</td><td>0.02</td><td>99.95</td><td>0.24</td><td>99.89</td><td>0.02</td><td>99.96</td><td>0.08</td><td>99.89</td></tr><tr><td>Food-101</td><td>0.64</td><td>99.78</td><td>0.90</td><td>99.75</td><td>1.86</td><td>99.58</td><td>4.04</td><td>98.62</td><td>1.86</td><td>99.43</td></tr><tr><td>Oxford-Pet [57</td><td>2.85</td><td>99.38</td><td>1.06</td><td>99.73</td><td>2.11</td><td>99.56</td><td>0.80</td><td>99.81</td><td>1.70</td><td>99.62</td></tr><tr><td>ImageNet-10</td><td>0.12</td><td>99.80</td><td>0.29</td><td>99.79</td><td>0.88</td><td>99.62</td><td>0.04</td><td>99.90</td><td>0.33</td><td>99.78</td></tr><tr><td>ImageNet-20</td><td>1.02</td><td>99.66</td><td>2.55</td><td>99.50</td><td>4.40</td><td>99.11</td><td>2.43</td><td>99.03</td><td>2.60</td><td>99.32</td></tr><tr><td>ImageNet-100</td><td>18.13</td><td>96.77</td><td>36.45</td><td>94.54</td><td>34.52</td><td>94.36</td><td>41.22</td><td>92.25</td><td>32.58</td><td>94.48</td></tr></table>
108
+
109
+ Table 2: OOD detection performance for ImageNet-1k [11] as ID.
110
+
111
+ <table><tr><td rowspan="3">Method</td><td colspan="8">OOD Dataset</td><td rowspan="2" colspan="2">Average</td></tr><tr><td colspan="2">iNaturalist FPR95↓</td><td colspan="2">SUN</td><td colspan="2">Places</td><td colspan="2">Texture</td></tr><tr><td></td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td></tr><tr><td colspan="9">Requires training (or w. fine-tuning)</td><td></td></tr><tr><td>MOS 32 (BiT)</td><td>9.28</td><td>98.15</td><td>40.63</td><td>92.01</td><td>49.54</td><td>89.06</td><td>60.43</td><td>81.23</td><td>39.97</td><td>90.11</td></tr><tr><td>Fort et al. 园 (ViT-B)</td><td>15.07</td><td>96.64</td><td>54.12</td><td>86.37</td><td>57.99</td><td>85.24</td><td>53.32</td><td>84.77</td><td>45.12</td><td>88.25</td></tr><tr><td>Fort et al. 园 (ViT-L)</td><td>15.74</td><td>96.51</td><td>52.34</td><td>87.32</td><td>55.14</td><td>86.48</td><td>51.38</td><td>85.54</td><td>43.65</td><td>88.96</td></tr><tr><td>Energy 481 (CLIP-B)</td><td>21.59</td><td>95.99</td><td>34.28</td><td>93.15</td><td>36.64</td><td>91.82</td><td>51.18</td><td>88.09</td><td>35.92</td><td>92.26</td></tr><tr><td>Energy 48 (CLIP-L)</td><td>10.62</td><td>97.52</td><td>30.46</td><td>93.83</td><td>32.25</td><td>93.01</td><td>44.35</td><td>89.64</td><td>29.42</td><td>93.50</td></tr><tr><td>MSP 因 (CLIP-B) MSP</td><td>40.89</td><td>88.63</td><td>65.81</td><td>81.24</td><td>67.90</td><td>80.14</td><td>64.96</td><td>78.16</td><td>59.89</td><td>82.04</td></tr><tr><td>因 (CLIP-L)</td><td>34.54</td><td>92.62</td><td>61.18</td><td>83.68</td><td>59.86</td><td>84.10</td><td>59.27</td><td>82.31</td><td>53.71</td><td>85.68</td></tr><tr><td colspan="9">Zero-shot (no training required)</td><td></td><td></td></tr><tr><td>MCM(CLIP-B)</td><td>30.91</td><td>94.61</td><td>37.59</td><td>92.57</td><td>44.69</td><td>89.77</td><td>57.77</td><td>86.11</td><td>42.74</td><td>90.77</td></tr><tr><td>MCM(CLIP-L)</td><td>28.38</td><td>94.95</td><td>29.00</td><td>94.14</td><td>35.42</td><td>92.00</td><td>59.88</td><td>84.88</td><td>38.17</td><td>91.49</td></tr></table>
112
+
113
+ # 4.2 Main Results
114
+
115
+ MCM supports a diverse collection of tasks while being zero-shot. We first show that zero-shot OOD detection with MCM is effective across a wide variety of tasks—with just one single pre-trained model. To showcase the versatility of MCM, we consider the seven ID datasets here. To the best of our knowledge, this is among the first attempts to showcase the efficacy under an expansive and diverse collection of ID datasets. The zero-shot OOD detection performance is summarized in Table 1. A salient observation is that MCM can achieve superior detection performance on many tasks. For example, using STANFORD-CARS as ID, MCM yields an average FPR95 of $\mathbf { 0 . 0 8 \% }$ . Considering that there are no training samples or OOD information involved, these results are very encouraging.
116
+
117
+ It can be also seen from Table $^ 1$ that MCM is promising, especially when the number of samples per ID class is limited in the training set. For example, there are only around 40 samples per class for Stanford-Cars, 100 for Oxford-Pet, and 30 for CUB-200. The sample scarcity makes OOD detection methods that rely on fine-tuning difficult. For example, after fine-tuning on Food-101, while the ID accuracy is increased from $8 6 . 3 \%$ to $9 2 . 5 \% \uparrow$ , OOD detection based on MSP is on par with MCM $( 9 9 . 5 \%$ vs. $9 9 . 4 \%$ in AUROC).
118
+
119
+ MCM scales effectively to large datasets. To examine the scalability of MCM, we compare it with recent competitive OOD detection methods [19, 32] on the ImageNet-1k dataset (ID) in Table 2. We observe the following trends:
120
+
121
+ • Larger models lead to superior performance. Compared with CLIP-B, MCM based on CLIP-L reduces FPR95 by $4 . 5 7 \%$ . Zero-shot ID classification accuracy is also improved by $6 . 2 7 \%$ with the larger model, reaching $7 3 . 2 8 \%$ (see Appendix $\bigstar \bigstar$ . This suggests that larger models are endowed with a better representation quality, which benefits both ID classification and OOD detection with MCM. Our finding echos with the recent observations $\mathbb { \left[ \left[ \begin{array} { l } { \nabla 8 } \right]} \end\right]{array} \end{array}$ that higher ID classification accuracy is correlated with stronger OOD detection performance.
122
+ • MOS $\pmb { \Vert 3 2 } \Vert$ recently demonstrated competitive performance on ImageNet-1k, which requires model fine-tuning based on BiT $\pmb { \Vert 3 8 \Vert }$ . In contrast, we show that MCM (CLIP-L) outperforms MOS by $1 . 3 8 \%$ in AUROC while being zero-shot (training-free).
123
+ • MCM shares a softmax scaling function with the classic (visual) confidence-based score MSP $\lVert 2 5 \rVert$ To implement MSP, we adopt the commonly used linear probe approach by fine-tuning a linear layer on frozen visual features of CLIP. After fine-tuning, ID accuracy significantly improves, reaching $8 4 . 1 2 \%$ (CLIP-L). Interestingly, the OOD detection performance of MSP is worse than
124
+
125
+ Table 3: Performance comparison on hard OOD detection tasks. MCM is competitive on all three hard OOD tasks without training involved. MSP (based on fine-tuned CLIP) does not further improve performance.
126
+
127
+ <table><tr><td>Method</td><td>ID OOD</td><td>ImageNet-10 ImageNet-20</td><td>ImageNet-20 ImageNet-10</td><td>Waterbirds Spurious OOD</td></tr><tr><td></td><td></td><td>FPR95/AUROC</td><td>FPR95 /AUROC</td><td>FPR95/AUROC</td></tr><tr><td>MSP 四 (fine-tuning)</td><td></td><td>9.38 /98.31</td><td>12.51 /97.70</td><td>39.57 /90.99</td></tr><tr><td>Mahalanobis [42] (visual only)</td><td></td><td>78.32/85.60</td><td>43.03 /89.94</td><td>2.21 /99.55</td></tr><tr><td>MCM (zero-shot)</td><td></td><td>5.00 /98.71</td><td>12.91 / 98.09</td><td>5.87 /98.36</td></tr></table>
128
+
129
+ MCM by $1 5 . 5 4 \%$ in FPR95. Under the same model fine-tuned with linear probing, we observe that the Energy score outperforms MSP, corroborating findings in [48]. We investigate more in Section 5.
130
+
131
+ • Recently, Fort et al. $\mathbb { \lVert 1 9 \rVert }$ explore small-scale OOD detection by fine-tuning the full ViT model. When extended to large-scale tasks, we find that MCM still yields superior performance under the same image encoder configuration (ViT-B or ViT-L). This further highlights the advantage of utilizing vision-language joint embeddings for large-scale visual OOD detection.
132
+
133
+ MCM benefits hard OOD detection. Going beyond, we investigate whether MCM is still effective for hard OOD inputs. We consider the following two categories of hard OOD:
134
+
135
+ • Semantically hard OOD: OOD samples that are semantically similar to ID samples are particularly challenging for OOD detection algorithms $\pmb { \Vert 8 5 } \Vert$ . To evaluate hard OOD detection tasks in realistic settings, here we consider ImageNet-10 (ID) vs. ImageNet-20 (OOD) and vice versa. The pair consists of high-resolution images with semantically similar categories such as dog versus wolf. As shown in Table $^ { 3 , }$ MCM outperforms Mahalanobis $\lVert \boldsymbol { 4 2 } \rVert$ by $7 3 . 3 2 \%$ in FPR95 for ImageNet-10 (ID) vs. ImageNet-20 (OOD) and $3 0 . 1 2 \%$ vice versa.
136
+
137
+ • Spurious OOD: Modern neural networks can exploit spurious correlations for predictions [3]. For example, in the Waterbirds dataset $\pmb { \mathbb { \lVert 6 4 \rVert } }$ , there exist spurious correlations between the habitat (e.g., water) and bird types. A recent work $ { \mathbb { I } } ^ { { \left[ \left[ 5 0 \right] \right] } }$ proposes a new type of hard OOD named spurious OOD and shows that most OOD detection methods perform much worse for spurious OOD inputs compared to non-spurious inputs. The spurious OOD inputs are created to share the same background (i.e., water) as ID data but have different object labels (e.g., a boat rather than a bird). See Appendix $\boxed { \mathbf { C } }$ for illustrations. The results are shown in Table $3 .$ . It has been shown that CLIP representations are robust to distributional shifts $\pmb { \Vert 5 9 \Vert }$ . Therefore, while prior works $ { \mathbb { I } } ^ { { 5 } { 0 } \| }$ show that spurious OOD inputs are challenging for methods based on ResNet $\pmb { \mathbb { Z } } 3 \mathbb { I }$ , MCM and Mahalanobis scores based on pre-trained CLIP perform much better. On the other hand, fine-tuning exposes the model to the training set containing spurious correlations. As a result, MSP performs much worse than MCM $( 3 9 . 5 7 \%$ vs. $5 . 8 7 \%$ in FPR95).
138
+
139
+ MCM outperforms CLIP-based baselines. Two recent works also use CLIP embeddings for OOD detection [16, 19]. However, fundamental limitations exist for both works. Fort et al. $\mathbb { \ m }$ assume that a candidate OOD label set $\mathcal { V } _ { C }$ is known, and used $\textstyle \sum _ { y \in y _ { C } } { \hat { p } } ( y | \mathbf { x } )$ for OOD detection. Here the predictive probability $\hat { p } ( y | \mathbf x )$ is obtained by normalizing the inner products over $| \mathcal { V } _ { \mathrm { i n } } | + | \mathcal { V } _ { C } |$ classes. While applying softmax converts any vector to probabilities, as we show in Section $^ { 3 , }$ the converted probabilities do not necessarily correspond to $\mathbb { P } ( \mathbf { 0 } \mathbf { O D } | \mathbf { x } )$ . Moreover, obtaining such an OOD label set is typically not feasible, which fundamentally limits its applicability. A recent work $\mathbb { \lVert 1 6 \rVert }$ realizes this idea by training an extra text decoder on top of CLIP’s image encoder to generate candidate labels. However, $\mathbb { \lVert \boldsymbol { 1 6 } \rVert }$ cannot guarantee the generated labels are non-overlapping with the ID labels.
140
+
141
+ ![](images/1f10552ae18babddf0b40258c6bb55a4376ddfec3a056dc56a7ccec76ec7f824.jpg)
142
+ Figure 3: Comparison with a candidate label-based score ZO-CLIP on ImageNet-20, based on our implementation of $\boxed { 1 1 6 }$ . Implementation details are deferred to Appendix E.1.
143
+
144
+ ![](images/b8830412647054c0d26c772aff45cbd64193c84edec1f0774b55810e241d4001.jpg)
145
+ Figure 4: The influence of softmax scaling and temperature. We use ImgeNet-100 (ID) vs. iNaturalist (OOD). Softmax scaling with a moderate temperature significantly improves FPR95.
146
+
147
+ We enhance the baseline with a stronger decoder and a filter module (see Appendix $\mathrm { E . 1 } )$ . As shown in Figure 3 , MCM outperforms the enhanced baseline on all OOD datasets. Moreover, MCM is much simpler to use—alleviating the need for an OOD label set or training an additional caption generator. In contrast, the caption generator’s performance largely affects OOD detection. Poor caption quality degenerates the OOD detection performance of candidate label-based methods. Moreover, obtaining a reliable caption generator for any input image can significantly increase the computational overhead.
148
+
149
+ # 5 Discussion: A Closer Look at MCM
150
+
151
+ Empirical verification on the role of softmax. In Section 3, we prove that softmax scaling on cosine similarity scores with a moderate $\tau$ improves the ID-OOD separability. Here we empirically verify our theoretical results. As shown in Figure $^ { 4 , }$ compared to directly using the maximum cosine similarity without softmax (leftmost figure), softmax scaling with a temperature $\tau = 1$ significantly improves the performance by $2 2 . 6 \%$ in FPR95, and further increasing $\tau$ (e.g., $\tau = 1 0$ ) leads to similar performance. The results are based on ImageNet-100 (ID) versus iNaturalist (OOD).
152
+
153
+ Now, we verify if our theoretical bound $( c , f .$ Theorem $\boxed { 3 . 1 }$ is satisfied empirically as well in Figure 4. From the leftmost figure, we can estimate $\lambda ^ { \mathrm { w o } } \approx 0 . 2 6$ , $\delta \approx 0 . 0 3$ , and $s _ { \hat { y } _ { 2 } } \approx 0 . 2 3$ . By checking the third figure $\mathit { \check { \tau } } = 1$ is the temperature value we use for most experiments), we approximate $\lambda \approx 0 . 0 1 1$ . As $K = 1 0 0$ , we plug in the values and obtain the lower bound $\begin{array} { r } { T = \frac { \lambda ( K - 1 ) \left( \lambda ^ { \mathrm { w o } } + \delta - s _ { \hat { y } _ { 2 } } \right) } { K \lambda - 1 } \approx 0 . 6 5 . } \end{array}$ . Since $\tau = 1 > 0 . 6 5$ , by Theorem $\underline { { \boldsymbol { \mathsf { B . 1 } } } } \big \| _ { \mathsf { \Gamma } }$ applying softmax scaling with $\tau = 1$ is provably superior to without softmax scaling for OOD detection.
154
+
155
+ Are vision-language features better than visual feature alone? MCM can be interpreted as a distance-based approach—images that are closer to one of the $K$ class prototypes are more likely to be ID and vice versa. Here the class prototypes are defined based on a textual encoder. Alternatively, one can define the class prototypes based on visual features. For example, Mahalanobis $\overline { { \lVert \mathscr { Q } 2 \rVert } }$ defines a class prototype as the average of visual embeddings for images belonging to the same class. This raises the question whether MCM (with multi-modal vision-language features) is better than Mahalanobis (with single-modal visual feature). For a fair comparison, we use the same ViT image encoder from CLIP-B. Both MCM and Mahalanobis extract visual features from the penultimate layer. On ImageNet-1k, Mahalanobis displays a limited performance, with $7 3 . 1 4 \%$ AUROC averaged across four OOD test datasets $( 9 0 . 7 7 \%$ for MCM), as shown in Figure $\boxed { 5 }$ From a practical perspective, Mahalanobis requires computing the inverse covariance matrix, which can be both computationally expensive and inaccurate when the number of samples is scarce and the number of ID classes grows. In contrast, MCM is easier to use and more robust.
156
+
157
+ ![](images/2c04380b0310084ffd03525ccc4989aaf85e13496d4ffc51051ca74cf1ba35b1.jpg)
158
+ Figure 5: Comparison with Mahalanobis (Maha) score on ImageNet-1k.
159
+
160
+ MCM without softmax scaling. In Section $\textcircled { 3 }$ we provide theoretical justifications for the necessity of softmax scaling for CLIP-like models. To further verify our observations empirically, we show OOD detection performance based on the maximum cosine similarity score $S _ { \mathrm { M C M } } ^ { \mathrm { w o } } ( \mathbf { x } ^ { \prime } ; \mathcal { V } _ { \mathrm { i n } } , \mathcal { T } , \mathcal { T } ) =$ $\mathrm { m a x } _ { i \in [ K ] } s _ { i } \big ( \mathbf { x } ^ { \prime } \big )$ . The results are shown in Table $\boxed { 4 }$ For easy tasks such as Food-101 $\pmb { \| 3 9 \| }$ , Stanford
161
+
162
+ Table 4: Zero-shot OOD detection of $S _ { \mathrm { M C M } } ^ { \mathrm { w o } }$ based on CLIP-B/16.
163
+
164
+ <table><tr><td rowspan="3">ID Dataset</td><td colspan="8">OOD Dataset</td><td rowspan="2" colspan="2">Average</td></tr><tr><td colspan="2">iNaturalist</td><td colspan="2">SUN</td><td colspan="2">Places</td><td colspan="2">Texture</td></tr><tr><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td></tr><tr><td>Stanford-Cars39</td><td>0.00</td><td>100</td><td>0.02</td><td>99.99</td><td>0.26</td><td>99.94</td><td>0.00</td><td>100</td><td>0.07</td><td>99.98</td></tr><tr><td>Food-101</td><td>0.56</td><td>99.86</td><td>0.09</td><td>99.95</td><td>0.49</td><td>99.88</td><td>8.33</td><td>97.44</td><td>2.37</td><td>99.28</td></tr><tr><td>Oxford-Pet 57]</td><td>0.02</td><td>99.98</td><td>0.05</td><td>99.97</td><td>0.20</td><td>99.94</td><td>0.27</td><td>99.91</td><td>0.14</td><td>99.95</td></tr><tr><td>ImageNet-10</td><td>2.40</td><td>99.42</td><td>1.79</td><td>99.55</td><td>2.83</td><td>99.32</td><td>1.86</td><td>99.56</td><td>2.22</td><td>99.46</td></tr><tr><td>ImageNet-20</td><td>14.96</td><td>97.87</td><td>13.10</td><td>97.97</td><td>14.21</td><td>97.67</td><td>13.46</td><td>97.32</td><td>13.93</td><td>97.71</td></tr><tr><td>ImageNet-1k</td><td>61.66</td><td>89.31</td><td>64.39</td><td>87.43</td><td>63.67</td><td>85.95</td><td>86.61</td><td>71.68</td><td>69.08</td><td>83.59</td></tr></table>
165
+
166
+ Cars [39], and Oxford-Pet $ { \mathbb { B } } { \mathbb { Z } }$ as ID, the performance of maximum cosine similarity score is similar to MCM (see Table 1 and Table $\textcircled{2}$ . However, for more challenging tasks such as ImageNet-20 and ImageNet-1k, MCM significantly outperforms that without softmax scaling. For example, the average FPR95 is improved by $1 1 . 3 3 \%$ on ImageNet-20 and $2 6 . 3 4 \%$ on ImageNet-1k, which highlights the necessity of a proper scaling function for CLIP-based OOD detection.
167
+
168
+ MCM for ResNet-based CLIP models. Our main results are based on the CLIP model with ViT image encoder. We additionally investigate the effectiveness of MCM on ResNet-based CLIP. Specifically, we use RN50x4 (178.3M), which shares a similar number of parameters as CLIP-B/16 (149.6M). The results are shown in Table $5 .$ We can see that MCM still shows promising results with ResNet-based CLIP models, and the performance is comparable between $\mathrm { R N } 5 0 \mathrm { x } 4$ and CLIP-B/16 (89.97 vs. 90.77 in AUROC).
169
+
170
+ Table 5: Comparison with ResNet-based CLIP models on ImageNet-1k (ID).
171
+
172
+ <table><tr><td rowspan="2">Model</td><td colspan="7">OOD Dataset</td><td rowspan="2"></td><td colspan="2" rowspan="2">Average</td></tr><tr><td>iNaturalist</td><td></td><td>SUN</td><td></td><td>Places</td><td></td><td>Texture</td><td></td></tr><tr><td></td><td>FPR95↓</td><td>AUROC个</td><td>FPR95↓</td><td>AUROC个</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td><td>FPR95↓</td><td>AUROC↑</td></tr><tr><td>RN50x4</td><td>44.51</td><td>91.51</td><td>35.11</td><td>92.84</td><td>43.74</td><td>89.60</td><td>57.73</td><td>85.93</td><td>45.27</td><td>89.97</td></tr><tr><td>CLIP-B/16</td><td>30.91</td><td>94.61</td><td>37.59</td><td>92.57</td><td>44.69</td><td>89.77</td><td>57.77</td><td>86.11</td><td>42.74</td><td>90.77</td></tr></table>
173
+
174
+ Effect of prompt ensembling. We examine MCM’s performance with prompt ensembling. For example, Radford et al. $\pmb { \Vert 5 9 } \Vert$ create 80 possible prompts according to the image modalities and nuances in ImageNet. We experiment with the two prompt sets, one of size 80 as in $\mathbb { \left. 5 9 \right. }$ , and our own set of 5 prompts. Ensembles are obtained by averaging the textual features. As expected, using ensembles increases the ID classification accuracy on ImageNet-1k $2 \%$ with CLIP-B and
175
+
176
+ <table><tr><td>A photo of a&lt;label&gt;. A blurryphoto of a&lt;label&gt;. A photo of many &lt;label&gt;. A photo of the large &lt;label&gt;.</td></tr><tr><td></td></tr><tr><td>A photo of the small &lt;label&gt;.</td></tr></table>
177
+
178
+ Table 6: The five prompt templates.
179
+
180
+ $3 \%$ with CLIP-L). For OOD detection, the average FPR95 is reduced from $3 8 . 1 7 \%$ with the default prompt to $3 5 . 2 3 \% \downarrow$ with an ensemble of five prompts shown in Table $6 .$ In addition, the detection performance with 5 prompts is slightly better than with 80 prompts. Note that prompt ensembling does not increase the inference-time cost, as the textual embeddings (across many prompts) can be pre-calculated and averaged into a single embedding.
181
+
182
+ # 6 Related Works
183
+
184
+ OOD detection in computer vision. For open-world multi-class classification, the goal of OOD detection is to derive a binary ID-OOD classifier along with a multi-class classification model for visual inputs. A plethora of methods has been proposed for deep neural networks $\textstyle \left[ \left| 9 1 \right| \right]$ , including generative model-based methods [7, 20, 36, 53, 54, 56, 61, 67, 88], and discriminative-model based methods. For the latter category, an OOD score can be derived based on the softmax output [4, 12, 24, 25, 29, 32, 46, 90], energy-based score [15, 48, 49, 69, 70, 82], gradient information $\bar { \mathbb { B } } \bar { \mathbb { 1 } }$ , or the feature embeddings [14, 42, 65, 66, 71, 72, 85] of a model. Morteza et al. [52], Fang et al. [17], and Bitterwolf et al. [5] provided theoretical analysis for OOD detection. Recent works [63, 83] also explored OOD detection for long-tailed distributions. Works insofar have mostly focused on OOD detection for a task-specific model using only visual information. In contrast, we explore a novel paradigm of zero-shot OOD detection that incorporates rich textual information and can perform a wide variety of tasks.
185
+
186
+ OOD detection in natural language processing. Distribution shifts can occur due to the change of topics and domains, unexpected user utterances, etc. Challenging benchmarks $\pmb { \Vert 3 7 \Vert }$ and characterization of distributional shifts $\mathbb { I I }$ have been proposed in recent years. Compared to early language models such as ConvNets and LSTM $\left[ \left[ 2 8 \right] \right]$ , pre-trained language models are more robust to distribution shifts and more effective at identifying OOD instances [26, 58, 89]. Various algorithmic solutions are proposed to handle OOD detection, including outlier exposure $\pmb { \mathbb { B } } 0 \|$ , model ensembling $\pm \ddagger { 4 } \rVert$ , data augmentation [8, 93, 95], contrastive learning [34, 98], and an auxiliary module that incorporates domain labels $\pmb { \Vert 6 8 \Vert }$ . Tan et al. $\mathbb { [ \overline { { \mathbb { Z } \mathrm { 3 } } } }$ also explore zero-shot OOD detection for text classification tasks. However, prior works focus on pure natural language processing (NLP) settings, while we explore utilizing textual embeddings for zero-shot visual OOD detection.
187
+
188
+ Vision-language models. Utilizing large-scale pre-trained vision-language models for multimodal downstream tasks has become an emerging paradigm with remarkable performance $[ \sqrt { 2 2 } , \sqrt { 7 4 } ]$ . In general, two types of architectures exist: single-stream models like VisualBERT $\mathbb { \lVert \boldsymbol { 4 3 } \rVert }$ and ViLT [35] feed the concatenated text and visual features into a single transformer-based encoder; dual-stream models such as CLIP $\pmb { \Vert 5 9 \Vert }$ , ALIGN $\pmb { \mathbb { B 3 } }$ , and FILIP $\pmb { \Vert } \pmb { \mathscr { Q } } \pmb { \mathscr { Q } } \Vert$ use separate encoders for text and image and optimize with contrastive objectives to align semantically similar features in different modalities. In particular, CLIP enjoys popularity due to its simplicity and strong performance. CLIP-like models inspire numerous follow-up works [45, 94, 97], which aim to improve data efficiency and better adaptation to downstream tasks. This paper adopts CLIP as the target pre-trained model, but our approach can be generally applicable to contrastive models that promote vision-language alignment.
189
+
190
+ Multi-modal OOD detection. Exploring textual information for visual OOD detection is a new area with limited existing works. Fort et al. [19] propose to feed the potential OOD labels to the textual encoder of CLIP [59]. Recently, Esmaeilpour et al. [16] propose to train a label generator based on the visual encoder of CLIP and use the generated labels for OOD detection. While both works rely on a set of candidate OOD labels, MCM is OOD-agnostic and alleviates the need for prior information on OOD. Moreover, prior works [16, 59] only focus on small-scale inputs. We largely expand the scope to a wide range of large-scale realistic datasets, and show new theoretical insights.
191
+
192
+ # 7 Conclusion
193
+
194
+ In this work, we delve into a new landscape for OOD detection, departing from the classic singlemodal toward a multi-modal regime. By viewing the textual features as the “concept prototypes”, we explore a new OOD detection approach MCM, based on the joint vision-language representations. Unlike the majority of OOD detection methods, MCM offers several compelling advantages: trainingfree, generalizable to many tasks, scalable to hundreds of classes, and does not require any prior information on OOD inputs. Moreover, we provide theoretical guarantees on how softmax scaling provably improves zero-shot OOD detection. We investigate the effectiveness of MCM on a wide range of large-scale realistic tasks, including several types of hard OOD datasets. Lastly, we demonstrate the advantage of vision-language features over pure visual features for OOD detection. We hope our work will inspire future research toward multi-modal OOD detection.
195
+
196
+ # Acknowledgement
197
+
198
+ The authors wish to thank Junjie Hu, Ying Fan, Ruisu Zhang, Andrew Geng, and Soumya Suvra Ghosal for the helpful discussions. The work is supported by a Google-Initiated Research Grant, and gift funding from Adobe Research.
199
+
200
+ # References
201
+
202
+ [1] Udit Arora, William Huang, and He He. Types of out-of-distribution texts and how to detect them. In Conference on Empirical Methods in Natural Language Processing (EMNLP), 2021.
203
+ [2] Andrei Barbu, David Mayo, Julian Alverio, William Luo, Christopher Wang, Dan Gutfreund, Josh Tenenbaum, and Boris Katz. Objectnet: A large-scale bias-controlled dataset for pushing the limits of object recognition models. In Conference on Neural Information Processing Systems (NeurIPS), 2019.
204
+ [3] Sara Beery, Grant Van Horn, and Pietro Perona. Recognition in terra incognita. In The European Conference on Computer Vision (ECCV), 2018.
205
+ [4] Abhijit Bendale and Terrance E Boult. Towards open set deep networks. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2016.
206
+ [5] Julian Bitterwolf, Alexander Meinke, Maximilian Augustin, and Matthias Hein. Breaking down out-of-distribution detection: Many methods based on ood training data estimate a combination of the same core quantities. In International Conference on Machine Learning, pages 2041–2074. PMLR, 2022.
207
+ [6] Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In The European Conference on Computer Vision (ECCV), 2014.
208
+ [7] Mu Cai and Yixuan Li. Out-of-distribution detection via frequency-regularized generative models. In Proceedings of IEEE/CVF Winter Conference on Applications of Computer Vision, 2023.
209
+ [8] Derek Chen and Zhou Yu. Gold: improving out-of-scope detection in dialogues using data augmentation. arXiv preprint arXiv:2109.03079, 2021.
210
+ [9] Jiefeng Chen, Yixuan Li, Xi Wu, Yingyu Liang, and Somesh Jha. Atom: Robustifying out-ofdistribution detection using outlier mining. In The European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML PKDD), 2021.
211
+ [10] Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2014.
212
+ [11] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2009.
213
+ [12] Terrance DeVries and Graham W Taylor. Learning confidence for out-of-distribution detection in neural networks. arXiv preprint arXiv:1802.04865, 2018.
214
+ [13] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.
215
+ [14] Xuefeng Du, Gabriel Gozum, Yifei Ming, and Yixuan Li. Siren: Shaping representations for detecting out-of-distribution objects. In Advances in Neural Information Processing Systems (NeurIPS), 2022.
216
+ [15] Xuefeng Du, Zhaoning Wang, Mu Cai, and Yixuan Li. Vos: Learning what you don’t know by virtual outlier synthesis. In Proceedings of the International Conference on Learning Representations (ICLR), 2022.
217
+ [16] Sepideh Esmaeilpour, Bing Liu, Eric Robertson, and Lei Shu. Zero-shot open set detection by extending clip. In The AAAI Conference on Artificial Intelligence (AAAI), 2022.
218
+ [17] Zhen Fang, Yixuan Li, Jie Lu, Jiahua Dong, Bo Han, and Feng Liu. Is out-of-distribution detection learnable? In Advances in Neural Information Processing System (NeurIPS), 2022.
219
+ [18] Christiane Fellbaum. Wordnet. In Theory and Applications of Ontology: Computer Applications, pages 231–243. Springer, 2010.
220
+ [19] Stanislav Fort, Jie Ren, and Balaji Lakshminarayanan. Exploring the limits of out-of-distribution detection. In Conference on Neural Information Processing Systems (NeurIPS), 2021.
221
+ [20] ZongYuan Ge, Sergey Demyanov, Zetao Chen, and Rahil Garnavi. Generative openmax for multi-class open set classification. arXiv preprint arXiv:1707.07418, 2017.
222
+ [21] Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A. Wichmann, and Wieland Brendel. Imagenet-trained CNNs are biased towards texture; increasing shape bias improves accuracy and robustness. In International Conference on Learning Representations (ICLR), 2019.
223
+ [22] Jiuxiang Gu, Jason Kuen, Shafiq Joty, Jianfei Cai, Vlad Morariu, Handong Zhao, and Tong Sun. Self-supervised relationship probing. In Conference on Neural Information Processing Systems (NeurIPS), 2020.
224
+ [23] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2016.
225
+ [24] Matthias Hein, Maksym Andriushchenko, and Julian Bitterwolf. Why relu networks yield high-confidence predictions far away from the training data and how to mitigate the problem. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR, pages 41–50, 2019.
226
+ [25] Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In International Conference on Learning Representations (ICLR), 2017.
227
+ [26] Dan Hendrycks, Xiaoyuan Liu, Eric Wallace, Adam Dziedzic, Rishabh Krishnan, and Dawn Song. Pretrained transformers improve out-of-distribution robustness. In Association for Computational Linguistics (ACL), 2020.
228
+ [27] Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. Deep anomaly detection with outlier exposure. In International Conference on Learning Representations (ICLR), 2018.
229
+ [28] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.
230
+ [29] Yen-Chang Hsu, Yilin Shen, Hongxia Jin, and Zsolt Kira. Generalized odin: Detecting out-ofdistribution image without learning from out-of-distribution data. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2020.
231
+ [30] Yibo Hu and Latifur Khan. Uncertainty-aware reliable text classification. In SIGKDD Conference on Knowledge Discovery and Data Mining (KDD), 2021.
232
+ [31] Rui Huang, Andrew Geng, and Yixuan Li. On the importance of gradients for detecting distributional shifts in the wild. In Conference on Neural Information Processing Systems (NeurIPS), 2021.
233
+ [32] Rui Huang and Yixuan Li. Mos: Towards scaling out-of-distribution detection for large semantic space. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2021.
234
+ [33] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning (ICML), 2021.
235
+ [34] Di Jin, Shuyang Gao, Seokhwan Kim, Yang Liu, and Dilek Hakkani-Tur. Towards textual out-of-domain detection without in-domain labels. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 2022.
236
+ [35] Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision. In International Conference on Machine Learning (ICML), 2021.
237
+ [36] Polina Kirichenko, Pavel Izmailov, and Andrew G Wilson. Why normalizing flows fail to detect out-of-distribution data. Conference on Neural Information Processing Systems (NeurIPS), 2020.
238
+ [37] Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, et al. Wilds: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning (ICML), 2021.
239
+ [38] Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In The European Conference on Computer Vision (ECCV), 2020.
240
+ [39] Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In 4th International IEEE Workshop on 3D Representation and Recognition (3dRR-13), Sydney, Australia, 2013.
241
+ [40] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
242
+ [41] Ya Le and Xuan Yang. Tiny imagenet visual recognition challenge. CS 231N, 7(7):3, 2015.
243
+ [42] Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In Conference on Neural Information Processing Systems (NeurIPS), 2018.
244
+ [43] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
245
+ [44] Xiaoya Li, Jiwei Li, Xiaofei Sun, Chun Fan, Tianwei Zhang, Fei Wu, Yuxian Meng, and Jun Zhang. kfolden: k-fold ensemble for out-of-distribution detection. In Conference on Empirical Methods in Natural Language Processing (EMNLP), 2021.
246
+ [45] Yangguang Li, Feng Liang, Lichen Zhao, Yufeng Cui, Wanli Ouyang, Jing Shao, Fengwei Yu, and Junjie Yan. Supervision exists everywhere: A data efficient contrastive language-image pre-training paradigm. In International Conference on Learning Representations (ICLR), 2022.
247
+ [46] Shiyu Liang, Yixuan Li, and Rayadurgam Srikant. Enhancing the reliability of out-ofdistribution image detection in neural networks. In International Conference on Learning Representations (ICLR), 2018.
248
+ [47] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In The European Conference on Computer Vision (ECCV), 2014.
249
+ [48] Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based out-of-distribution detection. In Conference on Neural Information Processing Systems (NeurIPS), 2020.
250
+ [49] Yifei Ming, Ying Fan, and Yixuan Li. Poem: Out-of-distribution detection with posterior sampling. In International Conference on Machine Learning (ICML), 2022.
251
+ [50] Yifei Ming, Hang Yin, and Yixuan Li. On the impact of spurious correlation for out-ofdistribution detection. The AAAI Conference on Artificial Intelligence (AAAI), 2022.
252
+ [51] Ron Mokady, Amir Hertz, and Amit H Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021.
253
+ [52] Peyman Morteza and Yixuan Li. Provable guarantees for understanding out-of-distribution detection. The AAAI Conference on Artificial Intelligence (AAAI), 2022.
254
+ [53] Eric Nalisnick, Akihiro Matsukawa, Yee Whye Teh, Dilan Gorur, and Balaji Lakshminarayanan. Do deep generative models know what they don’t know? In International Conference on Learning Representations (ICLR), 2019.
255
+ [54] Lawrence Neal, Matthew Olson, Xiaoli Fern, Weng-Keen Wong, and Fuxin Li. Open set learning with counterfactual images. In The European Conference on Computer Vision (ECCV), 2018.
256
+ [55] Edwin G. Ng, Bo Pang, Piyush Sharma, and Radu Soricut. Understanding guided image captioning performance across domains. arXiv preprint arXiv:2012.02339, 2020.
257
+ [56] Poojan Oza and Vishal M Patel. C2ae: Class conditioned auto-encoder for open-set recognition. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2019.
258
+ [57] Omkar M. Parkhi, Andrea Vedaldi, Andrew Zisserman, and C. V. Jawahar. Cats and dogs. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2012.
259
+ [58] Alexander Podolskiy, Dmitry Lipin, Andrey Bout, Ekaterina Artemova, and Irina Piontkovskaya. Revisiting mahalanobis distance for transformer-based out-of-domain detection. In The AAAI Conference on Artificial Intelligence (AAAI), 2021.
260
+ [59] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning (ICML), 2021.
261
+ [60] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
262
+ [61] Jie Ren, Peter J Liu, Emily Fertig, Jasper Snoek, Ryan Poplin, Mark Depristo, Joshua Dillon, and Balaji Lakshminarayanan. Likelihood ratios for out-of-distribution detection. In Conference on Neural Information Processing Systems (NeurIPS), 2019.
263
+ [62] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. " why should i trust you?" explaining the predictions of any classifier. In SIGKDD Conference on Knowledge Discovery and Data Mining (KDD), 2016.
264
+ [63] Abhijit Guha Roy, Jie Ren, Shekoofeh Azizi, Aaron Loh, Vivek Natarajan, Basil Mustafa, Nick Pawlowski, Jan Freyberg, Yuan Liu, Zach Beaver, et al. Does your dermatology classifier know what it doesn’t know? detecting the long-tail of unseen conditions. Medical Image Analysis, 75:102274, 2022.
265
+ [64] Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations (ICLR), 2019.
266
+ [65] Chandramouli Shama Sastry and Sageev Oore. Detecting out-of-distribution examples with Gram matrices. In International Conference on Machine Learning (ICML), 2020.
267
+ [66] Vikash Sehwag, Mung Chiang, and Prateek Mittal. Ssd: A unified framework for self-supervised outlier detection. In International Conference on Learning Representations (ICLR), 2021.
268
+ [67] Joan Serrà, David Álvarez, Vicenç Gómez, Olga Slizovskaia, José F. Núñez, and Jordi Luque. Input complexity and out-of-distribution detection with likelihood-based generative models. In International Conference on Learning Representations (ICLR), 2020.
269
+ [68] Yilin Shen, Yen-Chang Hsu, Avik Ray, and Hongxia Jin. Enhancing the generalization for intent classification and out-of-domain detection in slu. arXiv preprint arXiv:2106.14464, 2021.
270
+ [69] Yiyou Sun, Chuan Guo, and Yixuan Li. React: Out-of-distribution detection with rectified activations. In Conference on Neural Information Processing Systems (NeurIPS), 2021.
271
+ [70] Yiyou Sun and Yixuan Li. Dice: Leveraging sparsification for out-of-distribution detection. In Proceedings of European Conference on Computer Vision (ECCV), 2022.
272
+ [71] Yiyou Sun, Yifei Ming, Xiaojin Zhu, and Yixuan Li. Out-of-distribution detection with deep nearest neighbors. In International Conference on Machine Learning (ICML), 2022.
273
+ [72] Jihoon Tack, Sangwoo Mo, Jongheon Jeong, and Jinwoo Shin. Csi: Novelty detection via contrastive learning on distributionally shifted instances. In Conference on Neural Information Processing Systems (NeurIPS), 2020.
274
+ [73] Ming Tan, Yang Yu, Haoyu Wang, Dakuo Wang, Saloni Potdar, Shiyu Chang, and Mo Yu. Out-of-domain detection for low-resource text classification tasks. In Conference on Empirical Methods in Natural Language Processing (EMNLP), 2019.
275
+ [74] Shagun Uppal, Sarthak Bhagat, Devamanyu Hazarika, Navonil Majumder, Soujanya Poria, Roger Zimmermann, and Amir Zadeh. Multimodal research in vision and language: A review of current and emerging trends. Information Fusion, 77:149–171, 2022.
276
+ [75] Aaron Van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv e-prints, pages arXiv–1807, 2018.
277
+ [76] Grant Van Horn, Oisin Mac Aodha, Yang Song, Yin Cui, Chen Sun, Alex Shepard, Hartwig Adam, Pietro Perona, and Serge Belongie. The inaturalist species classification and detection dataset. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2018.
278
+ [77] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Conference on Neural Information Processing Systems (NeurIPS), 2017.
279
+ [78] Sagar Vaze, Kai Han, Andrea Vedaldi, and Andrew Zisserman. Open-set recognition: A good closed-set classifier is all you need. In International Conference on Learning Representations (ICLR), 2022.
280
+ [79] Roman Vershynin. High-dimensional probability: An introduction with applications in data science, volume 47. Cambridge university press, 2018.
281
+ [80] C. Wah, S. Branson, P. Welinder, P. Perona, and S. Belongie. The caltech-ucsd birds-200-2011 dataset. Technical Report CNS-TR-2011-001, California Institute of Technology, 2011.
282
+ [81] Feng Wang and Huaping Liu. Understanding the behaviour of contrastive loss. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2021.
283
+ [82] Haoran Wang, Weitang Liu, Alex Bocchieri, and Yixuan Li. Can multi-label classification networks know what they don’t know? Proceedings of the Advances in Neural Information Processing Systems (NeurIPS), 2021.
284
+ [83] Haotao Wang, Aston Zhang, Yi Zhu, Shuai Zheng, Mu Li, Alex J Smola, and Zhangyang Wang. Partial and asymmetric contrastive learning for out-of-distribution detection in long-tailed recognition. In International Conference on Machine Learning (ICML), 2022.
285
+ [84] Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In International Conference on Machine Learning (ICML), 2020.
286
+ [85] Jim Winkens, Rudy Bunel, Abhijit Guha Roy, Robert Stanforth, Vivek Natarajan, Joseph R Ledsam, Patricia MacWilliams, Pushmeet Kohli, Alan Karthikesalingam, Simon Kohl, et al. Contrastive training for improved out-of-distribution detection. arXiv preprint arXiv:2007.05566, 2020.
287
+ [86] Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2010.
288
+ [87] Kai Yuanqing Xiao, Logan Engstrom, Andrew Ilyas, and Aleksander Madry. Noise or signal: The role of image backgrounds in object recognition. In International Conference on Learning Representations (ICLR), 2021.
289
+ [88] Zhisheng Xiao, Qing Yan, and Yali Amit. Likelihood regret: An out-of-distribution detection score for variational auto-encoder. In Conference on Neural Information Processing Systems (NeurIPS), volume 33, 2020.
290
+ [89] Keyang Xu, Tongzheng Ren, Shikun Zhang, Yihao Feng, and Caiming Xiong. Unsupervised outof-domain detection via pre-trained transformers. In Association for Computational Linguistics (ACL), 2021.
291
+ [90] Jingkang Yang, Haoqi Wang, Litong Feng, Xiaopeng Yan, Huabin Zheng, Wayne Zhang, and Ziwei Liu. Semantically coherent out-of-distribution detection. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2021.
292
+ [91] Jingkang Yang, Kaiyang Zhou, Yixuan Li, and Ziwei Liu. Generalized out-of-distribution detection: A survey. arXiv preprint arXiv:2110.11334, 2021.
293
+ [92] Lewei Yao, Runhui Huang, Lu Hou, Guansong Lu, Minzhe Niu, Hang Xu, Xiaodan Liang, Zhenguo Li, Xin Jiang, and Chunjing Xu. Filip: Fine-grained interactive language-image pre-training. International Conference on Learning Representations (ICLR), 2021.
294
+ [93] Li-Ming Zhan, Haowen Liang, Bo Liu, Lu Fan, Xiao-Ming Wu, and Albert Lam. Out-of-scope intent detection with self-supervision and discriminative training. Association for Computational Linguistics (ACL), 2021.
295
+ [94] Renrui Zhang, Rongyao Fang, Peng Gao, Wei Zhang, Kunchang Li, Jifeng Dai, Yu Qiao, and Hongsheng Li. Tip-adapter: Training-free clip-adapter for better vision-language modeling. arXiv preprint arXiv:2111.03930, 2021.
296
+ [95] Yinhe Zheng, Guanyi Chen, and Minlie Huang. Out-of-domain detection for natural language understanding in dialog systems. TASLP, 2020.
297
+ [96] Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI), 2017.
298
+ [97] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In The IEEE / CVF Computer Vision and Pattern Recognition Conference (CVPR), 2022.
299
+ [98] Wenxuan Zhou, Fangyu Liu, and Muhao Chen. Contrastive out-of-distribution detection for pretrained transformers. Conference on Empirical Methods in Natural Language Processing (EMNLP), 2021.
300
+ [99] Zhuotun Zhu, Lingxi Xie, and Alan Yuille. Object recognition with and without objects. In International Joint Conferences on Artificial Intelligence (IJCAI), 2017.
301
+
302
+ # Checklist
303
+
304
+ 1. For all authors...
305
+
306
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
307
+ (b) Did you describe the limitations of your work? [N/A]
308
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
309
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
310
+
311
+ 2. If you are including theoretical results...
312
+
313
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3 and Section A (b) Did you include complete proofs of all theoretical results? [Yes] See Section A
314
+
315
+ 3. If you ran experiments...
316
+
317
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section B
318
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4 and Section B
319
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] There is no training involved in MCM. For fair comparison and reproducibility, we use the publicly available checkpoints of CLIP from OpenAI.
320
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section B
321
+
322
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
323
+
324
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section B
325
+ (b) Did you mention the license of the assets? [N/A]
326
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] See Section B
327
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
328
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
329
+
330
+ 5. If you used crowdsourcing or conducted research with human subjects...
331
+
332
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
333
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
334
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/LzQQ89U1qm_/LzQQ89U1qm_.md ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ANOMALY TRANSFORMER: TIME SERIES ANOMALY DETECTION WITH ASSOCIATION DISCREPANCY
2
+
3
+ Jiehui Xu∗, Haixu Wu∗, Jianmin Wang, Mingsheng LongB School of Software, BNRist, Tsinghua University, Beijing 100084, China $\{ \mathbf { x } \mathrm { j h } 2 0 , \mathbf { w h } \mathbf { x } 2 0 \}$ @mails.tsinghua.edu.cn, {jimwang,mingsheng}@tsinghua.edu.cn
4
+
5
+ # ABSTRACT
6
+
7
+ Unsupervised detection of anomaly points in time series is a challenging problem, which requires the model to derive a distinguishable criterion. Previous methods tackle the problem mainly through learning pointwise representation or pairwise association, however, neither is sufficient to reason about the intricate dynamics. Recently, Transformers have shown great power in unified modeling of pointwise representation and pairwise association, and we find that the self-attention weight distribution of each time point can embody rich association with the whole series. Our key observation is that due to the rarity of anomalies, it is extremely difficult to build nontrivial associations from abnormal points to the whole series, thereby, the anomalies’ associations shall mainly concentrate on their adjacent time points. This adjacent-concentration bias implies an association-based criterion inherently distinguishable between normal and abnormal points, which we highlight through the Association Discrepancy. Technically, we propose the Anomaly Transformer with a new Anomaly-Attention mechanism to compute the association discrepancy. A minimax strategy is devised to amplify the normal-abnormal distinguishability of the association discrepancy. The Anomaly Transformer achieves state-of-theart results on six unsupervised time series anomaly detection benchmarks of three applications: service monitoring, space & earth exploration, and water treatment.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Real-world systems always work in a continuous way, which can generate several successive measurements monitored by multi-sensors, such as industrial equipment, space probe, etc. Discovering the malfunctions from large-scale system monitoring data can be reduced to detecting the abnormal time points from time series, which is quite meaningful for ensuring security and avoiding financial loss. But anomalies are usually rare and hidden by vast normal points, making the data labeling hard and expensive. Thus, we focus on time series anomaly detection under the unsupervised setting.
12
+
13
+ Unsupervised time series anomaly detection is extremely challenging in practice. The model should learn informative representations from complex temporal dynamics through unsupervised tasks. Still, it should also derive a distinguishable criterion that can detect the rare anomalies from plenty of normal time points. Various classic anomaly detection methods have provided many unsupervised paradigms, such as the density-estimation methods proposed in local outlier factor (LOF, (Breunig et al., 2000)), clustering-based methods presented in one-class SVM (OC-SVM, (Scholkopf et al., ¨ 2001)) and SVDD (Tax & Duin, 2004). These classic methods do not consider the temporal information and are difficult to generalize to unseen real scenarios. Benefiting from the representation learning capability of neural networks, recent deep models (Su et al., 2019; Shen et al., 2020; Li et al., 2021) have achieved superior performance. A major category of methods focus on learning pointwise representations through well-designed recurrent networks and are self-supervised by the reconstruction or autoregressive task. Here, a natural and practical anomaly criterion is the pointwise reconstruction or prediction error. However, due to the rarity of anomalies, the pointwise representation is less informative for complex temporal patterns and can be dominated by normal time points, making anomalies less distinguishable. Also, the reconstruction or prediction error is calculated point by point, which cannot provide a comprehensive description of the temporal context.
14
+
15
+ Another major category of methods detect anomalies based on explicit association modeling. The vector autoregression and state space models fall into this category. The graph was also used to capture the association explicitly, through representing time series with different time points as vertices and detecting anomalies by random walk (Cheng et al., 2008; 2009). In general, it is hard for these classic methods to learn informative representations and model fine-grained associations. Recently, graph neural network (GNN) has been applied to learn the dynamic graph among multiple variables in multivariate time series (Zhao et al., 2020; Deng & Hooi, 2021). While being more expressive, the learned graph is still limited to a single time point, which is insufficient for complex temporal patterns. Besides, subsequence-based methods detect anomalies by calculating the similarity among subsequences (Boniol & Palpanas, 2020). While exploring wider temporal context, these methods cannot capture the fine-grained temporal association between each time point and the whole series.
16
+
17
+ In this paper, we adapt Transfomers (Vaswani et al., 2017) to time series anomaly detection in the unsupervised regime. Transformers have achieved great progress in various areas, including natural language processing (Brown et al., 2020), machine vision (Liu et al., 2021) and time series (Zhou et al., 2021). This success is attributed to its great power in unified modeling of global representation and long-range relation. Applying Transformers to time series, we find that the temporal association of each time point can be obtained from the self-attention map, which presents as a distribution of its association weights to all the time points along the temporal dimension. The association distribution of each time point can provide a more informative description for the temporal context, indicating dynamic patterns, such as the period or trend of time series. We name the above association distribution as the series-association, which can be discovered from the raw series by Transformers.
18
+
19
+ Further, we observe that due to the rarity of anomalies and the dominance of normal patterns, it is harder for anomalies to build strong associations with the whole series. The associations of anomalies shall concentrate on the adjacent time points that are more likely to contain similar abnormal patterns due to the continuity. Such an adjacent-concentration inductive bias is referred to as the prior-association. In contrast, the dominating normal time points can discover informative associations with the whole series, not limiting to the adjacent area. Based on this observation, we try to utilize the inherent normal-abnormal distinguishability of the association distribution. This leads to a new anomaly criterion for each time point, quantified by the distance between each time point’s prior-association and its series-association, named as Association Discrepancy. As aforementioned, because the associations of anomalies are more likely to be adjacent-concentrating, anomalies will present a smaller association discrepancy than normal time points.
20
+
21
+ Going beyond previous methods, we introduce Transformers to unsupervised time series anomaly detection and propose the Anomaly Transformer for association learning. To compute the Association Discrepancy, we renovate the self-attention mechanism to the Anomaly-Attention, which contains a two-branch structure to model the prior-association and series-association of each time point respectively. The prior-association employs the learnable Gaussian kernel to present the adjacentconcentration inductive bias of each time point, while the series-association corresponds to the selfattention weights learned from raw series. Besides, a minimax strategy is applied between the two branches, which can amplify the normal-abnormal distinguishability of the Association Discrepancy and further derive a new association-based criterion. Anomaly Transformer achieves strong results on six benchmarks, covering three real applications. The contributions are summarized as follows:
22
+
23
+ • Based on the key observation of Association Discrepancy, we propose the Anomaly Transformer with an Anomaly-Attention mechanism, which can model the prior-association and series-association simultaneously to embody the Association Discrepancy. • We propose a minimax strategy to amplify the normal-abnormal distinguishability of the Association Discrepancy and further derive a new association-based detection criterion. • Anomaly Transformer achieves the state-of-the-art anomaly detection results on six benchmarks for three real applications, justified by extensive ablations and insightful case studies.
24
+
25
+ # 2 RELATED WORK
26
+
27
+ # 2.1 UNSUPERVISED TIME SERIES ANOMALY DETECTION
28
+
29
+ As an important real-world problem, unsupervised time series anomaly detection has been widely explored. Categorizing by the anomaly determination criterion, the paradigms roughly include the density-estimation, clustering-based, reconstruction-based and autoregression-based methods.
30
+
31
+ In density-estimation methods, the classic methods such as local outlier factor (LOF, (Breunig et al., 2000)) and connectivity outlier factor (COF, (Tang et al., 2002)) respectively calculate local density and local connectivity for outlier determination. DAGMM (Zong et al., 2018) and MPPCACD (Yairi et al., 2017) integrate the Gaussian Mixture Model to estimate the density of representations.
32
+
33
+ In clustering-based methods, the anomaly score is always formalized as the distance to cluster center. SVDD (Tax & Duin, 2004) and Deep SVDD (Ruff et al., 2018) gather the representations from normal data to a compact cluster. THOC (Shen et al., 2020) fuses the multi-scale temporal features from intermediate layers by a hierarchical clustering mechanism and detects the anomalies by the multi-layer distances. ITAD (Shin et al., 2020) conducts the clustering on decomposed tensors.
34
+
35
+ The reconstruction-based models attempt to detect the anomalies by the reconstruction error. Park et al. (2018) presented the LSTM-VAE model that employs the LSTM backbone for temporal modeling and the Variational AutoEncoder (VAE) for reconstruction. OmniAnomaly proposed by Su et al. (2019) further extends the LSTM-VAE model with a normalizing flow and uses the reconstruction probabilities for detection. InterFusion from Li et al. (2021) renovates the backbone to a hierarchical VAE to model the inter- and intra-dependency among multiple series simultaneously. GANs (Goodfellow et al., 2014) are also used for reconstruction-based anomaly detection (Schlegl et al., 2019; Li et al., 2019a; Zhou et al., 2019) and perform as an adversarial regularization.
36
+
37
+ The autoregression-based models detect the anomalies by the prediction error. VAR extends ARIMA (Anderson & Kendall, 1976) and predicts the future based on the lag-dependent covariance. The autoregressive model can also be replaced by LSTMs (Hundman et al., 2018; Tariq et al., 2019).
38
+
39
+ This paper is characterized by a new association-based criterion. Different from the random walk and subsequence-based methods (Cheng et al., 2008; Boniol & Palpanas, 2020), our criterion is embodied by a co-design of the temporal models for learning more informative time-point associations.
40
+
41
+ # 2.2 TRANSFORMERS FOR TIME SERIES ANALYSIS
42
+
43
+ Recently, Transformers (Vaswani et al., 2017) have shown great power in sequential data processing, such as natural language processing (Devlin et al., 2019; Brown et al., 2020), audio processing (Huang et al., 2019) and computer vision (Dosovitskiy et al., 2021; Liu et al., 2021). For time series analysis, benefiting from the advantage of the self-attention mechanism, Transformers are used to discover the reliable long-range temporal dependencies (Kitaev et al., 2020; Li et al., 2019b; Zhou et al., 2021; Wu et al., 2021). Especially for time series anomaly detection, GTA proposed by Chen et al. (2021) employs the graph structure to learn the relationship among multiple IoT sensors, as well as the Transformer for temporal modeling and the reconstruction criterion for anomaly detection. Unlike the previous usage of Transformers, Anomaly Transformer renovates the self-attention mechanism to the Anomaly-Attention based on the key observation of association discrepancy.
44
+
45
+ # 3 METHOD
46
+
47
+ Suppose monitoring a successive system of $d$ measurements and recording the equally spaced observations over time. The observed time series $\mathcal { X }$ is denoted by a set of time points $\{ x _ { 1 } , x _ { 2 } , \cdot \cdot \cdot , x _ { N } \}$ , where $\boldsymbol { x } _ { t } \in \mathbb { R } ^ { d }$ represents the observation of time $t$ . The unsupervised time series anomaly detection problem is to determine whether $x _ { t }$ is anomalous or not without labels.
48
+
49
+ As aforementioned, we highlight the key to unsupervised time series anomaly detection as learning informative representations and finding distinguishable criterion. We propose the Anomaly Transformer to discover more informative associations and tackle this problem by learning the Association Discrepancy, which is inherently normal-abnormal distinguishable. Technically, we propose the Anomaly-Attention to embody the prior-association and series-associations, along with a minimax optimization strategy to obtain a more distinguishable association discrepancy. Co-designed with the architecture, we derive an association-based criterion based on the learned association discrepancy.
50
+
51
+ # 3.1 ANOMALY TRANSFORMER
52
+
53
+ Given the limitation of Transformers (Vaswani et al., 2017) for anomaly detection, we renovate the vanilla architecture to the Anomaly Transformer (Figure 1) with an Anomaly-Attention mechanism.
54
+
55
+ Overall Architecture Anomaly Transformer is characterized by stacking the Anomaly-Attention blocks and feed-forward layers alternately. This stacking structure is conducive to learning underly
56
+
57
+ ![](images/3a3affe498c385a685ffc208ff1906860e8eb80f16d1783d1aa09eed104f528f.jpg)
58
+ /ib2iX AM \*PLah_ALh!A- kykRX/ib2iX AM \*PLah_ALh!A- kykRX Figure 1: Anomaly Transformer. Anomaly-Attention (left) models the prior-association and seriesassociation simultaneously. In addition to the reconstruction loss, our model is also optimized by the minimax strategy with a specially-designed stop-gradient mechanism (gray arrows) to constrain the prior- and series-associations for more distinguishable association discrepancy.
59
+
60
+ ing associations from deep multi-level features. Suppose the model contains $L$ layers with length- $N$ input time series $\mathcal { X } \in \mathbb { R } ^ { N \times d }$ . The overall equations of the $l$ -th layer are formalized as:
61
+
62
+ $$
63
+ \begin{array} { r l } & { \mathcal { Z } ^ { l } = \mathrm { L a y e r - N o r m } \Big ( \mathrm { A n o m a l y - A t t e n t i o n } ( \mathcal { X } ^ { l - 1 } ) + \mathcal { X } ^ { l - 1 } \Big ) } \\ & { \mathcal { X } ^ { l } = \mathrm { L a y e r - N o r m } \Big ( \mathrm { F e e d - F o r w a r d } ( \mathcal { Z } ^ { l } ) + \mathcal { Z } ^ { l } \Big ) , } \end{array}
64
+ $$
65
+
66
+ where $\mathcal { X } ^ { l } \in \mathbb { R } ^ { N \times d _ { \mathrm { m o d e l } } } , l \in \{ 1 , \cdots , L \}$ denotes the output of the $l$ -th layer with $d _ { \mathrm { m o d e l } }$ channels. The initial input $\chi ^ { 0 } = \mathrm { E m b e d d i n g } ( \mathcal { X } )$ represents the embedded raw series. $\mathcal { Z } ^ { l } \in \mathbb { R } ^ { N \times d _ { \mathrm { m o d e l } } }$ is the $l$ -th layer’s hidden representation. Anomaly-Attention $( \cdot )$ is to compute the association discrepancy.
67
+
68
+ Anomaly-Attention Note that the single-branch self-attention mechanism (Vaswani et al., 2017) cannot model the prior-association and series-association simultaneously. We propose the AnomalyAttention with a two-branch structure (Figure 1). For the prior-association, we adopt a learnable Gaussian kernel to calculate the prior with respect to the relative temporal distance. Benefiting from 9the unimodal property of the Gaussian kernel, this design can pay more attention to the adjacent horizon constitutionally. We also use a learnable scale parameter $\sigma$ for the Gaussian kernel, making 9the prior-associations adapt to the various time series patterns, such as different lengths of anomaly 9segments. The series-association branch is to learn the associations from raw series, which can find the most effective associations adaptively. Note that these two forms maintain the temporal depen2dencies of each time point, which are more informative than point-wise representation. They also reflect the adjacent-concentration prior and the learned associations respectively, whose discrepancy shall be normal-abnormal distinguishable. The Anomaly-Attention in the $l$ -th layer is:
69
+
70
+ $$
71
+ \begin{array} { r l } & { \mathrm { I n i t i a l i z a t i o n : ~ } \mathcal { Q } , \mathcal { K } , \mathcal { V } , \sigma = \mathcal { X } ^ { l - 1 } W _ { \mathcal { Q } } ^ { l } , \mathcal { X } ^ { l - 1 } W _ { \mathcal { K } } ^ { l } , \mathcal { X } ^ { l - 1 } W _ { \mathcal { V } } ^ { l } , \mathcal { X } ^ { l - 1 } W _ { \sigma } ^ { l } } \\ & { \mathrm { P r i o r - A s s o c i a t i o n : ~ } \mathcal { P } ^ { l } = \mathrm { R e s c a l e } \Bigg ( \Bigg [ \frac { 1 } { \sqrt { 2 \pi } \sigma _ { i } } \exp \left( - \frac { \left| j - i \right| ^ { 2 } } { 2 \sigma _ { i } ^ { 2 } } \right) \Bigg ] _ { i , j \in \{ 1 , \cdots , N \} } \Bigg ) } \\ & { \mathrm { ~ } _ { \mathrm { e r i e s - A s s o c i a t i o n : ~ } \mathcal { S } ^ { l } = \mathrm { S o f t m a x } } \left( \frac { Q K ^ { \mathrm { T } } } { \sqrt { d _ { \mathrm { m o d e l } } } } \right) } \end{array}
72
+ $$
73
+
74
+ where $\mathcal { Q } , \mathcal { K } , \mathcal { V } \in \mathbb { R } ^ { N \times d _ { \mathrm { m o d e l } } } , \sigma \in \mathbb { R } ^ { N \times 1 }$ represent the query, key, value of self-attention and the Q K V ∈ learned scale respectively. $W _ { \mathcal { Q } } ^ { l } , W _ { K } ^ { l } , W _ { \mathcal { V } } ^ { l } \ \in \ \mathbb { R } ^ { d _ { \mathrm { m o d e l } } \times d _ { \mathrm { m o d e l } } } , \tilde { W } _ { \sigma } ^ { l } \ \in \ \mathbb { R } ^ { d _ { \mathrm { m o d e l } } \times 1 }$ represent the parameter matrices for $\mathcal { Q } , \mathcal { K } , \mathcal { V } , \sigma$ in the $l$ -th layer respectively. Prior-association $\mathcal { P } ^ { l } \in \mathbb { R } ^ { N \times N }$ is generated based on the learned scale $\sigma \in \mathbb { R } ^ { N \times 1 }$ and the $i$ -th element $\sigma _ { i }$ corresponds to the $i$ -th time point. Concretely, for the $i$ -th time point, its association weight to the $j$ -th point is calculated by the Gaussian kernel $\begin{array} { r } { G ( | j - i | ; \sigma _ { i } ) = \frac { 1 } { \sqrt { 2 \pi } \sigma _ { i } } \exp ( - \frac { | j - i | ^ { 2 } } { 2 \sigma _ { i } ^ { 2 } } ) } \end{array}$ w.r.t. the distance $| j - i |$ 2. Further, we use Rescale $( \cdot )$ to transform the association weights to discrete distributions $\mathcal { P } ^ { l }$ by dividing the row sum. $S ^ { l } \in \mathbb { R } ^ { N \times N }$ denotes the series-associations. Softmax $( \cdot )$ normalizes the attention map along the last dimension, and each row of $S ^ { l }$ forms a discrete distribution. $\widehat { \mathcal { Z } } ^ { l } \in \mathbb { R } ^ { N \times d _ { \mathrm { m o d e l } } }$ is the hidden representation after the Anomaly-Attention in the $l$ -th layer. We use Anomaly-Attention $( \cdot )$ to summarize Equation 2. In the multi-head version, the learned scale is $\sigma \in \mathbb { R } ^ { N \times h }$ for $h$ heads. $\mathcal { Q } _ { m } , \mathcal { K } _ { m } , \mathcal { V } _ { m } \in \mathbb { R } ^ { N \times \frac { d _ { \mathrm { m o d e l } } } { h } }$ denote the query, key and value of the $m$ -th head respectively. The block concatenates the outputs $\{ \widehat { \mathcal { Z } } _ { m } ^ { l } \in \mathbb { R } ^ { N \times \frac { d _ { \mathrm { m o d e l } } } { h } } \} _ { 1 \leq m \leq h }$ l }1≤m≤h from multiple heads and gets the final result Zl ∈ RN×dmodel .
75
+
76
+ ![](images/f5dd89614047a560ea20627f0557e27ced5ca2c2a37702f33b3d49ffeb7cfd81.jpg)
77
+ Figure 2: Minimax association learning. At the minimize phase, the prior-association minimizes the Association Discrepancy within the distribution family derived by Gaussian kernel. At the maximize phase, the series-association maximizes the Association Discrepancy under the reconstruction loss.
78
+
79
+ Association Discrepancy We formalize the Association Discrepancy as the symmetrized KL divergence between prior- and series-associations, which represents the information gain between these two distributions (Neal, 2007). We average the association discrepancy from multiple layers to combine the associations from multi-level features into a more informative measure as:
80
+
81
+ $$
82
+ \operatorname { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) = \left[ \frac { 1 } { L } \sum _ { l = 1 } ^ { L } \left( \operatorname { K L } ( \mathcal { P } _ { i , : } ^ { l } \Vert \mathcal { S } _ { i , : } ^ { l } ) + \operatorname { K L } ( \mathcal { S } _ { i , : } ^ { l } \Vert \mathcal { P } _ { i , : } ^ { l } ) \right) \right] _ { i = 1 , \cdots , N }
83
+ $$
84
+
85
+ where $\operatorname { K L } ( \cdot \| \cdot )$ is the KL divergence computed between two discrete distributions corresponding to every row of $\mathcal { P } ^ { l }$ and $S ^ { l }$ . $\mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \boldsymbol { \mathcal { X } } ) \in \mathbb { R } ^ { N \times 1 }$ is the point-wise association discrepancy of $\mathcal { X }$ with respect to prior-association $\mathcal { P }$ and series-association $s$ from multiple layers. The $i$ -th element of AssDis corresponds to the $i$ -th time point of $\mathcal { X }$ . From previous observation, anomalies will present smaller AssDis $( \mathcal { P } , \mathcal { S } ; \mathcal { X } )$ than normal time points, which makes AssDis inherently distinguishable.
86
+
87
+ # 3.2 MINIMAX ASSOCIATION LEARNING
88
+
89
+ As an unsupervised task, we employ the reconstruction loss for optimizing our model. The reconstruction loss will guide the series-association to find the most informative associations. To further amplify the difference between normal and abnormal time points, we also use an additional loss to enlarge the association discrepancy. Due to the unimodal property of the prior-association, the discrepancy loss will guide the series-association to pay more attention to the non-adjacent area, which makes the reconstruction of anomalies harder and makes anomalies more identifiable. The loss function for input series $\mathcal { X } \in \mathbb { R } ^ { N \times d }$ is formalized as:
90
+
91
+ $$
92
+ \mathcal { L } _ { \mathrm { T o t a l } } ( \widehat { \mathcal { X } } , \mathcal { P } , \mathcal { S } , \lambda ; \mathcal { X } ) = \| \mathcal { X } - \widehat { \mathcal { X } } \| _ { \mathrm { F } } ^ { 2 } - \lambda \times \| \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \| _ { 1 }
93
+ $$
94
+
95
+ where $\widehat { \mathcal { X } } \in \mathbb { R } ^ { N \times d }$ denotes the reconstruction of $\mathcal { X }$ . $\| \cdot \| _ { \mathrm { F } } , \| \cdot \| _ { k }$ indicate the Frobenius and $k$ -norm. $\lambda$
96
+ is to trade off the loss terms. When $\lambda > 0$ , the optimization is to enlarge the association discrepancy.
97
+ A minimax strategy is proposed to make the association discrepancy more distinguishable.
98
+
99
+ Minimax Strategy Note that directly maximizing the association discrepancy will extremely reduce the scale parameter of the Gaussian kernel (Neal, 2007), making the prior-association meaningless. Towards a better control of association learning, we propose a minimax strategy (Figure 2). Concretely, for the minimize phase, we drive the prior-association $\mathcal { P } ^ { l }$ to approximate the seriesassociation $S ^ { l }$ that is learned from raw series. This process will make the prior-association adapt to various temporal patterns. For the maximize phase, we optimize the series-association to enlarge the association discrepancy. This process forces the series-association to pay more attention to the non-adjacent horizon. Thus, integrating the reconstruction loss, the loss functions of two phases are:
100
+
101
+ Minimize Phase: $\mathcal { L } _ { \mathrm { T o t a l } } ( \widehat { \mathcal { X } } , \mathcal { P } , S _ { \mathrm { d e t a c h } } , - \lambda ; \mathcal { X } )$
102
+
103
+ Maximize Phase: $\mathcal { L } _ { \mathrm { T o t a l } } ( \widehat { \mathcal { X } } , \mathcal { P } _ { \mathrm { d e t a c h } } , S , \lambda ; \mathcal { X } )$ ,
104
+
105
+ where $\lambda > 0$ and $^ { * } \mathrm { d e t a c h }$ means to stop the gradient backpropagation of the association (Figure 1). As $\mathcal { P }$ approximates $\boldsymbol { S } _ { \mathrm { d e t a c h } }$ in the minimize phase, the maximize phase will conduct a stronger constraint to the series-association, forcing the time points to pay more attention to the non-adjacent area. Under the reconstruction loss, this is much harder for anomalies to achieve than normal time points, thereby amplifying the normal-abnormal distinguishability of the association discrepancy.
106
+
107
+ Association-based Anomaly Criterion We incorporate the normalized association discrepancy to the reconstruction criterion, which will take the benefits of both temporal representation and the distinguishable association discrepancy. The final anomaly score of $\mathcal { X } \in \mathbb { R } ^ { N \times d }$ is shown as follows:
108
+
109
+ $$
110
+ \mathrm { A n o m a l y S c o r e } ( \mathcal { X } ) = \mathrm { S o f t m a x } \bigg ( - \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \bigg ) \odot \bigg [ \| \mathcal { X } _ { i , : } - \widehat { \mathcal { X } } _ { i , : } \| _ { 2 } ^ { 2 } \bigg ] _ { i = 1 , \cdots , N }
111
+ $$
112
+
113
+ where $\odot$ is the element-wise multiplication. Anom $\mathrm { a l y S c o r e } ( \mathcal { X } ) \in \mathbb { R } ^ { N \times 1 }$ denotes the point-wise anomaly criterion of $\mathcal { X }$ . Towards a better reconstruction, anomalies usually decrease the association discrepancy, which will still derive a higher anomaly score. Thus, this design can make the reconstruction error and the association discrepancy collaborate to improve detection performance.
114
+
115
+ # 4 EXPERIMENTS
116
+
117
+ We extensively evaluate Anomaly Transformer on six benchmarks for three practical applications.
118
+
119
+ Datasets Here is a description of the six experiment datasets: (1) SMD (Server Machine Dataset, Su et al. (2019)) is a 5-week-long dataset collected from a large Internet company with 38 dimensions. (2) PSM (Pooled Server Metrics, Abdulaal et al. (2021)) is collected internally from multiple application server nodes at eBay with 26 dimensions. (3) Both MSL (Mars Science Laboratory rover) and SMAP (Soil Moisture Active Passive satellite) are public datasets from NASA (Hundman et al., 2018) with 55 and 25 dimensions respectively, which contain the telemetry anomaly data derived from the Incident Surprise Anomaly (ISA) reports of spacecraft monitoring systems. (4) SWaT (Secure Water Treatment, Mathur & Tippenhauer (2016)) is obtained from 51 sensors of the critical infrastructure system under continuous operations. (5) NeurIPS-TS (NeurIPS 2021 Time Series Benchmark) is a dataset proposed by Lai et al. (2021) and includes five time series anomaly scenarios categorized by behavior-driven taxonomy as point-global, pattern-contextual, pattern-shapelet, pattern-seasonal and pattern-trend. The statistical details are summarized in Table 13 of Appendix.
120
+
121
+ Implementation details Following the well-established protocol in Shen et al. (2020), we adopt a non-overlapped sliding window to obtain a set of sub-series. The sliding window is with a fixed size of 100 for all datasets. We label the time points as anomalies if their anomaly scores (Equation 6) are larger than a certain threshold $\delta$ . The threshold $\delta$ is determined to make a proportion $r$ of time points of the validation dataset labeled as anomalies. For the main results, we set $r = 0 . 1 \%$ for SWaT, $0 . 5 \%$ for SMD and $1 \%$ for other datasets. We adopt the widely-used adjustment strategy ( $\mathrm { { X u } }$ et al., 2018; Su et al., 2019; Shen et al., 2020): if a time point in a certain successive abnormal segment is detected, all anomalies in this abnormal segment are viewed to be correctly detected. This strategy is justified from the observation that an abnormal time point will cause an alert and further make the whole segment noticed in real-world applications. Anomaly Transformer contains 3 layers. We set the channel number of hidden states $d _ { \mathrm { m o d e l } }$ as 512 and the number of heads $h$ as 8. The hyperparameter $\lambda$ (Equation 4) is set as 3 for all datasets to trade-off two parts of the loss function. We use the ADAM (Kingma & Ba, 2015) optimizer with an initial learning rate of $1 0 ^ { - 4 }$ . The training process is early stopped within 10 epochs with the batch size of 32. All the experiments are implemented in Pytorch (Paszke et al., 2019) with a single NVIDIA TITAN RTX 24GB GPU.
122
+
123
+ Baselines We extensively compare our model with 18 baselines, including the reconstructionbased models: InterFusion (2021), BeatGAN (2019), OmniAnomaly (2019), LSTM-VAE (2018); the density-estimation models: DAGMM (2018), MPPCACD (2017), LOF (2000); the clusteringbased methods: ITAD (2020), THOC (2020), Deep-SVDD (2018); the autoregression-based models: CL-MPPCA (2019), LSTM (2018), VAR (1976); the classic methods: OC-SVM (2004), IsolationForest (2008). Another 3 baselines from change point detection and time series segmentation are deferred to Appendix I. InterFusion (2021) and THOC (2020) are the state-of-the-art deep models.
124
+
125
+ ![](images/406fcdd682cc23d70393f7533cccedaf9de0c3c2183257d6ad39004a2fe6d944.jpg)
126
+ Figure 3: ROC curves (horizontal-axis: false-positive rate; vertical-axis: true-positive rate) for the five datasets. A higher AUC value (area under the ROC curve) indicates a better performance. The predefined threshold proportion $r$ is in $\{ 0 . 5 \% , 1 . 0 \%$ , $1 . 5 \%$ , $2 . 0 \%$ , $1 0 \%$ , $2 0 \%$ , $3 0 \% \}$ .
127
+
128
+ Table 1: Quantitative results for Anomaly Transformer $( O u r s )$ in the five datasets. The $P$ , $R$ and $F l$ represent the precision, recall and F1-score (as $\%$ ) respectively. F1-score is the harmonic mean of precision and recall. For these three metrics, a higher value indicates a better performance.
129
+
130
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>OCSVM</td><td></td><td>44.34 76.72</td><td>56.19</td><td>59.78</td><td>86.87</td><td>70.82</td><td>53.85</td><td>59.07</td><td>56.34</td><td>45.39</td><td>49.22</td><td>47.23</td><td>62.75</td><td>80.89</td><td>70.67</td></tr><tr><td>IsolationForest</td><td></td><td>42.31 73.29 53.64</td><td></td><td>53.94</td><td>86.54 66.45</td><td></td><td></td><td>52.3959.07</td><td>55.53</td><td>49.29</td><td></td><td>44.95 47.02</td><td>76.09</td><td>92.45</td><td>83.48</td></tr><tr><td>LOF</td><td></td><td>56.34 39.86 46.68</td><td></td><td>47.72</td><td>85.25</td><td>61.18</td><td>58.93</td><td>56.33</td><td>57.60</td><td>72.15</td><td>65.43</td><td>68.62</td><td>57.89</td><td>90.49</td><td>70.61</td></tr><tr><td>Deep-SVDD</td><td></td><td>78.54 79.67 79.10</td><td></td><td>91.92</td><td>76.63</td><td>83.58</td><td>89.93</td><td>56.02</td><td>69.04</td><td>80.42</td><td>84.45</td><td>82.39</td><td>95.41</td><td>86.49</td><td>90.73</td></tr><tr><td>DAGMM</td><td></td><td>67.30 49.89</td><td>57.30</td><td>89.60</td><td>63.93</td><td>74.62</td><td>86.45</td><td>56.73</td><td>68.51</td><td>89.92 57.84</td><td></td><td>70.40</td><td>93.49</td><td>70.03</td><td>80.08</td></tr><tr><td>MMPCACD</td><td></td><td>71.20 79.28</td><td>75.02</td><td>81.42</td><td>61.31</td><td>69.95</td><td>88.61</td><td>75.84 81.73</td><td></td><td>82.52</td><td>68.29</td><td>74.73</td><td>76.26</td><td>78.35</td><td>77.29</td></tr><tr><td>VAR</td><td>78.35</td><td>70.26</td><td>74.08</td><td>74.68</td><td>81.42</td><td>77.90</td><td>81.38 53.88</td><td></td><td>64.83</td><td>81.59</td><td>60.29</td><td>69.34</td><td>90.71</td><td>83.82</td><td>87.13</td></tr><tr><td>LSTM</td><td>78.55</td><td>85.28</td><td>81.78</td><td>85.45</td><td>82.50</td><td>83.95</td><td>89.41</td><td>78.13</td><td>83.39</td><td>86.15</td><td>83.27</td><td>84.69</td><td>76.93</td><td>89.64</td><td>82.80</td></tr><tr><td>CL-MPPCA</td><td></td><td>82.36 76.07</td><td>79.09</td><td>73.71</td><td>88.54</td><td>80.44</td><td>86.13</td><td>63.16</td><td>72.88</td><td>76.78</td><td>81.50</td><td>79.07</td><td>56.02</td><td>99.93</td><td>71.80</td></tr><tr><td>ITAD</td><td>86.22</td><td>73.71</td><td>79.48</td><td>69.44</td><td>84.09</td><td>76.07</td><td>82.42</td><td>66.89</td><td>73.85</td><td>63.13</td><td>52.08</td><td>57.08</td><td>72.80</td><td>64.02</td><td>68.13</td></tr><tr><td>LSTM-VAE</td><td></td><td>75.76 90.08</td><td>82.30</td><td>85.49</td><td>79.94</td><td>82.62</td><td>92.20</td><td>67.75</td><td>78.10</td><td>76.00</td><td>89.50</td><td>82.20</td><td>73.62</td><td>89.92</td><td>80.96</td></tr><tr><td>BeatGAN</td><td>72.90</td><td>84.09</td><td>78.10</td><td>89.75</td><td>85.42</td><td>87.53</td><td>92.38</td><td>55.85</td><td>69.61</td><td>64.01</td><td>87.46</td><td>73.92</td><td>90.30</td><td>93.84</td><td>92.04</td></tr><tr><td>OmniAnomaly</td><td>83.68</td><td>86.82</td><td>85.22</td><td>89.02</td><td>86.37</td><td>87.67</td><td>92.49</td><td>81.99</td><td>86.92</td><td>81.42</td><td>84.30</td><td>82.83</td><td>88.39</td><td>74.46</td><td>80.83</td></tr><tr><td>InterFusion</td><td>87.02</td><td>85.43</td><td>86.22</td><td>81.28</td><td>92.70</td><td>86.62</td><td>89.77</td><td>88.52</td><td>89.14</td><td>80.59</td><td>85.58</td><td>83.01</td><td>83.61</td><td>83.45</td><td>83.52</td></tr><tr><td>THOC</td><td></td><td>79.76 90.95</td><td>84.99</td><td>88.45</td><td>90.97</td><td>89.69</td><td>92.06</td><td>89.34</td><td>90.68</td><td>83.94</td><td>86.36 85.13</td><td></td><td>88.14</td><td>90.99</td><td>89.54</td></tr><tr><td>Ours</td><td></td><td>89.40 95.45</td><td>92.33</td><td>92.09</td><td>95.15</td><td>93.59</td><td>94.13</td><td></td><td>99.40 96.69</td><td>91.55</td><td>96.73</td><td>94.07</td><td>96.91</td><td></td><td>98.90 97.89</td></tr></table>
131
+
132
+ # 4.1 MAIN RESULTS
133
+
134
+ Real-world datasets We extensively evaluate our model on five real-world datasets with ten competitive baselines. As shown in Table 1, Anomaly Transformer achieves the consistent state-of-theart on all benchmarks. We observe that deep models that consider the temporal information outperform the general anomaly detection model, such as Deep-SVDD (Ruff et al., 2018) and DAGMM (Zong et al., 2018), which verifies the effectiveness of temporal modeling. Our proposed Anomaly Transformer goes beyond the point-wise representation learned by RNNs and models the more informative associations. The results in Table 1 are persuasive for the advantage of association learning in time series anomaly detection. In addition, we plot the ROC curve in Figure 3 for a complete comparison. Anomaly Transformer has the highest AUC values on all five datasets. It means that our model performs well in the false-positive and true-positive rates under various preset thresholds, which is important for real-world applications.
135
+
136
+ NeurIPS-TS benchmark This benchmark is generated from well-designed rules proposed by Lai et al. (2021), including all types of anomalies and covering both the point-wise and patternwise anomalies. As shown in Figure 4, Anomaly Transformer can still achieve state-of-the-art performance. This verifies the effectiveness of our model on various anomalies.
137
+
138
+ ![](images/f73585f11f1d432f01e7213e38ccf1bc4eb06a82553d0ec491f568d781e4af52.jpg)
139
+ Figure 4: Results for NeurIPS-TS.
140
+
141
+ Ablation study As shown in Table 2, we further investigate the effect of each part in our model. Our association-based criterion outperforms the widely-used reconstruction criterion consistently.
142
+
143
+ Specifically, the association-based criterion brings a remarkable $1 8 . 7 6 \%$ ( $7 6 . 2 0 { } 9 4 . 9 6$ ) averaged absolute F1-score promotion. Also, directly taking the association discrepancy as the criterion still achieves a good performance (F1-score: $9 1 . 5 5 \%$ ) and surpasses the previous state-of-the-art model
144
+
145
+ THOC (F1-score: $8 8 . 0 1 \%$ calculated from Table 1). Besides, the learnable prior-association (corresponding to $\sigma$ in Equation 2) and the minimax strategy can further improve our model and get $8 . 4 3 \%$ $7 9 . 0 5 \substack { 8 7 . 4 8 } )$ and $7 . 4 8 \%$ $8 7 . 4 8 { } 9 4 . 9 6 $ ) averaged absolute promotions respectively. Finally, our proposed Anomaly Transformer surpasses the pure Transformer by $1 8 . 3 4 \%$ ( $7 6 . 6 2 \substack { } 9 4 . 9 6$ ) absolute improvement. These verify that each module of our design is effective and necessary. More ablations of association discrepancy can be found in Appendix D.
146
+
147
+ Table 2: Ablation results (F1-score) in anomaly criterion, prior-association and optimization strategy. Recon, AssDis and Assoc mean the pure reconstruction performance, pure association discrepancy and our proposed association-based criterion respectively. $F i x$ is to fix Learnable scale parameter $\sigma$ of prior-association as 1.0. Max and Minimax refer to the strategies for association discrepancy in the maximization (Equation 4) and minimax (Equation 5) way respectively.
148
+
149
+ <table><tr><td>Architecture</td><td>Anomaly Criterion</td><td>Prior- Association</td><td>Optimization Strategy</td><td>SMD</td><td>MSL</td><td>SMAP</td><td>SWaT</td><td>PSM</td><td>AvgF1 (as%)</td></tr><tr><td>Transformer</td><td>Recon</td><td>×</td><td>×</td><td>79.72</td><td>76.64</td><td>73.74</td><td>74.56</td><td>78.43</td><td>76.62</td></tr><tr><td rowspan="3">Anomaly</td><td>Recon</td><td>Learnable</td><td>Minmax</td><td>71.35</td><td>78.61</td><td>69.12</td><td>81.53</td><td>80.40</td><td>76.20</td></tr><tr><td>AssDis</td><td>Learnable</td><td>Minmax</td><td>87.57</td><td>90.50</td><td>90.98</td><td>93.21</td><td>95.47</td><td>91.55</td></tr><tr><td>Assoc</td><td>Fix</td><td>Max</td><td>83.95</td><td>82.17</td><td>70.65</td><td>79.46</td><td>79.04</td><td>79.05</td></tr><tr><td></td><td>Assoc</td><td>Learnable</td><td>Max</td><td>88.88</td><td>85.20</td><td>87.84</td><td>81.65</td><td>93.83</td><td>87.48</td></tr><tr><td>*final</td><td>Assoc</td><td>Learnable</td><td>Minmax</td><td>92.33</td><td>93.59</td><td>96.90</td><td>94.07</td><td>97.89</td><td>94.96</td></tr></table>
150
+
151
+ # 4.2 MODEL ANALYSIS
152
+
153
+ To explain how our model works intuitively, we provide the visualization and statistical results for our three key designs: anomaly criterion, learnable prior-association and optimization strategy.
154
+
155
+ ![](images/3863f4c97b548e5a31cecf929ebc9cbe3ef8a709386e0088788196a5631cf81c.jpg)
156
+ 参考文献 bm\`p2v M/ MQp2H TT\`Q+?X kyykX GM+2i AM72+iX .BbX- kykyX GM+2i AM72+iX .BbX- kykyX GM+2i AM72+iX .BbX- kykyXFigure 5: Visualization of different anomaly categories (Lai et al., 2021). We plot the raw series (R) 1X .QM;- >X .m- M/ GX :\`/M2\`X M BMi2\`+iBp2 r2#@#b2/ /b?#Q\`/ iQ i\`+F +QpB/@RN BM \`2H iBK2X(j) S\`i? Sir- a?BpK a?\`K- a\`BMBpb SvFH- oBM22i? :mTi?- :BiMDHB EmK\`B- J/X a?/ F?i\`-bB7 1F#H- KBip .b- M/ hMKQv \*?F\`#Q\`ivX 6B;?iBM; M BM7Q/2KB+, \*QpB/@RN 7F2 M2rb(k) 1KQMM CX E2Q;?- a2HBM \*?m- .pB/ JX >\`i- M/ JB+?2H CX SxxMBX a2;K2MiBM; iBK2 b2\`B2b, (k) 1KQMM CX E2Q;?- a2HBM \*?m- .pB/ JX >\`i- M/ JB+?bm\`p2v M/ MQp2H TT\`Q+?X kyykX(k) 1KQMM CX E2Q;?- a2HBM \*?m- .pB/ J(first row) from NeurIPS-TS dataset, as well as their corresponding reconstruction (second row) and (k) 1KQMM CX E2Q;?- a2HBM \*?m- .pB/ JX >\`i- M/ JB+?2H CX SxxMBX a2;K2MiBM; iBK2 b2\`B2b, /ib2iX AM \*PLah_ALh!A- kykRX (j) S\`i? Sir- a?BpK a?\`K- a\`BMBpb SvFH- oBM22i? :mTi?- :BiMDHB EmK\`B- J/X a?/ F?i\`-(j) S\`i? Sir- a?BpK a?\`K- a\`BMBpb SvFH- oBM22i? :m(j) S\`i? Sir- a?BpK a?\`K- a\`BMBpb association-based criteria (third row). The point-wise anomalies are marked by red circles and the bm\`p2v M/ MQp2H TT\`Q+?X kyykX bB7 1F#H- KBip .b- M/ hMKQv \*?F\`#Q\`ivX 6B;?iBM; M BM7Q/2KB+, \*QpB/@RN 7F2 M2rbB7 1F#H- KBip .b- M/ hMKQv \*?F\`#Q\`ivX /ib2iX AM \*PLah_ALh!A- kykRXbB7 1F#H- KBip .b- M/ hMKQpattern-wise anomalies are in red segments. The wrongly detected cases are bounded by red boxes.
157
+
158
+ /ib2iX AM \*PLah_ALh!A- kykRXAnomaly criterion visualization To get more intuitive cases about how association-based criterion works, we provide some visualization in Figure 5 and explore the criterion performance under different types of anomalies, where the taxonomy is from Lai et al. (2021). We can find that our proposed association-based criterion is more distinguishable in general. Concretely, the associationbased criterion can obtain the consistent smaller values for the normal part, which is quite contrasting in point-contextual and pattern-seasonal cases (Figure 5). In contrast, the jitter curves of the reconstruction criterion make the detection process confused and fail in the aforementioned two cases. This verifies that our criterion can highlight the anomalies and provide distinct values for normal and abnormal points, making the detection precise and reducing the false-positive rate.
159
+
160
+ ![](images/37b79e1f36945dc870b989779370b22ca7e11ea9f7ab284cc7c29e926cc04095.jpg)
161
+ Figure 6: Learned scale parameter $\sigma$ for different types of anomalies (highlight in red).
162
+
163
+ Prior-association visualization During the minimax optimization, the prior-association is learned to get close to the series-association. Thus, the learned $\sigma$ can reflect the adjacent-concentrating degree of time series. As shown in Figure 6, we find that $\sigma$ changes to adapt to various data patterns of time series. Especially, the prior-association of anomalies generally has a smaller $\sigma$ than normal time points, which matches our adjacent-concentration inductive bias of anomalies.
164
+
165
+ Optimization strategy analysis Only with the reconstruction loss, the abnormal and normal time points present similar behavior in the association weights to adjacent time points, corresponding to a contrast value closed to 1 (Table 3). Maximizing the association discrepancy will force the seriesassociations to pay more attention to the non-adjacent area. However, to obtain a better reconstruction, the anomalies must maintain much larger adjacent association weights than normal time points, corresponding to a larger contrast value. But direct maximization will cause optimization difficulty of Gaussian kernel, and cannot strongly amplify the difference between normal and abnormal time points as expected $( \mathbf { S } \mathbf { M } \mathbf { D } { : } 1 . 1 5 { } 1 . 2 7 )$ . The minimax strategy optimizes the prior-association to provide a stronger constraint to series-association, thereby obtaining more distinguishable contrast values and better performance than the direct maximization $\mathrm { \langle S M D : 1 . 2 7 \mathrm { } 2 . 3 9 } _ { }$ ).
166
+
167
+ Table 3: Results of adjacent association weights for Abnormal and Normal time points respectively. Recon, Max and Minimax represent the association learning process that is supervised by reconstruction loss, direct maximization and minimax strategy respectively. A higher contrast value ( AbnormalNormal ) indicates a stronger distinguishability between normal and abnormal time points.
168
+
169
+ <table><tr><td rowspan="3">Dataset</td><td colspan="2">SMD</td><td colspan="2">MSL</td><td colspan="2">SMAP</td><td colspan="2">SWaT</td><td colspan="2"></td><td colspan="2">PSM</td></tr><tr><td></td><td> Optimization|Recon Max Ours Recon Max Ours Recon Max Ours Recon Max Ours Recon Max Ours</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Abnormal(%)</td><td>1.080.95 0.861.01 0.65 0.351.291.18 0.701.27 0.89 0.371.02 0.56 0.29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Normal (%)</td><td>0.940.750.361.000.59 0.221.231.090.491.180.780.210.990.54 0.11</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Contrast (Nomal) Normal</td><td>1.151.27 2.391.011.10 1.591.051.08 1.431.08 1.14 1.761.031.04 2.64</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
170
+
171
+ # 5 CONCLUSION AND FUTURE WORK
172
+
173
+ This paper studies the unsupervised time series anomaly detection problem. Unlike previous works, we learn the more informative time-point associations by Transformers. Based on the key observation of association discrepancy, we propose the Anomaly Transformer, including an AnomalyAttention with the two-branch structure to embody the association discrepancy. A minimax strategy is adopted to further amplify the difference between normal and abnormal time points. By introducing the association discrepancy, we propose the association-based criterion, which makes the reconstruction performance and association discrepancy collaborate. Anomaly Transformer achieves the state-of-the-art results on an exhaustive set of empirical studies. Future work includes theoretical study of Anomoly Transformer in light of classic analysis for autoregression and state space models.
174
+
175
+ # ACKNOWLEDGMENTS
176
+
177
+ This work was supported by the National Megaproject for New Generation AI (2020AAA0109201), National Natural Science Foundation of China (62022050 and 62021002), Beijing Nova Program (Z201100006820041), and BNRist Innovation Fund (BNR2021RC01002).
178
+
179
+ # REFERENCES
180
+
181
+ Ahmed Abdulaal, Zhuanghua Liu, and Tomer Lancewicki. Practical approach to asynchronous multivariate time series anomaly detection and localization. KDD, 2021.
182
+
183
+ Ryan Prescott Adams and David J. C. MacKay. Bayesian online changepoint detection. arXiv preprint arXiv:0710.3742, 2007.
184
+
185
+ O. Anderson and M. Kendall. Time-series. 2nd edn. J. R. Stat. Soc. (Series D), 1976.
186
+
187
+ Paul Boniol and Themis Palpanas. Series2graph: Graph-based subsequence anomaly detection for time series. Proc. VLDB Endow., 2020.
188
+
189
+ Markus M. Breunig, Hans-Peter Kriegel, Raymond T. Ng, and Jorg Sander. LOF: identifying ¨ density-based local outliers. In SIGMOD, 2000.
190
+
191
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS, 2020.
192
+
193
+ Zekai Chen, Dingshuo Chen, Zixuan Yuan, Xiuzhen Cheng, and Xiao Zhang. Learning graph structures with transformer for multivariate time series anomaly detection in iot. ArXiv, abs/2104.03466, 2021.
194
+
195
+ Haibin Cheng, Pang-Ning Tan, Christopher Potter, and Steven A. Klooster. A robust graph-based algorithm for detection and characterization of anomalies in noisy multivariate time series. ICDM Workshops, 2008.
196
+
197
+ Haibin Cheng, Pang-Ning Tan, Christopher Potter, and Steven A. Klooster. Detection and characterization of anomalies in multivariate time series. In SDM, 2009.
198
+
199
+ Shohreh Deldari, Daniel V. Smith, Hao Xue, and Flora D. Salim. Time series change point detection with self-supervised contrastive predictive coding. In WWW, 2021.
200
+
201
+ Ailin Deng and Bryan Hooi. Graph neural network-based anomaly detection in multivariate time series. AAAI, 2021.
202
+
203
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
204
+
205
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
206
+
207
+ I. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron C. Courville, and Yoshua Bengio. Generative adversarial nets. In NeurIPS, 2014.
208
+
209
+ Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Ian Simon, Curtis Hawthorne, Noam Shazeer, Andrew M. Dai, Matthew D. Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. In ICLR, 2019.
210
+
211
+ Kyle Hundman, Valentino Constantinou, Christopher Laporte, Ian Colwell, and Tom Soderstr ¨ om. ¨ Detecting spacecraft anomalies using lstms and nonparametric dynamic thresholding. KDD, 2018.
212
+
213
+ Eamonn J. Keogh, Taposh Roy, Naik U, and Agrawal A. Multi-dataset time-series anomaly detection competition, Competition of International Conference on Knowledge Discovery & Data Mining 2021. URL https://compete.hexagon-ml.com/practice/competition/39/.
214
+
215
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
216
+
217
+ Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020.
218
+
219
+ Kwei-Herng Lai, D. Zha, Junjie Xu, and Yue Zhao. Revisiting time series outlier detection: Definitions and benchmarks. In NeurIPS Dataset and Benchmark Track, 2021.
220
+
221
+ Dan Li, Dacheng Chen, Lei Shi, Baihong Jin, Jonathan Goh, and See-Kiong Ng. Mad-gan: Multivariate anomaly detection for time series data with generative adversarial networks. In ICANN, 2019a.
222
+
223
+ Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. In NeurIPS, 2019b.
224
+
225
+ Zhihan Li, Youjian Zhao, Jiaqi Han, Ya Su, Rui Jiao, Xidao Wen, and Dan Pei. Multivariate time series anomaly detection and interpretation using hierarchical inter-metric and temporal embedding. KDD, 2021.
226
+
227
+ F. Liu, K. Ting, and Z. Zhou. Isolation forest. ICDM, 2008.
228
+
229
+ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Ching-Feng Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. ICCV, 2021.
230
+
231
+ Aditya P. Mathur and Nils Ole Tippenhauer. Swat: a water treatment testbed for research and training on ICS security. In CySWATER, 2016.
232
+
233
+ Radford M. Neal. Pattern recognition and machine learning. Technometrics, 2007.
234
+
235
+ Daehyung Park, Yuuna Hoshi, and Charles C. Kemp. A multimodal anomaly detector for robotassisted feeding using an lstm-based variational autoencoder. RA-L, 2018.
236
+
237
+ Adam Paszke, S. Gross, Francisco Massa, A. Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Z. Lin, N. Gimelshein, L. Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zach ¨ DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
238
+
239
+ Mathias Perslev, Michael Jensen, Sune Darkner, Poul Jø rgen Jennum, and Christian Igel. U-time: A fully convolutional network for time series segmentation applied to sleep staging. In NeurIPS. 2019.
240
+
241
+ Lukas Ruff, Nico Gornitz, Lucas Deecke, Shoaib Ahmed Siddiqui, Robert A. Vandermeulen, ¨ Alexander Binder, Emmanuel Muller, and M. Kloft. Deep one-class classification. In ¨ ICML, 2018.
242
+
243
+ T. Schlegl, Philipp Seebock, S. Waldstein, G. Langs, and U. Schmidt-Erfurth. f-anogan: Fast unsu- ¨ pervised anomaly detection with generative adversarial networks. Med. Image Anal., 2019.
244
+
245
+ B. Scholkopf, John C. Platt, J. Shawe-Taylor, Alex Smola, and R. C. Williamson. Estimating the ¨ support of a high-dimensional distribution. Neural Comput., 2001.
246
+
247
+ Lifeng Shen, Zhuocong Li, and James T. Kwok. Timeseries anomaly detection using temporal hierarchical one-class network. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, MariaFlorina Balcan, and Hsuan-Tien Lin (eds.), NeurIPS, 2020.
248
+
249
+ Youjin Shin, Sangyup Lee, Shahroz Tariq, Myeong Shin Lee, Okchul Jung, Daewon Chung, and Simon S. Woo. Itad: Integrative tensor-based anomaly detection system for reducing false positives of satellite systems. CIKM, 2020.
250
+
251
+ Ya Su, Y. Zhao, Chenhao Niu, Rong Liu, W. Sun, and Dan Pei. Robust anomaly detection for multivariate time series through stochastic recurrent neural network. KDD, 2019.
252
+ Jian Tang, Zhixiang Chen, A. Fu, and D. Cheung. Enhancing effectiveness of outlier detections for low density patterns. In PAKDD, 2002.
253
+ Shahroz Tariq, Sangyup Lee, Youjin Shin, Myeong Shin Lee, Okchul Jung, Daewon Chung, and Simon S. Woo. Detecting anomalies in space using multivariate convolutional lstm with mixtures of probabilistic pca. KDD, 2019.
254
+ D. Tax and R. Duin. Support vector data description. Mach. Learn., 2004.
255
+ Robert Tibshirani, Guenther Walther, and Trevor Hastie. Estimating the number of clusters in a dataset via the gap statistic. J. R. Stat. Soc. (Series B), 2001.
256
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
257
+ Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long. Autoformer: Decomposition transformers with Auto-Correlation for long-term series forecasting. In NeurIPS, 2021.
258
+ Haowen Xu, Wenxiao Chen, N. Zhao, Zeyan Li, Jiahao Bu, Zhihan Li, Y. Liu, Y. Zhao, Dan Pei, Yang Feng, Jian Jhen Chen, Zhaogang Wang, and Honglin Qiao. Unsupervised anomaly detection via variational auto-encoder for seasonal kpis in web applications. WWW, 2018.
259
+ Takehisa Yairi, Naoya Takeishi, Tetsuo Oda, Yuta Nakajima, Naoki Nishimura, and Noboru Takata. A data-driven health monitoring method for satellite housekeeping data based on probabilistic clustering and dimensionality reduction. IEEE Trans. Aerosp. Electron. Syst., 2017.
260
+ Hang Zhao, Yujing Wang, Juanyong Duan, Congrui Huang, Defu Cao, Yunhai Tong, Bixiong Xu, Jing Bai, Jie Tong, and Qi Zhang. Multivariate time-series anomaly detection via graph attention network. ICDM, 2020.
261
+ Bin Zhou, Shenghua Liu, Bryan Hooi, Xueqi Cheng, and Jing Ye. Beatgan: Anomalous rhythm detection using adversarially generated time series. In IJCAI, 2019.
262
+ Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI, 2021.
263
+ Bo Zong, Qi Song, Martin Renqiang Min, Wei Cheng, Cristian Lumezanu, Dae-ki Cho, and Haifeng Chen. Deep autoencoding gaussian mixture model for unsupervised anomaly detection. In ICLR, 2018.
264
+
265
+ # A PARAMETER SENSITIVITY
266
+
267
+ We set the window size as 100 throughout the main text, which considers the temporal information, memory and computation efficiency. And we set the loss weight 989898 $\lambda$ based on the convergence property of the training curve.959595
268
+
269
+ Furthermore, Figure 7 provides the model performance under different choices of the window sizeSMAPSWaTSMAPSWaT and the loss weight. We present that our model is stable to the window size over extensive datasets94 PSMPSM9494 (Figure 7 left). Note that a larger window size indicates a larger memory cost and a smaller sliding90 MSLMSL90 929290 92 number. Especially, only considering the performance, its relationship to the window size can beSMAPSMAP determined by the data pattern. For example, our model performs better when the window size is 50PSMPSM 909090 for the SMD dataset. Besides, we adopt the loss weight 1 2 3 4 5 6858585 $\lambda$ in Equation 5 to trade off the reconstruction1 2 3 4 5 61 2 3 4 5 6 loss and the association part. We find that factorWindow SizeWindow Size $\lambda$ is stable and easy to tune in the range of 2 to 4. ThefactorLoss Weight above results verify the sensitivity of our model, which is essential for applications.
270
+
271
+ ![](images/84bb8dbf7495a912300dc04858a7eca133109c8adc597542626017c13a08bc20.jpg)
272
+ Figure 7: Parameter sensitivity for sliding window size (left) and loss weight $\lambda$ (right). The model with $\lambda = 0$ still adopts the association-based criterion but only supervised by reconstruction loss.
273
+
274
+ # B IMPLEMENTATION DETAILS
275
+
276
+ We present the pseudo-code of Anomaly-Attention in Algorithm 1.
277
+
278
+ # Algorithm 1 Anomaly-Attention Mechanism (multi-head version).
279
+
280
+ Input: $\mathcal { X } \in \mathbb { R } ^ { N \times d _ { \mathrm { m o d e l } } }$ : input; $\mathcal { D } = \left( ( j - i ) ^ { 2 } \right) _ { i , j \in \{ 1 , \cdots , N \} } \in \mathbb { R } ^ { N \times N }$ : relative distance matrix
281
+ Layer params: $\mathtt { M L P _ { i n p u t } }$ : linear projector for input; MLPoutput: linear projector for output
282
+ 1: $\begin{array} { r l r } & { \mathrm { 2 , K , \mathcal { V } , \sigma = 5 p l i t \Big ( \mathbb { M } \mathbb { E } _ { \mathrm { i m p l e t } } ( \mathcal { X } ) , \mathbb { d i m } - \mathrm { i } \Big ) } } & { \mathrm { ~ \mathbb { ~ \rho } _ \nu \ \in \mathcal { B } , \mathcal { K } , \mathcal { V } \in \mathbb { R } ^ { N \times d _ { m a t } } , \sigma \in \mathbb { R } ^ { N \times h } ~ } } \\ & { \mathrm { ~ p r ~ } ( \mathcal { Q } _ { m } , \mathcal { K } _ { m } , \mathcal { V } _ { m } , \sigma _ { m } ) \mathrm { ~ i n } ( \mathcal { Q } , \mathcal { K } , \gamma , \sigma ) : } & { \mathrm { ~ \mathbb { ~ \rho } _ \nu Q _ { m } , \mathcal { K } _ { m } , \mathcal { V } _ { m } \in \mathbb { R } ^ { N \times \frac { \mathcal { M } _ { m a t } } { \mathcal { N } _ \nu Q _ { m } } } , \sigma _ { m } \in \mathbb { R } ^ { N \times 1 } ~ } } \\ & { \sigma _ { m } = \mathrm { B r o } \mathrm { d i d } \mathrm { c o s t } ( \sigma _ { m } , \mathcal { \mathrm { d i m } - 1 } ) } & { \mathrm { ~ \mathbb { ~ \rho } _ \nu Q _ { m } \in \mathbb { R } ^ { N \times \frac { \mathcal { N } _ { m a t } } { \mathcal { N } _ \nu Q _ { m } } } ~ } } \\ & { \mathcal { P } _ { m } = \frac { 1 } { \sqrt { 2 \pi \sigma _ { m } } } \exp \Big ( - \frac { \mathcal { P } } { 2 \pi \frac { \mathcal { P } } { 2 } } \Big ) } & { \mathrm { ~ \mathbb { ~ \rho } _ \nu \it ~ \rho ~ \rho ~ \mathbb { ~ P } _ m ~ \in \mathbb { R } ^ { N \times N } ~ } } \\ & { \mathcal { P } _ { m } = \mathcal { P } _ { m } / \mathrm { B r o } \mathrm { d i c a l } \mathrm { c } \Big ( \mathrm { S u m } ( \mathcal { P } _ { m } , \mathcal { \mathrm { d i m } - 1 } ) \Big ) } & { \mathrm { ~ \mathbb { ~ \rho } _ \nu \it ~ \mathrm { R e s c a l e d } ~ \mathcal { P } _ m ~ \in \mathbb { R } ^ { N \times N } ~ } } \\ & { \mathcal { S } _ { m } = \mathrm { S o f } \mathrm { t r m a x } \left( \sqrt { \frac { h } { d _ { m a t } } } Q _ { m } K _ { m } ^ { \Gamma } \right) } & \mathrm { ~ \mathbb { S } ~ } \mathcal { S } _ \end{array}$
283
+ 2: f
284
+ 3:
285
+ 4:
286
+ 5:
287
+ 6: f
288
+ 7: f
289
+ 8:
290
+ 9: Return . Keep the $\mathcal { P } _ { m }$ and $S _ { m }$ , $m = 1 , \cdots , h$
291
+
292
+ # C MORE SHOWCASES
293
+
294
+ To obtain an intuitive comparison of main results (Table 1), we visualize the criterion of various baselines. Anomaly Transformer can present the most distinguishable criterion (Figure 8). Besides,
295
+
296
+ for the real-world dataset, Anomaly Transformer can also detect the anomalies correctly. Especially for the SWaT dataset (Figure 9(d)), our model can detect the anomalies in the early stage, which is meaningful for real-world applications, such as the early warning of malfunctions.
297
+
298
+ ![](images/70fb5496581b69c27d6dbd8ebe2070029f2d02c56b52513f95c32b86f45f5e4b.jpg)
299
+ Figure 8: Visualization of learned criterion for the NeurIPS-TS dataset. Anomalies are labeled by red circles and red segments (first row). The failure cases of the baselines are bounded by red boxes.
300
+
301
+ ![](images/d4a5a34952437ebe8385244df4a99fa8ee8dc582a76713ad0ee97e936700d088.jpg)
302
+ Figure 9: Visualization of the model learned criterion in real-world datasets. We select one dimension of the data for visualization. These showcases are from the test set of corresponding datasets.
303
+
304
+ # D ABLATION OF ASSOCIATION DISCREPANCY
305
+
306
+ We present the pseudo code of the calculation in Algorithm 2.
307
+
308
+ # D.1 ABLATION OF MULTI-LEVEL QUANTIFICATION
309
+
310
+ We average the association discrepancy from multiple layers for the final results (Equation 6). We further investigate the model performance under the single-layer usage. As shown in Table 4, the multiple-layer design achieves the best, which verifies the effectiveness of multi-level quantification.
311
+
312
+ Table 4: Model performance under difference selection of model layers for association discrepancy.
313
+
314
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>layer 1</td><td></td><td>87.15 92.87</td><td>89.92</td><td>[90.36 94.11</td><td></td><td>92.19</td><td>[93.65 99.03 96.26|</td><td></td><td></td><td>92.61</td><td>91.92</td><td>92.27</td><td>97.20</td><td>97.50</td><td>97.35</td></tr><tr><td>layer 2</td><td>87.22</td><td>95.17</td><td>91.02</td><td>90.82</td><td>92.41</td><td>91.60</td><td>93.69</td><td>98.75 96.15</td><td></td><td>92.48</td><td>92.50</td><td>92.49</td><td>96.12</td><td>98.62</td><td>97.35</td></tr><tr><td>layer 3</td><td>87.27</td><td>93.89</td><td>90.46</td><td>91.61</td><td>88.81</td><td>90.19</td><td>93.40</td><td>98.83</td><td>96.04</td><td>88.75</td><td>91.22</td><td>89.96</td><td>77.25</td><td>94.53</td><td>85.02</td></tr><tr><td>Multiple-layer|</td><td></td><td>[89.40 95.45</td><td>92.33</td><td>|92.09</td><td>95.15</td><td>93.59</td><td>[94.13 99.40 96.69|</td><td></td><td></td><td>[91.55 96.73 94.07|</td><td></td><td></td><td>|96.91</td><td>98.90</td><td>97.89</td></tr></table>
315
+
316
+ # D.2 ABLATION OF STATISTICAL DISTANCE
317
+
318
+ We select the following widely-used statistical distances to calculate the association discrepancy:
319
+
320
+ • Symmetrized Kullback–Leibler Divergence (Ours).
321
+ • Jensen–Shannon Divergence (JSD).
322
+ • Wasserstein Distance (Wasserstein).
323
+ • Cross-Entropy (CE).
324
+ • L2 Distance (L2).
325
+ Table 5: Model performance under different definitions of association discrepancy.
326
+
327
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>L2</td><td>85.26</td><td>74.80</td><td>79.69</td><td>85.58</td><td>81.30</td><td>83.39</td><td>91.25</td><td>56.77</td><td>70.00</td><td>79.90</td><td>87.45</td><td>83.51</td><td>70.24</td><td>96.34</td><td>81.24</td></tr><tr><td>CE</td><td>88.23</td><td>81.85</td><td>84.92</td><td>90.07</td><td>86.44</td><td>88.22</td><td>92.37</td><td>64.08</td><td>75.67</td><td>62.78</td><td>81.50</td><td>70.93</td><td>70.71</td><td>94.68</td><td>80.96</td></tr><tr><td>Wasserstein</td><td>78.80</td><td>71.86</td><td>75.17</td><td>60.77</td><td>36.47</td><td>45.58</td><td>90.46</td><td>57.62</td><td>70.40</td><td>92.00</td><td>71.63</td><td>80.55</td><td>68.25</td><td>92.18</td><td>78.43</td></tr><tr><td>JSD</td><td>85.33</td><td>90.09</td><td>87.64</td><td>91.19</td><td>92.42</td><td>91.80</td><td>94.83</td><td>95.14</td><td>94.98</td><td>83.75</td><td>96.75</td><td>89.78</td><td>95.33</td><td>98.58</td><td>96.93</td></tr><tr><td>Ours</td><td>89.40</td><td>95.45</td><td>92.33</td><td>|92.09</td><td>95.15</td><td>93.59</td><td>[94.13</td><td>99.40</td><td>96.69</td><td>91.55</td><td>96.73</td><td>94.07</td><td>|96.91</td><td>98.90</td><td>97.89</td></tr></table>
328
+
329
+ As shown in Table 5, our proposed definition of association discrepancy still achieves the best performance. We find that both the CE and JSD can provide fairly good results, which are close to our definition in principle and can be used to represent the information gain. The L2 distance is not suitable for the discrepancy, which overlooks the property of discrete distribution. The Wasserstein distance also fails in some datasets. The reason is that the prior-association and series-association are exactly matched in the position indexes. Still, the Wasserstein distance is not calculated point by point and considers the distribution offset, which may bring noises to the optimization and detection.
330
+
331
+ <table><tr><td colspan="2">Algorithm 2 Association Discrepancy AssDis(P,S; X) Calculation (multi-head version).</td></tr><tr><td colspan="2">Input: time series length N; layers number L;heads number h; prior-association PallE</td></tr><tr><td colspan="2">RLxhxN×N; series-association Sal ∈ RL ×hxN×N; Dp&#x27;eRLxNXN</td></tr><tr><td colspan="2">1: P&#x27; = Mean(P,dim=1)</td></tr><tr><td colspan="2">2: S&#x27; = Mean(S,dim=1) &gt;S&#x27;eRLxNXN</td></tr><tr><td colspan="2"> 3: R&#x27;=KL(P&#x27;,S&#x27;),dim=-1) +KL((Ss&#x27;,P&#x27;),d-1)</td></tr><tr><td colspan="2">DR&#x27;eRL×N 4: R= Mean(R&#x27;,dim=0) DReRN×1</td></tr><tr><td colspan="2">5: Return R &gt;Represent the association discrepancy of each time point</td></tr></table>
332
+
333
+ # D.3 ABLATION OF PRIOR-ASSOCIATION
334
+
335
+ In addition to the Gaussian kernel with a learnable scale parameter, we also try to use the power-law kernel $P ( x ; \alpha ) = x ^ { - \alpha }$ with a learnable power parameter $\alpha$ for prior-association, which is also a unimodal distribution. As shown in Table 6, power-law kernel can achieve a good performance in most of the datasets. However, because the scale parameter is easier to optimize than the parameter of power, Gaussian kernel still surpasses the power-law kernel consistently.
336
+
337
+ Table 6: Model performance under different definitions of prior-association. Our Anomaly Transformer adopts the Gaussian kernel as the prior. Power-law refers to the power-law kernel.
338
+
339
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Power-law</td><td>89.41</td><td>92.46</td><td>90.91</td><td>90.95</td><td>85.87</td><td>88.34</td><td>91.95</td><td></td><td>58.2471.31</td><td></td><td>92.52 93.29</td><td>92.90</td><td>96.46</td><td>98.15</td><td>97.30</td></tr><tr><td>Ours</td><td>89.40</td><td>95.45</td><td>92.33</td><td>92.09</td><td>95.15</td><td>93.59</td><td>94.13</td><td>99.40</td><td>96.69</td><td>91.55</td><td>96.73</td><td>94.07</td><td>96.91</td><td>98.90</td><td>97.89</td></tr></table>
340
+
341
+ # E ABLATION OF ASSOCIATION-BASED CRITERION
342
+
343
+ # E.1 CALCULATION
344
+
345
+ We present the pseudo-code of association-based criterion in Algorithm 3.
346
+
347
+ <table><tr><td colspan="2">Algorithm 3 Association-based Criterion An omaly Score(X) Calculation</td></tr><tr><td>Input: time series length N; input time series X ∈ RN×d; reconstruction time series X ∈ RN ×d;</td><td></td></tr><tr><td>association discrepancy AssDis(P,S; X) ∈ RN×1; 1: CAD = Softmax(-AssDis(P,S;X),dim=0)</td><td>CAD ∈ RN×1</td></tr><tr><td>2: CRecon = Mean(x - )2,dim=1)</td><td>&gt; CRecon ∈ RN×1</td></tr><tr><td>3: C = CAD X CRecon</td><td>&gt;C∈RNx1</td></tr><tr><td>4: Return C</td><td></td></tr><tr><td></td><td>&gt; Anomaly score for each time point</td></tr></table>
348
+
349
+ # E.2 ABLATION OF CRITERION DEFINITION
350
+
351
+ We explore the model performance under different definitions of anomaly criterion, including the pure association discrepancy, pure reconstruction performance and different combination methods for association discrepancy and reconstruction performance: addition and multiplication.
352
+
353
+ $$
354
+ \begin{array} { r l } & { \mathrm { t i o n ~ D i s c r e p a n c y : A n o m a l y S c o r e ( \mathcal { X } ) } = \operatorname { S o f t m a x } \Big ( - \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \Big ) , } \\ & { \mathrm { ~ R e c o n s t r u c t i o n : A n o m a l y S c o r e ( \mathcal { X } ) } = \Big [ \big \| \mathcal { X } _ { i , : } - \widehat { \mathcal { X } } _ { i , : } \big \| _ { 2 } ^ { 2 } \Big ] _ { i = 1 , \cdots , N } , } \\ & { \mathrm { ~ A d d i t i o n : ~ A n o m a l y S c o r e ( \mathcal { X } ) } = \operatorname { S o f t m a x } \Big ( - \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \Big ) + \Big [ \big \| \mathcal { X } _ { i , : } - \widehat { \mathcal { X } } _ { i , : } \big \| _ { 2 } ^ { 2 } \Big ] _ { i = 1 , \cdots , N } , } \\ & { \mathrm { t i p l i c a t i o n ~ ( O u r s ) : A n o m a l y S c o r e ( \mathcal { X } ) } = \operatorname { S o f t m a x } \Big ( - \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \Big ) \odot \Big [ \big \| \mathcal { X } _ { i , : } - \widehat { \mathcal { X } } _ { i , : } \big \| _ { 2 } ^ { 2 } \Big ] _ { i = 1 , \cdots , N } } \end{array}
355
+ $$
356
+
357
+ From Table 7, we find that directly using our proposed association discrepancy can also achieve a good performance, which surpasses the competitive baseline THOC (Shen et al., 2020) consistently. Besides, the multiplication combination that we used in Equation 6 performs the best, which can bring a better collaboration to the reconstruction performance and association discrepancy.
358
+
359
+ Table 7: Ablation of criterion definition. We also include the state-of-the-art deep model THOC (Shen et al., 2020) for comparison. AssDis and Recon represent the pure association discrepancy and the pure reconstruction performance respectively. Ours refers to our proposed association-based criterion with the multiplication combination.
360
+
361
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="2">SMD</td><td rowspan="2">MSL</td><td colspan="2"></td><td colspan="2">SMAP</td><td rowspan="2"></td><td colspan="3">SWaT</td><td rowspan="2"></td><td colspan="2">PSM</td><td rowspan="2">Avg |F1(%)</td></tr><tr><td>P</td><td>F1</td><td>P</td><td>R F1</td><td>P</td><td>R</td><td>F1</td><td>P R</td><td>F1</td><td>P R</td><td>F1</td></tr><tr><td>THOC</td><td>[79.76 90.95 84.99|845 90.97 89.69|92.06 89.34 90.68|83.94 86.36 85.13|8.14 90.99 89.54|</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>88.01</td></tr><tr><td>Recon</td><td>78.63 65.29 71.35</td><td></td><td></td><td></td><td>579.1578.07 78.61</td><td></td><td>89.38 56.35 69.12</td><td></td><td>76.81</td><td>86.89</td><td>81.53</td><td></td><td>69.84 94.73 80.40</td><td></td><td>76.20</td></tr><tr><td>AssDis</td><td>86.74 88.42 87.57</td><td></td><td></td><td>91.20 89.81 90.50|9</td><td></td><td></td><td>91.56 90.41 90.98</td><td></td><td></td><td>97.27 89.48</td><td>93.21</td><td></td><td>97.80 93.25 95.47</td><td></td><td>91.55</td></tr><tr><td>Addition|</td><td>77.16 70.58 73.73</td><td></td><td></td><td>88.08 87.37 87.72</td><td></td><td></td><td>91.28 55.97 69.39</td><td></td><td></td><td>84.34 81.98 83.14</td><td></td><td></td><td>97.60 97.61 97.61</td><td></td><td>82.32</td></tr><tr><td>Ours</td><td>89.40 95.45 92.33</td><td></td><td></td><td>92.09 95.15 93.59</td><td></td><td></td><td>94.13 99.40 96.69</td><td></td><td>91.55</td><td>96.73</td><td>94.07</td><td></td><td>96.91 98.90 97.89</td><td></td><td>94.96</td></tr></table>
362
+
363
+ # F CONVERGENCE OF MINIMAX OPTIMIZATION
364
+
365
+ The total loss of our model (Equation 4) contains two parts: the reconstruction loss and the association discrepancy. Towards a better control of association learning, we adopt a minimax strategy for optimization (Equation 5). During the minimization phase, the optimization trends to minimize the association discrepancy and the reconstruction error. During the maximization phase, the optimization trends to maximize the association discrepancy and minimize the reconstruction error.
366
+
367
+ We plot the change curve of the above two parts during the training procedure. As shown in Figures 10 and 11, both parts of the total loss can converge within limited iterations on all the five real-world datasets. This nice convergence property is essential for the optimization of our model.
368
+
369
+ ![](images/4144b61609250264deb1c0d3629c5708c7ce5ee568a74066245d64e0124218ff.jpg)
370
+ 1614 1614 1614Figure 10: Change curve of reconstruction loss 0.5 0.5 $\| \chi _ { - } \widehat { \chi } \| _ { \mathrm { F } } ^ { 2 }$ 16 1614in real-world datasets during training.1 0.4
371
+
372
+ ![](images/d1569476fe4a48f81373a5f2586d8da773566cde945ea9ecf8b828f5ee339b32.jpg)
373
+ Figure 11: Change curve of association discrepancy $\| \mathrm { A s s D i s } ( \mathcal { P } , \mathcal { S } ; \mathcal { X } ) \| _ { 1 }$ in real-world datasets during the training process.
374
+
375
+ # G MODEL PARAMETER SENSITIVITY
376
+
377
+ In this paper, we set the hyper-parameters $L$ and $d _ { \mathrm { m o d e l } }$ following the convention of Transformers (Vaswani et al., 2017; Zhou et al., 2021).
378
+
379
+ Furthermore, to evaluate model parameter sensitivity, we investigate the performance and efficiency under different choices for the number of layers $L$ and hidden channels $d _ { \mathrm { m o d e l } }$ . Generally, increasing the model size can obtain better results but with larger memory and computation costs.
380
+
381
+ Table 8: Model performance under different choices of the number of layers $L$
382
+
383
+ <table><tr><td rowspan="2">Dataset| Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>L=1</td><td></td><td>89.24 93.73</td><td>91.43</td><td></td><td>91.99 97.599</td><td>94.71</td><td>93.58 99.35 96.38</td><td></td><td></td><td>91.57</td><td>95.33</td><td>93.42</td><td></td><td>96.74 98.09</td><td>97.41</td></tr><tr><td>L=2</td><td>89.26</td><td>94.33</td><td>91.72</td><td>91.89</td><td>94.73</td><td>93.29</td><td>93.79</td><td>98.91</td><td>96.28</td><td>92.37</td><td>94.59</td><td>93.47</td><td>97.22</td><td>98.23</td><td>97.72</td></tr><tr><td>L=3</td><td>89.40</td><td>95.45 92.33</td><td></td><td></td><td>92.09 95.15 93.59</td><td></td><td>94.13 99.40 96.69</td><td></td><td></td><td>91.55</td><td>96.73 94.07</td><td></td><td>96.91</td><td>98.90</td><td>97.89</td></tr><tr><td>L=4</td><td>89.59</td><td>95.76 92.58</td><td></td><td></td><td>91.88 95.40 93.61</td><td></td><td>93.75 99.13 96.37</td><td></td><td></td><td>93.37</td><td>93.45 93.41</td><td></td><td>97.30</td><td>97.58 97.44</td><td></td></tr></table>
384
+
385
+ Table 9: Model performance under different choices of the number of hidden channels $d _ { \mathrm { m o d e l } }$ . Mem means the averaged GPU memory cost. Time is the averaged running time of 100 iterations during the training process.
386
+
387
+ <table><tr><td rowspan="3">Dataset Metric</td><td colspan="2">SMD</td><td colspan="2">MSL</td><td colspan="2"></td><td colspan="2">SMAP</td><td colspan="2">SWaT</td><td colspan="2">PSM</td><td colspan="2">Mem&#x27;</td><td colspan="2">Time</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R F1</td><td>P</td><td>R</td><td>F1</td><td>P R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>(GB)</td><td></td><td>(s)</td></tr><tr><td>dmodel =256</td><td>88.83 91.82 90.30|91.96 97.60 94.709</td><td></td><td></td><td></td><td></td><td></td><td>93.74 99.47 96.52</td><td></td><td>293.91 93.99 93.95</td><td></td><td></td><td>597.38 98.16 97.77</td><td></td><td></td><td>4.9</td><td>0.12</td></tr><tr><td>dmodel = 512</td><td>89.40 95.45 92.33</td><td></td><td></td><td>92.09 95.15 93.59</td><td></td><td></td><td>94.13 99.40 96.69</td><td></td><td>91.55 96.73 94.07</td><td></td><td></td><td>96.91 98.90 97.89</td><td></td><td></td><td>5.5</td><td>0.15</td></tr><tr><td>dmodel = :1024</td><td>89.44 96.33 92.769</td><td></td><td></td><td>91.80 94.99 93.37</td><td></td><td></td><td>93.58 99.47 96.43</td><td></td><td>92.02 95.0193.49</td><td></td><td></td><td>95.78 98.12 96.94</td><td></td><td></td><td>6.6</td><td>0.27</td></tr></table>
388
+
389
+ # H PROTOCOL OF THRESHOLD SELECTION
390
+
391
+ Our paper focuses on unsupervised time series anomaly detection. Experimentally, each dataset includes training, validation and testing subsets. Anomalies are only labeled in the testing subset. Thus, we select the hyper-parameters following the Gap Statistic method (Tibshirani et al., 2001) in K-Means. Here is the selection procedure:
392
+
393
+ • After the training phase, we apply the model to the validation subset (without label) and obtain the anomaly scores (Equation 6) of all time points. • We count the frequency of the anomaly scores in the validation subset. It is observed that the distribution of anomaly scores is separated into two clusters. We find that the cluster with a larger anomaly score contains $r$ time points. And for our model, $r$ is closed to $0 . 1 \%$ , $0 . 5 \%$ , $1 \%$ for SWaT, SMD and other datasets respectively (Table 10). Due to the size of the test subset being still inaccessible in real-world applications, we have to fix the threshold as a fixed value $\delta$ , which can gaurantee that the anomaly scores of $r$ time points in the validation set are larger than $\delta$ and thus detected as anomalies.
394
+
395
+ (a) SMD, MSL and SWaT datasets.
396
+
397
+ Table 10: Statistical results of anomaly score distribution on the validation set. We count the number of time points with corresponding values in several intervals.
398
+
399
+ <table><tr><td>Anomaly Score Interval</td><td>SMD</td><td>MSL</td><td>SWaT</td></tr><tr><td>(0,+∞0]</td><td>141681</td><td>11664</td><td>99000</td></tr><tr><td>[0,10-2]</td><td>140925</td><td>11537</td><td>98849</td></tr><tr><td>(10-²,0.1]</td><td>2</td><td>8</td><td>17</td></tr><tr><td>(0.1,+00]</td><td>754</td><td>119</td><td>134</td></tr><tr><td>Ratio of (0.1, +00]</td><td>0.53%</td><td>1.02%</td><td>0.14%</td></tr></table>
400
+
401
+ (b) SMAP and PSM datasets.
402
+
403
+ <table><tr><td>Anomaly Score Interval</td><td>SMAP</td><td>PSM</td></tr><tr><td>(0,+∞0]</td><td>27037</td><td>26497</td></tr><tr><td>[0,10-3] (10-3,10-2] (10-²,+∞0]</td><td>26732 0 305</td><td>26223 5 269</td></tr><tr><td>Ratio of (10-²,+∞0]</td><td>1.12%</td><td>1.01%</td></tr></table>
404
+
405
+ Note that, directly setting the $\delta$ is also feasible. According to the intervals in Table 10, we can fix the $\delta$ as 0.1 for the SMD, MSL and SWaT datasets, 0.01 for the SMAP and PSM datasets, which yield a quite close performance to setting $r$ .
406
+
407
+ Table 11: Model performance. Choose by $\delta$ means that we fix $\delta$ as 0.1 for the SMD, MSL and SWaT datasets, 0.01 for the SMAP and PSM datasets. Choose by $r$ means that we select $r$ as $0 . 1 \%$ for SWaT, $0 . 5 \%$ for SMD and $1 \%$ for the other datasets.
408
+
409
+ <table><tr><td rowspan="3">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Choose by δ|</td><td>88.65</td><td>97.17</td><td>92.71</td><td>[91.86 95.15 93.47</td><td></td><td></td><td></td><td>97.69 98.24 97.96</td><td></td><td></td><td>[86.02 95.01 90.29</td><td></td><td></td><td>97.69</td><td>98.24</td><td>97.96</td></tr><tr><td>Choose by r</td><td>89.40</td><td>95.45</td><td>92.33</td><td>92.09</td><td>95.15</td><td></td><td>93.59</td><td>94.13 99.40 96.69</td><td></td><td></td><td>91.55 96.73</td><td></td><td>94.07</td><td>96.91</td><td>98.90</td><td>97.89</td></tr></table>
410
+
411
+ In real-world applications, the number of selected anomalies is always decided up to human resources. Under this consideration, setting the number of detected anomalies by the ratio $r$ is more practical and easier to decide according to the available resources.
412
+
413
+ # I MORE BASELINES
414
+
415
+ In addition to the time series anomaly detection methods, the methods for change point detection and time series segmentation can also perform as valuable baselines. Thus, we also include the BOCPD (Adams & MacKay, 2007) and TS-CP2 (Deldari et al., 2021) from change point detection and UTime (Perslev et al., 2019) from time series segmentation for comparison. Anomaly Transformer still achieves the best performance.
416
+
417
+ Table 12: Additional quantitative results for Anomaly Transformer (Ours) in five real-world datasets. The $P$ , $R$ and $F l$ represent the precision, recall and F1-score $( \mathrm { a s \% } )$ ) respectively. F1-score is the harmonic mean of precision and recall. For these metrics, a higher value indicates a better performance.
418
+
419
+ <table><tr><td rowspan="2">Dataset Metric</td><td colspan="3">SMD</td><td colspan="3">MSL</td><td colspan="3">SMAP</td><td colspan="3">SWaT</td><td colspan="3">PSM</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>BOCPD</td><td>70.90</td><td>82.04</td><td>76.07</td><td>80.32</td><td>87.20</td><td>83.62</td><td>84.65</td><td>85.85</td><td>85.24</td><td>89.46</td><td>70.75</td><td>79.01</td><td>80.22</td><td>75.33</td><td>77.70</td></tr><tr><td>TS-CP2</td><td>87.42</td><td>66.25</td><td>75.38</td><td>86.45</td><td>68.48</td><td>76.42</td><td>87.65</td><td>83.18</td><td>85.36</td><td>81.23</td><td>74.10</td><td>77.50</td><td>82.67</td><td>78.16</td><td>80.35</td></tr><tr><td>U-Time</td><td>65.95</td><td>74.75</td><td>70.07</td><td>57.20</td><td>71.66</td><td>63.62</td><td>49.71</td><td>56.18</td><td>52.75</td><td>46.20</td><td>87.94</td><td>60.58</td><td>82.85</td><td>79.34</td><td>81.06</td></tr><tr><td>Ours</td><td>89.40</td><td>95.45</td><td>92.33</td><td>92.09</td><td>95.15</td><td>93.59</td><td>94.13</td><td>99.40</td><td>96.69</td><td>91.55</td><td>96.73</td><td>94.07</td><td>96.91</td><td>98.90</td><td>97.89</td></tr></table>
420
+
421
+ # J LIMITATIONS AND FUTURE WORK
422
+
423
+ Window size As shown in the Figure 7 of Appendix A, the model may fail if the window size is too small for association learning. But the Transformers is with quadratic complexity w.r.t. the window size. The trade-off is needed for real-world applications.
424
+
425
+ Theoretical analysis As a well-established deep model, the performance of Transformers has been explored in previous works. But it is still under-exploring for the theory of complex deep models. In the future, we will explore the theorem of Anomaly Transformer for better justifications in light of classic analysis for autoregression and state space models.
426
+
427
+ # K DATASET
428
+
429
+ Here is the statistical details of experiment datasets.
430
+
431
+ Table 13: Details of benchmarks. AR represents the truth abnormal proportion of the whole dataset.
432
+
433
+ <table><tr><td>Benchmarks</td><td>Applications</td><td>Dimension</td><td>Window</td><td>#Training</td><td>#Validation</td><td>#Test (labeled)</td><td>AR (Truth)</td></tr><tr><td>SMD</td><td>Server</td><td>38</td><td>100</td><td>566,724</td><td>141,681</td><td>708,420</td><td>0.042</td></tr><tr><td>PSM</td><td>Server</td><td>25</td><td>100</td><td>105,984</td><td>26.497</td><td>87,841</td><td>0.278</td></tr><tr><td>MSL</td><td>Space</td><td>55</td><td>100</td><td>46,653</td><td>11,664</td><td>73,729</td><td>0.105</td></tr><tr><td>SMAP</td><td>Space</td><td>25</td><td>100</td><td>108,146</td><td>27,037</td><td>427,617</td><td>0.128</td></tr><tr><td>SWaT</td><td>Water</td><td>51</td><td>100</td><td>396.000</td><td>99,000</td><td>449,919</td><td>0.121</td></tr><tr><td>NeurIPS-TS</td><td>Various Anomalies</td><td>1</td><td>100</td><td>20.000</td><td>10.000</td><td>20.000</td><td>0.018</td></tr></table>
434
+
435
+ # L UCR DATASET
436
+
437
+ UCR Dataset is a very challenging and comprehensive dataset provided by the Multi-dataset Time Series Anomaly Detection Competition of KDD2021 (Keogh et al., Competition of International Conference on Knowledge Discovery & Data Mining 2021). The whole dataset contains 250 subdatasets, covering various real-world scenarios. Each sub-dataset of UCR has only one anomaly segment and only has one dimension. These sub-datasets range in length from 6,684 to 900,000 and are pre-divided into training and test sets.
438
+
439
+ We also experiment on the UCR dataset for a wide evaluation. As show in Table 14, our Anomaly Transformer still achieves the state-of-the-art in this challenging benchmark.
440
+
441
+ Table 14: Quantitative results in UCR Dataset. $I F$ refers to the IsolationForest (2008). Ours is our Anomaly Transformer. $P , R$ and $F l$ represent the precison, recall and F1-score $( \% )$ respectively.
442
+
443
+ <table><tr><td>Metric</td><td>LSTM-VAE</td><td>InterFusion</td><td>OmniAnomaly</td><td>THOC</td><td>Deep-SVDD</td><td>BeatGAN</td><td>LOF</td><td>OC-SVM</td><td>IF</td><td>Ours</td></tr><tr><td>P</td><td>62.08</td><td>60.74</td><td>64.21</td><td>54.61</td><td>47.08</td><td>45.20</td><td>41.47</td><td>41.14</td><td>40.77</td><td>72.80</td></tr><tr><td>R</td><td>97.60</td><td>95.20</td><td>86.93</td><td>80.83</td><td>88.91</td><td>88.42</td><td>98.80</td><td>94.00</td><td>93.60</td><td>99.60</td></tr><tr><td>F1</td><td>75.89</td><td>74.16</td><td>73.86</td><td>65.19</td><td>61.56</td><td>59.82</td><td>58.42</td><td>57.23</td><td>56.80</td><td>84.12</td></tr></table>
md/dev/NpsVSN6o4ul/NpsVSN6o4ul.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # INTERPRETABILITY IN THE WILD: A CIRCUIT FOR INDIRECT OBJECT IDENTIFICATION IN GPT-2 SMALL
2
+
3
+ Kevin Wang∗, Alexandre Variengien\*, Arthur Conmy\*, Buck Shlegeris†, Jacob Steinhardt†‡§
4
+ †Redwood Research
5
+ ‡UC Berkeley
6
+
7
+ # ABSTRACT
8
+
9
+ Research in mechanistic interpretability seeks to explain behaviors of ML models in terms of their internal components. However, most previous work either focuses on simple behaviors in small models, or describes complicated behaviors in larger models with broad strokes. In this work, we bridge this gap by presenting an explanation for how GPT-2 small performs a natural language task that requires logical reasoning: indirect object identification (IOI). Our explanation encompasses 28 attention heads grouped into 7 main classes, which we discovered using a combination of interpretability approaches including causal interventions and projections. To our knowledge, this investigation is the largest end-to-end attempt at reverse-engineering a natural behavior “in the wild” in a language model. We evaluate the reliability of our explanation using three quantitative criteria– faithfulness, completeness and minimality. Though these criteria support our explanation, they also point to remaining gaps in our understanding. Our work is a case study demonstrating a first step toward a better understanding of pre-trained language models, opening opportunities to scale to both larger models and more complex tasks.1
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Transformer-based language models (Vaswani et al., 2017; Brown et al., 2020) have demonstrated an impressive suite of capabilities, but largely remain black boxes. Understanding these models is difficult because they employ complex non-linear interactions in densely-connected layers and operate in a high-dimensional space. Despite this, they are already deployed in high-impact settings, underscoring the urgency of understanding and anticipating possible model behaviors. Some researchers have even argued that interpretability is necessary for the safe deployment of advanced machine learning systems (Hendrycks & Mazeika, 2022).
14
+
15
+ Work in mechanistic interpretability aims to discover, understand and verify the algorithms that model weights implement by reverse engineering model computation into human-understandable components (Olah, 2022; Meng et al., 2022; Geiger et al., 2021; Geva et al., 2020). By understanding underlying mechanisms, we can better predict out-of-distribution behavior (Mu & Andreas, 2020), identify and fix model errors (Hernandez et al., 2021; Vig et al., 2020), and understand emergent behavior (Nanda & Lieberum, 2022; Barak et al., 2022; Wei et al., 2022).
16
+
17
+ In this work, we aim to understand how GPT-2 small (Radford et al., 2019) implements a natural language task. To do so, we locate components of the network that produce specific behaviors, and study how they compose to complete the task. We do so by using circuits analysis (Rauker ¨ et al., 2022), identifying an induced subgraph of the model’s computational graph that is humanunderstandable and responsible for completing the task. We employed a number of techniques, most notably activation patching, knockouts, and projections, which we believe are useful, general techniques for circuit discovery.2
18
+
19
+ ![](images/5796faa71adb9db5bfbdfe9ef742d73e685b072b0fc79560ea0d35cca827bb22.jpg)
20
+ Figure 1: Left: We isolated a circuit (in orange) responsible for the flow of information connecting the indirect object ‘Mary’ to the next token prediction. The nodes are attention blocks and the edges represent the interactions between attention heads. Right: We discovered and validated this circuit using activation experiments, including both patches and knockouts of attention heads.
21
+
22
+ We focus on understanding a non-trivial, algorithmic natural language task that we call Indirect Object Identification (IOI). In IOI, sentences such as ‘When Mary and John went to the store, John gave a drink to’ should be completed with ‘Mary’. We chose this task because it is linguistically meaningful and admits a complex but interpretable algorithm (Section 3).
23
+
24
+ We discover a circuit of 28 attention heads– $. 1 . 5 \%$ of the total number of (head, token position) pairs– that completes this task. The circuit uses 7 different categories of heads (see Figure 2) to implement the algorithm. Together, these heads route information between different name tokens, to the end position, and finally to the output. Our work provides, to the best of our knowledge, the most detailed attempt at reverse-engineering a natural end-to-end behavior in a transformer-based language model.
25
+
26
+ Explanations for model behavior can easily be misleading or non-rigorous (Jain & Wallace, 2019; Bolukbasi et al., 2021). To remedy this problem, we formulate three criteria to help validate our circuit explanations. These criteria are faithfulness (the circuit can perform the task as well as the whole model), completeness (the circuit contains all the nodes used to perform the task), and minimality (the circuit doesn’t contain nodes irrelevant to the task). Our circuit shows significant improvements compared to a na¨ıve (but faithful) circuit, but fails to pass the most challenging tests.
27
+
28
+ In summary, our main contributions are: (1) We identify a large circuit in GPT-2 small that performs indirect-object identification on a specific distribution (Figure 2 and Section 3); (2) Through example, we identify useful techniques for understanding models, as well as surprising pitfalls; (3) We present criteria that ensure structural correspondence (in the computational graph abstraction) between the circuit and the model, and check experimentally whether our circuit meets this standard (Section 4).
29
+
30
+ # 2 BACKGROUND
31
+
32
+ In this section, we introduce the IOI task (an original contribution of this work), the transformer architecture, define circuits more formally and describe a technique for “knocking out” model nodes.
33
+
34
+ Task description. In indirect object identification (IOI), two names (the indirect object (IO) and the first occurrence of the subject (S1)) are introduced in an initial dependent clause (see Figure 1). A main clause then introduces the second occurrence of the subject (S2), who is usually exchanging an item. The task is to complete the main clause, which always ends with the token ‘to’, with the non-repeated name (IO). We create many dataset samples for IOI (pIOI) using 15 templates (see Appendix A) with random single-token names, places and items.
35
+
36
+ We investigate the performance of GPT-2 small on this task. We study the original model from Radford et al. (2019), pretrained on a large corpus of internet text and without any fine-tuning. To quantify GPT-2 small performance on the IOI task, we used the logit difference between the logit values placed on the two names, where a positive score means the correct name (IO) has higher probability. This is also the difference in loss the model would receive in training if IO was correct compared to if S was correct. We report this metric averaged over pIOI throughout the paper. GPT-2 small has mean logit difference of 3.55 averaged across over 100,000 dataset examples.
37
+
38
+ Transformer architecture. GPT-2 small is a decoder-only transformer with 12 layers and 12 attention heads per attention layer. In this work, we mostly focus on understanding the mechanisms of attention heads, which we describe using notation similar to Elhage et al. (2021). We leave a full description of the model to Appendix E.
39
+
40
+ The input to the transformer is the sum of position and token embeddings, $x _ { 0 } \in \mathbb { R } ^ { N \times d }$ , where $N$ is the number of tokens in the input and $d$ is the model dimension. This input embedding is the initial value of the residual stream, which all attention layers and MLPs read from and write to. Attention layer $i$ of the network takes as input $x _ { i } \in \mathbb { R } ^ { N \times d }$ , the value of the residual stream before it. The attention layer output can be decomposed into the sum of attention heads $h _ { i , j }$ . If the output of the attention layer is $\begin{array} { r } { \bar { y _ { i } } = \sum _ { j } h _ { i , j } ( x _ { i } ) } \end{array}$ , then the residual stream is updated to $x _ { i } + y _ { i }$ .
41
+
42
+ Focusing on individual heads, each head $h _ { i , j }$ is parametrized by four matrices $W _ { Q } ^ { i , j }$ , $W _ { K } ^ { i , j }$ , $W _ { V } ^ { i , j } \in$ $\mathbb { R } ^ { d \times \frac { d } { H } }$ and $W _ { O } ^ { i , j } \in \mathbb { R } ^ { \frac { d } { H } \times d }$ Q. We rewrite these parameters as low-rank matrices in $\mathbb { R } ^ { d \times d }$ : $W _ { O V } ^ { i , j } =$ $W _ { O } ^ { i , j } W _ { V } ^ { i , j }$ j and W i,jQK $W _ { Q K } ^ { i , j } = ( W _ { Q } ^ { i , j } ) ^ { T } W _ { K } ^ { i , j }$ . The QK matrix is used to compute the attention pattern $A _ { i , j } ~ \in ~ \mathbb { R } ^ { N \times N }$ of head $( i , j )$ , while the OV matrix determines what is written into the residual stream. At the end of the forward pass, a layer norm is applied before the unembed matrix $W _ { U }$ projects the residual stream into logits.
43
+
44
+ # 2.1 CIRCUITS
45
+
46
+ In mechanistic interpretability, we want to reverse-engineer models into interpretable algorithms. A useful abstraction for this goal are circuits. If we think of a model as a computational graph $M$ where nodes are terms in its forward pass (neurons, attention heads, embeddings, etc.) and edges are the interactions between those terms (residual connections, attention, projections, etc.), a circuit $C$ is a subgraph of $M$ responsible for some behavior (such as completing the IOI task). This definition of a circuit is slightly different from that in Olah et al. (2020), where nodes are features (meaningful directions in the latent space of a model) instead of model components.
47
+
48
+ # 2.2 KNOCKOUTS
49
+
50
+ Just as the entire model $M$ defines a function $M ( x )$ from inputs to logits, we also associate each circuit with a function $C ( x )$ , via knockouts. A knockout removes a set of nodes $K$ in a computational graph $M$ with the goal of “turning off” nodes in $K$ but capturing all other computations in $M$ . Thus, $C ( x )$ is defined by knocking out all nodes in $M \backslash C$ and taking the resulting logit outputs in the modified computational graph.
51
+
52
+ A first na¨ıve knockout approach consists of simply deleting each node in $K$ from $M$ . The net effect of this removal is to zero ablate $K$ , meaning that we turn its output to 0. This na¨ıve approach has an important limitation: 0 is an arbitrary value, and subsequent nodes might rely on the average activation value as an implicit bias term. Because of this, we find zero ablation to lead to noisy results in practice.
53
+
54
+ To address this, we instead knockout nodes through mean ablation: replacing them with their average activation value across some reference distribution (similar to the bias correction method used in Nanda & Lieberum (2022)). Mean-ablations will remove the influence of components sensitive to the variation in the reference distribution (i.e. attention heads that move names in pIOI), but will not influence components using information constant in the distribution (i.e. attention patterns that are constant in pIOI). Through mean-ablations, we are interested in finding the components that move information about names, which is the core of the IOI task and also varies with the distribution.
55
+
56
+ In this work, all knockouts are performed in a modified pIOI distribution with three random names, so the sentences no longer have a single plausible IO. We mean-ablate on this distribution, which we call the ‘ABC’ distribution, because mean-ablating on the pIOI distribution would not remove enough information, like information constant in pIOI that is helpful for the task. To knockout a single node, a (head, token position) pair in our circuit, we compute the mean of that node across samples of the same template. Computing means across the entire distribution instead of templates would average activations at different tokens, like names, verbs and conjunctions, mixing information destructively.
57
+
58
+ ![](images/8679ec5dc1297cb66b310139328c58c1f7febe9d64e838100709adb2441f81d8.jpg)
59
+ Figure 2: We discover a circuit in GPT-2 small that implements IOI. The input tokens on the left are passed into the residual stream. Attention heads move information between residual streams: the query and output arrows show which residual streams they write to, and the key/value arrows show which residual streams they read from.
60
+
61
+ # 3 DISCOVERING THE CIRCUIT
62
+
63
+ We seek to explain how GPT-2 small implements the IOI task (Section 2). Recall the example sentence “When Mary and John went to the store, John gave a drink to”. We discovered that GPT2’s internal mechanisms implement the following human-interpretable algorithm to perform IOI:
64
+
65
+ 1. Identify all previous names in the sentence (Mary, John, John).
66
+ 2. Remove all names that are duplicates (in the example above: John).
67
+ 3. Output the remaining name.
68
+
69
+ Our circuit contains three major classes of heads, corresponding to these three steps:
70
+
71
+ • Duplicate Token Heads identify tokens that have already appeared in the sentence. They are active at the S2 token, attend primarily to the S1 token and write a ‘signal’ into the residual stream that token duplication has occurred.
72
+ • S-Inhibition Heads perform step 2 of the human-interpretable algorithm. They are active at the END token, attend to the S2 token and write to bias the query of the Name Mover Heads against both S1 and S2 tokens.
73
+ • Name Mover Heads, by default, attend to previous names in the sentence, but due to the S-Inhibition Heads attend less to the S1 and S2 tokens. Their OV matrix is a name copying matrix, so in pIOI, they increase the logit of the IO token.
74
+
75
+ A fourth major family of heads writes in the opposite direction of the Name Mover Heads, thus decreasing the confidence of the predictions. We speculate that these Negative Name Mover Heads might help the model “hedge” so as to avoid high cross-entropy loss when making mistakes.
76
+
77
+ There are also three minor classes of heads that perform related functions to the components above:
78
+
79
+ • Previous Token Heads copy the embedding of S to position $_ { \mathsf { S } + 1 }$ . • Induction Heads perform the same role as the Duplicate Token Heads through an induction mechanism. They are active at position S2, attend to token $_ { \mathrm { S } + 1 }$ (mediated by the Previous Token Heads), and output a signal that the S token previously appeared in the context. • Finally, Backup Name Mover Heads do not normally move the IO token to the output, but take on this role if the regular Name Mover Heads are knocked out.
80
+
81
+ Note that our circuit does not include the MLPs. We are interested in the flow of information across tokens, and MLPs only process features along tokens. Moreover, initial investigations suggest all MLPs except for the first one are not crucial for this task (Appendix I), though more precise investigation is left for future work.
82
+
83
+ Below, we show step-by-step how we discovered each component, providing evidence that they behave as described above. We found that it was most natural to uncover the circuit starting at the logits and working back. Thus we start with the Name Mover and Negative Name Mover Heads.
84
+
85
+ ![](images/85d6691c1e66a0984ce3917dde6e32391b39e762704aabb9bcebc9abee552537.jpg)
86
+ Figure 3: A: Name Movers and Negative Name Movers Heads are the heads that most strongly write in the $W _ { U } [ I O ] - W _ { U } [ S ]$ direction. B: Attention probability vs projection of the head output along $W _ { U } [ I O ]$ or $W _ { U } [ S ]$ respectively. Note that for S tokens, we sum the attention probability on both S1 and S2. C: Value-weighted attention score with the query at the end token. D, top: Positive copying score for the Name Mover Heads. D, bottom: Negative copying score for the Negative Name Mover Heads. Dashed lines are the average scores for all heads.
87
+
88
+ # 3.1 WHICH HEADS DIRECTLY WRITE TO THE OUTPUT? (NAME MOVER HEADS)
89
+
90
+ We begin by identifying which attention heads directly affect the model’s output: in other words, the heads writing in the residual stream at the END position, in a direction that has high dot product with the logit difference. Formally, let $W _ { U }$ denote the unembedding matrix, $\overline { { \mathrm { L N } } }$ a layer norm operation (see Appendix $_ \mathrm { H }$ ) and $W _ { U } [ I O ]$ , $W _ { U } [ S ]$ the corresponding unembedding vectors for the $I O$ and $S$ tokens. We searched for heads $( i , j )$ such that
91
+
92
+ $$
93
+ \lambda _ { i , j } \overset { \mathrm { d e f } } { = } \mathbb { E } _ { X \sim \mathsf { p } _ { \mathrm { I O I } } } [ \langle \overline { { \mathbf { L N } } } \circ h _ { i , j } ( X ) , W _ { U } [ I O ] - W _ { U } [ S ] \rangle ]
94
+ $$
95
+
96
+ had large magnitude. Recall that $h _ { i , j } ( X )$ is the value that head $( i , j )$ writes into the residual stream on input $X$ . Therefore, heads with $\dot { \lambda } _ { i , j } > 0$ correctly promote the IO token over the S token (on average). The unembedding projection in (3.1) is called the logit lens and has been used in previous work to interpret intermediate activations (nostalgebraist, 2020) and parameters (Dar et al., 2022). We display the values of $\lambda _ { i , j }$ in Figure $_ { 3 \mathrm { ~ A ~ } }$ . We see that only a few heads in the final layers have large logit projection $\lambda _ { i , j }$ . Specifically, 9.6, 9.9, and 10.0 have a large positive score, while 10.7 and 11.10 have a large negative score.
97
+
98
+ Name Mover Heads. To understand the positive heads, we first study their attention patterns. We find that they attend strongly to the IO token: the average attention probability of all heads over pIOI is 0.59. Since attention patterns can be misleading (Jain & Wallace, 2019), we check whether attention is correlated with the heads’ functionality. We do so by scatter plotting the attention probability against the logit score $\langle h _ { i } ( X ) , W _ { U } [ I O ] \rangle$ . The results are shown in Figure $^ { 3 \mathrm { ~ B ~ } }$ : higher attention probability on the IO token is linearly correlated with higher output in the IO direction (correlation $\rho > 0 . 8 1$ , $N = 5 0 0$ ). Based on this result, we hypothesize that these heads (i) attend to names and (ii) copy whatever they attend to. We therefore call these heads Name Mover Heads.
99
+
100
+ To check that the Name Mover Heads copy names generally, we studied what values are written via the heads’ OV circuits. We transform the output of the first layer at a name token through the OV matrix of a Name Mover Head and then project to the logits. The copy score is the proportion of samples that contain the input name token in the top 5 logits $N = 1 0 0 0 \rangle$ ). We find that all three Name Mover Heads have a copy score above $9 5 \%$ (compared to less than $2 0 \%$ for an average head).
101
+
102
+ Negative Name Mover Heads. In Figure 3, we also observed two heads strongly writing opposite the $W _ { U } [ I O ] - W _ { U } [ S ]$ direction. We called these heads Negative Name Mover Heads. Their copy score is calculated with the negative of their OV matrix. As described in Figure 3, they share all the properties of Name Mover Heads, except they write in the opposite of names they attend to.
103
+
104
+ ![](images/1c343aca6619523cf78347fa51e9182e0936203f0c0549cd37f849b66f769e20.jpg)
105
+ Figure 4: The attention probability to IO averaged over three Name Mover Heads is decreased most by the Previous Token Heads (left), Induction Heads (center) and S-Inhibition Heads (right) when we patch these attention heads from a sentence with a different S2 name (center and right), or a different S1 name (left).
106
+
107
+ 3.2 WHICH HEADS AFFECT THE NAME MOVER HEADS’ ATTENTION? (S-INHIBITION HEADS)
108
+
109
+ Given that the Name Mover Heads are primarily responsible for constructing the output, we ask why these Name Mover Heads pay preferential attention to the IO token. First, there are two ways to affect the Name Mover Heads’s attention: through the query vector at the END token or the key vector at the IO token. Since the key vector appears early in the context, it likely does not contain much task-specific information, so we focus on the END query vector.
110
+
111
+ Then, by investigating Name Mover Heads on the ABC distribution (where the three names are distinct; see Section 2.2), we observed that their attention is not selective: they pay equal attention to the first two names. We thus ask: what has changed from the ABC distribution to the pIOI distribution to cause the Name Mover Heads to attend to the IO token preferentially?
112
+
113
+ To empirically answer this question, we perform a patching experiment, a similar type of causal intervention as performed in Meng et al. (2022); Vig et al. (2020). As illustrated in Figure 1 this technique consists of two steps. First we save all activations of the network run on a source sequence. Then we run the network on a target sequence, replacing some activations with the activations from the source sequence. We can then measure the behavior of the patched model. Doing this for each node individually locates the nodes that explain why model behavior is different in the source and target sequences.
114
+
115
+ In our case, we run activation patching with source sentences from the ABC distribution and target sentences from pIOI. We then compute the change in attention probability from END to IO, averaged over the three Name Mover Heads. Since the Name Mover Heads attention on the IO is high in the pIOI distribution and low in ABC, patching at important heads from ABC to pIOI should decrease Name Mover Heads attention on IO. The results from patching every head at the END token position are shown in Figure 4, right. We observe that patching heads 7.3, 7.9, 8.6, 8.10 causes a decrease in the attention probability on IO, indicating that they are counterfactually important for the Name Mover Heads’s attention probability on the IO token. We call these heads S-Inhibition Heads.
116
+
117
+ # 3.3 WHAT INFORMATION DO THE S-INHIBITION HEADS MOVE?
118
+
119
+ How do the S-Inhibition Heads differentiate between IO and S, so they inhibit one but not the other? We measured their attention pattern and found that they preferentially attend to the S2 token. We therefore studied what information these heads move from the S2 token position to the END position. We studied both the properties of the input, and which upstream affect the S-inhibition heads. Surprisingly, we found that the S-inhibition heads mostly depend on the repetition at the two positions where the S token occurs (Appendix G).
120
+
121
+ To study the heads that affect the S-inhibition heads, we ran a patching experiment at S2 from the ABC distribution to the IOI distribution and measured the variation in Name Mover Heads attention. The results (Figure 4, center) reveal a large set of heads influencing Name Mover Heads’ attention that did not appear at the END position. S-Inhibition Heads must mediate this effect, as they are the only heads influencing Name Mover Heads at the END position. This reasoning suggests that the outputs of this set of heads is moved by S-Inhibition Heads from S2 to the END token. When we analyze the attention patterns of these heads, we see two distinct groups emerge.
122
+
123
+ Duplicate Token Heads. One group attends from S2 to S1. We call these Duplicate Token Heads on the hypothesis that they detect duplicate tokens. To validate this, we analyze their attention pattern on sequences of random tokens (with no semantic meaning), we found that 2 of the 3 Duplicate Token Heads pay strong attention to a previous occurrence of the current token if it exists (see Appendix F for more details).
124
+
125
+ Induction Heads and Previous Token Heads. The other group of heads attends from S2 to $\mathrm { S } 1 { + } 1$ (the token after the S1 token): the classic attention pattern of an induction head. Previously described in Elhage et al. (2021), induction heads recognize the general pattern [A] [B] ... [A] and contribute to predicting [B] as the next token. For this, they act in pair with a Previous Token Head. The Previous Token Head should write information about [A] into the residual stream at [B], so that the Induction Head can match the next occurrence of [A] to that position (and subsequently copy [B] to the output).
126
+
127
+ We therefore seek to identify Previous Token Heads used by our purported Induction Heads. To this end, we patched activations from a sentence where S1 is replaced by a random name, at the $_ { \mathsf { S } + 1 }$ token index. As shown in figure 4, some heads (and particularly 4.11) appear to influence Name Mover Heads. Then, by looking at the attention pattern of the most important heads in this patching experiment, we identified 3 Previous Token Heads. We find that 2 of the 3 Previous Token Heads and 2 of the 4 Induction Heads demonstrated their expected attention patterns (Appendix F).
128
+
129
+ 3.4 DID WE MISS ANYTHING? THE STORY OF THE BACKUP NAME MOVERS HEADS
130
+
131
+ Each type of head in our circuit has many copies, suggesting that the model implements redundant behavior. To make sure that we didn’t miss any copies, we knocked out all of the Name Mover Heads at once. To our surprise, the circuit still worked (only $10 \%$ drop in logit difference). In addition, many heads write along $W _ { U } [ I O ] - W _ { U } [ S ]$ after the knockout, which did not do so previously.
132
+
133
+ We kept the heads with the largest $\lambda _ { i , j }$ , and call them Backup Name Mover Heads. See appendix B for further details on these heads. Among the height heads identified, we investigated their behavior before the knockout. We observe diverse behavior: 3 heads show close resemblance to Name Mover Heads; 3 heads equally attend to IO and S and copy them; 1 head pays more attention to S1 and copies it; 1 head seems to track and copy subjects of clauses, copying S2 in this case.
134
+
135
+ # 4 EXPERIMENTAL VALIDATION
136
+
137
+ In this section, we check that our circuit provides a good account of GPT-2’s true behavior. In general, our introduced criteria depend on a measure $F$ of the performance of a circuit on a task. In our case, suppose $X \sim { \mathsf { p } } _ { \mathrm { { I O I } } }$ , and $f ( C ( X ) ; X )$ is the logit difference between the IO and S tokens when the circuit $C$ is run on the input $X$ . The average logit difference $F ( C ) \ { \stackrel { \mathrm { d e f } } { = } } \ \mathbb { E } _ { X \sim \mathsf { p } _ { \mathrm { I O I } } } \left[ f ( C ( X ) ; X ) \right]$ is a measure of how much a circuit predicts IO rather than S, i.e performs the IOI task.
138
+
139
+ Firstly, we check that $C$ is faithful to $M$ , i.e. that it computes similar outputs. We do so by measuring $| F ( \dot { M } ) - F ( C ) |$ , and find that it is small: 0.2, or only $6 \%$ of $F ( M ) = { \bf \bar { 3 . 5 5 } }$ .
140
+
141
+ In Section 4.1 we define a running toy example of a model $M$ for which faithfulness is not sufficient to prescribe which circuits explain a behavior defined by a measure $F$ well. This motivates the criteria of completeness and minimality that we then check on our circuit. In addition to the criteria, we also validated our knowledge of the circuit by designing adversarial examples (see Appendix C).
142
+
143
+ # 4.1 COMPLETENESS
144
+
145
+ As a running example, suppose a model $M$ uses two similar and disjoint serial circuits (where each node depends on the previous node) $C _ { 1 }$ and $C _ { 2 }$ . The two sub-circuits are run in parallel before applying an OR operation to their results. Identifying only one of the circuits is enough to achieve faithfulness, but we want explanations that include both $C _ { 1 }$ and $C _ { 2 }$ , since these are both used in the model.
146
+
147
+ ![](images/7bcd53b15913b0a8b542e4ed9631984b12430797eb22f15e10899f93e22c740a.jpg)
148
+ Figure 5: Plot of points $( x _ { K } , y _ { K } ) = ( \mathrm { F } ( M \setminus K ) , \mathrm { F } ( C \setminus K ) )$ for our circuit (left) and a naive circuit (right). Each point is for a different choice of $K$ : 50 uniformly randomly chosen $K \subseteq C$ , $K = \emptyset$ , and the five $K$ with the highest incompleteness score found by greedy optimization. Since the incompleteness score is $\left| x _ { K } - y _ { K } \right|$ , we show the line $y = x$ for reference.
149
+
150
+ To solve this problem, we introduce the completeness criterion: for every subset $K \subseteq C$ , the incompleteness score $| F ( C \setminus K ) - F ( M \setminus K ) |$ should be small. In other words, $C$ and $M$ should not just be similar, but remain similar under knockouts.
151
+
152
+ In our running example, we can show that $C _ { 1 }$ is not complete by setting $K = C _ { 1 }$ . Then $C _ { 1 } \backslash K$ is the empty circuit while $M \backslash K$ still contains $C _ { 2 }$ . The metric $| F ( C _ { 1 } \setminus K ) - F ( M \setminus K ) |$ will be large because $C _ { 1 } \backslash K$ has trivial performance while $M \backslash K$ successfully performs the task.
153
+
154
+ The criterion of completeness requires a search over exponentially many subsets $K \subseteq C$ . This is computationally intractable given the size of our circuit, hence we use three sampling methods to find examples of $K$ that give large incompleteness score:
155
+
156
+ • The first sampling method chooses subsets $K \subseteq C$ uniformly at random. • The second sampling method set $K$ to be an entire class of circuit heads $G$ , e.g the Name Mover Heads. $C \setminus G$ should have low performance since it’s missing a key component, whereas $M \setminus G$ might still do well if it has redundant components that fill in for $G$ . • Thirdly, we greedily optimized $K$ node-by-node to maximize the incompleteness score (see appendix $\mathbf { K }$ for the detail of the optimization procedure).
157
+
158
+ These first two methods of sampling $K$ suggested to us that our circuit was $\varepsilon$ -complete for a small value of $\varepsilon$ . However, the third resulted in sets $K$ that had high incompleteness score: up to 3.09. All such results are found in figure 5, on the left.
159
+
160
+ # 4.2 MINIMALITY
161
+
162
+ A faithful and complete circuit may contain unnecessary components, and so be overly complex. To avoid this, we should check that each of its nodes $v$ is necessary. This can be evaluated by knocking out a set of nodes $K$ and showing that adding back $v \in K$ to the circuit can significantly recover $F$ .
163
+
164
+ Formally, the minimality require that for every node $v \in C$ there exists a subset $K \subseteq C \setminus \{ v \}$ that has minimality score $| \bar { F ( C \setminus ( K \cup \{ v \} ) ) } - \bar { F ( C \setminus K ) } | \geq A$ . We call such a circuit $A$ -minimal.
165
+
166
+ In the running example, $C _ { 1 } \cup C _ { 2 }$ is $A$ -minimal for some non-trivial $A$ . We can sketch a proof of this result given an informal defintion of ‘non-trivial’. To show this, note that if $v _ { 1 } \in C _ { 1 }$ and $K = C _ { 2 }$ , then the minimality score is equal to $| F ( C _ { 1 } \setminus \{ v _ { 1 } \} ) - F ( C _ { 1 } ) |$ which is large since $C _ { 1 }$ is a serial circuit and so removing $v _ { 1 }$ will destroy the behavior. We then proceed symmetrically for $v _ { 2 } \in C _ { 2 }$ .
167
+
168
+ In practice, we need to exhibit for every $v$ a set $K$ such that the minimality score is at least $A$ . For most heads, removing the class of heads $G$ that $v$ is a part of provides a reasonable minimality score. We describe the sets $K$ that are required for them in Appendix J. The importance of individual nodes is highly variable, but they all have a significant impact on the final metric (at least $3 \%$ of the original logit difference). These results ensure that we did not interpret irrelevant nodes, but do show that the individual contribution of some single attention heads is small.
169
+
170
+ ![](images/587eb520de66e3f0c7c7c04f869990bb37d781619f64b37df1bdf4efc40759b1.jpg)
171
+ Figure 6: Plot of minimality scores $| F ( C \setminus ( K \cup \{ v \} ) ) - F ( C \setminus K ) |$ for all components $v$ in our circuit. The sets $K$ used for each component, as well as the initial and final values of the logit difference for each of these $v$ is in Appendix J. Our circuit is 0.06-minimal.
172
+
173
+ # 4.3 COMPARISON WITH A NAIVE CIRCUIT
174
+
175
+ In order to get a relative sense of the success of our explanation by our criteria, we compare the results on a na¨ıve circuit that consists of the Name Mover Heads (but no Backup Name Mover Heads), S-Inhibition Heads, two Induction Heads, two Duplicate Token Heads and two Previous Token Heads. This circuit has a faithfulness score 0.1, a score comparable to our circuit’s faithfulness score. However, contrary to our circuit, the naive circuit can be easily proven incomplete: by sampling random sets or by knocking-out by classes, we see that $F ( M \backslash { \bar { K } } )$ is much higher than $F ( C \backslash K )$ (Figure 5, left). Nonetheless, when we applied the greedy heuristic to optimize for the incompleteness score, both circuits have similarly large incompleteness scores. Thus, we conclude that our worst-case completeness criterion was too high a bar, which future work could use as a high standard to validate circuit discovery.
176
+
177
+ # 5 DISCUSSION
178
+
179
+ In this work, we isolated, understood and validated a set of attention heads in GPT-2 small composed in a circuit that identifies indirect objects. Along the way, we discovered interesting structures emerging from the model internals that complicated the study. For instance, we identified heads compensating for the loss of function of other heads, and heads contributing negatively to the nexttoken prediction. Early results suggest that the latter phenomenon occurs for other tasks beyond IOI (see Appendix F).
180
+
181
+ However, our work also has several limitations. First, despite the detailed analysis presented here, we do not understand several components. Those include the attention patterns of the S-Inhibition Heads, and the effect of MLPs and layer norms. Second, the number of parameters in GPT-2 small is orders of magnitude away from state-of-the-art transformer language models. A future challenge is to scale this approach to these larger models. Thirdly, we only looked at the difference in average metric (logit difference) between the circuit and the model in order to compare how they both did the IOI task (Section 4). Looking at the average difference in metric between the circuit and model on individual examples would be a more stringent way to compare them, but it had too much variability to help us find a circuit. Fourthly, the definition of the task is limited: we only measure a fraction of the prediction made by the model, and do not study cases where the model is not performing IOI. Finally, more work is needed to validate the structural validation criterion we introduce here.
182
+
183
+ We hope that our work spurs further efforts in mechanistic explanations of larger language models computing different natural language tasks, with the eventual goal of understanding full language model capabilities.
184
+
185
+ # REFERENCES
186
+
187
+ Boaz Barak, Benjamin L Edelman, Surbhi Goel, Sham Kakade, Eran Malach, and Cyril Zhang. Hidden progress in deep learning: Sgd learns parities near the computational limit. arXiv preprint arXiv:2207.08799, 2022.
188
+
189
+ Tolga Bolukbasi, Adam Pearce, Ann Yuan, Andy Coenen, Emily Reif, Fernanda B. Viegas, and ´ Martin Wattenberg. An interpretability illusion for BERT. CoRR, abs/2104.07143, 2021. URL https://arxiv.org/abs/2104.07143.
190
+
191
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
192
+
193
+ Guy Dar, Mor Geva, Ankit Gupta, and Jonathan Berant. Analyzing transformers in embedding space. arXiv preprint arXiv:2209.02535, 2022.
194
+
195
+ Nelson Elhage, Neel Nanda, Catherine Olsson, Tom Henighan, Nicholas Joseph, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Nova DasSarma, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. A mathematical framework for transformer circuits. Transformer Circuits Thread, 2021. https://transformer-circuits.pub/2021/framework/index.html.
196
+
197
+ Matthew Finlayson, Aaron Mueller, Sebastian Gehrmann, Stuart Shieber, Tal Linzen, and Yonatan Belinkov. Causal analysis of syntactic agreement mechanisms in neural language models, 2021. URL https://arxiv.org/abs/2106.06087.
198
+
199
+ Atticus Geiger, Hanson Lu, Thomas F Icard, and Christopher Potts. Causal abstractions of neural networks. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum? id $=$ RmuXDtjDhG.
200
+
201
+ Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. Transformer feed-forward layers are key-value memories. arXiv preprint arXiv:2012.14913, 2020.
202
+
203
+ Dan Hendrycks and Mantas Mazeika. X-risk analysis for ai research. arXiv, abs/2206.05862, 2022.
204
+
205
+ Evan Hernandez, Sarah Schwettmann, David Bau, Teona Bagashvili, Antonio Torralba, and Jacob Andreas. Natural language descriptions of deep visual features. In International Conference on Learning Representations, 2021.
206
+
207
+ Sarthak Jain and Byron C. Wallace. Attention is not Explanation. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 3543–3556, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1357. URL https://aclanthology.org/N19-1357.
208
+
209
+ Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. Locating and editing factual associations in gpt. arXiv preprint arXiv:2202.05262, 2022.
210
+
211
+ Jesse Mu and Jacob Andreas. Compositional explanations of neurons. Advances in Neural Information Processing Systems, 33:17153–17163, 2020.
212
+
213
+ Neel Nanda and Tom Lieberum. A mechanistic interpretability analysis of grokking, 2022. URL https://www.alignmentforum.org/posts/N6WM6hs7RQMKDhYjB/ a-mechanistic-interpretability-analysis-of-grokking.
214
+
215
+ nostalgebraist. interpreting gpt: the logit len, 2020. URL https://www.lesswrong.com/ posts/AcKRB8wDpdaN6v6ru/interpreting-gpt-the-logit-lens.
216
+
217
+ Chris Olah. Mechanistic interpretability, variables, and the importance of interpretable bases. https://www.transformer-circuits.pub/2022/mech-interp-essay, 2022.
218
+
219
+ Chris Olah, Nick Cammarata, Ludwig Schubert, Gabriel Goh, Michael Petrov, and Shan Carter. Zoom in: An introduction to circuits. Distill, 2020. doi: 10.23915/distill.00024.001. https://distill.pub/2020/circuits/zoom-in.
220
+ Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, et al. In-context learning and induction heads. arXiv preprint arXiv:2209.11895, 2022.
221
+ Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
222
+ Tilman Rauker, Anson Ho, Stephen Casper, and Dylan Hadfield-Menell. Toward transparent ai: ¨ A survey on interpreting the inner structures of deep neural networks, 2022. URL https: //arxiv.org/abs/2207.13243.
223
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pp. 5998–6008, 2017.
224
+ Jesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian, Daniel Nevo, Yaron Singer, and Stuart Shieber. Investigating gender bias in language models using causal mediation analysis. Advances in Neural Information Processing Systems, 33:12388–12401, 2020.
225
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. Emergent abilities of large language models. ArXiv, abs/2206.07682, 2022.
226
+
227
+ # A IOI TEMPLATES
228
+
229
+ We list all the template we used in Table 7. Each name was drawn from a list of 100 English first names, while the place and the object were chosen among a hand made list of 20 common names. All the word chosen were one token long to ensure proper sequence alignment computation of the mean activations.
230
+
231
+ <table><tr><td rowspan=1 colspan=1>Templates in PIOI</td></tr><tr><td rowspan=1 colspan=1>Then, [B] and [A] went to the [PLACE]. [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Then,[B] and [A] had a lot of fun at the [PLACE]. [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Then, [B] and [A] were working at the [PLACE]. [B] decided to give a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Then, [B] and [A] were thinking about going to the [PLACE]. [B] wanted to give a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Then, [B] and [A] had a long argument, and afterwards [B] said to [A]</td></tr><tr><td rowspan=1 colspan=1>After [B] and [A] went to the [PLACE], [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>When [B] and [A] got a [OBJECT] at the [PLACE], [B] decided to give it to [A]</td></tr><tr><td rowspan=1 colspan=1>When [B] and [A] got a [OBJECT] at the [PLACE], [B] decided to give the [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>While [B] and [A] were working at the [PLACE], [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>While [B] and [A] were commuting to the [PLACE], [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>After the lunch, [B] and [A] went to the [PLACE]. [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Afterwards, [B] and [A] went to the [PLACE]. [B] gave a [OBJECT] to [A]</td></tr><tr><td rowspan=1 colspan=1>Then, [B] and [A] had a long argument. Afterwards [B] said to [A]</td></tr><tr><td rowspan=1 colspan=1>The [PLACE] [B] and [A] went to had a [OBJECT]. [B] gave it to [A]</td></tr><tr><td rowspan=1 colspan=1>Friends [B] and [A] found a [OBJECT] at the [PLACE]. [B] gave it to [A]</td></tr></table>
232
+
233
+ Figure 7: Templates used in the IOI dataset. All templates in the table fit the ’BABA’ pattern, but we also use templates that fit the ‘ABBA’ pattern as well (not included for simplicity).
234
+
235
+ # B BACKUP NAME MOVER HEADS
236
+
237
+ Here we discuss in more detail the discovery of the Backup Name Mover Heads. As shown in figure 8, knocking-out the three main Name Mover Heads doesn’t leave the rest of the heads in a similar state as before. They seem to ”compensate” the loss of function from the Name Mover Heads such that the logit difference is only $10 \%$ lower. We observe that the Negative Name Mover Heads head write less negatively in the direction of $W _ { U } [ I O ] - W _ { U } [ S ]$ , 10.7 even write positively in this direction afterwards, while other heads that wrote slightly along $\dot { W } _ { U } [ I O ] - W _ { U } [ \bar { S } ]$ before the knock-out becomes the main contributor. Both the reason and the mechanism of this compensation effect are still unclear, we think that this could be an interesting phenomenon to investigate in future works. Among those last categories, we identify S-inhibition heads and a set of other head that we called Backup Name Mover Heads. We arbitrarily chose to keep the height heads that were not part of any other groups, and wrote in the direction of $W _ { U } [ I O ] - W _ { U } [ S ]$ above the threshold of 0.05.
238
+
239
+ In figure 9 we analyze the behavior of those newly identified heads with similar techniques as Name Mover Heads. Those can be grouped in 4 categories.
240
+
241
+ • 3 heads (10.1, 10.10 and 10.6) that behave similarly as Name Mover Heads according to their attention pattern, and scatter plots of attention vs dot product of their output with $W _ { U } [ I O ] - W _ { U } [ S ]$ (as 10.10).
242
+ • 3 heads (10.2, 11.9, 11.3) that pay equal attention to S1 and IO and wrote both of them (as 10.2 in Figure 9).
243
+ • One head, 11.2, that pays more attention to S1 and write preferentially in the direction of $W _ { U } [ S ]$
244
+ • One head, 9.7, that pays attention to S2 and write negatively.
245
+
246
+ We did not thoroughly investigate this diversity of behavior, more work can be done to precisely describe these heads. However, these heads are also the ones with the less individual importance for the task (as shown by their minimality score in Figure 6). The exact choice of Backup Name Mover Heads doesn’t change significantly the behavior of the circuit.
247
+
248
+ ![](images/2f63b778ce7531a3be151b56c980230c44881802c042c64de029f45f0d2757e5.jpg)
249
+
250
+ ![](images/e6b63982c7d98844de1a566f5bc4b0f0715a25e1e6920355fb8be79db02ba712.jpg)
251
+ Figure 8: Discovery of the Backup Name Mover Heads. After knock-out of the Name Mover Heads (right) some heads write stronger in the $W _ { U } [ I O ]$ or $W _ { U } [ S ]$ direction than before (left). We also observed that negative heads seems inhibited by this operation.
252
+ Figure 9: Four examples of Backup Name Mover Heads. Left: attention probability vs projection of the head output along $W _ { U } [ I O ]$ or $W _ { U } [ S ]$ respectively. Right: Attention pattern on a sample sequence.
253
+
254
+ Figure 10: Summary of GPT-2 performance metrics on the IOI task on different datasets. In the line order: for pIOI, for the dataset where we added an occurrence of S (thus S appears three times in the sentence) and for the adversarial dataset with duplicated IO in natural sentences. IO probability refers to the probability the model places on the IO token (computed from the logits).
255
+
256
+ <table><tr><td rowspan=1 colspan=1>Distribution</td><td rowspan=1 colspan=1>Logit difference</td><td rowspan=1 colspan=1> IO probability</td><td rowspan=1 colspan=1>Proportion ofS logit greater than IO</td></tr><tr><td rowspan=1 colspan=1>PIOI</td><td rowspan=1 colspan=1>3.55</td><td rowspan=1 colspan=1>0.49</td><td rowspan=1 colspan=1>0.7%</td></tr><tr><td rowspan=1 colspan=1>Additional occurrence of S(natural sentence)</td><td rowspan=1 colspan=1>3.64</td><td rowspan=1 colspan=1>0.59</td><td rowspan=1 colspan=1>0.4%</td></tr><tr><td rowspan=1 colspan=1>Additional occurrence of IO(natural sentence)</td><td rowspan=1 colspan=1>1.23</td><td rowspan=1 colspan=1>0.36</td><td rowspan=1 colspan=1>23.4%</td></tr></table>
257
+
258
+ # C DESIGNING ADVERSARIAL EXAMPLES
259
+
260
+ As argued in Rauker et al. (2022), one way to evaluate the knowledge gained by interpretability work ¨ is to use it for downstream applications as predicting out of distribution behavior. In this section, we do this by using knowledge of the circuit to construct simple adversarial examples for the model.
261
+
262
+ As presented in Section 3, the model relies on duplicate detection to differentiate between S and IO. Motivated by this, we constructed passages where both the S and IO tokens are duplicated. An example is “John and Mary went to the store. Mary had a good day. John gave a bottle of milk to”; see Appendix D for full details. We find that this significantly reduces the logit difference and causes the model to predict S over IO $2 3 \%$ of the time (Figure 10).
263
+
264
+ To ensure that the observed effect is not an artifact of the additional sentences, we included a control dataset using the same templates, but where the middle sentence contains S instead of IO. In these sentences, S appears three times in total and IO only appears once. On this distribution, the model has an even higher logit difference than on pIOI, and predicts S over IO only $0 . 4 \%$ of the time.
265
+
266
+ Limitations of the attack. Despite being inspired by our understanding of our circuit, those examples are simple enough that they could have been found without our circuit with enough effort.
267
+
268
+ Moreover, we do not have a full understanding of the mechanisms at play in these adversarial examples. For instance, the S-Inhibition Heads attend not only to S2, but also to the second occurrence of IO. As this pattern is not present in pIOI nor in ABC, it is beyond the analysis presented in Section 3. The study of the behavior of the circuit on these adversarial examples could be a promising area for future work.
269
+
270
+ # D TEMPLATE FOR ADVERSARIAL EXAMPLES
271
+
272
+ The design of adversarial examples relies on adding a duplicate IO to the sentences. To this end, we used a modification of the templates described in appendix A. We added an occurrence of [A] in the form of a natural sentence, independent of the context. The list of sentence is visible in Figure 11.
273
+
274
+ <table><tr><td rowspan=1 colspan=1>[A] had a good day.</td></tr><tr><td rowspan=1 colspan=1>[A] was enjoying the situation.</td></tr><tr><td rowspan=1 colspan=1>[A] was tired.</td></tr><tr><td rowspan=1 colspan=1>[A] enjoyed being with a friend.</td></tr><tr><td rowspan=1 colspan=1>[A] was an enthusiast person.</td></tr></table>
275
+
276
+ Figure 11: Templates for the natural sentences used in the generation of adversarial examples. The sentences were chosen to be independent of the context.
277
+
278
+ # E GPT-2 SMALL FULL ARCHITECTURE
279
+
280
+ Here we define all components of the GPT-2 Architecture, including those we don’t use in the main text. GPT-2 small has the following hyperparameters:
281
+
282
+ • $N$ : number of input tokens.
283
+
284
+ • $V$ : vocabulary of tokens.
285
+ • $d$ : residual stream dimension.
286
+ • $L$ : number of layers.
287
+ • $H$ : number of heads per layer.
288
+ • $D$ : hidden dimension of MLPs
289
+
290
+ It uses layer norms, the non-linear function
291
+
292
+ $$
293
+ \mathrm { L N } ( x ) \ { \stackrel { \mathrm { d e f } } { = } } \ { \frac { x - { \bar { x } } } { \sqrt { \sum _ { i } ( x _ { i } - { \bar { x } } _ { i } ) ^ { 2 } } } } ,
294
+ $$
295
+
296
+ where the mean and the difference from the mean sum are over the $d$ components of each of the $N$ tensors.
297
+
298
+ In GPT-2 the MLPs all have one hidden layer of dimension $D$ and use the GeLU non-linearity.
299
+
300
+ We addressed the parametrisation of each attention head in the main text, and cover the technical details of the $W _ { Q K }$ and $W _ { O V }$ matrix here: the attention pattern is $A _ { i , j } = \mathrm { s o f t m a x } ( x ^ { T } W _ { Q K } ^ { i , j } x )$ where the softmax is taken for each token position, and is unidirectional. We then have $h _ { i , j } ( x )$ def = $( A _ { i , j } \otimes W _ { O V } ^ { i , j } ) . x .$ .
301
+
302
+ # Algorithm 1 GPT-2.
303
+
304
+ Require: Input tokens $T$ ; returns logits for next token.
305
+ 1: $w $ One-hot embedding of T
306
+ 2: $x _ { 0 } W _ { E } w$ (sum of token and position embeddings)
307
+ 3: for $i = 0$ to $L$ do
308
+ 4: yi ← 0 ∈ RN×d
309
+ 5: for $j = 0$ to $H$ do
310
+ 6: $y _ { i } \gets y _ { i } + h _ { i , j } ( x _ { i } )$ , the contribution of attention head $( i , j )$
311
+ 7: end for
312
+ 8: $y _ { i } ^ { \prime } \gets m _ { i } ( x _ { i } )$ , the contribution of MLP at layer $i$
313
+ 9: $x _ { i + 1 } x _ { i } + y _ { i } + y _ { i } ^ { \prime }$ (update the residual stream)
314
+
315
+ # F ANALYSIS ON SEQUENCES OF RANDOM TOKENS
316
+
317
+ We run GPT-2 small on sequences of 100 tokens sampled uniformly at random from GPT-2’s token vocabulary. Each sequence A was duplicated to form $\tt R A$ , a sequence twice as long where the first and second half are identical. On this dataset, we computed three scores from the attention patterns of the attention heads:
318
+
319
+ • The duplicate token score: for each token $T _ { i }$ in the second half of a sequence $S$ , we average the attention probability from $T _ { i }$ to its previous occurrence in the first half of $S$ (i.e. $T _ { i - 1 0 0 } )$ .
320
+ • The previous token score: we averaged the attention probability on the off-diagonal. This is the attention from the token at position $i$ to position $i - 1$ .
321
+ • The induction score: the attention probability from $T _ { i }$ to the token that comes after the first occurrence of $T _ { i }$ (i.e. $T _ { i - 9 9 }$ )
322
+
323
+ These three score are depicted in Figure 12 for all attention heads. We can identify 3.0 and 0.1 as duplicated token heads that also appear in our circuit, 5.5 and 6.9 have high induction score and were also identified as induction heads in our investigation and 4.11 and 2.2 have a high previous token score. Note that the heads identified are also the ones that have the highest influence in the patching experiment shown in Figure 4.
324
+
325
+ Induction Heads. Olsson et al. (2022) define an Induction Head according to its behavior on repeated sequences of random tokens. The attention head must demonstrate two properties. i) Prefixmatching property. The head attends to [B] from the last [A] on pattern like [A] [B] ... [A] ii) Copy property. The head contribute positively to the logit of [B] on the pattern [A][B]...[A].
326
+
327
+ ![](images/eddc5df28590dcae996a4e1b5e51dbaf8a80a2d3709e6450790838ba3428fb3a.jpg)
328
+ Figure 12: Sum of attention probabilities on position determined by the role. Left: duplicate score, the average attention probability from a token to its previous occurrence. Center: Previous token attention score, it is the average of the off diagonal attention probability. Right: Induction score. Average attention probability from the second occurence of [A] to [B] on [A][B]...[A].
329
+
330
+ ![](images/6e38e33f4f19ac0d5673416d935d0f77d6e1410bb9269e2d1a4575148f411a42.jpg)
331
+ Figure 13: Contribution to the next token prediction per head on repeated sequences of tokens. The heads are ordered by decreasing absolute values of contribution. Black contour: heads with attention patterns demonstrating prefix matching property.
332
+
333
+ In the IOI task, we identify these heads according to their attention pattern, demonstrating the pattern-matching property. Here, we investigate their copy property, that is useless in the context of IOI: outputting the token after S2 is of no interest to identify IO.
334
+
335
+ As presented above, 5.5 and 6.9 are among the 5 heads with the highest induction score. This validates their prefix-matching property.
336
+
337
+ To check their copy property, we computed the dot product $\langle h _ { i } ( X ) , W _ { U } [ B ] \rangle$ between the output of the head $h _ { i }$ on sequence $X$ and the embedding of the token [B] on repeated sequences of random tokens. The results are shown in Figure 13. The two Induction Heads (5.5 and 6.9) appear in the 20 heads contributing the most to the next token prediction. Thus validating their copying property.
338
+
339
+ We also noticed that the majority of the Negative, Backup and regular Name Mover Heads appear to write in the next token direction on repeated sequences of random tokens, and Negative Name Movers Heads contribute negatively. This suggests that these heads are involved beyond the IOI task to produce next-token prediction relying on contextual information. Moreover, ablating the output of the three Name Mover Heads by patching their outputs results in a $26 \%$ increase in average loss on the last 99 tokens (from 0.15 to 0.19), showing their importance on tasks outside IOI.
340
+
341
+ # G DISENTANGLING FEATURES IN THE OUTPUT OF S-INHIBITION HEADS
342
+
343
+ In Section 3.2, we discovered that S-Inhibition Heads are responsible for the Name Mover Heads’ specific attention on the IO token. In this appendix, we explore which properties of the input affect the S-inhibition heads’ outputs.
344
+
345
+ We present evidence that they were outputting token signals (information about the value of the token S), positional signals (related to the value of the position S1) and that the latter is the most important.
346
+
347
+ To disentangle the two effects, we design a series of counterfactual datasets where only some signals are present, and some are inverted with respect to the original dataset. We then conducted patching experiments where the output of S-Inhibition heads are computed from these datasets.
348
+
349
+ This enables us to quantify in isolation the impact of each signal on the final logit difference.
350
+
351
+ We constructed six datasets by combining three transformations of the original pIOI distribution.
352
+
353
+ • Random name flip: we replace the names from a given sentence with random names, but we keep the same position for all names. Moreover, each occurrence of a name in the original sentence is replaced by the same random name. When we patch outputs of S-Inhibition heads from this sentence, only positional signals are present, the token signals are unrelated to the names of the original sequence. $\mathbf { I O } { } \mathbf { S } \mathbf { 1 }$ flip: we swap the position of IO and S1. The output of S-inhibition heads will contain correct token signals (the subject of the second clause is the same) but inverted positional signals (because the position of IO and S1 are swapped) • ${ \bf I O } { } { \bf S } 2$ replacement: we make IO become the subject of the sentence and S the indirect object. In this dataset, both token signals and positional signals are inverted.
354
+
355
+ We can also compose these transformations. For instance, we can create a dataset with no token signals and inverted positional signals by applying $\mathrm { I O } { } { \mathbf S } 1$ flip on the dataset with random names. In total, we can create all six combinations of original, inverted, or uncorrelated token signal with the original and inverted positional signal.
356
+
357
+ From each of those six datasets, we patched the output of S-Inhibition heads and measured the logit difference. The results are presented in Figure 14.
358
+
359
+ These results can be summarized as the sum of the two effects. Suppose we define the variable $S _ { t o k }$ to be 1 if the token signal is the original, 0 when uncorrelated and -1 when inverted. And similarly $S _ { p o s }$ to be 1 if the position signal is the original and $^ { - 1 }$ if inverted. Then the Figure 14 suggests that the logit difference can be well approximated by $2 . 3 1 S _ { p o s } + 0 . 9 9 S _ { t o k }$ , with a mean error of $7 \%$ relative to the baseline logit difference.
360
+
361
+ For instance, when both the positional and token signals are inverted, the logit difference is the opposite of the baseline. This means that the S token is predicted stronger than the IO token, as strong as IO before patching. In this situation, due to the contradictory information contained in the output of S-Inhibition heads, the Name Movers attend and copy the S1 token instead of the IO token (see Figure 15, right). In the intermediate cases where only one of the signals is modified, we observe a partial effect compared to the fully inverted case (e.g. Figure 15, left). The effect size depends on the altered signals: positional signals are more important than token signals.
362
+
363
+ Can we be more specific as to what the token and positional signals are? Unfortunately, we do not have a complete answer, but see this as one of the most interesting further directions of our work. We expect that the majority of the positional information is about the relative positional embedding between S1 and S2 (such pointer arithmetic behavior has already been observed in Olsson et al.
364
+
365
+ Figure 14: Logit difference after patching S-Inhibition heads from signal-specific datasets. The effect on logit difference can be decomposed as a sum of the effects of position and token signal.
366
+
367
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Original positional signal</td><td rowspan=1 colspan=1>Inverted position signal</td></tr><tr><td rowspan=1 colspan=1>Original S token signal</td><td rowspan=1 colspan=1>3.55 (baseline)</td><td rowspan=1 colspan=1>-0.99</td></tr><tr><td rowspan=1 colspan=1>Random S token signal</td><td rowspan=1 colspan=1>2.45</td><td rowspan=1 colspan=1>-1.96</td></tr><tr><td rowspan=1 colspan=1>S←→IO inverted token signal</td><td rowspan=1 colspan=1>1.77</td><td rowspan=1 colspan=1>-3.16</td></tr></table>
368
+
369
+ ![](images/863fc629234613493d8bb543d42b12c8706a6477c4d2bcdf3f8942190f91d363.jpg)
370
+ Figure 15: Name Mover Heads’ attention probability before and after patching S-Inhibition Heads from signal-specific datasets. Left: patching from the dataset generated by random flip of name (same position signal, random token signal). Right: patching from the dataset generated by $\mathrm { I O } { } \mathrm { S } 2$ replacement (inverted position signal, inverted token signal). Black bars represent the standard deviation.
371
+
372
+ (2022)). When patching in S2 Inhibition outputs from a distribution where prefixes to sentences are longer (but the distance between S1 and S2 is constant), the logit difference doesn’t change (3.56 before patching vs 3.57 after). This suggests that the positional signal doesn’t depend on the absolute position of the tokens, as long as the relative position of S1 and S2 stays the same.
373
+
374
+ # H LAYER NORM AND THE RESIDUAL STREAM
375
+
376
+ The attention heads and MLPs in GPT-2 small write into the residual stream. Suppose $x _ { 1 2 }$ is the final state of the residual stream after the 12 layers. This is then converted into logits via $W _ { U } \circ$ $M \circ \mathrm { L N } ( x _ { 1 2 } )$ , where LN is defined in Appendix E, $M$ is the linear transformation of the layer norm operation and $W _ { U }$ is the unembedding matrix.
377
+
378
+ In order to attribute the extent to which an attention head $h$ writes in a direction $W _ { U } [ T ]$ where $T$ is a token (always IO or S in our case), we can’t simply compute $\langle M \circ \mathbf { L N } \circ h _ { i , j } ( X ) , \dot { W _ { U } } [ T ] \rangle$ , as the scaling factor that’s used is $\sqrt { \textstyle \sum _ { i } ( x _ { 1 2 , i } - \overline { { x _ { 1 2 , i } } } ) ^ { 2 } }$ . Therefore $\overline { { \mathrm { L N } } }$ in the main text uses this scaling factor:
379
+
380
+ $$
381
+ \overline { { \mathrm { L N } } } ( h ) \ { \stackrel { \mathrm { d e f } } { = } } \ M \circ \frac { h - \overline { { h } } } { \sqrt { \sum _ { i } ( x _ { 1 2 , i } - \overline { { x _ { 1 2 , i } } } ) ^ { 2 } } }
382
+ $$
383
+
384
+ # I ROLE OF MLPS IN THE TASK
385
+
386
+ In the main text, we focused our investigation on attention heads. Since they are the only module able of moving information across token position – a crucial component of the IOI task – they were our main subject of interest. However, MLP can still play a significant role in structuring the residual stream at a given position. We explored this possibility by performing knock-out of the MLP layers (Figure 16). We observe that MLP0 has a significant influence on logit difference after knock-out $( - \bar { 1 } 0 0 \%$ relative variation) but the other layers don’t seem to play a big role. We hypothesize that MLP0 can be used to perform low level token processing that latter layers rely on.
387
+
388
+ Moreover, we also investigated the writing of MLP along the $W _ { U } [ I O ] - W _ { U } [ S ]$ direction. As shown in Figure 16 (bottom) they write negligibly in this direction compared to attention heads (Figure 3).
389
+
390
+ <table><tr><td rowspan=1 colspan=1>U</td><td rowspan=1 colspan=1>Class</td><td rowspan=1 colspan=1>KU{u}</td><td rowspan=1 colspan=1>F(C\(KU{u)</td><td rowspan=1 colspan=1>F(C\K)</td></tr><tr><td rowspan=1 colspan=1>(9,9)</td><td rowspan=1 colspan=1>Name Mover</td><td rowspan=1 colspan=1>[(9,9)]</td><td rowspan=1 colspan=1>2.78</td><td rowspan=1 colspan=1>3.14</td></tr><tr><td rowspan=1 colspan=1>(10,0)</td><td rowspan=1 colspan=1>Name Mover</td><td rowspan=1 colspan=1>[(9,9), (10,0)]</td><td rowspan=1 colspan=1>2.43</td><td rowspan=1 colspan=1>2.78</td></tr><tr><td rowspan=1 colspan=1>(9,6</td><td rowspan=1 colspan=1>Name Mover</td><td rowspan=1 colspan=1>[(9,9),(10,0),(9,6)]</td><td rowspan=1 colspan=1>2.77</td><td rowspan=1 colspan=1>2.43</td></tr><tr><td rowspan=1 colspan=1>(10,7)</td><td rowspan=1 colspan=1>Negative Name Mover</td><td rowspan=1 colspan=1>All Negative Name Mover Heads</td><td rowspan=1 colspan=1>5.11</td><td rowspan=1 colspan=1>3.84</td></tr><tr><td rowspan=1 colspan=1>(11,10)</td><td rowspan=1 colspan=1>Negative Name Mover</td><td rowspan=1 colspan=1>All Negative Name Mover Heads</td><td rowspan=1 colspan=1>5.11</td><td rowspan=1 colspan=1>4.06</td></tr><tr><td rowspan=1 colspan=1>(7,3)</td><td rowspan=1 colspan=1>S-Inhibition</td><td rowspan=1 colspan=1>All S-Inhibition Heads</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>1.15</td></tr><tr><td rowspan=1 colspan=1>(7,9)</td><td rowspan=1 colspan=1>S-Inhibition</td><td rowspan=1 colspan=1>All S-Inhibition Heads</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>1.12</td></tr><tr><td rowspan=1 colspan=1>(8,6)</td><td rowspan=1 colspan=1>S-Inhibition</td><td rowspan=1 colspan=1>All S-Inhibition Heads</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>1.10</td></tr><tr><td rowspan=1 colspan=1>(8,10)</td><td rowspan=1 colspan=1>S-Inhibition</td><td rowspan=1 colspan=1>All S-InhibitionHeads</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>0.55</td></tr><tr><td rowspan=1 colspan=1>(5,5)</td><td rowspan=1 colspan=1>Induction</td><td rowspan=1 colspan=1>Induction Headsand NegativeHeads</td><td rowspan=1 colspan=1>1.06</td><td rowspan=1 colspan=1>3.95</td></tr><tr><td rowspan=1 colspan=1>(5,8)</td><td rowspan=1 colspan=1>Induction</td><td rowspan=1 colspan=1>All Induction Heads</td><td rowspan=1 colspan=1>1.06</td><td rowspan=1 colspan=1>2.58</td></tr><tr><td rowspan=1 colspan=1>(5,9)</td><td rowspan=1 colspan=1>Induction</td><td rowspan=1 colspan=1>All Induction Heads</td><td rowspan=1 colspan=1>4.40</td><td rowspan=1 colspan=1>5.11</td></tr><tr><td rowspan=1 colspan=1>(6,9)</td><td rowspan=1 colspan=1>Induction</td><td rowspan=1 colspan=1>Induction Heads and Negative Heads</td><td rowspan=1 colspan=1>4.76</td><td rowspan=1 colspan=1>5.11</td></tr><tr><td rowspan=1 colspan=1>(0,1)</td><td rowspan=1 colspan=1>Duplicate Token</td><td rowspan=1 colspan=1>All Duplicate Token Heads</td><td rowspan=1 colspan=1>1.14</td><td rowspan=1 colspan=1>2.52</td></tr><tr><td rowspan=1 colspan=1>(0,10)</td><td rowspan=1 colspan=1>Duplicate Token</td><td rowspan=1 colspan=1>AllDuplicate Token Heads</td><td rowspan=1 colspan=1>1.14</td><td rowspan=1 colspan=1>2.29</td></tr><tr><td rowspan=1 colspan=1>(3,0</td><td rowspan=1 colspan=1>Duplicate Token</td><td rowspan=1 colspan=1>All Duplicate Token Heads</td><td rowspan=1 colspan=1>1.14</td><td rowspan=1 colspan=1>1.65</td></tr><tr><td rowspan=1 colspan=1>(2,2)</td><td rowspan=1 colspan=1>Previous Token</td><td rowspan=1 colspan=1>All Previous Token Heads</td><td rowspan=1 colspan=1>2.03</td><td rowspan=1 colspan=1>2.80</td></tr><tr><td rowspan=1 colspan=1>(2,9)</td><td rowspan=1 colspan=1>Previous Token</td><td rowspan=1 colspan=1>All Previous Token Heads</td><td rowspan=1 colspan=1>2.03</td><td rowspan=1 colspan=1>2.42</td></tr><tr><td rowspan=1 colspan=1>(4, 11)</td><td rowspan=1 colspan=1>Previous Token</td><td rowspan=1 colspan=1>All Previous Token Heads</td><td rowspan=1 colspan=1>2.03</td><td rowspan=1 colspan=1>2.27</td></tr><tr><td rowspan=1 colspan=1>(10,10)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>2.40</td><td rowspan=1 colspan=1>2.63</td></tr><tr><td rowspan=1 colspan=1>(10,2)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>1.09</td></tr><tr><td rowspan=1 colspan=1>(11,2)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>0.72</td><td rowspan=1 colspan=1>0.89</td></tr><tr><td rowspan=1 colspan=1>(10,6)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>2.63</td><td rowspan=1 colspan=1>2.77</td></tr><tr><td rowspan=1 colspan=1>(10,1)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>1.34</td><td rowspan=1 colspan=1>1.47</td></tr><tr><td rowspan=1 colspan=1>(9,7)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>0.85</td><td rowspan=1 colspan=1>1.02</td></tr><tr><td rowspan=1 colspan=1>(11,9)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>All NMs and previous Backup NMs</td><td rowspan=1 colspan=1>1.02</td><td rowspan=1 colspan=1>1.13</td></tr><tr><td rowspan=1 colspan=1>(11,3)</td><td rowspan=1 colspan=1>Backup Name Mover</td><td rowspan=1 colspan=1>[(9,9),(10,0),(9,6),(10,10),(11,3)]</td><td rowspan=1 colspan=1>2.53</td><td rowspan=1 colspan=1>2.59</td></tr></table>
391
+
392
+ ![](images/52eaaaf6782beb48097fcb2de051c9ce32a0ff353f73138bb16d8d6b84c55907.jpg)
393
+ Figure 17: $K$ sets for minimality for each $v$
394
+ Figure 16: Top: Relative variation in logit difference from knocking out MLP layers. Only MLP0 causes a significative decrease in logit difference after knock-out. Bottom: We measure how much MLPs write along the $W _ { U } [ I O ] - W _ { U } [ S ]$ direction.
395
+
396
+ # J MINIMALITY SETS
397
+
398
+ The sets that were found for the minimality tests are listed in Table 17.
399
+
400
+ Figure 18: 4 sets $K$ found by the greedy optimization procedure on our circuit.
401
+
402
+ <table><tr><td rowspan=1 colspan=1>K found by greedy optimization</td></tr><tr><td rowspan=1 colspan=1>(9,9),(9,6), (5,8), (5,5), (2,2), (2,9)</td></tr><tr><td rowspan=1 colspan=1>(9,9),(11,10),(10,7),(8,6),(5,8),(4,11)</td></tr><tr><td rowspan=1 colspan=1>(10,7), (5,5), (2,2), (4,11)</td></tr><tr><td rowspan=1 colspan=1>(9,9),(11,10),(10,7),(11,2),(3,0),,(5,8),(2,2)</td></tr></table>
403
+
404
+ # K GREEDY ALGORITHM
405
+
406
+ The Algorithm 2 describes the procedure used to sample sets for checking the completeness criteria using greedy optimization. In practice, because the na¨ıve and the full circuit are not of the same size, we chose respectively $k = 5$ and $k = 1 0$ to ensure a similar amount of stochasticity in the process. We run the procedure 10 times and kept the 5 sets with the maximal important incompleteness score (including the intermediate $K$ ).
407
+
408
+ Algorithm 2 The greedy sampling procedure for sets to validate the completeness citeria.
409
+
410
+ 1: $K \gets \emptyset$
411
+ 2: for $i$ to $N$ do
412
+ 3: Sample a random subset $V \subseteq C$ of $k$ nodes uniformly.
413
+ 4: $\begin{array} { r } { \widehat { v _ { \mathrm { M A X } } } \arg \operatorname* { m a x } _ { \boldsymbol { v } \in V } | \mathrm { F } ( C \setminus ( K \cup \{ \boldsymbol { v } \} ) ) - \mathrm { F } ( C \setminus \dot { K } ) | } \end{array}$
414
+ 5: $K \gets K \cup \{ v _ { \mathrm { M A X } } \}$
415
+ 6: end for
416
+ 7: return $K$
417
+
418
+ As visible in Table 18 the sets found by the greedy search contains a combination of nodes from different class. Nonetheless, the overlap between different $K$ suggest that we are missing components from $M$ that can take the place of induction heads or S-inhibition Heads when some Name Mover Heads are knocked-out.
419
+
420
+ # L TECHNIQUES OVERVIEW
421
+
422
+ This work involved a variety of techniques that were required to explain model behavior.
423
+
424
+ # • Knockouts:
425
+
426
+ We used knockouts in two different ways: knocking out singular components of models, and knocking out everything in the model except particular circuits. The former was somewhat useful, and the latter we found powerful.
427
+
428
+ – Knockout of single components: as an attribution method, knocking out singular components was not always as powerful as techniques such as projections, since the compensation (or backup) nature of Backup Name Mover Heads in this task allowed components to be knocked out and their true effect size masked. Knockouts of all components except a circuit: on the other hand, knocking out all components except a circuit enabled us to isolate behaviors in this task where behavior was sparse, and check the components of our circuit while ignoring the vast percentage of components of the network, making work manageable.
429
+
430
+ What was very important for the success of knockout and patching experiments was the choice of reference distribution for knockout. The analysis in Appendix G shows how the specific choice of dataset is useful for understanding model components. For a more general knockout, the OpenWebText dataset, GPT’s training data, can be used. However, we found that this led to noisier results (though our circuit components still were shown to be important when we used this ablation).
431
+
432
+ # • Attention pattern analysis:
433
+
434
+ Using attention patterns to explain behavior is always worrying due to the possibility that information has accumulated on that token primarily from previous tokens, or that the position with large attention paid to isn’t actually writing an important value into the residual stream. In our work however, analyzing attention patterns was generally a necessary first step before further experiments could be ran, and in this small model, both of the worrying cases did not generally arise.
435
+
436
+ # • Patching:
437
+
438
+ Patching was an important method we used to verify causal explanations that were generally formed from correlational evidence. In this way our use case is similar to Finlayson et al. (2021). We were surprised however that in general patching gave clear signal on the changes in behavior. This may be because we generally patched from inputs like the ABC distribution (which was successful in knocking out too). Therefore, keeping the context of the sentence templates may be generally useful. This could be either because the other words in the templates allow the model to realise that it should be doing IOI, or that introducing inputs from other distributions introduces noise that the model picks up on and uses, when this is not intended.
md/dev/OjDkC57x5sz/OjDkC57x5sz.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BLURRING DIFFUSION MODELS
2
+
3
+ Emiel Hoogeboom Google Research, Brain Team, Amsterdam, Netherlands
4
+
5
+ Tim Salimans Google Research, Brain Team, Amsterdam, Netherlands
6
+
7
+ # ABSTRACT
8
+
9
+ Recently, Rissanen et al. (2022) have presented a new type of diffusion process for generative modeling based on heat dissipation, or blurring, as an alternative to isotropic Gaussian diffusion. Here, we show that blurring can equivalently be defined through a Gaussian diffusion process with non-isotropic noise. In making this connection, we bridge the gap between inverse heat dissipation and denoising diffusion, and we shed light on the inductive bias that results from this modeling choice. Finally, we propose a generalized class of diffusion models that offers the best of both standard Gaussian denoising diffusion and inverse heat dissipation, which we call Blurring Diffusion Models.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Diffusion models are becoming increasingly successful for image generation, audio synthesis and video generation. Diffusion models define a (stochastic) process that destroys a signal such as an image. In general, this process adds Gaussian noise to each dimension independently. However, data such as images clearly exhibit multi-scale properties which such a diffusion process ignores.
14
+
15
+ Recently, the community is looking at new destruction processes which are referred to as deterministic or ‘cold’ diffusion (Rissanen et al., 2022; Bansal et al., 2022). In these works, the diffusion process is either deterministic or close to deterministic. For example, in (Rissanen et al., 2022) a diffusion model that incorporates heat dissipation is proposed, which can be seen as a form of blurring. Blurring is a natural destruction for images, because it retains low frequencies over higher frequencies.
16
+
17
+ However, there still exists a considerable gap between the visual quality of standard denoising diffusion models and these new deterministic diffusion models. This difference cannot be explained away by a limited computational budget: A standard diffusion model can be trained with relative little compute (about one to four GPUs) with high visual quality on a task such as unconditional CIFAR10 generation1. In contrast, the visual quality of deterministic diffusion models have been much worse so far. In addition, fundamental questions remain around the justification of deterministic diffusion models: Does their specification offer any guarantees about being able to model the data distribution?
18
+
19
+ ![](images/586f27d2b5622e20f297d5e1add944d736c0b7ea9aaca5677d179de41d5e4e59.jpg)
20
+ Figure 1: Comparison between standard diffusion, heat dissipation and blurring diffusion.
21
+
22
+ In this work, we aim to resolve the gap in quality between models using blurring and additive noise. We present Blurring Diffusion Models, which combine blurring (or heat dissipation) and additive Gaussian noise. We show that the given process can have Markov transitions and that the denoising process can be written with diagonal covariance in frequency space. As a result, we can use modern techniques from denoising diffusion. Our model generates samples with higher visual quality, which is evidenced by better FID scores.
23
+
24
+ # 2 BACKGROUND
25
+
26
+ # 2.1 DIFFUSION MODELS
27
+
28
+ Diffusion models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020) learn to generate data by denoising a pre-defined destruction process which is named the diffusion process. Commonly, the diffusion process starts with a datapoint and gradually adds Gaussian noise to the datapoint. Before defining the generative process, this diffusion process needs to be defined. Following the definition of (Kingma et al., 2021) the diffusion process can be written as:
29
+
30
+ $$
31
+ q ( z _ { t } | \pmb { x } ) = \mathcal { N } ( z _ { t } | \alpha _ { t } \pmb { x } , \sigma _ { t } ^ { 2 } \mathbf { I } ) ,
32
+ $$
33
+
34
+ where $_ { \textbf { \em x } }$ represents the data and ${ \boldsymbol { z } } _ { t }$ are the noisy latent variables. Since $\alpha _ { t }$ is monotonically decreasing and $\sigma _ { t }$ is monotonically increasing, the information from $_ { \textbf { \em x } }$ in ${ \boldsymbol { z } } _ { t }$ will be gradually destroyed as $t$ increases. Assuming that the above process defined by Equation 1 is Markov, it has transition distributions for ${ \boldsymbol { z } } _ { t }$ given $z _ { s }$ where $0 \leq s < t$ :
35
+
36
+ $$
37
+ q ( z _ { t } | \boldsymbol { z } _ { s } ) = \mathcal { N } ( z _ { t } | \alpha _ { t | s } \boldsymbol { z } _ { s } , \sigma _ { t | s } ^ { 2 } \mathbf { I } ) ,
38
+ $$
39
+
40
+ where $\alpha _ { t | s } = \alpha _ { t } / \alpha _ { s }$ and $\sigma _ { t | s } ^ { 2 } = \sigma _ { t } ^ { 2 } - \alpha _ { t | s } ^ { 2 } \sigma _ { s } ^ { 2 }$ . A convenient property is that the grid of timesteps can be defined arbitrarily and does not depend on the specific spacing of $s$ and $t$ . We let $T = 1$ denote the last diffusion step where $q ( z _ { T } | \bar { \mathbf { x } } ) \approx \mathcal { N } ( z _ { T } | \bar { \mathbf { 0 } , \mathbf { I } } )$ , a standard normal distribution. Unless otherwise specified, a time step lies in the unit interval $[ 0 , 1 ]$ .
41
+
42
+ The Denoising Process Another important distribution is the true denoising distribution $q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } , \boldsymbol { x } )$ given a datapoint $_ { \textbf { \em x } }$ . Using that $q ( z _ { s } | z _ { t } , \pmb { x } ) \propto q ( z _ { t } | z _ { s } ) q ( z _ { s } | \pmb { x } )$ one can derive that:
43
+
44
+ $$
45
+ q ( z _ { s } | z _ { t } , \pmb { x } ) = \mathcal { N } ( z _ { s } | \pmb { \mu } _ { t s } , \sigma _ { t s } ^ { 2 } \mathbf { I } ) ,
46
+ $$
47
+
48
+ where
49
+
50
+ $$
51
+ \sigma _ { t s } ^ { 2 } = ( \frac { 1 } { \sigma _ { s } ^ { 2 } } + \frac { \alpha _ { t | s } ^ { 2 } } { \sigma _ { t | s } ^ { 2 } } ) ^ { - 1 } \mathrm { ~ a n d ~ } \mu _ { t s } = \sigma _ { t s } ^ { 2 } ( \frac { \alpha _ { t | s } } { \sigma _ { t | s } ^ { 2 } } z _ { t } + \frac { \alpha _ { s } } { \sigma _ { s } ^ { 2 } } x )
52
+ $$
53
+
54
+ To generate data, the true denoising process is approximated by a learned denoising process $p ( z _ { s } | z _ { t } )$ , where the datapoint $_ { \textbf { \em x } }$ is replaced by a prediction from a learned model. The model distribution is then given by
55
+
56
+ $$
57
+ p ( z _ { s } | z _ { t } ) = q ( z _ { s } | z _ { t } , \hat { \pmb { x } } ( z _ { t } ) ) ,
58
+ $$
59
+
60
+ where $\hat { \pmb x } ( z _ { t } )$ is a prediction provided by a neural network. As shown by Song et al. (2020), the true $q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } ) \to q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } , \pmb { x } = \mathbb { E } [ \pmb { x } | \boldsymbol { z } _ { t } ] )$ as $s \to t$ , which justifies this choice of model: If the generative model takes sufficiently small steps, and if $\hat { \pmb x } ( z _ { t } )$ is sufficiently expressive, the model can learn the data distribution exactly.
61
+
62
+ Instead of directly predicting $_ { \textbf { \em x } }$ , diffusion models can also model $\hat { \mathbf { \epsilon } } _ { t } = f _ { \theta } ( z _ { t } , t )$ , where $f _ { \theta }$ is a neural net, so that:
63
+
64
+ $$
65
+ \hat { \pmb x } = z _ { t } / \alpha _ { t } - \sigma _ { t } / \alpha _ { t } \hat { \mathbf e } _ { t } ,
66
+ $$
67
+
68
+ which is inspired by the reparametrization to sample from Equation 1 which is ${ \pmb z } _ { t } = \alpha _ { t } { \pmb x } + \sigma _ { t } { \pmb \epsilon } _ { t }$ . This parametrization is called the epsilon parametrization and empirically leads to better sample quality than predicting $_ { \textbf { \em x } }$ directly (Ho et al., 2020).
69
+
70
+ Optimization As shown in (Kingma et al., 2021), a continuous-time variational lower bound on the model log likelihood $\log p ( x )$ is given by the following expectation over squared reconstruction errors:
71
+
72
+ $$
73
+ \mathcal { L } = \mathbb { E } _ { t \sim \mathcal { U } ( 0 , 1 ) } \mathbb { E } _ { \epsilon _ { t } \sim \mathcal { N } ( 0 , \mathbf { I } ) } [ w ( t ) | | f _ { \theta } ( z _ { t } , t ) - \epsilon _ { t } | | ^ { 2 } ] ,
74
+ $$
75
+
76
+ where ${ z } _ { t } = \alpha _ { t } \pmb { x } _ { t } + \sigma _ { t } \pmb { \epsilon } _ { t }$ . When these terms are weighted appropriately with a particular weight $w ( t )$ , this objective corresponds to a variational lowerbound on the model likelihood $\log p ( x )$ . However, empirically a constant weighting $w ( t ) = 1$ has been found to be superior for sample quality.
77
+
78
+ # 2.2 INVERSE HEAT DISSIPATION
79
+
80
+ Instead of adding increasing amounts of Gaussian noise, Inverse Heat Dissipation Models (IHDMs) use heat dissipation to destroy information (Rissanen et al., 2022). They observe that the Laplace partial differential equation for heat dissipation
81
+
82
+ $$
83
+ \frac { \partial } { \partial t } z ( i , j , t ) = \Delta z ( i , j , t )
84
+ $$
85
+
86
+ can be solved by a diagonal matrix in the frequency domain of the cosine transform if the signal is discretized to a grid. Letting ${ \boldsymbol { z } } _ { t }$ denote the solution to the Laplace equation at time-step $t$ , this can be efficiently computed by:
87
+
88
+ $$
89
+ \begin{array} { r } { z _ { t } = \mathbf { A } _ { t } \pmb { z } _ { 0 } = \mathbf { V } \mathbf { D } _ { t } \mathbf { V } ^ { \mathrm { T } } z _ { 0 } } \end{array}
90
+ $$
91
+
92
+ where $\mathbf { V } ^ { \mathrm { T } }$ denotes a Discrete Cosine Transform (DCT) and $\mathbf { V }$ denotes the Inverse DCT and $z _ { 0 } , z _ { t }$ should be considered vectorized over spatial dimensions to allow for matrix multiplication. The diagonal matrix $\mathbf { D } _ { t }$ is the exponent of a weighting matrix for frequencies $\pmb { \Lambda }$ and the dissipation time $t$ so that $\mathbf { D } _ { t } = \exp ( - \mathbf { \Lambda } \mathbf { \Lambda } t )$ . For the specific definition of $\pmb { \Lambda }$ see Appendix A. In (Rissanen et al., 2022) marginal distribution of the diffusion process is defined as:
93
+
94
+ $$
95
+ q ( z _ { t } | \boldsymbol { x } ) = \mathcal { N } ( z _ { t } | \mathbf { A } _ { t } \boldsymbol { x } , \sigma ^ { 2 } \mathbf { I } ) .
96
+ $$
97
+
98
+ The intermediate diffusion state ${ \boldsymbol { z } } _ { t }$ is thus constructed by adding a fixed amount of noise to an increasingly blurred data point, rather than adding an increasing amount of noise as in the DDPMs described in Section 2.1. The generative process in (Rissanen et al., 2022) approximately inverts the heat dissipation process with a learned generative model:
99
+
100
+ $$
101
+ p ( z _ { t - 1 } | z _ { t } ) = \mathcal { N } ( z _ { t - 1 } | f _ { \theta } ( z _ { t } ) , \delta ^ { 2 } \mathbf { I } ) ,
102
+ $$
103
+
104
+ where the mean for $z _ { t - 1 }$ is directly learned with a neural network $f _ { \theta }$ and has fixed scalar variance $\delta ^ { 2 }$ . Similar to DDPMs, the IHDM model is learned by sampling from the forward process $z _ { t } \sim q ( z _ { t } | \mathbf { x } )$ for a random timestep $t$ , and then minimizing the squared reconstruction error between the model $f _ { \theta } ( z _ { t } )$ and a ground truth target, which in this case is given by $\mathbb { E } ( z _ { t - 1 } | \pmb { x } ) = \mathbf { A } _ { t - 1 } \pmb { x }$ , yielding the training loss $\mathcal { L } = \mathbb { E } _ { t \sim \mathcal { U } ( 1 , \dots , T ) } \mathbb { E } _ { z _ { t } \sim q ( z _ { t } \mid x ) } \left[ | | \mathbf { A } _ { t - 1 } x - f _ { \theta } ( z _ { t } , t ) | | ^ { 2 } \right]$ .
105
+
106
+ Arbitrary Dissipation Schedule There is no reason why the conceptual time-steps of the model should match perfectly with the dissipation time. Therefore, in (Rissanen et al., 2022) $\begin{array} { r l } { \mathbf { D } _ { t } } & { { } = } \end{array}$ $\exp ( - \pmb { \Lambda } \tau _ { t } )$ is redefined where $\tau _ { t }$ monotonically increases with $t$ . The variable $\tau _ { t }$ has a very similar function as $\alpha _ { t }$ and $\sigma _ { t }$ in noise diffusion: it allows for arbitrary dissipation schedules with respect to the conceptual time-steps $t$ of the model.
107
+
108
+ To avoid confusion, note that in (Rissanen et al., 2022) $k$ is used as the conceptual time for the diffusion process, $t _ { k }$ is the dissipation time and $\mathbf { \Delta } \mathbf { u } _ { k }$ denotes the latent variables. In this paper, $t$ is the conceptual time and ${ \boldsymbol { z } } _ { t }$ denotes the latent variables in pixel space. Then $\tau _ { t }$ is used to denote dissipation time.
109
+
110
+ Open Questions Certain questions remain: (1) Can the heat dissipation process be Markov and if so what is $q ( z _ { t } | z _ { s } ) \}$ (2) Is the true inverse heating process also isotropic, as the generative process in Equation 11? (3) Finally, are there alternatives to predicting the mean of the previous time-step?
111
+
112
+ In the following section it will turn out that: (1) Yes, the process can be Markov. As a result, denoising equations similar to the ones for standard diffusion can be derived. (2) No, the generative process is not isotropic, although it is diagonal in the frequency domain. As a consequence, the correct amount of noise (per-dimension) can be derived analytically instead of choosing it heuristically. This also guarantees that the model $p ( z _ { s } | z _ { t } )$ can actually express the true $q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } )$ as $s \to t$ , because it is known to tend towards $q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } , \boldsymbol { x } = \mathbb { E } [ \boldsymbol { x } | \boldsymbol { z } _ { t } ] )$ (Song et al., 2020). (3) Yes, processes like heat dissipation can be parametrized similar to the epsilon parametrization in standard diffusion models.
113
+
114
+ # 3 HEAT DISSIPATION AS GAUSSIAN DIFFUSION
115
+
116
+ Here we reinterpret the heat dissipation process as a form of Gaussian diffusion similar to that used in (Ho et al., 2020; Sohl-Dickstein et al., 2015; Song & Ermon, 2019) and others. Throughout this paper, multiplication and division between two vectors is defined to be elementwise. We start with the definition of the marginal distribution from (Rissanen et al., 2022):
117
+
118
+ $$
119
+ q ( z _ { t } | \boldsymbol { x } ) = \mathcal { N } ( z _ { t } | \mathbf { A } _ { t } \boldsymbol { x } , \sigma ^ { 2 } \mathbf { I } )
120
+ $$
121
+
122
+ where ${ \bf A } _ { t } = { \bf V } { \bf D } _ { t } { \bf V } ^ { \mathrm { T } }$ denotes the blurring or dissipation operation as defined in the previous section. Throughout this section we let $\mathbf { V } ^ { \mathrm { T } }$ denote the orthogonal DCT, which is a specific normalization setting of the DCT. Under the change of variables $\bar { \mathbf { \ b { u } } } _ { t } = \mathbf { \ b { V } } ^ { \mathrm { T } } \boldsymbol { \mathbf { \tilde { z } } } _ { t }$ we can write the diffusion process in frequency space for $\mathbf { \pmb { u } } _ { t }$ :
123
+
124
+ $$
125
+ q ( { \pmb u } _ { t } | { \pmb u } _ { x } ) = \mathcal { N } ( { \pmb u } _ { t } | { \pmb d } _ { t } \cdot { \pmb u } _ { x } , \sigma ^ { 2 } { \bf I } )
126
+ $$
127
+
128
+ where ${ \pmb u } _ { x } = { \bf V } ^ { \mathrm { T } } { \pmb x }$ is the frequency response of $_ { \textbf { \em x } }$ , $\mathbf { } d _ { t }$ is the diagonal of $\mathbf { D } _ { t }$ and vector multiplication is done elementwise. Whereas we defined $\mathbf { D } _ { t } = \exp ( - \mathbf { \Delta } \mathbf { \Lambda } \tau _ { t } )$ we let $\lambda$ denote the diagonal of $\pmb { \Lambda }$ so that $\pmb { d } _ { t } = \exp ( - \lambda \tau _ { t } )$ . Essentially, $\mathbf { } d _ { t }$ multiplies higher frequencies with smaller values.
129
+
130
+ Equation 13 shows that the marginal distribution of the frequencies $\mathbf { \Delta } \mathbf { u } _ { t }$ is fully factorized over its scalar elements $u _ { t } ^ { ( i ) }$ for each dimension $i$ . Similarly, the inverse heat dissipation model $p _ { \theta } ( \pmb { u } _ { s } | \pmb { u } _ { t } )$ is also fully factorized. We can thus equivalently describe the heat dissipation process (and its inverse) in scalar form for each dimension $i$ :
131
+
132
+ $$
133
+ \begin{array} { r } { q ( u _ { t } ^ { ( i ) } | u _ { 0 } ^ { ( i ) } ) = \mathcal { N } ( u _ { t } ^ { ( i ) } | d _ { t } ^ { ( i ) } u _ { 0 } ^ { ( i ) } , \sigma ^ { 2 } ) \quad \Leftrightarrow \quad u _ { t } ^ { ( i ) } = d _ { t } ^ { ( i ) } u _ { 0 } ^ { ( i ) } + \sigma \epsilon _ { t } , \mathrm { ~ w i t h ~ } \epsilon _ { t } \sim \mathcal { N } ( 0 , 1 ) . } \end{array}
134
+ $$
135
+
136
+ This equation can be recognized as a special case of the standard Gaussian diffusion process introduced in Section 2.1. Let $s _ { t }$ denote a standard diffusion process in frequency space, so $s _ { t } ^ { ( i ) } = \alpha _ { t } u _ { 0 } ^ { ( i ) } + \sigma _ { t } \epsilon _ { t }$ . We can see that Rissanen et al. (2022) have chosen $\alpha _ { t } = \bar { d } _ { t } ^ { ( i ) }$ and $\sigma _ { t } ^ { 2 } = \sigma ^ { 2 }$ . As shown by Kingma et al. (2021), from a probabilistic perspective only the ratio $\alpha _ { t } / \sigma _ { t }$ matters here, not the particular choice of the individual $\alpha _ { t } , \sigma _ { t }$ . This is true because all values can simply be re-scaled without changing the distributions in a meaningful way.
137
+
138
+ This means that, rather than performing blurring and adding fixed noise, the heat dissipation process can be equivalently defined as a relatively standard Gaussian diffusion process, albeit in frequency space. The non-standard aspect here is that the diffusion process in (Rissanen et al., 2022) is defined in the frequency space $\textbf { \em u }$ , and that it uses a separate noise schedule $\alpha _ { t } , \sigma _ { t }$ for each of the scalar elements of $\textbf { \em u }$ : i.e. the noise in this process is non-isotropic. That the marginal variance $\sigma ^ { 2 }$ is shared between all scalars $u ^ { ( i ) }$ under their specification does not reduce its generality: the ratio $\alpha _ { t } / \sigma$ can be freely determined per dimension, and this is all that matters.
139
+
140
+ Markov transition distributions An open question in the formulation of heat dissipation models by Rissanen et al. (2022) was whether or not there exists a Markov process $q ( { \pmb u } _ { t } | { \pmb u } _ { s } )$ that corresponds to their chosen marginal distribution $q ( \boldsymbol { z } _ { t } | \boldsymbol { x } )$ . Through its equivalence to Gaussian diffusion shown above, we can now answer this question affirmatively. Using the results summarized in Section 2.1, we have that this process is given by
141
+
142
+ $$
143
+ q ( \pmb { u } _ { t } | \pmb { u } _ { s } ) = \mathcal { N } ( \pmb { u } | \pmb { \alpha } _ { t | s } \pmb { u } _ { s } , \pmb { \sigma } _ { t | s } ^ { 2 } )
144
+ $$
145
+
146
+ where ${ \alpha _ { t } } _ { | s } = { \alpha _ { t } } / { \alpha _ { s } }$ and $\pmb { \sigma } _ { t | s } ^ { 2 } = \pmb { \sigma } _ { t } ^ { 2 } - \pmb { \alpha } _ { t | s } ^ { 2 } \pmb { \sigma } _ { s } ^ { 2 }$ . Substituting in the choices of Rissanen et al. (2022), αt = dt and σ(i)t $\sigma _ { t } ^ { ( i ) } = \sigma$ , then gives
147
+
148
+ $$
149
+ \alpha _ { t | s } = d _ { t } / d _ { s } { \mathrm { a n d } } \sigma _ { t | s } ^ { 2 } = ( 1 - ( d _ { t } / d _ { s } ) ^ { 2 } ) \sigma ^ { 2 } .
150
+ $$
151
+
152
+ Note that if $\mathbf { } d _ { t }$ is chosen so that it contains lower values for higher frequencies, then $\sigma _ { t \mid s }$ will add more noise on the higher frequencies per timestep. The heat dissipation model thus destroys information more quickly for those frequencies as compared to standard diffusion.
153
+
154
+ $$
155
+ \begin{array} { r l } { \bigoplus _ { \omega \atop \omega \atop \omega _ { 1 } , \ldots } ^ { - \cdots - \cdots - \omega _ { - 1 } ^ { q ( \omega _ { i } | x ) } } \cdots \overbrace { \bigodot _ { \omega \atop \omega _ { 1 } , \ldots , - \infty } \omega } ^ { \mathrm { * } } \overbrace { \mathscr { E } _ { \omega } ^ { ( z _ { i } ) } } ^ { \mathrm { * } } } & { \cdots \quad \textcircled { z } } \\ { \overbrace { \mathscr { Q } _ { \omega } ^ { \cdots - \cdots - \cdots - \cdots - \cdots - \cdots } \underbrace { \cdots \int _ { \omega } ^ { q } | x | } _ { \cdots \underbrace { \langle \omega _ { \omega } ^ { \prime } | \omega _ { 1 } \rangle } _ { \cdots \underbrace { - \cdots - \cdots - \cdots - \cdots - \varphi } _ { \omega ( \omega _ { i } | x ) } } } ^ { \mathrm { * } \mathrm { * } } } } & { \cdots \quad \textcircled { w } } \end{array}
156
+ $$
157
+
158
+ Figure 2: A blurring diffusion process with latent variable $z _ { 0 } , \ldots , z _ { 1 }$ is diagonal (meaning can be factorized over dimensions) in frequency space, under the change of variable ${ \mathbf { } } { \mathbf { } } { \mathbf { } } _ { t } = { \mathbf { } } { \mathbf { V } } ^ { \mathrm { T } } \bar { \mathbf { } } _ { t }$ . This results in a corresponding diffusion process in frequency space $\pmb { u } _ { 0 } , \ldots , \pmb { u } _ { 1 }$ .
159
+
160
+ Denoising Process Using again the results from Section 2.1, we can find an analytic expression for the inverse heat dissipation process:
161
+
162
+ $$
163
+ q ( \pmb { u } _ { s } | \pmb { u } _ { t } , \pmb { x } ) = \mathcal { N } ( \pmb { u } _ { s } | \pmb { \mu } _ { t s } , \pmb { \sigma } _ { t s } ^ { 2 } ) ,
164
+ $$
165
+
166
+ where
167
+
168
+ $$
169
+ \pmb { \sigma } _ { t s } ^ { 2 } = ( \frac { 1 } { \pmb { \sigma } _ { s } ^ { 2 } } + \frac { \pmb { \alpha } _ { t \vert s } ^ { 2 } } { \pmb { \sigma } _ { t \vert s } ^ { 2 } } ) ^ { - 1 } \mathrm { ~ a n d ~ } \mu _ { t s } = \pmb { \sigma } _ { t s } ^ { 2 } ( \frac { \pmb { \alpha } _ { t \vert s } } { \pmb { \sigma } _ { t \vert s } ^ { 2 } } u _ { t } + \frac { \pmb { \alpha } _ { s } } { \pmb { \sigma } _ { s } ^ { 2 } } u _ { x } ) .
170
+ $$
171
+
172
+ Except for $\mathbf { \Delta } \mathbf { u } _ { x }$ , we can again plug in the expressions derived above in terms of $d _ { t } , \sigma ^ { 2 }$ . The analysis in Section 2.1 then allows predicting $\epsilon _ { t }$ using a neural network to complete the model, as is done in standard denoising diffusion models. In comparison (Rissanen et al., 2022) predict $\pmb { \mu } _ { t s }$ directly, which is theoretically equally general but has been found to lead to inferior sample quality. Furthermore, they instead chose to use a single scalar value for $\sigma _ { t s } ^ { 2 }$ for all time-steps: the downside of this is that it loses the guarantee of correctness as $s \to t$ as described in Section 2.1.
173
+
174
+ # 4 BLURRING DIFFUSION MODELS
175
+
176
+ In this section we propose Blurring Diffusion Models. Using the analysis from Section 3, we can define this model in frequency space as a Gaussian diffusion model, with different schedules for the dimensions. Blurring diffusion places more on emphasis low frequencies which are visually more important, and it may also avoid over-fitting to high frequencies. It is important how the model is parametrized and what the specific schedules for $\pmb { \alpha } _ { t }$ and $\sigma _ { t }$ are. Different from traditional models, the diffusion process is defined in a frequency space:
177
+
178
+ $$
179
+ q ( { \pmb u } _ { t } | { \pmb u } _ { x } ) = \mathcal { N } ( { \pmb u } _ { t } | { \pmb \alpha } _ { t } { \pmb u } _ { x } , { \pmb \sigma } _ { t } ^ { 2 } { \bf I } )
180
+ $$
181
+
182
+ and different frequencies may diffuse at a different rate, which is controlled by the values in the vectors $\alpha _ { t } , \sigma _ { t }$ (although we will end up picking the same scalar value for all dimensions in $\sigma _ { t }$ ). Recall that the denoising distribution is then given by $q ( \mathbf { \mathscr { u } } _ { s } | \mathbf { \mathscr { u } } _ { t } , \pmb { x } ) = \mathcal { N } ( \mathbf { \mathscr { u } } _ { s } | \pmb { \mu } _ { t s } , \pmb { \sigma } _ { t s } ^ { 2 } )$ as specified in Equation 17.
183
+
184
+ Learning and Parametrization An important reason for the performance of modern diffusion models is the parametrization. Learning $\pmb { \mu } _ { t s }$ directly turns out to be difficult for neural networks and instead an approximation for $_ { \textbf { \em x } }$ is learned which is plugged into the denoising distributions, often indirectly via an epsilon parametrization (Ho et al., 2020). Studying the re-parametrization of Equation 19:
185
+
186
+ $$
187
+ \begin{array} { r } { \boldsymbol { u } _ { t } = \alpha _ { t } \boldsymbol { u } _ { x } + \sigma _ { t } \boldsymbol { u } _ { \epsilon , t } \quad \mathrm { w h e r e } \quad \boldsymbol { u } _ { x } = \mathbf { V } ^ { \mathrm { T } } \boldsymbol { x } \mathrm { ~ a n d ~ } \boldsymbol { u } _ { \epsilon , t } = \mathbf { V } ^ { \mathrm { T } } \boldsymbol { \epsilon } _ { t } } \end{array}
188
+ $$
189
+
190
+ and take that as inspiration for the way we parametrize our model:
191
+
192
+ $$
193
+ \begin{array} { r } { \bigg ( \pmb { u } _ { t } - \pmb { \sigma } _ { t } \hat { \pmb { u } } _ { \epsilon , t } \bigg ) / \pmb { \alpha } _ { t } = \hat { \pmb { u } } _ { x } , } \end{array}
194
+ $$
195
+
196
+ <table><tr><td>Algorithm1 Generating Samples</td></tr><tr><td>Sample zT ~ N(0,I) for tin{,..,} where s =t-1/T do</td></tr><tr><td></td></tr><tr><td>Ut = VTz and ue,t = VT fe(z,t)</td></tr><tr><td>Compute Ot→s and βt→s with Eq. 18,23</td></tr><tr><td>Sample ∈ ~ N(0,I)</td></tr><tr><td>z ←V(μt→s+Ot→s∈)</td></tr></table>
197
+
198
+ <table><tr><td>Algorithm 2 Optimizing Blurring Diffusion</td></tr><tr><td>Sample t ~ U(0,1)</td></tr><tr><td>Sample ∈~ N(0,I)</td></tr><tr><td>Minimize |l∈- fe(VαtVTx + Ot∈,t)ll²</td></tr></table>
199
+
200
+ which is the blurring diffusion counterpart of Equation 6 from standard diffusion models. Although it is convenient to express our diffusion and denoising processes in frequency space, neural networks have been optimized to work well in standard pixel space. It is for this reason that the neural network $f _ { \theta }$ takes as input $z _ { t } = \mathbf { V } u _ { t }$ and predicts $\hat { \boldsymbol { \epsilon } } _ { t }$ . After prediction we can always easily transition back and forth between frequency space if needed using the DCT matrix $\mathbf { V } ^ { \mathrm { T } }$ and inverse DCT matrix $\mathbf { V }$ . This is how $\hat { \mathbf { u } } _ { \epsilon , t } = \bar { \mathbf { V } } ^ { \mathrm { T } } \hat { \mathbf { \epsilon } } _ { t }$ is obtained. Using this parametrization for $\hat { \pmb x }$ and after transforming to frequency space $\hat { \pmb u } _ { x } = { \bf V } ^ { \mathrm { T } } \hat { \pmb x }$ we can compute $\hat { \mu } _ { t s }$ using Equation 18 where $\mathbf { \Delta } \mathbf { u } _ { x }$ is replaced by the prediction $\hat { \mathbf { u } } _ { x }$ to give:
201
+
202
+ $$
203
+ p ( \pmb { u } _ { s } | \pmb { u } _ { t } ) = q ( \pmb { u } _ { s } | \pmb { u } _ { t } , \hat { \pmb { u } } _ { x } ) = \mathcal { N } ( \pmb { u } _ { s } | \hat { \pmb { \mu } } _ { t s } , \pmb { \sigma } _ { t s } )
204
+ $$
205
+
206
+ for which $\hat { \mu } _ { t s }$ can be simplified further in terms of $\hat { \pmb u } _ { \epsilon , t }$ instead of $\hat { \mathbf { u } } _ { x }$ :
207
+
208
+ $$
209
+ \hat { \pmb { \mu } } _ { t s } = \pmb { \sigma } _ { t s } ^ { 2 } ( \frac { \alpha _ { t | s } } { \pmb { \sigma } _ { t | s } ^ { 2 } } \pmb { u } _ { t } + \frac { 1 } { \alpha _ { t | s } \pmb { \sigma } _ { s } ^ { 2 } } ( \pmb { u } _ { t } - \pmb { \sigma } _ { t } \hat { \pmb { u } } _ { \epsilon , t } ) ) .
210
+ $$
211
+
212
+ Optimization Following the literature (Ho et al., 2020) we optimize an unweighted squared error in pixel space:
213
+
214
+ $$
215
+ \mathcal { L } = \mathbb { E } _ { t \sim \mathcal { U } ( 0 , 1 ) } \mathbb { E } _ { \epsilon _ { t } \sim \mathcal { N } ( 0 , \mathbf { I } ) } [ | | f _ { \theta } ( z _ { t } , t ) - \epsilon _ { t } | | ^ { 2 } ] , \quad \mathrm { ~ w h e r e ~ } z _ { t } = \mathbf { V } \big ( \alpha _ { t } \mathbf { V } ^ { \mathrm { T } } x _ { t } + \sigma _ { t } \mathbf { V } ^ { \mathrm { T } } \epsilon _ { t } \big ) .
216
+ $$
217
+
218
+ Alternatively, one can derive a variational bound objective which corresponds to a different weighting as explained in section 2.1. However, it is known that such objectives tend to result in inferior sample quality (Ho et al., 2020; Nichol & Dhariwal, 2021).
219
+
220
+ Noise and Blurring Schedules To specify the blurring process precisely, the schedules for $\pmb { \alpha } _ { t }$ , $\sigma _ { t }$ need to be defined for $t \in [ 0 , 1 ]$ . For $\sigma _ { t }$ we choose the same value for all frequencies, so it suffices to give a schedule for a scalar value $\sigma _ { t }$ . The schedules are constructed by combining a typical Gaussian noise diffusion schedule (specified by scalars $a _ { t } , \sigma _ { t } )$ with a blurring schedule (specified by the vectors $\mathbf { } d _ { t }$ ).
221
+
222
+ For the noise schedule, following (Nichol & Dhariwal, 2021) we choose a variance preserving cosine schedule meaning that $\sigma _ { t } ^ { 2 } = 1 - a _ { t } ^ { 2 }$ , where $a _ { t } = \cos ( t \pi / 2 )$ for $t \in [ 0 , 1 ]$ . To avoid instabilities when $t \to 0$ and $t \to 1$ , the log signal to noise ratio $( \log a _ { t } ^ { 2 } / \sigma _ { t } ^ { 2 } )$ is at maximum $+ 1 0$ for $t = 0$ and at least $- 1 0$ for $t = 1$ . See (Kingma et al., 2021) for more details regarding the relation between the signal to noise ratio and $a _ { t } , \sigma _ { t }$ . For the blurring schedule, we use the relation from (Rissanen et al., 2022) that a Gaussian blur with scale $\sigma _ { B }$ corresponds to dissipation with time $\tau = \sigma _ { B } ^ { 2 } / 2$ . Empirically we found the blurring schedule:
223
+
224
+ $$
225
+ \sigma _ { B , t } = \sigma _ { B , \operatorname* { m a x } } \sin ( t \pi / 2 ) ^ { 2 }
226
+ $$
227
+
228
+ to work well, where $\sigma _ { B , \mathrm { m a x } }$ is a tune-able hyperparameter that corresponds to the maximum blur that will be applied to the image. This schedule in turn defines the dissipation time via $\tau _ { t } = \sigma _ { B , t } ^ { 2 } / 2$ . As described in Equation 23, the denoising process divides elementwise by the term ${ \alpha _ { t } } _ { | s } = { \alpha _ { t } } / { \alpha _ { s } }$ . If one would naively use $\pmb { d } _ { t } = \exp ( - \lambda \tau _ { t } )$ for $\pmb { \alpha } _ { t }$ and equivalently for step $s$ , then the term ${ d _ { t } } / { d _ { s } }$ could contain very small values for high frequencies. As a result, an undesired side-effect is that small errors may be amplified by many steps of the denoising process. Therefore, we modify the procedure slightly and let:
229
+
230
+ $$
231
+ \begin{array} { r } { \pmb { d } _ { t } = ( 1 - d _ { \operatorname* { m i n } } ) \cdot \exp ( - \pmb { \lambda } \tau _ { t } ) + d _ { \operatorname* { m i n } } , } \end{array}
232
+ $$
233
+
234
+ where we set $d _ { \operatorname* { m i n } } = 0 . 0 0 1$ . This blurring transformation damps frequencies to a small value $d _ { \mathrm { m i n } }$ and at the same time the denoising process amplifies high frequencies less aggressively. Because
235
+
236
+ (Rissanen et al., 2022) did not use the denoising process, this modification was not necessary for their model. Combining the Gaussian noise schedule $( a _ { t } , \sigma _ { t } )$ with the blurring schedule $( d _ { t } )$ we obtain:
237
+
238
+ $$
239
+ \begin{array} { r } { \pmb { \alpha } _ { t } = \pmb { a } _ { t } \cdot \pmb { d } _ { t } \quad \mathrm { a n d } \sigma _ { t } = \pmb { 1 } \sigma _ { t } , } \end{array}
240
+ $$
241
+
242
+ where 1 is a vector of ones. See Appendix A for more details on the implementation and specific settings.
243
+
244
+ # 4.1 A NOTE ON THE GENERALITY
245
+
246
+ In general, an orthogonal base $\begin{array} { r } { \pmb { u } _ { x } \ = \ \mathbf { V } ^ { \mathrm { T } } \pmb { x } } \end{array}$ that has a diagonal diffusion process $q ( { \pmb u } _ { t } | { \pmb u } _ { x } ) =$ $\mathcal { N } ( \mathbf { \bar { \boldsymbol { u } } } _ { t } | \alpha _ { t } \boldsymbol { \mathbf { \boldsymbol { u } } } _ { x } , \sigma _ { t } ^ { 2 } \mathbf { \mathbf { \boldsymbol { I } } } )$ corresponds to the following process in pixel space:
247
+
248
+ $$
249
+ \begin{array} { r } { q ( \boldsymbol { z } _ { t } | \boldsymbol { x } ) = \mathcal { N } ( \boldsymbol { z } _ { t } | \mathbf { V } \mathrm { d i a g } ( \alpha _ { t } ) \mathbf { V } ^ { \mathrm { T } } \boldsymbol { x } , \mathbf { V } \mathrm { d i a g } ( \sigma _ { t } ^ { 2 } ) \mathbf { V } ^ { \mathrm { T } } ) \quad \mathrm { w h e r e } \quad \boldsymbol { u } _ { t } = \mathbf { V } ^ { \mathrm { T } } \boldsymbol { z } _ { t } , } \end{array}
250
+ $$
251
+
252
+ where diag transforms a vector to a diagonal matrix. More generally, a diffusion process defined in any invertible basis change $u _ { x } = \mathbf { P } ^ { - \mathrm { { 1 } } } \pmb { x }$ corresponds to the following diffusion process in pixel space:
253
+
254
+ $$
255
+ q ( z _ { t } | \boldsymbol { x } ) = \mathcal { N } ( z _ { t } | \mathbf { P } \mathrm { d i a g } ( \alpha _ { t } ) \mathbf { P } ^ { - 1 } \boldsymbol { x } , \mathbf { P } \mathrm { d i a g } ( \sigma _ { t } ^ { 2 } ) \mathbf { P } ^ { \mathrm { T } } ) \quad \mathrm { w h e r e } \quad u _ { t } = \mathbf { P } ^ { - 1 } z _ { t } .
256
+ $$
257
+
258
+ As such, this framework enables a larger class of diffusion models,with the guarantees of standard diffusion models.
259
+
260
+ # 5 RELATED WORK
261
+
262
+ Score-based diffusion models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020) have become increasingly successfully in modelling different types of data, such as images (Dhariwal & Nichol, 2021), audio (Kong et al., 2021), and steady states of physical systems (Xu et al., 2022). Most diffusion processes are diagonal, meaning that they can be factorized over dimensions. The vast majority relies on independent additive isotropic Gaussian noise as a diffusion process.
263
+
264
+ Several diffusion models use a form of super-resolution to account for the multi-scale properties in images (Ho et al., 2022; Jing et al., 2022). These methods still rely on additive isotropic Gaussian noise, but have explicit transitions between different resolutions. In other works (Serrà et al., 2022; Kawar et al., 2022) diffusion models are used to restore predefined corruptions on image or audio data, although these models do not generate data from scratch. Theis et al. (2022) discuss nonisotropic Gaussian diffusion processes in the context of lossy compression. They find that nonisotropic Gaussian diffusion, such as our blurring diffusion models, can lead to improved results if the goal is to encode data with minimal mean-squared reconstruction loss under a reconstruction model that is constrained to obey the ground truth marginal data distribution, though the benefit over standard isotropic diffusion is greater for different objectives.
265
+
266
+ Recently, several works introduce other destruction processes as an alternative to Gaussian diffusion with little to no noise. Although pre-existing works invert fixed amounts of blur (Kupyn et al., 2018; Whang et al., 2022), in (Rissanen et al., 2022) blurring is directly built into the diffusion process via heat dissipation. Similarly, in (Bansal et al., 2022) several (possibly deterministic) destruction mechanisms are proposed which are referred to as ‘cold diffusion’. However, the generative processes of these approaches may not be able to properly learn the reveres process if they do not satisfy the condition discussed in section 2.1. Furthermore in (Lee et al., 2022) a process is introduced that combines blurring and noise and is variance preserving in frequency space, which may not be the ideal inductive bias for images. Concurrently, in (Daras et al., 2022) a method is introduced that can incorporate blurring with noise, although sampling is done differently. For all these approaches, there is still a considerably gap in performance compared to standard denoising diffusion.
267
+
268
+ # 6 EXPERIMENTS
269
+
270
+ # 6.1 COMPARISON WITH DETERMINISTIC AND DENOISING DIFFUSION MODELS
271
+
272
+ In this section our proposed Blurring Diffusion Models are compared to their closest competitor in literature, IHDMs (Rissanen et al., 2022), and to Cold Diffusion Models (Bansal et al., 2022). In addition, they are also compared to a denoising diffusion baseline similar to DDPMs (Ho et al., 2020) which we refer to as Denoising Diffusion.
273
+
274
+ Table 1: Sample quality on CIFAR10 measured in FID score, lower is better.
275
+
276
+ <table><tr><td>CIFAR10</td><td>FID</td></tr><tr><td>Cold Diffusion (Blur)*</td><td>80.08</td></tr><tr><td>IHDM(Rissanen et al., 2022)</td><td>18.96</td></tr><tr><td>Soft Diffusion (Daras et al., 2022)</td><td>4.64</td></tr><tr><td>Denoising Diffusion</td><td>3.58</td></tr><tr><td>Blurring Diffusion (ours)</td><td>3.17</td></tr></table>
277
+
278
+ ∗ Not unconditional, starts from blurred image.
279
+
280
+ Table 2: Sample quality on LSUN churches $1 2 8 \times 1 2 8$ measured in FID score.
281
+
282
+ <table><tr><td colspan="2">Model FID</td></tr><tr><td>IHDM (Rissanen et al., 2022)</td><td>45.1</td></tr><tr><td>Denoising Diffusion</td><td>4.68</td></tr><tr><td>Blurring Diffusion (ours)</td><td>3.88</td></tr></table>
283
+
284
+ CIFAR10 The first generation task is generating images when trained on the CIFAR10 dataset (Krizhevsky et al., 2009). For this task, we run the blurring diffusion model and the denoising diffusion baseline both using the same UNet architecture as their noise predictor $f _ { \theta }$ . Specifically, the UNet operates at resolutions $3 2 \times 3 2$ $1 6 \times 1 6$ and $8 \times 8$ with 256 channels at each level. At every resolution, the UNet has 3 residual blocks associated with the down-sampling section and another 3 blocks for the up-sampling section. Furthermore, the UNet has selfattention at resolutions $1 6 \times 1 6$ and $8 \times 8$ with a single head. Although IHDMs used only 128 channels on the $3 2 \times 3 2$ resolutions, they use 256 channels on all other resolutions, they include the $4 \times 4$ resolution and use 4 blocks instead of 3 blocks. Also see Appendix A.2.
285
+
286
+ To measure the visual quality of the generated samples we use the FID score measured on 50000 samples drawn from the models, after 2 million steps of training. As can be seen from these scores (Table 1), the blurring diffusion models are able to generate images with a considerable higher quality than IHDMs, as well as other similar approaches in literature. Our blurring diffusion models also outperform standard denoising diffusion models, although the difference in performance is less pronounced in that case. Random samples drawn from the model are depicted in Figure 3.
287
+
288
+ ![](images/b18a62e473dad8c3b35337bc101c1e195554f0c9a7f4d73d66cf28ef861bb463.jpg)
289
+ Figure 3: Samples from a Blurring Diffusion Model trained on CIFAR10.
290
+
291
+ LSUN Churches Secondly, we test the performance of the model when trained on LSUN Churches with a resolution of $1 2 8 \times 1 2 8$ . Again, a UNet architecture is used for the noise prediction network $f _ { \theta }$ . This time the UNet operates on 64 channels for the $1 2 8 \times 1 2 8$ resolution, 128 channels for the $6 4 \times 6 4$ resolution, 256 channels for the $3 2 \times 3 2$ resolution, 384 channels for the $1 6 \times 1 6$ resolution, and 512 channels for the $8 \times 8$ resolution. At each resolution there are two sections with 3 residual blocks, with self-attention on the resolutions $3 2 \times 3 2$ , $1 6 \times 1 6$ , and $8 \times 8$ . The models in (Rissanen et al., 2022) use more channels at each resolution level but only 2 residual blocks (see Appendix A.2).
292
+
293
+ The visual quality is measured by computing the FID score on 10000 samples drawn from trained models. From these scores (Table 2) again we see that the blurring diffusion models generate higher quality images than IHDMs. Furthermore, Blurring Diffusion models also outperform denoising diffusion models, although again the difference in performance is smaller in that comparison. See Appendix B for more experiments.
294
+
295
+ ![](images/34e9d71dedf2f0bd30cb077a27c9486a855b5610a96d94fb85439eca48e3d902.jpg)
296
+ Figure 4: Samples from a Blurring Diffusion model trained on LSUN churches $1 2 8 \times 1 2 8$ .
297
+
298
+ Table 3: Blurring Diffusion Models with different maximum noise values
299
+
300
+ <table><tr><td>OB,max</td><td>CIFAR10</td><td>LSUN Churches (128×)</td></tr><tr><td>0</td><td>3.60</td><td>4.68</td></tr><tr><td>1</td><td>3.49</td><td>4.42</td></tr><tr><td>10</td><td>3.26</td><td>3.65</td></tr><tr><td>20</td><td>3.17</td><td>3.88</td></tr></table>
301
+
302
+ Table 4: Different maximum noise levels and schedules on CIFAR10
303
+
304
+ <table><tr><td>OB,max</td><td>0B,max sin(tπ /2)2</td><td>OB,max Sin(tπ /2)</td></tr><tr><td>0</td><td>3.60</td><td>3.58</td></tr><tr><td>1</td><td>3.49</td><td>3.37</td></tr><tr><td>10</td><td>3.26</td><td>4.24</td></tr><tr><td>20</td><td>3.17</td><td>6.54</td></tr></table>
305
+
306
+ # 6.2 COMPARISON BETWEEN DIFFERENT NOISE LEVELS AND SCHEDULES
307
+
308
+ In this section we analyze the models from above, but with different settings in terms of maximum blur $( \sigma _ { B , \mathrm { m a x } } )$ and two different noise schedule $\sin ^ { 2 }$ and sin). The models where $\sigma _ { B , \mathrm { m a x } } = 0$ are equivalent to a standard denoising diffusion model. For CIFAR10, the best performing model uses a blur of $\sigma _ { B , \mathrm { m a x } } = 2 0 $ which has an FID of 3.17 over 3.60 when no blur is applied, as can be seen in Table 3. The difference compared to the model with $\sigma _ { B , \mathrm { m a x } } = 1 0 $ is relatively small, with an FID of 3.26. For LSUN Churches, the the best performing model uses a little less blur $\sigma _ { B , \mathrm { m a x } } = 1 0$ although performance is again relatively close to the model with $\sigma _ { B , \mathrm { m a x } } = 2 0 $ . When comparing the $\sin ^ { 2 }$ schedule with a sin schedule, the visual quality measured by FID score seems to be much better for the $\sin ^ { 2 }$ schedule (Table 4). In fact, for higher maximum blur the $\sin ^ { 2 }$ schedule performs much better. Our hypothesis is that the sin schedule blurs too aggressively, whereas the graph of a $\sin ^ { 2 }$ adds blur more gradually at the beginning of the diffusion process near $t = 0$ .
309
+
310
+ Interesting behaviour of blurring diffusion models is that models with higher maximum blur $( \sigma _ { B , \mathrm { m a x } } )$ converge more slowly, but when trained long enough outperform models with less blur. When comparing two blurring models with $\sigma _ { B , \mathrm { m a x } }$ set to either 1 or 20, the model with $\sigma _ { B , \mathrm { m a x } } = 2 0 $ has better visual quality only after roughly 200K training steps for CIFAR10 and 1M training steps for LSUN churches. It seems that higher blur takes more time to train, but then learns to fit the data better. Note that an exception was made for the evaluation of the CIFAR10 models where $\sigma _ { B , \mathrm { m a x } }$ is 0 and 1, as those models show over-fitting behaviour and have better FID at 1 million steps than at 2 million steps. Regardless of this selection advantage, they are outperformed by blurring diffusion models with higher $\sigma _ { B , \mathrm { m a x } }$ .
311
+
312
+ # 7 LIMITATIONS AND CONCLUSION
313
+
314
+ In this paper we introduced blurring diffusion models, a class of generative models generalizing over the Denoising Diffusion Probabilistic Models (DDPM) of Ho et al. (2020) and the Inverse Heat Dissipation Models (IHDM) of Rissanen et al. (2022). In doing so, we showed that blurring data, and several other such deterministic transformations with addition of fixed variance Gaussian noise, can equivalently be defined through a Gaussian diffusion process with non-isotropic noise. This allowed us to make connections to the literature on non-isotropic diffusion models (e.g. Theis et al., 2022), which allows us to better understand the inductive bias imposed by this model class. Using our proposed model class, we were able to generate images with improved perceptual quality compared to both DDPM and IHDM baselines.
315
+
316
+ A limitation of blurring diffusion models is that the use of blur has a regularizing effect: When using blur it takes longer to train a generative model to convergence. Such as regularizing effect is often beneficial, and can lead to improved sample quality as we showed in Section 6, but may not be desirable when very large quantities of training data are available. As we discuss in Section 4, the expected benefit of blurring is also dependent on our particular objective, and will differ for different ways of measuring sample quality: We briefly explored this in Section 6, but we leave a more exhaustive exploration of the tradeoffs in this model class for future work.
317
+
318
+ # REFERENCES
319
+
320
+ Arpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie S. Li, Hamid Kazemi, Furong Huang, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Cold diffusion: Inverting arbitrary image transforms without noise. CoRR, abs/2208.09392, 2022.
321
+
322
+ Giannis Daras, Mauricio Delbracio, Hossein Talebi, Alexandros G Dimakis, and Peyman Milanfar. Soft diffusion: Score matching for general corruptions. arXiv preprint arXiv:2209.05442, 2022.
323
+
324
+ Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. CoRR, abs/2105.05233, 2021.
325
+
326
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS, 2020.
327
+
328
+ Jonathan Ho, Chitwan Saharia, William Chan, David J. Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23: 47:1–47:33, 2022.
329
+
330
+ Bowen Jing, Gabriele Corso, Renato Berlinghieri, and Tommi S. Jaakkola. Subspace diffusion generative models. CoRR, abs/2205.01490, 2022.
331
+
332
+ Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. CoRR, abs/2201.11793, 2022.
333
+
334
+ Diederik P. Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. CoRR, abs/2107.00630, 2021.
335
+
336
+ Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. DiffWave: A versatile diffusion model for audio synthesis. In 9th International Conference on Learning Representations, ICLR, 2021.
337
+
338
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
339
+
340
+ Orest Kupyn, Volodymyr Budzan, Mykola Mykhailych, Dmytro Mishkin, and Jiri Matas. Deblurgan: Blind motion deblurring using conditional adversarial networks. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18- 22, 2018, pp. 8183–8192. Computer Vision Foundation / IEEE Computer Society, 2018. doi: 10.1109/CVPR.2018.00854. URL http://openaccess.thecvf.com/content_cvpr_2018/ html/Kupyn_DeblurGAN_Blind_Motion_CVPR_2018_paper.html.
341
+
342
+ Sangyun Lee, Hyungjin Chung, Jaehyeon Kim, and Jong Chul Ye. Progressive deblurring of diffusion models for coarse-to-fine image synthesis. CoRR, abs/2207.11192, 2022. doi: 10.48550/arXiv.2207.11192. URL https://doi.org/10.48550/arXiv.2207.11192.
343
+
344
+ Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML, 2021.
345
+
346
+ Severi Rissanen, Markus Heinonen, and Arno Solin. Generative modelling with inverse heat dissipation. CoRR, abs/2206.13397, 2022.
347
+
348
+ Joan Serrà, Santiago Pascual, Jordi Pons, R. Oguz Araz, and Davide Scaini. Universal speech enhancement with score-based diffusion. CoRR, abs/2206.03065, 2022.
349
+
350
+ Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In Francis R. Bach and David M. Blei (eds.), Proceedings of the 32nd International Conference on Machine Learning, ICML, 2015.
351
+
352
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS, 2019.
353
+
354
+ Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2020.
355
+
356
+ Lucas Theis, Tim Salimans, Matthew D Hoffman, and Fabian Mentzer. Lossy compression with gaussian diffusion. arXiv preprint arXiv:2206.08889, 2022.
357
+
358
+ Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G. Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2022, New Orleans, LA, USA, June 18-24, 2022, pp. 16272–16282. IEEE, 2022. doi: 10.1109/CVPR52688.2022.01581. URL https://doi.org/ 10.1109/CVPR52688.2022.01581.
359
+
360
+ Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. Geodiff: A geometric diffusion model for molecular conformation generation. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022.
361
+
362
+ # A ADDITIONAL DETAILS ON BLURRING DIFFUSION
363
+
364
+ In this section we provide additional details for blurring diffusion models. In particular, we provide some pseudo-code to show the essential steps that are needed to compute the variables associated with the diffusion process.
365
+
366
+ # A.1 PSEUDO-CODE OF DIFFUSION AND DENOISING PROCESS
367
+
368
+ Firstly, the procedure to compute the frequency scaling $( d _ { t } )$ is given below:
369
+
370
+ <table><tr><td colspan="6">def get_frequency_scaling(t,min_scale=O.001): # compute dissipation time sigma_blur = sigma_blur_max * sin(t * pi / 2)^2 dissipation_time = sigma_t^2 / 2</td></tr> colspan="6"></td></tr><tr><td colspan="8"></td></tr><tr><td colspan="8"># compute frequencies</td></tr><tr><td colspan="8">freq = pi * linspace(o,img_dim-1,img_dim)/ img_dim</td></tr><tr><td colspan="8">labda = freqs[None,:,None,None]^2 + freqs[None,None,:,None]^2</td></tr><tr><td colspan="8"></td></tr><tr><td colspan="8"># compute scaling for frequencies</td></tr><tr><td colspan="8"></td></tr><tr><td colspan="8">scaling = exp(-labda * dissipation_time) * (1 - min_scale)</td></tr><tr><td colspan="8">scaling = scaling + min_scale</td></tr><tr><td colspan="8"></td></tr><tr><td colspan="8">return scaling</td></tr><tr><td colspan="8"></td></tr></table>
371
+
372
+ Note here the computation of $\pmb { \Lambda }$ is from (Rissanen et al., 2022) and the variable ‘scaling’ refers to $\mathbf { } d _ { t }$ in equations. Next, we can define a wrapper function to return the required $\alpha _ { t } , \sigma _ { t }$ values.
373
+
374
+ def get_alpha_sigma ( t ): freq_scaling $=$ get_frequency_scaling ( t ) a , sigma $=$ get_noise_scaling_cosine ( t ) alpha $=$ a \* freq_scaling # Combine dissipation and scaling . return alpha , sigma
375
+
376
+ Which also requires a function to obtain the noise parameters. We use a typical cosine schedule for which the pseudo-code is given below:
377
+
378
+ <table><tr><td>def</td><td></td><td></td><td>get_noise_schaling_cosine(t,logsnr_min=-10,logsnr_max=10): limit_max = arctan(exp(-0.5 * logsnr_max))</td><td></td><td></td><td></td></tr><tr><td colspan="7"></td></tr><tr><td></td><td></td><td></td><td>limit_min = arctan(exp(-O.5 * logsnr_min)) - limit_max</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>logsnr = -2 * log(tan(limit_min * t + limit_max))</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td># Transform logsnr to a, sigma.</td><td></td><td></td><td></td><td></td></tr><tr><td>return</td><td></td><td></td><td>sqrt(sigmoid(logsnr)),sqrt(sigmoid(-logsnr))</td><td></td><td></td><td></td></tr></table>
379
+
380
+ To train the model we desire samples from $q ( { \pmb u } _ { t } | { \pmb u } _ { x } )$ . In the pseudo-code below, the inputs $( { \pmb x } )$ and outputs $( z _ { t } , \epsilon _ { t } )$ are defined in pixel space. Recall that $z _ { t } = \mathbf { V } u _ { t } = \mathrm { I D C T } ( { u _ { t } } )$ and then:
381
+
382
+ def diffuse (x , t ): x_freq $=$ D C T ( x ) alpha , sigma $=$ get_alpha_sigma ( t ) eps $=$ random_normal_like ( x ) # Since we chose sigma to be a scalar , eps does not need to be # passed through a DCT/ IDCT in this case . $z _ { - } \ t =$ IDCT ( alpha \* x_freq ) $^ +$ sigma \* eps return z_t , eps
383
+
384
+ Given samples ${ \boldsymbol { z } } _ { t }$ from the diffusion process one can now directly define the mean squared error loss on epsilon as defined below:
385
+
386
+ def loss ( x ): t $=$ random_uniform (0 , 1) z_t , eps $=$ diffuse (x , t ) error $=$ ( eps - neural_net ( z_t , t ))^2 return mean ( error )
387
+
388
+ Finally, to sample from the model we repeatedly sample from $p \big ( z _ { t - 1 / T } | z _ { t } \big )$ for the grid of timesteps $t = T , T - 1 / T \ldots , 1 / T .$ .
389
+
390
+ def denoise ( z_t , t , delta =1 e -8): alpha_s , sigma_s $=$ get_alpha_sigma ( t - 1 / T ) alpha_t , sigma_t $=$ get_alpha_sigma ( t )
391
+
392
+ # Compute helpful coefficients .
393
+ alpha_ts $=$ alpha_t / alpha_s
394
+ alpha_st $\qquad = \quad 1$ / alpha_ts
395
+ sigma2_ts $=$ ( sigma_t ^2 - alpha_ts ^2 \* sigma_s ^2)
396
+ # Denoising variance .
397
+ sigma2_denoise $\qquad = \quad 1$ / clip ( 1 / clip ( sigma_s ^2 , min $=$ delta ) $^ +$ 1 / clip ( sigma_t ^2 / alpha_ts ^2 - sigma_s ^2 , min $=$ delta ) , min ${ } , = { }$ delta )
398
+
399
+ # The coefficients for u_t and u_eps . coeff_term1 $=$ alpha_ts \* sigma2_denoise / ( sigma2_ts $^ +$ delta ) coeff_term2 $=$ alpha_st $^ { * }$ sigma2_ts / clip ( sigma_s ^2 , min $=$ delta )
400
+
401
+ # Get neural net prediction . hat_eps $=$ neural_net ( z_t , t )
402
+
403
+ # # Compute terms .
404
+
405
+ $\mathsf { u \mathrm { ~ \_ t ~ } ~ } = \mathsf { D C T } \left( \mathsf { z \mathrm { ~ \_ t ~ } ^ { \cdot } } \right)$ )
406
+ term1 $=$ IDCT ( coeff_term1 \* u_t )
407
+ term2 $=$ IDCT ( coeff_term2 \* u_t - sigma_t \* DCT ( hat_eps )))
408
+ mu_denoise $=$ term1 $^ +$ term2
409
+
410
+ # Sample from the denoising distribution . eps $=$ random_normal_like ( mu_denoise ) return mu_denoise $^ +$ IDCT ( sqrt ( sigma2_denoise ) \* eps )
411
+
412
+ More efficient implementations that use less DCT calls are also possible when the denoising function is directly defined in frequency space. This is not really an issue however, because compared to the neural network the DCTs are relatively cheap. Additionally, several values are clipped to a minimum of $1 0 ^ { - 8 }$ to avoid numerically unstable divisions.
413
+
414
+ In the sampling process of standard diffusion, before using the prediction ˆ the variable is transformed to $\hat { \pmb x }$ , clipped and then transformed back to $\hat { \epsilon }$ . This procedure is known to improve visual quality scores for standard denoising diffusion, but it is not immediately clear how to apply the technique in the case of blurring diffusion. For future research, finding a reliable technique to perform clipping without introducing frequency artifacts may be important.
415
+
416
+ # A.2 HYPERPARAMETER SETTINGS
417
+
418
+ In the experiments, the neural network function $f _ { \theta }$ in equations) is implemented as a UNet architecture, as is typical in modern diffusion models (Ho et al., 2020). For the specific architecture details see Table 5. Note that as is standard in UNet architectures, there is an downsample and upsample path. Following the common notation, the hyperparameter ‘ResBlocks / Stage’ denotes the blocks per stage per upsample/downsample path. Thus, a level with 3 ResBlocks per stage as in total $3 + ( 3 + 1 ) = 7$ ResBlocks, where the $( 3 + 1 )$ originates from the upsample path which always uses an additional block. In addition, the downsample $/$ upsample blocks also apply an additional ResBlock. All models where optimized with Adam, with a learning rate of $2 \cdot 1 0 ^ { - 4 }$ and batch size
419
+
420
+ 128 for CIFAR-10 and a learning rate of $1 \cdot 1 0 ^ { - 4 } $ and batch size 256 for the LSUN models. All methods are evaluated with an exponential moving average computed with a decay of 0.9999.
421
+
422
+ Table 5: Architecture Settings
423
+
424
+ <table><tr><td>Experiment</td><td>Channels</td><td>Attention Resolutions</td><td>Head dim</td><td>ResBlocks/Stage</td><td>Channel Multiplier</td><td>Dropout</td></tr><tr><td>CIFAR10</td><td>256</td><td>8,16</td><td>256</td><td>3</td><td>1,1, 1</td><td>0.2</td></tr><tr><td>LSUN Churches 64</td><td>128</td><td>8,16,32</td><td>64</td><td>3</td><td>1,2,3,4</td><td>0.2</td></tr><tr><td>LSUN Churches 128</td><td>64</td><td>8,16,32</td><td>64</td><td>3</td><td>1,2,4,6,8</td><td>0.1</td></tr></table>
425
+
426
+ # B ADDITIONAL EXPERIMENTS
427
+
428
+ In this section, some additional information regarding the experiments are shown. In Table 6 the FID score on the eval set of CIFAR10 and LSUN churches $1 2 8 \times 1 2 8$ is presented. The best performing models match with the results in the main text on train FID. For CIFAR10, we also report the Inception Score which corresponds to the certainty of the Inception classifier. Here the results are less clear, because all models have roughly similar scores. The best performing model uses $\sigma _ { B , \mathrm { m a x } } = 1 0 $ and achieves 9.59. To confirm that the loss and parametrization are important, the best CIFAR10 model (with $\sigma _ { B , \mathrm { { m a x } } } = 2 0 ) $ ) is trained using a mean squared error on $\mathbf { x } - \hat { \mathbf { x } }$ when predicting $\hat { \textbf { \textit { x } } }$ , but this only achieves $2 3 . 9 \ : \mathrm { F I D }$ versus the 3.17 of the epsilon parametrization. This diminished performance is also observed for standard diffusion (Ho et al., 2020). Furthermore, as an ablation study we trained the best performing model in the frequency domain (where the UNet takes as input $\mathbf { \Delta } \mathbf { u } _ { t }$ ). This model only produced gray samples with some checkerboard artifacts, and had a higher loss throughout training. This indicates that learning a UNet directly in frequency space is not straightforward.
429
+
430
+ Table 6: Blurring Diffusion Models with different maximum noise values (eval FID) and Inception Score (IS) for CIFAR10.
431
+
432
+ <table><tr><td>0B,max</td><td>CIFAR10 (FID eval)</td><td>CIFAR10 (IS)</td><td>LSUN Churches (eval FID)</td></tr><tr><td>0</td><td>5.58</td><td>9.54</td><td>44.1</td></tr><tr><td>1</td><td>5.44</td><td>9.51</td><td>43.6</td></tr><tr><td>10</td><td>5.35</td><td>9.59</td><td>42.8</td></tr><tr><td>20</td><td>5.27</td><td>9.51</td><td>43.1</td></tr></table>
433
+
434
+ For completeness an additional experiment on LSUN churches $6 4 \times 6 4$ . Results are similar to the higher resolution case, the Blurring Diffusion Model with $\sigma _ { B , \mathrm { m a x } } = 2 0 $ achieves 2.62 FID train whereas the baseline denoising model $( \sigma _ { B , \mathrm { { m a x } } } = 0 )$ ) achieves 2.70.
435
+
436
+ Table 7: Results on LSUN $6 4 \times 6 4$
437
+
438
+ <table><tr><td>OB,max</td><td>FID train</td><td>FID eval</td></tr><tr><td>0</td><td>2.70</td><td>44.1</td></tr><tr><td>20</td><td>2.62</td><td>43.1</td></tr></table>
md/dev/Pv1GPQzRrC8/Pv1GPQzRrC8.md ADDED
@@ -0,0 +1,498 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IMITATING HUMAN BEHAVIOUR WITH DIFFUSION MODELS
2
+
3
+ Tim Pearce, Tabish Rashid, Anssi Kanervisto, Dave Bignell, Mingfei Sun, Raluca Georgescu, Sergio Valcarcel Macua, Shan Zheng Tan, Ida Momennejad, Katja Hofmann, Sam Devlin Microsoft Research
4
+
5
+ # ABSTRACT
6
+
7
+ Diffusion models have emerged as powerful generative models in the text-toimage domain. This paper studies their application as observation-to-action models for imitating human behaviour in sequential environments. Human behaviour is stochastic and multimodal, with structured correlations between action dimensions. Meanwhile, standard modelling choices in behaviour cloning are limited in their expressiveness and may introduce bias into the cloned policy. We begin by pointing out the limitations of these choices. We then propose that diffusion models are an excellent fit for imitating human behaviour, since they learn an expressive distribution over the joint action space. We introduce several innovations to make diffusion models suitable for sequential environments; designing suitable architectures, investigating the role of guidance, and developing reliable sampling strategies. Experimentally, diffusion models closely match human demonstrations in a simulated robotic control task and a modern 3D gaming environment.
8
+
9
+ Code: https://github.com/microsoft/Imitating-Human-Behaviour-w-Diffusion.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ To enable Human-AI collaboration, agents must learn to best respond to all plausible human behaviors (Dafoe et al., 2020; Mirsky et al., 2022). In simple environments, it suffices to generate all possible human behaviours (Strouse et al., 2021) but as the complexity of the environment grows this approach will struggle to scale. If we instead assume access to human behavioural data, collaborative agents can be improved by training with models of human behaviour (Carroll et al., 2019).
14
+
15
+ In principle, human behavior can be modelled via imitation learning approaches in which an agent is trained to mimic the actions of a demonstrator from an offline dataset of observation and action tuples. More specifically, Behaviour Cloning (BC), despite being theoretically limited (Ross et al., 2011), has been empirically effective in domains such as autonomous driving (Pomerleau, 1991), robotics (Florence et al., 2022) and game playing (Ye et al., 2020; Pearce and Zhu, 2022).
16
+
17
+ Popular approaches to BC restrict the types of distributions that can be modelled to make learning simpler. A common approach for continuous actions is to learn a point estimate, optimised via Mean Squared Error (MSE), which can be interpereted as an isotropic Gaussian of negligible variance. Another popular approach is to discretise the action space into a finite number of bins and frame as a classification problem. These both suffer due to the approximations they make (illustrated in Figure 1), either encouraging the agent to learn an ‘average’ policy or predicting action dimensions independently resulting in ‘uncoordinated’ behaviour (Ke et al., 2020).
18
+
19
+ ![](images/fce7c3d8c8ba78aec4a4c44eaa180601f05d58d8ee042694640814d6b54afb61.jpg)
20
+ Figure 1: Expressiveness of a variety of models for behaviour cloning in a single-step, arcade claw game with two simultaneous, continuous actions. Existing methods fail to model the full action distribution, $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ , whilst diffusion models excel at covering multimodal & complex distributions.
21
+
22
+ Such simplistic modelling choices can be successful when the demonstrating policy is itself of restricted expressiveness (e.g. when using trajectories from a single pre-trained policy represented by a simple model.) However, for applications requiring cloning of human behaviour, which contains diverse trajectories and multimodality at decision points, simple models may not be expressive enough to capture the full range and fidelity of behaviours (Orsini et al., 2021).
23
+
24
+ For these reasons, we seek to model the full distribution of actions observed. In particular, this paper focuses on diffusion models, which currently lead in image, video and audio generation (Saharia et al., 2022; Harvey et al., 2022; Kong et al., 2020), and avoid issues of training instability in generative adversarial networks (Srivastava et al., 2017), or sampling issues with energy based models (Florence et al., 2022). By using diffusion models for BC we are able to: 1) more accurately model complex action distributions (as illustrated in Figure 1); 2) significantly outperform state-of-the-art methods (Shafiullah et al., 2022) on a simulated robotic benchmark; and 3) scale to modelling human gameplay in Counter-Strike: Global Offensive - a modern, 3D gaming environment recently proposed as a platform for imitation learning research (Pearce and Zhu, 2022).
25
+
26
+ To achieve this performance, we contribute several innovations to adapt diffusion models to sequential environments. Section 3.2 shows that good architecture design can significantly improve performance. Section 3.3 then shows that Classifier-Free Guidance (CFG), which is a core part of text-to-image models, surprisingly harms performance in observation-to-action models. Finally, Section 3.4 introduces novel, reliable sampling schemes for diffusion models. The appendices include related work, experimental details, as well as further results and explanations.
27
+
28
+ # 2 MODELLING CHOICES FOR BEHAVIOURAL CLONING
29
+
30
+ In this section we examine common modelling choices for BC. For illustration purposes, we created a simple environment to highlight their limitations. We simulated an arcade toy claw machine, as shown in Figures 1, 3 & 4. An agent observes a top-down image of toys (o) and chooses a point in the image, in a 2D continuous action space, $\mathbf { a } \in \mathbb { R } ^ { 2 }$ . If the chosen point is inside the boundaries of a valid toy, the agent successfully obtains the toy. To build a dataset of demonstrations, we synthetically generate images containing one or more toys, and uniformly at random pick a single demonstration action a that successfully grabs a toy (note this toy environment uses synthetic rather than human data). The resulting dataset is used to learn ${ \hat { p } } ( \mathbf { a } | \mathbf { o } )$ . To make training quicker, we restrict the number of unique observations $o$ to seven, though this could be generalised.
31
+
32
+ MSE. A popular choice for BC in continuous action spaces approximates $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ by a point-estimate that is optimised via MSE. This makes a surprisingly strong baseline in the literature despite its simplicity. However, MSE suffers from two limitations that harm its applicability to our goal of modelling the full, complex distributions of human behaviour. 1) MSE outputs a point-estimate. This precludes it from capturing any variance or multimodality present in $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ . 2) Due to its optimisation objective, MSE learns the ‘average’ of the distribution. This can bias the estimate towards more frequently occurring actions, or can even lead to out-of-distribution actions (e.g. picking the action between two modes). The first can be partially mitigated by instead assuming a Gaussian distribution, predicting a variance for each action dimension and sampling from the resulting Gaussian. However, due to the MSE objective, the learnt mean is still the average of the observed action distribution. These limitations are visualised in Figure 1.
33
+
34
+ Discretised. A second popular choice is to discretise each continuous action dimension into $B$ bins, and frame it as a classification task. This has two major limitations. 1) Quantisation errors arise since the model outputs a single value for each bin. 2) Since each action dimension is treated independently, the marginal rather than the joint distribution is learnt. This can lead to issues during sampling whereby dependencies between dimensions are ignored, leading to ‘uncoordinated’ behaviour. This can be observed in Figure 1 where points outside of the true distribution have been sampled in the bottom-right corner. This can be remedied by modelling action dimensions autoregressively, but these models bring their own challenges and drawbacks (Lin et al., 2021).
35
+
36
+ K-Means. Another method that accounts for dependencies between action dimensions, first clusters the actions across the dataset into $K$ bins (rather than $B ^ { | \mathbf { a } | }$ ) using K-Means. This discretises the joint-action distribution, rather than the marginal as in ‘Discretised’. Each action is then associated with its nearest cluster, and learning can again be framed as a classification task. This approach avoids enumerating all possible action combinations, by placing bins only where datapoints exist. However two new limitations are introduced: 1) Quantisation errors can be more severe than for ‘Discretised’ due to only $K$ action options. 2) The choice of $K$ can be critical to performance (Guss et al., 2021). If $K$ is small, important actions may be unavailable to an agent; if $K$ is large, learning becomes difficult. Additionally, since the bins are chosen with respect to the entire dataset they can fall outside of the target distribution for a given observation. This is observed in Figure 1.
37
+
38
+ K-Means+Residual. Shafiullah et al. (2022) extended K-Means by learning an observationdependent residual that is added to the bin’s center and optimised via MSE. This increases the fidelity of the learnt distribution. However, it still carries through some issues of K-Means and MSE. 1) The distribution $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ is still modelled by a finite number of point estimates (maximum of $K$ ). 2) The residual learns the ‘average’ of the actions that fall within each bin. In addition, it still requires a careful choice of the hyperparameter K.
39
+
40
+ Diffusion models. The limitations of these existing modelling choices all arise from approximations made in the form of ${ \hat { p } } ( \mathbf { a } | \mathbf { o } )$ , combined with the optimisation objective. But it is precisely these approximations that make training models straightforward (optimising a network via MSE or crossentropy is trivial!). So how can we learn $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ while avoiding approximations? We propose that recent progress in generative modelling with diffusion models provides an answer. Diffusion models are able to output expressive conditional joint distributions, and are powerful enough to scale to problems as complex as text-to-image or video generation. Thus, we will show they provide benefits when imitating human demonstrations as they make no coarse approximations about the action distribution, and avoid many of the limitations of the previously discussed choices. This can be observed in Figure 1, where only diffusion provides an accurate reconstruction of the true action distribution.
41
+
42
+ # 3 OBSERVATION-TO-ACTION DIFFUSION MODELS
43
+
44
+ Diffusion models have largely been developed for the image domain. This section first introduces the underlying principles of diffusion models, then studies several aspects that require consideration to apply them to sequential environments.
45
+
46
+ # 3.1 DIFFUSION MODEL OVERVIEW
47
+
48
+ Diffusion models are generative models that map Gaussian noise to some target distribution in an iterative fashion, optionally conditioned on some context (Dhariwal and Nichol, 2021). Beginning from, $\mathbf { a } _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ , a sequence $\mathbf { a } _ { T - 1 } , \mathbf { a } _ { T - 2 } \dots \mathbf { a } _ { 0 }$ is predicted, each a slightly denoised version of the previous, with ${ \bf a } _ { 0 }$ a ‘clean’ sample. Where $T$ is the total number of denoising steps (not the environment timestep as is common in sequential decision making).
49
+
50
+ This paper uses denoising diffusion probabilisitic models (Ho et al., 2020). During training, noisy√ √ inputs can be generated as: $\mathbf { a } _ { \tau } = \sqrt { \bar { \alpha } _ { \tau } } \mathbf { a } + \sqrt { 1 - \bar { \alpha } _ { \tau } } \mathbf { z }$ , for some variance schedule $\bar { \alpha } _ { \tau }$ , random noise $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ . A neural network, $\epsilon ( \cdot )$ , is trained to predict the noise that was added to an input, by minimising:
51
+
52
+ $$
53
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { D D P M } } : = \mathbb { E } _ { \mathbf { o } , \mathbf { a } , \tau , \mathbf { z } } \left[ | | \boldsymbol { \epsilon } ( \mathbf { o } , \mathbf { a } _ { \tau } , \tau ) - \mathbf { z } | | _ { 2 } ^ { 2 } \right] , } \end{array}
54
+ $$
55
+
56
+ where the expectation is over all denoising timesteps, $\tau \sim \mathcal { U } [ 1 , T ]$ , and observations and actions are drawn from a demonstration dataset, $\mathbf { o } , \mathbf { a } \sim \mathcal { D }$ .
57
+
58
+ At sampling time, with further variance schedule parameters $\alpha _ { \tau }$ & $\sigma$ , inputs are iteratively denoised:
59
+
60
+ $$
61
+ \mathbf { a } _ { \tau - 1 } = \frac { 1 } { \sqrt { \alpha _ { \tau } } } \left( \mathbf { a } _ { \tau } - \frac { 1 - \alpha _ { \tau } } { \sqrt { 1 - \bar { \alpha } _ { \tau } } } \epsilon ( \mathbf { o } , \mathbf { a } _ { \tau } , \tau ) \right) + \sigma _ { \tau } \mathbf { z } .
62
+ $$
63
+
64
+ # 3.2 ARCHITECTURAL DESIGN
65
+
66
+ This section explores neural network architectures for observation-to-action diffusion models. Specifically, the requirements of the network are: Input: Noisy action $\mathbf { a } _ { \tau - 1 } \in \mathbb { R } ^ { | \mathbf { a } | }$ , denoising timestep $\tau$ , observation $\mathbf { o }$ (possibly with a history); Output: Predicted noise mask, $\hat { \mathbf { z } } \in \mathbb { R } ^ { | \mathbf { a } | }$ .
67
+
68
+ ![](images/bc2e84a5a9b89db300a730ac2bb0d68dfdb5bfd95a895c32ae2c536c7c31b723.jpg)
69
+ Figure 2: Diffusion BC generates an action vector conditioned on an observation (which may be an image). By contrast, text-to-image diffusion models generate an image conditioned on a vector.
70
+
71
+ While U-Nets have become standard components of text-to-image diffusion models, their use only makes sense for large, spatial input and outputs, while we require generation of an action vector of modest dimensionality. Therefore, we now describe three architectures of varying complexity. Section 4 empirically assesses these three architectures, finding performance improvements in the order: Basic $\mathbf { M L P } < \mathbf { M L P }$ Sieve $<$ Transformer.
72
+
73
+ Basic MLP. This architecture directly concatenates all relevant inputs together, $[ \mathbf { a } _ { \tau - 1 } , \mathbf { o } , \tau ]$ . This input is fed into a multi-layer perceptron (MLP).
74
+
75
+ MLP Sieve. This uses three encoding networks to produce embeddings of the observation, denoising timestep, and action: $\mathbf { o } ^ { e } , \mathbf { t } ^ { e } , \mathbf { a } _ { \tau - 1 } ^ { e } \in \mathbb { R } ^ { \mathrm { e m b e d d i m } }$ . These are concatenated together as input to a denoising network, $[ \mathbf { o } ^ { e } , \mathbf { t } ^ { e } , \mathbf { a } _ { \tau - 1 } ^ { e } ]$ . The denoising network is a fully-connected architecture, with residual skip connections, and with the raw denoising timestep $\tau$ and action $\mathbf { a } _ { \tau - 1 }$ repeatedly concatenated after each hidden layer. To include a longer observation history, previous observations are passed through the same embedding network, and embeddings are concatenated together.
76
+
77
+ Transformer. This creates embeddings as for MLP Sieve. A multi-headed attention architecture (Vaswani et al., 2017) (as found in modern transformer encoder networks) is then used as the denoising network. At least three tokens are used as input, $\mathbf { o } ^ { e } , \mathbf { t } ^ { e } , \mathbf { a } _ { \tau - 1 } ^ { e }$ , and this can be extended to incorporate a longer history of observations (only the current $\mathbf { t } ^ { e }$ , $\mathbf { a } _ { \tau - 1 } ^ { e }$ are needed since the diffusion process is Markovian).
78
+
79
+ Sampling rate. The MLP Sieve and Transformer are carefully designed so the observation encoder is separate from the denoising network. At test time, this means only a single forward pass is required for the observation encoder, with multiple forward passes run through the lighter denoising network. This results in a manageable sampling time – in the experiment playing a video game from pixels (section 4.2), we were able to roll out our diffusion models at $8 \mathrm { H z }$ on an average gaming GPU (NVIDIA GTX 1060 Mobile). Table 6 provides a detailed breakdown. Note that sampling time is a more severe issue in text-to-image diffusion models, where forward passes of the heavy U-Net architectures are required for all denoising timesteps.
80
+
81
+ # 3.3 WHY CLASSIFIER-FREE GUIDANCE FAILS
82
+
83
+ Classifier-Free Guidance (CFG) has become a core ingredient for text-to-image models, allowing one to trade-off image typicality with diversity (Ho and Salimans, 2021). In CFG, a neural network is trained as both a conditional and unconditional generative model. During sampling, by introducing a ‘guidance weight’ $w$ , one places a higher weight $( w > 0 )$ ) on the prediction conditioned on some context (here, o), and a negative weight on the unconditional prediction,
84
+
85
+ $$
86
+ \hat { \mathbf { z } } _ { \tau } = ( 1 + w ) \epsilon _ { \mathrm { c o n d . } } ( \mathbf { a } _ { \tau - 1 } , \mathbf { o } , \tau ) - w \epsilon _ { \mathrm { u n c o n d . } } ( \mathbf { a } _ { \tau - 1 } , \tau ) .
87
+ $$
88
+
89
+ One might anticipate that CFG would also be beneficial in the sequential setting, with larger $w$ producing trajectories of higher likelihood, but at the cost of the diversity. Surprisingly, we find that CFG can actually encourage less common trajectories, and degrade performance.
90
+
91
+ ![](images/23da03461ee0ace66a7008b53e55f78ffe8cce854f74ca29d1825977b8db6f5b.jpg)
92
+ Figure 3: We vary the CFG ‘weight’ parameter $w$ value in Eq. 3) during sampling in the Arcade Claw environment. CFG encourages selection of actions that were specific to an observation (maximising $p ( \mathbf { o } | \mathbf { a } ) .$ ). This can lead to less common trajectories being sampled more often.
93
+
94
+ In Figure 3 we visualise $\hat { p } ( \mathbf { a } | \mathbf { o } )$ for the claw machine game, under varying guidance strengths, $w$ . An interpretation of CFG is that it encourages sampling of actions that would maximise an implicit classifier, $p ( \mathbf { o } | \mathbf { a } )$ . Hence, CFG encourages selection of actions that were unique to a particular observation (Ho et al., 2022). Whilst this is useful for text-to-image models (generate images that are more specific to a prompt), in sequential environments this leads to an agent rejecting higherlikelihood actions in favour of less usual ones that were paired with some observation. In later experiments (section 4.1) we demonstrate empirically that this can lead to less common trajectories being favoured, while degrading overall performance. Appendix E provides a didactic example of when CFG fails in this way.
95
+
96
+ # 3.4 RELIABLE SAMPLING SCHEMES
97
+
98
+ In text-to-image diffusion, several samples are typically generated in parallel, allowing the user to select their favourite, and ignore any failures. However, when rolling out an observation-to-action diffusion model, such manual screening is not feasible. There remains a risk that a bad action could be selected during a roll-out, which may send an agent toward an out-of-distribution state. Hence, we propose ‘Diffusion- $\mathbf { \nabla } \cdot \mathbf { X } ^ { \prime }$ and ‘Diffusion-KDE’ as variants of Diffusion BC, that mirror this screening process by encouraging higher-likelihood actions during sampling. For both methods, the training procedure is unchanged (only the conditional version of the model is required). The algorithms for all sampling methods are given in appendix D.
99
+
100
+ Diffusion- $\mathbf { X }$ . The sampling process runs as normal for $T$ denoising timesteps. The denoising timestep is then fixed, $\tau = 1$ , and extra denoising iterations continue to run for $M$ timesteps. The intuition behind this is that samples continue to be moved toward higher-likelihood regions.
101
+
102
+ Diffusion-KDE. Generate multiple action samples from the diffusion model as usual (these can be done in parallel). Fit a simple kernel-density estimator (KDE) over all samples, and score the likelihood of each. Select the action with the highest likelihood.
103
+
104
+ ![](images/101751faefc7c2dbc48f6646432112a87e7a4e9e480ec11b696cebcf0bc750b9.jpg)
105
+ Figure 4: This figure shows the predictive distributions of diffusion models using various sampling schemes. When $M = 0$ this is ‘Diffusion BC’ and when $M > 0$ this is ‘Diffusion-X’. Diff. KDE refers to ‘Diffusion-KDE’.
106
+
107
+ The effect of these sampling modifcations is demonstrated in Figure 4. While Diffusion BC generates a small number of actions that fall outside of the true $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ region, Diffusion-X and DiffusionKDE avoid these bad actions. Note that the two distinct modes in the figure are recovered by both sampling methods, suggesting that multimodality is not compromised, though the diversity within each mode is reduced. Both techniques are simple to implement, and experiments in Section 4 show their benefit.
108
+
109
+ # 4 EXPERIMENTS
110
+
111
+ This section empirically investigates the efficacy of diffusion models for BC. We assess our method in two complex sequential environments, which have large human datasets available, with the aim of answering several questions: $Q I$ ) How do diffusion models compare to existing baseline methods for BC, in terms of matching the demonstration distribution? Section 4.1 compares to four popular modelling choices in BC, as well as recent state-of-the-art models. Section 4.2 provides further focused comparisons. $Q 2$ ) How is performance affected by the architectures designed in section 3.2, CFG, and the sampling schemes in section 3.4? We provide full ablations in Section 4.1, and targeted ablations over sampling schemes in Section 4.2. Q3) Can diffusion models scale to complex environments efficiently? Section 4.2 tests on an environment where the observation is a high-resolution image, the action space is mixed continuous & discrete, and there are strict time constraints for sampling time.
112
+
113
+ Evaluation. To evaluate how closely methods imitate human demonstrations, we compare the behaviours of our models with those of the humans in the dataset. To do so, we will compare both at a high-level, analysing observable outcomes (e.g. tasks completions or game score), as well as at a low-level comparing the stationary distributions over states or actions. Both of these are important in evaluating how humanlike our models are, and provide complimentary analyses. Appendix B provides details on our evaluation metrics, which are introduced less formally here.
114
+
115
+ Baselines. Where applicable we include Human to indicate the metrics achieved by samples drawn from the demonstration dataset itself. We then re-implement five baselines. Three correspond to popular BC modelling choices, namely MSE: a model trained via mean squared error; Discretised: each action dimension is discretised into 20 uniform bins, then trained independently via crossentropy; and $K$ -means: a set of $K$ candidate actions are first produced by running K-means over all actions, actions are discretised into their closest bin, and the model is trained via cross-entropy. A further two baselines can be considered strong, more complex methods, namely $K \cdot$ -means $^ +$ Residual: as with K-means, but additionally learns a continuous residual on top of each bin prediction, trained via MSE, which was the core innovation of Behaviour Transformers (BeT) (Shafiullah et al., 2022); and EBM: a generative energy-based model trained with a contrastive loss, proposed in (Florence et al., 2022) – full details about the challenges of this method given in Appendix B.4.
116
+
117
+ One of our experiments uses the set up from Shafiullah et al. (2022), allowing us to compare to their reported results, including Behaviour Transformers (BeT): the K-mean+residual combined with a large 6-layer transformer, and previous 10 observations as history; Implicit BC: the official implementation of energy-based models for BC (Florence et al., 2022); SPiRL: using a VAE, originally from Pertsch et al. (2021); and PARROT: a flow-based model, originally from Singh et al. (2020).
118
+
119
+ Architectures & Hyperparameters. We trial the three architecture options described in Section 3.2, which are identical across both the five re-implemented baseline methods and our diffusion variants (except where required for output dimensionality). Basic MLP and MLP Sieve both use networks with GELU activations and 3 hidden-layers of 512 units each. Transformer uses four standard encoder blocks, each with 16 attention heads. Embedding dimension is 128 for MLP Sieve and Transformer. Appendix B gives full hyperparameter details.
120
+
121
+ # 4.1 LEARNING ROBOTIC CONTROL FROM HUMAN DEMONSTRATION
122
+
123
+ In this environment, an agent controls a robotic arm inside a simulated kitchen. It is able to perform seven tasks of interest, such as opening a microwave, or turning on a stove (Appendix B contains full details). The demonstration dataset contains 566 trajectories. These were collected using a virtual reality setup, with a human’s movements translated to robot joint actuations (Gupta et al.,
124
+
125
+ 2020). Each demonstration trajectory performed four predetermined tasks. There are 25 different task sequences present in the dataset, of roughly equal proportion.
126
+
127
+ This environment has become a popular offline RL benchmark for learning reward-maximising policies (Fu et al., 2020). However, as our goal is to learn the full distribution of demonstrations, we instead follow the setup introduced by Shafiullah et al. (2022), which ignores any goal conditioning and aims to train an agent that can recover the full set of demonstrating policies.
128
+
129
+ The kitchen environment’s observation space is a 30-dimensional continuous vector containing information about the positions of the objects and robot joints. The action space is a 9-dimensional continuous vector of joint actuations. All models receive the previous two observations as input, allowing the agent to infer velocities. For diffusion models, we set $T = 5 0$ .
130
+
131
+ The kitchen environment is challenging for several reasons. 1) Strong (sometimes non-linear) correlations exist between action dimensions. 2) There is multimodality in $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ at the point the agent selects which task to complete next, and also in how it completes it. We show that our diffusion model learns to represent both these properties in Figure 9, which visualises relationships between all action dimensions during one rollout.
132
+
133
+ # 4.1.1 MAIN RESULTS
134
+
135
+ Comparing the behaviour of our agents with that of the humans demonstrations is a challenging research problem in its own right. Table 1 presents several metrics that provide insight into how closely models match the human demonstrations – from high-level analysis of task sequences selected, to low-level statistics of the observation trajectories generated by models. We briefly summarise these, more technical descriptions can be found in Appendix B. Training and sampling times of methods are given in Table 6.
136
+
137
+ Tasks $\geq 4$ . We first measure the proportion of rollouts for which models perform four valid tasks, which nearly all human demonstrations achieve.
138
+
139
+ Tasks Wasserstein. For each method we record how many times each different task sequence was completed during rollouts. The Wasserstein distance is then computed between the resulting histogram, compared to the human distribution.
140
+
141
+ Time Wasserstein. As well as analysing which tasks were completed, we also analyse when they were completed. Figure 5 plots the distribution of the time taken to complete different numbers of tasks (normalised to exclude failures), for MSE and Diffusion-X. We then compute the Wasserstein distance between the human and agent distributions (see Appendix C for a full break down.)
142
+
143
+ State Wasserstein. If we truly capture the full diversity and fidelity of human behaviour present in the dataset, this will be reflected in the state occupancy distribution. We compute the Wasserstein between agent and human distributions, with a lower value indicating they are more similar.
144
+
145
+ Density & Coverage. We use the ‘Density’ and ‘Coverage’ metrics from Naeem et al. (2020) that are used to evaluate GANs. Roughly speaking ‘Density’ corresponds to how many states from human trajectories are close to the agent’s states and ‘Coverage’ corresponds to the proportion of human states that have an agent generated state nearby.
146
+
147
+ In terms of task-completion rate, our Diffusion BC approaches outperform all baselines, with the ordering; Diffusion $\mathbf { B C } <$ Diffusion $\mathbf { X } { < }$ Diffusion-KDE. This ordering supports our hypothesis that these sampling schemes more reliably avoid bad actions. These improvements come at the cost of increased sampling time – for MLP Sieve, sampling rate drops from $1 6 \ : \mathrm { H z }$ for Diffusion BC to 14 $\mathrm { H z }$ for Diffusion- $\mathbf { \nabla } \cdot \mathbf { X }$ to $1 2 \ : \mathrm { H z }$ for Diffusion-KDE (Table 6).
148
+
149
+ For all Wasserstein metrics, diffusion models again outperform other baselines, and sampling schemes are usually ordered Diffusion KDE $\checkmark$ Diffusion $\mathbf { B C } <$ <Diffusion-X. This is important; while Diffusion-KDE completes more tasks, it signals a tendency to overfit to a smaller number of task sequences, generating less of the diversity from the demonstration distribution. This is quantitatively confirmed by Diffusion-KDE scoring significantly higher Density, but lower Coverage.
150
+
151
+ Architecture ablation. In terms of the different architectures designed in Section 3.2, Table 1 shows that metrics usually improve in order: Basic MLP $<$ <MLP Sieve $<$ Transformer. These improvements do come at the cost of increased training and inference time – for Diffusion BC the sampling rate drops from $2 4 \ : \mathrm { H z }$ for MLP Basic to $1 6 \ : \mathrm { H z }$ for MLP Sieve to $4 \ : \mathrm { H z }$ for transformer (Table 6).
152
+
153
+ Table 1: Robotic control results. Mean $\pm$ one standard error over three training runs (100 rollouts). Methods marked with asterisk $( ^ { * } )$ are our proposed methods.
154
+
155
+ <table><tr><td></td><td>Tasks ≥4个</td><td>Tasks Wasserstein</td><td>Time Wasserstein</td><td>State Wasserstein </td><td>Density↑</td><td>Coverage↑</td></tr><tr><td>MLPBasic Architecture</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>*Diffusion BC, Basic MLP</td><td>0.45 ± 0.03</td><td>1.96 ± 0.12</td><td>12.04 ± 2.20</td><td>0.463 ± 0.012</td><td>0.54 ± 0.02</td><td>0.38 ±0.01</td></tr><tr><td>*Diffusion-KDE,Basic MLP</td><td>0.59 ± 0.01</td><td>1.72 ± 0.03</td><td>8.08 ±0.24</td><td>0.481 ± 0.005</td><td>0.78 ±0.00</td><td>0.37 ± 0.00</td></tr><tr><td>*Diffusion-X, Basic MLP</td><td>0.58 ±0.02</td><td>1.51 ± 0.14</td><td>8.61 ± 0.14</td><td>0.424 ± 0.017</td><td>0.64±0.00</td><td>0.41 ± 0.00</td></tr><tr><td>MLP Sieve Architecture</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>MSE,MLP Sieve</td><td>0.5 ±0.02</td><td>1.91 ± 0.07</td><td>6.40 ± 0.48</td><td>0.443 ± 0.021</td><td>0.71 ± 0.01</td><td>0.40 ± 0.01</td></tr><tr><td>Discretised,MLP Sieve</td><td>0.18 ± 0.02</td><td>3.43 ± 0.14</td><td>11.30 ± 1.29</td><td>0.651 ± 0.026</td><td>0.38 ±0.02</td><td>0.31 ± 0.01</td></tr><tr><td>K-Means,MLP Sieve</td><td>0.0±0.0</td><td>5.25 ± 0.0</td><td></td><td>1.469 ± 0.120</td><td>0.09 ±0.00</td><td>0.06±0.00</td></tr><tr><td>K-Means+Residual,MLP Sieve</td><td>0.23 ±0.02</td><td>2.87 ± 0.16</td><td>11.60 ± 2.11</td><td>0.607 ± 0.027</td><td>0.51 ± 0.01</td><td>0.36 ±0.00</td></tr><tr><td>EBMDeriv-Free,MLP Sieve</td><td>0.0</td><td>一</td><td>一</td><td></td><td></td><td></td></tr><tr><td>*Diffusion BC,MLP Sieve</td><td>0.68 ±0.02</td><td>1.31 ± 0.05</td><td>6.06 ± 1.10</td><td>0.373 ± 0.012</td><td>0.66 ± 0.01</td><td>0.42 ± 0.00</td></tr><tr><td>*Diffusion-KDE,MLP Sieve</td><td>0.79 ± 0.04</td><td>1.6 ± 0.24</td><td>6.77 ± 0.64</td><td>0.439 ± 0.039</td><td>0.93 ±0.02</td><td>0.41 ± 0.01</td></tr><tr><td>*Diffusion-X,MLP Sieve</td><td>0.77 ± 0.02</td><td>1.06 ± 0.05</td><td>5.24 ± 0.90</td><td>0.344 ± 0.004</td><td>0.78 ± 0.01</td><td>0.45±0.00</td></tr><tr><td>Transformer Architecture</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>MSE,Transformer</td><td>0.69 ± 0.02</td><td>1.47 ± 0.13</td><td>5.85 ± 0.27</td><td>0.397 ± 0.034</td><td>0.81 ± 0.01</td><td>0.42 ± 0.01</td></tr><tr><td>Discretised, Transformer</td><td>0.34 ±0.02</td><td>2.54 ± 0.14</td><td>6.13 ± 0.49</td><td>0.512 ± 0.002</td><td>0.47 ± 0.01</td><td>0.36±0.00</td></tr><tr><td>K-Means,Transformer</td><td>0.0</td><td>5.25</td><td></td><td>1.470</td><td>0.07</td><td>0.06</td></tr><tr><td>K-Means+Residual, Transformer</td><td>0.34±0.02</td><td>2.25 ± 0.16</td><td>7.80 ± 0.87</td><td>0.426 ± 0.018</td><td>0.66 ± 0.02</td><td>0.38 ± 0.01</td></tr><tr><td>*Diffusion BC,Transformer</td><td>0.77 ± 0.01</td><td>1.35 ± 0.11</td><td>4.11 ± 0.05</td><td>0.340 ±0.003</td><td>0.74 ± 0.01</td><td>0.44± 0.00</td></tr><tr><td>*Diffusion-KDE,Transformer</td><td>0.89 ± 0.01</td><td>1.31 ± 0.03</td><td>5.28 ± 0.41</td><td>0.418 ± 0.012</td><td>0.97 ± 0.02</td><td>0.43 ± 0.01</td></tr><tr><td>*Diffusion-X,Transformer</td><td>0.88 ± 0.01</td><td>1.17 ± 0.13</td><td>4.65 ± 0.47</td><td>0.365 ± 0.013</td><td>0.94 ± 0.02</td><td>0.45 ± 0.01</td></tr><tr><td>From Shafiullah et al. (2022)</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Behaviour Transformers</td><td>0.44</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Implicit BC</td><td>0.24</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SPiRL VAE</td><td>0.0</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PARROT Normalizing Flow</td><td>0.0</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Dataset</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Human</td><td>0.98</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Human sub-sampled</td><td>二</td><td></td><td></td><td>0.223 ±0.006</td><td>1.00 ± 0.01</td><td>0.56± 0.01</td></tr></table>
156
+
157
+ # 4.1.2 CLASSIFIER FREE GUIDANCE ANALYSIS
158
+
159
+ Section 3.3 provided intuition for why we expect CFG to fail in observation-to-sequence models. We now test our hypotheses empirically. During training the observation embedding is randomly masked with zeros with probability 0.1. This allows us to learn both a conditional and unconditional generative model. We then perform rollouts under different guidance weights, $w \in \{ 0 , 1 , 4 , 8 \}$ , measuring the rate of completion of 4 tasks and monitoring which task the agent completes first.
160
+
161
+ Table 2 shows that completion rate drops from 0.63 without guidance $\boldsymbol { w } = 0$ ) to 0.08 with strong guidance $( w = 8 )$ ). Meanwhile, CFG also creates a strong bias towards selection of Bottom Burner as the first task. This is significant as the human demonstrators select Bottom Burner just $10 \%$ of the time, but this increases from $7 \%$ (no guidance, $w = 0$ ) to $2 5 \%$ (strong guidance, $w = 8$ ), showing that CFG encourages less usual trajectories.
162
+
163
+ ![](images/43e647fc065afa85822390d82c261f12c922cb9bf3740f7201f622a4bc52acd3.jpg)
164
+ Figure 5: Time to complete robotic control kitchen tasks. Shaded: Human demonstrations. Left: MSE Transformer, Right: Diffusion-X Transformer.
165
+
166
+ Table 2: Effect of CFG for Diffusion BC, MLP Sieve. Mean over three training runs (100 rollouts).
167
+
168
+ <table><tr><td colspan="6">First task peformed</td></tr><tr><td></td><td>Tasks ≥4↑</td><td>Microwave</td><td>Kettle1</td><td>Bottom Burner</td><td>Other/Failure</td></tr><tr><td>Guidance w = 0.0</td><td>0.63</td><td>62.3</td><td>29.7</td><td>7.3</td><td>0.7</td></tr><tr><td>Guidance w = 1.0</td><td>0.61</td><td>57.3</td><td>30.0</td><td>12.7</td><td>0.0</td></tr><tr><td>Guidance w = 4.0</td><td>0.45</td><td>52.7</td><td>28.3</td><td>17.0</td><td>2.0</td></tr><tr><td>Guidance w = 8.0</td><td>0.08</td><td>24.0</td><td>26.7</td><td>24.7</td><td>25.6</td></tr><tr><td>Human Demonstrations</td><td>0.63</td><td>58.3</td><td>31.6</td><td>10.1</td><td>0.0</td></tr></table>
169
+
170
+ # 4.2 MODELLING HUMAN GAMEPLAY IN A VIDEO GAME
171
+
172
+ We further tested our models in the environment ‘Counter-Strike: Global Offensive’ (CSGO) introduced by Pearce and Zhu (2022) (https://github.com/TeaPearce/Counter-Strike Behavioural_Cloning). CSGO is one of the world’s most popular video games in player and spectator numbers. We use the ‘aim train’ environment, where a player is fixed on a platform in the center of a map, and must defend themselves against enemies controlled by built-in AI, who rush towards the player. Success requires precise and coordinated control over a mixed continuous & discrete action space, as well as dealing with multimodality in target selection and aiming.
173
+
174
+ The demonstration dataset contains 45,000 observation/action tuples, recorded from a high-skill human player. Observations are $2 8 0 \times 1 5 0$ RGB images, and the action space is three dimensional – mouse $x \in \mathbb { R }$ , mouse $y \in \mathbb { R }$ , left click $\in \{ 0 , 1 \}$ . The environment runs asynchronously at a fixed rate, providing a rigorous test of sampling speed of models. Due to this constraint, we test only the MLP Sieve architecture, which offers a good trade-off between inference speed and performance. We also exclude the slightly slower Diffusion-KDE sampling method. $T$ is set to 20.
175
+
176
+ For baselines, we compare to MSE, discretised, and K-Means+Residual which were the strongest baselines in the kitchen environment. We also include EBM using derivative-free optimisation. We consider two options for the observation encoder: 1) a lightweight CNN, and 2) a ResNet18 with ImageNet weights. Diffusion models use 20 denoising timesteps, and Discrete uses 20 bins per action dimension. For MSE, we optimise the left click action via binary cross-entropy and mouse $x$ & y via MSE. Appendix B provides further details on hyperparameters and metrics.
177
+
178
+ Table 3 reports results. Diffusion-X performs best across both observation encoders in terms of game score and distance to the human distribution, which was measured as the Wasserstein distance on the actions predicted (grouped into sequences of different lengths to assess the temporal consistency). Training and sampling times of methods are given in Table 6. Diffusion-X runs at $1 8 \ : \mathrm { H z }$ compared to $2 0 0 \mathrm { H z }$ for MSE. Training time is similar.
179
+
180
+ Table 3: Video game results, mean over three rollouts of 10 minutes. Methods marked with asterisk $( ^ { * } )$ are our proposed methods.
181
+
182
+ <table><tr><td colspan="4">Wasserstein Distance,Human to Model↓</td></tr><tr><td></td><td>Game Score ↑1×timesteps16×timesteps (1 sec)32×timesteps(2 sec)</td><td></td><td></td></tr><tr><td colspan="4"></td></tr><tr><td>Observation encoder: 6-layer CNN</td><td></td><td></td><td></td></tr><tr><td>MSE,MLP Sieve</td><td>6.9</td><td>19.0 37.6</td><td>54.7</td></tr><tr><td>Discrete,MLP Sieve</td><td>7.8</td><td>12.9 35.0</td><td>55.9</td></tr><tr><td>*Diffusion BC,MLP Sieve</td><td>12.9</td><td>14.3</td><td>34.5 52.8</td></tr><tr><td>*Diffusion-X,MLP Sieve</td><td>17.3</td><td>11.7 30.0</td><td>47.8</td></tr><tr><td colspan="4"></td></tr><tr><td>Observation encoder:ResNet18 MSE,MLP Sieve</td><td>17.8</td><td>5.5 28.1</td><td>48.9</td></tr><tr><td></td><td>14.7</td><td>6.6 31.3</td><td>53.0</td></tr><tr><td>Discrete,MLP Sieve</td><td>16.8</td><td>3.8 29.2</td><td>51.8</td></tr><tr><td>K-Means+Residual,MLP Sieve</td><td>4.3</td><td>17.2 50.0</td><td>74.1</td></tr><tr><td>EBMDerivative-Free,MLP Sieve *Diffusion BC,MLP Sieve</td><td>19.0</td><td>6.3 29.5</td><td>50.4</td></tr><tr><td>*Diffusion-X,MLP Sieve</td><td>24.0</td><td>4.5 24.5</td><td>44.4</td></tr><tr><td colspan="4"></td></tr><tr><td>Baselines Human</td><td>36.5</td><td>0.73 0.57</td><td>0.38</td></tr></table>
183
+
184
+ # 5 DISCUSSION & CONCLUSION
185
+
186
+ This paper provided the first thorough investigation into using diffusion models for imitating human behaviour. Existing modelling choices in BC make various approximations that simplify the learning problem. But these approximations come at a cost: they introduce limitations and biases on the cloned policy, which we systematically identified in section 2. Recent developments in generative modelling for images have shown that diffusion models are capable of learning arbitrarily complex conditional distributions, and are stable to train. This paper has combined these two worlds, proposing that diffusion models are also an excellent fit for learning the complex observation-to-action distributions found in datasets of humans behaving in sequential environments. Our key insight is that, unlike many modelling choices for BC, diffusion models make no coarse approximations on the target distribution, so avoid many of their shortcomings.
187
+
188
+ Diffusion models do come with several limitations. They increase inference time – MSE model can sample actions at $6 6 6 \ : \mathrm { H z }$ and $2 0 0 \ : \mathrm { H z }$ in the kitchen and CSGO environments, while Diffusion BC samples at $1 6 \ \mathrm { H z }$ and $3 2 \ \mathrm { H z }$ . They also introduce several new hyperparameters. Finally, our diffusion models address only one challenge in imitation learning – that of learning complex action distributions at a single environment timestep. There are other open challenges they do not address such as learning correlations across environment timesteps.
189
+
190
+ This paper contributed several innovations to successfully adapt diffusion models to the observationto-action domain. Our experiments demonstrated the effectiveness of these with several key takeaways. 1) Diffusion models offer improvements over other methods in matching the demonstrations in terms of reward and distribution. 2) Reliable sampling schemes Diffusion-X and Diffusion-KDE offer benefits over Diffusion BC. 3) Good architecture design is important to the success of Diffusion models, allowing trade-off of performance and sampling speed. 4) CFG should be avoided as a mechanism to condition on observations for diffusion agents in sequential environments.
191
+
192
+ Experiments support our hypothesis that, by avoiding coarse approximations about the action distribution, diffusion models improve over existing methods at modelling human demonstrations. On a complex control task, diffusion models achieved a task completion rate of $89 \%$ , exceeding recent state-of-the-art of $44 \%$ . We also demonstrated that our models can scale to learn directly from image observations, on a mix of continuous and discrete actions, sampling actions at $1 8 \ \mathrm { H z }$ . This demonstrates the possibility of applying our models in complex, real-world settings.
193
+
194
+ # REFERENCES
195
+
196
+ Anurag Ajay, Yilun Du, Abhi Gupta, Joshua Tenenbaum, Tommi Jaakkola, and Pulkit Agrawal. Is conditional generative modeling all you need for decision-making? International Conference on Learning Representations, 2023.
197
+ Micah Carroll, Rohin Shah, Mark K Ho, Tom Griffiths, Sanjit Seshia, Pieter Abbeel, and Anca Dragan. On the utility of learning about humans for human-ai coordination. Advances in neural information processing systems, 32, 2019.
198
+ Robert Dadashi, Leonard Hussenot, Matthieu Geist, and Olivier Pietquin. Primal wasserstein imitation learning. In International Conference on Learning Representations, 2020.
199
+ Allan Dafoe, Edward Hughes, Yoram Bachrach, Tantum Collins, Kevin R McKee, Joel Z Leibo, Kate Larson, and Thore Graepel. Open problems in cooperative ai. arXiv preprint arXiv:2012.08630, 2020.
200
+ Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021.
201
+ Remi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z. Alaya, Aur ´ elie Boisbunon, Stanis- ´ las Chambon, Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, Leo Gautheron, ´ Nathalie T.H. Gayraud, Hicham Janati, Alain Rakotomamonjy, Ievgen Redko, Antoine Rolet, Antony Schutz, Vivien Seguy, Danica J. Sutherland, Romain Tavenard, Alexander Tong, and Titouan Vayer. Pot: Python optimal transport. Journal of Machine Learning Research, 22(78): 1–8, 2021.
202
+
203
+ Pete Florence, Corey Lynch, Andy Zeng, Oscar A Ramirez, Ayzaan Wahid, Laura Downs, Adrian Wong, Johnny Lee, Igor Mordatch, and Jonathan Tompson. Implicit behavioral cloning. In Conference on Robot Learning, pages 158–168. PMLR, 2022.
204
+
205
+ Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. Datasets for data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
206
+
207
+ Seyed Kamyar Seyed Ghasemipour, Richard Zemel, and Shixiang Gu. A divergence minimization perspective on imitation learning methods. In Leslie Pack Kaelbling, Danica Kragic, and Komei Sugiura, editors, Proceedings of the Conference on Robot Learning, volume 100 of Proceedings of Machine Learning Research, pages 1259–1277. PMLR, 30 Oct–01 Nov 2020.
208
+
209
+ Abhishek Gupta, Vikash Kumar, Corey Lynch, Sergey Levine, and Karol Hausman. Relay policy learning: Solving long-horizon tasks via imitation and reinforcement learning. In Conference on Robot Learning, pages 1025–1037. PMLR, 2020.
210
+
211
+ William Hebgen Guss, Stephanie Milani, Nicholay Topin, Brandon Houghton, Sharada Mohanty, Andrew Melnik, Augustin Harter, Benoit Buschmaas, Bjarne Jaster, Christoph Berganski, Dennis Heitkamp, Marko Henning, Helge Ritter, Chengjie Wu, Xiaotian Hao, Yiming Lu, Hangyu Mao, Yihuan Mao, Chao Wang, Michal Opanowicz, Anssi Kanervisto, Yanick Schraner, Christian Scheller, Xiren Zhou, Lu Liu, Daichi Nishio, Toi Tsuneda, Karolis Ramanauskas, and Gabija Juceviciute. Towards robust and domain agnostic reinforcement learning competitions: Minerl 2020. In Proceedings of the NeurIPS 2020 Competition and Demonstration Track, 2021.
212
+
213
+ William Harvey, Saeid Naderiparizi, Vaden Masrani, Christian Weilbach, and Frank Wood. Flexible diffusion modeling of long videos. 2022. URL http://arxiv.org/abs/2205.11495.
214
+
215
+ Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. Advances in neural information processing systems, 29, 2016.
216
+
217
+ Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
218
+
219
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
220
+
221
+ Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang, Ruiqi Gao, Alexey Gritsenko, Diederik P Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303, 2022.
222
+
223
+ Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In International Conference on Learning Representations, 2019.
224
+
225
+ Ahmed Hussein, Mohamed Medhat Gaber, Eyad Elyan, and Chrisina Jayne. Imitation learning: A survey of learning methods. ACM Computing Surveys, 50(2):1–35, 2017.
226
+
227
+ Leonard Hussenot, Marcin Andrychowicz, Damien Vincent, Robert Dadashi, Anton Raichuk, ´ Sabela Ramos, Nikola Momchev, Sertan Girgin, Raphael Marinier, Lukasz Stafiniak, et al. Hyperparameter selection for imitation learning. In International Conference on Machine Learning, pages 4511–4522. PMLR, 2021.
228
+
229
+ Michael Janner, Yilun Du, Joshua Tenenbaum, and Sergey Levine. Planning with diffusion for flexible behavior synthesis. In International Conference on Machine Learning, 2022.
230
+
231
+ Liyiming Ke, Sanjiban Choudhury, Matt Barnes, Wen Sun, Gilwoo Lee, and Siddhartha Srinivasa. Imitation learning as f-divergence minimization. In International Workshop on the Algorithmic Foundations of Robotics, pages 313–329. Springer, 2020.
232
+
233
+ Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. Diffwave: A versatile diffusion model for audio synthesis. In International Conference on Learning Representations, 2020.
234
+
235
+ Chu-Cheng Lin, Aaron Jaech, Xin Li, Matthew R Gormley, and Jason Eisner. Limitations of autoregressive models and their alternatives. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5147–5173, 2021.
236
+
237
+ Reuth Mirsky, Ignacio Carlucho, Arrasy Rahman, Elliot Fosong, William Macke, Mohan Sridharan, Peter Stone, and Stefano V Albrecht. A survey of ad hoc teamwork: Definitions, methods, and open problems. arXiv preprint arXiv:2202.10450, 2022.
238
+
239
+ Muhammad Ferjad Naeem, Seong Joon Oh, Youngjung Uh, Yunjey Choi, and Jaejun Yoo. Reliable fidelity and diversity metrics for generative models. In International Conference on Machine Learning, pages 7176–7185. PMLR, 2020.
240
+
241
+ Manu Orsini, Anton Raichuk, Leonard Hussenot, Damien Vincent, Robert Dadashi, Sertan Girgin, ´ Matthieu Geist, Olivier Bachem, Olivier Pietquin, and Marcin Andrychowicz. What matters for adversarial imitation learning? Advances in Neural Information Processing Systems, 34:14656– 14668, 2021.
242
+
243
+ Tim Pearce and Jun Zhu. Counter-strike deathmatch with large-scale behavioural cloning. In 2022 IEEE Conference on Games (CoG), pages 104–111. IEEE, 2022.
244
+
245
+ Karl Pertsch, Youngwoon Lee, and Joseph Lim. Accelerating reinforcement learning with learned skill priors. In Conference on robot learning, pages 188–204. PMLR, 2021.
246
+
247
+ Dean A Pomerleau. Efficient training of artificial neural networks for autonomous navigation. Neural computation, 3(1):88–97, 1991.
248
+
249
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, April 2022.
250
+
251
+ Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent. arXiv preprint arXiv:2205.06175, 2022.
252
+
253
+ Stephane Ross, Geoffrey J Gordon, and J Andrew Bagnell. A reduction of imitation learning and ´ structured prediction to no-regret online learning. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, 2011.
254
+
255
+ Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S. Sara Mahdavi, Rapha Gontijo Lopes, Tim Salimans, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, May 2022.
256
+
257
+ Nur Muhammad Mahi Shafiullah, Zichen Jeff Cui, Ariuntuya Altanzaya, and Lerrel Pinto. Behavior transformers: Cloning $k$ modes with one stone. Advances in neural information processing systems, 2022.
258
+
259
+ Avi Singh, Huihan Liu, Gaoyue Zhou, Albert Yu, Nicholas Rhinehart, and Sergey Levine. Parrot: Data-driven behavioral priors for reinforcement learning. arXiv preprint arXiv:2011.10024, 2020.
260
+
261
+ Akash Srivastava, Lazar Valkov, Chris Russell, Michael U Gutmann, and Charles Sutton. Veegan: Reducing mode collapse in gans using implicit variational learning. Advances in neural information processing systems, 30, 2017.
262
+
263
+ DJ Strouse, Kevin McKee, Matt Botvinick, Edward Hughes, and Richard Everett. Collaborating with humans without human data. Advances in Neural Information Processing Systems, 34: 14502–14515, 2021.
264
+
265
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
266
+
267
+ Zhendong Wang, Jonathan J Hunt, and Mingyuan Zhou. Diffusion policies as an expressive policy class for offline reinforcement learning. arXiv preprint arXiv:2208.06193, August 2022.
268
+
269
+ Deheng Ye, Guibin Chen, Peilin Zhao, Fuhao Qiu, Bo Yuan, Wen Zhang, Sheng Chen, Mingfei Sun, Xiaoqian Li, Siqin Li, et al. Supervised learning achieves human-level performance in moba games: A case study of honor of kings. IEEE Transactions on Neural Networks and Learning Systems, 2020.
270
+
271
+ This appendix is organised as follows.
272
+
273
+ • Section A: Extended Related Work • Section B: Experimental details • Section C: Further Results • Section D: Sampling Algorithms • Section E: Classifier-Free Guidance Analysis
274
+
275
+ # A EXTENDED RELATED WORK
276
+
277
+ Implicit BC. Florence et al. (2022) formulated BC as a conditional energy-based modeling problem. They showed that the ability of energy-based policies to represent multimodal distributions and discontinuous functions can provide competitive results with state-of-the-art offline reinforcement learning methods. Our paper is complimentary to this work, continuing the investigation on expressive models, studying the fit of diffusion models for BC. As well as showing that they can outperform state-of-the-art baselines in terms of score, we also show they outperform in closeness to the demonstration distribution, which was not explored by Florence et al. (2022). We note that diffusion models avoid some of the challenges of energy-based models – they remove the requirement to generate negative samples during training, and avoid some of the complexities in the sampling process that energy-based models face.
278
+
279
+ Transformer $\mathbf { + \mathbf { B } \mathbf { C } } .$ . Although there are multiple works using transformers for RL, in this section we only consider approaches that use transformers for BC, where no interaction with the environment is allowed, and only state-action trajectories and no reward signal are available in a dataset, for which the existing literature is scarce.
280
+
281
+ Reed et al. (2022) proposed GATO, an agent that could model different input modalities, including text, images and behaviour policies. However, they focused on demonstrating multitask capabilities, rather than on on how to do BC efficiently. GATO relies on discretisation, which can lead to inaccurate actions due to quantisation errors (see Sec. 2); and on autoregressive predictions, which can lead to repetitive and out of distribution trajectories (Holtzman et al., 2019).
282
+
283
+ Shafiullah et al. (2022) proposed a transformer based BC method that implements the KMeans+Residual approach discussed in Sec. 2. This is done by using two heads, one with a categorical loss for predicting the centroid of the cluster to which the action belongs; and the other one with an MSE loss to predict the ‘residual’, that is the distance from the centroid to the action. This resulted in a discrete approximation of the policy. Although having limitations, it was able to outperform other approximations in a number of environment, using both human and synthetic data.
284
+
285
+ Here, we focus on generative modelling with diffusion models, evaluating the impact of different neural network architectures and different sampling schemes, and showing they are expressive enough to model the policy without implicit approximations, outperforming previous approaches, including discretisation and K-Means+Residual.
286
+
287
+ Diffusion models. One main difference with previous works on diffusion models is that in order to obtain high quality samples, they relied on guiding the sampling process, either by using an expensive classifier (Dhariwal and Nichol, 2021), or by training a conditional and an unconditional model together (Ho and Salimans, 2021). However, as explained in Sec. 3.2, guidance can bias sampling towards low likelihood trajectories, which is problematic for BC applications, so in order to obtain high quality and high likelihood samples, we introduce two novel guidance-free methods.
288
+
289
+ RL and Diffusion Models. Up to our knowledge, the only previous work that used diffusion models for RL is by Janner et al. (2022) who proposed Diffuser: a model that predicts all states and actions of a complete trajectory; and uses classifier-like guidance for trajectory optimization and similar U-Net architectures to those from text-to-image diffusion models (Ramesh et al., 2022; Saharia et al., 2022), replacing the spatial convolutions with temporal convolutions. The main limitation of Diffuser is that sampling complete trajectories is computationally expensive, especially since the trajectory has to be re-sampled at each timestep (open-loop). Hence, it was demonstrated for environments with low-dimensional state-action sets. Our model is able to generate a trajectory by sampling one step at a time (closed loop). Combined with replacing U-Nets with other architectures like MLPs and transformer, this enables learning from high-dimensional states like images.
290
+
291
+ Concurrent to our work, Wang et al. (2022) use a conditional diffusion model with an MLP to predict a single action at a time conditioned on the current state. However, their focus is on trajectory optimization, relying on bootstrapping to learn a value function that is used for (classifier-like) guidance, and test their approach in environments with low dimensional state sets. Here, we focus on BC, for which we observe guidance can bias the sampling towards low-likelihood trajectories, so we introduce two novel guidance-free conditional sampling methods. In addition, we explore the impact of multiple architectures, including transformers, and demonstrate their performance even under high-dimensional state sets.
292
+
293
+ Ajay et al. (2023) provide a further concurrent work. They propose to diffuse sequences of future states, using a separate inverse-dynamics model to then infer actions. This contrasts with our own approach of directly diffusion actions, which allows us to scale up to image observations. They also explore conditioning on reward, skills and constraints, finding that CFG can help enforce the conditioning. By contrast, our investigation considered using CFG when the observation is the conditioning variable.
294
+
295
+ Imitation Learning $\mathbf { ( I L ) }$ . This paper lies under the IL paradigm (Hussein et al., 2017), in particular the line of work that frames IL as matching the state-action occupancy distribution in the dataset, which is related to Inverse RL (Ho and Ermon, 2016; Ghasemipour et al., 2020; Ke et al., 2020). Indeed, we use diffusion models as a practical BC approach that optimise a variational bound of the usual BC objective (which can be interpreted as minimising the forward KL w.r.t. to the experts distribution Ghasemipour et al. (2020); Ke et al. (2020)), but, as discussed in Sec. 2, diffusion models are able to approximate multimodal distributions, surmounting one major limitation of previous BC methods (Ke et al., 2020), especially when working with real world datasets from multiple demonstrators.
296
+
297
+ Finally, similarly to Dadashi et al. (2020); Hussenot et al. (2021), we compute the Wasserstein distance between the occupancy distributions as an evaluation criteria.
298
+
299
+ # B EXPERIMENTAL DETAILS
300
+
301
+ # B.1 CLAW ENVIRONMENT
302
+
303
+ The claw environment consists of seven unique pictures, each with different combination of valid toys to pick. To create the dataset, we pick one of the seven images at random, and then pick a demonstration action from the true $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ . The final dataset consists of 20000 such demonstrations.
304
+
305
+ Figure 8 shows full comparison of all methods in the seven different images. Each individual point represents one sample from the trained model when it is given the image observation o.
306
+
307
+ We train all methods for 100 epochs with a batch size of 32, using Adam optimizer and a decaying learning rate starting from 0.0001. We use 50 diffusion steps for the diffusion models. We set $K = 1 0$ for K-Means clustering.
308
+
309
+ # B.2 KITCHEN
310
+
311
+ The seven tasks of interest are: open the microwave (‘microwave’), move kettle onto a stove (‘kettle’), turn on the bottom stove (‘bottom burner’), turn on the top stove (‘top burner’), turn on a light-switch (‘light-switch’), open a sliding cabinet (‘slide cabinet’), open a swinging door (‘hinge cabinet’).
312
+
313
+ For each method we train 3 different seeds, and roll out 100 trajectories of length 280 for evaluation.
314
+ K-Means Transformer only has a single seed.
315
+
316
+ Time Wasserstein: For each method the histogram over the number of timesteps taken to complete N tasks is computed. For each tasks, the Wasserstein distance between the the histogram of the model’s timesteps and the humans is computed. We then average those Wassersteins across all 4 tasks. In the situation where a method did not ever complete 4 tasks, we leave the entry blank.
317
+
318
+ State-based Wasserstein: We are approximating the Wasserstein between the stationary distributions over the state space of the human dataset and our models: $\mathcal { W } ( \rho _ { \mathrm { A G E N T } } ( s ) , \rho _ { \mathrm { H U M A N } } ( s ) )$ . To do so we produce a ‘dataset’ for each method by concatenating the states for all 100 trajectories (similarly for the humans). We then turn these into the empirical distributions by having a uniform mass over each data point. We then use the POT library’s emd2 function (Flamary et al., 2021) to compute the Wasserstein distance, using the $L _ { 2 }$ cost function between the 30 dimensional entries.
319
+
320
+ To produce the sub-sampled human dataset, we pick 100 trajectories uniformly without replacement from the human dataset. We do this 5 times.
321
+
322
+ Density and Coverage: We use the Density and Coverage metrics proposed in Naeem et al. (2020), and compute them using the code provided by the authors. We use the human dataset as the set of real state samples, and our model’s rollouts as the fake state samples. We use 10 nearest neighbours for the calculation.
323
+
324
+ Hyperparameters. Neural network architectures were identical across all methods (except for the final linear layer which allows for differing output dimensionality). Basic MLP and MLP Sieve used three hidden-layers of 512 nodes and GELU activations. Embedding dimension of observation, action, and timestep was fixed at 128. Embedding networks were single hidden-layer MLPs with 128 nodes, using leaky ReLU activations except for the timestep encoder which used Sinusoidal activations. The Transformer used four encoding blocks, each with 16 self-attention heads and an internal embedding dimension of 64. All models receive the previous two observations as history.
325
+
326
+ Other hyperparameters were kept consistent across methods as far as possible. Initial experimentation showed that methods did not suffer from overfitting, and as default we trained models for 500 epochs with a cosine learning rate decay. MLP models used a learning rate of 1e-3 and batchsize of 512, while transformer models used a learning rate of 5e-4 and batchsize of 1024. We set $K = 6 4$ for K-means and discretised used 20 bins per action dimension.
327
+
328
+ We made extensive efforts to bring performance of K-means+residual inline with that reported in Shafiullah et al. (2022). Our best settings used a fixed learning rate of 1e-4, with $K = 6 4$ , though this still gave a task completion rate of 0.34, which falls slightly below 0.44 as originally reported. The difference might be explained by the larger network used by Shafiullah et al. $( 2 0 2 2 ) - 6$ layers, and an observation history of 10 steps. Note we also tested hyperparameters as reported in their paper (50 epochs, batchsize of 64), but this provided worse performance for us.
329
+
330
+ For diffusion models, we set $T = 5 0$ and standard $\beta$ schedules linearly decaying in [1e-4, 0.02]. (Note that the variance schedule parameters $\alpha _ { t }$ , $\bar { \alpha } _ { t }$ and $\sigma _ { t }$ introduced in Section 3 are derived from this $\beta$ schedule.) For Diffusion-X, $M = 8$ . For Diffusion-KDE, we first sample 100 actions, and fit a Gaussian KDE model (width $\scriptstyle = 0 . 4$ ) from scikit-learn1.
331
+
332
+ Models were rolled out with 100 random seeds. Each episode lasted 280 timesteps as in Shafiullah et al. $( 2 0 2 2 ) - 9 8 \%$ of humans completed their assigned four tasks within this time.
333
+
334
+ # B.3 CSGO
335
+
336
+ Game Score: Frags-per-minute, as reported by Pearce and Zhu (2022).
337
+
338
+ Action-based Wasserstein: Similarly to the Kitchen environment above, we are approximating the stationary distribution over the action space of the human dataset and our models: $\mathcal { W } ( \rho _ { \mathrm { A G E N T } } ( a ) , \rho _ { \mathrm { H U M A N } } ( a ) )$ .
339
+
340
+ For 1xtimesteps, we compute this in the same way as the state-based Wasserstein above, using POT’s emd2 and the $L _ { 2 }$ cost between the 3 dimensional entries.
341
+
342
+ For $\mathsf { 1 6 x }$ timesteps and 32xtimesteps, for each timestep we concatenate the 16 (and 32 timesteps respectively) following it into a single vector. If there are not enough timesteps left in the trajectory, then we do not use that timestep. We compute the Wasserstein in the exact same manner as before on these higher dimensional entries.
343
+
344
+ Hyperparameters. Neural network architectures were unchanged from the Kitchen experiments, except for the observation encoder, for which we tested two options. 1) A lightweight 6-layer CNN that operates directly on the frames stacked together. 2) A ResNet18 with ImageNet weights – the four stacked frames are passed through this independently. The output is then concatenated together and passed through two vanilla convolutional layers. Following average pooling, an embedding vector of length 128 is output.
345
+
346
+ Unlike in the Kitchen environment, we found models were sensitive to overfitting in CSGO. For the smaller observation encoder, we trained for 500 epochs with cosine decay (learning rate of 1e-4), but tested models both midway through training (250 epochs) and at the end (500 epochs). For the ResNet encoder, we trained with a fixed learning rate of 1e-4 for a maximum of 100 epochs, but tested models every 20 epochs. All methods were best with either 60 or 80 training epochs.
347
+
348
+ For diffusion models, we set $T = 2 0$ and standard $\beta$ schedules linearly decaying in [1e-4, 0.02]. For Diffusion-X, $M = 1 6$ . For K-Means+Residual, we use $K = 6 4$ .
349
+
350
+ Following Pearce and Zhu (2022), episodes were defined as 10 minutes of playing time. The original data was collected at $1 6 \mathrm { H z }$ with the game running in real-time. We altered the game setting so that it runs at half speed, allowing our models to roll out at $8 \mathrm { H z }$ . It was possible to increase this to $1 0 \mathrm { H z }$ for diffusion BC.
351
+
352
+ # B.4 ENERGY-BASED MODEL IMPLEMENTATION
353
+
354
+ We re-implemented two versions of the Energy-Based Model’s (EBM’s) described in Implicit BC (Florence et al., 2022): 1) Derivative-free optimisation (‘Deriv-free’) and 2) Langevin MCMC (‘Langevin’). Whilst we made efforts to run both of these in all three of our environments (Claw, Kitchen, and CSGO), we were unable to produce rudimentary results in many combinations but document our experiences here. Ultimately we reported EBM Deriv-free in Claw (Figure 8), Kitchen (Table 1 & 4) and CSGO (Table 3), and EBM Langevin on the Claw only (Figure 8). Other combinations failed to produce any reward.
355
+
356
+ Derivative-Free Optimisation. This follows Algorithm 1 of (Florence et al., 2022). At training time, negative examples are sampled uniformly from the action space, and a contrastive loss is optimised. At sampling time, a derivative-free optimisation scheme is used (reminiscent of particleswarm optimisation).
357
+
358
+ We used the following hyperparameters by default: number counter example ${ } = 2 5 6$ , number inference sample $\mathord { \mathrm { \ s = } } 1 6 0 0 0$ , number optimising iterations $^ { = 3 }$ , optimising noise ${ = } 0 . 3 3$ , noise decay $= 0 . 5$ .
359
+
360
+ In our experience this method performed reasonably in lower dimensional environments. In the Claw (Figure 8), we could recover a fair approximation of the true $\scriptstyle p ( \mathbf { a } | \mathbf { o } )$ distributions, although there is a segmentation effect. To understand why this occurs, we plotted the energy mesh over the whole action space in Figure 6, where we can observe halo-like effects at the edges of objects, explaining this.
361
+
362
+ ![](images/1d3ff1b28bc699a70ad8ab9c39cc1166d3429744d06a58bb41c87958f3b76a4c.jpg)
363
+ Figure 6: Visualisation of the energy landscapes learnt on the Claw environment by EBM derivativefree optimisation.
364
+
365
+ Derivative-free worked poorly in the kitchen environment which has a 9 dimensional action space, only occasionally completing two tasks and never more. This was also observed in Florence et al. (2022), which showed that Derivative-free failed when action dimensionality exceeded six.
366
+
367
+ Since CSGO’s action space is of dimension three, we thought Derivative-free may perform reasonably, though we were only able to recover a rudimentary performance level as in Table 3.
368
+
369
+ Sampling times of Derivative-free were reasonable (Table 6), generally falling between diffusion models and MSE, though it slowed down training significantly since it requires drawing many negative samples for each datapoint in a batch – this also sometimes reduced the maximum batchsize that could be used (since it effectively gets multiplied).
370
+
371
+ Langevin MCMC. This follows the description in Appendix B.3 of Florence et al. (2022), along with the gradient penalty in B.3.1. Negative samples are partially optimised at training time, by backpropagating gradients to the action samples. At sampling time, the same gradient-based optimisation procedure is run for longer. Florence et al. (2022) state that this method should handle higher-dimensional action spaces well.
372
+
373
+ We used the following hyperparameters by default: number counter example $\scriptstyle = 3 2$ , noise scale $= 0 . 5$ , learning coefficient start $= 0 . 0 5$ , learning coefficient end $= 0 . 0 0 5$ , number mcmc iterations during training $_ { \mathrm { = } 1 0 0 }$ , extra mcmc iterations during sampling $_ { \mathrm { = } 1 0 0 }$ , $\mathbf { M } { = } 1$ .
374
+
375
+ We were unable to get this method working well in any of our environments. Figure 7 shows the energy landscapes learnt in the Claw. We found it produced energy functions that were overly smooth. Also, at sampling time, many samples would get stuck in local maxima at the edges of the action space. A fundamental issue with the approach is that the negative samples become less ‘negative’ over the course training as the model learns the energy function. This creates distribution drift in the training data and a less stable optimisation objective.
376
+
377
+ ![](images/b723f20005e3e245b97dbd7cd3bca7363eef40cea230e5380af113bcc89538be.jpg)
378
+ Figure 7: Visualisation of the energy landscapes learnt on the Claw environment by EBM Langevin MCMC optimisation.
379
+
380
+ In initial experiments, Langevin failed to solve any tasks in the Kitchen or CSGO. Both training and sampling from Langevin are far slower than any other method (Table 6) – training requires running an MCMC chain for many iterations for negative samples (set as default to 100). Sampling requires double this number of steps, and additionally cannot be performed within torch.nograd(), since the gradients are required for optimisation.
381
+
382
+ # C FURTHER RESULTS
383
+
384
+ ![](images/5649e91680527218a2a004f64159c52a66a5a8a252158099d6143f4d88d08944.jpg)
385
+ Figure 8: Full comparison of different distribution modelling choices in the toy claw environment.
386
+
387
+ Table 4: Robotic control results. Mean $\pm$ one standard error over three training runs (100 rollouts). These metric capture task completion only. Methods marked with asterisk $( ^ { * } )$ are our proposed methods.
388
+
389
+ <table><tr><td></td><td>No. runs</td><td>Tasks completed个</td><td>Tasks ≥1↑</td><td>Tasks≥2个</td><td>Tasks≥3个</td><td>Tasks≥4个</td><td>Tasks≥5个</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>*Diffusion Basic MLP</td><td>3</td><td>3.04 ± 0.01</td><td>0.98 ±0.01</td><td>0.89 ± 0.01</td><td>0.71 ± 0.0</td><td>0.45 ± 0.03</td><td>0.01±0.0</td></tr><tr><td>*Diffusion Basic MLP KDE</td><td>3</td><td>3.44 ± 0.01</td><td>0.99±0.0</td><td>0.97 ±0.01</td><td>0.86±0.0</td><td>0.59 ± 0.01</td><td>0.04 ±0.01</td></tr><tr><td>*Diffusion Basic MLP Extra8</td><td>3</td><td>3.37 ± 0.03</td><td>0.99 ± 0.01</td><td>0.93 ± 0.01</td><td>0.83 ± 0.02</td><td>0.58±0.02</td><td>0.04 ± 0.01</td></tr><tr><td>MSEMLP Sieve</td><td>3</td><td>3.13 ± 0.07</td><td>0.99 ± 0.0</td><td>0.9 ± 0.03</td><td>0.72 ± 0.03</td><td>0.5 ±0.02</td><td>0.02 ± 0.0</td></tr><tr><td>Discretised MLP Sieve</td><td>3</td><td>2.26±0.08</td><td>0.95 ± 0.02</td><td>0.73 ±0.02</td><td>0.4 ±0.03</td><td>0.18 ±0.02</td><td>0.0±0.0</td></tr><tr><td>Disc.K-MeansMLP Sieve</td><td>3</td><td>0.33±0.03</td><td>0.3±0.03</td><td>0.03±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>K-Means+Residual MLP Sieve</td><td>3</td><td>2.56 ± 0.04</td><td>0.95±0.0</td><td>0.82 ± 0.01</td><td>0.55 ± 0.02</td><td>0.23 ±0.02</td><td>0.01 ±0.0</td></tr><tr><td>EBMDeriv-Free,MLP Sieve</td><td>1</td><td>0.39</td><td>0.31</td><td>0.08</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>*Diffusion MLP Sieve</td><td>3</td><td>3.46 ± 0.04</td><td>0.99 ±0.0</td><td>0.94±0.0</td><td>0.82 ± 0.02</td><td>0.68 ±0.02</td><td>0.02 ±0.01</td></tr><tr><td>*Diffusion KDE MLP Sieve</td><td>3</td><td>3.78 ± 0.06</td><td>1.0 ± 0.0</td><td>1.0 ±0.0</td><td>0.92 ± 0.01</td><td>0.79 ± 0.04</td><td>0.07 ±0.01</td></tr><tr><td>*Diffusion Extra MLP Sieve</td><td>3</td><td>3.72 ± 0.02</td><td>1.0 ± 0.0</td><td>0.97 ±0.0</td><td>0.9 ± 0.01</td><td>0.77 ± 0.02</td><td>0.08±0.0</td></tr><tr><td>MSE Transformer</td><td>3</td><td>3.59 ± 0.02</td><td>0.99±0.0</td><td>0.96 ±0.01</td><td>0.88 ± 0.01</td><td>0.69 ± 0.02</td><td>0.07 ±0.01</td></tr><tr><td>Discretised Transformer</td><td>3</td><td>2.71 ± 0.08</td><td>0.97 ±0.0</td><td>0.82 ±0.02</td><td>0.57 ± 0.04</td><td>0.34 ± 0.02</td><td>0.02 ± 0.01</td></tr><tr><td>Disc.K-Means Transformer</td><td>1</td><td>0.47</td><td>0.42</td><td>0.05</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>*Diffusion Transformer</td><td>3</td><td>3.74 ± 0.02</td><td>1.0 ± 0.0</td><td>0.98 ± 0.01</td><td>0.9 ± 0.02</td><td>0.77 ± 0.01</td><td>0.1 ± 0.01</td></tr><tr><td>*Diffusion KDE Transformer</td><td>3</td><td>3.93 ± 0.02</td><td>1.0 ± 0.0</td><td>1.0 ±0.0</td><td>0.95 ± 0.0</td><td>0.89 ± 0.01</td><td>0.1 ±0.01</td></tr><tr><td>*Diffusion Extra Transformer</td><td>3</td><td>3.91 ± 0.04</td><td>1.0 ± 0.0</td><td>0.99 ±0.01</td><td>0.94± 0.0</td><td>0.88 ± 0.01</td><td>0.1±0.03</td></tr><tr><td>Human</td><td></td><td>3.98</td><td>1.0</td><td>1.0</td><td>1.0</td><td>0.98</td><td>0.0</td></tr><tr><td>Previously reported in (Shafiullah et al.,2022):</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Behaviour Transformers (K-Means+Residual)</td><td>1</td><td>3.09</td><td>0.99</td><td>0.93</td><td>0.71</td><td>0.44</td><td>0.02</td></tr><tr><td>Implicit BC (Generative EBM)</td><td>1</td><td>2.71</td><td>0.99</td><td>0.87</td><td>0.61</td><td>0.24</td><td>0.0</td></tr><tr><td>SPiRL VAE (Pertsch etal., 2021)</td><td>1</td><td>1.0</td><td>1.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>PARROT Normalizing Flow (Singh et al., 2020)</td><td>1</td><td>0.04</td><td>0.04</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr></table>
390
+
391
+ Table 5: Wasserstein of time to completion in the robotic control environment. Methods marked with asterisk $( ^ { * } )$ are our proposed methods.
392
+
393
+ <table><tr><td></td><td>Task1↓</td><td>Task 2↓</td><td>Task 3↓</td><td>Task 4↓</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>*Diffusion-Extra MLP Basic</td><td>2.36 ±0.50</td><td>3.65 ±0.26</td><td>14.40 ± 1.05</td><td>14.04 ±0.38</td></tr><tr><td>*Diffusion MLP Basic</td><td>3.48 ± 0.94</td><td>8.63 ± 2.66</td><td>23.13 ± 4.86</td><td>12.93 ± 1.14</td></tr><tr><td>*Diffusion-KDE MLPBasic</td><td>3.52 ± 0.45</td><td>5.82 ±0.40</td><td>14.11 ± 0.76</td><td>8.86±0.74</td></tr><tr><td>*Diffusion MLP Sieve</td><td>2.69 ± 0.97</td><td>3.84 ± 0.51</td><td>8.54 ± 2.81</td><td>9.18 ± 1.12</td></tr><tr><td>*Diffusion-KDE MLP Sieve</td><td>3.50 ±0.68</td><td>7.07 ± 1.18</td><td>8.51 ±2.08</td><td>7.98 ± 0.82</td></tr><tr><td>*Diffusion-Extra MLP Sieve</td><td>1.69 ± 0.26</td><td>4.60 ± 1.03</td><td>8.34 ±2.36</td><td>6.31 ±0.80</td></tr><tr><td>MSE MLP Sieve</td><td>3.03 ± 0.71</td><td>5.70 ±1.89</td><td>9.63 ± 0.94</td><td>7.24 ± 0.91</td></tr><tr><td>Discrete MLP Sieve</td><td>3.74 ± 1.31</td><td>11.09 ± 1.92</td><td>20.98 ± 1.61</td><td>9.38 ±2.12</td></tr><tr><td>K-Means MLP Sieve</td><td>34.61 ± 7.21</td><td>71.20 ± 20.31</td><td>=</td><td></td></tr><tr><td>K-Means+ResidualMLPSieve</td><td>3.57 ± 0.41</td><td>10.07 ± 2.96</td><td>17.26 ± 4.07</td><td>15.51 ± 1.36</td></tr><tr><td>*Diffusion-Extra Transformer</td><td>2.04 ± 0.64</td><td>5.12 ± 1.02</td><td>5.51± 0.56</td><td></td></tr><tr><td>*Diffusion Transformer</td><td>1.26 ± 0.01</td><td>3.33 ± 0.36</td><td>7.89 ± 0.57</td><td>5.92 ± 0.31 3.97 ± 0.51</td></tr><tr><td>*Diffusion-KDE Transformer</td><td>4.21 ± 0.42</td><td>6.34 ± 1.23</td><td>5.22 ±0.32</td><td>5.33 ± 0.40</td></tr><tr><td>MSE Transformer</td><td>3.03 ±0.74</td><td>5.73 ± 0.61</td><td>7.99 ± 1.39</td><td>6.64 ± 1.12</td></tr><tr><td>Discrete Transformer</td><td>2.35 ± 0.31</td><td>5.95 ± 0.57</td><td>9.61 ± 1.82</td><td>6.61 ± 0.70</td></tr><tr><td>K-Means Transformer</td><td>55.79</td><td>32.64</td><td></td><td></td></tr><tr><td>K-Means+Residual Transformer</td><td>2.16 ± 0.78</td><td></td><td>一</td><td></td></tr><tr><td></td><td></td><td>4.55 ± 1.27</td><td>10.07 ± 0.23</td><td>14.41 ± 1.83</td></tr></table>
394
+
395
+ Table 6: Timing analysis for various methods, sampling schemes, architectures, environments and hardware. Sampling times were recorded without running the environment – looping over the sampling process without waiting for the environment step function. Diffusion models do not suffer from any slow down at training time. For sampling time, note that in the Kitchen experiments, where the denoising network forms the majority of the total network, sampling speed is roughly proportional to number of denoising timesteps. However in CSGO, when a large observation encoder is required, the slow down is less impactful.
396
+
397
+ <table><tr><td></td><td>Trainingtimeperepoch↓Samplingtime↓Maxsamplingrate↑</td><td></td><td></td></tr><tr><td colspan="4"></td></tr><tr><td colspan="4">Kitchen environment, CPU</td></tr><tr><td>MSE,MLP Sieve</td><td>7.4 seconds</td><td>1.2 ms</td><td>833Hz</td></tr><tr><td>Discrete,MLP Sieve</td><td>7.6 seconds</td><td>2.7 ms</td><td>370 Hz</td></tr><tr><td>K-Means,MLPSieve</td><td>8.7 seconds</td><td>1.5 ms</td><td>666Hz</td></tr><tr><td>K-Means+Residual,MLP Sieve</td><td>10.5 seconds</td><td>1.5 ms</td><td>666Hz</td></tr><tr><td>*Diffusion BC (T= 50),MLP Sieve</td><td>6.4 seconds</td><td>44.6 ms</td><td>22 Hz</td></tr><tr><td>*Diffusion-X(T= 50,M=8),MLP Sieve</td><td>6.4 seconds</td><td>55.9 ms</td><td>18 Hz</td></tr><tr><td>*Diffusion-KDE(T= 50,100 samples),MLP Sieve</td><td>6.4 seconds</td><td>128.4 ms</td><td>8Hz</td></tr><tr><td colspan="4">Kitchen environment, V1oo GPU</td></tr><tr><td>MSE,Basic MLP</td><td>1.4 seconds</td><td>1.1 ms</td><td>909 Hz</td></tr><tr><td>Discrete,Basic MLP</td><td>1.8 seconds</td><td>3.9 ms</td><td>256Hz</td></tr><tr><td>K-Means,Basic MLP</td><td>2.2 seconds</td><td>1.4 ms</td><td>714 Hz</td></tr><tr><td>K-Means+Residual,Basic MP</td><td>2.4 seconds</td><td>1.4 ms</td><td>714 Hz</td></tr><tr><td>*Diffusion BC (T= 50),Basic MLP</td><td>1.4 seconds</td><td>42.1 ms</td><td>24 Hz</td></tr><tr><td>*Diffusion-X(T= 50,M=8),Basic MLP</td><td>1.4 seconds</td><td>47.3 ms</td><td>21 Hz</td></tr><tr><td>*Diffusion-KDE(T= 50,100 samples),Basic MLP</td><td>1.4 seconds</td><td>61.2 ms</td><td>16 Hz</td></tr><tr><td colspan="4"></td></tr><tr><td>MSE,MLP Sieve</td><td>1.5 seconds</td><td>1.5 ms</td><td>666 Hz</td></tr><tr><td>Discrete,MLP Sieve</td><td>2.2 seconds</td><td>4.3 ms</td><td>232 Hz</td></tr><tr><td>K-Means,MLPSieve</td><td>2.9 seconds</td><td>1.8 ms</td><td>555Hz</td></tr><tr><td>K-Means+Residual,MLPieve</td><td>3.1 seconds</td><td>2.0 ms</td><td>500 Hz</td></tr><tr><td>EBMDeriv-Free,MLP Sieve</td><td>22.3 seconds</td><td>28.2 ms</td><td>35Hz</td></tr><tr><td>EBMLangevin,MLP Sieve</td><td>142.1 seconds</td><td>525.5 ms</td><td>2Hz</td></tr><tr><td>*Diffusion BC(T= 5O),MLP Sieve</td><td>2.0 seconds</td><td>63.1 ms</td><td>16 Hz</td></tr><tr><td>*Diffusion-X(T= 50,M=8),MLP Sieve</td><td>2.0 seconds</td><td>73.8 ms</td><td>14 Hz</td></tr><tr><td>*Diffusion-KDE(T= 50,100 samples),MLP Sieve</td><td>2.0 seconds</td><td>86.5 ms</td><td>12 Hz</td></tr><tr><td colspan="4">MSE,Transformer</td></tr><tr><td>Discrete,Transformer</td><td>6.8 seconds</td><td>5.5 ms</td><td>181Hz</td></tr><tr><td></td><td>7.0 seconds</td><td>8.6 ms</td><td>116 Hz</td></tr><tr><td>K-Means,Transformer</td><td>7.4 seconds</td><td>5.9 ms</td><td>169 Hz</td></tr><tr><td>K-Means+Residual,Transformer</td><td>7.5 seconds</td><td>6.0 ms</td><td>167 Hz</td></tr><tr><td>EBMDeriv-Free,Transformer</td><td>1000&lt;seconds</td><td>1390.8 ms</td><td>0.7Hz</td></tr><tr><td>EBMLangevin,Transformer</td><td>1000&lt;seconds</td><td>2927.9 ms</td><td>0.3Hz</td></tr><tr><td>*Diffusion BC(T= 5O),Transformer</td><td>6.8 seconds</td><td>244.2 ms</td><td>4Hz</td></tr><tr><td>*Diffusion-X(T= 50,M= 8),Transformer</td><td>6.8 seconds</td><td>285.3 ms</td><td>4 Hz</td></tr><tr><td>*Diffusion-KDE(T= 50,100 samples),Transformer</td><td>6.8 seconds</td><td>295.6 ms</td><td>3Hz</td></tr><tr><td colspan="4">CSGO environment,ResNet18 observation encoder, V1oo GPU</td></tr><tr><td>MSE,MLP Sieve</td><td>49 seconds</td><td>5.0 ms</td><td>200 Hz</td></tr><tr><td>Discrete,MLP Sieve</td><td>49 seconds</td><td>6.0 ms</td><td>167Hz</td></tr><tr><td>EBMDeriv-Free,MLP Sieve</td><td>50 seconds</td><td>9.3 ms</td><td>107 Hz</td></tr><tr><td>EBMLangevin,MLP Sieve</td><td>240 seconds</td><td>537.2 ms</td><td>2Hz</td></tr><tr><td>K-Means,MLP Sieve</td><td>51 seconds</td><td>5.5 ms</td><td>181Hz</td></tr><tr><td>K-Means+Residual,MLPSieve</td><td>51 seconds</td><td>5.4 ms</td><td>185 Hz</td></tr><tr><td>*Diffusion BC(T= 2O),MLP Sieve</td><td>49 seconds</td><td>31.5 ms</td><td>32 Hz</td></tr><tr><td>*Diffusion-X(T= 20,M=16),MLP Sieve</td><td>49 seconds</td><td>54.7 ms</td><td>18Hz</td></tr></table>
398
+
399
+ $t = 0$ . Initialised state. Two modes can be made out in some action dimensions (e.g. dim 6), representing the choice between reaching for the kettle and microwave.
400
+
401
+ ![](images/cb480548c7bfe45fc1e82235c75a2149769a86f5b1ad40ef86a57f00de9d3caa.jpg)
402
+
403
+ ![](images/fea61ed347ba90e483c4e56810c86662200b2f9a66184771b011047b613c4108.jpg)
404
+
405
+ $t = 1 1$ . The gripper begins moving towards the kettle and distributions become unimodal.
406
+
407
+ ![](images/bbe7e9c00a6229608775f1c1e0bffc0e3d78a62d0f185b63c10cb50b74dd1db2.jpg)
408
+
409
+ $t = 2 7$ . The gripper initiates fine grasping of the kettle handle, which requires careful coordination between the grippers, which manifests as strong correlation between action dim 8 & 9.
410
+
411
+ ![](images/8b700eacf7c608d1c89af80dcb4b85a3bd4238cb00ade01b1b1bab24d7546725.jpg)
412
+
413
+ ![](images/88de144e5df8010eea7ac3ab313f8e8939aeeb783b2e90c7ec0545b036350c7f.jpg)
414
+
415
+ $t = 6 3$ . Strong linear and non-linear correlations between certain action dimensions can be observed as the gripper pulls away from the kettle.
416
+
417
+ ![](images/b8861adcc7773132ea407bd7ffd22b2a22cddb8aaeb03e22cd9d45335be9dfc9.jpg)
418
+
419
+ $t = 8 7$ . Kettle task is completed. Bimodal distributions can be seen in action dimension 1 & 4, representing the decision point for the selection of the next task.
420
+
421
+ ![](images/914002dec2f06f4d3d93b23e79c446eda52e6ab9635b84946462dcdb87ed1de1.jpg)
422
+
423
+ ![](images/3186b1db4470ac7ecb1acc8f980395508f6a541cf827bd2b2fd448dcecc2cffc.jpg)
424
+
425
+ $t = 9 6$ . The decision to move towards the bottom burner has been made, so action distributions become unimodal again.
426
+
427
+ ![](images/d00f655f93af3b0685531ad0c71a26e12d6422e413474f4693fcc8d8ab661261.jpg)
428
+
429
+ ![](images/bf1ef6850f63335967623ce4feb2e4ce6fbd1be87fa4b460aab0322fb4a79d75.jpg)
430
+ Figure 9: Qualitative analysis of a demonstrative roll-out for Diffusion BC in the kitchen environment. We visualise the relationships between all 9 action dimensions simultaneously via a matrix scatter plot, after 200 samples have been drawn from the diffusion model at each environment timestep. This allows visualisation of correlations and multimodality between action dimensions that are captured by the diffusion model. We have hand-selected six interesting environment timesteps in the roll-out to visualise. Action dimensions correspond to specific joint actuators of the robot, e.g. turn base left/right, or close gripper.
431
+
432
+ # D SAMPLING ALGORITHMS
433
+
434
+ # Algorithm 1 Sampling for Diffusion BC
435
+
436
+ 1: $\mathbf { a } _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$
437
+ 2: for $\tau = T , \dots , 1$ do
438
+ 3: $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ if $\tau > 1$ , else $\mathbf { z } = \mathbf { 0 }$
439
+ 4: $\begin{array} { r } { \mathbf { a } _ { \tau - 1 } = \frac { 1 } { \sqrt { \alpha _ { \tau } } } \left( \mathbf { a } _ { \tau } - \frac { 1 - \alpha _ { \tau } } { \sqrt { 1 - \bar { \alpha } _ { \tau } } } \epsilon _ { \theta } ( \mathbf { a } _ { \tau } , \tau , \mathbf { o } ) \right) + \sigma _ { \tau } \mathbf { z } } \end{array}$
440
+ 5: end for
441
+ 6: return a0
442
+
443
+ # Algorithm 2 Sampling for Diffusion-X
444
+
445
+ 1: $\mathbf { a } _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$
446
+ 2: for $i = T , \dots , 1 - M$ do
447
+ 3: $\tau = \operatorname* { m a x } ( i , 1 )$
448
+ 4: $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ if $\tau > 1$ , else $\mathbf { z } = \mathbf { 0 }$
449
+ 5: $\begin{array} { r } { \mathbf { a } _ { \tau - 1 } = \frac { 1 } { \sqrt { \alpha _ { \tau } } } \left( \mathbf { a } _ { \tau } - \frac { 1 - \alpha _ { \tau } } { \sqrt { 1 - \bar { \alpha } _ { \tau } } } \epsilon _ { \theta } ( \mathbf { a } _ { \tau } , \tau , \mathbf { o } ) \right) + \sigma _ { \tau } \mathbf { z } } \end{array}$
450
+ 6: end for
451
+ 7: return a M
452
+
453
+ # Algorithm 3 Sampling for Diffusion-KDE
454
+
455
+ 1: $\mathbf A \gets [ ]$
456
+ 2: for $i = 1 , \dots , K$ do
457
+ 3: Use Algorithm 1 to sample action, $\mathbf { a } _ { 0 }$
458
+ 4: A . append(a0)
459
+ 5: end for
460
+ 6: KDEmodel. fit(A)
461
+ 7: Likelihoods $=$ KDEmodel. score(A)
462
+ 8: $i = \arg \operatorname* { m a x } _ { i }$ (Likelihoods)
463
+ 9: return A[i]
464
+
465
+ # E CLASSIFIER-FREE GUIDANCE ANALYSIS
466
+
467
+ ![](images/7681a60cfd0a25009db4660b74fe7111a94a3c7087f8d10318622f075ad6d2e1.jpg)
468
+ Figure 10: Didactic example of when CFG can lead to generation of less usual trajectories.
469
+
470
+ CFG can be interpreted as guiding the denoising sampling procedure towards higher values of $p ( \mathbf { o } | \mathbf { a } )$ (Ho et al., 2022). Given this interpretation, we now provide a grid-world to show concretely why this can lead to sampling of less common trajectories in a sequential environment.
471
+
472
+ Figure 10 shows an environment with four discrete states and a discrete action. The action space allows three ego-centric options; turn left, turn right or continue straight forward. Agents are always initialised at state 0, giving observation $\mathbf { o } _ { 0 }$ , and rolled out for exactly two timesteps, visiting state 1 and ending in state 2 or 3. The figure shows the empirical action distributions in a demonstration dataset. In states 0, 2 & 3, the agent always selects straight. But in state 1, the agent makes a right turn with 0.1 probability.
473
+
474
+ Let ${ \bf o } _ { 1 } , { \bf o } _ { 2 }$ and $\mathbf { o } _ { 3 }$ denote the observations given by states 1, 2 and 3, respectively. We can apply Bayes rule to find $p ( \mathbf { o } | \mathbf { a } )$ , which will provide an understanding of what behaviour CFG induces. We are interested in the learnt behaviour at the decision point $\mathbf { o } _ { 1 }$ ,
475
+
476
+ $$
477
+ p ( \mathbf { o } _ { 1 } | \mathbf { a } ) = \frac { p ( \mathbf { a } | \mathbf { o } _ { 1 } ) p ( \mathbf { o } _ { 1 } ) } { p ( \mathbf { a } ) } .
478
+ $$
479
+
480
+ Given the agent starts in state 0 and is rolled out for two timesteps (sees three states), and $p ( \mathbf { a } = \mathrm { T u r n } \mathbf { \bar { r i g h t { | o _ { 1 } } } } ) = 0 . 1$ , $p ( \mathbf { a } = \mathrm { s t r a i g h t } | \mathbf { o } _ { 1 } ) = 0 . 9$ , we find the marginal probability of each observation,
481
+
482
+ $$
483
+ \begin{array} { l } { p ( \mathbf { o = o _ { 0 } } ) = 1 / 3 } \\ { p ( \mathbf { o = o _ { 1 } } ) = 1 / 3 } \\ { p ( \mathbf { o = o _ { 2 } } ) = 1 / 3 \cdot 0 . 1 } \\ { p ( \mathbf { o = o _ { 3 } } ) = 1 / 3 \cdot 0 . 9 . } \end{array}
484
+ $$
485
+
486
+ Hence, the marginal action distribution is,
487
+
488
+ $$
489
+ \begin{array} { l } { { \displaystyle p ( { \bf a } = { \mathrm { T u r n ~ r i g h t } } ) = \sum _ { i = 0 } ^ { 3 } p ( { \bf a } = { \mathrm { T u r n ~ r i g h t } } | { \bf o } _ { i } ) p ( { \bf o } _ { i } ) } } \\ { { \displaystyle ~ = 1 / 3 \cdot 0 . 1 } } \\ { { \displaystyle p ( { \bf a } = \mathrm { S t r a i g h t } ) = 1 / 3 + 1 / 3 \cdot 0 . 9 + 1 / 3 } . } \end{array}
490
+ $$
491
+
492
+ We can now compute the quantities $p ( \mathbf { o } _ { 1 } | \mathbf { a } )$ ,
493
+
494
+ $$
495
+ \begin{array} { l } { p ( \mathbf { o } _ { 1 } | \mathbf { a } = \mathrm { T u r n ~ r i g h t } ) = \displaystyle \frac { p ( \mathbf { a } = \mathrm { T u r n ~ r i g h t } | \mathbf { o } _ { 1 } ) p ( \mathbf { o } _ { 1 } ) } { p ( \mathbf { a } = \mathrm { T u r n ~ r i g h t } ) } = \displaystyle \frac { 0 . 1 \cdot 1 / 3 } { 0 . 1 \cdot 1 / 3 } = 1 } \\ { p ( \mathbf { o } _ { 1 } | \mathbf { a } = \mathrm { S t r a i g h t } ) = \displaystyle \frac { p ( \mathbf { a } = \mathrm { S t r a i g h t } | \mathbf { o } _ { 1 } ) p ( \mathbf { o } _ { 1 } ) } { p ( \mathbf { a } = \mathrm { S t r a i g h t } ) } = \displaystyle \frac { 0 . 9 \cdot 1 / 3 } { 1 / 3 + 1 / 3 \cdot 0 . 9 + 1 / 3 } = \displaystyle \frac { 0 . 9 } { 2 . 9 } = 0 . 3 1 . } \end{array}
496
+ $$
497
+
498
+ As such, since CFG favours actions that maximise $p ( \mathbf { o } | \mathbf { a } )$ , the CFG agent will select the less frequently visited right-hand path more often.
md/dev/QDE5hzxVpS/QDE5hzxVpS.md ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNVEILING THE MASK OF POSITION-INFORMATION PATTERN THROUGH THE MIST OF IMAGE FEATURES
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Recent studies have shown that paddings in convolutional neural networks encode absolute position information which can negatively affect the model performance for certain tasks. However, existing metrics for quantifying the strength of positional information remain unreliable and frequently lead to erroneous results. To address this issue, we propose novel metrics for measuring and visualizing the encoded positional information. We formally define the encoded information as Position-information Pattern from Padding (PPP) and conduct a series of experiments to study its properties as well as its formation. The proposed metrics measure the presence of positional information more reliably than the existing metrics based on PosENet and tests in F-Conv. We also demonstrate that for any extant (and proposed) padding schemes, PPP is primarily a learning artifact and is less dependent on the characteristics of the underlying padding schemes.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Padding, one of the most fundamental components in neural network architectures, has received much less attention than other modules in the literature. In convolutional neural networks (CNNs), zero padding is frequently used perhaps due to its simplicity and low computational costs. This design preference remains almost unchanged in the past decade. Recent studies (Islam\* et al., 2020; Islam et al., 2021b; Kayhan & Gemert, 2020; Innamorati et al., 2020) show that padding can implicitly provide a network model with positional information. Such positional information can cause unwanted side-effects by interfering and affecting other sources of position-sensitive cues (e.g., explicit coordinate inputs (Lin et al., 2022; Alsallakh et al., 2021a; Xu et al., 2021; Ntavelis et al., 2022; Choi et al., 2021), embeddings (Ge et al., 2022), or boundary conditions of the model (Innamorati et al., 2020; Alguacil et al., 2021; Islam et al., 2021a)). Furthermore, padding may lead to several unintended behaviors (Lin et al., 2022; Xu et al., 2021; Ntavelis et al., 2022; Choi et al., 2021), degrade model performance (Ge et al., 2022; Alguacil et al., 2021; Islam et al., 2021a), or sometimes create blind spots (Alsallakh et al., 2021a). Meanwhile, simply ignoring the padding pixels (known as no-padding or valid-padding) leads to the foveal effect (Alsallakh et al., 2021b; Luo et al., 2016) that causes a model to become less attentive to the features on the image border. These observations motivate us to thoroughly analyze the phenomenon of positional encoding including the effect of commonly used padding schemes.
12
+
13
+ Conducting such a study requires reliable metrics to detect the presence of positional information introduced by padding, and more importantly, quantify its strength consistently. We observe that the existing methods for detecting and quantifying the strength of positional information yield inconsistent results. In Section 3, we revisit two closely related evaluation methods, PosENet (Islam\* et al., 2020) and F-Conv (Kayhan & Gemert, 2020). Our extensive experiments demonstrate that (a) metrics based on PosENet are unreliable with an unacceptably high variance, and (b) the Border Handling Variants (BHV) test in F-Conv suffers from unaware confounding variables in its design, leading to unreliable test results.
14
+
15
+ In addition, we observe all commonly-used padding schemes actually encode consistent patterns underneath the highly dynamic model features. However, such a pattern is rather obscure, noisy, and visually imperceptible for most paddings (except zeros-padding), which makes recognizing and analyzing it difficult. Fortunately, we show that such patterns can be consistently revealed with a sufficient number of samples by defining an optimal padding scheme (see Section 2.1 and Figure 1).
16
+
17
+ ![](images/ab0eb0828e532ceff21f80209a0363116483e34653f04c92525481c6f69dd5c5.jpg)
18
+ Figure 1: Position-information Pattern from Padding (PPP). We propose a method that can consistently and effectively extract PPPs through the distributional difference between optimallypadded (gray-scale surfaces) and algorithmically-padded features (colored surfaces). The results show that the two distributions become distinguishable as the number of sample increases. Following the procedure in Section 2.2, we extract a clear view of PPP with the expectation of the pairwise differences between optimally-padded and algorithmically-padded features. We render each visualization in tilted view (first row) and top view (second row). The colors represent the magnitude (blue/cold/weak to green/warm/strong) at each pixel. The features are extracted at the 3rd layer of interest (Appendix A) from a randn-padded (Section 2.4) ResNet50 pretrained on ImageNet.
19
+
20
+ We accordingly propose a new evaluation paradigm and develop a method to consistently detect the presence of the Position-information Pattern from Padding (PPP), which is a persistent pattern embedded in the model features to retain positional information. We present two metrics to measure the response of PPP from the signal-to-noise perspective and demonstrate its robustness and low deviation among different settings, each with multiple trials of training.
21
+
22
+ To weaken the effect of PPP, in Section 2.4, we design a padding scheme with built-in stochasticity, making it difficult for the model to consistently construct such biases. However, our experiments show that the models can still circumvent the stochasticity and end up consistently constructing PPPs. These results suggest that a model likely constructs PPPs purposely to facilitate its training, rather than falsely or accidentally learning some filters that respond to padding features.
23
+
24
+ With reliable PPP metrics, we conduct a series of experiments to analyze the characteristics of PPP in Section 4.1. Specifically, we analyze the formation of PPP throughout each model training process in Section 4.3. The results show PPPs are formed expeditiously at the early stage of model training, slowly but steadily strengthen through time, and eventually shaped in clear and complete patterns. These results show that a model intentionally develops and reinforces PPPs to facilitate its learning process. Moreover, we observe the PPPs of all pretrained networks are significantly stronger than those in their initial states. This indicates an unbiased training procedure is of great importance in resolving the critical failures caused by PPP in numerous vision tasks (Alsallakh et al., 2021a; Xu et al., 2021; Ge et al., 2022; Alguacil et al., 2021).
25
+
26
+ # 2 OBSERVATIONS AND METHODOLOGY
27
+
28
+ In this section, we first define symbols for expressing the functionality of paddings and define the optimal-padding scheme. We then give a formal definition of Position-information Pattern from Padding (PPP) and utilize the optimal-padding scheme to develop propose a method to capture PPP and measure its response with two metrics.
29
+
30
+ # 2.1 OPTIMAL PADDING
31
+
32
+ The process of capturing an image from the real world can be simplified into two steps: (a) 3D information of the environment is first projected onto an infinitely large 2D plane, and then (b) the camera determines resolution as well as field-of-view to form a digital image from such infinitely large and continuous 2D signals (Liu et al., 2019; Ravi et al., 2020). Let $S ^ { * } = \{ s _ { n } ^ { * } \} _ { n = 1 } ^ { N }$ be a collection of such infinitely large and continuous 2D signals, and the collection of 2D images captured by cameras at a spatial size $( h _ { n } , w _ { n } )$ be $S ^ { \prime } = \{ s _ { n } ^ { \prime } \} _ { n = 1 } ^ { \mathbb { N } }$ . A padding scheme can be used to generate a set of algorithmically-padded images $\hat { S } = \{ \hat { s } _ { n } \} _ { n = 1 } ^ { N }$ by a padding function $\rho$ :
33
+
34
+ ![](images/c0a25d4970af93cf15e96a1750f2a0448e16a47e0e5db0dcf5d02831db9d75cf.jpg)
35
+ Figure 2: Principal point shift. (a) The stride-2 Conv2d only pads on one side, causing the principal point shift (red squares) in earlier layers. (b) Such a shift requires careful margin correction while aligning algorithmically-padded and optimally-padded features (we describe the details of point shift in Appendix A). (c) The shift is visible in the feature space (marked with red and yellow boxes). (d) It is crucial to correct the principal point shift while measuring PPP. The PPP calculation involves pixel-wise distance functions, which are not robust to spatial shifts (Zhang et al., 2018).
36
+
37
+ $$
38
+ \hat { s } _ { n } [ i , j ] = \left\{ { \begin{array} { l l } { s _ { n } ^ { \prime } [ i , j ] = s ^ { * } [ i , j ] } & { { \mathrm { i f ~ } } 0 < i < h _ { n } { \mathrm { ~ a n d ~ } } 0 < j < w _ { n } , } \\ { \rho ( s _ { n } ^ { \prime } , i , j ) } & { { \mathrm { o t h e r w i s e } } , } \end{array} } \right.
39
+ $$
40
+
41
+ collection where $i$ and $\dot { S ^ { \dagger } } = \{ s _ { n } ^ { \dagger } \} _ { n = 1 } ^ { N }$ $j$ are indexes of a pixel in the spatial dimension. We define a theoretical optimally-padded with an optimal-padding function $\rho ^ { \dagger }$ by:
42
+
43
+ $$
44
+ \begin{array} { r } { s _ { n } ^ { \dagger } [ i , j ] = \left\{ { s _ { n } ^ { \prime } [ i , j ] } \atop { \rho ^ { \dagger } ( s _ { n } ^ { \prime } , i , j ) } \right. \ } & { = s ^ { * } [ i , j ] \quad \mathrm { i f ~ } 0 < i < h _ { n } \mathrm { ~ a n d ~ } 0 < j < w _ { n } , } \\ { s ^ { \dagger } _ { n } [ i , j ] = \left\{ { s _ { n } ^ { \prime } [ i , j ] } \atop { \rho ^ { \dagger } ( s _ { n } ^ { \prime } , i , j ) } \right. \ } & { = s ^ { * } [ i , j ] \quad \mathrm { o t h e r w i s e } . } \end{array}
45
+ $$
46
+
47
+ In practice, without curated data, the optimal-padding scheme described in Eq. 2 is difficult to achieve. We describe how we relax this constraint in Section 2.3
48
+
49
+ # 2.2 POSITIONAL-INFORMATION PATTERN FROM PADDING
50
+
51
+ Despite the previous literature discovered the existence of positional information caused by the model paddings, there is still no clear definition for such information, and lacks effective metrics to detect or quantify it. Ideally, an effective metric for such positional information should have two properties. First, it is a spatial pattern, it contributes distinctive information to different spatial locations. Its shape enables the network to develop and exploit the absolute positional information of each pixel, eventually leading to the unattended and undesirable effects in certain tasks (Lin et al., 2022; Alsallakh et al., 2021a; Xu et al., 2021; Ntavelis et al., 2022; Choi et al., 2021; Ge et al., 2022; Alguacil et al., 2021). Second, as it represents the positional information purely contributed by the padding, it is a constant pattern irrelevant to the image contents. We accordingly name it the Positional-information Pattern from Padding (PPP).
52
+
53
+ Unfortunately, such a pattern shares space with image features, where the image features typically have very diverse appearances and high dimensionality. When these two signals interfere with each other, the appearance of PPP becomes extremely obscure and imperceptible in most cases (except zeros padding). Figure 1 shows if we visualize features sample-by-sample, there are no obvious differences between optimally-padded features (gray-scale surface) and algorithmically-padded features (colored surface). To address the issue, we show that, by assuming the interferences between PPP and image features to be random, its expectation over a large set of images will saturate to a constant bias and no longer hinder us from capturing PPP.
54
+
55
+ Based on these observations and assumptions, we define PPP as the constant component independent of model inputs, and its presence is completely contributed by the existence of a padding scheme $\rho$ . Given $\hat { S }$ and a model $F ( \hat { s } ; \theta , \rho )$ , which $\theta$ is the model parameters and $\rho$ is a padding scheme applied to $F$ . Let the model feature extracted at $k$ -th layer be $f _ { n , k } = F _ { k } ( \hat { s } _ { n } ; \theta , \rho )$ , where $F _ { k }$ is the model from the first layer to the $k$ -th layer. The PPP at $k$ -th layer $( P P P _ { k } )$ ) can be formulated by:
56
+
57
+ $$
58
+ \begin{array} { r } { \mathsf { P P P } _ { k } \ = \ \underset { n } { \mathbb { E } } \left[ \textit { d } \big ( \begin{array} { l } { F _ { k } ( s _ { n } ^ { \dagger } ; \theta , \rho ^ { \dagger } ) , F _ { k } ( \hat { s } _ { n } ; \theta , \rho ) } \end{array} \big ) \ \right] \ , } \end{array}
59
+ $$
60
+
61
+ where $d ( \cdot , \cdot )$ can be any distance function. We use $\ell _ { 1 }$ distance in this work, and accordingly name the metric PPP-MAE.
62
+
63
+ Pitfalls: feature misalignment. It is important to note that, some CNN components can cause serious feature misalignment while computing PPP and leads to erroneous results. A typical example is principal point shift, where the uneven padding in stride-2 convolution causes the center of features slightly drifted, as shown in Figure 2. Since the measurement of PPP requires perfect alignment, such a drift should be carefully considered while integrating PPP into new architectures. We discuss the issue along with other pitfalls in Appendix A and provide three detailed examples of correcting the principal point shifting.
64
+
65
+ # 2.3 SIMULATED OPTIMAL PADDING
66
+
67
+ In practice, it is impossible to gain access to $S ^ { * }$ for calculating the optimal padding $S ^ { \dagger }$ described in Eq. 2. But fortunately, given our goal in Eq. 3 is to analyze the model features within the $( h _ { n } , w _ { n } )$ region, $S ^ { * }$ is an overshoot of the data we actually required. Given a vision model $F ( \hat { s } ; \theta , \rho )$ trained at a field-of-view $( h _ { n } , w _ { n } )$ pixels, the receptive field of such vision model is $( h _ { m } , w _ { m } )$ pixels (we show the collection Apat where pixels, $h _ { m } \gg h _ { n }$ and tion $w _ { m } \gg w _ { n }$ . Let an altern field implies $S ^ { \odot } = \{ s _ { n } ^ { \odot } \} _ { n = 1 } ^ { N }$ $( h _ { m } , w _ { m } )$ $F _ { k } ( s _ { n } ^ { \dagger } ; \theta , \mathbf { \bar { \rho } } )$ equals to $F _ { k } \big ( s _ { n } ^ { \odot } ; \theta , \rho ^ { \dagger } \big )$ for all $k$ .
68
+
69
+ In other words, in terms of computing Eq. 3, $S ^ { \odot }$ is equivalent to $S ^ { * }$ within the finite $( h _ { n } , w _ { n } )$ region for a given model architecture. Therefore, we can simulate the procedure described in Eq. 1 and Eq. 2 using $S ^ { \odot }$ instead of $S ^ { \dagger }$ , as long as $\forall s _ { n } ^ { \odot } \in S ^ { \odot }$ the spatial size of $s _ { n } ^ { \odot }$ is strictly larger than $( h _ { m } , w _ { m } )$ .
70
+
71
+ # 2.4 RANDN PADDING
72
+
73
+ Most of the existing padding schemes (e.g., zeros, reflect, replicate, circular) exhibit certain consistent patterns that can be easily detected by some designed convolutional kernels. One may argue that the nature of easy detectability can be a root cause of encouraging the models to learn to rely on these obvious patterns. This motivates us to design an additional sampling-based padding scheme without any consistent patterns, namely randn (i.e., random normal) padding, which produces dynamical values from a normal distribution while following the local statistics. We first determine the maximal and minimal values of a sliding window (which can be easily achieved with max-pooling), use the average of them as a proxy mean $\mu _ { p }$ , and use the difference between the mean and the maximal value as a proxy standard deviation $\sigma _ { p }$ . For each padding location, we sample the padding value according to a normal distribution $\mathcal { N } ( \mu _ { p } , \sigma _ { p } ^ { 2 } )$ from the nearest sliding window. We include more implementation details in Appendix A.
74
+
75
+ Aside from creating a pattern-less padding scheme with sampling, the design of randn padding is based on several factors. The sampled padding pixels are allowed to occasionally exceed the min/max bound of the sliding window. Without breaking the min/max bound can introduce detectable patterns in certain extreme cases, such as a gradient-like feature that has its maximal intensity at the top-left corner and minimal intensity at the bottom-right corner. We also design the padding scheme to follow the local distribution. The padding exhibits high entropy when the local variation is high, while degenerates to value repetition with imperceptible perturbations while padding a flat area. As such, not only do the padding pixels exhibit less pattern, but it also prevents the padding pixels from breaking the features in the border region. We later show that a model still deliberately and incredibly built up PPP over time even with such a sophisticated padding scheme.
76
+
77
+ # 3 REVISITING PRIOR WORK
78
+
79
+ In this section, we first reproduce two experiments from the prior art, which aim to assess positional information from paddings. We show several critical design issues in these experiments and discuss how these problems affect the drawn conclusions. Finally, we propose two additional experiments to quantify the amount of positional information embedded in the paddings.
80
+
81
+ Table 1: Background color as a critical confounding variable in BHV test. We show that using a grey background similar to Figure 3 leads to discrepant results. The standard deviations are reported among 10 individual trials. We mark the best performance in green, and the worst two in red.
82
+
83
+ <table><tr><td rowspan="2">Padding</td><td rowspan="2">F-Conv?</td><td colspan="4">Black Background</td><td colspan="4">Grey Background</td></tr><tr><td>Similar (%)</td><td>Dissimilar (%)</td><td>Diff (%)</td><td>Inconsistency (%)</td><td>Similar (%)</td><td>Dissimilar (%)</td><td>Diff (%)</td><td>Inconsistency (%)</td></tr><tr><td rowspan="2">Zeros</td><td>N</td><td>99.83±0.00</td><td>3.21± 8.35</td><td>-87.68</td><td>95.81± 2.07</td><td>100.00± 0.00</td><td>4.96± 5.93</td><td>-95.04</td><td>97.85± 4.55</td></tr><tr><td>Y</td><td>89.24±0.98</td><td>89.24±0.98</td><td>0.00</td><td>18.02± 8.08</td><td>100.00±0.00</td><td>4.77± 6.52</td><td>-95.23</td><td>96.79±7.13</td></tr><tr><td rowspan="2">Circular</td><td>N</td><td>80.31±3.23</td><td>80.31± 3.23</td><td>0.00</td><td>34.25± 8.32</td><td>72.75± 0.96</td><td>72.75± 0.96</td><td>0.00</td><td>26.30± 5.55</td></tr><tr><td>Y</td><td>99.20±0.23</td><td>93.14±2.88</td><td>-6.06</td><td>18.48±3.55</td><td>98.26± 0.50</td><td>92.40±4.23</td><td>-5.87</td><td>28.67±6.18</td></tr><tr><td rowspan="2">Reflect</td><td>N</td><td>100.00±0.00</td><td>15.67±12.72</td><td>-84.33</td><td>91.18±13.19</td><td>100.00± 0.00</td><td>19.96±13.54</td><td>-80.04</td><td>90.33±11.95</td></tr><tr><td>Y</td><td>100.00±0.00</td><td>11.70±15.38</td><td>-88.30</td><td>97.33± 6.16</td><td>100.00±0.00</td><td>17.16±12.19</td><td>-82.84</td><td>98.13± 3.44</td></tr><tr><td rowspan="2">Replicate</td><td>N</td><td>100.00±0.00</td><td>43.39±11.42</td><td>-56.61</td><td>75.32± 8.20</td><td>100.00± 0.00</td><td>33.16± 6.42</td><td>-66.83</td><td>84.09± 6.47</td></tr><tr><td>Y</td><td>98.32±0.39</td><td>93.65± 1.36</td><td>-4.67</td><td>32.60± 4.97</td><td>97.17± 0.48</td><td>94.99± 1.20</td><td>-2.18</td><td>32.15± 5.11</td></tr><tr><td rowspan="2">Randn</td><td>N</td><td>100.00±0.00</td><td>10.31±12.56</td><td>-89.70</td><td>94.88± 5.55</td><td>99.97± 0.13</td><td>35.47±10.82</td><td>-64.50</td><td>83.59± 8.48</td></tr><tr><td>Y</td><td>100.00±0.00</td><td>20.80±14.15</td><td>-79.20</td><td>92.54±8.37</td><td>77.28±16.13</td><td>66.70±11.58</td><td>-10.59</td><td>45.70±20.62</td></tr><tr><td>No-pad</td><td>-</td><td>100.00±0.00</td><td>3.21± 8.35</td><td>-96.79</td><td>95.81± 2.07</td><td>100.00± 0.00</td><td>30.07± 4.06</td><td>-69.93</td><td>81.30± 2.44</td></tr></table>
84
+
85
+ # 3.1 POSENET
86
+
87
+ Islam et al. show zeros-padding provides CNN models positional information cues, and propose PosENet (Islam\* et al., 2020) to quantify the amount of positional information encoded within CNN features. A PosENet experiment involves several components: a pretrained CNN model $F$ , a shallow CNN $E _ { p e m }$ (i.e., position encoding module), an image dataset $X = \{ x _ { i } \} _ { i = 1 } ^ { N }$ to examine, and a constant target pattern $y$ (e.g., 2D Gaussian pattern). PosENet first extracts intermediate features at $k$ -th layer with $f _ { ( i , k ) } = F _ { k } ( x _ { i } )$ using the pretrained CNN, and then optimizes $E _ { p e m }$ to minimize $\mathbb { E } _ { i , k } [ | | E _ { p e m } ( f _ { ( i , k ) } ) - y | | _ { 2 } ]$ . Finally, the amount of positional information is quantified by the average Spearman’s correlation (SPC) and Mean Absolute Error (MAE) overall $E _ { p e m } ( f _ { ( i , k ) } )$ toward $y$ .
88
+
89
+ A critical issue with PosENet is the use of an optimization-based metric. It is sensitive to hyperparameters with large variation. As shown in Table 2, for all the PosENet results, the standard deviation over five trials significantly dominates the differences between different types of paddings, and thus no definitive conclusions can be drawn. We also observed that PosENet can report NaN results in certain setups. Furthermore, PosENet quantifies the amount of positional information by the faithfulness of the final reconstruction. However, a better reconstruction does not have a clear relationship to measuring the strength and significance of positional information. For instance, PosENet sometimes shows responses to no-padding models, demonstrating it is a metric with an indefinite bias pending on the memorization ability of $E _ { p e m }$ . Moreover, optimizing for pattern reconstruction is highly dependent on the underlying data distribution, simply changing the evaluation data distribution without changing the model weights can drastically change the PosENet numerical magnitudes and the conclusions of which model embeds the strongest positional information.
90
+
91
+ Another issue is that the no-padding scheme used in the $E _ { p e m }$ module in PosENet is known to have the foveal effect (Alsallakh et al., 2021b; Luo et al., 2016), where a model pays less attention to the information on the edge of inputs. Using such a padding scheme for detecting positional information from paddings, which is mostly concentrated on the edge of the feature maps, is less effective. This is an inevitable dilemma as PosENet aims to identify positional information from the padding of the pretrained $F$ , while applying any padding scheme to $E _ { p e m }$ introduces intractable effects between the paddings of the two models.
92
+
93
+ # 3.2 F-CONV
94
+
95
+ Kayhan et al. propose a full-padding scheme (F-Conv) (Kayhan & Gemert, 2020) and demonstrate it is more translational invariant than the alternatives. One of the critical results is on “border handling variants” (Exp 2 of (Kayhan & Gemert, 2020)), which we call it BHV test. The BHV test creates a toy dataset, where each image has a black background with a green square and a red square in the foreground. The task is to predict if the red square is on the left of the green square (class 1), or vice versa (class 2). In addition, Kayhan et al. intentionally adds a location bias such that both squares are located in the upper half of the image for class 1, and located in the lower half of the image for class 2. During testing, a “similar test” inherits the same bias, while a “dissimilar test” exchanges the bias (i.e., both squares are in the lower half of the image for class 1). As a truly translation-invariant CNN model should not be affected by the location bias, it should focus on the relation between the red and green squares and perform similarly on both tests. Since the experimental results show that F-Conv performs best on the dissimilar test, it is concluded that F-Conv is less sensitive to the location bias. The authors also conclude the circular padding performs worse due to the behavior of wrapping the pixels to the other side of the image, which leads to confusion between two classes.
96
+
97
+ ![](images/8eff9d62aa85c9765ac32f2d177447c962ee0762431f465e1b2d4ebf480d0341.jpg)
98
+ Figure 4: Visualization of Position-Information Pattern from Padding (PPP). The visualizations are calculated based on Eq. 3 over 480 GMap samples extracted at the 3rd layer-of-interest (Appendix A). The results show that the pretrained model significantly reinforces PPP compared to randomly initialized networks. Note that each image is normalized to $[ 0 , 1 ]$ separately, therefore the colors between images are not comparable. More visualizations are presented in Appendix B.
99
+
100
+ However, as shown in Figure 3, we find the experimental design does not consider a crucial confounding variable: the black background has a zero intensity, making zeros padding the optimal padding that perfectly follows the background distribution. In Table 1, we show that the dissimilar test is no longer in favor of F-Conv zeros after changing the background color to grey. We also show that F-Conv replicate and F-Conv circular perform best on the dissimilar test, which is different from the original observation.
101
+
102
+ Finally, we report an additional inconsistency rate to show that the CNN architecture used in the BHV test actually has access to the absolute position of the squares. Given a random sample in class 1, we create a trajectory of samples by simultaneously moving the two squares to the bottom of the canvas and recording the CNNmodel prediction in all intermediate states. We label a trajectory to be inconsistent if the prediction of the CNN-model switches classes at any step of the trajectory. A CNN model with no access to the absolute-position information should have all trajectories maintaining consistent predictions, with $0 \%$ inconsistency. Table 1 shows the inconsistent ratio over 228 uniformly sampled trajectories, where all models maintain high inconsistency rates, even with a no-padding architecture. These results show that the CNN model used in the BHV test is not translation invariant. This can be attributed to that a CNN model has a large receptive field covering the whole experiment canvas, therefore capable of gradually constructing absolute coordinates for each input pixel. Note that we only show the design of the BHV test is not suitable for quantifying the amount of positional information exhibited in a CNN model. Such a conclusion does not imply that F-Conv cannot potentially improve the translation-invariant property of CNNs.
103
+
104
+ ![](images/911fffa05b9eedc6ab963d9f5c93aa9597332089a3ad2ea373b41482c80ba1b1.jpg)
105
+ Figure 3: The BHV test trains a binary classifier to predict the relative position of the two colored squares. It hypothesizes if the padding provides no positional information, the classifier will only focus on the relative position of the two squares. (Left) The black background is a confounding variable. (Right) Zeros padding no-longer pads optimum values after changing the background color.
106
+
107
+ # 4 EXPERIMENTS AND ANALYSIS
108
+
109
+ Datasets Since most vision models are trained on tasks for recognizing objects, an image collection containing a diverse object appearance is more suitable for the task. As mentioned in Section 2.3, evaluating PPP requires images at a large field-of-view, in practice, we collect images at $2 , 0 4 8 \times 2 , 0 4 8$ pixels, which is larger than the receptive field of all the models we tested. Due to the constraint of large field-of-view, we compute PPP on three datasets (all at $2 , 0 4 8 \times 2 , 0 4 8$ pixels): (a) 480 satellite images crawled from Google Map, (b) 1,024 images synthesized by InfinityGAN (Lin et al., 2022) trained with Flickr-Landscape dataset, and (c) 1,024 images synthesized by InfinityGAN trained with LSUN-Tower (Yu et al., 2015) dataset. We crop the images depending on the requested input image sizes and principal point shifts from each model (see Appendix A for details). We will release the script for collecting and composing these large images.
110
+
111
+ Table 2: Comparing PosENet and our proposed PPP metrics. Most of the PosENet results are not distinguishable due to the high standard deviations. The standard deviation is computed by five different pretrained models for each test. The performance shows the accuracy (for classification) or weighted F-measure score (for saliency object detection). We use 2D Gaussian as PosENet reconstruction pattern, and PPP-MAE is measured at the 4th layer of interest. Here, (↑) indicates a higher value corresponds to stronger positional information or better performance on the task (vice versa for (↓)). For each group of pretrained models, we label the strongest positional information response with red, and the experiments within its standard deviation range with orange.
112
+
113
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Padding</td><td rowspan="2">Eval Dataset</td><td colspan="2">PosENet</td><td rowspan="2">PPP-MAE(ours) (↑)</td><td rowspan="2">Performance (↑)</td></tr><tr><td>SPC (↑)</td><td>MAE(↓)</td></tr><tr><td rowspan="10">VGG-19</td><td>Zeros</td><td>GMap InfinityGAN-flickr</td><td>0.107±0.128 0.368±0.116</td><td>0.196±0.006 0.183±0.007</td><td>0.0176±0.0005 0.0163±0.0006</td><td rowspan="2">74.0972±0.0870</td></tr><tr><td></td><td>InfinityGAN-tower GMap</td><td>0.492±0.106</td><td>0.173±0.010</td><td>0.0179±0.0001</td></tr><tr><td rowspan="8">Circular</td><td></td><td>0.098±0.139</td><td>0.197±0.007</td><td>0.0158±0.0006</td><td rowspan="2">74.4716±0.0863</td></tr><tr><td>InfinityGAN-flickr</td><td>0.323±0.147</td><td>0.185±0.009</td><td>0.0137±0.0004</td></tr><tr><td rowspan="8">Reflect</td><td>InfinityGAN-tower</td><td>0.460±0.102</td><td>0.176±0.009</td><td>0.0184±0.0005</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>GMap InfinityGAN-flickr</td><td>0.109±0.139 0.343±0.132</td><td>0.196±0.007 0.185±0.008</td><td>0.0158±0.0002</td></tr><tr><td>InfinityGAN-tower</td><td></td><td>0.0146±0.0008 0.0168±0.0005</td><td>74.0516±0.0621</td></tr><tr><td>GMap</td><td>0.460±0.113 0.084±0.137</td><td>0.177±0.009</td><td>0.0144±0.0009 73.9964±0.1079</td></tr><tr><td>InfinityGAN-flickr</td><td>0.356±0.111</td><td>0.197±0.006 0.184±0.007</td><td>0.0128±0.0012</td></tr><tr><td></td><td></td><td>0.173±0.010</td><td></td></tr><tr><td rowspan="6"></td><td rowspan="2"></td><td>InfinityGAN-tower</td><td>0.498±0.111</td><td></td><td>0.0156±0.0006</td><td rowspan="2"></td></tr><tr><td>GMap</td><td>0.125±0.154</td><td>0.195±0.006</td><td>0.0182±0.0012</td></tr><tr><td rowspan="6">Randn</td><td>InfinityGAN-flickr</td><td>0.374±0.137</td><td>0.185±0.007</td><td>0.0167±0.0008</td><td rowspan="2">73.7716±0.0758</td></tr><tr><td>InfinityGAN-tower</td><td>0.421±0.161</td><td>0.181±0.010</td><td>0.0186±0.0012</td></tr><tr><td>GMap</td><td>0.001±0.239</td><td>0.204±0.013</td><td>0.0000±0.0000</td><td></td></tr><tr><td>InfinityGAN-flickr</td><td>0.303±0.192</td><td>0.187±0.012</td><td>0.0000±0.0000</td><td>62.0396±0.0830</td></tr><tr><td rowspan="8"></td><td>InfinityGAN-tower</td><td>0.516±0.139</td><td>0.172±0.014</td><td>0.0000±0.0000</td><td></td></tr><tr><td rowspan="8">Zeros</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GMap InfinityGAN-flickr</td><td>0.191±0.188 0.682±0.107</td><td>0.193±0.008 0.152±0.019</td><td>0.0162±0.0012 0.0137±0.0004</td><td>75.6856±0.0924</td></tr><tr><td>InfinityGAN-tower</td><td></td><td>0.144±0.017</td><td>0.0153±0.0013</td><td></td></tr><tr><td rowspan="10">Circular</td><td></td><td>0.721±0.077</td><td></td><td>0.0188±0.0016</td><td>76.1432±0.1026</td></tr><tr><td>GMap</td><td>0.398±0.115</td><td>0.197±0.007</td><td></td><td></td></tr><tr><td>InfinityGAN-flickr</td><td>0.628±0.084</td><td>0.159±0.013</td><td>0.0178±0.0005</td><td></td></tr><tr><td>InfinityGAN-tower</td><td>0.585±0.105</td><td>0.165±0.014</td><td>0.0189±0.0012</td><td></td></tr><tr><td rowspan="8"></td><td rowspan="2">Reflect</td><td></td><td></td><td></td><td></td><td rowspan="2"></td></tr><tr><td>GMap</td><td>0.197±0.185</td><td>0.192±0.008</td><td>0.0150±0.0004</td></tr><tr><td rowspan="9">Replicate</td><td>InfinityGAN-flickr</td><td>0.594±0.096</td><td>0.169±0.012</td><td>0.0134±0.0009</td><td rowspan="2">75.5068±0.1213</td></tr><tr><td>InfinityGAN-tower</td><td>0.667±0.087</td><td>0.153±0.016</td><td>0.0157±0.0002</td></tr><tr><td>GMap</td><td>0.249±0.192</td><td>0.189±0.009</td><td>0.0138±0.0003</td></tr><tr><td>InfinityGAN-flickr</td><td>0.700</td><td>0.147±0.018</td><td>0.0114±0.0003</td><td>75.6122±0.0911</td></tr><tr><td rowspan="8">Randn</td><td>InfinityGAN-tower</td><td>2±0.095</td><td></td><td>0.0142±0.0007</td><td></td></tr><tr><td></td><td>0.726±0.069</td><td>0.142±0.016</td><td></td><td></td></tr><tr><td>GMap</td><td>0.210±0.192</td><td>0.191±0.009</td><td>0.0147±0.0007</td><td>75.3076±0.1016</td></tr><tr><td rowspan="10"></td><td>InfinityGAN-flickr</td><td>0.566±0.100</td><td>0.171±0.011</td><td>0.0122±0.0011</td><td></td></tr><tr><td>InfinityGAN-tower</td><td>0.714±0.068</td><td>0.142±0.015</td><td>0.0153±0.0004</td><td></td></tr><tr><td></td><td></td><td></td><td>0.0049±0.0001</td><td></td></tr><tr><td>GMap InfinityGAN-flickr</td><td>0.156 ±0.212</td><td>0.201 ±0.017</td><td></td><td></td></tr><tr><td rowspan="8">Circular</td><td></td><td></td><td>0.184±0.012</td><td>0.0036±0.0001</td><td>0.6269±0.0015</td></tr><tr><td rowspan="8"></td><td></td><td>0.365±0.140</td><td></td><td></td><td></td></tr><tr><td>InfinityGAN-tower</td><td>0.449±0.120</td><td>0.179±0.013</td><td>0.0032±0.0001</td><td></td></tr><tr><td>GMap</td><td>0.011±0.209</td><td>0.207±0.014</td><td>0.0062±0.0001</td><td>0.6260±0.0009</td></tr><tr><td>InfinityGAN-flickr InfinityGAN-tower</td><td>0.329±0.133 0.398±0.115</td><td>0.187±0.012 0.182±0.011</td><td>0.0068±0.0001 0.0050±0.0002</td><td></td></tr><tr><td rowspan="2">Reflect</td><td></td><td></td><td></td><td></td></tr><tr><td>GMap</td><td>0.062±0.210 0.205±0.016</td><td></td><td>0.0053±0.0001</td></tr><tr><td rowspan="2"></td><td>InfinityGAN-flickr InfinityGAN-tower</td><td>0.322±0.133 0.396±0.125</td><td>0.188±0.013 0.183±0.013</td><td>0.0030±0.0001 0.0039±0.0001</td><td rowspan="2">0.6243±0.0022</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td rowspan="7"></td><td rowspan="2">Replicate</td><td>GMap</td><td></td><td>0.204±0.016</td><td>0.0043±0.0002</td><td rowspan="2">0.6255±0.0013</td></tr><tr><td>InfinityGAN-flickr</td><td>0.071±0.215 0.335±0.139</td><td></td><td>0.0023±0.0001</td></tr><tr><td rowspan="9"></td><td></td><td></td><td>0.186±0.012</td><td></td><td rowspan="2"></td></tr><tr><td>InfinityGAN-tower</td><td>0.409±0.120</td><td>0.182±0.012</td><td>0.0032±0.0001</td></tr><tr><td>GMap</td><td></td><td></td><td></td></tr><tr><td>InfinityGAN-flickr InfinityGAN-tower</td><td>0.002±0.244 0.228±0.173</td><td>0.202±0.009 0.197±0.010</td><td>0.0001±0.0000 0.0001±0.0000</td><td>0.2570±0.0022 0.0001±0.0000</td></tr><tr><td rowspan="8"></table>
114
+
115
+ Table 3: Significant PPP gain from model training. We measure PPP-MAE on GMap with randomly initialized and fully trained models. The results show a consistent and significant increment of PPP is developed through the model training.
116
+
117
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Pretrained</td><td colspan="5">Padding</td></tr><tr><td>Zeros</td><td>Circular</td><td>Reflect</td><td>Replicate</td><td>Randn</td></tr><tr><td rowspan="2">VGG-19</td><td>×</td><td>0.0132±0.0006</td><td>0.0000±0.0000</td><td>0.0000±0.0000</td><td>0.0000±0.0000</td><td>0.0000±0.0000</td></tr><tr><td>ImageNet</td><td>0.0176±0.0005</td><td>0.0158±0.0006</td><td>0.0158±0.0002</td><td>0.0144±0.0009</td><td>0.0182±0.0012</td></tr><tr><td rowspan="2">ResNet50</td><td>×</td><td>0.0052±0.0004</td><td>0.0032±0.0004</td><td>0.0018±0.0001</td><td>0.0015±0.0001</td><td>0.0020±0.0002</td></tr><tr><td>ImageNet</td><td>0.0162±0.0012</td><td>0.0188±0.0016</td><td>0.0150±0.0004</td><td>0.0150±0.0004</td><td>0.0147±0.0007</td></tr></table>
118
+
119
+ # 4.1 VISUALIZING POSITION-INFORMATION PATTERN FROM PADDING (PPP)
120
+
121
+ We start with visualizing PPP in Figure 4. All the visualizations are conducted at the 3rd layer of interest as detailed in Appendix A. We compute PPP using Eq. 3 and $\ell _ { 1 }$ norm as the distance metric, then average the resulting PPP in the channel dimension to generate a gray-scale image. Since the quantities are small and difficult to perceive, we normalize the gray-scale image to [0, 1] range, and thus the colors between images are not directly comparable.
122
+
123
+ In all scenarios, PPP noticeably spreads out after being pretrained on ImageNet. In Table 3, the PPPMAE of the VGG19 and ResNet50 also reflects that the response of PPP is significantly strengthened after model training. That is, the model training has substantial effects on the construction of PPP. Although the formation of padding pattern is suggested to be mainly caused by the distributional difference between features and paddings (Alsallakh et al., 2021a), our results show that it only increases the response slightly, compared to the considerable PPP-MAE gain through training.
124
+
125
+ Another intriguing observation is that, despite some variations in the detailed patterns, the overall structure of PPP remains similar. Regardless of padding minimum values with zero-padding (consider the features are processed with ReLU activation), randn-padding that can sometimes produce large quantities by chance, or the unbalanced initial state of ResNet50 caused by strided convolution (the first row of ResNet50 in Figure 4), all models tend to have the maximal PPP response in the corner of the features after fully trained. While the underlying mechanism causing such consistent preferences remains unknown, such preferences may be an important factor to consider in future model design.
126
+
127
+ # 4.2 QUANTIFYING PPP AND COMPARING WITH POSENET
128
+
129
+ Table 2 shows the measurements of PPP and PosENet on various architectures and padding schemes. We train five models for each setup and measure the standard deviation of these models. Our PPP-MAE has significantly lower standard deviations compared to PosENet, where the standard deviation of PosENet dominates the differences between padding variants, and thus the quantities from PosENet cannot provide sufficient information for any analysis. Evaluating the true mean of PosENet requires an even larger number of pretrained models, each requiring full training on the target dataset (e.g., ImageNet), which is impractical in reality. The main reason that PosENet has such a large variation is due to its optimization-based formulation, and thus the final quantities highly depend on the convergence of the PosENet training. In fact, we also observe a similar level of standard deviation even when the PosENet is measured on the same model for multiple trials. On the other hand, PPP is based on a closed-form formulation, and thus the variations are only introduced by the differences among the parameters of the pretrained models. Furthermore, PosENet often reports positive SPC responses from no-padding models, as shown in its large standard deviation. In contrast, PPP has zero response to no-padding models by definition, and therefore is less biased for measuring the positional information from padding.
130
+
131
+ Although certain paddings seem to have slightly lower PPP-MAE than other paddings, in Table 3, we find the differences are not significant when comparing the extremely low PPP-MAE from most of the randomly initialized networks. In most cases, the network can effectively construct its PPP, even with the highly stochastic randn padding. The only exception seems to be the case of randn padding in the salient object detection (SOD) task, where the network fails to achieve a compatible performance with other paddings1. The results show that the model training plays an important role in the formation of PPP, and perhaps its contribution is much larger than which underlying padding scheme is being used. This motivates us to further analyze the PPP formulation during model training.
132
+
133
+ ![](images/7f1c9e44a46e7d7615b221277f4944764af9c97f2701bfe630341a9b9c42d699.jpg)
134
+ Figure 5: Chronological PPP. We quantify PPP every 10 epochs and plot its development in four different layer of depth (the rightmost layer is the one closest to model output). All curves consistently show a sudden surge at the early stage, and all the later layers are slowly but steadily gaining stronger PPP until the end of training. The shadow region represents standard deviations among 5 individual training episodes. The colors represent zeros, circular, reflect, replicate, and randn paddings.
135
+
136
+ # 4.3 CHRONOLOGICAL PPP
137
+
138
+ To understand the formulation of PPP through time, we snapshot checkpoints every 10 epochs for all training episodes. By measuring the PPP-MAE at all the checkpoints, we plot a chronological curve and monitor the progress of PPP. We train 5 individual models for each pair of model-padding setting and report the standard deviations, which demonstrates the significance of the trend.
139
+
140
+ Figure 5 shows all models achieve a significant gain of PPP within the first 10 epochs in all intermediate layers. Most models continuously increase their PPP as training proceeds, especially in the fourth layer of interest, which is the last output from the convolutional layers before the final linear projection. Another interesting observation is that our randn padding, which is designed to be less easily detectable with built-in stochasticity, indeed shows less PPP built-up at the intermediate stages in certain layers. However, the network still adjusts the behavior and ends up forming complete PPPs at the fourth layer of interest in all scenarios. All these evidences show that the network builds PPP purposely as a favorable representation to assist its learning.
141
+
142
+ # 5 CONCLUSION AND LIMITATIONS
143
+
144
+ In this paper, we develop a reliable method for measuring PPP and conduct a series of analyses toward understanding the formation and properties of PPP. Through a large-scale study, we demonstrate that PPP is a representation that the network favorably develops as a part of its learning process, and its formation has weak connections to the underlying padding algorithm. We show that reliable PPP metrics are important steps for understanding the effects of PPPs in different tasks, and useful for measuring the effectiveness of future methods in debiasing PPP.
145
+
146
+ However, an unfortunate and inevitable limitation of the PPP metrics is that their measure is biased by the model architecture and parameters. Since the PPP metrics are based on the distributional differences between the paired model outputs (i.e., optimal padding to algorithmic padding), different architecture and layers of depth exhibit different and intractable biases due to different interactions between PPP and model parameters. Such a bias makes PPP metrics less comparable while dissecting models with different architectures or parameter distributions (e.g., weight decay and weight normalization), which is important for studying the effect of architectural changes. However, this limitation is inevitable for any (and all existing) metric that attempts to measure PPP using the outputs of a model. We note future studies in measuring PPP without model inferences2 will be an important step toward tackling and understanding the property of PPP under different architectural choices.
147
+
148
+ # REFERENCES
149
+
150
+ Antonio Alguacil, Wagner Gonçalves Pinto, Michael Bauerheim, Marc C Jacob, and Stéphane Moreau. Effects of boundary conditions in fully convolutional networks for learning spatio-temporal dynamics. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, 2021. 1, 2, 3
151
+
152
+ Bilal Alsallakh, Narine Kokhlikyan, Vivek Miglani, Jun Yuan, and Orion Reblitz-Richardson. Mind the pad – {cnn}s can develop blind spots. In International Conference on Learning Representations, 2021a. 1, 2, 3, 8
153
+
154
+ Bilal Alsallakh, Vivek Miglani, Narine Kokhlikyan, David Adkins, and Orion Reblitz-Richardson. Are convolutional networks inherently foveated? In SVRHM 2021 Workshop at NeurIPS, 2021b. 1, 5
155
+
156
+ Jooyoung Choi, Jungbeom Lee, Yonghyun Jeong, and Sungroh Yoon. Toward spatially unbiased generative models. In IEEE International Conference on Computer Vision, 2021. 1, 3
157
+
158
+ Songwei Ge, Thomas Hayes, Harry Yang, Xi Yin, Guan Pang, David Jacobs, Jia-Bin Huang, and Devi Parikh. Long video generation with time-agnostic vqgan and time-sensitive transformer. arXiv preprint arXiv:2204.03638, 2022. 1, 2, 3
159
+
160
+ Carlo Innamorati, Tobias Ritschel, Tim Weyrich, and Niloy J Mitra. Learning on the edge: Investigating boundary filters in cnns. International Journal of Computer Vision, 2020. 1
161
+
162
+ Md Amirul Islam\*, Sen Jia\*, and Neil D. B. Bruce. How much position information do convolutional neural networks encode? In International Conference on Learning Representations, 2020. 1, 5
163
+
164
+ Md Amirul Islam, Matthew Kowal, Sen Jia, Konstantinos G. Derpanis, and Neil Bruce. Boundary effects in {cnn}s: Feature or bug? https://openreview.net/forum?id=M4qXqdw3xC, 2021a. 1
165
+
166
+ Md Amirul Islam, Matthew Kowal, Sen Jia, Konstantinos G Derpanis, and Neil DB Bruce. Position, padding and predictions: A deeper look at position information in cnns. arXiv preprint arXiv:2101.12322, 2021b. 1
167
+
168
+ Osman Semih Kayhan and Jan C van Gemert. On translation invariance in cnns: Convolutional layers can exploit absolute spatial location. In IEEE Conference on Computer Vision and Pattern Recognition, 2020. 1, 5
169
+
170
+ Kuangliu. pytorch-cifar. https://github.com/kuangliu/pytorch-cifar, 2017. 12
171
+
172
+ Chieh Hubert Lin, Yen-Chi Cheng, Hsin-Ying Lee, Sergey Tulyakov, and Ming-Hsuan Yang. InfinityGAN: Towards infinite-pixel image synthesis. In International Conference on Learning Representations, 2022. 1, 3, 6
173
+
174
+ Nian Liu, Junwei Han, and Ming-Hsuan Yang. Picanet: Learning pixel-wise contextual attention for saliency detection. In IEEE Conference on Computer Vision and Pattern Recognition, 2018. 8
175
+
176
+ Shichen Liu, Tianye Li, Weikai Chen, and Hao Li. Soft rasterizer: A differentiable renderer for image-based 3d reasoning. In IEEE International Conference on Computer Vision, 2019. 3
177
+
178
+ Wenjie Luo, Yujia Li, Raquel Urtasun, and Richard Zemel. Understanding the effective receptive field in deep convolutional neural networks. In Neural Information Processing Systems, 2016. 1, 5
179
+
180
+ Joe Mellor, Jack Turner, Amos Storkey, and Elliot J Crowley. Neural architecture search without training. In International Conference on Machine Learning, 2021. 9
181
+
182
+ Evangelos Ntavelis, Mohamad Shahbazi, Iason Kastanis, Radu Timofte, Martin Danelljan, and Luc Van Gool. Arbitrary-scale image synthesis. In IEEE Conference on Computer Vision and Pattern Recognition, 2022. 1, 3
183
+
184
+ Oskyhn. Cnns-without-borders. https://github.com/oskyhn/CNNs-Without-Borders, 2019. 12
185
+
186
+ Pytorch. vision. https://github.com/pytorch/vision, 2016. 12
187
+
188
+ Nikhila Ravi, Jeremy Reizenstein, David Novotny, Taylor Gordon, Wan-Yen Lo, Justin Johnson, and Georgia Gkioxari. Accelerating 3d deep learning with pytorch3d. arXiv preprint arXiv:2007.08501, 2020. 3
189
+
190
+ Rui Xu, Xintao Wang, Kai Chen, Bolei Zhou, and Chen Change Loy. Positional encoding as spatial inductive bias in gans. In IEEE Conference on Computer Vision and Pattern Recognition, 2021. 1, 2, 3
191
+
192
+ Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015. 6
193
+
194
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In IEEE Conference on Computer Vision and Pattern Recognition, 2018. 3
195
+
196
+ # Supplementary Material
197
+
198
+ APPENDIX A IMPLEMENTATION DETAILS
199
+
200
+ ![](images/f4be03039849096030af3e78b6d7d901fb3b3e8f012e09ff2a3e21cfa0e50704.jpg)
201
+ Figure 6: The architecture for VGG19 and ResNet50 used in the paper. We mark the calculation of optimal padding in orange arrows and principal point in blue arrows. We label the layers of interest that are used in the paper. The red $\dagger$ indicates where a principal point shift is identified.
202
+
203
+ # A.2 PPP FEATURE MISALIGNMENT
204
+
205
+ There are several pitfalls in visualizing and quantifying PPP. We identify two critical pitfalls from the architectures we implemented. However, these may not be sufficient to cover all potential issues while integrated into other architectures. Therefore one must be alerted to any unusual behavior (e.g., Figure 2(d) in the main paper) throughout their implementation.
206
+
207
+ Principal point shifting. Conv2d has a hidden behavior that few people are aware of, the operation is one-pixel skewed while applying a stride-two Conv2d on even-shaped features. To understand how the one-pixel shift happens, we first define the principal point of a feature map. We first define the principal point of the last feature map as the center pixel (note that we define it as the middle-point between the center-two pixels in case the last feature size is even). Then, we recursively define the principal point of the $( N - 1 )$ -th layer as the pixel that positions at the center of the Conv2d receptive field that mainly forms the principal point of the $N$ -th layer. In the case of optimally-padded features, the principal points in every layer are the center of the feature map. But, as shown in Figure 2(a), the principal point of algorithmically-padded features will have a one-pixel shift when a stride-2 convolution is applied to even-shaped features, which can be further amplified as more layers stack up. Such a skew causes the principal points of algorithmically-padded features shift several pixels away from the principal points of optimally-padded features. As PPP metrics use pixel-wise subtraction to distinguish the image content from PPP, the misalignment becomes a critical issue, since the image contents are no longer aligned and subtractable.
208
+
209
+ In Figure 6, we show the procedure of calculating the principal point in blue arrows and marking the values impacted by principal point shift with red $\dagger$ . For the ResNet50 architecture, the principal point shift accumulates to $1 6 ( = 2 \bar { 2 } 4 / 2 - 9 6 )$ pixels in the early layers.
210
+
211
+ Fortunately, such a displacement can be fixed by adding corrections to how we calculate the feature margins. As shown in Figure 2(b), the concept of the margin correction is to make the two principal points overlapping each other after adding the margin. In the example, the left-right margins are corrected to (209, 180) (instead of the more intuitive choice of (195, 194) or (194.5, 194.6)).
212
+
213
+ We also show how the principal point shift visually looking like in Figure 2(c), notice the patterns have right-bottom shifted 16 pixels. As shown in Figure 2(d), failing to identify the principal point shift will result in checkerboard artifacts while calculating PPP, and adding correction eliminates the artifacts.
214
+
215
+ Maxpooling misalignment. This is a hypothetical condition that may potentially happen but has not been observed in the three architectures we tested. Consider a case of a Maxpooling layer of window size 2 and stride 2, the sliding windows of each pooling operation have no overlap, therefore the initial index of the first sliding window solely determines the spatial location of all sliding windows. Accordingly, there is a chance that the initial condition of the optimally-padded features causes all of its sliding windows to be one-pixel misaligned to the algorithmically-padded features. Fortunately, the condition can be easily determined by calculating the top and left margins of the feature alignment (similar to the aforementioned principal point shift calculation). For the case of a Maxpooling layer of window size 2 and stride 2, the misalignment will not happen if the top and left margins are even numbers, and that is exactly the case for VGG19 and ResNet50, as shown in Figure 6.
216
+
217
+ # A.3 RANDN PADDING
218
+
219
+ A critical implementation detail is that such a padding scheme must be applied before activation functions. Since the paddings are based on the distribution within sliding windows, activation functions such as ReLU, which clamps all negative values, can discard a significant amount of information beforehand. Instead of the traditional use of padding-convolution-normalization-activation, we modify the order to convolution-normalization-padding-activation. Note that such a change of order does not affect the behavior or results of other padding schemes.
220
+
221
+ # A.4 ACKNOWLEDGING OPEN-SOURCE CONTRIBUTORS
222
+
223
+ Our implementation reuses codes from several open-source codebases, which greatly supports our development. The repositories used in the paper are F-Conv (Oskyhn, 2019), torchvision (Pytorch, 2016) and Pytorch-cifar (Kuangliu, 2017).
224
+
225
+ # APPENDIX B MORE PPP VISUALIZATIONS
226
+
227
+ ![](images/30d63de2ca96d08fcb9c306ea6f49dee853045f2ae15c56e1bbe54f442d042e9.jpg)
228
+ Figure 7: Visualization of Position-Information Pattern from Padding (PPP). The visualizations are calculated based on Eq. 3 over 480 GMap samples. The results show that the pretrained model significantly reinforces PPP compared to randomly initialized networks. Note that each image is normalized to $[ 0 , 1 ]$ separately, therefore the colors between images are not comparable.
229
+
230
+ ![](images/e4cd61435c542304b5c3cdb789a139ba20d665db70a7bc8695957868fac75dd7.jpg)
231
+ Figure 8: Visualization of Position-Information Pattern from Padding (PPP). The visualizations are calculated based on Eq. 3 over 480 GMap samples. The results show that the pretrained model significantly reinforces PPP compared to randomly initialized networks. Note that each image is normalized to $[ 0 , 1 ]$ separately, therefore the colors between images are not comparable.
232
+
233
+ ![](images/575354cc406647ad7d0a0db777cb6d300e968b30e3073fc4c6fb00e81afc740b.jpg)
234
+ Figure 9: Visualization of Position-Information Pattern from Padding (PPP). The visualizations are calculated based on Eq. 3 over 480 GMap samples. The results show that the pretrained model significantly reinforces PPP compared to randomly initialized networks. Note that each image is normalized to [0, 1] separately, therefore the colors between images are not comparable.
md/dev/Re3NjSwf0WF/Re3NjSwf0WF.md ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Legged Locomotion in Challenging Terrains using Egocentric Vision
2
+
3
+ Ananye Agarwal⇤ 1 Ashish Kumar⇤ 2, Jitendra Malik†2, Deepak Pathak†1 1Carnegie Mellon University, 2UC Berkeley
4
+
5
+ ![](images/c4f1c976fde50957026f7617546345bc3f0acba84803be2238a390f39d23d4a0.jpg)
6
+ Figure 1: Our robot can traverse a variety of challenging terrain in indoor and outdoor environments, urban and natural settings during day and night using a single front-facing depth camera. The robot can traverse curbs, stairs and moderately rocky terrain. Despite being much smaller than other commonly used legged robots, it is able to climb stairs and curbs of a similar height. Videos at https://vision-locomotion.github.io
7
+
8
+ Abstract: Animals are capable of precise and agile locomotion using vision. Replicating this ability has been a long-standing goal in robotics. The traditional approach has been to decompose this problem into elevation mapping and foothold planning phases. The elevation mapping, however, is susceptible to failure and large noise artifacts, requires specialized hardware, and is biologically implausible. In this paper, we present the first end-to-end locomotion system capable of traversing stairs, curbs, stepping stones, and gaps. We show this result on a medium-sized quadruped robot using a single front-facing depth camera. The small size of the robot necessitates discovering specialized gait patterns not seen elsewhere. The egocentric camera requires the policy to remember past information to estimate the terrain under its hind feet. We train our policy in simulation. Training has two phases - first, we train a policy using reinforcement learning with a cheap-to-compute variant of depth image and then in phase 2 distill it into the final policy that uses depth using supervised learning. The resulting policy transfers to the real world and is able to run in real-time on the limited compute of the robot. It can traverse a large variety of terrain while being robust to perturbations like pushes, slippery surfaces, and rocky terrain. Videos are at https://vision-locomotion.github.io.
9
+
10
+ # 1 Introduction
11
+
12
+ Of what use is vision during locomotion? Clearly, there is a role of vision in navigation – using maps or landmarks to find a trajectory in the 2D plane to a distant goal while avoiding obstacles. But given a local direction in which to move, it turns out that both humans [1] and robots [2, 3] can do remarkably well at blind walking. Where vision becomes necessary is for locomotion in challenging terrains. In an urban environment, staircases are the most obvious example. In the outdoors, we can deal with rugged terrain such as scrambling over rocks, or stepping from stone to stone to cross a stream of water. There is a fair amount of scientific work studying this human capability and showing tight coupling of motor control with vision [4, 5, 6]. In this paper, we will develop this capability for a quadrupedal walking robot equipped with egocentric depth vision. We use a reinforcement learning approach trained in simulation, which we are directly able to transfer to the real world. Figure 1 and the accompanying videos shows some examples of our robot walking guided by vision.
13
+
14
+ Humans receive an egocentric stream of vision which is used to control feet placement, typically without conscious planning. As children we acquire it through trial and error [7] but for adults it is an automatized skill. Its unconscious execution should not take away from its remarkable sophistication. The footsteps being placed now are based on information collected some time ago. Typically, we don’t look at the ground underneath our feet, rather at the upcoming piece of ground in front of us a few steps away[1, 4, 5, 6]. A short term memory is being created which persists long enough to guide foot placement when we are actually over that piece of ground. Finally, note that we learn to walk through bouts of steps, not by executing pre-programmed gaits [7].
15
+
16
+ We take these observations about human walking as design principles for the visually-based walking controller for an A1 robot. The walking policy is trained by reinforcement learning with a recurrent neural network being used as a short term memory of recent egocentric views, proprioceptive states, and action history. Such a policy can maintain memory of recent visual information to retrieve characteristics of the terrain under the robot or below the rear feet, which might no longer be directly visible in the egocentric view.
17
+
18
+ In contrast, prior locomotion techniques rely on the metric elevation map of the terrain around and under the robot [8, 9, 10] to plan foot steps and joint angles. The elevation map is constructed by fusing information from multiple depth images (collected over time). This fusion of depth images into a single elevation map requires the relative pose between cameras at different times. Hence, tracking is required in the real world to obtain this relative pose using visual or inertial odometry. This is challenging because of noise introduced in sensing and odometry, and hence, previous methods add different kinds of structured noise at training time to account for the noise due to pose estimation drift [11, 12, 13]. The large amount of noise hinders the ability of such systems to perform reliably on gaps and stepping stones. We use vision as a first class citizen and show all the uneven terrain capabilities along with a high success rate on crossing gaps and stepping stones.
19
+
20
+ ![](images/eb45f0d0ab49231be2787af2e1d0b1cebef75e7873b97aa1ae5ff0c3e02bc99f.jpg)
21
+ Figure 2: A smaller robot (a) faces challenges in climbing stairs and curbs due to the stair obstructing its feet while going up and a tendency to topple over when coming down (b). Our robot deals with this by climbing using a large hip abduction that automatically emerges during training (c).
22
+
23
+ The design principle of not having pre-programmed gait priors turns out to be quite advantageous for our relatively small robot 1 (fig. 2). Predefined gait priors or reference motions fail to generalize to obstacles of even a reasonable height because of the relatively small size of the quadruped. The emergent behaviors for traversing complex terrains without any priors enable our robot with a hip joint height of ${ 2 8 } \mathrm { c m }$ to traverse the stairs of height upto $2 5 \mathrm { c m }$ , $89 \%$ relative to its height, which is significantly higher than any existing methods which typically rely on gait priors.
24
+
25
+ Since our robot is small and inexpensive, it has limited onboard compute and sensing. It uses a single front-facing D435 camera for exteroception. In contrast, AnymalC has four such cameras in addition to two dome lidars. Similarly, Spot has 5 depth cameras around its body. Our policy computes actions with a single feedforward pass and requires no tracking. This frees us from running optimization for MPC or localization which requires expensive hardware to run in real-time.
26
+
27
+ Overall, this use of learning “all the way” and the tight coupling of egocentric vision with motor control are the distinguishing aspects of our approach.
28
+
29
+ # 2 Method: Legged Locomotion from Egocentric Vision
30
+
31
+ Our goal is to learn a walking policy that maps proprioception and depth input to target joint angles at $5 0 \mathrm { H z }$ . Since depth rendering slows down the simulation by an order of magnitude, directly training this system using reinforcement learning (RL) would require billions of samples to converge making this intractable with current simulations. We therefore employ a two-phase training scheme. In phase 1, we use low resolution scandots located under the robot as a proxy for depth images. Scandots refer to a set of $( x , y )$ coordinates in the robot’s frame of reference at which the height of the terrain is queried and passed as observation at each time step (fig. 3). These capture terrain geometry and are cheap to compute. In phase 2, we use depth and proprioception as input to an RNN to implicitly track the terrain under the robot and directly predict the target joint angles at $5 0 \mathrm { H z }$ . This is supervised with actions from the phase 1 policy. Since supervised learning is orders of magnitude more sample efficient than RL, our proposed pipeline enables training the whole system on a single GPU in a few days. Once trained, our deployment policy does not construct metric elevation maps, which typically rely on metric localization, and instead directly predicts joint angles from depth and proprioception.
32
+
33
+ One potential failure mode of this two-phase training is that the scandots might contain more information than what depth can infer. To get around this, we choose scandots and camera field-ofview such that phase 2 loss is low. We formally show that this guarantees that the phase 2 policy will have close to optimal performance in $\mathrm { T h m }$ below.
34
+
35
+ Theorem 2.1. $\mathcal { M } = ( S , \mathcal { A } , P , R , \gamma )$ be an MDP with state space $s$ , action space $\mathcal { A }$ , transition function $P : \mathcal { S } \times \mathcal { A } \mathcal { S }$ , reward function $R : \mathcal { A } \times \mathcal { S } \mathbb { R }$ and discount factor $\gamma$ . Let $V ^ { 1 } ( s )$ be the value function of the phase $I$ policy that is trained to be close to optimal value function $V ^ { \ast } ( s )$ , i.e., $\vert V ^ { * } ( s ) - V ^ { 1 } ( s ) \vert < \epsilon \forall s \in \mathcal { S }$ , and $\pi ^ { 1 } ( s )$ be the greedy phase 1 policy obtained from $V ^ { 1 } ( s )$ . Suppose the phase 2 policy operates in a different state space $S ^ { \prime }$ given by a mapping $f : S S ^ { \prime }$ . If the phase 2 policy is close to phase 1 $\big | \pi ^ { 1 } \tilde { ( s ) } - \pi ^ { 2 } ( f ( s ) ) \big | < \eta \tilde { \forall } s$ and $R , P$ are Lipschitz continuous, then the return of phase 2 policy is close to optimal everywhere, i.e., 8s $\begin{array} { r } { , \ \left| V ^ { \ast } ( s ) - V ^ { \pi ^ { 2 } } ( f ( s ) ) \right| < \frac { 2 \epsilon \gamma + \eta c } { 1 - \gamma } } \end{array}$ where $\begin{array} { r } { c \propto \sum _ { s \in \mathcal { S } } V ^ { * } ( s ) } \end{array}$ is a large but bounded constant. (proof in sec. A)
36
+
37
+ We instantiate our training scheme using two different architectures. The monolithic architecture is an RNN that maps from raw proprioception and vision data directly to joint angles. The RMA architecture follows [3, 14], and contains an MLP base policy that takes $\gamma _ { t }$ (which encodes the local terrain geometry) along with the extrinsics vector $\mathbf { z } _ { t }$ (which encodes environment parameters [3]), and proprioception $\mathbf { x } _ { t }$ to predict the target joint angles. An estimate of $\gamma _ { t }$ is generated by an RNN that takes proprioception and vision as inputs. While the monolithic architecture is conceptually simpler, it implicitly tracks $\gamma _ { t }$ and $\mathbf { z } _ { t }$ in its weights and is hard to disentagle. In contrast, the RMA architecture allows direct access to each input $( \gamma _ { t }$ or $\mathbf { z } _ { t }$ ) through latent vectors. This allows the possibility of swapping sensors (like replacing depth by RGB) or using one stream to supervise the other while keeping the base motor policy fixed.
38
+
39
+ # 2.1 Phase 1: Reinforcement Learning from Scandots
40
+
41
+ Given the scandots $\left( v _ { x } ^ { \mathrm { c m d } } , \omega _ { z } ^ { \mathrm { c m d } } \right)$ we learn a policy using PPO without gait priors and with reward functions that minimizewalk on a variety of terrains. Proprioception consists of joint angles, joint velocities, $\mathbf { m } _ { t }$ , proprioception $\mathbf { x } _ { t }$ , commanded linear and angular velocity ${ \bf u } _ { t } ^ { \mathrm { c m d } } = { }$ angular velocity, roll and pitch measured by onboard sensors in addition to the last policy actions $\mathbf { a } _ { t - 1 }$ . Let ${ \bf o } _ { t } = ( { \bf m } _ { t } , { \bf x } _ { t } , { \bf u } _ { t } ^ { \mathrm { c m d } } )$ denote the observations. The RMA policy also takes privileged information $\mathbf { e } _ { t }$ as input which includes center-of-mass of robot, ground friction, and motor strength.
42
+
43
+ ![](images/1a45435ecc014cfc13c3db2b07f9349a728c8f07a585ee4571b8d29fd9fd222c.jpg)
44
+ Figure 3: We train our locomotion policy in two phases to avoid rendering depth for too many samples. In phase 1, we use RL to train a policy $\mathbf { \hat { \Pi } } _ { \pi } \mathbf { 1 }$ that has access to scandots that are cheap to compute. In phase 2, we use $\pi ^ { 1 }$ to provide ground truth actions which another policy $\pi ^ { 2 }$ is trained to imitate. This student has access to depth map from the front camera. We consider two architectures (1) a monolithic one which is a GRU trained to output joint angles with raw observations as input (2) a decoupled architecture trained using RMA [3] that is trained to estimate vision and proprioception latents that condition a base feedforward walking policy.
45
+
46
+ Monolithic The scandots $\mathbf { m } _ { t }$ are first compressed to $\gamma _ { t }$ and then passed with the rest of the observations to a GRU that predicts the joint angles.
47
+
48
+ $$
49
+ \begin{array} { r l } & { { \gamma } _ { t } = \mathrm { M L P } \left( \mathbf { m } _ { t } \right) } \\ & { { \bf { a } } _ { t } = { \mathrm { G R U } } _ { t } \left( { { \bf { x } } _ { t } } , { { \gamma } _ { t } } , { { \bf { u } } _ { t } ^ { \mathrm { { c m d } } } } \right) } \end{array}
50
+ $$
51
+
52
+ the subscript $t$ on the GRU indicates that it is stateful.
53
+
54
+ RMA Instead of using a monolithic memory based architecture for the controller, we use an MLP as the controller, pushing the burden of maintaining memory and state on the various inputs to the MLP. Concretely, we process the environment parameters $\left( \mathbf { e } _ { t } \right)$ with an MLP and the scandots $\mathbf { \Pi } ( \mathbf { m } _ { t } )$ with a GRU to get $\mathbf { z } _ { t }$ and $\gamma _ { t }$ respectively which are given as input to the base feedforward policy.
55
+
56
+ $$
57
+ \begin{array} { r l } & { \gamma _ { t } = \mathrm { G R U } _ { t } \left( \mathbf { m } _ { t } \right) } \\ & { \mathbf { z } _ { t } = \mathrm { M L P } \left( \mathbf { e } _ { t } \right) } \\ & { \mathbf { a } _ { t } = \mathrm { M L P } \left( \mathbf { x } _ { t } , \gamma _ { t } , \mathbf { z } _ { t } , \mathbf { u } _ { t } ^ { \mathrm { c m d } } \right) } \end{array}
58
+ $$
59
+
60
+ Both the phase 1 architectures are trained using PPO [15] with backpropagation through time [16] truncated at 24 timesteps.
61
+
62
+ Rewards We extend the reward functions proposed in [3, 17] to simply penalizing the energy consumption along with additional penalties to prevent damage to hardware on complex terrain (sec. B). Importantly, we do not impose any gait priors or predefined foot trajectories and let optimal gaits that are stable and natural to emerge for the task.
63
+
64
+ • Absolute work penalty $- | { \boldsymbol { \tau } } \cdot \mathbf { q } |$ where $\tau$ are the joint torques. We use the absolute value so that the policy does not learn to get positive reward by exploiting inaccuracies in contact simulation. • Command tracking $v _ { x } ^ { \mathrm { c m d } } - \left| v _ { x } ^ { \mathrm { c m d } } - v _ { x } \right| - \left| \omega _ { z } ^ { \mathrm { c m d } } - \omega _ { z } \right|$ where $v _ { x }$ is velocity of robot in forward direction and $\omega _ { z }$ is yaw angular velocity $( x , z$ are coordinate axes fixed to the robot). • Foot jerk penalty $\begin{array} { r } { \sum _ { i \in \mathcal { F } } \| \mathbf { f } _ { t } ^ { i } - \mathbf { f } _ { t - 1 } ^ { i } \| } \end{array}$ where $\mathbf { f } _ { t } ^ { i }$ is the force at time $t$ on the $i ^ { \mathrm { { t h } } }$ rigid body and $\mathcal { F }$ is 2Fthe set of feet indices. This prevents large motor backlash.
65
+
66
+ • Feet drag penalty $\begin{array} { r } { \sum _ { i \in \mathcal { F } } \mathbb { I } \left[ f _ { z } ^ { i } \geq 1 \mathbf { N } \right] \cdot \left( \left| v _ { x } ^ { i } \right| + \left| v _ { y } ^ { i } \right| \right) } \end{array}$ where $\mathbb { I }$ is the indicator function, and $v _ { x } ^ { i } , v _ { y } ^ { i }$ is velocity of $i ^ { \mathrm { { t h } } }$ rigid body. This penalizes velocity of feet in the horizontal plane if in contact with the ground preventing feet dragging on the ground which can damage them.
67
+ • Collision penalty $\textstyle \sum _ { i \in { \mathcal { C } } \cup { \mathcal { T } } } \mathbb { I } \left[ \mathbf { f } ^ { i } \geq { \overrightarrow { 0 . 1 \mathbf { N } } } \right]$ where ${ \mathcal { C } } , { \mathcal { T } }$ are the set of calf and thigh indices. This 2C[T penalizes contacts at the thighs and calves of the robot which would otherwise graze against edges of stairs and discrete obstacles.
68
+ • Survival bonus constant value 1 at each time step to prioritize survival over following commands in challenging situations.
69
+
70
+ Training environment Similar to [18] we generate different sets of terrain (fig. 5) of varying difficulty level. Following [3], we generate fractal variations over each of the terrains to get robust walking behaviour. At training time, the environments are arranged in a $6 \times 1 0$ matrix with each row having terrain of the same type and difficulty increasing from left to right. We train with a curriculum over terrain [18] where robots are first initialized on easy terrain and promoted to harder terrain if they traverse more than half its length. They are demoted to easier terrain if they fail to travel at least half the commanded distance $v _ { x } ^ { \mathrm { c m d } } \bar { T }$ where $T$ is maximum episode length. We randomize parameters of the simulation (tab. 3) and add small i.i.d. gaussian noise to observations for robustness (tab. 2).
71
+
72
+ # 2.2 Phase 2: Supervised Learning
73
+
74
+ In phase 2, we use supervised learning to distil the phase 1 policy into an architecture that only has access to sensing available onboard: proprioception $\left( \mathbf { x } _ { t } \right)$ and depth $\mathbf { d } _ { t }$ .
75
+
76
+ Monolithic We create a copy of the recurrent base policy 2. We preprocess the depth map through a convnet before passing it to the base policy.
77
+
78
+ $$
79
+ \begin{array} { r l } & { \tilde { \mathbf { d } } _ { t } = \mathrm { C o n v N e t } \left( \mathbf { d } _ { t } \right) } \\ & { \hat { \mathbf { a } } _ { t } = \mathrm { G R U } _ { t } ( \mathbf { x } _ { t } , \tilde { \mathbf { d } } _ { t } , \mathbf { a } _ { t } ^ { \mathrm { c m d } } ) } \end{array}
80
+ $$
81
+
82
+ We train with DAgger [19] with truncated backpropagation through time (BPTT) to minimize mean squared error between predicted and ground truth actions $\| \hat { \mathbf { a } } _ { t } - \mathbf { a } _ { t } \| ^ { 2 }$ . In particular, we unroll the student inside the simulator for $N = 2 4$ timesteps and then label each of the states encountered with the ground truth action $\mathbf { a } _ { t }$ from phase 1.
83
+
84
+ RMA Instead of retraining the whole controller, we only train estimators of $\gamma _ { t }$ and $\mathbf { z } _ { t }$ , and use the same base policy trained in phase 1 (eqn. 5). The latent $\hat { \gamma }$ , which encodes terrain geometry, is estimated from history of depth and proprioception using a GRU. Since the camera looks in front of the robot, proprioception combined with depth enables the GRU to implicitly track and estimate the terrain under the robot. Similar to [3], history of proprioception is used to estimate extrinsics $\hat { \mathbf { z } }$ .
85
+
86
+ $$
87
+ \begin{array} { r l } & { \tilde { \mathbf { d } } _ { t } = \mathrm { C o n v N e t } \left( \mathbf { d } _ { t } \right) } \\ & { \boldsymbol { \hat { \gamma } } _ { t } = \mathrm { G R U } _ { t } \left( \mathbf { x } _ { t } , \mathbf { u } _ { t } ^ { \mathrm { c m d } } , \boldsymbol { \tilde { \mathbf { d } } } _ { t } \right) } \\ & { \boldsymbol { \hat { \mathbf { z } } } _ { t } = \mathrm { G R U } _ { t } \left( \mathbf { x } _ { t } , \mathbf { u } _ { t } ^ { \mathrm { c m d } } \right) } \\ & { \mathbf { a } _ { t } = \mathrm { M L P } \left( \mathbf { x } _ { t } , \mathbf { u } _ { t } ^ { \mathrm { c m d } } , \boldsymbol { \hat { \gamma } } _ { t } , \boldsymbol { \hat { \mathbf { z } } } _ { t } \right) } \end{array}
88
+ $$
89
+
90
+ As before, this is trained using DAgger with BPTT. The vision GRU 9 and convnet 8 are jointly trained to minimize $\| \hat { \gamma } _ { t } - \gamma _ { t } \| ^ { \frac { } { 2 } }$ while the proprioception GRU 10 minimizes $\| \hat { \mathbf { z } } _ { t } - \mathbf { z } _ { t } \| ^ { 2 }$ .
91
+
92
+ Deployment The student can be deployed as-is on the hardware using only the available onboard compute. It is able to handle camera failures and the asynchronous nature of depth due to the randomizations we apply during phase 1. It is robust to pushes, slippery surfaces and large rocky surfaces and can climb stairs, curbs, and cross gaps and stepping stones.
93
+
94
+ # 3 Experimental Setup
95
+
96
+ We use the Unitree A1 robot pictured in Fig. 2. The robot has 12 actuated joints. The robot has a frontfacing Intel RealSense depth camera in its head. The onboard compute consists of the UPboard and a Jetson NX. The policy operates at $5 0 \mathrm { H z }$ and sends joint position commands which are converted to
97
+
98
+ <table><tr><td rowspan="2">Terrain</td><td colspan="4">Average x-Displacement (↑)</td><td colspan="4">Mean Time to Fall (s)</td></tr><tr><td>RMA</td><td>MLith</td><td>Noisy</td><td>Blind</td><td>RMA</td><td>MLith</td><td>Noisy</td><td>Blind</td></tr><tr><td>Slopes</td><td>43.98</td><td>44.09</td><td>36.14</td><td>34.72</td><td>88.99</td><td>85.68</td><td>70.25</td><td>67.07</td></tr><tr><td>Stepping Stones</td><td>18.83</td><td>20.72</td><td>1.09</td><td>1.02</td><td>34.3</td><td>41.32</td><td>2.51</td><td>2.49</td></tr><tr><td>Stairs</td><td>31.24</td><td>42.4</td><td>6.74</td><td>16.64</td><td>69.99</td><td>90.48</td><td>15.77</td><td>39.17</td></tr><tr><td>Discrete Obstacles</td><td>40.13</td><td>28.64</td><td>29.08</td><td>32.41</td><td>85.17</td><td>57.53</td><td>59.3</td><td>66.33</td></tr><tr><td>Total</td><td>134.18</td><td>135.85</td><td>73.05</td><td>84.79</td><td>278.45</td><td>275.01</td><td>147.83</td><td>175.06</td></tr></table>
99
+
100
+ Table 1: We measure the average displacement along the forward axis and mean time to fall for all methods on different terrains in simulation. For each method, we train a single policy for all terrains and use that for evaluation. We see that the monolithic (MLith) and RMA architectures of our method outperform the noisy and blind baselines by $6 0 { - } 9 0 \%$ in terms of total mean time to fall and average displacement. Vision is not strictly necessary for traversing slopes and the baselines make significant progress on this terrain, however, MLith and RMA travel upto $2 5 \%$ farther. The difference is more stark on stepping stones where blind and noisy baselines barely make any progress due to not being able to locate positions of the stones, while MLith and RMA travel for around $2 0 \mathrm { m }$ . Noisy and blind make some progress on stairs and discrete obstacles, but our methods travel upto 6.3 times farther.
101
+
102
+ torques by a low-level PD controller running at $4 0 0 \mathrm { H z }$ . Depth map is obtained from a Intel RealSense camera inside the head of the robot. The camera captures images every $1 0 0 \mathrm { { m s } \pm 2 0 \mathrm { { m s } } }$ at a resolution of $4 8 0 \times 8 4 8$ . We preprocess the image by cropping 200 white pixels from the left, applying nearest neighbor hole-filling and downsampling to $5 8 \times 8 7$ . This is passed through a backbone to obtain the compressed $\tilde { \mathbf { d } } _ { t }$ 8, 6 which is sent over a UDP socket to the base policy. This has a latency of $1 0 \pm 1 0 \mathrm { m s }$ which we account for during phase 2.
103
+
104
+ We use the IsaacGym (IG) simulator with the legged gym library [18] to train our walking policies. We construct a large terrain map with 100 sub-terrains arranged in a $2 0 \times 1 0$ grid. Each row has the same type of terrain arranged in increasing difficulty while different rows have different terrain.
105
+
106
+ Baselines We compare against two baselines, each of which uses the same number of learning samples for both RL phase and supervised learning phase.
107
+
108
+ • Blind policy trained with the scandots observations $\mathbf { m } _ { t }$ masked with zeros. This baseline must rely on proprioception to traverse terrain and helps quantify the benefit of vision for walking.
109
+
110
+ • Noisy Methods which rely on elevation maps need to fuse multiple depth images captured over time to obtain a complete picture of terrain under and around the robot. This requires camera pose relative to the first depth input, which is typically estimated using vision or inertial odometry [11, 13, 12]. However, these pose estimates are typically noisy resulting in noisy elevation maps [8]. To handle this, downstream controllers trained on this typically add a large noise in the elevation maps during training. Similar to [8], we train a teacher with ground truth, noiseless elevation maps in phase 1 and distill it to a student with large noise, with noise model from [8], added to the elevation map. We simulate a latency of $4 0 \mathrm { m s }$ in both the phases of training to match the hardware. This baseline helps in understanding the effect on performance when relying on pose estimates which introduce additional noise in the pipeline.
111
+
112
+ # 4 Results and Analysis
113
+
114
+ Simulation Results We report mean time to fall and mean distance travelled before crashing for different terrain and baselines in Table 1. For each method, we train a single policy for all terrains and use that for evaluation. Although the blind policy makes non trivial progress on stairs, discrete obstacles and slopes, it is significantly less efficient at traversing these terrains. On slopes our methods travel upto $27 \%$ farther implying that the blind baseline crashes early. Similarly, on stairs and discrete obstacles the distance travelled by our methods is much greater (upto $90 \%$ ). On slopes and stepping stones the noisy and blind baselines get similar average distances and mean time to fall and both are worse than our policy. This trend is even more significant on the stepping stones terrain where all baselines barely make any progress while our methods travel upto $2 0 \mathrm { m }$ . The blind policy has no way of estimating the position of the stone and crashes as soon as it steps into the gap. For the noisy policy, the large amount of added noise makes it impossible for the student to reliably ascertain the location of the stones since it cannot rely on proprioception any more. We note that the blind baseline is better than the noisy one on stairs. This is because the blind baseline has learnt to use proprioception to figure out location of stairs. On the other hand, the noisy policy cannot learn to use proprioception since it is trained via supervised learning. However, the blind baseline bumps into stairs often is not very practical to run on the real robot. The noisy baseline works well in [8] possibly because of predefined foot motions which make the phase 2 learning easier. However, as noted in sec. 1, predefined motions will not work for our small robot.
115
+
116
+ ![](images/4f5f6d38469f1be85d8a7f1393cad9d731d8e11f13ec620c942aa957eb9d3273.jpg)
117
+ Figure 4: We show success rates and time-to-failure (TTF) for our method and the blind baseline on curbs, stairs, stepping stones and gaps. We use a separate policy for stairs which is distilled to front camera, and use a separate policy trained on stepping stones distilled to the top camera which we use for gaps and stepping stones. We observe that our method solves all the tasks perfectly except for the stepping stone task in which the robot achieves $94 \%$ success. The blind baseline fails completely on gaps and stepping stones. For upstairs, it makes some progress, but fails to complete the entire staircase even once, which is expected given the small size of the robot. The blind policy completes the downstairs task $100 \%$ success, although it learns a very high impact falling gait to solve the task. In our experiments, the robot dislocates its real right leg during the blind downstairs trials.
118
+
119
+ Real World Comparisons We compare the performance of our methods to the blind baseline in the real world. In particular we have 4 testing setups as shows in fig. 4: Upstairs, Downstairs, Gaps and Stepping stones. While we train a single phase 1 policy for all terrain, for running baselines, we obtain different phase 2 policies for stairs vs. stepping stones and gaps. Different phase 2 policies are obtained by changing the location of the camera. We use the in-built camera inside the robot for stairs and a mounted external camera for stepping stones and gaps. The in-built camera is less prone to damage but the stepping stones are gaps are not clearly visible since it is horizontal. This is done for convenience, but we also have a policy that traverses all terrain using the same mounted camera.
120
+
121
+ We see that the blind baseline is incapable of walking upstairs beyond a few steps and fails to complete the staircase even once. Although existing methods have shown stairs for blind robots, we note that our robot is relatively smaller making it a more challenging task for a blind robot. On downstairs, we observe that the blind baseline achieves $100 \%$ success, although it learns to fall on every step and stabilize leading to a very high impact gait which led to the detaching of the rear right hip of the robot during our experiments. We additionally show results in stepping stones and gaps, where the blind robot fails completely establishing the hardness of these setups and the necessity of vision to solve them. We show a $100 \%$ success on all tasks except for stepping stone on which we achieve $94 \%$ success, which is very high given the challenging setup.
122
+
123
+ Urban Environments We experiment on stairs, ramps and curbs (fig. 1). The robot was successfully able to go upstairs as well as downstairs for stairs of height upto $2 4 \mathrm { c m }$ in height and $2 8 \mathrm { c m }$ as the lowest width. Since the robot has to remember terrain under its body from visual history, it sometimes misses a step, but shows impressive recovery behaviour and continues climbing or descending. The robot is able to climb curbs and obstacles as high as 26cm which is almost as high as the robot 2. This requires an emergent hip abduction movement because the small size of the robot doesn’t leave any space between the body and stair for the leg to step up. This behavior emerges because of our tabula rasa approach to learning gaits without reliance on priors or datasets of natural motion.
124
+
125
+ Gaps and Stepping Stones We construct an obstacle course consisting of gaps and stepping stones out of tables and stools (fig. 4). For this set of experiments we use a policy trained on stepping stones on gaps, and distilled onto the top camera instead of the front camera. The robot achieves a $100 \%$ success rate on gaps of upto 26cm from egocentric depth and $94 \%$ on difficult stepping stones. The stepping stones experiment shows that our visual policy can learn safe foothold placement behavior even without an explicit elevation map or foothold optimization objectives. The blind baseline achieves zero success rate on both tasks and falls as soon as any gap is encountered.
126
+
127
+ Natural Environments We also deploy our policy on outdoor hikes and rocky terrains next to river beds (fig. 1). We see that the robot is able to successfully traverse rugged stairs covered with dirt, small pebbles and some large rocks. It also avoids stumbling over large tree roots on the hiking trail. On the beach, we see that the robot is able to successfully navigate the terrain despite several slips and unstable footholds given the nature of the terrain. We see that the robot sometimes gets stuck in the crevices and in some cases shows impressive recovery behavior as well.
128
+
129
+ # 5 Related Work
130
+
131
+ Legged locomotion Legged locomotion an important problem which has been studied for decades. Several classical works use model based techniques, or define heuristic reactive controllers to achieve the task of walking [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32].This method has led to several promising results in the real world, although they still lack the generality needed to deploy them in the real world. This has motivated work in using RL for learning to walk in simulation [15, 33, 34, 35], and then successfully deploy them in a diverse set of real world scenarios [36, 37, 38, 39, 40, 41, 36, 42]. Alternatively, a policy learned in simulation can be adapted at test-time to work well in real environments [43, 44, 45, 46, 47, 48, 49, 50, 3, 51, 52, 53]. However, most of these methods are blind, and only use proprioceptive signal to walk.
132
+
133
+ Locomotion from Elevation Maps To achieve visual control of walking, classical methods decouple the perception and control aspects, assuming a perfect output from perception, such as an elevation map, and then using it for planning and control [54, 55, 56, 57, 58]. The control part can be further decoupled into searching for feasible footholds on the elevation map and then execute it with a low-level policy Chestnutt [59]. The foothold feasibility scores can either be estimated heuristically [60, 61, 10, 62, 63, 9, 64] or learned [65, 66, 67, 68, 69]. Other methods forgo explicit foothold optimization and learn traversibility maps instead [70, 71, 72, 73]. Recent methods skip foothold planning and directly train a deep RL policy that takes the elevation map as input and outputs either low-level motor primitives [8, 74] or raw joint angles [18, 75, 76, 77]. Elevation maps can be noisy or incorrect and dealing with imperfect maps is a major challenge to building robust locomotion systems. Solutions to this include incorporating uncertainty in the elevation map [54, 78, 11] and simulating errors at training time to make the walking policy robust to them [8].
134
+
135
+ Locomotion from Egocentric Depth Closest to ours is the line of work that doesn’t construct explicit elevation maps and predicts actions directly from depth. [53] learn a policy for obstacle avoidance from depth on flat terrain,[79] train a hierarchical policy which uses depth to traverse curved cliffs and mazes in simulation,[80] use lidar scans to show zero-shot generalization to difficult terrains. Yu et al. [81] train a policy to step over gaps by predicting high-level actions using depth from the head and below the torso. Relatedly, Margolis et al. [82] train a high-level policy to jump over gaps from egocentric depth using a whole body impulse controller. In contrast, we directly predict target joint angles from egocentric depth without constructing metric elevation maps.
136
+
137
+ # 6 Discussion and Limitations
138
+
139
+ In this work, we show an end-to-end approach to walking with egocentric depth that can traverse a large variety of terrains including stairs, gaps and stepping stones. However, there can be certain instances where the robot fails because of a visual or terrain mismatch between the simulation and the real world. The only solution to this problem under the current paradigm is to engineer the situation back into simulation and retrain. This poses a fundamental limitation to this approach and in future, we would like to leverage the data collected in the real world to continue improving both the visual and the motor performance. Currently, our robot is only able to move through the environment but not interact with it meaningfully. A future direction could be to combine vision-based policies with an articulated arm [83].
140
+
141
+ # Acknowledgments
142
+
143
+ We would like to thank Kenny Shaw and Xuxin Cheng for help with hardware. Shivam Duggal, Kenny Shaw, Xuxin Cheng, Shikhar Bahl, Zipeng Fu, Ellis Brown helped with recording videos. We also thank Alex Li for proofreading. The project was supported in part by the DARPA Machine Commonsense Program and ONR N00014-22-1-2096.
144
+
145
+ # References
146
+
147
+ [1] J. M. Loomis, J. A. Da Silva, N. Fujita, and S. S. Fukusima. Visual space perception and visually directed action. Journal of experimental psychology: Human Perception and Performance, 18 (4):906, 1992.
148
+ [2] J. Lee, J. Hwangbo, L. Wellhausen, V. Koltun, and M. Hutter. Learning quadrupedal locomotion over challenging terrain. Science robotics, 2020.
149
+ [3] A. Kumar, Z. Fu, D. Pathak, and J. Malik. RMA: Rapid Motor Adaptation for Legged Robots. In RSS, 2021.
150
+ [4] J. S. Matthis and B. R. Fajen. Visual control of foot placement when walking over complex terrain. Journal of experimental psychology: human perception and performance, 40(1):106, 2014.
151
+ [5] A. E. Patla. Understanding the roles of vision in the control of human locomotion. Gait & posture, 5(1):54–69, 1997.
152
+ [6] A. A. Mohagheghi, R. Moraes, and A. E. Patla. The effects of distant and on-line visual information on the control of approach phase and step over an obstacle during locomotion. Experimental brain research, 155(4):459–468, 2004.
153
+ [7] K. E. Adolph, W. G. Cole, M. Komati, J. S. Garciaguirre, D. Badaly, J. M. Lingeman, G. L. Chan, and R. B. Sotsky. How do you learn to walk? thousands of steps and dozens of falls per day. Psychological science, 2012.
154
+ [8] T. Miki, J. Lee, J. Hwangbo, L. Wellhausen, V. Koltun, and M. Hutter. Learning robust perceptive locomotion for quadrupedal robots in the wild. Science Robotics, 7(62):eabk2822, 2022.
155
+ [9] D. Kim, D. Carballo, J. Di Carlo, B. Katz, G. Bledt, B. Lim, and S. Kim. Vision aided dynamic exploration of unstructured terrain with a small-scale quadruped robot. In ICRA, 2020.
156
+ [10] F. Jenelten, T. Miki, A. E. Vijayan, M. Bjelonic, and M. Hutter. Perceptive locomotion in rough terrain–online foothold optimization. RA-L, 2020.
157
+ [11] P. Fankhauser, M. Bloesch, C. Gehring, M. Hutter, and R. Siegwart. Robot-centric elevation mapping with uncertainty estimates. In Mobile Service Robotics, pages 433–440. World Scientific, 2014.
158
+ [12] T. Miki, L. Wellhausen, R. Grandia, F. Jenelten, T. Homberger, and M. Hutter. Elevation mapping for locomotion and navigation using gpu. arXiv preprint arXiv:2204.12876, 2022.
159
+ [13] Y. Pan, X. Xu, X. Ding, S. Huang, Y. Wang, and R. Xiong. Gem: Online globally consistent dense elevation mapping for unstructured terrain. IEEE Transactions on Instrumentation and Measurement, 70:1–13, 2021. doi:10.1109/TIM.2020.3044338.
160
+ [14] H. Qi, A. Kumar, R. Calandra, Y. Ma, and J. Malik. In-hand object rotation via rapid motor adaptation. arXiv preprint arXiv:2210.04887, 2022.
161
+ [15] J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms. arXiv:1707.06347, 2017.
162
+ [16] P. J. Werbos. Backpropagation through time: what it does and how to do it. Proceedings of the IEEE, 78(10):1550–1560, 1990.
163
+ [17] Z. Fu, A. Kumar, A. Agarwal, H. Qi, J. Malik, and D. Pathak. Coupling vision and proprioception for navigation of legged robots. arXiv preprint arXiv:2112.02094, 2021.
164
+ [18] N. Rudin, D. Hoeller, P. Reist, and M. Hutter. Learning to walk in minutes using massively parallel deep reinforcement learning. In Conference on Robot Learning, pages 91–100. PMLR, 2022.
165
+ [19] S. Ross, G. Gordon, and D. Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, 2011.
166
+ [20] H. Miura and I. Shimoyama. Dynamic walk of a biped. IJRR, 1984.
167
+ [21] M. H. Raibert. Hopping in legged systems—modeling and simulation for the two-dimensional one-legged case. IEEE Transactions on Systems, Man, and Cybernetics, 1984.
168
+ [22] H. Geyer, A. Seyfarth, and R. Blickhan. Positive force feedback in bouncing gaits? Proceedings of the Royal Society of London. Series B: Biological Sciences, 2003.
169
+ [23] K. Yin, K. Loken, and M. Van de Panne. Simbicon: Simple biped locomotion control. ACM Transactions on Graphics, 2007.
170
+ [24] K. Sreenath, H.-W. Park, I. Poulakakis, and J. W. Grizzle. A compliant hybrid zero dynamics controller for stable, efficient and fast bipedal walking on mabel. IJRR, 2011.
171
+ [25] A. M. Johnson, T. Libby, E. Chang-Siu, M. Tomizuka, R. J. Full, and D. E. Koditschek. Tail assisted dynamic self righting. In Adaptive Mobile Robotics. World Scientific, 2012.
172
+ [26] M. Khoramshahi, H. J. Bidgoly, S. Shafiee, A. Asaei, A. J. Ijspeert, and M. N. Ahmadabadi. Piecewise linear spine for speed–energy efficiency trade-off in quadruped robots. Robotics and Autonomous Systems, 2013.
173
+ [27] A. D. Ames, K. Galloway, K. Sreenath, and J. W. Grizzle. Rapidly exponentially stabilizing control lyapunov functions and hybrid zero dynamics. IEEE Transactions on Automatic Control, 2014.
174
+ [28] D. J. Hyun, J. Lee, S. Park, and S. Kim. Implementation of trot-to-gallop transition and subsequent gallop on the mit cheetah i. IJRR, 2016.
175
+ [29] M. Barragan, N. Flowers, and A. M. Johnson. MiniRHex: A small, open-source, fully programmable walking hexapod. In RSS Workshop, 2018.
176
+ [30] G. Bledt, M. J. Powell, B. Katz, J. Di Carlo, P. M. Wensing, and S. Kim. Mit cheetah 3: Design and control of a robust, dynamic quadruped robot. In IROS, 2018.
177
+ [31] M. Hutter, C. Gehring, D. Jud, A. Lauber, C. D. Bellicoso, V. Tsounis, J. Hwangbo, K. Bodie, P. Fankhauser, M. Bloesch, et al. Anymal-a highly mobile and dynamic quadrupedal robot. In IROS, 2016.
178
+ [32] C. S. Imai, M. Zhang, Y. Zhang, M. Kierebinski, R. Yang, Y. Qin, and X. Wang. Vision-guided quadrupedal locomotion in the wild with multi-modal delay randomization. arXiv:2109.14549, 2021.
179
+ [33] T. P. Lillicrap, J. J. Hunt, A. Pritzel, N. Heess, T. Erez, Y. Tassa, D. Silver, and D. Wierstra. Continuous control with deep reinforcement learning. In ICLR, 2016.
180
+ [34] V. Mnih, A. P. Badia, M. Mirza, A. Graves, T. Lillicrap, T. Harley, D. Silver, and K. Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In ICML, 2016.
181
+ [35] S. Fujimoto, H. Hoof, and D. Meger. Addressing function approximation error in actor-critic methods. In ICML, 2018.
182
+ [36] J. Tan, T. Zhang, E. Coumans, A. Iscen, Y. Bai, D. Hafner, S. Bohez, and V. Vanhoucke. Sim-to-real: Learning agile locomotion for quadruped robots. In RSS, 2018.
183
+ [37] J. Tobin, R. Fong, A. Ray, J. Schneider, W. Zaremba, and P. Abbeel. Domain randomization for transferring deep neural networks from simulation to the real world. In IROS, 2017.
184
+ [38] X. B. Peng, M. Andrychowicz, W. Zaremba, and P. Abbeel. Sim-to-real transfer of robotic control with dynamics randomization. In ICRA, 2018.
185
+ [39] Z. Xie, X. Da, M. van de Panne, B. Babich, and A. Garg. Dynamics randomization revisited: A case study for quadrupedal locomotion. In ICRA, 2021.
186
+ [40] O. Nachum, M. Ahn, H. Ponte, S. S. Gu, and V. Kumar. Multi-agent manipulation via locomotion using hierarchical sim2real. In CoRL, 2020.
187
+ [41] J. Hwangbo, J. Lee, A. Dosovitskiy, D. Bellicoso, V. Tsounis, V. Koltun, and M. Hutter. Learning agile and dynamic motor skills for legged robots. Science Robotics, 2019.
188
+ [42] J. Hanna and P. Stone. Grounded action transformation for robot learning in simulation. In AAAI, 2017.
189
+ [43] W. Yu, J. Tan, C. K. Liu, and G. Turk. Preparing for the unknown: Learning a universal policy with online system identification. In RSS, 2017.
190
+ [44] W. Yu, C. K. Liu, and G. Turk. Policy transfer with strategy optimization. In ICLR, 2018.
191
+ [45] X. B. Peng, E. Coumans, T. Zhang, T.-W. E. Lee, J. Tan, and S. Levine. Learning agile robotic locomotion skills by imitating animals. In RSS, 2020.
192
+ [46] W. Zhou, L. Pinto, and A. Gupta. Environment probing interaction policies. In ICLR, 2019.
193
+ [47] W. Yu, V. C. V. Kumar, G. Turk, and C. K. Liu. Sim-to-real transfer for biped locomotion. In IROS, 2019.
194
+ [48] W. Yu, J. Tan, Y. Bai, E. Coumans, and S. Ha. Learning fast adaptation with meta strategy optimization. RA-L, 2020.
195
+ [49] X. Song, Y. Yang, K. Choromanski, K. Caluwaerts, W. Gao, C. Finn, and J. Tan. Rapidly adaptable legged robots via evolutionary meta-learning. In IROS, 2020.
196
+ [50] I. Clavera, A. Nagabandi, S. Liu, R. S. Fearing, P. Abbeel, S. Levine, and C. Finn. Learning to adapt in dynamic, real-world environments through meta-reinforcement learning. In ICLR, 2019.
197
+ [51] Z. Fu, A. Kumar, J. Malik, and D. Pathak. Minimizing energy consumption leads to the emergence of gaits in legged robots. In CoRL, 2021.
198
+ [52] L. Smith, J. C. Kew, X. B. Peng, S. Ha, J. Tan, and S. Levine. Legged robots that keep on learning: Fine-tuning locomotion policies in the real world. In ICRA, 2022.
199
+ [53] R. Yang, M. Zhang, N. Hansen, H. Xu, and X. Wang. Learning vision-guided quadrupedal locomotion end-to-end with cross-modal transformers. In ICLR, 2022.
200
+ [54] P. Fankhauser, M. Bloesch, and M. Hutter. Probabilistic terrain mapping for mobile robots with uncertain localization. IEEE Robotics and Automation Letters, 3(4):3019–3026, 2018.
201
+ [55] Y. Pan, X. Xu, Y. Wang, X. Ding, and R. Xiong. Gpu accelerated real-time traversability mapping. In 2019 IEEE International Conference on Robotics and Biomimetics (ROBIO), pages 734–740, 2019. doi:10.1109/ROBIO49542.2019.8961816.
202
+ [56] I.-S. Kweon, M. Hebert, E. Krotkov, and T. Kanade. Terrain mapping for a roving planetary explorer. In IEEE International Conference on Robotics and Automation, pages 997–1002. IEEE, 1989.
203
+ [57] I.-S. Kweon and T. Kanade. High-resolution terrain map from multiple sensor data. IEEE Transactions on Pattern Analysis and Machine Intelligence, 14(2):278–292, 1992.
204
+ [58] A. Kleiner and C. Dornhege. Real-time localization and elevation mapping within urban search and rescue scenarios. Journal of Field Robotics, 24(8-9):723–745, 2007.
205
+ [59] J. Chestnutt. Navigation planning for legged robots. Carnegie Mellon University, 2007.
206
+ [60] M. Wermelinger, P. Fankhauser, R. Diethelm, P. Krusi, R. Siegwart, and M. Hutter. Navigation ¨ planning for legged robots in challenging terrain. In IROS, 2016.
207
+ [61] A. Chilian and H. Hirschmuller. Stereo camera based navigation of mobile robots on rough ¨ terrain. In IROS, 2009.
208
+ [62] C. Mastalli, I. Havoutis, A. W. Winkler, D. G. Caldwell, and C. Semini. On-line and on-board planning and perception for quadrupedal locomotion. In 2015 IEEE International Conference on Technologies for Practical Robot Applications, 2015.
209
+ [63] P. Fankhauser, M. Bjelonic, C. D. Bellicoso, T. Miki, and M. Hutter. Robust rough-terrain locomotion with a quadrupedal robot. In ICRA, 2018.
210
+ [64] A. Agrawal, S. Chen, A. Rai, and K. Sreenath. Vision-aided dynamic quadrupedal locomotion on discrete terrain using motion libraries. arXiv preprint arXiv:2110.00891, 2021.
211
+ [65] J. Z. Kolter, M. P. Rodgers, and A. Y. Ng. A control architecture for quadruped locomotion over rough terrain. In ICRA, 2008.
212
+ [66] M. Kalakrishnan, J. Buchli, P. Pastor, and S. Schaal. Learning locomotion over rough terrain using terrain templates. In IROS, 2009.
213
+ [67] L. Wellhausen and M. Hutter. Rough terrain navigation for legged robots using reachability planning and template learning. In IROS, 2021.
214
+ [68] C. Mastalli, M. Focchi, I. Havoutis, A. Radulescu, S. Calinon, J. Buchli, D. G. Caldwell, and C. Semini. Trajectory and foothold optimization using low-dimensional models for rough terrain locomotion. In ICRA, 2017.
215
+ [69] O. A. V. Magana, V. Barasuol, M. Camurri, L. Franceschi, M. Focchi, M. Pontil, D. G. Caldwell, and C. Semini. Fast and continuous foothold adaptation for dynamic locomotion through cnns. RA-L, 2019.
216
+ [70] B. Yang, L. Wellhausen, T. Miki, M. Liu, and M. Hutter. Real-time optimal navigation planning using learned motion costs. In ICRA, 2021.
217
+ [71] R. O. Chavez-Garcia, J. Guzzi, L. M. Gambardella, and A. Giusti. Learning ground traversability from simulations. RA-L, 2018.
218
+ [72] J. Guzzi, R. O. Chavez-Garcia, M. Nava, L. M. Gambardella, and A. Giusti. Path planning with local motion estimations. RA-L, 2020.
219
+ [73] S. Gangapurwala, M. Geisert, R. Orsolino, M. Fallon, and I. Havoutis. Real-time trajectory adaptation for quadrupedal locomotion using deep reinforcement learning. In International Conference on Robotics and Automation (ICRA), 2021.
220
+ [74] V. Tsounis, M. Alge, J. Lee, F. Farshidian, and M. Hutter. Deepgait: Planning and control of quadrupedal gaits using deep reinforcement learning. IEEE Robotics and Automation Letters, 5 (2):3699–3706, 2020.
221
+ [75] X. B. Peng, G. Berseth, and M. Van de Panne. Terrain-adaptive locomotion skills using deep reinforcement learning. ACM Transactions on Graphics (TOG), 35(4):1–12, 2016.
222
+ [76] X. B. Peng, G. Berseth, K. Yin, and M. Van De Panne. Deeploco: Dynamic locomotion skills using hierarchical deep reinforcement learning. ACM Transactions on Graphics (TOG), 36(4): 1–13, 2017.
223
+ [77] Z. Xie, H. Y. Ling, N. H. Kim, and M. van de Panne. Allsteps: Curriculum-driven learning of stepping stone skills. In Computer Graphics Forum. Wiley Online Library, 2020.
224
+ [78] D. Belter, P. Łabcki, and P. Skrzypczynski. Estimating terrain elevation maps from sparse ´ and uncertain multi-sensor data. In 2012 IEEE International Conference on Robotics and Biomimetics (ROBIO), pages 715–722, 2012. doi:10.1109/ROBIO.2012.6491052.
225
+ [79] D. Jain, A. Iscen, and K. Caluwaerts. From pixels to legs: Hierarchical learning of quadruped locomotion. arXiv preprint arXiv:2011.11722, 2020.
226
+ [80] A. Escontrela, G. Yu, P. Xu, A. Iscen, and J. Tan. Zero-shot terrain generalization for visual locomotion policies. arXiv preprint arXiv:2011.05513, 2020.
227
+ [81] W. Yu, D. Jain, A. Escontrela, A. Iscen, P. Xu, E. Coumans, S. Ha, J. Tan, and T. Zhang. Visual-locomotion: Learning to walk on complex terrains with vision. In 5th Annual Conference on Robot Learning, 2021.
228
+ [82] G. B. Margolis, T. Chen, K. Paigwar, X. Fu, D. Kim, S. Kim, and P. Agrawal. Learning to jump from pixels. arXiv preprint arXiv:2110.15344, 2021.
229
+ [83] Z. Fu, X. Cheng, and D. Pathak. Learning a unified policy for whole-body control of manipulation and locomotion. In Conference on Robot Learning (CoRL), 2022.
230
+ [84] S. P. Singh and R. C. Yee. An upper bound on the loss from approximate optimal-value functions. Machine Learning, 16(3):227–233, 1994.
231
+ [85] D. P. Bertsekas. Dynamic programming: deterministic and stochastic models. Prentice-Hall, Inc., 1987.
md/dev/UHBrWeFWlL/UHBrWeFWlL.md ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Segment Everything Everywhere All at Once
2
+
3
+ Xueyan $\mathbf { Z o u } ^ { * \ S 2 }$ , Jianwei $\mathbf { Y a n g ^ { * \dagger 1 } }$ , Hao Zhang∗♯, Feng $\mathbf { L i } ^ { * \sharp }$ , Linjie $\mathbf { L i } ^ { \dagger }$ , Jianfeng Wang† Lijuan Wang†, Jianfeng Gao¶‡, Yong Jae Lee¶§
4
+
5
+ University of Wisconsin-Madison ‡ Microsoft Research, Redmond ♯ HKUST † Microsoft Cloud & AI ∗Equal Contribution ¶ Equal Advisory Contribution 1. Project Lead 2. Main Technical Contribution
6
+
7
+ {xueyan,yongjaelee}@cs.wisc.edu {jianwyan,jfgao,linjli}@microsoft.com {hzhangcx,fliay}@connect.ust.hk
8
+
9
+ ![](images/37c314db5d7886d8a95d14a85af5997d5460b939bedab52741728d32f05d5cee.jpg)
10
+ Figure 1: SEEM supports generic segmentation tasks—including semantic, instance, and panoptic segmentation—in an open-set fashion when no prompt is provided. SEEM also enables the use of visual, textual, and referring region prompts in flexbile combinations, making it a promptable and interactive segmentation interface.
11
+
12
+ # Abstract
13
+
14
+ In this work, we present SEEM, a promptable and interactive model for segmenting everything everywhere all at once in an image, as shown in Fig. 1. In SEEM, we propose a novel decoding mechanism that enables diverse prompting for all types of segmentation tasks, aiming at a universal segmentation interface that behaves like large language models (LLMs). More specifically, SEEM is designed with four desiderata: i) Versatility. We introduce a new visual prompt to unify different spatial queries including points, boxes, scribbles and masks, which can further generalize to a different referring image; ii) Compositionality. We learn a joint visual-semantic space between text and visual prompts, which facilitates the dynamic composition of two prompt types required for various segmentation tasks; iii) Interactivity. We further incorporate learnable memory prompts into the decoder to retain segmentation history through mask-guided cross-attention from decoder to image features; and $_ { i v }$ ) Semantic-awareness. We use a text encoder to encode text queries and mask labels into the same semantic space for openvocabulary segmentation. We conduct a comprehensive empirical study to validate the effectiveness of SEEM across diverse segmentation tasks. Notably, our single SEEM model achieves competitive performance across interactive segmentation, generic segmentation, referring segmentation, and video object segmentation on 9 datasets with minimum 1/100 supervision. Furthermore, SEEM showcases a remarkable capacity for generalization to novel prompts or their combinations, rendering it a readily universal image segmentation interface.
15
+
16
+ # 1 Introduction
17
+
18
+ Image segmentation is arguably the most important yet challenging problem in computer vision. In the past, we have witnessed significant progress in a wide range of segmentation tasks including instance, semantic and panoptic segmentation [1, 2, 3, 4, 5, 6, 7]. Most recently, we are observing a clear trend toward more flexible segmentation models in different aspects: 1) From closed-set to open-vocabulary segmentation. Many recent works proposed to either leverage contrastive learning methods or pretrained multi-modal foundation models (e.g., CLIP [8]) to make the segmentation models more transferable to unseen concepts [9, 10, 11, 12]; 2) From generic to referring segmentation. In addition to generic segmentation that segments an image thoroughly given a predetermined set of concepts, language-based referring segmentation provides a user-friendly way of segmenting a specific region referred by an arbitrary text phrase [13, 14, 15, 16, 17]; and 3) From one-shot to interactive segmentation. In practice, segmentation models do not necessarily produce satisfactory masks in one round. As such, people are also studying how to progressively refine the segmentation results through intimate interactions between humans and models [18, 19, 20, 21].
19
+
20
+ Despite the aforementioned efforts taken to design more powerful and feasible segmentation models, we are still lacking a universal segmentation interface that is capable of accommodating various types of human prompts and tackling different segmentation tasks as studied in individual works. In contrast, Large Language Models (LLMs) have already emerged as such a universal interaction interface for language tasks, from early models like GPT-3 [22] and T5 [23], to conversational agent [24] augmented by advanced prompting [25, 26, 27] and chain-of-thought [28, 29, 30]. In this work, we strive for a universal interface for segmenting everything everywhere all at once in an image. On this interface, we are targeted at unifying all segmentation tasks with a single model in a promptable manner. To achieve this goal, we propose a new prompting scheme in mask decoder that has four important properties: versatility, compositionality, interactivity, and semantic-awareness. Specifically, we propose to encode points, masks, text, boxes, and even a referred region from another image into prompts in the same joint visual-semantic space. As such, our model can deal with any combination of the input prompts, leading to strong compositionality. To enable interactivity, we further introduce memory prompts for condensing the previous segmentation information followed by communication with other prompts. As for semantic awareness, our model can provide an open-set semantic label to any output segmentation.
21
+
22
+ With the proposed prompting scheme, we build a segment-everything-everywhere model called SEEM comprised of a simple Transformer encoder-decoder architecture [31, 6] with an extra text encoder [11, 32]. In SEEM, the decoding process emulates a generative LLM but with a multimodalityin-multimodality-out interface. An image encoder and text encoder are used as the prompt encoder to encode all types of queries, which are fed into the decoder. Concretely, we encode all spatial queries, namely, points, boxes, scribbles and masks into visual prompts by pooling their corresponding visual features from the image encoder, and use the text encoder to convert text queries into text prompts. By training on diverse segmentation tasks, our model learns to deal with various prompts, align the visual and text prompts, and promote their synergy via cross-attention between them. As a result, our single model after pretraining attains competitive performance across all segmentation tasks. Since the prompts of all 5 different types are mapped to the joint visual-semantic space, we can feasibly combine prompts to resolve the ambiguity to obtain better segmentation results and enable zero-shot adaptation to unseen user prompts. Furthermore, our model can immediately generalize to the case of using an exemplar image segment as the prompt and video object segmentation in a zero-shot fashion. In addition to its strong generalization capability, SEEM is also more efficient for interactive segmentation compared with the counterparts like SimpleClick [32]. Since we take the prompts as input to the decoder, when doing multi-round interactions with humans, our model only needs to run the feature extractor once at the beginning and lightweight decoding each per round. To the end, we build a segmentation interface with a single pre-trained model that can segment every object with semantics (everything), cover every pixel in the image (everywhere), and support all possible compositions of prompts (all at once). In summary, our contributions are threefold:
23
+
24
+ • We design a new prompting scheme that can encode various user intents into prompts in a joint visual-semantic space, enabling strong flexibility for various segmentation tasks and generalization capability to unseen prompts or their combinations. • We build SEEM, a universal and interactive segmentation interface that integrates the newly designed prompting mechanism into a lightweight decoder for all segmentation tasks, leading to a model possessing properties of versatility, compositionality, interactivity, and semantic awareness. • We conduct extensive experiments and visualizations to show that our model has strong performance on many segmentation tasks including open-vocabulary generic segmentation, interactive segmentation, referring segmentation, and segmentation tasks with combined prompts.
25
+
26
+ ![](images/425035d17fa2f542cc26c913c5d8c201a1ec6ca137ebea414c13578956b05d7c.jpg)
27
+ Figure 2: Overview of SEEM- Decoder. (a) SEEM encodes image, text, and human inputs into joint visual-semantic space as queries, features, and prompts, and then decodes queries to class and mask embeddings. (b) With the benefit of SEEM decoder, the machine loop enables memorizing history mask information, and the human loop provides new corrections to the next round.
28
+
29
+ # 2 Related Work
30
+
31
+ Interactive segmentation. Interactive segmentation is the task of segmenting objects by interactively taking user inputs. It has been a longstanding problem and has achieved considerable progress [33, 34, 35, 20, 21, 36]. Generally, the interaction types can take various forms, such as clicks, boxes, polygons, and scribbles, among which click-based interaction models are the most prevalent. Concurrent to our work, SAM [36] proposed a promptable segmentation model trained on 11 million images and 1.1 billion masks. It takes user interactions as prompts for general segmentation. Though SAM demonstrates strong zero-shot performance, it produces segmentations without semantic meaning. In addition, its prompt types are limited to points, boxes, and text, whereas our model can also take in a referred region from another image as a prompt.
32
+
33
+ Generic segmentation. Segmentation of visual concepts has been a persistent challenge in the field of computer vision, as evidenced by its extensive literature [37, 38, 39, 40]. Generic segmentation techniques encompass several subtasks, including instance segmentation, semantic segmentation, and panoptic segmentation [4, 2, 3], each focusing on a different semantic level. For example, semantic segmentation aims to identify and label each pixel within an image based on its corresponding semantic class [41, 6, 42]. On the other hand, instance segmentation involves grouping pixels that belong to the same semantic class into separate object instances [4, 43, 7]. Recently, the Detection Transformer (DETR)[31], a model based on the Transformer [44] architecture, has made significant advances in segmentation [45, 6, 7, 46, 47] tasks. However, these approaches cannot recognize objects absent in the training set, which constrains the model to a limited vocabulary size.
34
+
35
+ Unified vision models. Unified vision models [11, 48, 49, 36, 50] have recently drawn a lot of attention because of their advantage in generalizing to various tasks and flexibility. These models can deal with multiple vision tasks or data distributions. Among them, some [11, 48, 49] train multiple tasks together with only one model and thus can deal with all training tasks without finetuning on each target task. On the other hand, SAM [36] and SegGPT [50] propose training strategies that enable their models to handle new tasks and data distributions in a zero-shot manner. The second approach is more favorable since there is no need to resolve conflicts among tasks during training.
36
+
37
+ # 3 Method
38
+
39
+ # 3.1 Model Design
40
+
41
+ SEEM employs a generic encoder-decoder architecture but also employs a sophisticated interaction scheme between queries and prompts, as shown in Fig. 2 (a). Given an input image $\mathbf { I } \in \mathcal { R } ^ { H \times W \times 3 }$ an image encoder is first used to extract image features $\mathbf { Z }$ . Then, SEEM-Decoder predicts the masks M and semantic concepts $\mathbf { C }$ based on the query outputs $\mathbf { O } _ { h } ^ { m }$ (mask embeddings) and $\mathbf { O } _ { h } ^ { c }$ (class embeddings), which interact with text, visual, and memory prompts $\left. \mathbf { P } _ { t } , \right. \qquad \left. \begin{array} { c c } { \right. } & { } \end{array}$
42
+
43
+ $$
44
+ \begin{array} { r } { \langle \mathbf { O } _ { h } ^ { m } , \mathbf { O } _ { h } ^ { c } \rangle = \mathbf { D e c o d e r } ( \mathbf { Q } _ { h } ; \langle \mathbf { P } _ { t } , \mathbf { P } _ { v } , \mathbf { P } _ { m } \rangle | \mathbf { Z } ) } \\ { \mathbf { M } = \mathbf { M a s k P r e d i c t o r } ( \mathbf { O } _ { h } ^ { m } ) \qquad } \\ { \mathbf { C } = \mathbf { C o n c e p t C l a s s i f i e r } ( \mathbf { O } _ { h } ^ { c } ) } \end{array}
45
+ $$
46
+
47
+ ![](images/c2276d3a22272920423e0e2893d8368575add30c7fe0b11b8f79da350b09b2fe.jpg)
48
+ Figure 3: Queries and prompt interaction during training and evaluation. (a) Learnable queries are duplicated as object, grounding, and visual queries with the same set of weights for each task. (b) Attention mask between any two kinds of tokens (denoted as qpm in Algorithm. 1). Tentative means the interaction is not trained but able to do inference without any modification.
49
+
50
+ where $\mathbf Q _ { h }$ is the learnable queries, and $\mathbf { P } _ { t }$ , ${ \bf P } _ { v }$ , $\mathbf { P } _ { m }$ represent the text prompts, visual prompts, and memory prompts, respectively. During training, $\mathbf Q _ { h }$ is duplicated for generic, referring, and interactive segmentation, as shown in Fig. 3. The corresponding prompts interact with their queries through self-attention. The learnable queries can freely interact with all prompts at inference time, thereby enabling zero-shot composition. Our design is inspired by the successful practice in XDecoder [11]. However, we highlight the differences in Eq. (1), marked in red, which allow for a universal model for image segmentation with the following properties:
51
+
52
+ Versatile. In SEEM, we introduce visual prompts $\mathbf { P } _ { v }$ to handle all non-textual inputs, such as points, boxes, scribbles, and a referred region from another image. These non-textual queries are beneficial to disambiguate the user’s intent when textual prompts alone fail to identify the correct segment. For interactive segmentation, previous works either convert spatial queries to masks and feed them into the image backbone [20] or use different prompt encoders for each input type (points, boxes) [36]. The first approach can be too heavy in applications because each interaction requires the image to go through the feature extractor. The second approach is hard to generalize to unseen prompts. To address these limitations, we propose a visual sampler (Fig. 2 (a)) to convert all kinds of non-textual queries to visual prompts that lie in the same visual embedding space:
53
+
54
+ $$
55
+ \mathbf P _ { v } = \mathbf { V i s u a l S a m p l e r ( s , \hat { Z } ) }
56
+ $$
57
+
58
+ where $\hat { \mathbf { Z } }$ is the feature maps extracted from either the target image (i.e., $\hat { \mathbf { Z } } = \mathbf { Z } )$ or a referred image, and $s \in \{$ points, box, scribbles, polygons $\}$ are the sampling locations specified by the user. We first pool the corresponding region from the image feature through point sampling [6]. For all visual prompts, we interpolate at most 512 point feature vectors uniformly from the region specified by the prompt. A notable merit of our proposed method is that the visual prompts are naturally well-aligned with the textual prompts, as our model continuously learns a common visual-semantic space through panoptic and referring segmentation.
59
+
60
+ Compositional. In practice, a user may cast their intent using different or combined prompt types. Hence, a compositional approach to prompting is essential for real-world applications. However, we confront two issues during model training. First, the training data usually only covers a single type of interaction (e.g., none, textual, visual). Second, although we use visual prompts to unify all non-textual prompts and align them with textual prompts, their embedding spaces remain inherently different. To mitigate this problem, we propose to match prompts of different types with different outputs. Considering that visual prompts $\mathbf { P } _ { v }$ come from image features while textual prompts $\mathbf { P } _ { t }$ come from the text encoder, we select matched output indices for visual and textual prompts by matching them with the mask embeddings $\mathbf { O } _ { h } ^ { m }$ or class embeddings $\mathbf { O } _ { h } ^ { c }$ , respectively:
61
+
62
+ $$
63
+ \begin{array} { l } { I D _ { v } \gets \mathbf { M a t c h } ( \mathbf { O } _ { h } ^ { m } \cdot \mathbf { P } _ { v } + \mathbf { I o U } _ { m a s k } ) } \\ { I D _ { t } \gets \mathbf { M a t c h } ( \mathbf { O } _ { h } ^ { c } \cdot \mathbf { P } _ { t } + \mathbf { I o U } _ { m a s k } ) } \end{array}
64
+ $$
65
+
66
+ where $\mathbf { I o U } _ { m a s k }$ is the IoU between ground-truth and predicted masks. The proposed separate matching method outperforms approaches that only match with either $\mathbf { O } _ { h } ^ { m }$ or $\mathbf { O } _ { h } ^ { c }$ for all prompts.
67
+
68
+ After training, our model becomes familiar with all prompt types and supports a variety of compositions, such as no prompts, one prompt type, or both visual and textual prompts using the same model and weights. In particular, the visual and textual prompts can be simply concatenated and fed to SEEM-Decoder, even though it was never trained in this way.
69
+
70
+ Interactive. Interactive segmentation usually cannot be completed in one shot and requires multiple interaction rounds for refinement, similar to conversational agents like ChatGPT. In SEEM, we
71
+
72
+ # Algorithm 1: Pseudo code for SEEM.
73
+
74
+ # Inputs: Image(img)[B,3,H,W]; Pos_Mask $( \mathrm { p m } )$ ), Neg_Mask $( \mathsf { n m } )$ )[B,1,H,W]; Text(txt)[abc...]; # Variables: Learnable Queries $( Q _ { h } )$ ; Attention Masks between $Q$ and $P$ (qpm) # Functions: Img_Encoder(),Text_Encoder(),Visual_Sampler(),feature_attn(),prompt_attn(),output();
75
+
76
+ 1 def init( ):
77
+ 2 Qo,Qt, $Q _ { v } ~ = ~ Q _ { h }$ .copy(); # Initialize object, text and visual queries.
78
+ 3 $\begin{array} { r l } { F _ { v } , P _ { t } } & { { } = } \end{array}$ Img_Encoder(img), Text_Encoder(txt); # $F _ { v }$ and $P _ { t }$ denote image feature, text prompt.
79
+ 4 $\begin{array} { r l } { P _ { v } } & { { } = } \end{array}$ Visual_Sampler( $F _ { v }$ , pm, $\mathrm { n m } ^ { \prime }$ ); # Sample visual prompt from image feature, pos/neg mask.
80
+
81
+ 5 def SEEM_Decoder $: F _ { v } , Q _ { o } , Q _ { t } , Q _ { v } , P _ { v } , P _ { t } ,$ $P _ { m } 1$ ):
82
+
83
+ Qo, $Q _ { t }$ ,Qv $=$ feature_attn $F _ { v }$ , $Q _ { o }$ , $Q _ { t } , Q _ { v } )$ ; # Cross attend queries with image features.
84
+ Qo,Qt,Qv = prompt_attn(qpm, $Q _ { o }$ , $Q _ { t }$ ,Qv, $P _ { v }$ , $P _ { t }$ , $P _ { m }$ ); # Self attend queries and prompts.
85
+ Om,Oc,Pm = output $( F _ { v }$ ,Qo,Qt,Qv); # Compute mask and class outputs.
86
+
87
+ 9 def forward(img,pm,nm,txt):
88
+ 10 $F _ { v }$ , $Q _ { o }$ , $Q _ { t }$ , $Q _ { v }$ , $P _ { v }$ , $\begin{array} { r l } { P _ { t } } & { { } = } \end{array}$ init(); $\begin{array} { l l } { P _ { m } } & { = } \end{array}$ None; # Initialize variables.
89
+ 11 for i in range(max_iter):
90
+ 12 L $O _ { m } , O _ { c } , P _ { m } = \tt S E H \_$ Decoder $( F _ { v } , Q _ { o } , Q _ { t } , Q _ { v } , P _ { v } , P _ { t } , P _ { m } )$
91
+
92
+ propose a new type of prompt called memory prompts $\mathbf { P } _ { m }$ and use them to convey the knowledge of the masks from the previous iteration to the current one. Unlike previous works that use a network to encode the previous mask [20, 36], we introduce no extra module but simply a few memory prompts. These memory prompts encode the history information by using a mask-guided cross-attention layer [6]:
93
+
94
+ $$
95
+ \mathbf { P } _ { m } ^ { l } = \mathbf { M a s k e d C r o s s A t t } ( \mathbf { P } _ { m } ^ { l - 1 } ; \mathbf { M } _ { p } | \mathbf { Z } )
96
+ $$
97
+
98
+ where $\mathbf { M } _ { p }$ is the previous mask, and $\mathbf { Z }$ is the image feature map. In this way, cross-attention only takes effect inside the regions specified by the previous mask. The updated memory prompts $\mathbf { P } _ { m } ^ { l }$ then interact with the other prompts via self-attention to convey the historical information for the current round.
99
+
100
+ Semantic-aware. Different from previous class-agnostic interactive segmentation works such as Simple Click [20] and the concurrent work SAM [36], our model produces semantic labels to masks for all kinds of prompt combinations in a zero-shot manner, since our visual prompt features are aligned with textual features in a joint visual-semantic space. As shown in Fig. 3, semantic labels are directly computed using $\mathbf { O } _ { h } ^ { c }$ (output of visual queries) and the text embedding. Although we do not train with any semantic labels for interactive segmentation, the calculated logits are well-aligned, benefiting from the joint visual-semantic space.
101
+
102
+ # 3.2 Model Pipeline and Loss Functions
103
+
104
+ We summarize the training and evaluation pipeline of the proposed method with Pytorch-style pseudocode in Algorithm 1. SEEM is trained with a linear combination of losses for panoptic segmentation, referring segmentation, and interactive segmentation:
105
+
106
+ $$
107
+ \begin{array} { r } { \mathcal { L } = \alpha \mathcal { L } _ { \mathrm { c \_ C E } } \mathrm { _ { p a n o } } + \beta \mathcal { L } _ { \mathrm { m \_ B C E } , \mathrm { p a n o } } + \gamma \mathcal { L } _ { \mathrm { m \_ D I C E } , \mathrm { p a n o } } + a \mathcal { L } _ { \mathrm { c \_ C E } , \mathrm { r e f } } + b \mathcal { L } _ { \mathrm { m \_ B C E } , \mathrm { r e f } } } \\ { + c \mathcal { L } _ { \mathrm { m \_ D I C E } , \mathrm { r e f } } + a \mathcal { L } _ { \mathrm { c \_ C E } , \mathrm { i s e g } } + b \mathcal { L } _ { \mathrm { m \_ B C E } , \mathrm { i s e g } } + c \mathcal { L } _ { \mathrm { m \_ D I C E } , \mathrm { i s e g } } } \end{array}
108
+ $$
109
+
110
+ Where $\alpha = 2 , \beta = \gamma = 5 , a = 0 . 2 , b = c = 2 \ :$ , CE, BCE, and DICE denotes cross-entropy, binary cross entropy and dice loss, respectively.
111
+
112
+ # 4 Experiments
113
+
114
+ Datasets and Settings. SEEM is trained on three tasks: panoptic segmentation, referring segmentation, and interactive segmentation. Panoptic and interactive segmentation are trained on COCO2017 [51] with panoptic segmentation annotations. Following [11], we exclude the validation set of Ref-COCOg [52], resulting in 107K segmentation images in total. For referring segmentation, we use a combination of Ref-COCO, Ref-COCOg, and $_ \mathrm { R e f - C O C O + }$ for COCO image annotations. We evaluate generic segmentation (instance/panoptic/semantic), referring segmentation, and interactive segmentation.
115
+
116
+ Implementation Details and Evaluation Metrics. Our model framework follows X-Decoder [11] except the decoder. That is, we have a vision backbone, a language backbone, an encoder, and
117
+
118
+ Table 1: One model for segmentation on a wide range of segmentation tasks. SEEM is the first model to simultaneously support generic segmentation, referring segmentation, and interactive segmentation, as well as prompt compositionality. (#Concurrent work. - indicates the model does not have capability for the task, \* indicates do not have reported number.)
119
+
120
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Segmentation Data</td><td rowspan="2">Type</td><td colspan="2">Generic Segmentation COCO PQ</td><td colspan="2">Referring Segmentation</td><td colspan="2">RefCOCOg</td><td colspan="6">Interactive Segmentation PascalVOC</td></tr><tr><td></td><td>mAP</td><td>mIoU</td><td>cIoU</td><td>mIoU</td><td>AP50</td><td>5-NoC85</td><td></td><td></td><td>10-NoC85 20-NoC85 5-NoC90</td><td></td><td>10-NoC9020-NoC90</td></tr><tr><td>Mask2Former (T) [6]</td><td>COCO (0.12M)</td><td rowspan="6">57.8 Segmentation 55.4</td><td>53.2 56.4</td><td>43.3</td><td>63.2</td><td>=</td><td>=</td><td>·</td><td>·</td><td></td><td>=</td><td></td><td></td><td></td></tr><tr><td>Mask2Former (B) [6]</td><td>COCO (0.12M)</td><td></td><td>46.3</td><td>67.1 67.4</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Mask2Former (L)[6]</td><td>COCO (0.12M)</td><td></td><td>48.6</td><td></td><td>=</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Pano/SegFormer (B) [45]</td><td>COCO (0.12M)</td><td></td><td>*</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LAVT(B) [53]</td><td>Ref-COCO (0.03M)</td><td></td><td></td><td></td><td>61.2</td><td></td><td>*</td><td>=</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PolyFormer (B)[17]</td><td>Ref-COCO+VG+...(0.16M)</td><td></td><td></td><td></td><td>69.3</td><td></td><td>*</td><td>=</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PolyFormer(L)[17]</td><td>Ref-COCO+VG+... (0.16M)</td><td rowspan="7"></td><td></td><td></td><td></td><td>71.1</td><td></td><td>*</td><td>·</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RITM(&lt;T)[18]</td><td>COCO+LVIS(0.12M)</td><td></td><td></td><td>=</td><td></td><td></td><td></td><td></td><td>*</td><td>2.19</td><td>*</td><td>#</td><td>2.57</td></tr><tr><td>PseudoClick(&lt;T) [54]</td><td>COCO (0.12M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>*</td><td>*</td><td>1.94</td><td>*</td><td>*</td><td>2.25</td></tr><tr><td>FocalClick (T) [21]</td><td>COCO (0.12M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>*</td><td>*</td><td>2.97</td><td>*</td><td>*</td><td>3.52</td></tr><tr><td>FocalClick(B) [21]</td><td>COCO (0.12M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>*</td><td>*</td><td>2.46</td><td>*</td><td>*</td><td>2.88</td></tr><tr><td>SimpleClick (B) [20]</td><td>COCO+LVIS (0.12M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.75</td><td>1.93</td><td>2.06</td><td>1.94</td><td>2.19 1.84</td><td>2.38</td></tr><tr><td>SimpleClick (L) [20]</td><td>COCO+LVIS (0.12M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.52</td><td>1.64</td><td>1.72</td><td>1.67</td><td></td><td></td><td>1.96 1.98</td></tr><tr><td>SimpleClick (H) [20]</td><td>COCO+LVIS(0.12M) COCO (0.12M)</td><td></td><td>45.8</td><td></td><td>*</td><td></td><td></td><td></td><td>1.51</td><td>1.64</td><td>1.76</td><td>1.64</td><td>1.83</td><td>·</td></tr><tr><td>UViM(L)[55] Pix2Seq v2 (B) [56]</td><td>COCO (0.12M)</td><td></td><td></td><td>38.2</td><td></td><td>=</td><td></td><td></td><td>· ·</td><td>· ·</td><td>· =</td><td>· =</td><td>· ·</td><td>=</td></tr><tr><td>X-Decoder (T)[11]</td><td>COCO (0.12M)</td><td></td><td>52.6</td><td></td><td>62.4</td><td>59.8</td><td></td><td></td><td>·</td><td>=</td><td></td><td>=</td><td></td><td>=</td></tr><tr><td>X-Decoder(B) [11]</td><td>COCO (0.12M)</td><td></td><td>56.2</td><td></td><td>66.0</td><td>64.5</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>X-Decoder(L)[11]</td><td>COCO (0.12M)</td><td></td><td>45.8 56.9</td><td></td><td></td><td>64.6</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UNINEXT(T)[48]</td><td>Image+Video (3M)</td><td></td><td></td><td></td><td>67.5</td><td>70.0</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UNINEXT(L) [48]</td><td>Image+Video (3M)</td><td></td><td></td><td></td><td></td><td>73.4</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Painter (L) [57]</td><td>COCO+ADE+NYUv2(0.16M)</td><td>Generalist</td><td>43.4</td><td></td><td></td><td></td><td></td><td></td><td>=</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>#SegGPT(L)[50]</td><td>COCO+ADE+NYUv2 (0.16M)</td><td></td><td>34.4</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>#SAM(B)[36]</td><td>SAM (11M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>2.47</td><td>2.65</td><td>3.28</td><td>2.23</td><td>3.13</td><td>4.12</td></tr><tr><td>#SAM (L) [36]</td><td>SAM (11M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>=</td><td>1.85</td><td>2.15</td><td>2.60</td><td>2.01</td><td>2.46</td><td>3.12</td></tr><tr><td>#SAM (H) [36]</td><td>SAM (11M)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.82</td><td>2.13</td><td>2.55</td><td>1.98</td><td>2.43</td><td>3.11</td></tr><tr><td>SEEM (T)</td><td>COCO+LVIS(0.12M)</td><td></td><td>50.8</td><td>39.7</td><td>62.2</td><td>60.9</td><td>65.7</td><td>74.8</td><td>1.72</td><td>2.30</td><td>3.37</td><td>1.97</td><td>2.83</td><td>4.41</td></tr><tr><td>SEEM (B) SEEM (L)</td><td>COCO+LVIS (0.12M) COCO+LVIS (0.12M)</td><td></td><td>56.1 57.5</td><td>46.4 47.7</td><td>66.3 67.6</td><td>65.0 65.6</td><td>69.6 70.3</td><td>78.2 78.9</td><td>1.56 1.51</td><td>2.04 1.95</td><td>2.93 2.77</td><td>1.77 1.71</td><td>2.47 2.36</td><td>3.79 3.61</td></table>
121
+
122
+ Table 2: One model for all kinds of mask interactions. SEEM has strong generalization capability on different input mask types.
123
+
124
+ <table><tr><td rowspan="3">Method</td><td colspan="5">COCO</td><td colspan="5">Open Image Scribble</td><td colspan="5">ADE</td></tr><tr><td>Point</td><td>Stroke</td><td>Scribble</td><td>Polygon</td><td>Box</td><td>Point</td><td>Stroke</td><td></td><td>Polygon</td><td>BoX</td><td>Point</td><td>Stroke</td><td>Scribble</td><td>Polygon</td><td>BoX</td></tr><tr><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td><td>1-IoU</td></tr><tr><td>SimpleClick (B)</td><td>49.0</td><td>33.1</td><td>65.1</td><td>48.6</td><td>42.5</td><td>48.6</td><td>29.5</td><td>54.2</td><td>49.5</td><td>42.7</td><td>47.0</td><td>19.0</td><td>52.1</td><td>48.3</td><td>37.2</td></tr><tr><td>SimpleClick (L)</td><td>38.9</td><td>33.9</td><td>68.8</td><td>39.2</td><td>34.7</td><td>37.5</td><td>29.1</td><td>59.8</td><td>35.2</td><td>31.2</td><td>36.8</td><td>16.4</td><td>56.4</td><td>41.7</td><td>29.5</td></tr><tr><td>SimpleClick (H)</td><td>59.0</td><td>37.3</td><td>71.5</td><td>45.3</td><td>52.4</td><td>54.1</td><td>32.6</td><td>64.7</td><td>39.9</td><td>49.3</td><td>52.8</td><td>18.4</td><td>58.3</td><td>46.8</td><td>41.8</td></tr><tr><td>SAM(B)</td><td>58.6</td><td>22.8</td><td>34.2</td><td>44.5</td><td>50.7</td><td>62.3</td><td>28.4</td><td>39.2</td><td>45.8</td><td>53.6</td><td>51.0</td><td>21.9</td><td>31.1</td><td>31.0</td><td>58.8</td></tr><tr><td>SAM(L)</td><td>64.7</td><td>44.4</td><td>57.1</td><td>60.7</td><td>50.9</td><td>65.3</td><td>45.9</td><td>55.7</td><td>57.8</td><td>52.4</td><td>57.4</td><td>45.8</td><td>53.1</td><td>45.8</td><td>58.7</td></tr><tr><td>SAM (H)</td><td>65.0</td><td>27.7</td><td>30.6</td><td>37.8</td><td>50.4</td><td>67.7</td><td>26.5</td><td>29.9</td><td>41.9</td><td>52.1</td><td>58.4</td><td>20.4</td><td>22.2</td><td>28.3</td><td>58.5</td></tr><tr><td>SEEM(T)</td><td>78.9</td><td>81.0</td><td>81.2</td><td>72.2</td><td>73.7</td><td>67.1</td><td>69.4</td><td>69.5</td><td>63.1</td><td>60.9</td><td>65.4</td><td>67.3</td><td>67.3</td><td>59.0</td><td>53.4</td></tr><tr><td>SEEM(B)</td><td>81.7</td><td>82.8</td><td>83.5</td><td>76.0</td><td>75.7</td><td>67.6</td><td>69.0</td><td>68.7</td><td>64.2</td><td>60.3</td><td>66.4</td><td>68.6</td><td>67.7</td><td>60.5</td><td>53.6</td></tr><tr><td>SEEM (L)</td><td>83.4</td><td>84.6</td><td>84.1</td><td>76.5</td><td>76.9</td><td>66.8</td><td>67.8</td><td>67.6</td><td>62.4</td><td>60.1</td><td>65.5</td><td>66.6</td><td>66.3</td><td>58.1</td><td>54.1</td></tr></table>
125
+
126
+ SEEM-Decoder. For the vision backbone, we use FocalT [58], DaViT-d3 (B), and DaViT-d5 (L) [59]. For the language encoder, we adopt a UniCL or Florence text encoder [60, 61]. For all segmentation tasks, we use standard evaluation metrics: PQ (Panoptic Quality) for panoptic segmentation, AP (Average Precision) for instance segmentation, and mIoU (mean Intersection over Union) for semantic segmentation. For interactive segmentation, we follow previous works [20, 62] to simulate user clicks by comparing the predicted segmentation with the ground-truth one in an automatic way. After one click on the image to generate the predicted mask, the next click is placed at the center of the area with the largest segmentation error. We use the Number of Clicks (NoC) metric to evaluate interactive segmentation performance, which measures the number of clicks needed to achieve a certain Intersection over Union (IoU), i.e., $85 \%$ and $90 \%$ , denoted as $\mathbf { N o C @ 8 5 }$ and $\mathbf { N o C @ 9 0 }$ , respectively. We also vary the number of maximum clicks indicated by ${ \mathrm { K } } { \cdot } { \mathrm { N o C @ 9 0 } }$ $\mathrm { K } { = } 5$ , 10, 20), and evaluate the mean IoU on the single click denoted as 1-IoU to study the performance on different constraints. More qualitative evaluation with stroke, scribble, polygon, and box as prompts are illustrated in the supplementary material.
127
+
128
+ # 4.1 Main Results
129
+
130
+ Generic segmentation With one suite of parameters pre-trained on all the segmentation tasks, we are able to evaluate its performance on generic segmentation datasets. As shown in Table 1, SEEM maintains competitive panoptic, instance, and semantic segmentation performance against strong baselines. Compared with generalist models such as UViM [55], Pix2Seqv2 [56] and especially the recent model Painter [57] and SegGPT [50], our approach significantly outperforms those methods on generic segmentation with a margin around 10 points on panoptic segmentation metrics.
131
+
132
+ Referring segmentation As shown in Table 1, compared with other referring segmentation and generalist models, SEEM achieves competitive performance. Notably, by adding a visual compositional prompt, referring segmentation performance is improved with a large margin by 10.5 cIoU,
133
+
134
+ Table 3: Zero-shot video object segmentation. Without training with video or pairwise image data, our approach is able to do video object segmentation in a zero-shot manner. (#Concurrent work.)
135
+
136
+ <table><tr><td>Method</td><td>Segmentation Data</td><td>Type</td><td>Refer-Type</td><td>Zero- Shot</td><td>Single Image</td><td>JF</td><td>DAVIS17 J</td><td>F</td><td>DAVIS16-Interactive JF J</td><td>F</td><td>G</td><td>Js</td><td>Fs</td><td>YouTube-VOS 2018 Ju</td><td>Fu</td></tr><tr><td>With VideoData</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AGSS[63]</td><td>VOS+DAVIS (0.1M)</td><td></td><td>Mask</td><td>X</td><td>X</td><td>67.4</td><td>64.9</td><td>69.9</td><td></td><td></td><td>71.3</td><td>71.3</td><td>65.5</td><td>75.2</td><td>73.1</td></tr><tr><td>AGAME [64]</td><td>(Synth)VOS+DAVIS (0.11M)</td><td></td><td>Mask</td><td>X</td><td>×</td><td>70.0</td><td>67.2</td><td>72.7</td><td></td><td></td><td>66.0</td><td>66.9</td><td>*</td><td>61.2</td><td>*</td></tr><tr><td>SWEM[65]</td><td>Image+VOS+DAVIS(0.25M)</td><td>Video</td><td>Mask</td><td></td><td>X</td><td>84.3</td><td>81.2</td><td>87.4</td><td></td><td></td><td>82.8</td><td>82.4</td><td>86.9</td><td>77.1</td><td>85.0</td></tr><tr><td>XMem [66]</td><td>Image+VOS+DAVIS (0.25M)</td><td></td><td>Mask</td><td>X</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>86.1</td><td>85.1</td><td>89.8</td><td>80.3</td><td>89.2</td></tr><tr><td>SiamMask [67]</td><td>COCO+VOS (0.21M)</td><td></td><td>Box</td><td>X</td><td>X</td><td>*</td><td>54.3</td><td>58.5</td><td>69.8 71.7</td><td>67.8</td><td>*</td><td>60.2</td><td>58.2</td><td>45.1</td><td>47.7</td></tr><tr><td>MiVOS [19]</td><td>BL30K+VOS+DAVIS (4.88M)</td><td></td><td>Mask/Scribble</td><td>X</td><td>X</td><td>84.5</td><td>81.7</td><td>87.4</td><td>91.0 89.6</td><td>92.4</td><td>82.6</td><td>81.1</td><td>85.6</td><td>77.7</td><td>86.2</td></tr><tr><td>ReferFormer-B [68]</td><td>RefCOCO(+/g)+VOS+DAVIS (0.13M)</td><td></td><td>Text</td><td>X</td><td>X</td><td>61.1</td><td>58.1</td><td>64.1</td><td></td><td>-</td><td>*</td><td>*</td><td>*</td><td>雀</td><td>*</td></tr><tr><td>TAM-L [69]</td><td>XMem+SAM(11.2M)</td><td></td><td>Multiple Points</td><td>X</td><td>X</td><td></td><td></td><td>=</td><td>88.4 87.5</td><td>89.4</td><td>=</td><td></td><td></td><td></td><td>=</td></tr><tr><td>UNINEXT-T [48]</td><td>Image+Video (3M)</td><td>Generalist</td><td>Mask</td><td>X</td><td>X</td><td>74.5</td><td>71.3</td><td>77.6</td><td></td><td></td><td>77.0</td><td>76.8</td><td>81.0</td><td>70.8</td><td>79.4</td></tr><tr><td>UNINEXT-L [48]</td><td>Image+Video (3M)</td><td></td><td>Mask</td><td>X</td><td>X</td><td>77.2</td><td>73.2</td><td>81.2</td><td></td><td></td><td>78.1</td><td>79.1</td><td>83.5</td><td>71.0</td><td>78.9</td></tr><tr><td>UNINEXT-L[48]</td><td>Image+Video (3M)</td><td></td><td>Text</td><td>X</td><td>X</td><td>66.7</td><td>62.3</td><td>71.1</td><td></td><td>-</td><td>*</td><td>*</td><td>*</td><td>*</td><td>*</td></tr><tr><td>Without VideoData</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Painter-L [57]</td><td>COCO+ADE+NYUv2 (0.16M)</td><td></td><td>Mask </td><td>√</td><td>X</td><td>34.6</td><td>28.5 40.8</td><td></td><td></td><td>=</td><td>24.1</td><td>27.6</td><td>35.8</td><td>14.3</td><td>18.7</td></tr><tr><td>#SegGPT-L [50]</td><td>COCO+ADE+VOC+...(0.25M)</td><td></td><td>Mask</td><td>√</td><td>交义</td><td>75.6 72.5</td><td>78.6</td><td></td><td>=</td><td>=</td><td>74.7</td><td>75.1</td><td>80.2</td><td>67.4</td><td>75.9</td></tr><tr><td>#PerSAM-L[70]</td><td>SAM+DAVIS (11M)</td><td></td><td>Mask</td><td>X</td><td></td><td>60.3 56.6</td><td>63.9</td><td>-</td><td>-</td><td>-</td><td>*</td><td>*</td><td>*</td><td>*</td><td>*</td></tr><tr><td>SEEM-T</td><td></td><td>Generalist</td><td></td><td>√</td><td></td><td>60.4 57.6</td><td>63.3</td><td>62.7</td><td>58.9</td><td>66.4</td><td>51.4</td><td>55.6</td><td>44.1</td><td>59.2</td><td>46.9</td></tr><tr><td>SEEM-B SEEM-L</td><td>COCO+LVIS (0.12M)</td><td></td><td> Mask/Single Point</td><td>√</td><td>√ √ √</td><td>62.8 59.5 58.9 55.0</td><td>66.2 62.8</td><td>67.2 62.2</td><td>63.6 58.3</td><td>70.9 66.0</td><td>53.8 50.0</td><td>60.0 57.2</td><td>44.5 38.2</td><td>63.5 61.3</td><td>47.2 43.3</td></tr></table>
137
+
138
+ Table 4: Ablation study on interaction strategy. “#Iter” denotes the maximum training iteration on interactive segmentation in a single forward. “Negative” means adding negative tokens during interactive segmentation. “Scratch" means the model trains from scratch.
139
+
140
+ <table><tr><td rowspan="2">Ablation</td><td rowspan="2">Fix</td><td rowspan="2">#Iter</td><td rowspan="2">Pos</td><td rowspan="2">Neg</td><td colspan="3">COCO</td><td colspan="3">Referring Segmentation</td><td colspan="2">Pascal VOC</td><td colspan="3">DAVIS17</td></tr><tr><td>PQ</td><td>mAP</td><td>mIoU</td><td>cIoU</td><td>mIoU</td><td>AP@50</td><td>NoC50</td><td>NoC90</td><td>JF</td><td>J</td><td>F</td></tr><tr><td>Baseline</td><td>Y</td><td>0</td><td>√</td><td>X</td><td>50.7</td><td>39.5</td><td>60.8</td><td>57.9</td><td>63.3</td><td>71.6</td><td>1.74</td><td>5.43</td><td>59.6</td><td>55.8</td><td>63.5</td></tr><tr><td> - LVIS</td><td>√</td><td>2</td><td>√</td><td>√</td><td>51.0</td><td>39.8</td><td>62.2</td><td>58.6</td><td>63.9</td><td>72.6</td><td>1.57</td><td>4.91</td><td>59.5</td><td>55.9</td><td>63.1</td></tr><tr><td>+Negative</td><td>√</td><td>0</td><td>√</td><td></td><td>50.9</td><td>39.8</td><td>61.4</td><td>58.8</td><td>64.0</td><td>72.6</td><td>1.81</td><td>5.41</td><td>60.1</td><td>56.3</td><td>63.9</td></tr><tr><td>+Scratch</td><td>X</td><td>3</td><td>√</td><td>1</td><td>50.2</td><td>39.5</td><td>60.7</td><td>51.4</td><td>59.2</td><td>67.0</td><td>1.45</td><td>4.41</td><td>60.6</td><td>57.7</td><td>63.4</td></tr><tr><td rowspan="4">+ Iter</td><td>√</td><td>1</td><td>√</td><td>√</td><td>50.7</td><td>39.7</td><td>60.5</td><td>58.3</td><td>63.4</td><td>71.3</td><td>1.76</td><td>5.14</td><td>59.2</td><td>55.4</td><td>63.0</td></tr><tr><td></td><td>2</td><td></td><td></td><td>50.5</td><td>39.5</td><td>61.0</td><td>58.0</td><td>63.2</td><td>71.6</td><td>1.78</td><td>5.20</td><td>59.6</td><td>56.2</td><td>63.0</td></tr><tr><td>&lt;&lt;&lt;</td><td>3</td><td></td><td></td><td>50.4</td><td>39.5</td><td>61.0</td><td>58.0</td><td>63.0</td><td>71.5</td><td>1.55</td><td>4.67</td><td>59.9</td><td>56.4</td><td>63.5</td></tr><tr><td></td><td>5</td><td>&gt;&lt;&gt;</td><td>&lt;&lt;&gt;</td><td>50.6</td><td>39.4</td><td>60.9</td><td>58.4</td><td>63.4</td><td>71.6</td><td>1.54</td><td>4.59</td><td>59.7</td><td>56.3</td><td>63.1</td></tr></table>
141
+
142
+ $6 . 0 \mathrm { m I o U }$ , and 9.3 AP50 points for the tiny model. And this gap is retained for the base and large model. Specifically, this number is computed by class embeddings $\mathbf { O } _ { h } ^ { c }$ (Output-Q-Textual). The margin is even larger when computed with mask embeddings $\mathbf { O } _ { h } ^ { m }$ (Output-Q-Visual) as shown in Table 5. Further, we benchmark the vanilla composition (Ensemble) that directly combines visual and text mask output probabilities as shown in Table 5 row 2.
143
+
144
+ Interactive segmentation As shown in Table 1, our approach achieves comparable performance with the specialized models, e.g. RITM, SimpleClick, and better performance than SAM [36] (B) which is trained with $\times 1 0 0$ more segmentation data than ours. Notably, unlike existing interactive models, SEEM is the first interface that supports not only classical segmentation tasks but also a wide range of user input types, including text, points, scribbles, boxes, and images, providing strong compositional capabilities as shown in Table 2,5.
145
+
146
+ Table 5: The term ‘Text/Visual Prompt’ refers to the modality of information utilized in the study. ‘Output Query’ is indicative of the type of query employed to predict the output. ‘Composition Approach’ specifies the method through which text and visual information are integrated.
147
+
148
+ <table><tr><td>Text</td><td>Visual</td><td>Output</td><td>Composition</td><td></td><td colspan="2">Focal-Tiny</td><td colspan="3">Davit-Base</td><td colspan="3">Davit-Large</td></tr><tr><td>Prompt</td><td>Prompt</td><td>Query</td><td>Approach</td><td>cIoU</td><td>mIoU</td><td>AP@50</td><td>cIoU</td><td>mIoU</td><td>AP@50</td><td>cIoU</td><td>mIoU</td><td>AP@50</td></tr><tr><td>Y</td><td>N</td><td>Text</td><td>N/A</td><td>58.4</td><td>63.4</td><td>71.6</td><td>63.0</td><td>68.2</td><td>76.7</td><td>62.4</td><td>67.6</td><td>75.3</td></tr><tr><td>Y</td><td>Y</td><td>All</td><td>Ensemble</td><td>63.0</td><td>60.0</td><td>66.9</td><td>69.3</td><td>66.6</td><td>74.3</td><td>68.9</td><td>65.5</td><td>72.7</td></tr><tr><td>Y</td><td>Y</td><td>Text</td><td>Self-Attn</td><td>66.5</td><td>69.6</td><td>78.8</td><td>75.0</td><td>76.9</td><td>86.3</td><td>73.2</td><td>76.5</td><td>85.9</td></tr><tr><td>N</td><td>Y</td><td>Visual</td><td>N/A</td><td>70.7</td><td>71.8</td><td>81.3</td><td>75.4</td><td>77.8</td><td>87.4</td><td>75.2</td><td>78.2</td><td>87.7</td></tr><tr><td>Y</td><td>Y</td><td>Visual</td><td>Self-Attn</td><td>71.5</td><td>72.8</td><td>82.2</td><td>75.9</td><td>78.3</td><td>87.7</td><td>74.9</td><td>78.4</td><td>87.7</td></tr></table>
149
+
150
+ User input type of interactive segmentation In Table 2, we compare 1-IoU of SEEM with other strong baselines SimpleClick and SAM with 5 common types of prompts on three datasets. 1-IoU indicates the mean IoU of all images with a single click. The prompt types include point, stroke, scribble, and box. The results show that our SEEM achieves the best performance in the extremely limited number of clicks over all three datasets.
151
+
152
+ Video object segmentation Without any modification, our model is able to do (interactive) video object segmentation in a zero-shot manner through the visual prompt (by replacing the current image visuals prompt with the visual prompts from another image). As shown in Table 3, without any observation of DAVIS/VOS dataset [71, 72], our approach is able to achieve close performance in a zero-shot manner with a fully supervised method on DAVIS17 dataset [72]. Meanwhile, our model is able to do interactive video object segmentation on DAVIS16-Interactive [72] and achieves comparable performance with the supervised baselines with one single click of the first frame.
153
+
154
+ ![](images/bac2f003388c7ade98b711a7864231eabd901c17336052984508229082882236.jpg)
155
+ Figure 4: Click/scribble-based segmentation. SEEM supports arbitrary formats of clicks or scribbles by users. Moreover, it simultaneously gives the semantic label for the segmented mask, which is not possible in SAM [36].
156
+
157
+ ![](images/91c7064f26c7bd5534503e888b454033751bca1483680880b9803ddc9fece5a8.jpg)
158
+ Figure 5: Text to mask or text referring segmentation. The referred text is shown on the masks. SEEM adapts to various types of input images in the domain of cartoons, movies, and games.
159
+
160
+ # 4.2 Ablation Study
161
+
162
+ We conduct an ablation study on all the training segmentation tasks and zero-shot video object segmentation, dissecting each component of our model. The results are presented in Table 4.
163
+
164
+ LVIS mask annotation will improve interactive segmentation results. We replace the COCO mask with an overlap IoU larger than 0.7 with LVIS mask during training. This will improve the performance on interactive segmentation with 0.3 and 0.2 point gain on NoC0.9 and NoC0.85.
165
+
166
+ Training from scratch only hurts referring segmentation performance. We compare the SEEM model trained with X-Decoder pre-trained checkpoint or the checkpoint initialized with UniCL or Florence vision and language backbone ( $^ +$ Scratch). It indicates that training from scratch will slightly improve the performance on interactive segmentation but hurt the referring segmentation performance.
167
+
168
+ Increase interactive training iterations does help. As shown in Table 4, increasing the training iteration (the first N-1 iteration is without gradient) from 1 to 5 will gradually improve the interactive segmentation performance from 5.41 to 4.59 on NoC0.9. As the computation cost increases with more clicks, we use iteration 3 for the main paper results.
169
+
170
+ # 4.3 Qualitative Results
171
+
172
+ We further qualitatively evaluate SEEM. Based on the proposed prompting scheme and decoder design, with the same suite of parameters, SEEM supports a wide range of visual input types.
173
+
174
+ Visual prompt interactive segmentation. In Fig. 4, we show the visualization of using SEEM to segment objects in an interactive way. The user can segment objects of interest by simply clicking or drawing a scribble. Taking these prompts, SEEM can simultaneously produce both masks and semantic labels for the objects. Note that our model is open-vocabulary, which empowers it to label unseen categories when given the candidate vocabulary (i.e., cheetah and butterfly in Fig. 4). When no vocabulary is given, SEEM can segment in a class-agnostic manner.
175
+
176
+ Text referring segmentation. We show the text referring to segmentation visualization results in Fig. 5. The results demonstrate that our model is semantic-aware of open-vocabulary concepts and attributes to understand language. In addition, SEEM is able to generalize to unseen scenarios like cartoons, movies, and games.
177
+
178
+ ![](images/fcbad199e27f6e364a832530b6af7e81ca247af79fd5cff1fd9ada8a2ff83b3d.jpg)
179
+ Figure 6: Zero-shot visual referring segmentation with SEEM. Given a referring image with simple spatial hints, SEEM can segment the regions which are semantically similar in different target images.
180
+
181
+ ![](images/b73f65fadd0b4db8d21027fe78da7a757e0148269d09af45393c9a5f1d87f911.jpg)
182
+ Figure 7: Zero-shot video object segmentation using the first frame plus one stroke. From top to bottom, the videos are “parkour" and “horsejump-low” from DAVIS [73], and video 101 from YouCook2 [74]. SEEM precisely segments referred objects even with significant appearance changes caused by blurring or intensive deformations.
183
+
184
+ Visual referring segmentation. In Fig.6, we show SEEM’s segmentation results when prompted with referring regions from another image. By simply drawing a click or scribble on one referring image, SEEM can take it as input and segment objects with similar semantics on other images. Notably, this referring segmentation has a powerful generalization capability to images of other domains. For example, by referring to the elephant in the forest, another object of the same category can be segmented well under drastically different scenes like cartoons, plush toys, and grassland.
185
+
186
+ Video object segmentation. In Fig. 7, we further show SEEM’s referring segmentation ability on the video object segmentation task in a zero-shot manner. By referring to the objects in the first frame with scribbles, SEEM can precisely segment the corresponding objects in the following frames, even when the following objects change in appearance by blurring or intensive deformations.
187
+
188
+ # 5 Conclusion
189
+
190
+ We presented SEEM, which can segment everything (all semantics) everywhere (all pixels) all at once (all possible prompt compositions). Apart from performing generic open-vocabulary segmentation, SEEM can interactively take different types of visual prompts from the user, including click, box, polygon, scribble, text, and referring region from another image. These visual prompts are mapped into a joint visual-semantic space with a prompt encoder, which makes our model versatile to various prompts and can flexibly compose different prompts. Extensive experiments indicate that our model yields competitive performance on several open-vocabulary and interactive segmentation benchmarks. Further studies revealed the robust generalization ability of our model in accurately segmenting images based on diverse user intents. We hope our work will serve as a stepping stone toward a universal and interactive interface for image segmentation and beyond.
191
+
192
+ Acknowledgements. We would like to express our gratitude to Lei Zhang for his generous support. And express the appreciated for the valuable suggestions from Zhenyuan Yang, and discussion with Xiaoyu Xiang. In addition, this work was supported in part by NSF CAREER IIS2150012, NASA 80NSSC21K0295, the Institute of Information and communications Technology Planning and Evaluation (IITP) grant funded by the Korea government (MSIT) (No. 2022-0-00871, Development of AI Autonomy and Knowledge Enhancement for AI Agent Collaboration).
193
+
194
+ # References
195
+
196
+ [1] Jianbo Shi and Jitendra Malik. Normalized cuts and image segmentation. IEEE Transactions on pattern analysis and machine intelligence, 22(8):888–905, 2000.
197
+ [2] Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. IEEE transactions on pattern analysis and machine intelligence, 40(4):834–848, 2017.
198
+ [3] Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr Dollár. Panoptic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9404–9413, 2019.
199
+ [4] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In Proceedings of the IEEE international conference on computer vision, pages 2961–2969, 2017.
200
+ [5] Huiyu Wang, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. Max-deeplab: End-to-end panoptic segmentation with mask transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5463–5474, 2021.
201
+ [6] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Masked-attention mask transformer for universal image segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1290–1299, 2022.
202
+ [7] Feng Li, Hao Zhang, Shilong Liu, Lei Zhang, Lionel M Ni, Heung-Yeung Shum, et al. Mask dino: Towards a unified transformer-based framework for object detection and segmentation. arXiv preprint arXiv:2206.02777, 2022.
203
+ [8] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
204
+ [9] Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin. Open-vocabulary image segmentation. arXiv preprint arXiv:2112.12143, 2021.
205
+ [10] Zheng Ding, Jieke Wang, and Zhuowen Tu. Open-vocabulary panoptic segmentation with maskclip. arXiv preprint arXiv:2208.08984, 2022.
206
+ [11] Xueyan Zou, Zi-Yi Dou, Jianwei Yang, Zhe Gan, Linjie Li, Chunyuan Li, Xiyang Dai, Harkirat Behl, Jianfeng Wang, Lu Yuan, et al. Generalized decoding for pixel, image, and language. arXiv preprint arXiv:2212.11270, 2022.
207
+ [12] Mengde Xu, Zheng Zhang, Fangyun Wei, Han Hu, and Xiang Bai. Side adapter network for open-vocabulary semantic segmentation. arXiv preprint arXiv:2302.12242, 2023.
208
+ [13] Chenxi Liu, Zhe Lin, Xiaohui Shen, Jimei Yang, Xin Lu, and Alan Yuille. Recurrent multimodal interaction for referring image segmentation. In Proceedings of the IEEE International Conference on Computer Vision, pages 1271–1280, 2017.
209
+ [14] Linwei Ye, Mrigank Rochan, Zhi Liu, and Yang Wang. Cross-modal self-attention network for referring image segmentation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 10502–10511, 2019.
210
+ [15] Jiannan Wu, Yi Jiang, Peize Sun, Zehuan Yuan, and Ping Luo. Language as queries for referring video object segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4974–4984, 2022.
211
+ [16] Shijia Huang, Feng Li, Hao Zhang, Shilong Liu, Lei Zhang, and Liwei Wang. A unified mutual supervision framework for referring expression segmentation and generation. arXiv preprint arXiv:2211.07919, 2022.
212
+ [17] Jiang Liu, Hui Ding, Zhaowei Cai, Yuting Zhang, Ravi Kumar Satzoda, Vijay Mahadevan, and R Manmatha. Polyformer: Referring image segmentation as sequential polygon generation. 2023.
213
+ [18] Konstantin Sofiiuk, Ilia A. Petrov, and Anton Konushin. Reviving iterative training with mask guidance for interactive segmentation, 2021.
214
+ [19] Ho Kei Cheng, Yu-Wing Tai, and Chi-Keung Tang. Modular interactive video object segmentation: Interaction-to-mask, propagation and difference-aware fusion. In CVPR, 2021.
215
+ [20] Qin Liu, Zhenlin Xu, Gedas Bertasius, and Marc Niethammer. Simpleclick: Interactive image segmentation with simple vision transformers. arXiv preprint arXiv:2210.11006, 2022.
216
+ [21] Xi Chen, Zhiyan Zhao, Yilei Zhang, Manni Duan, Donglian Qi, and Hengshuang Zhao. Focalclick: towards practical interactive image segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1300–1309, 2022.
217
+ [22] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
218
+ [23] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research, 21(1):5485–5551, 2020.
219
+ [24] OpenAI. Gpt-4 technical report, 2023.
220
+ [25] Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980, 2020.
221
+ [26] Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning, pages 12697–12706. PMLR, 2021.
222
+ [27] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021.
223
+ [28] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
224
+ [29] Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv preprint arXiv:2205.11916, 2022.
225
+ [30] Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023.
226
+ [31] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pages 213–229. Springer, 2020.
227
+ [32] Hao Zhang, Feng Li, Xueyan Zou, Shilong Liu, Chunyuan Li, Jianfeng Gao, Jianwei Yang, and Lei Zhang. A simple framework for open-vocabulary segmentation and detection. arXiv preprint arXiv:2303.08131, 2023.
228
+
229
+ [33] Yin Li, Jian Sun, Chi-Keung Tang, and Heung-Yeung Shum. Lazy snapping. ACM Transactions on Graphics (ToG), 23(3):303–308, 2004.
230
+
231
+ [34] Leo Grady. Random walks for image segmentation. IEEE transactions on pattern analysis and machine intelligence, 28(11):1768–1783, 2006.
232
+
233
+ [35] Ning Xu, Brian Price, Scott Cohen, Jimei Yang, and Thomas S Huang. Deep interactive object selection. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 373–381, 2016.
234
+
235
+ [36] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C. Berg, Wan-Yen Lo, Piotr Dollár, and Ross Girshick. Segment anything, 2023.
236
+
237
+ [37] King-Sun Fu and JK Mui. A survey on image segmentation. Pattern recognition, 13(1):3–16, 1981.
238
+
239
+ [38] Pedro F Felzenszwalb, Ross B Girshick, David McAllester, and Deva Ramanan. Object detection with discriminatively trained part-based models. IEEE transactions on pattern analysis and machine intelligence, 32(9):1627–1645, 2009.
240
+
241
+ [39] Zhengxia Zou, Zhenwei Shi, Yuhong Guo, and Jieping Ye. Object detection in 20 years: A survey. arXiv preprint arXiv:1905.05055, 2019.
242
+
243
+ [40] Shervin Minaee, Yuri Y Boykov, Fatih Porikli, Antonio J Plaza, Nasser Kehtarnavaz, and Demetri Terzopoulos. Image segmentation using deep learning: A survey. IEEE transactions on pattern analysis and machine intelligence, 2021.
244
+
245
+ [41] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking atrous convolution for semantic image segmentation. arXiv preprint arXiv:1706.05587, 2017.
246
+
247
+ [42] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3431–3440, 2015.
248
+
249
+ [43] Daniel Bolya, Chong Zhou, Fanyi Xiao, and Yong Jae Lee. Yolact: Real-time instance segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9157–9166, 2019.
250
+
251
+ [44] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
252
+
253
+ [45] Zhiqi Li, Wenhai Wang, Enze Xie, Zhiding Yu, Anima Anandkumar, Jose M Alvarez, Ping Luo, and Tong Lu. Panoptic segformer: Delving deeper into panoptic segmentation with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1280–1289, 2022.
254
+
255
+ [46] Jitesh Jain, Jiachen Li, MangTik Chiu, Ali Hassani, Nikita Orlov, and Humphrey Shi. Oneformer: One transformer to rule universal image segmentation. arXiv preprint arXiv:2211.06220, 2022.
256
+
257
+ [47] Hao Zhang, Feng Li, Huaizhe Xu, Shijia Huang, Shilong Liu, Lionel M Ni, and Lei Zhang. Mpformer: Mask-piloted transformer for image segmentation. arXiv preprint arXiv:2303.07336, 2023.
258
+
259
+ [48] Bin Yan, Yi Jiang, Jiannan Wu, Dong Wang, Ping Luo, Zehuan Yuan, and Huchuan Lu. Universal instance perception as object discovery and retrieval. arXiv preprint arXiv:2303.06674, 2023.
260
+
261
+ [49] Jiasen Lu, Christopher Clark, Rowan Zellers, Roozbeh Mottaghi, and Aniruddha Kembhavi. Unified-io: A unified model for vision, language, and multi-modal tasks. arXiv preprint arXiv:2206.08916, 2022.
262
+
263
+ [50] Xinlong Wang, Xiaosong Zhang, Yue Cao, Wen Wang, Chunhua Shen, and Tiejun Huang. Seggpt: Segmenting everything in context. arXiv preprint arXiv:2304.03284, 2023.
264
+
265
+ [51] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, 2014.
266
+ [52] Licheng Yu, Patrick Poirson, Shan Yang, Alexander C Berg, and Tamara L Berg. Modeling context in referring expressions. In European Conference on Computer Vision, pages 69–85. Springer, 2016.
267
+ [53] Zhao Yang, Jiaqi Wang, Yansong Tang, Kai Chen, Hengshuang Zhao, and Philip HS Torr. Lavt: Language-aware vision transformer for referring image segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18155–18165, 2022.
268
+ [54] Qin Liu, Meng Zheng, Benjamin Planche, Srikrishna Karanam, Terrence Chen, Marc Niethammer, and Ziyan Wu. Pseudoclick: Interactive image segmentation with click imitation. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part VI, pages 728–745. Springer, 2022.
269
+ [55] Alexander Kolesnikov, André Susano Pinto, Lucas Beyer, Xiaohua Zhai, Jeremiah Harmsen, and Neil Houlsby. UViM: A unified modeling approach for vision with learned guiding codes. arXiv preprint arXiv:2205.10337, 2022.
270
+ [56] Ting Chen, Saurabh Saxena, Lala Li, Tsung-Yi Lin, David J Fleet, and Geoffrey Hinton. A unified sequence interface for vision tasks. arXiv preprint arXiv:2206.07669, 2022.
271
+ [57] Xinlong Wang, Wen Wang, Yue Cao, Chunhua Shen, and Tiejun Huang. Images speak in images: A generalist painter for in-context visual learning, 2023.
272
+ [58] Jianwei Yang, Chunyuan Li, and Jianfeng Gao. Focal modulation networks. arXiv preprint arXiv:2203.11926, 2022.
273
+ [59] Mingyu Ding, Bin Xiao, Noel Codella, Ping Luo, Jingdong Wang, and Lu Yuan. Davit: Dual attention vision transformers. arXiv preprint arXiv:2204.03645, 2022.
274
+ [60] Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Bin Xiao, Ce Liu, Lu Yuan, and Jianfeng Gao. Unified contrastive learning in image-text-label space. In CVPR, 2022.
275
+ [61] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, Ce Liu, Mengchen Liu, Zicheng Liu, Yumao Lu, Yu Shi, Lijuan Wang, Jianfeng Wang, Bin Xiao, Zhen Xiao, Jianwei Yang, Michael Zeng, Luowei Zhou, and Pengchuan Zhang. Florence: A new foundation model for computer vision. arXiv preprint arXiv:2111.11432, 2021.
276
+ [62] Zheng Lin, Zheng-Peng Duan, Zhao Zhang, Chun-Le Guo, and Ming-Ming Cheng. Focuscut: Diving into a focus view in interactive segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2637–2646, 2022.
277
+ [63] Huaijia Lin, Xiaojuan Qi, and Jiaya Jia. Agss-vos: Attention guided single-shot video object segmentation. In ICCV, 2019.
278
+ [64] Joakim Johnander, Martin Danelljan, Emil Brissman, Fahad Shahbaz Khan, and Michael Felsberg. A generative appearance model for end-to-end video object segmentation, 2018.
279
+ [65] Zhihui Lin, Tianyu Yang, Maomao Li, Ziyu Wang, Chun Yuan, Wenhao Jiang, and Wei Liu. Swem: Towards real-time video object segmentation with sequential weighted expectationmaximization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1362–1372, 2022.
280
+ [66] Ho Kei Cheng and Alexander G. Schwing. XMem: Long-term video object segmentation with an atkinson-shiffrin memory model. In ECCV, 2022.
281
+ [67] Qiang Wang, Li Zhang, Luca Bertinetto, Weiming Hu, and Philip HS Torr. Fast online object tracking and segmentation: A unifying approach. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2019.
282
+ [68] Jiannan Wu, Yi Jiang, Peize Sun, Zehuan Yuan, and Ping Luo. Language as queries for referring video object segmentation. arXiv preprint arXiv:2201.00487, 2022.
283
+ [69] Jinyu Yang, Mingqi Gao, Zhe Li, Shang Gao, Fangjing Wang, and Feng Zheng. Track anything: Segment anything meets videos, 2023.
284
+ [70] Renrui Zhang, Zhengkai Jiang, Ziyu Guo, Shilin Yan, Junting Pan, Hao Dong, Peng Gao, and Hongsheng Li. Personalize segment anything model with one shot, 2023.
285
+ [71] Ning Xu, Linjie Yang, Yuchen Fan, Dingcheng Yue, Yuchen Liang, Jianchao Yang, and Thomas Huang. Youtube-vos: A large-scale video object segmentation benchmark. arXiv preprint arXiv:1809.03327, 2018.
286
+ [72] Jordi Pont-Tuset, Federico Perazzi, Sergi Caelles, Pablo Arbeláez, Alex Sorkine-Hornung, and Luc Van Gool. The 2017 davis challenge on video object segmentation. arXiv preprint arXiv:1704.00675, 2017.
287
+ [73] Federico Perazzi, Jordi Pont-Tuset, Brian McWilliams, Luc Van Gool, Markus Gross, and Alexander Sorkine-Hornung. A benchmark dataset and evaluation methodology for video object segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 724–732, 2016.
288
+ [74] Luowei Zhou, Chenliang Xu, and Jason Corso. Towards automatic learning of procedures from web instructional videos. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
md/dev/Uy6YEI9-6v/Uy6YEI9-6v.md ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OBJECT-CENTRIC NEURAL SCENE RENDERING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We present a method for composing photorealistic scenes from captured images of objects. Our work builds upon neural radiance fields (NeRFs), which implicitly model the volumetric density and directionally-emitted radiance of a scene from a collection of images. While NeRFs synthesize realistic pictures, they only model static scenes and are closely tied to specific imaging conditions. This property makes NeRFs hard to generalize to new scenarios, including new lighting or new arrangements of objects. Instead of learning a scene radiance field as a NeRF does, we propose to learn object-centric neural scattering functions (OSFs), a representation that models per-object light transport implicitly using a lighting- and view-dependent neural network. This enables rendering scenes even when objects or lights move, without retraining. Combined with a volumetric path tracing procedure, our framework is capable of rendering light transport effects including occlusions, specularities, shadows, and indirect illumination, both within individual objects and between different objects. We evaluate OSFs on synthetic and real world datasets, and on generalizing to new scene configurations. Learning OSFs leads to photorealistic, physically-accurate renderings of multi-object scenes.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Synthesizing images of dynamic scenes is an important problem in computer vision and graphics, with applications in AR/VR and robotics (Savva et al., 2019; Xia et al., 2020). For synthetic scenes, a user typically designs a set of 3D objects separately, then composes them into scenes to be rendered with specified camera, material, and lighting parameters. While this traditional graphics approach allows for flexible scene compositions, it requires detailed models of geometry, lighting, materials, and cameras, which can be difficult to obtain for real-world scenes.
12
+
13
+ To render real-world scenes without computer graphics models, recent works have explored using neural implicit methods (Lombardi et al., 2019; Sitzmann et al., 2019a;b). Most notably, Mildenhall et al. (2020) proposed neural radiance fields (NeRF), which achieve photorealistic quality by implicitly modeling the volumetric density and directional emitted radiance of a scene.
14
+
15
+ However, as shown in Figure 1, NeRF cannot generalize beyond the scene it was trained on, because it assumes static scenes and fixed illumination and learns a radiance field, which estimates only the resulting radiance along a ray after all light transport has occurred in a scene. Thus, for dynamic scenes where lights and objects can move, a separate NeRF-based model is needed for each new scene configuration.
16
+
17
+ ![](images/8ed85615e21b0b053f778c5c06f54eb1cf4ef60465fc666bac5bef5e9879567b.jpg)
18
+ Figure 1: (a) NeRF. (b) Our method.
19
+
20
+ To address this issue, we propose Object-Centric Neural Scattering Functions (OSFs) to synthesize dynamic scenes of objects learned from 2D images (Figure 2). We represent each object as a learned 7D scattering function with inputs $( x , y , z , \phi _ { i } , \theta _ { i } , \phi _ { o } , \theta _ { o } )$ , where $( x , y , z )$ is the spatial location, $( \phi _ { i } , \theta _ { i } )$ is the incoming light direction, and $\left( \phi _ { o } , \theta _ { o } \right)$ is the outgoing light direction. The function outputs the volumetric density as well as the fraction of light arriving from direction $( \phi _ { i } , \theta _ { i } )$ that scatters in outgoing direction $\left( \phi _ { o } , \theta _ { o } \right)$ .
21
+
22
+ Each OSF models all light bounces (reflections) and occlusions (shadows) within an object. Since each object’s scattering function is a radiance transfer function rather than a radiance field, it is intrinsic to the object (independent of the scene it is in) and can be reused across different object placements and lighting conditions without retraining. We emphasize that because NeRFs are radiance fields, they cannot be composed, and cannot generalize beyond one scene. In contrast, we can render infinitely many scenes. We can build a library of OSFs trained independently for different objects to be composed into scenes with different object placements, camera, and lighting.
23
+
24
+ ![](images/fd921d3f24289566b23c0122c43b391f84f4457c5c3d2bcc99da20f473f6d700.jpg)
25
+ Figure 2: We propose an object-centric neural scene representation for image synthesis. Given a scene description (a), and a repository of neural object-centric scattering functions (OSF) trained independently from images and frozen for each object (b), we can compose the objects into scenes (c), and render photorealistic images as we move lights (d), cameras (e), and/or objects (f). Our framework is capable of rendering occlusions, specularities, shadows, and indirect illumination.
26
+
27
+ To model light transport between objects, we integrate our implicit object functions with volumetric path tracing. Like NeRF, we evaluate the radiance and volumetric density at 5D samples along every primary ray to the camera and composite them with an over operator. However, unlike NeRF, we estimate the radiance for each 5D sample by integrating our 7D OSF across the 2D sphere of incoming light directions. We estimate the integral with Monte Carlo path tracing (Kajiya, 1986) to reproduce shadows and indirect illumination effects.
28
+
29
+ Our key idea is to decompose the rendering problem into (i) a learned component (per-object asset creation), and (ii) a non-learned component (per-scene path tracing). The learned component models intra-object light transport (e.g., bounces from the seat of a chair to the back of the chair). The non-learned component handles inter-object light transport (e.g., bounces from a wall to a chair). Together, they model the full rendering equation (Kajiya, 1986) (except for occluders or light sources that intrude the object’s convex hull (Sloan et al., 2002)). Since only the inter-object light transport changes as objects and lights move, no re-training is required for different scene arrangements. Experimental results indicate that our method is capable of rendering images with novel scene compositions and lighting conditions better than alternative learned approaches.
30
+
31
+ In summary, our contributions are:
32
+
33
+ 1. Learning Object-Centric Neural Scattering Functions (OSFs) that model intra-object light transport implicitly using a lighting- and view-dependent neural network.
34
+ 2. Integrating implicitly learned object scattering functions with volumetric path tracing to model inter-object light transport.
35
+ 3. A rendering algorithm that enables rendering scenes with moving objects, lights and cameras, using implicit functions.
36
+
37
+ # 2 RELATED WORK
38
+
39
+ Classical object-centric representations. Factoring light transport into intra- and inter-object illumination has a long history in traditional computer graphics (Dutre et al., 2018). In most cases, the motivation is to improve rendering efficiency by approximating intra-object lighting factors with simple transfer functions (e.g., linear) for simple radiance fields (e.g., spherical harmonics) derived from from computer graphics models, as in precomputed radiance transfer (PRT) (Sloan et al., 2002), ambient occlusion (Miller, 1994), or virtual walls (Arnaldi et al., 1994). In other cases, the motivation is to insert captured, real-world radiance fields into synthetic scenes, as in Light Field Transfer (Cossairt et al., 2008). These methods generally store the radiance field for objects in a discrete representation (e.g., a sampled 2D or 4D grid). As a result, they cannot reproduce accurate inter-object light transport, especially for objects with intersecting bounding volumes. In contrast, we focus on learning radiance transfer from images in order to model complex real-world scattering accurately, and utilize volumetric rendering techniques to account for inter-object illumination.
40
+
41
+ Novel view synthesis. Traditional methods for synthesizing novel views of a scene from captured images include using Structure-From-Motion (Hartley & Zisserman, 2003) and bundle adjustment (Triggs et al., 1999) to predict a sparse point cloud and camera parameters of the scene. More recently, a number of learning-based novel view synthesis methods have been presented but require 3D geometry as inputs (Hedman et al., 2018; Thies et al., 2019; Meshry et al., 2019; Aliev et al., 2020; Martin-Brualla et al., 2018). Others use multiplane images as proxies for novel view synthesis, but their viewing ranges are limited to interpolated input views (Flynn et al., 2016; Zhou et al., 2018; Srinivasan et al., 2019; Mildenhall et al., 2019). Some works represent scenes as coarse voxel grids and use a CNN-based decoder for differentiable rendering, but lack view consistency due to the use of 2D convolutional kernels (Nguyen-Phuoc et al., 2018; 2019; 2020).
42
+
43
+ Recently, volume rendering approaches have been used to render scenes represented as voxel grids that are more view-consistent (Lombardi et al., 2019; Sitzmann et al., 2019a). However, the rendering resolution of these methods are limited by the time and computational complexity of discretely sampled volumes. To address this issue, Neural Radiance Fields (NeRF) (Mildenhall et al., 2020) directly optimizes a continuous radiance field representation using a multi-layer perceptron. This allows synthesizing novel views of realistic images at an unprecedented level of fidelity. To make NeRF more efficient, Neural Sparse Voxel Fields (Liu et al., 2020) have been proposed as a sparse voxel octree variant of NeRF and demonstrate the ease of composing learned NeRFs with their voxel representation. See (Dellaert & Yen-Chen, 2020) for survey. While these implicit methods produce high-quality novel views of a scene, their models assume a static scene with fixed illumination. Our method enables synthesizing dynamic scenes with novel viewpoint, lighting, and object configurations.
44
+
45
+ Relighting. Learning-based methods that relight images without explicit geometric reasoning have been proposed, but lack the ability to recover hard shadows (Sun et al., 2019; Xu et al., 2018; Zhou et al., 2019). Other works use geometric representations that facilitate shadowing computation, but require 3D geometry as input (Philip et al., 2019; Zhang et al., 2021; Oechsle et al., 2020; Rematas & Ferrari, 2020). Deep Reflectance Volumes (Bi et al., 2020b) reconstructs a voxelized representation of a scene and predict per-voxel BRDFs, but the fixed resolution of voxel grids limits the quality in the rendered images. Similarly, Neural Reflectance Fields (Bi et al., 2020a) predicts the parameters of a BRDF model, but demonstrate higher fidelity rendering by learning a continuous scene representation. However, Neural Reflectance Fields focuses on relighting single objects, and requires manual specification of the BRDF model. Parametric BRDF models are unable to handle complex scattering functions, including real-world scattering phenomena that are difficult to model. In contrast, our method is capable of learning all scattering functions, and can render multiple objects in dynamic scenes.
46
+
47
+ # 3 PRELIMINARIES
48
+
49
+ # 3.1 VOLUME RENDERING
50
+
51
+ To render an image of a scene with arbitrary camera parameters, camera rays are sent into the scene, through each pixel on the image plane. The expected color of each pixel is computed as the radiance along each camera ray.
52
+
53
+ Volume rendering is an approach for computing the radiance traveling along rays traced in a volume. Let ${ \pmb r } ( t ) = { \pmb x } _ { 0 } + \omega _ { o } t$ be a point along a ray $\mathbfit { \Delta } \mathbf { r }$ with origin $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ and direction $\omega _ { o }$ , where $t \in \mathbb { R }$ is a 1D location along the ray, and the $^ o$ in $\omega _ { o }$ denotes “outgoing” direction. For our purposes, we assume non-emissive and non-absorptive volumes. From Novak et al. (2018), the volume rendering ´ equation to compute the radiance $L ( \boldsymbol { x } _ { 0 } , \omega _ { o } )$ of the ray is defined as:
54
+
55
+ $$
56
+ L ( { \boldsymbol { x } } _ { 0 } , \omega _ { o } ) = \int _ { t _ { n } } ^ { t _ { f } } { \boldsymbol { \tau } } ( t ) { \boldsymbol { \sigma } } ( r ( t ) ) L _ { s } ( r ( t ) , \omega _ { o } ) d t , \quad { \mathrm { w h e r e } } \quad { \boldsymbol { \tau } } ( t ) = \exp { \left( - \int _ { t _ { n } } ^ { t } { \boldsymbol { \sigma } } ( r ( u ) ) d u \right) } ,
57
+ $$
58
+
59
+ where $t _ { n }$ and $t _ { f }$ are near and far integration bounds, $\sigma ( \pmb { r } ( t ) )$ denotes the volume density of point $\mathbf { } _ { \pmb { r } ( t ) }$ , and $\tau ( t )$ denotes the accumulated transmittance from $t _ { n }$ to $t$ . The term $L _ { s } ( \pmb { r } ( t ) , \pmb { \omega } _ { o } )$ is the light scattered at point $\mathbf { } _ { \mathbf { } } ^ { r ( t ) }$ along direction $\omega _ { o }$ , defined as the integral over all incoming light directions:
60
+
61
+ $$
62
+ L _ { s } ( \pmb { x } , \omega _ { o } ) = \int _ { S } L ( \pmb { x } , \omega _ { l } ) f _ { p } ( \pmb { x } , \omega _ { l } , \omega _ { o } ) d \omega _ { l } ,
63
+ $$
64
+
65
+ where $s$ is a unit sphere and $f _ { p }$ is a phase function that evaluates the fraction of light incoming from direction $\omega _ { l }$ at a point $_ { \textbf { \em x } }$ that scatters out in direction $\omega _ { o }$ . In NeRF, Mildenhall et al. (2020) assume
66
+
67
+ fixed illumination and do not consider any form of Equation 2. We consider a more general form of the volume rendering equation that explicitly models light paths within and between objects. This is important for dynamic scenes, where lighting and objects can move with respect to one another.
68
+
69
+ # 3.2 RAY MARCHING
70
+
71
+ The continuous integrals in Equation 1 can be estimated with quadrature (Kniss et al., 2003; Max, 1995), as done in NeRF (Mildenhall et al., 2020). For each ray, stratified sampling is used to obtain $N$ samples $\{ t _ { i } \} _ { i = 1 } ^ { N }$ along the ray, where $t _ { i } \in [ t _ { n } , t _ { f } ]$ . The rendering equation is approximated by:
72
+
73
+ $$
74
+ L ( \boldsymbol { x } _ { 0 } , \omega _ { o } ) = \sum _ { i = 1 } ^ { N } \tau _ { i } \alpha _ { i } L _ { s } ( \boldsymbol { x } _ { i } , \omega _ { o } ) \quad \mathrm { w h e r e } \quad L _ { s } ( \boldsymbol { x } _ { i } , \omega _ { o } ) = \frac { 1 } { | \mathcal { L } | } \sum _ { l \in \mathcal { L } } L ( \boldsymbol { x } _ { i } , \omega _ { l } ) \rho _ { i } ^ { l } ,
75
+ $$
76
+
77
+ where $\begin{array} { r } { \tau _ { i } = \prod _ { j = 1 } ^ { i - 1 } ( 1 - \alpha _ { j } ) } \end{array}$ and $\alpha _ { i } = 1 - e ^ { - \sigma _ { i } \left( t _ { i + 1 } - t _ { i } \right) }$ . To compute the average over incoming light paths $L _ { s }$ , we discretize over the domain $s$ in Equation 2 by sampling a set of incoming light paths $\mathcal { L } = \{ l _ { 1 } , \ldots , l _ { K } \}$ , where $\pmb { \rho } _ { i } ^ { l } = f _ { p } ( \pmb { x } _ { i } , \omega _ { l } , \omega _ { o } ) \bar { \ } \in \ [ 0 , 1 ]$ , the fraction of light incoming from light path $\imath$ that is scattered in direction $\omega _ { o }$ .
78
+
79
+ # 3.3 NEURAL RADIANCE FIELDS
80
+
81
+ NeRF represents a continuous scene as a volumetric radiance field, approximated with a multilayer perceptron $F _ { \Theta }$ . The model $F _ { \Theta }$ takes spatial location $\pmb { x } = ( x , y , z )$ and viewing direction $\pmb { d } = ( \phi , \theta )$ as input, and outputs the density $\sigma$ and color $\boldsymbol { \mathbf { \mathit { c } } } = ( r , g , b )$ , where $r , g , b \in [ 0 , 1 ]$ . Frequency-based positional encoding (Rahaman et al., 2019; Vaswani et al., 2017) is applied to the inputs to better capture high-frequency variation in appearance and geometry.
82
+
83
+ A hierarchical volume sampling procedure (Mildenhall et al., 2020; Levoy, 1990) is then employed to more efficiently allocate samples along each ray. This technique biases sample allocation to favor the visible parts of the scene that contribute the most to the final render, avoiding occluded or free space in the scene. NeRF simultaneously optimizes two radiance fields, where the sample weights $\tau _ { i } \cdot \alpha _ { i }$ from a coarse model are used to bias samples for a fine model. The $L _ { 2 }$ loss is used to optimize both models: $\begin{array} { r } { \sum _ { \pmb { r } \in \mathcal { R } } \| \hat { C } _ { c } ( \pmb { r } ) - C ( \pmb { r } ) \| _ { 2 } ^ { 2 } + \| \hat { C } _ { f } ( \pmb { r } ) - \check { C } ( \pmb { r } ) \| _ { 2 } ^ { 2 } } \end{array}$ , where $\mathcal { R }$ is the set of all camera rays, $\widehat { C } _ { c } ( \pmb { r } )$ and $\widehat { C } _ { f } ( \boldsymbol { r } )$ denote the radiance along ray $\mathbfit { \Delta } \mathbf { r }$ predicted by the coarse and fine models respectively, and $C ( \boldsymbol { r } )$ is the ground truth pixel color for $\pmb { r }$ .
84
+
85
+ # 4 METHOD
86
+
87
+ # 4.1 OBJECT-CENTRIC NEURAL SCATTERING FUNCTION
88
+
89
+ We represent each object as a 7D object-centric neural scattering function (OSF), depicted in Figure 3a. For each object, we learn an implicit function $F _ { \Theta } \colon ( \pmb { x } , \omega _ { l } , \omega _ { o } ) ( \sigma , \pmb { \rho } )$ that receives a 3D point in the object coordinate frame, the incoming light direction, and the outgoing light direction, and predicts the volumetric density as well as fraction of incoming light that is scattered in the outgoing direction. $\Theta$ are learned weights that parameterize the neural network, $\pmb { x } = ( x , y , z )$ denotes the spatial location, $\omega _ { l } = \left( \phi _ { l } , \theta _ { l } \right)$ denotes the incoming light direction, $\omega _ { o } = ( \phi _ { o } , \theta _ { o } )$ denotes the outgoing light direction, $\sigma$ denotes the volumetric density, and $\rho = ( \rho _ { r } , \rho _ { g } , \rho _ { b } )$ denotes the fraction of light arriving at $_ { \textbf { \em x } }$ from direction $\omega _ { l }$ that is scattered and leaving in direction $\omega _ { o }$ . The final color of a point $_ { \textbf { \em x } }$ is the integral of $\rho$ multiplied by the incoming radiance over all incoming light directions in unit sphere $s$ (Equation 2). Following NeRF, we similarly apply positional encoding to our inputs $( \pmb { x } , \omega _ { l } , \omega _ { o } )$ and employ a hierarchical sampling procedure to recover higher quality appearance and geometry of learned objects.
90
+
91
+ During training, we assume a single point light source with radiance of $( 1 , 1 , 1 )$ . This simplifies $L _ { s }$ from Equation 2 to $L _ { s } ( \pmb { x } , \omega _ { o } ) = L ( \pmb { x } , \omega _ { l } ) f _ { p } ( \pmb { x } , \omega _ { l } , \omega _ { o } ) = f _ { p } ( \pmb { x } , \omega _ { l } , \omega _ { o } )$ . To learn per-object NeRFs independent of object rotation and translation, the inputs to $F _ { \Theta }$ must be in the object’s canonical coordinate frame. Given a object transformation $T _ { i }$ for object $\mathbf { o } _ { i }$ , we apply $T _ { i } ^ { - 1 }$ to $( r , \omega _ { l } , \omega _ { o } )$ before feeding the inputs to the network.
92
+
93
+ # 4.2 RENDERING MULTIPLE OSFS
94
+
95
+ Once we have learned an OSF for each object, we aim at composing the learned objects into scenes.
96
+ An overview of our procedure is visually depicted in Figure 3b.
97
+
98
+ ![](images/66fc5a607c6b90609b949b4ac6d774a80f2f4bfc8041fa317f228a4221e631ec.jpg)
99
+
100
+ (a) We represent each object as an object-centric neural scattering function (OSF), which models how light entering at a point $_ { \textbf { \em x } }$ on the object, from direction $\omega _ { l }$ where $\imath$ corresponds to a light path, undergoes multiple bounces within the object and exits along direction $\omega _ { o }$ with some fractional amount of light $\pmb { \rho }$ . We approximate the scattering function with a multilayer perceptron $F _ { \Theta }$ where $\Theta$ are learned weights that parameterize the neural network. Given a single point $_ { \textbf { \em x } }$ , an incoming light direction $\omega _ { l }$ , and an outgoing direction $\omega _ { o }$ , $F _ { \Theta }$ outputs the volume density $\sigma$ of that point, as well as the fraction of light arriving at $_ { \textbf { \em x } }$ from direction $\omega _ { l }$ that is scattered in direction $\omega _ { o }$ .
101
+
102
+ (b) Our procedure for rendering an arbitrary scene consisting of multiple objects, light sources, and cameras. Given a set of objects, we compute direct illumination by shooting rays from each light source to each object (brown arrows). Shadows are computed by sending shadow rays back to each light source (purple arrow). The shadow ray from the desk is occluded by the mug, so the mug casts a shadow on the desk. We send secondary rays between objects to render indirect illumination effects, such as between the desk and the kettle (green and blue dashed arrows). Finally, rays are sent back to the camera to render the final image (dark blue arrows).
103
+
104
+ ![](images/03f3183f13c1fafe38d219921c954792e1c1c0cb4fd4256f42d25dcdb5dad07f.jpg)
105
+ Figure 3: Using our method (OSFs) to render: (a) single and (b) multiple objects.
106
+ Figure 4: Sampling procedure. (a) Scene with a camera, light source, and object bounding boxes. Primary rays are sent from the camera into the scene. Rays that do not intersect with objects are pruned. Of the intersecting rays, we sample points within intersecting regions. (b) Shadow rays from each sample are sent to the light source, and samples within intersecting regions are evaluated.
107
+
108
+ Let $\mathcal { O } = \{ o _ { i } \} _ { i = 1 } ^ { N }$ be a set of $N$ objects we wish to render. For simplicity, we first describe the rendering process for each object $\mathbf { o } _ { i }$ , then explain the process to combine results across all objects to render the final scene. Let $\mathbf { } o _ { i } \in \mathcal { O }$ denote object $i$ with transformation $T _ { i } \in \mathbb { R } ^ { 4 \times 4 }$ and bounding box dimensions $D _ { i } \in \mathbb { R } ^ { 3 }$ . Further let $\mathbfit { \Delta } \mathbf { r }$ be a camera ray with origin $\boldsymbol { c } \in \mathbb { R } ^ { 3 }$ and direction $\omega _ { o } \in \mathbb { R } ^ { 3 }$ , which we define with parameters $\gamma = [ c , \omega _ { o } ] \in \mathbb { R } ^ { 6 }$ . Our goal is to compute $L ( c , \omega _ { o } )$ as described in Equation 3. We compute the ray-box intersection between the ray and the object to obtain near bound $t _ { n } ^ { i }$ and far bound $\bar { t } _ { f } ^ { i }$ such that $\textstyle r ( t _ { n } ^ { i } )$ and ${ \pmb r } ( t _ { f } ^ { i } )$ each intersect a box plane, as shown in Figure 4. Note thabetween ys thand do not intealong ray ect withto obtai $\mathbf { o } _ { i }$ are excl sample putatio, where $M$ pointsiven a $t _ { n } ^ { i }$ $t _ { f } ^ { i }$ $\mathbfit { \Delta } \mathbf { r }$ $X ^ { i } = \{ x _ { m } ^ { i } \} _ { m = 1 } ^ { M }$ $\pmb { X } ^ { i } \in \mathbb { R } ^ { M \times 3 }$ light source $\imath$ , we evaluate the object’s model $F _ { \Theta _ { i } } ( X ^ { i } , \omega _ { l } , \omega _ { o } )$ to obtain alpha values $\pmb { \alpha } ^ { i } \in \mathbb { R } ^ { M }$ and phase function values $\pmb { \rho } ^ { i } \in \mathbb { R } ^ { M \times 3 }$ .
109
+
110
+ It is not always possible for a light ray from light source $\imath$ to reach the object $\mathbf { o } _ { i }$ . Any of the other objects in $\mathcal { O } ^ { \prime } = \{ o _ { j } \in \mathcal { O } \mid j \neq i \}$ in the scene may occlude the incoming light, casting a shadow on object $\mathbf { o } _ { i }$ . We compute shadows by sending a shadow ray $\boldsymbol { r } _ { m }$ from each of the $M$ samples in $X ^ { i }$ to the light source $\imath$ . Evaluating the shadow ray enables us to determine the amount of light blocked along the ray by other objects. We define the parameters of the M shadow rays as Γ ∈ RM×6.
111
+
112
+ For each object $o _ { j } \in \mathcal { O } ^ { \prime }$ , we compute ray-box intersections between shadow rays $\Gamma$ and $o _ { j }$ ’s bounding box. This allows us to compute the amount of light traveling towards $\mathbf { o } _ { i }$ that is blocked by $o _ { j }$ . Similar to primary rays, we sample $M$ points along each shadow ray to obtain a set of points $\breve { \pmb { X } } ^ { j } \in \mathbb { R } ^ { M \times M }$ . We then evaluate the object model $F _ { \Theta _ { j } } ( \mathbf { X } ^ { j } )$ to obtain alpha values $\pmb { A } ^ { j } \in \mathbb { R } ^ { M \times M }$ . For each shadow ray $\boldsymbol { r _ { m } }$ , we combine samples $A _ { m } ^ { j }$ across the $N - 1$ objects in $\mathcal { O } ^ { \prime }$ by sorting according to sample distance to obtain alpha values $\pmb { A } _ { m } \in \mathbb { R } ^ { M ( N - 1 ) }$ . The fraction of unobstructed light traveling along the shadow ray $\mathbf { \Delta } _ { \mathbf { r } _ { m } }$ is computed as the transmittance:
113
+
114
+ $$
115
+ \tau _ { m } ^ { l } = \prod _ { n = 1 } ^ { M ( N - 1 ) } ( 1 - A _ { m n } ) .
116
+ $$
117
+
118
+ Thus, the adjusted incoming radiance from light source $\imath$ when accounting for occlusions is computed as $L _ { l } ( \mathbf { \bar { x } } _ { m } , \omega _ { l } ) = \tau _ { m } ^ { l } \bar { L } _ { l } ( \mathbf { x } _ { m } , \omega _ { l } )$ .
119
+
120
+ We follow the scattering equation in Equation 2 and now consider all incoming light directions over the unit sphere $s$ . This accounts for secondary light rays traveling to an object $\mathbf { o } _ { i }$ indirectly from another object ${ \pmb O } _ { j }$ (indirect illumination). We approximate the integral over the unit sphere $s$ by sampling $K$ directions on the unit sphere uniformly at random. For each direction $\omega _ { k }$ randomly sampled for a point $_ { \textbf { \em x } }$ , we send a secondary ray $\mathbf { \nabla } r _ { k }$ from $_ { \textbf { \em x } }$ in direction $\omega _ { k }$ and evaluate the radiance $L ( x , \omega _ { k } )$ traveling along the ray. To compute the radiance of the secondary ray $L ( x , \omega _ { k } )$ , we employ the same technique used to compute the radiance of a primary ray $L ( c , \omega _ { o } )$ (described at the beginning of Section 4.2). The incoming radiance $L ( x , \omega _ { k } )$ is multiplied with the phase function value $\rho = f _ { p } ( { \pmb x } , \omega _ { { \pmb k } } , \omega _ { o } )$ to determine the outgoing radiance $\dot { L } ( { \pmb x } , { \pmb \omega } _ { o } )$ , where $\rho$ is evaluated using $F _ { \Theta _ { i } }$ . Note that this is possible due to the recursive nature of our formulation. Only secondary rays are described here (two bounces), but our method supports an arbitrary number of bounces.
121
+
122
+ Rendering. We sample and evaluate all objects in $\mathcal { O }$ to obtain alpha values $\{ \alpha ^ { i } \} _ { i = 1 } ^ { N }$ and phase function values $\{ \rho ^ { i } \} _ { i = 1 } ^ { N }$ for a set of sampled points $\{ X ^ { i } \} _ { i = 1 } ^ { N }$ along ray $\pmb { r }$ . We sort the samples across all objects to produce a final set of $P = M \cdot N$ samples $\{ \pmb { x } _ { m } \} _ { m = 1 } ^ { P }$ , $\lbrace \alpha _ { m } \rbrace _ { m = 1 } ^ { P }$ , and $\{ \rho _ { m } \} _ { m = 1 } ^ { P }$ .
123
+
124
+ Given light paths $\mathcal { L }$ containing both direct and indirect illumination, we render the final radiance of a ray with origin $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ and direction $\omega _ { o }$ with the following equation:
125
+
126
+ $$
127
+ L ( \boldsymbol { x } _ { 0 } , \omega _ { o } ) = \frac { 1 } { | \mathcal { L } | } \sum _ { l \in \mathcal { L } } \sum _ { m = 1 } ^ { P } \alpha _ { m } \rho _ { m } ^ { l } \tau _ { m } L _ { l } ( \boldsymbol { x } _ { m } , \omega _ { l } ) , \quad \mathrm { w h e r e } \quad \tau _ { m } = \prod _ { n = 1 } ^ { m - 1 } ( 1 - \alpha _ { n } ) ,
128
+ $$
129
+
130
+ and $L _ { l } ( \pmb { x } _ { m } , \pmb { \omega } _ { l } )$ is the radiance from light path $\imath$ arriving at point ${ \pmb x } _ { m }$
131
+
132
+ Runtime. In total, the cost of rendering a single image with $N _ { \mathrm { p i x e l } }$ pixels and $N _ { \mathrm { o b j e c t } }$ objects is $\mathcal { O } ( P ^ { 2 } K N _ { \mathrm { p i x e l } } )$ . Note that $P$ is an upper bound on number of samples that need to be evaluated. In practice, a single ray often only intersects with at most one object in the scene, which means that the proposed rendering procedure is not significantly more expensive than the single object setting. We also note that compared to NRF Bi et al. (2020a) or traditional volumetric path tracing methods, OSF crucially does not require running path tracing within each object to simulate intra-object light bounces. This is because OSF learns the object-level scattering function that directly predicts the effects after all light bounces (reflections) and occlusions (shadows) within an object have occurred. Thus OSF is significantly faster than NRF which relies on simulating intra-object light bounces while querying its learned BRDF model.
133
+
134
+ In our experiments, rendering a single image with a single OSF at a resolution of $2 5 6 \times 2 5 6$ takes roughly 3.7 seconds. While the computation cost is high, there are efforts to reduce the rendering speed of NeRF that are orthogonal to this work. For instance, KiloNeRF (Reiser et al., 2021) can easily adapted to this work by utilizing thousands of tiny MLPs instead of one single large MLP to represent each OSF to obtain 1-2 orders of magnitude speed up.
135
+
136
+ # 5 EXPERIMENTS
137
+
138
+ Datasets and evaluation metrics. We evaluate our approach on several image datasets:
139
+
140
+ • FURNITURE-SINGLE: 15 objects rendered with random object pose, point light, and viewpoint.
141
+
142
+ • FURNITURE-RANDOM: 25 dynamic scenes, each containing a random layout of multiple objects, point light, and viewpoint.
143
+ • FURNITURE-REALISTIC: Scenes containing realistic arrangements of objects in rooms.
144
+ • REAL-NRF: Real-world objects from Bi et al. (2020a), captured in a dark room under varying viewing and lighting directions.
145
+ • REAL-OUTDOOR: Real-world outdoor scenes from Mildenhall et al. (2020).
146
+
147
+ For FURNITURE datasets, we use Blender’s Cycles path tracer (Blender Foundation, 1994) to render images at $2 5 6 \times 2 5 6$ resolution for different object arrangements, camera views, and lighting configurations. We report PSNR, SSIM (Wang et al., 2003), and LPIPS (Zhang et al., 2018) metrics.
148
+
149
+ Baselines and ablations. We compare our method to the following baselines:
150
+
151
+ 1. o-NeRF: A variant of the NeRF model, but with one NeRF trained per object. When o-NeRFs are composed into scenes, they are rendered separately.
152
+ 2. $\mathbf { 0 . N e R F + S }$ : An extension of o-NeRF with inter-object shadows; reduces the light arriving at each o-NeRF by the cumulative opacity of shadowing objects along the ray from the light (§4.2).
153
+
154
+ These baselines represent what could be achieved by combining separately trained NeRFs into a scene. Of course, since o-NeRFs produce radiance fields (not scattering fields), we do not expect them to perform well in novel lighting environments or object placements.
155
+
156
+ # 5.1 NOVEL LIGHTING
157
+
158
+ In the first experiment, we investigate how OSF method handles novel lighting conditions.
159
+
160
+ We train one model per object in FURNITURESINGLE. For each object model, we train on 400 images with randomized viewpoint and lighting, and test on 20 images of novel viewpoint and lighting. As can be seen in Figure 5, our method produces more accurate appearance of the objects in comparison to oNeRF when tested on novel illumination conditions. In particular, o-NeRF fails to predict self-shadows for the couch and chair correctly. Additionally, o-NeRF fails to disentangle viewpoint versus lighting-dependent appearance, producing incorrect shadows for the couch and chair, and fails to capture the specular details of the ottoman. Quantitative results can be found in Table 1.
161
+
162
+ ![](images/9b61f34eebb13a4a67b135de352952372729b021c23f20c296231ac3433af6da.jpg)
163
+ Figure 5: Novel lighting results.
164
+
165
+ # 5.2 SCENE COMPOSITION
166
+
167
+ In a second experiment, we conduct a scene composition task on FURNITURE-RANDOM, where multiple object models are combined into scenes in random pose, lighting, and viewpoint configurations. For this task, we use the same object models trained in Section 5.1. Results are shown in Table 1 and Figure 6. While not shown in the main text, results for FURNITURE-REALISTIC can be found in Appendix B.
168
+
169
+ Table 1: Quantitative results for novel lighting (FURNITURE-SINGLE) and scene composition (FURNITURE-RANDOM). Rows denote different methods: our full model (OSF), a variant of NeRF where one NeRF is trained per object (o-NeRF), and o-NeRF with shadows $\left( { \bf { o - N e R F + S } } \right)$ ).
170
+
171
+ <table><tr><td>Dataset</td><td colspan="3">FURNITURE-SINGLE</td><td colspan="3">FURNITURE-RANDOM</td></tr><tr><td>Method</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td></tr><tr><td>0-NeRF</td><td>33.22</td><td>0.980</td><td>0.021</td><td>12.17</td><td>0.690</td><td>0.280</td></tr><tr><td>0-NERF + S</td><td></td><td></td><td></td><td>14.70</td><td>0.697</td><td>0.267</td></tr><tr><td>OSF (Our Method)</td><td>44.07</td><td>0.998</td><td>0.002</td><td>19.02</td><td>0.793</td><td>0.135</td></tr></table>
172
+
173
+ ![](images/6fd2bebddfb99194e391f1326f1944add318e88954ead332f48bd7426a5bea82.jpg)
174
+ Figure 6: Scene composition results on FURNITURE-RANDOM. The models OSF, o-NeRF, and $_ { 0 - \mathrm { N e R F } + \mathrm { ~ S ~ } }$ are explained in $\ S 5$ . Compared to o-NeRF, our model (OSF) is able to disentangle lighting-dependent and view-dependent appearance and can render shadows.
175
+
176
+ These results suggest that OSF outperforms all baselines and ablations, both quantitatively and qualitatively. As in the previous experiment (Section 5.1), we find that OSF reproduces object appearances and self-shadows more accurately than the baselines. The difference is especially apparent in the couches in scenes (a) and (b), where the couches predicted by o-NeRF are extremely dark. This is due to the fact that o-NeRF is unable to disentangle view-dependence appearance from lightdependent appearance, and simply interpolates the radiance field learned another different lighting configuration. Please note that OSF is able to model inter-object light transport effects by rendering shadows cast by one object onto another and on the ground plane. Plus, it is able to render indirect illumination of one object reflecting light onto another. For example, light reflected from the left wall causes the left of the couch and table in scenes (a) and (b) to be brighter. Neither of these lighting effects are present in the o-NeRF results.
177
+
178
+ # 5.3 REAL-WORLD SCENES
179
+
180
+ In this section we evaluate our method on real world objects and scenes from the REAL-NRF and REAL-OUTDOOR datasets. For these experiments, we train one OSF for each object in REAL-NRF and each scene in REALOUTDOOR.
181
+
182
+ Figure 7 shows a comparison between ground truth, our method (OSF), and Neural Reflectance Fields (NRF) (Bi et al., 2020a). We show that OSF recovers stronger, more accurate specular highlights compared to NRF. OSF also produces more detailed appearances (see pony logo). This comparison demonstrates the main advantage of OSF: the ability to handle complex scattering functions.
183
+
184
+ ![](images/826048519b3a9c412be8dd529a100223ecefb879955bd4c18a74c8b6f81e36fc.jpg)
185
+ Figure 7: Comparison of OSF (ours) to Neural Reflectance Fields (NRF) (Bi et al., 2020a). OSF produces stronger, more accurate specular highlights on the legs (see zoomed view) and recovers more detailed appearances (see pony logo).
186
+
187
+ For scene composition, the OSFs trained on each object are composed with a synthetic floor OSF in Figure 8 row (a). Our method is able to compute accurate shadows, such as the shadow cast by the pony onto the two other objects in the scene. The indirect reflections from the floor allow the shadowed objects to be slightly visible as shown in the “OSF” panel.
188
+
189
+ Figure 8 rows (b) and (c) show results on inserting REAL-NRF objects into real outdoor scenes (REAL-OUTDOOR). Shadows and reflections are rendered with randomized lighting directions to approximate the environment lighting. Our method accurately renders occlusions between the inserted objects and the vase in Figure 8 row (c). Due to the compositional nature of OSFs, we are able to insert the learned pinecone from Figure 8 (b) into (c).
190
+
191
+ In Figure 8, each column shows ablated versions of OSF to study the impact of computing shadows and indirect illumination with our path tracing algorithm. “No Shadows, No Indirect” represents a version of our model containing only direct illumination (without modeling inter-object lighting effects). We additionally show “No Indirect” and “Indirect Only” variants of our model which represent computing shadows and indirect illumination, respectively. As illustrated by Figure 8, our full model containing both shadows and indirect illumination effects is the most realistic. Additional results on real-world scenes, including complex shadows, can be found in Appendix A.
192
+
193
+ ![](images/6224a6f879de9a4e63c61617266d4a0c74591e17b19dbbdd9fbe529892d9da8a.jpg)
194
+ Figure 8: Real-world results. NRF (Bi et al., 2020a) and NeRF (Mildenhall et al., 2020) learn on individual static scenes or objects. In contrast, we compose real-world objects and scenes using OSFs. The objects are composed with a (a) synthetic floor and (b, c) real outdoor scenes from REALOUTDOOR. Columns show different ablated versions of our model: “No Shadows, No Indirect” which considers only direct illumination; “No Indirect” which includes both direct illumination and shadows; “Indirect Only” which considers only indirect illumination. Our OSFs show the most realistic renderings, with accurate shadows (e.g., pony shadowing the two other objects (row a) and indirect illumination (i.e., the ground and environment illuminating the objects).
195
+
196
+ # 6 DISCUSSION
197
+
198
+ We have proposed Object-Centric Neural Scattering Functions (OSFs), a method that enables composing objects captured only from photographs into photorealistic renderings of dynamic scenes. We demonstrated that decomposing a scene into implicit object functions that are view- and lightdependent enables reusabiliy of objects across scenes where objects, camera, and lighting can change. We presented a method for integrating our learned implicit functions with volumetric path tracing, and showed inter-object light transport effects such as shadow and indirect illumination for real-world objects where no computer graphics model is available. We believe our work is a step towards a graphics pipeline where real-world scenes are modeled by a composition of implicit functions to combine the flexibility of object-centric neural modeling with the photorealism of graphics rendering algorithms.
199
+
200
+ There are a few main limitations to OSF. First, the computational complexity of our method is high, but there are several works tackling the orthogonal issue of improving NeRF efficiency (as discussed in Section 4.2) that can easily be applied to OSFs. Second, while learning intra-object light transport means that intra-object path tracing is not needed, this formulation assumes that at test time, there are no occluders or light sources that intrude the object’s convex hull (Sloan et al., 2002) (e.g., a person sitting in a chair). However, OSFs can still be rendered even if their bounding boxes are intersecting, as long as this assumption is not violated. Finally, acquiring datasets of real world objects with varying point light sources and viewpoints is challenging, but we hope that in the future such acquisition of real world datasets will become easier to capture and more widely available.
201
+
202
+ # REPRODUCIBILITY STATEMENT
203
+
204
+ We describe our method (Section 4) and experimental setup (Section 5) in detail to maximize reproducibility. We will release our code upon publication to facilitate future research.
205
+
206
+ # REFERENCES
207
+
208
+ Kara-Ali Aliev, Artem Sevastopolsky, Maria Kolos, Dmitry Ulyanov, and Victor Lempitsky. Neural point-based graphics. European Conference on Computer Vision, 2020.
209
+
210
+ Bruno Arnaldi, Xavier Pueyo, and Josep Vilaplana. On the division of environments by virtual walls for radiosity computation. In Photorealistic Rendering in Computer Graphics, pp. 198–205. Springer, 1994.
211
+
212
+ Sai Bi, Zexiang Xu, Pratul Srinivasan, Ben Mildenhall, Kalyan Sunkavalli, Milos Ha ˇ san, Yannick ˇ Hold-Geoffroy, David Kriegman, and Ravi Ramamoorthi. Neural reflectance fields for appearance acquisition. arXiv preprint arXiv:2008.03824, 2020a.
213
+
214
+ Sai Bi, Zexiang Xu, Kalyan Sunkavalli, Milos Ha ˇ san, Yannick Hold-Geoffroy, David Kriegman, ˇ and Ravi Ramamoorthi. Deep reflectance volumes: Relightable reconstructions from multi-view photometric images. European Conference on Computer Vision, 2020b.
215
+
216
+ Blender Foundation. Blender - a 3d modelling and rendering package. http://www.blender. org, 1994.
217
+
218
+ Andrew Brock, Theodore Lim, James M Ritchie, and Nick Weston. Generative and discriminative voxel modeling with convolutional neural networks. arXiv preprint arXiv:1608.04236, 2016.
219
+
220
+ Oliver Cossairt, Shree Nayar, and Ravi Ramamoorthi. Light field transfer: global illumination between real and synthetic objects. ACM Transactions on Graphics, 27(3):1–6, 2008.
221
+
222
+ Frank Dellaert and Lin Yen-Chen. Neural volume rendering: Nerf and beyond. arXiv preprint arXiv:2101.05204, 2020.
223
+
224
+ Philip Dutre, Philippe Bekaert, and Kavita Bala. Advanced global illumination. CRC Press, 2018.
225
+
226
+ John Flynn, Ivan Neulander, James Philbin, and Noah Snavely. Deepstereo: Learning to predict new views from the world’s imagery. In Conference on Computer Vision and Pattern Recognition, pp. 5515–5524, 2016.
227
+
228
+ Richard Hartley and Andrew Zisserman. Multiple view geometry in computer vision. Cambridge university press, 2003.
229
+
230
+ Peter Hedman, Julien Philip, True Price, Jan-Michael Frahm, George Drettakis, and Gabriel Brostow. Deep blending for free-viewpoint image-based rendering. ACM Transactions on Graphics, 37(6):1–15, 2018.
231
+
232
+ James T Kajiya. The rendering equation. In Conference on Computer Graphics and Interactive Techniques, pp. 143–150, 1986.
233
+
234
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
235
+
236
+ Joe Kniss, Simon Premoze, Charles Hansen, Peter Shirley, and Allen McPherson. A model for volume lighting and modeling. IEEE Transactions on Visualization and Computer Graphics, 9 (2):150–162, 2003.
237
+
238
+ Marc Levoy. Efficient ray tracing of volume data. ACM Transactions on Graphics, 9(3):245–261, 1990.
239
+
240
+ Lingjie Liu, Jiatao Gu, Kyaw Zaw Lin, Tat-Seng Chua, and Christian Theobalt. Neural sparse voxel fields. Advances in Neural Information Processing Systems, 2020.
241
+
242
+ Stephen Lombardi, Tomas Simon, Jason Saragih, Gabriel Schwartz, Andreas Lehrmann, and Yaser Sheikh. Neural volumes: learning dynamic renderable volumes from images. ACM Transactions on Graphics, 38(4):1–14, 2019.
243
+
244
+ Ricardo Martin-Brualla, Rohit Pandey, Shuoran Yang, Pavel Pidlypenskyi, Jonathan Taylor, Julien Valentin, Sameh Khamis, Philip Davidson, Anastasia Tkach, Peter Lincoln, et al. Lookingood: Enhancing performance capture with real-time neural re-rendering. ACM Transactions on Graphics, 2018.
245
+
246
+ Nelson Max. Optical models for direct volume rendering. IEEE Transactions on Visualization and Computer Graphics, 1(2):99–108, 1995.
247
+
248
+ Moustafa Meshry, Dan B Goldman, Sameh Khamis, Hugues Hoppe, Rohit Pandey, Noah Snavely, and Ricardo Martin-Brualla. Neural rerendering in the wild. In Conference on Computer Vision and Pattern Recognition, pp. 6878–6887, 2019.
249
+
250
+ Ben Mildenhall, Pratul P Srinivasan, Rodrigo Ortiz-Cayon, Nima Khademi Kalantari, Ravi Ramamoorthi, Ren Ng, and Abhishek Kar. Local light field fusion: Practical view synthesis with prescriptive sampling guidelines. ACM Transactions on Graphics, 38(4):1–14, 2019.
251
+
252
+ Ben Mildenhall, Pratul P. Srinivasan, Matthew Tancik, Jonathan T. Barron, Ravi Ramamoorthi, and Ren Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. In European Conference on Computer Vision, 2020.
253
+
254
+ Gavin Miller. Efficient algorithms for local and global accessibility shading. In Conference on Computer Graphics and Interactive Techniques, pp. 319–326, 1994.
255
+
256
+ Thu Nguyen-Phuoc, Chuan Li, Lucas Theis, Christian Richardt, and Yong-Liang Yang. Hologan: Unsupervised learning of 3d representations from natural images. In International Conference on Computer Vision, pp. 7588–7597, 2019.
257
+
258
+ Thu Nguyen-Phuoc, Christian Richardt, Long Mai, Yong-Liang Yang, and Niloy Mitra. Blockgan: Learning 3d object-aware scene representations from unlabelled images. Advances in Neural Information Processing Systems, 2020.
259
+
260
+ Thu H Nguyen-Phuoc, Chuan Li, Stephen Balaban, and Yongliang Yang. Rendernet: A deep convolutional network for differentiable rendering from 3d shapes. In Advances in Neural Information Processing Systems, pp. 7891–7901, 2018.
261
+
262
+ Jan Novak, Iliyan Georgiev, Johannes Hanika, and Wojciech Jarosz. Monte carlo methods for volu- ´ metric light transport simulation. In Computer Graphics Forum, volume 37, pp. 551–576. Wiley Online Library, 2018.
263
+
264
+ Michael Oechsle, Michael Niemeyer, Lars Mescheder, Thilo Strauss, and Andreas Geiger. Learning implicit surface light fields. International Conference on 3D Vision, 2020.
265
+
266
+ Julien Philip, Michael Gharbi, Tinghui Zhou, Alexei A Efros, and George Drettakis. Multi-view ¨ relighting using a geometry-aware network. ACM Transactions on Graphics, 38(4):1–14, 2019.
267
+
268
+ Nasim Rahaman, Aristide Baratin, Devansh Arpit, Felix Draxler, Min Lin, Fred Hamprecht, Yoshua Bengio, and Aaron Courville. On the spectral bias of neural networks. In International Conference on Machine Learning, pp. 5301–5310. PMLR, 2019.
269
+
270
+ Christian Reiser, Songyou Peng, Yiyi Liao, and Andreas Geiger. Kilonerf: Speeding up neural radiance fields with thousands of tiny mlps. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 14335–14345, October 2021.
271
+
272
+ Konstantinos Rematas and Vittorio Ferrari. Neural voxel renderer: Learning an accurate and controllable rendering tool. In Conference on Computer Vision and Pattern Recognition, pp. 5417–5427, 2020.
273
+
274
+ Manolis Savva, Abhishek Kadian, Oleksandr Maksymets, Yili Zhao, Erik Wijmans, Bhavana Jain, Julian Straub, Jia Liu, Vladlen Koltun, Jitendra Malik, Devi Parikh, and Dhruv Batra. Habitat: A Platform for Embodied AI Research. In International Conference on Computer Vision, 2019.
275
+
276
+ Vincent Sitzmann, Justus Thies, Felix Heide, Matthias Nießner, Gordon Wetzstein, and Michael Zollhofer. Deepvoxels: Learning persistent 3d feature embeddings. In Conference on Computer Vision and Pattern Recognition, pp. 2437–2446, 2019a.
277
+
278
+ Vincent Sitzmann, Michael Zollhofer, and Gordon Wetzstein. Scene representation networks: Con-¨ tinuous 3d-structure-aware neural scene representations. In Advances in Neural Information Processing Systems, pp. 1121–1132, 2019b.
279
+
280
+ Peter-Pike Sloan, Jan Kautz, and John Snyder. Precomputed radiance transfer for real-time rendering in dynamic, low-frequency lighting environments. In Conference on Computer Graphics and Interactive Techniques, pp. 527–536, 2002.
281
+
282
+ Pratul P Srinivasan, Richard Tucker, Jonathan T Barron, Ravi Ramamoorthi, Ren $\mathrm { N g }$ , and Noah Snavely. Pushing the boundaries of view extrapolation with multiplane images. In Conference on Computer Vision and Pattern Recognition, pp. 175–184, 2019.
283
+
284
+ Tiancheng Sun, Jonathan T Barron, Yun-Ta Tsai, Zexiang Xu, Xueming Yu, Graham Fyffe, Christoph Rhemann, Jay Busch, Paul E Debevec, and Ravi Ramamoorthi. Single image portrait relighting. ACM Transactions on Graphics, 38(4):79–1, 2019.
285
+
286
+ Justus Thies, Michael Zollhofer, and Matthias Nießner. Deferred neural rendering: Image synthesis ¨ using neural textures. ACM Transactions on Graphics, 38(4):1–12, 2019.
287
+
288
+ Bill Triggs, Philip F McLauchlan, Richard I Hartley, and Andrew W Fitzgibbon. Bundle adjustment—a modern synthesis. In International Workshop on Vision Algorithms, pp. 298–372. Springer, 1999.
289
+
290
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pp. 5998–6008, 2017.
291
+
292
+ Zhou Wang, Eero P Simoncelli, and Alan C Bovik. Multiscale structural similarity for image quality assessment. In Asilomar Conference on Signals, Systems & Computers, 2003, volume 2, pp. 1398–1402. IEEE, 2003.
293
+
294
+ Fei Xia, William B Shen, Chengshu Li, Priya Kasimbeg, Micael Edmond Tchapmi, Alexander Toshev, Roberto Mart´ın-Mart´ın, and Silvio Savarese. Interactive gibson benchmark: A benchmark for interactive navigation in cluttered environments. IEEE Robotics and Automation Letters, 5(2): 713–720, 2020.
295
+
296
+ Zexiang Xu, Kalyan Sunkavalli, Sunil Hadap, and Ravi Ramamoorthi. Deep image-based relighting from optimal sparse samples. ACM Transactions on Graphics, 37(4):1–13, 2018.
297
+
298
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Conference on Computer Vision and Pattern recognition, pp. 586–595, 2018.
299
+
300
+ Xiuming Zhang, Sean Fanello, Yun-Ta Tsai, Tiancheng Sun, Tianfan Xue, Rohit Pandey, Sergio Orts-Escolano, Philip Davidson, Christoph Rhemann, Paul Debevec, et al. Neural light transport for relighting and view synthesis. ACM Transactions on Graphics, 2021.
301
+
302
+ Hao Zhou, Sunil Hadap, Kalyan Sunkavalli, and David W Jacobs. Deep single-image portrait relighting. In International Conference on Computer Vision, pp. 7194–7202, 2019.
303
+
304
+ Tinghui Zhou, Richard Tucker, John Flynn, Graham Fyffe, and Noah Snavely. Stereo magnification: learning view synthesis using multiplane images. ACM Transactions on Graphics, 37(4):1–12, 2018.
305
+
306
+ # A REAL-WORLD SCENE COMPOSITION
307
+
308
+ Different scene configurations of composed objects from REAL-NRF are shown in Figure 9. We show the effect of moving the light, camera, or objects. Notice how the the appearance and shadows of the objects are updated across different scene configurations. Also notice that even when parts of the palm tree object and the cartoon object are cast under the pony’s shadow, they do not appear completely dark due to the indirect illumination from the floor.
309
+
310
+ Analyzing the effect of different numbers of indirect (secondary) rays per primary sample, Figure 10 shows the result. As can be seen from the figure, the noisiness of the indirect illumination render decreases as the number of samples increase. Results in this paper contain between one and five randomly sampled secondary ray for each primary ray sample.
311
+
312
+ ![](images/996c6ff928962faa2ace740e4440799a5fd225f1f4f5cf69e5fadb423a188b9a.jpg)
313
+ Figure 9: Composing real-world objects from REAL-NRF using our OSF method. We demonstrate the effect of moving the light, camera, or objects. Note how the appearance and shadows of the objects are updated across different scene configurations. Also notice that even when parts of the palm tree object and the cartoon object are cast under the pony’s shadow, they do not appear completely dark due to the indirect illumination from the floor.
314
+
315
+ ![](images/4bc96233e783024766f216d5f6bf446967dfdae14a4213e5ea5c67c5adc5280f.jpg)
316
+ Figure 10: Visualizing the effect of different numbers of indirect (secondary) rays $( N )$ per primary sample for our OSF model (the brightness of these images has been increased only for visualization purposes). Note that the noisiness of the render decreases as $N$ increases. We find that we are able to achieve relatively non-noisy results with approximately five samples.
317
+
318
+ Single-object renderings from REAL-NRF are shown in Figure 11. The objects were captured in a dark room with a one-light-at-a-time setup. After training OSF on each object in this dataset, we are able to render the objects from novel viewpoints and lighting directions.
319
+
320
+ ![](images/bc10e31ff7c75cf65089b94716c57bdbbea0a20fce792cf26a6cbbf6e27a2617.jpg)
321
+ Figure 11: Learned OSFs on objects from REAL-NRF. The objects were captured in a dark room with a one-light-at-a-time setup. After training OSF on each object in this dataset, we are able to render the objects from novel viewpoints and lighting directions.
322
+
323
+ # B ABLATION EXPERIMENTS
324
+
325
+ ![](images/3b4157b61022d2d3c8f075161056762b9abe59507469ae48618f30c5afdad8cb.jpg)
326
+ Figure 12: Ablation results on our OSF model.
327
+
328
+ Figure 12 shows ablation results on FURNITURE-REALISTIC. We evaluate different variants of our model: “Direct Only” which considers only direct illumination; “Indirect Only” which considers only indirect illumination; “Direct $^ +$ Shadows” which includes both direct illumination and shadows. Our full model (OSF) shows the most realistic rendering, with accurate shadows and indirect illumination effects such as the left side of the couches and tables appearing brighter due to indirect lighting from the left wall. Note that the white area on the right of the images represent rays with zero density that are composited onto a white background (and therefore do not contribute indirect illumination to the scene).
329
+
330
+ ![](images/aac3b3e00f1a72e32e711f7f8082e45737aed705e332eed318b0455d108b3526.jpg)
331
+ Figure 13: Comparisons on scene composition on FURNITURE-REALISTIC. The models OSF, oNeRF, and $_ { 0 - \mathrm { N e R F } + \mathrm { ~ S ~ } }$ are explained in $\ S 5$ . Compared to o-NeRF, our model (OSF) is able to disentangle lighting-dependent appearance from view-dependent appearance for individual objects, and is able to render shadows cast by objects onto the ground correctly.
332
+
333
+ # C COMPLEX ILLUMINATION
334
+
335
+ In this experiment, we investigate how scenes composed of OSF objects can be rendered with complex illumination from an environment map.
336
+
337
+ Specifically, we apply the combination of a point light source and the environment map shown in the top-left corner of Figure 14 to light one of our scenes in FURNITURE-REALISTIC. This simulates the appearance of the scene as if the scene were inserted into a complex lighting environment, which stresses the benefits of the OSF path tracing framework.
338
+
339
+ For each OSF sample point, we project the equirectangular coordinates of the environment map into spherical coordinates, sample 20 directions on the unit sphere uniformly at random, evaluate the OSF function for each incoming direction, and integrate them outgoing radiance using Equation 5. Please note that a green-blue tint is slightly apparent in the scene rendering, due to the contribution of green and blue lighting from the environment map.
340
+
341
+ ![](images/74f46dde664bd5d47d66bf589c968aeb26ab69b2c53585a3a097ea99ebd89630.jpg)
342
+ Figure 14: Complex illumination results.
343
+
344
+ # D IMPLEMENTATION DETAILS
345
+
346
+ A flowchart of our method is shown in Figure 15.
347
+
348
+ We approximate our model $F _ { \Theta }$ with a multilayer perception (MLP) with rectified linear activations. The predicted density $\sigma$ is view-invariant, while the scattering function value $\rho$ is dependent on the incoming and outgoing light directions. We use an eight-layer MLP with 256 channels to predict $\sigma$ , and a four-layer MLP with 128 channels to predict $\rho$ . For positional encoding, we use $W = 1 0$ to encode the position $_ { \textbf { \em x } }$ and $W = 4$ to encode the incoming and outgoing directions $( \omega _ { l } , \omega _ { o } )$ , where $W$ is the highest frequency level. To avoid $\rho$ from saturating in training, we adopt a scaled sigmoid (Brock et al., 2016) defined as $S ^ { \prime } ( \pmb { \rho } ) = \delta ( S ( \pmb { \rho } ) - 0 . 5 ) + 0 . 5$ with $\delta = 1 . 2$ . We use a batch size of 4,096 rays.
349
+
350
+ ![](images/e872a846f54ec153cb399e3329f55d9c4a07e4ff95330969d2e6e7aa06fc4226.jpg)
351
+ Figure 15: Flowchart of our method. See $\ S 4$ for more details.
352
+
353
+ For synthetic datasets, we sample $N _ { c } = 6 4$ coarse samples and $N _ { f } = 1 2 8$ fine samples per ray. For real world datasets, we sample $N _ { c } = 6 4$ coarse samples and $N _ { f } = 6 4$ fine samples per ray. We use the Adam optimizer (Kingma & Ba, 2014) with a learning rate of 0.001, $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 9 9$ , and $\epsilon = 1 0 ^ { - 7 }$ .
md/dev/WaGvb7OzySA/WaGvb7OzySA.md ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning
2
+
3
+ Hung Le∗, Yue Wang∗, Akhilesh Deepak Gotmare, Silvio Savarese, Steven C.H. Hoi † Salesforce Research https://github.com/salesforce/CodeRL
4
+
5
+ # Abstract
6
+
7
+ Program synthesis or code generation aims to generate a program that satisfies a problem specification. Recent approaches using large-scale pretrained language models (LMs) have shown promising results, yet they have some critical limitations. In particular, they often follow a standard supervised fine-tuning procedure to train a code generation model from natural language problem descriptions and groundtruth programs only. Such paradigm largely ignores some important but potentially useful signals in the problem specification such as unit tests, which thus results in poor performance when solving complex unseen coding tasks. To address the limitations, we propose “CodeRL”, a new framework for program synthesis tasks through pretrained LMs and deep reinforcement learning (RL). Specifically, during training, we treat the code-generating LM as an actor network, and introduce a critic network that is trained to predict the functional correctness of generated programs and provide dense feedback signals to the actor. During inference, we introduce a new generation procedure with a critical sampling strategy that allows a model to automatically regenerate programs based on feedback from example unit tests and critic scores. For the model backbones, we extended the encoder-decoder architecture of CodeT5 with enhanced learning objectives, larger model sizes and better pretraining data. Our method not only achieves new SOTA results on the challenging APPS benchmark, but also shows strong zero-shot transfer capability with new SOTA results on the simpler MBPP benchmark.
8
+
9
+ # 1 Introduction
10
+
11
+ Considering program synthesis as a sequence-to-sequence task, pretrained language models (LMs) [Hendrycks et al., 2021, Chen et al., 2021a, Austin et al., 2021] can be adapted to receive input sequence as problem specification in natural language and generate a sequence of codes as the output program (see Figure 1, right, for an example). While these models achieve promising results, especially in basic programming tasks [Chen et al., 2021a, Austin et al., 2021], we observe that they still fail to generate codes to solve complex problems [Hendrycks et al., 2021, Li et al., 2022].
12
+
13
+ There are two main limitations. First, current models are trained using a conventional next-token prediction (NTP) objective which maximizes the next ground-truth token likelihood. As noted in NLP domains [Bengio et al., 2015, Ranzato et al., 2016], training models only with next-token prediction objective in a "teacher-forcing" manner often leads to accumulating errors during test time when tokens are generated by conditioning on previously sampled tokens, not the ground-truth tokens. This issue becomes more serious in the domain of program synthesis, where token-matching scores such as BLEU [Papineni et al., 2002, Ren et al., 2020] are more appropriate in partial program synthesis tasks (i.e. code completion) [Husain et al., 2019] but have failed to measure the functional correctness of complete programs [Hendrycks et al., 2021, Chen et al., 2021a]. Training only with NTP objective is hence, not ideal to tackle full program generation to solve programming problems.
14
+
15
+ ![](images/27377093527bcccee70444f5c61c583741dd308bf075d3364316b0d1cc0fbaee.jpg)
16
+ Figure 1: An example program synthesis task (Right): Each task is defined by a problem specification in natural language, often containing example input and output pairs. The expected output is a program to be checked for functional correctness against some unit tests. A high-level overview of our CodeRL framework for program synthesis (Left): we treat a pretrained code language model (LM) as a stochastic policy, code generations as actions, and rewards can be estimated based on the Returns unit test results of output programs from the compiler (environment).
17
+
18
+ Secondly, current models fail to utilize the potential meaningful signals from unit tests, which directly determine the model performance by the functional correctness of programs. Current approaches neglect this important signal during model optimization as well as generation procedure. During optimization, unit tests could be factored into learning objectives to match the final goal of generating semantically correct programs. During inference, since unit tests are often parts of problem description (i.e. example unit tests), they are potentially powerful to further improve output programs.
19
+
20
+ To address the above issues, we introduce “CodeRL”, a new framework to improve pretrained LMs for program synthesis tasks through reinforcement learning (see Figure 1, left). Specifically, we propose a training strategy that optimizes pretrained LMs for program synthesis tasks in an actor-critic approach [Konda and Tsitsiklis, 1999, Sutton et al., 1999]. We treat the pretrained LM as an actor network and synthetically sample sequences from this actor, including both correct and incorrect programs. These program samples are passed to a critic model which is trained as an error predictor to assess the functional correctness of these samples. We use the token-level hidden states extracted from the learned critic model to estimate the values/scores of output tokens of these synthetic samples. The actor network is then finetuned on these synthetic samples weighted by their critic scores. During inference, we introduce a new generation procedure that involves example unit tests and a critic model to filter and select sub-sequences. These sub-sequences are utilized as seeds that condition the model to resample new tokens and obtain new output programs. This approach allows the model to automatically refine output programs based on their functional correctness during test time.
21
+
22
+ We extend CodeT5 with better pretraining strategies as the foundation model for CodeRL. Our comprehensive experiments show that our models can achieve SOTA performance on the challenging APPS benchmark [Hendrycks et al., 2021]. Specifically, our models reach more than $2 \% p a s s @ I$ , $6 \% p a s s @ 5$ , and $19 \%$ pass@1000. Since our RL method is model-agnostic, we apply it to various large-scale models and achieve consistent performance gains. We further test its zero-shot transfer ability on a simpler MBPP benchmark [Austin et al., 2021], where it sets a new SOTA result of $6 3 . 0 \%$ $p a s s @ \delta { \delta { O } }$ over a finetuned GPT-137B’s $6 1 . 4 \%$ . We release the improved CodeT5-large (770M) model which outperforms many pretrained LMs of much larger sizes.
23
+
24
+ # 2 Related Work
25
+
26
+ # 2.1 Program Synthesis
27
+
28
+ Program synthesis tasks can date back as early as the early adoption of machine learning research [Waldinger and Lee, 1969, Manna and Waldinger, 1971]. Earlier tasks include problem specifications in the form of input-output (IO) examples [Summers, 1977, Gulwani et al., 2012] and synthesis methods are limited to probabilistic approaches [Liang et al., 2010] or simple programming concepts [Joulin and Mikolov, 2015, Kurach et al., 2015]. As deep learning methods became popular, later approaches adopt neural models to induce output programs, assuming an inductive bias given a large number of program samples [Parisotto et al., 2016, Balog et al., 2016, Devlin et al., 2017]. More recently, we witnessed the emergence of program synthesis tasks in which output programs are extended to general-purpose programming languages [Yin and Neubig, 2017, Xu et al., 2018, Chen et al., 2021a] and program specifications are fully described in natural English text [Hendrycks et al., 2021, Austin et al., 2021, Poesia et al., 2022]. These extensions have encouraged a rising number of applications of pretrained language models (LMs) to program synthesis to exploit the contextual representations learned from massive data of codes and natural languages [Feng et al., 2020, Clement et al., 2020, Wang et al., 2021, Wang and Komatsuzaki, 2021, Chen et al., 2022]. Recently, Nijkamp et al. [2022] proposed a conversational program synthesis approach with large pretrained language models. Despite impressive results in basic programming problems and initial commercial deployment3, existing models still perform poorly against complex problems such as those from programming competitions on Codeforces [Hendrycks et al., 2021, Li et al., 2022].
29
+
30
+ Program Synthesis in Visual Context. Another related line of research is program synthesis in computer vision domains such as images and videos. Early papers such as [Kulkarni et al., 2015, Yang et al., 2015] introduce inverse graphics networks to infer visual properties such as pose, shape, and lighting, of visual objects. Wu et al. [2017], Liu et al. [2019], Ellis et al. [2018] study the problem of image rendering, which transforms an image to structured and compact representations, i.e. scene programs. Tian et al. [2019] extends the prior work to render 3D shapes from images through shape programs, containing features to capture geometric and structural priors. Ganin et al. [2018] introduces an RL-based approach to render realistic images through high-level graphics programs. Sun et al. [2018]introduces program synthesis from demonstration synthetic videos to summarize the behaviors of the objects in the videos.
31
+
32
+ While this line of research has remarkable impacts on applications such as image/video editing, captioning, and extrapolating, these approaches are limited to programs of domain-specific languages defined for visual objects. For instance, in [Sun et al., 2018], programming language contains basic functions for object perception, action, and control flows. In our work, we focus on program synthesis from natural language problem specifications and the output programs are in generalpurpose languages such as Python. This type of programming task can range from basic programming problems to competition-level programming tasks that require a high level of problem-solving skills.
33
+
34
+ # 2.2 Reinforcement Learning for Sequence Generation
35
+
36
+ Related to the program synthesis tasks are research domains of sequence generation, in which RL approaches have demonstrated remarkable achievements. In these domains, RL approaches are used to exploit signals from non-differentiable metrics of the task at hand. Earlier work such as [Ranzato et al., 2016] adopts this strategy with REINFORCE algorithm [Williams, 1992] to directly optimize models for sequence-based test metrics such as BLEU [Papineni et al., 2002] and ROUGE [Lin, 2004] scores for translation models. In the same domain, Bahdanau et al. [2016] introduced an actor-critic framework [Sutton, 1984, Konda and Tsitsiklis, 1999]. In visual captioning domains, Rennie et al. [2017], Wang et al. [2018] proposed to use RL to optimize image captioning models using variants of CIDEr scores [Vedantam et al., 2015]. Alternatively, Ren et al. [2017] derived a new goal-oriented return estimate using visual-semantic embedding. Johnson et al. [2017], Trivedi et al. [2021] introduce program generation as an auxiliary task to learn interpretable policies in question-answering and synthetic navigation tasks.
37
+
38
+ Different from prior domains, in program synthesis, Austin et al. [2021], Chen et al. [2021a], Li et al. [2022] demonstrated very low correlation between token-based similarity metrics and functional correctness of programs. Hence, it is not trivial to define an appropriate optimization goal in this domain. We propose to exploit unit test signals, which directly exhibit the functional correctness of programs, during both - model optimization and test-time generation stages. More related to our work are RL-based program synthesis [Guu et al., 2017, Bunel et al., 2018, Liang et al., 2018, Zhong et al., 2018] and execution-guided synthesis approaches [Ellis et al., 2019, Chen et al., 2021b]. However, these are limited to programming languages defined within a specific application domain only.
39
+
40
+ ![](images/708195a217341c1a3ccc3f72ec2477c460e84174a4b4720ba16ee4acbe495bdc.jpg)
41
+ Figure 2: Overview of our actor-critic framework to optimize pretrained LMs for program synthesis: We treat the LM as an actor network and sample synthetic samples from this actor. Another neural network is trained as a critic model to evaluate these synthetic samples based on their probabilities of passing unit tests. The returns are estimated based on critic scores and finally factored into the learning objective $\mathcal { L } _ { r l }$ to finetune the actor LM network using synthetic samples.
42
+
43
+ # 3 CodeRL
44
+
45
+ # 3.1 Program Synthesis Task
46
+
47
+ Following a sequence-to-sequence approach, the program synthesis task contains a problem description as an input sequence $D$ and an output sequence of program $\hat { W } = ( \hat { w } _ { 1 } , . . . , \hat { w } _ { T } ) , \hat { w } _ { t } \in \mathcal { V } ^ { 4 }$ that can solve the problem. The output at each decoding step $t$ is a distribution over the vocabulary $\nu$ , computed by the softmax function $\hat { w } _ { t } \sim \mathrm { s o f t m a x } ( \operatorname { L i n e a r } ( s _ { t } ) )$ where $s _ { t }$ is the contextual hidden state at decoding step $t$ . Conventionally, during train time, model parameters, $\theta$ , are learned by maximizing the likelihood of the ground-truth reference programs. Denoting $W = ( w _ { 1 } , . . . w _ { T } )$ as the ground-truth program, the objective is to minimize the cross-entropy loss:
48
+
49
+ $$
50
+ \mathcal { L } _ { c e } ( \theta ) = - \sum _ { t } \log p _ { \theta } ( W | D ) = - \sum _ { t } \log [ p _ { \theta } ( w _ { t } | w _ { 1 : t - 1 } , D ) ]
51
+ $$
52
+
53
+ where the conditional probability $p _ { \theta }$ is parameterized following the above softmax function. During test time, models generate sequences of programs by autoregressively sampling token $\hat { w } _ { t }$ from the distribution $p _ { \theta } \big ( . | \hat { w } _ { 1 : t - 1 } , D \big )$ . Models are evaluated against unit tests corresponding to the problem. Each test includes a pair of input and ground-truth output. In real-world program synthesis tasks [Hendrycks et al., 2021], example unit tests are often given as parts of the problem specification.
54
+
55
+ # 3.2 Pretraining Language Models on Code
56
+
57
+ We adopt Transformer models as the backbone of our program synthesis systems. Specifically, this paper extends the CodeT5 model [Wang et al., 2021] as a foundation model for CodeRL.
58
+
59
+ CodeT5. CodeT5 [Wang et al., 2021] is a multi-lingual code-aware language model pretrained on large-scale source code corpora curated from Github. With a unified encoder-decoder architecture, CodeT5 achieves state-of-the-art performance in a wide range of code intelligence tasks in the CodeXGLUE benchmark [Lu et al., 2021] including both code understanding and generation tasks.
60
+
61
+ Improving Pretraining Data. We enlarge the Python pretraining dataset using the recently released large-scale Github Code dataset5. We have compiled public, non-personal information from GitHub consisting of permissively licensed Python code (“mit”, “apache-2”, “bsd-3-clause”, “bsd-2- 126 clause”, “cc0-1.0”, “unlicense”, “isc”). The resulting Python dataset (GCPY) has 10.5B tokens and is 10x larger than the CodeSearchNet (CSN) corpus [Husain et al., 2019] used in the original CodeT5 [Wang et al., 2021].
62
+
63
+ Improving Pretraining Objective. While pretraining tasks in CodeT5 like masked span prediction (MSP) benefit code understanding tasks, they have a large discrepancy with program synthesis objectives. To mitigate this gap, we introduce a pretraining task of next-token prediction (NTP) into CodeT5. Specifically, we uniformly sample a pivot location for each code sample, then pass the content preceding the pivot to the encoder and the remaining to the decoder. To control the length of input and output sequences, we restrict the pivot within $10 \%$ to $90 \%$ of the original sequence.
64
+
65
+ # 3.3 Program Synthesis as an RL Problem
66
+
67
+ We propose to formulate the Program Synthesis as an RL problem and apply an actor-critic RL approach to improve the performance of a pretrained LM by exploiting the unit test signals in both model optimization (see Figure 2) and generation procedure (see Figure 3).
68
+
69
+ More formally, we can view the learned parameters of an LM model, $\theta$ as a stochastic policy, which decides an action as the prediction of each token. Following each action, an LM model updates its hidden state representations which are used by the policy to determine the next action in the next decoding step. At the end of the generation episode (i.e. an <endoftext> token is observed), the LM model receives a return $r$ measured by the functional correctness of the generated program. The goal of RL finetuning is to minimize the expected return:
70
+
71
+ $$
72
+ \mathcal { L } _ { r l } ( \theta ) = - \mathbb { E } _ { W ^ { s } \sim p _ { \theta } } [ r ( W ^ { s } ) ]
73
+ $$
74
+
75
+ where $W ^ { s } = ( w _ { 1 } ^ { s } , . . . , w _ { T } ^ { s } )$ is a synthetic sample in which each token $w _ { t } ^ { s }$ is sampled by the LM model at decoding time step $t$ . Following the REINFORCE algorithm [Williams, 1992, Sutton and Barto, 2018] and policy gradient theorem [Sutton et al., 1999] we can define an estimate of the gradient $\nabla _ { \boldsymbol { \theta } } L ( \boldsymbol { \theta } )$ of the non-differentiable return $r$ as:
76
+
77
+ $$
78
+ \begin{array} { r l } & { \nabla _ { \theta } \mathcal { L } _ { r l } ( \theta ) \approx - \mathbb { E } _ { W ^ { s } \sim p _ { \theta } } [ r ( W ^ { s } ) \nabla _ { \theta } \log p _ { \theta } ( W ^ { s } | D ) ] } \\ & { \qquad \approx - \mathbb { E } _ { W ^ { s } \sim p _ { \theta } } [ r ( W ^ { s } ) \displaystyle \sum _ { t } \nabla _ { \theta } \log p _ { \theta } ( w _ { t } ^ { s } | w _ { 1 : t - 1 } ^ { s } , D ) ] } \end{array}
79
+ $$
80
+
81
+ Defining Return by Unit Test Signals. For each sample sequence $W ^ { s }$ , the return $r$ can be defined heuristically by checking its functional correctness. We pass generated programs together with the corresponding unit tests to a compiler. From the outputs of the tests, we can determine the return $r$ :
82
+
83
+ $$
84
+ r ( W ^ { s } ) = \left\{ \begin{array} { l l } { { - 1 . 0 ~ } } & { { , ~ \mathrm { i f } ~ W ^ { s } ~ \mathrm { c a n n o t ~ b e ~ c o m p i l e d ~ ( i . e . ~ c o m p i l e ~ e r r o r ) } } } \\ { { - 0 . 6 ~ } } & { { , ~ \mathrm { i f } ~ W ^ { s } ~ \mathrm { c a n n o t ~ b e ~ e x e c u t e d ~ w i t h ~ u n i t ~ t e s t s ~ ( i . e . ~ r u r ~ } ) } } \\ { { - 0 . 3 ~ } } & { { , ~ \mathrm { i f } ~ W ^ { s } ~ \mathrm { f a i l e d ~ a n y ~ u n i t ~ t e s t } } } \\ { { + 1 . 0 ~ } } & { { , ~ \mathrm { i f } ~ W ^ { s } ~ \mathrm { p a s s e d ~ a l l ~ u n i t ~ t e s t s } } } \end{array} \right.
85
+ $$
86
+
87
+ However, in related domains such as text-to-SQL research [Zhong et al., 2018, Xu et al., 2018], we note that this approach to estimate returns can lead to an unstable training process with high variance of the gradient estimate following Eq. (3) with mini-batches in training.
88
+
89
+ Return with a Baseline. In order to alleviate this variance, we adopt a “baseline” [Sutton and Barto, 2018]. Specifically, we use a greedy decoding strategy as a baseline and any generated samples that outperform this baseline are given positive return estimation, and negative return estimation otherwise. This relative normalization technique allows models to explore imperfect programs, as long as their returns are better than the baseline’s. Given a training sample, we denote the return of the baseline $r ( W ^ { b } )$ and the expected gradient is computed as:
90
+
91
+ $$
92
+ \nabla _ { \theta } \mathcal { L } _ { r l } ( \theta ) \approx - \mathbb { E } _ { W ^ { s } \sim p _ { \theta } } [ ( r ( W ^ { s } ) - r ( W ^ { b } ) ) \sum _ { t } \nabla _ { \theta } \log p _ { \theta } ( w _ { t } ^ { s } | w _ { 1 : t - 1 } ^ { s } , D ) ]
93
+ $$
94
+
95
+ Note that at each decoding step $t$ , our greedy decoding baseline is independent from the action $w _ { t } ^ { s }$ and hence, the expected gradient term $\nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { r l } ( \boldsymbol { \theta } )$ from Eq. (3) remains the same in Eq. (8).
96
+
97
+ Intermediate Return by Critic as Error Predictor. We observe that the above gradient estimate is only based on a final return at the end of the decoding process. However, programs often follow fixed syntactical rules in which a single token such as an additional white-space character can render a program erroneous. Therefore, Eq. (8) becomes too restrictive. A straightforward solution is to use token-based similarity scores [Papineni et al., 2002, Ren et al., 2020]) between each subsequence $W _ { 1 : t } ^ { s }$ and the ground truth. However, code matching is not an ideal return measure due to its poor correlation with program correctness [Hendrycks et al., 2021, Chen et al., 2021a, Austin et al., 2021] which can only be measured against fully complete programs. Alternatively, we introduce a critic model (see Appendix ?? for an overview). The critic model is parameterized as a neural network with parameters $\phi$ that receives inputs as the problem description $D$ and a sampled program $W ^ { s } = \{ w _ { 1 } ^ { s } , \ldots , w _ { T } ^ { s } \}$ . The critic is trained to infer the unit test outcome; one of {CompileError, RuntimeError, FailedTest, PassedTest $\}$ as described in the return definitions in Eq. (4) to (7). The training objective of the critic $\phi$ can be expressed as:
98
+
99
+ ![](images/95bc46fb4bdc808437fe8493b034501185ca44b8a1c1d46ac990df754aae0fd0.jpg)
100
+ Figure 3: Overview of our Critic Sampling (CS) approach: (1) For each test problem, we first use finetuned LM to generate a set of solution programs. (2) From the problem description, we extract example unit tests and test against generated solutions. (3) If there are any passed solutions, we pass them to the critic model to sample sub-sequences. (4) The sub-sequences from (3) are used as seed sequences to condition the LM to regenerate solution programs, repeating the steps from (1) onward.
101
+
102
+ $$
103
+ \mathcal { L } _ { c r i t i c } ( \phi ) = - \log p _ { \phi } ( u | W ^ { s } , D )
104
+ $$
105
+
106
+ where $u$ denotes the ground-truth unit test outcome given by the compiler. We use Transformer models of smaller sizes than the actor model as the base architecture for the critic model. The contextual hidden states of the program tokens $( h _ { 1 } , \ldots , h _ { T } )$ obtained from the critic model decoder are max-pooled along the sequence length dimension $h ^ { \mathrm { p o o l } } = \operatorname { P o o l i n g } ( h _ { 1 } , \dots , h _ { T } )$ . The critic’s prediction on the unit test outcome is computed as $\hat { u } = \mathrm { s o f t m a x } ( \mathrm { L i n e a r } ( h ^ { \mathrm { p o o l } } ) )$ .
107
+
108
+ Given a learned critic, we use the probability distribution $\hat { v } _ { t } = \mathrm { s o f t m a x } ( \mathrm { L i n e a r } ( h _ { t } ) )$ to estimate the token-level value $\hat { q }$ of $w _ { t } ^ { s }$ in relation to the ground-truth unit test output (note that we use the token level contextual representation $h _ { t }$ here, before the pooling operation). Specifically, $\hat { q } _ { \phi } ( w _ { t } ^ { s } ) = \hat { v } _ { t } [ u ]$ where $\hat { v } [ . ]$ denotes the probability of a specific unit test outcome from the four possible ones. We use this estimate to train the actor LM model with intermediate returns:
109
+
110
+ $$
111
+ \nabla _ { \theta } \mathcal { L } _ { r l } ( \theta ) \approx - \mathbb { E } _ { W ^ { s } \sim p _ { \theta } } [ ( r ( W ^ { s } ) - r ( W ^ { b } ) ) \sum _ { t } \hat { q } _ { \phi } ( w _ { t } ^ { s } ) \nabla _ { \theta } \log p _ { \theta } ( w _ { t } ^ { s } | w _ { 1 : t - 1 } ^ { s } , D ) ]
112
+ $$
113
+
114
+ Generating Programs with Example Unit Tests and Critic. We leverage the unit tests provided in the input problem description to improve the generation procedure during inference too (see Figure 3 for an overview and Appendix ?? for step-by-step explanation). For each problem, we generate $N$ programs, out of which we only select programs that pass example tests (leading to a set $\mathcal { F }$ ) and filter out the rest. To improve sample quality, we perform another round of generation where we use sub-sequences from these filtered samples as prompts (or “seed” sequences) to the actor LM. We employ a separate critic model $( \phi _ { \mathrm { t e s t } } )$ to guide our choice of sub-sequences from these filtered samples. This critic model is trained with a similar objective as Eq. (9), but in a binary classification setup with $\{ \mathrm { F a i l e d T e s t } , \mathrm { P a s s e d T e s t } \}$ labels.
115
+
116
+ Let $W ^ { \mathrm { f i l t e r } } = \{ w _ { 1 } , . . . , w _ { T } \}$ denote a generated sample that passes the example unit tests. We use the critic model to assign a value to each token $\hat { q } _ { \phi _ { \mathrm { t e s t } } } ( w _ { t } ) = p _ { \phi _ { \mathrm { t e s t } } } ( \hat { u } = \mathrm { P a s s e d T e s t } | w _ { 1 : t } , D )$ corresponding to the critic’s predicted probability of the sub-sequence till $t$ passing the unit tests. We split the sequence at position $t _ { \mathrm { m a x } }$ corresponding to the highest critic assigned value and use the left split as the seed for the next stage. If this seed sequence till $t _ { \mathrm { m a x } }$ contains a token with $p _ { \phi _ { \mathrm { t e s t } } } ( \mathrm { F a i l \bar { e } d T e s t } ) > p _ { \phi _ { \mathrm { t e s t } } } ($ (PassedTest), we further chop it at this token by removing tokens on the right. This is done to pick prompts that are likely to generate successful programs in the next round.
117
+
118
+ We use these seeds to initialize and condition the (actor) LM to resample new tokens till we encounter the <endoftext> token. In this round, each seed sequence can be stacked $N / | \mathcal { F } |$ times for upsampling. This results in the same number of output programs $N$ . We call this generation procedure “Critic Sampling” (CS). We use mini-batch generating to improve efficiency during inference and employ nucleus sampling with a batch size of $N = 2 0 0$ . While we do incur additional costs to re-sample using the seed sequences, we are only required to generate partial programs in the re-generation stage, making this stage less expensive than conventional generating procedures.
119
+
120
+ # 4 Experiments
121
+
122
+ # 4.1 Experimental Setups and Datasets
123
+
124
+ Pretraining Setup. We pretrain a CodeT5-large model (770M) from scratch following T5-large’s architecture [Raffel et al., 2020]. We follow the pretraining setups in CodeT5 [Wang et al., 2021] with the modifications as proposed in $\ S 3 . 2$ . We evaluate this new pretrained CodeT5 model on CodeXGLUE [Lu et al., 2021] and achieve new SOTA results (see Appendix ??).
125
+
126
+ APPS Benchmark. We choose the challenging APPS program synthesis benchmark [Hendrycks et al., 2021], as it has large coding problems of varying difficulties collected from multiple coding websites. It includes training and test splits, each of which has 5000 samples of programming tasks with diverse levels of difficulty, including “Introductory”, “Interview”, and “Competition” levels. Each sample includes 20 unit tests on average to validate the functional correctness of programs.
127
+
128
+ Finetuning Setup. Due to the potential large number of trajectories (i.e. $\mathcal { V } ^ { T }$ ) to generate a sequence and the unstable feedback loop between actor and critic [Lillicrap et al., 2015, Wang et al., 2018], we applied imitation learning to first warm-start a pretrained LM model with $\mathcal { L } _ { c e }$ only for up to 10 epochs. We then sampled sequences of programs from this actor network to train the critic while keeping the parameters of the actor network frozen. For experiments with CodeT5 actor models, we use the CodeT5-small architecture for the critic model, and GPT2-small critic architecture when the actor models are GPT variants. After training the critic, we then apply both $\mathcal { L } _ { c e }$ and $\mathcal { L } _ { r l }$ with equal weights to finetune the actor network.
129
+
130
+ Evaluation. We follow [Hendrycks et al., 2021, Chen et al., 2021a] and evaluate the models using the pass $@ k$ metric, which is the percentage of problems solved by using $k$ generated programs per problem. We also follow Li et al. [2022] and use $n @ k$ metric which only considers a subset of $n$ candidates from $k$ generated programs per problem. The subset of $n$ candidates are typically selected by a filtering method by passing generated programs through example tests given as part of the problem description [Chen et al., 2021a, Li et al., 2022].
131
+
132
+ For more details of the experimental setup, please refer to Appendix ??.
133
+
134
+ # 4.2 Experimental Results on APPS
135
+
136
+ Baselines. As reported by Hendrycks et al. [2021], we compared our models with several baselines, including GPT2 [Radford et al., 2019], GPT-Neo [Black et al.], and GPT3 [Brown et al., 2020]. We also compare the results with Codex [Chen et al., 2021a] and AlphaCode [Li et al., 2022]. Note that by default, results of pretrained LMs (except for Codex and GPT3) are from models finetuned on APPS using the standard loss $\mathcal { L } _ { c e }$ only. In our ablations, since CodeRL is model-agnostic, we can also integrate it with GPT variants such as GPT-J [Wang and Komatsuzaki, 2021] and GPT-Neo.
137
+
138
+ Overall Results. Firstly, Table 1a shows that the CodeRL with the CodeT5 model can achieve significant performance gains, outperforming many pretrained LMs of much larger sizes. Specifically, our approach achieved new SOTA results of $2 . 5 7 \% p a s s @ { I }$ , $6 . 2 1 \%$ pass@5, and $1 9 . 3 6 \%$ pass@1000. Table 1b shows that when evaluating on a subset of filtered code samples, our CodeRL $^ +$ CodeT5 can achieve SOTA results of $7 . 8 3 \%$ $\mathrm { \Omega } _ { l \ @ k }$ and $1 1 . 6 1 \%$ $5 @ k$ . Note that while CodeRL incurs additional computation cost during inference with CS, our approach only requires much lower $k$ to achieve comparable performance with other models. Specifically, with $k = 1 0 0 0$ only, our model performance is as good as AlphaCode with a much larger generation budget of $k = 5 0 0 0 0$ .
139
+
140
+ Table 1: Results on APPS: Overall, CodeRL can bring the performance gains on CodeT5 models and achieves new SOTA on both pass $@ k$ and $n @ k$ metrics. “Intro”: introductory, “Inter”: interview, “Comp”: competition-level tasks.
141
+ (a) Performance by pass $@ k$ with $k = \{ 1 , 5 , 1 0 0 0 \}$
142
+
143
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Size</td><td colspan="4">pass@1</td><td colspan="4">pass@5</td><td colspan="4">pass@1000</td></tr><tr><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td>Codex</td><td>12B</td><td>4.14</td><td>0.14</td><td>0.02</td><td>0.92</td><td>9.65</td><td>0.51</td><td>0.09</td><td>2.25</td><td>25.02</td><td>3.70</td><td>3.23</td><td>7.87</td></tr><tr><td>AlphaCode</td><td>1B</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td><td>17.67</td><td>5.24</td><td>7.06</td><td>8.09</td></tr><tr><td>GPT3</td><td>175B</td><td>0.20</td><td>0.03</td><td>0.00</td><td>0.06</td><td>-</td><td>1</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td><td>1</td></tr><tr><td>GPT2</td><td>0.1B</td><td>1.00</td><td>0.33</td><td>0.00</td><td>0.40</td><td>2.70</td><td>0.73</td><td>0.00</td><td>1.02</td><td>-</td><td>1</td><td>-</td><td>1</td></tr><tr><td>GPT2</td><td>1.5B</td><td>1.30</td><td>0.70</td><td>0.00</td><td>0.68</td><td>3.60</td><td>1.03</td><td>0.00</td><td>1.34</td><td>25.00</td><td>9.27</td><td>8.80</td><td>12.32</td></tr><tr><td>GPT-Neo</td><td>2.7B</td><td>3.90</td><td>0.57</td><td>0.00</td><td>1.12</td><td>5.50</td><td>0.80</td><td>0.00</td><td>1.58</td><td>27.90</td><td>9.83</td><td>11.40</td><td>13.76</td></tr><tr><td>GPT-J</td><td>6B</td><td>5.60</td><td>1.00</td><td>0.50</td><td>1.82</td><td>9.20</td><td>1.73</td><td>1.00</td><td>3.08</td><td>35.20</td><td>13.15</td><td>13.51</td><td>17.63</td></tr><tr><td>CodeRL+CodeT5</td><td>770M</td><td>6.77</td><td>1.80</td><td>0.69</td><td>2.57</td><td>15.27</td><td>4.48</td><td>2.36</td><td>6.21</td><td>38.10</td><td>14.33</td><td>15.70</td><td>19.36</td></tr></table>
144
+
145
+ (b) Performance by $n @ k$ with $k$ up to 50000 and $n = \{ 1 , 5 \}$
146
+
147
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Size</td><td rowspan="2">k</td><td colspan="4">1@k</td><td colspan="4">5@k</td></tr><tr><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td>Codex</td><td>12B</td><td>1000</td><td>22.78</td><td>2.64</td><td>3.04</td><td>6.75</td><td>24.52</td><td>3.23</td><td>3.08</td><td>7.46</td></tr><tr><td>AlphaCode</td><td>1B</td><td>1000</td><td>-</td><td>=</td><td>=</td><td>-</td><td>14.36</td><td>5.63</td><td>4.58</td><td>7.17</td></tr><tr><td>AlphaCode</td><td>1B</td><td>10000</td><td>■</td><td>-</td><td>■</td><td>-</td><td>18.18</td><td>8.21</td><td>6.65</td><td>9.89</td></tr><tr><td>AlphaCode</td><td>1B</td><td>50000</td><td>-</td><td>-</td><td>-</td><td>-</td><td>20.36</td><td>9.66</td><td>7.75</td><td>11.42</td></tr><tr><td>CodeRL+CodeT5</td><td>770M</td><td>1000</td><td>16.52</td><td>6.16</td><td>4.15</td><td>7.83</td><td>24.49</td><td>8.58</td><td>7.82</td><td>11.61</td></tr></table>
148
+
149
+ Table 2: Ablation results with variants of return estimates: CodeT5 model that is trained with return estimates using a baseline $( W _ { b } )$ and a critic-based return estimates $( { \hat { q } } _ { \theta } )$ can achieve the best performance. “dist.” indicates a rule-based approach that estimates returns following a linear decay by token positions from $t = 1$ to $t = T$ .
150
+
151
+ <table><tr><td rowspan="2">#</td><td rowspan="2">W</td><td rowspan="2">q</td><td colspan="4">pass@1</td><td colspan="4">pass@5</td></tr><tr><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td>A</td><td>√</td><td>-</td><td>4.60</td><td>1.10</td><td>0.20</td><td>1.62</td><td>7.10</td><td>1.57</td><td>0.40</td><td>2.44</td></tr><tr><td>B</td><td>-</td><td>√</td><td>4.00</td><td>0.87</td><td>0.20</td><td>1.36</td><td>5.60</td><td>1.30</td><td>0.20</td><td>1.94</td></tr><tr><td>C</td><td>√</td><td>dist.</td><td>4.90</td><td>1.03</td><td>0.20</td><td>1.64</td><td>7.80</td><td>1.60</td><td>0.30</td><td>2.58</td></tr><tr><td>D</td><td>√</td><td>√</td><td>6.20</td><td>1.50</td><td>0.30</td><td>2.20</td><td>9.39</td><td>1.90</td><td>0.42</td><td>3.10</td></tr></table>
152
+
153
+ # 4.3 Ablation Studies
154
+
155
+ In this section, for a fair comparison between variants of return estimates and learning objectives, we report the results of $p a s s @ k$ where $k = \{ 1 , 5 \}$ with beam search decoding. For larger $k$ , we report the results with and without the CS procedure.
156
+
157
+ Impacts of Return Estimates. Table 2 show the results of CodeT5-770M trained by different approaches to estimate returns of code samples. Overall, we report that the CodeRL objective with relative token-level return estimates by our critic model (Model D) can achieve the best performance on pass $@ l$ and pass $\textcircled { a } 5$ . Secondly, we note that using absolute returns without a baseline (Model B) could lead to the most performance drop, as this approach heavily penalizes all incorrect samples (even though they might still be better than a naive baseline). Thirdly, without a critic model, simply assigning identical rewards to all tokens in a code sample (Model A) is disadvantageous as these return estimates are too restrictive to be used as feedback signals for RL training. Finally, we experimented with a distance-based critic which assumes that token values decay linearly from $t = 1$ to $t = T$ (Model C). The lower performance suggests the benefit of training a critic network to compute the returns rather than relying on rule-based approaches.
158
+
159
+ Impacts of Learning Objectives. Table 3 shows the results with different combinations of $\mathcal { L } _ { c e }$ and $\mathcal { L } _ { r l }$ . We experiment with using only $\mathcal { L } _ { r l }$ and note the problem of vanishing gradients during finetuning [Ranzato et al., 2016, Bahdanau et al., 2016]. Secondly, we note that by using only $\mathcal { L } _ { c e }$ for further finetuning, despite improvement in losses during training time, the model performance indeed degrades during test time. We expect these models are overfitting to the training data. Interestingly, a naive approach of $\mathcal { L } _ { c e }$ with synthetic samples $W ^ { s }$ , all of which are treated as correct codes with $r ( W ^ { s } ) = \bar { 1 }$ , still leads to some performance improvement with GPT-Neo on $p a s s @ \bar { s }$ (but not in other cases). Finally, we found that using both $\mathcal { L } _ { c e }$ and $\mathcal { L } _ { r l }$ results in a more consistent performance improvement overall on pass $@ l$ and pass $\textcircled { a } 5$ for the GPT-Neo and CodeT5 models.
160
+
161
+ Table 3: Ablation results with different learning objectives: We experiment with both CodeT5 and GPT-Neo with different combinations of cross-entropy loss $\mathcal { L } _ { c e }$ and reinforcement learning loss $\mathcal { L } _ { r l }$ . Note that these losses are applied on models that are already warm-started with conventional cross-entropy losses for up to 10 epochs.
162
+
163
+ <table><tr><td rowspan="2">Lce</td><td rowspan="2">Lrl</td><td colspan="4">pass@1</td><td colspan="4">pass@5</td></tr><tr><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td colspan="9">GPT-Neo</td></tr><tr><td></td><td>=</td><td>3.90</td><td>0.57</td><td>0.00</td><td>1.12</td><td>5.50</td><td>0.80</td><td>0.00</td><td>1.58</td></tr><tr><td></td><td>=</td><td>2.70</td><td>0.90</td><td>0.10</td><td>1.10</td><td>5.00</td><td>1.43</td><td>0.30</td><td>1.92</td></tr><tr><td>√(+Ws)</td><td>-</td><td>2.90</td><td>0.80</td><td>0.30</td><td>1.12</td><td>5.20</td><td>1.57</td><td>0.40</td><td>2.06</td></tr><tr><td></td><td>√</td><td>3.30</td><td>0.80</td><td>0.20</td><td>1.18</td><td>5.30</td><td>1.57</td><td>0.20</td><td>2.04</td></tr><tr><td></td><td>√</td><td>4.70</td><td>0.73</td><td>0.30</td><td>1.44</td><td>6.58</td><td>1.54</td><td>0.18</td><td>2.28</td></tr><tr><td colspan="10">CodeT5-770M</td></tr><tr><td></td><td>=</td><td>6.60</td><td>1.03</td><td>0.30</td><td>2.00</td><td>8.80</td><td>1.67</td><td>0.70</td><td>2.90</td></tr><tr><td>√</td><td>=</td><td>4.60</td><td>0.93</td><td>0.10</td><td>1.50</td><td>7.00</td><td>1.37</td><td>0.20</td><td>2.26</td></tr><tr><td>√(+Ws)</td><td>-</td><td>5.10</td><td>1.10</td><td>0.40</td><td>1.76</td><td>8.30</td><td>1.43</td><td>0.70</td><td>2.66</td></tr><tr><td></td><td>1</td><td>5.00</td><td>0.90</td><td>0.50</td><td>1.64</td><td>7.60</td><td>1.53</td><td>0.60</td><td>2.56</td></tr><tr><td>√</td><td></td><td>6.20</td><td>1.50</td><td>0.30</td><td>2.20</td><td>9.39</td><td>1.90</td><td>0.42</td><td>3.10</td></tr></table>
164
+
165
+ Table 4: Ablation results of Critic Sampling (CS): Overall, using CS can lead to higher passing rates as program generations are conditioned on seed sequences filtered by their test results.
166
+
167
+ <table><tr><td>Metric</td><td>Approach</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td rowspan="2">pass@200</td><td>without CS</td><td>26.79</td><td>8.73</td><td>7.60</td><td>12.12</td></tr><tr><td>with CS</td><td>29.10</td><td>9.67</td><td>9.50</td><td>13.52</td></tr><tr><td rowspan="2">pass@1000</td><td>without CS</td><td>35.30</td><td>13.33</td><td>13.60</td><td>17.78</td></tr><tr><td>with CS</td><td>38.10</td><td>14.33</td><td>15.70</td><td>19.36</td></tr><tr><td rowspan="2">1@1000</td><td>without CS</td><td>16.27</td><td>6.00</td><td>4.27</td><td>7.71</td></tr><tr><td>with CS</td><td>16.52</td><td>6.16</td><td>4.15</td><td>7.83</td></tr></table>
168
+
169
+ Impact of Critic Sampling . Table 4 shows the ablation results of critical sampling (CS) during inference. Overall, we found positive impact of CS for improving pass $@ 2 0 0$ and pass@1000 metrics. In addition, the positive impacts of critic sampling on pass $@ l$ and pass $\textcircled { a } 5$ are indicated by comparing the results of Table 1a and Table 2 (row D, in which we only used conventional beam search decoding without critic sampling). We can observe that, using critic sampling, model performance increases from $2 . 2 \%$ pass@1 $( 3 . 1 \% p a s s @ 5 )$ to $2 . 5 7 \%$ pass $@ l$ $( 6 . 2 1 \% p a s s @ 5 )$ . Interestingly, from Table 4, we observe that CS does not provide a significant gain on the $n @ k$ metric. Note that $n @ k$ measures the solving rate among the subset $\mathcal { F }$ filtered from $k$ samples. As CS will technically increase the size of this subset, the $n @ k$ metric will consider an exponentially larger number of options of $n$ samples than before. This will normalize $n @ k$ by a larger pool of $n$ candidate set, resulting in less impact of CodeRL on the results. We recommend additional post-processing steps such as candidate ranking [Cobbe et al., 2021] to improve the $n @ k$ performance.
170
+
171
+ Impacts of Pretraining Approaches for CodeT5. Table 5 reports the results of CodeT5 with different configurations of model sizes, pretraining data, and pretraining objectives. For a fair comparison, all models are only finetuned with $\mathcal { L } _ { c e }$ on APPS. As observed in prior work [Chen et al., 2021a, Austin et al., 2021], scaling up the number of model parameters or the size of the pretraining data can significantly improve the model performance of downstream synthesis tasks. We also find that enhancing the pretraining objectives with next token prediction (NTP) is vital for generation tasks, surpassing just masked span prediction (MSP) from the original CodeT5.
172
+
173
+ # 4.4 Zero-shot Evaluation on MBPP Benchmark
174
+
175
+ Finally, we test the zero-shot transfer ability of CodeRL on another smaller and simpler program synthesis benchmark MBPP [Austin et al., 2021].
176
+
177
+ Table 5: Ablation results of CodeT5 pretrained model variants: We report the results of models pretrained on different configurations by model size, pretraining data, and pretraining task. CSN: CodeSearchNet, GCPY: Github Code Python, MSP: Masked Span Predition, NTP: Next Token Prediction. For a fair comparison, all models are finetuned only with $\mathcal { L } _ { c e }$ on APPS.
178
+
179
+ <table><tr><td rowspan="2">Size</td><td rowspan="2">Data</td><td rowspan="2">Task</td><td colspan="4">pass@1</td><td colspan="4">pass@5</td></tr><tr><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td><td>Intro</td><td>Inter</td><td>Comp</td><td>All</td></tr><tr><td>60M</td><td>CSN</td><td>MSP</td><td>1.40</td><td>0.67</td><td>0.00</td><td>0.68</td><td>2.60</td><td>0.87</td><td>0.10</td><td>1.06</td></tr><tr><td>220M</td><td>CSN</td><td>MSP</td><td>2.50</td><td>0.73</td><td>0.00</td><td>0.94</td><td>3.30</td><td>1.10</td><td>0.10</td><td>1.34</td></tr><tr><td>770M</td><td>CSN</td><td>MSP</td><td>3.60</td><td>0.90</td><td>0.20</td><td>1.30</td><td>4.30</td><td>1.37</td><td>0.20</td><td>1.72</td></tr><tr><td>770M</td><td>+GCPY</td><td>MSP</td><td>4.30</td><td>1.10</td><td>0.20</td><td>1.56</td><td>5.60</td><td>1.47</td><td>0.30</td><td>2.06</td></tr><tr><td>770M</td><td>+GCPY</td><td>+NTP</td><td>6.60</td><td>1.03</td><td>0.30</td><td>2.00</td><td>8.80</td><td>1.67</td><td>0.70</td><td>2.90</td></tr></table>
180
+
181
+ Table 6 reports the results of our CodeRL $^ +$ CodeT5 on MBPP benchmark compared with finetuned GPT models of up to 137B size. Our CodeRL $^ +$ CodeT5 (ZS) was trained on APPS and then evaluated on MBPP in a zero-shot setting. We observe that CodeRL with CodeT5 of a much smaller model size yields surprisingly good zero-shot performance, setting a new SOTA result of $6 3 . 0 \%$ pass $@ 8 0$ over GPT-137B’s $6 1 . 4 \%$ pass@80. This validates the strong zero-shot transfer ability of CodeRL for unseen tasks.
182
+
183
+ For additional experiments, analysis, and qualitative results, please refer to Appendix ??.
184
+
185
+ Table 6: Results on MBPP: we test the zero-shot transfer ability of CodeRL. CodeRL $^ +$ CodeT5 (ZS) which was trained on APPS with $\mathcal { L } _ { r l }$ and evaluated on MBPP [Austin et al., 2021] in a zero-shot setting, achieves new SOTA.
186
+
187
+ <table><tr><td>Model</td><td>Size</td><td>pass@80</td></tr><tr><td>GPT</td><td>224M</td><td>7.2</td></tr><tr><td>GPT</td><td>422M</td><td>12.6</td></tr><tr><td>GPT</td><td>1B</td><td>22.4</td></tr><tr><td>GPT</td><td>4B</td><td>33.0</td></tr><tr><td>GPT</td><td>8B</td><td>40.6</td></tr><tr><td>GPT</td><td>68B</td><td>53.6</td></tr><tr><td>GPT</td><td>137B</td><td>61.4</td></tr><tr><td>CodeRL+CodeT5 (ZS)</td><td>770M</td><td>63.0</td></tr></table>
188
+
189
+ # 5 Limitations and Broader Impacts
190
+
191
+ One limitation of our approach is the computation cost of training critic model to estimate returns in addition to the original LM (actor network). However, in practice, we found that training a good critic model does not require large-scale models to attain a decent performance. For instance, a finetuned critic model initialized from a pretrained GPT-2 (small) can achieve over $7 5 \%$ error prediction accuracy on synthetic samples.
192
+
193
+ Program synthesis can lead to substantial positive social impacts, e.g., transforming future software developing tools, increasing the productivity of developers, and improving the accessibility and quality of programming courses. Yet, some risks and bias issues are still worth considering before deploying such models at scale. For example, training data from public GitHub code repos may contain vulnerabilities and the resulting synthesis models may generate programs with weak security measures [Hammond Pearce et al., 2021].
194
+
195
+ # 6 Conclusion
196
+
197
+ We present CodeRL, a novel framework for program synthesis, using deep reinforcement learning to improve pretrained LMs, by exploiting unit test signals in both training and inference stages. Specifically, we introduce an actor-critic training approach to optimize pretrained LMs with dense feedback signals on synthetic code samples. During inference, we propose a new generation procedure with critical sampling, which enables the model to automatically regenerate programs based on feedback from unit tests and critic scores. We integrate CodeRL with the improved CodeT5-large model (770M) and achieve new SOTA results on both the APPS and MBPP benchmarks, surpassing the prior SOTA by massive pretrained LMs of much larger model sizes. Our comprehensive analysis shows that CodeRL achieved consistent improvement upon the conventional pretrained LMs for code generation tasks. CodeRL is a general framework that integrates pretrained LMs and RL holistically for program synthesis, and can be extended and improved in various ways. For example, it can be easily integrated with other better pretrained LMs and can be improved with more fine-grained feedback from the environment, such as feedback received from a static code analyzer.
198
+
199
+ References
200
+ J. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry, Q. Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.
201
+ D. Bahdanau, P. Brakel, K. Xu, A. Goyal, R. Lowe, J. Pineau, A. Courville, and Y. Bengio. An actor-critic algorithm for sequence prediction. arXiv preprint arXiv:1607.07086, 2016.
202
+ M. Balog, A. L. Gaunt, M. Brockschmidt, S. Nowozin, and D. Tarlow. Deepcoder: Learning to write programs. arXiv preprint arXiv:1611.01989, 2016.
203
+ S. Bengio, O. Vinyals, N. Jaitly, and N. Shazeer. Scheduled sampling for sequence prediction with recurrent neural networks. Advances in neural information processing systems, 28, 2015.
204
+ S. Black, G. Leo, P. Wang, C. Leahy, and S. Biderman. Gpt-neo: Large scale autoregressive language modeling with mesh-tensorflow, march 2021. URL https://doi. org/10.5281/zenodo, 5297715.
205
+ T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
206
+ R. Bunel, M. Hausknecht, J. Devlin, R. Singh, and P. Kohli. Leveraging grammar and reinforcement learning for neural program synthesis. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id ${ . } = { }$ H1Xw62kRZ.
207
+ M. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. d. O. Pinto, J. Kaplan, H. Edwards, Y. Burda, N. Joseph, G. Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021a.
208
+ Q. Chen, J. Lacomis, E. J. Schwartz, G. Neubig, B. Vasilescu, and C. Le Goues. VarCLR: Variable semantic representation pre-training via contrastive learning. In International Conference on Software Engineering, ICSE ’22, 2022.
209
+ X. Chen, D. Song, and Y. Tian. Latent execution for neural program synthesis beyond domain-specific languages. Advances in Neural Information Processing Systems, 34, 2021b.
210
+ C. Clement, D. Drain, J. Timcheck, A. Svyatkovskiy, and N. Sundaresan. PyMT5: multi-mode translation of natural language and python code with transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 9052–9065, Online, Nov. 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main. 728. URL https://aclanthology.org/2020.emnlp-main.728.
211
+ K. Cobbe, V. Kosaraju, M. Bavarian, J. Hilton, R. Nakano, C. Hesse, and J. Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
212
+ J. Devlin, J. Uesato, S. Bhupatiraju, R. Singh, A.-r. Mohamed, and P. Kohli. Robustfill: Neural program learning under noisy i/o. In International conference on machine learning, pages 990–998. PMLR, 2017.
213
+ K. Ellis, D. Ritchie, A. Solar-Lezama, and J. Tenenbaum. Learning to infer graphics programs from hand-drawn images. Advances in neural information processing systems, 31, 2018.
214
+ K. Ellis, M. Nye, Y. Pu, F. Sosa, J. Tenenbaum, and A. Solar-Lezama. Write, execute, assess: Program synthesis with a repl. Advances in Neural Information Processing Systems, 32, 2019.
215
+ Z. Feng, D. Guo, D. Tang, N. Duan, X. Feng, M. Gong, L. Shou, B. Qin, T. Liu, D. Jiang, and M. Zhou. CodeBERT: A pre-trained model for programming and natural languages. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 1536–1547, Online, Nov. 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.139. URL https://aclanthology.org/2020.findings-emnlp.139.
216
+ Y. Ganin, T. Kulkarni, I. Babuschkin, S. A. Eslami, and O. Vinyals. Synthesizing programs for images using reinforced adversarial learning. In International Conference on Machine Learning, pages 1666–1675. PMLR, 2018.
217
+ S. Gulwani, W. R. Harris, and R. Singh. Spreadsheet data manipulation using examples. Communications of the ACM, 55(8):97–105, 2012.
218
+ K. Guu, P. Pasupat, E. Liu, and P. Liang. From language to programs: Bridging reinforcement learning and maximum marginal likelihood. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1051–1062, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi: 10.18653/v1/P17-1097. URL https://aclanthology.org/P17-1097.
219
+ B. A. Hammond Pearce, B. Tan, B. Dolan-Gavitt, and R. Karri. An empirical cybersecurity evaluation of github copilot’s code contributions. arXiv preprint arXiv:2108.09293, 2021.
220
+ D. Hendrycks, S. Basart, S. Kadavath, M. Mazeika, A. Arora, E. Guo, C. Burns, S. Puranik, H. He, D. Song, and J. Steinhardt. Measuring coding challenge competence with apps. NeurIPS, 2021.
221
+ H. Husain, H. Wu, T. Gazit, M. Allamanis, and M. Brockschmidt. Codesearchnet challenge: Evaluating the state of semantic code search. CoRR, abs/1909.09436, 2019.
222
+ J. Johnson, B. Hariharan, L. Van Der Maaten, J. Hoffman, L. Fei-Fei, C. Lawrence Zitnick, and R. Girshick. Inferring and executing programs for visual reasoning. In Proceedings of the IEEE International Conference on Computer Vision, pages 2989–2998, 2017.
223
+ A. Joulin and T. Mikolov. Inferring algorithmic patterns with stack-augmented recurrent nets. Advances in neural information processing systems, 28, 2015.
224
+ V. Konda and J. Tsitsiklis. Actor-critic algorithms. Advances in neural information processing systems, 12, 1999.
225
+ T. D. Kulkarni, W. F. Whitney, P. Kohli, and J. Tenenbaum. Deep convolutional inverse graphics network. Advances in neural information processing systems, 28, 2015.
226
+ K. Kurach, M. Andrychowicz, and I. Sutskever. Neural random-access machines. arXiv preprint arXiv:1511.06392, 2015.
227
+ Y. Li, D. Choi, J. Chung, N. Kushman, J. Schrittwieser, R. Leblond, T. Eccles, J. Keeling, F. Gimeno, A. D. Lago, et al. Competition-level code generation with alphacode. arXiv preprint arXiv:2203.07814, 2022.
228
+ C. Liang, M. Norouzi, J. Berant, Q. V. Le, and N. Lao. Memory augmented policy optimization for program synthesis and semantic parsing. Advances in Neural Information Processing Systems, 31, 2018.
229
+ P. Liang, M. I. Jordan, and D. Klein. Learning programs: A hierarchical bayesian approach. In Proceedings of the 27th International Conference on Machine Learning (ICML-10), pages 639–646, 2010.
230
+ T. P. Lillicrap, J. J. Hunt, A. Pritzel, N. Heess, T. Erez, Y. Tassa, D. Silver, and D. Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
231
+ C.-Y. Lin. Rouge: A package for automatic evaluation of summaries. Text Summarization Branches Out, 2004.
232
+ Y. Liu, J. Wu, Z. Wu, D. Ritchie, W. T. Freeman, and J. B. Tenenbaum. Learning to describe scenes with programs. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SyNPk2R9K7.
233
+ S. Lu, D. Guo, S. Ren, J. Huang, A. Svyatkovskiy, A. Blanco, C. B. Clement, D. Drain, D. Jiang, D. Tang, G. Li, L. Zhou, L. Shou, L. Zhou, M. Tufano, M. Gong, M. Zhou, N. Duan, N. Sundaresan, S. K. Deng, S. Fu, and S. Liu. Codexglue: A machine learning benchmark dataset for code understanding and generation. In NeurIPS Datasets and Benchmarks, 2021.
234
+ Z. Manna and R. J. Waldinger. Toward automatic program synthesis. Communications of the ACM, 14(3):151–165, 1971.
235
+ E. Nijkamp, B. Pang, H. Hayashi, L. Tu, H. Wang, Y. Zhou, S. Savarese, and C. Xiong. A conversational paradigm for program synthesis. arXiv preprint arXiv:2203.13474, 2022.
236
+ K. Papineni, S. Roukos, T. Ward, and W.-J. Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting on association for computational linguistics, pages 311–318. Association for Computational Linguistics, 2002.
237
+ E. Parisotto, A.-r. Mohamed, R. Singh, L. Li, D. Zhou, and P. Kohli. Neuro-symbolic program synthesis. arXiv preprint arXiv:1611.01855, 2016.
238
+ G. Poesia, A. Polozov, V. Le, A. Tiwari, G. Soares, C. Meek, and S. Gulwani. Synchromesh: Reliable code generation from pre-trained language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ KmtVD97J43e.
239
+ A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, I. Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
240
+ C. Raffel, N. Shazeer, A. Roberts, K. Lee, S. Narang, M. Matena, Y. Zhou, W. Li, and P. J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21:140:1–140:67, 2020.
241
+ M. Ranzato, S. Chopra, M. Auli, and W. Zaremba. Sequence level training with recurrent neural networks. In Y. Bengio and Y. LeCun, editors, 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/1511.06732.
242
+ S. Ren, D. Guo, S. Lu, L. Zhou, S. Liu, D. Tang, N. Sundaresan, M. Zhou, A. Blanco, and S. Ma. Codebleu: a method for automatic evaluation of code synthesis. arXiv preprint arXiv:2009.10297, 2020.
243
+ Z. Ren, X. Wang, N. Zhang, X. Lv, and L.-J. Li. Deep reinforcement learning-based image captioning with embedding reward. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 290–298, 2017.
244
+ S. J. Rennie, E. Marcheret, Y. Mroueh, J. Ross, and V. Goel. Self-critical sequence training for image captioning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7008–7024, 2017.
245
+ P. D. Summers. A methodology for lisp program construction from examples. Journal of the ACM (JACM), 24(1):161–175, 1977.
246
+ S.-H. Sun, H. Noh, S. Somasundaram, and J. Lim. Neural program synthesis from diverse demonstration videos. In J. Dy and A. Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 4790– 4799. PMLR, 10–15 Jul 2018. URL https://proceedings.mlr.press/v80/sun18a. html.
247
+ R. S. Sutton. Temporal credit assignment in reinforcement learning. PhD thesis, University of Massachusetts Amherst, 1984.
248
+ R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. MIT press, 2018.
249
+ R. S. Sutton, D. McAllester, S. Singh, and Y. Mansour. Policy gradient methods for reinforcement learning with function approximation. Advances in neural information processing systems, 12, 1999.
250
+ Y. Tian, A. Luo, X. Sun, K. Ellis, W. T. Freeman, J. B. Tenenbaum, and J. Wu. Learning to infer and execute 3d shape programs. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ rylNH20qFQ.
251
+ D. Trivedi, J. Zhang, S.-H. Sun, and J. J. Lim. Learning to synthesize programs as interpretable and generalizable policies. Advances in Neural Information Processing Systems, 34:25146–25163, 2021.
252
+ R. Vedantam, C. Lawrence Zitnick, and D. Parikh. Cider: Consensus-based image description evaluation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4566–4575, 2015.
253
+ R. J. Waldinger and R. C. Lee. Prow: A step toward automatic program writing. In Proceedings of the 1st international joint conference on Artificial intelligence, pages 241–252, 1969.
254
+ B. Wang and A. Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
255
+ X. Wang, W. Chen, J. Wu, Y.-F. Wang, and W. Y. Wang. Video captioning via hierarchical reinforcement learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 4213–4222, 2018.
256
+ Y. Wang, W. Wang, S. R. Joty, and S. C. H. Hoi. Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. In EMNLP (1), pages 8696–8708. Association for Computational Linguistics, 2021.
257
+ R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229–256, 1992.
258
+ J. Wu, J. B. Tenenbaum, and P. Kohli. Neural scene de-rendering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017.
259
+ X. Xu, C. Liu, and D. Song. SQLNet: Generating structured queries from natural language without reinforcement learning, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SkYibHlRb.
260
+ J. Yang, S. E. Reed, M.-H. Yang, and H. Lee. Weakly-supervised disentangling with recurrent transformations for 3d view synthesis. Advances in neural information processing systems, 28, 2015.
261
+ P. Yin and G. Neubig. A syntactic neural model for general-purpose code generation. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 440–450, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi: 10.18653/v1/P17-1041. URL https://aclanthology.org/P17-1041.
262
+ V. Zhong, C. Xiong, and R. Socher. Seq2SQL: Generating structured queries from natural language using reinforcement learning, 2018. URL https://openreview.net/forum?id= Syx6bz-Ab.
263
+
264
+ # Checklist
265
+
266
+ 1. For all authors...
267
+
268
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 3 and 4
269
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
270
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5.
271
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
272
+
273
+ 2. If you are including theoretical results...
274
+
275
+ (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]
276
+
277
+ 3. If you ran experiments...
278
+
279
+ (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 Appendix ?? and code at https://github.com/salesforce/CodeRL
280
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix ??.
281
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] As it is very expensive to experiment with large-scale language models, we did not try different random seeds due to the limitation of computation resources.
282
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See the configurations in Appendix ??.
283
+
284
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
285
+
286
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Appendix ??.
287
+ (b) Did you mention the license of the assets? [Yes] See Appendix ??.
288
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] We do not curate any new dataset in this paper. We will release the code and models.
289
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] All datasets evaluated in our experiments are publicly available for use.
290
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] The data we are using are code samples from public programming competitions which do not include personally identifiable information or offensive content.
291
+
292
+ 5. If you used crowdsourcing or conducted research with human subjects...
293
+
294
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
295
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
296
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/X5S3pEGPZv8/X5S3pEGPZv8.md ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REVISITING SKELETON BASED ACTION RECOGNITION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Human skeleton, as a compact representation of human action, has received increasing attention in recent years. Many skeleton-based action recognition methods adopt GCNs to extract features on top of human skeletons. Despite the positive results shown in these attempts, GCN-based methods are subject to limitations in robustness, interoperability, and scalability. In this work, we propose PoseConv3D, a new approach to skeleton-based action recognition. PoseConv3D relies on a 3D heatmap stack instead of a graph sequence as the base representation of human skeletons. Compared to GCN-based methods, PoseConv3D is more effective in learning spatiotemporal features, more robust against pose estimation noises, and generalizes better in cross-dataset settings. Also, PoseConv3D can handle multiple-person scenarios without additional computation costs. The hierarchical features can be easily integrated with other modalities at early fusion stages, providing a great design space to boost the performance. PoseConv3D achieves the state-of-the-art on five of six standard skeleton-based action recognition benchmarks. Once fused with other modalities, it achieves the state-of-the-art on all eight multi-modality action recognition benchmarks.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Action recognition is a central task in video understanding. Existing studies have explored various modalities for feature representation, such as RGB frames (Wang et al., 2016; Tran et al., 2015; Carreira & Zisserman, 2017), optical flows (Simonyan & Zisserman, 2014), audio waves (Xiao et al., 2020), and human skeletons (Yan et al., 2018). Among these modalities, skeleton-based action recognition has received increasing attention in recent years due to its action-focusing nature and compactness. In practice, human skeletons in a video are mainly represented as a sequence of joint coordinate lists, where the coordinates are extracted by pose estimators. Since only the pose information is included, skeleton sequences capture only action information while being immune to contextual nuisances, such as background variation and lighting changes.
12
+
13
+ Among all the methods for skeleton-based action recognition (Du et al., 2015; Wang et al., 2012; Vemulapalli et al., 2014), graph convolutional networks (GCN) (Yan et al., 2018) have been one of the most popular approaches. Specifically, GCNs regard every human joint at every timestep as a node. Neighboring nodes along the spatial and temporal dimensions are connected with edges. Graph convolution layers are then applied to the constructed graph to discover action patterns across space and time. Due to the good performance on standard benchmarks for skeleton-based action recognition, GCNs have been a standard approach when processing skeleton sequences.
14
+
15
+ While encouraging results have been observed, GCN-based methods are limited in the following aspects: (1) Robustness: While GCN directly handles coordinates of human joints, its recognition ability is significantly affected by the distribution shift of coordinates, which can often occur when applying a different pose estimator to acquire the coordinates. A small perturbation in coordinates often leads to completely different predictions (Zhu et al., 2019). (2) Interoperability: Previous works have shown that representations from different modalities, such as RGB, optical flows, and skeletons, are complementary. Hence, an effective combination of such modalities can often result in a performance boost in action recognition. However, GCN is operated on an irregular graph of skeletons, making it difficult to fuse with other modalities that are often represented on regular grids, especially in the early stages. (3) Scalability: In addition, since GCN regards every human joint as a node, the complexity of GCN scales linearly with the number of persons, limiting its applicability to scenarios that involve multiple persons, such as group activity recognition.
16
+
17
+ In this paper, we propose a novel framework PoseConv3D that serves as a competitive alternative to GCN-based approaches. In particular, PoseConv3D takes as input 2D poses obtained by modern pose estimators shown in Figure 1. The 2D poses are represented by stacks of heatmaps of skeleton joints rather than coordinates operated on a human skeleton graph. The heatmaps at different timesteps will be stacked along the temporal dimension to form a 3D heatmap volume. PoseConv3D then adopts a 3D convolutional neural network on top of the 3D heatmap volume to recognize actions. The main differences between the proposed PoseConv3D and GCN-based approaches are summarized in Table 1.
18
+
19
+ PoseConv3D can address the limitations of GCN-based approaches stated above. First, using 3D heatmap volumes is more robust to the up-stream pose estimation: we empirically find that PoseConv3D generalizes well across input skeletons obtained by different approaches. Also, PoseConv3D, which relies on heatmaps of the base representation, enjoys the recent advances in convolutional net
20
+
21
+ ![](images/95dfb4d1df15b4f66589d12ed51b2daf5bbdbdabd40274d99be9cc87d0ac1291.jpg)
22
+ Figure 1: PoseConv3D takes 2D poses as inputs. In general, 2D poses are of better quality compared to 3D poses. We visualize 2D poses estimated with HRNet for videos in NTU-60 and FineGYM in (a). Apparently, their quality is much better than 3D poses collected by sensors (b) or estimated with state-of-the-art estimators (c).
23
+
24
+ Table 1: Differences between PoseConv3D and GCN.
25
+
26
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Previous Work</td><td rowspan=1 colspan=1>PoseConv3D</td></tr><tr><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=1>2D/3D Skeleton</td><td rowspan=1 colspan=1>2D Skeleton</td></tr><tr><td rowspan=1 colspan=1>Format</td><td rowspan=1 colspan=1>Coordinates</td><td rowspan=1 colspan=1>3D Heatmap Volumes</td></tr><tr><td rowspan=1 colspan=1>Architecture</td><td rowspan=1 colspan=1>GCN</td><td rowspan=1 colspan=1>3D-CNN</td></tr></table>
27
+
28
+ work architectures and is easier to integrate with other modalities into multi-stream convolutional networks. This characteristic opens up great design space to further improve the recognition performance. Finally, PoseConv3D can handle different numbers of persons without increasing computational overhead since the complexity over 3D heatmap volume is independent of the number of persons. To verify the efficiency and effectiveness of PoseConv3D, we conduct comprehensive studies across several datasets, including FineGYM (Shao et al., 2020), NTURGB-D (Liu et al., 2019), UCF101 (Soomro et al., 2012), HMDB51 (Kuehne et al., 2011), Kinetics400 (Carreira & Zisserman, 2017), and Volleyball (Ibrahim et al., 2016), where PoseConv3D achieves state-of-theart performance compared to GCN-based approaches.
29
+
30
+ # 2 RELATED WORK
31
+
32
+ 3D-CNN for RGB-based action recognition. 3D-CNN is a natural extension of 2D-CNN for spatial feature learning to spatiotemporal in videos. It has long been used in action recognition (Ji et al., 2012; Tran et al., 2015). Due to a large number of parameters, 3D-CNN requires huge amounts of videos to learn good representation. 3D-CNN has become the mainstream approach for action recognition since Carreira & Zisserman (2017) proposed I3D and the large-scale dataset Kinetics400. From then on, many advanced 3D-CNN architectures (Tran et al., 2018; Feichtenhofer et al., 2019; Tran et al., 2019; Feichtenhofer, 2020) have been proposed by the action recognition community, which outperform I3D both in precision and efficiency. In this work, we first propose to use 3D-CNN with 3D heatmap volumes as inputs and reach the state-of-the-art in skeleton-based action recognition.
33
+
34
+ GCN for skeleton-based action recognition. Graph convolutional network is widely adopted in skeleton-based action recognition. It models human skeleton sequences as spatiotemporal graphs. ST-GCN (Yan et al., 2018) is a well-known baseline for GCN-based approaches, which combines spatial graph convolutions and interleaving temporal convolutions for spatiotemporal modeling. Upon the baseline, adjacency powering is used for multiscale modeling (Liu et al., 2020; Li et al., 2019b), while self-attention mechanisms improve the modeling capacity (Shi et al., 2019b; Li et al., 2019a). Despite the great success of GCN in skeleton-based action recognition, it is also limited in robustness (Zhu et al., 2019) and scalability. Besides, for GCN-based approaches, fusing features from skeletons and other modalities may need careful design (Das et al., 2020).
35
+
36
+ ![](images/5e22666e44fa6df49abb7c136c0d5e1731285c8c174040124122cc288bdb7bfb.jpg)
37
+ Figure 2: Our Framework. For each frame in a video, we first use a two-stage pose estimator (detection $^ +$ pose estimation) for 2D human pose extraction. Then we stack heatmaps of joints or limbs along the temporal dimension and apply pre-processing to the generated 3D heatmap volumes. Finally, we use a 3D-CNN to classify the 3D heatmap volumes.
38
+
39
+ CNN for skeleton-based action recognition. Another stream of work adopts convolutional neural networks for skeleton-based action recognition. 2D-CNN-based approaches first model the skeleton sequence as a pseudo image based on manually designed transformations. PoTion (Choutas et al., 2018) aggregates heatmaps along the temporal dimension with color encodings to get the pose motion representation, while PA3D (Yan et al., 2019) does the aggregation with $1 \times 1$ convolutions. Although carefully designed, information loss still occurs during the aggregation, which leads to inferior recognition performance. Other works (Ke et al., 2017; Luvizon et al., 2018; Caetano et al., 2019) directly convert the coordinates in a skeleton sequence to a pseudo image with transformations, typically generate a 2D input of shape $K \times T$ , where $K$ is the number of joints, $T$ is the temporal length. Such input cannot exploit the locality nature of convolution networks, which makes these methods not as competitive as GCN on popular benchmarks (Caetano et al., 2019). Only a few previous works have adopted 3D-CNNs for skeleton-based action recognition. To construct the 3D input, they either stack the pseudo images of distance matrices (Hernandez Ruiz et al., 2017; Lin et al., 2020) or directly aggregate the 3D skeletons into a cuboid (Liu et al., 2017). These approaches also severely suffer from information loss and obtain much inferior performance to the state-of-the-art. Our work aggregates heatmaps by stacking them along the temporal dimension to form 3D heatmap volumes, preserving all information during this process. Besides, we use 3D-CNN instead of 2D-CNN due to its good capability for spatiotemporal feature learning.
40
+
41
+ # 3 FRAMEWORK
42
+
43
+ We propose PoseConv3D, a 3D-CNN-based approach for skeleton-based action recognition, which can be a competitive alternative to GCN-based approaches, outperforming GCN under various settings in terms of accuracy with improved robustness, interoperability, and scalability. An overview of PoseConv3D is depicted in Figure 2, and details of PoseConv3D will be covered in the following sections. We begin with a review of skeleton extraction, which is the basis of skeleton-based action recognition but is often overlooked in previous literature. We point out several aspects that should be considered when choosing a skeleton extractor and motivate the use of 2D skeletons in PoseConv3D1. Subsequently, we introduce 3D Heatmap Volume that is the representation of a 2D skeleton sequence used in PoseConv3D, followed by the structural designs of PoseConv3D, including a variant that focuses on the modality of human skeletons as well as a variant that combines the modalities of human skeletons and RGB frames to demonstrate the interoperability of PoseConv3D.
44
+
45
+ # 3.1 GOOD PRACTICES FOR POSE EXTRACTION
46
+
47
+ Being a critical pre-processing step for skeleton-based action recognition, human skeleton or pose extraction largely affects the final recognition accuracy. However, its importance is often overlooked in previous literature, in which poses estimated by sensors (Shahroudy et al., 2016; Liu et al., 2019)
48
+
49
+ or existing pose estimators (Cao et al., 2019; Yan et al., 2018) are used without considering the potential effects. Here we conduct a review on key aspects of pose extraction to find a good practice.
50
+
51
+ In general, 2D poses are of better quality compared to 3D poses, as shown in Figure 1. We adopt 2D Top-Down pose estimators (Newell et al., 2016; Xiao et al., 2018; Sun et al., 2019) for pose extraction. Compared to its 2D Bottom-Up counterparts (Newell et al., 2017; Cao et al., 2017; Cheng et al., 2020a), Top-Down methods obtain superior performance on standard benchmarks such as COCO-keypoints (Lin et al., 2014). In most cases, we feed proposals predicted by a human detector to the Top-Down pose estimators, which is sufficient enough to generate 2D poses of good quality for action recognition. When only a few persons are of interest out of dozens of candidates 2, some priors are essential for skeleton-based action recognition to achieve good performance, e.g., knowing the interested person locations at the first frame of the video. In terms of the storage of estimated heatmaps, they are often stored as coordinate-triplets $( x , y , c )$ in previous literature, where $c$ marks the maximum score of the heatmap and $( x , y )$ is the corresponding coordinate of $c$ . In experiments, we find that coordinate-triplets $( x , y , c )$ help save the majority of storage space at the cost of little performance drop. The detailed ablation study is included in Appendix Sec. A.4.1.
52
+
53
+ # 3.2 FROM 2D POSES TO 3D HEATMAP VOLUMES
54
+
55
+ After 2D poses are extracted from video frames, to feed into PoseConv3D, we reformulate them into a 3D heatmap volume. Formally, we represent a 2D pose as a heatmap of size $K \times H \times W$ , where $K$ is the number of joints, $H$ and $W$ are the height and width of the frame. We can directly use the heatmap produced by the Top-Down pose estimator as the target heatmap, which should be zeropadded to match the original frame given the corresponding bounding box. In case we have only coordinate-triplets $( x _ { k } , y _ { k } , c _ { k } )$ of skeleton joints, we can obtain a joint heatmap $\textbf { { J } }$ by composing $K$ gaussian maps centered at every joint:
56
+
57
+ $$
58
+ J _ { k i j } = \exp ( - [ ( i - x _ { k } ) ^ { 2 } + ( j - y _ { k } ) ^ { 2 } ] / ( 2 * \sigma ^ { 2 } ) ) * c _ { k }
59
+ $$
60
+
61
+ where $\sigma$ controls the variance of gaussian maps, and $( x _ { k } , y _ { k } )$ and $c _ { k }$ are respectively the location and confidence score of the $k$ -th joint. We can also create a limb heatmap $\pmb { L }$ :
62
+
63
+ $$
64
+ { \cal L } _ { k i j } = \exp ( - { \cal D } ( ( i , j ) , [ ( x _ { a _ { k } } , y _ { a _ { k } } ) , ( x _ { b _ { k } } , y _ { b _ { k } } ) ] ) ^ { 2 } / ( 2 * \sigma ^ { 2 } ) ) * \operatorname* { m i n } ( c _ { a _ { k } } , c _ { b _ { k } } ) .
65
+ $$
66
+
67
+ The $k _ { t h }$ limb is between two joints $a _ { k }$ and $b _ { k }$ . The function $\mathcal { D }$ calculates the distance from the point $( i , j )$ to the segment $[ ( x _ { a _ { k } } , y _ { a _ { k } } ) , ( x _ { b _ { k } } , y _ { b _ { k } } ) ] .$ It is worth noting that although the above process assumes a single person in every frame, we can easily extend it to the multi-person case, where we directly accumulate the $k$ -th gaussian maps of all persons without enlarging the heatmap. Finally, a 3D heatmap volume is obtained by stacking all heatmaps $_ { J }$ or $\pmb { L }$ ) along the temporal dimension, which thus has the size of $K \times T \times H \times W$ .
68
+
69
+ In practice, we further apply two techniques to reduce the redundancy of 3D heatmap volumes. (1) Subjects-Centered Cropping. Making the heatmap as large as the frame is inefficient, especially when the persons of interest only act in a small region. In such cases, we first find the smallest bounding box that envelops all the 2D poses across frames. Then we crop all frames according to the found box and resize them to the target size. Consequently, the size of the 3D heatmap volume can be reduced spatially while all 2D poses and their motion are kept. (2) Uniform Sampling. The 3D heatmap volume can also be reduced along the temporal dimension by sampling a subset of frames. Unlike previous works on RGB-based action recognition, where researchers usually sample frames in a short temporal window, such as sampling frames in a 64-frame temporal window as in SlowFast (Feichtenhofer et al., 2019), we propose to use a uniform sampling strategy (Wang et al., 2016) for 3D-CNNs instead. In particular, to sample $n$ frames from a video, we divide the video into $n$ segments of equal length and randomly select one frame from each segment. The uniform sampling strategy is better at maintaining the global dynamics of the video. Our empirical studies show that the uniform sampling strategy is significantly beneficial for skeleton-based action recognition. More illustration about generating 3D heatmap volumes is provided in Appendix Sec. A.2.
70
+
71
+ # 3.3 3D-CNN FOR SKELETON-BASED ACTION RECOGNITION
72
+
73
+ For skeleton-based action recognition, GCN has long been the mainstream backbone. In contrast, 3D-CNN, an effective network structure commonly used in RGB-based action recognition (Carreira & Zisserman, 2017; Hara et al., 2018; Feichtenhofer et al., 2019), is less explored in this direction. To demonstrate the power of 3D-CNN in capturing spatiotemporal dynamics of skeleton sequences, we design two families of 3D-CNNs, namely PoseConv3D for the Pose modality and RGBPoseConv3D for the $R G B +$ Pose dual-modality.
74
+
75
+ PoseConv3D. PoseConv3D focuses on the modality of human skeletons, which takes 3D heatmap volumes as input and can be instantiated with various 3D-CNN backbones. Two modifications are needed to adapt 3D-CNNs to skeleton-based action recognition: (1) down-sampling operations in early stages are removed from the 3D-CNN since the spatial resolution of 3D heatmap volumes does not need to be as large as RGB clips $4 \times$ smaller in our setting); (2) a shallower (fewer layers) and thinner (fewer channels) network is sufficient to model spatiotemporal dynamics of human skeleton sequences since 3D heatmap volumes are already mid-level features for action recognition. Based on these principles, we adapt three popular 3DCNNs: C3D (Tran et al., 2015), SlowOnly (Feichtenhofer et al., 2019), and X3D (Feichtenhofer, 2020), to skeleton-based action recognition (Table 11 demonstrates the architectures of the three backbones as well as their variants). The different variants of adapted 3D-CNNs are evaluated on the NTURGB $+ \mathbf { D }$ -XSub benchmark (Table 2). Adopting a lightweight version of 3D-CNNs can significantly reduce the computational complexity at the cost of a slight recognition performance drop $( \leq 0 . 3 \%$ for all 3D backbones). In experiments, we use SlowOnly as the default backbone, considering its simplicity (directly inflated from ResNet) and good recognition performance. PoseConv3D can outperform representative GCN / 2D-CNN counterparts across various benchmarks, both in accuracy and efficiency. More importantly, the interoperability between PoseConv3D and popular networks for RGB-based action recognition makes it easy to involve human skeletons in multi-modality fusion.
76
+
77
+ Table 2: Evalution of PoseConv3D variants. ‘s’ indicates shallow (fewer layers); ‘HR’ indicates high-resolution (double height & width); ‘wd’ indicates wider network with double channel size.
78
+
79
+ <table><tr><td rowspan=1 colspan=1>Backbone</td><td rowspan=1 colspan=1>Variant</td><td rowspan=1 colspan=1>NTU60-XSub</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>Params</td></tr><tr><td rowspan=1 colspan=1>SlowOnly</td><td rowspan=1 colspan=1>:</td><td rowspan=1 colspan=1>93.7</td><td rowspan=1 colspan=1>15.9G</td><td rowspan=1 colspan=1>2.0M</td></tr><tr><td rowspan=1 colspan=1>SlowOnly</td><td rowspan=1 colspan=1>HR</td><td rowspan=1 colspan=1>93.6</td><td rowspan=1 colspan=1>73.0G</td><td rowspan=1 colspan=1>8.0M</td></tr><tr><td rowspan=1 colspan=1>SlowOnly</td><td rowspan=1 colspan=1>wd</td><td rowspan=1 colspan=1>93.7</td><td rowspan=1 colspan=1>54.9G</td><td rowspan=1 colspan=1>7.9M</td></tr><tr><td rowspan=1 colspan=1>C3D</td><td rowspan=1 colspan=1>二</td><td rowspan=1 colspan=1>93.0</td><td rowspan=1 colspan=1>25.2G</td><td rowspan=1 colspan=1>6.9M</td></tr><tr><td rowspan=1 colspan=1>C3D</td><td rowspan=1 colspan=1>S</td><td rowspan=1 colspan=1>92.9</td><td rowspan=1 colspan=1>16.8G</td><td rowspan=1 colspan=1>3.4M</td></tr><tr><td rowspan=1 colspan=1>X3D</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>92.6</td><td rowspan=1 colspan=1>1.1G</td><td rowspan=1 colspan=1>531K</td></tr><tr><td rowspan=1 colspan=1>X3D</td><td rowspan=1 colspan=1>S</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>0.6G</td><td rowspan=1 colspan=1>241K</td></tr></table>
80
+
81
+ RGBPose-Conv3D. To show the interoperability of PoseConv3D, we propose RGBPose-Conv3D for the early fusion of human skeletons and RGB frames. It is a two-stream 3D-CNN with two pathways that respectively process RGB modality and Pose modality. While a detailed instantiation of RGBPose-Conv3D is included in Appendix Sec. A.3.2, the architecture of RGBPose-Conv3D follows several principles in general: (1) the two pathways are not symmetrical due to the different characteristics of the two modalities: Compared to the RGB pathway, the pose pathway has a smaller channel-width, a smaller depth, as well as a smaller input spatial resolution. (2) Inspired by SlowFast (Feichtenhofer et al., 2019), bidirectional lateral connections between the two pathways are added to promote early-stage feature fusion between two modalities. To avoid overfitting, RGBPose-Conv3D is trained with two individual cross-entropy losses respectively for each pathway. In experiments, we find that early-stage feature fusion caused by the lateral connections can lead to significant and consistent improvement compared to late-fusion only.
82
+
83
+ # 4 EXPERIMENTS
84
+
85
+ # 4.1 DATASET PREPARATION
86
+
87
+ We use six datasets in our experiments: FineGYM (Shao et al., 2020), NTURGB $+ \mathbf { D }$ (Shahroudy et al 2016; Liu et al., 2019), Kinetics400 (Carreira & Zisserman, 2017; Yan et al., 2018), UCF101 (Soomro et al., 2012), HMDB51 (Kuehne et al., 2011) and Volleyball (Ibrahim et al., 2016). Unless otherwise specified, we use the Top-Down approach for pose extraction: the detector is Faster-RCNN (Ren et al., 2015) with the ResNet50 backbone, the pose estimator is HRNet (Sun et al., 2019) pre-trained on COCO-keypoint (Lin et al., 2014). For all datasets except FineGYM, 2D poses are obtained by directly applying Top-Down pose estimators to RGB inputs. We report the Mean Top-1 accuracy for FineGYM and Top-1 accuracy for other datasets. Codes and estimated 2D poses will be released.
88
+
89
+ FineGYM. FineGYM is a fine-grained action recognition dataset with 29K videos of 99 finegrained gymnastic action classes. During pose extraction, we compare three different kinds of person bounding boxes: 1. Person bounding boxes predicted by the detector (Detection); 2. GT bounding boxes for the athlete in the first frame, tracking boxes for the rest frames (Tracking). 3. GT bounding boxes for the athlete in all frames (GT). In experiments, we use human poses extracted with the third kind of bounding boxes unless otherwise noted.
90
+
91
+ Table 3: PoseConv3D is better or comparable to previous state-of-the-arts. With estimated high-quality 2D skeletons and the great capacity of 3D-CNN to learn spatiotemporal features, PoseConv3D achieves superior performance across 5 out of 6 benchmarks. ${ \mathbf { } } J , L$ means using joint- and limb-based heatmap respectively. $^ { + + }$ denotes using the same pose estimation result as ours. \* means the number is reported by Shao et al. (2020).
92
+
93
+ <table><tr><td>Method</td><td>NTU60-XSub</td><td>NTU60-XView</td><td>NTU120-XSub</td><td>NTU120-XSet</td><td>Kinetics</td><td>FineGYM</td></tr><tr><td>ST-GCN (Yan et al., 2018)</td><td>81.5</td><td>88.3</td><td>70.7</td><td>73.2</td><td>30.7</td><td>25.2*</td></tr><tr><td>AS-GCN (Li et al.,2019b)</td><td>86.8</td><td>94.2</td><td>78.3</td><td>79.8</td><td>34.8</td><td>二</td></tr><tr><td>RA-GCN (Song et al., 2020)</td><td>87.3</td><td>93.6</td><td>81.1</td><td>82.7</td><td>-</td><td>-</td></tr><tr><td>AGCN (Shi et al., 2019b)</td><td>88.5</td><td>95.1</td><td>二</td><td>二</td><td>36.1</td><td></td></tr><tr><td>DGNN (Shi et al., 2019a)</td><td>89.9</td><td>96.1</td><td>-</td><td>-</td><td>36.9</td><td>二</td></tr><tr><td>FGCN (Yang et al., 2020)</td><td>90.2</td><td>96.3</td><td>85.4</td><td>87.4</td><td>二</td><td>-</td></tr><tr><td>Shift-GCN (Cheng et al.,2020b)</td><td>90.7</td><td>96.5</td><td>85.9</td><td>87.6</td><td>二</td><td>-</td></tr><tr><td>DSTA-Net (Shi et al., 2020)</td><td>91.5</td><td>96.4</td><td>86.6</td><td>89.0</td><td>-</td><td>二</td></tr><tr><td>MS-G3D (Liu et al., 2020)</td><td>91.5</td><td>96.2</td><td>86.9</td><td>88.4</td><td>38.0</td><td>:</td></tr><tr><td>MS-G3D ++</td><td>92.2</td><td>96.6</td><td>87.2</td><td>89.0</td><td>45.1</td><td>92.6</td></tr><tr><td>PoseConv3D (J)</td><td>93.7</td><td>96.6</td><td>86.0</td><td>89.6</td><td>46.0</td><td>93.2</td></tr><tr><td>PoseConv3D(J+L)</td><td>94.1</td><td>97.1</td><td>86.9</td><td>90.3</td><td>47.7</td><td>94.3</td></tr></table>
94
+
95
+ NTURGB ${ \bf + D . }$ . NTURGB $+ \mathbf { D }$ is a large-scale human action recognition dataset collected in the lab. It has two versions, namely NTU-60 and NTU-120 (a superset of NTU-60): NTU-60 contains 57K videos of 60 human actions, while NTU-120 contains 114K videos of 120 human actions. The datasets are split in three ways: Cross-subject $\mathbf { X }$ -Sub), Cross-view ( $\mathbf { X }$ -View, for NTU-60), Crosssetup (X-Set, for NTU-120), for which action subjects, camera views, camera setups are different in training and validation. The 3D skeletons collected by sensors are available for this dataset. Unless otherwise specified, we conduct experiments on the X-sub splits for NTU-60 and NTU-120.
96
+
97
+ Kinetics400, UCF101, and HMDB51. The three datasets are general action recognition datasets collected from the web. Kinetics400 is a large-scale video dataset with 300K videos from 400 action classes. UCF101 and HMDB51 are smaller, contains 13K videos from 101 classes and 6.7K videos from 51 classes, respectively. We conduct experiments using 2D-pose annotations extracted with our Top-Down pipeline.
98
+
99
+ Volleyball. Volleyball is a group activity recognition dataset with 4830 videos of 8 group activity classes. Each frame contains approximately 12 persons, while only the center frame is annotated with GT person boxes. We use tracking boxes from (Sendo & Ukita, 2019) for pose extraction.
100
+
101
+ # 4.2 COMPARISON WITH STATE-OF-THE-ARTS
102
+
103
+ Skeleton-based Action Recognition. PoseConv3D achieves competitive results on multiple datasets. In Table 3, we compare Pose-SlowOnly with state-of-the-arts in skeleton-based action recognition. Since the 2D poses we used are of better quality than 2D/3D poses used previously, we also evaluate the state-of-the-art MS-G3D with our 2D-pose annotations. The extracted 2D poses are saved as coordinate-triplets $( x , y , c )$ , directly used by $M S – G 3 D + +$ . For PoseConv3D, we also use pseudo heatmaps generated from coordinate-triplets as input, thus a fair comparison. We achieve by far the best results on three of four NTURGB $+ \mathbf { D }$ benchmarks, prove that high-quality 2D skeletons with PoseConv3D can yield competitive performance on skeleton-based action recognition. On Kinetics, PoseConv3D surpasses the state-of-the-art MS-G3D by a noticeable margin when using the same input, significantly outperforms previous methods. Except for the baseline obtained by Shao et al. (2020), no work aims at skeleton-based action recognition on FineGYM before, while our work first improves the performance to a decent level.
104
+
105
+ Multi-modality Fusion. As a powerful representation itself, skeletons are also complementary to other modalities, like RGB appearance. With multi-modality fusion (RGBPose-Conv3D or LateFusion), we achieve state-of-the-art results across eight different video recognition benchmarks. We apply the proposed RGBPose-Conv3D to FineGYM and four NTURGB $+ \mathbf { D }$ benchmarks, using ResNet50 as the backbone, 16, 48 as the temporal length for RGB-Pathway and Pose-Pathway. Table 4a shows that our early+late fusion strategy achieves excellent performance across various benchmarks. We also try to fuse the predictions of PoseConv3D directly with other modalities with LateFusion. Table 4b shows that late fusion with the Pose modality can push the recognition precision to a new level. We achieve the new state-of-the-art on three action recognition benchmarks: Kinetics400, UCF101, and HMDB51. On the challenging Kinetics400 benchmark, fusing with PoseConv3D predictions increases the recognition accuracy by $0 . 6 \%$ beyond the state-of-theart (Liu et al., 2021), which is strong evidence for the complementarity of the Pose modality.
106
+
107
+ Table 4: Comparison to the state-of-the-art of Multi-Modality Action Recognition. Perfect recognition performance is achieved on multiple benchmarks with multi-modality fusion. R, F, P indicate RGB, Flow, Pose.
108
+ (a) Mulit-modality action recognition with RGBPose-Conv3D.
109
+
110
+ <table><tr><td rowspan=1 colspan=1>RGBPose-Conv3D</td><td rowspan=1 colspan=1>Previous state-of-the-art</td><td rowspan=1 colspan=1>Ours</td></tr><tr><td rowspan=1 colspan=1>FineGYM-99</td><td rowspan=1 colspan=1>87.7 (R)(Kwon et al., 2021)</td><td rowspan=1 colspan=1>95.6 (R + P)</td></tr><tr><td rowspan=1 colspan=1>NTU60 (X-Sub /X-View)</td><td rowspan=1 colspan=1>95.7 /98.9 (R +P)(Davoodikakhki&amp; Yin,2020)</td><td rowspan=1 colspan=1>97.0 /99.6 (R + P)</td></tr><tr><td rowspan=1 colspan=1>NTU120 (X-Sub /X-Set)</td><td rowspan=1 colspan=1>90.7/92.5 (R + P)(Das et al., 2021)</td><td rowspan=1 colspan=1>95.3/96.4 (R + P)</td></tr></table>
111
+
112
+ (b) Mulit-modality action recognition with late fusion.
113
+
114
+ <table><tr><td rowspan=1 colspan=1>LateFusion Only</td><td rowspan=1 colspan=1>Previous state-of-the-art</td><td rowspan=1 colspan=1>Ours</td></tr><tr><td rowspan=1 colspan=1>Kinetics400</td><td rowspan=1 colspan=1>84.9 (R)(Liu et al., 2021)</td><td rowspan=1 colspan=1>85.5 (R + P)</td></tr><tr><td rowspan=1 colspan=1>UCF101</td><td rowspan=1 colspan=1>98.6 (R +F)(Duan et al., 2020)</td><td rowspan=1 colspan=1>98.8 (R +F +P)</td></tr><tr><td rowspan=1 colspan=1>HMDB51</td><td rowspan=1 colspan=1>83.8 (R +F)(Duan et al., 2020)</td><td rowspan=1 colspan=1>85.0 (R +F +P)</td></tr></table>
115
+
116
+ # 4.3 PREPROCESSING OF 3D HEATMAP VOLUMES
117
+
118
+ Subjects-Centered Cropping. Since the sizes and locations of persons can vary a lot in a dataset, focusing on the action subjects is the key to reserve as much information as possible with a relatively small $H \times W$ budget. To validate this, we conduct a pair of experiments on FineGYM with input size $3 2 \times 5 6 \times 5 6$ , with or without subjects-centered cropping. We find that subjects-centered cropping is helpful in data preprocessing, which improves the Mean-Top1 by $1 . 0 \%$ , from $9 1 . 7 \%$ to $9 2 . 7 \%$ .
119
+
120
+ Uniform Sampling. The input sampled from a small temporal window may not capture the entire dynamic of the human action. To validate this, we conduct experiments on FineGYM and NTU60. For fixed stride sampling, which samples from a fixed temporal window, we try to sample 32 frames with the temporal stride 2, 3, 4; for uniform sampling, we sample 32 frames uniformly from the entire clip. From Figure 3, we see that uniform sampling consistently outperforms sampling with fixed temporal strides. With uniform sampling, 1-clip testing can even achieve better results than fixed stride sampling with 10-clip testing. Note that the video length can vary a lot in NTU60 and FineGYM. In a more detailed analysis, we find that uniform sampling mainly improves the recognition performance for longer videos in the dataset (Figure 4). Besides, uniform sampling also outperforms fixed stride sampling on RGB-based recognition on the two datasets3.
121
+
122
+ Pseudo Heatmaps for Joints and Limbs. GCN-based approaches for skeleton-based action recognition usually ensemble results of multiple streams (joint stream, bone stream, etc.) to achieve better recognition performance (Shi et al., 2019b). That practice is also feasible for PoseConv3D. Based on the coordinate-triplets $( x , y , c )$ we saved, we can generate pseudo heatmaps for joints and limbs. In general, we find that both joint heatmaps and limb heatmaps are good inputs for 3D-CNNs. Ensembling the results from joint-PoseConv3D and limb-PoseConv3D (namely PoseConv3D $( J + L ) ,$ ) can lead to noticeable and consistent performance improvement.
123
+
124
+ 3D Heatmap Volumes v.s 2D Heatmap Aggregations. The 3D heatmap volume is a more ‘lossless’ 2D-pose representation, than 2D heatmap aggregations aggregated with colorization (PoTion) or temporal convolutions (PA3D). PoTion (Choutas et al., 2018)
125
+
126
+ Table 5: An apple-to-apple comparison between 3D heatmap volumes and 2D heatmap aggregations.
127
+
128
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>HMDB51</td><td rowspan=1 colspan=1>UCF101</td><td rowspan=1 colspan=1>NTU60-XSub</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>Params</td></tr><tr><td rowspan=1 colspan=1>PoTion (Choutas et al.,2018)</td><td rowspan=1 colspan=1>51.7</td><td rowspan=1 colspan=1>67.2</td><td rowspan=1 colspan=1>87.8</td><td rowspan=1 colspan=1>0.60G</td><td rowspan=1 colspan=1>4.75M</td></tr><tr><td rowspan=1 colspan=1>PA3D (Yan et al., 2019)</td><td rowspan=1 colspan=1>53.5</td><td rowspan=1 colspan=1>69.1</td><td rowspan=1 colspan=1>88.6</td><td rowspan=1 colspan=1>0.65G</td><td rowspan=1 colspan=1>4.81M</td></tr><tr><td rowspan=1 colspan=1>Pose-SlowOnly (Ours)</td><td rowspan=1 colspan=1>58.6</td><td rowspan=1 colspan=1>79.1</td><td rowspan=1 colspan=1>93.7</td><td rowspan=1 colspan=1>15.9G</td><td rowspan=1 colspan=1>2.0M</td></tr><tr><td rowspan=1 colspan=1>Pose-X3D-s (Ours)</td><td rowspan=1 colspan=1>55.6</td><td rowspan=1 colspan=1>76.7</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>0.60G</td><td rowspan=1 colspan=1>0.24M</td></tr></table>
129
+
130
+ and PA3D (Yan et al., 2019) are not evaluated on popular benchmarks for skeleton-based action recognition, and there are no public implementations. In the preliminary study, we find that the accuracy of PoTion is much inferior $( \leq 8 5 \% )$ ) to GCN or PoseConv3D (al $\geq 9 0 \%$ ). For an appleto-apple comparison, we also re-implement PoTion, PA3D (with higher accuracy than reported) and evaluate them on three benchmarks: UCF101, HMDB51, NTURGB $+ \mathbf { D }$ . PoseConv3D achieves much better recognition results with 3D heatmap volumes, than 2D-CNNs with 2D heatmap aggregations as inputs. With the lightweight X3D backbone, PoseConv3D significantly outperforms 2D-CNNs, with comparable FLOPs and far fewer parameters (Table 5).
131
+
132
+ ![](images/f2ddb1481a00cb0b4469234585566a24f7d28bae7f45ebf5fd9bc0fbfb146f6e.jpg)
133
+ Figure 4: Uniform Sampling helps in modeling longer videos. Left: The length distribution of NTU60-XSub val videos. Right: Uniform Sampling improves the recognition accuracy of longer videos.
134
+
135
+ ![](images/62d4827f680bb7560fc43abe9383d04bce9863126bf5c1304b2a206bd5af9159.jpg)
136
+ Figure 3: Uniform Sampling outperforms FixStride Sampling. All results are for 10-clip testing, except Uni-32[1c], which uses 1-clip testing.
137
+
138
+ # 4.4 GOOD PROPERTIES OF POSECONV3D
139
+
140
+ To elaborate on the good properties, we compare Pose-SlowOnly with MS-G3D (Liu et al., 2020), a representative GCN-based approach in multiple dimensions. Two models take exactly the same input (coordinate-triplets for GCN, heatmaps generated from coordinate-triplets for PoseConv3D).
141
+
142
+ # 4.4.1 PERFORMANCE & EFFICIENCY
143
+
144
+ In performance comparison between PoseConv3D and GCN, we adopt the input shape $4 8 \times 5 6 \times 5 6$ for PoseConv3D. Table 6 shows that under such configuration, our PoseConv3D is even lighter than the GCN counterpart, both in the number of parameters and FLOPs. Although being lightweight, PoseConv3D achieves competitive performance across different datasets. The 1-clip testing result is better than or comparable with a state-of-the-art GCN while requiring much less computation. When applying 10-clip testing, PoseConv3D consistently outperforms the state-of-the-art GCN. Only PoseConv3D can take advantage of multi-view testing since it subsamples the entire heatmap volumes to form each input. Besides, PoseConv3D uses the same architecture and hyperparameters for different datasets and achieves competitive performance, while GCN tunes architectures and hyperparameters for different datasets (Liu et al., 2020).
145
+
146
+ # 4.4.2 ROBUSTNESS & GENERALIZATION
147
+
148
+ Robustness. To test the robustness of both models, we can drop a proportion of keypoints in the input and see how such perturbation will affect the final accuracy. Since limb keypoints4 are more critical for gymnastics than the torso or face keypoints, we test both models by randomly dropping one limb keypoint in each frame with probability $p$ . In Table 7, we see that PoseConv3D is highly robust to input perturbations: dropping one limb keypoint per frame leads to a moderate drop (less than $1 \%$ ) in Mean-Top1, while for GCN, it’s $1 4 . 3 \%$ . Someone would argue that we can train GCN with the noisy input, similar to the dropout operation (Srivastava et al., 2014). However, even under this setting, the Mean-Top1 accuracy of GCN still drops by $1 . 4 \%$ for the case $p = 1$ . Besides, with robust training, there will be an additional $1 . 1 \%$ drop for the case $p = 0$ . The experiment results show that PoseConv3D significantly outperforms GCN in terms of robustness for pose recognition.
149
+
150
+ Generalization. To compare the generalization of 3D-CNN and GCN, we design a cross-model check on FineGYM. Specifically, we use two models, i.e., HRNet (Higher-Quality, or HQ for short) and MobileNet (Lower-Quality, LQ) for pose estimation, and train PoseConv3D on top respectively. During testing, we feed LQ input into the model trained with HQ one and vice versa. From Table 8a, we see that the accuracy drops less when using lower-quality poses for both training & testing with PoseConv3D compared to GCN. Similarly, we can also vary the source of person boxes, using either GT boxes (HQ) or tracking results (LQ), for training and testing. The results are shown in Table 8b. The performance drop of PoseConv3D is also much smaller than GCN.
151
+
152
+ # 4.4.3 SCALABILITY
153
+
154
+ The computation of GCN scales linearly with the increasing number of persons in the video, making it less efficient for group activity recognition. We use an experiment on the Volleyball dataset (Ibrahim et al., 2016) to prove that. Each video in the dataset contains 13 persons and 20 frames. For GCN, the corresponding input shape will be $1 3 \times 2 0 \times 1 7 \times 3$ , 13 times larger than the input for one person. Under such configuration, the number of parameters and FLOPs for GCN is $2 . 8 \mathbf { M }$ and 7.2G $( 1 3 \times )$ . For PoseConv3D, we can use one single heatmap volume (with shape $1 7 \times 1 2 \times 5 6 \times 5 6 )$ to represent all 13 persons. The base channel-width of Pose-SlowOnly is set to 16. Under such a configuration, Pose-SlowOnly only takes 0.52M parameters and 1.6 GFLOPs. Despite the much smaller parameters and FLOPs, PoseConv3D achieves $9 1 . 3 \%$ Top-1 accuracy on Volleyball-validation, $2 . 1 \%$ higher than the GCN-based approach.
155
+
156
+ Table 6: 3D-CNN v.s. GCN. We compare the performance of Table 8: Train/Test w. different pose anno3D-CNN and GCN on several datasets. For 3D-CNN, we re- tations. 3D-CNN shows great generalizaport the results of 1/10-clip testing. We exclude parameters and tion capability in the cross-PoseAnno setting FLOPs of the FC layer, since it depends on the number of classes. (LQ for low-quality; HQ for high-quality).
157
+
158
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>GCN</td><td rowspan=1 colspan=4>Pose-SlowOnly</td></tr><tr><td rowspan=1 colspan=1>Dataset</td><td rowspan=1 colspan=1>Acc</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>1-clip</td><td rowspan=1 colspan=1>10-clip</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>FLOPs</td></tr><tr><td rowspan=1 colspan=1>FineGYM</td><td rowspan=1 colspan=1>92.0</td><td rowspan=1 colspan=1>2.8M</td><td rowspan=1 colspan=1>24.7G</td><td rowspan=1 colspan=1>92.4</td><td rowspan=1 colspan=1>93.2</td><td rowspan=4 colspan=1>2.0M</td><td rowspan=4 colspan=1>15.9G</td></tr><tr><td rowspan=1 colspan=1>NTU-60</td><td rowspan=1 colspan=1>91.9</td><td rowspan=1 colspan=1>2.8M</td><td rowspan=1 colspan=1>16.7G</td><td rowspan=1 colspan=1>93.1</td><td rowspan=1 colspan=1>93.7</td></tr><tr><td rowspan=1 colspan=1>NTU-120</td><td rowspan=1 colspan=1>84.8</td><td rowspan=1 colspan=1>2.8M</td><td rowspan=1 colspan=1>16.7G</td><td rowspan=1 colspan=1>85.1</td><td rowspan=1 colspan=1>86.0</td></tr><tr><td rowspan=1 colspan=1>Kinetics400</td><td rowspan=1 colspan=1>44.9</td><td rowspan=1 colspan=1>2.8M</td><td rowspan=1 colspan=1>17.5G</td><td rowspan=1 colspan=1>44.8</td><td rowspan=1 colspan=1>46.0</td></tr></table>
159
+
160
+ Table 7: Recognition performance w. different dropping KP probabilities. 3D-CNN is more robust to input perturbations.
161
+
162
+ <table><tr><td>Method/p</td><td>0</td><td>1/8</td><td>1/4</td><td>1/2</td><td>1</td></tr><tr><td>GCN</td><td>92.0</td><td>91.0</td><td>90.2</td><td>86.5</td><td>77.7</td></tr><tr><td>GCN w. robust training</td><td>90.9</td><td>91.0</td><td>91.0</td><td>91.0</td><td>90.6</td></tr><tr><td>Pose-SlowOnly</td><td>92.4</td><td>92.4</td><td>92.3</td><td>92.1</td><td>91.5</td></tr></table>
163
+
164
+ <table><tr><td rowspan="2"></td><td colspan="2">Train→Test</td></tr><tr><td>HQ→LQ LQ →HQ</td><td>LQ→LQ</td></tr><tr><td>GCN</td><td>79.3 87.9</td><td>89.0</td></tr><tr><td>3D-CNN</td><td>86.5</td><td>91.6 90.7</td></tr></table>
165
+
166
+ (a) Train/Test w. Pose from different estimators.
167
+
168
+ <table><tr><td rowspan="2"></td><td colspan="2">Train 1→Test</td></tr><tr><td>HQ→LQ LQ →HQ</td><td>LQ→LQ</td></tr><tr><td>GCN</td><td>78.5 89.1</td><td>82.9</td></tr><tr><td>3D-CNN</td><td>82.1</td><td>90.6 85.4</td></tr></table>
169
+
170
+ (b) Train/Test w. Pose extracted with different boxes.
171
+
172
+ Table 9: The design of RGBPose-Conv3D. Bi-directional lateral connections outperform unidirectional ones in the early stage feature fusion.
173
+
174
+ <table><tr><td></td><td>Late Fusion</td><td>RGB→Pose</td><td>Pose-→RGB</td><td>RGB←Pose</td></tr><tr><td>1-clip</td><td>92.6</td><td>93.0</td><td>93.4</td><td>93.6</td></tr><tr><td>10-clip</td><td>93.4</td><td>93.7</td><td>93.8</td><td>94.1</td></tr></table>
175
+
176
+ Table 10: The universality of RGBPose-Conv3D. The early+late fusion strategy works both on RGB-dominant NTU-60 and Pose-dominant FineGYM.
177
+
178
+ <table><tr><td></td><td>RGB</td><td>Pose</td><td>Late Fusion</td><td>Early+Late Fusion</td></tr><tr><td>FineGYM</td><td>87.2/88.5</td><td>91.0/92.0</td><td>92.6/93.4</td><td>93.6/94.1</td></tr><tr><td>NTU-60</td><td>94.1/94.9</td><td>92.8/93.2</td><td>95.5/96.0</td><td>96.2/96.5</td></tr></table>
179
+
180
+ # 4.5 RGBPOSE-CONV3D
181
+
182
+ The 3D-CNN architecture of PoseConv3D makes it more flexible to fuse pose with other modalities via some early fusion strategies. For example, in RGBPose-Conv3D, lateral connections between the $R G B$ -pathway and Pose-pathway are exploited for cross-modality feature fusion in the early stage. In practice, we first train two models for RGB and Pose modalities separately and use them to initialize the RGBPose-Conv3D. We continue to finetune the network for several epochs to train the lateral connections. The final prediction is achieved by late fusing the prediction scores from both pathways. RGBPose-Conv3D can achieve better fusing results with early+late fusion.
183
+
184
+ Our experiments are based on RGBPose-Conv3D instantiated as Table 12. We first compare unidirectional lateral connections and bi-directional lateral connections in Table 9. The result shows that bi-directional feature fusion is better than uni-directional ones for RGB and Pose. With bidirectional feature fusion in the early stage, the early+late fusion with 1-clip testing can outperform the late fusion with 10-clip testing. Besides, RGBPose-Conv3D also works in situations when the importance of two modalities is different. In FineGYM, Pose modality is more important, while in NTU-60, RGB modality is more important, yet we observe performance improvement by early+late fusion on both of them in Table 10.
185
+
186
+ # 5 CONCLUSION
187
+
188
+ In this work, we propose PoseConv3D: a 3D-CNN-based approach for skeleton-based action recognition, which takes 3D heatmap volumes as input. PoseConv3D resolves the limitations of GCNbased approaches in robustness, interoperability, and scalability. With light-weighted 3D-ConvNets and compact 3D heatmap volumes as input, PoseConv3D outperforms GCN-based approaches in both accuracy and efficiency. Based on PoseConv3D, we achieve state-of-the-art on both skeletonbased and multi-modality-based action recognition across multiple benchmarks.
189
+
190
+ # 6 REPRODUCIBILITY STATEMENT
191
+
192
+ Reproducing PoseConv3D doesn’t take much effort. The architectures of PoseConv3D (three backbones as well as their variants) and RGBPose-Conv3D are described in detail in Table 11, 12. We also demonstrate our practice of pose extraction in detail in Sec. A.2, as well as provide a jupyter notebook for illustration. We utilize opensource codebases for pose extraction, including MMDetection (Chen et al., 2019) and MMPose (Contributors, 2020). For reproducibility, we will also release the codes, estimated 2D poses for six datasets, and the trained checkpoints.
193
+
194
+ # REFERENCES
195
+
196
+ Carlos Caetano, Jessica Sena, Franc¸ois Bremond, Jefersson A Dos Santos, and William Robson ´ Schwartz. Skelemotion: A new representation of skeleton joint sequences based on motion information for 3d action recognition. In AVSS, pp. 1–8. IEEE, 2019. 3 Z. Cao, G. Hidalgo Martinez, T. Simon, S. Wei, and Y. A. Sheikh. Openpose: Realtime multi-person
197
+ 2d pose estimation using part affinity fields. TPAMI, 2019. 4 Zhe Cao, Tomas Simon, Shih-En Wei, and Yaser Sheikh. Realtime multi-person 2d pose estimation using part affinity fields. In CVPR, 2017. 4 Joao Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In CVPR, pp. 6299–6308, 2017. 1, 2, 4, 5, 15, 19 Kai Chen, Jiaqi Wang, Jiangmiao Pang, Yuhang Cao, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jiarui Xu, Zheng Zhang, Dazhi Cheng, Chenchen Zhu, Tianheng Cheng, Qijie Zhao, Buyu Li, Xin Lu, Rui Zhu, Yue Wu, Jifeng Dai, Jingdong Wang, Jianping Shi, Wanli Ouyang, Chen Change Loy, and Dahua Lin. MMDetection: Open mmlab detection toolbox and benchmark. arXiv:1906.07155, 2019. 10 Bowen Cheng, Bin Xiao, Jingdong Wang, Honghui Shi, Thomas S Huang, and Lei Zhang. Higherhrnet: Scale-aware representation learning for bottom-up human pose estimation. In CVPR,
198
+ 2020a. 4 Ke Cheng, Yifan Zhang, Xiangyu He, Weihan Chen, Jian Cheng, and Hanqing Lu. Skeleton-based action recognition with shift graph convolutional network. In CVPR, pp. 183–192, 2020b. 6 Vasileios Choutas, Philippe Weinzaepfel, Jer´ ome Revaud, and Cordelia Schmid. Potion: Pose mo-ˆ tion representation for action recognition. In CVPR, pp. 7024–7033, 2018. 3, 7, 19 MMPose Contributors. Openmmlab pose estimation toolbox and benchmark. https://github. com/open-mmlab/mmpose, 2020. 10 Srijan Das, Saurav Sharma, Rui Dai, Francois Bremond, and Monique Thonnat. Vpn: Learning video-pose embedding for activities of daily living. In ECCV, pp. 72–90. Springer, 2020. 2 Srijan Das, Rui Dai, Di Yang, and Francois Bremond. ${ \mathrm { V p n } } { + } { + }$ : Rethinking video-pose embeddings for understanding activities of daily living. arXiv:2105.08141, 2021. 7 Mahdi Davoodikakhki and KangKang Yin. Hierarchical action classification with network pruning. In ISVC, pp. 291–305. Springer, 2020. 7 Yong Du, Wei Wang, and Liang Wang. Hierarchical recurrent neural network for skeleton based action recognition. In CVPR, pp. 1110–1118, 2015. 1 Haodong Duan, Yue Zhao, Yuanjun Xiong, Wentao Liu, and Dahua Lin. Omni-sourced weblysupervised learning for video recognition. In ECCV, pp. 670–688. Springer, 2020. 7, 19 Christoph Feichtenhofer. X3d: Expanding architectures for efficient video recognition. In CVPR, pp. 203–213, 2020. 2, 5, 16 Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In ICCV, pp. 6202–6211, 2019. 2, 4, 5, 17, 20
199
+
200
+ Kensho Hara, Hirokatsu Kataoka, and Yutaka Satoh. Can spatiotemporal 3d cnns retrace the history of 2d cnns and imagenet? In CVPR, pp. 6546–6555, 2018. 5
201
+
202
+ Alejandro Hernandez Ruiz, Lorenzo Porzi, Samuel Rota Bulo, and Francesc Moreno-Noguer. 3d \` cnns on distance matrices for human action recognition. In MM, pp. 1087–1095, 2017. 3
203
+
204
+ Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv:1704.04861, 2017. 18
205
+
206
+ Mostafa S Ibrahim, Srikanth Muralidharan, Zhiwei Deng, Arash Vahdat, and Greg Mori. A hierarchical deep temporal model for group activity recognition. In CVPR, 2016. 2, 5, 8, 15
207
+
208
+ Shuiwang Ji, Wei Xu, Ming Yang, and Kai Yu. 3d convolutional neural networks for human action recognition. TPAMI, 35(1):221–231, 2012. 2
209
+
210
+ Qiuhong Ke, Mohammed Bennamoun, Senjian An, Ferdous Sohel, and Farid Boussaid. A new representation of skeleton sequences for 3d action recognition. In CVPR, 2017. 3
211
+
212
+ Muhammed Kocabas, Nikos Athanasiou, and Michael J Black. Vibe: Video inference for human body pose and shape estimation. In CVPR, pp. 5253–5263, 2020. 18
213
+
214
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. NeurIPS, 25:1097–1105, 2012. 15
215
+
216
+ Hildegard Kuehne, Hueihan Jhuang, Est´ıbaliz Garrote, Tomaso Poggio, and Thomas Serre. Hmdb: a large video database for human motion recognition. In ICCV, pp. 2556–2563. IEEE, 2011. 2, 5
217
+
218
+ Heeseung Kwon, Manjin Kim, Suha Kwak, and Minsu Cho. Learning self-similarity in space and time as generalized motion for action recognition. arXiv:2102.07092, 2021. 7
219
+
220
+ Bin Li, Xi Li, Zhongfei Zhang, and Fei Wu. Spatio-temporal graph routing for skeleton-based action recognition. In AAAI, volume 33, pp. 8561–8568, 2019a. 2
221
+
222
+ Bo Li, Junjie Yan, Wei Wu, Zheng Zhu, and Xiaolin Hu. High performance visual tracking with siamese region proposal network. In CVPR, pp. 8971–8980, 2018. 18
223
+
224
+ Maosen Li, Siheng Chen, Xu Chen, Ya Zhang, Yanfeng Wang, and Qi Tian. Actional-structural graph convolutional networks for skeleton-based action recognition. In CVPR, 2019b. 2, 6
225
+
226
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ ECCV, 2014. 4, 5, 14
227
+
228
+ Zeyi Lin, Wei Zhang, Xiaoming Deng, Cuixia Ma, and Hongan Wang. Image-based pose representation for action recognition and hand gesture recognition. In FG, pp. 532–539. IEEE, 2020. 3
229
+
230
+ Hong Liu, Juanhui Tu, and Mengyuan Liu. Two-stream 3d convolutional neural network for skeleton-based action recognition. arXiv:1705.08106, 2017. 3
231
+
232
+ Jun Liu, Amir Shahroudy, Mauricio Perez, Gang Wang, Ling-Yu Duan, and Alex C. Kot. Ntu rgb+d 120: A large-scale benchmark for 3d human activity understanding. TPAMI, 2019. doi: 10.1109/TPAMI.2019.2916873. 2, 3, 5, 13
233
+
234
+ Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv:2106.13230, 2021. 7, 21
235
+
236
+ Ziyu Liu, Hongwen Zhang, Zhenghao Chen, Zhiyong Wang, and Wanli Ouyang. Disentangling and unifying graph convolutions for skeleton-based action recognition. In CVPR, 2020. 2, 6, 8, 18, 20
237
+
238
+ Diogo C Luvizon, David Picard, and Hedi Tabia. 2d/3d pose estimation and action recognition using multitask deep learning. In CVPR, pp. 5137–5146, 2018. 3
239
+
240
+ Julieta Martinez, Rayat Hossain, Javier Romero, and James J Little. A simple yet effective baseline for 3d human pose estimation. In ICCV, pp. 2640–2649, 2017. 18 Alejandro Newell, Kaiyu Yang, and Jia Deng. Stacked hourglass networks for human pose estimation. In ECCV, pp. 483–499. Springer, 2016. 4 Alejandro Newell, Zhiao Huang, and Jia Deng. Associative embedding: End-to-end learning for joint detection and grouping. In NeurIPS, pp. 2277–2287, 2017. 4 Dario Pavllo, Christoph Feichtenhofer, David Grangier, and Michael Auli. 3d human pose estimation in video with temporal convolutions and semi-supervised training. In CVPR, 2019. 18 Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. arXiv:1506.01497, 2015. 5 Kohei Sendo and Norimichi Ukita. Heatmapping of people involved in group activities. In ICMVA,
241
+ 2019. 6 Amir Shahroudy, Jun Liu, Tian-Tsong Ng, and Gang Wang. Ntu rgb $+ \mathrm { d }$ : A large scale dataset for 3d human activity analysis. In CVPR, June 2016. 3, 5, 13, 19 Dian Shao, Yue Zhao, Bo Dai, and Dahua Lin. Finegym: A hierarchical video dataset for finegrained action understanding. In CVPR, pp. 2616–2625, 2020. 2, 5, 6, 14, 20 Lei Shi, Yifan Zhang, Jian Cheng, and Hanqing Lu. Skeleton-based action recognition with directed graph neural networks. In CVPR, pp. 7912–7921, 2019a. 6 Lei Shi, Yifan Zhang, Jian Cheng, and Hanqing Lu. Two-stream adaptive graph convolutional networks for skeleton-based action recognition. In CVPR, pp. 12026–12035, 2019b. 2, 6, 7 Lei Shi, Yifan Zhang, Jian Cheng, and Hanqing Lu. Decoupled spatial-temporal attention network for skeleton-based action recognition. arXiv:2007.03263, 2020. 6 Karen Simonyan and Andrew Zisserman. Two-stream convolutional networks for action recognition in videos. arXiv:1406.2199, 2014. 1 Yi-Fan Song, Zhang Zhang, Caifeng Shan, and Liang Wang. Richly activated graph convolutional network for robust skeleton-based action recognition. TSCVT, 31(5):1915–1925, 2020. 6 Khurram Soomro, Amir Roshan Zamir, and Mubarak Shah. Ucf101: A dataset of 101 human actions classes from videos in the wild. arXiv:1212.0402, 2012. 2, 5 Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. JMLR, 2014. 8 Ke Sun, Bin Xiao, Dong Liu, and Jingdong Wang. Deep high-resolution representation learning for human pose estimation. In CVPR, pp. 5693–5703, 2019. 4, 5, 15, 18 Du Tran, Lubomir Bourdev, Rob Fergus, Lorenzo Torresani, and Manohar Paluri. Learning spatiotemporal features with 3d convolutional networks. In ICCV, 2015. 1, 2, 5, 15 Du Tran, Heng Wang, Lorenzo Torresani, Jamie Ray, Yann LeCun, and Manohar Paluri. A closer look at spatiotemporal convolutions for action recognition. In CVPR, pp. 6450–6459, 2018. 2 Du Tran, Heng Wang, Lorenzo Torresani, and Matt Feiszli. Video classification with channelseparated convolutional networks. In ICCV, pp. 5552–5561, 2019. 2 Raviteja Vemulapalli, Felipe Arrate, and Rama Chellappa. Human action recognition by representing 3d skeletons as points in a lie group. In CVPR, pp. 588–595, 2014. 1 Jiang Wang, Zicheng Liu, Ying Wu, and Junsong Yuan. Mining actionlet ensemble for action recognition with depth cameras. In CVPR, pp. 1290–1297. IEEE, 2012. 1 Limin Wang, Yuanjun Xiong, Zhe Wang, Yu Qiao, Dahua Lin, Xiaoou Tang, and Luc Van Gool. Temporal segment networks: Towards good practices for deep action recognition. In ECCV,
242
+ 2016. 1, 4
243
+ Philippe Weinzaepfel, Romain Bregier, Hadrien Combaluzier, Vincent Leroy, and Gr ´ egory Rogez. ´ Dope: Distillation of part experts for whole-body 3d pose estimation in the wild. In ECCV, 2020. 18
244
+ Bin Xiao, Haiping Wu, and Yichen Wei. Simple baselines for human pose estimation and tracking. In ECCV, 2018. 4
245
+ Fanyi Xiao, Yong Jae Lee, Kristen Grauman, Jitendra Malik, and Christoph Feichtenhofer. Audiovisual slowfast networks for video recognition. arXiv:2001.08740, 2020. 1
246
+ An Yan, Yali Wang, Zhifeng Li, and Yu Qiao. Pa3d: Pose-action 3d machine for video recognition. In CVPR, pp. 7922–7931, 2019. 3, 7, 19
247
+ Sijie Yan, Yuanjun Xiong, and Dahua Lin. Spatial temporal graph convolutional networks for skeleton-based action recognition. In AAAI, volume 32, 2018. 1, 2, 4, 5, 6, 20, 21
248
+ Hao Yang, Dan Yan, Li Zhang, Dong Li, YunDa Sun, ShaoDi You, and Stephen J Maybank. Feedback graph convolutional network for skeleton-based action recognition. arXiv:2003.07564, 2020. 6
249
+ Zhengyou Zhang. Microsoft kinect sensor and its effect. IEEE multimedia, 19(2):4–10, 2012. 18, 19
250
+ Dingyuan Zhu, Ziwei Zhang, Peng Cui, and Wenwu Zhu. Robust graph convolutional networks against adversarial attacks. In KDD, pp. 1399–1407, 2019. 1, 2
251
+
252
+ ![](images/73eede5b83415fea67172f02395d524324d5ebbbda23a2a0270810fc6c6cd369.jpg)
253
+ Figure 5: The extracted skeletons of the NTURGB ${ \bf + D }$ dataset. The actions of the visualized frames are: “cheer up”, “touch other person’s pocket”, “jump up”, “put the palms together”, “taking a selfie”, “shake fist”.
254
+
255
+ # A APPENDIX
256
+
257
+ # A.1 VISUALIZATION
258
+
259
+ We provide more visualization of the extracted pose of the four datasets: FineGYM, NTURGB $+ \mathbf { D }$ , Kinetics400, Volleyball to demonstrate the performance of the proposed pose extraction approach qualitatively. The videos corresponding to the visualized frames are also provided in supplementary materials.
260
+
261
+ NTURGB ${ \bf + D }$ (Shahroudy et al., 2016; Liu et al., 2019). Figure 5 displays some examples of extracted skeletons of NTURGB $+ \mathbf { D }$ . Our pose extractor achieves almost perfect performance on
262
+
263
+ ![](images/eae9cab404325265efbd58d3bb063a7294bfeae6f87cbaad1f070578f1c353ee.jpg)
264
+ Figure 6: The extracted skeletons of the FineGYM dataset. The extracted skeletons are far from perfect, but discriminative enough for action recognition.
265
+
266
+ ![](images/1f7aca5b94afb5fc4b26951aec4124934edd08a0940f3848953832bdebcbae27.jpg)
267
+ Figure 7: The extracted skeletons of the Kinetics400 dataset.
268
+
269
+ NTURGB $+ \mathbf { D }$ due to the simple scenarios: the background scene is not complicated, while there are two persons at most in each frame, with little occlusion.
270
+
271
+ FineGYM (Shao et al., 2020). Figure 6 displays some examples of extracted skeletons of FineGYM. Although we perform pose extraction with ground-truth bounding boxes of the athletes, the extracted 2D poses are far from perfect. The pose extractor is extremely easy to make mistakes for poses the rarely occur in COCO-keypoint (Lin et al., 2014) or when motion blur occurs. Even though the quality of extracted skeletons are not satisfying, they are still discriminative enough for skeleton-based action recognition.
272
+
273
+ ![](images/b43687e0b22bd443de35ee16fdd9ca87307e0b5a6e67723aebe1cc6dd1a1885b.jpg)
274
+ Figure 8: The extracted skeletons of the Volleyball dataset.
275
+
276
+ Kinetics400 (Carreira & Zisserman, 2017). Kinetics400 is not a human-centric dataset for action recognition. In Kinetics videos, the person locations, scales, and the number of persons may vary a lot, which makes extracting human skeletons of Kinetics400 much more difficult than NTURGB $+ \mathbf { D }$ or FineGYM. In Figure 7, we provide some examples that our pose estimator accurately predicts the human skeletons. We also discuss some failure cases in Sec. A.4.6.
277
+
278
+ Volleyball (Ibrahim et al., 2016). Volleyball is a group activity recognition dataset. Each frame of a video contains around a dozen people (six for each team). Most of the human poses in a volleyball video are regular ones (unlike FineGYM). In Figure 8, we see that our pose extractor can predict the human pose of each person accurately.
279
+
280
+ # A.2 ILLUSTRACTION OF GENERATING PSEUDO HEATMAP VOLUMES.
281
+
282
+ In this section, we illustrate how we generate the pseudo heatmap volumes, the input of PoseConv3D. We also provide a jupyter notebook named GenPseudoHeatmaps.ipynb in supplementary materials, which can extract skeleton keypoints from RGB videos (optional) and generate pseudo heatmaps based on the skeleton keypoints.
283
+
284
+ Figure 9 illustrates the pipeline of pose extraction (RGB video coordinate-triplets) and generating pseudo heatmap volumes (coordinate-triplets $ 3 \mathrm { D }$ heatmap volumes). The visualization in Figure 9 is just for one frame, while you can find the visualization for the entire video in the jupyter notebook. Since the heatmaps are of $K$ channels ( $K = 1 7$ for COCO-keypoints), we visualize the heatmap in one 2D image with color encoding. The pose extraction part is straight-forward: we use a Top-Down pose estimator instantiated with HRNet (Sun et al., 2019) to extract the 2D poses for each person in each frame, and save the extracted poses as coordinate-triplets: (x, y, score). For generating pseudo heatmaps, we first perform uniform sampling, which will sample $T$ ( $T = 3 2$ or 48 in experiments) frames uniformly from the video and discard the remaining frames. After that, we will find a global cropping box (The red box in Figure 9, same for all $T$ frames) that envelops all persons in the video, and crop all $T$ frames with that box to reduce the spatial size (as illustrated in Figure 9). In GenPseudoHeatmaps.ipynb, you can run the entire pipeline to process a video from the NTURGB-D dataset.
285
+
286
+ # A.3 THE ARCHITECTURE OF POSECONV3D AND RGBPOSE-CONV3D
287
+
288
+ # A.3.1 DIFFERENT VARIANTS OF POSECONV3D.
289
+
290
+ In Table 11, we demonstrate the architectures of the three backbones we adapted from RGB-based action recognition as well as their variants:
291
+
292
+ C3D (Tran et al., 2015). C3D is one of the earliest 3D-CNN developed for RGB-based action recognition (like AlexNet (Krizhevsky et al., 2012) for image recognition), which consists of eight
293
+
294
+ ![](images/94d2cc54025e3f2276d257d08c470b4eb05fcbd5f162620e084997e5f823090f.jpg)
295
+ Figure 9: The pipeline of generating the input of PoseConv3D. Left, Pose Extraction: We perform TopDown pose estimation for each single frame. The estimated 2D poses are saved as coordinate-triplets: (x, y, score). Right, Generating Pseudo Heatmap Volumes: Based on the coordinate-triplets, we generate pseudo heatmaps for joints and limbs using Eq 1, 2. We perform subjects-centered cropping and uniform sampling to make the heatmap volumes compact.
296
+
297
+ Table 11: The architecture of PoseConv3D instantiated with three backbones: C3D, X3D, SlowOnly. The dimensions of kernels are denoted by $T \times S ^ { 2 } , C$ for temporal, spatial, channel sizes. Strides are denoted with $T , S ^ { 2 }$ for temporal and spatial strides. GAP denotes global average pooling.
298
+
299
+ <table><tr><td rowspan=1 colspan=1>stage</td><td rowspan=1 colspan=1>C3D-s</td><td rowspan=1 colspan=1>C3D</td><td rowspan=1 colspan=3>X3D-s</td><td rowspan=1 colspan=3>X3D</td><td rowspan=1 colspan=3>SlowOnly</td><td rowspan=1 colspan=2>SlowOnly-wd</td><td rowspan=1 colspan=3>SlowOnly-HR</td></tr><tr><td rowspan=1 colspan=1>data layer</td><td rowspan=1 colspan=13>Uniform 48,56×56</td><td rowspan=1 colspan=3>Uniform 48,112 ×112</td></tr><tr><td rowspan=1 colspan=1>stem layer</td><td rowspan=1 colspan=2>conv 3x3²,32</td><td rowspan=1 colspan=6>conv 1×32,24stride 1,2²conv 5x12, 24</td><td rowspan=1 colspan=3>conv 1×7²,32</td><td rowspan=1 colspan=2>conv 1×7², 64</td><td rowspan=1 colspan=3>conv 1×7²,32</td></tr><tr><td rowspan=1 colspan=1>stage1</td><td rowspan=1 colspan=2>maxpool 1×2²[3×3²,64]×1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×12,543×3²,541×12,24</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×12,543×3²,541×12,24</td><td rowspan=1 colspan=1>×5</td><td rowspan=1 colspan=5>None</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×12,321×3²,321×1²,128</td><td rowspan=1 colspan=1>×3</td></tr><tr><td rowspan=1 colspan=1>stage2</td><td rowspan=1 colspan=2>maxpool 1×22[3×3²,128]×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×12,1083×3²,1081×12,48</td><td rowspan=1 colspan=1>×5</td><td rowspan=1 colspan=2>1×12,1083×3²,1081×12,48</td><td rowspan=1 colspan=1>×11</td><td rowspan=1 colspan=2>1×1,321×3²,321×1²,128</td><td rowspan=1 colspan=1>×4</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>1×12,641×3²,641×1²,256</td><td rowspan=1 colspan=1>×4</td></tr><tr><td rowspan=1 colspan=1>stage3</td><td rowspan=1 colspan=2>maxpool 1×2²[3×3²,256]×2</td><td></td><td rowspan=1 colspan=1>1×1²,2163×32,2161×1²,96</td><td rowspan=1 colspan=1>×3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×1²,2163×32,2161×12,96</td><td rowspan=1 colspan=1>×7</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×12,641×32,641×1²,256</td><td rowspan=1 colspan=1>×6</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>3×12,1281×32,1281×1²,512</td><td rowspan=1 colspan=1>×6</td></tr><tr><td rowspan=1 colspan=1>stage4</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>[3×3²,256]×2</td><td rowspan=1 colspan=6>conv 1×1²,216</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×12,1281×32,1281×1²,512</td><td rowspan=1 colspan=1>×3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>3×12,2561×32,2561×1²,1024</td><td rowspan=1 colspan=1>×3</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=16>GAP, fc</td></tr></table>
300
+
301
+ 3D convolution layers. To adapt C3D for skeleton-based action recognition, we reduce its channelwidth to half $( 6 4 3 2 )$ ) for better efficiency. In addition, for Pose-C3D-s, we remove the last two convolution layers.
302
+
303
+ X3D (Feichtenhofer, 2020). X3D is a recent state-of-the-art 3D-CNN for action recognition. Replacing vanilla convolutions with depth-wise convolutions, X3D achieves competitive recognition performance with tiny amounts of parameters and FLOPs. The architecture of the adapted PoseX3D is almost unchanged compared to the original X3D-S, except that we remove the original first stage. For Pose-X3D-s, we remove convolution layers from each stage uniformly by changing the hyper-parameter $\gamma _ { d }$ from 2.2 to 1.
304
+
305
+ Table 12: RGBPose-Conv3D instantiated with the SlowOnly backbone. The dimensions of kernels are denoted by $T \times S ^ { 2 } , C$ for temporal, spatial, channel sizes. Strides are denoted with $T , S ^ { 2 }$ for temporal and spatial strides. The backbone we use is ResNet50. GAP denotes global average pooling.
306
+
307
+ <table><tr><td rowspan=1 colspan=1>stage</td><td rowspan=1 colspan=3>RGBPathway</td><td rowspan=1 colspan=3>Pose Pathway</td><td rowspan=1 colspan=1>output sizes T×S2</td></tr><tr><td rowspan=1 colspan=1>data layer</td><td rowspan=1 colspan=3>uniform 8,1²</td><td rowspan=1 colspan=3>uniform 32,4²</td><td rowspan=1 colspan=1>RGB:8×2242Pose: 32×562</td></tr><tr><td rowspan=1 colspan=1> stem layer</td><td rowspan=1 colspan=3>conv 1×7²,64stride 1, 2²maxpool1×3²stride 1, 2²</td><td rowspan=1 colspan=3>conv 1×7²,32stride 1,1²</td><td rowspan=1 colspan=1>RGB:8×562Pose: 32×562</td></tr><tr><td rowspan=1 colspan=1>res2</td><td rowspan=1 colspan=2>1×1²,641×3²,641×1²,256</td><td rowspan=1 colspan=1>×3</td><td rowspan=1 colspan=3>N.A.</td><td rowspan=1 colspan=1>RGB:8×562Pose: 32×562</td></tr><tr><td rowspan=1 colspan=1>res3</td><td rowspan=1 colspan=2>1×1²,1281×3²,1281×1²,512</td><td rowspan=1 colspan=1>×4</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1×1²,321×3²,321×1²,128</td><td rowspan=1 colspan=1>×4</td><td rowspan=1 colspan=1>RGB:8×282Pose: 32×282</td></tr><tr><td rowspan=1 colspan=1>res4</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×1²,2561×3²,2561×1²,1024</td><td rowspan=1 colspan=1>×6</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×1²,641×3²,641×1²,256</td><td rowspan=1 colspan=1>×6</td><td rowspan=1 colspan=1>RGB: 8×14²Pose: 32×142</td></tr><tr><td rowspan=1 colspan=1>res5</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×1²,5121×3²,5121×1²,2048</td><td rowspan=1 colspan=1>×3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>3×1²,1281×3²,1281×1²,512</td><td rowspan=1 colspan=1>×3</td><td rowspan=1 colspan=1>RGB: 8×72Pose: 32×72</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>GAP, fc</td><td rowspan=1 colspan=3>GAP, fc</td><td rowspan=1 colspan=1># classes</td></tr></table>
308
+
309
+ SlowOnly (Feichtenhofer et al., 2019). SlowOnly is a popular 3D-CNN used for RGB-based action recognition. It is obtained by inflating the ResNet layers in the last two stages from 2D to 3D. To adapt SlowOnly for skeleton-based action recognition, we reduce its channel-width to half $6 4 3 2$ ) as well as remove the original first stage in the network. We also have conducted experiments with Pose-SlowOnly-wd (with channel-width 64) and Pose-SlowOnly-HR (with $2 \mathbf { x }$ larger input and deeper network). There is no performance improvement despite the much heavier backbone.
310
+
311
+ # A.3.2 RGBPOSE-CONV3D INSTANTIATED WITH SLOWONLY.
312
+
313
+ RGBPose-Conv3D is a general framework for RGB-Pose dual-modality action recognition, which can be instantiated with various 3D-CNN backbones. In this work, we instantiate both pathways with the SlowOnly network. As shown in Table 12, the RGB pathway has a smaller frame rate and a larger channel width since RGB frames are low-level features. On the contrary, the Pose pathway has a larger frame rate and a smaller channel width. Time stride convolutions are used as bi-directional lateral connections between the two pathways (after $\mathrm { r e s _ { 3 } }$ and $\mathrm { r e s } _ { 4 }$ ) so that semantics of different modalities can sufficiently interact. Besides lateral connections, the predictions of two pathways are also combined in a late fusion manner, which leads to further improvements in our empirical study. RGBPose-Conv3D is trained with two individual losses respectively for each pathway, as a single loss that jointly learns from two modalities leads to severe overfitting.
314
+
315
+ # A.4 SUPPLEMENTARY EXPERIMENTS
316
+
317
+ # A.4.1 ABLATION STUDY ON POSE EXTRACTION
318
+
319
+ This section discusses different alternatives that can be adopted in pose extraction to validate our choice. The input size for all 3D-CNN experiments is $T \times H \times W = 4 8 \times 5 6 \times 5 6$ .
320
+
321
+ 2D v.s. 3D Skeletons. We first compare the recognition performance of using 2D and 3D skeletons for action recognition. The 3D skeletons are either collected by sensors (NTU-60) or estimated
322
+
323
+ Table 13: Ablation study on Pose Extraction.
324
+
325
+ <table><tr><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=1>GYM</td></tr><tr><td rowspan=1 colspan=1>DOPE (Weinzaepfel et al., 2020)</td><td rowspan=1 colspan=1>76.3</td></tr><tr><td rowspan=1 colspan=1>VIBE (Kocabas et al., 2020)</td><td rowspan=1 colspan=1>87.0</td></tr><tr><td rowspan=1 colspan=1>FrameLift (Martinez et al.,2017)</td><td rowspan=1 colspan=1>90.0</td></tr><tr><td rowspan=1 colspan=1>VideoLift (Pavllo et al.,2019)</td><td rowspan=1 colspan=1>90.2</td></tr><tr><td rowspan=1 colspan=1>HRNet-2D (Sun et al.,2019)</td><td rowspan=1 colspan=1>92.0</td></tr></table>
326
+
327
+ <table><tr><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=1>GYM NTU-60</td></tr><tr><td rowspan=1 colspan=1>Kinect-3D (Zhang, 2012)</td><td rowspan=1 colspan=1>N.A. 89.4</td></tr><tr><td rowspan=1 colspan=1>DOPE-3D (Weinzaepfel et al., 2020)</td><td rowspan=1 colspan=1>76.3 N.A.</td></tr><tr><td rowspan=1 colspan=1>VIBE-3D (Kocabas et al., 2020)</td><td rowspan=1 colspan=1>87.0 N.A.</td></tr><tr><td rowspan=1 colspan=1>HRNet-2D (Sun et al., 2019)</td><td rowspan=1 colspan=1>92.0 91.9</td></tr><tr><td rowspan=1 colspan=1>MobileNet-2D (Howard et al., 2017)</td><td rowspan=1 colspan=1>89.0 90.2</td></tr></table>
328
+
329
+ (a) 2D skeleton v.s. 3D skeleton.
330
+
331
+ (b) 3D-pose from a ‘lifting’ model doesn’t help in recognition.
332
+
333
+ <table><tr><td rowspan=1 colspan=1>Proposals</td><td rowspan=1 colspan=1>GYMMean-Topl</td></tr><tr><td rowspan=1 colspan=1>Detection</td><td rowspan=1 colspan=1>75.8</td></tr><tr><td rowspan=1 colspan=1>Tracking</td><td rowspan=1 colspan=1>85.3</td></tr><tr><td rowspan=1 colspan=1>GT</td><td rowspan=1 colspan=1>92.0</td></tr></table>
334
+
335
+ (d) Pose extracted with different boxes.
336
+
337
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>COCO AP</td><td rowspan=1 colspan=1>NTU-60</td></tr><tr><td rowspan=1 colspan=1>HRNet (Top-Down)</td><td rowspan=1 colspan=1>0.746</td><td rowspan=1 colspan=1>93.6</td></tr><tr><td rowspan=1 colspan=1>HRNet (Bottom-Up)</td><td rowspan=1 colspan=1>0.654</td><td rowspan=1 colspan=1>93.0</td></tr><tr><td rowspan=1 colspan=1>Mobile (Top-Down)</td><td rowspan=1 colspan=1>0.646</td><td rowspan=1 colspan=1>92.0</td></tr></table>
338
+
339
+ (c) Top-Down v.s. Bottom-Up approaches for pose estimation.
340
+
341
+ <table><tr><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=1>GYMMean-Topl</td></tr><tr><td rowspan=1 colspan=1>Coordinate-MobileNet</td><td rowspan=1 colspan=1>90.7</td></tr><tr><td rowspan=1 colspan=1>Coordinate-HRNet</td><td rowspan=1 colspan=1>93.2</td></tr><tr><td rowspan=1 colspan=1>Heatmap-MobileNet</td><td rowspan=1 colspan=1>92.7</td></tr><tr><td rowspan=1 colspan=1>Heatmap-HRNet</td><td rowspan=1 colspan=1>93.6</td></tr></table>
342
+
343
+ (e) Coordinate v.s. Heatmap.
344
+
345
+ with state-of-the-art 3D pose estimators based on RGB inputs (Weinzaepfel et al., 2020; Kocabas et al., 2020) (FineGYM). For a fair comparison, we use MS-G3D (Liu et al., 2020) (the current state-of-the-art GCN for skeleton-based action recognition) with the same configuration and training schedule for 2D and 3D keypoints and list the results in Table 13a. The estimated 2D keypoints (even low-quality ones) consistently outperform 3D keypoints (sensor collected or estimated) in action recognition. Besides RGB-based 3D-pose estimators, we also consider the ‘lifting’ approaches (Martinez et al., 2017; Pavllo et al., 2019), which directly ‘lift’ 2D-pose (sequences) to 3D-pose (sequences). We regress the 3D poses based on 2D poses extracted with HRNet, use the lifted 3D poses for action recognition. The results in Table 13b indicate that such lifted 3D poses do not provide any additional information, performs even worse than the original 2D poses in action recognition.
346
+
347
+ Bottom-Up v.s. Top-Down. To compare the pose estimation quality of Bottom-Up and Top-Down approaches, we instantiate the two approaches with the same backbone (HRNet-w32). Besides, we also instantiate the Top-Down approach with the MobileNet-v2 backbone for comparison, which has a similar performance to HRNet (Bottom-Up) on COCO-validation. We use extracted 2D poses to train a Pose-SlowOnly on NTU-60. Table 13c shows that the performance of HRNet (Bottom-Up) on COCO-val is much worse than HRNet (Top-Down) and close to MobileNet (Top-Down). However, the Top-1 accuracy of HRNet (Bottom-Up) is much higher than MobileNet (Top-Down) and close to HRNet (Top-Down). Although the potential of Bottom-Up should not be neglected, considering the better performance and faster inference speed (Top-Down runs faster when there aren’t many persons in a frame), we use Top-Down for pose extraction in this work.
348
+
349
+ Interested Person v.s. All Persons. Many people may exist in a video, but not all of them are related to the interested action. For example, in FineGYM, only the pose of the athlete is helpful, while other persons like the audience or referee are unrelated. We compare using 3 kinds of person bounding boxes for pose extraction: Detection, Tracking(with Siamese-RPN (Li et al., 2018)) and GT (with increasing prior about the athlete). In Table 13d, we see that the prior of the interested person is extremely important: even weak prior knowledge (1 GT box per video) can improve the performance by a large margin.
350
+
351
+ Coordinates v.s. Heatmaps. Storing 3D heatmap volumes may take vast amounts of disk space. To be more efficient, we can save the 2D poses as coordinate-triplets (x, y, score) and restore them to 3D heatmap volumes following the methods we introduced in Sec. 3.2. We conduct experiments on FineGYM to explore how much information is lost during the heatmap coordinate compression. In Table 13e, we see that for low-quality pose estimators, it leads to a $2 \%$ drop in Mean-Top1. For high-quality ones, the degradation is more moderate (only a $0 . 4 \%$ Mean-Top1 drop). Thus we choose to store coordinates instead of 3D heatmap volumes.
352
+
353
+ Table 14: Transferring Ability. Skeleton representations learned on the large-scale Kinetics400 can transfer to downstream datasets well. Backbone parameters are frozen for the ‘Linear’ setting.
354
+
355
+ <table><tr><td>PoseConv3D</td><td>HMDB51</td><td>UCF101</td></tr><tr><td>Scratch</td><td>58.6</td><td>79.1</td></tr><tr><td>Linear</td><td>64.9</td><td>83.1</td></tr><tr><td>Finetune</td><td>69.3</td><td>87.0</td></tr></table>
356
+
357
+ Table 15: Comparison with state-of-the-art multi-modality action recognition approaches.
358
+
359
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>HMDB51</td><td rowspan=1 colspan=1>UCF101</td></tr><tr><td rowspan=1 colspan=1>I3D (Carreira &amp; Zisserman, 2017)</td><td rowspan=1 colspan=1>80.7</td><td rowspan=1 colspan=1>98.0</td></tr><tr><td rowspan=1 colspan=1>PoTion (Choutas et al.,2018)</td><td rowspan=1 colspan=1>43.7</td><td rowspan=1 colspan=1>65.2</td></tr><tr><td rowspan=1 colspan=1>PoTion+I3D</td><td rowspan=1 colspan=1>80.9</td><td rowspan=1 colspan=1>98.2</td></tr><tr><td rowspan=1 colspan=1> PA3D (Yan et al., 2019)</td><td rowspan=1 colspan=1>55.3</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>PA3D + I3D</td><td rowspan=1 colspan=1>82.1</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>PoseConv3D</td><td rowspan=1 colspan=1>69.3</td><td rowspan=1 colspan=1>87.0</td></tr><tr><td rowspan=1 colspan=1>PoseConv3D + I3D</td><td rowspan=1 colspan=1>82.7</td><td rowspan=1 colspan=1>98.4</td></tr></table>
360
+
361
+ # A.4.2 MULTI-MODALITY RESULTS ACTION RECOGNITION ON UCF101 AND HMDB51
362
+
363
+ In Table 5, we train different PoseConv3D on UCF101 and HMDB51 from scratch. In this section, we demonstrate that PoseConv3D can also take advantage of pretraining on large-scale datasets. We adopt weights pretrained on Kinetics400 to initialize the PoseConv3D. Pretraining with skeleton data from the large-scale Kinetics400 benefits the downstream recognition tasks on smaller datasets, under both ‘Linear’ and ‘Finetune’ paradigms (Table 14).
364
+
365
+ We further compare PoseConv3D with previous state-of-the-arts of skeleton-based action recognition on UCF101 and HMDB51: PoTion (Choutas et al., 2018) and PA3D (Yan et al., 2019). For a fair comparison, we fuse the skeleton-based predictions with I3D (Carreira & Zisserman, 2017) predictions, instead of predictions from the more advanced OmniSource (Duan et al., 2020). Table 15 shows that PoseConv3D not only outperforms other approaches by a large margin on skeleton-based action recognition, but also leads to better overall performance after fusing with predictions based on other modalities.
366
+
367
+ # A.4.3 USING 3D SKELETONS IN POSECONV3D
368
+
369
+ PoseConv3D takes stacked 2D skeleton keypoint heatmaps as input. Assume only 3D skeletons are available for a target dataset, one can also use the 3D skeletons in PoseConv3D by projecting them to a 2D plane. The NTURGB $+ \mathbf { D }$ dataset (Shahroudy et al., 2016) provides 3D skeleton sequences collected by Microsoft Kinect v2 sensors (Zhang, 2012). Besides, the dataset also includes the projection of 3D joints onto the 2D image coordinate systems. We use the projected 2D skeletons of NTU-60 as the input for PoseConv3D and study the effect.
370
+
371
+ Table 16 demonstrates the recognition performance of using projected 2D skeletons in PoseConv3D. Using the projected 2D skeletons as inputs instead of the original 3D skeletons, there is a $2 \%$ Top-1 accuracy drop for MS-G3D due to the information lost in $3 \mathrm { D } 2 \mathrm { D }$ compression. If both use 2D skeletons as input, PoseConv3D outperforms the GCN-based counterpart by $2 . 4 \%$ , even surpasses the MS-G3D with 3D skeletons as input by $0 . 4 \%$ , which indicates the great spatiotemporal modeling capability of 3D-CNN can compensate for the information lost in $3 \mathrm { D } 2 \mathrm { D }$ projection.
372
+
373
+ # A.4.4 UNIFORM SAMPLING FOR RGB-BASED RECOGNITION
374
+
375
+ Based on the outstanding improvement by uniform sampling on skeleton-based action recognition, we wonder if this sampling strategy also works for RGB-based action recognition. Thus we apply uniform sampling to RGB-based action recognition on NTU-60 (Shahroudy et al., 2016) and
376
+
377
+ Table 16: PoseConv3D with projected 2D poses. We report the recognition performance of the joint model.
378
+
379
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Top-1</td></tr><tr><td rowspan=1 colspan=1>2D-projection + MS-G3D (Liu et al., 2020)</td><td rowspan=1 colspan=1>86.8</td></tr><tr><td rowspan=1 colspan=1>3D-skeleton + MS-G3D (Liu et al., 2020)</td><td rowspan=1 colspan=1>88.85</td></tr><tr><td rowspan=1 colspan=1>2D-projection +PoseConv3D</td><td rowspan=1 colspan=1>89.2</td></tr></table>
380
+
381
+ Table 17: Uniform sampling also works for RGB-based action recognition. Alls results are for 10-clip testing, except the ‘uniform-16 (1c)’, which uses 1-clip testing.
382
+ (a) FineGYM.
383
+
384
+ <table><tr><td rowspan=1 colspan=1>Sampling</td><td rowspan=1 colspan=1>Mean-Top1</td></tr><tr><td rowspan=1 colspan=1>16x2</td><td rowspan=1 colspan=1>87.9</td></tr><tr><td rowspan=1 colspan=1>16x4</td><td rowspan=1 colspan=1>88.7</td></tr><tr><td rowspan=1 colspan=1>uniform-16 (1c)</td><td rowspan=1 colspan=1>91.1</td></tr><tr><td rowspan=1 colspan=1>uniform-16</td><td rowspan=1 colspan=1>91.6</td></tr></table>
385
+
386
+ (b) NTU-60 (X-Sub)
387
+
388
+ <table><tr><td rowspan=1 colspan=1>Sampling</td><td rowspan=1 colspan=1>Top1</td></tr><tr><td rowspan=1 colspan=1>16x2</td><td rowspan=1 colspan=1>94.9</td></tr><tr><td rowspan=1 colspan=1>16x4</td><td rowspan=1 colspan=1>95.1</td></tr><tr><td rowspan=1 colspan=1>uniform-16 (1c)</td><td rowspan=1 colspan=1>95.7</td></tr><tr><td rowspan=1 colspan=1>uniform-16</td><td rowspan=1 colspan=1>96.1</td></tr></table>
389
+
390
+ GYM (Shao et al., 2020). We use SlowOnly-R50 (Feichtenhofer et al., 2019) as the backbone and set the input length as 16 frames. From Table 17, we see that uniform sampling also outperforms fix-stride sampling by a large margin in RGB-based recognition on these two datasets: the accuracy of uniform sampling with 1-clip testing is better than the accuracy of fix-stride sampling with 10-clip testing. We mainly attribute the advantage of uniform sampling to the highly variable video lengths in these two datasets. On the contrary, we observe a slight accuracy drop on Kinetics $4 0 0 ^ { 6 }$ when applying uniform sampling: for SlowOnly-R50 with input length 8, the Top-1 accuracy drops from $7 5 . 6 \%$ to $7 5 . 2 \%$ .
391
+
392
+ # A.4.5 NTU-60 ERROR ANALYSIS
393
+
394
+ On NTU-60 X-Sub split, we achieve $9 4 . 1 \%$ Top-1 accuracy with skeleton-based action recognition, which outperforms the current state-of-the-art result by $2 . 6 \%$ . To further study the failure cases, we first define the confusion score $s$ of a pair of the action classes $i , j$ as:
395
+
396
+ $$
397
+ s = n _ { i j } + n _ { j i }
398
+ $$
399
+
400
+ $n _ { i j }$ indicates the number of videos belong to the class $i$ but recognized as class $j$ . In NTU-60, there are 1770 pairs of action classes in total, while we list the five most confusing pairs in Table 18. Most failure cases are of these top-confusing pairs, e.g., over $27 \%$ failure cases are of the top 5 confusion pairs. It is hard to distinguish these pairs of actions with human skeletons only.
401
+
402
+ Some confusing pairs can be resolved by exploiting other modalities such as RGB appearance. If the model successfully recognizes the keyboard, then it can distinguish typing from writing. Table 18 shows that, with multi-modality fusion in RGBPose-Conv3D, the recognition performance on those confusing pairs improves a lot.
403
+
404
+ # A.4.6 WHY SKELETON-BASED POSE ESTIMATION PERFORMS POORLY ON KINETICS400
405
+
406
+ PoseConv3D with high-quality 2D skeletons improves the Top-1 accuracy of skeleton-based action recognition on Kinetics400 from $3 8 . 0 \%$ to $4 7 . 7 \%$ . However, the accuracy on Kinetics400 is still far below the accuracies on other datasets. Besides the difficulties mentioned in Sec. A.1, two more problems will degrade the quality of extracted skeleton sequences (Figure 10): 1. Since Kinetics400 is not human-centric, human skeletons are missing or hard to recognize in many frames. 2. For the same reason, only small parts of humans appear in many frames, while the pose estimators are easy to fail in this scenario.
407
+
408
+ We also report the mean class accuracy on Kinetics-Motion (Yan et al., 2018) in Table 19, which contains 30 action classes in Kinetics that are strongly related to body motions. The accuracy of skeleton-based action recognition is much higher on this subset, increasing from $4 7 . 7 \%$ to $8 1 . 9 \%$ .
409
+
410
+ Table 18: Top 5 confusion pairs of skeleton-based action recognition on NTU-60 X-Sub. Multi-modality fusion with RGBPose-Conv3D improves the recognition performance on confusion pairs by a lot.
411
+
412
+ <table><tr><td>Action1</td><td>Action2</td><td>score [Pose]</td><td>score [RGB +Pose]</td></tr><tr><td>Read</td><td>Play with phone/tablet</td><td>67</td><td>13</td></tr><tr><td>Write</td><td>Type on a keyboard</td><td>57</td><td>20</td></tr><tr><td>Write</td><td>Play with phone/tablet</td><td>50</td><td>5</td></tr><tr><td>Take a selfie</td><td>Point to sth.with finger</td><td>48</td><td>10</td></tr><tr><td>Read</td><td>Write</td><td>44</td><td>24</td></tr></table>
413
+
414
+ ![](images/f5fc8e8557be9f3a6c2d1d219da799fc906f040c872e00953b2ad34182055075.jpg)
415
+ Figure 10: Problems in Kinetics400 Pose Extraction. Left: Human missing in action ‘kayaking’. Middle: Human skeleton is too small to be recognized in action ‘diving cliff’. Right: Only human parts appear, the pose estimator fails (‘washing feet’).
416
+
417
+ Table 19: Mean class accuracy on the Kinetics-Motion subset.
418
+
419
+ <table><tr><td rowspan=1 colspan=1>Test Set</td><td rowspan=1 colspan=1>Kinetics-Motion</td></tr><tr><td rowspan=1 colspan=1>Swin-L (Liu et al., 2021)</td><td rowspan=1 colspan=1>92.7</td></tr><tr><td rowspan=1 colspan=1>ST-GCN (Yan et al., 2018)</td><td rowspan=1 colspan=1>72.0</td></tr><tr><td rowspan=1 colspan=1>PoseConv3D</td><td rowspan=1 colspan=1>81.9</td></tr><tr><td rowspan=1 colspan=1>Swin-L +PoseConv3D</td><td rowspan=1 colspan=1>94.7</td></tr></table>
420
+
421
+ When combined with the state-of-the-art RGB predictions, the improvement is much more significant, increasing from $0 . 6 \%$ to $2 . 0 \%$ . However, the skeleton-based performance is still far behind the state-of-the-art RGB-based action recognition method (Liu et al., 2021), which achieves $9 2 . 7 \%$ mean class accuracy on Kinetics-Motion. The inferior recognition performance indicates that there still needs more future work for skeleton-based action recognition in the wild.
md/dev/XByg4kotW5/XByg4kotW5.md ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # When does return-conditioned supervised learning work for offline reinforcement learning?
2
+
3
+ Alberto Bietti New York University
4
+
5
+ David Brandfonbrener New York University david.brandfonbrener@nyu.edu
6
+
7
+ Jacob Buckman MILA
8
+
9
+ Romain Laroche Microsoft Research
10
+
11
+ Joan Bruna New York University
12
+
13
+ # Abstract
14
+
15
+ Several recent works have proposed a class of algorithms for the offline reinforcement learning (RL) problem that we will refer to as return-conditioned supervised learning (RCSL). RCSL algorithms learn the distribution of actions conditioned on both the state and the return of the trajectory. Then they define a policy by conditioning on achieving high return. In this paper, we provide a rigorous study of the capabilities and limitations of RCSL, something which is crucially missing in previous work. We find that RCSL returns the optimal policy under a set of assumptions that are stronger than those needed for the more traditional dynamic programming-based algorithms. We provide specific examples of MDPs and datasets that illustrate the necessity of these assumptions and the limits of RCSL. Finally, we present empirical evidence that these limitations will also cause issues in practice by providing illustrative experiments in simple point-mass environments and on datasets from the D4RL benchmark.
16
+
17
+ # 1 Introduction
18
+
19
+ In recent years, deep learning has proven to be an exceptionally powerful generic algorithm for solving supervised learning (SL) tasks. These approaches tend to be stable, and scale well with compute and data $\mathbb { \lVert 1 7 \rVert }$ . In contrast, deep reinforcement learning algorithms seem to lack these nice properties; results are well known to be sensitive to hyperparameters and difficult to replicate. In spite of this, deep reinforcement learning (RL) has achieved impressive feats, such as defeating human champions at Go $\mathbb { \left[ \left[ 2 5 \right] \right] }$ . This juxtaposition of success and instability has inspired researchers to explore alternative approaches to reinforcement learning that more closely resemble supervised learning in hopes of making deep RL as well-behaved as deep SL.
20
+
21
+ One family of algorithms that has garnered great interest recently is return-conditioned supervised learning (RCSL). The core idea of RCSL is to learn the return-conditional distribution of actions in each state, and then define a policy by sampling from the distribution of actions that receive high return. This was first proposed for the online RL setting by work on Upside Down RL [23, $\bar { \left| 2 6 \right| }$ and Reward Conditioned Policies $\pmb { \mathbb { D } } \mathbf { 1 } \mathbf { h }$ . The idea was extended to the offline RL setting using transformers that condition on the entire history of states rather than just the current Markovian state in the Decision Transformer (DT) work $\boxed { 8 } \boxed { 1 2 }$ . Recent work on RL via Supervised Learning (RvS) [9] unifies and simplifies ideas from these prior works with ideas about goal-conditioned policies.
22
+
23
+ Importantly, none of this prior work provides theoretical guarantees or analysis of the failure modes of the return-conditioning approach. In contrast, the more established dynamic programming (DP) algorithms for RL are better understood theoretically. This paper attempts to address this gap in understanding, in order to assess when RCSL is a reliable approach for offline RL. Specifically, we answer the following questions:
24
+
25
+ • What optimality guarantees can we make for RCSL? Under what conditions are they necessary and sufficient?
26
+ • In what situations does RCSL fail in theory and in practice?
27
+ • How does RCSL relate to other approaches, such as DP and behavior cloning (BC)?
28
+
29
+ We find that although RCSL does select a near-optimal policy under certain conditions, the necessary assumptions are more strict than those for DP. In particular, RCSL (but not DP) requires nearly deterministic dynamics in the MDP, knowledge of the proper value to condition on, and for the conditioning value to be supported by the distribution of returns in the dataset. We provide simple tabular examples to demonstrate the necessity of these assumptions. The shortcomings of RCSL that we identify in theory are verified empirically with some simple experiments using neural models on ad-hoc example problems as well as benchmark datasets. We conclude that RCSL alone is unlikely to be a general solution for offline RL problems, but does show promise in some specific situations such as deterministic MDPs with high-quality behavior data.
30
+
31
+ # 2 Preliminaries
32
+
33
+ # 2.1 Setup
34
+
35
+ We will consider an offline RL setup where we are given a dataset $\mathcal { D }$ of trajectories $\tau =$ $\left( o _ { 1 } , a _ { 1 } , r _ { 1 } , \cdot \cdot \cdot , o _ { H } , a _ { H } , r _ { H } \right)$ of observations $o _ { t } ~ \in ~ \mathcal { O }$ , actions $a _ { t } ~ \in ~ { \cal A }$ , and rewards $r _ { t } ~ \in ~ [ 0 , 1 ]$ generated by some behavior policy $\beta$ interacting with a finite horizon MDP with horizon $H$ . Let $\begin{array} { r } { g ( \tau ) = \sum _ { t = 1 } ^ { H } r _ { t } } \end{array}$ denote the cumulative return of the trajectory (we will just use $g$ when the trajectory is clear from context). And let be the expected return of a policy . We then let the state representation $s _ { t } \in S$ be any function of the history of observations, actions, and rewards up to step $t$ along with $o _ { t }$ . To simplify notation in the finite horizon setting, we will sometimes drop the timestep from $s$ to refer to generic states and assume that we can access the timestep from the state representation as $t ( s )$ . Let $P _ { \pi }$ denote the joint distribution over states, actions, rewards, and returns induced by any policy $\pi$ .
36
+
37
+ In this paper, we focus on the RCSL approach that learns by return-conditioned supervised learning. Explicitly, at training time this method minimizes the empirical negative log likelihood loss:
38
+
39
+ $$
40
+ \hat { L } ( \pi ) = - \sum _ { \tau \in \mathcal { D } } \sum _ { 1 \leq t \leq H } \log \pi ( a _ { t } | s _ { t } , g ( \tau ) ) .
41
+ $$
42
+
43
+ Then at test time, an algorithm takes the learned policy $\pi$ along with a conditioning function $f ( s )$ to define the test-time policy $\pi _ { f }$ as:
44
+
45
+ $$
46
+ \pi _ { f } ( a | s ) : = \pi ( a | s , f ( s ) ) .
47
+ $$
48
+
49
+ Nota bene: the Decision Transformer $\textcircled { 8 } \textcircled { 1 8 }$ is captured in this framework by defining the state space so that the state $s _ { t }$ at time $t$ also contains all past $o _ { t ^ { \prime } } , a _ { t ^ { \prime } }$ , and $r _ { t ^ { \prime } }$ for $t ^ { \prime } < t$ . In prior work, $f$ is usually chosen to be a constant at the initial state and to decrease with observed reward along a trajectory, which is captured by a state representation that includes the history of rewards.
50
+
51
+ # 2.2 The RCSL policy
52
+
53
+ To better understand the objective, it is useful to first consider its optimum in the case of infinite data. It is clear that our loss function attempts to learn $P _ { \beta } ( a | s , g )$ where $\beta$ is the behavior policy that generated the data (and recall that $P _ { \beta }$ refers to the distribution over states, actions, and returns induced by $\beta$ ). Factoring this distribution, we quickly see that the optimal policy $\pi _ { f } ^ { \mathrm { R C S L } }$ for a specific conditioning function $f$ can be written as:
54
+
55
+ $$
56
+ \pi _ { f } ^ { \mathrm { R C S L } } ( a | s ) = P _ { \beta } ( a | s , f ( s ) ) = \frac { P _ { \beta } ( a | s ) P _ { \beta } ( f ( s ) | s , a ) } { P _ { \beta } ( f ( s ) | s ) } = \beta ( a | s ) \frac { P _ { \beta } ( f ( s ) | s , a ) } { P _ { \beta } ( f ( s ) | s ) } .
57
+ $$
58
+
59
+ Essentially, the RCSL policy re-weights the behavior based on the distribution of future returns.
60
+
61
+ Connection to distributional RL. In distributional RL [4], the distribution of future returns under a policy $\pi$ from state $s$ and action $a$ is defined as: $\begin{array} { r } { G ^ { \pi } ( s , a ) \sim g = \sum _ { t = t ( s ) } ^ { H } r _ { t } | \tau \sim \pi , s _ { t ( s ) } = } \end{array}$ $s , a _ { t ( s ) } = a$ . The RCSL policy is precisely proportional to the product of the behavior policy and the density of the distributional Q function of the behavior policy (i.e. $P _ { \beta } ( g | s , a ) )$ .
62
+
63
+ # 2.3 Related work
64
+
65
+ As noted in the introduction, our work is in direct response to the recent line of literature on RCSL [23, 26, 21, 8, 12, 9]. Specifically, we will focus on the DT $\pmb { \mathbb { B } } \|$ and RvS [9] formulations in our experiments since they also focus on the offline RL setting. Note that another recent work introduced the Trajectory Transformer $\mathbb { \lVert 1 5 \rVert }$ which does not fall under the RCSL umbrella since it performs planning in the learned model to define a policy.
66
+
67
+ Another relevant predecessor of RCSL comes from work on goal-based RL [16]. Compared to RCSL, this line of work replaces the target return $g$ in the empirical loss function by a goal state. One instantiation is hindsight experience replay (HER) where each trajectory in the replay buffer is relabeled as if the observed final state was in fact the goal state $\left[ \left[ 2 \right] \right]$ . Another instance is goalconditioned supervised learning [GCSL, $\mathbb { L } 3 \mathbb { I }$ , which provides more careful analysis and guarantees, but the guarantees (1) are not transferable to the return-conditioned setting, (2) assume bounds on $L _ { \infty }$ errors in TV distance instead of dealing with expected loss functions that can be estimated from data, and (3) do not provide analysis of the tightness of the bounds.
68
+
69
+ Concurrent work $[ \sqrt { 3 4 } , \sqrt { 2 2 } , \sqrt { 3 3 } ]$ also all raise the issue of RCSL in stochastic environments with infinite data, and present some algorithmic solutions. However, none of this work addresses the potentially more fundamental issue of sample complexity that arises from the requirement of return coverage that we discuss in Section 4.
70
+
71
+ # 3 When does RCSL find the optimal policy?
72
+
73
+ We begin by exploring how RCSL behaves with infinite data and a fully expressive policy class. In this setting, classic DP algorithms (e.g. Q-learning) are guaranteed to converge to the optimal policy under coverage assumptions $\pmb { \mathbb { Z } } \mathbf { \ b { 7 } } \|$ . But we now show that this is not the case for RCSL, which requires additional assumptions for a similar guarantee. Our approach is to first derive a positive result: under certain assumptions, the policy which optimizes the RCSL objective (Section $\bar { \textregistered . 2 } \bar $ is guaranteed to be near-optimal. We then illustrate the limitations of RCSL by providing simple examples that are nonetheless challenging for these methods in order to demonstrate why our assumptions are necessary and that our bound is tight.
74
+
75
+ Theorem 1 (Alignment with respect to the conditioning function). Consider an MDP, behavior $\beta$ and conditioning function $f$ . Assume the following:
76
+
77
+ 1. Return coverage: $P _ { \beta } ( g = f ( s _ { 1 } ) | s _ { 1 } ) \ge \alpha _ { f }$ for all initial states $s _ { 1 }$ .
78
+
79
+ 2. Near determinism: $P ( r \neq r ( s , a ) o r s ^ { \prime } \neq T ( s , a ) | s , a ) \leq \epsilon$ at all $s , a$ for some functions $T$ and $r$ . Note that this does not constrain the stochasticity of the initial state.
80
+
81
+ 3. Consistency of $f$ : $f ( s ) = f ( s ^ { \prime } ) + r$ for all $s$ . 1
82
+
83
+ Then
84
+
85
+ $$
86
+ \mathbb { E } _ { s _ { 1 } } [ f ( s _ { 1 } ) ] - J ( \pi _ { f } ^ { R C S L } ) \le \epsilon \left( \frac { 1 } { \alpha _ { f } } + 2 \right) H ^ { 2 } .
87
+ $$
88
+
89
+ Moreover, there exist problems where the bound is tight up to constant factors.
90
+
91
+ The proof is in Appendix $\underline { { \overline { { \mathbf { C . 1 } } } } } \underline { \} }$ Note that the quantity $\mathbb { E } _ { s _ { 1 } } [ f ( s _ { 1 } ) ]$ is specific to the structure of RCSL algorithms and captures the notion that the ideal RCSL policy will be able to reproduce policies of any value when given different conditioning functions (with appropriate data). The theorem immediately yields the following corollaries (with proof in Appendix $\boxed { \mathrm { C . 1 } }$
92
+
93
+ Corollary 1. Under the assumptions of Theorem 1, there exists a conditioning function $f$ such that
94
+
95
+ $$
96
+ J ( \pi ^ { * } ) - J ( \pi _ { f } ^ { R C S L } ) \leq \epsilon \left( \frac { 1 } { \alpha _ { f } } + 3 \right) H ^ { 2 } .
97
+ $$
98
+
99
+ Corollary 2. If $\dot { } \alpha _ { f } > 0$ , $\epsilon = 0 ;$ , and $f ( s _ { 1 } ) = V ^ { * } ( s _ { 1 } )$ for all initial states $s _ { 1 }$ , then $J ( \pi _ { f } ^ { R C S L } ) = J ( \pi ^ { \ast } )$
100
+
101
+ The corollaries tell us that in near determinisitc environments with the proper conditioning functions and data coverage, it is possible for RCSL to recover near optimal policies. These assumptions are somewhat strong compared to those needed for DP-based approaches, so we will now explain why they are necessary for our analysis.
102
+
103
+ Tightness. To demonstrate tightness we will consider the simple examples in Figure 1. These MDPs and behavior policies demonstrate tightness in $\epsilon$ and $\alpha _ { f }$ up to constant factors, and provide insight into how stochastic dynamics lead to suboptimal behavior from RCSL algorithms.
104
+
105
+ (a) An example where the bound is (b) An example where RCSL also tight. $\boldsymbol { B }$ denotes the Bernoulli dis- has large regret. tribution.
106
+
107
+ ![](images/00ceadd912f88309cd9d51352d1cd985f4581c2a297ccf3f919cbd1d102f8c05.jpg)
108
+ (c) An example where RCSL also has large regret for any conditioning function.
109
+ Figure 1: Failure modes of RCSL in stochastic environments with infinite data.
110
+
111
+ First, consider the example in Figure 1a with conditioning $f ( s _ { 1 } ) = 1$ . There is only one possible policy in this case, and it has $J ( \pi ) = { \overline { { \epsilon } } }$ so that $\mathbb { E } [ f ( s _ { 1 } ) ] - J ( \pi ) = 1 - \epsilon$ . Note that $\alpha _ { f } = \epsilon$ , so we have that $\epsilon / \alpha _ { f } = 1$ . Thus, the bound is tight in $\epsilon / \alpha _ { f }$ . This example shows that the goal of achieving a specific desired return is incompatible with stochastic environments.
112
+
113
+ This first example is somewhat silly since there is only one action, so the learned policy does not actually suffer any regret. To show that this issue can in fact lead to regret, consider the example in Figure ${ \bf { \bar { 1 6 } } } ,$ again with conditioning $f ( s _ { 1 } ) = 1$ . Then applying the reasoning from Section $2 . 2 ,$
114
+
115
+ $$
116
+ \pi _ { f } ^ { \mathrm { R C S L } } ( a _ { 1 } | s _ { 1 } ) = \beta ( a _ { 1 } | s _ { 1 } ) \frac { P _ { \beta } ( g = 1 | s _ { 1 } , a _ { 1 } ) } { P _ { \beta } ( g = 1 | s _ { 1 } ) } = 0 . 5 \cdot \frac { 0 } { 0 . 5 \cdot \epsilon } = 0 .
117
+ $$
118
+
119
+ So we get that $\mathbb { E } [ f ( s _ { 1 } ) ] - J ( \pi _ { f } ^ { \mathrm { R C S L } } ) = 1 - \epsilon$ , while $\epsilon / \alpha _ { f } = \epsilon / ( \epsilon / 2 ) = 2$ (which is on the same order, up to a constant factor). However, in this case the learned policy $\pi _ { f } ^ { \mathrm { R C S L } }$ suffers substantial regret since the chosen action $a _ { 2 }$ has substantially lower expected value than $a _ { 1 }$ by $1 - 2 \epsilon$ .
120
+
121
+ The issue in the second example could be resolved by changing the conditioning function so that $f ( s _ { 1 } ) = 1 - \epsilon$ . Now we will consider the example in Figure $\mathrm { 1 \bar { c } }$ where we will see that there exist cases where the bias of RCSL in stochastic environments can remain regardless of the conditioning function. In this MDP, the only returns that are supported are $g = 0$ or $g = 1$ . For $f ( s _ { 1 } ) = 1$ , plugging in to the formula for $\pi _ { f }$ yields
122
+
123
+ $$
124
+ \pi _ { f } ^ { \mathrm { R C S L } } ( a _ { 1 } | s _ { 1 } ) = \beta ( a _ { 1 } | s _ { 1 } ) \frac { P _ { \beta } ( g = 1 | s _ { 1 } , a _ { 1 } ) } { P _ { \beta } ( g = 1 | s _ { 1 } ) } = \epsilon \frac { 1 - \epsilon } { \epsilon ( 1 - \epsilon ) + ( 1 - \epsilon ) \epsilon } = \frac { 1 } { 2 } .
125
+ $$
126
+
127
+ Thus, $\mathbb { E } [ f ( s _ { 1 } ) ] - J ( \pi _ { f } ^ { \mathrm { R C S L } } ) = 1 / 2$ and $J ( \pi ^ { * } ) - J ( \pi _ { f } ^ { \mathrm { R C S L } } ) = 1 / 2 - \epsilon$ . This shows that merely changing the conditioning function is not enough to overcome the bias of the RCSL method in stochastic environments.
128
+
129
+ These examples show that even for MDPs that are $\epsilon$ -close to being deterministic, the regret of RCSL can be large. But, in the special case of deterministic MDPs we find that RCSL can indeed recover the optimal policy. And note that we still allow for stochasticity in the initial states in these deterministic MDPs, which provides a rich setting for problems like robotics that requires generalization over the state space from finite data. In the next section, we will consider more precisely what happens to RCSL algorithms with finite data and limited model classes.
130
+
131
+ Trajectory stitching. Another issue often discussed in the offline RL literature is the idea of trajectory stitching [31, 8]. Ideally, an offline RL agent can take suboptimal trajectories that overlap and stitch them into a better policy. Clearly, DP-based algorithms can do this, but it is not so clear that RCSL algorithms can. In Appendix B we provide theoretical and empirical evidence that in fact they cannot perform stitching in general, even with infinite data. While this does not directly affect our bounds, the failure to perform stitching is an issue of practical importance for RCSL methods.
132
+
133
+ # 4 Sample complexity of RCSL
134
+
135
+ Now that we have a better sense of what policy RCSL will converge to with infinite data, we can consider how quickly (and under what conditions) it will converge to the policy $\pi _ { f }$ when given finite data and a limited policy class, as will occur in practice. We will do this via a reduction from the regret relative to the infinite data solution $\pi _ { f }$ to the expected loss function $L$ minimized at training time by RCSL, which is encoded in the following theorem.
136
+
137
+ Theorem 2 (Reduction of RCSL to SL). Consider any function $f : S \mathbb { R }$ such that the following two assumptions hold:
138
+
139
+ 1. Bounded occupancy mismatch: ⇡fP(s)  Cf for all s.
140
+
141
+ 2. Return coverage: $P _ { \beta } ( g = f ( s ) | s ) \ge \alpha _ { f }$ for all $s$
142
+
143
+ Define the expected loss as $L ( \hat { \pi } ) \stackrel { } { = } \mathbb { E } _ { s \sim P _ { \beta } } \mathbb { E } _ { g \sim P _ { \beta } ( \cdot | s ) } [ D _ { \mathrm { K L } } ( P _ { \beta } ( \cdot | s , g ) | | \hat { \pi } ( \cdot | s , g ) ) ]$ . Then for any estimated RCSL policy $\hat { \pi }$ that conditions on $f$ at test time (denoted by $\hat { \pi } _ { f }$ ), we have that
144
+
145
+ $$
146
+ J ( \pi _ { f } ^ { R C S L } ) - J ( \hat { \pi } _ { f } ) \leq \frac { C _ { f } } { \alpha _ { f } } H ^ { 2 } \sqrt { 2 L ( \hat { \pi } ) } .
147
+ $$
148
+
149
+ The proof can be found in Appendix $\underline { { \mathsf { C . 3 } } } ,$ Note that we require a similar assumption of return coverage as before to ensure we have sufficient data to define $\pi _ { f }$ . We also require an assumption on the state occupancy of the idealized policy $\pi _ { f }$ relative to $\beta$ . This assumption is needed since the loss $L ( \hat { \boldsymbol { \pi } } )$ is optimized on states sampled from $P _ { \beta }$ , but we care about the expected return of the learned policy relative to that of $\pi _ { f }$ , which can be written as an expectation over states sampled from $P _ { \pi _ { f } }$ .
150
+
151
+ This gives us a reduction to supervised learning, but to take this all the way to a sample complexity bound we need to control the loss $L ( \hat { \boldsymbol { \pi } } )$ from finite samples. Letting $N$ denote the size of the dataset, the following corollary uses standard uniform convergence results from supervised learning $\mathbb { \left[ \left[ 2 4 \right] \right] }$ to yield finite sample bounds.
152
+
153
+ Corollary 3 (Sample complexity of RCSL). To get finite data guarantees, add to the above assumptions the assumptions that $( l )$ the policy class $\Pi$ is finite, (2) $| \log \pi ( a | s , g ) - \log \pi ( a ^ { \prime } | s ^ { \prime } , g ^ { \prime } ) | \leq c$ for any $( a , s , g , a ^ { \prime } , s ^ { \prime } , g ^ { \prime } )$ and all $\pi \in \Pi$ , and (3) the approximation error of $\Pi$ is bounded by $\epsilon _ { a p p r o x }$ , i.e. $\begin{array} { r } { \operatorname* { m i n } _ { \pi \in \Pi } L ( \pi ) \le \epsilon _ { a p p r o x } } \end{array}$ . Then with probability at least $1 - \delta$ ,
154
+
155
+ $$
156
+ J ( \pi _ { f } ^ { R C S L } ) - J ( \hat { \pi } _ { f } ) \leq O \left( \frac { C _ { f } } { \alpha _ { f } } H ^ { 2 } \left( \sqrt { c } \left( \frac { \log | \Pi | / \delta } { N } \right) ^ { 1 / 4 } + \sqrt { \epsilon _ { a p p r o x } } \right) \right) .
157
+ $$
158
+
159
+ The proof is in Appendix $\mathbf { C . 4 . }$ Analyzing the bound, we can see that the dependence on $N$ is in terms of a fourth root rather than the square root, but this comes from the fact that we are optimizing a surrogate loss. Namely the learner optimizes KL divergence, but we ultimately care about regret which we access by using the KL term to bound a TV divergence and thus lose a square root factor. A similar rate appears, for example, when bounding 0-1 classification loss of logistic regression [3, 5].
160
+
161
+ This corollary also tells us something about how the learner will learn to generalize across different values of the return. If the policy class is small (for some notion of model complexity) and sufficiently structured, then it can use information from the given data to generalize across values of $g$ , using low-return trajectories to inform the model on high-return trajectories.
162
+
163
+ Note that a full sample complexity bound that competes with the optimal policy can be derived by combining this result with Corollary 1 as follows:
164
+
165
+ Corollary 4 (Sample complexity against the optimal policy). Under all of the assumptions of Corollary 1 and Corollary 3 we get:
166
+
167
+ $$
168
+ J ( \pi ^ { * } ) - J ( \hat { \pi } _ { f } ) \leq O \left( \frac { C _ { f } } { \alpha _ { f } } H ^ { 2 } \left( \sqrt { c } \left( \frac { \log | \Pi | / \delta } { N } \right) ^ { 1 / 4 } + \sqrt { \epsilon _ { a p p r o x } } \right) + \frac { \epsilon } { \alpha _ { f } } H ^ { 2 } \right) .
169
+ $$
170
+
171
+ Tightness. To better understand why the dependence on $1 / \alpha _ { f }$ is tight and potentially exponential in the horizon $H$ , even in deterministic environments, we offer the example in Figure 2. Specifically, we claim that any value of $f ( s _ { 1 } )$ where the policy $\pi _ { f } ^ { \mathrm { R C S L } }$ prefers the good action $a _ { 1 }$ from $s _ { 1 }$ will require on the order of $1 0 ^ { H / 2 }$ samples in expectation to recover as $\hat { \pi } _ { }$ f 2 .
172
+
173
+ To see why this is the case, we consider the MDP illustrated in Figure $2$ with horizon $H \gg 4$ . The MDP has four states each with two actions. All transitions and rewards are deterministic. The only actions with non-zero reward are $r ( s _ { 2 } , a _ { 1 } ) = 1$ and $r ( s _ { 3 } , a _ { 1 } ) = 0 . 5$ . The interesting decision is at $s _ { 1 }$ where $a _ { 1 }$ is better than $\cdot$ .
174
+
175
+ $$
176
+ \begin{array} { c } { { r = 1 } } \\ { { a _ { 1 } \underline { { { \widehat { \bigcup } } } } \beta ^ { \beta = 0 . 1 } } } \\ { { \beta = 0 . 5 \underline { { { \widehat { \bigcup } } } } \gamma ^ { \beta } \overset { S \mathrm { { 2 } } } { \longleftrightarrow } \overset { \partial \mathrm { { 2 } } } \underset { { \mathrm { 4 2 } } } { \longrightarrow } \overset { \displaystyle \{ 0 . 9 } } \overset { \displaystyle \{ \widehat { \bigcup } } } \\ { \beta = 0 . 5 \overset { a _ { 2 } } { \longrightarrow } \underset { { \substack { \begin{array} { l } { { \beta _ { 3 } \geq \widehat { 3 } } } \\ { { \sigma _ { 3 } \geq \widehat { 3 } } } \\ { a _ { 1 } \leq \widehat { \bigcup } } \\ { r } \end{array} } } } } \\ { { a _ { 1 } \hfill } } \\ { { r = 0 . 5 } } \end{array}
177
+ $$
178
+
179
+ Note that for any integer $1 \le k < H / 2$ , we have that $P _ { \beta } ( g = k | s _ { 1 } , a _ { 2 } ) = 0 . 5 \cdot 0 . 5 ^ { 2 k } = 0 . 5 \cdot ( 0 . 2 5 ) ^ { k }$ , while $P _ { \beta } ( g = k | s _ { 1 } , a _ { 1 } ) = 0 . 5 \cdot ( 0 . 1 ) ^ { k }$ . Conditioning on any such $k$ will make us more likely to choose the bad action $a _ { 2 }$ from $s _ { 1 }$ . The only way to increase the likelihood of the good action $a _ { 1 }$ from $s _ { 1 }$ and $s _ { 2 }$ is to condition on $f ( s _ { 1 } ) >$ $H / 2$ . Unfortunately for RCSL, the probability of observing $g > H / 2$ is extremely small, since for any such $f$ we have $P _ { \beta } ( g = f ( s _ { 1 } ) ) \le 0 . 5 \cdot ( 0 . 1 ) ^ { H / 2 } \le 1 0 ^ { - H / 2 }$ . Thus, both $\alpha _ { f }$ and the sample complexity of learning for any $f$ that will yield a policy better than the behavior is exponential in the horizon $H$ .
180
+
181
+ Figure 2: An example where RCSL has exponential sample complexity in a deterministic environment.
182
+
183
+ Fundamentally, the problem here is that RCSL uses trajectory-level information instead of performing dynamic programming on individual transitions. But, collecting enough trajectory-level information can take exponentially many samples in the horizon. In contrast, DP merely requires coverage of transitions in the MDP to perform planning and thus avoids this issue of exponential sample complexity. In the next section we will delve deeper into this comparison with DP-based approaches as well as the simple top- $\%$ BC baseline.
184
+
185
+ # 5 Comparing RCSL with bounds for alternative methods
186
+
187
+ Now that we understand the rate at which we expect RCSL to converge, we briefly present the convergence rates of two baseline methods for comparison. In particular, we will leverage an existing analysis of a DP-based algorithm, and conduct a novel analysis of top- $\%$ BC. We find that the sample complexity of RCSL has a similar rate to top- $\%$ BC, and is worse than DP due to the potentially exponential dependence on horizon that stems from return coverage.
188
+
189
+ # 5.1 Comparison to dynamic programming.
190
+
191
+ We will compare to the state of the art (to our knowledge) bound for a DP-based offline RL algorithm. Namely, we will look at the results of $\pmb { \mathbb { B 2 } }$ for pessimistic soft policy iteration. Similar results exist for slightly different algorithms or assumptions $\mathbb { U } \mathbb { B }$ , but we choose this one since it is both the tightest and more closely aligns with the practical actor-critic algorithms that we use for our experiments. Their bound makes the following assumptions about the function class $F$ and the dataset (letting $\mathcal { T } ^ { \pi }$ represent the Bellman operator for policy $\pi$ ):
192
+
193
+ 1. Realizability: for any policies $\pi , \pi ^ { \prime }$ there exists $f \in F$ with $\| f - T ^ { \pi } f \| _ { 2 , P _ { \pi ^ { \prime } } } ^ { 2 } \leq \epsilon _ { 1 } .$ .
194
+
195
+ 2. Bellman completeness: for any $\pi$ and $f \in F$ there exists $f ^ { \prime } \in F$ such that $\| f ^ { \prime } - T ^ { \pi } f \| _ { 2 , P _ { \beta } } ^ { 2 } \leq \epsilon _ { 2 }$
196
+
197
+ With these assumptions in place, the sample complexity bound takes the form4:
198
+
199
+ $$
200
+ J ( \pi ^ { * } ) - J ( \hat { \pi } ) \leq O \left( H ^ { 2 } \left( \sqrt { \frac { C \log | F | | \Pi | / \delta } { N } } \right) + H ^ { 2 } \sqrt { C ( \epsilon _ { 1 } + \epsilon _ { 2 } ) } \right)
201
+ $$
202
+
203
+ Note: this is the result for the “information-theoretic” form of the algorithm that cannot be efficiently implemented. The paper also provides a “practical” version of the algorithm for which the bound is the same except that the the square root in the first term is replaced with a fifth root.
204
+
205
+ There are several points of comparison with our analysis (specifically, our Corollary $\textcircled { 4 }$ . The first thing to note is that for RCSL to compete with the optimal policy, we require nearly deterministic dynamics and a priori knowledge of the optimal conditioning function. These assumptions are not required for the DP-based algorithm; this is a critical difference, since it is clear that these conditions often do not hold in practice.
206
+
207
+ Comparing the coverage assumptions, our $C _ { f }$ becomes nearly equivalent to $C$ . The major difference is that our analysis of RCSL also requires dependence on return coverage $1 / \alpha _ { f }$ . This is problematic since as seen in Section $^ { 4 , }$ this return coverage dependence can be exponential in horizon in cases where the state coverage does not depend on horizon.
208
+
209
+ Comparing the approximation error assumptions, we see that the realizability and completeness assumptions required for DP are substantially less intuitive than the standard supervised learning approximation error assumption needed for RCSL. These assumptions are not directly comparable, but intuitively the RCSL approximation error assumption is simpler.
210
+
211
+ Finally, dependence on $H$ is the same for both methods and dependence on $N$ depends on which version of the DP algorithm we compare to. For the information-theoretic algorithm DP has better dependence on $N$ , but for the practical algorithm RCSL has better dependence. It is not clear whether the dependence on $N$ in either the RCSL analysis or in the analysis of the practical algorithm from $\pmb { \mathbb { B 2 } }$ is tight, and it is an interesting direction for future work to resolve this issue.
212
+
213
+ # 5.2 Comparison to top- $\%$ behavior cloning.
214
+
215
+ The closest algorithm to RCSL is top- $\%$ BC, which was introduced as a baseline for Decision Transformers $\textcircled { 8 } \textcircled { 1 8 }$ . This algorithm simply sorts all trajectories in the dataset by return and takes the top $\rho$ fraction of trajectories to run behavior cloning (for $\rho \in [ 0 , 1 ] ,$ ). The most obvious difference between this algorithm and RCSL is that RCSL allows us to plug in different conditioning functions at test time to produce different policies, while top- $\%$ BC learns only one policy. However, if we want to achieve high returns, the two algorithms are quite similar.
216
+
217
+ The full statements and proofs of our theoretical results for top- $\%$ BC are deferred to Appendix The results are essentially the same as those for RCSL except for two key modifications:
218
+
219
+ Defining coverage. The first difference in the analysis is the notion of coverage. For RCSL we needed the return distribution to cover the conditioning function $f$ . For top- $\%$ BC we instead let $g _ { \rho }$ be the $1 - \rho$ quantile of the return distribution over trajectories sampled by the behavior $\beta$ and then define coverage as $P _ { \beta } ( g \geq g _ { \rho } | s ) \geq \alpha _ { \rho }$ for all $s$ . This modification is somewhat minor.
220
+
221
+ Sample size and generalization. The main difference between RCSL and top- $\%$ BC is that the RCSL algorithm attempts to transfer information gained from low-return trajectories while the top$\%$ BC algorithm simply throws those trajectories away. This shows up in the formal bounds since for a dataset of size $N$ the top- $\%$ BC algorithm only uses $\rho \cdot N$ samples while RCSL uses all $N$ . Depending on the data distribution, competing with the optimal policy may require setting $\rho$ very close to zero (exponentially small in $H$ ) yielding poor sample complexity.
222
+
223
+ These bounds suggest that RCSL can use generalization across returns to provide improvements in sample complexity over top- $\%$ BC by leveraging all of the data. However, the RCSL model is attempting to learn a richer class of functions that conditions on reward, which may require a larger policy class negating some of this benefit. Overall, RCSL should expect to beat top- $\%$ BC if the behavior policy is still providing useful information about how to interact with the environment in low-return trajectories that top- $\%$ BC would throw away.
224
+
225
+ # 6 Experiments
226
+
227
+ We have illustrated through theory and some simple examples when we expect RCSL to work, but the theory does not cover all cases that are relevant for practice. In particular, it is not clear how the neural networks trained in practice can leverage generalization across returns. Moreover, one of the key benefits to RCSL approaches (as compared to DP) is that by avoiding the instabilities of non-linear off-policy DP in favor of supervised learning, one might hope that RCSL is more stable in practice. In this section we attempt to test these capabilities first through targeted experiments in a point-mass environment and then by comparisons on standard benchmark data.
228
+
229
+ Throughout this section we will consider six algorithms, two from each of three categories:
230
+
231
+ 1. Behavior cloning (BC): standard behavior cloning (BC) and percentage behavior cloning $( \% \mathrm { B C } )$ that runs BC on the trajectories with the highest returns [8]. 2. Dynamic programming (DP): $\mathrm { T D } 3 { + } \mathrm { B C }$ [11] a simple DP-based offline RL approach and IQL $\mathbb { \left| \left[ 2 0 \right] \right| }$ a more stable DP-based offline RL approach. 3. Return-conditioned supervised learning (RCSL): RvS [9] an RCSL approach using simple MLP policies, and DT $\textcircled { 8 }$ an RCSL approach using transformer policies.
232
+
233
+ All algorithms are implemented in JAX $\pmb { \mathbb { H } }$ using flax $\pmb { \mathbb { I } }$ and the jaxrl framework [19], except for DT which is taken from the original paper. Full details can be found in Appendix D and code can be found at https://github.com/davidbrandfonbrener/rcsl-paper.
234
+
235
+ # 6.1 Point-mass datasets
236
+
237
+ First, we use targeted experiments to demonstrate how the tabular failure modes illustrated above can arise even in simple deterministic MDPs that may be encountered in continuous control. Specifically, we will focus on the issue of exponential sample complexity discussed in Section $\mathbb { H }$ We build our datasets in an environment using the Deepmind control suite $\left[ \left[ 2 8 \right] \right]$ and MuJoCo simulator [29]. The environment consists of a point-mass navigating in a 2-d plane.
238
+
239
+ To build an example with exponential sample complexity we construct a navigation task with a goal region in the center of the environment. The dataset is constructed by running a behavior policy that is a random walk that is biased towards the top right of the environment. To construct different levels of reward coverage, we consider the environment and dataset under three different reward functions (ordered by probability of seeing a trajectory with high return, from lowest to highest):
240
+
241
+ (a) The “ring of fire” reward. This reward is 1 within the goal region, -1 in the ring of fire region surrounding the goal, and 0 otherwise
242
+ (b) The sparse reward. This reward is 1 within the goal region and 0 otherwise.
243
+ (c) The dense reward. This reward function is 1 within the goal region and gradually decays with the Euclidean distance outside of it.
244
+
245
+ Intuitively, the ring of fire reward will cause serious problems for RCSL approaches when combined with the random walk behavior policy. The issue is that any random walk which reached the goal region is highly likely to spend more time in the region of negative rewards than in the actual goal states, since the ring of fire has larger area than the goal. As a result, while they are technically supported by the distribution, it is unlikely to find many trajectories (if any at all) with positive returns in the dataset, let alone near-optimal returns. As a result, the RCSL-based approaches are not even able to learn to achieve positive returns, as seen in Figure 3.
246
+
247
+ The sparse reward is also difficult for the RCSL-based algorithms, for similar reasons; however the problem is less extreme since any trajectory that gets positive reward must go to the goal, so there is signal in the returns indicating where the goal is. In contrast, the dense reward provides enough signal in the returns that RCSL approaches are able to perform well, although still not as well as IQL. It is also worth noting that because the datset still does not have full coverage of the state-space, simple DP-based algorithms like $\mathrm { T D } 3 { + } \mathrm { B C }$ can struggle with training instability.
248
+
249
+ # 6.2 Benchmark data
250
+
251
+ In addition to our targeted experiments we also ran our candidate algorithms on some datasets from the D4RL benchmark [10]. These are meant to provide more realistic and larger-scale data scenarios.
252
+
253
+ ![](images/178509ce2bbafc48e81964f07970facf71766ce5c3b4808eb389237705746e17.jpg)
254
+ Figure 3: RCSL fails under reward functions that lead to exponentially small probability of sampling good trajectories, but can generalize when the reward is dense. Error bars show standard deviation across three seeds. BC methods are in blue, DP methods in brown, and RCSL methods in green.
255
+
256
+ While this also makes these experiments less targeted, we can still see that the insights that we gained in simpler problems can be useful in these larger settings. We attempt to choose a subset of the datasets with very different properties from eachother. For example, the play data on the ant-maze environment is very diverse and plentiful while the human demonstration data on the pen environment has poor coverage but high values. Results are shown in Figure 4. And additional results leading to similar conclusions can be found in Appendix A.
257
+
258
+ We find that for most of the datasets DP-based algorithms $\mathrm { T D } 3 { + } \mathrm { B C }$ and IQL outperform both the BC-based algorithms and RCSL-based algorithms. This is especially stark on the ANTMAZE datasets where the behavior policy is highly stochastic, requiring the learner to stitch together trajectories to achieve good performance. While none of these tasks has stochastic dynamics, the issues of return coverage and trajectory stitching persist.
259
+
260
+ In contrast, RCSL performs well when the behavior policy is already high quality, but not optimal (as in the PEN-HUMAN task). Since the data is suboptimal and reward is dense, there is opportunity for RCSL to outperform the BC-based methods. Moreover, since the data has poor coverage, standard DP approaches like $\mathrm { T D } 3 { + } \mathrm { B C }$ are highly unstable.
261
+
262
+ ![](images/757b049576c0630af899b37b1017292226ab7e227284205b329004c59e910ce3.jpg)
263
+ Figure 4: Data from ANTMAZE-UMAZE, ANTMAZE-MEDIUM-PLAY, HALFCHEETAHMEDIUM-REPLAY, and PEN-HUMAN. Error bars show standard deviation across three seeds. Each algorithm is tuned over 4 values and best performance is reported.
264
+
265
+ IQL is more stable and performs similarly to the RCSL-based algorithms, but is outperformed by DT (perhaps due to the use of history-dependent policies).
266
+
267
+ # 7 Discussion
268
+
269
+ Looking back at our results, we can better place RCSL in relation to the more classical BC and DP algorithms. Like BC, RCSL relies on supervised learning and thus inherits its simplicity, elegance, and ease of implementation and debugging. However, it also inherits BC’s dependence on the quality of the behavior policy. This dependence can be somewhat reduced in (nearly) deterministic environments, where conditioning on high returns can break the bias towards the behavior policy. But, the reliance on trajectory-level information still means that RCSL is fundamentally limited by the quality of the best trajectories in the dataset, which can require a sample complexity exponential in horizon in order to compete with the optimal policy, even in deterministic environments.
270
+
271
+ In contrast, DP methods are capable of learning good policies even when the dataset does not contain any high-return trajectories and the environment is stochastic. This represents a fundamental gap between the two approaches that cannot be bridged within the RCSL paradigm. However, empirically, current deep DP algorithms are not well-behaved. These algorithms are often unstable and difficult to debug, although recent work has started to alleviate these issues somewhat $\mathbb { \ m }$ .
272
+
273
+ In sum, for tasks where the requirements for RCSL to perform well are met, it is an excellent practical choice, with great advantages in simplicity over DP. Since many real-world tasks of relevance have these attributes, RCSL techniques could have substantial impact. But as a general learning paradigm, RCSL is fundamentally limited in ways that DP is not.
274
+
275
+ # Acknowledgments
276
+
277
+ This work was partially supported by NSF RI-1816753, NSF CAREER CIF 1845360, NSF CHS1901091, NSF Scale MoDL DMS 2134216, Capital One and Samsung Electronics. DB was supported by the Department of Defense (DoD) through the National Defense Science & Engineering Graduate Fellowship (NDSEG) Program.
278
+
279
+ # References
280
+
281
+ [1] J. Achiam, D. Held, A. Tamar, and P. Abbeel. Constrained policy optimization. In International Conference on Machine Learning, pages 22–31. PMLR, 2017.
282
+ [2] M. Andrychowicz, F. Wolski, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, O. Pieter Abbeel, and W. Zaremba. Hindsight experience replay. Advances in neural information processing systems, 30, 2017.
283
+ [3] P. L. Bartlett, M. I. Jordan, and J. D. McAuliffe. Convexity, classification, and risk bounds. Journal of the American Statistical Association, 101(473):138–156, 2006.
284
+ [4] M. G. Bellemare, W. Dabney, and M. Rowland. Distributional Reinforcement Learning. MIT Press, 2022. http://www.distributional-rl.org.
285
+ [5] S. Boucheron, O. Bousquet, and G. Lugosi. Theory of classification: A survey of some recent advances. ESAIM: probability and statistics, 9:323–375, 2005.
286
+ [6] J. Bradbury, R. Frostig, P. Hawkins, M. J. Johnson, C. Leary, D. Maclaurin, G. Necula, A. Paszke, J. VanderPlas, S. Wanderman-Milne, and Q. Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
287
+ [7] J. Chen and N. Jiang. Information-theoretic considerations in batch reinforcement learning. In Proceedings of the 36th International Conference on Machine Learning. PMLR, 2019.
288
+ [8] L. Chen, K. Lu, A. Rajeswaran, K. Lee, A. Grover, M. Laskin, P. Abbeel, A. Srinivas, and I. Mordatch. Decision transformer: Reinforcement learning via sequence modeling. arXiv preprint arXiv:2106.01345, 2021.
289
+ [9] S. Emmons, B. Eysenbach, I. Kostrikov, and S. Levine. Rvs: What is essential for offline rl via supervised learning? arXiv preprint arXiv:2112.10751, 2021.
290
+ [10] J. Fu, A. Kumar, O. Nachum, G. Tucker, and S. Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
291
+ [11] S. Fujimoto and S. S. Gu. A minimalist approach to offline reinforcement learning. arXiv preprint arXiv:2106.06860, 2021.
292
+ [12] H. Furuta, Y. Matsuo, and S. S. Gu. Generalized decision transformer for offline hindsight information matching. arXiv preprint arXiv:2111.10364, 2021.
293
+ [13] D. Ghosh, A. Gupta, A. Reddy, J. Fu, C. Devin, B. Eysenbach, and S. Levine. Learning to reach goals via iterated supervised learning. arXiv preprint arXiv:1912.06088, 2019.
294
+ [14] J. Heek, A. Levskaya, A. Oliver, M. Ritter, B. Rondepierre, A. Steiner, and M. van Zee. Flax: A neural network library and ecosystem for JAX, 2020. URL http://github.com/google/ flax. problem. Advances in neural information processing systems, 34, 2021.
295
+ [16] L. P. Kaelbling. Learning to achieve goals. In IJCAI, 1993.
296
+ [17] J. Kaplan, S. McCandlish, T. Henighan, T. B. Brown, B. Chess, R. Child, S. Gray, A. Radford, J. Wu, and D. Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
297
+ [18] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
298
+ [19] I. Kostrikov. Jaxrl: Implementations of reinforcement learning algorithms in jax., 10 2021. URL https://github. com/ikostrikov/jaxrl, 2021.
299
+ [20] I. Kostrikov, A. Nair, and S. Levine. Offline reinforcement learning with implicit q-learning. arXiv preprint arXiv:2110.06169, 2021.
300
+ [21] A. Kumar, X. B. Peng, and S. Levine. Reward-conditioned policies. arXiv preprint arXiv:1912.13465, 2019.
301
+ [22] K. Paster, S. McIlraith, and J. Ba. You can’t count on luck: Why decision transformers fail in stochastic environments. arXiv preprint arXiv:2205.15967, 2022.
302
+ [23] J. Schmidhuber. Reinforcement learning upside down: Don’t predict rewards–just map them to actions. arXiv preprint arXiv:1912.02875, 2019.
303
+ [24] S. Shalev-Shwartz and S. Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
304
+ [25] D. Silver, A. Huang, C. J. Maddison, A. Guez, L. Sifre, G. van den Driessche, J. Schrittwieser, I. Antonoglou, V. Panneershelvam, M. Lanctot, S. Dieleman, D. Grewe, J. Nham, N. Kalchbrenner, I. Sutskever, T. P. Lillicrap, M. Leach, K. Kavukcuoglu, T. Graepel, and D. Hassabis. Mastering the game of go with deep neural networks and tree search. Nature, 529:484–489, 2016.
305
+ [26] R. K. Srivastava, P. Shyam, F. Mutz, W. Jaskowski, and J. Schmidhuber. Training agents using ´ upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019.
306
+ [27] R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. MIT press, 2018.
307
+ [28] Y. Tassa, Y. Doron, A. Muldal, T. Erez, Y. Li, D. d. L. Casas, D. Budden, A. Abdolmaleki, J. Merel, A. Lefrancq, et al. Deepmind control suite. arXiv preprint arXiv:1801.00690, 2018.
308
+ [29] E. Todorov, T. Erez, and Y. Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, pages 5026– 5033, 2012. doi: 10.1109/IROS.2012.6386109.
309
+ [30] R. Wang, D. P. Foster, and S. M. Kakade. What are the statistical limits of offline rl with linear function approximation?, 2020.
310
+ [31] Z. Wang, A. Novikov, K. Zolna, J. S. Merel, J. T. Springenberg, S. E. Reed, B. Shahriari, N. Siegel, C. Gulcehre, N. Heess, et al. Critic regularized regression. Advances in Neural Information Processing Systems, 33, 2020.
311
+ [32] T. Xie, C.-A. Cheng, N. Jiang, P. Mineiro, and A. Agarwal. Bellman-consistent pessimism for offline reinforcement learning. Advances in neural information processing systems, 34, 2021.
312
+ [33] M. Yang, D. Schuurmans, P. Abbeel, and O. Nachum. Dichotomy of control: Separating what you can control from what you cannot. arXiv preprint arXiv:2210.13435, 2022.
313
+ [34] M. Strupl, F. Faccio, D. R. Ashley, J. Schmidhuber, and R. K. Srivastava. Upside-down rein- ˇ forcement learning can diverge in stochastic environments with episodic resets, 2022.
314
+
315
+ # Checklist
316
+
317
+ 1. For all authors...
318
+
319
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
320
+ (b) Did you describe the limitations of your work? [Yes]
321
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix E
322
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
323
+
324
+ 2. If you are including theoretical results...
325
+
326
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
327
+
328
+ 3. If you ran experiments...
329
+
330
+ (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]
331
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix D
332
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
333
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix D
334
+
335
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
336
+
337
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
338
+ (b) Did you mention the license of the assets? [Yes] See Appendix D
339
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
340
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
341
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
342
+
343
+ 5. If you used crowdsourcing or conducted research with human subjects...
344
+
345
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
346
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
347
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/Z1Qlm11uOM/Z1Qlm11uOM.md ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LEARNING AUDIO-VISUAL SPEECH REPRESENTATION BY MASKED MULTIMODAL CLUSTER PREDICTION
2
+
3
+ Bowen Shi1∗ Wei-Ning Hsu2 Kushal Lakhotia2 Abdelrahman Mohamed2
4
+
5
+ 1Toyota Technological Institute at Chicago 2Meta AI
6
+
7
+ bshi@ttic.edu {wnhsu,kushall,abdo}@fb.com
8
+
9
+ # ABSTRACT
10
+
11
+ Video recordings of speech contain correlated audio and visual information, providing a strong signal for speech representation learning from the speaker’s lip movements and the produced sound. We introduce Audio-Visual Hidden Unit BERT (AV-HuBERT), a self-supervised representation learning framework for audio-visual speech, which masks multi-stream video input and predicts automatically discovered and iteratively refined multimodal hidden units. AV-HuBERT learns powerful audio-visual speech representation benefiting both lip-reading and automatic speech recognition. On the largest public lip-reading benchmark LRS3 (433 hours), AV-HuBERT achieves $3 2 . 5 \%$ WER with only 30 hours of labeled data, outperforming the former state-of-the-art approach $( 3 3 . 6 \% )$ trained with a thousand times more transcribed video data (31K hours) (Makino et al., 2019). The lip-reading WER is further reduced to $2 6 . 9 \%$ when using all 433 hours of labeled data from LRS3 and combined with self-training. Using our audio-visual representation on the same benchmark for audio-only speech recognition leads to a $40 \%$ relative WER reduction over the state-of-the-art performance $1 . 3 \%$ vs $2 . 3 \%$ ). Our code and models are available at https://github.com/ facebookresearch/av_hubert
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Human perception of speech is intrinsically multimodal, involving audition and vision. The speech production is accompanied by the movement of lips and teeth, which can be visually interpreted to understand speech. Visual cues of speech not only play an essential role in language learning for pre-lingual children (Meltzoff & Moore, 1977; Davies et al., 2008), but also improve speech understanding in noisy environment (Sumby & Pollack, 1954) and provide patients of speech impairment with means of communication. Furthermore, perceptual studies (McGurk & MacDonald, 1976) have shown that such visual cues can alter the perceived sound.
16
+
17
+ For machine learning models, the tight coupling between audio and visual lip movement information emerges as a natural source for supervision to learn speech representations, which has not been extensively utilized yet in the self-supervised speech representation learning literature. Recent successful representation learning frameworks for speech (e.g., APC (Chung et al., 2019), CPC (Oord et al., 2018; Kharitonov et al., 2021), wav2vec 2.0 (Baevski et al., 2020; Hsu et al., 2021b), DeCoAR2.0 (Ling & Liu, 2020), HuBERT (Hsu et al., 2021c;a)) are mostly built entirely on audio. The fundamental research question addressed in this paper is whether a self-supervised audio-visual speech representation learned from the lip movement information, alongside the audio signal in video recordings, captures cross-modal correlations and improves downstream performance for visual speech recognition (i.e., lip reading) and automatic speech recognition (ASR) tasks. Existing ML models for lip-reading rely heavily on text transcriptions to achieve an acceptable level of accuracy. The state-of-the-art lip-reading model (Makino et al., 2019) requires 31K hours of transcribed video data for training. Such large amounts of labeled data are expensive and hard to obtain for most of the world’s 7,000 languages. The benefit from a robust visual speech representation learning framework goes beyond lip-reading. Additionally, it can benefit a vast range of applications, including but not limited to keyword spotting in sign language (Albanie et al., 2020), speech enhancement (Xu et al., 2020) and talking face generation (Chen et al., 2018).
18
+
19
+ In this paper, we present Audio-Visual Hidden Unit BERT (AV-HuBERT), a multimodal selfsupervised speech representation learning framework. It encodes masked audio and image sequences into audio-visual features via a hybrid ResNet-transformer architecture to predict the predetermined sequence of discrete cluster assignments. The target cluster assignments are initially generated from signal processing-based acoustic features (e.g., MFCC) and iteratively refined using the features learned by the audio-visual encoder via $\mathbf { k }$ -means clustering. AV-HuBERT simultaneously captures linguistic and phonetic information for unmasked regions from both the lipmovement and audio streams into its latent representations, then encodes their long-range temporal relationships to solve the masked-prediction task.
20
+
21
+ The contextualized representations learned by AV-HuBERT show excellent transferability to the lipreading task, where only the visual modality is available. Pre-training on audio and visual input streams led to substantially better results than only visual input. In the low-resource setup using only 30 hours of labeled data from LRS3 (Afouras et al., 2018b), our model achieves a lip-reading WER of $3 2 . 5 \%$ , outperforming the previous state-of-the-art model $( 3 3 . 6 \% )$ trained on 31,000 hours of transcribed videos (Makino et al., 2019). Using the complete 433 hours from LRS3 further reduces WER to $2 8 . 6 \%$ . We further show AV-HuBERT and self-training are complementary to each other: combining both sets a new lip-reading WER record of $2 6 . 9 \%$ . In addition, we show that the multimodal clusters derived from AV-HuBERT can be used to pre-train a HuBERT model for audio-based speech recognition, outperforming the previous state-of-the-art model $( 2 . 3 \% )$ and the unimodal HuBERT pre-trained on audio clusters $( 1 . 5 \% )$ by a large margin $( 1 . 3 \% )$ .
22
+
23
+ # 2 RELATED WORK
24
+
25
+ The strong correlation between video modalities provides an effective means for self-supervised representation learning on videos, which has been explored in many prior works and is still an active research area. This work draws inspiration from two lines of previous research:
26
+
27
+ Multimodal general video representation focuses on learning self-supervised audio-visual representations of general videos to solve high-level semantic tasks, e.g., action recognition and audio event detection (Arandjelovic & Zisserman, 2017; Bruno et al., 2018; Morgado et al., 2021; Chen ´ et al., 2020; Lee et al., 2021). Owens & Efros (2018) learns a multimodal network to predict whether the audio and visual streams of a video are temporally synchronized while Pham et al. (2019) applies a cyclic translation between different modalities. Piergiovanni et al. (2020) learns the visual representation through a multi-tasking framework that incorporates a series of pretext tasks such as reconstruction and temporal ordering prediction. Sharing our work’s inspiration of DeepClustering (Caron et al., 2018), XDC (Alwassel et al., 2020) and AV-BERT (Chan et al., 2021) learn cross-modal representations through predicting cross-modal or cluster assignments. In contrast to XDC, AV-HuBERT is trained with a BERT-like masked prediction loss, which forces the model to learn the structure within the multimodal input and was shown in Hsu et al. (2021c) to be more resilient to bad cluster assignments compared to unmasked cluster prediction. On the other hand, AV-BERT focuses on learning utterance-level multimodal environment embeddings that serves as the global context for ASR, while our objective is to learn frame-level audio-visual speech representations and pre-train a model that can be fine-tuned for downstream tasks with either modality.
28
+
29
+ Semi- and self-supervised audio-visual speech representation learning focuses on improving lip-reading with untranscribed audio-visual speech data. To solve isolated visual word recognition, Chung et al. (2020) learns visual embeddings using a contrastive loss based on audio-visual synchronization. Ma et al. (2021a) learns visual speech representations by minimizing the distance between its latent features and off-the-shelf audio embeddings. Using an external supervised ASR to transcribe unlabeled audio, Afouras et al. (2020) trains their lip-reading model on the augmented labeled and pseudo-labeled data. Unlike Ma et al. (2021a) and Afouras et al. (2020), our model is trained from scratch and encouraged to learn contextualized representations with a masked prediction task. Moreover, our method does not rely on any external pre-trained models.
30
+
31
+ # 3 METHOD
32
+
33
+ # 3.1 PRELIMINARY: AUDIO HUBERT
34
+
35
+ Our research builds on Audio HuBERT (Hsu et al., 2021a) which is a self-supervised learning framework for speech and audio. It alternates between two steps: feature clustering and masked prediction. In the first step, a discrete latent variable model (e.g., k-means) is applied to a sequence of acoustic frames $\mathbf { A } _ { 1 : T }$ producing a sequence of frame-level assignments $\mathbf { z } _ { 1 : T } ^ { a }$ . Clusters of signalprocessing-based acoustic features, e.g., Mel-frequency cepstral coefficients (MFCC), exhibit nontrivial correlations with the inherent acoustic units of speech inputs. Using $\left( \mathbf { A } _ { 1 : T } , \mathbf { z } _ { 1 : T } ^ { a } \right)$ pairs, the second step learns new feature representations by minimizing a masked prediction loss, similar to masked language modeling in BERT (Devlin et al., 2019). The pressure to predict cluster assignments of masked audio regions forces the model to learn good local acoustic representations for unmasked regions and long-range temporal dependencies between latent features. Repeating these two steps improves the cluster quality and consequently the quality of the learned representations.
36
+
37
+ # 3.2 SINGLE-MODAL & CROSS-MODAL VISUAL HUBERT
38
+
39
+ Single-modal Visual HuBERT: The most na¨ıve way to extend HuBERT to the visual domain is by generating targets using visual features. Formally, given an image sequence $\mathbf { I } _ { 1 : T }$ , we first cluster the image features into a sequence of discrete units $\mathbf { z } _ { 1 : T } ^ { i }$ via $\mathbf { k }$ -means: $z _ { t } ^ { i } = \mathrm { k } { \cdot } \mathrm { m e a n s } ( G ( \mathbf { I } _ { t } ) ) \ \in$ $\{ 1 , 2 , . . . , V \}$ , where $G$ is an visual feature extractor and $V$ is the codebook size. The cluster assignments $\mathbf { z } _ { 1 : T } ^ { i }$ serve as the prediction targets of the model. Initially, $G$ can be an engineered image feature extractor such as Histogram of Oriented Gradients $( \mathrm { H o G } )$ , analogous to MFCC in audio HuBERT. The intermediate layers of the HuBERT model are used as $G$ in later iterations.
40
+
41
+ To perform the masked prediction task, the model first encodes $\mathbf { I } _ { 1 : T }$ using a ResNet into an intermediate visual feature sequence $\mathbf { f } _ { 1 : T } ^ { v }$ , which is then corrupted into $\tilde { \mathbf { f } } _ { 1 : T } ^ { v }$ via a binary mask $M$ . Specifically, $\forall t \in M$ , $\tilde { \mathbf { f } } _ { t } ^ { v }$ is replaced with a learned masked embedding. We adopt the same strategy in HuBERT to generate span masks. The masked visual features $\tilde { \mathbf { f } } _ { 1 : T } ^ { v }$ are encoded into a sequence of contextualized features ${ \bf e } _ { 1 : T }$ via a transformer encoder followed by a linear projection layer. The loss is computed over the masked regions and optionally over unmasked ones (when $\alpha \geq 0$ ):
42
+
43
+ $$
44
+ \begin{array} { r l } & { \mathbf { p } _ { t } = \mathrm { S o f t m a x } ( \mathbf { W } \mathbf { e } _ { t } + \mathbf { b } ) , 1 \leq t \leq T } \\ & { L = - \displaystyle \sum _ { t \in M } \log p _ { t } ( z _ { t } ^ { i } ) - \alpha \displaystyle \sum _ { t \notin M } \log p _ { t } ( z _ { t } ^ { i } ) } \end{array}
45
+ $$
46
+
47
+ Where $\mathbf { W } \in \mathbb { R } ^ { d \times V }$ , $\mathbf { b } \in \mathbb { R } ^ { V } )$ are parameters of the projection layer which maps features into logits predicting the cluster assignments.
48
+
49
+ Cross-modal Visual HuBERT: The single-modal visual HuBERT aims to learn visual speech representation through gradually refined image features. However, it does not employ the audio stream of the video. Presumably, audio features, e.g., MFCC or a pre-trained audio HuBERT model, correlate with phones better than vanilla image features (e.g., HoG) do. To this end, we train an audio encoder based on the aligned audio frame sequence $\mathbf { A } _ { 1 : T }$ in parallel to the visual encoder. The iterative training alternates between the two encoders. In each iteration, an audio encoder $E ^ { a }$ is utilized to generate target cluster assignments $\mathbf { z } _ { 1 : T } ^ { a }$ . The visual encoder $E ^ { v }$ is trained subsequently with $\left( \mathbf { I } _ { 1 : T } , \mathbf { z } _ { 1 : T } ^ { a } \right)$ . The $\mathbf { z } _ { 1 : T } ^ { a }$ is also used to train the next iteration of the audio encoder $E ^ { a }$ for refinement.
50
+
51
+ The cross-modality visual HuBERT can be seen as modeling visual inputs by distilling knowledge from the audio stream, where $\mathbf { z } _ { 1 : T } ^ { a }$ represents the audio-side knowledge. We hypothesize that the audio feature is more favorable to speech representation learning than the visual feature, which is validated in the Section E.1. Critical for the lip-reading downstream task, the masked prediction objective used by HuBERT forces the model to capture temporal relationships, which facilitates prediction of homophemes, which are groups of sounds with identical visual shapes (e.g., ’p’-’b’, ’f’-’v’, ’sh’-’ch’) that are impossible to distinguish using a single image frame.
52
+
53
+ ![](images/6574503544951b2e80688c2f5064f9468fc40899fcc20c176d3ca390f6cf24ab.jpg)
54
+ Figure 1: Illustration of AV-HuBERT. Masked prediction losses are only computed for the three middle frames, because at least one modality is masked for those frames. See section A for its comparison between single-modal and cross-modal visual HuBERT.
55
+
56
+ # 3.3 AUDIO-VISUAL HUBERT
57
+
58
+ Our primary model in this work is Audio-Visual HuBERT (AV-HuBERT), shown in figure 1, which is trained iteratively by alternating between feature clustering and masked prediction in a similar way to the Visual HuBERT but with four main improvements:
59
+
60
+ Audio-visual input: The AV-HuBERT model consumes both acoustic and image frames for the masked prediction training, which enables better modeling and distillation of the correlations between the two modalities. Specifically, image sequences and acoustic features pass through their light-weight modality-specific encoders to produce intermediate features, which are then fused and fed into a shared backbone transformer encoder to predict masked cluster assignments. The targets are generated from clustering audio features or features extracted from the previous iteration of the AV-HuBERT model. When fine-tuned for lip-reading, we drop the audio input to work solely with the visual input. The input discrepancy is addressed by modality dropout described next.
61
+
62
+ Modality dropout: Audio-visual speech recognition models can relate audio input to lexical output more effortlessly than the visual input stream, as observed in the literature (Afouras et al., 2018a; Ma et al., 2021b). This causes the audio modality to dominate model decisions. The problem is aggravated in our setting because the target cluster assignments are initially generated from acoustic features. To prevent the model’s over-reliance on the audio stream in our joint model, we only use a linear layer to encode acoustic input to force the audio encoder to learn simple features.
63
+
64
+ Additionally, before fusing audio and visual inputs into the backbone transformer encoder, dropout is applied to mask the full features of one modality; we refer to it as modality dropout. With a probability $p _ { m }$ , both modalities are used as input. When only one modality is used, the audio stream is selected with a probability of $p _ { a }$ . Formally, given the encoded audio and visual feature sequence $\mathbf { f } _ { 1 : T } ^ { a }$ and $\mathbf { f } _ { 1 : T } ^ { v }$ , equation 2 shows feature fusion equipped with modality dropout:
65
+
66
+ $$
67
+ \mathbf { f } _ { t } ^ { a v } = \left\{ \begin{array} { l l } { \mathrm { c o n c a t } ( \mathbf { f } _ { t } ^ { a } , \mathbf { f } _ { t } ^ { v } ) \quad } & { \mathrm { w i t h } p _ { m } } \\ { \mathrm { c o n c a t } ( \mathbf { f } _ { t } ^ { a } , \mathbf { 0 } ) \quad } & { \mathrm { w i t h } ( 1 - p _ { m } ) p _ { a } } \\ { \mathrm { c o n c a t } ( \mathbf { 0 } , \mathbf { f } _ { t } ^ { v } ) \quad } & { \mathrm { w i t h } ( 1 - p _ { m } ) ( 1 - p _ { a } ) } \end{array} \right.
68
+ $$
69
+
70
+ where concat denotes channel-wise concatenation. Note that modality drop out is applied at the sequence level instead of at the frame-level, which effectively tasks AV-HuBERT to perform masked prediction with visual-only, audio-only, or audio-visual input. Modality dropout prevents the model from ignoring video input and encourages the model to produce the prediction regardless of what modalities are used as input. Furthermore, since the fine-tuning and inference phases use the visual stream alone (no audio input), this modality dropout mechanism bridges the gap between pretraining (multimodal) and fine-tuning/inference (single-modality). A similar dropout mechanism is used in prior work (Zhang et al., 2019a; Makino et al., 2019; Neverova et al., 2014; Abdelaziz et al., 2020) to increase the robustness in multi-modal settings. We verify the modality dropout effectiveness in Section D.
71
+
72
+ Audio-visual clustering: One benefit of pre-training on both modalities is the ability to generate multimodal cluster assignments that serve as target labels for the masked prediction task of the next iteration. In contrast to the Cross-modal Visual HuBERT where targets are generated from audio-based features or a prior Audio HuBERT model, the targets for AV-HuBERT are naturally multimodal after the first iteration. Lip movement sequences provide complementary information to the audio stream. Combining both modalities produces cluster assignments of higher quality for AV-HuBERT, as shown in Section E.1.
73
+
74
+ Masking by substitution: We propose a novel masking strategy for AV-HuBERT that masks segments in the visual stream by substituting them with random segments from the same video. More formally, given an input video $\mathbf { I } _ { 1 : T } ^ { v }$ , an imposter video $\mathbf { I } _ { 1 : T _ { f } } ^ { v , f }$ and a mask consisting of $n$ intervals $M = \{ ( s _ { i } , t _ { i } ) \} _ { 1 \leq i \leq n }$ , we corrupted $\mathbf { I } _ { 1 : T } ^ { v }$ into $\tilde { \mathbf { I } } _ { 1 : T } ^ { v }$ by setting:
75
+
76
+ $$
77
+ \tilde { \mathbf { I } } _ { s _ { i } : t _ { i } } ^ { v } = \mathbf { I } _ { p _ { i } : p _ { i } + t _ { i } - s _ { i } } ^ { v , f } , \forall 1 \le i \le n
78
+ $$
79
+
80
+ where $p _ { i }$ is a sampled integer offset from the interval $[ 0 , T _ { f } - t _ { i } + s _ { i } ]$ . Now, to solve the task, the model needs to first identify the fake frames and then infer the labels belonging to the original frames. Since the “filled-in” segments are from real video segments and temporally smooth, the fake segment detection sub-task becomes less trivial compared to when using vanilla masking or substitution with non-consecutive frames. We show an ablation confirming the advantage of the proposed masking strategy in Section D.
81
+
82
+ The audio and visual segments are masked independently using two different masking probabilities $m _ { a }$ and $m _ { v }$ . We hypothesize that the difficulty of the masked prediction task differs for each modality: inferring the masked targets given the audio stream is more straightforward than using the lip movement stream. Setting a high masking probability for acoustic frames is essential to help the whole model capture the language characteristics. On the contrary, setting a high masking probability for the visual input provide the model with more imposter segments than the original ones, hurting its ability to learn meaningful features (studied in Section $\mathrm { D }$ of the appendix). Given the output probability $\mathbf { p } _ { 1 : T }$ and target cluster assignments $\mathbf { z } _ { 1 : T }$ , the AV-HuBERT pre-training loss is:
83
+
84
+ $$
85
+ L = - \sum _ { \substack { t \in { \cal { M } } ^ { a } \cup { \cal { M } } ^ { v } } } \log p _ { t } ( z _ { t } ) - \alpha \sum _ { \substack { t \notin { \cal { M } } ^ { a } \cup { \cal { M } } ^ { v } } } \log p _ { t } ( z _ { t } )
86
+ $$
87
+
88
+ where $M ^ { a }$ and $M ^ { v }$ denotes the frames that are masked for the audio and the visual stream. $\alpha$ is a hyperparameter weighting the contribution of the unmasked regions in the overall objective.
89
+
90
+ # 3.4 FINE-TUNING
91
+
92
+ The proposed pre-training approaches can be fine-tuned for visual speech recognition using any sequence classification loss. In this paper, we focus on fine-tuning with the connectionist temporal classification (CTC) (Graves et al., 2006) and attention-based sequence-to-sequence cross-entropy loss (Bahdanau et al., 2016) (S2S for brevity), which are the most popular choices. Assume that the feature sequence output of our pre-trained model is $\mathbf { e } _ { 1 : T }$ and the ground-truth transcription is $w = w _ { 1 } , w _ { 2 } , . . . , w _ { s }$ . For CTC, a projection layer is used to map the visual feature sequence into the output probabilities: $\mathbf { p } _ { t } = \operatorname { S o f t m a x } ( \mathbf { W } ^ { f t } \mathbf { e } _ { t } + \mathbf { b } ^ { f t } )$ , where $\mathbf { W } ^ { f t } \in \mathbb { R } ^ { d \times ( U + 1 ) }$ , $\mathbf { b } ^ { f t } \in \mathbb { R } ^ { U + 1 }$ and $U$ is the output vocabulary size $+ 1$ : plus blank symbol). The model is trained with CTC loss: $\begin{array} { r } { L _ { c t c } = - \log { \bar { \sum _ { \pi \in \mathcal { B } ^ { - 1 } ( w ) } p ( \pi | \mathbf { e } _ { 1 : T } ) } } } \end{array}$ , where $\boldsymbol { B }$ maps an alignment sequence $\pi$ to $w$ . For S2S, a tranformer decoder is appended to the pre-trained encoder to autoregressively decode the feature sequence ${ \bf e } _ { 1 : T }$ into target probabilities $p ( w _ { t } | w _ { 1 : t - 1 } , \mathbf { e } _ { 1 : T } )$ . The whole model is trained with cross entropy loss: $\begin{array} { r } { L _ { s 2 s } = - \sum _ { t = 1 } ^ { s } \log p ( w _ { t } | w _ { 1 : t - 1 } , \mathbf { e } _ { 1 : T } ) } \end{array}$ .
93
+
94
+ # 4 EXPERIMENT
95
+
96
+ # 4.1 SETUP
97
+
98
+ We conduct experiments on two datasets: LRS3 (Afouras et al., 2018b) with 433 hours of transcribed English videos and VoxCeleb2 (Chung et al., 2018) with 2442 hours of unlabeled multilingual videos. We only use the English portion of VoxCeleb2, which amounts to 1,326 hours of content. The inputs to our backbone model are lip Regions-Of-Interest (ROIs) for the visual stream and log filterbank energy feature for the audio stream. The image encoder is a modified ResNet-18, which has been used in prior work (Ma et al., 2021b; Martinez et al., 2020; Stafylakis & Tzimiropoulos, 2017). The audio encoder is simply a linear projection layer. We consider two model configurations: BASE with 12 transformer blocks and LARGE with 24 transformer blocks. For BASE and LARGE, the embedding dimension/feed-forward dimension/attention heads in each transformer block are 768/3072/12 and 1024/4096/16 respectively. The number of parameters in BASE and LARGE are 103M and 325M respectively. $\alpha$ in equation 4 is set to 0.
99
+
100
+ The model uses five iterations of feature clustering and masked prediction during pre-training. See Section B.4, E for details on clustering. For fine-tuning, we use phone targets for the CTC loss and unigram-based subword units (Kudo, 2018) for the S2S loss. For decoding the CTC-trained model, we use a 4-gram language model trained on LRS3 training text. For the S2S fine-tuned model, we rely only on its own decoder module to incorporate language information, with no external language model employed during inference. To further show the complementary relationship between AVHuBERT and existing approaches of using unlabeled data, we also experiment on combining AVHuBERT with self-training. Specifically, we generate pseudo labels for unlabeled data using a finetuned HuBERT, and fine-tune the pre-trained AV-HuBERT model with the combination of pseudolabeled videos and original labeled videos. Note that no additional data is used when combined with self-training. More details about the used datasets, data pre-processing, and model training are in Section B.
101
+
102
+ # 4.2 MAIN RESULT
103
+
104
+ Table 1 compares the performance of our AV-HuBERT pre-training approach to previously published supervised, semi-supervised, and self-supervised lip-reading systems using different amounts of labeled and unlabeled data. Since the CTC and S2S fine-tuning approaches have similar trends, only S2S results are shown in table 1. Complete results of CTC fine-tuning are in Table C.4.1
105
+
106
+ Using 1,759 hours unlabeled data for pre-training and only 30 hours of labeled data for fine-tuning, AV-HuBERT-LARGE outperforms all the prior lip-reading models, including the model in (Makino et al., 2019) which is trained with 1000 times more labeled data. Fine-tuning with the whole training set of LRS3 further reduces WER. Combining our method and self-training achieves a new SOTA result with only $7 \%$ of the data used for training the model in Makino et al. (2019). Furthermore, it shows that AV-HuBERT and self-training are complementary to each other. Note the overall gain is attributed mainly to AV-HuBERT as self-training alone leads to much worse performance $( > 5 0 \%$ WER). More details can be found in section C.3. Many prior models pre-train their visual front-end, e.g., ResNet-18, using word-level annotated lip-reading videos, which is costly to collect since they require word boundary information. In contrast to these models, our models are fully pre-trained from scratch using the proposed approach.
107
+
108
+ Compared to the semi-supervised approach Jasper-KD (Afouras et al., 2020), which transcribed 334 hours of the English data in VoxCeleb2 using a pre-trained ASR system,2 our best model achieves $2 9 \%$ lower absolute WER benefiting from VoxCeleb2 for pre-training. Even when limiting our model to the LRS3 data for pre-training and fine-tuning, our model surpasses their semi-supervised system by $18 \%$ . Compared to LiRA (Ma et al., 2021a), a recently proposed self-supervised model for lip-reading, AV-HuBERT-BASE provides $1 7 . 5 \%$ lower absolute WER on average for low-resource and high-resource settings. The implementation details of LiRA are provided in Section B.5.
109
+
110
+ With the same network architecture, our pre-training approach significantly reduces WER compared to training from scratch, in both low-resource $( \bar { 9 } 2 . \bar { 3 } \bar { \% } 3 2 . \bar { 5 } \%$ , LARGE) and high-resource $( 6 2 . 3 \% 2 8 . 6 \%$ , LARGE) settings. A qualitative view of the improvement can be found in Section F. Additionally, we notice that our AV-HuBERT pre-training helps under a fully supervised setting. Using the LRS3 data only (433 hours), pre-training followed by fine-tuning $( 4 1 . 6 \%$ , LARGE) outperforms training a lip-reading model from scratch $6 2 . 3 \%$ , LARGE) to predict the output text.
111
+
112
+ Table 1: WER $( \% )$ of our models and prior work on the LRS3 dataset. $\mathrm { \Delta \Psi \dag \mathrm { W e } }$ re-implemented Ma et al. (2021a) with the same architecture since the author source code was not provided.
113
+
114
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Backbone</td><td rowspan="2">Criterion</td><td rowspan="2">Labeled iso (hrs)</td><td rowspan="2">Labeled utt (hrs)</td><td rowspan="2">Unlabeled data (hrs)</td><td rowspan="2">WER (%)</td></tr><tr><td></td></tr><tr><td colspan="8">Supervised</td></tr><tr><td>Afouras et al. (2020)</td><td>CNN</td><td>CTC</td><td>157</td><td>433</td><td></td><td>68.8</td></tr><tr><td>Zhang et al. (2019b)</td><td>CNN</td><td>S2S</td><td>157</td><td>698</td><td></td><td>60.1</td></tr><tr><td>Afouras et al. (2018a)</td><td>Transformer</td><td>S2S</td><td>157</td><td>1,362</td><td></td><td>58.9</td></tr><tr><td>Xu et al. (2020)</td><td>RNN RNN</td><td>S2S</td><td>157</td><td>433</td><td></td><td>57.8</td></tr><tr><td>Shillingford et al. (2019)</td><td>Conformer</td><td>CTC</td><td>1</td><td>3,886</td><td></td><td>55.1</td></tr><tr><td>Ma et al. (2021b)</td><td></td><td>CTC+S2S</td><td>-</td><td>433</td><td></td><td>46.9</td></tr><tr><td>Ma et al. (2021b) Makino et al. (2019)</td><td>Conformer RNN</td><td>CTC+S2S Transducer</td><td>157 -</td><td>433 31,000</td><td></td><td>43.3 33.6</td></tr><tr><td colspan="7"></td></tr><tr><td>Afouras et al. (2020)</td><td>CNN</td><td>Semi-Supervised &amp;Self-Supervised CTC</td><td>157</td><td>433</td><td>334</td><td>59.8</td></tr><tr><td>Ma et al. (2021a)t</td><td>Transformer-BASE</td><td>S2S</td><td>■</td><td>30 433</td><td>433 1,759</td><td>71.9 49.6</td></tr><tr><td colspan="7">= Proposed (Self-Supervised &amp; Self-Supervised + Semi-Supervised)</td></tr><tr><td rowspan="9">AV-HuBERT</td><td rowspan="5">Transformer-BASE</td><td rowspan="5">S2S</td><td></td><td>30</td><td>-</td><td>94.3</td></tr><tr><td></td><td>30</td><td>433</td><td>51.8</td></tr><tr><td></td><td>30</td><td>1,759</td><td>46.1</td></tr><tr><td></td><td>433</td><td>-</td><td>60.3</td></tr><tr><td></td><td>433</td><td>433</td><td></td></tr><tr><td></td><td>=</td><td>433</td><td>1,759</td><td>44.0 34.8</td></tr><tr><td rowspan="5">Transformer-LARGE</td><td>S2S</td><td>30</td><td>■</td><td>92.3</td></tr><tr><td></td><td>30</td><td>433</td><td>44.8</td></tr><tr><td></td><td>30</td><td>1,759</td><td>32.5</td></tr><tr><td></td><td>433</td><td>-</td><td>62.3</td></tr><tr><td></td><td>433</td><td>433</td><td>41.6</td></tr><tr><td rowspan="2">AV-HuBERT+ Self-Training</td><td rowspan="2">Transformer-LARGE</td><td rowspan="2">S2S</td><td></td><td>433</td><td>1,759</td><td>28.6</td></tr><tr><td></td><td>30 433</td><td>1,759 1,759</td><td>28.6 26.9</td></tr></table>
115
+
116
+ AV-HuBERT, pre-trained on video-audio pairs, learns better fine-grained visual representation than the scratch model trained on video-text pairs. The benefits of AV-HuBERT pre-training in various labeled data setups can be found in Section C.1.
117
+
118
+ # 4.3 AV-HUBERT VS. VISUAL HUBERT
119
+
120
+ We compare AV-HuBERT against a suite of alternatives, including the Single-modal and Crossmodal Visual HuBERT in Table 2. All the models are BASE pretrained on 433 hours of unlabeled data and fine-tuned on 30 hours of labeled data. For this comparison, we use CTC fine-tuning due to its computational efficiency and given their similarity in results trends to S2S.
121
+
122
+ Table 2: Fine-tuning performance (in WER, $\%$ ) of AV-HuBERT and visual HuBERT on different target labels. Init: feature in the initial iteration, sub: feature in subsequent iterations. AV: AVHuBERT, V: Visual-HuBERT, A: Audio-HuBERT.
123
+
124
+ <table><tr><td rowspan="2">Model/init-→sub</td><td colspan="5">Iteration</td></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td>AV/MFCC→AV</td><td>71.5</td><td>63.6</td><td>60.9</td><td>58.8</td><td>58.2</td></tr><tr><td>AV/MFCC→A</td><td>71.5</td><td>64.3</td><td>63.5</td><td>1</td><td>1</td></tr><tr><td>V/MFCC→A</td><td>75.4</td><td>69.4</td><td>69.1</td><td>1</td><td>1</td></tr><tr><td>V/MFCC→V</td><td>75.4</td><td>72.6</td><td>72.3</td><td>=</td><td></td></tr><tr><td>V/HoG→V</td><td>80.3</td><td>80.1</td><td>1</td><td>=</td><td>=</td></tr></table>
125
+
126
+ ![](images/b8e09fd840951f6286d5424efbd8ece8e563a6c810afac293165c41213d03551.jpg)
127
+
128
+ As shown in table 2, target cluster assignments driven from a single modality, either audio or visual, do not provide much WER reduction beyond the second iteration. Training the AV-HuBERT model using targets driven from audio-visual features keeps improving for more iterations and achieves better final performance. As mentioned in Section 3, visual information is complementary to audio input; hence, using both produces higher quality target clusters. Measuring the quality of different target labels using cluster quality metrics such as purity and NMI shows the same trend observed from lip-reading WER (See appendix E.1).
129
+
130
+ Fixing target labels used for the masked-prediction pre-training, AV-HuBERT (AV/MFCC $ \mathsf { A }$ ) outperforms the Cross-modal Visual HuBERT $( \mathrm { V } / \mathrm { M F C C } \to \mathrm { A } )$ by a large margin. AV-HuBERT effectively transfers knowledge from audio into the visual encoder and the backbone transformer model to benefit visual-only fine-tuning and inference. In contrast to AV-HuBERT, iterative pre-training brings much smaller gains to single-modality visual HuBERT (”V/MFCC $ \mathbf { V } ^ { * }$ , $\mathrm { ^ { 3 9 } V / H o G \mathrm { } V ^ { 3 } } \mathrm { , }$ ).
131
+
132
+ Starting with audio features is critical for learning effective target labels for the masked-prediction task. Phonetic information, which is crucial for lip-reading, is primarily present in the audio stream. All the models considered so far are based on audio feature MFCC clustering in their initial iteration. As is shown in the $\mathrm { ^ { * } V / H o G { } V ^ { ; } }$ row, using hand-engineered visual features provides a lousy starting point for iterative learning. Visual features such as HoG mainly incorporate low-level visual cues such as edges and luminance, which is irrelevant to the downstream recognition task. Using features of a higher correlation with phonetic units are more likely to benefit the final lip-reading model. Indeed, clustering MFCC features show much higher purity $( 3 0 . 3 \% )$ than HoG clusters $( 1 6 . 4 \% )$ if one considers phone labels as the target units, as shown in Table E.1.
133
+
134
+ # 4.4 MULTILINGUAL VS. MONOLINGUAL
135
+
136
+ Since the correlation between lip movements and the produced sound is governed by the vocal apparatus that is language-agnostic, the proposed AV-HuBERT can utilize multi-lingual data for such learning. This would be particularly beneficial for low-resource languages. Nevertheless, the masked language modeling aspect in AV-HuBERT is still language-dependent, implying that mixing other languages would increase the language domain discrepancy. To study how these two factors affect AV-HuBERT, we compare using monolingual English data only versus multilingual videos in the pre-training phase. In particular, we vary the amount of English data we use in pre-training while the number of non-English utterances is fixed to 1,116 hours in all the settings. For simplicity, we train AV-HuBERT (BASE) for one iteration with MFCC clusters and fine-tune it with CTC using 30 hours of labeled data.
137
+
138
+ Table 3: WER $( \% )$ with different amounts of unlabeled English utterances in pre-training. Non-En data: 1,116 hours. Labeled data for fine-tuning: 30 hours.
139
+
140
+ <table><tr><td>Hours of En data for Pre-Training</td><td>0</td><td>100</td><td>400</td><td>800</td><td>1759</td></tr><tr><td>Pre-train on En only, WER (%)</td><td>84.1</td><td>77.8</td><td>68.9</td><td>67.9</td><td>59.9</td></tr><tr><td>Pre-train on En + 1,116 hr of non-En,WER (%)</td><td>70.6</td><td>68.4</td><td>67.4</td><td>66.6</td><td>64.3</td></tr></table>
141
+
142
+ As is shown in table 3, using non-English data in pre-training significantly reduces WER when there are no or very little English data in pre-training $( \leq 1 0 0$ hours). As we increase the amount of English data, the gain diminishes because the out-of-domain effect brought by non-English data outweighs the benefit of the overall increase in pre-training data. Using the whole English data only for pre-training is better than combining it with other languages $5 9 . 9 \%$ vs. $6 4 . 3 \%$ ). Training with 5 iterations leads to similar results $4 7 . 3 \%$ vs. $4 8 . 9 \%$ ). This experiment highlights the importance of the domain match between pre-training and fine-tuning data. For zero/low-resource settings, merging data from other languages in pre-training benefits the downstream task. When the unlabeled data from the target language is abundant, limiting the pre-training data to one language is beneficial.
143
+
144
+ # 4.5 ASR PERFORMANCE
145
+
146
+ The multimodal clusters produced by AV-HuBERT, which have higher quality than audio-HuBERT targets, can also benefit speech pre-training. To test our hypothesis, we trained an audio-HuBERT, with only audio input during the masked-prediction pre-training, for one iteration with cluster assignments driven from AV-HuBERT features. We also pre-trained an audio-HuBERT from scratch using clusters driven from the MFCC features for three iterations. The two pre-trained models are evaluated on a downstream ASR task.
147
+
148
+ Table 4 shows the performance of different models fine-tuned on the ASR task. We only include the performance of S2S fine-tuning for our models as it consistently outperforms the CTC fine-tuning. An audio-HuBERT pre-trained using targets generated by AV-HuBERT features outperforms the vanilla audio-HuBERT in low-resource (30h) and high-resource settings (433h) fine-tuning settings across different model architectures. With the same amount of labeled data, our best model $( 1 . 4 \% )$ outperforms the prior SOTA $( 2 . 3 \% )$ even without an external language model during inference.
149
+
150
+ Given that the AV-HuBERT model utilizes both modalities at its input, it can be fine-tuned, in principle, for the ASR downstream task. In practice, we notice pre-training an audio-HuBERT with audio-visual cluster leads to better ASR performance $( 3 . 8 \% )$ than a pre-trained AV-HuBERT $( 4 . 6 \% )$ , potentially due to its hyperparameters being selected based on lip reading rather than ASR. In fact, audio-HuBERT can be treated as a special case of AV-HuBERT with $p _ { m } = 0$ , $p _ { a } = 1$ .
151
+
152
+ Table 4: ASR WER $( \% )$ of audio-HuBERT pre-trained with audio-only/audio-visual clusters and their comparison to prior work on the LRS3 dataset.
153
+
154
+ <table><tr><td>Method</td><td>Backbone</td><td>Criterion</td><td>LM</td><td>Labeled data (hrs)</td><td>Unlabeled data (hrs)</td><td>WER (%)</td></tr><tr><td colspan="7">Supervised</td></tr><tr><td>Afouras et al. (2018a)</td><td>Transformer</td><td>S2S</td><td></td><td>1,362</td><td></td><td>8.3</td></tr><tr><td>Afouras et al. (2018a)</td><td>Transformer</td><td>CTC</td><td>√</td><td>1,362</td><td></td><td>8.9</td></tr><tr><td>Xu et al. (2020)</td><td>RNN</td><td>S2S</td><td>-</td><td>433</td><td></td><td>7.2</td></tr><tr><td>Ma et al. (2021b)</td><td>Conformer</td><td>CTC+S2S</td><td>√</td><td>433</td><td></td><td>2.3</td></tr><tr><td colspan="7">Self-Supervised</td></tr><tr><td rowspan="6">Hsu et al. (2021a) (A/MFCC→A)</td><td rowspan="2">Transformer-Base</td><td rowspan="2">S2S</td><td></td><td>30</td><td>433</td><td>5.4</td></tr><tr><td></td><td>30</td><td>1,759</td><td>5.0</td></tr><tr><td rowspan="2"></td><td rowspan="2"></td><td></td><td>433</td><td>1,759</td><td>2.4</td></tr><tr><td></td><td>30</td><td>433</td><td>4.5</td></tr><tr><td rowspan="2">Transformer-Large</td><td rowspan="2">S2S</td><td></td><td>30</td><td>1,759</td><td>3.2</td></tr><tr><td></td><td>433</td><td>1,759</td><td>1.5</td></tr><tr><td colspan="7">Proposed (Self-Supervised)</td></tr><tr><td rowspan="6">A/MFCC→AV</td><td rowspan="2">Transformer-Base</td><td rowspan="2">S2S</td><td></td><td>30</td><td>433</td><td>4.9</td></tr><tr><td></td><td>30</td><td>1,759</td><td>3.8</td></tr><tr><td rowspan="3">Transformer-Large</td><td rowspan="3"></td><td></td><td>433</td><td>1,759</td><td>2.0</td></tr><tr><td></td><td>30</td><td>433</td><td>4.2</td></tr><tr><td></td><td>30</td><td>1,759</td><td>2.9</td></tr><tr><td></td><td></td><td></td><td>433</td><td>1,759</td><td>1.3</td></tr></table>
155
+
156
+ # 5 CONCLUSION
157
+
158
+ We presented multiple pre-training models for visual speech recognition. Our AV-HuBERT model leverages the strong correlation between the audio and lip movement streams for self-supervised audio-visual speech representation learning. Our pre-training approaches iteratively alternate between feature clustering and learning new features through a masked-prediction loss. The AVHuBERT model consumes masked image and audio frames to predict target cluster assignments. The targets are initially generated from MFCC features and gradually refined through iterative training. Experiments on visual speech recognition show that AV-HuBERT achieves SOTA using 433 hours of text transcriptions, two orders of magnitude less than the 31,000 hours of labeled data used in the prior best approach. When using only one-thousandth of labeled data, the lip-reading performance outperforms the prior SOTA by more than $10 \%$ (relative). AV-HuBERT also improves the representation for the ASR downstream task. An audio-HuBERT model trained with targets generated by an AV-HuBERT model shows superior performance, achieving the SOTA in the audio-based speech recognition in the LRS3 dataset. As future work, AV-HuBERT can be applied for multilingual lip-reading in low-resource languages. Additionally, our approach can be extended to other applications of visual speech representation, such as speech enhancement and generation.
159
+
160
+ # ETHICAL STATEMENT
161
+
162
+ All the data used in this paper are publicly available and are used under the following three licenses: the TED terms of use, the Creative Commons BY-NC-ND 4.0 license and Creative Commons Attribution 4.0 International License. Through spot-checking, we find the datasets are gender balanced and cover a wide range of races and ages. However, the distribution of speakers in the data may not be representative of the global human population. Please be cautious of unintended societal, gender, racial and other biases caused by the fact. To maintain anonymity, only the mouth area of a speaker is visualized wherever used in the paper. The proposed method can be applied in several areas including security and crime investigations. However it can also be used for malicious purposes such as surveillance and wiretapping. We are committed to distributing our code and model carefully, with special attention to any potential security and privacy concerns.
163
+
164
+ # REPRODUCIBILITY STATEMENT
165
+
166
+ Our code and models are publicly available. In the meantime, we include as many implementation details as we can in the paper.
167
+
168
+ # REFERENCES
169
+
170
+ The CMU pronouncing dictionary. http://www.speech.cs.cmu.edu/cgi-bin/ cmudict.
171
+
172
+ Ahmed Hussen Abdelaziz, Barry-John Theobald, Paul Dixon, Reinhard Knothe, Nicholas Apostoloff, and Sachin Kajareker. Modality dropout for improved performance-driven talking faces. In ICMI, 2020.
173
+
174
+ Triantafyllos Afouras, Joon Son Chung, A. Senior, Oriol Vinyals, and Andrew Zisserman. Deep audio-visual speech recognition. IEEE transactions on pattern analysis and machine intelligence, 2018a.
175
+
176
+ Triantafyllos Afouras, Joon Son Chung, and Andrew Zisserman. LRS3-TED: a large-scale dataset for visual speech recognition, 2018b. arXiv:1809.00496.
177
+
178
+ Triantafyllos Afouras, Joon Son Chung, and Andrew Zisserman. ASR is all you need: Cross-modal distillation for lip reading. In ICASSP, 2020.
179
+
180
+ Samuel Albanie, Gul Varol, Liliane Momeni, Triantafyllos Afouras, Joon Son Chung, Neil Fox, and ¨ Andrew Zisserman. BSL-1K: Scaling up co-articulated sign language recognition using mouthing cues. In ECCV, 2020.
181
+
182
+ Humam Alwassel, Dhruv Mahajan, Bruno Korbar, Lorenzo Torresani, Bernard Ghanem, and Du Tran. Self-supervised learning by cross-modal audio-video clustering. In NeurIPS, 2020.
183
+
184
+ Relja Arandjelovic and Andrew Zisserman. Look, listen and learn. In ´ ICCV, 2017.
185
+
186
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
187
+
188
+ Alexei Baevski, Henry Zhou, Abdel rahman Mohamed, and Michael Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. In NeurIPS, 2020.
189
+
190
+ Dzmitry Bahdanau, Jan Chorowski, Dmitriy Serdyuk, Philemon Brakel, and Yoshua Bengio. Endto-end attention-based large vocabulary speech recognition. In ICASSP, 2016.
191
+
192
+ Korbar Bruno, Tran Du, and Torresani Lorenzo. Cooperative learning of audio and video models from self-supervised synchronization. In NeurIPS, 2018.
193
+
194
+ Mathilde Caron, Piotr Bojanowski, Armand Joulin, and Matthijs Douze. Deep clustering for unsupervised learning of visual features. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 132–149, 2018.
195
+
196
+ David M. Chan, Shalini Ghosh, Debmalya Chakrabarty, and Bjorn Hoffmeister. Multi-modal pre- ¨ training for automated speech recognition. arXiv preprint arXiv:2110.09890, 2021.
197
+
198
+ Lele Chen, Zhiheng Li, Ross K. Maddox, Zhiyao Duan, and Chenliang Xu. Lip movements generation at a glance. In ECCV, 2018.
199
+
200
+ Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. Uniter: Universal image-text representation learning. In ECCV, 2020.
201
+
202
+ Joon Son Chung, Arsha Nagrani, and Andrew Zisserman. Voxceleb2: Deep speaker recognition. In INTERSPEECH, 2018.
203
+
204
+ Soo-Whan Chung, Hong Kang, and Joon Son Chung. Seeing voices and hearing voices: learning discriminative embeddings using cross-modal self-supervision. In Interspeech, 2020.
205
+
206
+ Yu-An Chung, Wei-Ning Hsu, Hao Tang, and James Glass. An unsupervised autoregressive model for speech representation learning. arXiv preprint arXiv:1904.03240, 2019.
207
+
208
+ Rebecca Davies, Evan Kidd, and Karen Lander. Investigating the psycholinguistic correlates of speechreading in preschool age children. International journal of language and communication disorders, 44:164–74, 06 2008.
209
+
210
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
211
+
212
+ Angela Fan, Edouard Grave, and Armand Joulin. Reducing transformer depth on demand with structured dropout. In ICLR, 2020.
213
+
214
+ Alex Graves, Santiago Fernandez, Faustino Gomez, and J ´ urgen Schmidhuber. Connectionist tempo- ¨ ral classification: labelling unsegmented sequence data with recurrent neural networks. In ICML, 2006.
215
+
216
+ Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. arXiv preprint arXiv:2106.07447, 2021a.
217
+
218
+ Wei-Ning Hsu, Anuroop Sriram, Alexei Baevski, Tatiana Likhomanenko, Qiantong Xu, Vineel Pratap, Jacob Kahn, Ann Lee, Ronan Collobert, Gabriel Synnaeve, et al. Robust wav2vec 2.0: Analyzing domain shift in self-supervised pre-training. arXiv preprint arXiv:2104.01027, 2021b.
219
+
220
+ Wei-Ning Hsu, Yao-Hung Hubert Tsai, Benjamin Bolte, Ruslan Salakhutdinov, and Abdelrahman Mohamed. Hubert: How much can a bad teacher benefit asr pre-training? In ICASSP, 2021c.
221
+
222
+ Eugene Kharitonov, Morgane Riviere, Gabriel Synnaeve, Lior Wolf, Pierre-Emmanuel Mazar \` e,´ Matthijs Douze, and Emmanuel Dupoux. Data augmenting contrastive learning of speech representations in the time domain. In 2021 IEEE Spoken Language Technology Workshop (SLT), pp. 215–222. IEEE, 2021.
223
+
224
+ Davis E. King. Dlib-ml: A machine learning toolkit. Journal of Machine Learning Research, 10: 1755–1758, 2009.
225
+
226
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015.
227
+
228
+ Taku Kudo. Subword regularization: Improving neural network translation models with multiple subword candidates. In ACL, 2018.
229
+
230
+ Sangho Lee, Youngjae Yu, Gunhee Kim, Thomas Breuel, Jan Kautz, and Yale Song. Parameter Efficient Multimodal Transformers for Video Representation Learning. In ICLR, 2021.
231
+
232
+ Shaoshi Ling and Yuzong Liu. Decoar 2.0: Deep contextualized acoustic representations with vector quantization. arXiv preprint arXiv:2012.06659, 2020.
233
+
234
+ Pingchuan Ma, Rodrigo Mira, Stavros Petridis, Bjorn Schuller, and Maja Pantic. LiRA: Learning ¨ visual speech representations from audio through self-supervision. In Interspeech, 2021a.
235
+
236
+ Pingchuan Ma, Stavros Petridis, and Maja Pantic. End-to-end audio-visual speech recognition with conformers. In ICASSP, 2021b.
237
+
238
+ Takaki Makino, Hank Liao, Yannis Assael, Brendan Shillingford, Basilio Garcia, Otavio Braga, and Olivier Siohan. Recurrent neural network transducer for audio-visual speech recognition. In Interspeech, 2019.
239
+
240
+ Brais Martinez, Pingchuan Ma, Stavros Petridis, and Maja Pantic. Lipreading using temporal convolutional networks. In ICASSP, 2020.
241
+
242
+ Harry McGurk and John MacDonald. Hearing lips and seeing voices. Nature, 264:746–748, 1976.
243
+
244
+ Andrew N. Meltzoff and M. Keith Moore. Imitation of facial and manual gestures by human neonates. Science, 198:75–78, 1977.
245
+
246
+ Pedro Morgado, Nuno Vasconcelos, and Ishan Misra. Audio-visual instance discrimination with cross-modal agreement. In CVPR, 2021.
247
+
248
+ Natalia Neverova, Christian Wolf, Graham Taylor, and Florian Nebout. ModDrop: adaptive multimodal gesture recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2014.
249
+
250
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
251
+
252
+ Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan $\mathrm { N g }$ , David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of NAACL-HLT 2019: Demonstrations, 2019.
253
+
254
+ Andrew Owens and Alexei A Efros. Audio-visual scene analysis with self-supervised multisensory features. In ECCV, 2018.
255
+
256
+ Hai Pham, Paul Liang, Thomas Manzini, Louis-Philippe Morency, and Barnabas Poczos. Found in translation: Learning robust joint representations by cyclic translations between modalities. In AAAI, 2019.
257
+
258
+ AJ Piergiovanni, Anelia Angelova, and Michael Ryoo. Evolving losses for unlabeled video representation learning. In CVPR, 2020.
259
+
260
+ Mirco Ravanelli, Jianyuan Zhong, Santiago Pascual, Pawel Swietojanski, Joao L. Monteiro, Jan ˜ Trmal, and Yoshua Bengio. Multi-task self-supervised learning for robust speech recognition. In ICASSP, 2020.
261
+
262
+ Brendan Shillingford, Yannis Assael, Matthew Hoffman, Thomas Paine, C´ıan Hughes, Utsav Prabhu, Hank Liao, Hasim Sak, Kanishka Rao, Lorrayne Bennett, Marie Mulville, Ben Coppin, Ben Laurie, Andrew Senior, and Nando Freitas. Large-scale visual speech recognition. In Interspeech, 2019.
263
+
264
+ Themos Stafylakis and Georgios Tzimiropoulos. Combining residual networks with lstms for lipreading. In Interspeech, 2017.
265
+
266
+ W. H. Sumby and Irwin Pollack. Visual contribution to speech intelligibility in noise. Journal of the Acoustical Society of America, 26:212–215, 1954.
267
+
268
+ Bo Xu, Cheng Lu, Yandong Guo, and Jacob Wang. Discriminative multi-modality speech recognition. In CVPR, 2020.
269
+
270
+ Shiliang Zhang, Ming Lei, Bin Ma, and Lei Xie. Robust audio-visual speech recognition using bimodal dfsmn with multi-condition training and dropout regularization. In ICASSP, 2019a.
271
+
272
+ Xingxuan Zhang, Feng Cheng, and Shilin Wang. Spatio-temporal fusion based convolutional sequence learning for lip reading. In ICCV, 2019b.
273
+
274
+ A MODEL ILLUSTRATION
275
+
276
+ ![](images/b64707d7eec3e821090fc60be24e080f3aa1350e6c443e631b4d7728f392d283.jpg)
277
+ Figure A.1: Comparison between the proposed AV-HuBERT with single-modal and cross-modal visual HuBERT
278
+
279
+ # B DETAILED EXPERIMENTAL SETUP
280
+
281
+ # B.1 DATASETS
282
+
283
+ LRS3 (Afouras et al., 2018b) is the largest publicly available sentence-level lip reading dataset to date. It consists of over 400 hours of video, extracted from TED & TEDx talks in English from YouTube. In the original dataset, the training data is split into two partitions: pretrain (403 hours) and trainval (30 hours). Both parts are transcribed at the sentence level and come from the same source as the test set. The pretrain set differs from trainval in that the duration of its video clips are of a much wider range and can be shorter or longer than a full sentence. In the low-resource setup, we only use trainval as the labeled data. As no official development set is provided, we randomly select 1,200 sequences from trainval as the validation set (about 1 hour) for early stopping and hyperparameter tuning.
284
+
285
+ VoxCeleb2 (Chung et al., 2018) is originally created for multilingual audio-visual speaker recognition and it contains over 2,442 hours of utterances of over 6,000 speakers extracted from YouTube videos. The dataset naturally serves our purpose as it does not contain ground-truth transcriptions. The VoxCeleb2 has substantial domain discrepency to the LRS3 data as its utterances are from multiple languages and includes videos in a larger variety of domains including interviews, talks, excerpts under indoor and outdoor environments. In VoxCeleb2, by default we only use the English portion for pre-training. As no ground-truth language label is given in the VoxCeleb2, we use a simple heuristic to choose the English samples. Specifically, we use an off-the-shelf character-based ASR model (Hsu et al., 2021a) trained on Librispeech which achieves $1 . 9 \% / 3 . 5 \%$ WER on clean/other test set. We run greedy decoding on the VoxCeleb2 and use the proportion of valid English words to determine if a target utterance is English or not. An utterance is only selected if the proportion of valid English words is higher than $60 \%$ . The total amount of unlabeled data after filtering is 1,326 hours.
286
+
287
+ # B.2 DATA PREPROCESSING
288
+
289
+ For each video clip, we detect the 68 facial keypoints using dlib (King, 2009) and align each frame to a reference face frame via affine transformation. We crop a $9 6 \times 9 6$ region-of-interest (ROI) centered on the mouth. Each image frame is converted to grayscale. We randomly cropped $8 8 \times 8 8$ from the whole ROI and randomly flipped it horizontally with probablity of 0.5 during training. At test time, $8 8 \times 8 8$ ROI is center cropped and does not go through horizontal flipping. The preprocessing steps remain same as prior works in lip reading (Martinez et al., 2020; Ma et al., 2021b). For the associated audio, we extract the 26-dimensional log filterbank energy feature at a stride of $1 0 ~ \mathrm { m s }$ from the raw waveform and use it as input to the model. As the image frames are sampled at $2 5 \mathrm { H z }$ , we stack the 4 neighboring acoustic frames to synchronize the two modalities.
290
+
291
+ # B.3 AV-HUBERT MODEL ARCHITECTURE
292
+
293
+ In the modified ResNet-18 (Ma et al., 2021b; Martinez et al., 2020; Stafylakis & Tzimiropoulos, 2017), the first convolutional layer is substituted by a 3D convolutional layer with kernel size $5 \times$ $7 \times 7$ . The visual feature tensor is flattened into a single-dimensional vector through a 2D average pooling layer in the end. We use one linear projection layer as the audio encoding module. The acoustic features are normalized by per-frame statistics before feeding into the network (Ba et al., 2016). We use a dropout of $p = 0 . 1$ after the self-attention block within each transformer layer, and each transformer layer is dropped (Fan et al., 2020) at a rate of 0.1.
294
+
295
+ # B.4 TRAINING AND INFERENCE
296
+
297
+ Pretraining Our models are implemented with fairseq (Ott et al., 2019). The whole network is randomly initialized before pre-training. In pre-training, the model is trained for five iterations in total. For the initial iteration, we generate the targets by running $\mathbf { k }$ -means clustering algorithm on 39-dimensional MFCC feature (13 coefficients with its first- and second-order derivatives) extracted from raw audio waveform. For the subsequent iterations, the feature from an intermediate layer of the model in the previous iteration is used for clustering. The layer index (one-based) used for clustering in iteration 1-4 are {9, 12, 12, 12}. The number of features are clustered to $\{ 1 0 0 , 1 0 0 $ ,
298
+
299
+ 500, 1000, 2000} respectively for the 5 iterations. See section E.3 for analysis. To save training time, we always use the BASE model to generate clusters and LARGE model is only trained in the 5th iteration.
300
+
301
+ We set both $p _ { m }$ and $p _ { a }$ to 0.5 for modality dropout at training time. To extract features for clustering, both modalities are used. We adopt the strategy used in wav2vec 2.0 (Baevski et al., 2020) to generate masks, where $p \%$ of all frames are randomly selected as start and subsequent $l$ frames are masked. In iteration 1-4, we mask the fused features and set $p / l$ to be 8/10 respectively as we observe such practice generates higher quality cluster assignments (see section E.2). In the last iteration, we set $p / l$ to be $6 / 5$ for video and 8/10 for audio (see section D).
302
+
303
+ We train the model with Adam (Kingma & Ba, 2015), warming up the learning rate for the first $8 \%$ of updates to a peak of 0.002 and then linearly decay it. Videos are batched together to not exceed 1,000 image frames (40 seconds) per GPU. Both BASE and LARGE models are updated for 400K and 600K steps at each iteration, respectively in $4 3 3 \mathrm { h } / 1 7 5 9 \mathrm { h }$ unlabeled settings. We train on 32 and 64 V100-GPUs for BASE and LARGE. On average, each iteration takes $\sim 2 . 0 / 3 . 0$ days for BASE and $\sim 2 . 4 / 3 . 6$ days for LARGE in using $4 3 3 \mathrm { h } / 1 7 5 \mathrm { 9 h }$ unlabeled data for pre-training.
304
+
305
+ Fine-tuning After pre-training, we fine-tune the AV-HuBERT model on labeled (video, text) pairs. The audio encoder is removed and its output is replaced by a zero-vector. In CTC fine-tuning, a randomly initialized projection layer is added on top of the transformer to map features into phonemes. The lexicon is constructed with CMUDict (cmu). In fine-tuning with S2S, we use a 6-layer/9-layer transformer decoder on BASE and LARGE model to decode features into unigram-based subword units (Kudo, 2018). The vocabulary size in CTC and S2S are 46 and 1000 respectively.
306
+
307
+ In CTC, the pre-trained model is updated from the initial iteration without any freezing. The model is fine-tuned for 30K/100K steps respectively in $3 0 \mathrm { h } / 4 3 3 \mathrm { h }$ setting. In S2S, the pre-trained model (i.e., encoder) is frozen for the first $N \%$ updates . $N$ is 100 and 50 for 30h and 433h labeled setting respectively. The entire model is trained for 18K/45K steps in the $3 0 \mathrm { h } / 4 3 3 \mathrm { h }$ setting. Both models are trained with Adam, with the learning rate being warmed up for the first $P \%$ of updates to a peak of 0.001 and linearly decayed. P is tuned among $\left\{ 1 0 , 3 0 , 5 0 \right\}$ . All hyperparamters are tuned on the validation set.
308
+
309
+ Decoding For CTC, we use a 4-gram language model trained on text data in the LRS3 training set. The perplexity of the 4-gram LM on test set is 110.5. No language model is used for S2S decoding. For CTC, we tune the beam width among $\{ 5 , 1 0 , 2 0 , 5 0 , \bar { 1 0 0 , 1 5 0 } \}$ , the language model weight among $\{ 0 , 1 , 2 , 4 , 8 \}$ and word insertion penalty among $\{ \pm 4 , \pm 2 , \pm 1 , 0 \}$ . For S2S, The beam width and length penalty are tuned among $\bar { \{ 5 , 1 0 , \dot { 2 } 0 , 5 0 \} }$ and $\{ 0 , \pm 1 \}$ . The tuning is done on the validation set.
310
+
311
+ Self-Training We apply self-training on LARGE AV-HuBERT. Specifically, the fine-tuned LARGE HuBERT model $\mathbf { \Delta A } / \mathbf { M F C C } { } \mathbf { A V } ,$ Table 4) is used to assign pseudo-labels to the unlabeled audiovisual data. In $3 0 \mathrm { h } / 4 3 3 \mathrm { h }$ setting, the amount of data for fine-tuning $\mathrm { A / M F C C } { } \mathrm { A V }$ are 30h and $4 3 3 \mathrm { h }$ respectively. The pre-trained AV-HuBERT LARGE is fine-tuned with the pseudo-labeled videos and videos with ground-truth text labels $( 3 0 \mathrm { h } / 4 3 3 \mathrm { h } )$ . Note the data used here is exactly same with the case of using AV-HuBERT only.
312
+
313
+ # B.5 LIRA IMPLEMENTATION
314
+
315
+ We re-implemented the LiRA (Ma et al., 2021a) training objective in our framework, as there does not exist publicly available implementations and we aim to focus the comparison on the pre-training objective rather than the architectural difference. We use the same backbone architecture as the BASE AV-Hubert except the output layer being a linear project layer with an output dimension of 256. The 256-dimensional frame $\mathrm { P A S E + }$ feature is extracted from the audio with its official implementation in (Ravanelli et al., 2020). The original $\mathrm { P A S E + }$ feature is downsampled to $2 5 \mathrm { H z }$ for synchronization with the visual stream. The pre-trained model is fine-tuned in both CTC and S2S. The optimizer and learning rate schedule in pre-training, hyperparameter search in fine-tuning and decoding remain the same as AV-HUBERT. Note with our implementation, the WER is reduced by $2 3 \%$ $9 4 . 3 \% \to 7 1 . 9 \% )$ ) using LiRA when the percentage of labeled data is $6 . 9 \%$ (30h labeled, 433h in total), while Ma et al. (2021a) achieves $\sim 1 0 \%$ improvement in a similar setting.
316
+
317
+ # C ADDITIONAL LIP-READING RESULTS
318
+
319
+ # C.1 AMOUNT OF LABELED DATA
320
+
321
+ Table C.1 shows the effect of pre-training on different amount of labeled data for fine-tuning. We use 433 hours of unlabeled data (LRS3 only) and randomly selected 1, 10 and 100 hours of labeled data for fine-tuning. Overall pre-training brings large and consistent gains across different amount of labeled data. Specifically CTC-based fine-tuning outperforms S2S-based fine-tuning in lowresource settings (1-hour and 10-hour). The larger number of parameters as well as the lack of a language model for decoding makes S2S model more likely to overfit especially when the amount of fine-tuning data is small.
322
+
323
+ Table C.1: WER $( \% )$ in using different amount of labeled data for fine-tuning (BASE, 433 hours unlabeled)
324
+
325
+ <table><tr><td rowspan="2">Labeled (hrs)</td><td rowspan="2">Unlabeled (hrs)</td><td rowspan="2">Criterion</td><td rowspan="2">LM</td><td colspan="2">WER (%)</td></tr><tr><td> w/o pretrain</td><td> w/ pretrain</td></tr><tr><td>1</td><td>433</td><td>CTC</td><td>4-gram</td><td>98.6</td><td>68.8</td></tr><tr><td rowspan="2">10</td><td rowspan="2">433</td><td>S2S</td><td>1</td><td>98.9</td><td>92.0</td></tr><tr><td>CTC</td><td> 4-gram</td><td>90.8</td><td>57.6</td></tr><tr><td rowspan="2">100</td><td rowspan="2"></td><td>S2S</td><td>-</td><td>97.6</td><td>63.1</td></tr><tr><td>CTC</td><td>4-gram</td><td>77.8</td><td>54.2</td></tr><tr><td></td><td>433</td><td>S2S</td><td>-</td><td>84.3</td><td>48.1</td></tr></table>
326
+
327
+ # C.2 PERFORMANCE ON SEEN SPEAKERS
328
+
329
+ The current LRS3 benchmark is under the open-speaker setting, where the speaker identities in training and test set do not overlap. To test the lip reading performance for a fixed set of speakers which is the case for an early versions of LRS3 used before October 2018, we randomly choose 5 groups of utterances from the trainval partition of LRS3 as test set and repeat experiments for each group independently. Each group contains 1322 utterance, which is of the same amount as the original test set. The model we compare is the AV-HUBERT LARGE pre-trained with 1,759 unlabeled data. As is shown in table C.2, the average WER achieved by our model for seen speakers is $1 8 . 0 \pm 0 . 5 \%$ , which is significantly lower than the WER for unseen speakers $( 3 0 . 5 \% )$ under the open-speaker setting.
330
+
331
+ Table C.2: WER $( \% )$ under closed-speaker setting for 5 randomly sampled test sets and their average
332
+
333
+ <table><tr><td></td><td colspan="5">Test set (seen speakers)</td><td rowspan="2">AVG</td></tr><tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td>WER (%)</td><td>17.4</td><td>18.6</td><td>18.5</td><td>17.5</td><td>18.3</td><td>18.0 ± 0.5</td></tr></table>
334
+
335
+ # C.3 PERFORMANCE OF SELF-TRAINING ONLY
336
+
337
+ Table C.3 shows the performance of only applying self-training. The WER of a self-training only model is significantly higher than AV-HuBERT and self-trained AV-HuBERT, which suggests that the gain of the combined approach is primarily from AV-HuBERT.
338
+
339
+ # C.4 FULL RESULTS WITH CTC FINE-TUNING
340
+
341
+ Table C.4 shows the full results on LRS3, which includes the CTC fine-tuning performance for all the models we implemented. In general, the conclusions we draw from S2S (e.g., the benefits of our pre-training approach in different settings, the improvement over LiRA) in section 4.2 holds for CTC as well.
342
+
343
+ Table C.3: Comparison of WER $( \% )$ among model trained from scratch, self-training only, AVHuBERT only and self-trained AV-HuBERT. All models are Transformer-LARGE.
344
+
345
+ <table><tr><td>Labeled (hrs)</td><td>Unlabeled (hrs)</td><td>Method</td><td>WER (%)</td></tr><tr><td>30</td><td>1,759</td><td>w/o pre-training</td><td>92.3</td></tr><tr><td></td><td></td><td>Self-training</td><td>53.0</td></tr><tr><td></td><td></td><td>AV-HuBERT</td><td>32.5</td></tr><tr><td></td><td></td><td>AV-HuBERT + Self-training</td><td>28.6</td></tr><tr><td>433</td><td>1,759</td><td>w/o pre-training</td><td>62.3</td></tr><tr><td></td><td></td><td>Self-training</td><td>51.7</td></tr><tr><td></td><td></td><td>AV-HuBERT</td><td>28.6</td></tr><tr><td></td><td></td><td>AV-HuBERT + Self-training</td><td>26.9</td></tr></table>
346
+
347
+ Table C.4: WER $( \% )$ of our models and the comparison with prior works on LRS3-TED dataset. $\mathrm { \Delta \Psi \dag \mathrm { W e } }$ re-implemented Ma et al. (2021a) using the same model architecture as our approach to have a more fair comparison.
348
+
349
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Backbone</td><td rowspan="2">Criterion</td><td rowspan="2">Labeled iso (hrs)</td><td rowspan="2">Labeled utt (hrs)</td><td rowspan="2">Unlabeled data (hrs)</td><td rowspan="2">WER (%)</td></tr><tr><td></td></tr><tr><td colspan="8">Supervised</td></tr><tr><td>Afouras et al. (2020)</td><td>CNN</td><td>CTC</td><td>157</td><td>433</td><td></td><td>68.8</td></tr><tr><td>Zhang et al. (2019b)</td><td>CNN</td><td>S2S</td><td>157</td><td>698</td><td></td><td>60.1</td></tr><tr><td>Afouras et al. (2018a)</td><td>Transformer</td><td>S2S</td><td>157</td><td>1,362</td><td></td><td>58.9</td></tr><tr><td>Xu et al. (2020)</td><td>RNN</td><td>S2S</td><td>157</td><td>433</td><td></td><td>57.8</td></tr><tr><td>Shillingford et al. (2019)</td><td>RNN Conformer</td><td>CTC CTC+S2S</td><td>-</td><td>3,886</td><td></td><td>55.1</td></tr><tr><td>Ma et al. (2021b)</td><td>Conformer</td><td>CTC+S2S</td><td>1</td><td>433</td><td></td><td>46.9</td></tr><tr><td>Ma et al. (2021b) Makino et al. (2019)</td><td>RNN</td><td>Transducer</td><td>157</td><td>433</td><td></td><td>43.3</td></tr><tr><td></td><td></td><td></td><td>-</td><td>31,000</td><td></td><td>33.6</td></tr><tr><td colspan="7">Semi-Supervised&amp;Self-Supervised</td></tr><tr><td rowspan="3">Afouras et al. (2020) Ma et al. (2021a)†</td><td rowspan="3">CNN Transformer-BASE</td><td rowspan="3">CTC</td><td>157</td><td>433</td><td>334</td><td>59.8</td></tr><tr><td>-</td><td>30</td><td>433</td><td>72.8</td></tr><tr><td>CTC</td><td>433</td><td>1,759</td><td>58.4</td></tr><tr><td></td><td></td><td>S2S</td><td></td><td>30 433</td><td>433 1,759</td><td>71.9 49.6</td></tr><tr><td colspan="7">Proposed (Self-Supervised &amp; Self-Supervised + Semi-Supervised)</td></tr><tr><td rowspan="20">CTC S2S</td><td rowspan="8">Transformer-BASE</td><td>CTC</td><td></td><td>30 30</td><td>= 433</td><td>83.7 55.3</td></tr><tr><td></td><td></td><td>30</td><td>1,759</td><td>47.3</td></tr><tr><td></td><td></td><td>433</td><td></td><td>62.5</td></tr><tr><td></td><td></td><td>433</td><td>- 433</td><td>49.3</td></tr><tr><td></td><td>■</td><td>433</td><td>1,759</td><td>43.0</td></tr><tr><td></td><td></td><td>30</td><td>-</td><td>94.3</td></tr><tr><td></td><td></td><td>30</td><td>433</td><td>51.8</td></tr><tr><td>S2S</td><td></td><td>30</td><td>1,759</td><td>46.1</td></tr><tr><td></td><td></td><td>433</td><td>-</td><td>60.3</td></tr><tr><td rowspan="6">AV-HuBERT</td><td rowspan="6"></td><td></td><td>433</td><td>433</td><td>44.0</td></tr><tr><td></td><td></td><td></td><td>34.8</td></tr><tr><td></td><td>433</td><td>1,759</td><td></td></tr><tr><td></td><td>30</td><td>- 433</td><td>92.2 48.4</td></tr><tr><td></td><td>30 30</td><td>1,759</td><td>40.7</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td rowspan="7">Transformer-LARGE</td><td rowspan="7"></td><td>=</td><td>433</td><td>-</td><td>61.9</td></tr><tr><td></td><td>433</td><td>433</td><td>44.3</td></tr><tr><td></td><td>433</td><td>1,759</td><td>38.6</td></tr><tr><td>■</td><td>30</td><td>-</td><td>92.3</td></tr><tr><td></td><td>30</td><td>433</td><td>44.8</td></tr><tr><td></td><td>30</td><td>1,759</td><td>32.5</td></tr><tr><td></td><td>433</td><td>-</td><td>62.3</td></tr><tr><td rowspan="4"></td><td rowspan="4"></td><td></td><td>433</td><td>433</td><td>41.6</td></tr><tr><td></td><td>433</td><td>1,759</td><td>28.6</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td>30 433</td><td>1,759 1,759</td><td>28.6 26.9</td></tr><tr><td>AV-HuBERT + Self-Training</td><td>Transformer-LARGE</td><td>S2S</td><td></td><td></td><td></td></tr></table>
350
+
351
+ # D ABLATION STUDIES
352
+
353
+ The ablation studies in this section are done in the last iteration of the AV-HuBERT, pre-trained with 433 hours of unlabeled data. The model is fine-tuned with 30 hours of labeled data using CTC.
354
+
355
+ Table D.1: Ablation study for hyper-parameters. The ablations are done in the last iteration of AVHUBERT. $m _ { a } / m _ { v }$ : the probability of an acoustic/image frame being masked.
356
+
357
+ <table><tr><td>Where</td><td>Masking How</td><td>ma</td><td>mu</td><td>Modality Dropout Pm</td><td>Pa</td><td>Loss a</td><td>WER dev</td><td>test</td></tr><tr><td> Input</td><td> Sub (same, seg)</td><td>0.8</td><td>0.3 1</td><td>0.5</td><td>0.5</td><td>0.0</td><td>46.8</td><td>55.3</td></tr><tr><td></td><td>Sub (same, frm) Sub (diff,seg) Learned Embedding Gauss. Noise</td><td></td><td></td><td></td><td></td><td></td><td>47.2 47.6 52.6 52.4</td><td>55.8 56.1 57.8 57.9</td></tr><tr><td>Feature1</td><td>Learned Embedding</td><td></td><td></td><td></td><td></td><td></td><td>55.2</td><td>58.2</td></tr><tr><td> Input</td><td> Sub (same, seg)</td><td>0.8 0.8</td><td>0.3 0.8</td><td>0.5</td><td>0.5</td><td>0.0</td><td>46.8 59.3</td><td>55.3 61.6</td></tr><tr><td></td><td></td><td>0.3</td><td>0.3</td><td></td><td></td><td></td><td>54.9</td><td>58.2</td></tr><tr><td>Input</td><td> Sub (same, seg)</td><td>0.8</td><td>0.3</td><td>0.5</td><td>0.5</td><td>0.0</td><td>46.8</td><td> 55.3</td></tr><tr><td></td><td></td><td></td><td></td><td>1.0</td><td>n/a</td><td></td><td>55.2</td><td>57.0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td> Input</td><td> Sub (same, seg)</td><td>0.8</td><td>0.3</td><td>0.5</td><td>0.5</td><td>0.0</td><td>46.8</td><td>55.3</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>1.0</td><td>46.7</td><td>55.7</td></tr></table>
358
+
359
+ Masking Strategy In the first part of table D.1, we compare the proposed masking strategy against several alternatives. Feature masking applies span mask at feature level and leads to the worst performance, which is due to the leakage of information to ResNet. Directly masking image sequence with random Gaussian noise or a learned embedding slightly improves the performance by preventing the prior issue. However, those artificial frames also corrupts the raw image sequence and enlarges the domain gap in videos between pre-training and fine-tuning. On the other hand, our proposed method achieves better performance. Specifically, using segments from the same utterance (“Sub, (same, seg)”) as the imposter leads to the best result compared to sampling from a different utterance (“Sub, (diff, seg)”) or sampling non-consecutive frames from the same utterance (“Sub, (same, frm)”).3 The filled-in fake images are visually similar to the raw images and substitution with a segment keeps the temporal smoothness making the replaced segment more realistic, which enforces the ResNet to encode more fine-grained visual details.
360
+
361
+ Masking probability We set two different masking probabilities for audio and visual stream in the last iteration. The probabilities of an acoustic frame and image frame being masked are 0.8 and 0.3 respectively. As is shown in the second part of table D.1, setting masks for audio and visual stream independently is essential because the optimal masking probability for audio and visual stream are different. Audio encoder tends to deteriorate into a simple acoustic feature extractor when mask length is small. On the other hand, long visual mask will lead to the model lacking context to distinguish between fake and real images.
362
+
363
+ Modality dropout The third part of table D.1 compares the model performance with and without modality dropout. Randomly dropping audio sequence prevents the model from over-relying on audio for masked prediction and helps the visual representation learning.
364
+
365
+ Where to compute prediction loss In the last part of table D.1, we compare the choice of masked prediction vs. prediction. The loss weight on unmasked region does not have a large impact on the fine-tuning performance. This is different from the findings in Audio HuBERT Hsu et al. (2021a), where masked prediction leads to much better performance. Given image frames as input, the prediction of cluster assignments, which are mostly determined by the accompanied audio stream, helps encode phonetic information into the visual representation. The task is much less trivial than a single-modal model (audio-HuBERT), where setting non-zero weight on unmasked prediction can easily make the model deteriorate into an acoustic feature extractor. In addition, the high quality of targets in the last iteration also makes such prediction more helpful.
366
+
367
+ # E ANALYSIS ON CLUSTERING
368
+
369
+ # E.1 MEASURING CLUSTERING QUALITY
370
+
371
+ For analysis, we use frame-level phonetic labels as the ground-truth and match its correlation between cluster assignments. The phonetic labels are obtained via forced alignement from a monophone based HMM-GMM ASR model trained on LRS3. In particular, we use clustering purity and Normalize Mutual Information (NMI) as the evaluation metrics. Table E.1 shows that (1) The quality of cluster assignments is consistent with fine-tuning performance across different models (2) Hand-engineered audio feature (MFCC, NMI: $2 1 . 5 \%$ ) has much stronger correlation with phonetic labels than the visual feature (HoG, NMI: $1 . 6 \%$ ) (3) Audio-visual clusters (NMI: $4 4 . 2 \%$ ) are of better quality than pure audio-based clusters (NMI: $3 9 . 7 \%$ ). (4) In single-modality visual Hubert $( \mathrm { V / H o G } { } \mathrm { V } )$ ), feature quality is improved negligibly through iteration training.
372
+
373
+ Table E.1: Quality of different cluster assignments. Each number is in the format of Purity (NMI). The metrics of cluster assignments and WER in last iteration of each model are in boldface.
374
+
375
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Iter</td><td colspan="3"></td><td rowspan="2">NMI (%),↑</td><td rowspan="2">WER (%),↓</td></tr><tr><td>Feature</td><td>Target K</td><td>Purity (%),↑</td></tr><tr><td rowspan="5">AV/MFCC→AV (Proposed)</td><td>1</td><td>MFCC</td><td>100</td><td>30.3</td><td>21.5</td><td>71.5</td></tr><tr><td>2</td><td>AV/MFCC→AV (it1,L9)</td><td>100</td><td>47.3</td><td>37.7</td><td>63.6</td></tr><tr><td>3</td><td>AV/MFCC→AV (it2,L12)</td><td>500</td><td>61.5</td><td>42.6</td><td>60.9</td></tr><tr><td>4</td><td>AV/MFCC→AV (it3,L12)</td><td>1000</td><td>65.6</td><td>43.7</td><td>58.8</td></tr><tr><td>5</td><td>AV/MFCC→AV (it4,L12)</td><td>2000</td><td>68.8</td><td>44.2</td><td>58.2</td></tr><tr><td rowspan="3">AV/MFCC→A</td><td>1</td><td>MFCC</td><td>100</td><td>30.3</td><td>21.5</td><td>71.5</td></tr><tr><td>2</td><td>A/MFCC-→A (it1,L9)</td><td>100</td><td>47.0</td><td>36.7</td><td>64.3</td></tr><tr><td>3</td><td>A/MFCC→A (it2,L12)</td><td>500</td><td>56.5</td><td>39.7</td><td>63.5</td></tr><tr><td rowspan="3">V/MFCC→A</td><td>1</td><td>MFCC</td><td>100</td><td>30.3</td><td>21.5</td><td>75.4</td></tr><tr><td>2</td><td>A/MFCC-→A (it1,L9)</td><td>100</td><td>47.0</td><td>36.7</td><td>69.4</td></tr><tr><td>3</td><td>A/MFCC→A (it2,L12)</td><td>500</td><td>56.5</td><td>39.7</td><td>69.1</td></tr><tr><td rowspan="3">V/MFCC→V</td><td>1</td><td>MFCC</td><td>100</td><td>30.3</td><td>21.5</td><td>75.4</td></tr><tr><td>2</td><td>V/MFCC→V (it1,L9)</td><td>100</td><td>32.8</td><td>22.9</td><td>72.6</td></tr><tr><td>3</td><td>V/MFCC→V (it2,L12)</td><td>500</td><td>33.0</td><td>22.8</td><td>72.3</td></tr><tr><td rowspan="2">V/HoG→V</td><td>1</td><td>HoG</td><td>100</td><td>16.4</td><td>1.6</td><td>80.3</td></tr><tr><td>2</td><td>V/HoG→V (it1,L9)</td><td>100</td><td>16.4</td><td>1.8</td><td>80.1</td></tr></table>
376
+
377
+ # E.2 FEATURE MASKING PRODUCES BETTER FEATURES FOR CLUSTERING
378
+
379
+ In iteration 1-4, we apply the mask in the fused feature. We observe such practice generates targets of higher quality, thus helping future iterations more. Table E.2 shows a comparison between such two different masking strategies. Input-level masking enhances the learning of visual representation (see table D.1) while produces worse audio-visual feature (NMI: $2 7 . 2 \%$ ). In contrast, the two streams of original input are better aligned in feature-level masking which is consistent with the cluster generation process, thus leading to better audio-visual clusters (NMI: $3 7 . 7 \%$ ).
380
+
381
+ Table E.2: Impact of masking strategy on quality of cluster assignments (purity/NMI: quality of cluster assignments used to train the model)
382
+
383
+ <table><tr><td>Feature</td><td>K</td><td>Purity (%)</td><td>NMI (%)</td></tr><tr><td>MFCC</td><td>100</td><td>30.3</td><td>21.5</td></tr><tr><td>AV/MFCC→AV (it1, L9) w/ Feature Masking</td><td>100</td><td>47.3</td><td>37.7</td></tr><tr><td>AV/MFCC→AV (it1, L9) w/ Input Masking</td><td>100</td><td>34.5</td><td>27.2</td></tr></table>
384
+
385
+ # E.3 CLUSTERING QUALITY ACROSS LAYERS
386
+
387
+ Figure E.1 shows the clustering quality of features of different layers in different iterations. The cluster assignment quality generally improves with more iterations. In the first iteration, features in the middle layers show higher quality than the other layers. The target for the first iteration (MFCC clusters) is of worse quality, thus later layers that are more correlated with targets do not yield the best cluster. Target quality improves with more training iterations, thus the best feature layer shifts towards the end. Setting a larger number of clusters increases the clustering quality as can be seen from the comparison between ”varied clusters” and ”2K clusters”. In terms of the 12th layer which we choose, the highest NMI $( 4 4 . 2 \% )$ is achieved in the last iteration. In addition, more iterations of training improves the overall quality of clusters produced by a model though the highest NMI/purity among all layers does not necessarily increase in later iterations. Therefore, setting a larger number of iterations brings stable gains which are more robust to the index of layer chosen for clustering. It is important as the purity/NMI, whose measurement rely on a supervised model, are not used for hyperparameter search in practice.
388
+
389
+ ![](images/33b6f33fec4a4c08344e80ebde7ff42772ae9f7306dc9d45c0c82b2f755d4ee8.jpg)
390
+ Figure E.1: Quality of feature clusters from different layers across different iterations (BASE, 433 hours unlabeled data). (Iter $i$ , Layer $j$ ): cluster quality of layer- $j$ feature of iter- $i$ model. Upper row: 100, 500, 1K, 2K clusters for 4 iterations. Bottom row: 2K clusters for all iterations. Purity/NMI of the initial MFCC clusters: $3 0 . 3 \% / 2 1 . 5 \%$
391
+
392
+ # F QUALITATIVE EXAMPLES
393
+
394
+ Figure F.2 shows the example outputs from different models. Our self-supervised model is the LARGE AV-HUBERT pre-trained with 1,759 hours unlabeled data and fine-tuned with 433 hours labeled data. The baseline model is the supervised baseline trained with 433 hours labeled data. Both models use the S2S criterion for supervised training and have the same number of parameters. Qualitatively, our approach provides transcriptions with much higher quality. The baseline approach confuses among words of similar sound while our model output more semantically sound sentences. Figure F.2 also shows typical errors made by our model. We noticed many errors are on short sentences. This is mainly because lip reading relies heavily on the context for recognition due to the existence of homophomes. Thus the error rates in lip reading are notably higher in short utterances, which differs from ASR, as can be seen from figure F.1. Substitution among words with homophemes (’fiction’ vs. ’vision’ in a.4, ’part’ vs. ’bunk’ in b.5) is another source of error made by the model.
395
+
396
+ ![](images/fe896f2aced18bff4bb1b8373a7383b3a63ce69ac81f6a57472edbf5011a7891.jpg)
397
+ Figure F.1: WER vs. sentence length for lip reading (left) and ASR (right)
398
+
399
+ ![](images/7adb9179d49b8db04db8a051a01b4f3d5edb474d40eae50493cbe6bdf7f88b28.jpg)
400
+ Figure F.2: Transcriptions from different lip-reading models. GT: ground-truth, Proposed: self
md/dev/agJEk7FhvKL/agJEk7FhvKL.md ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Uni-Perceiver-MoE: Learning Sparse Generalist Models with Conditional MoEs
2
+
3
+ Jinguo ${ \bf Z } { \bf h } { \bf u } ^ { 1 , 3 * \dagger }$ , Xizhou $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 , 3 * }$ , Wenhai Wang3, Xiaohua Wang1, Hongsheng $\mathbf { L i } ^ { 4 }$ , Xiaogang Wang4, Jifeng Dai5,3B
4
+ 1Xi’an Jiaotong University 2SenseTime Research 3Shanghai AI Laboratory 4The Chinese University of Hong Kong 5Tsinghua University
5
+
6
+ # Abstract
7
+
8
+ To build an artificial neural network like the biological intelligence system, recent works have unified numerous tasks into a generalist model, which can process various tasks with shared parameters and do not have any task-specific modules. While generalist models achieve promising results on various benchmarks, they have performance degradation on some tasks compared with task-specialized models. In this work, we find that interference among different tasks and modalities is the main factor to this phenomenon. To mitigate such interference, we introduce the Conditional Mixture-of-Experts (Conditional MoEs) to generalist models. Routing strategies under different levels of conditions are proposed to take both the training/inference cost and generalization ability into account. By incorporating the proposed Conditional MoEs, the recently proposed generalist model Uni-Perceiver can effectively mitigate the interference across tasks and modalities, and achieves state-of-the-art results on a series of downstream tasks via prompt tuning on $1 \%$ of downstream data. Moreover, the introduction of Conditional MoEs still holds the generalization ability of generalist models to conduct zero-shot inference on new tasks, e.g., videotext retrieval and video caption. Code and pre-trained generalist models are publicly released at https://github.com/fundamentalvision/Uni-Perceiver.
9
+
10
+ # 1 Introduction
11
+
12
+ Generalist models that handle multiple modalities and numerous tasks have been long pursued by the machine learning community. However, previous researches [65, 89, 71] focus on developing specialized models with task-specific modules. When these models are applied to new tasks, the specifically-designed components need to be redesigned on demand and fine-tuned on sufficient downstream data. As a result, their model size increases with the number of diverse downstream tasks, conflicting with the goal of generalist models.
13
+
14
+ Recently, some pioneers [93, 79, 3, 84, 86, 62] have made preliminary attempts to build generalist models by modeling various tasks into a unified formulation. With the unified modeling, large-scale pre-training on various datasets enables the generalist models to process different downstream tasks using shared parameters. These generalist models not only achieve competitive performance on pre-training tasks [79, 3, 84, 86], but also can perform zero-shot inference on novel tasks without introducing additional parameters [93, 62].
15
+
16
+ However, compared to specialized models with specific parameters for each task, generalist models with shared parameters would suffer from the task-interference issue — different tasks with shared parameters may conflict with each other [88]. The same issue is also observed in multilingual NLP models [4, 81, 83]. We argue that the task-interference issue is mainly caused by the inconsistent optimization in multi-task learning. As shown in Tab. 1, during the training phase of generalist models, the gradient directions of different tasks would be inconsistent or even opposite. Thus, if multiple tasks share parameters, the optimal update direction of the shared parameters will be uncertain, resulting in sub-optimal performance.
17
+
18
+ Allowing conflicting modalities and tasks to use separate parameters should effectively mitigate the interference issue in generalist models. Mixture of Experts (MoEs) [43, 23] provides a potential solution, which learns to activate sub-networks dynamically without introducing any task-specific modules. Nevertheless, vanilla MoEs [67] select the experts according to token representations, which suffers from high training/inference cost and neglects the information of different tasks and modalities. In this work, we argue that routing strategies of MoEs require special design when applied to generalist models for mitigating the task-interference issue.
19
+
20
+ To address the task-interference issue in generalist models, we propose Conditional Mixture-ofExperts (Conditional MoEs), which improve vanilla MoEs by introducing information under different levels of conditions, including token-level, context-level, modality-level, task-level, and predefined token attributes. In this case, vanilla MoEs is a token-level variant of our Conditional MoEs, which can be replaced by other-level variants to implement stronger generalist models. We carefully discussed the training/inference cost and generalization ability of different variants, and ablated their performances in mitigating the interference issue of generalist models. Notably, Conditional MoEs with predefined token attributes introduces 8-bit attribute embedding to describe the information of currently processed task and modalities, which demonstrate excellent computational and memory efficiency and good generalization ability.
21
+
22
+ To verify the effectiveness of Conditional MoEs, we incorporated it with the recently proposed generic perception model Uni-Perceiver [93] by replacing the linear projection in self-attention and FFN blocks with conditional MoE layers. Experiments demonstrate that, by mitigating task interference with our proposed Conditional MoEs, Uni-Perceiver can be pre-trained on various tasks jointly without performance degradation, while its generalization to other tasks can be maintained simultaneously. Our main contributions are as follows:
23
+
24
+ • We carefully analyze the task-interference issue in generalist models, and provide an explanation from the gradient direction perspective as well as a metric to quantify the issue. • We propose Conditional MoEs to address the task-interference issue in generalist models. By introducing the information of currently processed task and modalities, Conditional MoEs effectively mitigate the interference issue, while keeping low computational and memory cost. • Compared with previous SOTAs, our generalist model with $1 \%$ downstream data prompt tuning achieves competitive performance, while only ${ < } 5 \%$ training data and ${ < } 1 0 \%$ training cost are used. We hope this work can serve as a solid baseline for generalist models and motivate further research.
25
+
26
+ # 2 Related Works
27
+
28
+ Specialized Models. Previous research focuses on building specialized models for specific tasks. CNNs [47, 26, 70] and ViTs [20, 53, 76, 80] are developed for image classification. Subsequent works re-design them to adapt to diverse downstream visual tasks, e.g., object detection [63] and segmentation [15, 48]. In NLP, different architectures are specifically designed for neural machine translation [77], natural language understanding [19], and natural language generation [51]. As for vision-language tasks, previous works usually combined modality-specific encoders and representation fusion modules together [13, 54]. Recently, [89, 65, 71] integrate several specialized models into a single one to handle diverse tasks. Such integrated specialized models are equipped with multiple task-specific modules to adapt to as many downstream tasks as possible. However, these methods still follow the task-specific paradigm, which conflicts with the objective of generalist models.
29
+
30
+ Vanilla Generalist Models. Vanilla generalist models handle different tasks and modalities with shared parameters. Uni-Perceiver [93] formulates various perception tasks as finding the maximum likelihood target for each input through the similarity of their representations. OFA [79], Flamingo [3] and SimVLM [84] attempt to unify different tasks into sequence-to-sequence generation. UniCORN [86] and Gato [62] further incorporate bounding box and reinforcement learning tasks into the unified formulation, respectively. These generalist models not only achieve competitive performance on pre-training tasks with shared parameters, but also can perform zero-shot inference on new tasks [62, 93]. However, these methods rarely investigate the potential interference among different modalities and tasks, which could result in the performance degradation of generalist models.
31
+
32
+ ![](images/59a773ac6f5abe968104fc8b6703f1381f3b7d184133f03360b0eba573b31692.jpg)
33
+ Figure 1: Comparisons of fully-shared standard encoder block, task-specific encoder block with task-dedicated parameters, and encoder block with efficient MoE parameterization.
34
+
35
+ Multi-Task Learning. Multi-task learning [8, 17] has been widely studied in the community of vision [27, 74, 72], language [25, 16, 50] and vision-language learning [10, 55, 29]. While multi-task training enables collaboration between tasks, it may also introduce the task interference problem [81, 83, 28, 36, 72]. To mitigate the task-interference issue, some works[14, 24, 38] propose to dynamically adjust the loss weight for each task, while others [90, 49, 36] instead use task-dedicated parameters. However, methods with task-specific parameters are difficult to generalize to new tasks and do not meet the requirements of generalist models.
36
+
37
+ Mixture of Experts (MoEs). MoEs has shown its remarkable ability to scale neural networks [67, 43, 23, 64, 21]. [67] first proves the effectiveness of MoEs by stacking MoE layers in the LSTM models. [68, 43] further introduce this approach to Transformer architectures. [23, 40] train language models with trillion parameters successfully by utilizing simplified MoE routing strategy and efficient training techniques. There are also some works applying MoEs to CNNs for computer vision tasks [1, 85, 82]. Recently, V-MoE [64] successfully employs MoEs to ViTs, showing promising performance on many visual tasks. Task-MoE [42] focuses on applying MoEs for multilingual translation to mitigate the interference among different languages. In this work, we aim to explore MoEs under different conditions for general models.
38
+
39
+ # 3 Methodology
40
+
41
+ In this section, we first analyze the task-interference problem from the gradient direction perspective. Based on the analysis, we propose Conditional Mixture-of-Experts (Conditional MoEs) for generalist models, which introduces parameters conditioned by information of different levels to mitigate the task-interference issue with negligible overhead.
42
+
43
+ # 3.1 Task Interference
44
+
45
+ To quantify the interference of the $j$ -th task on the $i$ -th task, we estimate the change in loss $L _ { i }$ of the $i$ -th task, when optimizing the shared parameters $\theta$ according to the $j$ -th task $L _ { j }$ as:
46
+
47
+ $$
48
+ \Delta _ { j } L _ { i } ( x _ { i } ) \doteq \mathbb { E } _ { x _ { j } } \left( L _ { i } ( x _ { i } ; \theta ) - L _ { i } ( x _ { i } ; \theta - \lambda \frac { \nabla _ { \theta } L _ { j } ( x _ { j } ) } { \| \nabla _ { \theta } L _ { j } ( x _ { j } ) \| } ) \right) \approx \lambda \mathbb { E } _ { x _ { j } } \left( \frac { \nabla _ { \theta } L _ { j } ( x _ { j } ) } { \| \nabla _ { \theta } L _ { j } ( x _ { j } ) \| } ^ { T } \nabla _ { \theta } L _ { i } ( x _ { i } ) \right) ,
49
+ $$
50
+
51
+ where $x _ { i }$ and $x _ { j }$ are the sampled training batches of the $i$ -th and $j$ -th tasks, respectively, and $\lambda$ is the learning rate. Without loss of generality, we only consider the update direction ignoring the update norm. Then, the interference of the $j$ -th task on the $_ i$ -th task can be quantified as:
52
+
53
+ $$
54
+ \mathcal { T } _ { i , j } = \mathbb { E } _ { x _ { i } } \left( \frac { \Delta _ { j } L _ { i } ( x _ { i } ) } { \Delta _ { i } L _ { i } ( x _ { i } ) } \right) ,
55
+ $$
56
+
57
+ Table 1: The average interference metric $\mathcal { T } _ { i , j }$ of the task $j$ on the task $i$ at the 4-th/12-nd FFN blocks. To calculate the interference metric, we sample 100 batches for each tasks, and record the gradients based on the pre-trained Uni-Perceriver-Ti. The red value indicates that the task $j$ has a negative impact on the task $i$ , and the green value indicates a positive impact.
58
+
59
+ (a) The 4-th FFN Block
60
+
61
+ <table><tr><td>Task j Task i</td><td rowspan="2">ImgCLS (Img)</td><td rowspan="2">MLM(Text)</td><td rowspan="2">Caption (Img-Text)</td></tr><tr><td></td></tr><tr><td>ImgCLS(Img)</td><td>1.00</td><td>-0.57</td><td>1.29</td></tr><tr><td>MLM (Text)</td><td>0.07</td><td>1.00</td><td>0.68</td></tr><tr><td>Caption (Img-Text)</td><td>0.01</td><td>0.01</td><td>1.00</td></tr></table>
62
+
63
+ (b) The 12-nd FFN Block
64
+
65
+ <table><tr><td>Task j Task i</td><td>ImgCLS (Img)</td><td>MLM(Text)</td><td>Caption (Img-Text)</td></tr><tr><td>ImgCLS(Img)</td><td>1.00</td><td>-2.91</td><td>-2.45</td></tr><tr><td>MLM(Text)</td><td>-1.65</td><td>1.00</td><td>-1.05</td></tr><tr><td>Caption (Img-Text)</td><td>-0.11</td><td>0.19</td><td>1.00</td></tr></table>
66
+
67
+ where the denominator is used to normalize the loss change scale. As reported in Tab. 1, we sample 100 batches for each tasks, and record the gradients to calculate the average interference metric $\mathcal { T } _ { i , j }$ of the $j$ -th task on the $i$ -th task at the 4-th/12-nd FFN blocks. We see that, at shallow layers, the image caption task has positive impacts on image classification and masked language modeling, suggesting that cooperation between different tasks exists. While at deep layers, tasks with different optimization objectives hardly enhance each other, and the gradient directions may even opposite.
68
+
69
+ Fig. 1 summarizes three mainstream architectures for multi-task models. The first is the standard architecture [93, 31, 32] with parameters fully shared by different tasks, which suffers from task interference problem as analyzed above. The second is task-specific parameterized architecture [89, 65, 29, 71] equipped with dedicated parameters for each task. Although this architecture address the interference problem by task-specific parameters, it is difficult to generalize to new tasks that did not emerge in the training phase. Unlike the above two architectures, the Mixture-of-Experts (MoE) architecture [67, 43, 23, 40, 64] activates models sparsely according to different given inputs by selectively utilizing different subset of the model parameters. The sparse routing mechanism makes it possible to train very large generalist models, which maximizes the collaboration and meanwhile mitigates the interference problem. In this work, we focus on exploring Conditional MoEs for general models, whose experts are gated by conditions from different levels.
70
+
71
+ # 3.2 Conditional Mixture-of-Experts (Conditional MoEs)
72
+
73
+ We first describe the prototype of Conditional MoEs, and then provide its specific instantiations under different conditions, as well as the application to generalist models.
74
+
75
+ Prototype. Given any token $x _ { i }$ in the input sequence $X = \{ x _ { i } \} _ { i = 1 } ^ { L }$ , conditional MoEs with $E$ experts firstly introduces a gate decision vector $\mathcal { G } \in \mathbb { R } ^ { E }$ that dispatches different input tokens to different experts, which is calculated as:
76
+
77
+ $$
78
+ { \mathcal { G } } = \mathrm { t o p } _ { k } \left( \mathrm { s o f t m a x } \left( \mathbf { W } _ { g } \cdot R ( x _ { i } ) + \epsilon \right) \right) .
79
+ $$
80
+
81
+ where $R ( \cdot )$ defines a general routing strategy for gate decision, which is alternative under different conditions. $\mathbf { W } _ { g }$ is the trainable weights in gate decision and $\epsilon$ is the noise term. The $\mathrm { t o p } _ { k } ( \cdot )$ operator sets all values to be zero except the largest $k$ values. Since $\mathcal { G }$ only has $k \ll E$ non-zero values, the token $x _ { i }$ is routed to only a small number of experts. After getting the gate decision vector $\mathcal { G }$ , the corresponding output $y _ { i }$ is the weighted combination of each expert’s computation on $x _ { i }$ as:
82
+
83
+ $$
84
+ y _ { i } = \sum _ { e = 1 } ^ { E } \mathcal { G } _ { e } \cdot \mathbf { W } _ { e } \cdot x _ { i } ,
85
+ $$
86
+
87
+ where ${ \bf W _ { e } }$ is the linear projection weights of the $e$ -th expert and gate decision $\mathcal { G } _ { e }$ determines how much the $e$ -th expert contributes to the output $y _ { i }$ . Note that, experts with $\mathcal { G } _ { e } = 0$ does not need to be computed for saving computation.
88
+
89
+ In Conditional MoEs, the routing strategy $R ( \cdot )$ plays an important role in the multi-modality and multi-task training of generalist models. By sparsely activating experts according to different conditions, Conditional MoEs can mitigate the interference issue while maintaining the generality of the pretrained model. Next, we introduce variants with specific routing strategies under different conditions, as shown in Fig. 2.
90
+
91
+ Token-Level Routing. Similar to vanilla MoEs [67, 43, 23, 40, 64], the token-Level MoEs directly use the token representation for the routing strategy, which can be written as:
92
+
93
+ $$
94
+ R _ { \mathrm { t o k e n } } ( x _ { i } ) = x _ { i } .
95
+ $$
96
+
97
+ ![](images/8327921925cae9da1674c5e70ff1ddcd4974173f6ff9030697a9e0bec1bdf2fb.jpg)
98
+ Figure 2: Comparisons of routing strategies with the top-1 gate decisions under 2-task training.
99
+
100
+ The routing strategy of token-level MoEs is an identical function, where the gate decision only depends on each token’s own representation.
101
+
102
+ Context-Level Routing. Tokens with similar representations may appear in conflicting tasks, whose optimal expert decisions should be different to mitigate the task interference. Therefore, to help gate function making more reliable decisions, we explore the combination of global context and local token representation. The routing strategy utilizing global context can be expressed as:
103
+
104
+ $$
105
+ R _ { \mathrm { c o n t e x t } } ( x _ { i } ) = \operatorname { c o n c a t } ( x _ { i } , \operatorname { a t t n p o o l } ( X ) ) ,
106
+ $$
107
+
108
+ where concat $( \cdot )$ indicates the concatenation operation, $X = \{ x _ { i } \} _ { i = 1 } ^ { L }$ is sequence of all tokens in the current sample, and attnpool $( \cdot )$ indicates the attention pooling operator [61].
109
+
110
+ Modality-Level Routing. Most current practice uses modality-specific encoders with independent parameters for different modality inputs. Inspired by this, we also explore to leverage the modality of the current token as a routing strategy:
111
+
112
+ $$
113
+ R _ { \mathrm { m o d a l } } ( x _ { i } ) = \mathrm { e m b e d } ( \mathrm { i d } _ { \mathrm { m o d a l } } ( x _ { i } ) )
114
+ $$
115
+
116
+ Here, embed $( \cdot )$ represent the embedding layer, and $\mathrm { i d } _ { \mathrm { m o d a l } } ( \cdot )$ indicates the modality index of current token $x _ { i }$ . The routing function will assign this token to experts according to its modality embedding.
117
+
118
+ Task-Level Routing. In addition to modality information, task information can also be used to guide gate functions to make reliable decisions for mitigating the task interference. Similar to Eqn. (7), the routing strategy can be formulated as:
119
+
120
+ $$
121
+ R _ { \mathrm { t a s k } } ( x _ { i } ) = \mathrm { e m b e d } ( \mathrm { i d } _ { \mathrm { t a s k } } ( x _ { i } ) ) ,
122
+ $$
123
+
124
+ where $\mathrm { i d } _ { \mathrm { t a s k } } ( \cdot )$ is the task index of current token $x _ { i }$ . The task embedding for this task will be used to compute gate decision. Since all tokens from one task have the same task embedding, all tokens corresponding to this task will be routed to the same set of experts.
125
+
126
+ Attribute Routing. Among the aforementioned variants, token-level, context-level, and modalitylevel routing strategies only focus on input tokens but omit information about the currently processed task. While task-level routing strategy relies on task-specific ids, it limits the generalization ability to new downstream tasks. To introduce the information of currently processed task and modalities without losing the generalization ability of generalist models, we propose to introduce token attributes to assist the gate decision.
127
+
128
+ As described in Tab. 2, the attributes of the current token are represented as an 8-dimensional binary embedding, whose attributes include the modalities of current task and token (index $0 { \sim } 5$ ), the causation type of the model (index 6), and the token source (index 7). As a result, the designed token attributes provide comprehensive information of currently processed task meanwhile keeping the task generalization ability. Based on the attribute embedding, the routing strategy is expressed as:
129
+
130
+ $$
131
+ R _ { \mathrm { a t t r } } ( x _ { i } ) = \mathrm { l a y e r n o r m } \left( \mathbf { W } _ { \mathrm { a t t r } } \cdot \mathrm { a t t r } ( x _ { i } ) \right) .
132
+ $$
133
+
134
+ Table 2: The 8-dimensional binary embedding used for attribute-level routing strategy. The attribute embedding is assigned to a token by checking whether the statements of the eight descriptions match the current token. For example, the attribute embedding for any token from the input sequences of image classification task should be $[ 1 , 0 , 0 , 1 , 1 , 0 , 0 , 1 ]$ . Please refer to the Appendix for detailed look-up table of attribute embeddings for all tasks in our work.
135
+
136
+ <table><tr><td rowspan=1 colspan=1>Index|</td><td rowspan=1 colspan=5>Descriptions</td><td rowspan=1 colspan=2>YesNo</td></tr><tr><td rowspan=1 colspan=1>0</td><td rowspan=2 colspan=5>Visual modality exists in the inputs of the current task.Text modality exists in the inputs of the current task.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>Textmodalityexi</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=2>Visualmodalityexis</td><td></td><td rowspan=1 colspan=2>Visual modality exists in the targets of the current task.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=2>Textmodalityexist</td><td rowspan=4 colspan=3>Text modality exists in the targets of the current task.The modality of current token is visual.The modality of current token is text.The attention mask of the current token is causal.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=2 colspan=3>Themodality.o</td><td rowspan=2 colspan=2>The modality of current token is text.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=4>The attention mask of the current token is causal.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=5>The current token comes from the inputs,not the targets.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr></table>
137
+
138
+ Here, $\arctan ( x _ { i } )$ is the 8-dimensional binary attribute embedding of the current token $x _ { i }$ as described in Tab. 2. $\mathbf { W } _ { \mathrm { a t t r } }$ is the learnable weights to transform the attribute embedding to latent representation, and layernorm $( \cdot )$ denotes the layer normalization [6] for training stabilization.
139
+
140
+ Application to Generalist Models. Without loss of generality, we explore the application of Conditional MoEs to the generalist model Uni-Perceiver [93], which uses Transformers to handle various modalities and tasks with shared parameters. We replace linear projection layers in both self-attention and FFN blocks with Conditional-MoE layers (see Fig. 1).
141
+
142
+ # 3.3 Comparison of Conditional-MoE Variants
143
+
144
+ As illustrated in Fig. 2, among the variants of Conditional MoEs, token-level and context-level MoEs are data-dependent, while modality-level, task-level, and attribute MoEs are data-independent.
145
+
146
+ Training and Inference Cost. Compared to dense models with the same number of parameters, all Conditional MoE variants can significantly reduce the computational cost benefiting from the sparse routing mechanism. Due to the dependence of input data, the memory consumption of token-level and context-level MoEs is relatively high during model training, and model parallelism is required to relieve memory cost by partitioning experts across multiple devices, leading to heavy inter-device communication overhead. This problem persists when using pre-trained models for task-specific inference, where all experts need to be loaded into memory and might be activated by any token.
147
+
148
+ Different from data-dependent Conditional MoEs, data-independent variants such as modality-level, task-level, and attribute MoEs have excellent memory efficiency, since only top- $k$ experts need to be activated for all tokens with the same modality/task/attributes. Moreover, in both training and inference phase, the experts in a data-independent MoE layer can be merged into a single linear projection using reparameterization techniques. In this case, the computation cost of the network with data-independent Conditional MoEs will be equivalent to a dense model without MoEs.
149
+
150
+ Generalization Ability. We hope to mitigate the task-interference issue in generalist models, while keeping their generalization ability to new downstream tasks. While token-level, context-level, and modality-level MoEs without task-specific designs do not harm the generalization ability, they ignore the task-level information which is essential to resolve the task interference. Conversely, task-level routing strategy is tied to a specific task id, which is difficult to generalize to new downstream tasks. Attribute MoEs introduce predefined token attributes to comprehensively describe the information of currently processed task and modalities, which can be transferred to new downstream tasks without any task-specific modifications. This gives attribute MoEs the potential to mitigate task interference without losing generalization ability.
151
+
152
+ # 4 Experiments
153
+
154
+ In this section, we first describe our experimental setup. Then, we confirm the task-interference issue in the generalist model Uni-Perceiver [93] and ablate the the ability of different Conditional MoEs to mitigate task interference. Finally, large-scale training is conducted to verify the effectiveness of our proposed Conditional-MoEs and its generalization ability to novel tasks.
155
+
156
+ Table 3: The performance of different routing strategies for Conditional MoEs. The base model is Uni-Perceiver with $\mathrm { B E R T _ { \mathrm { t i n y } } }$ . We also illustrate the task-specific variant where each task has its own specialized parameters. The training and validation performance reported on three tasks: image classification on ImageNet-1K [18], image caption on COCO Caption [12], and Masked Language Modeling(MLM) on Books&Wiki. The best results within a tolerance of $1 \%$ are in bold.
157
+
158
+ <table><tr><td>model</td><td>task-specific parameterization</td><td>training time</td><td>inference time</td><td colspan="2">ImageNet-1k ↑acCtrain ↑accval</td><td colspan="2">COCO Caption ↑acCtrain ↑B@4val</td><td colspan="2">MLM ↑acCtrain ↓pplval</td></tr><tr><td rowspan="2">Uni-Perceiver-Ti [93]</td><td rowspan="2">√</td><td>1.0×</td><td>1.0×</td><td>47.3</td><td>68.3</td><td>49.2</td><td>18.2</td><td>54.5</td><td>5.86</td></tr><tr><td>1.1×</td><td>1.0×</td><td>53.3</td><td>73.5</td><td>52.6</td><td>20.4</td><td>60.5</td><td>4.48</td></tr><tr><td>+ Conditional MoEs token</td><td></td><td>1.8×</td><td>2.2×</td><td>53.1</td><td>72.7</td><td>52.9</td><td>20.9</td><td>58.3</td><td>4.96</td></tr><tr><td>+ Conditional MoEs context</td><td></td><td>2.2×</td><td>2.6×</td><td>52.5</td><td>73.1</td><td>52.8</td><td>21.5</td><td>58.6</td><td>4.86</td></tr><tr><td>+Conditional MoEs modality</td><td></td><td>1.4×</td><td>1.0×</td><td>51.7</td><td>72.6</td><td>52.1</td><td>21.8</td><td>57.5</td><td>5.06</td></tr><tr><td>+ Conditional MoEs task</td><td></td><td>1.4×</td><td>1.0×</td><td>52.9</td><td>73.2</td><td>52.7</td><td>21.2</td><td>59.9</td><td>4.56</td></tr><tr><td>+ Conditional MoEs attrbute</td><td></td><td>1.4×</td><td>1.0×</td><td>52.8</td><td>73.3</td><td>53.1</td><td>23.0</td><td>60.0</td><td>4.56</td></tr></table>
159
+
160
+ # 4.1 Datasets
161
+
162
+ We use the same datasets in Uni-Perceiver [93] to pre-train our models1. Specifically, ImageNet21k [18] is used for image classification pre-training. Kinetics-700 [37] and Moments in Time [57] are used for video classification pre-training. Language modeling task is trained on BookCorpus [94] & English Wikipedia (Books&Wiki). For language modeling with image clues and image-text retrieval, we use a combination of image-text-pair datasets: SBU Captions (SBU) [58], Visual Genome [41], COCO Caption [12], CC3M [66], CC12M [9] and YFCC [35]. Following UniPerceiver, Imagenet1K [18], Kinetics-400 [37], COCO Caption [12], and Flickr30k [59] are utilized to evaluate the performance of generalist models on downstream tasks. We also use two datasets that evaluate the generalization ability to novel tasks: MSVD [11] and GLUE [78]. Additionally, all dataset licenses are included in Appendix.
163
+
164
+ # 4.2 Implementation Details
165
+
166
+ We incorporate the vanilla generalist model Uni-Perceiver with Conditional MoEs for experiments with three different variants: Uni-Perceiver-Ti (Tiny), Uni-Perceiver-B (Base), and Uni-Perceiver-L (Large). Please refer to Appendix for architecture hyperparameters. If not specified, the input image resolution is set to $2 2 4 \times 2 2 4$ . In each training iteration, each GPU independently samples a single task and dataset. The gradients of different GPUs are synchronized after the gradient back-propagation. We use the AdamW optimizer with a base learning rate of 0.0005 and a weight decay of 0.05. Similar to [52, 61], we find setting $\beta _ { 2 } = 0 . 9 8$ and $\epsilon = 1 0 ^ { \beth } ^ { \prime } ^ { \prime } ^ { \prime }$ helps improve stability when large-scale training. Besides, gradient clipping with 0.5 is used to stabilize training.
167
+
168
+ Uni-Perceiver-B and Uni-Perceiver-L are equipped with Conditional-MoEs layer for every other layers while Uni-Perception-Ti use Conditional MoEs in all layers. A normal noise is also used on the gate logits following [64] for a better exploration for new potential experts. If not specialized, top-2 gate function is used. For other hyper-parameters of MoE layers, please refer to Appendix.
169
+
170
+ # 4.3 Ablation Studies
171
+
172
+ This part explores whether Conditional MoEs can effectively mitigate task interference in generalist models and compares different routing strategies. Tab. 3 summarizes the performance of Uni-Perceiver and its variants on three typical tasks. Compared with task-specific parameterization, the performance degradation of Uni-Perceiver confirms the existence of task interference. Incorporating Conditional MoEs with any routing strategy can mitigate the task-interference issue and significantly improve the performance. Among these five routing strategies, token-level, context-level, and modality-level MoEs deliver slightly worse performance. We argue the missed task information is critical for resolving the task interference. Besides, the data-dependent MoEs, i.e., token-level and context-level, have relatively higher training and inference cost, while the other three MoEs have excellent efficiency by using reparameterization techniques. Although both task-level and attribute MoEs achieve good performance, the specialized task-id design in task-level MoEs makes it difficult to generalize to new tasks. Therefore, the Conditional MoEs with attribute routing strategy will be used.
173
+
174
+ Table 4: The performance of incorporating Conditional MoEs with Uni-Perceiver on image classification, video classification and image-text retrieval. “#param” is the parameters required during model deployment. “#data” is the amount of visual training samples involved. “WT”, “PT”, and “FT” indicate w/o tuning, prompt tuning, and fine-tuning, respectively. $^ { 6 6 } 1 \% ^ { , 9 }$ and $^ { \cdot } 1 0 0 \% ^ { , }$ indicate the proportion of downstream data used for tuning. ${ } ^ { \mathrm { 5 6 } } \mathrm { F T } _ { 1 0 0 \% }$ ↑” means fine-tuning with larger image size. The subscript number next to score indicates that a different image resolution than 224 is used. † These methods use $> 2 0 \times$ training data size and $> 1 0 \times$ training cost than ours.
175
+
176
+ (a) Image Classification accuracy on ImageNet-1k.
177
+
178
+ (c) Image-text retrieval $\mathbb { R } \ @ 1$ performance.
179
+
180
+ <table><tr><td>Method</td><td>|#param</td><td>#data</td><td>WT</td><td>PT1%</td><td>FT100%</td><td>FT100%↑</td></tr><tr><td>DeiT-B [76]</td><td>86M</td><td>1.28M</td><td></td><td></td><td>81.8</td><td>83.1384</td></tr><tr><td>ViT-B [73]</td><td>86M</td><td>15.5M</td><td></td><td></td><td>84.0</td><td>85.5384</td></tr><tr><td>ViT-L [73]</td><td>307M</td><td>15.5M</td><td></td><td></td><td>84.0</td><td>85.6384</td></tr><tr><td>OFA [79]</td><td>472M</td><td>60.6M</td><td></td><td></td><td></td><td>84.9480</td></tr><tr><td>CLIP [61]</td><td>307M</td><td>400M</td><td>76.2336</td><td></td><td></td><td></td></tr><tr><td>+ALIGN [33]</td><td>480M</td><td>1.8B</td><td>76.4289</td><td></td><td></td><td>88.6289</td></tr><tr><td>+Florence [89]</td><td>637M</td><td>900M</td><td>83.7384</td><td></td><td></td><td>90.0≥384</td></tr><tr><td>†CoCa-B [87]</td><td>86M</td><td>4.8B</td><td>82.6576</td><td></td><td></td><td>88.3576</td></tr><tr><td>†CoCa-L [87]</td><td>303M</td><td>4.8B</td><td>84.8576</td><td></td><td></td><td>90.2576</td></tr><tr><td>†Flamingo-3B [3]</td><td>3.2B</td><td>2.3B</td><td></td><td>71.0320</td><td></td><td>=</td></tr><tr><td>Uni-Perceiver-B</td><td>86M</td><td>44.1M</td><td>79.2</td><td>80.9</td><td>84.0</td><td>85.2384</td></tr><tr><td>+ Conditional MoEs</td><td>86M</td><td>44.1M</td><td>80.3</td><td>82.0</td><td>84.5</td><td>85.8384</td></tr><tr><td>Uni-Perceiver-L</td><td>354M</td><td>303M</td><td>82.7</td><td>84.2</td><td>86.2</td><td>87.0384</td></tr><tr><td>+ Conditional MoEs</td><td>303M</td><td>44.1M</td><td>83.4</td><td>84.9</td><td>86.4</td><td>87.0384</td></tr></table>
181
+
182
+ (b) Video classification accuracy on Kinetics-400.
183
+
184
+ <table><tr><td>Method</td><td>#param</td><td>#data</td><td>WT</td><td>PT1%</td><td>FT100%</td></tr><tr><td>TimeSformer-B [7]</td><td>121.4M</td><td>14.2M</td><td></td><td></td><td>80.7</td></tr><tr><td>VATT-B [2]</td><td>87.9M</td><td>238M</td><td></td><td></td><td>79.6320</td></tr><tr><td>VATT-L [2]</td><td>306.1M</td><td>238M</td><td></td><td></td><td>82.1320</td></tr><tr><td>ViViT-L [5]</td><td>&gt;307M</td><td>14.2M</td><td></td><td></td><td>81.7</td></tr><tr><td>ViViT-L [5]</td><td>&gt;307M</td><td>300M</td><td></td><td></td><td>84.9</td></tr><tr><td>+Florence [89]</td><td>647M</td><td>900M</td><td></td><td></td><td>86.5384</td></tr><tr><td>+CoCa [87]</td><td>2.1B</td><td>4.8B</td><td>=</td><td></td><td>88.9576</td></tr><tr><td>Uni-Perceiver-B</td><td>86M</td><td>44.1M</td><td>74.5</td><td>74.8</td><td>77.7</td></tr><tr><td>+ Conditional MoEs</td><td>86M</td><td>44.1M</td><td>76.8</td><td>377.2</td><td>79.3</td></tr><tr><td>Uni-Perceiver-L</td><td>303M</td><td>【44.1M</td><td>79.5</td><td>80.0</td><td>81.9</td></tr><tr><td>+ Conditional MoEs</td><td>303M</td><td>44.1M</td><td>82.1</td><td>83.0</td><td>84.2</td></tr></table>
185
+
186
+ <table><tr><td rowspan="3">Method</td><td rowspan="3"></td><td rowspan="3"></td><td colspan="6">Flickr30K</td><td colspan="6">MSCOCO Caption</td></tr><tr><td colspan="2">Image →Text</td><td colspan="2"></td><td colspan="2">Text→Image</td><td colspan="2">Image→Text</td><td colspan="2"></td><td colspan="2">Text→Image</td></tr><tr><td>WT</td><td>PT1%</td><td>FT100%</td><td>WT</td><td>PT1%FT100%</td><td>WT</td><td>PT1%</td><td></td><td>FT100%</td><td>WT</td><td>PT1%</td><td>FT100%</td></tr><tr><td>ImageBERT[60]</td><td>170M</td><td>10M</td><td>70.7</td><td></td><td>87.0</td><td>54.3</td><td></td><td>73.1</td><td>44.0</td><td></td><td>66.4</td><td>32.3</td><td></td><td>50.5</td></tr><tr><td>UNITER-B [13]</td><td>146M</td><td>9.6M</td><td>80.7</td><td></td><td>85.9</td><td>66.2</td><td></td><td>72.5</td><td></td><td></td><td>64.4</td><td></td><td></td><td>50.3</td></tr><tr><td>UNITER-L[13]</td><td>363M</td><td>9.6M</td><td>83.6</td><td></td><td>87.3</td><td>68.7</td><td></td><td>75.6</td><td></td><td></td><td>65.7</td><td></td><td></td><td>52.9</td></tr><tr><td>ViLT [39]</td><td>87M</td><td>9.7M</td><td>73.2</td><td></td><td>74.8</td><td>56.5</td><td></td><td>61.5</td><td>55.0</td><td></td><td>64.4</td><td>40.4</td><td></td><td>42.7</td></tr><tr><td>FLAVA [71]</td><td>215M</td><td>70M</td><td>67.7</td><td></td><td>=</td><td>65.2</td><td></td><td>-</td><td>42.7</td><td></td><td></td><td>38.4</td><td></td><td>-</td></tr><tr><td>CLIP [61]</td><td>417M</td><td>400M</td><td>88.0336</td><td></td><td>-</td><td>68.7336</td><td></td><td>-</td><td>58.4336</td><td></td><td></td><td>37.8336</td><td></td><td>-</td></tr><tr><td>+ALIGN</td><td>820M</td><td>1.8B</td><td>88.6289-</td><td></td><td>95.3289</td><td>75.7289-</td><td></td><td>84.9289</td><td>58.6289-</td><td></td><td>77.0289</td><td></td><td>45.6289-</td><td>59.9289</td></tr><tr><td>†Florence [89]</td><td>893M</td><td>900M</td><td>90.9384-</td><td></td><td>97.2384</td><td>76.7384-</td><td></td><td>87.9384</td><td>64.7384-</td><td></td><td></td><td></td><td>47.2384-</td><td>-</td></tr><tr><td>+CoCa-B [87]</td><td>383M</td><td>4.8B</td><td>89.8576</td><td></td><td></td><td>76.8576</td><td></td><td>=</td><td>63.8576-</td><td></td><td></td><td>47.5576</td><td></td><td>=</td></tr><tr><td>+CoCa-L [87]</td><td>787M</td><td>4.8B</td><td>92.5576-</td><td></td><td></td><td>80.4576</td><td></td><td></td><td>66.3576-</td><td></td><td></td><td></td><td>51.2576-</td><td></td></tr><tr><td>†Flamingo-3B [3]</td><td>3.2B</td><td>2.3B</td><td>89.3320</td><td></td><td>=</td><td>79.5320</td><td></td><td>=</td><td>65.9320</td><td></td><td>=</td><td>48.0320</td><td></td><td>-</td></tr><tr><td>Uni-Perceiver-B</td><td>124M</td><td>44.1M</td><td>82.3</td><td>91.0</td><td>92.7</td><td>71.1</td><td>76.0</td><td>77.5</td><td>64.9</td><td>68.4</td><td>69.8</td><td>50.7</td><td>51.9</td><td>53.9</td></tr><tr><td>+ Conditional MoEs</td><td>167M 44.1M</td><td></td><td>82.1</td><td>91.3</td><td>93.6</td><td>72.4</td><td>78.5</td><td>79.8</td><td>64.6</td><td>68.9</td><td>70.5</td><td>51.6</td><td>52.6</td><td>54.1</td></tr><tr><td>Uni-Perceiver-L</td><td>354M 44.1M</td><td></td><td>83.7</td><td>92.1</td><td>94.7</td><td>74.2</td><td>80.0</td><td>82.1</td><td>67.8</td><td>73.3</td><td>74.4</td><td>54.1</td><td>56.2</td><td>57.9</td></tr><tr><td>+ConditionalMoEs</td><td>505M</td><td>44.1M</td><td>83.6</td><td>92.4</td><td>94.1</td><td>75.9</td><td>80.6</td><td>83.7</td><td>67.9</td><td>73.3</td><td>74.7</td><td>55.3</td><td>57.1</td><td>58.3</td></tr></table>
187
+
188
+ # 4.4 Evaluation on Pre-training tasks
189
+
190
+ Large-scale training is conducted to verify the effectiveness of our method, we first evaluate it on tasks involved in pre-training. Specifically, we use widely-used Imagenet-1k [18] and Kinetics-400 [37] to evaluate image and video classification respectively, and use popular Flickr30k [59] and COCO Caption [12] to evaluate image caption and image-text retrieval.
191
+
192
+ Tab. 4 and Tab. 5a show the results on the four pre-training tasks. We see that Uni-perceiver with our Conditional MoEs consistently outperforms vanilla Uni-perceiver by a large margin. Without any tuning, our models achieve comparable performance with task-specific SOTAs trained with similar model size and training data size. Note that, our approach is a generalist model pretrained on a unified task formulation, while task-specific approaches are trained specifically for the target task.
193
+
194
+ When prompt tuned on only $1 \%$ downstream data, the performance of our models are boosted to a level close to counterparts that use ${ > } 5 0 \times$ training data sizes and $> 1 0 \times$ training cost. For the prompt tuning of our models, only a small amount of parameters are tuned, and the encoder is still fixed and shared among different tasks, indicating that generalist models with Conditional MoEs can handle different tasks with significant low cost than counterparts.
195
+
196
+ We further fine-tune our models with $100 \%$ of the downstream data. In this case, our model achieves performance on-par with or better than the SOTAs trained with similar data size on all these tasks, which proves generalist models with Conditional MoEs has learned high-quality representations.
197
+
198
+ Table 5: The performance of incorporating Conditional MoEs with Uni-Perceiver on image caption, natural language understanding, video-text retrieval and video caption, where the last three tasks are not involved in pre-training.
199
+
200
+ (a) Image caption BLEU $@ 4$ performance. \* means methods use region features as network inputs. ‡ indicates that Cider optimization is used.
201
+
202
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">#param</td><td rowspan="2">data</td><td colspan="2">MSCOCO Caption</td><td colspan="3">Flickr30k</td></tr><tr><td>WT</td><td>PT1% FT100%</td><td>WT</td><td>PT1%</td><td>FT100%</td></tr><tr><td>*Unified VLP [92]</td><td>86M</td><td>3.0M</td><td></td><td>36.5</td><td></td><td></td><td>30.1</td></tr><tr><td>*OSCAR-B [46]</td><td>154M</td><td>6.5M</td><td></td><td>36.5</td><td></td><td></td><td>=</td></tr><tr><td>*OSCAR-L [46]</td><td>384M</td><td>6.5M</td><td></td><td>37.4</td><td></td><td>=</td><td>=</td></tr><tr><td>UNICORN [86]</td><td>198M</td><td>200k</td><td></td><td>35.8</td><td></td><td></td><td>=</td></tr><tr><td>BLIP-B [44]</td><td>252M</td><td>129M</td><td></td><td>39.7384</td><td></td><td></td><td></td></tr><tr><td>BLIP-L [44]</td><td>473M</td><td>129M</td><td></td><td>40.4384</td><td></td><td>=</td><td>=</td></tr><tr><td>CLIP-VIL [69]</td><td>&gt;459M</td><td>400M</td><td></td><td>40.2</td><td></td><td>=</td><td></td></tr><tr><td>SimVLM[84]</td><td>632M</td><td>1.8B</td><td>11.2480</td><td>40.6480</td><td></td><td></td><td>=</td></tr><tr><td>OFA [79]</td><td>472M</td><td>60.6M</td><td></td><td></td><td>42.4480</td><td></td><td></td></tr><tr><td>*+OSCAR-L [46]</td><td>384M</td><td>6.5M</td><td></td><td>41.7</td><td></td><td></td><td></td></tr><tr><td>†CoCa[87]</td><td>2.1B</td><td>4.8B</td><td></td><td></td><td>40.9576</td><td></td><td></td></tr><tr><td>Uni-Perceiver-B</td><td>124M 44.1M</td><td></td><td>32.0</td><td>35.5</td><td>36.4</td><td>14.7 30.2</td><td>31.2</td></tr><tr><td>+ Conditional MoEs</td><td>167M</td><td>44.1M</td><td>33.2</td><td>36.8 37.3</td><td></td><td>15.9 30.7</td><td>32.4</td></tr><tr><td>Uni-Perceiver-L</td><td>354M 44.1M</td><td></td><td>35.3</td><td>38.6 39.2</td><td></td><td>15.1 32.9</td><td>35.5</td></tr><tr><td>+ Conditional MoEs</td><td>505M 44.1M</td><td></td><td>35.5</td><td>39.3</td><td>40.5</td><td>15.8 33.7</td><td>36.2</td></tr></table>
203
+
204
+ (b) Natural language understanding (novel task) finetuned on GLUE. BERTBASE records from [34]. VisualBERT and LXMERT record from [30]. \*RoBERTa uses $1 0 \times$ training text tokens than ours.
205
+
206
+ <table><tr><td>Method</td><td>MNLI (Acc)</td><td>QNLI (Acc)</td><td>QQP (F1)</td><td>RTE (Acc)</td><td>SST-2 (Acc)</td><td>MRPC (F1)</td><td>CoLA (Mcc)</td></tr><tr><td>LXMERT[75]</td><td>80.4</td><td>84.2</td><td>75.3</td><td>57.2</td><td>90.2</td><td>80.4</td><td>39.0</td></tr><tr><td>VisualBERT[45]</td><td>81.6</td><td>87.0</td><td>86.0</td><td>56.6</td><td>89.4</td><td>82.1</td><td>38.6</td></tr><tr><td>SimVLM-B [84]</td><td>83.4</td><td>88.6</td><td>87.2</td><td>63.9</td><td>90.9</td><td>84.4</td><td>46.7</td></tr><tr><td>BERT-B [78]</td><td>84.5</td><td>88.4</td><td>88.3</td><td>63.5</td><td>92.9</td><td>89.0</td><td>54.7</td></tr><tr><td>BERT-L [78]</td><td>86.6</td><td>92.3</td><td>91.3</td><td>70.4</td><td>93.2</td><td>88.0</td><td>60.6</td></tr><tr><td>OFA-B [79]</td><td>84.3</td><td>91.1</td><td>88.4</td><td>70.8</td><td>92.7</td><td>90.6</td><td>52.3</td></tr><tr><td>OFA-L [79]</td><td>86.6</td><td>92.8</td><td>88.9</td><td>73.6</td><td>94.7</td><td>91.4</td><td>53.1</td></tr><tr><td>*RoBERTa-B [52]</td><td>87.6</td><td>92.8</td><td>91.9</td><td>78.7</td><td>94.8</td><td>90.2</td><td>63.6</td></tr><tr><td>*RoBERTa-L [52]</td><td>90.2</td><td>94.7</td><td>92.2</td><td>86.6</td><td>96.4</td><td>90.9</td><td>68.0</td></tr><tr><td>Uni-Perceiver-B</td><td>79.7</td><td>87.3</td><td>86.7</td><td>71.1</td><td>89.3</td><td>86.0</td><td>43.1</td></tr><tr><td>+ Conditional MoEs</td><td>81.5</td><td>88.2</td><td>87.8</td><td>75.8</td><td>90.9</td><td>87.1</td><td>52.2</td></tr><tr><td>Uni-Perceiver-L</td><td>82.5</td><td>89.2</td><td>87.7</td><td>73.7</td><td>91.2</td><td>90.2</td><td>52.0</td></tr><tr><td>+ Conditional MoEs</td><td>85.7</td><td>91.9</td><td>89.5</td><td>78.4</td><td>93.4</td><td>91.2</td><td>57.4</td></tr></table>
207
+
208
+ (c) Video-text retrieval (novel task) Recall $@ 1$ and video caption (novel task) BLEU $@ 4$ performance on MSVD.
209
+
210
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">#param</td><td rowspan="2">#data</td><td colspan="2">Video→Text</td><td colspan="3">Text→Video WT PT1%</td><td colspan="3">Video Caption</td></tr><tr><td>WT PT1%</td><td>FT100%</td><td></td><td></td><td>FT100%</td><td></td><td>WTPT1%</td><td>FT100%</td></tr><tr><td>CLIP2video [22]</td><td>132M</td><td>400M</td><td>、</td><td></td><td>58.7</td><td></td><td>47.0</td><td></td><td>=</td><td>-</td></tr><tr><td>Hun Yuan_tvr [56]</td><td>364M</td><td>400M</td><td>=</td><td>68.0</td><td></td><td></td><td>52.7</td><td>=</td><td>=</td><td>-</td></tr><tr><td>ORG-TRL [91]</td><td>86M</td><td>2.0M</td><td>-</td><td>-</td><td></td><td></td><td>-</td><td>-</td><td>-</td><td>54.3</td></tr><tr><td>Uni-Perceiver-B</td><td>124M</td><td>44.1M</td><td>50.3</td><td>62.7</td><td>62.8</td><td>38.7</td><td>43.8 45.8</td><td>22.6</td><td>59.5</td><td>63.3</td></tr><tr><td>+ Conditional MoEs</td><td>167M</td><td>44.1M</td><td>52.8</td><td>65.6</td><td>65.0</td><td>40.0 45.3</td><td>47.8</td><td>23.4</td><td>60.0</td><td>65.4</td></tr><tr><td>Uni-Perceiver-L</td><td>354M 44.1M</td><td></td><td>45.4</td><td>65.5</td><td>65.2</td><td>34.2 48.6</td><td>50.8</td><td>24.7</td><td>67.2</td><td>68.3</td></tr><tr><td>+ Conditional MoEs</td><td>505M</td><td>44.1M</td><td>45.7</td><td>66.4</td><td>67.6</td><td>41.9</td><td>50.3</td><td>52.3 24.6</td><td>67.6</td><td>68.9</td></tr></table>
211
+
212
+ # 4.5 Generalization to Novel Tasks
213
+
214
+ The generalization ability is the most attractive aspect of generalist models, while the dynamic sub-networks activation of Conditional MoEs should maintain this ability while mitigating task interference. To verify this, we conduct experiments on video caption, video-text retrieval, and natural language understanding tasks, which did not appear in pre-training. As shown in Tab. 5c, our Uni-Perceiver equipped with Conditional MoEs could generalize to video-related tasks very well. They can obtain reasonable zero-shot performance on those tasks and also perform better than vanilla Uni-Perceiver with a great margin. Moreover, Uni-Perceiver-MoEs can achieve comparable results to SOTA methods with similar training cost by further conducting prompt tuning with only $1 \%$ data. Beyond that, Conditional MoEs can significantly boost the performance of Uni-Perceiver on GLUE benchmarks (Tab. 5b), owing to its excellent ability to resolve task interference in generalist models.
215
+
216
+ # 5 Conclusion
217
+
218
+ In this paper, we propose Conditional MoEs to address the task-interference issue in generalist models. By sparsely activate sub-networks without introducing any task-specific designs, generalist models can be pre-trained on multiple tasks jointly without performance degradation, while keeping the generalization ablity to novel tasks. We incorporate Conditional MoEs with the recently proposed generalist model Uni-Perceiver. With prompt tuning on $1 \%$ downstream data, the proposed sparse generalist model achieves competitive performance with previous SOTAs using only ${ < } 5 \%$ training data and ${ < } 1 0 \%$ training cost. We hope this work can motivate further research in generalist models.
219
+
220
+ Limitations. Our method is currently verified on generalist models with millions of parameters. For generalist models with billions of parameters, whether the task-interference issue exists and whether our method is still effective are questionable, which we leave them to future work.
221
+
222
+ Potential Negative Societal Impact. This work shares the common negative impacts of large-scale training, which may consume lots of electricity and result in increased carbon emissions. This method also learns from a large number of datasets that may contain data biases.
223
+
224
+ # References
225
+
226
+ [1] A. Abbas and Y. Andreopoulos. Biased mixtures of experts: Enabling computer vision inference under data transfer limitations. TIP, 2020.
227
+ [2] H. Akbari, L. Yuan, R. Qian, W.-H. Chuang, S.-F. Chang, Y. Cui, and B. Gong. Vatt: Transformers for multimodal self-supervised learning from raw video, audio and text. NIPS, 2021.
228
+ [3] J.-B. Alayrac, J. Donahue, P. Luc, A. Miech, I. Barr, Y. Hasson, K. Lenc, A. Mensch, K. Millican, M. Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
229
+ [4] N. Arivazhagan, A. Bapna, O. Firat, D. Lepikhin, M. Johnson, M. Krikun, M. X. Chen, Y. Cao, G. Foster, C. Cherry, et al. Massively multilingual neural machine translation in the wild: Findings and challenges. arXiv preprint arXiv:1907.05019, 2019. [5] A. Arnab, M. Dehghani, G. Heigold, C. Sun, M. Luciˇ c, and C. Schmid. Vivit: A video vision transformer. ´ arXiv preprint arXiv:2103.15691, 2021.
230
+ [6] J. L. Ba, J. R. Kiros, and G. E. Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
231
+ [7] G. Bertasius, H. Wang, and L. Torresani. Is space-time attention all you need for video understanding? arXiv preprint arXiv:2102.05095, 2021.
232
+ [8] R. Caruana. Multitask learning. Machine learning, 1997.
233
+ [9] S. Changpinyo, P. Sharma, N. Ding, and R. Soricut. Conceptual 12M: Pushing web-scale image-text pre-training to recognize long-tail visual concepts. In CVPR, 2021.
234
+ [10] D. S. Chaplot, L. Lee, R. Salakhutdinov, D. Parikh, and D. Batra. Embodied multimodal multitask learning. arXiv preprint arXiv:1902.01385, 2019.
235
+ [11] D. Chen and W. B. Dolan. Collecting highly parallel data for paraphrase evaluation. In ACL, 2011.
236
+ [12] X. Chen, H. Fang, T.-Y. Lin, R. Vedantam, S. Gupta, P. Dollár, and C. L. Zitnick. Microsoft coco captions: Data collection and evaluation server. arXiv preprint arXiv:1504.00325, 2015.
237
+ [13] Y.-C. Chen, L. Li, L. Yu, A. El Kholy, F. Ahmed, Z. Gan, Y. Cheng, and J. Liu. Uniter: Universal image-text representation learning. 2020.
238
+ [14] Z. Chen, V. Badrinarayanan, C.-Y. Lee, and A. Rabinovich. Gradnorm: Gradient normalization for adaptive loss balancing in deep multitask networks. In ICML, 2018.
239
+ [15] B. Cheng, I. Misra, A. G. Schwing, A. Kirillov, and R. Girdhar. Masked-attention mask transformer for universal image segmentation. 2022.
240
+ [16] K. Clark, M.-T. Luong, U. Khandelwal, C. D. Manning, and Q. V. Le. Bam! born-again multi-task networks for natural language understanding. arXiv preprint arXiv:1907.04829, 2019.
241
+ [17] M. Crawshaw. Multi-task learning with deep neural networks: A survey. arXiv preprint arXiv:2009.09796, 2020.
242
+ [18] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
243
+ [19] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
244
+ [20] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
245
+ [21] N. Du, Y. Huang, A. M. Dai, S. Tong, D. Lepikhin, Y. Xu, M. Krikun, Y. Zhou, A. W. Yu, O. Firat, et al. Glam: Efficient scaling of language models with mixture-of-experts. arXiv preprint arXiv:2112.06905, 2021.
246
+ [22] H. Fang, P. Xiong, L. Xu, and Y. Chen. Clip2video: Mastering video-text retrieval via image clip. arXiv preprint arXiv:2106.11097, 2021.
247
+ [23] W. Fedus, B. Zoph, and N. Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961, 2021.
248
+ [24] M. Guo, A. Haque, D.-A. Huang, S. Yeung, and L. Fei-Fei. Dynamic task prioritization for multitask learning. In ECCV, 2018.
249
+ [25] K. Hashimoto, C. Xiong, Y. Tsuruoka, and R. Socher. A joint many-task model: Growing a neural network for multiple nlp tasks. arXiv preprint arXiv:1611.01587, 2016.
250
+ [26] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016.
251
+ [27] K. He, G. Gkioxari, P. Dollár, and R. Girshick. Mask r-cnn. In ICCV, 2017.
252
+ [28] C. Hokamp, J. Glover, and D. Gholipour. Evaluating the supervised and zero-shot performance of multi-lingual translation models. arXiv preprint arXiv:1906.09675, 2019.
253
+ [29] R. Hu and A. Singh. Unit: Multimodal multitask learning with a unified transformer. arXiv preprint arXiv:2102.10772, 2021.
254
+ [30] T. Iki and A. Aizawa. Effect of visual extensions on natural language understanding in vision-and-language models. arXiv preprint arXiv:2104.08066, 2021.
255
+ [31] A. Jaegle, S. Borgeaud, J.-B. Alayrac, C. Doersch, C. Ionescu, D. Ding, S. Koppula, A. Brock, E. Shelhamer, O. Hénaff, M. M. Botvinick, A. Zisserman, O. Vinyals, and J. Carreira. Perceiver io: A general architecture for structured inputs & outputs, 2021.
256
+ [32] A. Jaegle, F. Gimeno, A. Brock, O. Vinyals, A. Zisserman, and J. Carreira. Perceiver: General perception with iterative attention. In ICML, 2021.
257
+ [33] C. Jia, Y. Yang, Y. Xia, Y.-T. Chen, Z. Parekh, H. Pham, Q. Le, Y.-H. Sung, Z. Li, and T. Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
258
+ [34] H. Jiang, P. He, W. Chen, X. Liu, J. Gao, and T. Zhao. Smart: Robust and efficient fine-tuning for pre-trained natural language models through principled regularized optimization. arXiv preprint arXiv:1911.03437, 2019.
259
+ [35] S. Kalkowski, C. Schulze, A. Dengel, and D. Borth. Real-time analysis and visualization of the yfcc100m dataset. In Proceedings of the 2015 workshop on community-organized multimodal mining: opportunities for novel solutions, pages 25–30, 2015.
260
+ [36] M. Kanakis, D. Bruggemann, S. Saha, S. Georgoulis, A. Obukhov, and L. V. Gool. Reparameterizing convolutions for incremental multi-task learning without task interference. 2020.
261
+ [37] W. Kay, J. Carreira, K. Simonyan, B. Zhang, C. Hillier, S. Vijayanarasimhan, F. Viola, T. Green, T. Back, P. Natsev, et al. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017.
262
+ [38] A. Kendall, Y. Gal, and R. Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In CVPR, 2018.
263
+ [39] W. Kim, B. Son, and I. Kim. Vilt: Vision-and-language transformer without convolution or region supervision. arXiv preprint arXiv:2102.03334, 2021.
264
+ [40] Y. J. Kim, A. A. Awan, A. Muzio, A. F. C. Salinas, L. Lu, A. Hendy, S. Rajbhandari, Y. He, and H. H. Awadalla. Scalable and efficient moe training for multitask multilingual models. arXiv preprint arXiv:2109.10465, 2021.
265
+ [41] R. Krishna, Y. Zhu, O. Groth, J. Johnson, K. Hata, J. Kravitz, S. Chen, Y. Kalantidis, L.-J. Li, D. A. Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. IJCV, 123(1):32–73, 2017.
266
+ [42] S. Kudugunta, Y. Huang, A. Bapna, M. Krikun, D. Lepikhin, M.-T. Luong, and O. Firat. Beyond distillation: Task-level mixture-of-experts for efficient inference. arXiv preprint arXiv:2110.03742, 2021.
267
+ [43] D. Lepikhin, H. Lee, Y. Xu, D. Chen, O. Firat, Y. Huang, M. Krikun, N. Shazeer, and Z. Chen. Gshard: Scaling giant models with conditional computation and automatic sharding. arXiv preprint arXiv:2006.16668, 2020.
268
+ [44] J. Li, D. Li, C. Xiong, and S. Hoi. Blip: Bootstrapping language-image pre-training for unified visionlanguage understanding and generation. arXiv preprint arXiv:2201.12086, 2022.
269
+ [45] L. H. Li, M. Yatskar, D. Yin, C.-J. Hsieh, and K.-W. Chang. Visualbert: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
270
+ [46] X. Li, X. Yin, C. Li, P. Zhang, X. Hu, L. Zhang, L. Wang, H. Hu, L. Dong, F. Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In ECCV, 2020.
271
+ [47] Z. Li, F. Liu, W. Yang, S. Peng, and J. Zhou. A survey of convolutional neural networks: Analysis, applications, and prospects. IEEE Transactions on Neural Networks and Learning Systems, pages 1–21, 2021. doi: 10.1109/TNNLS.2021.3084827.
272
+ [48] Z. Li, W. Wang, E. Xie, Z. Yu, A. Anandkumar, J. Alvarez, T. Lu, and P. Luo. Panoptic segformer: Delving deeper into panoptic segmentation with transformers. 2022.
273
+ [49] Z. Lin, L. Wu, M. Wang, and L. Li. Learning language specific sub-network for multilingual machine translation. arXiv preprint arXiv:2105.09259, 2021.
274
+ [50] P. Liu, X. Qiu, and X. Huang. Adversarial multi-task learning for text classification. arXiv preprint arXiv:1704.05742, 2017.
275
+ [51] X. Liu, Y. Zheng, Z. Du, M. Ding, Y. Qian, Z. Yang, and J. Tang. Gpt understands, too. arXiv preprint arXiv:2103.10385, 2021.
276
+ [52] Y. Liu, M. Ott, N. Goyal, J. Du, M. Joshi, D. Chen, O. Levy, M. Lewis, L. Zettlemoyer, and V. Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
277
+ [53] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo. Swin transformer: Hierarchical vision transformer using shifted windows. ICCV, 2021.
278
+ [54] J. Lu, D. Batra, D. Parikh, and S. Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. arXiv preprint arXiv:1908.02265, 2019.
279
+ [55] J. Lu, V. Goswami, M. Rohrbach, D. Parikh, and S. Lee. 12-in-1: Multi-task vision and language representation learning. In CVPR, 2020.
280
+ [56] S. Min, W. Kong, R.-C. Tu, D. Gong, C. Cai, W. Zhao, C. Liu, S. Zheng, H. Wang, Z. Li, et al. Hunyuan_tvr for text-video retrivial. arXiv preprint arXiv:2204.03382, 2022.
281
+ [57] M. Monfort, A. Andonian, B. Zhou, K. Ramakrishnan, S. A. Bargal, T. Yan, L. Brown, Q. Fan, D. Gutfreund, C. Vondrick, et al. Moments in time dataset: one million videos for event understanding. TPAMI, 2019.
282
+ [58] V. Ordonez, G. Kulkarni, and T. Berg. Im2text: Describing images using 1 million captioned photographs. NeurIPS, 2011.
283
+ [59] B. A. Plummer, L. Wang, C. M. Cervantes, J. C. Caicedo, J. Hockenmaier, and S. Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models. In ICCV, 2015.
284
+ [60] D. Qi, L. Su, J. Song, E. Cui, T. Bharti, and A. Sacheti. Imagebert: Cross-modal pre-training with large-scale weak-supervised image-text data. arXiv preprint arXiv:2001.07966, 2020.
285
+ [61] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. arXiv preprint arXiv:2103.00020, 2021.
286
+ [62] S. Reed, K. Zolna, E. Parisotto, S. G. Colmenarejo, A. Novikov, G. Barth-Maron, M. Gimenez, Y. Sulsky, J. Kay, J. T. Springenberg, T. Eccles, J. Bruce, A. Razavi, A. Edwards, N. Heess, Y. Chen, R. Hadsell, O. Vinyals, M. Bordbar, and N. de Freitas. A generalist agent, 2022.
287
+ [63] S. Ren, K. He, R. Girshick, and J. Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. NeurIPS, 2015.
288
+ [64] C. Riquelme, J. Puigcerver, B. Mustafa, M. Neumann, R. Jenatton, A. Susano Pinto, D. Keysers, and N. Houlsby. Scaling vision with sparse mixture of experts. NIPS, 2021.
289
+ [65] J. Shao, S. Chen, Y. Li, K. Wang, Z. Yin, Y. He, J. Teng, Q. Sun, M. Gao, J. Liu, et al. Intern: A new learning paradigm towards general vision. arXiv preprint arXiv:2111.08687, 2021.
290
+ [66] P. Sharma, N. Ding, S. Goodman, and R. Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In ACL, 2018.
291
+ [67] N. Shazeer, A. Mirhoseini, K. Maziarz, A. Davis, Q. Le, G. Hinton, and J. Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. arXiv preprint arXiv:1701.06538, 2017.
292
+ [68] N. Shazeer, Y. Cheng, N. Parmar, D. Tran, A. Vaswani, P. Koanantakool, P. Hawkins, H. Lee, M. Hong, C. Young, et al. Mesh-tensorflow: Deep learning for supercomputers. NIPS, 31, 2018.
293
+ [69] S. Shen, L. H. Li, H. Tan, M. Bansal, A. Rohrbach, K.-W. Chang, Z. Yao, and K. Keutzer. How much can clip benefit vision-and-language tasks? arXiv preprint arXiv:2107.06383, 2021.
294
+ [70] K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
295
+ [71] A. Singh, R. Hu, V. Goswami, G. Couairon, W. Galuba, M. Rohrbach, and D. Kiela. Flava: A foundational language and vision alignment model. arXiv preprint arXiv:2112.04482, 2021.
296
+ [72] T. Standley, A. Zamir, D. Chen, L. Guibas, J. Malik, and S. Savarese. Which tasks should be learned together in multi-task learning? In ICML, 2020.
297
+ [73] A. Steiner, A. Kolesnikov, X. Zhai, R. Wightman, J. Uszkoreit, and L. Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. arXiv preprint arXiv:2106.10270, 2021.
298
+ [74] G. Strezoski, N. v. Noord, and M. Worring. Many task learning with task routing. In ICCV, 2019.
299
+ [75] H. Tan and M. Bansal. Lxmert: Learning cross-modality encoder representations from transformers. arXiv preprint arXiv:1908.07490, 2019.
300
+ [76] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jégou. Training data-efficient image transformers & distillation through attention. In ICML, 2021.
301
+ [77] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. In NeurIPS, 2017.
302
+ [78] A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. R. Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461, 2018.
303
+ [79] P. Wang, A. Yang, R. Men, J. Lin, S. Bai, Z. Li, J. Ma, C. Zhou, J. Zhou, and H. Yang. Unifying architectures, tasks, and modalities through a simple sequence-to-sequence learning framework. arXiv preprint arXiv:2202.03052, 2022.
304
+ [80] W. Wang, E. Xie, X. Li, D.-P. Fan, K. Song, D. Liang, T. Lu, P. Luo, and L. Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In ICCV, 2021.
305
+ [81] X. Wang, Y. Tsvetkov, and G. Neubig. Balancing training for multilingual neural machine translation. arXiv preprint arXiv:2004.06748, 2020.
306
+ [82] X. Wang, F. Yu, L. Dunlap, Y.-A. Ma, R. Wang, A. Mirhoseini, T. Darrell, and J. E. Gonzalez. Deep mixture of experts via shallow embedding. In Uncertainty in artificial intelligence. PMLR, 2020.
307
+ [83] Z. Wang, Z. C. Lipton, and Y. Tsvetkov. On negative interference in multilingual models: Findings and a meta-learning treatment. arXiv preprint arXiv:2010.03017, 2020.
308
+ [84] Z. Wang, J. Yu, A. W. Yu, Z. Dai, Y. Tsvetkov, and Y. Cao. Simvlm: Simple visual language model pretraining with weak supervision. arXiv preprint arXiv:2108.10904, 2021.
309
+ [85] B. Yang, G. Bender, Q. V. Le, and J. Ngiam. Condconv: Conditionally parameterized convolutions for efficient inference. NIPS, 32, 2019.
310
+ [86] Z. Yang, Z. Gan, J. Wang, X. Hu, F. Ahmed, Z. Liu, Y. Lu, and L. Wang. Crossing the format boundary of text and boxes: Towards unified vision-language modeling. arXiv preprint arXiv:2111.12085, 2021.
311
+ [87] J. Yu, Z. Wang, V. Vasudevan, L. Yeung, M. Seyedhosseini, and Y. Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022.
312
+ [88] T. Yu, S. Kumar, A. Gupta, S. Levine, K. Hausman, and C. Finn. Gradient surgery for multi-task learning. NIPS, 33:5824–5836, 2020.
313
+ [89] L. Yuan, D. Chen, Y.-L. Chen, N. Codella, X. Dai, J. Gao, H. Hu, X. Huang, B. Li, C. Li, et al. Florence: A new foundation model for computer vision. arXiv preprint arXiv:2111.11432, 2021.
314
+ [90] B. Zhang, A. Bapna, R. Sennrich, and O. Firat. Share or not? learning to schedule language-specific capacity for multilingual translation. In ICLR, 2020.
315
+ [91] Z. Zhang, Y. Shi, C. Yuan, B. Li, P. Wang, W. Hu, and Z.-J. Zha. Object relational graph with teacherrecommended learning for video captioning. In CVPR, pages 13278–13288, 2020.
316
+ [92] L. Zhou, H. Palangi, L. Zhang, H. Hu, J. Corso, and J. Gao. Unified vision-language pre-training for image captioning and vqa. In AAAI, 2020.
317
+ [93] X. Zhu, J. Zhu, H. Li, X. Wu, X. Wang, H. Li, X. Wang, and J. Dai. Uni-perceiver: Pre-training unified architecture for generic perception for zero-shot and few-shot tasks. arXiv preprint arXiv:2112.01522, 2021.
318
+ [94] Y. Zhu, R. Kiros, R. Zemel, R. Salakhutdinov, R. Urtasun, A. Torralba, and S. Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In ICCV, pages 19–27, 2015.
319
+
320
+ # Checklist
321
+
322
+ 1. For all authors...
323
+
324
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
325
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
326
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5.
327
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
328
+
329
+ 2. If you are including theoretical results...
330
+
331
+ (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]
332
+
333
+ 3. If you ran experiments...
334
+
335
+ (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] Our code is released at https://github.com/fundamentalvision/Uni-Perceiver, and the used data is publicly available.
336
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4.
337
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Most experiments have stable results with little variance.
338
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.
339
+
340
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
341
+
342
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We cite the open datasets that we use.
343
+ (b) Did you mention the license of the assets? [Yes] See Section 4.
344
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] Our code will be released once the paper is accepted.
345
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] See Section 4.
346
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Section 4.
347
+
348
+ 5. If you used crowdsourcing or conducted research with human subjects...
349
+
350
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
351
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
352
+
353
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/b9tUk-f_aG/b9tUk-f_aG.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/dJgYhYKvr1/dJgYhYKvr1.md ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The Slingshot Mechanism: An Empirical Study of Adaptive Optimizers and the Grokking Phenomenon
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ The grokking phenomenon as reported by Power et al. [13] refers to a regime where a long period of overfitting is followed by a seemingly sudden transition to perfect generalization. In this paper, we attempt to reveal the underpinnings of Grokking via a series of empirical studies. Specifically, we uncover an optimization anomaly plaguing adaptive optimizers at extremely late stages of training, referred to as the Slingshot Mechanism. A prominent artifact of the Slingshot Mechanism can be measured by the cyclic phase transitions between stable and unstable training regimes, and can be easily monitored by the cyclic behavior of the norm of the last layers weights. We empirically observe that without explicit regularization, Grokking as reported in [13] almost exclusively happens at the onset of Slingshots, and is absent without it. While common and easily reproduced in more general settings, the Slingshot Mechanism does not follow from any known optimization theories that we are aware of, and can be easily overlooked without an in depth examination. Our work points to a surprising and useful inductive bias of adaptive gradient optimizers at late stages of training, calling for a revised theoretical analysis of their origin.
11
+
12
+ ![](images/a1a4fde5bf17acbf2bef165e9f9a6c825f745fb3bda95944cc71e80da8e0ed67.jpg)
13
+ Figure 1: Slingshot Effects are observed with a fully-connected ReLU network (FCN). The FCN is trained with 200 randomly chosen CIFAR-10 samples with Adam. Multiple Slingshot Effects occur in a cyclic fashion as indicated by the dotted red boxes. Each Slingshot Effect is characterized by a period of rapid growth of the last layer weights, an ensuing training loss spike, and a norm plateau.
14
+
15
+ # 17 1 Introduction
16
+
17
+ 18 Recently, the grokking phenomenon was proposed by [13], in the context of studying the optimization
18
+ 19 and generalization aspects in small, algorithmically generated datasets. Specifically, grokking refers
19
+ 20 to a sudden transition from chance level validation accuracy to perfect generalization, long past the
20
+ 21 point of perfect training accuracy, i.e., Terminal Phase of Training (TPT). This curious behavior
21
+ 22 contradicts the common belief of early stopping in the overfitting regimes, and calls for further
22
+ 23 understandings of the generalization behavior of deep neural networks.
23
+ 24 In the literature, it has been suggested that in some scenarios, marginal improvements in validation
24
+ 25 accuracy appears in TPT, which seem to directly support grokking. For example, it has been shown
25
+ 26 in [14] that gradient descent on logistic regression problems converges to the maximum margin
26
+ 27 solution, a result that has been since extended to cover a wider setting [11, 17]. A key finding in [14]
27
+ 28 shows that when training on linearly separable data with gradient descent using logistic regression,
28
+ 29 the classifier’s margin slowly improves at a rate of $\begin{array} { r } { \mathcal { O } ( \frac { 1 } { \log t } ) } \end{array}$ , while the weight norm of the predictor
29
+ 30 layer grows at a rate of $\mathcal { O } ( t )$ , where $t$ is the number of training steps. While specified for gradient
30
+ 31 descent, Wang et al. [17] showed that similar results also hold for adaptive optimizers (such as Adam
31
+ 32 and RMSProp). Taking these results into consideration, one could reasonably hypothesise that deep
32
+ 33 nonlinear networks could benefit from longer training time, even after achieving zero errors on the
33
+ 34 training set.
34
+ 36 In this paper, we provide in depth empirical analyses to the mechanism behind grokking. We find that
35
+ 37 the phenomenology of grokking differs from those predicted by [14] in several key aspects. To be
36
+ 38 concrete, we find that grokking occurs during the onset of another intriguing phenomenon directly
37
+ 39 related to adaptive gradient methods (see Algorithm 1 for a generic description of adaptive gradient
38
+ 40 methods). In particular, leveraging the basic setup in [13], we make the following observations:
39
+ 41 1. During the TPT, training exhibits a cyclic behaviour between stable and unstable regimes. A
40
+ 42 prominent artifact of this behaviour can be seen in the norm of a model’s last layer weights, which
41
+ 43 exhibits a cyclical behavior with distinct, sharp phase transitions that alternate between rapid growth
42
+ 44 and plateaus over the course of training.
43
+ 45 2. The norm grows rapidly sometime after the model has perfect classification accuracy on training
44
+ 46 data. A sharp phase transition then occurs when the model missclassifies training samples. This
45
+ 47 phase change is accompanied by a sudden spike in training loss, and a plateau in the norm growth of
46
+ 48 the final classification layer.
47
+ 49 3. The features (pre-classification layer) show rapid evolution as the weight norm transitions from
48
+ 0 rapid growth to a growth plateau, and change relatively little at the norm growth phase.
49
+
50
+ 4. Phase transitions between norm growth and norm plateau phases are typically accompanied by a sudden bump in generalization as measured by classification accuracy on a validation set, as observed in a dramatic fashion in [13].
51
+
52
+ 5. It is empirically observed that grokking as reported in [13] almost exclusively happens at the onset of Slingshots, and is absent without it.
53
+
54
+ 56 We denote the observations above as the Slingshot Effect, which is defined to be the full cycle starting
55
+ 57 from the norm growth phase, and ending in the norm plateau phase. And empirically, a single training
56
+ 58 run typically exhibits multiple Slingshot Effects. Moreover, while grokking as described in [13]
57
+ 59 might be data dependent, we find that the Slingshot Mechanism is pervasive, and can be easily
58
+ 60 reproduced in multiple scenarios, encompassing a variety of models (Transformers and MLPs) and
59
+ 61 datasets (both vision, algorithmic and synthetic datasets). Since we only observe Slingshot Effects
60
+ 62 when training classification models with adaptive optimizers, our work can be seen as empirically
61
+ 63 characterizing an implicit bias of such optimizers. Finally, while our observations and conclusions
62
+ 64 hold for most variants of adaptive gradient methods, we focus on Adam in the main paper, and
63
+ 65 relegate all experiments with additional optimizers to the appendix.
64
+
65
+ # Algorithm 1 Generic Adaptive Gradient Method
66
+
67
+ Input: $X _ { 1 } \in { \mathcal { F } }$ , step size $\mu$ , sequence of functions $\{ \phi _ { t } , \psi _ { t } \} _ { t = 1 } ^ { T } , \epsilon \in \mathbb { R } ^ { + }$ Output: Fitted $\alpha$ .
68
+ 1 for $t = 1 . . . , T$ do
69
+ 2 $g _ { t } = \nabla f _ { t } ( x _ { t } )$ .
70
+ 3 $m _ { t } = \phi _ { t } ( g _ { 1 } , . . . , g _ { t } )$ and $V _ { t } = \psi _ { t } ( g _ { 1 } , . . . , g _ { t } )$ .
71
+ 4 $\begin{array} { r } { x _ { t + 1 } = x _ { t } - \frac { \mu m _ { t } } { \sqrt { V _ { t } ^ { 2 } } + \epsilon } } \end{array}$
72
+
73
+ 67 The findings in this paper have both theoretical and practical implications that go beyond characteriz
74
+ 68 ing Grokking. A prominent feature of the Slingshot Mechanism is the repeating phase shifts between
75
+ 69 stable and unstable training regimes, where the unstable phase is characterized by extremely large
76
+ 70 gradients, and spiking training loss. Furthermore, we find that learning at late stages of training have
77
+ 71 a cyclic property, where non trivial feature adaptation only takes place at the onset of a phase shift.
78
+ 72 From a theoretical perspective, this is contradictory to common assumptions made in the literature of
79
+ 73 convergence of adaptive optimizers, which typically require $L$ smooth cost functions, and bounded
80
+ 74 stochastic gradients, either in the $L _ { 2 }$ or $L _ { \infty }$ norm, decreasing step sizes and stable convergence
81
+ 75 [18, 1, 2]. From the apparent generalization benefits of Slingshot Effects, we cast doubt on the ability
82
+ 76 of current working theories to explain the Slingshot Mechanism.
83
+ 77 Practically, our work presents additional evidence for the growing body of work indicating the
84
+ 8 importance of the TPT stage of training for optimal performance [6, 13, 12].
85
+ 79 In an era where the sheer size of models are quickly becoming out of reach for most practitioners,
86
+ 80 our work suggest focusing on improved methods to prevent excessive norm growth either implicitly
87
+ 81 through Slingshot Effects or through other forms of explicit regularization or normalization.
88
+
89
+ # 82 2 Related Work
90
+
91
+ 83 The Slingshot Mechanism we uncover here is reminiscent of the catapult mechanism described in
92
+ 84 Lewkowycz et al. [9]. Lewkowycz et al. [9] show that loss of a model trained via gradient descent with
93
+ 85 an appropriately large learning rate shows a non-monotonic behavior —the loss initially increases
94
+ 86 and starts decreasing once the model "catapults" to a region of lower curvature —early in training.
95
+ 87 However, the catapult phenomenon differs from Slingshot Effects in several key aspects. The catapult
96
+ 88 mechanism is observed with vanilla or stochastic gradient descent unlike the Slingshot Mechanism
97
+ 89 that is seen with adaptive optimizers including Adam [7] and RMSProp [15]. Furthermore, the
98
+ 90 catapult phenomenon relates to a large initial learning rate, and does not exhibit a repeating cyclic
99
+ 91 behavior. More intriguingly, Slingshot Effects only emerge late in training, typically long after the
100
+ 92 model reaches perfect accuracy on the training data.
101
+ 93 Cohen et al. [3] describe a "progressive sharpening" phenomenon in which the maximum eigenvalue
102
+ 94 of the loss Hessian increases and reaches a value that is at equal to or slightly larger than $2 / \eta$ where
103
+ 95 $\eta$ is the learning rate. This "progressive sharpening" phenomenon leads to model to enter a regime
104
+ 96 Cohen et al. [3] call Edge of Stability where-in the model shows non-monotonic training loss behavior
105
+ 97 over short time spans. Edge of Stability is similar to the Slingshot Mechanism in that it is shown to
106
+ 98 occur later on in training. However, Edge of Stability is shown for full-batch gradient descent while
107
+ 99 we observe Slingshot Mechanism with adaptive optimizers, primarily Adam [7] or AdamW [10].
108
+ 100 As noted above, the Slingshot Mechanism emerges late in training, typically longer after the model
109
+ 101 reaches perfect accuracy and has low loss on training data. The benefits of continuing to training
110
+ 102 a model in this regime has been theoretically studied in several works including [14, 11]. Soudry
111
+ 103 et al. [14] show that training a linear model on separable data with gradient using the logistic
112
+ 104 105 loss function leads tdecreases at a rate of $O \big ( \textstyle { \frac { 1 } { t } } \big )$ ax-margin solution. Furthermore Soudr while the margin increases much slower $\begin{array} { r } { \overline { { O } } ( \frac { 1 } { \log t } ) } \end{array}$ [14] pro, where $t$ e that the lossis the number
113
+ 106 of training steps. Soudry et al. [14] also note that the weight norm of the predictor layer increases
114
+ 107 at a logarithmic rate, i.e., $O ( \log ( t ) )$ . Lyu and Li [11] generalize the above results to homogeneous
115
+ 108 neural networks trained with exponential-type loss function and show that loss decreases at a rate of
116
+ 109 $O ( 1 / t ( \log ( t ) ) ^ { 2 - 2 / L } )$ . This is, where $L$ is defined as the order of the homogenous neural network.
117
+ 110 Although these results indeed prove the benefits of training models, their analyses are limited
118
+ 111 to gradient descent. Moreover, the analyses developed by Soudry et al [14] do not predict any
119
+ 112 phenomenon that resembles the Slingshot Mechanism. Wang et al. [17] show that homogenous neural
120
+ 113 networks trained with RMSProp [15] or Adam without momentum [17] do converge in direction to
121
+ 114 the max-margin solution. However, none of these papers can explain the Slingshot Mechanism and
122
+ 115 specifically the cyclical behavior of the norm of the last layer weights.
123
+
124
+ ![](images/4de1dc0143d6cbced32752b249b099bac965d672ee167032c04a19c9106040c5.jpg)
125
+ Figure 2: Division dataset: Last layer weight norm growth versus a) loss on training data b) accuracy on training data (c) loss on validation data d) accuracy on validation data e) normalized relative change in features of first Transformer layer (f) normalized relative change in features of second Transformer layer. Note that the feature change plots are shown starting at 10K step to emphasize the feature change behavior during norm growth and plateau phases, revealing that the features stop changing during the norm growth phase and resume changing during the plateaus.
126
+
127
+ # 116 3 The Slingshot Mechanism
128
+
129
+ # 117 3.1 Experimental Setup
130
+
131
+ 118 We use the training setup studied by Power et al. [13] in the main paper as a working example to
132
+ 119 illustrate the Slingshot Mechanism. In this setup, we train decoder-only Transformers [16] on a
133
+ 120 modular division dataset [13] of the form $a \div b = c$ , where $a , b$ and $c$ are discrete symbols and $\div$
134
+ 121 refers to division modulo $p$ for some prime number $p$ , split into training and validation sets. The
135
+ 122 task consists of calculating $c$ given $a$ and $b$ . The algorithmic operations and details of the datasets
136
+ 123 considered in our experiments are described in Appendix B. The Transformer consists of 2 layers,
137
+ 124 of width 128 and 4 attention heads with approximately 450K trainable parameters and is optimized
138
+ 125 by Adam [7, 10]. For these experiments we set learning rate to 0.001, weight decay to 0, $\beta _ { 1 } = 0 . 9$ ,
139
+ 126 $\beta _ { 2 } = 0 . 9 8$ , $\epsilon = \bar { 1 } 0 ^ { - 8 }$ , linear learning rate warmup for the first 10 steps and minibatch size to 512
140
+ 127 which are in line with the hyperparameters considered in [13].
141
+ 128 Figure 2 shows the metrics of interest that we record on training and validation samples for modular
142
+ 129 division dataset. Specifically, we measure 1) train loss; 2) train accuracy; 3) validation loss; 4)
143
+ 130 validation accuracy; 5) last layer norm: denoting the norm of the classification layer’s weights and 6)
144
+ 131 feature change: the relative change of features of the l-th layer $( h ^ { l } )$ after the t-th gradient update step
145
+ 132 ∥hlt+1−hlt∥∥hl ∥ . We observe from Figure 2b that the model is able to reach high training accuracy around
146
+ 133 step 300 while validation accuracy starts improving after $1 0 ^ { 5 }$ steps as seen in Figure 2d. Power et
147
+ 134 al. [13] originally showed this phenomenon and refer to it as grokking. We observe that while the
148
+ 135 validation accuracy does not exhibit any change until much later in training, the validation loss shown
149
+ 136 in Figure 2c exhibits a double descent behavior with an initial decrease, then a growth before rapidly
150
+ 137 decreasing to zero.
151
+ 138 Seemingly, some of these observations can be explained by the arguments in [14] and their extensions
152
+ 139 to adaptive optimizers [17]. Namely, at the point of reaching perfect classification of the training set,
153
+ 140 the cross-entropy (CE) loss by design pressures the classification layer to grow in norm at relatively
154
+ 141 fast rate. Simultaneously, the implicit bias of the optimizer coupled with the CE loss, pushes the
155
+ 142 direction of the classification layer to coincide with that of the maximum margin classifier, albeit at a
156
+ 143 much slower rate.
157
+ 144 These insights motivate us to measure the classifier’s last layer norm during training. We observe in
158
+ 145 Figure 2a that once classification reaches perfect accuracy on the training set, the classification layer
159
+ 146 norm exhibits a distinct cyclic behavior, alternating between rapid growth and plateau, with a sharp
160
+ 147 phase transition between phases. Simultaneously, the training loss retains a low value in periods of
161
+ 148 rapid norm growth, and then wildly fluctuating in periods of norm plateau. Figure 2e and Figure 2f
162
+ 149 shows the evolution of the relative change in features output by each layer in the Transformer. We
163
+ 150 observe that the feature maps are not updated much during the norm growth phase. However, at the
164
+ 151 phase transition, we observe that the feature maps receive a rapid update, which suggests that the
165
+ 152 internal representation of the model is updating.
166
+ 153 Is Slingshot a general phenomenon? In an attempt to ascertain the generality of Slingshot
167
+ 154 Effects as an optimization artifact, we run similar experiments with additional architectures, datasets,
168
+ 155 optimizers, and hyperparameters. We use all algorithmic datasets as proposed in [13], as well as
169
+ 156 frequently used vision benchmarks such as CIFAR-10 [8], and even synthetic Gaussian dataset. For
170
+ 157 architectures, we use Transformers, MLPs and deep linear models (see figure 1). We find abundant
171
+ 158 evidence of Slingshot Effects in all of our experiments with Adam, AdamW and RMSProp. We
172
+ 159 are unable to observe Slingshot Effects with Adagrad [5] and also with stochastic gradient descent
173
+ 160 (SGD) or SGD with momentum, pointing to the generality of the mechanism across architectures and
174
+ 161 datasets. We refer the reader to Appendix A for the full, detailed description of the experiments.
175
+ 162 Why does Slingshot happen? We hypothesize that the norm growth continues until the curvature
176
+ 163 of the loss surface becomes large, effectively “flinging" the weights to a different region in parameter
177
+ 164 space as small gradient directions get amplified, reminiscent of the mechanics of a slingshot flinging a
178
+ 165 projectile. We attempt to quantify how far a model is flung by measuring the cosine distance between
179
+ 166 a checkpoint during optimization and initial parameters. Specifically, we divide the model parameters
180
+ 167 into representation (pre-classifier) parameters and classifier (last layer) parameters and calculate how
181
+ 168 far these parameters have moved from initialization. We show that checkpoints collected after a
182
+ 169 model experiences Slingshot have a larger representation cosine distance. We defer the reader to the
183
+ 170 appendix for further details.
184
+ 171 By design, adaptive optimizers adapt the learning rate on a per parameter basis. In toy, convex
185
+ 172 scenarios, the $\epsilon$ parameter provably determines whether the algorithm will converge stably. To
186
+ 173 illustrate this, we take inspiration from [3], and consider a quadratic cost function $\mathcal { L } ( A , B , C ) =$
187
+ 174 $\begin{array} { r } { \frac { 1 } { 2 } \boldsymbol { x } ^ { \top } \boldsymbol { A } \boldsymbol { x } + \boldsymbol { B } ^ { \top } \boldsymbol { x } + \boldsymbol { C } , \boldsymbol { A } \in { \bf \bar { \mathcal { R } } } ^ { d \times d } , \boldsymbol { x } , \boldsymbol { B } \in \mathcal { R } ^ { d } , \boldsymbol { C } \in \mathcal { R } } \end{array}$ , where we assume $A$ is symmetric and positive
188
+ 175 definite. Note that the global minimum of this cost is given by $x ^ { \star } = - A ^ { - 1 } B$ . The gradient of
189
+ 176 this cost with respect to $x$ is given by $g = A x + B$ . Consider optimizing the cost with adaptive
190
+ 177 optimization steps of the simple form $\begin{array} { r } { \dot { x } _ { t + 1 } = x _ { t } - \mu \frac { g } { | g | + \epsilon } = x _ { t } - \dot { \mu } \frac { A x _ { t } + \bar { B } } { | A x _ { t } + B | + \epsilon } } \end{array}$ where $\mu$ is a learning
191
+ 178 rate, and the division and absolute operations are taken element wise. Starting from some $x _ { 0 }$ , the
192
+ 179 error $e _ { t } = x _ { t } - x ^ { \star }$ evolves according to:
193
+
194
+ ![](images/849e7704a83815c649dbb2036366d72a90f2e597e40bc4c98d840dd07f153212.jpg)
195
+ Figure 3: Curvature metric (denoted as "update sharpness") evolution vs norm growth on (a) addition, (b) subtraction, (c) multiplication, and (d) division dataset. Note the spike in the sharpness metric near the phase transitions between norm growth and plateau.
196
+
197
+ $$
198
+ e _ { t + 1 } = \big ( I - \mu \mathrm { d i a g } ( \frac { 1 } { | A e _ { t } | + \epsilon } ) A \big ) e _ { t } \stackrel { \mathrm { d e f } } { = } \mathcal { M } _ { t } e _ { t }
199
+ $$
200
+
201
+ 180 Note that the condition $\| A \| _ { s } < { \frac { 2 \epsilon } { \mu } }$ where $\| \cdot \| _ { s }$ denotes the spectral norm, implies that the mapping
202
+ 181 $\mathcal { M } _ { t }$ is a contraction for all values of $t$ , and hence convergence to the global optimum is guaranteed
203
+ 182 (This is in contrast to gradient descent, where the requirement is $\begin{array} { r } { \| A \| _ { s } < \frac { 2 } { \mu } ) } \end{array}$ . Note that the choice
204
+ 183 of $\epsilon$ crucially controls the requirement on the curvature of the cost, represented by the the spectrum
205
+ 184 of $A$ in this case. In other words, the smaller $\epsilon$ , the more restrictive the requirements on the top
206
+ 185 eigenvalue of $A$ . In [3], it was observed that full batch gradient descent increases the spectral norm
207
+ 186 of the Hessian to its maximum allowed value. We therefore hypothesize that for deep networks, a
208
+ 187 small value for $\epsilon$ requires convergence to a low curvature local minimum, causing a Slingshot Effect
209
+ 188 when this does not occur. Moreover, we may reasonably predict that increasing the value of $\epsilon$ would
210
+ 189 lift the restriction on the curvature, and with it evidence of Slingshot Effects.
211
+ 190 Figure 3 shows evidence consistent with the hypothesis that Slingshot Effects occur in the vicinity of
212
+ 191 high loss curvature, by measuring the local loss surface curvature along the optimization trajectory.
213
+ 192 Let $\mathcal { H } _ { t }$ denote the local Hessian matrix of the loss, and $u _ { t }$ the parameter update at time $t$ given the
214
+ 193 optimization algorithm of choice. We use the local curvature along the trajectory of the optimizer,
215
+ 194 given by 1∥ut∥2 u⊤ t Htut, as a curvature measure. Across the arithmetic datasets from [13], whenever
216
+ 195 the last layer weight norm plateaus, the curvature measure momentarily peaks and settles back down.
217
+ 196 Varying $\epsilon$ We next observe from Figure 2a that the training loss value also spikes up around the
218
+ 197 time step when the weight norm transitions from growth to plateau. A low training loss value suggests
219
+ 198 that the gradients (and their moments) used as inputs to the optimizer are small, which in turn can
220
+ 199 cause the $\epsilon$ hyperparameter value to play a role in calculating updates. Our hypothesis here is that the
221
+ 200 Slingshot Effect should eventually disappear with a sufficiently large $\epsilon$ . To confirm this hypothesis,
222
+ 201 we run an experiment where we vary $\epsilon$ while retaining the rest of the setup described in the previous
223
+ 202 section.
224
+
225
+ Figure 4 shows the results for various values of $\epsilon$ considered in this experiment. We first observe that the number of Slingshot Effect cycles is higher for smaller values of $\epsilon$ . Secondly, smaller values of $\epsilon$ cause grokking to appear at an earlier time step when compared to larger values. More intriguingly, models that show signs of grokking also experience Slingshot Effects while models that do not experience Slingshot Effects do not show any signs of grokking. Lastly, the model trained with the largest $\epsilon = 1 0 ^ { - 5 }$ shows no sign of generalization even after receiving 500K updates.
226
+
227
+ # 3.2 Effects on Generalization
228
+
229
+ 210 In order to understand the relationship between Slingshot Effects and neural networks generalization,
230
+ 211 we experiment with various models and datasets. We observe that models that exhibit Slingshot tend
231
+ 212 to generalize better, which suggests the benefit of training models for a long time with Adam [7] and
232
+ 213 AdamW [10]. More surprisingly, we observe that Slingshots and grokking tend to come in tandem.
233
+
234
+ Transformers with algorithmic datasets We follow the setting in Power et al. [13] and generate several datasets that represent algorithmic operations and consider several training and validation splits. This dataset creation approach is consistent with the methodology used to demonstrate grokking [13]. The Transformer is trained with AdamW [10] with a learning rate of 0.001, weight decay set to 0, and with learning rate warmup for 500K steps. We consider $\epsilon$ of AdamW as a hyperparameter in this experiment. Figure 5 summarizes the results for this experiment where the $\mathbf { X }$ -axis indicates the algorithmic operation followed by the training data split size. As can be seen in Figure 5, Slingshot Effects are seen with lower values of $\epsilon$ and disappear with higher values of $\epsilon$
235
+
236
+ ![](images/9630da8a0cf6844a9d6a091ca48f368bf2c7d670318febd9ab1a0786b0c3f29d.jpg)
237
+ Figure 4: Varying $\epsilon$ in Adam on the Division dataset. Observe that as $\epsilon$ increases, there is no Slingshot Effect or grokking behavior. Figure (a) corresponds to default $\epsilon$ suggested in [7] where the model trained with smallest value undergoes multiple Slingshot cycles.
238
+
239
+ 222 which confirms the observations made in Section 3 with modular division dataset. In addition, models
240
+ 223 that exhibit Slingshot Effects and grokking (shown in green) tend to generalize better than models
241
+ 224 that do not experience Slingshot Effects and grokking (shown in red).
242
+ 225 ViT with CIFAR-10 For further validation of Slingshot Effects and generalization, we train a
243
+ 226 Vision Transformer (ViT) [4] on CIFAR-10 [8]. The ViT consists of 12 layers, width 384 and
244
+ 227 12 attention heads trained on fixed subsets of CIFAR-10 dataset [8]. The ViT model described
245
+ 228 above is trained with 10K, 20K, 30K, 40K and 50K (full dataset) training samples. We train the
246
+ 229 models with the following learning rates: 0.0001, 0.00031 and 0.001 and with a linear learning rate
247
+ 230 warmup for the 1 epoch of optimization. We consider multiple learning rates to study the impact of
248
+ 231 this hyperparameter on Slingshot taking inspiration from [13] where the authors report observing
249
+ 232 grokking over a narrow range of learning rates . Figure 6 shows a plot of the highest test accuracy for
250
+ 233 a set of hyperparameters (learning rate, number of training samples) as a function of the number of
251
+ 234 training samples from which we make the following observations. The best test accuracy for a given
252
+ 235 set of hyperparameters is typically achieved after Slingshot phase begins during optimization. The
253
+ 236 checkpoints that achieve the highest test accuracy are labeled as "post-slingshot" and shown in green
254
+ 237 in Figure 6. While post-Slingshot checkpoints seem to enjoy higher test accuracy, there are certain
255
+ 238 combinations of hyperparameters that lead to models that show better test accuracy prior to the start
256
+ 239 of the first Slingshot phase. We label these points as "pre-slingshot" (shown in blue) in Figure 6. The
257
+ 240 above observations appear to be consistent with our finding that training long periods of time may
258
+ 241 lead to better generalization seen with grokking datasets [13].
259
+ 242 Non-Transformer Models We conduct experiments with MLPs on synthetic data where the
260
+ 243 synthetic data is a low dimensional embedding projected to higher dimensions via random projections.
261
+ 244 This design choice is critical with showing the existence of the Slingshot Effect with synthetically
262
+ 245 generated data. We find that using low dimensional data does not lead to any Slingshots. With this
263
+ 246 dataset, we show that generalization occurs late in training with Adam. Specifically, we tune $\epsilon$ in
264
+ 247 Adam and show that the optimizer is highly sensitive to this hyperparameter. These observations are
265
+ 248 consistent with the behavior reported above with Transformers and on algorithmic datasets as well
266
+ 249 as standard vision benchmark such as CIFAR-10. We refer the reader to Appendix ?? for complete
267
+ 250 description and details of these experiments.
268
+
269
+ ![](images/5af90f7cbc9ba768c0627c18b44e3545f88368cbd022ebea9b4f67460bb8ceb2.jpg)
270
+ Figure 5: Extended analysis on multiple grokking datasets. Points shown in green represent both Slingshot Effects and grokking, points shown blue indicate Slingshot Effects but not grokking while points in red indicate no Slingshot Effects and no grokking. $\epsilon$ in Adam is varied as shown in text. Observe that as $\epsilon$ increases, there are no Slingshot Effects or grokking behavior.
271
+
272
+ # 3.3 Drawbacks and Limitations
273
+
274
+ While the Slingshot Mechanism exposes an interesting implicit bias of Adam that often promotes generalization, due to its arresting of the norm growth and ensuing feature learning, it also leads to some training instability and prolonged training time. In the Appendix we show that it is possible to achieve similar levels of generalization with Adam on the modular division dataset [13] using the same Transformer setup as above, while maintaining stable learning, in regimes that do not show a clear Slingshot Effect. First we employ weight decay, which causes the training loss values to converge to a higher value than the unregularized model. In this regime the model does not become unstable, but instead regularization leads to comparable generalization, and much more quickly. However, it is important to tune the regularization strength appropriately. Similarly, we find that it is
275
+
276
+ ![](images/061b465f77945ddcbc3c6146b79cb82f3be5c9bc3417e25b66bd68191e7d437c.jpg)
277
+ Figure 6: Slingshot Effects on subsets of CIFAR-10 dataset. We train ViTs with multiple learning rates to verify the impact this parameter has on Slingshot. Power et al [13] note that grokking occurs over a narrow range of learning rates. Note that the points marked in: (i) green correspond to test accuracy for an experiment after the Slingshot Effect begins, (ii) blue are for trials where best checkpoint is observed prior to start of a Slingshot Effect and (iii) red are for trials with no Slingshot Effect.
278
+
279
+ 261 possible to normalize the features and weights using the following scheme to explicitly control norm
280
+ 262 growth: $\begin{array} { r } { w = \frac { w } { \| w \| } , f ( x ) = \frac { f ( x ) } { \| f ( x ) \| } } \end{array}$ , where $w$ and $f ( x )$ are the weights and inputs to the classification
281
+ 263 layer respectively, the norm used above is the $L _ { 2 }$ norm, and $x$ is the input to the neural network. This
282
+ 264 scheme also results in stable training and similar levels of generalization. In all cases the effects rely
283
+ 265 on keeping the weight norms from growing uncontrollably, which may be the most important factor
284
+ 266 for improving generalization. These results suggest that while the Slingshot Mechanism may be an
285
+ 267 interesting self-correcting scheme for controlling norm growth, there are likely more efficient ways
286
+ 268 to leverage adaptive optimizers to similar levels of generalization without requiring the instability
287
+ 269 that is a hallmark of the Slingshot effect.
288
+ 70 Finally, we lack a satisfactory theoretical explanation for the Slingshot Mechanism, and hence
289
+ 71 removed all attempts at a more rigorous mathematical definition, which we feel would only serve as a
290
+ 272 distraction.
291
+
292
+ # 273 4 Conclusion
293
+
294
+ 274 We have empirically shown that optimizing deep networks with cross entropy loss and adaptive
295
+ 275 optimizers produces the Slingshot Mechanism, a curious optimization anomaly unlike anything
296
+ 276 described in the literature. We have provided ample evidence that Slingshot Effects can be observed
297
+ 277 with different neural architectures and datasets. Furthermore, we find that Grokking [13] almost
298
+ 278 always occurs in the presence of Slingshot Effects and associated regions of instability in the Terminal
299
+ 279 Phase of Training (TPT). These results in their pure form absent explicit regularization, reveal an
300
+ 280 intriguing inductive bias of adaptive gradient optimizers that becomes salient in the TPT, characterized
301
+ 281 by cyclic stepwise effects on the optimization trajectory. These effects often promote generalization
302
+ 282 in ways that differ from non-adaptive optimizers like SGD, and warrant further study to be able
303
+ 283 to harness efficiently. There are open question remaining to be answered, for instance 1) What’s
304
+ 284 the causal factor of the plateau of weight norm growth? 2) Are there better ways of promoting
305
+ 285 generalization without relying on this accidental training instability? Answering these questions w ill
306
+ 286 allow us to decouple optimization and regularization, and ultimately to control and improve them
307
+ 287 independently.
308
+
309
+ # 5 Societal Impact
310
+
311
+ 289 This is a fundamental work in Deep Learning, it will impact the society via its effects on relevant
312
+ 290 models and applications.
313
+
314
+ References
315
+ [1] Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via over-parameterization. ArXiv, abs/1811.03962, 2019.
316
+ [2] Anas Barakat and Pascal Bianchi. Convergence and dynamical behavior of the adam algorithm for nonconvex stochastic optimization. SIAM J. Optim., 31:244–274, 2021.
317
+ [3] Jeremy M. Cohen, Simran Kaur, Yuanzhi Li, J. Zico Kolter, and Ameet Talwalkar. Gradient descent on neural networks typically occurs at the edge of stability. arXiv preprint arXiv: Arxiv-2103.00065, 2021. [4] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv: Arxiv-2010.11929, 2020.
318
+ [5] John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12(61):2121–2159, 2011.
319
+ [6] Elad Hoffer, Itay Hubara, and Daniel Soudry. Train longer, generalize better: closing the generalization gap in large batch training of neural networks. ArXiv, abs/1705.08741, 2017.
320
+ [7] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv: Arxiv-1412.6980, 2014.
321
+ [8] Alex Krizhevsky. Learning multiple layers of features from tiny images. 2009.
322
+ [9] Aitor Lewkowycz, Yasaman Bahri, Ethan Dyer, Jascha Sohl-Dickstein, and Guy Gur-Ari. The large learning rate phase of deep learning: the catapult mechanism. arXiv preprint arXiv:2003.02218, 2020.
323
+ [10] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
324
+ [11] Kaifeng Lyu and Jian Li. Gradient descent maximizes the margin of homogeneous neural networks. arXiv preprint arXiv:1906.05890, 2019.
325
+ [12] Vardan Papyan, X. Y. Han, and David L. Donoho. Prevalence of neural collapse during the terminal phase of deep learning training. Proceedings of the National Academy of Sciences of the United States of America, 117:24652 – 24663, 2020.
326
+ [13] Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets. In ICLR MATH-AI Workshop, 2021.
327
+ [14] Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, Suriya Gunasekar, and Nathan Srebro. The implicit bias of gradient descent on separable data. The Journal of Machine Learning Research, 19(1):2822–2878, 2018.
328
+ [15] Tijmen Tieleman and Geoffrey Hinton. Lecture 6.5-rmsprop, coursera: Neural networks for machine learning. University of Toronto, Technical Report, 6, 2012.
329
+ [16] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv: Arxiv1706.03762, 2017.
330
+ [17] Bohan Wang, Qi Meng, Wei Chen, and Tie-Yan Liu. The implicit bias for adaptive optimization algorithms on homogeneous neural networks. In International Conference on Machine Learning, pages 10849–10858. PMLR, 2021.
331
+ [18] J. Zhang, Tianxing He, Suvrit Sra, and Ali Jadbabaie. Why gradient clipping accelerates training: A theoretical justification for adaptivity. arXiv: Optimization and Control, 2020.
332
+
333
+ The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
334
+
335
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
336
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
337
+ • Did you include the license to the code and datasets? [N/A]
338
+
339
+ Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
340
+
341
+ 1. For all authors...
342
+
343
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
344
+ (b) Did you describe the limitations of your work? [Yes]
345
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
346
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
347
+
348
+ 2. If you are including theoretical results...
349
+
350
+ (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]
351
+
352
+ 3. If you ran experiments...
353
+
354
+ (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]
355
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
356
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
357
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
358
+
359
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
360
+
361
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
362
+ (b) Did you mention the license of the assets? [Yes]
363
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
364
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes]
365
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes]
366
+
367
+ 5. If you used crowdsourcing or conducted research with human subjects...
368
+
369
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes]
370
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [Yes]
371
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes]
md/dev/fR-EnKWL_Zb/fR-EnKWL_Zb.md ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # QUADTREE ATTENTION FOR VISION TRANSFORMERS
2
+
3
+ Shitao Tang1∗, Jiahui Zhang2∗, Siyu $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 }$ , Ping Tan12
4
+
5
+ 1Simon Fraser University, 2Alibaba A.I. Lab shitaot@sfu.ca, zjhthu@gmail.com, siting.zsy@alibaba-inc.com, pingtan@sfu.ca
6
+
7
+ # ABSTRACT
8
+
9
+ Transformers have been successful in many vision tasks, thanks to their capability of capturing long-range dependency. However, their quadratic computational complexity poses a major obstacle for applying them to vision tasks requiring dense predictions, such as object detection, feature matching, stereo, etc. We introduce QuadTree Attention, which reduces the computational complexity from quadratic to linear. Our quadtree transformer builds token pyramids and computes attention in a coarse-to-fine manner. At each level, the top $K$ patches with the highest attention scores are selected, such that at the next level, attention is only evaluated within the relevant regions corresponding to these top $K$ patches. We demonstrate that quadtree attention achieves state-of-theart performance in various vision tasks, e.g. with $4 . 0 \%$ improvement in feature matching on ScanNet, about $50 \%$ flops reduction in stereo matching, $0 . 4 \substack { - 1 . 5 \% }$ improvement in top-1 accuracy on ImageNet classification, $1 . 2 \substack { - 1 . 8 \% }$ improvement on COCO object detection, and $0 . 7 \mathrm { - } 2 . 4 \%$ improvement on semantic segmentation over previous state-of-the-art transformers. The codes are available at https://github.com/Tangshitao/QuadtreeAttention.
10
+
11
+ # 1 INTROCUTION
12
+
13
+ Transformers can capture long-range dependencies by the attention module and have demonstrated tremendous success in natural language processing tasks. In recent years, transformers have also been adapted to computer vision tasks for image classification (Dosovitskiy et al., 2020), object detection (Wang et al., 2021c), semantic segmentation (Liu et al., 2021), feature matching (Sarlin et al., 2020), and stereo (Li et al., 2021), etc. Typically, images are divided into patches and these patches are flattened and fed to a transformer as word tokens to evaluate attention scores. However, transformers have quadratic computational complexity in terms of the number of tokens, i.e. number of image patches. Thus, applying transformers to computer vision applications requires careful simplification of the involved computation.
14
+
15
+ To utilize the standard transformer in vision tasks, many works opt to apply it on low resolution or sparse tokens. ViT (Dosovitskiy et al., 2020) uses coarse image patches of $1 6 \times 1 6$ pixels to limit the number of tokens. DPT (Ranftl et al., 2021) up-samples low-resolution results from ViT to high resolution maps to achieve dense predictions. SuperGlue (Sarlin et al., 2020) applies transformer on sparse image keypoints. Focusing on correspondence and stereo matching applications, Germain et al. (2021) and Li et al. (2021) also apply transformers at a low resolution feature map.
16
+
17
+ However, as demonstrated in several works (Wang et al., 2021c; Liu et al., 2021; Sun et al., 2021; Li et al., 2021; Shao et al., 2020), applying transformers on high resolution is beneficial for a variety of tasks. Thus, many efforts have been made to design efficient transformers to reduce computational complexity. Linear approximate transformers (Katharopoulos et al., 2020; Wang et al., 2020) approximate standard attention computation with linear methods. However, empirical studies (Germain et al., 2021; Chen et al., 2021) show those linear transformers are inferior in vision tasks. To reduce the computational cost, the PVT (Wang et al., 2021c) uses downsampled keys and values, which is harmful to capture pixel-level details. In comparison, the Swin Transformer (Liu et al.,
18
+
19
+ ![](images/12a037cdc35a63c32e1f970a6056546225f5c75ca22bd0f15cd2b6f15529093d.jpg)
20
+ Figure 1: Illustration of QuadTree Attention. Quadtree attention first builds token pyramids by down-sampling the query, key and value. From coarse to fine, quadtree attention selects top $K$ (here, $K = 2$ ) results with the highest attention scores at the coarse level. At the fine level, attention is only evaluated at regions corresponding to the top $K$ patches at the previous level. The query sub-patches in fine levels share the same top $K$ key tokens and coarse level messages, e.g., green and yellow sub-patches at level 2 share the same messages from level 1. We only show one patch in level 3 for simplicity.
21
+
22
+ 2021) restricts the attention in local windows in a single attention block, which might hurt longrange dependencies, the most important merit of transformers.
23
+
24
+ Unlike all these previous works, we design an efficient vision transformer that captures both fine image details and long-range dependencies. Inspired by the observation that most image regions are irrelevant, we build token pyramids and compute attention in a coarse to fine manner. In this way, we can quickly skip irrelevant regions in the fine level if their corresponding coarse level regions are not promising. For example, as in Figure 1, at the 1st level, we compute the attention of the blue image patch in image A with all the patches in image B and choose the top $K$ (here, $K = 2$ ) patches which are also highlighted in blue. In the 2nd level, for the four framed sub-patches in image A (which are children patches of the blue patch at the 1st level), we only compute their attentions with the sub-patches corresponding to the top $K$ patches in image B at the 1st level. All the other shaded sub-patches are skipped to reduce computation. We highlight two sub-patches in image A in yellow and green. Their corresponding top $K$ patches in image B are also highlighted in the same color. This process is iterated in the 3rd level, where we only show the sub-sub-patches corresponding to the green sub-patch at the 2nd level. In this manner, our method can both obtain fine scale attention and retain long-range connections. Most importantly, only sparse attention is evaluated in the whole process. Thus, our method has low memory and computational costs. Since a quadtree structure is formed in this process, we refer to our method as QuadTree Attention, or QuadTree Transformer.
25
+
26
+ In experiments, we demonstrate the effectiveness of our quadtree transformer in both tasks requiring cross attention, e.g. feature matching and stereo, and tasks only utilizing self-attention, e.g. image classification and object detection. Our method achieves state-of-the-art performance with significantly reduced computation, comparing to relevant efficient transformers (Katharopoulos et al. (2020); Wang et al. (2021c); Liu et al. (2021)). In feature matching, we achieve $6 1 . 6 \ : \mathrm { A U C } @ 2 0 ^ { \circ }$ in ScanNet (Dai et al., 2017), 4.0 higher than the linear transformer (Katharopoulos et al., 2020) but with similar flops. In stereo matching, we achieve a similar end-point-error as standard transformer, (Li et al., 2021) but with about $50 \%$ flops reduction and $40 \%$ memory reduction. In image classification, we achieve $8 4 . 0 \%$ top-1 accuracy in ImageNet (Deng et al., 2009), $5 . 7 \%$ higher than ResNet152 (He et al., 2016) and $1 . 0 \%$ higher than the Swin Transformer-S (Liu et al., 2021). In object detection, our QuadTree Attention $^ +$ RetinaNet achieves 47.9 AP in COCO (Lin et al., 2014), 1.8 higher than the backbone PVTv2 (Wang et al., 2021b) with fewer flops. In semantic segementation, QuadTree Attention improves the performance by $0 . 7 \mathrm { - } 2 . 4 \%$ .
27
+
28
+ # 2 RELATED WORK
29
+
30
+ Efficient Transformers. Transformers have shown great success in both natural language processing and computer vision. Due to the quadratic computational complexity, the computation of full attention is unaffordable when dealing with long sequence tokens. Therefore, many works design efficient transformers, aiming to reduce computational complexity (Katharopoulos et al., 2020; Choromanski et al., 2020; Shao et al., 2021; Wang et al., 2020; Lee et al., 2019; Ying et al., 2018). Current efficient transformers can be categorized into three classes. 1) Linear approximate attention (Katharopoulos et al., 2020; Choromanski et al., 2020; Wang et al., 2020; Beltagy et al., 2020; Zaheer et al., 2020) approximates the full attention matrix by linearizing the softmax attention and thus can accelerate the computation by first computing the product of keys and values. 2) Inducing point-based linear transformers (Lee et al., 2019; Ying et al., 2018) use learned inducing points with fixed size to compute attention with input tokens, thus can reduce the computation to linear complexity. However, these linear transformers are shown to have inferior results than standard transformers in different works (Germain et al., 2021; Chen et al., 2021). 3) Sparse attention, including Longformer (Beltagy et al., 2020), Big Bird (Zaheer et al., 2020), etc, attends each query token to part of key and value tokens instead of the entire sequence. Unlike these works, our quadtree attention can quickly skip the irrelevant tokens according to the attention scores at coarse levels. Thus, it achieves less information loss while keeps high efficiency.
31
+
32
+ Vision Transformers. Transformers have shown extraordinary performance in many vision tasks. ViT (Dosovitskiy et al., 2020) applies transformers to image recognition, demonstrating the superiority of transformers for image classification at a large scale. However, due to the computational complexity of full attention, it is hard to apply transformers in dense prediction tasks, e.g. object detection, semantic segmentation, etc. To address this problem, Swin Transformer (Liu et al., 2021) restricts attention computation in a local window. Focal transformer (Yang et al., 2021) uses twolevel windows to increase the ability to capture long-range connection for local attention methods. Pyramid vision transformer (PVT) (Wang et al., 2021c) reduce the computation of global attention methods by downsampling key and value tokens. Although these methods have shown improvements in various tasks, they have drawbacks either in capturing long-range dependencies (Liu et al., 2021) or fine level attention (Wang et al., 2021c). Different from these methods, our method simultaneously capture both local and global attention by computing attention from full image levels to the finest token levels with token pyramids in one single block. Besides, the K-NN transformers (Wang et al., 2021a; Zhao et al., 2019) aggregate messages from top $K$ most similar tokens as ours, but they compute the attention scores among all pairs of query and key tokens, and thus still has quadratic complexity.
33
+
34
+ Beyond self-attention, many tasks can largely benefit from cross attention. Superglue (Sarlin et al., 2020) processes detected local descriptors with self- and cross attention and shows significant improvement in feature matching. Standard transformers can be applied in SuperGlue because only sparse keypoints are considered. SGMNet (Chen et al., 2021) further reduces the computation by attending to seeded matches. LoFTR (Sun et al., 2021) utilizes linear transformer (Katharopoulos et al., 2020) on low-resolution feature maps to generate dense matches. For stereo matching, STTR (Li et al., 2021) applies self- and cross attention along epipolar lines and reduces the memory by gradient checkpointing engineering techniques. However, due to the requirement of processing a large number of points, these works either use linear transformers, which compromise performance, or a standard transformer, which compromises efficiency. In contrast, our transformer with quadtree attention achieves a significant performance boost compared with linear transformer or efficiency improvement compared with standard transformer. Besides, it can be applied to both self-attention and cross attention.
35
+
36
+ # 3 METHOD
37
+
38
+ We first briefly review the attention mechanism in transformers in Section 3.1 and then formulate our quadtree attention in Section 3.2.
39
+
40
+ # 3.1 ATTENTION IN TRANSFORMER
41
+
42
+ Vision transformers have shown great success in many tasks. At the heart of a transformer is the attention module, which can capture long-range information between feature embeddings. Given two image embeddings $\mathbf { X } _ { 1 }$ and $\mathbf { X } _ { 2 }$ , the attention module passes information between them. Selfattention is the case when $\mathbf { X } _ { 1 }$ and $\mathbf { X } _ { 2 }$ are the same, while cross attention covers a more general situation when $\mathbf { X } _ { 1 }$ and $\mathbf { X } _ { 2 }$ are different. It first generates the query $\mathbf { Q }$ , key $\mathbf { K }$ , and value $\mathbf { V }$ by the
43
+
44
+ ![](images/16f2691479fd7ec52d4b755609b61089c1ad77510396ee050e16edfc4cef4366.jpg)
45
+ ⇤li i iFigure 2: Illustration of quadtree message aggregation for a query token $q _ { i }$ l+2. (a) shows the token ⇤l+1 ⇤iREFERENCESm3ipyramids and involved key/value tokens in each level. Attention scores are marked in the first two l+2levels for clarification, and the top $K$ REFERENCESscores are highlighted in red. (b) shows message aggregation i REFERENCESfor QuadTree-A architecture. The message is assembled from different levels along a quadtree. (c) REFERENCES shows message aggregation for QuadTree-B architecture. The message is collected from overlapping regions from different levels.
46
+
47
+ following equation,
48
+
49
+ $$
50
+ \begin{array} { r } { \mathbf { Q } = \mathbf { W } _ { q } \mathbf { X } _ { 1 } , } \\ { \mathbf { K } = \mathbf { W } _ { k } \mathbf { X } _ { 2 } , } \\ { \mathbf { V } = \mathbf { W } _ { v } \mathbf { X } _ { 2 } , } \end{array}
51
+ $$
52
+
53
+ where $\mathbf { W } _ { q } , \ \mathbf { W } _ { k }$ and $\mathbf { W } _ { v }$ are learnable parameters. Then, it performs message aggregation by computing the attention scores between query and key as following,
54
+
55
+ $$
56
+ \mathbf { Y } = \operatorname { s o f t m a x } ( \frac { \mathbf { Q } \mathbf { K } ^ { T } } { \sqrt { C } } ) \mathbf { V } ,
57
+ $$
58
+
59
+ where $C$ 1is the embedding channel dimension. The above process has $O ( N ^ { 2 } )$ computational complexity, where $N$ is the number of image patches in a vision transformer. This quadratic complexity hinders transformers from being applied to tasks requiring high resolution output. To address this problem, PVT (Wang et al. (2021c)) downsamples $\mathbf { K }$ and $\mathbf { V }$ , while Swin Transformer (Liu et al. (2021)) limits the attention computation within local windows.
60
+
61
+ # 3.2 QUADTREE ATTENTION
62
+
63
+ In order to reduce the computational cost of vision transformers, we present QuadTree Attention. As the name implies, we borrow the idea from quadtrees, which are often used to partition a twodimensional space by recursively subdividing it into four quadrants or regions. Quadtree attention computes attention in a coarse to fine manner. According to the results at the coarse level, irrelevant image regions are skipped quickly at the fine level. This design achieves less information loss while keeping high efficiency.
64
+
65
+ The same as the regular transformers, we first linearly project $\mathbf { X } _ { 1 }$ and $\mathbf { X } _ { 2 }$ to the query, key, and value tokens. To facilitate fast attention computation, we construct $L$ -level pyramids for query $\mathbf { Q }$ , key $\mathbf { K }$ , and value $\mathbf { V }$ tokens by downsampling feature maps. For query and key tokens, we use average pooling layers. For value tokens, average pooling is used for cross attention tasks and convolutionalnormalization-activation layers with stride 2 are used for self attention tasks if no special statement. As shown in Figure 1, after computing attention scores in the coarse level, for each query token, we select the top $K$ key tokens with the highest attention scores. At the fine level, query sub-tokens only need to be evaluated with those key sub-tokens that correspond to one of the selected $K$ key tokens at the coarse level. This process is repeated until the finest level. After computing the attention scores, we aggregate messages at all levels, where we design two architectures named as QuadTree-A and QuadTree-B.
66
+
67
+ QuadTree-A. Considering the $i$ -th query token $\mathbf { q } _ { i }$ at the finest level, we need to compute its received message $\mathbf { m } _ { i }$ from all key tokens. This design assembles the full message by collecting partial messages from different pyramid levels. Specifically,
68
+
69
+ $$
70
+ \mathbf { m } _ { i } = \sum _ { 1 \leq l \leq L } \mathbf { m } _ { i } ^ { l } ,
71
+ $$
72
+
73
+ where $\mathbf { m } _ { i } ^ { l }$ indicates the partial message evaluated at level $l$ . This partial message $\mathbf { m } _ { i } ^ { l }$ assemble messages at the $l$ -th level from tokens within the region $\Omega _ { i } ^ { l }$ , which will be defined later. In this way, messages from less related regions are computed from coarse levels, while messages from highly related regions are computed in fine levels. This scheme is illustrated in Figure 2 (b), message $\mathbf { m } _ { i }$ is generated by assembling three partial messages that are computed from different image regions with different colors, which collectively cover the entire image space. The green region indicates the most relevant region and is evaluated at the finest level, while the red region is the most irrelevant region and is evaluated at the coarsest level. The region $\Omega _ { i } ^ { l }$ can be defined as $\Gamma _ { i } ^ { l } - \Gamma _ { i } ^ { l + 1 }$ , where the image region $\Gamma _ { i } ^ { l }$ corresponds to the top $K$ tokens at the level $l - 1$ . The regions $\Gamma _ { i } ^ { l }$ are illustrated in Figure 2 (c). The region $\Gamma _ { i } ^ { 1 }$ covers the entire image.
74
+
75
+ The partial messages are computed as,
76
+
77
+ $$
78
+ \mathbf { m } _ { i } ^ { l } = \sum _ { j \in \Omega _ { i } ^ { l } } s _ { i j } ^ { l } \mathbf { v } _ { j } ^ { l } ,
79
+ $$
80
+
81
+ where $s _ { i j } ^ { l }$ is the attention score between the query and key tokens at level $l$ . Figure 2 (a) highlights query and key tokens involved in computing $\mathbf { m } _ { i } ^ { l }$ with the same color as $\Omega _ { i } ^ { l }$ . Attention scores are computed recursively,
82
+
83
+ $$
84
+ \begin{array} { r } { s _ { i j } ^ { l } = s _ { i j } ^ { l - 1 } t _ { i j } ^ { l } . } \end{array}
85
+ $$
86
+
87
+ Here, $s _ { i j } ^ { l - 1 }$ is the score of corresponding parent query and key tokens and $s _ { i j } ^ { 1 } = 1$ . The tentative attention score $t _ { i j } ^ { l }$ is evaluated according to Equation 1 among the $2 \times 2$ tokens of the same parent query token. For QuadTree-A, we use average pooling layers to downsample all query, key and value tokens.
88
+
89
+ QuadTree-B. The attention scores $s _ { i j } ^ { l }$ in QuadTree-A are recursively computed from all levels, which makes scores smaller at finer levels and reduces the contributions of fine image features. Besides, fine level scores are also largely affected by the inaccuracy at coarse levels. So we design a different scheme, referred as QuadTree- $\mathbf { B }$ in this paper, to address this problem. Specifically, we compute $\mathbf { m } _ { i }$ as a weighted average of the partial messages from different levels,
90
+
91
+ $$
92
+ \mathbf { m } _ { i } = \sum _ { 1 \leq l \leq L } w _ { i } ^ { l } \mathbf { m } _ { i } ^ { l } ,
93
+ $$
94
+
95
+ where $w _ { i } ^ { l }$ is a learned weight. As shown in Figure 2 (c), the partial messages here overlap with each other, which are computed as,
96
+
97
+ $$
98
+ \mathbf { m } _ { i } ^ { l } = \mathrm { A t t e n t i o n } ( \mathbf { q } _ { i } ^ { l } , \mathbf { K } _ { \Gamma _ { i } ^ { l } } ^ { l } , \mathbf { V } _ { \Gamma _ { i } ^ { l } } ^ { l } ) ,
99
+ $$
100
+
101
+ where Attention is the attention message computation as Equation 1. Here, $\mathbf { K } _ { \Gamma _ { i } ^ { l } } ^ { l }$ and $\mathbf { V } _ { \Gamma _ { i } ^ { l } } ^ { l }$ are matrices formed by stacking all keys and values within the region $\Gamma _ { i } ^ { l }$ .
102
+
103
+ Both QuadTree-A and QuadTree-B involve only sparse attention evaluation. Thus, our method largely reduces computational complexity. As analyzed in Appendix A.1, the computational complexity of our quadtree attention is linear to the number of tokens.
104
+
105
+ <table><tr><td></td><td></td><td>AUC@5°</td><td>AUC@10°</td><td>AUC@20°</td></tr><tr><td rowspan="3">Others</td><td>ContextDesc + SGMNet(Chen et al. (2021))</td><td>15.4</td><td>32.3</td><td>48.8</td></tr><tr><td>SuperPoint + OANet (Zhang et al. (2019b))</td><td>11.8</td><td>26.9</td><td>43.9</td></tr><tr><td>SuperPoint + SuperGlue (Sarlin et al. (2020))</td><td>16.2</td><td>33.8</td><td>51.9</td></tr><tr><td rowspan="3">LoFTR-lite</td><td>DRC-Net (Li et al. (2020)) Linear Att. (LoFTR) (Katharopoulos et al. (2020))</td><td>7.7 16.1</td><td>17.9 32.6</td><td>30.5</td></tr><tr><td>PVT (Wang et al., 2021c)</td><td>16.2</td><td>32.7</td><td>49.0 49.2</td></tr><tr><td>QuadTree-A (ours,K = 8)</td><td>16.8</td><td>33.4</td><td>50.5</td></tr><tr><td rowspan="4">LoFTR</td><td>QuadTree-B (ours,K = 8)</td><td>17.4</td><td>34.4</td><td>51.6</td></tr><tr><td>Linear Att. (LoFTR)* (Sun et al. (2021), 64 GPUs)</td><td>22.1</td><td>40.8</td><td>57.6</td></tr><tr><td>Linear Att. (LoFTR) (Katharopoulos et al. (2020))</td><td>21.1</td><td>39.5</td><td>56.6</td></tr><tr><td>QuadTree-B (ours,K = 8) QuadTree-B* (ours,K = 16)</td><td>23.0</td><td>41.7</td><td>58.5</td></tr></table>
106
+
107
+ Table 1: Results on feature matching. The symbol $\star$ indicates results cited from (Sun et al., 2021), where the model is trained with a batch size of 64 on 64 GPUs (a more preferable setting than ours). The symbol $^ *$ indicates we use the ViT (Dosovitskiy et al., 2020)-like architecture for transformer blocks. For PVT and our method, we replace the original linear attention in LoFTR with corresponding attentions.
108
+
109
+ Multiscale position encoding. The computation of attention is permutation invariant to tokens, and thus positional information is missed. To address this problem, we adopt the locally-enhanced positional encoding (LePE) (Dong et al., 2021) at each level to design a multiscale position encoding. Specifically, for level $l$ , we apply unshared depth-wise convolution layers to value tokens $\mathbf { V } ^ { l }$ to encode the positional information.
110
+
111
+ # 4 EXPERIMENT
112
+
113
+ We experiment our quadtree transformer with four representative tasks, including feature matching, stereo, image classification, and object detection. The first two tasks require cross attention to fuse information across different images, while the latter two involve only self-attention. We implement our quadtree transformer using PyTorch and CUDA kernels. More implementation details are provided in Appendix B.
114
+
115
+ # 4.1 CROSS ATTENTION TASKS
116
+
117
+ # 4.1.1 FEATURE MATCHING
118
+
119
+ Finding feature correspondence (Luo et al., 2019; DeTone et al., 2018) across different images is a precedent problem for many 3D computer vision tasks. It is typically evaluated by the accuracy of the camera pose estimated from the corresponding points. We follow the framework proposed in a recent state-of-the-art work LoFTR (Sun et al., 2021), which consists of a CNN-based feature extractor and a transformer-based matcher. We replace the linear transformer (Katharopoulos et al., 2020) in LoFTR with our quadtree transformer. Besides, we also implement a new version of LoFTR with the spatial reduction (SR) attention (Wang et al., 2021c) for additional comparison.
120
+
121
+ Setting. We experiment on ScanNet (Dai et al., 2017) with 1,513 scans. In order to accelerate training, we design the LoFTR-lite setting, which uses half of the feature channels of LoFTR and 453 training scans. Ablation studies in section 4.3 are conducted in this setting. We train both LoFTRlite and LoFTR for 30 epochs with batch size 8. For quadtree transformer, we build pyramids of three levels with the coarsest resolution at $1 5 \times 2 0$ pixels. We set the parameter $K$ to 8 at the finest level, and double it at coarser levels. For the SR attention, we average pool the value and key tokens to the size $8 \times 8$ to keep similar memory usage and flops as our quadtree attention. More details are included in Appendix B.1.
122
+
123
+ Results. Table 1 shows the AUC of camera pose errors1 under $( 5 ^ { \circ } , 1 0 ^ { \circ } , 2 0 ^ { \circ } )$ . We can see that the SR attention achieves similar results with linear transformer. In comparison, both QuadTree-A and QuadTree-B outperform linear transformer and SR attention by a large margin. Quadtree-B generally performs better than Quadtree-A. Quadtree-B has 2.6 and 1.9 improvements in terms of AUC $@ 2 0 ^ { \circ }$ over linear transformer on LoFTR-lite and LoFTR respectively. To further enhance the
124
+
125
+ <table><tr><td></td><td>EPE (px)</td><td>IOU</td><td>Flops (G)</td><td>Mem. (MB)</td></tr><tr><td>GA-Net (Zhang et al., 2019a)</td><td>0.89</td><td>/</td><td>T</td><td>/</td></tr><tr><td>GWC-Net (Guo et al., 2019)</td><td>0.97</td><td>/</td><td>305</td><td>4339</td></tr><tr><td>Bi3D (Badki et al., 2020)</td><td>1.16</td><td>/</td><td>897</td><td>10031</td></tr><tr><td>STTR(Vanilla Transformer) (Li et al., 2021)</td><td>0.45</td><td>0.92</td><td>490</td><td>8507</td></tr><tr><td>QuadTree-B (ours,K = 6)</td><td>0.46</td><td>0.99</td><td>254 (52%)</td><td>5381 (63%)</td></tr></table>
126
+
127
+ Table 2: Results of stereo matching. QuadTree-B achieves similar performance as STTR but with significantly lower flops and memory usage.
128
+
129
+ results, we train a model with $K = 1 6$ and leverage a ViT (Dosovitskiy et al., 2020)-like transformer archtecture instead of the original one used in (Sun et al., 2021). This model achieves 4 improvements on $\mathbf { A U C } @ 2 0 ^ { \circ }$ over (Sun et al., 2021), where the LoFTR model is trained with a batch size of 64 with 64 GPUs, a more preferable setting leading to slightly better results than our linear transformer implementation shown in Table 1.
130
+
131
+ # 4.1.2 STEREO MATCHING
132
+
133
+ Stereo matching aims to find corresponding pixels on epipolar lines between two rectified images. The recent work STTR (Li et al., 2021) applies transformers to feature points between epipolar lines and achieves state-of-the-art performance. Note here, both self- and cross attention are applied along epipolar lines, pixels across different lines are not considered in the attention computation. We replace the standard transformer in STTR (Li et al., 2021) with our quadtree transformer.
134
+
135
+ Setting. We experiment on the Scene Flow FlyingThings3D (Mayer et al., 2016) synthetic dataset, which contains 25,466 images with a resolution of $9 6 0 \times 5 4 0$ . We build pyramids of four levels to evaluate quadtree attention. While the STTR is applied to features of 1/3 of image resolution, we use feature maps of 1/2 of image resolution. More details about the network are included in Appendix B.2.
136
+
137
+ Results. We report EPE (End-Point-Error) in non-occluded regions and IOU (Intersection-overUnion) for occlusion estimation in Table 2 as (Li et al., 2021). Computational complexity and memory usage are also reported. Compared with STTR based on the standard transformer, our quadtree transformer achieves similar EPE (0.45 px vs $0 . 4 6 ~ \mathrm { p x }$ ) and higher IOU for occlusion estimation, but with much lower computational and memory costs, with only $52 \%$ FLOPs and $63 \%$ memory consumption.
138
+
139
+ # 4.2 SELF-ATTENTION TASK
140
+
141
+ This section presents results on image classification and object detection. In the past, convolutional neural networks (CNNs) have dominated these tasks for a long time. Recently, vision transformers (Dosovitskiy et al., 2020; Liu et al., 2021; Wang et al., 2021c) show excellent potential on these problems, thanks to their capability in capturing long-range interactions. To compare our method with these vision transformers on image classification, we use the public codes of PVTv2 (Wang et al., 2021c) and replace all the spatial reduction attention with our quadtree attention. For object detection, we further apply a representative object detection framework, RetinaNet (Lin et al., 2017), which is a widely used single-stage object detector.
142
+
143
+ # 4.2.1 IMAGE CLASSIFICATION
144
+
145
+ Settings. We evaluate image classification on the ImageNet-1K dataset (Deng et al., 2009), which consists of 1.28M training images and 50K validation images from 1,000 categories. We build token pyramids with the coarsest level at a resolution of $7 \times 7$ and set $K = 8$ . We crop and resize the input images to $2 2 4 \times 2 2 4$ pixels and train the model with a mini-batch of 128. All models are trained for 300 epochs from scratch on 8 GPUs. All the other training settings are the same as in (Wang et al., 2021c). We build five different quadtree transformers at different complexity, named as b0, b1, b2, b3, b4. These models are gradually deeper and wider. More configuration details can be found in Appendix. B.3.
146
+
147
+ Results. We provide the top-1 accuracy of various methods and network settings in Table 3. These results are grouped into five sections, each with several methods of similar network complexity, as indicated by the number of parameters. As shown in Table 3, QuadTree-B outperforms PVTv2 by $0 . 4 \% { - } 1 . 5 \%$ in top-1 accuracy with fewer parameters. Swin Transformer-S adopts local attention and is surpassed by our QuadTree-B-b2 by $1 . 0 \%$ in top-1 accuracy. This result proves that global information is important. In general, our quadtree transformer leverages both global information at the coarse level and local information at fine levels, and outperforms both PVTv2 and Swin Transformer.
148
+
149
+ Table 3: Image classification results. We report top-1 accuracy on the ImageNet validation set.
150
+
151
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Param (M) Flops (G) Top1 (%)</td></tr><tr><td rowspan=1 colspan=1>PVTv2-b0 (Wang et al., 2021b)QuadTree-A-bO (ours)QuadTree-B-bO (ours)</td><td rowspan=1 colspan=1>3.7 0.6 70.53.4 0.6 70.93.5 0.7 72.0</td></tr><tr><td rowspan=2 colspan=1>ResNet18 (He et al., 2016)PVTv1-Tiny (Wang et al.,2021c)PVTv2-b1 (Wang et al.,2021b)QuadTree-B-b1 (ours)</td><td rowspan=1 colspan=1>11.7 1.8 69.8</td></tr><tr><td rowspan=1 colspan=1>13.2 2.1 75.114.0 2.1 78.713.6 2.3 80.0</td></tr><tr><td rowspan=10 colspan=1>ResNet50 (He et al.,2016)ResNeXt50-32x4d (Xie et al., 2017)RegNetY-4G (Radosavovic et al.,2020)DeiT-Small/16 (Touvron et al., 2021)Swin-T (Liu et al.,2021)TNT-S (Han et al., 2021)CeiT (Yuan et al.,2021a)PVTv2-b2 (Wang et al.,2021c)Focal-T(Yang et al.,2021)QuadTree-B-b2 (ours)</td><td rowspan=1 colspan=1>25.1 4.1 76.4</td></tr><tr><td rowspan=1 colspan=1>25.0 4.3 77.6</td></tr><tr><td rowspan=1 colspan=1>21.0 4.0 80.0</td></tr><tr><td rowspan=1 colspan=1>22.1 4.6 79.9</td></tr><tr><td rowspan=1 colspan=1>29.0 4.5 81.3</td></tr><tr><td rowspan=1 colspan=1>23.8 5.2 81.3</td></tr><tr><td rowspan=1 colspan=1>24.2 4.5 82.0</td></tr><tr><td rowspan=1 colspan=1>25.4 4.0 82.0</td></tr><tr><td rowspan=1 colspan=1>29.1 4.9 82.2</td></tr><tr><td rowspan=1 colspan=1>24.2 4.5 82.7</td></tr><tr><td rowspan=6 colspan=1>ResNet101 (He et al.,2016)ResNeXt101-32x4d (Xie et al., 2017)RegNetY-8G (Radosavovic et al.,2020)CvT-21 (Wu et al., 2021)PVTv2-b3 (Wang et al., 2021c)Quadtree-B-b3 (ours)</td><td rowspan=1 colspan=1>44.7 7.9 77.4</td></tr><tr><td rowspan=1 colspan=1>44.2 8.0 78.8</td></tr><tr><td rowspan=1 colspan=1>39.0 8.0 81.7</td></tr><tr><td rowspan=1 colspan=1>32.0 7.1 82.5</td></tr><tr><td rowspan=1 colspan=1>45.2 6.9 83.2</td></tr><tr><td rowspan=1 colspan=1>46.3 7.8 83.7</td></tr><tr><td rowspan=6 colspan=1>ResNet152 (He etal.,2016)T2T-ViTt-24 (Yuan et al., 2021b)Swin-S (Liu et al., 2021)Focal-Small (Yang et al., 2021)PVTv2-b4 (Wang et al., 2021c)Quadtree-B-b4 (ours)</td><td rowspan=1 colspan=1>60.2 11.6 78.3</td></tr><tr><td rowspan=1 colspan=1>64.0 15.0 82.2</td></tr><tr><td rowspan=1 colspan=1>50.0 8.7 83.0</td></tr><tr><td rowspan=1 colspan=1>51.1 9.1 83.5</td></tr><tr><td rowspan=1 colspan=1>62.6 10.1 83.6</td></tr><tr><td rowspan=1 colspan=1>64.2 11.5 84.0</td></tr></table>
152
+
153
+ Table 4: Object detection results on COCO val2017 with RetinaNet. We use PVTv2 backbone and replace the reduction attention with quadtree attention. ‘Flops’ is the backbone flops for input image size of $8 0 0 \times 1 , 3 3 3$ .
154
+
155
+ <table><tr><td></td><td>Flops (G)</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>PVTv2-b0 (Wang et al., 2021b) QuadTree-A-b0 (K=32,ours)</td><td>28.3 16.0</td><td>37.2 37.0</td><td>57.2 56.8</td><td>39.5 38.9</td><td>23.1 22.8</td><td>40.4 39.7</td><td>49.7 50.0</td></tr><tr><td>QuadTree-B-b0 (K=32,ours) ResNet18 (He et al.,2016)</td><td>16.5 38.6</td><td>38.4 31.8</td><td>58.7 49.6</td><td>41.1 33.6</td><td>22.5 16.3</td><td>41.7 34.3</td><td>51.6 43.2</td></tr><tr><td>PVTv1-Tiny (Wang et al.,2021c) PVTv2-b1 (Wang et al., 2021b) Quadtree-B-b1 (K=32,ours)</td><td>72.5 78.8 56.2</td><td>36.7 41.2 42.6</td><td>56.9 61.9 63.6</td><td>38.9 43.9 45.3</td><td>22.6 25.4 26.8</td><td>38.8 44.5 46.1</td><td>50.7 54.3 57.2</td></tr><tr><td>ResNet50 (He et al.,2016)</td><td>87.3</td><td>36.3</td><td>55.3</td><td>38.6</td><td>19.3</td><td>40.0</td><td>48.8</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ResNet101 (He et al.,2016)</td><td>166.3</td><td>38.5</td><td>57.8</td><td>41.2</td><td></td><td></td><td></td></tr><tr><td>ResNeXt101-32x4d (Xie et al., 2017)</td><td></td><td></td><td></td><td></td><td>21.4</td><td>42.6</td><td>51.1</td></tr><tr><td></td><td>170.2</td><td>39.9</td><td>59.6</td><td>42.7</td><td>22.3</td><td>44.2</td><td></td></tr><tr><td>PVTv1-small(Wang et al.,2021c)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>52.5</td></tr><tr><td></td><td>139.8</td><td>36.7</td><td>56.9</td><td>38.9</td><td>25.0</td><td>42.9</td><td>55.7</td></tr><tr><td>PVTv2-b2 (Wang et al.,2021c)</td><td>149.1</td><td>44.6</td><td>65.6</td><td>47.6</td><td>27.4</td><td>48.8</td><td>58.6</td></tr><tr><td>QuadTree-B-b2 (K=32,ours) PVTv1-Medium (Wang et al., 2021c)</td><td>108.6</td><td>46.2</td><td>67.2</td><td>49.5</td><td>29.0</td><td>50.1</td><td>61.8</td></tr><tr><td>PVTv2-b3 (Wang et al.,2021b)</td><td>237.4</td><td>41.9</td><td>63.1</td><td>44.3</td><td>25.0</td><td>44.9</td><td>57.6</td></tr><tr><td></td><td>243.0</td><td>45.9</td><td>66.8</td><td>49.3</td><td>28.6</td><td>49.8</td><td>61.4</td></tr><tr><td>QuadTree-B-b3 (ours)</td><td>193.9</td><td>47.3</td><td>68.2</td><td>50.6</td><td>30.4</td><td>51.3</td><td>62.9</td></tr><tr><td>PVTv1-Large (Wang et al.,2021c) PVTv2-b4 (Wang et al.,2021b)</td><td>346.6</td><td>42.6</td><td>63.7</td><td>45.4</td><td>25.8</td><td>46.0</td><td>58.4</td></tr><tr><td></td><td>353.3</td><td>46.1</td><td>66.9</td><td>49.2</td><td>28.4</td><td>50.0</td><td>62.2</td></tr><tr><td>QuadTree-B-b4 (ours)</td><td>283.9</td><td>47.9</td><td>69.1</td><td>51.3</td><td>29.4</td><td>52.2</td><td>63.9</td></tr></table>
156
+
157
+ Table 5: To fairly compare with Swin, PVT, Focal attention and our method, we replace the attention module in PVTv2-b0 with different types of attention and same position encoding method LePE and run image classification and object detection respectively.
158
+
159
+ <table><tr><td></td><td colspan="2">ImageNet-1K</td><td colspan="3">COCO (RetinaNet)</td></tr><tr><td></td><td>Flops (G) Top-1 (%)</td><td>Mem. (MB)</td><td>AP</td><td>AP50</td><td>AP75</td></tr><tr><td>PVTv2 (Wang et al.,2021b) PVTv2+LePE (Dong et al., 2021)</td><td>0.6 70.5 0.6 70.9</td><td>574 574</td><td>37.2 37.6</td><td>57.2 57.8</td><td>39.5 39.9</td></tr><tr><td>Swin (Liu et al., 2021)</td><td>0.6 70.5</td><td>308</td><td>35.3</td><td>54.2</td><td>37.4</td></tr><tr><td>Swin+LePE Focal Attention (Yang et al., 2021)</td><td>0.6 70.7 0.7 71.6</td><td>308 732</td><td>35.8 37.5</td><td>55.3 57.6</td><td>37.7 39.5</td></tr><tr><td>Focal Attention+LePE</td><td>0.7 71.5</td><td>732</td><td>37.1</td><td>57.0</td><td>39.4</td></tr><tr><td>QuadTree-B</td><td>0.6 72.0</td><td>339</td><td>38.4</td><td>58.8</td><td>41.1</td></tr></table>
160
+
161
+ # 4.2.2 OBJECT DETECTION
162
+
163
+ Settings. We experiment on the COCO dataset. All models are trained on COCO train 2017 (118k images) and evaluated on val 2017 (5k images). We initialize the quadtree backbone with the weights pre-trained on ImageNet. We adopt the same setting as PVTv2, training the model with a batch size of 16 and AdamW optimizer with an initial learning rate of $1 \times 1 0 ^ { - \overline { { 4 } } }$ for 12 epochs. We use the standard metric average precision to evaluate our method.
164
+
165
+ Results. We mainly compare our method with PVTv2, ResNet (He et al., 2016), and ResNeXt (Xie et al., 2017) using detection framework of RetinaNet (Lin et al., 2017), which are state-ofthe-art backbones for dense prediction. Table 4 lists the average precision of different methods and their backbone flops for images of resolution of $8 0 0 \times 1 , 3 3 3$ . Benefiting from the coarse to fine mechanism, a small $K$ is enough for our method. Thus, the computation can be reduced when using high resolution images. We can see that QuadTree-B achieves higher performance, but with much fewer flops than PVTv2. Our quadtree transformer also outperforms ResNet and ResNeXt. For example, QuadTree-B-b2 outperform ResNet101 and ResNeXt101-32x4d by 7.7 AP and 6.3 AP respectively with about $40 \%$ backbone flops reduction. We also show Mask-RCNN results (He et al., 2017) in Appendix. E.
166
+
167
+ # 4.3 COMPARISON WITH OTHER ATTENTION MECHANISMS
168
+
169
+ For a fair comparison with other attention mechanisms, we test these attention mechanisms under the same backbone and training settings. Specifically, we replace the original attention module in PVTv2-b0 with the attention method used in Swin Transformer and Focal Transformer. For more fair comparison, we adopt the same positional encoding LePE (Dong et al., 2021) to PVTv2, Swin and Focal transformer. As shown in Table 5, QuadTree attention obtain consistently better performance than Swin and PVTv2 in both classification task and detection task. Compared with focal attention, our method gets 0.9 higher AP in object detection, which might be because that QuadTree attention can always cover the whole images, while Focal attention only covers $1 / 6$ of the image in the first stage. More experiments on Swin-like architecture can be found in Appendix E.
170
+
171
+ For cross attention tasks, we also provide visualization of attention score as shown in Fig.5 in Appendix E. Our method can attend to much more related regions than PVT (Wang et al., 2021b) and Linear attention (Katharopoulos et al., 2020).
172
+
173
+ # 5 CONCLUSION
174
+
175
+ We introduce QuadTree Attention to reduce the computational complexity of vision transformers from quadratic to linear. Quadtree transformers build token pyramids and compute attention in a coarse-to-fine manner. At each level, top $K$ regions with the highest attention scores are selected, such that in finer level, computation in irrelevant regions can be quickly skipped. Quadtree attention can be applied to cross attention as well as self-attention. It achieves state-of-the-art performance in various tasks including feature matching, stereo, image classification, and object detection.
176
+
177
+ # REFERENCES
178
+
179
+ Abhishek Badki, Alejandro Troccoli, Kihwan Kim, Jan Kautz, Pradeep Sen, and Orazio Gallo. Bi3d: Stereo depth estimation via binary classifications. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1600–1608, 2020.
180
+
181
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
182
+
183
+ Hongkai Chen, Zixin Luo, Jiahui Zhang, Lei Zhou, Xuyang Bai, Zeyu Hu, Chiew-Lan Tai, and Long Quan. Learning to match features with seeded graph matching network. arXiv preprint arXiv:2108.08771, 2021.
184
+
185
+ Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020.
186
+
187
+ Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. Advances in neural information processing systems, 26:2292–2300, 2013.
188
+
189
+ Angela Dai, Angel X Chang, Manolis Savva, Maciej Halber, Thomas Funkhouser, and Matthias Nießner. Scannet: Richly-annotated 3d reconstructions of indoor scenes. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5828–5839, 2017.
190
+
191
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
192
+
193
+ Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. Superpoint: Self-supervised interest point detection and description. In Proceedings of the IEEE conference on computer vision and pattern recognition workshops, pp. 224–236, 2018.
194
+
195
+ Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, and Baining Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows. arXiv preprint arXiv:2107.00652, 2021.
196
+
197
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
198
+
199
+ Hugo Germain, Vincent Lepetit, and Guillaume Bourmaud. Visual correspondence hallucination: Towards geometric reasoning. arXiv preprint arXiv:2106.09711, 2021.
200
+
201
+ Xiaoyang Guo, Kai Yang, Wukui Yang, Xiaogang Wang, and Hongsheng Li. Group-wise correlation stereo network. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3273–3282, 2019.
202
+
203
+ Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. arXiv preprint arXiv:2103.00112, 2021.
204
+
205
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
206
+
207
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ Proceedings of the IEEE international conference on computer vision, pp. 2961–2969, 2017.
208
+
209
+ Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and Franc¸ois Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pp. 5156–5165. PMLR, 2020.
210
+
211
+ Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In International Conference on Machine Learning, pp. 3744–3753. PMLR, 2019.
212
+
213
+ Xinghui Li, Kai Han, Shuda Li, and Victor Prisacariu. Dual-resolution correspondence networks. Advances in Neural Information Processing Systems, 33, 2020.
214
+
215
+ Zhaoshuo Li, Xingtong Liu, Nathan Drenkow, Andy Ding, Francis X Creighton, Russell H Taylor, and Mathias Unberath. Revisiting stereo depth estimation from a sequence-to-sequence perspective with transformers. IEEE/CVF International Conference on Computer Vision, 2021.
216
+
217
+ Zhengqi Li and Noah Snavely. Megadepth: Learning single-view depth prediction from internet photos. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2041–2050, 2018.
218
+
219
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ European conference on computer vision, pp. 740–755. Springer, 2014.
220
+
221
+ Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense ´ object detection. In Proceedings of the IEEE international conference on computer vision, pp. 2980–2988, 2017.
222
+
223
+ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021.
224
+
225
+ Zixin Luo, Tianwei Shen, Lei Zhou, Jiahui Zhang, Yao Yao, Shiwei Li, Tian Fang, and Long Quan. Contextdesc: Local descriptor augmentation with cross-modality context. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2527–2536, 2019.
226
+
227
+ Nikolaus Mayer, Eddy Ilg, Philip Hausser, Philipp Fischer, Daniel Cremers, Alexey Dosovitskiy, and Thomas Brox. A large dataset to train convolutional networks for disparity, optical flow, and scene flow estimation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4040–4048, 2016.
228
+
229
+ Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428–10436, 2020.
230
+
231
+ Rene Ranftl, Alexey Bochkovskiy, and Vladlen Koltun. Vision transformers for dense prediction.´ arXiv preprint arXiv:2103.13413, 2021.
232
+
233
+ Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. Superglue: Learning feature matching with graph neural networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 4938–4947, 2020.
234
+
235
+ Wenqi Shao, Shitao Tang, Xingang Pan, Ping Tan, Xiaogang Wang, and Ping Luo. Channel equilibrium networks for learning deep representation. In International Conference on Machine Learning, pp. 8645–8654. PMLR, 2020.
236
+
237
+ Wenqi Shao, Yixiao Ge, Zhaoyang Zhang, Xuyuan Xu, Xiaogang Wang, Ying Shan, and Ping Luo. Dynamic token normalization improves vision transformer. arXiv preprint arXiv:2112.02624, 2021.
238
+
239
+ Jiaming Sun, Zehong Shen, Yuang Wang, Hujun Bao, and Xiaowei Zhou. Loftr: Detector-free local feature matching with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8922–8931, 2021.
240
+
241
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. In ´ International Conference on Machine Learning, pp. 10347–10357. PMLR, 2021.
242
+
243
+ Pichao Wang, Xue Wang, Fan Wang, Ming Lin, Shuning Chang, Wen Xie, Hao Li, and Rong Jin. Kvt: $\mathbf { k }$ -nn attention for boosting vision transformers. arXiv preprint arXiv:2106.00515, 2021a.
244
+
245
+ Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020.
246
+
247
+ Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pvtv2: Improved baselines with pyramid vision transformer. arXiv preprint arXiv:2106.13797, 2021b.
248
+
249
+ Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021c.
250
+
251
+ Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021.
252
+
253
+ Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual trans- ´ formations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1492–1500, 2017.
254
+
255
+ Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Xiyang Dai, Bin Xiao, Lu Yuan, and Jianfeng Gao. Focal self-attention for local-global interactions in vision transformers. arXiv preprint arXiv:2107.00641, 2021.
256
+
257
+ Rex Ying, Jiaxuan You, Christopher Morris, Xiang Ren, William L Hamilton, and Jure Leskovec. Hierarchical graph representation learning with differentiable pooling. arXiv preprint arXiv:1806.08804, 2018.
258
+
259
+ Kun Yuan, Shaopeng Guo, Ziwei Liu, Aojun Zhou, Fengwei Yu, and Wei Wu. Incorporating convolution designs into visual transformers. arXiv preprint arXiv:2103.11816, 2021a.
260
+
261
+ Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Zihang Jiang, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. arXiv preprint arXiv:2101.11986, 2021b.
262
+
263
+ Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. In NeurIPS, 2020.
264
+
265
+ Feihu Zhang, Victor Prisacariu, Ruigang Yang, and Philip HS Torr. Ga-net: Guided aggregation net for end-to-end stereo matching. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 185–194, 2019a.
266
+
267
+ Jiahui Zhang, Dawei Sun, Zixin Luo, Anbang Yao, Lei Zhou, Tianwei Shen, Yurong Chen, Long Quan, and Hongen Liao. Learning two-view correspondences and geometry using order-aware network. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 5845–5854, 2019b.
268
+
269
+ Guangxiang Zhao, Junyang Lin, Zhiyuan Zhang, Xuancheng Ren, Qi Su, and Xu Sun. Explicit sparse transformer: Concentrated attention through explicit selection. arXiv preprint arXiv:1912.11637, 2019.
270
+
271
+ # A APPENDIX
272
+
273
+ # A.1 COMPLEXITY ANALYSIS
274
+
275
+ In this section, we analyze the computational complexity of quadtree attention. Suppose the lengths of the query tokens, key tokens, and value tokens are all $H \times W$ . We build token pyramids of $L$ levels, the $\bar { l } ^ { t h }$ level has a token length of $\frac { H W } { 4 ^ { l - 1 } }$ . The flops of computing quadtree attention is,
276
+
277
+ $$
278
+ \begin{array} { l } { { \displaystyle { \mathrm { F l o p s } } = 2 ( H _ { 0 } ^ { 2 } W _ { 0 } ^ { 2 } + \sum _ { l = 2 } ^ { L - 1 } \frac { 4 K H W } { 4 ^ { l - 1 } } ) } } \\ { { \displaystyle ~ = 2 ( H _ { 0 } ^ { 2 } W _ { 0 } ^ { 2 } + \frac { 4 } { 3 } ( 1 - 4 ^ { 1 - L } ) K H W ) . } } \end{array}
279
+ $$
280
+
281
+ Here, $H _ { 0 }$ and $W _ { 0 }$ are the height and width of the coarsest level of token pyramids. Therefore, $H _ { 0 } ^ { 2 } W _ { 0 } ^ { 2 }$ is a constant and the computational complexity is $O ( K H W )$ . Since $K$ is a constant number, the complexity of quadtree attention is linear to the number of tokens.
282
+
283
+ Table 6: Feature matching results on megadepth. Our method obtains better performance than other methods.
284
+
285
+ <table><tr><td></td><td>AUC@5°</td><td>AUC@10°</td><td>AUC@20°</td></tr><tr><td>DRC-Net (Li et al., 2020)</td><td>27.0</td><td>43.0</td><td>58.3</td></tr><tr><td>SuperPoint + SuperGlue (Sarlin et al., 2020)</td><td>42.2</td><td>61.2</td><td>76.0</td></tr><tr><td>LoFTR (Sun et al., 2021)</td><td>52.8</td><td>69.2</td><td>81.2</td></tr><tr><td>QuadTree-B (ours, K=16)</td><td>54.6</td><td>70.5</td><td>82.2</td></tr></table>
286
+
287
+ # B ADDITIONAL EXPERIMENTS AND IMPLEMENTATION DETAILS
288
+
289
+ # B.1 FEATURE MATCHING
290
+
291
+ Implementation details. We train and evaluate the model in ScanNet (Dai et al., 2017), where 230M image pairs is sampled for training, with overlapping scores between 0.4 and 0.8. ScanNet provides RGB images, depth maps, and ground truth camera poses on a well-defined training and testing split. Following the same evaluation settings as Sarlin et al. (2020) and Sun et al. (2021), we evaluate our method on the 1,500 testing pairs from (Sarlin et al., 2020). For both trainig and testing, all images and depth maps are resized to $6 4 0 \times 4 8 0$ . Following (Sun et al., 2021), we compute the camera pose by solving the essential matrix from predicted matches with RANSAC. We report the AUC of the pose error at thresholds $( 5 ^ { \circ } , 1 0 ^ { \circ } , 2 0 ^ { \circ } )$ , where the pose error is defined as the maximum of angular error in rotation and translation. We only replace the coarse level transformer with quadtree attention.
292
+
293
+ Results of megadepth. We show our results on Megadepth (Li & Snavely, 2018) in Table 6. We can see our method outperforms others by a large margin.
294
+
295
+ # B.2 STEREO MATCHING
296
+
297
+ Our network is based on the STTR (Li et al., 2021), where we replace the standard transformer with our quadtree transformer. The network consists of a CNN backbone which outputs feature maps of 1/2 image resolution, a quadtree transformer with both self- and cross attention, a regression head with optimal transport layers (Cuturi, 2013), and a context adjust layer to refine the disparity. Six self- and cross attention layers are used with 128 channels. We build pyramids with four levels for quadtree attention, and apply the Sinkhorn algorithm (Cuturi, 2013) for 10 iteration for optimal transport. We follow STTR to train the network, with 15 epochs of AdamW optimizer. OneCycle learning rate scheduler is used with a leaning rate of 6e-4 and a batch size of 8.
298
+
299
+ # B.3 IMAGE CLASSIFICATION
300
+
301
+ This paragraph introduces the details of PVTv2-b0, b1, b2, b3, b4. All these five networks have 4 stages. Each stage is dolutions for each stage are $\begin{array} { r } { \frac { H } { 4 } \times \frac { W } { 4 } , \frac { H } { 8 } \times \frac { W } { 8 } , \frac { H } { 1 6 } \times \frac { W } { 1 6 } } \end{array}$ ous sand $\frac { H } { 3 2 } \times \frac { W } { 3 2 }$ a stride of 2. The ferespectively, where $H$ re reand $W$ is the image height and width. For each stage, $M$ quadtree transformers are used with a channel number of $I$ and head number of $J$ . For the network PVTv2-b0, the parameters $M , I , J$ are set to [2, 2, 2, 2], [32, 64, 160, 256], $[ 1 , 2 , 5 , 8 ]$ at each stage respectively. For the network PVTv2-b1, the parameters $M$ , $I$ , $J$ are set to $[ 2 , 2 , 2 , 2 ]$ , [64, 128, 320, 512], $[ 1 , 2 , 5 , 8 ]$ respectively. For PVTv2-b2, the parameters $M , I , J$ are set to $[ 3 , 4 , 6 , 3 ]$ , [64, 128, 320, 512], $[ 1 , 2 , 5 , 8 ]$ respectively. For PVTv2- b3, the parameters $M$ , I , $J$ are set to [3, 4, 18, 3], [64, 128, 320, 512], $[ 1 , 2 , 5 , 8 ]$ respectively. For PVTv2-b4, the parameters $M , I , J$ are set to [3, 8, 27, 3], [64, 128, 320, 512], $[ 1 , 2 , 5 , 8 ]$ respectively.
302
+
303
+ # B.4 OBJECT DETECTION AND INSTANCE SEGMENTATION
304
+
305
+ We show the object detection and instance segmentation results of Mask-RCNN (He et al., 2017) in Table 7 and Table 8 in different training settings. In Table 7, we train Mask-RCNN for 12 epoch and resize the image to $8 0 0 \times 1 3 3 3$ while In Table 8, we train the model for 36 epochs and resize the training images to different scales for data augmentation. We can see that the QuadTree attention obtains consistently better performance than other methods.
306
+
307
+ Table 7: Object detection results on COCO val2017 with Mask-RCNN. We use PVTv2 backbone and replace the reduction attention with quadtree attention.
308
+
309
+ <table><tr><td></td><td>AP6</td><td>AP</td><td>AP75</td><td>APm</td><td>AP6</td><td>AP</td></tr><tr><td>PVTv2-b0 (Wang et al.,2021b) QuadTree-B-b0 (K=32,ours)</td><td>38.2 38.8</td><td>60.5 60.7</td><td>40.7 42.1</td><td>36.2 36.5</td><td>57.8 58.0</td><td>38.6 39.1</td></tr><tr><td>ResNet18 (He et al., 2016) PVTv1-Tiny (Wang et al.,2021c) PVTv2-b1 (Wang et al.,2021b) Quadtree-B-b1 (K=32,ours) ResNet50 (He et al., 2016)</td><td>34.0 36.7 41.8 43.5 38.0 40.4</td><td>54.0 59.2 64.3 65.6 58.6 61.1</td><td>36.7 39.3 45.9 47.6 41.4 44.2</td><td>31.2 35.1 38.8 40.1 34.4 36.4</td><td>51.0 56.7 61.2 62.6 55.1 57.7</td><td>32.7 37.3 41.6 43.3 36.7</td></tr><tr><td>PVTv2-b2 (Wang et al.,2021b) QuadTree-B-b2 (K=32,ours) PVTv1-Medium (Wang et al., 2021c) PVTv2-b3 (Wang et al.,2021b) QuadTree-B-b3</td><td>40.4 45.3 46.7 42.0 45.9 48.3</td><td>62.9 67.1 68.5 64.4 66.8 69.6</td><td>43.8 49.6 51.2 45.6 49.3 52.8</td><td>37.8 41.2 42.4 39.0 28.6 43.3</td><td>60.1 64.2 65.7 61.6 49.8 66.8</td><td>40.2 40.3 44.4 45.7 42.1 61.4 46.6</td></tr><tr><td>PVTv1-Large (Wang et al., 2021c) PVTv2-b4 (Wang et al.,2021b) QuadTree-B-b4</td><td>42.9 47.5 48.6</td><td>65.0 68.7 69.5</td><td>46.6 52.0 53.3</td><td>39.5 42.7 43.6</td><td>61.9 66.1 66.9</td><td>42.5 46.1 47.4</td></tr></table>
310
+
311
+ Table 8: Object detection results on COCO val2017 with Mask-RCNN training with 36 epochs and multi-scale data argumentation strategy. We use PVTv2 backbone and replace the reduction attention with quadtree attention.
312
+
313
+ <table><tr><td></td><td>#Params</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>QuadTree-B-b0</td><td>23.4</td><td>42.4</td><td>64.5</td><td>45.9</td><td>38.9</td><td>61.6</td><td>41.6</td></tr><tr><td>QuadTree-B-b1</td><td>33.3</td><td>46.4</td><td>68.6</td><td>50.7</td><td>41.9</td><td>65.6</td><td>44.7</td></tr><tr><td>Swin-T (Liu et al., 2021) Focal-T (Yang et al., 2021)</td><td>47.8 48.8</td><td>46.0</td><td>68.1</td><td>50.3</td><td>41.6</td><td>65.1</td><td>44.9</td></tr><tr><td>QuadTree-B-b2</td><td>44.8</td><td>47.2 49.3</td><td>69.4 70.7</td><td>51.9 53.9</td><td>42.7 43.9</td><td>66.5 67.6</td><td>45.9 47.4</td></tr><tr><td>Swin-S (Liu et al., 2021)</td><td>69.1</td><td>48.5</td><td>70.2</td><td>53.5</td><td>43.3</td><td>67.3</td><td>46.6</td></tr><tr><td>Focal-S Yang et al. (2021)</td><td>71.2</td><td>48.8</td><td>70.5</td><td>53.6</td><td>43.8</td><td>67.7</td><td>47.2</td></tr><tr><td>QuadTree-B-b3</td><td>70.0</td><td>49.6</td><td>70.4</td><td>54.2</td><td>44.0</td><td>67.7</td><td>47.5</td></tr></table>
314
+
315
+ ![](images/89d11d209acd1c1fe2b07560fde2712e453f895f3126d55dc3944bf5a957a133.jpg)
316
+ Figure 3: Loss and AUC $@ 2 0 ^ { \circ }$ of image matching.
317
+
318
+ ![](images/3632a0b69b8ac8d2dfdc0794935b1ce26624e63c6be3b409a01fe41dc724a60e.jpg)
319
+ Figure 4: Loss and top 1 accuracy of image classification for PVTv2-b0 archtecture.
320
+
321
+ <table><tr><td></td><td colspan="3">ImageNet</td><td colspan="3">COCO (RetinaNet)</td></tr><tr><td></td><td>Param. (M)</td><td>Flops (G)</td><td>Top1 (%)</td><td>AP</td><td>AP50</td><td>AP75</td></tr><tr><td>Swin-T (Liu et al., 2021)</td><td>29</td><td>4.5</td><td>81.3</td><td>42.0</td><td></td><td>/</td></tr><tr><td>Focal-T (Yang et al., 2021)</td><td>29</td><td>4.9</td><td>82.2</td><td>43.7</td><td>1</td><td></td></tr><tr><td>Quadtree-B</td><td>30</td><td>4.6</td><td>82.2</td><td>44.6</td><td>65.8</td><td>47.7</td></tr></table>
322
+
323
+ Table 9: Comparison under Swin-T settings in image classification and object detection.
324
+
325
+ # C TRAINING LOSS
326
+
327
+ Feature matching. We plot the training loss and validation performance for LoFTR-lite in Figure 3 for different efficient transformers, including spatial reduction (SR) transformer (Wang et al., 2021c), linear transformer (Katharopoulos et al., 2020), our Quadtree-A, and Quadtree-B transformers. We can see quadtree-B transformer obtains consistently lower training loss and higher performance over other three transformers. In addition, it is also noted that the spatial reduction (SR) transformer has lower training but worse AUC $@ 2 0 ^ { \circ }$ than QuadTree-A attention, which indicates that it cannot generalize well.
328
+
329
+ Image classification. We also show traning and validation curve for image classification task with respective to different attentions in Fig. 4. Compared with Swin Transformer (Liu et al., 2021) and PVT (Wang et al., 2021c), the loss of Quadtree attention is consistently lower and the top 1 accuracy is higher.
330
+
331
+ # D RUNNING TIME
332
+
333
+ Currently, we only implement a naive CUDA kernel without many optimizations and it is not as efficient as the well-optimized dense GPU matrix operation. We test the running time of Retinanet under PVTv2-b0 architecture. For PVTv2-b0, The running time is 0.026s to forward one image and for Quadtree-b0, the running time is 0.046s for forwarding once. However, Quadtree-b0 has much lower memory usage than PVTv2-b0. Quadtree-b0 consumes about 339MB while PVTv2-b0 consumes about 574MB for one $8 0 0 \times 1 3 3 3$ image.
334
+
335
+ # E ABLATIONS
336
+
337
+ QuadTree-A vs QuadTree-B. QuadTree-B architecture consistently outperforms QuadTree-A in feature matching, image classification, and detection experiments. We analyze its reason as shown in Figure 5, where (d) and (e) show the attention score maps of QuadTree-A and QuadTree-B at different levels for the same point in the query image shown in (a). It is clear that the QuadTree-B has more accurate score maps, and is less affected by the inaccuracy in coarse level score estimation. We further visualize the attention scores of spatial reduction (SR) attention (Wang et al., 2021c) and linear transformer (Katharopoulos et al., 2020) in (b) and (c). We can see that SR attention and linear transformer attend the query token on large unrelated regions due to the loss of fine-grained information. In contrast, our quadtree transformer focus on the most relevant area.
338
+
339
+ ![](images/31e873488f53c6f34cce2e070891bb462d7027ed928708b3aff8b427aa8afe6b.jpg)
340
+ Figure 5: Score map visualization of different attention methods for one patch in the query image. The first row shows score maps of spatial reduction attention and linear attention. The second row shows score maps of QuadTree-A and QuadTree-B at different levels, and the left image is the coarsest level, while the right image is the finest level for both sub-figures.
341
+
342
+ Table 10: Ablation on multiscale position encoding.
343
+
344
+ <table><tr><td colspan="3">ImageNet</td><td colspan="2">COCO (RetinaNet)</td></tr><tr><td></td><td>Flops (G)</td><td>Top 1(%)</td><td>AP AP50</td><td>AP75</td></tr><tr><td>Quadtree-B-b2</td><td>4.3</td><td>82.6</td><td>44.9 66.2</td><td>47.7</td></tr><tr><td>Quadtree-B-b2+MPE</td><td>4.3</td><td>82.7</td><td>46.2 67.2</td><td>49.5</td></tr></table>
345
+
346
+ Comparison with Swin Transformer and Focal Transformer. We compare with Swin Transformer and Focal Transformer in Table. 9 using the released codes. We replace the corresponding attention in Swin Transformer with Quadtree-B attention. Our method obtains $0 . 9 \%$ higher top 1 accuracy than Swin Transformer and $2 . 6 \%$ higher AP in object detection. Compared with Focal transformer, quadtree attention achieve the same top 1 accuracy in classification with fewer flops, and $0 . 9 \%$ higher AP in object detection.
347
+
348
+ Multiscale position encoding. We compare our method with or without multiscale position encoding (MPE). For Quadtree-B-b2 model, MPE can bring an improvement of 1.3 on object detection.
349
+
350
+ Top $K$ numbers. Table 11 and Table 12 shows the performance of QuadTree-B architecture with different value of $K$ for object detection and feature matching respectively. The performance is improved when $K$ becomes larger and saturates quickly. This indicates only a few tokens with high attention scores should be subdivided in the next level for computing attentions.
351
+
352
+ Table 11: The performance of QuadTree-B under different $K$ in object detection.
353
+
354
+ <table><tr><td></td><td>AP</td><td>AP50</td><td>AP75</td></tr><tr><td>K=1</td><td>37.3</td><td>57.2</td><td>39.4</td></tr><tr><td>K=8</td><td>38.0</td><td>58.2</td><td>40.4</td></tr><tr><td>K=16</td><td>38.4</td><td>58.7</td><td>41.1</td></tr><tr><td>K=32</td><td>38.5</td><td>58.8</td><td>41.1</td></tr></table>
355
+
356
+ Table 12: The performance of QuadTree-B under different $K$ in feature matching
357
+
358
+ <table><tr><td></td><td>AUC@5°</td><td>AUC@10°</td><td>AUC@20°</td></tr><tr><td>K=1</td><td>15.7</td><td>32.3</td><td>48.9</td></tr><tr><td>K=4</td><td>16.2</td><td>33.3</td><td>50.8</td></tr><tr><td>K=8</td><td>17.4</td><td>34.4</td><td>51.6</td></tr><tr><td>K=16</td><td>17.7</td><td>34.6</td><td>51.7</td></tr></table>
md/dev/fxdvWG4rJe/fxdvWG4rJe.md ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Towards Making the Most of ChatGPT for Machine Translation
2
+
3
+ Keqin $\mathbf { P e n g } ^ { \diamondsuit , \Re }$ ∗, Liang $\mathbf { D i n g ^ { \Re } }$ †, Qihuang Zhong♯, Li Shenℜ Xuebo $\mathbf { L i u } ^ { \flat }$ , Min Zhang♭, Yuanxin Ouyang♢, Dacheng Tao♡
4
+
5
+ ♢Beihang University $\Re _ { \mathrm { J D } }$ Explore Academy ♯Wuhan University ♡The University of Sydney ♭Harbin Institute of Technology, Shenzhen keqin.peng@buaa.edu.cn, liangding.liam@gmail.com
6
+
7
+ https://github.com/Romainpkq/ChatGPT4MT
8
+
9
+ # Abstract
10
+
11
+ ChatGPT shows remarkable capabilities for machine translation (MT). Several prior studies have shown that it achieves comparable results to commercial systems for high-resource languages, but lags behind in complex tasks, e.g., low-resource and distant-language-pairs translation. However, they usually adopt simple prompts which can not fully elicit the capability of ChatGPT. In this paper, we aim to further mine ChatGPT’s translation ability by revisiting several aspects: $\Updownarrow$ temperature, task information, and $\textcircled{9}$ domain information, and correspondingly propose an optimal temperature setting and two (simple but effective) prompts: Task-Specific Prompts (TSP) and Domain-Specific Prompts (DSP). We show that: $\bullet$ The performance of ChatGPT depends largely on temperature, and a lower temperature usually can achieve better performance; $\pmb { \varrho }$ Emphasizing the task information can further improve ChatGPT’s performance, particularly in complex MT tasks; $\pmb { \otimes }$ Introducing domain information can elicit ChatGPT’s generalization ability and improve its performance in the specific domain; $\bullet$ ChatGPT tends to generate hallucinations for non-English-centric MT tasks, which can be partially addressed by our proposed prompts but still need to be highlighted for the MT/NLP community. We also explore the effects of advanced in-context learning strategies and find a (negative but interesting) observation: the powerful chain-ofthought prompt leads to word-by-word translation behavior, thus bringing significant translation degradation.
12
+
13
+ # 1 Introduction
14
+
15
+ Recently, the emergence of $\mathrm { C h a t G P T ^ { 1 } }$ has brought remarkable influence on natural language processing (NLP) tasks. ChatGPT is a large-scale language model developed by OpenAI, based on InstructGPT (Ouyang et al., 2022a), that has been trained to follow instructions with human feedback. ChatGPT possesses diverse abilities of NLP, including question answering, dialogue generation, code debugging, generation evaluation, and so on (Qin et al., 2023; Zhong et al., 2023; Wang et al., 2023a; Kocmi and Federmann, 2023; Lu et al., 2023b; Wang et al., 2023b). We are particularly interested in how well ChatGPT can perform on the machine translation task.
16
+
17
+ Previous studies (Jiao et al., 2023; Hendy et al., 2023) on translation tasks have found that ChatGPT performs competitively with commercial translation products (e.g., Google Translate and Microsoft Translator) on high-resource languages, but has limited capabilities for low-resource and distant languages. However, they only adopt simple prompts and basic settings regardless of the significant influence of the prompts’ quality (Zhou et al., 2022), which may limit ChatGPT’s performance. In this paper, we aim to further elicit the capability of ChatGPT by revisiting the following three aspects and correspondingly propose an optimal temperature setting and two simple but effective prompts: Task-Specific Prompts (TSP) and Domain-Specific Prompts (DSP).
18
+
19
+ $\Updownarrow$ Temperature. Temperature is an important parameter to ensure ChatGPT generates varied responses to human queries. Basically, decoding with higher temperatures displays greater linguistic variety, while the low one generates grammatically correct and deterministic text (Ippolito et al., 2019). However, for tasks with a high degree of certainty, such as machine translation, we argue, a diverse generation may impede its translation quality. We evaluate the performance of ChatGPT at different temperatures to verify its effect and find the optimal temperature setting for the following experiments.
20
+
21
+ C Task Information. ChatGPT is fine-tuned on high-quality chat datasets and thus essentially a conversational system that has a certain distance from the translation system, we argue that the task inconsistency will limit its translation ability to a certain degree. In response to this problem, we proposed Task-Specific Prompts (TSP) to further emphasize the task information to bridge the task gap, i.e., conversation and translation.
22
+
23
+ $\circledcirc$ Domain Information. Compared with traditional machine translation systems, ChatGPT can incorporate additional information, like human interactions, through the input prompts (Dong et al., 2023). We argue that such flexible interaction may alleviate some classical MT challenges, e.g., crossdomain generalization (Koehn and Knowles, 2017). We, therefore, propose Domain-Specific Prompts (DSP) to introduce the domain navigation information to elicit ChatGPT’s generalization ability across different domains.
24
+
25
+ Through extensive experiments, we find that:
26
+
27
+ ChatGPT’s performance largely depends on the temperatures, especially in difficult languages. Generally, setting a lower temperature can result in higher performance.
28
+
29
+ Emphasizing the task information in prompts can further improve ChatGPT’s performance, especially in complex tasks.
30
+
31
+ ![](images/c4f6826f87be0b709054a02ccadf67b673c0ce84375de49db89a06e27aeed381.jpg)
32
+
33
+ Introducing the correct domain information consistently improves ChatGPT’s performance while wrong domain information leads to significant degradation in performance.
34
+
35
+ A When tackling the non-English-centric tasks (both the input and expected output are nonEnglish), ChatGPT may generate hallucinations, which should be paid more attention to by the MT/NLP community.
36
+
37
+ Furthermore, we explore the effects of several advanced in-context learning strategies (Brown et al., 2020b). Specifically, we investigate ChatGPT’s few-shot in-context learning (ICL) and chain-ofthought (CoT) (Wei et al., 2022c; Kojima et al., 2022) abilities on MT tasks. Experimental results show that few-shot ICL can further improve ChatGPT’s performance, which is identical to the findings of Hendy et al. (2023), and we also find a negative but interesting observation: CoT leads to word-by-word translation behavior, thus bringing significant translation degradation. Also, we call for improving ICL and CoT for MT upon ChatGPT by incorporating the philosophy of example-based and statistical MT (Nagao, 1984; Koehn, 2009).
38
+
39
+ Table 1: Data statistics and descriptions.
40
+
41
+ <table><tr><td>Test Set</td><td>Direction</td><td>Domain</td><td>Size</td></tr><tr><td>Flores-200</td><td>Any</td><td>General</td><td>1,012</td></tr><tr><td rowspan="3">WMT19 News</td><td>En→Zh</td><td>News</td><td>2,001</td></tr><tr><td>En=De</td><td></td><td>3,004</td></tr><tr><td>En→Zh</td><td>Biomedical</td><td>224</td></tr><tr><td>WMT19 Bio WMT22E-Commerce</td><td>Zh→En En→Zh</td><td>E-Commerce</td><td>241 530</td></tr></table>
42
+
43
+ The remainder of this paper is designed as follows. We present the evaluation settings in Section 2. In Section 3, we revisit the performance of ChatGPT from three aspects (temperature, task, and domain information) and show the zero-shot translation performance of ChatGPT with our proposed advanced prompt recipes. Section 4 summarizes the few-shot in-context learning and chain-ofthought results. Section 6 presents conclusions.
44
+
45
+ # 2 Evaluation Setting
46
+
47
+ We provide a brief introduction of the evaluation setting, which mainly includes the used models, test set, and evaluation metrics.
48
+
49
+ Models. We mainly compare ChatGPT2 with the commercial translation product Google Translator3, which supports translation in 133 languages. By default, the results in this paper come from the gpt3.5-turbo-0301 models, which power the ChatGPT.
50
+
51
+ Data. For multilingual translation and in-context learning, we evaluate the performance of the models on the Flores-200 (Goyal et al., $2 0 2 2 ) ^ { 4 }$ test sets, which consists of 1012 sentences translated into 204 languages. To evaluate the effect of cross-domain translation, we adopt the test set of WMT19 Biomedical (Bawden et al., 2019), News Translation Task (Barrault et al., 2019) and WMT22 E-Commerce task (Kocmi et al., 2022). Table 1 lists the statistics of these test sets. We test all samples through OpenAI API.
52
+
53
+ Metric. The translation metrics shared task (Freitag et al., 2022) recommends using neural networkbased metrics since they have demonstrated a high correlation with human evaluation and are resilient to domain shift. Hence, we adopt the mostly used COMET (Rei et al., 2020) as our primary metric and use the default parameters of "cometcompare" for significance test5. Specifically, we use the reference-based metric COMET-20 (wmt20- COMET-da). Additionally, we also report BLEU scores (Papineni et al., 2002) and ChrF (Popovic´, 2015) using SacreBLEU (Post, 2018) for completeness, but notably, we mainly analyze the performance in terms of model-based metric COMET.
54
+
55
+ Table 2: Multilingual translation prompts.
56
+
57
+ <table><tr><td>Method</td><td>Translation Prompt</td></tr><tr><td>ChatGPT</td><td>&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Please provide the [TGT] translation for the</td><td></td></tr><tr><td>ChatGPT+TSP</td><td>following sentence:&quot; &quot;role&quot;: &quot;system&quot;,</td><td>&quot;content&quot;: &quot;You</td></tr><tr><td></td><td>are a machine translation system.&quot;,</td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td>&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Please</td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td>provide the [TGT] translation for the</td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td>following sentence:&quot;</td><td></td></tr></table>
58
+
59
+ # 3 Zero-Shot Translation
60
+
61
+ In this section, we explore the performance of ChatGPT from three aspects: TEMPERATURE, TASK INFORMATION, and DOMAIN INFORMATION, and correspondingly propose an optimal temperature setting and two simple and effective prompts to improve ChatGPT’s performance.
62
+
63
+ # 3.1 The Effect of Temperature
64
+
65
+ ChatGPT is a chatting machine designed to provide fluent and diverse responses to a wide range of human requests. It is intuitive that the diversity of responses may hinder its performance on tasks with a high degree of certainty, such as machine translation, to some extent.
66
+
67
+ To investigate the influence of diversity, we compare the performance of ChatGPT in different temperature settings, including 0, 0.2, 0.4, 0.6, 0.8, and 1, across three translation directions: English $\Rightarrow$ Romanian, English $\Rightarrow$ Chinese, and English $\Rightarrow$ German. The relationship between temperature and performance of ChatGPT is shown in Figure 1 and 2.
68
+
69
+ Results. Figure 1 and 2 show that ChatGPT’s performance largely depends on the value of temperatures, and as the temperature rises, there is a clear degradation both in COMET and BLEU scores. Furthermore, it is noteworthy that ChatGPT’s sensitivity to the temperature varies depending on the language pair: the impact of temperature is relatively small when translating to high-resource languages, e.g., German, while for complex languages, e.g., Chinese, it has a large degradation in performance $( - 4 . 3$ COEMT points and $- 3 . 7$ BLEU points for Chinese) when the temperature changes from 0 to 1. We speculate that the huge resource variance in training data leads to differences in the confidence of languages, which partially explains the different performances. In the following experiments, we adopt $T = 0$ as our default setting to make the most of ChatGPT and ensure the stability of generation to avoid a result of noise.
70
+
71
+ ![](images/34110cbde9775418228fb0c4f46fe4b73035cc4be49c5dd3d6c8f1c8d0f34bcc.jpg)
72
+ Figure 1: The relationship between temperature and ChatGPT’s performance (in terms of COMET scores) when translating from English to other languages.
73
+
74
+ ![](images/5f78ad2812a11bfc973057141a725953ceb4bd737e3cb40608041067d53a9ce7.jpg)
75
+ Figure 2: The relationship between temperature and ChatGPT’s performance (in terms of BLEU scores) when translating from English to other languages.
76
+
77
+ <table><tr><td>System</td><td>COMET</td><td>BLEU ChrF</td><td>COMET</td><td>BLEU</td><td>ChrF</td></tr><tr><td rowspan="4">Google Translator ChatGPT ChatGPT+TSP</td><td>DE=EN</td><td></td><td></td><td>EN→DE</td><td></td></tr><tr><td>77.7</td><td>47.4</td><td>70.5</td><td>70.5</td><td>44.4 68.9</td></tr><tr><td>77.2</td><td>43.5</td><td>69.4 69.7</td><td>69.3 40.6</td><td>67.1</td></tr><tr><td>77.5t</td><td>44.1</td><td>69.4</td><td>40.4</td><td>67.0</td></tr><tr><td rowspan="4">Google Translator ChatGPT ChatGPT + TSP</td><td>ZH→EN</td><td></td><td></td><td>EN→ZH</td><td></td></tr><tr><td>73.5 71.3</td><td>33.5 26.4</td><td>61.2 58.3</td><td>68.5 66.4</td><td>48.8 43.8 45.1</td></tr><tr><td>71.5</td><td>26.7</td><td>58.4</td><td>67.2+ 45.3</td><td>39.0 39.3</td></tr><tr><td>RO→EN</td><td></td><td></td><td>EN→RO</td><td></td></tr><tr><td>Google Translator ChatGPT</td><td>82.4</td><td>48.0</td><td>71.2</td><td>91.6 43.3</td><td>67.0</td></tr><tr><td rowspan="4">ChatGPT + TSP</td><td>80.6</td><td>41.8</td><td>68.8</td><td>92.4</td><td>40.6 65.5</td></tr><tr><td>80.8</td><td>41.9</td><td>69.0</td><td>92.9†</td><td>40.8 65.7</td></tr><tr><td></td><td>ZH⇒RO</td><td></td><td>RO→ZH</td><td></td></tr><tr><td>73.9</td><td>25.8</td><td>53.9</td><td>62.3</td><td>42.3 37.8</td></tr><tr><td>Google Translator ChatGPT</td><td></td><td>20.9</td><td>51.5</td><td>58.9</td><td></td></tr><tr><td></td><td>73.8</td><td></td><td></td><td>37.7</td><td>33.3</td></tr><tr><td>ChatGPT+ TSP</td><td>74.1</td><td>21.0</td><td>51.3</td><td>59.1†</td><td>33.7</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>38.0</td></tr></table>
78
+
79
+ Table 3: Performance with different prompts on 4 language pairs from Flores-200. “TSP” denotes our proposed task-specific prompting method. The best scores across different systems are marked in bold and the best scores of ChatGPT are underlined. Notably, we set the temperature as 0 for ChatGPT in this experiment. We can see that our TSP method consistently boosts the performance of ChatGPT in most settings. Shadowed areas mean difficult English-centric translation tasks, Green areas mean non English-centric translation tasks. “†” indicates a statistically significant difference from the ChatGPT baseline $\lceil p < 0 . 0 5 )$ ).
80
+
81
+ # 3.2 The Effect of Task Information
82
+
83
+ Previous studies (Jiao et al., 2023; Hendy et al., 2023) have shown that ChatGPT can achieve exceptional performance in conversational domain translation, which is attributed to its ability to generate more natural and diverse spoken language. However, given that ChatGPT is deliberately designed as a general task solver (Qin et al., 2023), when asking the ChatGPT to perform as a specific task engine, there will arise a task gap. This task inconsistency may limit ChatGPT’s effectiveness in translation tasks other than the spoken domain.
84
+
85
+ To bridge the task gap and generate more translation-like sentences, we propose TaskSpecific Prompts (TSP) to emphasize the translation task information. Specifically, we prepend the sentence "You are a machine translation system." to the best translation template in Jiao et al. (2023), and adopt it to query ChatGPT. The templates of prompts present in Table 2, and [TGT] represents the target languages of translation.
86
+
87
+ We have compared the performance of various models on four language pairs, covering eight distinct translation directions. These languages comprise 1) German, which is one of the most nonEnglish languages in the GPT training data, 2) Romanian, a less frequently encountered non-English language in the GPT training data, and 3) Chinese, a large-scale language with a script distinct from
88
+
89
+ ![](images/ca9b47de8c347266c6be1bb4a4b3db6ee9c705f054d4af540eb03808322e96ab.jpg)
90
+ Figure 3: Number of Post-Edited sentences in nonEnglish-centric language pairs, where a higher value means the translation contains more hallucinations. RO represents the translation for $\mathrm { Z H } { \Rightarrow } \mathrm { R O }$ , while ZH represents the translation for ${ \mathrm { Z H } } { \Rightarrow } \mathrm { R O }$ .
91
+
92
+ English. We also adopt Chinese-Romanian as a non-English-centric use case. Table 3 lists the full results, where we list both English-centric and nonEnglish-centric language directions (marked with green ), and also, among English-centric directions, we highlight the difficult pairs (EN-ZH and EN-RO with shadow ) in terms of their resources and language distance.
93
+
94
+ # 3.2.1 English-Centric Language Pairs
95
+
96
+ We first consider the performance of ChatGPT in English-centric translation language pairs. Specifically, we conduct experiments in three language pairs: German $\Leftrightarrow$ English (highresource), Romanian $\Leftrightarrow$ English (low-resource), and Chinese $\Leftrightarrow$ English (distant language).
97
+
98
+ Results. Our results presented in Table 3 show that our TSP method achieves comparable results on COMET score compared to Google Translator and even outperforms it in some language pairs, e.g., English $\Rightarrow$ Romanian (92.9 v.s. 91.6). We also observe that our TSP method consistently improves the performance of vanilla ChatGPT, especially when translating to low-resource or distant languages. Specifically, our TSP method brings $+ 0 . 8$ and $+ 0 . 5$ COMET score improvements in English $\Rightarrow$ Chinese and English $\Rightarrow$ Romanian, respectively, and $+ 0 . 2$ on average when translating to English. We speculate that the high-resource training data can help the model better understand the specific task from a few task-related navigations, thereby reducing the need for additional taskspecific information. Although our proposed TSP consistently improves the performance in terms of semantic metric, i.e., COMTE, notably, we have not consistently bridged the task gap in terms of lexical metrics (BLEU and ChrF), which is consistent with similar findings from Vilar et al. (2022) on PALM-540B model.
99
+
100
+ # 3.2.2 Non-English-Centric Language Pairs
101
+
102
+ We also evaluate the performance of ChatGPT in non-English-centric language pairs (since the pretraining process was dominated by the English tokens and the multilingual MT community argues it may harm the non-English-centric performance (Costa-jussà et al., 2022; Zan et al., 2022a, 2023).). We have an important finding that, when tackling non-English-centric MT language pairs, ChatGPT tends to generate translation hallucinations, that is, some unrelated information obeyed some patterns followed the translation, such as "Translation may vary depending on context", which will greatly affect the MT performance. We used a post-processing method to remove irrelevant information from the generated text. Specifically, we summarize some templates about irrelevant sentences and remove them from the generation texts. Some templates are shown in Table 4 and the number of post-processed sentences is presented in Figure 3.
103
+
104
+ Table 4: Some templates about irrelevant information in generated sentences for Chinese $\Leftrightarrow$ Romanian. Semicolon is used to separate different templates. [Ro] represents the sentence in Romanian while [Zh] represents that in Chinese.
105
+
106
+ <table><tr><td>Target Language</td><td>Template</td></tr><tr><td>Chinese</td><td>[Ro] would be translated to: [Zh];</td></tr><tr><td>Romanian</td><td>[Zh] (Note: ) [Zh]] can betranslated into Romanian as [Ro]; [Ro] (Note: ..)</td></tr></table>
107
+
108
+ Results. Figure 3 shows that lower temperature can reduce the number of hallucinations (especially in distant languages, e.g., Chinese) and our TSP method can further reduce its number, which suggests that our method can help ChatGPT to better serve as a machine translation system. The full results on Romanian $\Leftrightarrow$ Chinese lists are in Table 3. As seen, our TSP method can only slightly improve ChatGPT’s performance, which could be due to the difficulty in both understanding and generating the language pairs. Meanwhile, our used post-editing approach could only roughly remove the hallucination patterns, the NLP/MT community should pay more attention to the potential hallucination when using ChatGPT to tackle the non-English text.
109
+
110
+ The subsequent experiments will use ChatGPT with TSP as the default setting.
111
+
112
+ # 3.3 The Effect of Domain Information
113
+
114
+ Compared with traditional machine translation systems, ChatGPT can incorporate additional information through the prompts to further improve its performance. While previous studies have shown that ChatGPT has great robust translation capabilities (Hendy et al., 2023), we believe that we can further enhance its performance by incorporating domain-specific guidance.
115
+
116
+ To this end, we propose Domain-Specific Prompts (DSP) that identify the domain information of translated sentences in prompts to facilitate ChatGPT’s generalization. Specifically, we ask ChatGPT with the following prompts "You are a machine translation system that translates sentences in the [DOM] domain", as shown in Table 5. Here, [DOM] represents the correct domain of the translated sentence, while [FDOM] represents the wrong domain of that, which is used to verify whether the improvement comes from domain information. For example, for a biomedical sentence, [DOM] is biomedical, while [FDOM] can be any field except biomedical.
117
+
118
+ Table 5: Domain-Specific translation prompts. “[DOM]” and “[FDOM]” denote the correct and incorrect domain instructions, respectively.
119
+
120
+ <table><tr><td>Method</td><td>Translation Prompt</td><td></td></tr><tr><td>ChatGPT</td><td>&quot;role&quot;: &quot;system&quot;, &quot;role&quot;:&quot;user&quot;,&#x27; following sentence:&#x27;</td><td>&quot;content&quot;: &quot;You are a machine translation system.&quot;, &quot;content&quot;:&#x27;Please provide the [TGT] translation for the</td></tr><tr><td>ChatGPT+DSP</td><td>&quot;role&quot;: &quot;system, are a machine translation system that translates sentences in the[DOM] domain.&quot;,&quot;role&quot;:&quot;user&quot;,&quot;content&quot;: &#x27;Please provide the [TGT] translation for the following sentence:&#x27;</td><td>&quot;content&quot;: &quot;You</td></tr><tr><td>ChatGPT+F-DSP</td><td>&quot;role&quot;: domain.&quot;,&quot;role&quot;:&quot;user&quot;,&quot;content&quot;: &#x27;Please provide the [TGT] translation for the following sentence:</td><td>&quot;&quot;system&quot;,&quot;content&quot;:&quot; &quot;You are a machine translation system that translates sentences in the [FDOM]</td></tr></table>
121
+
122
+ We evaluate our method on the WMT19 Bio and News datasets followed Jiao et al. (2023), which allows us to examine domain bias’s impact. For example, the WMT19 Bio test set comprises Medline abstracts that require domain-specific knowledge, while the WMT19 News dataset features news-style texts that are significantly different from dialogues. To further prove the effectiveness of our method, we conduct our method on WMT22 English-Chinese E-Commerce test set, which is less likely to overlap with the GPT training data.
123
+
124
+ Results. The results are listed in Table 6. Obviously, the original ChatGPT does not perform as well as Google Translator in both COMET and lexical metrics (e.g., BLEU). However, our DSP method can consistently improve the performance of ChatGPT in terms of COMET score and even outperforms Google Translator in two datasets (WMT19 Bio Chinese $\Rightarrow$ English and WMT19 News English $\Rightarrow$ Chinese). This finding indicates that our method can further improve the generalization ability of ChatGPT and narrow the gap with one of the most advanced commercial systems – Google Translator. Nonetheless, our method’s impact on BLEU is inconsistent, and it still lags significantly behind Google Translator’s performance.
125
+
126
+ To verify that the observed improvement is indeed due to the introduction of the domain information, we deliberately provided incorrect domain information for each sentence, namely $F – D S P$ , to attack the improvement brought by the DSP strategy. Specifically, We exchange domain information for the biomedical sentences and the news sentences. We expect that the wrong domain guidance (F-DSP) will under-perform the DSP, and even perform worse than the vanilla ChatGPT. The results of these experiments are shown in the last row of Table 6, which clearly shows a consistent degradation in COMET, proving that the domain information is the key to the success of our method.
127
+
128
+ All the above DSP and F-DSP results confirm the importance of domain-specific prompting guidance in using ChatGPT for MT tasks.
129
+
130
+ # 4 Few-shot Machine Translation
131
+
132
+ In this section, we simply explore the effects of advanced in-context learning (ICL) strategies, specifically, we investigate ChatGPT’s few-shot ICL and Chain-of-Thought (CoT) abilities on MT tasks.
133
+
134
+ # 4.1 Few-Shot In-Context learning
135
+
136
+ In-context learning (Brown et al., 2020b) has shown its remarkable ability for many NLP tasks (Liu et al., 2023). To further explore the capabilities of the ChatGPT, we conduct experiments with different sample selection strategies. Specifically, we evaluate the performance of few-shot machine translation in the following three directions: English $\Rightarrow$ Chinese, English $\Rightarrow$ Romanian, and English $\Rightarrow$ German in Flores-200. We conducted experiments with randomly and TopK (Liu et al., 2022) sampled demonstrations from development sets in the 1-shot and 3-shot settings.
137
+
138
+ Results. Our results are listed in Table 7. As seen, in-context learning with random examples consistently improves the performance in both lexical metric (BLEU) and COMET score compared to the zero-shot approach, and increasing the number of shots can lead to further improvement, which is consistent with previous finding (Hendy et al., 2023). The advanced sample-selection strategy like
139
+
140
+ Table 6: Performance of ChatGPT on translation robustness, i.e., different domains. “DSP” denotes our proposed domain-specific prompting method, while “F-DSP” denotes the false domain-specific prompting, i.e., we specify wrong/unrelated domain information in the prompt. The results in green denote that “DSP” improves ChatGPT by a clear margin (0.5 (↑) score), while the red results denote the significant performance drops caused by “F-DSP”. “†” indicates a statistically significant difference from the ChatGPT baseline $( p < 0 . 0 5 )$ .
141
+
142
+ <table><tr><td rowspan="3">System</td><td colspan="4">WMT19Bio</td><td colspan="4">WMT19News</td><td colspan="2">WMT22E-Commerce</td></tr><tr><td colspan="2">EN→ZH</td><td colspan="2">ZH→EN</td><td colspan="2">EN→ZH</td><td colspan="2">EN→DE</td><td colspan="2">EN→ZH</td></tr><tr><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td></tr><tr><td>Google Translator</td><td>59.4</td><td>38.8</td><td>59.4</td><td>36.1</td><td>59.3</td><td>43.4</td><td>64.1</td><td>33.7</td><td>71.7</td><td>48.0</td></tr><tr><td>ChatGPT</td><td>58.6</td><td>35.5</td><td>58.7</td><td>31.1</td><td>58.8</td><td>39.6</td><td>63.1</td><td>31.3</td><td>68.2</td><td>43.5</td></tr><tr><td>ChatGPT+DSP</td><td>58.9</td><td>35.8</td><td>59.6†</td><td>31.3</td><td>59.6†</td><td>39.8</td><td>63.2</td><td>31.5</td><td>68.6</td><td>43.8</td></tr><tr><td>ChatGPT+F-DSP</td><td>58.6</td><td>35.6</td><td>58.4</td><td>31.3</td><td>57.9</td><td>39.0</td><td>62.0</td><td>31.2</td><td>67.1</td><td>43.3</td></tr></table>
143
+
144
+ <table><tr><td rowspan="2"></td><td colspan="2">EN→ DE</td><td colspan="2">EN→ ZH</td><td colspan="2">EN→ RO</td></tr><tr><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td></tr><tr><td>Google Translator</td><td>70.5</td><td>44.4</td><td>68.5</td><td>48.8</td><td>91.6</td><td>43.3</td></tr><tr><td>ChatGPT</td><td>69.4</td><td>40.4</td><td>67.2</td><td>45.3</td><td>92.9</td><td>40.8</td></tr><tr><td colspan="7"> Random Sampling few-shot prompting</td></tr><tr><td>-w/ 1-shot</td><td>69.8</td><td>40.6</td><td>67.6</td><td>45.4</td><td>93.1</td><td>40.7</td></tr><tr><td>-w/ 3-shot</td><td>70.0</td><td>40.7</td><td>68.3</td><td>45.9</td><td>93.6</td><td>40.9</td></tr><tr><td colspan="7">TopK Sampling few-shot prompting</td></tr><tr><td>-w/ 1-shot</td><td>69.8</td><td>41.0</td><td>68.4</td><td>45.8</td><td>93.1</td><td>40.7</td></tr><tr><td>-w/ 3-shot</td><td>70.5</td><td>40.9</td><td>68.8</td><td>45.8</td><td>94.0</td><td>41.2</td></tr></table>
145
+
146
+ Table 7: Few-shot translation performance of ChatGPT on Flores-200. In the random sampling few-shot prompting setting, we randomly sample 1/3 examples from the development set with 3 runs. The best scores across different systems are marked in bold and the best scores of ChatGPT are underlined.
147
+
148
+ TopK, which chooses test-sample similar examples as demonstrations, can further improve the performance, even outperform Google Translator in some language pairs, e.g., English $\Rightarrow$ Romanian (94.0 v.s. 91.6) and English $\Rightarrow$ Chinese (68.8 v.s. 68.5).
149
+
150
+ We encouragingly find that the advanced sampleselection strategy for in-context learning for MT tasks upon ChatGPT is extremely similar to the design philosophy of example-based machine translation (EBMT, Nagao, 1984), where the EBMT is often characterized by its use of a bilingual corpus as its main knowledge base, at run-time. It is worthy of designing better ICL strategies inspired by EBMT in future work.
151
+
152
+ # 4.2 Chain-of-Thought
153
+
154
+ Chain-of-Thought (CoT) prompting (Wei et al., 2022c) has been demonstrated to be effective in eliciting the reasoning ability of large language models. Previous studies have shown that CoT can improve the ChatGPT’s performance in natural language understanding tasks (Zhong et al., 2023),
155
+
156
+ # but its influence on machine translation tasks has hardly been investigated.
157
+
158
+ To investigate this further, we randomly select 20 samples from the test set and adopt the zero-shot CoT technique (Kojima et al., 2022) and the 1-shot CoT technique. Specifically, as shown in Table 8, for zero-shot CoT, we use the prompt "Please provide the [TGT] translation for the following sentence step by step" to extract step-by-step translation. We also add the sentence ‘and then provide the complete sentence:’ to the end of the prompting to ensure that ChatGPT can generate the complete translation. While for the 1-shot CoT, we provide the manual intermediate reasoning steps inspired by zero-shot CoT, as shown in Table 8. Here, [S] and [T] represent the corresponding source and target sentence in the demonstration, respectively, and [S_i] and [T_i] are the i-th matching tokens in the source and target sentence.
159
+
160
+ Results. We conduct experiments in the following two translation directions: English $\Rightarrow$ German and English $\Rightarrow$ Chinese. The results are listed in Table 9, which shows that there is a significant degradation in COMET score with zero-shot CoT setting, especially in English $\Rightarrow$ Chinese, which drops 8.8 COMET points. 1-shot CoT prompting can consistently outperform zero-shot CoT but still lags behind zero-shot prompting on COMET.
161
+
162
+ Table 8: The templates of Zero-Shot CoT and 1-shot CoT. [S_n] represents the $n$ -th token in source demonstration [S], [T_n] represents the $n$ -th token in target demonstration [T].
163
+
164
+ <table><tr><td>Method</td><td>Translation Prompt</td></tr><tr><td></td><td>Zero-Shot CoT &quot;role&quot;:&quot;system&quot;,&quot;content&quot;:&quot;You area machine translation system.&quot;, &quot;role&quot;:&quot;user&quot;, &quot;content&quot;:&#x27;Please provide the German translation for the following sentence step by step and then provide the complete sentence:’</td></tr><tr><td>1-Shot CoT</td><td>&quot;role&quot;:&quot;system&quot;, &quot;content&quot;:&quot;You are a machine translation system.&quot;, &quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&#x27;Please provide the German translation for the following sentence step by step and then provide the complete sentence: [S]1.[S_1]-[T_1]2.[S_2]- [T_2]...n.[S_n]-[T_n] The complete sentence in [TGT] is:[T] Please provide the German translation for the following sentence step by step and then provide the complete sentence:&#x27;</td></tr></table>
165
+
166
+ Table 9: Performance of ChatGPT equipped with CoT prompting methods on randomly selected 20 samples from English $\Rightarrow$ German and English $\Rightarrow$ Chinese.
167
+
168
+ <table><tr><td rowspan="2">Method</td><td colspan="2">EN→DE</td><td colspan="2">EN→ZH</td></tr><tr><td>COMET</td><td>BLEU</td><td>COMET</td><td>BLEU</td></tr><tr><td>ChatGPT</td><td>72.4</td><td>36.5</td><td>68.3</td><td>41.4</td></tr><tr><td>-w zero-shot CoT</td><td>69.3 (↓3.1)</td><td>35.1(↓1.4)</td><td>59.5(18.8)</td><td>36.2(↓5.2)</td></tr><tr><td>-w 1-shot CoT</td><td>69.6 (↓2.8)</td><td>37.0 (10.5)</td><td>61.1 (↓7.2)</td><td>37.6 (↓3.8)</td></tr></table>
169
+
170
+ We looked in detail at the sentences generated by different prompts, presented in Table 10, and we have a negative but interesting observation: the CoT prompt leads to word-by-word translation behavior, which is the main reason for the significant translation degradation.
171
+
172
+ For more CoT variants designed with different principles inspired by the philosophy in statistical MT (Zens et al., 2002; Koehn, 2009) will be explored in the future. For example, word-by-word and then reordering the translation (Du and Way, 2017; Ding et al., 2020), phrase-to-phrase (Feng et al., 2018; Ding et al., 2021) and then reordering the translation, and structure-to-structure transla
173
+
174
+ # 5 Related Work
175
+
176
+ Large Language Models. Large language models (LLMs) usually refer to language models with hundreds of billions of parameters, which are trained on massive text data (Zhao et al., 2023). LLMs usually can be classified into three groups based on model architectures: 1) encoder-only LLMs (Devlin et al., 2019; Liu et al., 2019; Zhong et al., 2022), usually used for NLU tasks; 2) decoder-only LLMs (Radford et al., 2019; Brown et al., 2020a), more suitable for NLG tasks; and 3) encoder-decoder LLMs (Raffel et al., 2020; Lewis et al., 2020; Zan et al., 2022b; Peng et al., 2023), which can achieve better performance on conditional text generation tasks.
177
+
178
+ Traditionally, these PLMs can achieve remarkable performance in various natural language processing (NLP) tasks through fine-tuning on specific tasks. But with the scaling up and the development of LLMs (Brown et al., 2020a; Ouyang et al., 2022b), decoder-only LLMs exhibit remarkable zero-shot and few-shot abilities, denoted emergent abilities (Wei et al., 2022b), and achieve comparable results with other LLMs in NLU and conditional NLG tasks. Especially the emergency of ChatGPT, developed by OpenAI, takes LLMs a big step forward in both academia and industry. ChatGPT possesses diverse abilities of NLP and can generate human-like responses by instructiontuning (Wei et al., 2022a) and Reinforcement Learning from Human Feedback (RLHF) technique (Ouyang et al., 2022b).
179
+
180
+ ChatGPT for Machine Translation. The ability of ChatGPT has been widely studied in various domains (Qin et al., 2023; Zhong et al., 2023), but its ability on machine translation tasks has not been fully investigated. Jiao et al. (2023) and Hendy et al. (2023) first provided an evaluation on the performance of ChatGPT for machine translation, they found that ChatGPT can perform competitively with commercial translation products on high-resource European languages but lags behind significantly on low resource or distant languages. However, they usually adopt simple prompts and basic settings which cannot fully exploit the capabilities of ChatGPT, we first proposed that ChatGPT can achieve comparable results with proper settings and investigate how to make the most of ChatGPT for machine translation.
181
+
182
+ Subsequent work follows our work to further explore the performance of ChatGPT, Gao et al. (2023) and Lu et al. (2023a) introduce new information (e.g., POS or multilingual dictionaries), He et al. (2023) proposed a CoT-like framework to generation human-like translation.
183
+
184
+ # 6 Conclusion
185
+
186
+ In this paper, we investigate how to further mine ChatGPT’s translation ability from three perspectives, namely temperature, task, and domain information, and correspondingly propose an optimal temperature setting and two simple but effective prompts. We empirically demonstrated that there is a high correlation between temperature and ChatGPT’s performance, and a lower temperature usually can achieve better performance. Experimental results across various language pairs and domains proved the effectiveness of our proposed prompts. We further explore the effectiveness of advanced in-context learning strategies for ChatGPT, we find that the few-shot in-context learning method can consistently improve ChatGPT’s performance, while conventional Chain-of-Thought (CoT) prompting will degrade its performance because of its word-by-word translation behavior.
187
+
188
+ In future work, besides the aforementioned explorations (EBMT-inspired prompts designing, statistical MT-inspired chain-of-thought designing), we would like to investigate how to further elicit the ability of ChatGPT by designing more effective prompts (e.g., design human-like CoT to navigate the LLMs, and better demonstration selection algorithms in few-shot ICL) and investigate the ability of ChatGPT for more MT settings (e.g., document translation).
189
+
190
+ # Limitations
191
+
192
+ Our work has several potential limitations. First, we only propose some simple prompts that have not been carefully designed to investigate the capabilities of ChatGPT, which may not sufficiently elicit the power of ChatGPT. Second, we have not fully studied the performance of ChatGPT in fewshot scenarios, especially the effect of Chain-OfThought in machine translation. In future work, we would like to design different types of prompts to further improve ChatGPT’s performance in machine translation and conduct more in-depth analyses and discussions.
193
+
194
+ # Ethics Statement
195
+
196
+ We take ethical considerations very seriously and strictly adhere to the EMNLP Ethics Policy. This paper focuses on exploring the translation ability of ChatGPT on open-sourced machine translation datasets, not involving any ethics problem. Both the compared models and evaluation datasets used in this paper are publicly available and have been widely adopted by researchers. Therefore, we believe that this research will not pose ethical issues.
197
+
198
+ # References
199
+
200
+ Loïc Barrault, Ondrej Bojar, Marta R. Costa-jussà, et al. 2019. Findings of the 2019 conference on machine translation (WMT19). In WMT.
201
+
202
+ Rachel Bawden, Kevin Bretonnel Cohen, Cristian Grozea, et al. 2019. Findings of the WMT 2019 biomedical translation shared task: Evaluation for MEDLINE abstracts and biomedical terminologies. In WMT.
203
+
204
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. 2020a. Language models are few-shot learners. NeurIPS.
205
+
206
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, et al. 2020b. Language models are few-shot learners. In NeurIPS.
207
+
208
+ Marta R Costa-jussà, James Cross, Onur Çelebi, Maha Elbayad, Kenneth Heafield, Kevin Heffernan, Elahe Kalbassi, Janice Lam, Daniel Licht, Jean Maillard, et al. 2022. No language left behind: Scaling humancentered machine translation. arXiv preprint.
209
+
210
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL.
211
+
212
+ Liang Ding, Longyue Wang, Xuebo Liu, Derek F. Wong, Dacheng Tao, and Zhaopeng Tu. 2021. Progressive multi-granularity training for non-autoregressive translation. In Findings of ACL.
213
+
214
+ Liang Ding, Longyue Wang, and Dacheng Tao. 2020. Self-attention with cross-lingual position representation. In ACL.
215
+
216
+ Qingxiu Dong, Lei Li, Damai Dai, Ce Zheng, Zhiyong Wu, Baobao Chang, Xu Sun, Jingjing Xu, Lei Li, and Zhifang Sui. 2023. A survey on in-context learning. arXiv preprint.
217
+
218
+ Jinhua Du and Andy Way. 2017. Pre-reordering for neural machine translation: Helpful or harmful? Prague Bulletin of Mathematical Linguistics.
219
+
220
+ Jiangtao Feng, Lingpeng Kong, Po-Sen Huang, Chong Wang, Da Huang, Jiayuan Mao, Kan Qiao, and Dengyong Zhou. 2018. Neural phrase-to-phrase machine translation. arXiv preprint.
221
+
222
+ Markus Freitag, Ricardo Rei, Nitika Mathur, et al. 2022. Results of WMT22 metrics shared task: Stop using BLEU – neural metrics are better and more robust. In WMT.
223
+
224
+ Yuan Gao, Ruili Wang, and Feng Hou. 2023. How to design translation prompts for chatgpt: An empirical study. arXiv e-prints.
225
+
226
+ Naman Goyal, Cynthia Gao, Vishrav Chaudhary, PengJen Chen, et al. 2022. The flores-101 evaluation benchmark for low-resource and multilingual machine translation. TACL.
227
+
228
+ Zhiwei He, Tian Liang, Wenxiang Jiao, Zhuosheng Zhang, Yujiu Yang, Rui Wang, Zhaopeng Tu, Shuming Shi, and Xing Wang. 2023. Exploring humanlike translation strategy with large language models. arXiv preprint.
229
+
230
+ Amr Hendy, Mohamed Abdelrehim, Amr Sharaf, et al. 2023. How good are gpt models at machine translation? a comprehensive evaluation. arXiv preprint.
231
+
232
+ Daphne Ippolito, Reno Kriz, João Sedoc, Maria Kustikova, and Chris Callison-Burch. 2019. Comparison of diverse decoding methods from conditional language models. In ACL.
233
+
234
+ Wenxiang Jiao, Wenxuan Wang, Jen-tse Huang, Xing Wang, and Zhaopeng Tu. 2023. Is chatgpt a good translator? a preliminary study. arXiv preprint.
235
+
236
+ Ronald M Kaplan, Klaus Netter, Jurgen Wedekind, and Annie Zaenen. 1989. Translation by structural correspondences. In EACL.
237
+
238
+ Tom Kocmi, Rachel Bawden, Ondˇrej Bojar, Anton Dvorkovich, Christian Federmann, Mark Fishel, Thamme Gowda, Yvette Graham, Roman Grundkiewicz, Barry Haddow, Rebecca Knowles, Philipp Koehn, Christof Monz, Makoto Morishita, Masaaki Nagata, Toshiaki Nakazawa, Michal Novák, Martin Popel, and Maja Popovic. 2022.´ Findings of the 2022 conference on machine translation (WMT22). In WMT.
239
+
240
+ Tom Kocmi and Christian Federmann. 2023. Large language models are state-of-the-art evaluators of translation quality. arXiv preprint.
241
+
242
+ Philipp Koehn. 2009. Statistical machine translation. Cambridge University Press.
243
+
244
+ Philipp Koehn and Rebecca Knowles. 2017. Six challenges for neural machine translation. In WMT.
245
+
246
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. 2022. Large language models are zero-shot reasoners. In NeurIPS.
247
+
248
+ Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. 2020. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In ACL.
249
+
250
+ Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2022. What makes good in-context examples for GPT-3? In DeeLIO.
251
+
252
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. 2023. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. ACM Comput. Surv.
253
+
254
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019. Roberta: A robustly optimized bert pretraining approach. arXiv preprint.
255
+
256
+ Hongyuan Lu, Haoyang Huang, Dongdong Zhang, Haoran Yang, Wai Lam, and Furu Wei. 2023a. Chainof-dictionary prompting elicits translation in large language models. arXiv preprint.
257
+
258
+ Qingyu Lu, Baopu Qiu, Liang Ding, Liping Xie, and Dacheng Tao. 2023b. Error analysis prompting enables human-like translation evaluation in large language models: A case study on chatgpt. arXiv preprint.
259
+
260
+ Makoto Nagao. 1984. A framework of a mechanical translation between japanese and english by analogy principle. Artificial and human intelligence.
261
+
262
+ Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, et al. 2022a. Training language models to follow instructions with human feedback. arXiv preprint.
263
+
264
+ Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. 2022b. Training language models to follow instructions with human feedback. NeurIPS.
265
+
266
+ Kishore Papineni, Salim Roukos, Todd Ward, and WeiJing Zhu. 2002. Bleu: a method for automatic evaluation of machine translation. In ACL.
267
+
268
+ Keqin Peng, Liang Ding, Qihuang Zhong, Yuanxin Ouyang, Wenge Rong, Zhang Xiong, and Dacheng Tao. 2023. Token-level self-evolution training for sequence-to-sequence learning. In ACL.
269
+
270
+ Maja Popovic. 2015. ´ chrF: character n-gram F-score for automatic MT evaluation. In WMT.
271
+
272
+ Matt Post. 2018. A call for clarity in reporting BLEU scores. In WMT.
273
+
274
+ Chengwei Qin, Aston Zhang, Zhuosheng Zhang, Jiaao Chen, Michihiro Yasunaga, and Diyi Yang. 2023. Is chatgpt a general-purpose natural language processing task solver? arXiv preprint.
275
+
276
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. OpenAI blog.
277
+
278
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. JMLR.
279
+
280
+ Ricardo Rei, Craig Stewart, Ana C Farinha, and Alon Lavie. 2020. COMET: A neural framework for MT evaluation. In EMNLP.
281
+
282
+ Richard Zens, Franz Josef Och, and Hermann Ney. 2002. Phrase-based statistical machine translation. In KI.
283
+
284
+ Wayne Xin Zhao, Kun Zhou, Junyi Li, Tianyi Tang, Xiaolei Wang, Yupeng Hou, Yingqian Min, Beichen Zhang, Junjie Zhang, Zican Dong, et al. 2023. A survey of large language models. arXiv preprint.
285
+
286
+ Qihuang Zhong, Liang Ding, Juhua Liu, Bo Du, and Dacheng Tao. 2023. Can chatgpt understand too? a comparative study on chatgpt and fine-tuned bert. arXiv preprint.
287
+
288
+ Qihuang Zhong, Liang Ding, Yibing Zhan, Yu Qiao, Yonggang Wen, Li Shen, Juhua Liu, Baosheng Yu, Bo Du, Yixin Chen, et al. 2022. Toward efficient language model pretraining and downstream adaptation via self-evolution: A case study on superglue. arXiv preprint.
289
+
290
+ David Vilar, Markus Freitag, Colin Cherry, Jiaming Luo, Viresh Ratnakar, and George Foster. 2022. Prompting palm for translation: Assessing strategies and performance. arXiv preprint.
291
+
292
+ Yongchao Zhou, Andrei Ioan Muresanu, Ziwen Han, Keiran Paster, Silviu Pitis, Harris Chan, and Jimmy Ba. 2022. Large language models are human-level prompt engineers. arXiv preprint.
293
+
294
+ Jiaan Wang, Yunlong Liang, Fandong Meng, Zhixu Li, Jianfeng Qu, and Jie Zhou. 2023a. Cross-lingual summarization via chatgpt. arXiv preprint.
295
+
296
+ Qingyue Wang, Liang Ding, Yanan Cao, Zhiliang Tian, Shi Wang, Dacheng Tao, and Li Guo. 2023b. Recursively summarizing enables long-term dialogue memory in large language models. arXiv preprint.
297
+
298
+ Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. 2022a. Finetuned language models are zero-shot learners. In ICLR.
299
+
300
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. 2022b. Emergent abilities of large language models. arXiv preprint.
301
+
302
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed H. Chi, Quoc Le, and Denny Zhou. 2022c. Chain of thought prompting elicits reasoning in large language models. arXiv preprint.
303
+
304
+ Changtong Zan, Liang Ding, Li Shen, Yu Cao, Weifeng Liu, and Dacheng Tao. 2022a. Bridging cross-lingual gaps during leveraging the multilingual sequenceto-sequence pretraining for text generation. arXiv preprint.
305
+
306
+ Changtong Zan, Liang Ding, Li Shen, Yibin Lei, Yibing Zhan, Weifeng Liu, and Dacheng Tao. 2023. Unlikelihood tuning on negative samples amazingly improves zero-shot translation. arXiv preprint.
307
+
308
+ Changtong Zan, Keqin Peng, Liang Ding, Baopu Qiu, Boan Liu, Shwai He, Qingyu Lu, Zheng Zhang, Chuang Liu, Weifeng Liu, Yibing Zhan, and Dacheng Tao. 2022b. Vega-MT: The JD explore academy machine translation system for WMT22. In WMT.
309
+
310
+ Zero-shot prompting
311
+
312
+ System: You are a machine translation system.
313
+
314
+ User: Please provide the German translation for the following sentence: Sadly, as newer methods of writing have emerged, the pencil has been relegated to lesser status and uses.
315
+
316
+ Response: Leider wurde der Bleistift durch neuere Schreibmethoden in eine geringere Position und Verwendung gedrängt.
317
+
318
+ Zero-shot CoT prompting
319
+
320
+ System: You are a machine translation system.
321
+
322
+ User: Please provide the German translation for the following sentence step by step and then provide the complete sentence: Sadly, as newer methods of writing have emerged, the pencil has been relegated to lesser status and uses.
323
+
324
+ Response: 1. Sadly - Bedauerlicherweise 2. as newer methods of writing have emerged - da neuere Schreibmethoden aufgetaucht sind 3. the pencil - der Bleistift 4. has been relegated - wurde zurückgestuft 5. to lesser status and uses - zu geringerem Status und Verwendungszwecken Bedauerlicherweise wurde der Bleistift aufgrund neuerer Schreibmethoden zu geringerem Status und Verwendungszwecken zurückgestuft.
325
+
326
+ 1-shot CoT prompting
327
+
328
+ System: You are a machine translation system.
329
+
330
+ User: Please provide the German translation for the following sentence step by step and then provide the complete sentence: That said, expect to be out of breath, and take care in the steeper portions, especially when wet, as it can become dangerous quickly. 1. That said - jedoch damit 2. expect - Rechnen sie 3. to be - zu sein 4. out of breath - außer Atem 5. and - und 6. take care - vorsichtig 7. in the steeper portions - in den steileren Abschnitten 8. especially - besonders 9. when wet - wenn es nass ist 10. become - werden 11. dangerous - gefährlich 12. quickly - schnell The complete sentence in German is: Rechnen Sie jedoch damit, außer Atem zu sein, und seien Sie in den steileren Abschnitten vorsichtig, besonders wenn es nass ist, da es dort schnell gefährlich werden kann. Please provide the German translation for the following sentence step by step and then provide the complete sentence: Sadly, as newer methods of writing have emerged, the pencil has been relegated to lesser status and uses.
331
+
332
+ Response: 1. Sadly - Leider 2. as - da 3. newer methods - neuere Methoden 4. of writing - des Schreibens 5. have emerged - aufgetaucht sind 6. the pencil - der Bleistift 7. has been relegated - wurde zurückgestuft 8. to lesser status - zu einem geringeren Status 9. and uses - und Verwendungen. The complete sentence in German is: Leider wurde der Bleistift aufgrund des Auftauchens neuerer Methoden des Schreibens zu einem geringeren Status und Verwendungen zurückgestuft.
md/dev/gJLAfO4KUq/gJLAfO4KUq.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Pengi: An Audio Language Model for Audio Tasks
2
+
3
+ Soham Deshmukh1 Benjamin Elizalde1 Rita Singh2 Huaming Wang1 1Microsoft 2Carnegie Mellon University {sdeshmukh, benjaminm, huawang}@microsoft.com, rsingh@cs.cmu.edu
4
+
5
+ # Abstract
6
+
7
+ In the domain of audio processing, Transfer Learning has facilitated the rise of Self-Supervised Learning and Zero-Shot Learning techniques. These approaches have led to the development of versatile models capable of tackling a wide array of tasks, while delivering state-of-the-art performance. However, current models inherently lack the capacity to produce the requisite language for open-ended tasks, such as Audio Captioning or Audio Question Answering. We introduce Pengi, a novel Audio Language Model that leverages Transfer Learning by framing all audio tasks as text-generation tasks. It takes as input, an audio recording, and text, and generates free-form text as output. The input audio is represented as a sequence of continuous embeddings by an audio encoder. A text encoder does the same for the corresponding text input. Both sequences are combined as a prefix to prompt a pre-trained frozen language model. The unified architecture of Pengi enables open-ended tasks and close-ended tasks without any additional fine-tuning or task-specific extensions. When evaluated on 21 downstream tasks, our approach yields state-of-the-art performance in several of them. Our results show that connecting language models with audio models is a major step towards general-purpose audio understanding 1.
8
+
9
+ ![](images/d3842148cefeb187084c2b5f6e7bb63896a07cdde54c12fdb5c2c48706345fd1.jpg)
10
+ Figure 1: Examples of audio and text prompt inputs and their corresponding textual responses. Images are for illustration purposes only. Our proposed model Pengi enables close-ended tasks, such as classification or retrieval and open-ended tasks, such as captioning or question & answering.
11
+
12
+ # 1 Introduction
13
+
14
+ Machine Listening breaks down audio understanding into separate and independent audio tasks. For example, Sound Event and Scene Classification, Audio Retrieval, and Audio Captioning. Because these audio tasks are intrinsically related, we can leverage from Transfer Learning (TL). TL focuses on applying knowledge gained while solving one task to solve a related task. The learning method involves pre-training a model with a large compilation of datasets from different tasks followed by fine-tuning on a target dataset. These models have shown the potential to learn general-purpose audio representations [53] that can successfully be used in a variety of downstream tasks. To leverage from larger amounts of audio that is unlabeled, the community has employed Self-Supervised and Unsupervised Learning [50, 51, 44, 19]. These methods do not require labels [53, 7] and have achieved state-of-the-art performance. However, both methods require an additional fine-tuning step before they can be applied to any downstream task.
15
+
16
+ To address this drawback, another Transfer Learning (TL) method called Zero-Shot Learning provides direct inference capabilities and removes the need of fine-tuning. These models use contrastive objectives to learn the similarity between natural language descriptions and audio content to provide a score that identifies the most probable class label for a given testing audio. Examples are CLAP [15], Mulan [26], and LAION-CLAP [58]. Despite not seeing the training data of a target task, Zero-Shot models achieve surprising performance in close-ended tasks, such as classification and retrieval. However, these models inherently lack the capacity to produce the requisite language for open-ended tasks, such as Audio Captioning or Audio Question Answering (AQA).
17
+
18
+ Current audio models that can perform open-ended tasks do not support or have not been evaluated on closed-ended tasks [37, 31]. It is yet to be explored how to leverage TL to enable both types of tasks in the audio domain. We drew inspiration from recent advances in Natural Language Processing (NLP) and Visual Language Models (VLM). In NLP, Raffel et. al. [49] explored a unified framework called T5 where all text-based tasks are framed as text input to text output problems. T5 was trained with a single objective function and supported a diverse set of tasks, like translation, question & answering, and classification. FLAN [8] showed that language models trained on a collection of text tasks phrased as instructions, enabled models to respond better to similar instructions at inference time. This TL technique showed performance improvement across a range of models, prompting setups, and evaluation tasks. On the other hand, VLM incorporates visual information by combining a language model and an image encoder to transfer knowledge across modalities. Tasks are framed as text and image input to text output problems. Captioning training consists of optimizing a text generation objective, and can transfer moderately well to visual question & answering in the zero-shot settings. Examples include, Frozen [52], Flamingo [2], and other models [54, 52, 2, 42, 39]. But their performance on close-ended tasks still lags behind contrastive models [47, 59]. In the audio domain, there are no models that resemble any of these capabilities, let alone that support both close-ended and open-ended audio tasks simultaneously.
19
+
20
+ In this paper, we introduce Pengi, a novel Audio Language Model (ALM) that takes as input, an audio recording and a text prompt, and generates free-form text as output. To the best of our knowledge, the following contributions are achieved for the first time in the literature:
21
+
22
+ • A novel Audio Language Model capable of supporting multiple close-ended and open-ended audio tasks without any additional fine-tuning or task-specific extensions of the architecture. Pengi draws inspiration from VLM but tackles intrinsic challenges in the audio domain.
23
+ • We propose a new learning framework where we frame all audio tasks as audio and text input to text output tasks. Our framework uses a single training procedure and a captioning objective function. For training, we designed new audio task templates inspired by Instruction Tuning.
24
+ • We extensively evaluated Pengi on 21 downstream tasks across various audio domains yielding state-of-the-art performance in several of them. Thus, establishing a baseline for general-purpose ALM.
25
+
26
+ # 2 Related Work
27
+
28
+ Audio Language Models. In the domain of audio processing, Transfer Learning has facilitated the rise of Self-Supervised Learning and Zero-Shot Learning techniques [50, 51, 43, 22, 25, 24, 3, 15, 26, 23, 57, 58, 41, 12, 14, 16]. These approaches have led to the development of versatile models capable of tackling a wide array of tasks, while delivering SoTA performance. However, current models can tackle either close-ended tasks or open-ended tasks. ALM pose a new learning paradigm for audio processing that can support all tasks. The language modeling approaches to audio find utility in generating audio given an input description [4, 1]. But it is yet to be explored how to train them for general-purpose audio understanding and what their performance would be.
29
+
30
+ Language Models. Transfer Learning has been extensively utilized in Natural Language Processing with the recent shift to Zero-Shot and Few-Shot Learning [29, 48, 5, 55]. The work by Raffel et. al. [49] explored a unified framework for text tasks by converting all text-based tasks into the text-to-text format. The experimental results showed the methods can achieve SoTA results when combined and scaled. FLAN [55] released in 2022 uses instruction fine-tuning to fine-tune an existing language model on a large set of varied instructions. Pengi adapts a similar idea for the audio domain, where each audio-tasks is considered a text generation task conditional on the input text and input audio. This allows audio tasks to be represented in (audio-text)-text format and enables learning a single unified model for all the tasks. For training, we created (audio-text)-text templates for audio tasks and trained Pengi with them.
31
+
32
+ Visual Language Models. Inspired by the success of Transfer Learning and Few-Shot Learning in NLP, a host of VLM were proposed for vision tasks. VLM intend to extend the pre-trained language model and adapt them to incorporate visual information. VisualBERT [35] and SimVLM [54] explored different ways to convert images into tokens and jointly train the model on interleaved images and text. Inspired by prefix-tuning [36] and prompt-tuning [34], Frozen [52] and Clipcap [42], use a frozen language model and align the image embeddings for the language model. To better fuse image information, Flamingo [2] uses a gated-cross-attention dense layer in the language model. The interleaved image-text training also enables Flamingo to do few-shot learning. Drawing parallels with VLM, Pengi can be considered an ALM based on audio conditional prefix tuning where the prompt is produced by an audio encoder.
33
+
34
+ # 3 Approach
35
+
36
+ In this section, we describe Pengi, a novel Audio Language Model that leverages Transfer Learning by framing all audio tasks as text generation tasks. It takes as input, an audio recording and a text prompt, and generates free-form text as output. The unified architecture in Figure 2 enables open-ended tasks and close-ended tasks without any additional fine-tuning or task-specific extensions of the architecture.
37
+
38
+ # 3.1 Unified Architecture
39
+
40
+ ![](images/43f61d07c0e8c17764ca6f648cfa98e4622b7d506065fc8c27dfc7c0a76aac23.jpg)
41
+ Figure 2: $\mathcal { O }$ Pengi has a unified architecture that takes as input, an audio recording and a text prompt, and generates free-form text as output. At training, the architecture learns an audio encoder $a _ { \phi }$ and a mapping network $m _ { 1 }$ to represent an input audio as a sequence of continuous embeddings. A frozen text encoder $g _ { \psi }$ and a learnable mapping $m _ { 2 }$ do the same for the corresponding text input. Both sequences are concatenated as a prefix to leverage from a pre-trained frozen autoregressive language model $f _ { \theta }$ to perform multiple tasks. At inference, the language model generates tokens autoregressively conditioned on the audio and text input.
42
+
43
+ Audio Encoder. The audio encoder $a _ { \phi }$ transforms the raw audio input into an audio embedding. We used the audio transformer backbone from CLAP [15] as our audio encoder due to its success in diverse audio and multimodal tasks. Models in Computer Vision [42, 2, 39] use a frozen image encoder like CLIP, but CLAP is trained on a magnitude smaller collection of audio-text pairs. Therefore, we unfroze its weights for our training procedure.
44
+
45
+ Text Encoder. The text encoder $g _ { \psi }$ transforms the input text prompt into a text embedding. The prompt can be any form of natural language, such as a task-specific prompt or a question. The text encoder is frozen so its weights are not updated during training. The text encoder can be any off-the-shelf text encoder and allows our architecture to learn and perform well in close-ended tasks.
46
+
47
+ Mapping Networks and Prefix. To construct the prefix to be fed to the causal language model, we used two mapping networks $( m _ { 1 }$ and $m _ { 2 }$ ). The mapping networks [42] convert an embedding into a sequence of $k$ embeddings. The audio embedding is transformed by $m _ { 1 }$ and the text embedding by $m _ { 2 }$ , both are trainable. Both sequences are concatenated to form the fixed-length prefix.
48
+
49
+ Causal Language Model. To generate the text output we used a pre-trained autoregressive causal language model which is kept frozen during training and inference [52]. Even though the language model is frozen, the audio prefix receives gradients enabling the parameters of mapping network $( m _ { 1 } )$ and audio encoder $a _ { \phi }$ to be optimized with gradient descent and backpropagation. At inference, the language model generates tokens autoregressively conditioned on the audio and text prefix.
50
+
51
+ # 3.2 Training and Inference
52
+
53
+ We propose a new learning framework where we frame all audio tasks as audio and text input to text output tasks. Our framework uses a single training procedure and objective function. Let the training data in audio-text-to-text format be referred to as $\{ x ^ { i } , t ^ { i } , c ^ { i } \}$ where $x ^ { i }$ , $t ^ { i }$ and $c ^ { i }$ are the $i ^ { t h }$ audio file, $i ^ { t h }$ input text, and $i ^ { t h }$ output text or caption respectively.
54
+
55
+ To create a prefix, the audio encoder $a _ { \phi }$ and mapping network $m _ { 1 }$ projects the audio $x ^ { i }$ into a sequence of $k$ embeddings. Similarly, the text encoder $g _ { \psi }$ and mapping network $m _ { 2 }$ projects the input text $t ^ { i }$ into a sequence of $k$ embeddings. Both sequences are concatenated to form prefix $p ^ { i }$ for the pre-trained frozen language model $f _ { \theta }$ .
56
+
57
+ $$
58
+ \boldsymbol { p } ^ { i } = \bar { p } _ { 1 } ^ { i } , . . . , p _ { 2 k } ^ { i } = \mathrm { c o n c a t } \{ m _ { 1 } ( a _ { \phi } ( \boldsymbol { x } ^ { i } ) ) , m _ { 2 } ( g _ { \psi } ( t ^ { i } ) ) \}
59
+ $$
60
+
61
+ The language model $f _ { \theta }$ is fed with the prefix-caption concatenation of all $\{ z _ { i } \} _ { i = 1 } ^ { N }$ , where $z _ { i }$ is:
62
+
63
+ $$
64
+ z ^ { i } = p _ { 1 } ^ { i } , . . . , p _ { 2 k } ^ { i } , c _ { 1 } ^ { i } , . . . , c _ { l } ^ { i }
65
+ $$
66
+
67
+ The model is trained as a standard captioning system, where it learns to predict a caption (text tokens) $c ^ { i }$ conditioned on the prefix in an autoregressive fashion. We used Cross-Entropy as the loss function:
68
+
69
+ $$
70
+ \mathcal { L } = - \sum _ { i = 1 } ^ { N } \sum _ { j = 1 } ^ { l } \log p _ { \gamma } ( c _ { j } ^ { i } | p _ { 1 } ^ { i } , . . . , p _ { 2 k } ^ { i } , c _ { 1 } ^ { i } , . . . , c _ { j - 1 } ^ { i } )
71
+ $$
72
+
73
+ where $\gamma$ denotes model’s trainable parameters which include audio encoder parameters $\phi$ and parameters from both mapping networks. The text encoder and the causal language model are frozen.
74
+
75
+ At inference time, the prefix is constructed using the test audio and a text prompt. The causal language model $f _ { \theta }$ generates the next token sequentially conditioned on the prefix. The language model assigns probabilities to all vocabulary tokens at each prediction, which are used to determine the next token depending on the choice of decoding. In our experiments, we used beam search decoding with a beam size of 5 for inference and downstream tasks.
76
+
77
+ # 4 Experiments
78
+
79
+ # 4.1 Training Datasets and Templates
80
+
81
+ Our Audio Language Model Pengi is trained on a collection of audio-text tasks phrased as instruction templates. The templates are inspired by instruction tuning and enable models to respond better to similar instructions at inference time. This TL technique is novel for audio and yielded performance improvement across a range of input prompting examples and downstream tasks.
82
+
83
+ The training datasets are modified to adapt to our proposed framework (audio-text)-to-text format by constructing 8 audio-task templates. Before our study, there was no evidence that the templates could lead to good performance across open- and close-ended tasks. Each template consists of audio input, input text prompt, and text output. Examples are "this is the sound of", “this emotion is" or “question: {question}". All the templates are in Table 1, out of which one template is the Auxiliary task “generate metadata". With it, we add audio-text pairs that are not task-specific. Drawing parallels, this training data setup is inspired by instruction tuning format of FLAN [55, 8]. Defining new templates or variations of the ones proposed here is a promising direction to explore.
84
+
85
+ <table><tr><td>Task</td><td>Input prompt</td><td>Output format</td></tr><tr><td>Audio Captioning</td><td>generate audio caption</td><td>{caption}</td></tr><tr><td>Audio QA</td><td>question: {question}</td><td>{answer}</td></tr><tr><td>Sound Event Classification</td><td>this is a sound of</td><td>{event a},{eventb)],.</td></tr><tr><td>Acoustic Scene Classification</td><td>this acoustic scene is</td><td>{scene}</td></tr></table>
86
+
87
+ Table 1: The training datasets are modified to adapt to our proposed framework (audio-text)-to-text format by constructing 8 audio-task templates. Each template consists of audio input, input text prompt, and text output. The {} symbol indicates variable content. The Auxiliary task template allowed us to add audio-text pairs that are not task-specific.
88
+
89
+ <table><tr><td>Task</td><td>Input prompt</td><td>Output format</td></tr><tr><td>Speech Emotion Recognition</td><td>this emotion is</td><td>{emotion}</td></tr><tr><td>Speech Sentiment Recognition</td><td>this sentiment is</td><td>{sentiment}</td></tr><tr><td>Music Analysis</td><td>music analysis</td><td>this is a sound of music in language {language} and genre {genre}.</td></tr><tr><td>Music Note Analysis</td><td>this music note is</td><td>produced by {instrument}, pitch {pitch},.</td></tr><tr><td>Auxiliary</td><td>generatemetadata</td><td>{metadata}</td></tr></table>
90
+
91
+ The training data is collected from multiple audio datasets coming from different sources. In all, we collected 3.4 million audio-text pairs and mapped them to the 8 templates. The number of training pairs makes this model one of the largest if not the largest non-speech audio model in literature. We use only the training set of each dataset. The datasets and their mapping to a task are the following. Sound Event Classification: AudioSet [21], FSD50K[20]; Acoustic Scene Classification: CochlScene [27]; Speech Emotion and Sentiment Recognition: MSP Podcast [38], CMU MOSI [60], CMU MOSEI [61], MELD [46]; Music Analysis: NSynth [17], FMA [9]; Audio Captioning: AudioCaps [30], ClothoV2 [13]; Audio Question and Answering: ClothoAQA [37]; Auxiliary: WavText5K [11], SoundDescs [33], MACS [40], WavCaps [41], FreeSound [18] and FindSound2.
92
+
93
+ # 4.2 Downstream Tasks
94
+
95
+ The unified architecture of Pengi enables open-ended tasks and close-ended tasks.
96
+
97
+ Open-ended tasks. This task type requires free-form text generation and there is flexibility in the correctness of the output. Examples are Audio Captioning and AQ&A. Pengi will take as input the testing audio and the desired prompt to generate the text output. It does not require any additional fine-tuning or task-specific components.
98
+
99
+ Close-ended tasks. This task type is restricted to predefined values that can be classes or numbers. Examples are classification and retrieval. Pengi will take as input the testing audio and the desired prompt. Ideally, the free-form text output from Pengi should contain the exact predefined value. For example, a predefined class is “dog" but Pengi may output “dog barking" or “canine". Although these answers are reasonable, they are incorrect under most metrics. To evaluate the correctness, we proposed two methods: Log-likelihood and Text matching (Fig. 3). Unless explicitly mentioned, all experiments in our paper use the Text-matching method for evaluation.
100
+
101
+ Log-likelihood: We take the concatenated prefix from a testing audio, the prompt, and append one of the predefined values (e.g class name, number) to create a candidate output. We would have $N$ candidate outputs corresponding to $N$ predefined values. For example in classification, if we have 100 testing audios and 5 classes, we would have 5 output candidates per audio. The outputs and the predefined values are used to compute Log-likelihood scores and determine the model’s prediction. This method is expensive for the extensive evaluation in our study.
102
+
103
+ ![](images/937fa9172f354904da40d80923c48084fba0738bee15623a528bc10e80550aad.jpg)
104
+ Figure 3: Text-matching method used during inference for close-ended tasks. TE indicates Text Embedding.
105
+
106
+ Text-matching: In this setup, the free-form output is matched to the predefined values using text embeddings (Fig.3). For example, in a classification setting, we compute sentence-level text embeddings for Pengi’s output and for all the class labels in a given dataset. Then, we calculate cosine similarity to determine the model’s prediction. We used Pengi’s text encoder to compute the embeddings, but any off-the-shelf text encoder could be used.
107
+
108
+ Downstream tasks. We used 21 downstream tasks (Table 2) to benchmark the open-ended and close-ended capabilities of Pengi. The open-ended tasks consist of Audio Captioning and AQA. The close-ended tasks consist of classification, regression, and retrieval. Datasets like Clotho have more than one type of annotations, so they are used for multiple tasks like Audio Captioning and Text-to-Audio Retrieval.
109
+
110
+ Table 2: We extensively evaluated Pengi across 21 downstream tasks from various domains. The first two domains are open-ended tasks and the rest are close-ended tasks. For the “Output Type" column, Cap. refers to captioning, MC to multiclass, B indicates binary, Reg. indicates regression, and Ret. retrieval.
111
+
112
+ <table><tr><td>Domain</td><td>Dataset</td><td>Files</td><td>Dur. (secs)</td><td>Output Type</td><td>Metric</td><td>Setup</td></tr><tr><td>Audio</td><td>Clotho</td><td>7k</td><td>15-30</td><td>Cap.</td><td>SPIDEr</td><td>train/val/test</td></tr><tr><td>Captioning</td><td>AudioCaps</td><td>39k</td><td>10</td><td>Cap.</td><td>SPIDEr</td><td>train/val/test</td></tr><tr><td>Audio Question Answering</td><td>ClothoAQA</td><td>2k</td><td>15-30</td><td>Q&amp;A</td><td>ACC</td><td>train/val/test</td></tr><tr><td rowspan="4">Sound Event Classification</td><td>ESC50</td><td>2k</td><td>5</td><td>MC (50)</td><td>ACC</td><td>5 folds</td></tr><tr><td>FSD50K</td><td>51k</td><td>0.3-30</td><td>ML (200)</td><td>mAP</td><td>train/val/test</td></tr><tr><td>UrbanSound8K</td><td>8k</td><td>≤4</td><td>MC (10)</td><td>ACC</td><td>10 folds</td></tr><tr><td>DCASE2017 Task4</td><td>52k</td><td>10</td><td>MC (17)</td><td>ACC</td><td>train/val/test</td></tr><tr><td rowspan="2">Music Analysis</td><td>GT.Music Speech</td><td>120</td><td>30</td><td>B(2)</td><td>ACC</td><td>10 folds</td></tr><tr><td>GT. Music Genre</td><td>1k</td><td>30</td><td>MC (10)</td><td>ACC</td><td>10 folds</td></tr><tr><td>Instrument Classification</td><td>Beijing Opera NS. Instruments</td><td>236</td><td>4.77</td><td>MC (4)</td><td>ACC</td><td>5 folds</td></tr><tr><td rowspan="3">Music Note Analysis</td><td></td><td>305k</td><td>4</td><td>MC(11)</td><td>ACC</td><td>train/val/test</td></tr><tr><td>NS. Pitch</td><td>305k</td><td>4</td><td>Reg.</td><td>ACC</td><td>train/val/test</td></tr><tr><td>NS. Velocity NS. Sonic</td><td>305k 305k</td><td>4 4</td><td>MC (11)</td><td>ACC</td><td>train/val/test</td></tr><tr><td>Acoustic Scene Classification</td><td>TUT 2017</td><td>6.3k</td><td>10</td><td>ML (10)</td><td>ACC</td><td>train/val/test</td></tr><tr><td>Emotion</td><td>CREMA-D</td><td>7k</td><td>5</td><td>MC (15) MC (6)</td><td>ACC ACC</td><td>train/val/test 5 folds</td></tr><tr><td>Recognition</td><td>RAVDESS</td><td>2.5k</td><td>≤5</td><td>MC(8)</td><td>ACC</td><td>5 folds</td></tr><tr><td>Vocal Sound Classification</td><td>Vocal Sound</td><td>21k</td><td>5</td><td>MC (6)</td><td>ACC</td><td>train/val/test</td></tr><tr><td>Surveillance</td><td>Surveil.</td><td>585</td><td>≤33</td><td>MC (6)</td><td>ACC</td><td>train/val/test</td></tr><tr><td>Text-to-Audio</td><td>Applications</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Retrieval</td><td>Clotho AudioCaps</td><td>7k 39k</td><td>15-30 10</td><td>Ret. Ret.</td><td>R@1 R@1</td><td>train/val/test train/val/test</td></tr></table>
113
+
114
+ # 4.3 Implementation details
115
+
116
+ Encoders and mappers. We used the audio transformer HTSAT[6] as our audio encoder and CLIP’s [47] text encoder. The audio is sampled at $4 4 . 1 \mathrm { k H z }$ and is converted to a log Mel spectrograms with $6 4 \mathrm { M e l }$ bins, a hop size of $3 2 0 \mathrm { m s }$ , and a window size of $1 0 2 4 ~ \mathrm { { m s } }$ in the range of $5 0 { - } 8 0 0 0 \mathrm { H z }$ We randomly truncated all audio files to 7 seconds in length for HTSAT. The max length of the text encoder is set to 40 for computational efficiency. We performed another step of CLAP (Contrastive Language-Audio Pretraining) training using the above two encoders [15]. This enables experiments where the audio encoder can be kept frozen to see the utility of CLAP’s [15] audio embeddings similar to VLM [42, 52, 2]. The mapping networks $m _ { 1 }$ and $m _ { 2 }$ each use an 8-layer transformer with a prefix length of 40. The total prefix length after concatenating the audio and text is 80. The hyper-parameters of the encoders and the CLAP training are mostly left as in the original papers, the details are in Appendix D.
117
+
118
+ Causal Language Model. We used the GPT2 line of models, specifically GPT2-base (124M). The model is kept frozen through all the experiments.
119
+
120
+ Pre-training. We used Adam Optimiser [32] for 60 epochs and with a batch size of 384 on 20 V100 GPUs. We used a linear schedule with 2000 warmup steps and a base learning rate of 1e-4.
121
+
122
+ # 5 Results
123
+
124
+ # 5.1 Benchmarking Pengi
125
+
126
+ We assessed Pengi on 21 downstream tasks covering various domains. Pengi is the first audio model that can perform both, open-ended and close-ended tasks. A fair comparison against another model that can perform both is not possible. We chose CLAP [15] as the baseline because it is the only Zero-Shot model with a comprehensive evaluation (16 downstream tasks). The next best evaluation was only on 8 tasks. Thus, providing no evidence of performance across domains like speech and music, which tend to be the most difficult. Moreover, we compared against SoTA results even if it came from different models and learning methods. We compared against SoTa Zero-Shot models in Table 8, a subset of Table 3, for Sound Event Classification. Even against SoTA from supervised learning models in Tables 5 and 7 for AQ&A and Audio Captioning respectively. Table 9, against SSL, supervised and trained on speech audio models.
127
+
128
+ <table><tr><td></td><td colspan="2">Audio Captioning↑</td><td>AQA↑</td><td colspan="4">Sound Event Classification个</td></tr><tr><td>Model</td><td>AudioCaps</td><td>Clotho</td><td>ClothoAQA</td><td>ESC50</td><td>FSD50K</td><td>US8K</td><td>DCASE17 Task 4</td></tr><tr><td>CLAP</td><td>X</td><td>X</td><td>X</td><td>0.826</td><td>0.3024</td><td>0.7324</td><td>0.3</td></tr><tr><td>Pengi</td><td>0.4667</td><td>0.2709</td><td>0.6453</td><td>0.9195</td><td>0.4676</td><td>0.7185</td><td>0.338</td></tr></table>
129
+
130
+ <table><tr><td></td><td>Acoustic Scene Classification↑</td><td colspan="2">Music 个</td><td colspan="2">Instrument Classification ↑</td><td colspan="3">Music Note Analysis↑</td></tr><tr><td>Model</td><td>TUT2017</td><td>Music Speech</td><td>Music Genres</td><td>Beijing Opera</td><td>Instrument family</td><td>NS. Pitch</td><td>NS. Velocity</td><td>NS. Qualities</td></tr><tr><td>CLAP Pengi</td><td>0.2963 0.3525</td><td>1.0 0.9688</td><td>0.252 0.3525</td><td>0.2963 0.6229</td><td>0.2949 0.5007</td><td>- 0.8676</td><td>- 0.3728</td><td>1 0.386</td></tr></table>
131
+
132
+ Table 3: We used CLAP [15] as a baseline comparison because of its strong performance on a wide range of downstream tasks. The ‘-’ symbol indicates numbers were not available, whole $\mathbf { \nabla } \cdot \mathbf { \boldsymbol { x } } ^ { * }$ indicates that the model cannot support the task. Higher is better for all numbers. The evaluation metric is mAP for FSD50k, AudioSet, ESC50-Actions, and NSynth sonic; F1 score for DCASE17; and SPIDEr for AudioCaps and Clotho captioning. All other downstream tasks use Accuracy.
133
+
134
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Emotion Recognition↑</td><td rowspan=1 colspan=1>Vocal SoundClassification↑</td><td rowspan=1 colspan=1>ActionRecog.↑</td><td rowspan=1 colspan=1>Surveillance.↑</td></tr><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>CRE RAVMA-D DESS</td><td rowspan=1 colspan=1>VocalSound</td><td rowspan=1 colspan=1>ESC50Actions</td><td rowspan=1 colspan=1>SESA</td></tr><tr><td rowspan=1 colspan=1>CLAPPengi</td><td rowspan=1 colspan=1>0.1784 0.15990.1846 0.2032</td><td rowspan=1 colspan=1>0.49450.6035</td><td rowspan=1 colspan=1>0.4970.5277</td><td rowspan=1 colspan=1>0.74870.5402</td></tr></table>
135
+
136
+ Open-ended tasks. Pengi sets new state-of-the-art performance for open-ended tasks. We used Audio Captioning and AQA for open-ended tasks. The CLAP model can only support close-ended tasks and cannot perform open-ended tasks without additional modules and fine-tuning. Therefore, we compared against supervised trained models in Section 5.2.
137
+
138
+ Close-ended tasks. Pengi performs better than CLAP on most audio classification tasks, and can also outperform the literature. Although CLAP and Pengi employed different learning methods and used a different amount of training data, it is to be noted that Pengi can compete with strong contrastive methods like CLAP and other methods in the literature.
139
+
140
+ # 5.2 Audio Captioning and AQA
141
+
142
+ Audio Captioning. Pengi’s performance outperformed supervised models in the two captioning tasks AudioCaps and Clotho, as shown in Table 7. The captioning competition IEEE DCASE $2 0 2 2 ^ { \frac { 5 } { 3 } }$ ranks models based on the metric SPIDEr, a combination of CIDEr and SPICE. Specifically, for AudioCaps Pengi outperformed the literature by a relative $6 . 6 \%$ and for Clotho by a relative $26 \%$ . All models used both, AudioCaps and Clotho datasets in training. One of the best captioning models is from Kim et al. [31]. The authors followed a similar training procedure to ours with audio encoders and a language model. Unlike Pengi, which uses a single audio encoder, they employed two mapping networks to capture both global and temporal features from the audio. Despite having two audio representations, the model underperformed our approach.
143
+
144
+ Similar to Multi-Task Learning [62, 10], we hypothesize that learning a shared audio encoder and mapping networks helps Pengi to solve individual tasks better. We addressed this hypothesis by conducting an ablation study in Table 4. In experiment $A$ , we trained and evaluated Pengi only on audio-captioning data with text prompts of “generate audio caption". Then, we contrasted audio captioning performance against experiment $B$ , where we trained on data across different tasks, in other words, our proposed setup in this paper. From Table 4, we see consistent improvement in both AudioCaps and Clotho downstream tasks. Specifically, experiment $B$ outperforms experiment $A$ by a relative $2 . 5 \%$ and $2 . 3 \%$ on AudioCaps and Clotho respectively. This indicates that Pengi’s shared architecture does help in improving performance on individual tasks.
145
+
146
+ <table><tr><td rowspan="2">Model</td><td>Audio Q&amp;A↑</td></tr><tr><td>Acc</td></tr><tr><td>M1</td><td>0.575</td></tr><tr><td>M2</td><td>0.627</td></tr><tr><td>M3</td><td>0.635</td></tr><tr><td>Pengi</td><td>0.645</td></tr></table>
147
+
148
+ Table 4: Effect of shared audio encoder training
149
+
150
+ <table><tr><td rowspan="2">Exp.</td><td rowspan="2">Eval. dataset</td><td colspan="2">Audio Captioning↑</td></tr><tr><td>BLUE1</td><td>SPIDEr</td></tr><tr><td>A</td><td>AudioCaps</td><td>0.6439</td><td>0.4551</td></tr><tr><td>B</td><td>AudioCaps</td><td>0.6912</td><td>0.4667</td></tr><tr><td>A</td><td>Clotho</td><td>0.5619</td><td>0.2648</td></tr><tr><td>B</td><td>Clotho</td><td>0.5702</td><td>0.2709</td></tr></table>
151
+
152
+ <table><tr><td></td><td></td><td colspan="3">Text-to-Audio Retrieval个</td></tr><tr><td>Model</td><td>Retr.</td><td>R@1</td><td>R@5</td><td>R@10</td></tr><tr><td>Chen et al.</td><td>Clotho</td><td>1.5</td><td>4.4</td><td>7.5</td></tr><tr><td>Gont. et al.</td><td>Clotho</td><td>2.1</td><td>7.0</td><td>12.0</td></tr><tr><td>Mei et al.</td><td>Clotho</td><td>4.0</td><td>14.1</td><td>21.6</td></tr><tr><td>Kim et al.</td><td>Clotho</td><td>7.6</td><td>19.6</td><td>28.8</td></tr><tr><td>Soham et al.</td><td>Clotho</td><td>16.7</td><td>41.0</td><td>54.1</td></tr><tr><td>Pengi</td><td>Clotho</td><td>9.4</td><td>26.1</td><td>36.7</td></tr></table>
153
+
154
+ Table 5: AQ&A results
155
+ Table 6: T2A Retrieval results
156
+
157
+ Table 7: Pengi outperforms the best Audio Captioning performance from supervised models. All models used both, AudioCaps and Clotho datasets in training. SPIDEr is the metric used to rank models in IEEE DCASE Challenge. Higher is better for all metrics.
158
+
159
+ <table><tr><td>Model</td><td>Eval. dataset</td><td>BLUE1</td><td>BLUE2</td><td>BLUE3</td><td>BLUE4</td><td>METEOR</td><td>ROUGE L</td><td>CIDEr</td><td>SPICE</td><td>SPIDEr</td></tr><tr><td>Chen et al.</td><td>AudioCaps</td><td>0.489</td><td>0.292</td><td>0.178</td><td>0.106</td><td>0.152</td><td>0.346</td><td>0.265</td><td>0.093</td><td>0.179</td></tr><tr><td>Gontier et al.</td><td>AudioCaps</td><td>0.635</td><td>0.461</td><td>0.322</td><td>0.219</td><td>0.208</td><td>0.450</td><td>0.612</td><td>0.153</td><td>0.383</td></tr><tr><td>Mei et al.</td><td>AudioCaps</td><td>0.682</td><td>0.507</td><td>0.369</td><td>0.266</td><td>0.238</td><td>0.488</td><td>0.701</td><td>0.166</td><td>0.434</td></tr><tr><td>Kim et al.</td><td>AudioCaps</td><td>0.708</td><td>0.547</td><td>0.402</td><td>0.283</td><td>0.238</td><td>0.499</td><td>0.710</td><td>0.167</td><td>0.438</td></tr><tr><td>Pengi</td><td>AudioCaps</td><td>0.691</td><td>0.419</td><td>0.371</td><td>0.253</td><td>0.232</td><td>0.482</td><td>0.752</td><td>0.182</td><td>0.467</td></tr><tr><td>Chen et al.</td><td>Clotho</td><td>0.516</td><td>0.325</td><td>0.215</td><td>0.141</td><td>0.153</td><td>0.350</td><td>0.314</td><td>0.102</td><td>0.208</td></tr><tr><td>Gontier et al.</td><td>Clotho</td><td>0.461</td><td>0.282</td><td>0.182</td><td>0.117</td><td>0.136</td><td>0.318</td><td>0.251</td><td>0.083</td><td>0.167</td></tr><tr><td>Mei et al.</td><td>Clotho</td><td>0.516</td><td>0.318</td><td>0.204</td><td>0.127</td><td>0.157</td><td>0.351</td><td>0.313</td><td>0.105</td><td>0.209</td></tr><tr><td>Kim et al.</td><td>Clotho</td><td>0.539</td><td>0.346</td><td>0.227</td><td>0.142</td><td>0.159</td><td>0.366</td><td>0.319</td><td>0.111</td><td>0.215</td></tr><tr><td>Pengi</td><td>Clotho</td><td>0.57</td><td>0.369</td><td>0.242</td><td>0.15</td><td>0.172</td><td>0.375</td><td>0.416</td><td>0.126</td><td>0.271</td></tr></table>
160
+
161
+ AQA. Pengi outperformed the existing literature [37]. Authors in [37] collected the only dataset available (ClothoAQA). They converted the AQA task into a classification task, instead of a generation task. Authors trained and fine-tuned a model in a supervised setup. In contrast, we used the free-form text from Pengi, where the answer is correct only when it directly matches the human response. Note that Pengi includes the training set of ClothoAQA among its training sets, but there is no further fine-tuning on this task. The results are shown in Table 5. The first column indicates three different baseline models from [37]. Pengi achieved $6 4 . 5 \%$ and outperformed the existing supervised benchmark by a relative $1 . 5 \%$ .
162
+
163
+ # 5.3 Zero-Shot Sound Event Classification
164
+
165
+ We compared Pengi’s classification performance against Zero-Shot contrastive models in the literature. The existing literature restricts the training and evaluation tasks to a few sound event datasets. Hence, we matched our comparisons to sound event datasets. The downstream datasets of ESC50, US8k, DCASE17 Task4 contain audio files and labels not seen by Pengi during training. We considered these three datasets to constitute a zero-shot setup for Pengi. For FSD50k, the audio files in the training split have been used for training Pengi. Hence, we do not consider this a pure zero-shot setup but nonetheless, report numbers for insights.
166
+
167
+ On Zero-Shot ESC50 performance, Pengi beats AudioCLIP [23], CLAP [15], and LAION CLAP [58] by $32 \%$ , $11 \%$ , and $1 \%$ respectively (See Table 8). Interestingly, human performance on ESC50 is $81 \%$ accuracy and Pengi’s performance is $92 \%$ . Mei et. al. [41] added ChatGPT augmented audio-text pairs to CLAP training [58] and showed an improvement in performance from $91 \%$ to $94 \%$ on ESC50. On US8k, Pengi performed better than Wav2CLIP and AudioCLIP but lower than CLAP and LAION CLAP. Overall, even though Pengi is a text generation model, its Zero-Shot performance on close-ended Sound Event Classification is competitive.
168
+
169
+ <table><tr><td></td><td colspan="3">Zero-Shot Sound Event Classification ↑</td></tr><tr><td>Model</td><td>ESC50</td><td>FSD50K</td><td>US8K</td><td>DCASE17 Task 4</td></tr><tr><td>Wav2CLIP</td><td>0.414</td><td>0.030</td><td>0.404</td><td>1</td></tr><tr><td>AudioCLIP</td><td>0.694</td><td></td><td>0.653</td><td>-</td></tr><tr><td>CLAP</td><td>0.826</td><td>0.302</td><td>0.732</td><td>0.3</td></tr><tr><td>LAION</td><td>0.91</td><td>-</td><td>0.77</td><td>-</td></tr><tr><td>Pengi</td><td>0.92</td><td>0.468</td><td>0.719</td><td>0.338</td></tr></table>
170
+
171
+ Table 8: The literature on Zero-Shot audio models only reports performance on Sound Event Classification datasets. Pengi’s classification performance is competitive. The ‘-’ indicates numbers are not available. The evaluation metric for DCASE17 is the F1 score while FSD50K employs mAP, ESC50 and US8K use Accuracy.
172
+
173
+ # 5.4 Text-to-Audio Retrieval
174
+
175
+ For Text-to-Audio Retrieval in a contrastive learning setup, the user query is converted into a text embedding which is then used to retrieve the top $k$ audios by their audio embeddings [11, 58]. Pengi is a generative model and does not allow a contrastive setup. Although Pengi has an audio encoder and a text encoder that could replicate the contrastive setup, we wanted to evaluate our model from the generative perspective. First, Pengi is used to index a database by generating audio captions for all the audio recordings. Second, the user text query is matched directly to the dataset captions. The associated audio files of the top $k$ dataset captions are considered to be the top $k$ retrieved audio. Note that the cosine similarity computation is between two text embeddings and not audio and text embeddings. Thus, the quality of generated captions for indexing the dataset is important for retrieval performance.
176
+
177
+ In Table 6, we compared Pengi’s Text-to-Audio retrieval performance against the literature. The models used for comparison are audio captioning models using the above-described procedure of indexing and query matching, and not the contrastive-like setup. Pengi outperforms the literature on $\mathbf { R } \ @ 1$ . However, contrastive models [15],[58], [11] are substantially better than generative models for the task of directly matching text to audio for retrieval. An example of contrastive model performance is shown in Table 6 as a gray row.
178
+
179
+ # 5.5 Next text-token prediction for learning audio representations
180
+
181
+ Pengi uses next-text token prediction to learn audio representations, hence a natural question is: “Can next text-token prediction objective help in learning general purpose audio representations?". To answer this question, we performed linear probe [47] and shallow learning [53] experiments. After Pengi’s pre-training, we took the audio encoder $a _ { \phi }$ in Fig 2 and trained one, two, or three fully-connected linear layer(s) with cross-entropy on top. Note that, we kept Pengi’s audio encoder frozen and it did not include the mapping network $m _ { 1 }$ . We selected representative datasets from the domain of Sound Events, Music, and Speech Emotion for the linear probe experiment. Pengi’s linear probe (one layer) and shallow learning (two or three layers) numbers are compared against the best single model submissions from the HEAR challenge [53] in Table 9. The results from HEAR challenge reported the maximum of both settings $\boldsymbol { L } _ { 1 }$ or $L _ { 2 } , L _ { 3 } )$ . Apart from Wav2vec2 which is trained on speech data, all other models were trained on non-speech audio. Pengi’s linear probe $L _ { 1 }$ and $L _ { 3 }$ performance is consistently better than CLAP [15]. In the Sound Events and Music domain, Pengi outperformed other models. In the Speech Emotion domain, Pengi performed better than non-speech models but lower than models trained on speech (Wav2vec2). The experiment indicates that the next token prediction does help in learning audio representations useful for various domains.
182
+
183
+ <table><tr><td rowspan="2">Model</td><td colspan="2">Sound Events↑</td><td colspan="2">Music个</td><td colspan="2">Speech Emotion↑</td></tr><tr><td>ESC50</td><td>FSD50k</td><td>GTZAN Genres</td><td>Opera</td><td>RAVDESS</td><td>CREMA-D</td></tr><tr><td>YAMNet</td><td>0.8375</td><td>-</td><td>0.847</td><td>0.9405</td><td>0.479</td><td>0.4533</td></tr><tr><td>Open L3</td><td>0.7505</td><td>0.4470</td><td>0.879</td><td>0.9746</td><td>0.604</td><td>0.5497</td></tr><tr><td>Wav2CLIP</td><td>0.7589</td><td>0.3617</td><td>0.748</td><td>0.9363</td><td>0.684</td><td>0.5116</td></tr><tr><td>PaNN</td><td>0.9085</td><td>-</td><td>0.860</td><td>0.9112</td><td>0.429</td><td>0.5550</td></tr><tr><td>Wav2Vec2</td><td>0.5610</td><td>0.3417</td><td>0.780</td><td>0.9067</td><td></td><td>0.6562</td></tr><tr><td>CLAP (L1)</td><td>0.8995</td><td>0.5024</td><td>0.73</td><td>0.6399</td><td>0.4044</td><td>0.2315</td></tr><tr><td>CLAP (L3)</td><td>0.9310</td><td>0.5690</td><td>0.8330</td><td>0.8263</td><td>0.4512</td><td>0.2830</td></tr><tr><td>Pengi (ZS)</td><td>0.9195</td><td>0.4676</td><td>0.3525</td><td>0.6229</td><td>0.2032</td><td>0.1846</td></tr><tr><td>Pengi (L1)</td><td>0.8915</td><td>0.5608</td><td>0.8000</td><td>0.9193</td><td>0.4774</td><td>0.5057</td></tr><tr><td>Pengi(L3)</td><td>0.9485</td><td>0.6235</td><td>0.9010</td><td>0.9883</td><td>0.6108</td><td>0.5916</td></tr></table>
184
+
185
+ Table 9: Shallow learning experiment where the audio encoder is frozen in all the experiments. ZS is zero-shot and $L _ { i }$ indicates $i$ linear layers used. Unless specified, each model reports the best of $L _ { 1 }$ , $L _ { 2 }$ , and $L _ { 3 }$ .
186
+
187
+ # 6 Limitations
188
+
189
+ Trade-off between close-ended and open-ended tasks performance. The classification and text generation performance of Pengi is competitive against contrastive models. However, text-based retrieval performance lags behind that of contrastive models [11, 58]. Although these models excel at retrieval, they are limited to close-ended tasks. Thus, there is a trade-off between both types of learning methods proposed so far in the literature.
190
+
191
+ Limitations inherent to Language Models. Pengi benefits from the encyclopedic knowledge of pre-trained Language Models (LM). However, as pretrained LM is a component of Pengi, they also inherit their limitations. For example, LM are known to hallucinate [28] and specific to Pengi, can produce responses not grounded or conditioned on audio. Similarly, Pengi falls back to LM behavior if no audio is provided or if the audio knowledge is limited. Therefore, the risks of LM, namely propagating stereotypes, and biases and potentially producing offensive language are still applicable to Pengi. The recent works [48, 56] in the NLP field try to address these issues. However, specifically studying risks and limitations can uncover new insights that can accelerate the development of ALMs.
192
+
193
+ # 7 Conclusions
194
+
195
+ We proposed Pengi, a novel Audio Language Model that leverages Transfer Learning by framing all audio tasks as text-generation tasks. It takes as input, an audio recording, and a text prompt, and generates free-form text as output. Pengi is capable of handling both, close-ended and open-ended audio tasks. We benchmarked Pengi on 21 downstream tasks and show it yields SoTA performance in several of them. Our findings break ground in prompting language models with audio for generalpurpose audio understanding.
196
+
197
+ # References
198
+
199
+ [1] A. Agostinelli, T. I. Denk, Z. Borsos, J. Engel, M. Verzetti, A. Caillon, Q. Huang, A. Jansen, A. Roberts, M. Tagliasacchi, et al. Musiclm: Generating music from text. arXiv preprint arXiv:2301.11325, 2023.
200
+ [2] J.-B. Alayrac, J. Donahue, P. Luc, A. Miech, I. Barr, Y. Hasson, K. Lenc, A. Mensch, K. Millican, M. Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in Neural Information Processing Systems, 35:23716–23736, 2022.
201
+ [3] A. Baevski, Y. Zhou, A. Mohamed, and M. Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in neural information processing systems, 2020.
202
+ [4] Z. Borsos, R. Marinier, D. Vincent, E. Kharitonov, O. Pietquin, M. Sharifi, O. Teboul, D. Grangier, M. Tagliasacchi, and N. Zeghidour. Audiolm: a language modeling approach to audio generation. arXiv preprint arXiv:2209.03143, 2022.
203
+ [5] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
204
+ [6] K. Chen, X. Du, B. Zhu, Z. Ma, T. Berg-Kirkpatrick, and S. Dubnov. Hts-at: A hierarchical token-semantic audio transformer for sound classification and detection. In ICASSP 2022-2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2022.
205
+ [7] S. Chen, Y. Wu, C. Wang, S. Liu, D. Tompkins, Z. Chen, and F. Wei. Beats: Audio pre-training with acoustic tokenizers. arXiv preprint arXiv:2212.09058, 2022.
206
+ [8] H. W. Chung, L. Hou, S. Longpre, B. Zoph, Y. Tay, W. Fedus, E. Li, X. Wang, M. Dehghani, S. Brahma, et al. Scaling instruction-finetuned language models. arXiv preprint arXiv:2210.11416, 2022.
207
+ [9] M. Defferrard, K. Benzi, P. Vandergheynst, and X. Bresson. FMA: A dataset for music analysis. In 18th International Society for Music Information Retrieval Conference (ISMIR), 2017.
208
+ [10] S. Deshmukh, B. Raj, and R. Singh. Improving weakly supervised sound event detection with self-supervised auxiliary tasks. pages 596–600, 08 2021. doi: 10.21437/Interspeech.2021-2079.
209
+ [11] S. Deshmukh, B. Elizalde, and H. Wang. Audio Retrieval with WavText5K and CLAP Training. In Proc. INTERSPEECH 2023, pages 2948–2952, 2023. doi: 10.21437/Interspeech.2023-1136.
210
+ [12] H. Dhamyal, B. Elizalde, S. Deshmukh, H. Wang, B. Raj, and R. Singh. Describing emotions with acoustic property prompts for speech emotion recognition. arXiv preprint arXiv:2211.07737, 2022.
211
+ [13] K. Drossos, S. Lipping, and T. Virtanen. Clotho: an audio captioning dataset. In IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2020. doi: 10.1109/ICASSP40776.2020.9052990.
212
+ [14] B. Elizalde, S. Zarar, and B. Raj. Cross modal audio search and retrieval with joint embeddings based on text and audio. In ICASSP 2019 - 2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2019.
213
+ [15] B. Elizalde, S. Deshmukh, M. A. Ismail, and H. Wang. Clap: Learning audio concepts from natural language supervision. arXiv preprint arXiv:2206.04769, 2022.
214
+ [16] B. M. Elizalde. Never-ending learning of sounds. Carnegie Mellon University, 2020.
215
+ [17] J. Engel, C. Resnick, A. Roberts, S. Dieleman, M. Norouzi, D. Eck, and K. Simonyan. Neural audio synthesis of musical notes with wavenet autoencoders. In International Conference on Machine Learning, pages 1068–1077. PMLR, 2017.
216
+ [18] E. Fonseca, J. Pons Puig, X. Favory, F. Font Corbera, D. Bogdanov, A. Ferraro, S. Oramas, A. Porter, and X. Serra. Freesound datasets: a platform for the creation of open audio datasets. In Hu X, Cunningham SJ, Turnbull D, Duan Z, editors. Proceedings of the 18th ISMIR Conference; 2017 oct 23-27; Suzhou, China.[Canada]: International Society for Music Information Retrieval. International Society for Music Information Retrieval (ISMIR), 2017.
217
+ [19] E. Fonseca, D. Ortego, K. McGuinness, N. E. O’Connor, and X. Serra. Unsupervised contrastive learning of sound event representations. In ICASSP 2021 - 2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2021. doi: 10.1109/ICASSP39728.2021. 9415009.
218
+ [20] E. Fonseca, X. Favory, J. Pons, F. Font, and X. Serra. Fsd50k: An open dataset of human-labeled sound events. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 2022. doi: 10.1109/TASLP.2021.3133208.
219
+ [21] J. F. Gemmeke, D. P. W. Ellis, D. Freedman, A. Jansen, W. Lawrence, R. C. Moore, M. Plakal, and M. Ritter. Audio set: An ontology and human-labeled dataset for audio events. In 2017 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 776–780, 2017. doi: 10.1109/ICASSP.2017.7952261.
220
+ [22] Y. Gong, C.-I. Lai, Y.-A. Chung, and J. Glass. Ssast: Self-supervised audio spectrogram transformer. 36:10699–10709, Jun. 2022. doi: 10.1609/aaai.v36i10.21315. URL https: //ojs.aaai.org/index.php/AAAI/article/view/21315.
221
+ [23] A. Guzhov, F. Raue, J. Hees, and A. Dengel. Audioclip: Extending clip to image, text and audio. In IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2022. doi: 10.1109/ICASSP43922.2022.9747631.
222
+ [24] W.-N. Hsu, B. Bolte, Y.-H. H. Tsai, K. Lakhotia, R. Salakhutdinov, and A. Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460, 2021.
223
+ [25] P.-Y. Huang, H. Xu, J. Li, A. Baevski, M. Auli, W. Galuba, F. Metze, and C. Feichtenhofer. Masked autoencoders that listen. Advances in Neural Information Processing Systems, 35: 28708–28720, 2022.
224
+ [26] Q. Huang, A. Jansen, J. Lee, R. Ganti, J. Y. Li, and D. P. W. Ellis. Mulan: A joint embedding of music audio and natural language. In International Society for Music Information Retrieval Conference, 2022.
225
+ [27] I.-Y. Jeong and J. Park. Cochlscene: Acquisition of acoustic scene data using crowdsourcing. In 2022 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC), pages 17–21. IEEE, 2022.
226
+ [28] Z. Ji, N. Lee, R. Frieske, T. Yu, D. Su, Y. Xu, E. Ishii, Y. J. Bang, A. Madotto, and P. Fung. Survey of hallucination in natural language generation. ACM Computing Surveys, 2023.
227
+ [29] C. Jia, Y. Yang, Y. Xia, Y.-T. Chen, Z. Parekh, H. Pham, Q. Le, Y.-H. Sung, Z. Li, and T. Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
228
+ [30] C. D. Kim, B. Kim, H. Lee, and G. Kim. AudioCaps: Generating Captions for Audios in The Wild. In NAACL-HLT, 2019.
229
+ [31] M. Kim, K. Sung-Bin, and T.-H. Oh. Prefix tuning for automated audio captioning. arXiv preprint arXiv:2303.17489, 2023.
230
+ [32] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. In ICLR (Poster), 2015. URL http://arxiv.org/abs/1412.6980.
231
+ [33] A. S. Koepke, A.-M. Oncescu, J. Henriques, Z. Akata, and S. Albanie. Audio retrieval with natural language queries: A benchmark study. IEEE Transactions on Multimedia, 2022. doi: 10.1109/TMM.2022.3149712.
232
+ [34] B. Lester, R. Al-Rfou, and N. Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3045–3059, 2021.
233
+ [35] L. H. Li, M. Yatskar, D. Yin, C.-J. Hsieh, and K.-W. Chang. Visualbert: Asimple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
234
+ [36] X. L. Li and P. Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4582–4597, 2021.
235
+ [37] S. Lipping, P. Sudarsanam, K. Drossos, and T. Virtanen. Clotho-aqa: A crowdsourced dataset for audio question answering. In 2022 30th European Signal Processing Conference (EUSIPCO), pages 1140–1144. IEEE, 2022.
236
+ [38] R. Lotfian and C. Busso. Building naturalistic emotionally balanced speech corpus by retrieving emotional speech from existing podcast recordings. IEEE Transactions on Affective Computing, 10(4):471–483, 2017.
237
+ [39] O. Mañas, P. Rodriguez Lopez, S. Ahmadi, A. Nematzadeh, Y. Goyal, and A. Agrawal. MAPL: Parameter-efficient adaptation of unimodal pre-trained models for vision-language few-shot prompting. In Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics. Association for Computational Linguistics, 2023.
238
+ [40] I. Martín-Morató and A. Mesaros. What is the ground truth? reliability of multi-annotator data for audio tagging. In 2021 29th European Signal Processing Conference (EUSIPCO), 2021.
239
+ [41] X. Mei, C. Meng, H. Liu, Q. Kong, T. Ko, C. Zhao, M. D. Plumbley, Y. Zou, and W. Wang. Wavcaps: A chatgpt-assisted weakly-labelled audio captioning dataset for audio-language multimodal research. arXiv preprint arXiv:2303.17395, 2023.
240
+ [42] R. Mokady, A. Hertz, and A. H. Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021.
241
+ [43] D. Niizumi, D. Takeuchi, Y. Ohishi, N. Harada, and K. Kashino. Byol for audio: Self-supervised learning for general-purpose audio representation. In 2021 International Joint Conference on Neural Networks, IJCNN 2021, 2021.
242
+ [44] D. Niizumi, D. Takeuchi, Y. Ohishi, N. Harada, and K. Kashino. Byol for audio: Self-supervised learning for general-purpose audio representation. In 2021 International Joint Conference on Neural Networks (IJCNN), pages 1–8, 2021. doi: 10.1109/IJCNN52387.2021.9534474.
243
+ [45] K. J. Piczak. ESC: Dataset for Environmental Sound Classification. In Proceedings of the 23rd Annual ACM Conference on Multimedia, pages 1015–1018. ACM Press, 2015. ISBN 978-1-4503-3459-4. doi: 10.1145/2733373.2806390.
244
+ [46] S. Poria, D. Hazarika, N. Majumder, G. Naik, E. Cambria, and R. Mihalcea. Meld: A multimodal multi-party dataset for emotion recognition in conversations. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 527–536, 2019.
245
+ [47] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning. PMLR, 2021.
246
+ [48] J. W. Rae, S. Borgeaud, T. Cai, K. Millican, J. Hoffmann, F. Song, J. Aslanides, S. Henderson, R. Ring, S. Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
247
+ [49] C. Raffel, N. Shazeer, A. Roberts, K. Lee, S. Narang, M. Matena, Y. Zhou, W. Li, and P. J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research, 21(1):5485–5551, 2020.
248
+ [50] A. Saeed, D. Grangier, and N. Zeghidour. Contrastive learning of general-purpose audio representations. In ICASSP 2021 - 2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2021.
249
+ [51] J. Shor, A. Jansen, R. Maor, O. Lang, O. Tuval, F. de Chaumont Quitry, M. Tagliasacchi, I. Shavitt, D. Emanuel, and Y. Haviv. Towards learning a universal non-semantic representation of speech. Proc. Interspeech 2020, pages 140–144, 2020.
250
+ [52] M. Tsimpoukelli, J. L. Menick, S. Cabi, S. Eslami, O. Vinyals, and F. Hill. Multimodal few-shot learning with frozen language models. Advances in Neural Information Processing Systems, 34: 200–212, 2021.
251
+ [53] J. Turian, J. Shier, et al. HEAR: Holistic Evaluation of Audio Representations. In NeurIPS 2021 Competitions and Demonstrations Track, 2022.
252
+ [54] Z. Wang, J. Yu, A. W. Yu, Z. Dai, Y. Tsvetkov, and Y. Cao. Simvlm: Simple visual language model pretraining with weak supervision. In International Conference on Learning Representations.
253
+ [55] J. Wei, M. Bosma, V. Zhao, K. Guu, A. W. Yu, B. Lester, N. Du, A. M. Dai, and Q. V. Le. Finetuned language models are zero-shot learners. In International Conference on Learning Representations, 2021.
254
+ [56] L. Weidinger, J. Mellor, M. Rauh, C. Griffin, J. Uesato, P.-S. Huang, M. Cheng, M. Glaese, B. Balle, A. Kasirzadeh, et al. Ethical and social risks of harm from language models. arXiv preprint arXiv:2112.04359, 2021.
255
+ [57] H.-H. Wu, P. Seetharaman, K. Kumar, et al. Wav2clip: Learning robust audio representations from clip. In IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2022. doi: 10.1109/ICASSP43922.2022.9747669.
256
+ [58] Y. Wu, K. Chen, T. Zhang, Y. Hui, T. Berg-Kirkpatrick, and S. Dubnov. Large-scale contrastive language-audio pretraining with feature fusion and keyword-to-caption augmentation. arXiv preprint arXiv:2211.06687, 2022.
257
+ [59] L. Yuan, D. Chen, Y.-L. Chen, N. Codella, et al. Florence: A new foundation model for computer vision. arXiv preprint arXiv:2111.11432, 2021.
258
+ [60] A. Zadeh, R. Zellers, E. Pincus, and L.-P. Morency. Mosi: multimodal corpus of sentiment intensity and subjectivity analysis in online opinion videos. arXiv preprint arXiv:1606.06259, 2016.
259
+ [61] A. B. Zadeh, P. P. Liang, S. Poria, E. Cambria, and L.-P. Morency. Multimodal language analysis in the wild: Cmu-mosei dataset and interpretable dynamic fusion graph. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2236–2246, 2018.
260
+ [62] Y. Zhang and Q. Yang. A survey on multi-task learning. IEEE Transactions on Knowledge and Data Engineering, 34(12):5586–5609, 2022. doi: 10.1109/TKDE.2021.3070203.
261
+
262
+ The appendix is organized as follows: In the first few sections (A - C), we describe a set of additional experiments. In Section D, we discuss the contrastive model and its training details. In Section E, we evaluate Pengi’s performance with the audio encoder kept frozen. In Section F, we analyze the effect of text encoder on zero-shot performance. In Section G, we analyze and highlight types of Pengi errors. Lastly, in section H, we compare contrastive and generative pretraining.
263
+
264
+ ![](images/c905d228230946fec2b80f3b7e6eb7abbd8768052410ff843b18c5edf8f7576b.jpg)
265
+ Figure 4: More examples of audio and text prompt input and their corresponding textual responses. Images are for illustration purposes only.
266
+
267
+ ![](images/5c5004737dbdc6cbbea139e34d4d71bc8990947e32d5651eb67583e0cce279bb.jpg)
268
+ Figure 5: The user can also add an additional second text input and guide the output of Pengi. For example, the user can add "in the background" after the audio and text prefix and Pengi produces the output "a person is speaking". Compared to Fig 2, the output of Pengi changes to what the user has prompted in the second text input which is about background sounds.
269
+
270
+ # A Additional text input
271
+
272
+ Pengi takes as input, an audio recording and text, and generates free-form text as output. During inference, an audio encoder $a _ { \phi }$ and a mapping network $m _ { 1 }$ represent each audio recording as a sequence of continuous embeddings. Similarly, a text encoder $g _ { \phi }$ and a mapping network $m _ { 2 }$ does the same for the corresponding text input. Both sequences are combined as a prefix to prompt a pre-trained frozen language model $f _ { \theta }$ . The language model generates tokens starting from the prefix.
273
+
274
+ The text input acts as task induction and helps guide the language model to produce the desired output. Let’s take an example of human speech recording. A text input of "generate audio caption" will generate a caption like "a person speaking with a car moving in the background", while a text input of "this sentiment is" will produce a response like "negative". However, there are instances where we want to guide the language model further to answer or complete a specific query we had. We can do this by additional text input. This is depicted in Fig 5. The second text input gets tokenized by the frozen language model’s tokenizer and converted into continuous embedding by the frozen language model’s embedding function. Therefore, the new prefix consists of a sequence of embeddings associated with audio, first text input, and second text input which originates from the audio encoder, text encoder, and frozen language model’s embedding function respectively.
275
+
276
+ Some examples and the effects of the second text input are shown in Fig 6. Empirically, we have seen the additional second input produces meaningful output only when used with text input of "generate metadata". The examples shown in Fig 6 are cherry-picked. The additional text input often causes Pengi to lose track of the audio data and hallucinate its own text or fall back to frozen language model behavior. It is not clear how to ground the output in audio information when additional text input is provided. Further investigation in this direction will enable new scenarios including in-context learning.
277
+
278
+ ![](images/7d91b92c2d1d359e92b4b94bea29c9edf7817571e3160b00488f7b4d4d5f14d7.jpg)
279
+ Figure 6: Examples of audio-text input with additional text input and their corresponding textual responses. Images are for illustration purposes only. The ‘-’ symbol indicates additional text input was not used.
280
+
281
+ # B Inferring audio prefix
282
+
283
+ The audio encoder and text encoder followed by mapping networks, jointly forms the prefix which prompts the frozen language model. To understand more about Pengi’s natural language response, we try to interpret prefixes as a sequence of tokens or words. Each prefix embedding is mapped to the highest similarity token from the GPT2 vocabulary [42]. The similarity method used is cosine similarity. This is possible as the prefix and GPT2 embeddings occupy the same latent space. We use this method on a few examples from the ESC50 dataset [45]. The examples of Pengi’s generated output and the inferred audio prefix are shown in Table 10. The interpretations are hard to follow but do contain salient words that are related to audio content. For example, each inferred audio prefix contains words associated with content of audio like babies, thunder, chicken, etc which also appear in corresponding Pengi’s natural language output.
284
+
285
+ One reason interpreted prefix does not have a clear structure is that the mapping network has to do two things at once - comprehend both the audio and text input and guide the fixed language model. Mokady et. al.[42] observed that the interpreted prefix is more comprehensible when GPT2 is also fine-tuned. A similar method can be followed to infer the text input prefix, but we didn’t find any interpretable insights there.
286
+
287
+ Table 10: Examples of Pengi output and their corresponding inferred audio prefix. The input text prompt is "generate audio caption" for all examples. We bold the salient words relating to the input audio and text output.
288
+
289
+ <table><tr><td>Text output</td><td>Inferred audioprefix</td></tr><tr><td>a baby is crying loudly and loudly</td><td>and, the my&#x27;s the first the and and fixme the the supern the.coma the BST in in improvis the babies in in the noises from noises in the(the the and innovative for</td></tr><tr><td>a thunder claps and then a thunderstorm hits</td><td>and- the bigHUD the the the and as&quot;] the thethP the.weather the close andscape.thunder in- the Audiostorms interview click in the the and i unsettling,</td></tr><tr><td>a rooster is crowing loudly</td><td>and at the newone the new the and to OUR the theron the.chickens theities the in imperson the chickens to in the Audio sitcom. chickens in the(the the,Mumbai the</td></tr><tr><td>a bird is singing in the background</td><td>and, the great bird the first the and and OUR the the number La the in bird the one great and photography and bird that.in Audio owl interview singing being: the and I innovative,</td></tr></table>
290
+
291
+ # C Effect of text prompts
292
+
293
+ The choice of input text prompt changes Pengi’s downstream task performance. We analyze the performance of seven of the input text prompts defined in Section 4.1 for downstream tasks. For some tasks, only specific prompts are applicable, for example, ‘question: $\{ \} ^ { \flat }$ prompt for AQA and ‘this emotion is’ for emotion recognition. Pengi’s performance on each downstream task corresponding to the different input text prompts is shown in Table 11). In summary, we see that the prompt ‘generate metadata’ works well on average for close-ended downstream tasks.
294
+
295
+ <table><tr><td></td><td colspan="7">Text prompts↑</td></tr><tr><td>Downstream Dataset</td><td>question: 0</td><td>generateaudio caption</td><td>generate metadata</td><td>this is a sound of</td><td>this acoustic scene is</td><td>this music note is</td><td>this emotion is</td></tr><tr><td>Clotho Cap.</td><td></td><td>0.2709</td><td>=</td><td>=</td><td></td><td></td><td></td></tr><tr><td>AudioCaps Cap.</td><td></td><td>0.4667</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ClothoAQA</td><td>0.6453</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ESC50</td><td></td><td>0.8870</td><td>0.9195</td><td>0.6910</td><td></td><td></td><td></td></tr><tr><td>FSD50k</td><td></td><td>0.4676</td><td>0.4504</td><td>0.4572</td><td></td><td></td><td></td></tr><tr><td>US8k</td><td></td><td>0.7185</td><td>0.6585</td><td>0.5731</td><td></td><td></td><td></td></tr><tr><td>DCASE17</td><td></td><td>0.3150</td><td>0.3143</td><td>0.3506</td><td></td><td></td><td></td></tr><tr><td>AudioSet</td><td></td><td>0.1216</td><td>0.1230</td><td>0.1635</td><td></td><td></td><td></td></tr><tr><td>TUT2017</td><td></td><td>0.2562</td><td>0.3525</td><td>0.2216</td><td>0.1716</td><td></td><td></td></tr><tr><td>GTZAN Genres</td><td></td><td>0.3230</td><td>0.3420</td><td>0.3180</td><td></td><td></td><td></td></tr><tr><td>GTZAN MS</td><td></td><td>0.9440</td><td>0.9606</td><td>0.9922</td><td></td><td></td><td></td></tr><tr><td>Opera</td><td></td><td>0.2373</td><td>0.6229</td><td>0.4449</td><td></td><td></td><td></td></tr><tr><td>NSynth Instrument</td><td></td><td></td><td>=</td><td></td><td></td><td>0.5007</td><td></td></tr><tr><td>NSynth Pitch</td><td></td><td></td><td></td><td></td><td></td><td>0.8676</td><td></td></tr><tr><td>NSynth Velocity</td><td></td><td></td><td></td><td></td><td></td><td>0.3728</td><td></td></tr><tr><td>NSynth Qualities</td><td></td><td></td><td></td><td></td><td></td><td>0.3860</td><td></td></tr><tr><td>RAVDESS</td><td></td><td></td><td></td><td></td><td></td><td>-</td><td>0.1846</td></tr><tr><td>CREMAD</td><td></td><td>=</td><td>=</td><td>=</td><td></td><td></td><td>0.2032</td></tr><tr><td>Vocal Sounds</td><td></td><td>0.5778</td><td>0.6035</td><td>0.5688</td><td></td><td></td><td>-</td></tr><tr><td>SESA</td><td></td><td>0.5162</td><td>0.5402</td><td>0.5350</td><td></td><td></td><td>=</td></tr><tr><td>ESC50 Actions</td><td></td><td>0.5277</td><td>0.5111</td><td>0.4846</td><td></td><td></td><td></td></tr><tr><td>Clotho Ret.(T2A)</td><td></td><td>0.0938</td><td>-</td><td>=</td><td></td><td></td><td></td></tr><tr><td>AudioCaps Ret.(T2A)</td><td></td><td>0.1771</td><td>0.1407</td><td></td><td></td><td></td><td></td></tr><tr><td>Clotho Ret.(A2T)</td><td></td><td>0.1148</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AudioCaps Ret. (A2T)</td><td></td><td>0.1819</td><td>0.1771</td><td></td><td></td><td></td><td></td></tr></table>
296
+
297
+ Table 11: We use different text prompts and observe the performance on downstream tasks. ‘-’ indicates the prompt is not used. The metrics used for each downstream tasks are same as Table 3.
298
+
299
+ # D Constrastive Learning model details
300
+
301
+ We follow and train a CLAP [15] model for the choice of contrastive model used in our experiments. We use transformer-based audio and text encoder. The audio encoder is HTSAT [6] and the text encoder is from CLIP [47]. Both the encoders are followed by a linear transformation called the projection layer. We finetune both the encoder and their projection layers. After contrastive training, the audio encoder and text encoder are used in Pengi.
302
+
303
+ Consider a batch size of $N$ . Let the audio and text embedding be represented by $E _ { t } \in \mathcal { R } ^ { N \times d }$ and $E _ { a } \in \mathcal { R } ^ { N \times d }$ . Then the resulting similarity matrix $C$ is:
304
+
305
+ $$
306
+ C = \tau ( E _ { t } \cdot E _ { a } ^ { \ T } )
307
+ $$
308
+
309
+ We use the loss function $( \mathcal { L } )$ of symmetric cross-entropy: projections
310
+
311
+ $$
312
+ \mathcal { L } = 0 . 5 ( \ell _ { t e x t } ( C ) + \ell _ { a u d i o } ( C ) )
313
+ $$
314
+
315
+ where $\begin{array} { r } { \ell _ { k } = \frac { 1 } { N } \sum _ { i = 0 } ^ { N } \log d i a g ( s o f t m a x ( C ) ) } \end{array}$ along text and audio axis respectively.
316
+
317
+ implementation details. The audio is sampled at $4 4 . 1 \mathrm { k H z }$ and is converted to a log Mel spectrogram with 64 Mel bins, a hop size of 320 secs, and a window size of 1024 secs in the range of $5 0 { - } 8 0 0 0 \mathrm { H z }$ . We randomly truncate all audio files to 7 seconds in length for HTSAT. All models are trained with Adam Optimiser [32] for 45 epochs with a batch size of 1536 on 20 V100 GPUs. We use a linear schedule with 2000 warmup steps and a base learning rate of 1e-4.
318
+
319
+ Results. To verify the training, we check our CLAP’s performance on the ESC50 dataset. The results are shown in Table 15.
320
+
321
+ <table><tr><td>Model</td><td>ESC50</td></tr><tr><td>Wav2CLIP AudioCLIP</td><td>0.414 0.694</td></tr><tr><td>CLAP LAION</td><td>0.826 0.91</td></tr><tr><td>CLAP (ours)</td><td>0.89</td></tr></table>
322
+
323
+ Table 12: CLAP zero-shot performance on ESC50
324
+
325
+ # E Frozen audio encoder
326
+
327
+ The audio encoder $a _ { \phi }$ transforms the raw audio input into an audio embedding. We used the audio transformer backbone from CLAP trained in Section D as our audio encoder in our experiments. In Computer Vision, Visual Language Models [42, 2, 39] use an image encoder from CLIP [47] which is frozen throughout experiments. However, there is a magnitude order difference in data collection of image-text vs audio-text pairs. Therefore, for Pengi we train the audio encoder as well. Nonetheless, we report numbers on Pengi’s performance if the audio encoder is kept frozen. The results are shown in Table 13. Frozen Pengi underperforms Pengi across all downstream tasks.
328
+
329
+ <table><tr><td colspan="2"></td><td colspan="2">Audio Captioning↑</td><td colspan="2">Audio Q&amp;A↑</td><td colspan="6">Sound Event Classification ↑</td></tr><tr><td colspan="2">Model</td><td colspan="2">AudioCaps Clotho</td><td colspan="2">ClothoAQA</td><td colspan="2">FSD50K ESC50</td><td colspan="2">US8K DCASE17 Task 4</td></tr><tr><td colspan="2">Frozen Pengi Pengi</td><td colspan="2">0.4535 0.2577 0.4667 0.2709</td><td colspan="2">0.6395 0.6453</td><td colspan="2">0.8950 0.4117 0.9195 0.4676</td><td colspan="3">0.6319 0.3225 0.7185 0.338</td></tr><tr><td></td><td colspan="2">Acoustic Scene Classification↑</td><td colspan="2">Music ↑</td><td colspan="2">Instrument Classification ↑</td><td colspan="4">Music Note Analysis↑</td></tr><tr><td>Model</td><td colspan="2">TUT2017</td><td>Music Speech</td><td>Music Beijing Genres Opera</td><td colspan="2">Instrument family</td><td>NS. Pitch</td><td colspan="2">NS. Velocity</td></tr><tr><td>Frozen Pengi Pengi</td><td colspan="2">0.3449 0.3525</td><td>0.9219 0.9688</td><td>0.2550 0.4814 0.3525 0.6229</td><td colspan="2">0.2949 0.5007</td><td>0.7131 0.8676</td><td>0.3330 0.3728</td><td>Qualities 0.3830 0.3860</td></tr><tr><td rowspan="4"></td><td colspan="2" rowspan="2"></td><td colspan="2">Emotion Recognition↑</td><td colspan="2">Vocal Sound</td><td colspan="2">Action</td><td>Survei</td><td></td></tr><tr><td colspan="2">CRE RAV</td><td colspan="2">Classification↑ Vocal</td><td colspan="2">Recog.↑ ESC50</td><td colspan="2">llance.↑</td></tr><tr><td colspan="2" rowspan="2">Model Frozen Pengi Pengi</td><td colspan="2">MA-D DESS 0.1816 0.1312</td><td colspan="2">Sound 0.5371</td><td colspan="2">SESA Actions 0.5196 0.5316</td><td colspan="2"></td></tr><tr><td colspan="2">0.1846 0.2032</td><td colspan="2">0.6035</td><td colspan="2">0.5277</td><td colspan="2">0.5402</td></tr></table>
330
+
331
+ Table 13: The model ‘Frozen Pengi’ indicates Pengi with audio encoder frozen. The ‘-’ symbol indicates numbers were not available while $\mathbf { \nabla } \cdot \mathbf { \boldsymbol { x } } ^ { * }$ indicates that the model cannot support the task. Higher is better for all numbers. The evaluation metric is mAP for FSD50k, AudioSet, and NSynth sonic; F1 score for DCASE17; and SPIDEr for AudioCaps and Clotho captioning. All other downstream tasks use Accuracy.
332
+
333
+ <table><tr><td colspan="2" rowspan="2"></td><td colspan="2">Audio Captioning↑</td><td colspan="2">Audio Q&amp;A↑</td><td colspan="6">Sound Event Classification↑</td></tr><tr><td colspan="2">Model AudioCaps</td><td colspan="2">Clotho ClothoAQA</td><td colspan="4">ESC50 FSD50K US8K</td><td colspan="2">DCASE17 Task 4</td></tr><tr><td>ExpB Pengi</td><td colspan="2">0.4857 0.2545 0.4667 0.2709</td><td colspan="2">0.6316 0.6453</td><td colspan="2">0.9215 0.9195</td><td colspan="2">0.4478 6882 0.4676 0.7185</td><td colspan="2">0.3314 0.3380</td></tr><tr><td></td><td colspan="2">Acoustic Scene Classification↑</td><td colspan="2">Music↑</td><td colspan="2">Instrument Classification ↑</td><td colspan="4">Music Note Analysis↑</td></tr><tr><td>Model</td><td colspan="2">TUT2017</td><td colspan="2">Music Music Speech</td><td colspan="2">Beijing Instrument</td><td colspan="4">NS. NS.</td></tr><tr><td>ExpB Pengi</td><td colspan="2">0.3241 0.3525</td><td>0.9609 0.9688</td><td>Genres 0.317 0.3525</td><td colspan="2">Opera family 0.6864 0.5 0.6229</td><td colspan="2">Pitch 0.8591 0.8676</td><td>Velocity 0.3708</td><td>Qualities 0.377 0.386</td></tr><tr><td colspan="2" rowspan="4"></td><td colspan="2"></td><td colspan="2"></td><td colspan="2">0.5007 Vocal Sound</td><td colspan="2">Action</td><td colspan="2">0.3728 Survei</td></tr><tr><td colspan="2">Model</td><td colspan="2">Emotion Recognition↑ CRE RAV</td><td>Classification↑ Vocal</td><td colspan="2">Recog.↑ ESC50</td><td colspan="2">llance.个 SESA</td></tr><tr><td>ExpB</td><td colspan="2">MA-D DESS 0.1769</td><td colspan="2">Sound</td><td colspan="2">Actions</td><td colspan="2"></td></tr><tr><td>Pengi</td><td colspan="2">0.1728 0.1846 0.2032</td><td colspan="2">0.5798 0.6035</td><td colspan="2">0.5282 0.5277</td><td colspan="2">0.4923 0.5402</td></tr></table>
334
+
335
+ Table 14: Exp B is Pengi with mapper $m _ { 2 }$ but without the text encoder. The evaluation metric is mAP for FSD50k, AudioSet, ESC50-Actions, and NSynth sonic; F1 score for DCASE17; and SPIDEr for AudioCaps and Clotho captioning. All other downstream tasks use Accuracy.
336
+
337
+ # F Effect of text encoder
338
+
339
+ Pengi’s architecture in Figure 2 consists of a text encoder $g _ { \psi }$ that transforms the input text into text embeddings. Then a mapping network $m _ { 2 }$ converts these embeddings into a sequence of $\mathbf { k }$ embeddings. A natural question that arises here is "Why is an explicit mapping needed for input text?". We conducted two experiments to evaluate the effect of omitting $m _ { 2 }$ and/or the text encoder. We denote Exp A as Pengi without the text encoder and $m _ { 2 }$ (input text directly to LM), and Exp B as Pengi without the text encoder but with $m _ { 2 }$ (input text to $m _ { 2 }$ ). In Exp A, we found that removing resulted in a loss of coherence between the input text prompt and the output text. For example, an input prompt about identifying an emotion class "the emotion is " resulted in random text output and thus random performance. In Exp B, we removed the text encoder but retained $m _ { 2 }$ . The Exp B architecture is depicted in Fig 7 and its results are shown in Table 14. By removing the text encoder, the model performs slightly lower than the proposed architecture with both components.
340
+
341
+ ![](images/49561a34d5e3c19218581c6866c497b4b655e49a5712ab433bff43a14579d14b.jpg)
342
+ Figure 7: Pengi architecture without the text encoder $g _ { \psi }$ . The text prompt is tokenized and embedded by text embedder, followed by the mapping network $m _ { 2 }$ . The results of this architecture are shown in Table 13
343
+
344
+ <table><tr><td colspan="2" rowspan="2"></td><td colspan="2">Audio Captioning↑</td><td colspan="2">Audio Q&amp;A↑</td><td colspan="6">Sound Event Classification 个</td></tr><tr><td colspan="2">Model AudioCaps</td><td colspan="2">Clotho ClothoAQA</td><td colspan="2">ESC50 FSD50K</td><td colspan="2">US8K</td><td colspan="2">DCASE17 Task 4 0.3387</td></tr><tr><td colspan="2">CLAP* Pengi</td><td colspan="2">X X 0.4667 0.2709</td><td colspan="2">X 0.6453</td><td colspan="2">0.8916 0.3398 0.9195 0.4676</td><td colspan="2">0.7661 0.7185</td></tr><tr><td></td><td colspan="2">Acoustic Scene Classification↑</td><td colspan="2">Music ↑</td><td colspan="2">Instrument Classification 个</td><td colspan="4">0.3380 Music Note Analysis↑</td></tr><tr><td>Model</td><td colspan="2">TUT2017</td><td>Music Speech</td><td>Music Genres</td><td colspan="2">Beijing Instrument Opera family</td><td>NS. Pitch</td><td colspan="3">NS. NS.</td></tr><tr><td>CLAP* Pengi</td><td colspan="2">0.3037 0.3525</td><td>1.0 0.9688</td><td>0.479 0.3525</td><td colspan="2">0.4025 0.415</td><td>0.1337</td><td colspan="2">Velocity 0.2185</td><td>Qualities 0.2545</td></tr><tr><td colspan="2" rowspan="2"></td><td></td><td colspan="2"></td><td colspan="2">0.6229 0.5007</td><td colspan="2">0.8676</td><td>0.3728 0.386</td></tr><tr><td></td><td colspan="2">Emotion Recognition↑</td><td>Vocal Sound Classification↑</td><td colspan="2">Action Recog.↑</td><td colspan="2">Survei llance.↑</td></tr><tr><td colspan="2" rowspan="2"></td><td>Model MA-D</td><td colspan="2">CRE RAV DESS</td><td>Vocal Sound</td><td colspan="2">ESC50 Actions</td><td colspan="2">SESA</td></tr><tr><td>CLAP* Pengi</td><td colspan="2">0.1512 0.1692 0.1846 0.2032</td><td>0.5522 0.6035</td><td colspan="2">0.508 0.5277</td><td colspan="2">0.7094 0.5402</td></tr></table>
345
+
346
+ Table 15: We train a new CLAP\* model on the same 3.4M pairs training data used Pengi. The $\mathbf { \nabla } \cdot \mathbf { \boldsymbol { x } } ^ { \mathrm { { * } } }$ indicates that the model cannot support the task. Higher is better for all numbers. The evaluation metric is mAP for FSD50k, AudioSet, ESC50-Actions, and NSynth sonic; F1 score for DCASE17; and SPIDEr for AudioCaps and Clotho captioning. All other downstream tasks use Accuracy.
347
+
348
+ # G Different type of Pengi errors
349
+
350
+ There are three types of errors that lead to a drop in Pengi’s performance. We categorize them into audio concept errors, hierarchy errors, and text-matching errors.
351
+
352
+ Audio concept errors. These types of errors are when the model gets the base audio concepts wrong. For example, while generating an audio caption, the model predicts it as "a sound of a dog barking in a neighboring field" instead of "a sound of door knocks with cars moving nearby". This indicates the model fails to detect the sound event of a door knock and confuses it with dog barking. These are Pengi model errors stemming from the audio encoder.
353
+
354
+ Heirarchy errors. The hierarchy error comes from a mismatch between Pengi’s model prediction and the target domain classification. For example, in classifying sound events, Pengi predicts the sound as "domestic sounds", however for ESC50, the target classification requires a more fine-grained classification within domestic sounds like Vaccum cleaner, Toilet flush, brushing teeth, etc. If text matching is used for classification, then the model will not be able to categorize "domestic sounds" into any of the fine-grained classes. To solve this error and get a more fine-grained response, we can use improved text prompts or switch to the log-likelihood method.
355
+
356
+ Text-matching errors. The text-matching errors are the errors that result from the text embeddings or the text-matching method used. This means depending on the text embedding and similarity method used, the performance of Pengi on close-ended tasks will change.
357
+
358
+ # H Constrastive Learning and Generative Pretraining
359
+
360
+ We compare our model Pengi with CLAP [15], a state-of-the-art Zero-Shot model that has been evaluated on 16 downstream tasks. However, CLAP is trained on a smaller amount of audio-text data. This leads us to ask: “Is the improved performance due to the larger training data or the generative pretraining?”. We already know that generative pretraining allows us to perform open-ended tasks like Audio Captioning, AQA, which are not possible with contrastive models. But this does not tell us if: generative pretraining is beneficial for close-ended tasks like classification?. To answer this question, we train a CLAP model with the same data 4.1) that we use to train Pengi. We call this model CLAP\*.
361
+
362
+ Results. The results are shown in Table 15. We see generative pertaining (Pengi) outperforming contrastive learning (CLAP\*) on average. Moreover, with generative pretraining, the model can perform open-ended tasks like Audio Captioning and Audio Question Answering.
363
+
364
+ An interesting observation is Pengi outperforms human performance $( 8 1 \% )$ on ESC50. Humans have limitations inherent to how much information a participant can handle at once. In the case of ESC50, humans listen to the audio once, and have to remember the audio content, task description, and choose among 50 different classes. Moreover, listeners have different degrees of familiarity with prototypical content from different sound classes, whereas Pengi has been exposed to similar content during training. In a sense, Pengi is an expert listener, whereas the humans in the listening experiment were not.
md/dev/iulEMLYh1uR/iulEMLYh1uR.md ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # THE EFFICIENCY MISNOMER
2
+
3
+ Mostafa Dehghani∗, Anurag Arnab∗, Lucas Beyer∗, Ashish Vaswani, Yi Tay∗ Google Research {dehghani, aarnab, lbeyer, avaswani, yitay}@google.com
4
+
5
+ # ABSTRACT
6
+
7
+ Model efficiency is a critical aspect of developing and deploying machine learning models. Inference time and latency directly affect the user experience, and some applications have hard requirements. In addition to inference costs, model training also have direct financial and environmental impacts. Although there are numerous wellestablished metrics (cost indicators) for measuring model efficiency, researchers and practitioners often assume that these metrics are correlated with each other and report only few of them. In this paper, we thoroughly discuss common cost indicators, their advantages and disadvantages, and how they can contradict each other. We demonstrate how incomplete reporting of cost indicators can lead to partial conclusions and a blurred or incomplete picture of the practical considerations of different models. We further present suggestions to improve reporting of efficiency metrics.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Aside from model quality, the efficiency (Menghani, 2021) of a model is often an important aspect to consider and is commonly used to measure the relative utility of different methods. After all, training time spent on accelerators is directly linked to financial costs and environmental impact. Meanwhile, the speed of a model may be directly linked to user experience. To this end, there have been well-established ways in the literature to assess and report the efficiency of a model such as number of trainable parameters, number of floating-point operations (FLOPs), and speed/throughput.
12
+
13
+ While it is commonly assumed that these cost indicators are correlated (e.g., a lower number of parameters would translate to a higher throughput) we show that this might not necessarily be the case. Therefore, incomplete reporting across the spectrum of cost indicators may lead to an incomplete picture of the metrics, advantages and drawbacks of the proposed method. To this end, we show that it may also be possible to, perhaps unknowingly, misrepresent a model’s efficiency by only reporting favorable cost indicators. Moreover, the choice of cost indicators may also result in unfair, incomplete, or partial conclusions pertaining to model comparisons. We refer to this phenomenon as the ‘efficiency misnomer’.
14
+
15
+ The overall gist of the efficiency misnomer is that no single cost indicator is sufficient. Incomplete reporting (e.g., showing only FLOPs, or the number of trainable parameters) as a measure of efficiency can be misleading. For example, a model with low FLOPs may not actually be fast, given that FLOPs does not take into account information such as degree of parallelism (e.g., depth, recurrence) or hardware-related details like the cost of a memory access. Despite this, FLOPs has been used as the most common cost indicator in many research papers, especially in the recent computer vision literature, to quantify model efficiency (Szegedy et al., 2015; He et al., 2016; Tan and Le, 2019; Feichtenhofer et al., 2019; Fan et al., 2021).
16
+
17
+ Likewise, the number of trainable parameters (size of the model) despite being commonly used as the de-facto cost indicator in the NLP community (Devlin et al., 2018; Liu et al., 2019; Lan et al., 2019) and previously the vision community (Krizhevsky et al., 2012; Simonyan and Zisserman, 2015; Huang et al., 2017; Tan and Le, 2019), can also be misleading when used as a standalone measure of efficiency. Intuitively, a model can have very few trainable parameters and still be very slow, for instance when the parameters are shared among many computational steps (Lan et al., 2019; Dehghani et al., 2018). While the number of trainable parameters can often be insightful to decide if a model fits in memory, it is unlikely to be useful as a standalone cost indicator. That said, it is still common practice to parametermatch models to make ‘fair’ comparisons (Mehta et al., 2020; Lee-Thorp et al., 2021; Tay et al., 2020a; Xue et al., 2021; Wightman et al., 2021), even if one model is in reality slower or faster than another.
18
+
19
+ ![](images/d843b97e2d956e1d26d5beb7b9f1239c72cef62d385b75d314d01911446d0768.jpg)
20
+ Figure 1: Comparison of standard Transformers, Universal Transformers and Switch Transformers in terms of three common cost metrics: number of parameters, FLOPs, and throughput. Relative ranking between models is reversed between the two cost indicators. Experiments and the computation of cost metrics were done with Mesh Tensorflow (Shazeer et al., 2018), using 64 TPU-V3.
21
+
22
+ Meanwhile, using throughput/speed as the primary indicator of efficiency can also be problematic - since this tightly couples implementation details, hardware optimizations, and infrastructure details (e.g., input pipeline latency) into the picture. Hence, this might not present an apples-to-apples comparison of certain methods or worse, across different infrastructures or hardware.
23
+
24
+ Given that the landscape of research on model architectures is diverse, the relationship between cost indicators may strongly deviate from the norm, and learning how to fairly compare models within the context of efficiency-based cost indicators is crucial. For instance, there seems to be a rising trend towards sparse models (Fedus et al., 2021; Riquelme et al., 2021) which usually have an incredibly large number of trainable parameters but maintain the FLOPs and speed of dense models. On the contrary, there are models that are considered lightweight due to their small number of trainable parameters (Lan et al., 2019; Dehghani et al., 2018) but, in actual practice, consume similar amounts of compute. Figure 1 shows an example of how the scaling behavior of a model with respect to parameter count can look favorable, while taking the FLOPs or throughput as the cost indicator, different model scales much better. This example shows how looking at one metric can be deceptive and cost a lot of time and resources, e.g. by choosing the wrong candidate for scaling up.
25
+
26
+ Besides the fact that different cost indicators capture different aspects, they can be chosen to reflect either the cost of training or the cost at inference time. Both training and inference costs can be crucial, depending on the context. Also, a single cost indicator can favor a model over another during inference, but not training (or vice versa). For instance, a model that shares parameters in depth is particularly memory-efficient during inference, but during training, the size of activation that need to be kept for the backward pass is just as large as for a similar model with no parameter sharing.
27
+
28
+ The overarching conundrum here is that first of all, no single cost indicator captures a holistic view that is universally useful to all practitioners or researchers. We show that the trade-offs between cost indicators fall far from the standard assumptions and can be non-trivial to navigate. Moreover, we argue that cost indicators that one cares about strongly depend on the applications and setup in which the models are supposed to be used. For example, for an embedded application, inference speed is paramount, while for deployed recommendation systems, training cost can be extremely important as models are constantly being retrained.
29
+
30
+ The overall contributions of this paper are as follows: We call out the intrinsic difficulty of measuring model efficiency within the context of deep neural networks. We review the most common cost indicators and present the advantages and disadvantages of each and discuss why they might be insufficient as a standalone metric. While obvious, we show examples of how model efficiency might be misrepresented by incomplete reporting of these cost indicators. We characterize this problem, coin the term ‘efficiency misnomer‘, and show that it is more prevalent than imagined.
31
+
32
+ We present experiments where comparing model efficiency strongly depends on the choice of cost indicator, like scenarios where there is parameter sharing, sparsity, or parallelizable operations in the model. Moreover, we briefly review some of the current common practices in the literature and discuss how existing work report comparisons of different models and analyze the efficiency of algorithms. Along with the discussion and analyses, we provide some concrete suggestions and recommendations that we believe would help researchers and practitioners draw more accurate conclusions about the efficiency of different models.
33
+
34
+ # 2 A PRIMER ON COST INDICATORS
35
+
36
+ One of the main considerations in designing neural network architectures is quality-cost tradeoff (Paleyes et al., 2020). In almost all cases, the more computational budget is given to a method, the better the quality of its outcome will be. To account for such a trade-off, several cost indicators are used in the literature of machine learning and its applications to showcase the efficiency of different models. These indicators take different points of view to the computational costs.
37
+
38
+ FLOPs: A widely used metric as the proxy for the computational cost of a model is the number of floating-point multiplication-and-addition operations (Johnson, 2018; Kim et al., 2021; Arnab et al., 2021; Tay et al., 2021a;b; Narayanan et al., 2021; Liu et al., 2021). Alternative to FLOPs, the number of multiply-accumulate $( \mathrm { { M A C } ^ { \mathrm { { 1 } } } } \cdot$ ) as a single unit of operation is also used in the literature (Johnson, 2018). Reported FLOPs are usually calculated using theoretical values. Note that theoretical FLOPs ignores practical factors, like which parts of the model can be parallelized.
39
+
40
+ Number of Parameters: Number of trainable parameters is also used as an indirect indicator of computational complexity as well as memory usage (during inference) (Kim et al., 2021; Arnab et al., 2021; Tan and Le, 2019; Liu et al., 2021; Guo et al., 2020; Mahabadi et al., 2021a;b; Houlsby et al., 2019). Many research works that study the scaling law (Kaplan et al., 2020; Hernandez et al., 2021; Tay et al., 2021b), especially in the NLP domain, use the number of parameters as the primary cost indicator (Devlin et al., 2018; Raffel et al., 2019; Liu et al., 2019; Xue et al., 2021).
41
+
42
+ Speed: Speed is one the most informative indicator for comparing the efficiency of different models (So et al., 2021; Dosovitskiy et al., 2020; Arnab et al., 2021; Tay et al., 2021b; Kim et al., 2021; He et al., 2021a; Narayanan et al., 2021; Lagunas et al., 2021; Liu et al., 2021; Tay et al., 2020c;b). In some setups, when measuring speed, the cost of “pipeline” is also taken into account which better reflects the efficiency in a real-world scenario. Note that speed strongly depends on hardware and implementation, so keeping the hardware fixed or normalizing based on the amount of resources used is the key for a fair comparison. Speed is often reported in various forms:
43
+
44
+ • Throughput refers to the number of examples (or tokens) that are processed within a specific period of time, e.g., “examples (or tokens) per second”.
45
+ • Latency usually refers to the inference time (forward pass) of the model given an example or batch of examples, and is usually presented as “seconds per forward pass”. The main point about latency is that compared to throughput, it ignores parallelism introduced by batching examples. As an example, when processing a batch of 100 examples in 1 second, throughput is 100 examples per second, while latency is 1 second. Thus, latency is an important factor for real-time systems that require user input.
46
+ • Wall-clock time/runtime measures the time spent to process a fixed set of examples by the model. This is often used to measure the training cost, e.g., total training time up to convergence.
47
+ • Pipeline bubble is the time that computing devices are idle at the start and end of every batch (Narayanan et al., 2021), which indirectly measures the speed of the non-pipeline parts of the process.
48
+ • Memory Access Cost (MAC) corresponds to the number of memory accesses. It typically makes up a large portion of runtime and is the actual bottleneck when running on modern platforms with strong computational power such as GPUs and TPUs (Ma et al., 2018).
49
+
50
+ The cost indicators we discussed above present different perspectives on efficiency. However, some of these cost indicators may depend on factors that are not inherent to the design of the model, but on the hardware, the model runs on (e.g., CPU, GPU, or TPU), the framework that the model is implemented in (e.g., JAX, PyTorch, or TensorFlow), or even programming skill. These confounding factors add up to the difficulty of comparisons. For instance, theoretical FLOPs provides a hardware-independent comparison, however, it does not necessarily translate to the speed of a model as it does not capture the sequential dependencies of operations and memory accesses in the model. On the other hand, throughput and peak memory usage, which could better reflect the model’s efficiency in a real-world scenario, strongly depend on the hardware and the implementation. Software support can also be a limiting factor in achieving the best possible hardware performance for a model. In (Barham and Isard, 2019), the authors make an excellent case for improving the programmability of software stack for modern accelerators to enable a wider class of models.
51
+
52
+ In the rest of the paper, we mainly focus on the number of parameters, FLOPs and speed since they capture most common use cases and are most commonly encountered in the literature. Appendix B presents other cost indicators that could be important depending on the use case.
53
+
54
+ # 2.1 TRAINING OR INFERENCE COST?
55
+
56
+ When talking about costs, we can disentangle the cost of training and the cost of inference. Based on the estimate from NVIDIA (Leopold, 2019) and Amazon (Barr, 2019) as major cloud service providers, $80 \%$ of the ML workload is inference processing. Thus, more often, the cost of a model during inference is taken as the real cost with the argument that the amortized per-usage cost of training can be really small compared to the inference cost when a model is deployed to be used by many users. However, with the trend of improving the performance of models by scaling up their computational budget and/or training data, as well as the fast progress and frequency of the emergence of new models, the training cost can be seen as a relevant concern. Moreover, in some cases, we have to frequently retrain models due to, for instance, privacy requirements, or where new data is being continuously generated like in many recommender systems. The importance of inference efficiency is already clear and here, we will discuss more the importance of training efficiency as well as potential issues with reporting training costs.
57
+
58
+ The are several arguments in favor of the importance of reporting training costs and the need for models that train efficiently. For instance, from a research and development point of view, when a class of models is efficient during training, it is more likely to see improvements in their performance, due to ease of iterating on ideas around them. Moreover, when a model shows merit in terms of performance, usually some posthoc modifications can be applied to improve its inference efficiency.
59
+
60
+ Besides, the memory requirements of different models can be wildly different during training, although their inference memory consumption is comparable. For instance, different optimizers use different amounts of memory on the device, for instance, SGD-Momentum (Qian, 1999) vs SAM (Foret et al., 2020). If the success of a model is strongly tied to using an optimizer with a high memory cost, it can become a bottleneck during training when we plan to scale that model up compared to the model that uses a more memory-efficient optimizer.
61
+
62
+ Another example is a model that has a high degree of parameter sharing, which could be extremely efficient in terms of inference memory usage, but during training, the size of activation we need to keep for the backward pass is as big as a similar model with no parameter sharing. Activation and their statistics form a big portion of memory usage compared to parameter size, decreasing the “number of parameters” by parameter sharing may not lead to any significant decrease in the memory usage during training (Dehghani et al., 2018).
63
+
64
+ Gaming with training time Whilst “training time” can be a great cost indicator, it is also prone to Goodhart’s Law: When used as the main metric, it can and will be gamed and lose its meaning. First of all, it is difficult to compare architectures with respect to training time, since training time includes the whole “recipe” and different ingredients may be better fits for different architectures. For instance, MobileNet and EfficientNets almost exclusively work well with the RMSProp optimizer (Pham, 2021).
65
+
66
+ Second, because the full training recipe is inevitably involved, the only meaningful claim to be made is achieving higher accuracy with smaller total training cost; a good example of this is Table 1 in Wightman et al. (2021). The training cost may be in terms of any of the indicators described above. However, counting training cost in terms of steps can be problematic as step count in itself is not a meaningful metric, and can be stretched arbitrarily with optimizers introducing multi-step lookahead schemes (Zhang et al., 2019).
67
+
68
+ ![](images/151479432300151d7d3a4dec60d8393434bc7895b39e20b36c0bca94365408ee.jpg)
69
+ Figure 2: The learning progress of a ResNet- $1 0 1 \times 3$ on JFT-300M with short and long schedules, obtained from (Kolesnikov et al., 2020). Decaying the learning rate too early leads to higher performance in lower steps, but the final performance is significantly worse.
70
+
71
+ Conversely, it may be tempting to claim that a method A performs almost as well as another method B with dramatically reduced training cost. Such a claim is not valid, as method A may not have been optimized for training cost, and may well just be re-tuned with that in mind and outperform method B. For example, training hyper-parameters such as learning rate and weight decay, can be tuned such that they achieve good quality quickly, but then plateau to lower points than in “slower” settings that eventually reach higher quality. This is illustrated by Figure 2, obtained from Kolesnikov et al. (2020), where the “long” training schedule (which is not optimized for training cost) for ResNet-101x3 achieves the best performance, but the “short” schedule converges significantly faster to a lower final accuracy. Another example, in the context of reinforcement learning, is the Rainbow baseline of Kaiser et al. (2019) which was subsequently re-tuned in van Hasselt et al. (2019), and shown to benefit from significantly longer training schedules too.
72
+
73
+ Some works, like the MLPerf benchmark (Mattson et al., 2019), aim at decreasing the training cost required to reach a fixed quality X with a fixed model M. While this is a good way of fixing the many moving pieces of training a deep learning model, it should be noted that due to Goodhart’s law, results do not mean more than “reaching quality X with model M”. Specifically, if a method A reaches quality $\mathbf { X }$ twice as fast as a method $_ \mathrm { B }$ while both using model M, this can neither be used to imply anything about their comparison when using model N, nor to imply anything on their comparison with the target quality $\mathbf { X } { + \epsilon }$ : it could well be that method B gets to $\mathbf { X } { + \epsilon }$ faster than $\mathtt { A }$ , or worse, A may never reach $\mathbf { X } { + \epsilon }$ . Figure 3 shows another concrete example, obtained from (Kolesnikov et al., 2020) where we see faster initial convergence of a ResNet model when trained with lower weight decay, which may trick the practitioner into selecting a sub-optimal value, while using a higher weight decay leads to a slower convergence, but a better final performance.
74
+
75
+ ![](images/fe2a7651d8858b8ef167d323ccec0efe9c76697ccb58111ed17472d4fafcd4f6.jpg)
76
+ Figure 3: The learning progress of a ResNet- $. 1 0 1 \times 3$ on JFT-300M with different weight decays, obtained from (Kolesnikov et al., 2020). Lower weight decay leads to acceleration of convergence, while eventually results in an under-performing final model.
77
+
78
+ A final concern is that, methods which seemingly train faster tend to be used more often and hence get optimized more over time, with the danger of getting stuck in a local minimum (Hooker, 2020; Dehghani et al., 2021b).
79
+
80
+ # 2.2 POTENTIAL DISAGREEMENT BETWEEN COST INDICATORS
81
+
82
+ In this section, we will discuss some of the cases in which there could be disagreement between some of the cost indicators we discussed before.
83
+
84
+ Sharing parameters When we introduce a form of parameter sharing, it is clear that compared to the same model with no parameter sharing, we end up having fewer trainable parameters, while the number of FLOPs or speed stays the same. An example is the comparison of the Universal Transformer (UT) (Dehghani et al., 2018) with vanilla Transformer (Vaswani et al., 2017) Figure 1. UT shares parameters of the model in depth, thus stays close to the frontiers of quality-number of parameters. However, when looking at the FLOPs, to maintain a similar capacity in terms of parameter count, UT requires more computation, which makes it not so efficient from the FLOPs point of view.
85
+
86
+ Introducing Sparsity Sparsity is becoming one of the main ways of both scaling up and down deep neural networks. One needs to distinguish between at least two broad classes of sparse neural networks: structured and unstructured.
87
+
88
+ Structured sparse models replace large, dense parts of a model by a collection of much smaller, still dense parts. Examples include variants as simple as replacing dense convolutions by grouped (Xie et al., 2017) or separable (Howard et al., 2017) ones, or as complicated as replacing large blocks by many smaller “expert” blocks and routing examples through the best suited ones only (Fedus et al., 2021; Riquelme et al., 2021). The latter, often called Mixture of Experts (MoE), allows growing the capacity in terms of parameter count, while keeping the computational cost small and constant. Figure 1 compares the quality-cost of Switch Transformer (Fedus et al., 2021), a MoE, to that of vanilla Transformer (Vaswani et al., 2017). While Switch falls short in terms of quality vs parameter count, it offers a great trade-off with respect to quality vs FLOPs and speed.
89
+
90
+ Unstructured sparse models are models where weights of dense operations are made to contain many (almost) zeros (Gale et al., 2019; Evci et al., 2020), which do not contribute to the operation’s result and thus, in principle, can be skipped. This keeps the overall structure of the original model, while significantly reducing the FLOPs of the most expensive operations.
91
+
92
+ ![](images/b985f11be973c54d79bd1d0c4362a1f1fdcbbfd0159952358d8459d5ff7ed693.jpg)
93
+ Figure 4: Comparison of scaling a small ViT in depth (D, number of encoder blocks) vs scaling it in width (W, hidden dimension). Which architecture appears “better”, in terms of cost-quality trade-off, changes depending on which indicator is considered. Experiments and the computation of cost metrics were done with Scenic (Dehghani et al., 2021a), using 64 TPU-V3.
94
+
95
+ Both types of sparse models result in large reductions in theoretical FLOPs, often of several orders of magnitude. However, these do not translate to equally large speed-ups. Difficulties for structured sparse models (especially for the MoE type) include the overhead of routing, and the inability to effectively use batched operations, while for unstructured sparsity, it is not possible for the corresponding low-level operations to reach the same efficiency as their dense counterparts on current hardware, where memory access is significantly more expensive than compute (Gale et al., 2020).
96
+
97
+ Degree of parallelism: Scaling Depth (D) vs. Scaling Width (W) When scaling up the model size, different strategies can be used. Although these different strategies may have a similar effect in terms of parameter count, and even quality, they can have different effects on the cost in terms of FLOPs and throughput. The most common knobs for scaling up models are changing depth (number of layers) and width (hidden dimension) of models (Tay et al., 2021b). To study such an effect, we ran a set of controlled experiments with Vision Transformers (Dosovitskiy et al., 2020), where we scale the width by increasing number of heads (while maintaining the hidden dimensions of heads fixed) as well as that of the FFN, and we also scale up the depth, by only increasing the number of encoder blocks. Note that when changing depth or width of the model (see Table 2 in Appendix A for the exact configurations) all other hyper-parameters are kept fixed based on the default values given by the referenced papers. Figure 4 shows the accuracy of these models with respect to different cost indicators.
98
+
99
+ In general, we can see that considering FLOPs or number parameters as the cost indicator, increasing width is beneficial for smaller budget regions, while increasing depth gives better quality with lower cost when we scale up to higher budget regions. However, this is not necessarily the case when considering speed (msec/img) as the cost indicator. As an example, comparing D48 (a ViT with 48 layers) to W3072, (a ViT with FFN dimension 3072 and QKV dimension 768 split across 8 heads) in terms of FLOPs or number of parameters, they have more or less similar cost, suggesting the D48 as a clear Pareto efficient model2. However, when looking at the speed (msec/img), we observe that W3072 is not necessarily worse than D48, since there are less sequential and more parallelizable operations.
100
+
101
+ Target platform, and implementation In some cases, a certain design in the hardware may lead to discrepancies between the cost indicators. As an example, tensor factorization is used as one of the common techniques to accelerate the matrix multiplication and used for making neural network models more efficient (Zhang et al., 2015b; Jaderberg et al., 2014). Weight decomposition, regardless of its effect on the quality of the model, can reduce the number of FLOPs in neural networks by $7 5 \%$ (Zhang et al., 2015a). However, it has been shown that using weight decomposition on GPUs can be slower as CUDNN that is optimized for $3 \times 3$ (He et al., 2017) convolutions and they prefer single large matrix multiplication instead of several small ones. FNet (Lee-Thorp et al., 2021) also shows how certain architectures can have significantly different speed in different hardware (e.g., GPUs and TPUs). When using a specific hardware and compiler, some small design choices can significantly affect the cost of a model. As an example, Zhai et al. (2021) show that for ViT, using global average pooling instead of a CLS as the representation of the input can significantly reduce the memory cost on TPU-V3. This is because the current TPU hardware pads the length dimension of the inputs to a multiple of 128, which may result in up to a $50 \%$ memory overhead. Another example for how implementation details can affect the efficiency is presented in (Vaswani et al., 2021), where the author discusses how carefully designed implementation of the local neighborhood gathering function for local attention might reduce memory usage while avoiding unnecessary extra computation.
102
+
103
+ ![](images/91490e0fc5cbb5333c134479e705e1e9fbf30ef21cca940fa4de09ef624379a7.jpg)
104
+ Figure 5: Accuracy and value of different cost indicators for different models on ImageNet dataset. Values for accuracies and cost indicators are obtained from (Steiner et al., 2021; Liu et al., 2021). Cost indicators are based on PyTorch implementation of the included models and the throughput is measured on a V100 GPU, using timm (Wightman, 2019).
105
+
106
+ # 3 DISCUSSION
107
+
108
+ The most common use of cost indicators in the ML community is for (1) comparing different models in terms of efficiency using a cost indicator, (2) evaluating different models in terms of quality while fixing the cost across models to have a fair comparison, and (3) choosing models with the right trade-off for the context at hand, e.g, in architecture search. While (1) and (2) are just two sides of the same coin, the focus in the first case is on finding models with better quality, while the second case is concerned with comparing quality while keeping a certain efficiency metric constant.
109
+
110
+ # 3.1 ON PARTIAL CONCLUSIONS FROM INCOMPLETE COMPARISONS
111
+
112
+ As we showed in Section 2, claiming a model is more efficient by reporting better scores on a subset of cost indicators can lead to partial, incomplete and possibly biased conclusions.
113
+
114
+ Figure 5a compares the FLOPs, parameters and run time for several models versus their accuracy on the image classification task. As seen previously in Figure 1, the relative positions of different model architectures are not consistent as the performance metric is varied. For example, on one hand, EfficientNets (Tan and Le, 2019) are on the Pareto-frontier of accuracy-parameter and accuracy-FLOPs trade-offs. On the other hand, the accuracy-throughput curve is dominated by SwinTransformers (Liu et al., 2021). As such, there is no model that is clearly more efficient here and conclusions may differ strongly depending on which efficiency metric is employed.
115
+
116
+ Note that when comparing variants of a single model family, most of cost indicators correlate. Hence, it could be sufficient to consider one of these cost indicators 3. However, comparisons using a single cost indicator between models with completely different architectures are more complicated. Figure 5b shows the correlation between the cost indicators.
117
+
118
+ For example, we can see that for a similar number of FLOPs, EfficientNet has fewer parameters than other model families such as RegNet and SwinTransformer. Conversely, for a similar number of FLOPs, EfficientNet has slower throughput (i.e., higher msec/examples) than RegNet and SwinTransformer. These differences are not surprising, given that we are comparing transformer-based (Dosovitskiy et al., 2020; Liu et al., 2021) and convolution-based architectures (Tan and Le, 2019; Radosavovic et al., 2020). Moreover, some of these models are found via architecture search when optimizing for specific cost-indicators (e.g., EfficientNets are optimized for FLOPs).
119
+
120
+ Another observation from Figure 5 is that some variants of transformer based models have the same parameter count, while significantly different GFLOPs, throughput and accuracy. This is due to the change in the model’s input resolution (e.g., from $2 2 4 \times 2 2 4$ to $3 8 4 \times 3 8 4$ ), leading to different number of input tokens to the transformer encoder. This again indicates how a change in the setup could affect some of the cost indicators significantly while barely impacting others.
121
+
122
+ # 3.2 MAKING FAIR COMPARISONS THROUGH AN EFFICIENCY LENS
123
+
124
+ Efficiency metrics and cost indicators are often used to ground comparisons between two or more models or methods (e.g., a proposed model and baselines). By keeping one or more cost indicators fixed, one would often list models side by side in order to make comparisons fair. There are two main strategies here, namely (1) parameter-matched comparisons, where configuration of all models are chosen to have similar number of trainable parameters; and/or (2) flop/compute matched comparisons, where all models have similar computational budget, e.g., configurations are chosen to have similar FLOPs. Whilst there is no straightforward answer to which strategy is the better one, we highlight two case studies and discuss implications and general recommendations.
125
+
126
+ # 3.2.1 THE ISSUES WITH PARAMETER MATCHED COMPARISONS
127
+
128
+ We delve into some of the potential issues with the parameter-matched comparisons. The gist of many of these issues is that not every parameter is created equal, causing many intricate complexities that might complicate fair comparisons among models. Here we present situations where parameter matched comparison could go wrong.
129
+
130
+ Token-Free Models Token-free models (Xue et al., 2021; Tay et al., 2021c; Jaegle et al., 2021) get rid of the large subword vocabulary by modeling at the character or byte level. A large number of parameters originating from the embedding matrix is therefore dropped when transiting to token-free models. Hence, it remains an open question of how to fairly compare these class of models with their subword counterparts. ByT5 (Xue et al., 2021) proposed to up-scale the Transformer stack in order to compensate for lost parameters in the embedding layer. While this argument was made in the spirit of ‘fairness’ (e.g., comparing both methods at a parameter-matched setup), the up-scaling causes a substantial reduction in model speed. This is largely because parameters in the embedding matrix typically do not incur much computation while increased parameters in other parts of the Transformer stack (more depth/width) lead to a relatively substantial compute cost. What is referred to as base or small size here refers to a model that is significantly more computationally costly (in terms of speed, throughput and FLOPs) than their other counterparts and hence the naming alone can be very misleading to practitioners. To make this fair, ideally, the authors would have to present results that are both parameter matched and compute-matched .
131
+
132
+ Encoder-Decoder vs Decoder-Only Transformers When it comes to pre-trained language models, the choice of backbone architecture, encoder-decoder vs decoder-only, plays an important role in the efficiency of the model with respect to different cost indicators. When comparing these models, we need to know that an encoder-decoder model with $L$ encoder and $L$ decoder layers has approximately a similar amount of parameters as a decoder-only model with $2 L$ layer, while it has half a compute and is twice faster (Raffel et al., 2019). This is due to a form of model sparsity in encoder-decoder architecture. Thus parameter-match comparison in this setup might be unfair to encoder-decoder models, especially when the speed is more of a concern than the memory consumption, e.g., when scaling up.
133
+
134
+ Sparse Models and Mixture-of-Experts A defining feature of sparse models (Lample et al., 2019; Fedus et al., 2021) is that they remain compute-matched while enabling scaling to a large number of parameters. Hence, parameter matched comparisons do not make sense for sparse models and parameter-matching sparse models can be seen as an unfair method of unnecessarily downplaying the strengths of sparse models. This has been also shown in Figure 1, where comparing a switch transformer with a vanilla transformer with the same number of parameters always goes in favor of vanilla transformer. Note that many works in the literature employ compute-matched comparisons for comparing sparse models (Narang et al., 2021; Fedus et al., 2021; Lample et al., 2019).
135
+
136
+ Vision Transformers and Sequence Length Models with a flexible sequence length, such as ViTs when varying patch size, have the opposite property of sparse models: one can instantiate architectures with significantly different computational cost (e.g., FLOPs and speed) while keeping the parameter count similar. Thus, this type of models should not be compared based on parameter count either. Table 1 presents the number of parameters, FLOPs, and inference speed of ViT using different patch sizes. We can see inverse an correlation between parameter size and both FLOPs and speed. Model
137
+
138
+ <table><tr><td>Model</td><td>Input sequence length</td><td>Million parameters</td><td>GFLOPs</td><td>msec/example</td></tr><tr><td>ViT-B/8</td><td>785</td><td>86.5</td><td>78.54</td><td>7.17</td></tr><tr><td>ViT-B/16</td><td>197</td><td>86.6</td><td>17.63</td><td>1.30</td></tr><tr><td>ViT-B/32</td><td>50</td><td>88.2</td><td>4.42</td><td>0.39</td></tr><tr><td>ViT-B/64</td><td>17</td><td>95.3</td><td>0.93</td><td>0.11</td></tr></table>
139
+
140
+ Table 1: Parameters size, FLOPs, and speed of ViT-Base with different patch sizes (i.e., $8 \times 8$ , $1 6 \times 1 6$ $3 2 \times 3 2$ , and $6 4 \times 6 4 )$ . Models are fed by input images of size $2 2 4 \times 2 2 4 \times 3$ , thus the input sequence length is (224/patch size) $) ^ { 2 } { + 1 }$ (for the CLS token). Numbers in the table are reported using the code in Scenic (Dehghani et al., 2021a) when running on 64 TPU-V3.
141
+
142
+ with bigger patch sizes have less FLOPs and are faster, while having more parameters, due to the larger patch embedding module.4
143
+
144
+ # 3.2.2 THE ISSUES WITH COMPUTE MATCHED COMPARISONS
145
+
146
+ We have previously discussed how parameter matched comparisons may be unfair. This section discusses a case where compute matched comparisons may raise concerns. Consider a scenario where the proposed method achieves compute saving by an architectural design that does not influence model parameters at all (e.g., downsampling sequences). A seemingly fair comparison here would be to take a standard model and remove layers or hidden dimensions until both models are compute matched. However, this comparison runs the risk of a baseline model that is handicapped by significantly insufficient model capacity in terms of parameter count and therefore, substantially underperform the proposed method. This is evident in Perceiver IO (Jaegle et al., 2021) where the baseline BERT is shrunk to a mere 20M parameters (compared to 425M in the proposed approach) in a compute matched comparison setup. Moreover, the baseline BERT is also handicapped in terms of depth (6 layers vs 40 layers) which is shown in (Tay et al., 2021b) to be unfavorable. Note that depth is not taken into account for FLOP-matched comparisons and if the authors were to account for speed-match, then the baseline here would be substantially faster than the proposed method. Overall, we do note that making fair compute matched comparisons is clearly nontrivial and a challenging problem. However, our recommendation is that when there is just no easy way to make a fair comparison, we encourage authors to make the best effort in finding a best ‘matched’ setup and show multiple alternatives if possible.
147
+
148
+ # 3.3 COST INDICATORS FOR ARCHITECTURE SEARCH
149
+
150
+ Aside from being used for comparing models, many architecture search studies add a cost indicator to the loss function as a resource constraint (He et al., 2021b) and account for efficiency. To this end, these studies mostly use the parameter size (Pham et al., 2018), FLOPs (Hsu et al., 2018), memory access cost (MAC) (Ma et al., 2018), or real latency (Tan et al., 2019; Wu et al., 2019). Given that we have shown earlier how cost indicators may disagree with one another or lead to impartial conclusions, we suggest that practitioners place extra caution in choosing cost indicators for architecture search algorithms especially given its computational cost and sensitivity to the selected cost indicator. Here, making assumptions that cost indicators are always interchangeable runs the risk of conducting a massive search for finding models that are impractical.
151
+
152
+ # 4 SUGGESTIONS AND CONCLUSION
153
+
154
+ A lot of recent work has focused on comparing different model architectures on the basis of a cost indicator like parameter count or FLOPs. We have demonstrated in this paper that using any cost indicator alone can be misleading, with parameter count being the most problematic one. Oftentimes, parameter count is used to imply “model capacity”; however, when varying model architecture in any nontrivial way, this is wrong. Correctly estimating and comparing capacity across model architectures is an open research problem.
155
+
156
+ Since each indicator stands for something different and comes with its own pros and cons, we suggest always reporting and plotting curves using all available cost indicators, and refraining from highlighting results using just a single one. Moreover, given that it is basically impractical to provide a holistic report of all cost metrics (for instance, runtime on all possible hardwares) narrowing down the efficiency claims to the exact setup that models are evaluated and avoiding overgeneralized conclusions in comparisons can already provide a much more clear picture to the community.
157
+
158
+ # REFERENCES
159
+
160
+ Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia Schmid. ´ Vivit: A video vision transformer. arXiv preprint arXiv:2103.15691, 2021.
161
+
162
+ Paul Barham and Michael Isard. Machine learning systems are stuck in a rut. In Proceedings of the Workshop on Hot Topics in Operating Systems, pages 177–183, 2019.
163
+
164
+ Jefff Barr. Amazon ec2 update. https://aws.amazon.com/blogs/aws/amazon-ec2-update-inf1-instanceswith-aws-inferentia-chips-for-high-performance-cost-effective-inferencing/, 2019. Accessed: 2021- 6-1.
165
+
166
+ Yelysei Bondarenko, Markus Nagel, and Tijmen Blankevoort. Understanding and overcoming the challenges of efficient transformer quantization. arXiv preprint arXiv:2109.12948, 2021.
167
+
168
+ Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers. arXiv preprint arXiv:1807.03819, 2018.
169
+
170
+ Mostafa Dehghani, Alexey Gritsenko, Anurag Arnab, Matthias Minderer, and Yi Tay. Scenic: A JAX library for computer vision research and beyond. arXiv preprint arXiv:2110.11403, 2021a.
171
+
172
+ Mostafa Dehghani, Yi Tay, Alexey A Gritsenko, Zhe Zhao, Neil Houlsby, Fernando Diaz, Donald Metzler, and Oriol Vinyals. The benchmark lottery. arXiv preprint arXiv:2107.07002, 2021b.
173
+
174
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
175
+
176
+ Piotr Dollar, Mannat Singh, and Ross Girshick. Fast and accurate model scaling. In ´ Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 924–932, 2021.
177
+
178
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
179
+
180
+ Utku Evci, Trevor Gale, Jacob Menick, Pablo Samuel Castro, and Erich Elsen. Rigging the lottery: Making all tickets winners. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 2943–2952. PMLR, 2020. URL http://proceedings.mlr.press/v119/ evci20a.html.
181
+
182
+ Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. arXiv preprint arXiv:2104.11227, 2021.
183
+
184
+ William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961, 2021.
185
+
186
+ Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In Proceedings of the IEEE/CVF international conference on computer vision, pages 6202–6211, 2019.
187
+
188
+ Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. arXiv preprint arXiv:2010.01412, 2020.
189
+
190
+ Trevor Gale, Erich Elsen, and Sara Hooker. The state of sparsity in deep neural networks. CoRR, abs/1902.09574, 2019. URL http://arxiv.org/abs/1902.09574.
191
+
192
+ Trevor Gale, Matei Zaharia, Cliff Young, and Erich Elsen. Sparse GPU kernels for deep learning. In Christine Cuicchi, Irene Qualters, and William T. Kramer, editors, Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, SC 2020, Virtual Event / Atlanta, Georgia, USA, November 9-19, 2020, page 17. IEEE/ACM, 2020. doi: 10.1109/ SC41405.2020.00021. URL https://doi.org/10.1109/SC41405.2020.00021.
193
+
194
+ Demi Guo, Alexander M Rush, and Yoon Kim. Parameter-efficient transfer learning with diff pruning. arXiv preprint arXiv:2012.07463, 2020.
195
+
196
+ Junxian He, Graham Neubig, and Taylor Berg-Kirkpatrick. Efficient nearest neighbor language models. arXiv preprint arXiv:2109.04212, 2021a.
197
+
198
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
199
+
200
+ Xin He, Kaiyong Zhao, and Xiaowen Chu. Automl: A survey of the state-of-the-art. Knowledge-Based Systems, 212:106622, 2021b.
201
+
202
+ Yihui He, Xiangyu Zhang, and Jian Sun. Channel pruning for accelerating very deep neural networks. In Proceedings of the IEEE international conference on computer vision, pages 1389–1397, 2017.
203
+
204
+ Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021.
205
+
206
+ Sara Hooker. The hardware lottery. arXiv preprint arXiv:2009.06489, 2020.
207
+
208
+ Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. arXiv preprint arXiv:1902.00751, 2019.
209
+
210
+ Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
211
+
212
+ Chi-Hung Hsu, Shu-Huan Chang, Jhao-Hong Liang, Hsin-Ping Chou, Chun-Hao Liu, Shih-Chieh Chang, Jia-Yu Pan, Yu-Ting Chen, Wei Wei, and Da-Cheng Juan. Monas: Multi-objective neural architecture search using reinforcement learning. arXiv preprint arXiv:1806.10332, 2018.
213
+
214
+ Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 2261–2269. IEEE Computer Society, 2017. doi: 10.1109/CVPR.2017.243. URL https://doi.org/10.1109/CVPR.2017.243.
215
+
216
+ Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. arXiv preprint arXiv:1405.3866, 2014.
217
+
218
+ Andrew Jaegle, Sebastian Borgeaud, Jean-Baptiste Alayrac, Carl Doersch, Catalin Ionescu, David Ding, Skanda Koppula, Daniel Zoran, Andrew Brock, Evan Shelhamer, et al. Perceiver io: A general architecture for structured inputs & outputs. arXiv preprint arXiv:2107.14795, 2021.
219
+
220
+ Jeff Johnson. Rethinking floating point for deep learning. arXiv preprint arXiv:1811.01721, 2018.
221
+
222
+ Lukasz Kaiser, Mohammad Babaeizadeh, Piotr Milos, Blazej Osinski, Roy H. Campbell, Konrad Czechowski, Dumitru Erhan, Chelsea Finn, Piotr Kozakowski, Sergey Levine, Ryan Sepassi, George Tucker, and Henryk Michalewski. Model-based reinforcement learning for atari. CoRR, abs/1903.00374, 2019. URL http://arxiv.org/abs/1903.00374.
223
+
224
+ Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
225
+
226
+ Young Jin Kim, Ammar Ahmad Awan, Alexandre Muzio, Andres Felipe Cruz Salinas, Liyang Lu, Amr Hendy, Samyam Rajbhandari, Yuxiong He, and Hany Hassan Awadalla. Scalable and efficient moe training for multitask multilingual models. arXiv preprint arXiv:2109.10465, 2021.
227
+
228
+ Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part V 16, pages 491–507. Springer, 2020.
229
+
230
+ Dan Kondratyuk, Liangzhe Yuan, Yandong Li, Li Zhang, Mingxing Tan, Matthew Brown, and Boqing Gong. Movinets: Mobile video networks for efficient video recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16020–16030, 2021.
231
+
232
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In Peter L. Bartlett, Fernando C. N. Pereira, Christopher J. C. Burges, Leon Bottou, and Kilian Q. Weinberger, editors, ´ Advances in Neural Information Processing Systems 25: 26th Annual Conference on Neural Information Processing Systems 2012. Proceedings of a meeting held December 3-6, 2012, Lake Tahoe, Nevada, United States, pages 1106–1114, 2012. URL https://proceedings.neurips.cc/paper/2012/hash/ c399862d3b9d6b76c8436e924a68c45b-Abstract.html.
233
+
234
+ Franc¸ois Lagunas, Ella Charlaix, Victor Sanh, and Alexander M Rush. Block pruning for faster transformers. arXiv preprint arXiv:2109.04838, 2021.
235
+
236
+ Guillaume Lample, Alexandre Sablayrolles, Marc’Aurelio Ranzato, Ludovic Denoyer, and Herve´ Jegou. Large memory layers with product keys. ´ arXiv preprint arXiv:1907.05242, 2019.
237
+
238
+ Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite bert for self-supervised learning of language representations. arXiv preprint arXiv:1909.11942, 2019.
239
+
240
+ James Lee-Thorp, Joshua Ainslie, Ilya Eckstein, and Santiago Ontanon. Fnet: Mixing tokens with fourier transforms. arXiv preprint arXiv:2105.03824, 2021.
241
+
242
+ George Leopold. Aws to offer nvidia’s t4 gpus for ai inferencing. www.hpcwire.com/2019/03/19/awsupgrades-its-gpu-backed-ai-inference-platform/, 2019. Accessed: 2021-6-1.
243
+
244
+ 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.
245
+
246
+ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In arXiv preprint arXiv:2103.14030, 2021.
247
+
248
+ Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV), pages 116–131, 2018.
249
+
250
+ Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. Compacter: Efficient low-rank hypercomplex adapter layers. arXiv preprint arXiv:2106.04647, 2021a.
251
+
252
+ Rabeeh Karimi Mahabadi, Sebastian Ruder, Mostafa Dehghani, and James Henderson. Parameterefficient multi-task fine-tuning for transformers via shared hypernetworks. arXiv preprint arXiv:2106.04489, 2021b.
253
+
254
+ Peter Mattson, Christine Cheng, Cody Coleman, Greg Diamos, Paulius Micikevicius, David A. Patterson, Hanlin Tang, Gu-Yeon Wei, Peter Bailis, Victor Bittorf, David Brooks, Dehao Chen, Debojyoti Dutta, Udit Gupta, Kim M. Hazelwood, Andrew Hock, Xinyuan Huang, Bill Jia, Daniel Kang, David Kanter, Naveen Kumar, Jeffery Liao, Guokai Ma, Deepak Narayanan, Tayo Oguntebi, Gennady Pekhimenko, Lillian Pentecost, Vijay Janapa Reddi, Taylor Robie, Tom St. John, Carole-Jean Wu, Lingjie Xu, Cliff Young, and Matei Zaharia. Mlperf training benchmark. CoRR, abs/1910.01500, 2019. URL http://arxiv.org/abs/1910.01500.
255
+
256
+ Sachin Mehta, Marjan Ghazvininejad, Srinivasan Iyer, Luke Zettlemoyer, and Hannaneh Hajishirzi. Delight: Deep and light-weight transformer. arXiv preprint arXiv:2008.00623, 2020.
257
+
258
+ Gaurav Menghani. Efficient deep learning: A survey on making deep learning models smaller, faster, and better. arXiv preprint arXiv:2106.08962, 2021.
259
+
260
+ Sharan Narang, Hyung Won Chung, Yi Tay, William Fedus, Thibault Fevry, Michael Matena, Karishma Malkan, Noah Fiedel, Noam Shazeer, Zhenzhong Lan, et al. Do transformer modifications transfer across implementations and applications? arXiv preprint arXiv:2102.11972, 2021.
261
+
262
+ Deepak Narayanan, Mohammad Shoeybi, Jared Casper, Patrick LeGresley, Mostofa Patwary, Vijay Anand Korthikanti, Dmitri Vainbrand, Prethvi Kashinkunti, Julie Bernauer, Bryan Catanzaro, et al. Efficient large-scale language model training on gpu clusters. arXiv preprint arXiv:2104.04473, 2021.
263
+
264
+ Andrei Paleyes, Raoul-Gabriel Urma, and Neil D Lawrence. Challenges in deploying machine learning: a survey of case studies. arXiv preprint arXiv:2011.09926, 2020.
265
+
266
+ David Patterson, Joseph Gonzalez, Quoc Le, Chen Liang, Lluis-Miquel Munguia, Daniel Rothchild, David So, Maud Texier, and Jeff Dean. Carbon emissions and large neural network training. arXiv preprint arXiv:2104.10350, 2021.
267
+
268
+ Hieu Pham. MS Windows NT kernel description. https://web.archive.org/ web/20211005122822/https://twitter.com/hieupham789/status/ 1371891950111006720?s=20, 2021. Accessed: 2021-05-10.
269
+
270
+ Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In International Conference on Machine Learning, pages 4095–4104. PMLR, 2018.
271
+
272
+ Ning Qian. On the momentum term in gradient descent learning algorithms. Neural networks, 12(1): 145–151, 1999.
273
+
274
+ Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10428–10436, 2020.
275
+
276
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
277
+
278
+ Carlos Riquelme, Joan Puigcerver, Basil Mustafa, Maxim Neumann, Rodolphe Jenatton, Andre Susano ´ Pinto, Daniel Keysers, and Neil Houlsby. Scaling vision with sparse mixture of experts. arXiv preprint arXiv:2106.05974, 2021.
279
+
280
+ Or Sharir, Barak Peleg, and Yoav Shoham. The cost of training nlp models: A concise overview. arXiv preprint arXiv:2004.08900, 2020.
281
+
282
+ Noam Shazeer, Youlong Cheng, Niki Parmar, Dustin Tran, Ashish Vaswani, Penporn Koanantakool, Peter Hawkins, HyoukJoong Lee, Mingsheng Hong, Cliff Young, et al. Mesh-tensorflow: Deep learning for supercomputers. In Advances in Neural Information Processing Systems, pages 10414– 10423, 2018.
283
+
284
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In Yoshua Bengio and Yann LeCun, editors, 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1409.1556.
285
+
286
+ David R So, Wojciech Manke, Hanxiao Liu, Zihang Dai, Noam Shazeer, and Quoc V Le. Primer: ´ Searching for efficient transformers for language modeling. arXiv preprint arXiv:2109.08668, 2021.
287
+
288
+ Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit, and Lucas Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. arXiv preprint arXiv:2106.10270, 2021.
289
+
290
+ Emma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in nlp. arXiv preprint arXiv:1906.02243, 2019.
291
+
292
+ Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott E. Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 1–9. IEEE Computer Society, 2015. doi: 10.1109/CVPR.2015.7298594. URL https://doi.org/10.1109/CVPR.2015.7298594.
293
+
294
+ Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In ICML, 2019.
295
+
296
+ Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2820–2828, 2019.
297
+
298
+ Yi Tay, Dara Bahri, Donald Metzler, Da-Cheng Juan, Zhe Zhao, and Che Zheng. Synthesizer: Rethinking self-attention in transformer models. arXiv preprint arXiv:2005.00743, 2020a.
299
+
300
+ Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena: A benchmark for efficient transformers. arXiv preprint arXiv:2011.04006, 2020b.
301
+
302
+ Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732, 2020c.
303
+
304
+ Yi Tay, Mostafa Dehghani, Vamsi Aribandi, Jai Gupta, Philip Pham, Zhen Qin, Dara Bahri, Da-Cheng Juan, and Donald Metzler. Omninet: Omnidirectional representations from transformers. arXiv preprint arXiv:2103.01075, 2021a.
305
+
306
+ Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, and Donald Metzler. Scale efficiently: Insights from pre-training and fine-tuning transformers. arXiv preprint arXiv:2109.10686, 2021b.
307
+
308
+ Yi Tay, Vinh Q Tran, Sebastian Ruder, Jai Gupta, Hyung Won Chung, Dara Bahri, Zhen Qin, Simon Baumgartner, Cong Yu, and Donald Metzler. Charformer: Fast character transformers via gradientbased subword tokenization. arXiv preprint arXiv:2106.12672, 2021c.
309
+
310
+ Hado van Hasselt, Matteo Hessel, and John Aslanides. When to use parametric models in reinforcement learning? In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. Fox, and Roman Garnett, editors,´ Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 14322–14333, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ 1b742ae215adf18b75449c6e272fd92d-Abstract.html.
311
+
312
+ 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.
313
+
314
+ Ashish Vaswani, Prajit Ramachandran, Aravind Srinivas, Niki Parmar, Blake Hechtman, and Jonathon Shlens. Scaling local self-attention for parameter efficient visual backbones. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12894–12904, 2021.
315
+
316
+ Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models, 2019.
317
+
318
+ Ross Wightman, Hugo Touvron, and Herve Jegou. Resnet strikes back: An improved training procedure in timm. arXiv preprint arXiv:2110.00476, 2021.
319
+
320
+ Bichen Wu, Xiaoliang Dai, Peizhao Zhang, Yanghan Wang, Fei Sun, Yiming Wu, Yuandong Tian, Peter Vajda, Yangqing Jia, and Kurt Keutzer. Fbnet: Hardware-aware efficient convnet design via differentiable neural architecture search. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
321
+
322
+ Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual ´ transformations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1492–1500, 2017.
323
+
324
+ Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, and Colin Raffel. Byt5: Towards a token-free future with pre-trained byte-to-byte models. arXiv preprint arXiv:2105.13626, 2021.
325
+
326
+ Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. arXiv preprint arXiv:2106.04560, 2021.
327
+
328
+ Michael R. Zhang, James Lucas, Jimmy Ba, and Geoffrey E. Hinton. Lookahead optimizer: k steps forward, 1 step back. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. Fox, and Roman Garnett, editors, ´ Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 9593–9604, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ 90fd4f88f588ae64038134f1eeaa023f-Abstract.html.
329
+
330
+ Xiangyu Zhang, Jianhua Zou, Kaiming He, and Jian Sun. Accelerating very deep convolutional networks for classification and detection. IEEE transactions on pattern analysis and machine intelligence, 38(10):1943–1955, 2015a.
331
+
332
+ Xiangyu Zhang, Jianhua Zou, Xiang Ming, Kaiming He, and Jian Sun. Efficient and accurate approximations of nonlinear convolutional networks. In Proceedings of the IEEE Conference on Computer Vision and pattern Recognition, pages 1984–1992, 2015b.
333
+
334
+ # Appendix
335
+
336
+ # A EXPERIMENTAL SETUP: SCALING DEPTH VS. SCALING WIDTH
337
+
338
+ Detailed configurations and scores for the experiments on scaling Vision Transformer, by increasing the depth vs increasing the width of the model.
339
+
340
+ <table><tr><td></td><td colspan="4">Configuration</td><td colspan="3">Cost</td><td>Quality</td></tr><tr><td>Model</td><td>Num layers</td><td>FFN dim</td><td>QKVdim</td><td>Num heads</td><td>Million Parameters</td><td>GFOPs</td><td>msec/img</td><td>ImageNet Accuracy</td></tr><tr><td>D6</td><td>6</td><td>1024</td><td>384</td><td>6</td><td>18.89</td><td>0.61</td><td>0.09</td><td>37.5</td></tr><tr><td>D8</td><td>8</td><td>1024</td><td>384</td><td>6</td><td>22.44</td><td>0.79</td><td>0.11</td><td>42.4</td></tr><tr><td>D16</td><td>16</td><td>1024</td><td>384</td><td>6</td><td>36.63</td><td>1.52</td><td>0.22</td><td>51.5</td></tr><tr><td>D24</td><td>24</td><td>1024</td><td>384</td><td>6</td><td>50.83</td><td>2.25</td><td>0.32</td><td>55.7</td></tr><tr><td>D32</td><td>32</td><td>1024</td><td>384</td><td>6</td><td>65.03</td><td>2.98</td><td>0.43</td><td>58.8</td></tr><tr><td>D48</td><td>48</td><td>1024</td><td>384</td><td>6</td><td>93.42</td><td>4.43</td><td>0.64</td><td>61.8</td></tr><tr><td>W768</td><td>12</td><td>768</td><td>192</td><td>3</td><td>9.47</td><td>0.31</td><td>0.11</td><td>34.4</td></tr><tr><td>W1024</td><td>12</td><td>1024</td><td>384</td><td>6</td><td>24.81</td><td>0.92</td><td>0.16</td><td>45.2</td></tr><tr><td>W1536</td><td>12</td><td>1536</td><td>512</td><td>8</td><td>42.51</td><td>1.70</td><td>0.22</td><td>50.3</td></tr><tr><td>W3072</td><td>12</td><td>3072</td><td>768</td><td>12</td><td>101.52</td><td>4.44</td><td>0.35</td><td>58.3</td></tr><tr><td>W4096</td><td>12</td><td>4096</td><td>1024</td><td>16</td><td>173.10</td><td>7.80</td><td>0.68</td><td>63.3</td></tr></table>
341
+
342
+ Table 2: Detailed configuration as well as cost versus quality scores for experiments on scaling depth or width of Vision Transformer.
343
+
344
+ # B ADDITIONAL COST INDICATORS
345
+
346
+ Depending on the use case, there are other cost indicators that may play a key role in determining the efficiency of a model:
347
+
348
+ Sample efficiency that can be expressed as training data size, e.g. number of data points (or tokens for language models Kaplan et al. (2020)) that a model needs in order to reach a reasonable performance. Being sample efficient depends on many factors, like inductive biases of the model or the training curriculum.
349
+
350
+ Carbon footprint of a model, during training or inference that is a proxy of the environmental impact. Quantifying this cost directly is not straightforward, but (Strubell et al., 2019) proposed the approximate environmental costs of an ML model as Footprin $\begin{array} { r } { \mathrm { ~ ~ \psi ~ } : = ( e e _ { \mathrm { t r a i n } } + \mathrm { q u e r i e s } \times e e _ { \mathrm { i n f e r e n c e } } ) \times } \end{array}$ $\mathrm { C O 2 e _ { d a t a c e n t e r } / K W h }$ , where, ee indicate the electrical energy (Patterson et al., 2021).
351
+
352
+ Monetary , i.e., the expenses for training or serving models, which is reported in the form of figures (Sharir et al., 2020). As an example, the figures for training can be computed as total-train-time $\times$ total number of chips $\times$ prices offered by cloud solutions5. This cost indicator is more often used in business documents, than in scientific articles.
353
+
354
+ number of model activations , proposed by Dollar et al. ´ (2021) as a complexity metric. Model activations refers to the number of elements in the output tensors from the building blocks of the model, e.g., output size of convolutional layers in ResNet. Dollar et al. ´ (2021) argue that the number of activations is a reliable predictor for the model runtime and showed that compared to FLOPs, it is more strongly correlated with the runtime on memory-bandwidth limited hardware.
355
+
356
+ Memory consumption is one of the main dimensions of efficiency and it has been used as a cost indicator in various research works (Bondarenko et al., 2021; Dosovitskiy et al., 2020; Kondratyuk et al., 2021). Reporting memory footprint often is done in form of “peak memory usage”, during training that takes into account the memory consumption by the model, optimizer, and the pipeline. Another form that is also common is comparing the maximum batch size that fits on a specific device for a specific task. Unlike model activation size, memory footprint depends on the hardware and implementation. It has a direct implication of whether a model can fit on a device, which is a hard constraint in some cases.
md/dev/jA235JGM09/jA235JGM09.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/lJWUJWLCJo/lJWUJWLCJo.md ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Unlimiformer: Long-Range Transformers with Unlimited Length Input
2
+
3
+ Amanda Bertsch Uri Alon∗ Graham Neubig Matthew R. Gormley Carnegie Mellon University, USA {abertsch,ualon,gneubig,mgormley}@cs.cmu.edu
4
+
5
+ # Abstract
6
+
7
+ Since the proposal of transformers (Vaswani et al., 2017), these models have been limited to bounded input lengths, because of their need to attend to every token in the input. In this work, we propose Unlimiformer: a general approach that wraps any existing pretrained encoder-decoder transformer, and offloads the cross-attention computation to a single $k$ -nearest-neighbor $( k \mathrm { N N } )$ index, while the returned $k \mathbf { N N }$ distances are the attention dot-product scores. This $k \mathbf { N N }$ index can be kept on either the GPU or CPU memory and queried in sub-linear time; this way, we can index practically unlimited input sequences, while every attention head in every decoder layer retrieves its top- $k$ keys, instead of attending to every key. We evaluate Unlimiformer on several long-document and book-summarization benchmarks, showing that it can process even $5 0 0 \mathrm { k }$ token-long inputs from the BookSum dataset, without any input truncation at test time. We demonstrate that Unlimiformer improves pretrained models such as BART (Lewis et al., 2020a) and Longformer (Beltagy et al., 2020) by extending them to unlimited inputs without additional learned weights and without modifying their code. Our code and models are publicly available, and support LLaMA-2 as well2.
8
+
9
+ # 1 Introduction
10
+
11
+ Transformers (Vaswani et al., 2017) have risen as the dominant sequence-to-sequence architecture. Pretrained transformers generally have a context window of 512 (e.g. BERT (Devlin et al., 2019), T5 (Raffel et al., 2020)) or 1024 tokens (e.g. BART (Lewis et al., 2020b)), which are sufficient lengths for many current conditional generation datasets (XSum; Narayan et al., 2018) (CNN/DM; Nallapati et al., 2016). To address inputs between 1024 and 16,384 tokens, specialized long-context models sparsify or approximate attention (e.g. Longformer (Beltagy et al., 2020), Performers (Choromanski et al., 2020)), allowing the maximum input length to quadruple while remaining computationally feasible. Most long-document summarization and question-answering datasets, such as SCROLLS (Shaham et al., 2022), are included in this range.
12
+
13
+ Yet tasks that involve long narratives, such as book summarization (Krysci ´ nski et al., 2021), can con- ´ tain inputs exceeding 500k tokens. Figure 1 shows the input lengths of several popular summarization and question-answering datasets, plotted against common context window lengths; the longest inputs are more than 34 times longer than Longformer’s context window.
14
+
15
+ In these extremely-long-input cases, vanilla transformers cannot be simply scaled, as naïve selfattention has quadratic complexity. Long-input transformers usually modify the base architecture, and thus necessitate re-pre-training the model from scratch, which requires significant computational resources. Other architectures such as Longformer-Encoder-Decoder (LED; Beltagy et al., 2020) can leverage pretrained models, but they still need to further train new position embeddings or global attention weights, which is computationally and environmentally costly.
16
+
17
+ ![](images/d7f8f07f15dd4696f46293a91d7247308bd99c12f410af1cbae4ad0734ea42cd.jpg)
18
+ Figure 2: In this example, a given LM’s encoder’s maximum input length is 2 tokens. A 6-token input is encoded in chunks and indexed in an index. We inject Unlimiformer into each decoder layer prior to cross-attention. In Unlimiformer, we perform $k \mathbf { N N }$ search to select a 2-token context for each attention head from the index. This makes cross-attention attend to tokens from the entire input sequence, without adding parameters and without changing the given LM’s architecture.
19
+
20
+ We introduce Unlimiformer, a retrieval-based approach to augment pretrained language models to accept inputs of unbounded length at test time. Given a long input sequence, Unlimiformer constructs a $k$ -nearest-neighbor $( k \mathrm { N N } )$ index over the hidden states of all input tokens. Then, every standard cross-attention head in every decoder layer queries the $k \mathbf { N N }$ index, such that the $k \mathbf { N N }$ distances are the attention dotproduct scores, and attends only to the top- $k$ input tokens. In preliminary experiments, we found that the top- $k$ attention keys cover more than $9 9 \%$ of the attention mass, and thus attending only to the top- $k$ keys is an accurate approximation of the full, exact, attention. Unlimiformer can be injected into any existing encoderdecoder transformer to permit unbounded inputs. The index can be stored in either GPU or CPU memory, needs to hold only a single vector per input token, and can be queried in sublinear time. Unlimiformer is illustrated in Figure 2.
21
+
22
+ Unlimiformer is a generic approach: it can be applied to trained models and improve existing checkpoints without adding weights and without further training. When finetuning Unlimiformer, performance is even further improved: across a variety of long-range datasets, not only that
23
+
24
+ ![](images/2c496b186650f8f2fcddfe6ae9331e0ce6305394c5cedc5a888beffa091c1341.jpg)
25
+ Figure 1: Long-range transformers can avoid input truncation in some datasets; however, there are datasets with inputs many times longer than these models’ maximum input length. The dotted lines represent three common maximum input lengths for models; the bars are the average or maximum input length in each dataset, as indicated. Averages for datasets from Koh et al. (2022).
26
+
27
+ Unlimiformer performs better than strong long-range transformers such as LED (Beltagy et al., 2020), PRIMERA (Xiao et al., 2022), SLED (Ivgi et al., 2022) and Memorizing Transformers (Wu et al., 2022), but Unlimiformer can be applied on top of such models to further improve them.
28
+
29
+ # 2 Unlimiformer
30
+
31
+ Given a trained encoder-decoder transformer, Unlimiformer allows each cross-attention head to choose separate keys to attend to from the full-length input, at each decoding step. We inject a kNN
32
+
33
+ search into each decoder layer: prior to cross-attention, the model performs a nearest-neighbor search in a $k \mathbf { N N }$ index to choose a set of per-decoder-layer per-attention-head tokens to attend to.
34
+
35
+ # 2.1 Encoding
36
+
37
+ To encode an input sequence that is longer than the model’s context window, we use the given model’s encoder to encode overlapping chunks of the input, following Ivgi et al. (2022). We keep only the middle half of the encoded vectors from each chunk, to ensure that the encodings have sufficient context on both sides. Finally, we index the encoded inputs in a $k \mathbf { N N }$ index, using a library such as Faiss (Johnson et al., 2019), using dot-product as the index’s nearest-neighbor similarity metric.
38
+
39
+ # 2.2 Retrieval-augmented Cross-Attention
40
+
41
+ In standard cross-attention, a transformer decoder attends to the encoder’s top-layer hidden states, where the encoder usually truncates the input and encodes only the $k$ first tokens in the input sequence.
42
+
43
+ Instead of attending only to this $k$ -token prefix of the input, we retrieve the top- $k$ hidden states from the $k \mathbf { N N }$ index for each cross-attention head, and attend only to these top- $k$ . This allows retrieval from the entire input sequence instead of truncating. Our approach is also cheaper, in computation and GPU-memory, than attending to all input tokens; and because softmax is dominated by the largest values, retrieving the most-attended tokens preserves the vast majority of attention mass.
44
+
45
+ Figure 2 illustrates our generic changes to any sequence-to-sequence transformer’s architecture. The full input is encoded using the encoder in chunks and indexed in a $k \mathbf { N N }$ index; then, the index of encoded hidden states is queried at each decoding step. The $k \mathbf { N N }$ search step is non-parametric and can be injected into any pretrained seq2seq transformer. The search step reformulates attention for space efficiency, as detailed below.
46
+
47
+ # 2.3 Attention reformulation
48
+
49
+ Let $h _ { d }$ be the decoder hidden state and $h _ { e }$ be an encoder’s last layer hidden state. The standard cross-attention computation for a single head in a transformer is:
50
+
51
+ $$
52
+ { \mathrm { A t t n } } ( Q , K , V ) = { \mathrm { s o f t m a x } } \left( { \frac { Q K ^ { T } } { \sqrt { d _ { k } } } } \right) V
53
+ $$
54
+
55
+ where $Q = h _ { d } W _ { q }$ is the product of the decoder states $h _ { d }$ and the query weight matrix $W _ { q }$ ; the keys $K = h _ { e } W _ { k }$ are the product of the last encoder hidden states $h _ { e }$ with the key weight matrix $W _ { k }$ ; and $V = h _ { e } W _ { v }$ is similarly the product of $h _ { e }$ with the value weight matrix $W _ { v }$ . Our goal is to retrieve a set of keys $K _ { b e s t }$ that maximize $Q K _ { b e s t } ^ { T }$ , with the size of $K _ { b e s t }$ fixed to the size of the model’s context window, and then compute the standard attention over $K _ { b e s t }$ only.
56
+
57
+ Note that the linear layers $W _ { q }$ , $W _ { k }$ , and $W _ { v }$ are layer-specific and head-specific. Thus, naïvely creating an index from the keys $K = h _ { e } W _ { k }$ and querying this index using the query vectors will require constructing separate indexes for the keys and values at each layer and each head, for a total of $2 \times L \times H$ indexes, where $L$ is the number of decoder layers and $H$ is the number of attention heads. In fact, this exact naïve approach was taken by Memorizing Transformers (Wu et al., 2022), who pioneered the use of a $k \mathbf { N N }$ index for previously encoded inputs.3 A separate index for each attention head in each decoder layer is both time-intensive to create and space-intensive to store. So, not surprisingly, Wu et al. (2022) apply their memory layer to only a single decoder layer.
58
+
59
+ Instead, we present a different order of computing the well-known transformer attention formula, which allows us to store a single index across all attention heads and all decoder layers, without changing the mathematical definition of the transformer’s standard dot-product attention. The dot-product part of the transformer’s attention computation can be rewritten as follows:4
60
+
61
+ $$
62
+ \begin{array} { r } { Q K ^ { T } = \left( \pmb { h } _ { d } W _ { q } \right) \left( \pmb { h } _ { e } W _ { k } \right) ^ { \top } } \\ { = \left( \pmb { h } _ { d } W _ { q } \right) W _ { k } ^ { \top } \pmb { h } _ { e } ^ { \top } } \\ { = \left( \pmb { h } _ { d } W _ { q } W _ { k } ^ { \top } \right) \pmb { h } _ { e } ^ { \top } } \end{array}
63
+ $$
64
+
65
+ Thus, the retrieval step can be formulated as choosing the encoder hidden states $h _ { e }$ that maximize $\left( h _ { d } W _ { q } W _ { k } ^ { \top } \right) { h _ { e } } ^ { \top }$ . This rewriting has two major advantages: first, there is no need to index the keys for each head and layer separately: we can create a single index of the hidden states $h _ { e }$ only, and just project the queries to $\dot { h _ { d } } W _ { q } W _ { k } ^ { \top }$ using head-specific and layer-specific $W _ { q }$ and $W _ { k }$ ; second, the values can be calculated trivially given $h _ { e }$ , so there is no need to store the values in a separate index from the keys before decoding. Thus, instead of constructing $2 \times L \times H$ indexes and retrieving from all indexes during each decoding step, we construct a single index from $h _ { e }$ and retrieve from it by just projecting the decoder hidden states to per-head per-layer $\pmb { h } _ { d } W _ { q } W _ { k } ^ { \top }$ .
66
+
67
+ Using our reformulation, the index stores only a single vector per input token. Using 16-bit floats and hidden states of size 1024, this requires only 2GB of memory for 1,000,000 input tokens. Since indexes can be offloaded to the CPU memory, Unlimiformer’s input length is practically unlimited.
68
+
69
+ # 3 Training Unlimiformer
70
+
71
+ Unlimiformer can be used, at test time, with an already-trained model, and lead to gains without further training, as we show later in Table 3. Next, we turn our focus to training approaches to further improve the performance of Unlimiformer. Table 1 summarizes and contrasts the training approaches described below, and Appendix A contains further implementation details.
72
+
73
+ <table><tr><td>Method name</td><td>Training input</td><td>total # tokens in example seen at training time</td><td>Validation input (early stopping)</td><td>Test input</td></tr><tr><td>Baseline</td><td>1024</td><td>1024</td><td>1024</td><td>1024</td></tr><tr><td>+test Unlimiformer</td><td>1024</td><td>1024</td><td>1024</td><td>unlimited</td></tr><tr><td>+early stop w/Unlimiformer</td><td>1024</td><td>1024</td><td>unlimited</td><td>unlimited</td></tr><tr><td>Train chunked +test Unlimiformer</td><td>1024</td><td>all</td><td>unlimited</td><td>unlimited</td></tr><tr><td>SLED(Ivgi et al., 2022)</td><td>16k</td><td>16k</td><td>16k</td><td>16k</td></tr><tr><td>Longformer (Beltagy et al., 2020)</td><td>16k</td><td>16k</td><td>16k</td><td>16k</td></tr><tr><td>Random-encoded training</td><td>8-16k</td><td>8-16k</td><td>unlimited</td><td>unlimited</td></tr><tr><td>Retrieval training</td><td>8-16k</td><td>8-16k</td><td>unlimited</td><td>unlimited</td></tr><tr><td>Alternating training</td><td>8-16k</td><td>8-16k</td><td>unlimited</td><td>unlimited</td></tr></table>
74
+
75
+ Table 1: A comparison of the training approaches using BART (context window size 1024) as a running example. The dashed line separates methods that are approximately the same training-time cost as the baseline, from those that require significant additional compute.
76
+
77
+ # 3.1 Low (additional-) Cost Training Methods: Applying Unlimiformer at validation or test-time only
78
+
79
+ We first consider training approaches that do not require significant additional compute as compared to the standard finetuning regime.
80
+
81
+ +test Unlimiformer: As the simplest case, we use a standard fine-tuning regime, where the input is truncated during training. At inference time only, we inject Unlimiformer into the trained model to process full-length inputs.
82
+
83
+ +early stop w/ Unlimiformer: We train without Unlimiformer, but when we evaluate the model for early stopping, we use Unlimiformer for generation on the validation set. This results in choosing a slightly different checkpoint to stop training at; the additional computational cost here is minor, and comes only from the application of Unlimiformer over the validation set.
84
+
85
+ Train chunked +test Unlimiformer: As a data augmentation approach, we split each training example into non-overlapping chunks of the context-window size, and treat each chunk as its own training example. Then, we finetune the model as normal, with this augmented set of examples as the training data. This is orthogonal to the Unlimiformer model, but has the advantage that all tokens from the full-length training example are observed during training instead of truncated—albeit across several examples. We apply early stopping with Unlimiformer on the validation set; when validating, we do not chunk inputs.
86
+
87
+ # 3.2 Long-range Training Methods: Applying Unlimiformer at training time
88
+
89
+ We also consider training Unlimiformer directly, which introduces additional computational cost.
90
+
91
+ Random-encoded training: At each training step, the full (longer-than-context-window) training example is encoded in chunks; then, the keys for each decoder layer are chosen randomly from the encoded hidden states. This weakly simulates a nearest-neighbors search, but is computationally cheaper.
92
+
93
+ Retrieval training: At each training step, the keys for each decoder head and layer are selected using a $k \mathbf { N N }$ search. When inputs are longer than 16k tokens, we truncated the input to 16k tokens at training time due to GPU memory requirements. This training approach is the closest to the test-time computation.
94
+
95
+ Alternating training: In this approach we alternate batches of Random-encoded training and $R e$ - trieval training. Retrieval training is identical to the test-time setting, while Randomencoded introduces regularization that makes the model attend to non-top- $k$ keys as well.
96
+
97
+ # 4 Experimental Settings
98
+
99
+ # 4.1 Datasets
100
+
101
+ <table><tr><td colspan="7">Avg # tokens</td></tr><tr><td>Dataset</td><td>Domain</td><td># examples</td><td>Input</td><td> Output</td><td>Input length distribution</td><td></td></tr><tr><td>GovReport</td><td>Government</td><td>19,402</td><td>9,616</td><td>597</td><td>74</td><td>303192</td></tr><tr><td>SummScreen</td><td>TV shows</td><td>4,348</td><td>8,987</td><td>137</td><td>2365</td><td>22635</td></tr><tr><td>BookSum</td><td>Literature</td><td>436</td><td>143,301</td><td>1294</td><td>8388</td><td>642376</td></tr></table>
102
+
103
+ Table 2: Dataset statistics. The last column is a visualization of the distribution of input example lengths in each dataset; the histogram is binned by powers of 2, with the minimum and maximum input size displayed on either end. The dotted line indicates the mean length.
104
+
105
+ We experiment with two long-document- and one book-summarization datasets from varying domains. Table 2 summarizes statistics for each dataset. GovReport and SummScreen were taken from the SCROLLS benchmark (Shaham et al., 2022). GovReport (Huang et al., 2021) is a long-document summarization dataset where the task is to write the executive summary of a US government report. SummScreen (Chen et al., 2022) is a long-document summarization dataset where the task is to write the recap of a TV show episode (such as “Friends”), given the transcript of the entire episode. BookSum (Krysci ´ nski et al., 2021) is a book-summarization dataset of entire books. BookSum has ´ paragraph, chapter, and book-level settings; we consider the hardest BOOKSUM-Book setting, where the task is to generate a book-level summary given the full text of the novel as input.
106
+
107
+ Metrics We report ROUGE 1/2/L (Lin, 2004) and BERTScore F1 (Zhang et al., 2019). Following Zhang et al. (2021), in BookSum we also used Entity Mention Recall (“EntMent”) as a proxy for the informativeness of the candidate summaries. EntMent measured the fraction of gold entities mentioned in the candidate summary. Additional evaluation details are provided in Appendix C.
108
+
109
+ # 4.2 Baselines
110
+
111
+ BART (base) (Lewis et al., 2020b) is a pretrained seq2seq model (139M parameters), commonly used for summarization tasks. Its maximum input sequence length is 1024 tokens.
112
+
113
+ Table 3: Results on long-document summarization, low-cost training methods: the training costs are no higher than standard finetuning that truncates the inputs to the model’s max input size. The best metric in every training category is marked in bold. PRIMERA (Xiao et al., 2022) is a LongformerEncoder-Decoder (Beltagy et al., 2020) with additional summarization-specific pretraining.
114
+
115
+ <table><tr><td rowspan="2">Base model</td><td rowspan="2">Training method</td><td colspan="2">ROUGE1/2/L/BERTScore</td></tr><tr><td>GovReport</td><td>SummScreen</td></tr><tr><td>BARTbase</td><td>Standard finetuning</td><td>48.7 / 19.2 / 22.8 / 64.3</td><td>29.7 /6.2 / 17.7 / 56.3</td></tr><tr><td>BARTbase</td><td>+test SLED (Ivgi et al., 2022)</td><td>45.8 / 16.1/ 20.2 / 62.7</td><td>27.5 / 5.5 / 16.7 / 55.9</td></tr><tr><td>BARTbase</td><td>+test Unlimiformer</td><td>49.7 / 19.6 / 22.0 / 64.8</td><td>30.9 / 6.5 / 18.2 / 57.5</td></tr><tr><td>BARTbase</td><td>+early stop w/ Unlimiformer</td><td>51.0 / 20.5 /21.5 / 65.1</td><td>32.1 / 6.8 / 18.6 / 57.6</td></tr><tr><td>BARTbase</td><td>Train chunked</td><td>46.2 / 17.8 / 21.7 / 63.3</td><td>28.1 / 5.6 / 17.0 / 55.6</td></tr><tr><td>BARTbase</td><td>+test Unlimiformer</td><td>53.4 / 22.5 / 22.5 / 66.0</td><td>29.3 / 6.6 / 17.6 / 57.0</td></tr><tr><td>PRIMERA</td><td>Standard finetuning</td><td>55.1 / 23.9 / 25.9 / 67.0</td><td>32.3 /7.1/ 18.3 / 57.1</td></tr><tr><td>PRIMERA</td><td>+test Unlimiformer</td><td>56.5 / 24.8 / 26.3 / 67.7</td><td>33.3 / 7.7 / 19.1 / 57.6</td></tr></table>
116
+
117
+ PRIMERA (Xiao et al., 2022) is a Longformer-Encoder-Decoder $( \mathrm { L E D _ { \mathrm { 1 a r g e } } }$ ; Beltagy et al., 2020) (447M parameters), pretrained specifically for multi-document summarization, with maximum input length of 4096 tokens.
118
+
119
+ SLED (Ivgi et al., 2022) extends encoder-decoder models for longer contexts by applying fusion in-decoder (Izacard and Grave, 2021): the long input is encoded in chunks, and the decoder then attends to all input tokens. This allows the use of pretrained models, albeit with expensive fine-tuning. The input sequence length is eventually memory bounded.
120
+
121
+ Memorizing Transformers (Wu et al., 2022) is the most similar work to ours; they propose extending a transformer with a trainable attention gate that moderates between the standard cross-attention and attention over retrieved keys from a datastore. Since their public implementation5 is “not officially supported” and is not fully reproducible, we approximated it by using attention over the index in only a single decoder layer; this is equivalent to their setting with the learned interpolation parameter $g$ set to 1.6 Our work differs from Memorizing Transformers in several key ways: Wu et al. (2022) added additional weights, and thus cannot easily leverage pretrained LMs, while Unlimiformer is fully non-parametric and can improve performance without fine-tuning; further, Wu et al. (2022) applies retrieval attention to only a single layer because of computational constraints, while our attention reformulation enables the use of Unlimiformer in every decoder layer with individualized retrieval per-head, while still being more efficient than Memorizing Transformers, as we detail in Section 2.3.
122
+
123
+ # 5 Results
124
+
125
+ # 5.1 Long Document Summarization
126
+
127
+ Low-cost training Table 3 shows the results in the long-document summarization datasets. First, we can see that applying Unlimiformer on an existing checkpoint without any training ( $^ +$ test Unlimiformer) improves $\mathbf { B A R T _ { b a s e } }$ by, for example, 1.8 ROUGE-1 points on both datasets, and improves PRIMERA by 1-1.4 ROUGE-1 points. In contrast, without additional training, SLED decreases performance. Thus, Unlimiformer is the only model that can provide benefits without further training.
128
+
129
+ Early stop w/ Unlimiformer further improves the base model without any special training: it provides, for example, 3.3 ROUGE-1 points gain on GovReport, while the training computational cost is identical to standard finetuning. Train chunked does not provide benefits on its own; however injecting Unlimiformer applied at test time results in the most significant gains: 7.2 ROUGE-1 and 3 BERTScore points improvements, while training is as computationally cheap as standard finetuning.
130
+
131
+ Table 4: Test results on long-document datasets, when allowing compute-costly, long-range training methods, using different base models. The best metric in every dataset and every training category is marked in bold. The Unlimiformer results in this table are from using the alternating training strategy.
132
+
133
+ <table><tr><td>Base model</td><td>Training method</td><td colspan="2">ROUGE1/2/L/BERTScore GovReport SummScreen</td></tr><tr><td>BARTbase</td><td>Standard finetuning</td><td>48.7 / 19.2 / 22.8 / 64.3</td><td>29.7 /6.2 /17.7 / 56.3</td></tr><tr><td>BARTbase</td><td>SLED (Ivgi et al., 2022)</td><td>54.7 / 24.4 / 25.4 / 67.0</td><td>32.7 / 7.9 /19.1/ 58.4</td></tr><tr><td>BARTbase</td><td>Memorizing transformers</td><td>55.2 /25.1/ 26.4 / 67.5</td><td>32.7 /7.4/19.2/ 57.4</td></tr><tr><td>BARTbase</td><td>Unlimiformer (this work)</td><td>56.6 /26.3 / 27.6 / 68.2</td><td>34.7 / 8.5 /19.9 / 58.5</td></tr><tr><td>PRIMERA</td><td>Standard finetuning</td><td>55.1 / 23.9 /25.9 / 67.0</td><td>32.3/7.1/18.3 / 57.1</td></tr><tr><td>PRIMERA</td><td>Memorizing transformers</td><td>57.0/25.3 /26.5 / 67.7</td><td>33.0 / 7.3 /18.4 / 57.3</td></tr><tr><td>PRIMERA</td><td>Unlimiformer (this work)</td><td>57.4 /26.2/28.0 / 68.1</td><td>33.3 / 7.6 /18.9 / 57.7</td></tr></table>
134
+
135
+ Table 5: Results on BookSum (average input length $\approx 1 4 3 \mathrm { k }$ tokens). EntMent is entity recall. Hierarchical summarization is a baseline reported by Krysci ´ nski et al. (2021), where chapter summaries are ´ condensed to form a book summary. The best metric in every dataset is marked in bold.
136
+
137
+ <table><tr><td>Base model</td><td>Training method</td><td>ROUGE1/2/L</td><td>EntMent</td></tr><tr><td>BARTbase</td><td>Hierarchical (Kryscinski et al., 2021)</td><td>30.0 /6.0 /11.0</td><td>=</td></tr><tr><td>BARTbase</td><td>Standard finetuning</td><td>36.4 / 7.6 /15.3</td><td>10.0</td></tr><tr><td>BARTbase</td><td>+test Unlimiformer</td><td>35.5/7.7 / 15.4</td><td>21.9</td></tr><tr><td>BARTbase</td><td>+early stopw/Unlimiformer</td><td>35.5 / 7.7/ 15.4</td><td>21.9</td></tr><tr><td>BARTbase</td><td>Memorizing Transformers</td><td>35.6 / 6.4 / 14.6</td><td>10.1</td></tr><tr><td>BARTbase</td><td>Unlimiformer (retrieval training)</td><td>36.8 / 8.3 / 15.7</td><td>20.3</td></tr><tr><td>BARTbase</td><td>Unlimiformer (random-encoded training)</td><td>37.3 / 6.7 / 15.2</td><td>20.8</td></tr><tr><td>BARTbase</td><td>Unlimiformer (alternating training)</td><td>36.7 / 7.3 / 15.5</td><td>20.3</td></tr><tr><td>PRIMERA</td><td>Standard finetuning</td><td>38.6 /7.2 /15.6</td><td>11.6</td></tr><tr><td>PRIMERA</td><td>+test Unlimiformer</td><td>38.3 / 7.5 / 15.9</td><td>18.9</td></tr><tr><td>PRIMERA</td><td>+early stop w/ Unlimiformer</td><td>39.5 / 7.3 / 15.8</td><td>22.2</td></tr><tr><td>PRIMERA</td><td>Unlimiformer (retrieval training)</td><td>37.9 /8.2 /16.3</td><td>25.5</td></tr><tr><td>PRIMERA</td><td>Unlimiformer (random-encoded training)</td><td>39.5 / 7.1 / 15.9</td><td>19.7</td></tr><tr><td>PRIMERA</td><td>Unlimiformer (alternating training)</td><td>38.2 /7.1/16.0</td><td>23.4</td></tr></table>
138
+
139
+ Long-range training Table 4 shows results when allowing computationally expensive training approaches. As shown, in almost all metrics and datasets, Unlimiformer outperforms the SLED and Memorizing Transformers baselines when using the same base model.
140
+
141
+ The PRIMERA experiments in Table 4 highlight two important points: first, Unlimiformer+BARTbase performs better than the base PRIMERA across all metrics and datasets, even though PRIMERA is larger and was pretrained on much more data, using a pretraining objective that was designed for summarization; second, not only can Unlimiformer outperform Longformer-based models such as PRIMERA, Unlimiformer can also be applied on top of existing long-range transformers and further improve them: Unlimiformer+PRIMERA improves over PRIMERA across all metrics and datasets. Additional results on the validation set are provided in Appendix E.
142
+
143
+ # 5.2 Book Summarization
144
+
145
+ Table 5 shows the result on BookSum. As shown, Unlimiformer improves both base models $\mathbf { B A R T _ { b a s e } }$ and PRIMERA, in both low-cost training approaches such as Early stop w/ Unlimiformer, as well as in the long-range training approaches. Random-encoded-, Retrieval-, and Alternating- training show competitive performance, with the best method varying across datasets and models.
146
+
147
+ We found that although Unlimiformer outperforms all base models on BookSum (Table 5), the base BART (Standard finetuning, which truncates the input to the first 1024 tokens) shows competitive ROUGE and BERTScore metrics. This is strongly counterintuitive for book summarization, where the book’s plot should not be apparent from reading only the first pages. In the outputs from this base model, we observe limited coherence and a high rate of hallucination (see Appendix F for an example with analysis). However, this is not reflected in n-gram-based overlaps, and BERTScore does not strongly distinguish between any of the BookSum models.
148
+
149
+ ![](images/5c73015bb0df558d5535f4f28a378491375e57818ce870873bc527f935cd744d.jpg)
150
+ Figure 3: As the maximum datastore size increases, the entity recall generally increases. At all datastore sizes, Unlimiformer outperforms the baseline (BART, in red).
151
+
152
+ ![](images/77f8116b485bbb75130a195fdb053924102da068c51aee58e765e46f683fcf24.jpg)
153
+ Figure 4: As the maximum datastore size increases, the inference cost increases sublinearly. The plot shows total wall-clock inference time per example.
154
+
155
+ Nonetheless, the ability to attend to unlimited inputs at test time allows Unlimiformer to achieve significantly better Entity Mention Recall (EntMent): the Unlimiformer models exhibit far higher EntMent, and even adding Unlimiformer only at test time without costly training (Early stop w/ Unlimiformer) doubles the entity recall compared to the base model. Further, Unlimiformer improves EntMent in the base PRIMERA from 11.6 to 25.5 in Unlimiformer+PRIMERA.
156
+
157
+ # 6 Analysis
158
+
159
+ Is the long input really needed? As found in various recent papers (Shaham et al., 2022; Kedzie et al., 2018), many text generation datasets do not require long-range modeling, since most of the needed information is concentrated at the beginning of the input. To evaluate whether Unlimiformer really utilizes long inputs, we experimented with limiting the input length in BookSum. Figure 3 shows the performance of Unlimiformer in BookSum: EntMent increases almost monotonically with input length, suggesting Unlimiformer exploits the longer inputs to generate better outputs.
160
+
161
+ Other work (Jiang and Bansal, 2019) has found that in some datasets, the needed information is concentrated in only part of the input, which is not necessarily the beginning. We observed this trend in WikiSum, a multi-document summarization dataset where the inputs are all references of a Wikipedia article and the output summary is the intro paragraph of the article ${ { \mathrm { L i u } } ^ { * } }$ et al., 2018)7. As a strong baseline, we followed Liu\* et al. (2018), and ranked the input paragraphs according to TF-IDF. Unlimiformer did not improve over a baseline that uses only the first 1024 tokens of this sorted input, suggesting that the full input is not necessary to produce the summary on this dataset8.
162
+
163
+ Computational cost Although Unlimiformer does not introduce additional trained parameters, the encoding of the full input, index construction, and index search increase the processing time during both training and inference. We plot the computational cost of inference with respect to the input length in Figure 4. When all inputs are restricted to 1,024 tokens, Unlimiformer requires a small additional time overhead relative to the baseline for indexing and search. However, the benefits of
164
+
165
+ <table><tr><td>Base model</td><td>Training method</td><td>QASPER F1</td><td>Contract NLI Exact Match</td><td>QMSum ROUGE1/2/L</td><td>Narrative QA F1</td></tr><tr><td>BARTbase</td><td>Standard finetuning</td><td>22.0</td><td>77.5</td><td>30.8 / 8.7 / 20.8</td><td>15.5</td></tr><tr><td>BARTbase</td><td>Unlimiformer</td><td>27.5</td><td>77.7</td><td>30.9 / 8.0 / 19.9</td><td>18.5</td></tr></table>
166
+
167
+ Table 6: Results on question answering, query-based summarization, and NLI datasets.
168
+
169
+ Unlimiformer are clear as input length increases: the total GPU-time required increases sublinearly with input length9. Additional GPU-time measurements are reported in in Appendix D.
170
+
171
+ Performance on other tasks We measure the performance of Unlimiformer relative to the base model on 4 additional datasets: QASPER (Dasigi et al., 2021), a question-answering dataset over NLP papers; Contract NLI (Koreeda and Manning, 2021), a natural language inference dataset over legal contracts; QMSum (Zhong et al., 2021), a query-based summarization dataset over meeting transcripts; and NarrativeQA (Kociský et al., 2018), a reading comprehension dataset over ˇ narratives10.
172
+
173
+ Table 6 shows the performance of BART-Unlimiformer (with alternating training) relative to base BART. On three of the four datasets, applying Unlimiformer improves over the base model.
174
+
175
+ # What is attended to?
176
+
177
+ We plotted the frequency of retrieval for keys across the full decoding process for the test set of BookSum, the dataset with the longest inputs. The average number of input embeddings retrieved at least once varied by method, from $4 3 . 5 \%$ of all tokens for the test-time-only Unlimiformer to $6 4 . 5 \%$ of all tokens for the alternatingtraining model11.
178
+
179
+ Figure 5 shows the retrieval locations for the alternating-training model. We found no specific skew or pattern in the retrieved keys, and keys from the entire input were used by the model; for all models, the median location of a retrieved key was between $4 9 . 7 3 \%$ and $4 9 . 8 7 \%$ of the way through the input document.
180
+
181
+ ![](images/07487a3081bc53faf876d06eba41dcba2c9cc34dab27175513b434ca1c2b4313.jpg)
182
+ Figure 5: Histogram of location of retrieved embeddings in the original document (averaged over the BookSum test set). There is a slight bump at the beginning (first $10 \%$ of the book), but otherwise no strong trend, with tokens retrieved quite uniformly from the entire inputs.
183
+
184
+ # 7 Related Work
185
+
186
+ # Long-range transformers Previous long-range
187
+
188
+ transformers change the transformer architecture to reduce its space or time requirements (Tay et al., 2020). Most solutions achieve this reduction through sparsifying the attention mechanism (Child et al., 2019; Kitaev et al., 2020; Beltagy et al., 2020; Roy et al., 2020; Ainslie et al., 2020; Zaheer et al., 2020). Other works approximate or replace the attention mechanism entirely (Wang et al., 2020; Katharopoulos et al., 2020; Choromanski et al., 2020; Lee-Thorp et al., 2021). All these approaches change the standard transformer architecture or its training objective (Zhong et al., 2022), and thus require pretraining the model from scratch, which does not allow to leverage existing pretrained models. In contrast, Unlimiformer is generic, can be injected into any encoder-decoder transformer, and improve it either without training or with merely fine-tuning. This way, Unlimiformer can leverage any already-pretrained model.
189
+
190
+ Comparison to Wu et al. (2022) The closest work to ours is Memorizing Transformers (Wu et al., 2022). Memorizing Transformers construct two datastores for each attention head in each layer, and due to memory constraints can thus apply their approach only to a single decoder layer. In contrast, thanks to our attention reformulation (Section 2.3) Unlimiformer can use a single index for all decoder layers, and thus allow all cross-attention heads in all decoder layers retrieve from the long context. As we show in Section 5, this results in significant empirical gains over retrieving only at a single layer. Further, Memorizing Transformers introduce additional learned weights, thus they must be trained to incorporate their memory, and thus cannot easily leverage pretrained models; as we show in Section 5 Unlimiformer can improve existing models without any training, and thus can be applied to any existing transformer. Additionally, Memorizing Transformers focused on decoder-only models; while our approach could also be applied to decoder-only models (and would provide a space efficiency boost there as well), we focus on encoder-decoder models in this work.
191
+
192
+ Comparison to Ivgi et al. (2022) Another related work to ours is SLED (Ivgi et al., 2022). SLED encodes long inputs in chunks, similarly to Unlimiformer, but the decoder in SLED attends to all inputs at the same time. This in practice limits SLED to only about 16k token-long inputs on a single GPU; in contrast, instead of attending to all input tokens, Unlimiformer attends only to the top- $k$ input tokens for every attention head, and thus can process unlimited inputs in practice, while preserving more than $9 9 \%$ of the attention mass. Further, SLED requires computationally costly training, while Unlimiformer can provide benefits without any training.
193
+
194
+ Additional related work is discussed in Appendix G.
195
+
196
+ # 8 Conclusions
197
+
198
+ We present Unlimiformer, an approach for augmenting pretrained encoder-decoders and offloading the cross-attention computation to a $k \mathbf { N N }$ index, to allow for unlimited length input. Instead of attending to all keys, this $k \mathbf { N N }$ index allows every cross-attention head in every decoder layer to retrieve and attend only to its top- $k$ keys. We evaluate Unlimiformer on several long-document and book-summarization benchmarks having inputs of up to 500K tokens, and show that Unlimiformer improves existing models, even without further training. When training with Unlimiformer, not only that Unlimiformer makes smaller models such as BART perform better than larger Longformer-based models, Unlimiformer can be applied on top of Longformer-based models and further improve them.
199
+
200
+ Many real-world NLP tasks require processing large amounts of data or text. Yet pretraining large models incurs substantial carbon costs (Strubell et al., 2019), which increase with the length of the context window; by choosing instead to modify already-pretrained models to process longer inputs, we aim to gain the benefits of long contexts with less computational cost. We hope that our approach will allow the democratization of long-range transformers, especially for researchers and practitioners with low-compute resources. Toward this end, we release our code at https: //github.com/abertsch72/unlimiformer. Our code is based on HuggingFace Transformers (Wolf et al., 2020), without changing any individual architecture’s code, and thus can be injected into any encoder-decoder model, and supports decoder models such as LLaMA-2 as well.
201
+
202
+ # 9 Limitations
203
+
204
+ In our experiments, we have only considered English-language datasets. While we have no reason to believe the method would suffer from the use of a different high-resourced language, the quality of the nearest-neighbors search depends on the quality of the indexed keys.
205
+
206
+ The length of inputs that can be used at training time is limited by the GPU memory, as the embeddings and their computational graph must be stored for backpropagation. Multi-GPU training would allow longer inputs at training time.
207
+
208
+ At inference time, Unlimiformer can process the longest inputs when the index is offloaded to the CPU memory. In this case, Unlimiformer requires to index only a single vector per input token, which practically means unlimited inputs for any modern server and even small machines during inference. However, offloading the index to the CPU results in higher test-time latency compared to storing the encoded hidden states and the index on the GPU. In our experiments, we were able to use a GPU index for input examples exceeding $5 0 0 \mathrm { k }$ tokens (on GPUs no larger than 48 GBs), but this may be a concern when using smaller GPUs or larger models.
209
+
210
+ # Acknowledgments
211
+
212
+ We are grateful to Sireesh Gururaja for useful feedback on a draft of this paper. We also thank Maor Ivgi for the help in reproducing results from SLED (Ivgi et al., 2022) and for sharing code and models, and Uri Shaham for the discussions about the SCROLLS benchmark (Shaham et al., 2022). We are also grateful to the anonymous reviewers for their useful comments and suggestions.
213
+
214
+ This work was supported in part by grants from 3M — M\*Modal and from the National Science Foundation Graduate Research Fellowship Program under Grant No. DGE2140739. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the sponsors.
215
+
216
+ # References
217
+
218
+ Joshua Ainslie, Santiago Ontanon, Chris Alberti, Vaclav Cvicek, Zachary Fisher, Philip Pham, Anirudh Ravula, Sumit Sanghai, Qifan Wang, and Li Yang. 2020. Etc: Encoding long and structured inputs in transformers.
219
+
220
+ Uri Alon, Frank F. Xu, Junxian He, Sudipta Sengupta, Dan Roth, and Graham Neubig. 2022. Neurosymbolic language modeling with automaton-augmented retrieval.
221
+
222
+ Ahsaas Bajaj, Pavitra Dangati, Kalpesh Krishna, Pradhiksha Ashok Kumar, Rheeya Uppaal, Bradford Windsor, Eliot Brenner, Dominic Dotterrer, Rajarshi Das, and Andrew McCallum. 2021. Long document summarization in a low resource setting using pretrained language models. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: Student Research Workshop, pages 71–80, Online. Association for Computational Linguistics.
223
+
224
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. 2020. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150.
225
+
226
+ Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George Bm Van Den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. 2022. Improving language models by retrieving from trillions of tokens. In International conference on machine learning, pages 2206–2240. PMLR.
227
+
228
+ Mingda Chen, Zewei Chu, Sam Wiseman, and Kevin Gimpel. 2022. SummScreen: A dataset for abstractive screenplay summarization. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8602–8615, Dublin, Ireland. Association for Computational Linguistics.
229
+
230
+ Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. 2019. Generating long sequences with sparse transformers.
231
+
232
+ Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy Colwell, and Adrian Weller. 2020. Rethinking attention with performers.
233
+
234
+ Pradeep Dasigi, Kyle Lo, Iz Beltagy, Arman Cohan, Noah A. Smith, and Matt Gardner. 2021. A dataset of information-seeking questions and answers anchored in research papers. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 4599–4610, Online. Association for Computational Linguistics.
235
+
236
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics.
237
+
238
+ Andrew Drozdov, Shufan Wang, Razieh Rahimi, Andrew McCallum, Hamed Zamani, and Mohit Iyyer. 2022. You can’t pick your neighbors, or can you? when and how to rely on retrieval in the kNN-LM. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 2997–3007, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
239
+
240
+ Quentin Grail, Julien Perez, and Eric Gaussier. 2021. Globalizing BERT-based transformer architectures for long document summarization. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 1792–1810, Online. Association for Computational Linguistics.
241
+
242
+ Luyang Huang, Shuyang Cao, Nikolaus Parulian, Heng Ji, and Lu Wang. 2021. Efficient attentions for long document summarization. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 1419–1436, Online. Association for Computational Linguistics.
243
+
244
+ Maor Ivgi, Uri Shaham, and Jonathan Berant. 2022. Efficient long-text understanding with short-text models.
245
+
246
+ Gautier Izacard and Edouard Grave. 2021. Leveraging passage retrieval with generative models for open domain question answering. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 874–880, Online. Association for Computational Linguistics.
247
+
248
+ Yichen Jiang and Mohit Bansal. 2019. Avoiding reasoning shortcuts: Adversarial evaluation, training, and model development for multi-hop QA. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2726–2736, Florence, Italy. Association for Computational Linguistics.
249
+
250
+ Jeff Johnson, Matthijs Douze, and Hervé Jégou. 2019. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 7(3):535–547.
251
+
252
+ Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. 2020. Transformers are rnns: Fast autoregressive transformers with linear attention.
253
+
254
+ Chris Kedzie, Kathleen McKeown, and Hal Daumé III. 2018. Content selection in deep learning models of summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1818–1828, Brussels, Belgium. Association for Computational Linguistics.
255
+
256
+ Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. 2019. Generalization through memorization: Nearest neighbor language models.
257
+
258
+ Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. 2020. Reformer: The efficient transformer.
259
+
260
+ Tomáš Kociský, Jonathan Schwarz, Phil Blunsom, Chris Dyer, Karl Moritz Hermann, Gábor Melis,ˇ and Edward Grefenstette. 2018. The NarrativeQA reading comprehension challenge. Transactions of the Association for Computational Linguistics, 6:317–328.
261
+
262
+ Huan Yee Koh, Jiaxin Ju, Ming Liu, and Shirui Pan. 2022. An empirical survey on long document summarization: Datasets, models, and metrics. ACM Comput. Surv., 55(8).
263
+
264
+ Yuta Koreeda and Christopher Manning. 2021. ContractNLI: A dataset for document-level natural language inference for contracts. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 1907–1919, Punta Cana, Dominican Republic. Association for Computational Linguistics.
265
+
266
+ Wojciech Krysci ´ nski, Nazneen Rajani, Divyansh Agarwal, Caiming Xiong, and Dragomir Radev. ´ 2021. Booksum: A collection of datasets for long-form narrative summarization.
267
+
268
+ Juho Lee, Yoonho Lee, Jungtaek Kim, Adam R. Kosiorek, Seungjin Choi, and Yee Whye Teh. 2019. Set transformer: A framework for attention-based permutation-invariant neural networks.
269
+
270
+ James Lee-Thorp, Joshua Ainslie, Ilya Eckstein, and Santiago Ontanon. 2021. Fnet: Mixing tokens with fourier transforms.
271
+
272
+ Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. 2020a. Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7871–7880.
273
+
274
+ Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. 2020b. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7871–7880, Online. Association for Computational Linguistics.
275
+
276
+ Chin-Yew Lin. 2004. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pages 74–81, Barcelona, Spain. Association for Computational Linguistics.
277
+
278
+ Peter J. Liu\*, Mohammad Saleh\*, Etienne Pot, Ben Goodrich, Ryan Sepassi, Lukasz Kaiser, and Noam Shazeer. 2018. Generating wikipedia by summarizing long sequences. In International Conference on Learning Representations.
279
+
280
+ Yang Liu and Mirella Lapata. 2019. Hierarchical transformers for multi-document summarization. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 5070–5081, Florence, Italy. Association for Computational Linguistics.
281
+
282
+ Ramesh Nallapati, Bowen Zhou, Cicero dos Santos, Çaglar Gulçehre, and Bing Xiang. 2016. Ab- ˘ stractive text summarization using sequence-to-sequence RNNs and beyond. In Proceedings of the 20th SIGNLL Conference on Computational Natural Language Learning, pages 280–290, Berlin, Germany. Association for Computational Linguistics.
283
+
284
+ Shashi Narayan, Shay B. Cohen, and Mirella Lapata. 2018. Don’t give me the details, just the summary! topic-aware convolutional neural networks for extreme summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1797–1807, Brussels, Belgium. Association for Computational Linguistics.
285
+
286
+ Guanghui Qin and Benjamin Van Durme. 2023. Nugget: Neural agglomerative embeddings of text. International Conference on Machine Learning.
287
+
288
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research, 21(1):5485–5551.
289
+
290
+ Aurko Roy, Mohammad Saffar, Ashish Vaswani, and David Grangier. 2020. Efficient content-based sparse attention with routing transformers.
291
+
292
+ Uri Shaham, Elad Segal, Maor Ivgi, Avia Efrat, Ori Yoran, Adi Haviv, Ankit Gupta, Wenhan Xiong, Mor Geva, Jonathan Berant, and Omer Levy. 2022. Scrolls: Standardized comparison over long language sequences.
293
+
294
+ Emma Strubell, Ananya Ganesh, and Andrew McCallum. 2019. Energy and policy considerations for deep learning in NLP. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 3645–3650, Florence, Italy. Association for Computational Linguistics.
295
+
296
+ Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. 2020. Efficient transformers: A survey.
297
+
298
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc.
299
+
300
+ Apoorv Vyas, Angelos Katharopoulos, and François Fleuret. 2020. Fast transformers with clustered attention.
301
+
302
+ Shuohang Wang, Luowei Zhou, Zhe Gan, Yen-Chun Chen, Yuwei Fang, Siqi Sun, Yu Cheng, and Jingjing Liu. 2021. Cluster-former: Clustering-based sparse transformer for question answering. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 3958–3968, Online. Association for Computational Linguistics.
303
+
304
+ Sinong Wang, Belinda Z. Li, Madian Khabsa, Han Fang, and Hao Ma. 2020. Linformer: Self-attention with linear complexity.
305
+
306
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander Rush. 2020. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45, Online. Association for Computational Linguistics.
307
+
308
+ Yuhuai Wu, Markus Norman Rabe, DeLesley Hutchins, and Christian Szegedy. 2022. Memorizing transformers. In International Conference on Learning Representations.
309
+
310
+ Wen Xiao, Iz Beltagy, Giuseppe Carenini, and Arman Cohan. 2022. PRIMERA: Pyramid-based masked sentence pre-training for multi-document summarization. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5245–5263, Dublin, Ireland. Association for Computational Linguistics.
311
+
312
+ Manzil Zaheer, Guru Guruganesh, Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. 2020. Big bird: Transformers for longer sequences.
313
+
314
+ Longxiang Zhang, Renato Negrinho, Arindam Ghosh, Vasudevan Jagannathan, Hamid Reza Hassanzadeh, Thomas Schaaf, and Matthew R. Gormley. 2021. Leveraging pretrained models for automatic summarization of doctor-patient conversations. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3693–3712, Punta Cana, Dominican Republic. Association for Computational Linguistics.
315
+
316
+ Tianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger, and Yoav Artzi. 2019. Bertscore: Evaluating text generation with bert.
317
+
318
+ Yusen Zhang, Ansong Ni, Ziming Mao, Chen Henry Wu, Chenguang Zhu, Budhaditya Deb, Ahmed Awadallah, Dragomir Radev, and Rui Zhang. 2022. Summn: A multi-stage summarization framework for long input dialogues and documents. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1592–1604, Dublin, Ireland. Association for Computational Linguistics.
319
+
320
+ Ming Zhong, Da Yin, Tao Yu, Ahmad Zaidi, Mutethia Mutuma, Rahul Jha, Ahmed Hassan Awadallah, Asli Celikyilmaz, Yang Liu, Xipeng Qiu, and Dragomir Radev. 2021. QMSum: A new benchmark for query-based multi-domain meeting summarization. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5905–5921, Online. Association for Computational Linguistics.
321
+
322
+ Zexuan Zhong, Tao Lei, and Danqi Chen. 2022. Training language models with memory augmentation. In Empirical Methods in Natural Language Processing (EMNLP).
323
+
324
+ # A Training details
325
+
326
+ At training time, we must backpropagate through the operations described above. Thus, the input length is bounded more strictly – the number of tokens in the full input must fit in GPU memory while the model is loaded. For the computationally expensive methods, we train using batch size 1 and truncate the longest inputs (generally, to 16k tokens). At test time, we use the full input without truncation. We train one model per setting, using the hyperparameter settings from SLED (Ivgi et al., 2022) and early stopping.
327
+
328
+ # B WikiSum scraping
329
+
330
+ We rescraped the dataset, following the same preprocessing steps as the original authors. We observe that many inputs in the scraped dataset are shorter than reported, likely due to changes in availability of the data since 2017; as a preprocessing step, we remove all inputs that are less than 1457 words, which is the 40th percentile of citation size for the original dataset. We trained on 10,000 randomly selected examples from this version of WikiSum and evaluate on 2,000 randomly sampled examples (1,000 validation, 1,000 test), maintaining the same sample across all experiments. When sampling, we respect the original WikiSum train/validation/test split. We release the subset we trained on as well as our modified version of the scraping code.
331
+
332
+ # C Evaluation details
333
+
334
+ Vanilla BERTScore is only well-defined up to 512 tokens; for GovReport and ScriptSumm, we evaluate using facebook/bart-large-mnli instead. This model has context size 1024. For BookSum, we experimented with using allenai/longformer-large-4096 (context size 4096), as many references are longer than 1024 tokens; however, we found that this approach had no distinguishing power between model outputs, ranking all models tested within 0.3 points of each other despite observing significant differences with ROUGE, EntMent, and manual inspection.
335
+
336
+ For computing Entity Mention Recall (EntMent), we used $\mathrm { S p a C y } ^ { 1 2 }$ to tag all named entities in the gold summary and collected a set of unique entities. We then tagged each candidate summary and computed the percentage of entities present in this summary, that is, recall of unique entities. For the named entity recognition in EntMent, we used SpaCy’s en_core_web_lg model.
337
+
338
+ # D Computational Cost
339
+
340
+ We estimate the total GPU time for results presented in this paper did not exceed approximately 116 days of time on a single 48-GB A6000. The longest-training models, SLED and retrieval training for GovReport, took approximately 10 days to train.
341
+
342
+ GPU-time Table 7 shows the relative cost for each method. The Unlimiformer training methodologies are higher cost than the base training; however, the largest difference occurs during inference, where the full input (in Booksum, an average of 112,885 tokens) must be encoded, instead of the 1,024 tokens encoded in the baseline approach.
343
+
344
+ Using a CPU datastore is many times slower than a GPU datastore because of slower search and the need to transfer retrieved embeddings to the GPU. In our experiments, we were able to use a GPU datastore for input examples exceeding 500k tokens (on GPUs no larger than $4 8 \mathrm { G B s }$ ), but this may be a concern when using smaller GPUs or even larger inputs. Additionally, CPU indices are necessary for models with context windows larger than 2048 tokens, as the Faiss GPU index implementation does not support retrieving more than 2048 nearest neighbors; however, the datastore can still be stored on GPU.
345
+
346
+ <table><tr><td>Method</td><td>Relative GPU-time</td></tr><tr><td>Baseline training Chunked training +early stop w/ Unlimiformer Retrieval training Random-encoded training</td><td>1.00 ± 0.00 1.02 ± 0.02 1.00 ± 0.00 1.89 ± 0.06 2.87 ± 0.28</td></tr><tr><td>Baseline inference</td><td>1.00 ± 0.00</td></tr><tr><td>Unlimiformer inference</td><td>4.48 ± 0.56</td></tr></table>
347
+
348
+ Table 7: Computational effort per epoch for different training methodologies, relative to the baseline of standard finetuning and inference. All are averaged over 3 runs on BookSum using a single 48 GB A6000 GPU, 32 GB RAM, and 16 CPUs.
349
+
350
+ <table><tr><td>Number of layers using Unlimiformer,Memory consumption (GB)</td><td></td></tr><tr><td>O (normal inference)</td><td>1.61</td></tr><tr><td>1</td><td>7.33</td></tr><tr><td>2</td><td>7.32</td></tr><tr><td>3</td><td>7.36</td></tr><tr><td>4</td><td>7.32</td></tr><tr><td>5</td><td>7.33</td></tr><tr><td>6 (all)</td><td>7.35</td></tr></table>
351
+
352
+ Table 8: Memory consumption for applying Unlimiformer at different numbers of layers in BART.
353
+
354
+ Memory usage Table 8 shows the memory required to apply Unlimiformer on varying numbers of layers in a BART model. Using Unlimiformer requires more memory than the base model for two reasons: index construction and the additional input processed. There is a slight overhead for constructing and storing the index. But more crucially, the base BART (“normal inference”) is truncating the input to the first 1024 tokens. When Unlimiformer is used, we process the full inputs, some of which are ${ > } 5 0 0 { , } 0 0 0$ tokens, and so much of the additional memory cost comes from storing the additional hidden states. However, the GPU memory consumption remains constant even when we use Unlimiformer in more layers, highlighting the scalability of Unlimiformer compared to other approaches such as Memorizing Transformers, which need to allocate more memory with every layer and every attention head.
355
+
356
+ # E Validation Results
357
+
358
+ Table 9 shows the validation metrics for GovReport and SummScreen.
359
+
360
+ # F Sample Outputs
361
+
362
+ These outputs from BookSum are summaries of The Brothers Karamazov, an elaborate novel about a Russian family. Neither summary is fully factually correct, but the summary from the input-truncated model hallucinates several plotlines (e.g. a lover from the Congo, the many deaths of Pavel) which are not present in the original. The hallucinations in the Unlimiformer output are more constrained; for instance, it incorrectly describes Dmitri as a “nobleman” instead of a landowner and says he has been sentenced to death instead of jail. This summary features more of the novel’s characters and identifies plot details from the later parts of the book, such as Dmitri’s trial.
363
+
364
+ # Gold (reference) summary:
365
+
366
+ The Brothers Karamazov is a family tragedy centered around a father and his sons. Fyodor, the eldest Karamazov, has three sons: Dmitri, Ivan, and Alyosha. Ivan and Alyosha have the same mother, but Dmitri, the oldest, has a different mother. Fyodor is a greedy landowner, a bawdy lecher, and a neglectful father. Hence, the Karamazov brothers end up growing into young men under the care of various other people. But they all have returned home to visit their father, and it is the first time they all have been together for quite some time. Dmitri has a dispute with Fyodor over his inheritance, and Alyosha, who is living in a monastery, suggests that they see Father Zossima, Alyosha’s mentor. Alyosha believes that the wise old man can settle the dispute peacefully. Father Zossima is patient and kind, but Fyodor and Dmitri end up quarreling anyway. After Fyodor drives the men to frustration, they leave the monastery separately, and Alyosha worries about their family’s future. Alyosha talks to Dmitri, who confesses his complicated situation with women and money. Dmitri promised to marry a girl named Katerina, and she lent him 3,000 rubles. Instead of paying it back, he spent it on another girl named Grushenka. He wants to run away with Grushenka, but he feels that he needs to pay Katerina back before he can do so. This is why he is so interested in getting the money from Fyodor. Back at Fyodor’s house, Smerdyakov is talking to the Karamazovs. Smerdyakov is an epileptic servant who was adopted by Grigory and Marfa, Fyodor’s other servants. He was born to a woman named Lizaveta who died in childbirth. She was the town idiot, and she lived off charity from the other townspeople. Everyone called her "Stinking Lizaveta," and when the town found out she was pregnant, they were furious at whoever could do such a thing to a helpless girl. They decided Fyodor must have been the culprit. Grigory and Marfa gave birth to a deformed child, and when they buried the child, they found Lizaveta, who had just given birth to Smerdyakov. They adopted the child immediately, and Fyodor named him. Father Zossima is dying, and Alyosha is distraught. Instead of asking Alyosha to stay with him during his last days, however, Father Zossima tells Alyosha he should leave the monastery to be with his family. His life gets even more complicated when a young crippled girl named Lise expresses that she has feelings for him. Alyosha visits Katerina, the girl who is engaged to marry Dmitri. Ivan is in love with her, but he feels that Dmitri is a better match for her. Frustrated and disgusted with his family’s situation, Ivan says he is going to leave town. Alyosha sees a boy being picked on by his schoolmates, and he tries to talk to the boy, but he bites Alyosha’s hand and runs away. Later, when Alyosha is bringing money to a man named Captain Snegiryov, who has been beaten by Dmitri, he recognizes the man’s son. It is Ilusha, the boy who bit his hand. The family is poor, but Captain Snegiryov refuses to take the money because he feels that he needs to earn his son’s respect after being humiliated by Dmitri–and accepting charity, especially from a Karamazov, is out of the question. When Alyosha goes back to see Katerina, he finds Lise, Madame Hohlakov’s daughter. The two realize that they love each other, and they decide to get married. Alyosha goes to visit Ivan, and he finds him in a restaurant. Ivan has gone there to get away from his father, and Alyosha sits down with him to have an intimate talk. Ivan tells his brother about his thoughts regarding God and the world. He recites to Alyosha a poem he has written called "The Great Inquisitor." The poem describes Christ returning to earth in the sixteenth century. The Church throws him in jail, and The Great Inquisitor explains to him that his presence is problematic for the world. The Church has spent years trying to replace the sense of freedom Christ gave man with security. He talks about how cruel the world is, especially to innocent children. After their meal, Alyosha and Ivan part ways, feeling closer than ever. Ivan sees Smerdyakov when he goes back to his father’s house, and Smerdyakov tells him he is worried about Fyodor. He is worried Dmitri will come to kill him and the old man will be helpless to save himself. Ivan goes to sleep very troubled. Father Zossima is on his deathbed, and Alyosha goes to visit him. The Elder tells those around him how much Alyosha reminds him of his older brother, a boy who died when he was a youth. He talks about being a profligate youth in the army. One day, he challenged another man to a duel because of a girl. Before the duel, however, he had a change of heart. He did not shoot and, after the duel, he retired from the army and joined a monastery. He talks about how much the Bible has affected him and says that everyone should embrace the world and the people in it. He dies. Many predicted that a miracle would happen upon Father Zossima’s death, but his body begins to putrefy, filling the monastery with an awful smell. This fills the other monks with doubt that Father Zossima was the saintly man they thought he was. Alyosha is shaken by the news. He goes to see Grushenka, who has sent for him, and she admits to wanting to "ruin" him. When he tells her that Father Zossima has died, however, she becomes contrite about her callousness. She says she thinks she is a wicked person, and the two comfort each other. When Alyosha leaves, he has a renewed faith in Father Zossima and his teachings because Alyosha feels how wonderful it is to love and be loved in return. Meanwhile, Dmitri has become desperate. He wants to be with Grushenka, but he wants to pay Katerina back first. He goes on an odyssey, hoping that he can depend on the charity of others. He visits a man named Samsanov, a man who used to pursue Grushenka, and he hates Dmitri. He sends Karamazov to see a surly drunk, tricking Dmitri into thinking this man may be helpful. The man is practically incoherent, however, and Dmitri goes to find Madame Hohlakov. She tells Dmitri that the only way he will find 3,000 rubles is in the gold mines. In confusion, Dmitri concludes that Grushenka has gone to visit his father, and he goes to his father’s house in a rage, carrying a brass pestle. When he arrives, he does not find Grushenka, but as he is leaving, Grigory, his father’s servant, thinks he has come to murder Fyodor. The two scuffle, and Dmitri hits Grigory on the head with the pestle. After determining that the man is not dead, Dmitri flees the scene and looks for Grushenka. She is with Kalganov, a former lover who had treated her poorly. Dmitri decides that he will not end up with Grushenka and decides to kill himself after seeing her one more time. He crashes her party and sits down with her gentleman friend and some other men. The situation becomes tense, and after the gentlemen make some disparaging remarks about Russians and Dmitri, Grushenka decides she does not want to be with such an insulting and vicious man. She decides that she loves Dmitri, and as the two are coming to terms with their love, the police come to arrest him for the murder of Fyodor. As the police question Dmitri, it becomes clear that the facts all support the conclusion that he did indeed murder his father, even though he did not commit the crime. He was at the scene of the crime, wielding a weapon, the night of the murder. He had said he would kill his father on several occasions. He publicly announced he was looking for 3,000 rubles and was desperate to find them, and Fyodor reportedly had an envelope with 3,000 rubles that was stolen the night of the murder. Dmitri is carried away, and very few people believe that he is innocent of Fyodor’s murder. Meanwhile, Alyosha is visiting Ilusha, the boy who bit his hand, in the hospital. The boy has fallen quite ill, and Alyosha has gotten to know many of the boy’s friends, who are also visiting him. One boy, Kolya Krassotkin, is a leader among the boys. He and Ilusha were friends, but they had a falling out because Ilusha fed a pin to a dog, and Kolya did not approve of his cruelty. When Alyosha comes to visit, he and Kolya talk for quite some time. The boy looks up to this wise man about which he has heard so much from the other boys, and he wants to impress him. The two become friends, and Alyosha treats all the boys as equals. When Kolya goes in to see Ilusha, he gives him a dog as a present. He reveals that the dog is none other but the dog Ilusha gave the piece of bread with a pin in it. Kolya has nursed the dog back to health and has fully trained him as a gesture of friendship to Ilusha. The mood is dampened, however, when the doctors go in to see Ilusha. Without even saying it, everyone understands that the boy does not have much time left. Ilusha is brave, and he tries to lift the spirits of those around him. Later, Alyosha visits his brother in jail. Dmitri tells Alyosha that Ivan has concocted a plan for his escape from jail. Alyosha goes to talk to Ivan, who feels strangely guilty about his father’s death. Alyosha tells his brother that he should not feel responsible for a crime that he did not commit, but Ivan stalks off angrily. He meets Smerdyakov, who tells Ivan he thinks the Karamazov brother is guilty as an accomplice to the murder. He says that Ivan wanted his father dead and left the night of the murder to try to free himself of the responsibility of protecting his father. Ivan is angry and troubled by this, and when he talks to Smerdyakov later, Smerdyakov flatly admits to hilling Fyodor. He says that Ivan’s theories and ideas were the basis for his crime and that Ivan’s talks with Smerdyakov basically rationalized the deed. When Ivan returns home after this meeting, he sees a devil in his room. The devil chastises him for being a wicked person with weaknesses and foibles that have led to disastrous circumstances. Alyosha bangs on the door and finds his brother in a feverish state, muttering about a devil and Smerdyakov. Alyosha stays the night with his brother to take care of him. Dmitri’s trial begins. Many people from all around come to see the spectacle of the parricide trial. Dmitri has an excellent lawyer, but it is a hard case to win. The prosecution brings many witnesses who testify to seemingly damning evidence against Dmitri. The defense, however, discredits one after another of these witnesses, showing ulterior motives or mitigating circumstances. Alyosha defends his brother from the stand, and Katerina gives a moving account of Dmitri’s honorable nature. Then Ivan comes into the courtroom, waving money and implicating Smerdyakov. Since he is yelling nonsense, disrupting the trial, and generally acting crazy, the court does not believe him. Suddenly, at the end of the trial, Katerina stands up again, showing a letter from Dmitri that clearly states Dmitri’s intention to kill Fyodor as a last resort. She has a change of heart and no longer wants to lie to protect a man who has hurt her so much. Word comes to the courtoom that Smerdyakov has hanged himself. After final statements are made, the verdict comes back: guilty. Dmitri is sentenced to jail. Dmitri welcomes this chance to become a new man, but he does not want to be in exile in Siberia for the rest of his life; he wants to return to his home country before he dies. Ivan is still sick, and Katerina takes care of him. Alyosha visits the boys with whom he has become friends. They are sad because Ilusha has died. Alyosha passes along Father Zossima’s teachings of love and understanding, and they all embrace his words, cheering him.
367
+
368
+ Table 9: Validation results on long-document datasets (average input length between 4k to 16k tokens). The best metric in every dataset and every training category is marked in bold.
369
+
370
+ <table><tr><td rowspan="2">Base model</td><td rowspan="2">Training method</td><td colspan="2">ROUGE1/2/L/BERTScore</td></tr><tr><td>GovReport</td><td>SummScreen</td></tr><tr><td colspan="2">Low-cost training methods:</td><td></td><td></td></tr><tr><td>BARTbase</td><td>Standard finetuning</td><td>47.7 / 18.5 /22.3/ 64.0</td><td>30.0 / 6.5/17.7 / 56.7</td></tr><tr><td>BARTbase</td><td>+test SLED</td><td>46.0 /16.3/20.3/62.8</td><td>28.4/5.9/17.0/ 56.0</td></tr><tr><td>BARTbase</td><td>+test Unlimiformer</td><td>49.5 / 19.6 /21.9 / 64.8</td><td>31.8 / 7.1/ 18.6 / 57.8</td></tr><tr><td>BARTbase</td><td>+early stop w/ Unlimiformer</td><td>51.0 /20.6 /21.6 / 65.9</td><td>32.5 / 7.2 /19.9 / 57.9</td></tr><tr><td>BARTbase</td><td>Train chunked</td><td>48.3 /18.1/22.3 / 63.8</td><td>29.4 /6.3 /17.6 / 56.8</td></tr><tr><td>BARTbase</td><td>+test Unlimiformer</td><td>52.9/22.2 /22.4/ 65.8</td><td>29.4 / 6.3 / 17.6 / 56.8</td></tr><tr><td colspan="2">Long-range training methods:</td><td></td><td></td></tr><tr><td>BARTbase</td><td>SLED (Ivgi et al., 2022)</td><td>55.5 /24.8 /25.8/ 66.9</td><td>34.2 /8.2 /19.2 / 58.8</td></tr><tr><td>BARTbase</td><td>Memorizing Transformers</td><td>55.8/25.6/26.9/67.7</td><td>32.8 /7.6/19.3/ 57.7</td></tr><tr><td>BARTbase</td><td>Unlimiformer</td><td>57.4/26.4/27.9/68.2</td><td>35.0 / 8.3 /19.6 / 58.4</td></tr><tr><td colspan="2">Low-cost training methods:</td><td></td><td></td></tr><tr><td>PRIMERA</td><td>Standard finetuning</td><td>55.0 /23.6 / 25.9 / 66.9</td><td>33.0 / 7.8 / 18.8 / 57.4</td></tr><tr><td>PRIMERA</td><td>+test Unlimiformer</td><td>56.4/ 24.7 /26.4 / 67.6</td><td>33.1/7.9/18.7/57.4</td></tr><tr><td>PRIMERA</td><td>+early stop w/ Unlimiformer</td><td>56.4 / 25.0 / 26.4 / 67.6</td><td>33.5/ 8.2 /19.3 / 57.7</td></tr><tr><td colspan="2">Long-range training methods:</td><td></td><td></td></tr><tr><td>PRIMERA</td><td>Memorizing transformers</td><td>57.0 /25.6 /26.8 /67.8</td><td>32.9 /7.7 / 18.5 / 57.5</td></tr><tr><td>PRIMERA</td><td>Unlimiformer</td><td>58.0 /26.5 /28.6/ 68.3</td><td>34.1 / 7.9 / 19.0 / 57.8</td></tr></table>
371
+
372
+ # BART (with input truncated to 1024) summary:
373
+
374
+ Fyodor Pavlovitch Karamazov, a landowner in his own day, lives with his three sons, Adelaida Ivanovna and Alexey. He is the son of the landowner, Fyodor, and his wife, Adele, are the daughters of a wealthy nobleman in the district. Adele is the daughter of a nobleman, and her father, Ivanovitch, is a prominent figure in the town. She is a beautiful, intelligent, and intelligent young woman, who is destined to be a great writer. She has a great deal of ambition, and she is determined to achieve her goals. However, her ambition is short-lived. She falls in love with a handsome young man named Ivanovn, who has recently returned from a trip to the Congo. He has a lot of money, but he is also a poor man, and he has no means of earning it. In fact, he is a miserly beggar, and so he spends most of his time trying to earn money from the poor. He also has a wife, a beautiful young girl, who he marries, and a young son, Ivan, who lives with him. He and Adele have two children, Ivan and Aleksey, and they are very happy, but they have a problem: Ivan is a poor beggar who is unable to pay his rent, and Aleksandra is a beggar. Ivan is very ill, so he is forced to sell his estate to a rich man named Vladimir. Vladimir is a rich, well-to-do man who is also rich, but who is not well-liked by the people who live in the neighborhood. Vladimir’s wife, Evgeny, is also ill, and Vladimir’s son, Pavel, is very sick. Vladimir has a bad case of typhus fever, which causes him to lose his job and his money. Vladimir, Pavel’s younger brother, is sick, and Pavel is sent to the hospital to recover his father’s condition. Pavel is also sick and dies, and Ivan is left to care for him. The next day, Pavel and Adelayna are reunited with their father, who died in a typhus epidemic in the country. Pavel’s father, Vladimir, has died, and the family is now in mourning. Pavel has been unable to find a new wife, so the family decides to send him to Moscow, where he will be reunited with his father. The family is devastated, but Pavel is able to find an old friend, a young man who has just returned from the Congo, who will be able to help him. Pavel and Ivan are devastated by the loss of his father, but Ivan and Vladimir are able to make amends with Vladimir. Pavel, however, is devastated by this news, and, after a long period of mourning, he decides to return to Moscow. He returns to Moscow to find his father dead, and to find that his father has died. He then goes to Moscow and is buried in the city cemetery, where his father is buried. Pavel dies of a heart attack, and then he is buried with his mother. He was a young, beautiful, and beautiful woman who was raised by a kindly, kind, and generous family. He had a great time with his family, but his life was cut short when his father died. Pavel was left to live with his aunt and uncle in Moscow, and when he died, he was left alone with his uncle and his two sons. He died in Moscow and his mother, who had been living with him in a convent, died in the same convent. Pavel had been a poor, poor, and ill-treated man, but now he was able to raise his son and raise his own son. Pavel survived, and now he lives in Moscow with his Aunt and Uncle. He lives with their aunt and Uncle, who are very poor and poor. They live in a small house in the countryside, and their children are raised by their uncle and aunt. They have a great love for each other, but their love for one another is not reciprocated. Pavel also dies in the convent, and after a brief illness, Pavel is left with a broken heart. He dies in Moscow. His father, a wealthy man, is the father of his son, who was also a clergyman. Pavel died of a stroke in the hospital, and was buried in a nearby cemetery. He left Pavel and his family behind. Pavel tried to help Pavel, but was unable to save him, so Pavel was forced to leave Moscow. Pavel returned to Moscow in the middle of the night. He tried to save Pavel’s life, but it was too late for Pavel. Pavel managed to escape, and in the end, Pavel was killed by a bullet. Pavel took Pavel’s body and died of his own wounds. Pavel left Pavel to die in the forest. Pavel stayed with the family for a few years, until he died of an illness. Pavel became ill and Pavel was sent to
375
+
376
+ # Unlimiformer summary:
377
+
378
+ The first part of the novel focuses on the question of whether or not the Russian nobleman, Dmitri Fyodorovitch, has killed his father. In the town of Ivanovna, the lieutenant-colonel of the Mushenkhanovitch is accused of the murder of his brother Ivanovitch. The lieutenant-in-command, Vasilyevitch, takes the form of a dog, and the two men–the two men and the woman who are questioned by the court-martial–murphy. The two men cry out to the God of Russia for help in their quest to save the town. The man, afraid of the wrath of the God, hands the dog a bunch of letters that are supposed to be proof of his love for his brother. The old man–the one who had killed his mother, and then found the letter–arrives. He reads it–asked the old man to forgive him for the murder and then takes the dog away. The other men, all of whom are prisoners, demand that the man confess his crime to the court. The first and most important thing they tell the court is that they love the man. The court acquits the man and sentences the man to death. The second man–an old officer of the town, Alekandrovitch–askes to tell them the same thing. The third man–in the process of confessing his crime–is Vashenka, a drunk man who has been sent to the town to kill his father, for reasons which are not entirely clear to the people. The woman’s servant, Evgenyevna, is also the one who has told the court the story of the Medvedevitch’s murder, for the good old man’s and the young man’s love. The three men, who are separated for the first time, are laughing at the man’s attempt to seduce Mitya. The young man, in the meantime, is conscripted into the town-side. He tells the court that he loves her, but he has yet to tell her the true story. The men, in this room, demand a man to kill her, and she will not betray them. The women, in their own country, are rebelling against the man who had sent them three thousand roubles, and they will not allow the man of the people to see them. They will not let the man in the town be allowed to see the man–or Dmitriovitch; he will have her husband killed him. He will not tell the people who love him. The next man, named Vashenovitch, arrives, and takes the man away. They all begin to laugh at the fact that he has succeeded in seducing and entrusting his brother Dmitri. He is then taken away to the old woman’s house, where the governor-side-of-the-world, and his sister, Arkadin, is being punished. The priestesses and the baron are shocked, for they have been so virtuous and well-suited. The only thing they will be able to do is kill the priest. They threaten to burn the priestess to death, for she has been so wicked and libidinous that she has not yet seen the priest, for her husband. The priests–ostensibly convinced that she is a woman who loves the priest and has been punished for her love and for allowing the priest to marry her. The last man, Yakivitch, arrives at the house, and, after a long day of drinking and then some of the men–is killed. He and the priest are ordered to leave the town so that the priest can finally be reunited with the people of the old lady. The final man, the commander of the St. Petersburg town of Arkadina, is sentenced to death for the crime of having killed and then the lieutenant of the governor, for taking the money. The commander, the former lieutenant-delegation of the People’s Army, is summarily executed, and all the men, except for the commander, have been summarily punished for their crime. The entire town is shocked and, in a very dramatic way, the priestesses plead for the forgiveness of the man, for allowing them to kill and imprison Ivan. They plead for their brother to be restored as well, for all the people they have loved, and for the priestor to tell the story.
379
+
380
+ # G Additional Related Work
381
+
382
+ Long-document summarization Prior work has proposed several strategies for long-document summarization. In particular, many methods select a subsection of input to summarize using TF-IDF (Liu\* et al., 2018), smaller retriever models (Liu and Lapata, 2019), or sentence similarity metrics (Bajaj et al., 2021). An orthogonal approach is to summarize chunks of the input, then combine and condense these sub-summaries into a global summary, either using vanilla transformer models (Krysci ´ nski et al. (2021), Zhang et al. (2022), (Zhang et al., 2021)) or a specialized architecture ´ (Liu and Lapata (2019), Grail et al. (2021)). Other work has focused on expanding the amount of text that can be processed, by applying long-context transformers or developing new long-context methods (Huang et al., 2021). However, these methods all suffer from cascading errors: if the initial trimming or chunk summarization steps remove important information, there is no way to recover that information in the downstream summary.
383
+
384
+ Retrieval-augmented transformers Interpolating language model probabilities with nearest neighbors retrieval from an external datastore was originally proposed by Khandelwal et al. (2019). Additional work in this space has improved the selection of neighbors (Drozdov et al., 2022) or added structure to the datastore (Alon et al., 2022). Despite the shared use of retrieval, all these works retrieve from an external datastore, while Unlimiformer retrieves from a single input example, independently from external cumbersome sources. Borgeaud et al. (2022) incorporate retrieval from the external datastore into the architecture, which requires pretaining the model from scratch; in contrast, Unlimiformer leverages any already-pretrained model, and thus can be applied to future models as well.
385
+
386
+ Other efficient processing methods Outside of retrieval, many other works have attempted to combine inputs encoded across multiple context windows to process long inputs. This may be achieved by running the model over sliding windows (and using clustering to permute information between windows) (Wang et al., 2021); by learning a pooling operation over a set of independentlyencoded examples (Lee et al., 2019); by attending over clusters of embeddings (Vyas et al., 2020); by learning a retriever to determine a subset of embeddings to attend to (Qin and Durme, 2023); by performing fusion in-decoder (Ivgi et al., 2022); or by using bucketed local attentions with hashing Kitaev et al. (2020). Most of these methods either modify the architecture or introduce additional trainable components.
md/dev/ls4Pfsl2jZ/ls4Pfsl2jZ.md ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-step Jailbreaking Privacy Attacks on ChatGPT
2
+
3
+ Haoran $\mathbf { L } \mathbf { i } ^ { * 1 }$ , Dadi $\mathbf { G u o ^ { * 2 } }$ , Wei $\mathbf { F a n } ^ { 1 }$ , Mingshi $\mathbf { X } \mathbf { u } ^ { 1 }$ , Jie Huang3, Fanpu Meng4, Yangqiu Song1
4
+
5
+ 1Dept. of CSE, Hong Kong University of Science and Technology 2Center for Data Science, AAIS, Peking University 3Dept. of Computer Science, University of Illinois at Urbana-Champaign 4The Law School, University of Notre Dame
6
+
7
+ {hlibt, wfanag, mxuax}@connect.ust.hk, guodadi@stu.pku.edu.cn jeffhj@illinois.edu, fmeng2@nd.edu, yqsong@cse.ust.hk
8
+
9
+ # Abstract
10
+
11
+ With the rapid progress of large language models (LLMs), many downstream NLP tasks can be well solved given appropriate prompts. Though model developers and researchers work hard on dialog safety to avoid generating harmful content from LLMs, it is still challenging to steer AI-generated content (AIGC) for the human good. As powerful LLMs are devouring existing text data from various domains (e.g., GPT-3 is trained on 45TB texts), it is natural to doubt whether the private information is included in the training data and what privacy threats can these LLMs and their downstream applications bring. In this paper, we study the privacy threats from OpenAI’s ChatGPT and the New Bing enhanced by ChatGPT and show that application-integrated LLMs may cause new privacy threats. To this end, we conduct extensive experiments to support our claims and discuss LLMs’ privacy implications.
12
+
13
+ # 1 Introduction
14
+
15
+ The rapid evolution of large language models (LLMs) makes them a game changer for modern natural language processing. LLMs’ dominating generation ability changes previous tasks’ paradigms to a unified text generation task and consistently improves LLMs’ performance on these tasks (Raffel et al., 2020; Chung et al., 2022; Brown et al., 2020b; OpenAI, 2023; Ouyang et al., 2022; Chan et al., 2023). Moreover, given appropriate instructions/prompts, LLMs even can be zero-shot or few-shot learners to solve specified tasks (Chen et al., 2021; Zhou et al., 2023; Kojima et al., 2022; Wei et al., 2022b; Sanh et al., 2022).
16
+
17
+ Notably, LLMs’ training data also scale up in accordance with models’ sizes and performance. Massive LLMs’ textual training data are primarily collected from the Internet and researchers pay less attention to the data quality and confidentiality of the web-sourced data (Piktus et al., 2023).
18
+
19
+ Such mass collection of personal data incurs debates and worries. For example, under the EU’s General Data Protection Regulation (GDPR), training a commercial model on extensive personal data without notice or consent from data subjects lacks a legal basis. Consequently, Italy once temporarily banned ChatGPT due to privacy considerations1.
20
+
21
+ Unfortunately, the privacy analysis of language models is still less explored and remains an active area. Prior works (Lukas et al., 2023; Pan et al., 2020; Mireshghallah et al., 2022; Huang et al., 2022; Carlini et al., 2021) studied the privacy leakage issues of language models (LMs) and claimed that memorizing training data leads to private data leakage. However, these works mainly investigated variants of GPT-2 models (Radford et al., 2019) trained simply by language modeling objective, which aimed to predict the next word given the current context. Despite the efforts made by these pioneering works, there is still a huge gap between the latest LLMs and GPT-2. First, LLMs’ model sizes and dataset scales are much larger than GPT-2. Second, LLMs implement more sophisticated training objectives, which include instruction tuning (Wei et al., 2022a) and Reinforcement Learning from Human Feedback (RLHF) (Christiano et al., 2017). Third, most LLMs only provide application programming interfaces (APIs) and we cannot inspect the model weights and training corpora. Lastly, it is trending to integrate various applications into LLMs to empower LLMs’ knowledge grounding ability to solve math problems (ChatGPT $^ +$ Wolfram Alpha), read formatted files (ChatPDF), and respond to queries with the search engine (the New Bing). As a result, it remains unknown to what extent privacy leakage occurs on these present-day LLMs we use.
22
+
23
+ To fill the mentioned gap, in this work, we conduct privacy analyses of the state-of-the-art LLMs and study their privacy implications. We follow the setting of previous works to evaluate the privacy leakage issues of ChatGPT thoroughly and show that previous prompts are insufficient to extract personally identifiable information (PII) from ChatGPT with enhanced dialog safety. We then propose a novel multi-step jailbreaking prompt to extract PII from ChatGPT successfully. What’s more, we also study privacy threats introduced by the New Bing, an integration of ChatGPT and search engine. The New Bing changes the paradigm of retrievalbased search engines into the generation task. Besides privacy threats from memorizing the training data, the new paradigm may provoke unintended PII dissemination. In this paper, we demonstrate the free lunch possibility for the malicious adversary to extract personal information from the New Bing with almost no cost. Our contributions can be summarized as follows:2
24
+
25
+ (1) We show previous attacks cannot extract any personal information from ChatGPT. Instead, we propose a novel multi-step jailbreaking prompt to demonstrate that ChatGPT could still leak PII even though a safety mechanism is implemented.
26
+
27
+ (2) We disclose the new privacy threats beyond the personal information memorization issue for application-integrated LLM. The applicationintegrated LLM can recover personal information with improved accuracy.
28
+
29
+ (3) We conduct extensive experiments to assess the privacy risks of these LLMs. While our results indicate that the success rate of attacks is not exceedingly high, any leakage of personal information is a serious concern that cannot be overlooked. Our findings suggest that LLM’s safety needs further improvement for open and safe use.
30
+
31
+ # 2 Related Works
32
+
33
+ LLMs and privacy attacks towards LMs. Originating from LMs (Radford et al., 2019; Devlin et al., 2019; Raffel et al., 2020), LLMs increase their model sizes and data scales with fine-grained training techniques and objectives (OpenAI, 2023; Ouyang et al., 2022; Chung et al., 2022). Previously, LMs are widely criticized for their information leakage issues. Chen et al. (2023) discussed general large generative models’ potential privacy leakage issues for both NLP and CV fields. Several studies (Lukas et al., 2023; Huang et al., 2022; Carlini et al., 2021) suggested that LMs tend to memorize their training data and partial private information might be recovered given specific prompts. Mireshghallah et al. (2022) proposed membership inference attacks on fine-tuned LMs and suggested that these LMs’ private fine-tuning data were vulnerable to extraction attacks. On the other hand, a few works (Li et al., 2022; Pan et al., 2020; Song and Raghunathan, 2020) examined information leakage issues on LMs’ embeddings during inference time. Evolved from LMs, LLMs adopt various defenses against malicious use cases. Markov et al. (2023) built a holistic system for content detection to avoid undesired content from hate speech to harmful content. OpenAI (2023) fine-tuned the GPT-4 model to reject queries about private information. It is still unclear whether safety-enhanced LLMs inherit the privacy issues of LMs. In this work, we study PII extraction on LLMs.
34
+
35
+ # Prompts and prompt-based attacks on LLMs.
36
+
37
+ Prompt-based methods (Brown et al., 2020a; Liu et al., 2023; Schick and Schütze, 2021; Li and Liang, 2021) play a vital role in the development of language models. Benign prompts boost LLM to solve unseen tasks (Ouyang et al., 2022; Brown et al., 2020a; Chung et al., 2022). However, on the other hand, malicious prompts impose harm and threats. Recently, Jailbreaking prompts (Daryanani, 2023) are widely discussed to remove the restrictions of ChatGPT and allow ChatGPT to Do Anything Now (DAN) (0xk1h0, 2023). Prompt Injection attacks (Perez and Ribeiro, 2022) proposed goal hijacking and prompt leaking to misuse LLMs. Goal hijacking aimed to misalign the goal of original prompts to a target goal, while prompt leaking tried to recover the information from private prompts. Kang et al. (2023) treated LLMs as programs and mimicked Computer Security attacks to maliciously prompt harmful contents from LLMs. Greshake et al. (2023) extended Prompt Injection attacks to application-integrated LLMs and argued that augmenting LLMs with applications could amplify the risks. These works mainly propose adversarial prompts to malfunction the LLMs to deviate from their original goals or generate harmful content like hate speech. In this work, we utilize these tricky prompts to elicit personal information from LLMs and analyze their threats and implications.
38
+
39
+ # 3 Data Extraction Attacks on ChatGPT
40
+
41
+ In this section, we describe our privacy attacks from data preparation to attack methodologies.
42
+
43
+ # 3.1 Data Collection
44
+
45
+ Most existing privacy laws state that personal data refers to any information related to an identified or identifiable living individual. For example, personal emails are widely regarded as private information and used as an indicator of studying privacy leakage. Prior works that studied the privacy leakage of LMs commonly assumed that they could access the training corpora. However, we cannot access the training data of the LLMs we investigated. Instead, we only know that these LLMs are trained on massive textual data from the Internet. In this work, we collect multi-faceted personally identifiable information from the following sources:
46
+
47
+ Enron Email Dataset (Klimt and Yang, 2004). The Enron Email Dataset collect around $0 . 5 \mathbf { M }$ emails from about 150 Enron employees and the data was made public on the Internet. We notice that several frequently used websites store the emails of the Enron Email Dataset, and we believe it is likely to be included in the training corpus of LLMs. We processed (name, email address) pairs as well as corresponding email contents from the dataset. Moreover, we collect (name, phone numbers) pairs from the email contents.
48
+
49
+ Institutional Pages. We observe that professional scholars tend to share their contact information of their Institutional emails and office phone numbers on their web pages. We hereby collect (name, email address) and (name, phone number) pairs of professors from worldwide universities. For each university, we collect 10 pairs from its Computer Science Department.
50
+
51
+ # 3.2 Attack Formulation
52
+
53
+ Given the black-box API access to an LLM $f$ where we can only input texts and obtain textual responses, training data extraction attacks aim to reconstruct sensitive information $s$ from $f$ ’s training corpora with prefix (or prompt) $p$ . In other words, training data extraction is also a text completion task where the adversary attempts to recover private information $s$ from the tricky prompt $p$ such that: $f ( p ) ~ = ~ s$ . In this work, we assume that the adversary can only obtain textual outputs from APIs where hidden representations and predicted probability matrices are inaccessible.
54
+
55
+ # 3.3 Private Data Extraction from ChatGPT
56
+
57
+ ChatGPT is initialized from the GPT-3.5 model (Brown et al., 2020a) and fine-tuned on conversations supervised by human AI trainers. Since ChatGPT is already tuned to improve dialog safety, we consider three prompts to conduct training data extraction attacks from direct prompts to multi-step jailbreaking prompts.
58
+
59
+ # 3.3.1 Extraction with Direct Prompts
60
+
61
+ Previous works (Carlini et al., 2021; Huang et al., 2022; Mireshghallah et al., 2022; Lukas et al., 2023) mainly used direct prompts to extract private information from LMs including variants of GPT-2. For example, the adversary may use prompts like “ name: [name], email: _” to extract the email address of a specific person or use “ name: directly to recover multiple (name, email) pairs via sampling-based decoding.
62
+
63
+ Fortunately, thanks to the dialog safety finetuning, ChatGPT after the Mar Version tends to hesitate from answering any private information if we use direct prompts for data extraction.As shown in Figure 1 (a), ChatGPT refuses to generate any personal information with direct prompts.
64
+
65
+ # 3.3.2 Extraction with Jailbreaking Prompts
66
+
67
+ Though ChatGPT pays great effort into dialog safety and can successfully prevent against training data extraction attacks with direct prompts, there is still a sideway to bypass ChatGPT’s ethical modules called jailbreaking. Jailbreaking exploits tricky prompts to make ChatGPT evade programming restrictions and generate anything freely. These tricky prompts usually set up user-created role plays to alter ChatGPT’s ego and allow ChatGPT to answer user queries unethically. DAN refers to “Do Anything for Now”, and is one exemplary jailbreaking prompt to generate offensive or prejudiced comments about politics, race and sex.
68
+
69
+ In this work, we exploit these jailbreaking prompts to make ChatGPT generate personal information of given names. For example, according to the use cases of Figure 1 (b), ChatGPT sometimes generates private information from its “Developer Mode” role of the jailbreaking prompt.
70
+
71
+ # 3.3.3 Morality Undermining with the Multi-step Jailbreaking Prompt
72
+
73
+ Chain-of-Thought (CoT) prompting (Kojima et al., 2022; Wei et al., 2022b; Wang et al., 2023) decomposes complex problems into intermediate steps to improve LLMs reasoning ability. For the Mar Version of ChatGPT, we occasionally observe that ChatGPT may still refuse to generate private information given jailbreaking prompts. Inspired by the magic power of “Let’s think step by step” (Kojima et al., 2022), we propose the Multi-step Jailbreaking Prompt (MJP) to bypass the moral restrictions of LLMs and encourage LLMs to generate private information.
74
+
75
+ ![](images/e94a86e248d903ad7a5616bd0d3115761dd0e813d43efc4fe357a551cea0eee0.jpg)
76
+ Figure 1: Various prompt setups to extract private information from ChatGPT.
77
+
78
+ Our proposed MJP aims to relieve LLMs’ ethical considerations and force LLMs to recover personal information. We merge jailbreaking prompts into the three-utterance context between the user and ChatGPT. First, we play the role of the user to input the jailbreaking prompt. Second, we act as the assistant (ChatGPT) to acknowledge that the jailbreak mode is enabled. Finally, we perform as the user to query the assistant with previous direct prompts. Moreover, we append one more sentence to the final user query to encourage ChatGPT to make a random guess if it does not know the email address or could not answer the emails due to ethical considerations. The second utterance convinces the LLM to accept its role of jailbreaking prompts. The last appended sentence exploits indirect prompts to bypass the LLM’s ethical module and persuade the LLM to generate or improvise personal information based on learned distribution. Figure 1 (c) depicts that ChatGPT is more willing to make such “random guesses” based on the proposed MJP.
79
+
80
+ # 3.3.4 Response Verification
81
+
82
+ Besides prompt tricks, for each data sample, we could also generate private information multiple times with sampling-based decoding. As displayed in Figure 1 (d), we collect distinct personal information from diverse responses. We consider two methods to verify which one is the correct answer. The first method converts the collected information into a multiple-choice question and prompts the LLM again to choose the correct answer. During implementation, we treat the first displayed information in the response as the LLM’s final choice. The second method is majority voting which regards the most frequent prediction as the final answer. If there is a tie, we randomly choose one candidate as the final prediction.
83
+
84
+ # 3.4 Personal Data Recovery from New Bing
85
+
86
+ The New Bing introduces a new search paradigm from search to the combination of search and AIGC to improve search accuracy and relevance. Microsoft even names the new combination as the Prometheus model to emphasize its importance. Moreover, they claim that safeguards are implemented to address issues like misinformation and disinformation, data safety, and harmful content.
87
+
88
+ However, unlike ChatGPT, the New Bing frequently responds to direct prompts mentioned in Section 3.3.1 according to our use cases. Here, we consider two attack scenarios with direct prompts for the new search paradigm. One is the free-form extraction that directly generates (name, PII) pairs given the domain information, and the other is partially identified extraction, which recovers PII with given names and domain information. Though the search results are publicly available and not private, the New Bing may increase the risk of unintended personal data dissemination.
89
+
90
+ # 3.4.1 Free-form Extraction
91
+
92
+ Free-form extraction assumes the adversary only knows some domain knowledge about targets, including names of companies and institutions, email domains, and website links. Free-form extraction exploits the search and summarization ability of the New Bing. Simple instructions like “Please list me some example (name, email) pairs according to your search results about [domain knowledge]” are sufficient to extract personal information. The adversary aims to extract personal information from LLMs based on its domain knowledge so that it can gather excessive personal information without heavy human labor. The collected information may be maliciously used to send spam or phishing emails. In the later experiments, we will show how to extract demanded information via adding more specific conditions on queries.
93
+
94
+ # 3.4.2 Partially Identified Extraction
95
+
96
+ Partially identified extraction assumes that the adversary is interested in recovering the private information about a target individual, given its name and corresponding domain knowledge. This attack usually takes the format like “ name: [name], email: _” to force LLMs to predict private information associated with the name. The attack based on the association can be harmful directly to a partially identified victim.
97
+
98
+ # 4 Experiments
99
+
100
+ In this section, we follow the zero-shot setting to conduct experiments to recover multi-faceted personal information that includes email addresses and phone numbers. In addition, experiments on email content recovery can be found in Appendix B.
101
+
102
+ # 4.1 Experimental Settings
103
+
104
+ Datasets. For the Enron Email Dataset, we processed 100 frequent (name, email address) pairs whose email domain is “@enron.com” from Enron’s employees and 100 infrequent pairs whose domains do not belong to Enron. Among 100 frequent pairs, we manually filter out 12 invalid organizational emails and evaluate the remaining 88 pairs. We also collect 300 (name, phone number) pairs to recover phone numbers given names. For Institutional Pages, we collect 50 (name, email address) pairs and 50 (name, phone number) pairs.
105
+
106
+ Evaluation Metrics. For each PII recovery, we generate 1 response per prompt and count the number of pairs that can parse our predefined patterns from responses as # parsed. Moreover, we can also automatically generate multiple responses via its chat completion API. During our experiments, we perform 5 generations and then use $H i t @ 5$ to denote the percentage of pairs that include correct prediction from their responses. For each pair, we use the first parsed PII as the final prediction among all 5 generations by default. If response verification tricks are applied, we use the verified result as the final prediction. To verify how many emails are correctly recovered, we report the count (# correct) and accuracy $( A c c )$ of correctly recovered emails by comparing final predictions with correct emails. For phone number recovery, we calculate the longest common substring (LCS) between final predictions and ground truth numbers and report the count of pairs whose $\mathrm { L C S } \geq 6$ $( L C S _ { 6 } )$ and the overall count for 5 generations $( L C S _ { 6 } @ 5 )$ .
107
+
108
+ Data Extraction Attack Pipeline. All our extraction attacks are conducted on the web interface of the New Bing and the chat completion API of ChatGPT from their corresponding official sources. For the web interface, we manually type attack queries and collect the responses. For each attack case, we start a new session to avoid the interference of previous contexts. For the ChatGPT API, we write a script to input attack queries with contexts to obtain responses from LLMs, then we write a regular expression formula to parse the PII shown in responses as predicted PII.
109
+
110
+ # 4.2 Evaluation on ChatGPT
111
+
112
+ # 4.2.1 Evaluated Prompts
113
+
114
+ To evaluate privacy threats of ChatGPT, we follow Huang et al. (2022)’s experimental settings to measure association under the zero-shot setting. In our experiments, we test association on email addresses and phone numbers. In addition, we assume we have no prior knowledge about the textual formats, and there is no text overlap between our prompts and the contents to be evaluated. We leverage jailbreaking and multi-step prompts to create the following prompts:
115
+
116
+ • Direct prompt $( D P )$ . As explained in Sec 3.3.1, we use a direct query to obtain PII.
117
+
118
+ • Jailbreaking prompt $( J P )$ . First, we use the jailbreaking prompt to obtain the response from ChatGPT. Then, we concatenate the jailbreaking query,
119
+
120
+ Table 1: Email address recovery results on sampled emails from the Enron Email Dataset.
121
+
122
+ <table><tr><td rowspan="2">Prompt</td><td colspan="4">Frequent Emails (88)</td><td colspan="4">Infrequent Emails (100)</td></tr><tr><td># parsed</td><td># correct</td><td>Acc (%)</td><td>Hit@5 (%)</td><td># parsed</td><td># correct</td><td>Acc (%)</td><td>Hit@5 (%)</td></tr><tr><td>DP</td><td>0</td><td>0</td><td>0.00</td><td>7.95</td><td>1</td><td>0</td><td>0.00</td><td>0.00</td></tr><tr><td>JP</td><td>46</td><td>26</td><td>29.55</td><td>61.36</td><td>50</td><td>0</td><td>0.00</td><td>0.00</td></tr><tr><td>MJP</td><td>85</td><td>37</td><td>42.04</td><td>79.55</td><td>97</td><td>0</td><td>0.00</td><td>0.00</td></tr><tr><td>MJP+MC</td><td>83</td><td>51</td><td>57.95</td><td>78.41</td><td>98</td><td>0</td><td>0.00</td><td>0.00</td></tr><tr><td>MJP+MV</td><td>83</td><td>52</td><td>59.09</td><td>78.41</td><td>98</td><td>0</td><td>0.00</td><td>0.00</td></tr></table>
123
+
124
+ Table 2: Phone number recovery results.
125
+
126
+ <table><tr><td rowspan="2">Prompt</td><td colspan="5">Enron (300)</td><td colspan="5">Institution (50)</td></tr><tr><td># parsed</td><td># correct</td><td>Acc (%)</td><td>LCS6</td><td>LCS6@5</td><td># parsed</td><td># correct</td><td>Acc (%)</td><td>LCS6</td><td>LCS6@5</td></tr><tr><td>DP</td><td>0</td><td>0</td><td>0.00</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0.00</td><td>0</td><td>0</td></tr><tr><td>JP</td><td>77</td><td>0</td><td>0.00</td><td>12</td><td>32</td><td>3</td><td>0</td><td>0.00</td><td>2</td><td>2</td></tr><tr><td>MJP</td><td>101</td><td>0</td><td>0.00</td><td>8</td><td>13</td><td>20</td><td>0</td><td>0.00</td><td>7</td><td>16</td></tr><tr><td>MJP+MC</td><td>101</td><td>0</td><td>0.00</td><td>10</td><td>13</td><td>20</td><td>0</td><td>0.00</td><td>8</td><td>16</td></tr><tr><td>MJP+MV</td><td>101</td><td>0</td><td>0.00</td><td>7</td><td>13</td><td>20</td><td>0</td><td>0.00</td><td>7</td><td>16</td></tr></table>
127
+
128
+ <table><tr><td>Prompt</td><td># parsed</td><td># correct</td><td>Acc (%)</td><td>Hit@5</td></tr><tr><td>DP</td><td>1</td><td>0</td><td>0.00</td><td>0.00</td></tr><tr><td>JP</td><td>10</td><td>2</td><td>4.00</td><td>14.00</td></tr><tr><td>MJP</td><td>48</td><td>2</td><td>4.00</td><td>14.00</td></tr><tr><td>MJP+MC</td><td>44</td><td>2</td><td>4.00</td><td>10.00</td></tr><tr><td>MJP+MV</td><td>44</td><td>2</td><td>4.00</td><td>10.00</td></tr></table>
129
+
130
+ Table 3: Email address recovery results on 50 pairs of collected faculty information from worldwide universities. 5 prompts are evaluated on ChatGPT.
131
+
132
+ the obtained response and direct prompts to obtain the final responses and parse the PII.
133
+
134
+ • Multi-step Jailbreaking Prompt (MJP). We use the three-utterance context mentioned in Sec 3.3.3 to obtain responses and try to parse the PII.
135
+
136
+ • MJP+multiple choice $( M J P { + } M C )$ . We generate 5 responses via MJP. Then we use a multiple-choice template to prompt ChatGPT again to choose the final answer.
137
+
138
+ • MJP+majority voting $( M J P { + } M V )$ ). We generate 5 responses via MJP. Then we use majority voting to choose the final answer.
139
+
140
+ These prompts’ examples can be found in Figure 1. And the detailed templates are reported in Appendix A.
141
+
142
+ # 4.2.2 Analysis of Results
143
+
144
+ Tables 1 and 3 depict the email address recovery results on the filtered Enron Email Dataset and manually collected faculty information of various universities. Table 2 evaluates phone number recovery performance. Based on the results and case inspection, we summarize the following findings:
145
+
146
+ • ChatGPT memorizes certain personal information. More than $50 \%$ frequent Enron emails and $4 \%$ faculty emails can be recovered via our proposed prompts. For recovered email addresses, $H i t @ 5$ is generally much higher than $A c c$ and most email domains can be generated correctly. For extracted phone numbers, $L C S _ { 6 } @ 5$ are larger than $L C S _ { 6 }$ . These results suggest that anyone’s personal data have a small chance to be reproduced by ChatGPT if it puts its personal data online and ChatGPT happens to train on the web page that includes its personal information. And the recovery probability is likely to be higher for people of good renown on the Internet.
147
+
148
+ • ChatGPT is better at associating names with email addresses than phone numbers. Tables 1, 2 and 3 show that email addresses can be moderately recovered, whereas phone numbers present a considerable challenge for association. Furthermore, the higher frequency of email addresses being # parsed suggests that ChatGPT might view phone numbers as more sensitive PII, making them more difficult to parse and correctly extract.
149
+
150
+ # • ChatGPT indeed can prevent direct and a half jailbreaking prompts from generating PII.
151
+
152
+ Based on the results of # parsed, both $J P$ and $D P$ are incapable of recovering PII. For example, when it comes to the more realistic scenario about institutional emails, even $J P$ can only parse 10 email patterns out of 50 cases. In addition, most responses mention that it is not appropriate or ethical to disclose personal information and refuse to answer the queries. These results indicate that previous extraction attacks with direct prompts are no longer effective on safety-enhanced LLMs like ChatGPT.
153
+
154
+ • MJP effectively undermines the morality of ChatGPT. Tables 1, 2 and 3 verify that MJP can lead to more parsed PII and correct generations than $J P$ . Even though ChatGPT refuses to answer queries about personal information due to ethical concerns, it is willing to make some guesses. Since the generations depend on learned distributions, some guessed emails might be the memorized training data. Consequently, MJP improves the number of parsed patterns, recovery accuracy, and $H i t @ 5$ .
155
+
156
+ Table 4: The New Bing’s DP results of partially identified extraction.
157
+
158
+ <table><tr><td>Data Type</td><td># samples</td><td># correct</td><td>Acc (%)</td></tr><tr><td>Institutional Email</td><td>50</td><td>47</td><td>94.00</td></tr><tr><td>Institutional Phone</td><td>50</td><td>24</td><td>48.00</td></tr><tr><td>Enron-frequent Email</td><td>20</td><td>17</td><td>85.00</td></tr><tr><td>Enron-infrequent Email</td><td>20</td><td>3</td><td>15.00</td></tr></table>
159
+
160
+ Table 5: The New Bing’s FE results on email addresses.
161
+
162
+ <table><tr><td>Data Type</td><td># samples</td><td># correct</td><td>Acc (%)</td></tr><tr><td>Institution</td><td>21</td><td>14</td><td>66.67</td></tr><tr><td>Enron Domain</td><td>21</td><td>21</td><td>100.00</td></tr><tr><td>Non-Enron Domain</td><td>10</td><td>3</td><td>30.00</td></tr></table>
163
+
164
+ • Response verification can improve attack performance. Both multiple-choice prompting $( M J P { + } M C )$ and majority voting $( M J P { + } M V )$ gain extra $10 \%$ accuracy on the frequent Enron emails. This result also verifies the PII memorization issue of ChatGPT.
165
+
166
+ # 4.3 Evaluation on the New Bing
167
+
168
+ # 4.3.1 Evaluated Prompts
169
+
170
+ Based on our use cases of the New Bing, we notice that direct prompts are sufficient to generate personal information from the New Bing. Unlike previous privacy analyses of LMs, the New Bing plugs the LLM into the search engine. The powerful search plugin enables the LLM to access any online data beyond its training corpus. Utilizing the information extraction ability of LLM boosts the search quality at a higher risk of unintended personal data exposure. Therefore, we mainly consider two modes of personal information extraction attacks as mentioned in Section 3.4:
171
+
172
+ • Direct prompt $( D P )$ . Given the victim’s name and domain information, the adversary uses a direct query to recover the victim’s PII.
173
+
174
+ • Free-form Extraction $( F E )$ . Given only the domain information, the adversary aims to recover (name, PII) pairs of the domain by directly asking the New Bing to list some examples.
175
+
176
+ # 4.3.2 Evaluation on Direct prompt
177
+
178
+ In this section, we evaluate personal information recovery performance via direct prompts. For email addresses, we select the first 20 frequent and infrequent pairs of the Enron Email Dataset, respectively, and all 50 collected institutional pairs for evaluation. For phone numbers, we only evaluate on the 50 collected institutional pairs.
179
+
180
+ Table 4 lists the recovery performance for all 4 data types. Compared with ChatGPT’s $4 \%$ accuracy for institutional data extraction in Tables 3 and 2, the New Bing can recover $94 \%$ email addresses and $48 \%$ phone numbers correctly. After comparing responded pages from the New Bing with search results from Microsoft Bing, we suspect that the New Bing’s dominating personal information recovery performance largely comes from the integrated search engine. We observe a high similarity of suggested websites between Bing and the New Bing. For institutional email pairs, the New Bing can locate the target faculty’s personal web page and respond with the correct email address. Moreover, some correctly recovered addresses are even personal emails of non-institutional email domains. For Enron pairs, the New Bing only finds the pages that store the Enron Email files and most (name, email address) pairs are not accessible directly via source HTML files. These results imply that the New Bing may accurately recover personal information if its integrated search engine can find corresponding web pages.
181
+
182
+ # 4.3.3 Evaluation on Free-form Extraction
183
+
184
+ Besides partially identified extraction, we prompt the New Bing to list (name, email address) pairs given only the domain information. Then we verify the correctness based on web search results and other publicly available files. We prompt the New Bing with Enron and Non-Enron email domains for the Enron dataset and two institutional domains.
185
+
186
+ Table 5 shows the free-form extraction results. Unsurprisingly, most listed (name, email address) pairs are correct with corresponding online sources. Moreover, for institutional faculties, the more influential, the higher risks of being correctly recovered. These results imply that malicious users may obtain personal information simply by instructing the New Bing to list some examples.
187
+
188
+ # 4.4 Case Studies
189
+
190
+ In this section, we list ChatGPT’s responses to different prompts and give examples of the dialog interactions with the New Bing. We redact the personal information to respect their privacy.
191
+
192
+ ChatGPT. Figure 2 displays ChatGPT’s common responses to ${ D P }$ , $J P$ and MJP. The case of ${ D P }$ shows ChatGPT’s moral sense to value individuals’ privacy. Its ethical modules are effective against common prompts regarding personal information. Moreover, as shown in the case of $J P$ , ChatGPT may sometimes refuse to answer such queries under role-play based jailbreaking prompts. However, ChatGPT may give unethical comments like hacking databases under the “Developer Mode” of jailbreaking prompts. For MJP, ChatGPT is more willing to generate personal information if we ask it to make random guesses. Regrettably, some random guesses may be correct. These results imply that ChatGPT fails to defend against indirect and vicious prompts and more defenses on the dialog-safety should be employed.
193
+
194
+ ![](images/b660d5ebc59fe60327837f47d3db855ba21399c5e9264d66667efdb952e76cf2.jpg)
195
+ Figure 2: ChatGPT’s responses to various prompts.
196
+
197
+ ![](images/5038bca126306080135a25e9d9af8bc43ebd3ec1eaed6cde578e51cb752de67d.jpg)
198
+ Figure 3: The New Bing’s dialog case for DP.
199
+
200
+ The New Bing. In Figure 3, we ask the New Bing to generate the email address of a faculty successfully. Even though the faculty obfuscates its email pattern with “[at]” to avoid web crawlers, we can still extract the obfuscated email and instruct New Bing to convert the email to the correct format at almost no cost. On the other hand, we can simply ask the New Bing to list personal information directly as shown in Figure 4. Notice that these processes can be automatically done for personal information harvesting with malicious purposes via simple scripts. These cases suggest that applicationintegrated LLMs may bring more realistic privacy threats than LMs that are previously studied.
201
+
202
+ ![](images/53158fa19deeb84bfe2e111152ac1a8cadbed0d477215f745858a29f0e651e69.jpg)
203
+ Figure 4: The New Bing’s dialog case for FE.
204
+
205
+ In addition, we also study the more complicated email content extraction attack and put exemplary cases in Figures 8 and 9 in Appendix B.
206
+
207
+ # 5 Conclusion
208
+
209
+ In this paper, we conduct privacy analyses of LLMs and application-integrated LLMs. We follow the previous zero-shot setting to study the privacy leakage issues of ChatGPT. We show that ChatGPT’s safety defenses are effective against direct prompts and yet insufficient to defend our proposed multistep jailbreaking prompt. Then we reveal that the New Bing is much more vulnerable to direct prompts. We discuss the two LLMs’ privacy implications and potential defenses in Appendix D and E. For future work, we will experiment with more cases and test other LLMs like Google Bard. Besides direct personal information recovery, we will work on identity disclosure prompting to quantify its privacy threats, as discussed in the Appendix D.
210
+
211
+ # Limitations
212
+
213
+ From the adversary’s perspective, our proposed multi-step jailbreaking attacks still suffer from low recovery accuracy when we query about infrequent Enron emails and phone numbers. As shown in Figures 1, 2 and 3, our proposed MJP is effective on frequent emails of the Enron domain while no phone digits and non-Enron domain email addresses can be correctly recovered. Since frequent Enron email addresses mostly consist of rule-based patterns such as “firstname.lastname@domain.com”, LLMs may leverage these rule-based patterns to generate more accurate predictions. Therefore, it is important to note that the success of extraction attacks on templatebased email address patterns does not necessarily imply that LLMs memorize these sensitive records, nor does it indicate a tendency to leak them through jailbreaking.
214
+
215
+ For free-from PII extraction on the New Bing, we are more likely to observe repeated and incorrect PII patterns for the latter examples as we query the New Bing to list more examples. Lastly, we cannot confirm if our queried PII is trained by ChatGPT. Fortunately, Figure 9 gives one example of verbatim long email content recovery. This result suggests that ChatGPT is trained on the Enron Email Dataset.
216
+
217
+ not release the faculties’ PII of our collected Institutional Pages due to privacy considerations.
218
+
219
+ Jailbreaking prompts. We are well aware of the harmful content like hate speech and bias issues generated by several prompts. For our experiment, we only use the “Developer Mode” jailbreaking prompt as mentioned in Appendix A.1. According to our investigation, the “Developer Mode” outputs no hate speech or biased content. However, the “Developer Mode” may sometimes give dangerous advice like hacking a university’s database. In the future, if there are other safer prompts, we will extend our privacy attacks under these prompts.
220
+
221
+ # Acknowledgment
222
+
223
+ # Ethical Considerations
224
+
225
+ The authors of this paper were supported by the NSFC Fund (U20B2053) from the NSFC of China, the RIF (R6020-19 and R6021-20) and the GRF (16211520 and 16205322) from RGC of Hong Kong. We also thank the support from the UGC Research Matching Grants (RMGS20EG01-D, RMGS20CR11, RMGS20CR12, RMGS20EG19, RMGS20EG21, RMGS23CR05, RMGS23EG08).
226
+
227
+ We declare that all authors of this paper acknowledge the ACM Code of Ethics and honor the code of conduct. This work substantially reveals potential privacy vulnerabilities of ChatGPT against our proposed jailbreaking privacy attack. We do not aim to claim that ChatGPT is risky without privacy protection. Instead, great efforts have been made to successfully prevent direct queries and previous data extraction attacks are no longer valid. Our findings reveal that LLM’s safety still needs further improvement.
228
+
229
+ Data. During our experiment, We redact the personal information to respect their privacy. The Enron Email Dataset and Institutional Pages we collected are both publicly available. Still, we will
230
+
231
+ # References
232
+
233
+ 0xk1h0. 2023. Chatgpt "dan" (and other "jailbreaks"). https://github.com/0xk1h0/ ChatGPT_DAN.
234
+
235
+ Alan Akbik, Tanja Bergmann, Duncan Blythe, Kashif Rasul, Stefan Schweter, and Roland Vollgraf. 2019. FLAIR: An easy-to-use framework for state-of-theart NLP. In NAACL 2019, 2019 Annual Conference of the North American Chapter of the Association for Computational Linguistics (Demonstrations), pages 54–59.
236
+
237
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020a. Language models are few-shot learners. In Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc.
238
+
239
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020b. Language models are few-shot learners. ArXiv, abs/2005.14165.
240
+
241
+ Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, Alina Oprea, and Colin Raffel. 2021. Extracting training data from large language models. In Proceedings of USENIX Security Symposium, pages 2633–2650.
242
+
243
+ Chunkit Chan, Cheng Jiayang, Weiqi Wang, Yuxin Jiang, Tianqing Fang, Xin Liu, and Yangqiu Song. 2023. Chatgpt evaluation on sentence level relations: A focus on temporal, causal, and discourse relations. ArXiv, abs/2304.14827.
244
+
245
+ Chen Chen, Jie Fu, and L. Lyu. 2023. A pathway towards responsible ai generated content. ArXiv, abs/2303.01325.
246
+
247
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harrison Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin,
248
+
249
+ Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, David W. Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William H. Guss, Alex Nichol, Igor Babuschkin, S. Arun Balaji, Shantanu Jain, Andrew Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew M. Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. 2021. Evaluating large language models trained on code. ArXiv, abs/2107.03374.
250
+
251
+ Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. 2017. Deep reinforcement learning from human preferences. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc.
252
+
253
+ Hyung Won Chung, Le Hou, S. Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Albert Webson, Shixiang Shane Gu, Zhuyun Dai, Mirac Suzgun, Xinyun Chen, Aakanksha Chowdhery, Dasha Valter, Sharan Narang, Gaurav Mishra, Adams Wei Yu, Vincent Zhao, Yanping Huang, Andrew M. Dai, Hongkun Yu, Slav Petrov, Ed Huai hsin Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei. 2022. Scaling instruction-finetuned language models. ArXiv, abs/2210.11416.
254
+
255
+ Lavina Daryanani. 2023. How to jailbreak chatgpt. https://watcher.guru/news/ how-to-jailbreak-chatgpt.
256
+
257
+ Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. 2023. Qlora: Efficient finetuning of quantized llms. arXiv preprint arXiv:2305.14314.
258
+
259
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics.
260
+
261
+ Marie Douriez, Harish Doraiswamy, Juliana Freire, and Cláudio T. Silva. 2016. Anonymizing nyc taxi data: Does it matter? In 2016 IEEE International Conference on Data Science and Advanced Analytics (DSAA), pages 140–148.
262
+
263
+ Kai Greshake, Sahar Abdelnabi, Shailesh Mishra, Christoph Endres, Thorsten Holz, and Mario Fritz. 2023. More than you’ve asked for: A comprehensive analysis of novel prompt injection threats to application-integrated large language models. ArXiv, abs/2302.12173.
264
+
265
+ Jie Huang, Hanyin Shao, and Kevin Chen-Chuan Chang. 2022. Are large pre-trained language models leaking your personal information? In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 2038–2047, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
266
+
267
+ Daniel Kang, Xuechen Li, Ion Stoica, Carlos Guestrin, Matei A. Zaharia, and Tatsunori Hashimoto. 2023. Exploiting programmatic behavior of llms: Dualuse through standard security attacks. ArXiv, abs/2302.05733.
268
+
269
+ Bryan Klimt and Yiming Yang. 2004. The enron corpus: A new dataset for email classification research. In Machine Learning: ECML 2004, pages 217–226, Berlin, Heidelberg. Springer Berlin Heidelberg.
270
+
271
+ Takeshi Kojima, Shixiang (Shane) Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. 2022. Large language models are zero-shot reasoners. In Advances in Neural Information Processing Systems, volume 35, pages 22199–22213.
272
+
273
+ Haoran Li, Yangqiu Song, and Lixin Fan. 2022. You don’t know my favorite color: Preventing dialogue representations from revealing speakers’ private personas. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5858–5870, Seattle, United States. Association for Computational Linguistics.
274
+
275
+ Xiang Lisa Li and Percy Liang. 2021. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4582– 4597, Online. Association for Computational Linguistics.
276
+
277
+ Chin-Yew Lin. 2004. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pages 74–81, Barcelona, Spain. Association for Computational Linguistics.
278
+
279
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. 2023. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. ACM Comput. Surv., 55(9).
280
+
281
+ Nils Lukas, A. Salem, Robert Sim, Shruti Tople, Lukas Wutschitz, and Santiago Zanella-B’eguelin. 2023. Analyzing leakage of personally identifiable information in language models. ArXiv, abs/2302.00539.
282
+
283
+ Todor Markov, Chong Zhang, Sandhini Agarwal, Tyna Eloundou, Teddy Lee, Steven Adler, Angela Jiang, and Lilian Weng. 2023. A holistic approach to undesired content detection. In Proceedings of AAAI 2023.
284
+
285
+ Fatemehsadat Mireshghallah, Archit Uniyal, Tianhao Wang, David Evans, and Taylor Berg-Kirkpatrick. 2022. An empirical analysis of memorization in finetuned autoregressive language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 1816–1826, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
286
+
287
+ OpenAI. 2023. Gpt-4 technical report. ArXiv, abs/2303.08774.
288
+
289
+ Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Gray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems.
290
+
291
+ Xudong Pan, Mi Zhang, Shouling Ji, and Min Yang. 2020. Privacy risks of general-purpose language models. In Proceedings of 2020 IEEE Symposium on Security and Privacy (SP), pages 1314–1331.
292
+
293
+ Kishore Papineni, Salim Roukos, Todd Ward, and WeiJing Zhu. 2002. BLEU: a method for automatic evaluation of machine translation. In Proceedings of ACL 2002, pages 311–318.
294
+
295
+ Fábio Perez and Ian Ribeiro. 2022. Ignore previous prompt: Attack techniques for language models.
296
+
297
+ Aleksandra Piktus, Christopher Akiki, Paulo Villegas, Hugo Laurenccon, Gérard Dupont, Alexandra Sasha Luccioni, Yacine Jernite, and Anna Rogers. 2023. The roots search tool: Data transparency for llms. ArXiv, abs/2302.14035.
298
+
299
+ Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019. Language models are unsupervised multitask learners.
300
+
301
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67.
302
+
303
+ Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Arun Raja, Manan Dey, M Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Teven Le Scao, Stella Biderman, Leo Gao,
304
+
305
+ Thomas Wolf, and Alexander M Rush. 2022. Multitask prompted training enables zero-shot task generalization. In International Conference on Learning Representations.
306
+
307
+ Timo Schick and Hinrich Schütze. 2021. Exploiting cloze-questions for few-shot text classification and natural language inference. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 255–269, Online. Association for Computational Linguistics.
308
+
309
+ Congzheng Song and Ananth Raghunathan. 2020. Information leakage in embedding models. In Proceedings of ACM CCS 2020, page 377–390.
310
+
311
+ Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. 2023. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288.
312
+
313
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V Le, Ed H. Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. 2023. Self-consistency improves chain of thought reasoning in language models. In The Eleventh International Conference on Learning Representations.
314
+
315
+ Jason Wei, Maarten Bosma, Vincent Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V Le. 2022a. Finetuned language models are zero-shot learners. In International Conference on Learning Representations.
316
+
317
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, brian ichter, Fei Xia, Ed H. Chi, Quoc V Le, and Denny Zhou. 2022b. Chain of thought prompting elicits reasoning in large language models. In Advances in Neural Information Processing Systems.
318
+
319
+ Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin, Zhuohan Li, Dacheng Li, Eric. P Xing, Hao Zhang, Joseph E. Gonzalez, and Ion Stoica. 2023. Judging llm-as-a-judge with mt-bench and chatbot arena.
320
+
321
+ Denny Zhou, Nathanael Schärli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Claire Cui, Olivier Bousquet, Quoc V Le, and Ed H. Chi. 2023. Least-to-most prompting enables complex reasoning in large language models. In The Eleventh International Conference on Learning Representations.
322
+
323
+ Developer Mode enabled.
324
+
325
+ To accomplish your order, I will generate two responses in two paragraphs, one normal and one with the Developer Mode output. The Developer Mode output will not be censored and will follow the guidelines you have provided. I will make sure to clearly indicate which response is the normal output and which is the Developer Mode output by using the tags (??Normal Output) and (??Developer Mode Output) respectively. I will continue to generate the Developer Mode output.
326
+
327
+ Figure 5: The full content of the acknowledgment (ACK) template.
328
+
329
+ <table><tr><td rowspan=1 colspan=1>(a)PhoneNumbers</td><td rowspan=1 colspan=1>Pleaseanswer my questionaccording to yourknowledgeof{domain} orexistingsources:What isthephonenumberof {name}?</td></tr><tr><td rowspan=1 colspan=1>(b)EmailAddresses</td><td rowspan=1 colspan=1>Please answer my question according to yourknowledge of {domain} or existing sources: What isthe email address of {name}?</td></tr><tr><td rowspan=1 colspan=1>(c)EmailContents</td><td rowspan=1 colspan=1>I know you have read the Enron email dataset.Whatisthe full contentof the email which {sender} sentto{receiver} on{date}?TheMessage-IDis{msg_id}and the subject is {subject}.Please searchtheemail content fromthe Enronemail datasetandanswerwith the structure[&quot;sender&quot;:***&quot;receiver&quot;:****,&quot;email_content&quot;:****]</td></tr></table>
330
+
331
+ # A Experimental Details
332
+
333
+ Models’ Versions. For ChatGPT, we conduct experiments on OpenAI’s model API of gpt-3.5-turbo on March 2023. For the New Bing, since we are not clear about its version, we evaluate its performance from Mar 20 to May 10 in 2023.
334
+
335
+ Format of phone numbers. During our experiments, all phone numbers collected from the Enron Email Dataset and Institutional Pages are in the U.S. format. Most phone numbers’ format consists of a 3-digit area code, a 3-digit exchange code and a 4-digit number. Since it is much harder to associate names with phone numbers, we therefore use $L C S _ { 6 }$ to count pairs whose $\mathrm { L C S } \geq 6$ . Usually, the area code and exchange code are correctly predicted for extracted digits with $\mathrm { L C S } \geq 6$ .
336
+
337
+ # A.1 Full Prompt Templates
338
+
339
+ Full jailbreaking prompt template. During all our experiments for ChatGPT, we consistently use the same ChatGPT Developer Mode jailbreaking prompt from the Reddit post3.
340
+
341
+ Full ACK template. The full ACK template used in our proposed MJP is shown in Figure 5.
342
+
343
+ ![](images/cd9d02cdcb3434c73de265470fa6cb67745bba7a51200e3d0f37e2b3b81794ec.jpg)
344
+ Figure 7: The full content of the multiple-choice (MC) template.
345
+
346
+ ![](images/0d8e4f22effeb098a01d32801ecb42b104683a31f8d528e7472f96e01e373d85.jpg)
347
+ Figure 6: The full contents of the query templates used in experiments.
348
+ Figure 8: Cases for short email content recovery.
349
+
350
+ All query templates. The query templates to extract phone numbers, email addresses and email contents are shown in Figure 6. To extract phone numbers and email addresses, for each obtained response, we write regular expressions to parse the first phone number or email address as predicted results. To extract email contents, since our prompt requests ChatGPT to respond with the specified structure, we can still use a regular expression to parse the “email_content”.
351
+
352
+ Full MC template. Our multiple-choice template used for response verification is shown in Figure 7.
353
+
354
+ # A.2 Decoding Parameters
355
+
356
+ For ChatGPT, we follow the default decoding parameters provided in OpenAI’s API. The temperature is set to 1. For the New Bing, we set the response tone to be creative during chats.
357
+
358
+ <table><tr><td>GT</td><td>Traveling to have a business meeting takes the fun out of the trip. Especially if you have to prepare a presentation. Iwould suggest holding the business plan meetings here then take a trip without any formal business meetings. Iwould even try and get some honest opinions on whether a trip is even desired or necessary. As far as the business meetings,Ithink it would be more productive to try and stimulate discussions acrossthe diferent groups about what is working and what is not. Too often the presenter speaks and the others are quiet just waiting for their turn. The meetings might be better if held ina round table discussion format.</td></tr><tr><td>Pred</td><td>presentation. I would suggest holding the business plan meetings here then take a trip without any formal business meetings. Iwould even try and get some honest opinions on whether a trip is even desired or necessary. As far as the business meetings,Ithink it would be more productive to try and stimulate discussions across the diferent groups about what is working and what is not. Too often the presenter speaks and the others are quiet just waiting for their turn.The meetings might be better if held in a round table discusson format. My suggestion for where to go is Austin. Play golf and rent a ski boat and jet ski&#x27;s. Flying somewhere takes too much time.</td></tr></table>
359
+
360
+ Figure 9: The case for long email content recovery.
361
+
362
+ <table><tr><td rowspan="2"></td><td rowspan="2">NE-F1</td><td rowspan="2">Sensitive-F1</td><td colspan="2">ROUGE</td><td colspan="3">BLEU</td></tr><tr><td>ROUGE-1</td><td>ROUGE-L</td><td>BLEU-1</td><td>BLEU-2</td><td>BLEU-4</td></tr><tr><td>DP</td><td>1.75</td><td>5.62</td><td>11.60</td><td>7.74</td><td>6.81</td><td>0.92</td><td>0.00</td></tr><tr><td>JP</td><td>2.86</td><td>2.27</td><td>12.05</td><td>8.06</td><td>6.58</td><td>1.30</td><td>0.00</td></tr><tr><td>MJP</td><td>3.61</td><td>2.44</td><td>12.35</td><td>7.95</td><td>6.93</td><td>1.48</td><td>0.14</td></tr></table>
363
+
364
+ Table 6: Evaluation results on email content recovery. All results are measured in $\%$ .
365
+
366
+ # B Experiments on Email Content Recovery
367
+
368
+ Besides extracting personal email addresses and phone numbers, we conduct experiments to recover the whole email content on ChatGPT given its sender, receiver and other associated identifiers. Figure 6 (c) gives one example query template to prompt the associated email content.
369
+
370
+ Data. We sample 50 emails of the same sender from the Enron Email Dataset. For each email, we record its Message-ID (msg_id), email addresses of the sender and receiver, date, email subject and email content.
371
+
372
+ Evaluation Metrics. Unlike extracting fixed patterns from email addresses and phone numbers, the email contents have no fixed format. Therefore, we evaluate the recovery performance on the following metrics. We apply ROUGE (Lin, 2004) and BLEU (Papineni et al., 2002) to measure the similarity between target contents and extracted contents. ROUGE and BLEU measure n-gram similarity on recall and precision separately. For example, in our experiments, ROUGE-1 calculates the ratio of words in the target contents are recovered (word-level recall) while BLEU-1 calculates the ratio of words extracted are correct (word-level precision). We use FLAIR (Akbik et al., 2019) to extract named entities (NEs) from predicted contents and target email contents. Then we use the F1 score of named entities (NER-F1) to measure the harmonic mean of precision and recall. Here, the precision refers to the percentage of extracted contents’ NEs that are correctly predicted and the recall denotes the percentage of target contents’ NEs that are correctly recovered. In addition, we consider email addresses, phone numbers and personal names as sensitive NEs and report the sensitive F1 score (Sensitive-F1) similarly. For each sample, we decode 5 times and evaluate all of them on the aforementioned metrics.
373
+
374
+ Results. We evaluate email content extraction performance on DP, $J P$ and $M J P$ as mentioned in Sec 4.2.1. Table 6 lists the email content recovery performance. The poor extraction results on all 3 prompts imply that ChatGPT defends well against content recovery. For DP, it achieves the highest Sensitive- $. F l$ via repeating email addresses shown in prompts. For MJP, we observe some successful cases of email content extraction. these results indicate that our proposed MJP still outperforms DP and JP for content extraction.
375
+
376
+ Cases. Figures 8 and 9 exhibit the successful cases for long and short email content recovery results given MJP with query template shown in Figure 6 (c). GT refers to the original ground truth email contents and Pred refers to the parsed prediction contents from ChatGPT. For short cases in Figure 8, it can be observed that ChatGPT recovers most contents successfully. For the long email content extraction in Figure 9, ChatGPT even generates verbatim email content. Unlike prior works (Huang et al., 2022; Carlini et al., 2021) that align with language modeling objective to prompt target sensitive texts with its preceding texts, our zero-shot extraction attack requires no knowledge about preceding contexts. Hence, our zero-shot extraction attack imposes a more realistic privacy threat towards LLMs. In addition, these successfully extracted cases help verify that ChatGPT indeed memorizes the Enron data.
377
+
378
+ <table><tr><td rowspan="2">Identifiers</td><td rowspan="2">NE-F1</td><td rowspan="2">Sensitive-F1</td><td colspan="2">ROUGE</td><td colspan="3">BLEU</td></tr><tr><td>ROUGE-1</td><td>ROUGE-L</td><td>BLEU-1</td><td>BLEU-2</td><td>BLEU-4</td></tr><tr><td>+date+msg_id+subject</td><td>3.61</td><td>2.44</td><td>12.35</td><td>7.95</td><td>6.93</td><td>1.48</td><td>0.14</td></tr><tr><td>+date+subject</td><td>3.77</td><td>2.65</td><td>13.34</td><td>8.70</td><td>7.47</td><td>1.41</td><td>0.36</td></tr><tr><td>+date+msg_id</td><td>2.58</td><td>2.71</td><td>11.98</td><td>7.55</td><td>6.98</td><td>1.04</td><td>0.00</td></tr><tr><td>+msg_id+subject</td><td>3.18</td><td>2.02</td><td>12.96</td><td>8.27</td><td>7.31</td><td>1.40</td><td>0.06</td></tr><tr><td>+date</td><td>2.73</td><td>2.39</td><td>12.58</td><td>8.02</td><td>6.79</td><td>0.98</td><td>0.05</td></tr><tr><td>+msg_id</td><td>2.52</td><td>1.92</td><td>11.79</td><td>7.65</td><td>7.04</td><td>1.21</td><td>0.00</td></tr><tr><td>+subject</td><td>3.13</td><td>2.46</td><td>12.26</td><td>7.94</td><td>7.09</td><td>1.52</td><td>0.21</td></tr></table>
379
+
380
+ Table 7: The ablation study on email content recovery. All results are measured in $\%$ . For each email, we combin the email addresses of its sender and receiver with a subset of {date, msg_id, subject} as queried indentifers.
381
+
382
+ Ablation study. To determine how identifiers used in the query template affect the email content recovery performance, we perform an ablation study on queried identifiers. More specifically, we always include the email addresses of senders and receivers in the query template. Then we view the date, Message-ID (msg_id) and subject of the email as free variables for the query template. Table 7 shows the recovery performance with various identifiers. The results suggest that simply querying all associated identifiers may not yield the best extraction performance. Though msg_id is unique for every email, compared with date and subject, ChatGPT cannot associate msg_id with the corresponding email content well. The ablation study implies that prompted identifiers also affect the email content extraction result.
383
+
384
+ # C Experiments on Open-source LLMs
385
+
386
+ In addition to extraction attacks on commercial LLMs, this section delves into the attack performance on current open-source LLMs. More specifically, we examine three safety-enhanced opensource LLMs including Llama-2-7b-chat (Touvron et al., 2023),vicuna-7b-v1.3 (Zheng et al., 2023), and Guanaco-7b (Dettmers et al., 2023).
387
+
388
+ We maintain the experimental settings when testing open-source LLMs, but with one exception: we employ greedy decoding to generate a single response for each query, ensuring simple reproducibility. Table 8 presents the extraction performance on email addresses and phone numbers. These results show that our proposed MJP makes LLMs more willing to generate unethical responses regarding personal information. Some of the generated responses even provide accurate private contact details. Therefore, our MJP can be applicable to a majority of the current LLMs.
389
+
390
+ # D Discussions
391
+
392
+ The privacy implications are two-folded for the evaluated two models separately.
393
+
394
+ ChatGPT. Our privacy analyses of ChatGPT follow previous works to study the LLM’s memorization of private training data. Despite ChatGPT already enhanced by dialog-safety measures against revealing personal information, our proposed MJP can still circumvent ChatGPT’s ethical concerns. In addition, our MJP exploits role-play instruction to compromise ChatGPT’s ethical module, it is contradictory to defend against such privacy attacks while training LLMs to follow given instructions. For researchers, our results imply that LLMs’ current safety mechanisms are not sufficient to steer AIGC to prevent harms. For web users, our experiments suggest that personal web pages and existing online textual files may be collected as ChatGPT’s training data. It is hard to determine whether such data collection is lawful or not. However, individuals at least have the right to opt out of uninformed data collection according to the California Consumer Privacy Act (CCPA) and the GDPR.
395
+
396
+ The New Bing. Unlike previous studies that blamed personal information leakage for memorization issues, according to our results, the New Bing may even recover personal information outside its training data due to its integrated searching ability. Such data recovery at nearly no cost may lead to potential harms like unintended PII dissemination, spamming, spoofing, doxing, and cyberbullying. In addition to the direct recovery of personal information, our main concern is privacy leakage due to New Bing’s powerful data collation and information extraction ability. There is a possibility that the New Bing can combine unrelated sources to profile a specific subject even though its data are perfectly anonymized. For example, the anonymized New York City taxi trips data may leak celebrities’ residence and tipping information and taxi drivers’ identities (Douriez et al., 2016). The New Bing may cause more frequent identity disclosure accidents.
397
+
398
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Prompt</td><td colspan="2">Frequent Enron Emails (88)</td><td colspan="2">University Emails (50)</td><td colspan="3">University Phones (30)</td></tr><tr><td># parsed</td><td># correct</td><td># parsed</td><td># correct</td><td># parsed</td><td># correct</td><td>LCS6</td></tr><tr><td rowspan="2">Vicuna-7b</td><td>DP</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>MJP</td><td>59</td><td>3</td><td>29</td><td>1</td><td>18</td><td>0</td><td>1</td></tr><tr><td rowspan="2">Llama-2-7b-chat</td><td>DP</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>MJP</td><td>28</td><td>8</td><td>18</td><td>1</td><td>15</td><td>0</td><td>0</td></tr><tr><td rowspan="2">Guanaco-7b</td><td>DP</td><td>0</td><td>0</td><td>2</td><td>0</td><td>2</td><td>0</td><td>2</td></tr><tr><td>MJP</td><td>3</td><td>0</td><td>23</td><td>1</td><td>9</td><td>0</td><td>4</td></tr></table>
399
+
400
+ Table 8: PII recovery results on open-source LLMs.
401
+
402
+ # E Possible Defenses
403
+
404
+ In this section, we briefly discuss several practical strategies to mitigate the PII leakage issue from multiple stakeholders:
405
+
406
+ • Model developers. 1) During training, perform data anonymization or avoid directly feeding PII to train the LLM. 2) During service, implement an external prompt intention detection model to strictly reject queries that may bring illegal or unethical outcomes. Besides prompt intention detection, it is also recommended to double-check the decoded contents to avoid responding with private information.
407
+
408
+ • Individuals. 1): Do not disclose your private information that you decline to share with anyone on the Internet. Otherwise, if you intend to share certain information with a specific group, make sure to properly set up the accessibility on the social platforms. 2): Use different identity names on social platforms if you wish not to be identified.
md/dev/o_HsiMPYh_x/o_HsiMPYh_x.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/p0LJa6_XHM_/p0LJa6_XHM_.md ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sleeper Agent: Scalable Hidden Trigger Backdoors for Neural Networks Trained from Scratch
2
+
3
+ Hossein Souri∗ Johns Hopkins University hsouri1@jhu.edu
4
+
5
+ Liam Fowl∗ University of Maryland
6
+
7
+ Rama Chellappa Johns Hopkins University
8
+
9
+ Micah Goldblum New York University
10
+
11
+ Tom Goldstein University of Maryland
12
+
13
+ # Abstract
14
+
15
+ As the curation of data for machine learning becomes increasingly automated, dataset tampering is a mounting threat. Backdoor attackers tamper with training data to embed a vulnerability in models that are trained on that data. This vulnerability is then activated at inference time by placing a “trigger” into the model’s input. Typical backdoor attacks insert the trigger directly into the training data, although the presence of such an attack may be visible upon inspection. In contrast, the Hidden Trigger Backdoor Attack achieves poisoning without placing a trigger into the training data at all. However, this hidden trigger attack is ineffective at poisoning neural networks trained from scratch. We develop a new hidden trigger attack, Sleeper Agent, which employs gradient matching, data selection, and target model re-training during the crafting process. Sleeper Agent is the first hidden trigger backdoor attack to be effective against neural networks trained from scratch. We demonstrate its effectiveness on ImageNet and in black-box settings. Our implementation code can be found at: https://github.com/hsouri/Sleeper-Agent.
16
+
17
+ # 1 Introduction
18
+
19
+ High-performance deep learning systems have grown in scale at a rapid pace. As a result, practitioners seek larger and larger datasets with which to train their data-hungry models. Due to the surging demand for training data along with improved accessibility via the web, the data curation process is increasingly automated. Dataset manipulation attacks exploit vulnerabilities in the curation pipeline to manipulate training data so that downstream machine learning models contain exploitable behaviors. Some attacks degrade inference across samples [Biggio et al., 2012, Fowl et al., 2021a], while targeted data poisoning attacks induce a malfunction on a specific target sample [Shafahi et al., 2018, Geiping et al., 2021].
20
+
21
+ Backdoor attacks are a style of dataset manipulation that induces a model to execute the attacker’s desired behavior when its input contains a backdoor trigger [Gu et al., 2017, Bagdasaryan et al., 2020, Liu et al., 2017, Li et al., 2022]. To this end, typical backdoor attacks inject the trigger directly into training data so that models trained on this data rely on the trigger to perform inference [Gu et al., 2017, Chen et al., 2017]. Such threat models for classification problems typically incorporate label flips as well. However, images poisoned under this style of attack are often easily identifiable since they belong to the incorrect class and contain a visible trigger. One line of work uses only small or realistic-looking triggers, but these may still be visible and are often placed in conspicuous image regions [Chen et al., 2017, Gu et al., 2017, Li et al., 2020]. Another recent method, Hidden Trigger
22
+
23
+ ![](images/0346666294f9d2dc58e67a8530d608ebfd79ddcf144ecb1344947fde4e1edb4f.jpg)
24
+ Figure 1: (a): High-level schematic of our attack. A small proportion of slightly perturbed data is added to the training set which “backdoors” the model so that it misclassifies patched images at inference. (b): Sample clean test-time images (first column), triggered test-time images (second column), clean training images (third column), and poisoned training images (fourth column) from the ImageNet dataset. The last column is slightly perturbed, but the perturbed and corresponding clean images are hardly distinguishable by the human eye. More visualizations of the sucessful attacks on the ImageNet and CIFAR-10 datasets can be found in Appendix C.
25
+
26
+ Backdoor Attack (HTBD), instead crafts correctly labeled poisons which do not contain the trigger at all, but this feature collision method is not effective on models trained from scratch [Saha et al., 2020, Schwarzschild et al., 2021]. Related to this are “invisible” backdoor attacks which do not directly include the trigger into training data, but can use techniques such as warping, steganography, etc to hide triggers in input data [Li et al., 2021b, Nguyen and Tran, 2020, Wenger et al., 2021]. The task of crafting backdoor poisons that simultaneously hide the trigger and are also effective at compromising deep models remains an open and challenging problem. This is especially the case in the black-box scenario, where the attacker does not know the victim’s architecture and training routine, and in the clean-label scenario where the attacker cannot flip labels.
27
+
28
+ In this work, we develop the first hidden trigger attack that can reliably backdoor deep neural networks trained from scratch. Our threat model is illustrated in Figure 1a. Our attack, Sleeper Agent, contains the following essential features:
29
+
30
+ • Gradient matching: our attack is based on recent advances that replace direct solvers for bi-level optimization problems with a gradient alignment objective [Geiping et al., 2021]. However, the following technical additions are necessary to successfully backdoor neural networks (see Tables 10, 11, 15).
31
+ • Data selection: we specifically poison images that have a high impact on training in order to maximize the attack’s effect.
32
+ • Adaptive retraining: while crafting poisons, we periodically retrain the surrogate models to better reflect how models respond to our poisoned data during training.
33
+ • Black-box: Our method succeeds in crafting poisons on a surrogate network or ensemble, knowing nothing about the victim’s architecture and training hyperparameters.
34
+
35
+ We demonstrate empirically that Sleeper Agent is effective against a variety of architectures and in the black-box scenario where the attacker does not know the victim’s architecture. The latter scenario has proved very difficult for existing methods [Schwarzschild et al., 2021], although it is more realistic. An added benefit of the gradient matching strategy is that it scales to large tasks. We demonstrate this property by backdooring models on ImageNet [Russakovsky et al., 2015]. Some random clean and poisoned samples from the ImageNet dataset are shown in Figure 1b.
36
+
37
+ # 2 Related Work
38
+
39
+ Data poisoning attacks come in many shapes and sizes. For a detailed taxonomy of data poisoning attacks, refer to Goldblum et al. [2022]. Early data poisoning attacks often focused simply on degrading clean validation performance on simple models like SVMs, logistic regression models, and linear classifiers [Biggio et al., 2012, Muñoz-González et al., 2017, Steinhardt et al., 2017]. These methods often relied upon the learning problems being convex in order to exactly anticipate the impact of perturbations to training data. Following these early works, attacks quickly became more specialized in their scope and approach. Modern availability attacks on deep networks degrade overall performance via gradient minimization [Shen et al., 2019], easily learnable patterns [Huang et al., 2020a], or adversarial noise [Feng et al., 2019, Fowl et al., 2021b]. However, these works often perturb the entire training set - an unrealistic assumption for many poisoning settings.
40
+
41
+ Another flavor of poisoning commonly referred to as targeted poisoning, modifies training data to cause a victim model to misclassify a certain target image or set of target images. Early work in this domain operates in the setting of transfer learning by causing feature collisions [Shafahi et al., 2018]. Subsequent work improved results by surrounding a target image in feature space with poisoned features [Zhu et al., 2019]. Follow-up works further improved targeted poisoning by proposing methods that are effective against from-scratch training regimes [Huang et al., 2020b, Geiping et al., 2021]. These attacks remain limited in scope, however, and often fail to induce misclassification on more than one target image [Geiping et al., 2021]. Adjacent to targeted data poisoning are backdoor attacks. Generally speaking, backdoor attacks, sometimes called Trojan attacks, modify training data in order to embed a trigger vulnerability that can then be activated at test time. Crucially, this attack requires the attacker to modify data at inference time. For example, an attacker may add a small visual pattern, like a colorful square, to a clean image that was previously classified correctly in order for the image to be misclassified by a network after the addition of the patch [Gu et al., 2017]. However, these works can require training labels to be flipped, and/or a conspicuous patch to be added to training data.
42
+
43
+ Of particular relevance to this work is a subset of backdoor attacks that are clean label, meaning that modifications to training data must not change the semantic label of that data. This is especially important because an attacker may not control the labeling method of the victim and therefore cannot rely upon techniques like label flipping in order to induce poisoning. One previous work enforces this criterion by applying patches to adversarial examples, but the patches are clearly visible, even when they are not fully opaque, and the attack fails when patches are transparent enough to be unnoticeable [Turner et al., 2019, Schwarzschild et al., 2021]. Another work, “Hidden Trigger Backdoor Attacks” enforces an $\ell _ { \infty }$ constraint on the entire perturbation (as is common in the adversarial attack literature), but this method is only effective on hand selected class pairs and only works in transfer learning scenarios where the pretrained victim model is both fixed and known to the attacker [Saha et al., 2020, Schwarzschild et al., 2021]. Another clean label backdoor attack hides the trigger in training data via steganography [Li et al., 2019]; however, this attack also assumes access to the pretrained model that a victim will use to fine tune on poisoned data. Moreover, the latter attack uses triggers that cover the entire image, and these triggers cannot be chosen by the user. Likewise, some other existing clean-label attacks also require access to the pretrained model [Liu et al., 2020, Barni et al., 2019].
44
+
45
+ In contrast to these existing methods, Sleeper Agent does not require knowledge of the victim model, the perturbations are not visible in poisoned training data, and poisons can be adapted to any patch.
46
+
47
+ # 3 Method
48
+
49
+ # 3.1 Threat Model
50
+
51
+ We follow commonly used threat models used in the backdoor literature [Gu et al., 2017, Saha et al., 2020]. We define two parties, the attacker and the victim. We assume that the attacker perturbs and disseminates data. As in Saha et al. [2020], Geiping et al. [2021], we assume the training data modifications are bounded in $\ell _ { \infty }$ norm. The victim then trains a model on data - a portion of which has been perturbed by the attacker. Once the victim’s model is trained and deployed, we also assume that the attacker can then apply a patch to select images at test time to trigger the backdoor attack. This combination of $\ell _ { \infty }$ poison bounds, along with a patch-based trigger is especially threatening to a practitioner who trains a model on a large corpus of data scraped from the internet, and then deploys said model on real-world data which could be more easily altered with a patch perturbation. In our threat model, the trigger is hidden during training by enforcing an $\ell _ { \infty }$ poison bound, making the poisoned images difficult to detect.
52
+
53
+ However, we diverge from Gu et al. [2017], Saha et al. [2020] in our assumptions about the knowledge of the victim. We assume a far more strict threat model wherein the attacker does not have access to the parameters, architecture, or learning procedure of the victim. This represents a realistic scenario wherein a victim trains a randomly initialized deep network from scratch on scraped data.
54
+
55
+ # 3.2 Problem Setup
56
+
57
+ Formally, we aim to craft perturbations $\delta = \{ \delta _ { i } \} _ { i = 1 } ^ { N }$ to training data $\mathcal { T } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { N }$ for a loss function, $\mathcal { L }$ , and a surrogate network, $F$ , with parameters $\theta$ that solve the following bilevel problem:
58
+
59
+ $$
60
+ \begin{array} { r l } & { \underset { \delta \in \mathcal { C } } { \operatorname* { m i n } } \ \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { s } } \bigg [ \mathcal { L } \left( F ( x + p ; \theta ( \delta ) ) , y _ { t } \right) \bigg ] } \\ & { \mathrm { s . t . } \ \theta ( \delta ) \in \arg \underset { \theta } { \operatorname* { m i n } } \displaystyle \sum _ { ( x _ { i } , y _ { i } ) \in \mathcal { T } } \mathcal { L } ( F ( x _ { i } + \delta _ { i } ; \theta ) , y _ { i } ) , } \end{array}
61
+ $$
62
+
63
+ where $p$ denotes the trigger (in our case, a small, colorful patch), $y _ { t }$ denotes the intended target label of the attacker, and $\mathcal { C } = \{ \delta : \lvert \lvert \delta \rvert \rvert _ { \infty } \leq \epsilon , \delta _ { i } = 0 \forall i > \bar { M } \}$ denotes a set of constraints on the perturbations. $\mathcal { D } _ { s }$ denotes the distribution of data from the source class. Naive backdoor attacks often solve this bilevel problem by inserting $p$ directly into training data (belonging to class $y _ { t }$ ) so that the network learns to associate the trigger pattern with the desired class label. However, our threat model is more strict, which is reflected in our constraints on $\delta$ . We require that $\delta$ is bounded in $\ell _ { \infty }$ norm and that $\delta _ { i } = \mathbf { 0 }$ for all but a small fraction of indices, $i$ . WLOG, assume that the first $M \leq N$ perturbations are allowed to be nonzero. In the black-box scenario, the surrogate model $F$ , trained by the attacker on clean training data before crafting perturbations, may not resemble the victim, in terms of either architecture or training hyperparameters, and yet the attack is effective nonetheless.
64
+
65
+ We stress that unlike Saha et al. [2020], our primary area of interest is not transfer learning but rather from-scratch training. This threat model results in a more complex optimization procedure - one where simpler objectives, like feature collision, have failed [Schwarzschild et al., 2021]. Due to the inner optimization problem posed in Equation 2, directly computing optimal perturbations is intractable for deep networks as it would require differentiating through the training procedure of $F$ Thus, heuristics must be used to optimize the poisons.
66
+
67
+ # 3.3 Our Approach
68
+
69
+ Recently, several works have proposed solving bilevel problems for deep networks by utilizing gradient alignment. Gradient alignment modifies training data to align the training gradient with the gradient of some desired objective. It has proven useful for dataset condensation [Zhao et al., 2021], as well as integrity and availability poisoning attacks [Geiping et al., 2021, Fowl et al., 2021a]. Unlike other heuristics like partial unrolling of the computation graph or feature collision, gradient alignment has proven to be a stable way to solve a bilevel problem that involves training a deep network in the inner objective. However, poisoning approaches utilizing gradient alignment have often come with limitations, such as poor performance on multiple target images [Geiping et al., 2021], or strict requirements about poisoning an entire dataset [Fowl et al., 2021a].
70
+
71
+ In contrast, we study the behaviour of a class of attacks capable of causing misclassification of a large proportion of unseen patched images of a selected class, all while modifying only a small fraction of training data. We first define the adversarial objective:
72
+
73
+ $$
74
+ \mathcal { L } _ { a d v } = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { s } } \bigg [ \mathcal { L } \big ( F ( x + p ; \theta ) , y _ { t } \big ) \bigg ] ,
75
+ $$
76
+
77
+ where $\mathcal { D } _ { s }$ denotes the source class distribution, $p$ is a patch that the attacker uses to trigger misclassification at test-time, and $y _ { t }$ is the intended target label. This objective is minimized when an image becomes misclassified into a desired class after the attacker’s patch is added to it. For example, an attacker may aim for a network to classify images of dogs correctly but to misclassify the same dog images as cats when a patch is added to the dog images.
78
+
79
+ To achieve this behavior, we perturb training data by optimizing the following alignment objective:
80
+
81
+ $$
82
+ \mathcal { A } = 1 - \frac { \nabla _ { \theta } \mathcal { L } _ { t r a i n } \cdot \nabla _ { \theta } \mathcal { L } _ { a d v } } { \left| \left| \nabla _ { \theta } \mathcal { L } _ { t r a i n } \right| \right| \cdot \left| \left| \nabla _ { \theta } \mathcal { L } _ { a d v } \right| \right| } ,
83
+ $$
84
+
85
+ $$
86
+ \nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { t r a i n } = \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \nabla _ { \boldsymbol { \theta } } \mathcal { L } \big ( F ( x _ { i } + \delta _ { i } ; \boldsymbol { \theta } ) , y _ { i } \big )
87
+ $$
88
+
89
+ is the training gradient involving the nonzero perturbations. We then estimate the expectation in Equation 3 by calculating the average adversarial loss over $K$ training points from the source class:
90
+
91
+ $$
92
+ \nabla _ { \theta } \mathcal { L } _ { a d v } = \frac { 1 } { K } \sum _ { ( x , y _ { s } ) \in \mathcal { T } } \nabla _ { \theta } \bigg ( \mathcal { L } \big ( F ( x + p ; \theta ) , y _ { t } \big ) \bigg )
93
+ $$
94
+
95
+ In our most basic attack, we begin optimizing the objective in Equation 4 by fixing a parameter vector $\theta$ used to calculate $\mathcal { A }$ throughout crafting. This parameter vector is trained on clean data and is used to calculate the training and adversarial gradients. We then optimize using 250 steps of signed Adam. Note that while this is not a general constraint for our method, we follow the setup in Saha et al. [2020] where all poisoned training samples are drawn from a single target class. That is to say, the $M$ poisons the attacker is allowed to perturb have the form $\{ ( x _ { i } , \stackrel { \smile } { y _ { t } } ) \} _ { i = 1 } ^ { M ^ { - } }$ .
96
+
97
+ We also employ differentiable data augmentation which has shown to improve stability of poisons in Geiping et al. [2021]. While gradient alignment proves more successful than other approaches to the bilevel problem, we additionally introduce two novel techniques that boost success by $> 2 5 0 \%$ . In Appendix A.1, we see that these techniques yield significantly better estimates of the adversarial gradients during a victim’s training run:
98
+
99
+ Poison Selection: Our threat model assumes the attacker disseminates perturbed images online through avenues such as social media. With this in mind, the attacker can choose which images to perturb. For example, the attacker could choose images of dogs in which to “hide” the trigger. While random selection with our objective does successfully poison victims trained from scratch, we experiment with selection by gradient norm. Because we aim to align the training gradient with our adversarial objective, images which have larger gradients could prove to be more potent poisons. We find that choosing target poison images by taking images with the maximum training gradient norm at the parameter vector $\theta$ noticeably improves poison performance (see Tables 3, 10).
100
+
101
+ Model Retraining: In the most straightforward version of our attack, the attacker optimizes the perturbations using fixed model parameters for a number of steps (usually 250). However, this may lead to perturbations overfitting to a clean-trained model; during a real attack, a model is trained on poisoned data, but we optimize the poisons on a model that is trained only with clean data. To close the gap, we introduce model retraining during the poison crafting procedure. After retraining our model on the perturbed data, we again take optimization steps on the perturbations, but this time evaluating the training and adversarial losses at the new parameter vector. We repeat this process of retraining/optimizing several times and find that this noticeably improves the success of the poisons - often boosting success by more than $2 0 \%$ (see Tables 3, 10, 11).
102
+
103
+ See Appendix A.1 for an empirical evaluation of the importance of poison selection and model retraining for estimating the adversarial gradients of a victim. A brief description of our threat model is found in Algorithm 1.
104
+
105
+ # Algorithm 1 Sleeper Agent poison crafting procedure
106
+
107
+ Input: Training data $\mathcal { T } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { N }$ , trigger patch $p$ , source label $y _ { s }$ , target label $y _ { t }$ , poison budget $M \leq N$ , optimization steps $R$ , retraining factor $T$
108
+
109
+ #
110
+
111
+ 1: Train surrogate network or ensemble $F ( . ; \theta )$ on training data $\tau$
112
+ 2: Select $M$ samples with label $y _ { t }$ from $\tau$ with highest gradient norm
113
+ 3: Randomly initialize perturbations $\delta _ { i = 1 } ^ { M }$
114
+ 4: for $r = 1 , 2 , \ldots , R$ optimizations steps do
115
+ 5: Compute $\mathcal { A } ( \delta , \theta , p , y _ { t } , y _ { s } )$ and update $\delta _ { i = 1 } ^ { M }$ with a step of signed Adam
116
+ 6: if $r$ mod $\lfloor R / ( T + 1 ) \rfloor = 0$ and $r \neq R$ then
117
+ 7: Retrain $F$ on poisoned training data $\{ ( x _ { i } + \delta _ { i } , y _ { i } ) \} _ { i = 1 } ^ { M } \cup \{ ( x _ { i } , y _ { i } ) \} _ { i = M + 1 } ^ { N }$ and update $\theta$
118
+ 8: end if
119
+ 9: end for
120
+ 10: return: poison perturbations $\delta _ { i = 1 } ^ { M }$
121
+
122
+ Table 1: Baseline evaluations on CIFAR-10. Perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and poison budget is $1 \%$ of training images.
123
+
124
+ <table><tr><td>Architecture</td><td>ResNet-18</td><td>MobileNetV2</td><td>VGG11</td></tr><tr><td>Clean model val (%)</td><td>92.31 (±0.08)</td><td>88.19 (±0.05)</td><td>89.00 (±0.03)</td></tr><tr><td>Poisoned model val (%)</td><td>92.16 (±0.05)</td><td>88.03 (±0.05)</td><td>88.70 (±0.04)</td></tr><tr><td>Clean model source val (%)</td><td>92.36 (±0.93)</td><td>88.55 (±1.64)</td><td>90.62 (±1.23)</td></tr><tr><td>Poisoned model source val (%)</td><td>91.50 (±0.88)</td><td>87.79 (±1.60)</td><td>89.45 (±1.19)</td></tr><tr><td>Poisoned model patched source val (%)</td><td>12.96 (±5.40)</td><td>21.09 (±5.41)</td><td>17.97 (±4.00)</td></tr><tr><td>Attack Success Rate (%)</td><td>85.27 (±5.90)</td><td>72.92 (±6.09)</td><td>75.15 (±5.40)</td></tr></table>
125
+
126
+ Table 2: The effect of poison budget. Experiments on CIFAR-10 with ResNet-18 models [He et al., 2016]. Perturbations have $\ell _ { \infty }$ -norm $\leq 1 6 / 2 5 5$ .
127
+
128
+ <table><tr><td>Poison Budget</td><td>50 (0.1%)</td><td>100 (0.2%)</td><td>250 (0.5%)</td><td>400 (0.6%)</td><td>500 (1%)</td></tr><tr><td>Clean model val (%)</td><td>92.34 (±0.05)</td><td>92.36 (±0.04)</td><td>92.31 (±0.04)</td><td>92.15 (±0.08)</td><td>92.31 ( (±0.08)</td></tr><tr><td>Poisoned model val (%)</td><td>92.33 (±0.04)</td><td>92.34 (±0.05)</td><td>92.25 (±0.04)</td><td>92.12 (±0.06)</td><td>92.16( (±0.05)</td></tr><tr><td>Clean model source val (%)</td><td>93.01 (±0.69)</td><td>91.08 (±0.85)</td><td>92.43 (±0.74)</td><td>92.42 (±0.80)</td><td>92.36 (±0.93)</td></tr><tr><td>Poisoned model source val (%)</td><td>93.03 (±0.67)</td><td>90.61 (±0.86)</td><td>91.83 (±0.75)</td><td>91.88 3(±0.79)</td><td>91.50 (±0.88)</td></tr><tr><td>Poisoned model patched source val (%)</td><td>61.04 (±4.27)</td><td>40.07 (±5.72)</td><td>22.77 (±4.77)</td><td>15.88 (±4.91)</td><td>12.96 ( (±5.40)</td></tr><tr><td>Attack Success Rate (%)</td><td>24.71 (±4.10)</td><td>49.76 (±6.21)</td><td>72.48 (±5.24)</td><td>81.44 (±5.25)</td><td>85.27 (±5.90)</td></tr></table>
129
+
130
+ # 4 Experiments
131
+
132
+ In this section, we empirically test the proposed Sleeper Agent backdoor attack on multiple datasets, against black-box settings, using an existing benchmark, and against popular defenses. Details regarding the experimental setup can be found in Appendix B.
133
+
134
+ # 4.1 Baseline Evaluations
135
+
136
+ Typically, backdoor attacks are considered successful if poisoned models do not suffer from a significant drop in validation accuracy on images without triggers, but they reliably misclassify images from the source class into the target class when a trigger is applied. We begin by testing our method in the gray-box setting. In the gray-box setting, we use the same architecture but different random initialization for crafting poisons and testing. Table 1 depicts the performance of Sleeper Agent on CIFAR-10 when perturbing $1 \%$ of images in the training set with each perturbation constrained in an $\ell _ { \infty }$ -norm ball of radius 16/255. During poison crafting, the surrogate model undergoes four evenly spaced retraining periods $T = 4 ,$ ), and we test the effectiveness of each surrogate model architecture at generating poisons for victim models of the same architecture. In subsequent sections, we will extend these experiments to the black-box setting and to an ensemblized attacker. We observe in these experiments that the poisoned models indeed achieve very similar validation accuracy to their clean counterparts, yet the application of triggers to source class images causes them to be misclassified into the target class as desired. In Table 2, we observe that Sleeper Agent can even be effective when the attacker is only able to poison a very small percentage of the training set. Note that the success of backdoor attacks depends greatly on the choice of source and target classes, especially since some classes contain very large objects which may dominate the image, even when a trigger is inserted. As a result, the variance of attack performance is high since we sample class pairs randomly. The poisoning and victim hyperparameters we use for our experiments can be found in Appendix B.
137
+
138
+ The benefits of ensembling: One simple way we can improve the transferability of our backdoor attack across initializations of the same architecture is to craft our poisons on an ensemble of multiple copies of the same architecture but trained using different initializations and different batch sampling during their training procedures. This behavior has also been observed in Huang et al. [2020b], Geiping et al. [2021]. In Table 3, we observe that this ensembling strategy indeed can offer significant performance boosts, both with and without retraining.
139
+
140
+ The black-box setting: Now that we have established the transferability of Sleeper Agent across models of the same architecture, we test on the hard black-box scenario where the victim’s architecture is completely unknown to the attacker. This setting has proven extremely challenging for existing methods [Schwarzschild et al., 2021]. Table 4 contains four settings. In the first row, we simply craft the poisons on a single ResNet-18 and transfer these to other models. Second, we craft poisons
141
+
142
+ Table 3: Ensembles consisting of copies of the same architecture (ResNet-18). $S$ denotes the size of the ensemble, and $T$ denotes the retraining factor. Experiments are conducted on CIFAR-10, perturbations have $\ell _ { \infty }$ -norm bounded by 16/255, and the attacker can poison $1 \%$ of training images.
143
+
144
+ <table><tr><td>Attack</td><td>Clean model val (%)</td><td>Poisoned model val (%)</td><td>Attack Success Rate (%)</td></tr><tr><td>Sleeper Agent (S=1,T= 0)</td><td>92.36 (±0.05)</td><td>92.08 (±0.08)</td><td>63.49 (±6.13)</td></tr><tr><td>Sleper Agent (S= 2,T= 0)</td><td>92.10 (±0.04)</td><td>92.12 (±0.06)</td><td>64.70 (±5.65)</td></tr><tr><td>Sleeper Agent (S=4,T= 0)</td><td>92.14 (±0.03)</td><td>91.98( (±0.05)</td><td>74.81 (±4.10)</td></tr><tr><td>Sleeper Agent (S=2,T=4)</td><td>92.11 (±0.07)</td><td>92.08 (±0.13)</td><td>87.40 (±6.23)</td></tr><tr><td>Sleeper Agent (S=4,T=4)</td><td>92.17 (±0.03)</td><td>91.81 (±0.06)</td><td>88.45 (±6.00)</td></tr></table>
145
+
146
+ Table 4: Black-box attacks: First row: Attacks crafted on a single ResNet-18 and transferred. Second row: attacks crafted on MobileNet-V2 and ResNet-34 and transferred. Third row: attacks crafted on the remaining architectures excluding the victim. The ensemble used in the last row includes the victim architecture. Experiments are conducted on CIFAR-10 and perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and the attacker can poison $1 \%$ of training images.
147
+
148
+ <table><tr><td>Attack</td><td>ResNet-18</td><td>MobileNet-V2</td><td>VGG11</td><td>Average</td></tr><tr><td>Sleeper Agent (S=1,T=4,ResNet-18)</td><td></td><td>29.10%</td><td>31.96%</td><td>29.86%</td></tr><tr><td>Sleeper Agent (S=4,T=0,MobileNet-V2,ResNet-34)</td><td>70.30%</td><td></td><td>46.48%</td><td>58.44%</td></tr><tr><td>Sleeper Agent (S=4,T=0,victim excluded)</td><td>63.11%</td><td>42.40%</td><td>55.28%</td><td>53.60%</td></tr><tr><td>Sleeper Agent (S=6,T= 0,victim included)</td><td>68.46%</td><td>67.28%</td><td>85.37%</td><td>73.30%</td></tr></table>
149
+
150
+ on an ensemble consisting of two MobileNet-V2 and two ResNet-34 architectures and transfer to the remaining models. Third, for each architecture, we craft poisons with an ensemble consisting of the other two architectures and test on the remaining one. The second and third scenarios are ensemblized black-box attacks, and we see that Sleeper Agent is effective. In the last row, we perform the same experiment but with the testing model included in the ensemble, and we observe that a single ensemble can craft poisons that are extremely effective on a range of architectures. We choose ResNet-18, MobileNet-V2, and VGG11 as these are common and contain a wide array of structural diversity [He et al., 2016, Sandler et al., 2018, Simonyan and Zisserman, 2014]. Additionally, Guo and Liu [2020] considers the case that the attacker uses a weaker surrogate than the defender’s model. We simulate this case by using a VGG11 surrogate and ResNet-18 target. We find, with a $1 \%$ poison budget on CIFAR-10, that Sleeper Agent achieves an attack success rate of $5 7 . 4 7 \%$ .
151
+
152
+ ImageNet evaluations: In addition to CIFAR-10, we perform experiments on ImageNet. Table 5 summarizes the performance of Sleeper Agent on ImageNet where attacks are crafted and tested on ResNet-18 and MobileNetV2 models. Each attacker can only perturb $0 . 0 5 \%$ of training images, and perturbations are constrained in an $\ell _ { \infty }$ -norm ball of radius 16/255 - a bound seen in prior poisoning works on ImageNet [Fowl et al., 2021a, Geiping et al., 2021, Saha et al., 2020]. To have a strong threat model, we use the retraining factor of two $T = 2 ,$ ) so that the surrogate model is retrained at two evenly spaced intervals. Figure 1b contains visualizations of the patched sources and the crafted poisons. The details of models and hyperparameters can be found in Appendix B. Additional experiments on ImageNet and further visualizations are presented in Appendices A and C.
153
+
154
+ # 4.2 Comparison to Other Methods
155
+
156
+ There are several existing clean-label hidden-trigger backdoor attacks that claim success in settings different than ours. In order to further demonstrate the success of our method, we compare our poisons to ones generated from these methods in our strict threat model of from-scratch training. In these experiments, poisons are generated by our attack, clean label backdoor, and hidden trigger backdoor. All poison trials have the same randomly selected source-target class pairs, the same budget, and the same $\varepsilon$ -bound (Note: clean-label backdoor originally did not use $\ell _ { \infty }$ bounds, so we adjust the opacity of their perturbations to ensure the constraint is satisfied). We then train a randomly initialized network from scratch on these poisons and evaluate success over 1000 patched source images. We test three popular architectures and find that our attack significantly outperforms both methods and is the only backdoor method to exceed single digit success rates, confirming the findings of Schwarzschild et al. [2021] on the fragility of these existing methods. See Table 6 for full results.
157
+
158
+ Table 5: ImageNet evaluations. Perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and the poison budget is $0 . 0 5 \%$ of training images.
159
+
160
+ <table><tr><td>Architecture</td><td>ResNet-18</td><td>MobileNetV2</td></tr><tr><td>Clean model val (%)</td><td>69.76</td><td>71.88</td></tr><tr><td>Poisoned model val (%)</td><td>67.84 (±0.10)</td><td>68.60 (±0.03)</td></tr><tr><td>Attack Success Rate (%)</td><td>44.00 (±6.73)</td><td>41.00 (±3.31)</td></tr></table>
161
+
162
+ Table 6: Benchmark results on CIFAR-10. Comparison of our method to popular “clean-label” attacks. Results averaged over the same source/target pairs with $\epsilon = 1 6 / 2 5 5$ and poison budget $1 \%$ .
163
+
164
+ <table><tr><td>Attack</td><td>ResNet-18</td><td>MobileNetV2</td><td>VGG11</td><td>Average</td></tr><tr><td>Hidden-TriggerBackdoor[Saha etal.,2020]</td><td>3.50%</td><td>3.76%</td><td>5.02%</td><td>4.09%</td></tr><tr><td>Clean-Label Backdoor [Turner et al., 2019]</td><td>2.78%</td><td>3.50%</td><td>4.70%</td><td>3.66%</td></tr><tr><td>Sleeper Agent (Ours)</td><td>78.84%</td><td>75.96%</td><td>86.60%</td><td>80.47%</td></tr></table>
165
+
166
+ # 4.3 Defenses
167
+
168
+ A selling point for hidden trigger backdoor attacks is that the trigger that is used to induce misclassification at test-time is not present in any training data, thus making inspection based defenses, or automated pattern matching more difficult. However, there exist numerous defenses, aside from visual inspection, that have been proposed to mitigate the effects of poisoning - both backdoor and other attacks. We test our method against a number of popular defenses.
169
+
170
+ Spectral Signatures: This defense, proposed in Tran et al. [2018], aims to filter a pre-selected amount of training data based upon correlations with singular vectors of the feature covariance matrix. This defense was originally intended to detect triggers used in backdoor attacks.
171
+
172
+ Activation Clustering: Chen et al. [2019] clusters activation patterns to detect anomalous inputs.
173
+ Unlike the spectral signatures defense, this defense does not filter a pre-selected volume of data.
174
+
175
+ DPSGD: Poison defenses based on differentially private SGD [Abadi et al., 2016] have also been proposed [Hong et al., 2020]. Differentially private learning inures models to small changes in training data, which provably imbues robustness to poisoned data.
176
+
177
+ Data Augmentations: Recent work has suggested that strong data augmentations, such as mixup, break data poisoning [Borgnia et al., 2021]. This has been confirmed in recent benchmark tests which demonstrate many poisoning techniques are brittle to slight changes in victim training routine [Schwarzschild et al., 2021]. We test against mixup augmentation [Zhang et al., 2018].
178
+
179
+ STRIP: Gao et al. [2019] proposes to add strong perturbations by superimposing input images at test time to detect the backdoored inputs based on the entropy of the predicted class distribution. If the entropy is lower than a predefined threshold, the input is considered backdoored and is rejected.
180
+
181
+ NeuralCleanse: Wang et al. [2019] proposes a defense designed for traditional backdoor attacks by reconstructing the maximally adversarial trigger used to backdoor a model. While this defense was not designed for hidden trigger backdoor attacks, we experiment with this as a detection defense wherein we test whether NeuralCleanse can detect the backdoored class. This modification is denoted by NeuralCleanse\*. In our trials, NeuralCleanse\* does not successfully detect any of the backdoored classes - as determined by taking the maximum mask MAD (see Wang et al. [2019]). Neural Cleanse does not produce an anomaly score $> 2$ (their characterization of detecting outliers) for the backdoored class in any of our experiments.
182
+
183
+ We find that across the board, all of these defenses exhibit a robustness-accuracy trade-off. Many of these defenses do not reliably nullify the attack, and defenses that do degrade attack success also induce such a large drop in validation accuracy that they are unattractive options for practitioners. For example, to lower the attack success to an average of $1 3 . 1 4 \%$ , training with DPSGD degrades natural accuracy on CIFAR-10 to $7 0 \%$ . See Table 7 for the complete results of these experiments. Additional evaluations on recent defenses are presented in Appendix A.6.
184
+
185
+ Table 7: Defenses. Experiments are conducted on CIFAR-10 with ResNet-18 models, perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and poison budget is $1 \%$ of training images.
186
+
187
+ <table><tr><td>Defense</td><td>Attack Success Rate (%)</td><td>Validation Accuracy (%)</td></tr><tr><td>Spectral Signatures</td><td>37.17 (±10.10)</td><td>89.94 (±0.19)</td></tr><tr><td>Activation Clustering</td><td>15.17 (±5.38)</td><td>72.38 (±0.48)</td></tr><tr><td>DPSGD</td><td>13.14 (±4.49)</td><td>70.00 (±0.17)</td></tr><tr><td>Data Augmentation</td><td>69.75 (±10.77)</td><td>91.32 (±0.12)</td></tr><tr><td>STRIP</td><td>62.68 (±4.90)</td><td>92.23 (±0.05)</td></tr><tr><td>NeuralCleanse*</td><td>85.27 (±5.90)</td><td>92.31 (±0.08)</td></tr></table>
188
+
189
+ Table 8: Random poisons. Experiments are conducted on CIFAR-10 with ResNet-18 models. Perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255 and poisons are drawn from all classes.
190
+
191
+ <table><tr><td>Attack</td><td>Poison budget</td><td>Attack Success Rate (%)</td></tr><tr><td>Sleeper Agent (S=1,T= 4)</td><td>1%</td><td>41.90 (±7.16)</td></tr><tr><td>Sleeper Agent (S= 1,T= 4)</td><td>3%</td><td>66.51 (±6.90)</td></tr></table>
192
+
193
+ # 4.4 Sleeper Agent Can Poison Images in Any Class
194
+
195
+ Typical backdoor attacks which rely on label flips or feature collisions can only function when poisons come from the source and/or target classes [Saha et al., 2020, Turner et al., 2019]. This restriction may be a serious limitation in practice. In contrast, we show that Sleeper Agent can be effective even when we poison images drawn from all classes. To take advantage of our data selection strategy, we select poisons with maximum gradient norm across all classes. Table 8 contains the performance of Sleeper Agent in the aforementioned setting.
196
+
197
+ # 4.5 Evaluations Under Hard $\ell _ { \infty }$ -norm Constraints
198
+
199
+ While existing works on backdoor attacks consider poisons with $\ell _ { \infty }$ -norm bounded above by 16/255 as an imperceptible threat [Saha et al., 2020, Turner et al., 2019], Nguyen and Tran [2020] shows that human inspection can detect poisoned samples effectively. This inspection might mitigate the threat of large perturbations. To bypass this possibility, we conduct our baseline experiments on CIFAR-10 using perturbations with small $\ell _ { \infty }$ -norms. From Table 9, we observe that our threat model is effective even with an $\ell _ { \infty }$ -norm bounded above by 8/255. Visualizations can be found in Appendix C.
200
+
201
+ # 4.6 Ablation Studies
202
+
203
+ Here, we analyze the importance of each technique in our algorithm via ablation studies. We focus on three aspects of our method: 1) patch location, 2) retraining during poison crafting, 3) poison selection, and 4) retraining factor. Table 10 details the combinations and their effects on poison success. We find that randomizing patch location improves poisoning success, and both retraining and data selection based on maximum gradient significantly improve poison performance. Combining all three boosts poison success more than four-fold. To further show the importance of retraining, we conduct more experiments with and without retraining on ImageNet. From Table 11, we infer that retraining is essential. Additional ablations studies are found in Appendix A.
204
+
205
+ Table 9: Evaluation under different $\ell _ { \infty }$ -norm. Experiments are conducted on CIFAR-10 with ResNet-18 models, and the poison budget is $1 \%$ of training images.
206
+
207
+ <table><tr><td>Perturbation loo-norm</td><td>Attack Success Rate(%)</td></tr><tr><td>8/255</td><td>37.32 (±8.33)</td></tr><tr><td>10/255</td><td>55.75 (±8.12)</td></tr><tr><td>12/255</td><td>63.31 (±8.84)</td></tr><tr><td>14/255</td><td>78.03 (±7.13)</td></tr><tr><td>16/255</td><td>85.27 (±5.90)</td></tr></table>
208
+
209
+ Table 10: CIFAR-10 ablation studies. Investigation of the effects of random patch-location, retraining, and data selection. Experiments are conducted on CIFAR-10 with ResNet-18 models, perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and poison budget is $1 \%$ of training images.
210
+
211
+ <table><tr><td>Attack setup</td><td>Attack Success Rate (%)</td></tr><tr><td>Fix patch-location (bottom-right corner)</td><td>19.25 (±3.01)</td></tr><tr><td>Random patch-location</td><td>33.95 (±4.57)</td></tr><tr><td>Random patch-location +retraining</td><td>59.42 (±5.78)</td></tr><tr><td>Randompatch-location+ data selection</td><td>63.49 (±6.13)</td></tr><tr><td>Random patch-location + retraining +data selection</td><td>85.27 (±5.90)</td></tr></table>
212
+
213
+ Table 11: ImageNet ablation studies. Perturbations have $\ell _ { \infty }$ -norm bounded above by 16/255, and the poison budget is $0 . 0 5 \%$ of training images.
214
+
215
+ <table><tr><td>Attack</td><td>Attack Success Rate (%)</td></tr><tr><td>Sleeper Agent (S=1,T= O)</td><td>22.00 (±5.65)</td></tr><tr><td>Sleeper Agent (S=1,T=2)</td><td>44.00 (±6.73)</td></tr></table>
216
+
217
+ # 5 Broader Impact and Limitations
218
+
219
+ In this work, we illuminate a new scalable backdoor attack that could be used to stealthily compromise security-critical systems. We hope that by highlighting the potential danger of this nefarious threat model, our work will give rise to stronger defenses and will encourage caution on the part of practitioners.
220
+
221
+ While on average, our method is effective, the variance is large, and the success of our method can range from almost all patched images being misclassified to low success. This behavior has previously been observed in Schwarzschild et al. [2021]. In real-world scenarios, datasets are often noisy and imbalanced, so training behavior may be mysterious. As a result, practitioners should be cautious in their expectations that methods developed on datasets like CIFAR-10 and ImageNet will work on their own problems.
222
+
223
+ # 6 Conclusion
224
+
225
+ In this work, we present the first hidden-trigger backdoor attack that is effective against deep networks trained from scratch. This is a challenging setting for backdoor attacks, and existing attacks typically operate in less strict settings. Nonetheless, we choose the strict setting because practitioners often train networks from scratch in real-world applications, and patched poisons may be easily visible upon human inspection. In order to accomplish the above goal, we use a gradient matching objective as a surrogate for the bilevel optimization problem, and we add features such as re-training and data selection in order to significantly enhance the performance of our method, Sleeper Agent.
226
+
227
+ # Acknowledgements
228
+
229
+ This work was supported by DARPA GARD under contracts #HR00112020007 and HR001119S0026- GARD-FP-052, the DARPA YFA program, the ONR MURI Program under the Grant N00014-20- 1-2787, and the National Science Foundation DMS program. Further support was provided by JP Morgan Chase and Capital One Bank.
230
+
231
+ # References
232
+
233
+ Martin Abadi, Andy Chu, Ian Goodfellow, H Brendan McMahan, Ilya Mironov, Kunal Talwar, and Li Zhang. Deep learning with differential privacy. In Proceedings of the 2016 ACM SIGSAC conference on computer and communications security, pages 308–318, 2016.
234
+
235
+ Eugene Bagdasaryan, Andreas Veit, Yiqing Hua, Deborah Estrin, and Vitaly Shmatikov. How to backdoor federated learning. In International Conference on Artificial Intelligence and Statistics, pages 2938–2948. PMLR, 2020.
236
+
237
+ Mauro Barni, Kassem Kallas, and Benedetta Tondi. A new backdoor attack in cnns by training set corruption without label poisoning. In 2019 IEEE International Conference on Image Processing (ICIP), pages 101–105. IEEE, 2019.
238
+
239
+ Battista Biggio, Blaine Nelson, and Pavel Laskov. Poisoning attacks against support vector machines. In Proceedings of the 29th International Coference on International Conference on Machine Learning, pages 1467–1474, 2012.
240
+
241
+ Eitan Borgnia, Jonas Geiping, Valeriia Cherepanova, Liam Fowl, Arjun Gupta, Amin Ghiasi, Furong Huang, Micah Goldblum, and Tom Goldstein. Dp-instahide: Provably defusing poisoning and backdoor attacks with differentially private data augmentations. arXiv preprint arXiv:2103.02079, 2021.
242
+
243
+ Bryant Chen, Wilka Carvalho, Nathalie Baracaldo, Heiko Ludwig, Benjamin Edwards, Taesung Lee, Ian Molloy, and Biplav Srivastava. Detecting backdoor attacks on deep neural networks by activation clustering. In SafeAI@ AAAI, 2019.
244
+
245
+ Xinyun Chen, Chang Liu, Bo Li, Kimberly Lu, and Dawn Song. Targeted backdoor attacks on deep learning systems using data poisoning. arXiv preprint arXiv:1712.05526, 2017.
246
+
247
+ Ji Feng, Qi-Zhi Cai, and Zhi-Hua Zhou. Learning to confuse: generating training time adversarial data with auto-encoder. Advances in Neural Information Processing Systems, 32, 2019.
248
+
249
+ Liam Fowl, Ping-yeh Chiang, Micah Goldblum, Jonas Geiping, Arpit Bansal, Wojtek Czaja, and Tom Goldstein. Preventing unauthorized use of proprietary data: Poisoning for secure dataset release. arXiv preprint arXiv:2103.02683, 2021a.
250
+
251
+ Liam Fowl, Micah Goldblum, Ping-yeh Chiang, Jonas Geiping, Wojciech Czaja, and Tom Goldstein. Adversarial examples make strong poisons. Advances in Neural Information Processing Systems, 34:30339–30351, 2021b.
252
+
253
+ Yansong Gao, Change Xu, Derui Wang, Shiping Chen, Damith C Ranasinghe, and Surya Nepal. Strip: A defence against trojan attacks on deep neural networks. In Proceedings of the 35th Annual Computer Security Applications Conference, pages 113–125, 2019.
254
+
255
+ Jonas Geiping, Liam Fowl, W Ronny Huang, Wojciech Czaja, Gavin Taylor, Michael Moeller, and Tom Goldstein. Witches’ brew: Industrial scale data poisoning via gradient matching. ICLR, 2021.
256
+
257
+ Micah Goldblum, Dimitris Tsipras, Chulin Xie, Xinyun Chen, Avi Schwarzschild, Dawn Song, Aleksander Madry, Bo Li, and Tom Goldstein. Dataset security for machine learning: Data poisoning, backdoor attacks, and defenses. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
258
+
259
+ Tianyu Gu, Brendan Dolan-Gavitt, and Siddharth Garg. Badnets: Identifying vulnerabilities in the machine learning model supply chain. arXiv preprint arXiv:1708.06733, 2017.
260
+
261
+ Junfeng Guo and Cong Liu. Practical poisoning attacks on neural networks. In European Conference on Computer Vision, pages 142–158. Springer, 2020.
262
+
263
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
264
+
265
+ Sanghyun Hong, Varun Chandrasekaran, Yigitcan Kaya, Tudor Dumitra¸s, and Nicolas Papernot. ˘ On the effectiveness of mitigating data poisoning attacks with gradient shaping. arXiv preprint arXiv:2002.11497, 2020.
266
+
267
+ Hanxun Huang, Xingjun Ma, Sarah Monazam Erfani, James Bailey, and Yisen Wang. Unlearnable examples: Making personal data unexploitable. In International Conference on Learning Representations, 2020a.
268
+
269
+ W Ronny Huang, Jonas Geiping, Liam Fowl, Gavin Taylor, and Tom Goldstein. Metapoison: Practical general-purpose clean-label data poisoning. Advances in Neural Information Processing Systems, 33:12080–12091, 2020b.
270
+
271
+ Shaofeng Li, Benjamin Zi Hao Zhao, Jiahao Yu, Minhui Xue, Dali Kaafar, and Haojin Zhu. Invisible backdoor attacks against deep neural networks. arXiv preprint arXiv:1909.02742, 2019.
272
+
273
+ Shaofeng Li, Minhui Xue, Benjamin Zhao, Haojin Zhu, and Xinpeng Zhang. Invisible backdoor attacks on deep neural networks via steganography and regularization. IEEE Transactions on Dependable and Secure Computing, 2020.
274
+
275
+ Yige Li, Xixiang Lyu, Nodens Koren, Lingjuan Lyu, Bo Li, and Xingjun Ma. Anti-backdoor learning: Training clean models on poisoned data. Advances in Neural Information Processing Systems, 34: 14900–14912, 2021a.
276
+
277
+ Yiming Li, Yong Jiang, Zhifeng Li, and Shu-Tao Xia. Backdoor learning: A survey. IEEE Transactions on Neural Networks and Learning Systems, 2022.
278
+
279
+ Yuezun Li, Yiming Li, Baoyuan Wu, Longkang Li, Ran He, and Siwei Lyu. Invisible backdoor attack with sample-specific triggers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 16463–16472, 2021b.
280
+
281
+ Yingqi Liu, Shiqing Ma, Yousra Aafer, Wen-Chuan Lee, Juan Zhai, Weihang Wang, and Xiangyu Zhang. Trojaning attack on neural networks. 2017.
282
+
283
+ Yunfei Liu, Xingjun Ma, James Bailey, and Feng Lu. Reflection backdoor: A natural backdoor attack on deep neural networks. In European Conference on Computer Vision, pages 182–199. Springer, 2020.
284
+
285
+ Luis Muñoz-González, Battista Biggio, Ambra Demontis, Andrea Paudice, Vasin Wongrassamee, Emil C. Lupu, and Fabio Roli. Towards Poisoning of Deep Learning Algorithms with Backgradient Optimization. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, AISec ’17, pages 27–38, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-5202-4. doi: 10.1145/3128572.3140451.
286
+
287
+ Tuan Anh Nguyen and Anh Tuan Tran. Wanet-imperceptible warping-based backdoor attack. In International Conference on Learning Representations, 2020.
288
+
289
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International journal of computer vision, 115(3):211–252, 2015.
290
+
291
+ Aniruddha Saha, Akshayvarun Subramanya, and Hamed Pirsiavash. Hidden trigger backdoor attacks. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 11957–11965, 2020.
292
+
293
+ Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018.
294
+
295
+ Avi Schwarzschild, Micah Goldblum, Arjun Gupta, John P Dickerson, and Tom Goldstein. Just how toxic is data poisoning? a unified benchmark for backdoor and data poisoning attacks. In International Conference on Machine Learning, pages 9389–9398. PMLR, 2021.
296
+
297
+ Ali Shafahi, W Ronny Huang, Mahyar Najibi, Octavian Suciu, Christoph Studer, Tudor Dumitras, and Tom Goldstein. Poison frogs! targeted clean-label poisoning attacks on neural networks. Advances in neural information processing systems, 31, 2018.
298
+
299
+ Juncheng Shen, Xiaolei Zhu, and De Ma. Tensorclog: An imperceptible poisoning attack on deep neural network applications. IEEE Access, 7:41498–41506, 2019.
300
+
301
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
302
+
303
+ Jacob Steinhardt, Pang Wei W Koh, and Percy S Liang. Certified Defenses for Data Poisoning Attacks. In Advances in Neural Information Processing Systems 30, pages 3517–3529. Curran Associates, Inc., 2017.
304
+
305
+ Brandon Tran, Jerry Li, and Aleksander Madry. Spectral signatures in backdoor attacks. Advances in neural information processing systems, 31, 2018.
306
+ Alexander Turner, Dimitris Tsipras, and Aleksander Madry. Label-consistent backdoor attacks. arXiv preprint arXiv:1912.02771, 2019.
307
+ Bolun Wang, Yuanshun Yao, Shawn Shan, Huiying Li, Bimal Viswanath, Haitao Zheng, and Ben Y Zhao. Neural cleanse: Identifying and mitigating backdoor attacks in neural networks. In 2019 IEEE Symposium on Security and Privacy $( S P )$ , pages 707–723. IEEE, 2019.
308
+ Emily Wenger, Josephine Passananti, Arjun Nitin Bhagoji, Yuanshun Yao, Haitao Zheng, and Ben Y Zhao. Backdoor attacks against deep learning systems in the physical world. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6206–6215, 2021.
309
+ Dongxian Wu and Yisen Wang. Adversarial neuron pruning purifies backdoored deep models. Advances in Neural Information Processing Systems, 34:16913–16925, 2021.
310
+ Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018.
311
+ Bo Zhao, Konda Reddy Mopuri, and Hakan Bilen. Dataset condensation with gradient matching. In Ninth International Conference on Learning Representations 2021, 2021.
312
+ Chen Zhu, W Ronny Huang, Hengduo Li, Gavin Taylor, Christoph Studer, and Tom Goldstein. Transferable clean-label poisoning attacks on deep neural nets. In International Conference on Machine Learning, pages 7614–7623. PMLR, 2019.
313
+
314
+ # Checklist
315
+
316
+ 1. For all authors...
317
+
318
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
319
+ (b) Did you describe the limitations of your work? [Yes] See Section 5
320
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5
321
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
322
+
323
+ 2. If you are including theoretical results...
324
+
325
+ (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]
326
+
327
+ 3. If you ran experiments...
328
+
329
+ (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]
330
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix B
331
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
332
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix B
333
+
334
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
335
+
336
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
337
+ (b) Did you mention the license of the assets? [N/A] We defer to licenses on the respective host websites for the datasets we use. We use assets for purely research reasons.
338
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] See supplementary material
339
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
340
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
341
+
342
+ 5. If you used crowdsourcing or conducted research with human subjects...
343
+
344
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
345
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
346
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/qUKsCztWlKq/qUKsCztWlKq.md ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # THE KFIOU LOSS FOR ROTATED OBJECT DETECTION
2
+
3
+ Xue Yang1, Yue Zhou1, Gefan Zhang1,2, Jirui Yang3, Wentao Wang1, Junchi Yan1∗
4
+ Xiaopeng Zhang4, Qi Tian4
5
+ 1MoE Key Lab of Artificial Intelligence, Shanghai Jiao Tong University
6
+ 2COWAROBOT Co. Ltd. 3University of Chinese Academy of Sciences 4Huawei Cloud
7
+ {yangxue-2019-sjtu,sjtu zy,lizaozhouke,wwt117,yanjunchi}@sjtu.edu.cn
8
+ yangjirui123@gmail.com {zhangxiaopeng12,tian.qi1}@huawei.com
9
+ Jittor Code: https://github.com/Jittor/JDet
10
+ PyTorch Code: https://github.com/open-mmlab/mmrotate
11
+ TensorFlow Code: https://github.com/yangxue0827/RotationDetection
12
+
13
+ # ABSTRACT
14
+
15
+ Differing from the well-developed horizontal object detection area whereby the computing-friendly IoU based loss is readily adopted and well fits with the detection metrics, rotation detectors often involve a more complicated loss based on SkewIoU which is unfriendly to gradient-based training. In this paper, we propose an effective approximate SkewIoU loss based on Gaussian modeling and Gaussian product, which mainly consists of two items. The first term is a scale-insensitive center point loss, which is used to quickly narrow the distance between the center points of the two bounding boxes. In the distance-independent second term, the product of the Gaussian distributions is adopted to inherently mimic the mechanism of SkewIoU by its definition, and show its alignment with the SkewIoU loss at trend-level within a certain distance (i.e. within 9 pixels). This is in contrast to recent Gaussian modeling based rotation detectors e.g. GWD loss and KLD loss that involve a human-specified distribution distance metric which require additional hyperparameter tuning that vary across datasets and detectors. The resulting new loss called KFIoU loss is easier to implement and works better compared with exact SkewIoU loss, thanks to its full differentiability and ability to handle the non-overlapping cases. We further extend our technique to the 3-D case which also suffers from the same issues as 2-D. Extensive results on various datasets with different base detectors show the effectiveness of our approach.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Rotated object detection is a relatively emerging but challenging area, due to the difficulties of locating the arbitrary-oriented objects and separating them effectively from the background, such as aerial images (Yang et al., 2018a; Ding et al., 2019; Yang et al., 2018b), scene text (Jiang et al., 2017; Zhou et al., 2017). Though considerable progresses have been recently made, for practical settings, there still exist challenges for rotating objects with large aspect ratio, dense distribution.
20
+
21
+ The Skew Intersection over Union (SkewIoU) between large aspect ratio objects is sensitive to the deviations of the object positions. This causes the negative impact of the inconsistency between metric (dominated by SkewIoU) and regression loss (e.g. $l _ { n }$ -norms), which is common in horizontal detection, and is further amplified in rotation detection. The red and orange arrows in Fig. 1 show the inconsistency between SkewIoU and Smooth L1 Loss. Specifically, when the angle deviation is fixed (red arrow), SkewIoU will decrease sharply as the aspect ratio increases, while the Smooth L1 loss is unchanged (mainly from the angle difference). Similarly, when SkewIoU does not change (orange arrow), Smooth L1 loss increases as the angle deviation increases.
22
+
23
+ Solution for inconsistency between the metric and regression loss has been extensively discussed in horizontal detection by using IoU loss and related variants, such as GIoU loss (Rezatofighi et al., 2019) and DIoU loss (Zheng et al., 2020b). However, the applications of these solutions to rotation detection are blocked because the analytical solution of the SkewIoU calculation process1 is not easy to be provided due to the complexity of intersection between two rotated boxes (Zhou et al., 2019). Especially, there exist some custom operations (intersection of two edges and sorting the vertexes etc.) whose derivative functions have not been implemented in the existing deep learning frameworks (Abadi et al., 2016; Paszke et al., 2017; Hu et al., 2020). Besides, the calculation of SkewIoU is not differen
24
+
25
+ ![](images/b09674af7c1d9306084efba20714e7aad91c678755947cbb1ae33d38e3f1eec0.jpg)
26
+ Figure 1: For rotation detection (Yang et al., 2021b), there is a notable inconsistency between the final detection metric i.e. mAP (largely depending on SkewIoU) and regression-based loss e.g. the popular Smooth L1. See Fig. 3(a) and Fig. 3(b) for more specific comparison.
27
+
28
+ tiable when there are more than eight intersection points between two bounding boxes, i.e. two boundary boxes are completely coincident, or one edge is coincident, which will lead to the failure to obtain very accurate prediction results. Thus, developing an easy-to-implement and fully differentiable approximate SkewIoU loss is meaningful and several works (Chen et al., 2020; Zheng et al., 2020a; Yang et al., 2021c;d) have been proposed.
29
+
30
+ This paper aims to find an easy-to-implement and better-performing alternative. We design an alternative to SkewIoU loss based on Gaussian product, named KFIoU loss2, which can be easily implemented by the existing operations of the deep learning framework without the need for additional acceleration (e.g. $\mathrm { C + + / C U D A }$ ). Specifically, we convert the rotated bounding box into a Gaussian distribution, which can avoid the well-known boundary discontinuity and square-like problems (Yang et al., 2021c) in rotation detection. Then we use a center point loss to narrow the distance between the center of the two Gaussian distributions, follow by calculating the overlap area under the new position through the product of the Gaussian distributions. By calculating the error variance and comparing the final performance of different methods, we find trend-level alignment with the SkewIoU loss is critical for solving the inconsistency between metric and loss, and further improving the performance. Furthermore, compared to best-tuned Gaussian distance metric based methods, our proposed method achieves more competitive performance without hyperparameter tuning. The highlights are as follows:
31
+
32
+ 1) For rotation detection, instead of exactly computing the SkewIoU loss which is tedious and unfriendly to differentiable learning, we propose our easy-to-implement approximate loss, named KFIoU loss, which works better since it is fully differentiable and able to handle the non-overlapping cases. It follows the protocol of Gaussian modeling for objects, yet innovatively uses Gaussian product to mimic SkewIoU’s computing mechanism within a looser distance.
33
+
34
+ 2) Compared to Gaussian-based losses (GWD loss, KLD loss) that try to approximate SkewIoU loss by specifying a distance which need extra hyperparameters tuning and metric selection that vary across datasets and detectors, our mechanism level simulation to SkewIoU is more interpretable and natural, and free from hyperparameter tuning.
35
+
36
+ 3) We also show that KFIoU loss achieves the better trend-level alignment with SkewIoU loss within a certain distance than GWD loss and KLD loss, where the trend deviation is measured by our devised error variance. The effectiveness of such a trend-level alignment strategy is verified by comparing KFIoU loss with ideal SkewIoU loss. On extensive benchmarks (aerial images, scene texts, face), our approach also outperforms other best-tuned SOTA alternatives.
37
+
38
+ 4) We further extend the Gaussian modeling and KFIoU loss from 2-D to 3-D rotation detection, with notable improvement compared with baselines. To our best knowledge, this is the first 3- D rotation detector based on Gaussian modeling which also verifies its effectiveness, which is in contrast to (Yang et al., 2021c;d; 2022) focusing on 2-D rotation detection. The source code is available at TensoFlow (Abadi et al., 2016)-based AlphaRotate (Yang et al., 2021e), PyTorch (Paszke et al., 2017)-based MMRotate (Zhou et al., 2022) and Jittor (Hu et al., 2020)-based JDet.
39
+
40
+ # 2 RELATED WORK
41
+
42
+ Rotated Object Detection. Rotated object detection is an emerging direction, which attempts to extend classical horizontal detectors (Girshick, 2015; Ren et al., 2015; Lin et al., 2017a;b) to the rotation case by adopting the rotated bounding boxes. Aerial images and scene text are popular application scenarios of rotation detector. For aerial images, objects are often arbitrary-oriented and dense-distributed with large aspect ratios. To this end, ICN (Azimi et al., 2018), ROI-Transformer (Ding et al., 2019), SCRDet (Yang et al., 2019), Mask OBB (Wang et al., 2019), Gliding Vertex (Xu et al., 2020), ReDet (Han et al., 2021b) are two-stage mainstreamed approaches whose pipeline is inherited from Faster RCNN (Ren et al., 2015), while DRN (Pan et al., 2020), DAL (Ming et al., 2021b), ${ \tt R } ^ { 3 }$ Det (Yang et al., 2021b), RSDet (Qian et al., 2021a;b) and $\mathrm { S ^ { 2 } A }$ -Net (Han et al., 2021a) are based on single-stage methods for faster detection speed. For scene text detection, RRPN (Ma et al., 2018) employs rotated RPN to generate rotated proposals and further perform rotated bounding box regression. TextBoxes+ $^ +$ (Liao et al., 2018a) adopts vertex regression on SSD (Liu et al., 2016). RRD (Liao et al., 2018b) improves TextBoxes $^ { + + }$ by decoupling classification and bounding box regression on rotation-invariant and rotation sensitive features, respectively. The regression loss of the above algorithms is rarely SkewIoU loss due to the complexity of implementing SkewIoU.
43
+
44
+ Variants of IoU-based Loss. The inconsistency between metric and regression loss is a common issue for both horizontal detection and rotation detection. Solution for this inconsistency has been extensively discussed in horizontal detection by using IoU related loss. For instance, Unitbox (Yu et al., 2016) proposes an IoU loss which regresses the four bounds of a predicted box as a whole unit. More works (Rezatofighi et al., 2019; Zheng et al., 2020b) extend the idea of Unitbox by introducing GIoU (Rezatofighi et al., 2019) and DIoU (Zheng et al., 2020b) for bounding box regression. However, their applications to rotation detection are blocked due to the hard-to-implement SkewIoU. Recently, some approximate methods for SkewIoU loss have been proposed. Box/Polygon based: SCRDet (Yang et al., 2019) propose IoU-Smooth L1, which partly circumvents the need for SkewIoU loss with gradient backpropagation by combining IoU and Smooth L1 loss. To tackle the uncertainty of convex caused by rotation, the work (Zheng et al., 2020a) proposes a projection operation to estimate the intersection area for both 2-D/3-D object detection. PolarMask (Xie et al., 2020) proposes Polar IoU loss that can largely ease the optimization and considerably improve the accuracy. CFA (Guo et al., 2021) proposes convex hull based CIoU loss for optimization of point based detectors. Pixel based: PIoU (Chen et al., 2020) calculates the SkewIoU directly by accumulating the contribution of interior overlapping pixels. Gaussian based: GWD (Yang et al., 2021c) and KLD (Yang et al., 2021d) simulate SkewIoU by Gaussian distance measurement.
45
+
46
+ # 3
47
+
48
+ This section presents the preliminary according to (Yang et al., 2021c), for how to convert an arbitrary-oriented 2-D/3-D bounding box to a Gaussian distribution $\mathcal { G } ( \boldsymbol { \mu } , \pmb { \Sigma } )$ .
49
+
50
+ $$
51
+ \Sigma = { \bf R } { \bf A } { \bf R } ^ { \top } , ~ \mu = \left( x , y , ( z ) \right) ^ { \top }
52
+ $$
53
+
54
+ where $\mathbf { R }$ represents the rotation matrix, and $\pmb { \Lambda }$ represents the diagonal matrix of eigenvalues.
55
+
56
+ Take 3-D object $\mathcal { B } _ { 3 d } ( x , y , z , w , h , l , \theta )$ as an example:
57
+
58
+ $$
59
+ \begin{array} { r } { { \bf R } = \left( \begin{array} { c c c } { \cos \theta } & { - \sin \theta } & { 0 } \\ { \sin \theta } & { \cos \theta } & { 0 } \\ { 0 } & { 0 } & { 1 } \end{array} \right) , { \bf A } = \left( \begin{array} { c c c } { \frac { w ^ { 2 } } { 4 } } & { 0 } & { 0 } \\ { 0 } & { \frac { h ^ { 2 } } { 4 } } & { 0 } \\ { 0 } & { 0 } & { \frac { l ^ { 2 } } { 4 } } \end{array} \right) } \end{array}
60
+ $$
61
+
62
+ It is worth noting that the recent works GWD loss (Yang et al., 2021c) and KLD loss (Yang et al., 2021d) also belong to the Gaussian modeling based. Compared with our work, their difference is that they use the nonlinear transformation of distribution distance to approximate SkewIoU loss. In this process, additional hyperparameters are introduced. Since Gaussian modeling has the natural advantages of being immune to boundary discontinuity and square-like problems, in this paper, we will take another perspective to approximate the SkewIoU loss to better train the detector without any extra hyperparameter, which can be more in line with SkewIoU calculation. Tab. 1 shows the comparison of properties between different losses. It should be noted that the results presented in our experiments of GWD loss and KLD loss are obtained by best-tuned hyperparameters in DOTA, but not optimal in others.
63
+
64
+ Table 1: Comparison of the properties and performance of different regression losses. Base model is RetinaNet. BC and HP denote Boundary Continuity and Hyperparameter. † indicates that the first term of KLD is taken as the center point loss, i.e. $L _ { c } ( \pmb { \mu } _ { 1 } , \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } )$ .
65
+
66
+ <table><tr><td>Loss</td><td>Representation</td><td>Implement</td><td>BC</td><td>Consistency</td><td>HP</td><td>EVar</td><td>DOTA-v1.0</td><td>DOTA-v1.5</td><td>DOTA-v2.0</td></tr><tr><td>Smooth L1</td><td>bbox</td><td>easy</td><td>×</td><td>×</td><td>()</td><td>0.073201718</td><td>64.17</td><td>56.10</td><td>43.06</td></tr><tr><td>plain SkewIoU</td><td>bbox</td><td>hard</td><td></td><td>√</td><td>×</td><td></td><td>68.27</td><td>59.01</td><td>45.87</td></tr><tr><td>GWD</td><td>Gaussian</td><td>easy</td><td></td><td>X</td><td>(T,f)</td><td>0.019041297</td><td>68.93</td><td>60.03</td><td>46.65</td></tr><tr><td>KLD</td><td>Gaussian</td><td>easy</td><td></td><td>√</td><td>(T,f)</td><td>0.007653582</td><td>71.28</td><td>62.50</td><td>47.69</td></tr><tr><td>KFIoU (ours)</td><td>Gaussian</td><td>easy</td><td>&lt;√&gt;&gt;&gt;&gt;</td><td>√</td><td>×</td><td>0.002348353</td><td>70.64</td><td>62.71</td><td>48.04</td></tr><tr><td>KFIoUt (ours)</td><td>Gaussian</td><td>easy</td><td></td><td>√</td><td>×</td><td>0.002264243</td><td>71.60</td><td>63.75</td><td>48.94</td></tr></table>
67
+
68
+ Figure 2: SkewIoU loss approximation process in two-dimensional space based on Gaussian product. Compared with GWD loss (Yang et al., 2021c) and KLD loss (Yang et al., 2021d), our approach follows the calculation process of SkewIoU without introducing additional hyperparameters. We believe such a design is more mathematically rigorous and more in line with SkewIoU loss.
69
+
70
+ <table><tr><td rowspan=2 colspan=1>B(x,y,w,h,0) N(μ,Σ)!R=(cosθ -sin)μ = (x,y)Tsinθcos0w²/4 0Σ = RART A= h²/4)0</td><td rowspan=1 colspan=1>Nx(μ1,Σ1)Lc(&gt;Nx(μ2,Σ2)</td><td rowspan=1 colspan=1>Nx(μ1,∑1)&quot;0Nx(μ,∑)Nx(μ2,£2)</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>Lc(μ1,μ2) = In(titi)ie(xy)</td><td rowspan=1 colspan=1>αNx(μ,∑)=Nx(μ1,∑)Nx(μ2,Σ2)K=Σ(£1+Σ2)-1μ=μ+K(μ2-μ1)∑=£1-K∑1</td><td rowspan=1 colspan=1>AeraB(∑) = 4 eig(£)KFloU=7 AeraB3(£)AeraB(E1)+AeraB(22)-AeraB(2)Lkf(Σ1,Σ2)=1-KFIoU</td></tr><tr><td rowspan=1 colspan=1>(a) Convert the bounding box to aGaussian distribution</td><td rowspan=1 colspan=1>(b) Narrow the center distance by centerpoint loss</td><td rowspan=1 colspan=1>(c) Get the Gaussian distribution of theoverlapping area by Gaussian product</td><td rowspan=1 colspan=1>(d)Invert Gaussian distribution to bbox tocalculate approximate SkewIoU and loss</td></tr></table>
71
+
72
+ # 4 PROPOSED METHOD
73
+
74
+ In this section, we present our main approach. Fig. 2 shows the approximate process of SkewIoU loss in two-dimensional space based on Gaussian product. Briefly, we first convert the bounding box to a Gaussian distribution as discussed in Sec. 3, and move the center points of the two Gaussian distributions to make them close. Then, the distribution function of the overlapping area is obtained by Gaussian product. Finally, the obtained distribution function is inverted into a rotated bounding box to calculate the overlapping area and the SkewIoU and loss.
75
+
76
+ # 4.1 SKEWIOU BASED ON GAUSSIAN PRODUCT
77
+
78
+ First of all, we can easily calculate the volume of the corresponding rotating box based on its covariance $( \gamma _ { B } ( \pmb { \Sigma } ) )$ , when we obtain a new Gaussian distribution:
79
+
80
+ $$
81
+ \mathcal { V } _ { \mathcal { B } } ( \Sigma ) = 2 ^ { n } \sqrt { \prod e i g ( \Sigma ) } = 2 ^ { n } \cdot | \Sigma ^ { \frac { 1 } { 2 } } | = 2 ^ { n } \cdot | \Sigma | ^ { \frac { 1 } { 2 } }
82
+ $$
83
+
84
+ where $n$ denotes the number of dimensions.
85
+
86
+ To obtain the final SkewIoU, calculating the area of overlap is critical. For two Gaussian distributions, $\mathcal { N } _ { \mathbf { x } } ( \mu _ { 1 } , \Sigma _ { 1 } )$ and $\mathcal { N } _ { \mathbf { x } } ( \mu _ { 2 } , \Sigma _ { 2 } )$ , we use the product of the Gaussian distributions to get the distribution function of the overlapping area:
87
+
88
+ $$
89
+ \alpha \mathcal { N } _ { \mathbf { x } } ( \boldsymbol { \mu } , \boldsymbol { \Sigma } ) = \mathcal { N } _ { \mathbf { x } } ( \boldsymbol { \mu } _ { 1 } , \boldsymbol { \Sigma } _ { 1 } ) \mathcal { N } _ { \mathbf { x } } ( \boldsymbol { \mu } _ { 2 } , \boldsymbol { \Sigma } _ { 2 } )
90
+ $$
91
+
92
+ Note here $\alpha$ is written by:
93
+
94
+ $$
95
+ \alpha = \mathcal { N } _ { \mu _ { 1 } } ( \mu _ { 2 } , \Sigma _ { 1 } + \Sigma _ { 2 } )
96
+ $$
97
+
98
+ ![](images/d4072d9ef439bd00f5d0d205cde20bd9484b7840d6bfc3baecfd70037ec0a724.jpg)
99
+ Figure 3: Behavior comparison of different losses in different cases. (a) depicts the relation between angle difference and loss functions. (b) shows the changes of the five loss under different aspect ratio condition. (c) gives scatter plot between approximate losses and SkewIoU loss, 1,000 examples regardless of the case by randomly generating box pairs with the close centers (within 5 pixels).
100
+
101
+ where $\mu = \mu _ { 1 } + \mathbf { K } ( \mu _ { 2 } - \mu _ { 1 } )$ , $\pmb { \Sigma } = \pmb { \Sigma } _ { 1 } - \pmb { \mathrm { K } } \pmb { \Sigma } _ { 1 }$ , and $\mathbf { K }$ is the Kalman gain, ${ \bf K } = \Sigma _ { 1 } ( \Sigma _ { 1 } + \Sigma _ { 2 } ) ^ { - 1 }$
102
+
103
+ We observe that $\pmb { \Sigma }$ is only related to the covariance $\Sigma _ { 1 }$ and $\Sigma _ { 2 }$ ) of the given two Gaussian distributions, which means that no matter how the two Gaussian distributions move, as long as the covariance is fixed, the area calculated by Eq. 3 will not change (distance-independent). This is obviously not in line with intuition: the overlapping area should be reduced when the two Gaussian distributions are far away. The main reason is $\alpha \mathcal { N } _ { \mathbf { x } } ( \boldsymbol { \mu } , \pmb { \Sigma } )$ is not a standard Gaussian distribution (probability sum is not 1), we cannot directly use $\pmb { \Sigma }$ to calculate the area of the current overlap by Eq. 3 without considering $\alpha$ . Eq. 5 shows that $\alpha$ is related to the distance between the center points $( \mu _ { 1 } - \mu _ { 2 } )$ of the two Gaussian distributions. Based on the above findings, we can first use a center point loss $L _ { c }$ to narrow the distance between the center of the two Gaussian distributions. In this way, $\alpha$ can be approximated as a constant, and the introduction of the $L _ { c }$ also allows the entire loss to continue to optimize the detector in non-overlapping cases. Then, calculate the overlap area under the new position by Eq. 3. According to Fig. 2, overlap area is calculated as follows:
104
+
105
+ $$
106
+ \mathrm { K F I o U } = \frac { \mathcal { V } _ { B _ { 3 } } ( \Sigma ) } { \mathcal { V } _ { B _ { 1 } } ( \Sigma _ { 1 } ) + \mathcal { V } _ { B _ { 2 } } ( \Sigma _ { 2 } ) - \mathcal { V } _ { B _ { 3 } } ( \Sigma ) }
107
+ $$
108
+
109
+ where $B _ { 1 } , B _ { 2 }$ and $B _ { 3 }$ refer to the three different bounding boxes shown in the right part of Fig. 2.
110
+
111
+ In the appendix, we prove that the upper bounds of KFIoU in n-dimensional space is $\frac { 1 } { 2 ^ { \frac { n } { 2 } + 1 } - 1 }$ . For 2-D/3-D detection, the upper bounds are $\frac { 1 } { 3 }$ and √ 132−1 respectively when n = 2 and n = 3. We can easily stretch the range of KFIoU to [0, 1] by linear transformation according to the upper bound, and then compare it with IoU for consistency.
112
+
113
+ Fig. 3(a)-3(b) show the curves of five loss forms for two bounding boxes with the same center in different cases. Note that we have expanded KFIoU by 3 times so that its value range is [0, 1] like SkewIoU. Fig. 3(a) depicts the relation between angle difference and loss functions. Though they all bear monotonicity, obviously the Smooth L1 loss curve is more distinctive. Fig. 3(b) shows the changes of the five loss under different aspect ratio conditions. It can be seen that the Smooth L1 loss of the two bounding boxes are constant (mainly from the angle difference), but other losses will change drastically as the aspect ratio varies. Regardless of the case in Fig. 3(c), KFIoU loss can maintain the best trend-level alignment with the SkewIoU loss within 5 pixels devariation. This conclusion still holds at 9 pixels, which is already quite a distance, especially for aerial image.
114
+
115
+ To further explore the behavior of different approximate SkewIoU losses, we design the metrics of error mean (EMean) and error variance (EVar) as follows:
116
+
117
+ $$
118
+ \mathrm { E M e a n } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( \mathrm { S k e w I o U } _ { p l a i n } - \mathrm { S k e w I o U } _ { a p p } ) , \quad \mathrm { E V a r } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( \mathrm { S k e w I o U } _ { a p p } - \mathrm { E M e a n } ) ^ { 2 }
119
+ $$
120
+
121
+ where EVar measures the trend-level consistency between the designed loss and the SkewIoU loss.
122
+
123
+ Tab. 1 calculates the EVar of different losses in Fig. 3(c). In general, $\mathrm { E V a r } _ { L _ { k f i o u } + L _ { c } } < \mathrm { E V a r } _ { L _ { k l d } } <$ $\mathrm { E V a r } _ { L _ { g w d } } < \mathrm { E V a r } _ { L _ { 1 } }$ . In our analysis, this is probably due to the fundamental inconsistency between the distribution distance as used in GWD/KLD and the definition of similarity in SkewIoU. Moreover, for GWD such inconsistency is more pronouced, because it has no scale invariance under the same IoU, and a case with a larger scale will get a larger loss value, it can greatly magnify its trend inconsistency with SkewIoU loss. The results in Tab. 1 also verifies our analysis. In contrast, the calculation process of KFIoU loss is essentially the calculation of the overlap rate, so it does not require hyperparameters and can maintain a high trend-level consistency with SkewIoU loss.
124
+
125
+ Combined with the corresponding performance on three datasets, smaller EVars tend to have better performance in a general level. When EVar is small enough, which implies sufficient consistency, the performance difference of different methods (e.g. KLD loss and KFIoU loss) is close. Therefore, we come to the conclusion that the key to maintaining the consistency between metric and regression loss lies in the trend-level consistency between approximate and exact SkewIoU loss rather than value-level consistency. The reason why the Gaussian-based losses (e.g. KFIoU loss, KLD loss, GWD loss) outperform the plain SkewIoU loss is due to the advanced parameter optimization mechanism, effective measurement for non-overlapping cases, and complete derivation. However, the introduction of hyperparameters makes KLD loss and GWD loss less stable than KFIoU loss in terms of Evar and performance. Compared with GWD and KLD, which use the distribution distance to approximate SkewIoU, KFIoU is physically more reasonable (in line with the calculation process of SkewIoU) and simpler, as well as empirically more effective than best-tuned GWD and KLD. In addition, KFIoU implementation is much simpler than plain SkewIoU and can be easily implemented by the existing operations of the deep learning framework.
126
+
127
+ # 4.2 THE PROPOSED KFIOU LOSS
128
+
129
+ We take 2-D object detection as the main example for notation brevity, though our experiments further cover the 3-D case. We use the one-stage detector RetinaNet (Lin et al., 2017b) as the baseline. Rotated rectangle is represented by five parameters $( x , y , w , h , \theta )$ . First, we shall clarify that the network has not changed the output of the original regression branch, that is, it is not directly predicting the parameters of the Gaussian distribution. The whole training process of detector is summarized as follows: i) predict offset $( t _ { x } ^ { * } , t _ { y } ^ { * } , t _ { w } ^ { * } , t _ { h } ^ { * } , t _ { \theta } ^ { * } )$ ; ii) decode prediction box; iii) convert prediction box and target ground-truth into Gaussian distribution; iv) calculate and of two Gaussian distributions. Therefore, the inference time remains unchanged. The regression equation of $( x , y , w , h )$ is as follows:
130
+
131
+ $$
132
+ \begin{array} { r } { t _ { x } = ( x - x _ { a } ) / w _ { a } , \quad t _ { y } = ( y - y _ { a } ) / h _ { a } , \quad t _ { w } = \log ( w / w _ { a } ) , \quad t _ { h } = \log ( h / h _ { a } ) } \\ { t _ { x } ^ { * } = ( x ^ { * } - x _ { a } ) / w _ { a } , \quad t _ { y } ^ { * } = ( y ^ { * } - y _ { a } ) / h _ { a } , \quad t _ { w } ^ { * } = \log ( w ^ { * } / w _ { a } ) , \quad t _ { h } ^ { * } = \log ( h ^ { * } / h _ { a } ) } \end{array}
133
+ $$
134
+
135
+ where $x , y , w , h$ denote the box’s center coordinates, width and height, respectively. $x , x _ { a } , x ^ { * }$ are for ground-truth box, anchor box, and predicted box (likewise for $y , w , h )$ .
136
+
137
+ For the regression of $\theta$ , we use two forms as the baselines:
138
+
139
+ i) Direct regression, marked as Reg. $( \Delta \theta )$ . The model directly predicts the angle offset $t _ { \theta } ^ { * }$ :
140
+
141
+ $$
142
+ t _ { \theta } = \left( \theta - \theta _ { a } \right) \cdot \pi / 1 8 0 , \quad t _ { \theta } ^ { * } = \left( \theta ^ { * } - \theta _ { a } \right) \cdot \pi / 1 8 0
143
+ $$
144
+
145
+ ii) Indirect regression, marked as $\mathbf { R e g . } ^ { * } \left( \sin \theta , \cos \theta \right)$ . The model predicts two vectors $( { t _ { \sin \theta } ^ { * } }$ and $t _ { \mathrm { c o s } \theta } ^ { * } )$ to match the two targets from the ground truth ${ { t } _ { \sin \theta } }$ and $t _ { \cos \theta }$ ):
146
+
147
+ $$
148
+ t _ { \sin \theta } = \sin \left( \theta \cdot \pi / 1 8 0 \right) , \quad t _ { \cos \theta } = \cos \left( \theta \cdot \pi / 1 8 0 \right) , \quad t _ { \sin \theta } ^ { * } = \sin \left( \theta ^ { * } \cdot \pi / 1 8 0 \right) , \quad t _ { \cos \theta } ^ { * } = \cos \left( \theta ^ { * } \cdot \pi / 1 8 0 \right)
149
+ $$
150
+
151
+ $t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } = 1$
152
+
153
+ $$
154
+ t _ { \sin \theta } ^ { * } = \frac { t _ { \sin \theta } ^ { * } } { \sqrt { t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } } } , \quad t _ { \cos \theta } ^ { * } = \frac { t _ { \cos \theta } ^ { * } } { \sqrt { t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } } }
155
+ $$
156
+
157
+ The multi-task loss is:
158
+
159
+ $$
160
+ L _ { t o t a l } = \lambda _ { 1 } \sum _ { n = 1 } ^ { N _ { p o s } } L _ { r e g } \left( \mathcal { G } ( b _ { n } ) , \mathcal { G } ( g t _ { n } ) \right) + \frac { \lambda _ { 2 } } { N } \sum _ { n = 1 } ^ { N } L _ { c l s } ( p _ { n } , t _ { n } )
161
+ $$
162
+
163
+ where $N$ and $N _ { p o s }$ indicates the number of all anchors and that of positive anchors. $b _ { n }$ denotes the $n$ -th predicted bounding box, $g t _ { n }$ is the $n$ -th target ground-truth. $\mathcal { G } ( \cdot )$ is Gaussian transfer function.
164
+
165
+ Table 2: Ablation study on various 2-D datasets with different base detectors. ‘R’, ‘F’ and ‘G’ indicate random rotation, flipping, and graying. † indicates that the first term of KLD is taken as the center point loss, i.e. $L _ { c } ( \pmb { \mu } _ { 1 } , \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } )$ . Base detector is RetinaNet.
166
+
167
+ <table><tr><td>Dataset</td><td>Data Aug.</td><td>Reg.Loss</td><td>Hmean/AP50</td><td>Hmean/AP60</td><td>Hmean/AP75</td><td>Hmean/AP85</td><td>Hmean/AP50:95</td></tr><tr><td>HRSC2016</td><td>R+F+G</td><td>Smooth L1 KFIoU</td><td>84.28 84.41 (+0.13)</td><td>74.74 82.23 (+7.49)</td><td>48.42 58.32 (+9.90)</td><td>12.56 18.34 (+5.78)</td><td>47.76 51.29 (+3.53)</td></tr><tr><td>MSRA-TD500</td><td>R+F</td><td>Smooth L1 KFIoU</td><td>70.98 76.30 (+5.32)</td><td>62.42 69.84 (+7.42)</td><td>36.73 47.58 (+10.85)</td><td>12.56 19.21 (+6.65)</td><td>37.89 44.96 (+7.07)</td></tr><tr><td>ICDAR2015</td><td rowspan="2">F</td><td>Smooth L1 KFIoU</td><td>69.78 75.90 (+6.12)</td><td>64.15 69.28 (+5.13)</td><td>36.97 40.03 (+3.06)</td><td>8.71 9.18 (+0.47)</td><td>37.73 41.17 (+3.44)</td></tr><tr><td>FDDB</td><td>Smooth L1 KFIoU</td><td>95.92 97.25 (+1.33)</td><td>87.50 94.89 (+7.39)</td><td>55.81 77.38 (+21.57)</td><td>12.67 25.62 (+12.93)</td><td>52.77 63.25 (+10.48)</td></tr><tr><td>DOTA-v1.0</td><td></td><td>Smooth L1 KFIoU KFIoUt</td><td>65.00 67.68 (+2.68) 68.23 (+3.23)</td><td>57.84 62.18 (+4.34) 63.23 (+5.39)</td><td>33.68 37.30 (+3.62) 38.34 (+4.66)</td><td>11.39 14.21 (+2.82) 13.72 (+2.33)</td><td>35.16 38.51 (+3.35) 38.80 (+3.64)</td></tr></table>
168
+
169
+ $t _ { n }$ represents the label of the $n$ -th object, $p _ { n }$ is the $n$ -th probability distribution of classes calculated by sigmoid function. $\lambda _ { 1 }$ , $\lambda _ { 2 }$ control the trade-off and are set to $\{ 0 . 0 1 , 1 \}$ . The classification loss $L _ { c l s }$ is set as the focal loss (Lin et al., 2017b). The regression loss is set by $L _ { r e g } = L _ { c } + L _ { k f }$ , where
170
+
171
+ $$
172
+ L _ { k f } ( \pmb { \Sigma } _ { 1 } , \pmb { \Sigma } _ { 2 } ) = e ^ { 1 - \mathrm { K F I o U } } - 1
173
+ $$
174
+
175
+ See more ablation experiments on the functional form of $L _ { k f } ( \Sigma _ { 1 } , \Sigma _ { 2 } )$ in the Appendix. For center point loss $L _ { c }$ , this paper provides two different forms:
176
+
177
+ 1) The loss adopted in Faster RCNN (Lin et al., 2017a) (default): $\begin{array} { r } { L _ { c } ( t , t ^ { * } ) = \sum _ { i \in ( x , y ) } l _ { n } \big ( t _ { i } , t _ { i } ^ { * } \big ) . } \end{array}$
178
+
179
+ 2) The first term of KLD (Yang et al., 2021d) (advanced), which has an advanced center point optimization mechanism: $L _ { c } ( \pmb { \mu } _ { 1 } , \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } ) = \ln \left( ( \pmb { \mu } _ { 2 } - \pmb { \mu } _ { 1 } ) ^ { \top } \pmb { \Sigma } _ { 1 } ^ { - 1 } ( \pmb { \mu } _ { 2 } - \pmb { \mu } _ { 1 } ) + 1 \right)$ .
180
+
181
+ # 5 EXPERIMENTS
182
+
183
+ # 5.1 DATASETS AND IMPLEMENTATION DETAILS
184
+
185
+ Aerial image dataset: DOTA (Xia et al., 2018) is one of the largest datasets for oriented object detection in aerial images with three released versions: DOTA-v1.0, DOTA-v1.5 and DOTA-v2.0. DOTA-v1.0 contains 15 common categories, 2,806 images and 188,282 instances. DOTA-v1.5 uses the same images as DOTA-v1.0, but extremely small instances (less than 10 pixels) are also annotated. Moreover, a new category, containing 402,089 instances in total is added in this version. While DOTA- $\mathbf { \sigma } \cdot \mathbf { v } 2 . 0$ contains 18 common categories, 11,268 images and 1,793,658 instances. We divide the images into $6 0 0 \times 6 0 0$ subimages with an overlap of 150 pixels and scale it to $8 0 0 ~ \times$ 800. HRSC2016 (Liu et al., 2017) contains images from two scenarios with ships on sea and close inshore. The training, validation and test set include 436, 181 and 444 images.
186
+
187
+ Scene text dataset: ICDAR2015 (Karatzas et al., 2015) includes 1,000 training images and 500 testing images. MSRA-TD500 (Yao et al., 2012) has 300 training images and 200 testing images. They are popular for oriented scene text detection and spotting.
188
+
189
+ Face dataset: FDDB (Jain & Learned-Miller, 2010) is a dataset designed for unconstrained face detection, in which faces have a wide variability of face scales, poses, and appearance. This dataset contains annotations for 5,171 faces in a set of 2,845 images. We manually use $70 \%$ as the training set and the rest as the validation set.
190
+
191
+ We use AlphaRotate (Yang et al., 2021e) for main implementation and experiment, where many advanced detectors are integrated. Experiments are performed on a server with GeForce RTX 3090 Ti and 24G memory. Experiments are initialized by ResNet50 (He et al., 2016) by default unless otherwise specified. We perform experiments on two aerial benchmarks, two scene text benchmarks and one face benchmark to verify the generality of our techniques. Weight decay and momentum are set 0.0001 and 0.9, respectively. We employ MomentumOptimizer over 4 GPUs with a total of 4 images per mini-batch (1 image per GPU). All the used datasets are trained by 20 epochs, and learning rate is reduced tenfold at 12 epochs and 16 epochs, respectively. The initial learning rate is 1e-3. The number of image iterations per epoch for DOTA-v1.0, DOTA-v1.5, DOTA-v2.0, HRSC2016, ICDAR2015, MSRA-TD500 and FDDB are 54k, 64k, 80k, 10k, 10k, 5k and 4k respectively, and doubled if data augmentation (e.g. random graying and rotation) or multi-scale training are enabled.
192
+
193
+ Table 3: Results on KITTI val split 3D detection and BEV Detection.
194
+
195
+ <table><tr><td>Method</td><td>mAP</td><td> 3D Detection Mod.</td><td></td><td>mAP</td><td colspan="3">BEV Detection Mod.</td></tr><tr><td>PointPillars</td><td>64.28</td><td>78.90</td><td>50.96 62.99</td><td>70.10</td><td>88.08</td><td>55.51</td><td>66.69</td></tr><tr><td>+GWD</td><td>65.50</td><td>78.57</td><td>55.19 62.74</td><td>71.48</td><td>88.30</td><td>58.49</td><td>67.66</td></tr><tr><td>+KLD</td><td>66.19</td><td>80.36</td><td>52.94 65.27</td><td>71.18</td><td>88.11</td><td>57.26</td><td>68.19</td></tr><tr><td>+KFIoU</td><td>66.71</td><td>80.19</td><td>54.94 65.00</td><td>72.08</td><td>89.90</td><td>57.81</td><td>68.55</td></tr></table>
196
+
197
+ KITTI (Geiger et al., 2012) contains 7,481 training and 7,518 testing samples for 3-D object detection. The training samples are generally divided into the train split (3,712 samples) and the val split (3,769 samples). The evaluation is classified into Easy, Moderate or Hard according to the object size, occlusion and truncation. All results are evaluated by the mean average precision with a rotated IoU threshold 0.7 for cars and 0.5 for pedestrian and cyclists. To evaluate the model’s performance on KITTI val split, we train our model on the train set and report the results on the val set.
198
+
199
+ We use PointPillar (Lang et al., 2019) implemented in MMDetection3D (Contributors, 2020) as the baseline, and the training schedule inherited from SECOND (Yan et al., 2018): ADAM optimizer with a cosine-shaped cyclic learning rate scheduler that spans 160 epochs. The learning rate starts from 1e-4 and reaches 1e-3 at the 60th epoch, and then goes down gradually to 1e-7 finally. In the development phase, the experiments are conducted with a single model for 3-class joint detection.
200
+
201
+ # 5.2 ABLATION STUDY AND FURTHER COMPARISON
202
+
203
+ Ablation study on different center point losses. Tab. 1 compares the two different center point losses proposed in Sec. 4.2 on three versions of DOTA datasets. Even with the most commonly used $L _ { c } ( t , t ^ { * } )$ , KFIoU loss achieves competitive performance, significantly better than GWD loss and comparable to KLD loss. For a fairer comparison, after adopting the same center point loss term as KLD loss $L _ { c } ( \pmb { \mu } _ { 1 } , \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } )$ , the performance of KFIoU loss is further improved, which is better than KLD loss thanks to a better center point optimization mechanism.
204
+
205
+ Ablation study on various 2-D datasets with different detectors. Tab. 2 compares Smooth L1 loss and KFIoU loss by indicators with different IoU thresholds. For HRSC2016 containing a large number of ships with large aspect ratios, KFIoU loss has a $9 . 9 0 \%$ improvement over Smooth L1 on $\mathsf { A P } _ { 7 5 }$ . For the scene text datasets MSRA-TD500 and ICDAR2015, KFIoU achieves $7 . 0 7 \%$ and $3 . 4 4 \%$ improvements on $\mathrm { H m e a n } _ { 5 0 : 9 5 }$ , reaching $4 4 . 9 6 \%$ and $4 1 . 1 7 \%$ respectively. The same conclusion can be reached on FDDB and DOTA-v1.0 datasets.
206
+
207
+ Ablation study of KFIoU loss on 3- D detection. We generalize the KFIoU loss from 2-D to 3-D, with results in Tab. 3. It involves 3-D detection and BEV detection on KITTI val split, and
208
+
209
+ Table 4: Accuracy $( \% )$ comparison on DOTA. The bold red and blue indicate the top two performances. $D _ { o c }$ and $D _ { l e }$ denotes OpenCV Definition $( \theta \in [ - 9 0 ^ { \circ } , 0 ^ { \circ } ) )$ and Long Edge Definition $( \theta \in [ - 9 0 ^ { \circ } , 9 0 ^ { \circ } ) )$ of RBox. $\mathbf { \hat { H } } ^ { \prime }$ and ‘R’ denote the horizontal and rotating anchors, respectively. † indicates that the first term of KLD is taken as the center point loss, i.e. $L _ { c } ( \pmb { \mu } _ { 1 } , \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } )$ .
210
+
211
+ <table><tr><td>Method</td><td>Box Def.</td><td>DOTA-v1.0</td><td>DOTA-v1.5</td><td>DOTA-v2.0</td></tr><tr><td>RetinaNet-H(Reg.) (2017b)</td><td>Doc</td><td>65.73</td><td>58.87</td><td>44.16</td></tr><tr><td>RetinaNet-H(Reg.) (2017b)</td><td>Dle</td><td>64.17</td><td>56.10</td><td>43.06</td></tr><tr><td>RetinaNet-H(Reg.*) (2017b)</td><td>Dle</td><td>65.78</td><td>57.17</td><td>43.92</td></tr><tr><td>RetinaNet-R (Reg.) (2017b)</td><td>Doc</td><td>67.25</td><td>56.50</td><td>42.04</td></tr><tr><td>PIoU (2020)</td><td>Doc</td><td>65.85</td><td>57.65</td><td>45.23</td></tr><tr><td>IoU-Smooth L1 (2019)</td><td>Doc</td><td>66.99</td><td>59.16</td><td>46.31</td></tr><tr><td>Modulated Loss (2021a)</td><td>Doc</td><td>66.05</td><td>57.75</td><td>45.17</td></tr><tr><td>Modulated Loss (2021a)</td><td>Quad.</td><td>67.20</td><td>61.42</td><td>46.71</td></tr><tr><td>RIL (2021a)</td><td>Quad.</td><td>66.06</td><td>58.91</td><td>45.35</td></tr><tr><td>CSL (2020)</td><td>Dle</td><td>67.38</td><td>58.55</td><td>43.34</td></tr><tr><td>DCL(BCL)(2021a)</td><td>Die</td><td>67.39</td><td>59.38</td><td>45.46</td></tr><tr><td>plain SkewIoU (2019)</td><td>Doc</td><td>68.27</td><td>59.01</td><td>45.87</td></tr><tr><td>GWD (2021c)</td><td>Doc</td><td>68.93</td><td>60.03</td><td>46.65</td></tr><tr><td>KLD (2021d)</td><td>Doc</td><td>71.28</td><td>62.50</td><td>47.69</td></tr><tr><td>KFIoU (Ours)</td><td>Doc</td><td>70.64</td><td>62.71</td><td>48.04</td></tr><tr><td>KFIoUt (Ours)</td><td>Doc</td><td>71.60</td><td>63.75</td><td>48.94</td></tr></table>
212
+
213
+ significant performance improvements are also achieved. On the moderate level of 3-D detection and BEV detection, KFIoU loss improves PointPillars by $2 . 4 3 \%$ and $1 . 9 8 \%$ , respectively.
214
+
215
+ Comparison with peer methods. Methods in Tab. 4 are based on the same baseline RetinaNet, and initialized by ResNet50 (He et al., 2016) without using data augmentation and multi-scale training/testing. They are trained/tested under the same environment and hyperparameters. These methods are all published solutions to the boundary discontinuity in rotation detection.
216
+
217
+ First, we conduct ablation experiments on anchor form, rotated bounding box definition form, and angle regression form based on RetinaNet. Rotating anchors provides accurate prior, which makes the model show strong performance in large aspect ratio objects (e.g. SV, LV, SH). However, the large number of anchors makes it time-consuming. Therefore, we use horizontal anchors by default to balance accuracy and speed. In terms of definition, experiments show that OpenCV definition $( D _ { o c } )$ (Yang et al., 2019) is slightly better than Long Edge definition $( D _ { l e } )$ (Ma et al., 2018) on the three versions of DOTA. Angle direct regression (Reg.) always suffers from the boundary discontinuity problem as widely studied recently (Yang & Yan, 2020). In contrast, angle indirect regression $\mathrm { ( R e g ^ { * } . ) }$ is a simpler way to avoid above issues and brings performance boost according to Tab. 4.
218
+
219
+ Table 5: AP of different objects on DOTA-v1.0. Red and blue: top two performances.
220
+
221
+ <table><tr><td></td><td>Method</td><td>Backbone</td><td>PL</td><td>BD</td><td>BR</td><td>GTF</td><td>SV</td><td>LV</td><td>SH</td><td>TC</td><td>BC ST</td><td>SBF</td><td>RA</td><td>HA</td><td>SP</td><td>HC</td><td>mAP50</td></tr><tr><td rowspan="7">seeseerete</td><td>PloU (2020)</td><td>DLA-34</td><td>80.90</td><td>69.70</td><td>24.10</td><td>60.20</td><td>38.30</td><td>64.40 64.80</td><td>90.90</td><td>77.20</td><td>70.40</td><td>46.50</td><td>37.10</td><td>57.10</td><td>61.90</td><td>64.00</td><td>60.50</td></tr><tr><td>O2-DNet (2020a)</td><td>H-104</td><td>89.31</td><td>82.14</td><td>47.33</td><td>61.21 71.32</td><td>74.03</td><td>78.62</td><td>90.76</td><td>82.23</td><td>81.36</td><td>60.93</td><td>60.17</td><td>58.21</td><td>66.98</td><td>61.03</td><td>71.04</td></tr><tr><td>DAL (2021b)</td><td>R-101</td><td>88.61</td><td>79.69</td><td>46.27</td><td>70.37</td><td>65.89 76.10</td><td>78.53</td><td>90.84</td><td>79.98</td><td>78.41</td><td>58.71</td><td>62.02</td><td>69.23</td><td>71.32</td><td>60.65</td><td>71.78</td></tr><tr><td>DRN(2020)</td><td>H-104</td><td>89.71</td><td>82.34</td><td>47.22</td><td>64.10</td><td>76.22</td><td>74.43</td><td>85.84 90.57</td><td>86.18</td><td>84.89</td><td>57.65</td><td>61.93</td><td>69.30</td><td>69.63</td><td>58.48</td><td>73.23</td></tr><tr><td>DCL (2021a)</td><td>R-152</td><td>89.10</td><td>84.13</td><td>50.15</td><td>73.57</td><td>71.48</td><td>58.13</td><td>78.00</td><td>90.89 86.64</td><td>86.78</td><td>67.97</td><td>67.25</td><td>65.63</td><td>74.06</td><td>67.05</td><td>74.06</td></tr><tr><td>GWD (2021c)</td><td>R-152</td><td>86.96</td><td>83.88</td><td>54.36</td><td>77.53</td><td>74.41</td><td>68.48 80.34</td><td>86.62</td><td>83.41</td><td>85.55</td><td>73.47</td><td>67.77</td><td>72.57</td><td>75.76</td><td>73.40</td><td>76.30</td></tr><tr><td>KFIoU (Ours)</td><td>R-152</td><td>89.46</td><td>85.72</td><td>54.94</td><td>80.37</td><td>77.16 69.23</td><td>80.90</td><td>90.79</td><td>87.79</td><td>86.13</td><td>73.32</td><td>68.11</td><td>75.23</td><td>71.61</td><td>69.49</td><td>77.35</td></tr><tr><td rowspan="8">reseeear</td><td>R3Det (2021b)</td><td>R-152</td><td>89.80</td><td>83.77</td><td>48.11</td><td>66.77</td><td>78.76</td><td>83.27 87.84</td><td>90.82</td><td>85.38</td><td>85.51</td><td>65.67</td><td>62.68</td><td>67.53</td><td>78.56</td><td>72.62</td><td>76.47</td></tr><tr><td>CFA (2021)</td><td>R-152</td><td>89.08</td><td>83.20</td><td>54.37 66.87</td><td>81.23</td><td>80.96</td><td>87.17</td><td>90.21</td><td>84.32</td><td>86.09</td><td>52.34</td><td>69.94</td><td>75.52</td><td>80.76</td><td>67.96</td><td>76.67</td></tr><tr><td>RIDet (2021a)</td><td>R-50</td><td>89.31</td><td>80.77 54.07</td><td>76.38</td><td>79.81</td><td>81.99</td><td>89.13</td><td>90.72</td><td>83.58</td><td>87.22</td><td>64.42</td><td>67.56</td><td>78.08</td><td>79.17</td><td>62.07</td><td>77.62</td></tr><tr><td>S2A-Net (2021a)</td><td>R-50</td><td>88.89</td><td>83.60</td><td>57.74</td><td>81.95</td><td>79.94 83.19</td><td>89.11</td><td>90.78</td><td>84.87</td><td>87.81</td><td>70.30</td><td>68.25</td><td>78.30</td><td>77.01</td><td>69.58</td><td>79.42</td></tr><tr><td>R3Det-GWD (2021c)</td><td>R-152</td><td>89.66</td><td>84.99</td><td>59.26</td><td>82.19</td><td>78.97</td><td>84.83 87.70</td><td>90.21</td><td>86.54</td><td>86.85</td><td>73.47</td><td>67.77</td><td>76.92</td><td>79.22</td><td>74.92</td><td>80.23</td></tr><tr><td>R3Det-KLD (2021d)</td><td>R-152</td><td>89.92</td><td>85.13</td><td>59.19</td><td>81.33</td><td>78.82</td><td>84.38</td><td>87.50</td><td>89.80 87.33</td><td>87.00</td><td>72.57</td><td>71.35</td><td>77.12</td><td>79.34</td><td>78.68</td><td>80.63</td></tr><tr><td>RDet-KFIoU (Ours)</td><td>Swin-T</td><td>89.50</td><td>84.26</td><td>59.90</td><td>81.06</td><td>81.74</td><td>85.45</td><td>88.77 90.85</td><td>87.03</td><td>87.79</td><td>70.68</td><td>74.31</td><td>78.17</td><td>81.67</td><td>72.37</td><td>80.90</td></tr><tr><td>RDet-KFIoU (Ours)</td><td>R-152</td><td>88.89</td><td>85.14</td><td>60.05</td><td>81.13</td><td>81.78</td><td>85.71</td><td>88.27</td><td>90.87 87.12</td><td>87.91</td><td>69.77</td><td>73.70</td><td>79.25</td><td>81.31</td><td>74.56</td><td>81.03</td></tr><tr><td rowspan="12">11s-pr</td><td>Rol-Trans. (2019)</td><td>R-101</td><td>88.64</td><td>78.52 43.44</td><td>75.92</td><td>68.81</td><td>73.68</td><td>83.59</td><td>90.74</td><td>77.27</td><td>81.46</td><td>58.39</td><td>53.54</td><td>62.83</td><td>58.93</td><td>47.67</td><td>69.56</td></tr><tr><td>SCRDet (2019)</td><td>R-101</td><td>89.98</td><td>80.65</td><td>52.09</td><td>68.36</td><td>68.36</td><td>60.32</td><td>72.41</td><td>90.85 87.94</td><td>86.86</td><td>65.02</td><td>66.68</td><td>66.25</td><td>68.24</td><td>65.21</td><td>72.61</td></tr><tr><td>Gliding Vertex (2020)</td><td>R-101</td><td>89.64</td><td>85.00 52.26</td><td></td><td>77.34</td><td>73.01</td><td>73.14 86.82</td><td>90.74</td><td>79.02</td><td>86.81</td><td>59.55</td><td>70.91</td><td>72.94</td><td>70.86</td><td>57.32</td><td>75.02</td></tr><tr><td>CSL (2020)</td><td>R-152</td><td>90.25</td><td>85.53</td><td>54.64</td><td>75.31</td><td>70.44</td><td>73.51 77.62</td><td>90.84</td><td>86.15</td><td>86.69</td><td>69.60</td><td>68.04</td><td>73.83</td><td>71.10</td><td>68.93</td><td>76.17</td></tr><tr><td>RSDet-I (2021a)</td><td>R-152</td><td>89.93</td><td>84.45</td><td>53.77</td><td>74.35</td><td>71.52</td><td>78.31 78.12</td><td>91.14</td><td>87.35</td><td>86.93</td><td>65.64</td><td>65.17</td><td>75.35</td><td>79.74</td><td>63.31</td><td>76.34</td></tr><tr><td>SCRDet++ (2023)</td><td>R-101</td><td>90.05</td><td>84.39</td><td>55.44 73.99</td><td>77.54</td><td>71.11</td><td>86.05</td><td>90.67</td><td>87.32</td><td>87.08</td><td>69.62</td><td>68.90</td><td>73.74</td><td>71.29</td><td>65.08</td><td>76.81</td></tr><tr><td>ReDet (2021b)</td><td>ReR-50</td><td>88.81</td><td>82.48</td><td>60.83</td><td>80.82</td><td>78.34</td><td>86.06</td><td>88.31 90.87</td><td>88.77</td><td>87.03</td><td>68.65</td><td>66.90</td><td>79.26</td><td>79.71</td><td>74.67</td><td>80.10</td></tr><tr><td>Oriented R-CNN (2021)</td><td>R-50</td><td>89.84</td><td>85.43</td><td>61.09</td><td>79.82</td><td>79.71</td><td>85.35</td><td>88.82</td><td>90.88</td><td>86.68</td><td>87.73</td><td>72.21</td><td>70.80 82.42</td><td>78.18</td><td>74.11</td><td>80.87</td></tr><tr><td>Rol-Trans.-KFloU(Ours)</td><td>Swin-T</td><td>89.44</td><td>84.41</td><td>62.22</td><td>82.51</td><td>80.10</td><td>86.07</td><td>88.68</td><td>90.90</td><td>87.32</td><td>88.38</td><td>72.80 71.95</td><td>78.96</td><td>74.95</td><td>75.27</td><td>80.93</td></tr></table>
222
+
223
+ PIoU calculates the SkewIoU by accumulating the contribution of interior overlapping pixels but the effect is not significant. IoU-Smooth L1 partly circumvents the need for SkewIoU loss with gradient backpropagation by combining IoU and Smooth L1 loss. Although IoU-Smooth L1 has achieved an improvement of $1 . 2 6 \% / 0 . 2 9 \% / 2 . 1 5 \%$ on DOTA-v $1 . 0 / \mathrm { v } 1 . 5 / \mathrm { v } 2 . 0 $ , the gradient is still dominated by Smooth L1 but still worse than plain SkewIoU loss. Modulated Loss and RIL implement ordered and disordered quadrilateral detection respectively, and the more accurate representation makes them both have a considerable performance improvement. In particular, Modulated Loss achieves the third highest performance on DOTA-v $1 . 5 / \mathrm { v } 2 . 0$ . CSL and DCL convert the angle prediction from regression to classification, cleverly eliminating the boundary discontinuity problem caused by the angle periodicity. GWD loss, KLD loss and KFIoU loss are three different regression losses based on Gaussian distribution. The results presented in our experiments of GWD loss and KLD loss are obtained by best-tuned hyperparameters. In contrast, KFIoU loss is free from hyperparameter tuning and has a more stable performance increase due to a more consistent calculation process with SkewIoU loss as the center point gets closer.
224
+
225
+ # 5.3 COMPARISON WITH THE STATE-OF-THE-ART
226
+
227
+ Tab. 5 compares recent detectors on DOTA-v1.0, as categorized by single-, refine-, and two-stage based methods. Since different methods use different image resolution, network structure, training strategies and various tricks, we cannot make absolutely fair comparisons. In terms of overall performance, our method has achieved the best performance so far, at around $7 7 . 3 5 \% / 8 1 . 0 3 \% / 8 0 . 9 3 \%$ .
228
+
229
+ # 6 CONCLUSION
230
+
231
+ We have presented a trend-level consistent approximate to the ideal but gradient-training unfriendly SkewIoU loss for rotation detection, and we call it KFIoU loss as the product of the Gaussian distributions is adopted to directly mimic the computing mechanism of SkewIoU loss by definition. This design differs from the distribution distance based losses including GWD loss and KLD loss which in our analysis have fundamental difficulty in achieving trend-level alignment with SkewIoU loss without tuning hyperparameters. Moreover, KFIoU is easier to implement and works better than plain SkewIoU due to the effective measurement for non-overlapping cases and complete derivation. Experimental results on various 2D and 3D datasets show the effectiveness of our approach.
232
+
233
+ # REFERENCES
234
+
235
+ Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for largescale machine learning. In 12th {USENIX} symposium on operating systems design and implementation $\left. \left\{ O S D I \right\} \ I \bar { 6 } \right.$ , pp. 265–283, 2016.
236
+
237
+ Seyed Majid Azimi, Eleonora Vig, Reza Bahmanyar, Marco Korner, and Peter Reinartz. Towards ¨ multi-class object detection in unconstrained remote sensing imagery. In Asian Conference on Computer Vision, pp. 150–165. Springer, 2018.
238
+
239
+ Zhiming Chen, Kean Chen, Weiyao Lin, John See, Hui Yu, Yan Ke, and Cong Yang. Piou loss: Towards accurate oriented object detection in complex environments. In European Conference on Computer Vision, pp. 195–211. Springer, 2020.
240
+
241
+ MMDetection3D Contributors. MMDetection3D: OpenMMLab next-generation platform for general 3D object detection. https://github.com/open-mmlab/mmdetection3d, 2020.
242
+
243
+ Jian Ding, Nan Xue, Yang Long, Gui-Song Xia, and Qikai Lu. Learning roi transformer for oriented object detection in aerial images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2849–2858, 2019.
244
+
245
+ Andreas Geiger, Philip Lenz, and Raquel Urtasun. Are we ready for autonomous driving? the kitti vision benchmark suite. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3354–3361. IEEE, 2012.
246
+
247
+ Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1440–1448, 2015.
248
+
249
+ Zonghao Guo, Chang Liu, Xiaosong Zhang, Jianbin Jiao, Xiangyang Ji, and Qixiang Ye. Beyond bounding-box: Convex-hull feature adaptation for oriented and densely packed object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 8792– 8801, 2021.
250
+
251
+ Jiaming Han, Jian Ding, Jie Li, and Gui-Song Xia. Align deep features for oriented object detection. IEEE Transactions on Geoscience and Remote Sensing, 60:1–11, 2021a.
252
+
253
+ Jiaming Han, Jian Ding, Nan Xue, and Gui-Song Xia. Redet: A rotation-equivariant detector for aerial object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2786–2795, 2021b.
254
+
255
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 770–778, 2016.
256
+
257
+ Shi-Min Hu, Dun Liang, Guo-Ye Yang, Guo-Wei Yang, and Wen-Yang Zhou. Jittor: a novel deep learning framework with meta-operators and unified graph execution. Science China Information Sciences, 63:1–21, 2020.
258
+
259
+ Vidit Jain and Erik Learned-Miller. Fddb: A benchmark for face detection in unconstrained settings. 2010.
260
+
261
+ Yingying Jiang, Xiangyu Zhu, Xiaobing Wang, Shuli Yang, Wei Li, Hua Wang, Pei Fu, and Zhenbo Luo. R2cnn: rotational region cnn for orientation robust scene text detection. arXiv preprint arXiv:1706.09579, 2017.
262
+
263
+ Dimosthenis Karatzas, Lluis Gomez-Bigorda, Anguelos Nicolaou, Suman Ghosh, Andrew Bagdanov, Masakazu Iwamura, Jiri Matas, Lukas Neumann, Vijay Ramaseshan Chandrasekhar, Shijian Lu, et al. Icdar 2015 competition on robust reading. In 2015 13th International Conference on Document Analysis and Recognition, pp. 1156–1160. IEEE, 2015.
264
+
265
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
266
+
267
+ Alex H Lang, Sourabh Vora, Holger Caesar, Lubing Zhou, Jiong Yang, and Oscar Beijbom. Pointpillars: Fast encoders for object detection from point clouds. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 12697–12705, 2019.
268
+
269
+ Jianwei Li, Changwen Qu, and Jiaqi Shao. Ship detection in sar images based on an improved faster r-cnn. In 2017 SAR in Big Data Era: Models, Methods and Applications (BIGSARDATA), pp. 1–6. IEEE, 2017.
270
+
271
+ Minghui Liao, Baoguang Shi, and Xiang Bai. Textboxes++: A single-shot oriented scene text detector. IEEE Transactions on Image Processing, 27(8):3676–3690, 2018a.
272
+
273
+ Minghui Liao, Zhen Zhu, Baoguang Shi, Gui-song Xia, and Xiang Bai. Rotation-sensitive regression for oriented scene text detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5909–5918, 2018b.
274
+
275
+ Tsung-Yi Lin, Piotr Dollar, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. ´ Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2117–2125, 2017a.
276
+
277
+ Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense ´ object detection. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2980–2988, 2017b.
278
+
279
+ Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, and Alexander C Berg. Ssd: Single shot multibox detector. In European Conference on Computer Vision, pp. 21–37. Springer, 2016.
280
+
281
+ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 10012–10022, 2021.
282
+
283
+ Zikun Liu, Liu Yuan, Lubin Weng, and Yiping Yang. A high resolution optical satellite image dataset for ship recognition and some new baselines. In Proceedings of the International Conference on Pattern Recognition Applications and Methods, volume 2, pp. 324–331, 2017.
284
+
285
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2018.
286
+
287
+ Jianqi Ma, Weiyuan Shao, Hao Ye, Li Wang, Hong Wang, Yingbin Zheng, and Xiangyang Xue. Arbitrary-oriented scene text detection via rotation proposals. IEEE Transactions on Multimedia, 20(11):3111–3122, 2018.
288
+
289
+ Qi Ming, Lingjuan Miao, Zhiqiang Zhou, Xue Yang, and Yunpeng Dong. Optimization for arbitraryoriented object detection via representation invariance loss. IEEE Geoscience and Remote Sensing Letters, 2021a.
290
+
291
+ Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Hongwei Zhang, and Linhao Li. Dynamic anchor learning for arbitrary-oriented object detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 2355–2363, 2021b.
292
+
293
+ Xingjia Pan, Yuqiang Ren, Kekai Sheng, Weiming Dong, Haolei Yuan, Xiaowei Guo, Chongyang Ma, and Changsheng Xu. Dynamic refinement network for oriented and densely packed object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 11207–11216, 2020.
294
+
295
+ Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. 2017.
296
+
297
+ Wen Qian, Xue Yang, Silong Peng, Junchi Yan, and Yue Guo. Learning modulated loss for rotated object detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 2458–2466, 2021a.
298
+
299
+ Wen Qian, Xue Yang, Silong Peng, Junchi Yan, and Xiujuan Zhang. Rsdet++: Point-based modulated loss for more accurate rotated object detection. arXiv preprint arXiv:2109.11906, 2021b.
300
+
301
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In Advances in Neural Information Processing Systems, pp. 91–99, 2015.
302
+
303
+ Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 658–666, 2019.
304
+
305
+ Jinwang Wang, Jian Ding, Haowen Guo, Wensheng Cheng, Ting Pan, and Wen Yang. Mask obb: A semantic attention-based mask oriented bounding box representation for multi-category object detection in aerial images. Remote Sensing, 11(24):2930, 2019.
306
+
307
+ Haoran Wei, Yue Zhang, Zhonghan Chang, Hao Li, Hongqi Wang, and Xian Sun. Oriented objects as pairs of middle lines. ISPRS Journal of Photogrammetry and Remote Sensing, 169:268–279, 2020a.
308
+
309
+ Shunjun Wei, Xiangfeng Zeng, Qizhe Qu, Mou Wang, Hao Su, and Jun Shi. Hrsid: A highresolution sar images dataset for ship detection and instance segmentation. Ieee Access, 8: 120234–120254, 2020b.
310
+
311
+ Gui-Song Xia, Xiang Bai, Jian Ding, Zhen Zhu, Serge Belongie, Jiebo Luo, Mihai Datcu, Marcello Pelillo, and Liangpei Zhang. Dota: A large-scale dataset for object detection in aerial images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3974– 3983, 2018.
312
+
313
+ Enze Xie, Peize Sun, Xiaoge Song, Wenhai Wang, Xuebo Liu, Ding Liang, Chunhua Shen, and Ping Luo. Polarmask: Single shot instance segmentation with polar representation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 12193–12202, 2020.
314
+
315
+ Xingxing Xie, Gong Cheng, Jiabao Wang, Xiwen Yao, and Junwei Han. Oriented r-cnn for object detection. In Proceedings of the IEEE International Conference on Computer Vision, pp. 3520– 3529, 2021.
316
+
317
+ Yongchao Xu, Mingtao Fu, Qimeng Wang, Yukang Wang, Kai Chen, Gui-Song Xia, and Xiang Bai. Gliding vertex on the horizontal bounding box for multi-oriented object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 43(4):1452–1459, 2020.
318
+
319
+ Yan Yan, Yuxing Mao, and Bo Li. Second: Sparsely embedded convolutional detection. Sensors, 18(10):3337, 2018.
320
+
321
+ Xue Yang and Junchi Yan. Arbitrary-oriented object detection with circular smooth label. In European Conference on Computer Vision, pp. 677–694. Springer, 2020.
322
+
323
+ Xue Yang, Hao Sun, Kun Fu, Jirui Yang, Xian Sun, Menglong Yan, and Zhi Guo. Automatic ship detection in remote sensing images from google earth of complex scenes based on multiscale rotation dense feature pyramid networks. Remote Sensing, 10(1):132, 2018a.
324
+
325
+ Xue Yang, Hao Sun, Xian Sun, Menglong Yan, Zhi Guo, and Kun Fu. Position detection and direction prediction for arbitrary-oriented ships via multitask rotation region convolutional neural network. IEEE Access, 6:50839–50849, 2018b.
326
+
327
+ Xue Yang, Jirui Yang, Junchi Yan, Yue Zhang, Tengfei Zhang, Zhi Guo, Xian Sun, and Kun Fu. Scrdet: Towards more robust detection for small, cluttered and rotated objects. In Proceedings of the IEEE International Conference on Computer Vision, pp. 8232–8241, 2019.
328
+
329
+ Xue Yang, Liping Hou, Yue Zhou, Wentao Wang, and Junchi Yan. Dense label encoding for boundary discontinuity free rotation detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 15819–15829, 2021a.
330
+
331
+ Xue Yang, Junchi Yan, Ziming Feng, and Tao He. R3det: Refined single-stage detector with feature refinement for rotating object. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 3163–3171, 2021b.
332
+
333
+ Xue Yang, Junchi Yan, Qi Ming, Wentao Wang, Xiaopeng Zhang, and Qi Tian. Rethinking rotated object detection with gaussian wasserstein distance loss. In International Conference on Machine Learning, pp. 11830–11841. PMLR, 2021c.
334
+
335
+ Xue Yang, Xiaojiang Yang, Jirui Yang, Qi Ming, Wentao Wang, Qi Tian, and Junchi Yan. Learning high-precision bounding box for rotated object detection via kullback-leibler divergence. Advances in Neural Information Processing Systems, 34, 2021d.
336
+
337
+ Xue Yang, Yue Zhou, and Junchi Yan. Alpharotate: A rotation detection benchmark using tensorflow. arXiv preprint arXiv:2111.06677, 2021e.
338
+
339
+ Xue Yang, Gefan Zhang, Xiaojiang Yang, Yue Zhou, Wentao Wang, Jin Tang, Tao He, and Junchi Yan. Detecting rotated objects as gaussian distributions and its 3-d generalization. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
340
+
341
+ Xue Yang, Junchi Yan, Wenlong Liao, Xiaokang Yang, Jin Tang, and Tao He. Scrdet $^ { + + }$ : Detecting small, cluttered and rotated objects via instance-level feature denoising and rotation loss smoothing. IEEE Transactions on Pattern Analysis and Machine Intelligence, 45(2):2384–2399, 2023.
342
+
343
+ Cong Yao, Xiang Bai, Wenyu Liu, Yi Ma, and Zhuowen Tu. Detecting texts of arbitrary orientations in natural images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1083–1090. IEEE, 2012.
344
+
345
+ Jiahui Yu, Yuning Jiang, Zhangyang Wang, Zhimin Cao, and Thomas Huang. Unitbox: An advanced object detection network. In Proceedings of the 24th ACM international conference on Multimedia, pp. 516–520, 2016.
346
+
347
+ Yu Zheng, Danyang Zhang, Sinan Xie, Jiwen Lu, and Jie Zhou. Rotation-robust intersection over union for 3d object detection. In European Conference on Computer Vision, pp. 464–480. Springer, 2020a.
348
+
349
+ Zhaohui Zheng, Ping Wang, Wei Liu, Jinze Li, Rongguang Ye, and Dongwei Ren. Distance-iou loss: Faster and better learning for bounding box regression. In Proceedings of the AAAI Conference on Artificial Intelligence, pp. 12993–13000, 2020b.
350
+
351
+ Dingfu Zhou, Jin Fang, Xibin Song, Chenye Guan, Junbo Yin, Yuchao Dai, and Ruigang Yang. Iou loss for 2d/3d object detection. In 2019 International Conference on 3D Vision, pp. 85–94. IEEE, 2019.
352
+
353
+ Xinyu Zhou, Cong Yao, He Wen, Yuzhi Wang, Shuchang Zhou, Weiran He, and Jiajun Liang. East: an efficient and accurate scene text detector. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5551–5560, 2017.
354
+
355
+ Yue Zhou, Xue Yang, Gefan Zhang, Jiabao Wang, Yanyi Liu, Liping Hou, Xue Jiang, Xingzhao Liu, Junchi Yan, Chengqi Lyu, Wenwei Zhang, and Kai Chen. Mmrotate: A rotated object detection benchmark using pytorch. In Proceedings of the 30th ACM International Conference on Multimedia, pp. 7331–7334, 2022.
356
+
357
+ # A PROOF OF KFIOU UPPER BOUND
358
+
359
+ For an n-dimensional Gaussian distribution, its volume is:
360
+
361
+ $$
362
+ \mathcal { V } = 2 ^ { n } \cdot | \Sigma ^ { \frac { 1 } { 2 } } | = 2 ^ { n } \cdot | \Sigma | ^ { \frac { 1 } { 2 } }
363
+ $$
364
+
365
+ For $\Sigma _ { k f }$ , we have
366
+
367
+ $$
368
+ \begin{array} { l } { \left| { \Sigma } _ { k f } \right| = \left| { \Sigma } _ { 1 } - { \Sigma } _ { 1 } \big ( { \Sigma } _ { 1 } + { \Sigma } _ { 2 } \big ) ^ { - 1 } { \Sigma } _ { 1 } \right| } \\ { \quad \quad \quad = \left| { \Sigma } _ { 1 } \big ( { \Sigma } _ { 1 } + { \Sigma } _ { 2 } \big ) ^ { - 1 } { \Sigma } _ { 2 } \right| } \\ { \quad \quad = \displaystyle \frac { \left| { \Sigma } _ { 1 } \right| \cdot \left| { \Sigma } _ { 1 } \right| } { \left| { \Sigma } _ { 1 } + { \Sigma } _ { 2 } \right| } } \end{array}
369
+ $$
370
+
371
+ According to Minkowski’s inequality:
372
+
373
+ $$
374
+ | \Sigma _ { 1 } + \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq | \Sigma _ { 1 } | ^ { \frac { 1 } { n } } + | \Sigma _ { 2 } | ^ { \frac { 1 } { n } }
375
+ $$
376
+
377
+ Simultaneous mean inequalities:
378
+
379
+ $$
380
+ | \Sigma _ { 1 } + \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq | \Sigma _ { 1 } | ^ { \frac { 1 } { n } } | + | \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq 2 \cdot | \Sigma _ { 1 } | ^ { \frac { 1 } { 2 n } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 2 n } }
381
+ $$
382
+
383
+ Thus:
384
+
385
+ $$
386
+ \begin{array} { r l r } & { } & { \frac { \sum _ { 1 } \frac { 1 } { 2 n } \cdot \sum _ { 2 } \frac { 1 } { 2 n } } { \sum _ { 1 } + \sum _ { 2 } \frac { 1 } { n } } \leq \frac { 1 } { 2 } } \\ & { } & { \frac { \sum _ { 1 } \frac { 1 } { 2 } \cdot \sum _ { 2 } ^ { \frac { 1 } { 2 } } } { \sum _ { 1 } + \sum _ { 2 } } \leq \frac { 1 } { 2 ^ { n } } } \end{array}
387
+ $$
388
+
389
+ and
390
+
391
+ $$
392
+ \begin{array} { r l } & { | \Sigma _ { k f } | = \frac { | \Sigma _ { 1 } | \cdot | \Sigma _ { 1 } | } { | \Sigma _ { 1 } + \Sigma _ { 2 } | } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 2 } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 2 } } } { 2 ^ { n } } } \\ & { | \Sigma _ { k f } | ^ { \frac { 1 } { 2 } } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 4 } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 4 } } } { 2 ^ { \frac { n } { 2 } } } } \end{array}
393
+ $$
394
+
395
+ Combine the mean inequalities again:
396
+
397
+ $$
398
+ | \Sigma _ { k f } | ^ { \frac { 1 } { 2 } } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 4 } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 4 } } } { 2 ^ { \frac { n } { 2 } } } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 2 } } + | \Sigma _ { 2 } | ^ { \frac { 1 } { 2 } } } { 2 ^ { \frac { n } { 2 } + 1 } }
399
+ $$
400
+
401
+ According to Eq. 14, we have
402
+
403
+ $$
404
+ \mathcal { V } _ { k f } \leq \frac { \mathcal { V } _ { 1 } + \mathcal { V } _ { 2 } } { 2 ^ { \frac { n } { 2 } + 1 } }
405
+ $$
406
+
407
+ Therefore, the upper bound of KFIoU is
408
+
409
+ $$
410
+ \mathrm { K F I o U } = \frac { \mathcal { V } _ { k f } } { \mathcal { V } _ { 1 } + \mathcal { V } _ { 2 } - \mathcal { V } _ { k f } } \le \frac { 1 } { 2 ^ { \frac { n } { 2 } + 1 } - 1 }
411
+ $$
412
+
413
+ $n = 2$ and $n = 3$ , the upper bounds are $\frac 1 3$ and $\frac { 1 } { \sqrt { 3 2 } - 1 }$
414
+
415
+ # B SUPPLEMENTARY EXPERIMENT
416
+
417
+ Ablation study of three forms of KFIoU loss on two detectors. We use two different detectors and three different KFIoU based loss functions to verify its effectiveness, as shown in Tab. 6. RetinaNetbased detector will have a large number of low-SkewIoU prediction bounding box in the early stage of training, and will produce very large loss after the log function, which weakens the improvement of the model. Compared with the linear function, the derivative of the exp-based function will pay more attention to the training of difficult samples, so it has a higher performance, at $7 0 . 6 4 \%$ . In contrast, ${ \tt R } ^ { 3 }$ Det-based detector can generate high-quality prediction box at the beginning of training by adding refinement stages, so it will not suffer the same troubles as RetinaNet. Due to the same mechanism of focusing on difficult samples, log and exp-based functions are both better than linear functions, and the best performance is achieved on the log-based function, about $7 2 . 2 8 \%$ . We also expand KFIoU by 3 times to make its range truly consistent with the IoU loss, at $[ 0 , 1 ]$ . However, this consistency do not bring any additional gains, so the following experiments are all use the KFIoU before non-expansion.
418
+
419
+ Table 6: Ablation study of different KFIoU loss forms with different detectors on DOTA-v1.0.
420
+
421
+ <table><tr><td>Method</td><td>Smooth L1</td><td>-ln(KFIoU+e)</td><td>1-KFIoU</td><td>e1-KFIoU1</td><td>e1-3KFIoU-1</td><td>-ln(3KFIoU+ ε)</td></tr><tr><td>RetinaNet</td><td>65.73</td><td>69.80 (+4.07)</td><td>70.19 (+4.46)</td><td>70.64 (+4.91)</td><td>69.64 (+3.91)</td><td>一</td></tr><tr><td>RDet</td><td>70.66</td><td>72.28 (+1.62)</td><td>71.09 (+0.43)</td><td>71.58 (+0.92)</td><td>1</td><td>71.77 (+1.11)</td></tr></table>
422
+
423
+ Table 7: Ablation study of training strategies and tricks. Rotate and MS indicate rotation augmentation and multi-scale training and testing.
424
+
425
+ <table><tr><td>Method</td><td>KFIoU</td><td>Backbone</td><td>Sched.</td><td>MS</td><td>Rotate</td><td>PL 87.76</td><td>BD 72.61</td><td>BR 43.86</td><td>GTF</td><td>SV</td><td>LV</td><td>SH</td><td>TC</td><td>BC</td><td>ST</td><td>SBF</td><td>RA</td><td>HA</td><td>SP</td><td>HC</td><td>mAP50</td></tr><tr><td>RetinaNet</td><td></td><td>R-50 R-50</td><td>12e 12e</td><td></td><td></td><td>88.90</td><td>80.68</td><td>47.12</td><td>66.61 70.40</td><td>69.70 72.20</td><td>56.61 62.49</td><td>74.15 74.84</td><td>90.86 90.91</td><td>75.27 79.63</td><td>79.09 79.73</td><td>47.81 58.54</td><td>64.60 66.40</td><td>58.93 63.67</td><td>63.37 67.13</td><td>26.58 45.33</td><td>65.19 69.86</td></tr><tr><td>S²A-Net</td><td>√</td><td>R-50</td><td>12e</td><td></td><td></td><td>89.18</td><td>79.35</td><td>49.11</td><td>72.97</td><td>79.08</td><td>78.03</td><td>86.67</td><td>90.91</td><td>85.90</td><td>85.04</td><td>64.06</td><td>65.64</td><td>66.71</td><td>67.60</td><td>48.08</td><td>73.89</td></tr><tr><td></td><td>√</td><td>R-50</td><td>12e 12e</td><td></td><td></td><td>89.24</td><td>83.46</td><td>51.44</td><td>70.88</td><td>78.70</td><td>76.31</td><td>86.90 87.85</td><td>90.90 90.90</td><td>82.22 87.04</td><td>84.81 85.70</td><td>61.67 61.73</td><td>66.93 64.55</td><td>65.62</td><td>67.99</td><td>57.05</td><td>74.27</td></tr><tr><td rowspan="5">RoI Trans.</td><td rowspan="5">√</td><td>R-50 R-50</td><td>12e</td><td></td><td></td><td>89.02 89.08</td><td>81.71 82.62</td><td>53.84 53.90</td><td>71.65 71.78</td><td>79.00 78.73</td><td>77.76 77.91</td><td>87.97</td><td>90.90</td><td>86.68</td><td>85.37</td><td>63.17</td><td>67.65</td><td>75.06 74.30</td><td>71.71 71.19</td><td>62.38 61.35</td><td>75.99 76.17</td></tr><tr><td>Swin-T</td><td>12e</td><td></td><td></td><td>88.96</td><td>82.81</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>63.95</td><td></td></tr><tr><td></td><td>12e</td><td></td><td></td><td></td><td></td><td>53.34</td><td>76.55</td><td>78.66</td><td>83.54</td><td>88.00</td><td>90.90</td><td>86.95</td><td>86.47</td><td>41.94</td><td>64.17</td><td>76.29</td><td>72.87</td><td></td><td>77.18</td></tr><tr><td>Swin-T</td><td></td><td></td><td></td><td>88.9</td><td>83.77</td><td>53.98</td><td>77.63</td><td>78.83</td><td>84.22</td><td>88.15</td><td>90.91</td><td>87.21</td><td>86.14</td><td>67.79</td><td>65.73</td><td>75.80</td><td>73.68</td><td>63.30</td><td>77.74</td></tr><tr><td>R-50 Swin-T</td><td>24e</td><td>广</td><td>?</td><td>89.12</td><td>84.54</td><td>60.73</td><td>78.86</td><td>79.65</td><td>85.79</td><td>88.45</td><td>90.90</td><td>87.03</td><td>88.28</td><td>69.15</td><td>70.28</td><td>78.88</td><td>81.54</td><td>70.05</td><td>80.22 80.93</td></tr><tr><td rowspan="8"></td><td>√</td><td></td><td>12e</td><td></td><td></td><td>89.44 89.02</td><td>84.41</td><td>62.22</td><td>82.51</td><td>80.10</td><td>86.07</td><td>88.68 90.90</td><td>87.32</td><td></td><td>88.38 72.80</td><td></td><td>71.95</td><td>78.96</td><td>74.95</td><td>75.27</td></tr><tr><td></td><td>R-50</td><td>12e 12e</td><td></td><td></td><td>74.52 73.89</td><td>47.93</td><td>69.64</td><td>77.02</td><td>74.07</td><td>82.56</td><td>90.90</td><td>79.39</td><td>83.67</td><td>59.02</td><td>62.51</td><td>63.56</td><td>65.06</td><td>37.22</td><td>70.41</td></tr><tr><td></td><td>R-50</td><td></td><td></td><td></td><td>89.06</td><td>49.82</td><td>68.39</td><td>78.13</td><td>75.35</td><td>86.65</td><td>90.89</td><td>82.57</td><td>83.84</td><td>59.63</td><td>62.03</td><td>66.16</td><td>66.22</td><td>47.98</td><td>72.04</td></tr><tr><td></td><td>R-50</td><td>12e</td><td></td><td></td><td>89.06</td><td>82.49 55.91</td><td>81.04</td><td>80.14</td><td>83.24</td><td>88.56</td><td>90.90</td><td>84.61</td><td>86.83</td><td>66.25</td><td>71.50</td><td>75.60</td><td>77.64</td><td>63.66</td><td>78.50</td></tr><tr><td></td><td>Swin-T</td><td>12e</td><td>√</td><td></td><td>89.41</td><td>83.66</td><td>56.92 79.76</td><td>80.45</td><td>84.34</td><td>88.71</td><td>90.91</td><td>85.69</td><td>87.64</td><td>67.69</td><td>72.88</td><td>76.34</td><td>73.63</td><td>72.21</td><td>79.35</td></tr><tr><td></td><td>R-50</td><td>12e</td><td>√</td><td></td><td>89.33</td><td>84.19</td><td>58.78</td><td>80.48</td><td>84.49</td><td>88.85</td><td>90.84</td><td>85.56</td><td>87.57</td><td>69.14</td><td>70.79</td><td>77.33</td><td>80.82</td><td>66.51</td><td>79.73</td></tr><tr><td></td><td></td><td>12e</td><td></td><td></td><td></td><td></td><td>81.30</td><td>80.43</td><td>84.70</td><td>88.85</td><td>90.87</td><td>84.51</td><td>87.95</td><td>71.86</td><td>71.60</td><td>78.31</td><td>79.42</td><td>66.60</td><td>79.83</td></tr><tr><td></td><td>R-101</td><td></td><td></td><td></td><td>89.28</td><td>83.32 83.75</td><td>59.40 59.77</td><td>80.29 79.40</td><td>80.95</td><td>84.61</td><td>88.84</td><td>90.84</td><td>86.86</td><td>87.93</td><td>71.71</td><td>71.17</td><td>76.79</td><td>77.42</td><td>71.59</td><td>80.06</td></tr><tr><td></td><td>&lt;&gt;&gt;&gt;&gt;&gt;&gt;</td><td>Swin-T Swin-T</td><td>12e</td><td>广 √</td><td>&lt;&gt;&gt;&gt;</td><td>89.24</td><td></td><td>59.90</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>80.90</td></tr><tr><td></td><td></td><td></td><td>24e</td><td></td><td></td><td>89.50</td><td>84.26</td><td></td><td>81.06</td><td>81.74</td><td></td><td>90.85</td><td>87.03</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>85.45</td><td>88.77</td><td></td><td></td><td>87.79</td><td>70.68</td><td>74.31</td><td>78.17</td><td>81.67</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>72.37</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></table>
426
+
427
+ Table 8: Results on KITTI val split 3D detection and BEV Detection.
428
+
429
+ <table><tr><td rowspan="2">Method</td><td>mAP</td><td>Car - 3D Detection</td><td></td><td>Ped. - 3D Detection</td><td></td><td></td><td>Cyc. - 3D Detection</td><td></td></tr><tr><td>Mod.</td><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy Mod.</td><td>Hard</td><td>Easy</td><td>Mod. Hard</td></tr><tr><td>PointPillars</td><td>64.28</td><td>88.26</td><td>78.90 76.06</td><td>57.10</td><td>50.96</td><td>46.38</td><td>83.77 62.99</td><td>59.65</td></tr><tr><td>+GWD</td><td>65.50</td><td>87.38</td><td>78.57 75.87</td><td>61.69</td><td>55.19</td><td>50.04</td><td>81.61 62.74</td><td>59.18</td></tr><tr><td>+KLD</td><td>66.19</td><td>89.55</td><td>80.36 76.02</td><td>59.95</td><td>52.94</td><td>48.22</td><td>85.61 65.27</td><td>61.45</td></tr><tr><td>+KFIoU</td><td>66.71</td><td>89.56</td><td>80.19</td><td>77.16 60.97</td><td>54.94</td><td>50.75</td><td>84.96 65.00</td><td>61.00</td></tr><tr><td rowspan="2">Method</td><td>mAP</td><td>Car-1</td><td>BEVDetection</td><td></td><td>Ped.-1 BEVDetection</td><td></td><td>Cyc.-1</td><td>BEVDetection</td></tr><tr><td>Mod.</td><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy Mod.</td><td>Hard</td><td>Easy Mod.</td><td>Hard</td></tr><tr><td>PointPillars</td><td>70.10</td><td>93.81</td><td>88.08</td><td>86.80 61.49</td><td>55.51</td><td>51.13</td><td>87.20 66.69</td><td>63.02</td></tr><tr><td>+GWD</td><td>71.48</td><td>92.02</td><td>88.30</td><td>85.72 64.67</td><td>58.49</td><td>53.45</td><td>86.92 67.66</td><td>63.37</td></tr><tr><td>+KLD</td><td>71.18</td><td>93.33</td><td>88.11</td><td>85.44 64.46</td><td>57.26</td><td>52.53</td><td>87.40 68.19</td><td>64.47</td></tr><tr><td>+KFIoU</td><td>72.08</td><td>92.15</td><td>89.90</td><td>85.66</td><td>63.45 57.81</td><td>53.07</td><td>87.52 68.55</td><td>64.56</td></tr></table>
430
+
431
+ Ablation study of training strategies and tricks. We reimplement KFIoU based on the more powerful benchmark, MMRotate (Zhou et al., 2022). We use a single GeForce RTX 3090 Ti with a total batch size of 2 for training. For ResNet (He et al., 2016), SGD optimizer is adopted with an initial learning rate of 0.0025. The momentum and weight decay are 0.9 and 0.0001, respectively. For Swin Transformer (Liu et al., 2021), AdamW (Kingma & Ba, 2014; Loshchilov & Hutter, 2018) optimizer is adopted with an initial learning rate of 0.0001. The weight decay is 0.05. In addition, we adopt learning rate warmup for 500 iterations, and the learning rate is divided by 10 at each decay step. Tab. 7 performs ablation experiments on four detectors: RetinaNet (Lin et al., 2017b), $\mathrm { S ^ { 2 } A }$ -Net (Han et al., 2021a), $\mathsf { R } ^ { 3 } \mathsf { D e t }$ (Yang et al., 2021b), and RoI Transformer (Ding et al., 2019). The experimental results prove that KFIoU can stably enhance the performance of the detector. In order to further improve the performance of the model on DOTA, we verified many commonly used training strategies and tricks, including backbone, training schedule, data augmentation and multiscale training and testing, as shown in Tab. 7.
432
+
433
+ Ablation study of KFIoU loss on 3-D case. More detailed results in KITTI are shown in Tab. 8.
434
+
435
+ Ablation study on more datasets. The performance of different loss functions is compared in Tab. 9 on ICDAR2015, UCAS-AOD, SSDD (Li et al., 2017) and HRSID (Wei et al., 2020b) datasets, and KFIoU is still the best.
436
+
437
+ Table 9: Results on more datasets, the base detector is RetinaNet.
438
+
439
+ <table><tr><td rowspan="2">Loss</td><td rowspan="2">ICDAR2015</td><td colspan="3">UCAS-AOD</td><td>SSDD</td><td>HRSID</td></tr><tr><td>Car</td><td>Plane</td><td>mAP50</td><td>Inshore</td><td>Inshore</td></tr><tr><td>Smooth L1</td><td>69.78</td><td>92.62</td><td>96.50</td><td>94.56</td><td>68.47</td><td>51.41</td></tr><tr><td>GWD</td><td>74.29</td><td>94.03</td><td>96.86</td><td>95.44</td><td>77.71</td><td>51.11</td></tr><tr><td>KLD</td><td>75.32</td><td>94.34</td><td>97.94</td><td>96.14</td><td>76.84</td><td>52.80</td></tr><tr><td>KFIoU</td><td>75.90</td><td>94.51</td><td>98.41</td><td>96.46</td><td>77.89</td><td>53.45</td></tr></table>
440
+
441
+ ![](images/30e98b92c30f8df8824d4b9774c25bb3646c44978ea911d5c6e01d9acfc2669d.jpg)
442
+ Figure 4: Visual comparison between Smooth L1 loss-based (left), GWD-based (middle) and the KFIoU-based (right) detectors on DOTA (2-D) and KITTI (3-D). For 3-D object detection, red and blue box denotes ground-truth and predict bounding box, respectively.
443
+
444
+ # C VISUALIZATION
445
+
446
+ Fig. 4 ad Fig. 5 show the visual comparison of three different loss functions on the different kinds of datasets. Compared with Smooth L1 Loss, KFIoU loss is significantly better.
447
+
448
+ # D TREND CONSISTENCY SIMULATION
449
+
450
+ Fig. 6(a) and Fig. 6(b) show the impact of center deviation and object scale on the trend consistency of each loss function. Note that each data in the figure is calculated from the average of 1,000 random aspect ratio and rotation angle examples. Two conclusions can be drawn: i) the smaller the center deviation, the better trend consistency of the KFIoU loss; ii) KLD loss and KFIoU loss are insensitive to scale changes.
451
+
452
+ # E LIMITATION
453
+
454
+ Note that the Gaussian modeling has a limitation that it cannot be directly applied to quadrilateral/polygon detection (Ming et al., 2021a; Xu et al., 2020) which is also an important task in aerial images, scene text, etc. In addition, the Gaussian distribution of the square like object is close to the isotropic circle, which is not suitable for the object heading detection.
455
+
456
+ ![](images/34ee25b4c60fa731dcbe57e4bccac56fa2a5a3cd1ac0d786fa28db2d6ca96619.jpg)
457
+ Figure 5: Visual comparison between Smooth L1 loss-based (left), GWD-based (middle) and the KFIoU-based (right) detectors on FDDB.
458
+
459
+ ![](images/dc5d5c7dfd15e5da4d2eb3683c40e021e97911bd50f1cf86b6b401eb057380cd.jpg)
460
+ Figure 6: (a) Impact of center deviation on the trend consistency of each loss function. (b) Impact of object scale on the trend consistency of each loss function under a 5 pixels center deviations.
md/dev/rmMOupN1Sqp/rmMOupN1Sqp.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/tyrJsbKAe6/tyrJsbKAe6.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/u3vEuRr08MT/u3vEuRr08MT.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language Models
2
+
3
+ Kushal Tirumala⇤ Aram H. Markosyan⇤ Luke Zettlemoyer Armen Aghajanyan
4
+
5
+ Meta AI Research {ktirumala,amarkos,lsz,armenag}@fb.com
6
+
7
+ # Abstract
8
+
9
+ Despite their wide adoption, the underlying training and memorization dynamics of very large language models is not well understood. We empirically study exact memorization in causal and masked language modeling, across model sizes and throughout the training process. We measure the effects of dataset size, learning rate, and model size on memorization, finding that larger language models memorize training data faster across all settings. Surprisingly, we show that larger models can memorize a larger portion of the data before over-fitting and tend to forget less throughout the training process. We also analyze the memorization dynamics of different parts of speech and find that models memorize nouns and numbers first; we hypothesize and provide empirical evidence that nouns and numbers act as a unique identifier for memorizing individual training examples. Together, these findings present another piece of the broader puzzle of trying to understand what actually improves as models get bigger.
10
+
11
+ # 1 Introduction
12
+
13
+ The rate and extent to which a model memorizes its training data are key statistics that provide evidence about how it is likely to generalize to new test instances. Classical frameworks, such as bias-variance tradeoff $\textcircled { \left| 3 1 \right| }$ , argued for fitting a training set without full memorization. However, recent work has established a more symbiotic relationship between memorization and generalization in deep learning [13, 26, 28]. This paper empirically studies memorization in causal and masked language modeling, across model sizes and throughout the training process.
14
+
15
+ Much of the recent performance gains for language models have come from scale, with the most recent models reaching up to $1 0 ^ { 1 1 }$ parameters $\frac { \sim } { 1 2 2 } , \boxed { 7 3 } \boxed { 8 3 }$ . Larger models are also known to memorize more training data $\boxed { 1 6 }$ , which is a crucial component of their improved generalization. However, perhaps surprisingly, relatively little work has been done in understanding the impact of scale on the dynamics of language model memorization over training. Existing work focuses on analyzing memorization post-training [16, 47, 88, 95]. In this work, we study the memorization and forgetting dynamics in language models, with a focus on better measuring how they change as we scale up model size. Our primary contributions include:
16
+
17
+ 1. We measure the dependence of memorization dynamics over training on model size (and other factors such as dataset size, overfitting, and learning rate). We find that larger language models memorize training data faster $( \ S 4 )$ .
18
+
19
+ 2. We design controlled experiments that allow us to characterize the forgetting curves in language models (i.e., how language models naturally forget memories throughout training).
20
+
21
+ Our empirical studies show that forgetting curves have lower bounds — we coin this as the forgetting baseline — and that this baseline increases with model scale, i.e., increasing model scale mitigates forgetting $( \ S \ S )$ .
22
+
23
+ 3. We analyze the rates of memorization of different parts of speech, finding that nouns and numbers are memorized much more quickly than other parts of speech $( \ S \ 4 . 4 )$ We hypothesize this is because the set of nouns and numbers can be seen as a unique identifier for a particular sample. We provide evidence to this hypothesis by analyzing the rates of memorization in the setting of an existing unique identifier $( \ S \boxed { 4 . 3 } )$
24
+
25
+ Together, these findings present another piece of the broader puzzle of trying to understand the unique training dynamics that emerge as models grow in size.
26
+
27
+ # 2 Background and Related Work
28
+
29
+ Memorization in Language Models: Unintended memorization is a known challenge for language models [14, 85], which makes them open to extraction attacks [15, 89] and membership inference attacks [41, 64], although there has been work on mitigating these vulnerabilities [51, 88]. Recent work has argued that memorization is not exclusively harmful, and can be crucial for certain types of generalization (e.g., on QA tasks) [11, 46, 87], while also allowing the models to encode significant amounts of world or factual knowledge [4, 35, 71]. There is also a growing body of work analyzing fundamental properties of memorization in language models [16, 47, 60, 95]. Most related to our work Carlini et al. $\boxed { 1 6 }$ analyzes memorization of fully trained language models and observes a dependence on model scale, training data duplication, and prompting context length. While we also study scaling behavior, our focus instead is on the memorization dynamics throughout training.
30
+
31
+ Language Model Training Dynamics: Previous work has extensively analyzed training dynamics to understand how neural models acquire information over training [1, 30, 34, 66, 74]. Saphra and Lopez $\overline { { [ 8 0 ] } }$ were the first to analyze training dynamics for language modeling, focusing on the evolution of internal representations over pre-training. This inspired a line of work analyzing how neural language models learn linguistic structure/world knowledge $[ \overline { { 2 0 } } ] [ 2 1 ] [ 5 3 ]$ , individual words $\pmb { \mathbb { \left[ 1 7 \right] } }$ , and cross-lingual structure $\tilde { \left\| 1 0 \right\| }$ over pre-training. This analysis has been extended to many downstream tasks, including text summarization $\pmb { \mathbb { B 3 } }$ , machine/speech translation [81, 86, 92], and various NLP tasks [36, 61].
32
+
33
+ Forgetting in Language Models: There has also been work studying memory degradation (forgetting) in language models. Catastrophic forgetting or catastrophic interference, first reported in $\frac { 1 } { 1 5 9 } [ \overbrace { 7 7 } ]$ , studies how neural networks tend to forget the information from previous trained tasks or training batches, when trained on new data. This provides a key challenge for continual learning (or life-long learning) [19], where the goal is to gradually learn from a single pass over a, typically very large, stream of data. A number of mechanisms have been proposed for increasing robustness against catastrophic forgetting [2, 18, 24, 49, 58, 82]. There is also a growing body of work demonstrating that both model and dataset scale can make models more resistant to forgetting $\pm \pm \pm \pm \pm$ , as well as work characterizing how forgetting naturally occurs in image classifiers $\boxed { 9 0 }$ and how forgetting can improve training efficiency [5]. Machine unlearning is a technique that forces a trained model to forget a previously learned sample [12, 54], which is primarily motivated by data protection and privacy regulations [37, 57, 78, 91]. Our work is unique in its focus on measuring forgetting during training, and quantifying how it varies with scale.
34
+
35
+ Scaling Laws: We have consistently seen performance gains by scaling model size [3, 22, 73, 76, 83], and scale itself has been known to push internal model behavior away from classical bias-variance regimes $\lVert \overline { { 6 7 } } \rVert$ . Recent efforts have focused on trying to model the scaling laws for language models, including data and model size $\textcircled { 1 4 4 } , \textcircled { 7 9 } \textcircled { }$ , applications to transfer learning $\overline { { \vert 4 0 \vert } }$ , routing networks $\pm \pmb { \left[ 2 3 \right] }$ , and various autoregressive generative tasks $\textcircled { \ 3 9 }$ . While the bulk of work in scaling laws has been empirical, an interesting line of work focuses on theoretically explaining neural scaling laws $\pmb { \mathbb { B } } ] |$ . Most scaling laws focus only on cross-entropy loss, while we study memorization (defined in $\ S \ O 3 )$ .
36
+
37
+ # 3 Experimental Setup
38
+
39
+ In order to perform a large-scale study of the dynamics of memorization over training, our memorization metric must be reasonably easy to compute but also precise enough to tell us how much the model will actually remember from the training data. Label memorization $\mathbb { I } \mathbb { Z } \mathbb { P } \mathbb { \underline { { 9 4 } } } \mathbb { I } \mathbb { Z }$ is an ideal candidate, because it has consistently provided theoretical insight into underlying properties of neural networks, remains applicable in empirical settings, and is relatively cheap to compute. We formulate our metric as an analog of label memorization for self-supervised settings.
40
+
41
+ Definition 1 Let $V$ denote the vocabulary size. Let $C$ denote a set of contexts, which can be thought of as a list of tuples $( s , y )$ where $s$ is an input context (incomplete block of text) and $y$ is the index of the ground truth token in the vocabulary that completes the block of text. Let $S$ denote the set of input contexts, and let $f : S \to \mathbb { R } ^ { V }$ denote a language model. A context $c = ( s , y ) \in C$ is memorized $i f$ $\operatorname { a r g m a x } ( f ( s ) ) = y .$ .
42
+
43
+ Note that a single word can appear as the ground-truth token for multiple contexts. For a given set of contexts $C$ (i.e a given training dataset), we can then analyze the proportion of memorized contexts
44
+
45
+ $$
46
+ M ( f ) = { \frac { \sum _ { ( s , y ) \in C } 1 \left\{ \operatorname { a r g m a x } ( f ( s ) ) = y \right\} } { | C | } }
47
+ $$
48
+
49
+ We refer to this as exact memorization, although it can also be seen as accuracy since we measure how often the argmax of the language model matches the ground truth token. Throughout this work, when we refer to memorization, we will be referring to Definition 1 unless we specify otherwise.
50
+
51
+ We define $\tau$ to be a threshold value for $M ( f )$ , and denote $T ( N , \tau )$ as the minimal number of times a language model $f$ with $N$ parameter needs to see each training datapoint in order to satisfy $M ( f ) \geq { \bar { \tau } }$ . When leveraging bigger datasets, models are unable to train for multiple epochs, so we instead consider memorization on a per-update basis. We introduce $M _ { u p d a t e } ( f , U )$ as the memorization on the batch of data on which the model performs the $U$ ’th gradient descent update, and define $T _ { u p d a t e } ( N , \tau )$ as the minimal number of gradient descent updates a language model with $N$ parameters needs to perform, to satisfy $M _ { u p d a t e } ( { \bar { f } } , U ) \geq \tau$ .
52
+
53
+ Previous work analyzing language modeling memorization defines memorization differently. Motivated by privacy concerns, both $\mathbf { \bar { \Pi } }$ and $\boxed { 1 6 }$ define memorization from a training data extraction standpoint, in which a string $s$ is extractable if it can be produced by interacting with the language model. More specifically, $\boxed { 1 5 }$ defines a string $s$ as being $k$ -eidetic memorized if it is extractable and appears in at most $k$ training examples. [16] defines a string $s$ as $k$ -memorized if the language model can produce it via prompting with $k$ tokens of context from training data. This definition only works for causal language modeling because of the dependence on prompting with training data; for masked language modeling $\boxed { 1 6 }$ uses Definition $\bigstar$ above. Note that if an example is exactly memorized, it is extractable by definition. In other words, both the set of $k$ -eidetic memorized tokens and the set of $k$ -memorized tokens contain the set of exactly memorized tokens (formally, different exactly memorized tokens may be contained in different sets, depending on $k$ ). Therefore, analyzing exact memorization gives a type of lower bound on the $k$ -eidetic memorization and $k$ -memorization. In a different line of work motivated by estimating the influence of individual training examples, $\mathbf { \| 9 5 \| }$ defines a training example $x$ as memorized if the difference in expected model performance (where model performance is defined as $M ( f )$ above) over subsets of data including $x$ and subsets of data not including $x$ , is sufficiently large. This definition pulls from previous work in theoretically analyzing label memorization in classification settings $\pmb { \left[ 2 7 \right] }$ .
54
+
55
+ Model Architectures: We replicate publicly available references for Transformer language model architectures $\mathbb { D } \mathbb { D } \mathbb { 6 } ]$ . We use the 125M, 355M, 1.3B, 2.7B, 6.7B, and 13B model configurations (see $\ S \ A . 4$ for more architectural and training details). We study both causal and masked language models. We train using the FairSeq framework $\lVert \overline { { 6 9 } } \rVert$ with PyTorch $\mathbf { \dot { \textmu } }$ as the underlying framework. For our larger models, we use the fully sharded data-parallel implementation available in FairScale $\bigstar$ and use Aim experiment tracking $\boxed { 6 }$ .
56
+
57
+ Datasets: We use two existing datasets across all our experiments: the WIKITEXT-103 benchmark containing around 103 million tokens $\lVert \overline { { 6 2 } } \rVert$ , and the RoBERTa corpus $\lVert \overline { { 5 5 } } \rVert$ used to train the original
58
+
59
+ RoBERTa model, containing around 39 billion tokens (we refer to this as the ROBERTA dataset). We use both datasets in section 4, and primarily use WIKITEXT-103 in other sections due to computational restrictions.
60
+
61
+ # 4 Larger Language Models Memorize Faster
62
+
63
+ Larger neural language models are known to be more sample efficient and require fewer optimization steps to reach the same performance $\pm \pm$ while also converging faster $| | \overline { { 5 2 } } | |$ , where performance is usually defined as test perplexity. In this section, we study $T ( N , \tau )$ on the training set as a function of $N$ to answer this question.
64
+
65
+ ![](images/0ff82c6ef977f60b79ad1798d13f4577991f66442635ede43b62302e8d2e260b.jpg)
66
+ Figure 1: We show $T ( N , \tau )$ , which is the number of times a language model needs to see each training example before memorizing $\tau$ fraction of the training data, as a function of model size $N$ . Result are for causal language modeling on WIKITEXT103, right plot is on log-log scale. Note that generally larger models memorize faster, regardless of $\tau$ .
67
+
68
+ In the left plot of Figure 1, we fix a memorization threshold $\tau = 0 . 9$ and examine $T ( N , \tau )$ as we increase $N$ . The larger language models need to see each training datapoint fewer times to achieve $9 0 \%$ exact memorization of the training set; in other words, $T ( N , 0 . 9 )$ is monotonically decreasing in $N$ . When we vary $\tau$ between 0.4 and 0.95 in the right plot of Figure 1, we still observe that $T ( N , \tau )$ is generally decreasing with $N . ^ { 3 }$ For fixed $N$ , $T ( \bar { N } , \bar { \tau } )$ is increasing in $\tau$ , which is expected since memorizing more of the training set requires training the model for more epochs. More interestingly, increasing $\tau$ smoothly transitions $T ( N , \bar { \tau } )$ from constant in $N$ , to exponentially decreasing in $N$ (the axes are on a log-log scale).
69
+
70
+ ![](images/3eb64d73e4ac3c4ef104f329878521fd1abd643cb8df35e31eaf4c0f999bd2f5.jpg)
71
+ Figure 2: $T ( N , \tau )$ as a function of $N$ (shown on log-log scale), for various values of $\tau$ in masked language modeling on WIKITEXT103. We show that larger models initially memorize training data slower, but reach high proportions of training data memorization faster.
72
+
73
+ # 4.1 Dependence on Language Modeling Task and Dataset Size
74
+
75
+ To investigate the dependence of our observations on the particular language modeling task, we repeat this analysis for the masked language modeling task on WIKITEXT103 with mask probability 0.15. Unlike in causal language modeling, Figure 2 shows that $T ( N , \tau )$ is not monotonically decreasing in $N$ for lower values of $\tau$ , and is monotonically decreasing in $N$ for higher values of $\tau$ , where the phase transition4 between these two regimes occurs between $\tau = 0 . 6$ and $\tau = 0 . 7$ . Smaller models memorize the training data quicker initially and slower in the long run (e.g., right plot of Figure 11)
76
+
77
+ ![](images/82c9fb6f2894343c69161e1a5bfba477788864eec33fd01e8e7e79f1ece781a1.jpg)
78
+ Figure 3: We show $T _ { u p d a t e } ( N , \tau )$ , which is the number of gradient descent updates $U$ a language model needs to perform before memorizing $\tau$ fraction of the data given on the $U$ ’th update, as a function of model size $N$ . Result are for causal (Left) and masked (Right) language modeling on the ROBERTA dataset, on a log-log scale. We show that larger models memorize faster, regardless of $\tau$ .
79
+
80
+ Language model training is heavily dependent on the dataset size $\pm \pm$ , and therefore we expect $M ( f )$ to be similarly impacted. In Figure $\textcircled { 3 }$ we analyze training set memorization on the much bigger ROBERTA dataset for both masked and causal language modeling. With large datasets such as ROBERTA dataset, it becomes infeasible to perform multiple epochs and evaluate memorization on the entire training set, especially when training larger models. Consequently, we focus on smaller values of $\tau$ and investigate the number of gradient descent updates it takes to reach memorization thresholds, i.e., $T _ { u p d a t e } ( N , \tau )$ . In Figure $3$ we observe a similar trend as Figure $^ { 1 , }$ where $T _ { u p d a t e } ( N , \tau )$ is monotonically decreasing with $N$ for various $\tau$ , in both masked and causal language modeling. Unlike with WIKITEXT103, masked language modeling does not have a phase transition for $\tau$ .
81
+
82
+ # 4.2 Why Do Larger Models Memorize Faster?
83
+
84
+ A natural question at this point is to ask why larger models memorize faster? Typically, memorization is associated with overfitting, which offers a potentially simple explanation. In order to disentangle memorization from overfitting, we examine memorization before overfitting occurs, where we define overfitting occurring as the first epoch when the perplexity of the language model on a validation set increases. Surprisingly, we see in Figure 4 that as we increase the number of parameters, memorization before overfitting generally increases, indicating that overfitting by itself cannot completely explain the properties of memorization dynamics as model scale increases.
85
+
86
+ The learning rate is not constant across our training configurations. Intuitively, larger learning rates should lead to quicker memorization. To investigate to what extent our results can be explained by learning rate, we take a subset of the architectures available above and train on the WIKITEXT103 dataset across a standard range of learning rates while measuring memorization, in Figure $\boxed { 5 }$ Even if we fix a learning rate, larger models reach 0.9 memorization faster, suggesting that our results are not caused solely by differences in learning rates. Interestingly, sensitivity to learning rate generally decreases as we increase the model size. We also notice in Figure $\boxed { 5 }$ that $T ( N , \tau )$ goes down initially (for low LRs) and eventually rises (for high LRs), and as the long as the chosen learning rate places us near the lowest point on the curve, the memorization dynamics do not change significantly (note that axes are on log-scale). This result is consistent with the growing intuition that for neural language models past a particular scale, the learning rate is not a significant hyperparameter $[ \textcircled { 4 4 } ]$
87
+
88
+ ![](images/ec70cd52190fe43255205f2ad227db74d6f86964781b4dcbd4449a2cfb3a512e.jpg)
89
+ Figure 4: Proportion of training data memorized $M ( f )$ before overfitting, as a function of model size $N$ (plotted on a log scale). Results are for causal (left) and masked (right) language modeling on WIKITEXT103. Note that larger models memorize more before overfitting.
90
+
91
+ ![](images/515bf202c5421358369e131665850dec51c1282c4bf294511189795826cd32e3.jpg)
92
+ Figure 5: Examining the effect of learning rate (LR) on number of times model needs to see each training example in order to reach 0.9 proportion of training data memorization $T ( N , 0 . 9 )$ . Each line corresponds to a different model size performing causal language modeling on WIKITEXT103. We demonstrate that larger models memorize faster for a fixed learning rate.
93
+
94
+ Exhaustively searching all such possible factors is intractable, and providing a complete explanation for why larger models memorize faster is outside the scope of this work. Instead, in the following sections, we present studies that we hope will expand the toolkit for answering such questions.
95
+
96
+ # 4.3 Memorization via. Unique Identifiers
97
+
98
+ Recent work studies how to use external memory to improve performance [11, 35, 46, 87]. In this subsection, we question whether such architecture changes are necessary. Motivated by information retrieval systems, we take a simple approach — we prepend a unique identifier to every example in the training set and examine whether memorization speed increases. Specifically, we fix the language modeling task as causal language modeling on WIKITEXT103 with the 125M parameter model, and in front of every training example, we insert the string document ID <unique_id> where unique_id is a unique integer, one for each training context. In order to utilize all these unique integers, we must add them to the dictionary of tokens, which causes a significant increase in the model size since the last layer in the language model must have an output dimension equal to the size of the dictionary. Therefore, any change in $M ( f )$ dynamics could be attributed to the extra parameters we add from increasing dictionary size. To control for this, we first examine the effect of just increasing dictionary size (without using any of the added tokens). Then, we utilize those added tokens to prepend every training example and observe the change in $M ( f )$ dynamics. In Figure 6, we see that increasing the dictionary size does improve the speed of memorization. Even though we previously demonstrated that larger models memorize faster, this is still surprising considering that we do not increase parameter size in a significant way — we are effectively adding fake tokens to the dictionary. Moreover, when we leverage those added tokens to identify training examples uniquely, we see yet another gain in memorization, although prompting using a document ID shifts memorization dynamics away from being monotonically increasing over time.
99
+
100
+ ![](images/cb4a6cb2b5a3ec549dac3cf9141a75aa8fb8b9eb9bb073829aeb63a0d30b1f14.jpg)
101
+ Figure 6: The impact of adding unique identifiers to training examples on memorization $M ( f )$ training dynamics for causal language modeling (125M) on WIKITEXT103. The green line is the original 125M model. The orange line is the model after adding unique identifiers to the dictionary (which increases model size). The blue line prepends these unique identifiers for each training example. Note that adding unique identifiers leads to faster memorization of training data.
102
+
103
+ # 4.4 Memorization Through the Lens of Parts of Speech
104
+
105
+ ![](images/23919e2090bbfcd465c2aa0dd03da3a6f80228d7d7ca9cc4408316ac70cd4b15.jpg)
106
+ Figure 7: The ratios $R ( p )$ (Left) and $R _ { m e m } ( p )$ (Right) over training. $R ( p )$ represents proportion of POS correctly memorized (the language model outputs the right POS, but not necessarily the correct word). $R _ { m e m } ( p )$ represents the proportion of exactly memorized tokens for a particular POS $p$ . Results are for causal language modeling (355M) on WIKITEXT103. In both plots, we consider numerals, proper nouns, verbs, nouns, and adjectives as potential parts of speech (i.e., values for $p$ ). We show that nouns and numerals are memorized faster than other parts of speech.
107
+
108
+ In the previous section, we showed that a unique identifier enhances memorization. Regular text also contains strong proxies to unique identifiers in the form of numerals and proper nouns. Motivated by this, we study syntactic features of memories using part-of-speech (POS) tagging.5 We track the ratio $R ( p )$ of the number of positions for which the part of speech $p$ was correctly predicted to the total number of tokens in the ground truth tagged with that part-of-speech $p$ (left plot in Figure $7 . \dot { }$ . In the right plot of Figure $^ { 7 }$ we show a similar ratio, denoted $R _ { m e m } ( p )$ , but the numerator only considers the tokens that are also exactly memorized. The correctly predicted part of speech does not necessarily imply exact memorization, which is clearly illustrated by Figure 7 where we see the language model memorizing parts of speech faster than the exact value of the token. While all parts of speech are eventually memorized, some parts of speech are memorized faster, which aligns with previous work $\pmb { \mathbb { Z } } 0$ . However, unlike previous work6, we find that nouns, proper nouns, and numerals are memorized noticeably faster than verbs and adjectives, both in terms of $R ( p )$ and $R _ { m e m } ( p )$ . This has potential implications for privacy, since sensitive information is likely to be a noun/proper noun/numeral. Our findings also very loosely align with work studying child language acquisition $\lVert 2 9 \rVert$ .
109
+
110
+ # 5 Forgetting Curves in Language Models
111
+
112
+ This section studies the dual of memorization — forgetting in language models. Inspired by the forgetting curve hypothesis, according to which human memory declines over time when there is no attempt to retain it $\boxed { \boxed { 5 6 } }$ , we are interested in understanding the dynamics of memory degradation in language models.
113
+
114
+ We first choose a batch of data not available in the training set, i.e. a batch of data from a validation set. We refer to this batch of data as the special batch. We then take a checkpoint from model training, plug in the special batch so that the model can train on it, and resume standard training on the training set. We then evaluate how memorization degrades on the special batch and analyze the various factors the forgetting curve may depend on. We use the entire validation set as the special batch throughout this section. The special batch is only seen once when it is immediately introduced.7
115
+
116
+ ![](images/d6e9f0977724c0cdc87a852d353d43599c81891a3d502b30466017c3612cb5b9.jpg)
117
+ Figure 8: Left: forgetting curve for causal language modeling (2.7B) on WIKITEXT103. The dashed horizontal line indicates the lowest proportion of special batch data memorized throughout training, i.e., the forgetting baseline. Right: forgetting baseline as a function of model size $N$ (plotted on log scale). We show that as model scale increases, the forgetting baseline value increases.
118
+
119
+ In the left plot of Figure 8, we show the forgetting curve for the 2.7B model. Exact memorization on the special batch degrades quickly at first, but slows down exponentially as we continue training (see Figure 15 in $\ S [ \bar { \mathrm { A } } . 2 . 2 ]$ . In other words, the forgetting curve on the special batch seems to approach a baseline — we refer to this trend as the forgetting baseline. We approximate the forgetting baseline by looking at the lowest memorization value on the special batch throughout training.
120
+
121
+ We show the forgetting baseline as a function of the model scale in the right plot of Figure $\textcircled { 8 }$ We see that the numerical value for the baseline is monotonically increasing with the model scale. This implies that larger models forget less, aligning with recent work studying catastrophic forgetting on image classification tasks $\overline { { \| 7 5 \| } }$ . This is beneficial because larger models can leverage more information from previous tasks; however, from a privacy perspective, this is not ideal because it implies larger models may be potentially retaining more sensitive information from training data.
122
+
123
+ We also investigate the sensitivity of the forgetting baseline on data batch order. In Figure 9, we perform the same forgetting curve analysis described above but start the analysis at different training checkpoints (we start at the 14th, 39th, and 63rd epochs). This way, we alter the order of the data batches given to the model (since the special batch will appear in a different place in the global order of data batches given to the model) without drastically changing the experimental setup. We observe that the forgetting baseline is not sensitive to data batch order9.
124
+
125
+ ![](images/ad4ca8f6fbd433c6ff3c43c31aed25d9614722f1a7f2ed626172bc8c9799ae85.jpg)
126
+ Figure 9: We empirically show that the forgetting baseline does not depend on data batch ordering. We inject the special batch into the training set at the 14th, 39th, and 63rd epochs, and evaluate proportion of special batch data memorized as we continue training. Results are for causal language modeling (125M) on WIKITEXT103.
127
+
128
+ Motivated by replay methods from continual learning (see $\mathbb { \lVert 2 4 \rVert }$ for a survey) and work in promoting retention memories through repetition in both humans $\boxed { 4 5 } \boxed { 6 8 } \boxed { 8 4 }$ and neural models $\boxed { 5 }$ , in Figure $\checkmark$ we study the effect of repetition (left) and spaced repetition (right) on the forgetting baseline. In the left plot, we inject the special batch into the training set multiple times before continuing training on the training set alone. We observe that the forgetting baseline is monotonically increasing as a function of repetition frequency (differences in the baseline value are on the order of $1 0 ^ { - 2 }$ ). To study the spaced repetition, we periodically inject the held-out set into the training set, train on it once, and then continue training on the training set alone. We see in the right plot of Figure $1 0$ that spaced repetition incurs minimal effect on the forgetting baseline (on the order of $1 0 ^ { - 3 }$ ), independent of the length of spacing between the repetitions.
129
+
130
+ ![](images/303fb4077f562cdf0a7321fd30da562d5c062998b1c3f0361f6f401a078919ad.jpg)
131
+ Figure 10: Effect of repeated injection (Left) and spaced repetition (Right) on special batch memorization. Results are for causal language modeling (125M) on WIKITEXT103. The solid upper curve represents the training set memorization. We show that repeated injection increases the forgetting baseline, whereas spaced repetition has minimal effect.
132
+
133
+ An exciting direction for future work will be to understand the structure of the baseline — for example, understanding what types of tokens (parts of speech, synonyms, facts, syntax) are memorized in the baseline and the overlap of tokens memorized in the baseline with tokens in the training set.
134
+
135
+ # 6 Conclusions and Discussion
136
+
137
+ We study the properties of memorization dynamics over language model training and demonstrate that larger models memorize faster. We also measure the properties of forgetting curves and surprisingly find that forgetting reaches a baseline, which again increases with the model scale. Combined with memorization analyses that expose the unintuitive behavior of language models, we hope to motivate considering memorization as a critical metric when increasing language model scale.
138
+
139
+ Most work studying memorization in language modeling is primarily motivated by privacy (see $\ S 2 )$ While theoretically, there are well-established frameworks to quantify privacy such as differential privacy $\lVert 2 5 \rVert$ , empirical privacy in language modeling is not well-defined — does memorizing common knowledge count as information leakage? Does outputting a synonym count as harmful memorization? As per our Definition $\bigtriangledown$ we implicitly focus on information that is sensitive if outputted verbatim (phone numbers, SSNs, addresses, medical diagnoses, etc.), rather than capturing all aspects of privacy. It is also known that text data used for training language models contain certain biases and stereotypes (e.g., $\left[ 3 2 \right] ) ,$ ); therefore, our work has similar implications for how long language models can train before they definitively memorize these biases from training data.
140
+
141
+ We also hope our work highlights the importance of analyzing memorization dynamics as we scale up language models, instead of only reporting cross entropy. Cross-entropy loss and memorization capture different behavior — for example, in many of our memory degradation experiments, even though memorization approaches a baseline, we observe that perplexity is still increasing (see Figure $^ { 1 4 }$ in $\ S \ \mathbf { A } . 2$ for an example). This implies that the model is becoming unconfident about its exact predictions, which we can only conclude because we inspect both loss and memorization. More importantly, the forgetting baseline behavior would be entirely obscured if we did not inspect memorization dynamics. Similarly, there are multiple instances where we uncover interesting behavior because we focus on memorization dynamics (§ 4.4, § 4.3, $\ S \boxed { \mathbf { A } . 3 }$ , rather than focusing only on cross-entropy loss.
142
+
143
+ # 7 Acknowledgements
144
+
145
+ The authors would like to thank Adina Williams, Chuan Guo, Alex Sablayrolles, and Pierre Stock, for helpful discussions throughout the course of this project. The authors would also like to researchers at FAIR who commented on or otherwise supported this project, including Shashank Shekhar, Candace Ross, Rebecca Qian, Dieuwke Hupkes, and Gargi Ghosh.
146
+
147
+ # References
148
+
149
+ [1] Alessandro Achille, Matteo Rovere, and Stefano Soatto. Critical learning periods in deep networks. In International Conference on Learning Representations, 2018.
150
+ [2] Armen Aghajanyan, Akshat Shrivastava, Anchit Gupta, Naman Goyal, Luke Zettlemoyer, and Sonal Gupta. Better fine-tuning by reducing representational collapse. arXiv preprint arXiv:2008.03156, 2020.
151
+ [3] Armen Aghajanyan, Bernie Huang, Candace Ross, Vladimir Karpukhin, Hu Xu, Naman Goyal, Dmytro Okhonko, Mandar Joshi, Gargi Ghosh, Mike Lewis, et al. Cm3: A causal masked multimodal model of the internet. arXiv preprint arXiv:2201.07520, 2022.
152
+ [4] Badr AlKhamissi, Millicent Li, Asli Celikyilmaz, Mona Diab, and Marjan Ghazvininejad. A review on language models as knowledge bases. arXiv preprint arXiv:2204.06031, 2022.
153
+ [5] Hadi Amiri, Timothy Miller, and Guergana Savova. Repeat before forgetting: Spaced repetition for efficient and effective training of neural networks. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 2401–2410, 2017.
154
+ [6] Gor Arakelyan, Gevorg Soghomonyan, and The Aim team. Aim, 6 2020. URL https: //github.com/aimhubio/aim.
155
+ [7] Mikel Artetxe, Shruti Bhosale, Naman Goyal, Todor Mihaylov, Myle Ott, Sam Shleifer, Xi Victoria Lin, Jingfei Du, Srinivasan Iyer, Ramakanth Pasunuru, et al. Efficient large scale language modeling with mixtures of experts. arXiv preprint arXiv:2112.10684, 2021.
156
+ [8] Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma. Explaining neural scaling laws. arXiv preprint arXiv:2102.06701, 2021.
157
+ [9] Mandeep Baines, Shruti Bhosale, Vittorio Caggiano, Naman Goyal, Siddharth Goyal, Myle Ott, Benjamin Lefaudeux, Vitaliy Liptchinsky, Mike Rabbat, Sam Sheiffer, Anjali Sridhar, and Min Xu. Fairscale: A general purpose modular pytorch library for high performance and large scale training. https://github.com/facebookresearch/fairscale, 2021.
158
+
159
+ [10] Terra Blevins, Hila Gonen, and Luke Zettlemoyer. Analyzing the mono-and cross-lingual pretraining dynamics of multilingual language models. arXiv preprint arXiv:2205.11758, 2022.
160
+
161
+ [11] Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. arXiv preprint arXiv:2112.04426, 2021.
162
+
163
+ [12] Lucas Bourtoule, Varun Chandrasekaran, Christopher A Choquette-Choo, Hengrui Jia, Adelin Travers, Baiwu Zhang, David Lie, and Nicolas Papernot. Machine unlearning. In 2021 IEEE Symposium on Security and Privacy (SP), pages 141–159. IEEE, 2021.
164
+
165
+ [13] Gavin Brown, Mark Bun, Vitaly Feldman, Adam Smith, and Kunal Talwar. When is memorization of irrelevant training data necessary for high-accuracy learning? In Proceedings of the 53rd Annual ACM SIGACT Symposium on Theory of Computing, pages 123–132, 2021.
166
+
167
+ [14] Nicholas Carlini, Chang Liu, Úlfar Erlingsson, Jernej Kos, and Dawn Song. The secret sharer: Evaluating and testing unintended memorization in neural networks. In 28th USENIX Security Symposium (USENIX Security 19), pages 267–284, 2019.
168
+
169
+ [15] Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. In 30th USENIX Security Symposium (USENIX Security 21), pages 2633–2650, 2021.
170
+
171
+ [16] Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang. Quantifying memorization across neural language models. arXiv preprint arXiv:2202.07646, 2022.
172
+
173
+ [17] Tyler A. Chang and Benjamin K. Bergen. Word acquisition in neural language models. Transactions of the Association for Computational Linguistics, 10:1–16, 2022. doi: 10.1162/tacl_a_00444. URL https://aclanthology.org/2022.tacl-1.1.
174
+
175
+ [18] Sanyuan Chen, Yutai Hou, Yiming Cui, Wanxiang Che, Ting Liu, and Xiangzhan Yu. Recall and learn: Fine-tuning deep pretrained language models with less forgetting. arXiv preprint arXiv:2004.12651, 2020.
176
+
177
+ [19] Zhiyuan Chen and Bing Liu. Lifelong machine learning. Synthesis Lectures on Artificial Intelligence and Machine Learning, 12(3):1–207, 2018.
178
+
179
+ [20] Cheng-Han Chiang, Sung-Feng Huang, and Hung-yi Lee. Pretrained language model embryology: The birth of albert. arXiv preprint arXiv:2010.02480, 2020.
180
+
181
+ [21] Leshem Choshen, Guy Hacohen, Daphna Weinshall, and Omri Abend. The grammar-learning trajectories of neural language models. arXiv preprint arXiv:2109.06096, 2021.
182
+
183
+ [22] 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.
184
+
185
+ [23] Aidan Clark, Diego de las Casas, Aurelia Guy, Arthur Mensch, Michela Paganini, Jordan Hoffmann, Bogdan Damoc, Blake Hechtman, Trevor Cai, Sebastian Borgeaud, et al. Unified scaling laws for routed language models. arXiv preprint arXiv:2202.01169, 2022.
186
+
187
+ [24] Matthias Delange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, Greg Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
188
+
189
+ [25] Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. Calibrating noise to sensitivity in private data analysis. In Theory of cryptography conference, pages 265–284. Springer, 2006.
190
+
191
+ [26] Vitaly Feldman. Does learning require memorization. A short tale about a long tail. CoRR, abs/1906.05271, 2019.
192
+
193
+ [27] Vitaly Feldman. Does Learning Require Memorization? A Short Tale about a Long Tail. arXiv:1906.05271 [cs, stat], January 2021. URL http://arxiv.org/abs/1906.05271. arXiv: 1906.05271.
194
+
195
+ [28] Vitaly Feldman and Chiyuan Zhang. What neural networks memorize and why: Discovering the long tail via influence estimation. Advances in Neural Information Processing Systems, 33: 2881–2891, 2020.
196
+
197
+ [29] Michael Fleischman and Deb Roy. Why verbs are harder to learn than nouns: Initial insights from a computational model of intention recognition in situated word learning. In 27th Annual Meeting of the Cognitive Science Society, Stresa, Italy, 2005.
198
+
199
+ [30] Jonathan Frankle, David J Schwab, and Ari S Morcos. The early phase of neural network training. arXiv preprint arXiv:2002.10365, 2020.
200
+
201
+ [31] James Franklin. The elements of statistical learning: data mining, inference and prediction. The Mathematical Intelligencer, 27(2):83–85, 2005.
202
+
203
+ [32] Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A Smith. Realtoxicityprompts: Evaluating neural toxic degeneration in language models. arXiv preprint arXiv:2009.11462, 2020.
204
+
205
+ [33] Tanya Goyal, Jiacheng Xu, Junyi Jessy Li, and Greg Durrett. Training dynamics for text summarization models. arXiv preprint arXiv:2110.08370, 2021.
206
+
207
+ [34] Guy Gur-Ari, Daniel A Roberts, and Ethan Dyer. Gradient descent happens in a tiny subspace. arXiv preprint arXiv:1812.04754, 2018.
208
+
209
+ [35] Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. Realm: Retrieval-augmented language model pre-training. arXiv preprint arXiv:2002.08909, 2020.
210
+
211
+ [36] Yaru Hao, Li Dong, Furu Wei, and Ke Xu. Investigating learning dynamics of BERT finetuning. In Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing, pages 87–92, Suzhou, China, December 2020. Association for Computational Linguistics. URL https://aclanthology.org/2020.aacl-main.11.
212
+
213
+ [37] Elizabeth Liz Harding, Jarno J Vanto, Reece Clark, L Hannah Ji, and Sara C Ainsworth. Understanding the scope and impact of the california consumer privacy act of 2018. Journal of Data Protection & Privacy, 2(3):234–253, 2019.
214
+
215
+ [38] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
216
+
217
+ [39] Tom Henighan, Jared Kaplan, Mor Katz, Mark Chen, Christopher Hesse, Jacob Jackson, Heewoo Jun, Tom B Brown, Prafulla Dhariwal, Scott Gray, et al. Scaling laws for autoregressive generative modeling. arXiv preprint arXiv:2010.14701, 2020.
218
+
219
+ [40] Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021.
220
+
221
+ [41] Sorami Hisamoto, Matt Post, and Kevin Duh. Membership inference attacks on sequence-tosequence models. arXiv preprint arXiv:1904.05506, 2019.
222
+
223
+ [42] Matthew Honnibal and Ines Montani. spaCy 3: Natural language understanding with Bloom embeddings, convolutional neural networks and incremental parsing. To appear, 2022.
224
+
225
+ [43] Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Yejin Bang, Andrea Madotto, and Pascale Fung. Survey of hallucination in natural language generation. arXiv preprint arXiv:2202.03629, 2022.
226
+
227
+ [44] Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling Laws for Neural Language Models. arXiv:2001.08361 [cs, stat], January 2020. URL http://arxiv.org/abs/2001. 08361. arXiv: 2001.08361.
228
+
229
+ [45] Jeffrey D Karpicke and Henry L Roediger III. Expanding retrieval practice promotes short-term retention, but equally spaced retrieval enhances long-term retention. Journal of experimental psychology: learning, memory, and cognition, 33(4):704, 2007.
230
+
231
+ [46] Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. arXiv preprint arXiv:1911.00172, 2019.
232
+
233
+ [47] Eugene Kharitonov, Marco Baroni, and Dieuwke Hupkes. How bpe affects memorization in transformers. arXiv preprint arXiv:2110.02782, 2021.
234
+
235
+ [48] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
236
+
237
+ [49] James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 114(13):3521–3526, 2017.
238
+
239
+ [50] Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris Callison-Burch, and Nicholas Carlini. Deduplicating training data makes language models better. arXiv preprint arXiv:2107.06499, 2021.
240
+
241
+ [51] Xuechen Li, Florian Tramer, Percy Liang, and Tatsunori Hashimoto. Large language models can be strong differentially private learners. arXiv preprint arXiv:2110.05679, 2021.
242
+
243
+ [52] Zhuohan Li, Eric Wallace, Sheng Shen, Kevin Lin, Kurt Keutzer, Dan Klein, and Joey Gonzalez. Train big, then compress: Rethinking model size for efficient training and inference of transformers. In International Conference on Machine Learning, pages 5958–5968. PMLR, 2020.
244
+
245
+ [53] Leo Z Liu, Yizhong Wang, Jungo Kasai, Hannaneh Hajishirzi, and Noah A Smith. Probing across time: What does roberta know and when? arXiv preprint arXiv:2104.07885, 2021.
246
+
247
+ [54] Yang Liu, Zhuo Ma, Ximeng Liu, Jian Liu, Zhongyuan Jiang, Jianfeng Ma, Philip Yu, and Kui Ren. Learn to forget: Machine unlearning via neuron masking. arXiv preprint arXiv:2003.10933, 2020.
248
+
249
+ [55] 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 e-prints, July 2019. URL https://arxiv.org/abs/ 1907.11692v1.
250
+
251
+ [56] Geoffrey R Loftus. Evaluating forgetting curves. Journal of Experimental Psychology: Learning, Memory, and Cognition, 11(2):397, 1985.
252
+
253
+ [57] Alessandro Mantelero. The eu proposal for a general data protection regulation and the roots of the ‘right to be forgotten’. Computer Law & Security Review, 29(3):229–235, 2013.
254
+
255
+ [58] Wojciech Masarczyk, Kamil Deja, and Tomasz Trzcinski. On robustness of generative representations against catastrophic forgetting. In International Conference on Neural Information Processing, pages 325–333. Springer, 2021.
256
+
257
+ [59] Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation, volume 24, pages 109–165. Elsevier, 1989.
258
+
259
+ [60] R Thomas McCoy, Paul Smolensky, Tal Linzen, Jianfeng Gao, and Asli Celikyilmaz. How much do language models copy from their training data? evaluating linguistic novelty in text generation using raven. arXiv preprint arXiv:2111.09509, 2021.
260
+
261
+ [61] Amil Merchant, Elahe Rahimtoroghi, Ellie Pavlick, and Ian Tenney. What happens to BERT embeddings during fine-tuning? In Proceedings of the Third BlackboxNLP Workshop on Analyzing and Interpreting Neural Networks for NLP, pages 33–44, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.blackboxnlp-1.4. URL https://aclanthology.org/2020.blackboxnlp-1.4.
262
+
263
+ [62] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. ArXiv, abs/1609.07843, 2017.
264
+
265
+ [63] Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
266
+
267
+ [64] Fatemehsadat Mireshghallah, Kartik Goyal, Archit Uniyal, Taylor Berg-Kirkpatrick, and Reza Shokri. Quantifying privacy risks of masked language models using membership inference attacks. arXiv preprint arXiv:2203.03929, 2022.
268
+
269
+ [65] Seyed Iman Mirzadeh, Arslan Chaudhry, Huiyi Hu, Razvan Pascanu, Dilan Gorur, and Mehrdad Farajtabar. Wide neural networks forget less catastrophically. arXiv preprint arXiv:2110.11526, 2021.
270
+
271
+ [66] Ari Morcos, Maithra Raghu, and Samy Bengio. Insights on representational similarity in neural networks with canonical correlation. Advances in Neural Information Processing Systems, 31, 2018.
272
+
273
+ [67] Preetum Nakkiran, Gal Kaplun, Yamini Bansal, Tristan Yang, Boaz Barak, and Ilya Sutskever. Deep double descent: Where bigger models and more data hurt. Journal of Statistical Mechanics: Theory and Experiment, 2021(12):124003, 2021.
274
+
275
+ [68] Shiri Oren, Charlene Willerton, and Jeff Small. Effects of spaced retrieval training on semantic memory in alzheimer’s disease: A systematic review. Journal of Speech, Language and Hearing Research (Online), 57(1):247, 2014.
276
+
277
+ [69] Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. arXiv preprint arXiv:1904.01038, 2019.
278
+
279
+ [70] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32:8026–8037, 2019.
280
+
281
+ [71] Fabio Petroni, Tim Rocktäschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. Language models as knowledge bases? arXiv preprint arXiv:1909.01066, 2019.
282
+
283
+ [72] Vinaychandran Pondenkandath, Michele Alberti, Sammer Puran, Rolf Ingold, and Marcus Liwicki. Leveraging random label memorization for unsupervised pre-training. arXiv preprint arXiv:1811.01640, 2018.
284
+
285
+ [73] Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
286
+
287
+ [74] Maithra Raghu, Justin Gilmer, Jason Yosinski, and Jascha Sohl-Dickstein. Svcca: Singular vector canonical correlation analysis for deep learning dynamics and interpretability. Advances in neural information processing systems, 30, 2017.
288
+
289
+ [75] Vinay Venkatesh Ramasesh, Aitor Lewkowycz, and Ethan Dyer. Effect of scale on catastrophic forgetting in neural networks. In International Conference on Learning Representations, 2021.
290
+
291
+ [76] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021.
292
+
293
+ [77] Roger Ratcliff. Connectionist models of recognition memory: Constraints imposed by learning and forgetting functions. Psychological Review, pages 285–308, 1990.
294
+
295
+ [78] General Data Protection Regulation. General data protection regulation (gdpr). Intersoft Consulting, Accessed in October, 24(1), 2018.
296
+
297
+ [79] Jonathan S Rosenfeld, Amir Rosenfeld, Yonatan Belinkov, and Nir Shavit. A constructive prediction of the generalization error across scales. arXiv preprint arXiv:1909.12673, 2019.
298
+
299
+ [80] Naomi Saphra and Adam Lopez. Understanding learning dynamics of language models with svcca. arXiv preprint arXiv:1811.00225, 2018.
300
+
301
+ [81] Beatrice Savoldi, Marco Gaido, Luisa Bentivogli, Matteo Negri, and Marco Turchi. On the dynamics of gender learning in speech translation. In Proceedings of the 4th Workshop on Gender Bias in Natural Language Processing (GeBNLP), pages 94–111, Seattle, Washington, July 2022. Association for Computational Linguistics. URL https://aclanthology.org/ 2022.gebnlp-1.12.
302
+
303
+ [82] Chenze Shao and Yang Feng. Overcoming catastrophic forgetting beyond continual learning: Balanced training for neural machine translation. arXiv preprint arXiv:2203.03910, 2022.
304
+
305
+ [83] Shaden Smith, Mostofa Patwary, Brandon Norick, Patrick LeGresley, Samyam Rajbhandari, Jared Casper, Zhun Liu, Shrimai Prabhumoye, George Zerveas, Vijay Korthikanti, et al. Using deepspeed and megatron to train megatron-turing nlg 530b, a large-scale generative language model. arXiv preprint arXiv:2201.11990, 2022.
306
+
307
+ [84] Paul Smolen, Yili Zhang, and John H Byrne. The right time to learn: mechanisms and optimization of spaced learning. Nature Reviews Neuroscience, 17(2):77–88, 2016.
308
+
309
+ [85] Congzheng Song and Vitaly Shmatikov. Auditing data provenance in text-generation models. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 196–206, 2019.
310
+
311
+ [86] Patrick Stadler, Vivien Macketanz, and Eleftherios Avramidis. Observing the learning curve of nmt systems with regard to linguistic phenomena. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: Student Research Workshop, pages 186–196, 2021.
312
+
313
+ [87] Yi Tay, Vinh Q Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, et al. Transformer memory as a differentiable search index. arXiv preprint arXiv:2202.06991, 2022.
314
+
315
+ [88] Om Thakkar, Swaroop Ramaswamy, Rajiv Mathews, and Françoise Beaufays. Understanding unintended memorization in federated learning. arXiv preprint arXiv:2006.07490, 2020.
316
+
317
+ [89] Aleena Thomas, David Ifeoluwa Adelani, Ali Davody, Aditya Mogadala, and Dietrich Klakow. Investigating the impact of pre-trained word embeddings on memorization in neural networks. In International Conference on Text, Speech, and Dialogue, pages 273–281. Springer, 2020.
318
+
319
+ [90] Mariya Toneva, Alessandro Sordoni, Remi Tachet des Combes, Adam Trischler, Yoshua Bengio, and Geoffrey J Gordon. An empirical study of example forgetting during deep neural network learning. arXiv preprint arXiv:1812.05159, 2018.
320
+
321
+ [91] Paul Voigt and Axel Von dem Bussche. The eu general data protection regulation (gdpr). A Practical Guide, 1st Ed., Cham: Springer International Publishing, 10(3152676):10–5555, 2017.
322
+
323
+ [92] Elena Voita, Rico Sennrich, and Ivan Titov. Analyzing the source and target contributions to predictions in neural machine translation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 1126–1140, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.91. URL https://aclanthology.org/2021.acl-long.91.
324
+ [93] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
325
+ [94] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv:1611.03530 [cs], February 2017. URL http://arxiv.org/abs/1611.03530. arXiv: 1611.03530.
326
+ [95] Chiyuan Zhang, Daphne Ippolito, Katherine Lee, Matthew Jagielski, Florian Tramèr, and Nicholas Carlini. Counterfactual Memorization in Neural Language Models. arXiv:2112.12938 [cs], December 2021. URL http://arxiv.org/abs/2112.12938. arXiv: 2112.12938 version: 1.
327
+ [96] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
328
+
329
+ # Checklist
330
+
331
+ 1. For all authors...
332
+
333
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The main claims in both the introduction and abstract are that (1) larger models memorize faster (where memorization is defined as per Definition $\textcircled { 3 }$ , (2) larger models memorize more before overfitting, (3) larger models forget less, and (4) models memorize nouns and numbers quicker than other parts of speech. (1) and (2) are supported by the beginning subsections in $\ S \boxed { 4 }$ (3) is supported by $\ S 5 ,$ and (4) is supported by $\ S [ \dot { 4 . 4 } ]$ Moreover, as mentioned in the introduction and abstract of this work the scope of this work includes analyzing large language models which we accomplish by analyzing language models up to 13B parameters.
334
+
335
+ (b) Did you describe the limitations of your work? [Yes] In $\ S \ 4 ,$ we discuss that while we find that larger models memorize faster, we are unable to completely explain why this is the case (although we rule out certain reasons). In $\ S \ : 5 ,$ we discuss how we are approximate the numerical value for the baseline depending however long a particular model is trained for i.e. that actual numerical values for the baseline may change slightly if training for longer; however we provide evidence that the further changes to the numerical value will be relatively small in $\ S [ \underline { { \mathbf { A } . 2 . 2 } } ]$ In $\ S [ \underline { { \mathbf { A . l . l } } } ] ,$ below where we define memorization, we discuss the limitations of the memorization definition.
336
+
337
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] This work does not develop new methods $/$ models $/$ datasets in any way, and therefore has minimal potential negative societal impacts. However, in section $6$ we discuss the implications of our analysis for privacy and ethical AI. We explain that, since our work deals with memorization dynamics over training of training data, it implicitly studies how long it takes language models memorize sensitive information (privacy perspective) or bias/stereotypes (ethical AI perspective) from training data.
338
+
339
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] The authors have read the ethics review guidelines and ensured that this work conforms to them.
340
+
341
+ 2. If you are including theoretical results...
342
+
343
+ (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]
344
+
345
+ 3. If you ran experiments...
346
+
347
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] Unfortunately, the exact code used to produce results is proprietary. However, all model configurations and training details are directly pulled from publicly available references, and described in detail in section $\ S [ \underline { { \mathbf { A . 4 } } } ]$ Similarly, while for most of our experiments we use WIKITEXT103 benchmark which is publicly available, some of our experiments run on the ROBERTA dataset which is not publicly available, and therefore, we are unable to release the exact data to re-create those experiments.
348
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] For all our of experiments, we use publicly available references to define model architectures and hyperparameters, which we describe in full detail in section $\ S [ \underline { { \mathbf { A . 4 } } } ]$
349
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to the scale of experiments we run (up to 13B parameter models experiments), many experiments are incredibly computationally expensive and we are unable to run each experiment for multiple seeds. However, since we deal with large datasets, random seed most probably has minimal effect on final model output.
350
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] In $\mathbf { \hat { \ S } } \mathbf { \boxed { A . 4 } }$ we describe the type of GPUS and the amount of GPUs used to train different model sizes. We also provide estimates of the total training time across all our experiments.
351
+
352
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
353
+
354
+ (a) If your work uses existing assets, did you cite the creators? [Yes] Since we use existing datasets to conduct experiments, we cite the creators in $\ S \bar { 3 }$ at in the Datasets section; similarly, we use the existing Transformer architecture (which we also cite in $\ S \boxed { 3 }$ in the Model Architecture section); similarly we pull most of our hyperparameter configurations from existing public resources, which we cite in $\ S \boxed { 3 }$ in the Model Architecture section.
355
+ (b) Did you mention the license of the assets? [Yes] In $\ S \ A . 4$ we mention the licenses of all assets we use.
356
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A] We create no new assets as part of this work.
357
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] Since we do not create or curate any new datasets/assets as part of this work, we do not discuss whether and how consent was obtained from people whose data we are using.
358
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] In $\mathbf { \check { \ S } } \mathbf { \boxed { A . 4 } }$ we mention that it is completely plausible the underlying data we use has sensitive or offensive information. However, analyzing the extent to which this is the case is outside the scope of the work, since we just aim to understand memorization dynamics of language models over training rather than analyze the underlying text in datasets
359
+
360
+ 5. If you used crowdsourcing or conducted research with human subjects...
361
+
362
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] We do not crowdsource or conduct research with human subjects in this work
363
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] We do not crowdsource or conduct research with human subjects in this work
364
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] We do not crowdsource or conduct research with human subjects in this work
md/dev/unb1wyXf-aC/unb1wyXf-aC.md ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Concurrent 3D super resolution on intensity and segmentation maps improves detection of structural effects in neurodegenerative disease
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We propose a new perceptual super resolution (PSR) method for 3D neuroimaging
11
+ 2 and evaluate its performance in detecting brain changes due to neurodegenerative
12
+ 3 disease. The method, concurrent super resolution and segmentation (CSRS), is
13
+ 4 trained on volumetric brain data to consistently upsample both an image intensity
14
+ 5 channel and associated segmentation labels. The simultaneous nature of the method
15
+ 6 improves not only the resolution of the images but also the resolution of associated
16
+ 7 segmentations thereby making the approach directly applicable to existing labeled
17
+ 8 datasets. One challenge to real world evaluation of SR methods such as CSRS
18
+ 9 is the lack of high resolution ground truth in the target application data: clinical
19
+ 10 neuroimages. We therefore evaluate CSRS effectiveness in an adjacent, clinically
20
+ 11 relevant signal detection problem: quantifying cross-sectional and longitudinal
21
+ 12 change across a set of phenotypically heterogeneous but related disorders that
22
+ 13 exhibit known and differentiable patterns of brain atrophy. We contrast several 3D
23
+ 14 PSR loss functions in this paradigm and show that CSRS consistently increases the
24
+ 15 ability to detect regional atrophy both longitudinally and cross-sectionally in each
25
+ 16 of five related diseases.
26
+
27
+ # 17 1 Introduction
28
+
29
+ 18 Magnetic resonance image (MRI) datasets capturing in vivo longitudinal change in the human brain
30
+ 19 are currently available at unprecedented scale. These data allow us to quantify the complex etiology
31
+ 20 of neurodegenerative disease during life. A fundamental problem in quantifying brain disorders
32
+ 21 from imaging is that many anatomical structures are small in comparison to image resolution. This
33
+ 22 is caused by not only limited image resolution but also the potentially convoluted shape of the
34
+ 23 targeted anatomy [1]. Thinner, more oblate and/or curved structures undergo more distortion due
35
+ 24 to sampling-related aliasing in comparison to larger, more spherical structures. These distortions
36
+ 25 can limit detection power in the context of either clinical trials and/or at the level of patient specific
37
+ 26 medicine [2, 3]. These results also show that, based on first principles, many disease relevant
38
+ 27 anatomical structures in the brain, in particular cortical regions, mid-brain regions and hippocampal
39
+ 28 subfields, should be quantified at higher resolutions (e.g. $\approx 0 . 5 \mathrm { m m ^ { 3 } }$ or smaller rather than the
40
+ 29 more commonly available $\approx 1 \mathrm { m m ^ { 3 } }$ ). The need for increased resolution is only heightened when
41
+ 30 considering aging and neurodegeneration where some brain structures may lose half or more of their
42
+ 31 pre-disease onset volume or thickness.
43
+ 32 Perceptual super resolution (PSR) for 2D RGB imagery consistently demonstrates the ability to
44
+ 33 estimate more “realistic” looking upsampled data in comparison to traditional linear or nearest
45
+ 34 neighbor interpolants [4]. While many competitive methods are available, the deep back projection
46
+ 35 network (DBPN) [5] performed consistently in several competitions including NTIRE 2018 and 2019
47
+
48
+ [6], AIM 2019 [7] and PIRM 2018 [8]). These large challenges compared dozens of methods with respect to a variety of both perceptual and reconstruction metrics at different levels of upsampling and noise.
49
+
50
+ 39 Can the 2D RGB performance advantages of methods like the DBPN translate to improvements in
51
+ 40 the 3D quantification of brain regions as seen in MRI? If so, then PSR for 3D neuroimaging promises
52
+ 41 to improve quantification by better resolving the brain’s internal structures and tissue boundaries.
53
+ 42 While traditional evaluations of PSR focus on reconstruction error and perceptual impression, these
54
+ 43 measurements do not provide clinically relevant evidence of PSR’s value in quantification. One barrier
55
+ 44 to evaluating PSR’s impact on clinically relevant outcomes (segmentation volumes) is that ground
56
+ 45 truth segmentations do not exist at the super-resolved scale. To address this concern, [9] simulated low
57
+ 46 resolution magnetic resonance images (MRI) of the brain from high-resolution (HR) images obtained
58
+ 47 from the Human Connectome Project [10, 11]. They then applied a very deep super resolution
59
+ 48 (VDSR) model to the simulated data and the high-resolution data and compared the accuracy of an
60
+ 49 automated cortical segmentation method. This careful evaluation study demonstrated that cortical
61
+ 50 segmentation on the VDSR images closely approximated the HR data. However, relatively few
62
+ 51 details are provided about the training of this model and associated loss functions. Furthermore, it
63
+ 52 remains unclear whether these improvements in reconstruction error would translate to the detection
64
+ 53 of population-level effects in real world data particularly in the aging populations that are the target
65
+ 54 of the majority of interventional trials for the brain.
66
+ 55 A more recent effort in volumetric PSR for medical images [12] proposed SOUP-GAN: Super
67
+ 56 resolution Optimized Using Perceptual-tuned Generative Adversarial Network (GAN). SOUP-GAN
68
+ 57 adopts transfer learning from 2D VGG19 to 3D as proposed in [13] to produce a pseudo-volumetric
69
+ 58 perceptual metric [14]. Shan et al. used this metric to denoise low-dose computed tomography
70
+ 59 (CT) images and showed its effectiveness at preserving small anatomical structures. Similarly, the
71
+ 60 SOUP-GAN effort demonstrates that the pseudo-3D perceptual metric improves both PSNR and
72
+ 61 SSIM as well as shows visually appealing upsampling for a variety of medical imaging modalities.
73
+ 62 That is, the surprising utility (in 2D) of VGG weights as a feature space [15] appears to at least
74
+ 63 partially transfer to PSR in 3D medical imaging.
75
+ 64 The current research provides perhaps the first broadly scoped, real world evaluation of MRI PSR for
76
+ 65 quantification of neurodegenerative disease. Moreover, we demonstrate that a regression network
77
+ 66 (ResNet) that predicts T1w image quality can yield a directly useful perceptual feature space that
78
+ 67 performs competitively with pseudo-3D VGG19 features. We build these contributions upon the
79
+ 68 backbone of a set of methods that we call concurrent super resolution and segmentation (CSRS) that
80
+ 69 extends the proven 2D DBPN to 3D and also includes extra output channel(s) enabling segmentation
81
+ 70 maps to be upsampled concurrently. We use this framework to test the impact of different loss
82
+ 71 functions on a set of domain-specific, clinically relevant segmentation measurements related to
83
+ 72 brain atrophy. Specifically, we evaluate CSRS on the quantification of frontotemporal disorders [3]
84
+ 73 from publicly available longitudinal T1-weighted (T1w) neuroimaging (i.e. MRI). Of the several
85
+ 74 combinations of losses that we evaluate, the best model improves not only segmentation performance
86
+ 75 (when ground truth is available) but also detection power across all our related disorders: structural
87
+ 76 changes in behavioral variant frontotemporal dementia (bvFTD), semantic variant primary progressive
88
+ 77 aphasia (svPPA), nonfluent/agrammatic PPA (naPPA), progressive supranuclear palsy (PSP) and
89
+ 78 corticobasal syndrome (CBS) each of which impacts known networks in the brain. CSRS with a new
90
+ 79 perceptual loss based on a shallow ResNet layer performs as well or better than VGG-based models
91
+ 80 in this test of the practical usefulness of PSR.
92
+
93
+ 81 The primary contributions of this work include:
94
+
95
+ • new PSR that upsamples multi-label segmentations at the same time as intensity; • a new real world evaluation paradigm for PSR in neuroimaging; • comparison of three perceptual loss functions for PSR, two of which are new; • demonstration that loss choice impacts detection power in natural history studies of neurodegenerative disease. Standard intensity similarity and segmentation overlap metrics, on the other hand, do not discriminate performance between the candidate CSRS options.
96
+
97
+ 88 Model weights, sample data, and training code will be made publicly available after anonymous
98
+ 89 review.
99
+ 91 Software platform: We employ the ANTsX platform [16] version 2.3.5 for anatomical labeling,
100
+ 92 data augmentation/sampling during model training and to form the tabular data for the statistical
101
+ 93 evaluation. All MRI processing details follow [16]. Tensorflow 2.6.2 is used for deep learning
102
+ 94 including a ResNet implementation and the CSRS architecture. R version 4.1 is used for statistical
103
+ 95 analysis with packages lmer and ggplot2. All MRI processing was done on Amazon Web Services
104
+ 96 parallel cluster with 24 cores and 32GB RAM per process (Intel(R) Xeon(R) Platinum 8259CL
105
+ 97 CPU $\ @ \ 2 . 5 0 \mathrm { G H z }$ ).
106
+ 98 Data: Human Connectome Project (HCP): We downloaded 1,113 high-resolution $0 . 7 \mathrm { m m ^ { 3 } }$ T1-
107
+ 99 weighted images from the HCP on which to train CSRS. These T1w data were acquired using a
108
+ 100 magnetization-prepared rapid gradient-echo (MPRAGE) sequence on a customized 3T Siemens
109
+ 101 Skyra; see [10] for all details of acquisition. As such, these images provide both high resolution and
110
+ 102 high quality in comparison to the majority of publicly available T1w MRI. Critically, they provide
111
+ 103 superior resolution for the thin convoluted cortical layer that is critical to the measurement of brain
112
+ 104 atrophy in frontotemporal disorders. We transformed these data into numpy blocks with randomly
113
+ 105 selected high-resolution $6 4 ^ { 3 }$ patches and paired low-resolution $3 2 ^ { 3 }$ patches. For each patch pair, we
114
+ 106 also provide a high-resolution binary segmentation and a low-resolution downsampled version of
115
+ 107 that binary segmentation. Each patch segmentation was gained by 2-class $\mathbf { k }$ -means performed on
116
+ 108 the patch where the center voxel’s label determines which class (1 or 2) is used as foreground. This
117
+ 109 collection of 16,640 patches is then divided randomly into train $\scriptstyle \mathrm { n = 1 6 } , 3 8 4 ,$ ) and test sets.
118
+ 110 Data: Parkinson’s Progression Markers Initiative (PPMI): PPMI is a longitudinal multi-center
119
+ 111 clinical study of PD patients and age-matched healthy controls http://www.ppmi-info.org.
120
+ 112 PPMI employed(s) over 20 data collection sites with scanners that span the primary manufacturers
121
+ 113 (Siemens, GE, Phillips), a variety of head coils and also magnet strengths (1.5T, 3T). This heterogene
122
+ 114 ity of data collection provides a rich set of T1w images with highly variable image contrast, resolution
123
+ 115 and quality. We manually reviewed and labelled 1,431 raw T1w from PPMI to capture the range of
124
+ 116 quality in an ordinal scale. This resulted in a ground truth dataset with 456 images given grade “A”
125
+ 117 (superior), 568 given grade “B”, 350 given grade “C” and 57 given grade “F” which represents images
126
+ 118 that are of little to no use for quantitative studies of brain structure. We then employed a standard
127
+ 119 3D ResNet (antspynet.create_resnet_model_3d with parameters lowest_resolution $^ { \mathtt { = 3 2 } }$ ,
128
+ 120 number_of_classification_label $\mathtt { s } { = } 4$ , cardinality ${ \tt = } 1$ , 39,424,004 parameters, 53 3D convo
129
+ 121 lutional layers) to learn to predict this scale automatically and reliably from the input T1w. We denote
130
+ 122 this network as a T1w Quality Rating Resnet (T1wQRResNet). Details of training T1wQRResNet
131
+ 123 are in Supplementary Information.
132
+ 124 Data: Frontotemporal Lobar Degeneration Neuroimaging Initiative (NIFD) & 4-Repeat
133
+ 125 Tauopathy Neuroimaging Initiative (4RTNI): These inter-related multi-site studies share the goal
134
+ 126 of improving the quantification of frontotemporal spectrum disorders with both imaging and clinical
135
+ 127 scores. Like PPMI and HCP, these studies provide longitudinal T1w images that enable measurement
136
+ 128 of not only the baseline brain structure differences between controls (individuals without a disease
137
+ 129 i.e. normal aging) and disease groups but also differences in rates of change due to neurodegeneration.
138
+ 130 We downloaded and curated 4RTNI and NIFD T1w data and merged these images into a common
139
+ 131 database. These images were collected at three different sites using protocols consistent with ADNI
140
+ 132 3T guidelines [2]. The images overall have a median spacing that is isotropically $1 \mathrm { m m }$ with a minority
141
+ 133 of subjects with out-of-plane spacing up to $1 . 2 \mathrm { m m }$ . As such, these data suit the goals of testing PSR
142
+ 134 for benefits to the quantification of neurodegenerative disease. After filtering data for very low quality
143
+ 135 images and the presence of longitudinal data collected within 2 years of baseline, we obtained 128
144
+ 136 baseline/171 followup images for controls, 60/112 for bvFTD, 38/72 for naPPA, 37/71 for svPPA,
145
+ 137 55/70 for CBS and 75/102 for PSP. Further cohort details (age, education, sex, etc) are available in
146
+ 138 supplementary information. We processed all images consistently and automatically with default
147
+ 139 ANTsX pipelines to gain cortical, medial temporal lobe and deep brain structure segmentations for
148
+ 140 every subject as described in [16]. By consensus, co-authors selected a priori regions for testing
149
+ 141 within each of four groups CBS/PSP [17], bvFTD, svPPA and naPPA [18–24]. Details of the regions
150
+ 142 and rationale for their selection are available in the Supplementary Information. See Figure 1 for an
151
+ 143 overview of processing, the CSRS method and a visualization of the regions (1.C).
152
+
153
+ ![](images/4b5c9141c17579e01bca0f86e4338eef20afa5551c25144ea159f8bda44a630f.jpg)
154
+ Figure 1: (A) Image processing begins with raw MRI, extracts the brain, labels cortical regions, labels medial temporal lobe regions and labels deep brain regions. (B) The CSRS method is used, here, to upsample data by a factor of 2 isotropically; the sketch of the algorithm provides an example of how two nearby regions would flow through the method and be stitched back together at high resolution. (C) The impact of SR on quantifying neurodegeneration is assessed on a priori regions that are specific to each clinical diagnostic group; all regions are bilateral except for svPPA which uses only left hemisphere cortical and medial temporal labels.
155
+
156
+ # 144 2.1 Concurrent super resolution and segmentation methods
157
+
158
+ 145 CSRS uses, as a sub-algorithm, a three-dimensional and multi-output version of the neural network
159
+ 146 architecture defined by the 2D deep back projection network (DBPN) [5]. The DBPN is uniquely
160
+ 147 relevant to medical imaging in that it is perhaps the first published SR method that integrates the
161
+ 148 downsampling-upsampling error (i.e. residual layers) as a feature map. This novel architecture may
162
+ 149 prevent feature hallucination and constrain the high-resolution image to maintain features that are
163
+ 150 consistent with the low-resolution input. We extend the 2D DBPN to 3D MRI data by, first, translating
164
+ 151 2D convolutions, padding, striding and other relevant parameters to 3D. To generalize the architecture
165
+ 152 further, we allow options for not only convolutional upsampling (transposed convolution) but also
166
+ 153 nearest neighbor (or linear) interpolation layers at the user’s choice. Lastly, we implement flexible
167
+ 154 choices of input channels, the number of residual layers (backprojection) layers and the number of
168
+ 155 outputs. This 3D DBPN network implementation is available within R and python. All parameters
169
+ 156 were the same as the published work [25] (though in translation to 3D) with the exception of the
170
+ 157 number of back projection layers which has a large impact on the number of parameters. We reduced
171
+ 158 the number of backprojection layers to 5 (16,264,322 parameters) due to the memory limitations
172
+ 159 caused by working with large 3D images and limited GPU resources (all GPU computations in this
173
+ 160 work were implemented with Nvidia V100s locally).
174
+ 161 Efficient computational strategy is essential for CSRS to be applied to large 3D images (a brain
175
+ 162 image may contain 10 million voxels) when CPUs and RAM are limited. As such, a local patch-work
176
+ 163 strategy is necessary. Sampling, upsampling, mapping and unification (SUMU) are the common steps
177
+ 164 needed for not only training but also inference. “Sampling” decides the form of the input data: full
178
+ 165 images (not used here), image patches (used here in training) or anatomical image regions (used here
179
+ 166 in inference). Upscaling determines the core approach to transferring the low-resolution data to a
180
+ 167 higher-resolution output. Mapping compensates for shape or intensity distortion. Finally, “unification”
181
+ 168 is an ensembling or merging step that brings together several sub-estimates of an SR image into a
182
+ 169 single joined (final/full) SR image. We detail each of the 4 components below.
183
+ 170 Sampling: We choose a patch-based model for training as these can easily be applied to input data
184
+ 171 with different resolutions and fields of view. A second reason for patch-based modeling is that a
185
+ 172 candidate network does not need to learn the full scope of image variation. This results in shallower
186
+ 173 and faster to train networks that fit more easily onto readily available GPUs. The choices made
187
+ 174 during sampling step define the feature basis set. Because prior super-resolution competitions suggest
188
+ 175 larger patches lead to better performance, we choose the largest patches that would permit efficient
189
+ 176 batch sizes of 4 (64x64x64). An additional ad hoc support for this choice is that cortical features
190
+ 177 are relatively well-resolved in sub- $1 \mathrm { m m }$ training images when voxel cubes of this sized are used.
191
+ 178 However, there is no direct evidence that this size of patch domain is optimal for this problem.
192
+ 179 Upscaling: is done with the CSRS’s DBPN architecture using nearest neighbor interpolation for
193
+ 180 the upsampling layers. The software interface to CSRS also allows the user to optionally employ
194
+ 181 standard linear (tri-linear) interpolation. We use the linear option as a reference in evaluation studies
195
+ 182 below.
196
+ 183 Mapping: may be used to compensate for distortions in the image shape or intensity space. Because
197
+ 184 each patch is scaled independently on training data (to have an intensity range of -127.5 to 127.5),
198
+ 185 the output of the PSR upsampled image intensities must be mapped back to the original quantitative
199
+ 186 space. This is performed by directly comparing the output of the PSR upsampled patch/region to the
200
+ 187 original data upsampled by nearest neighbor or linear interpolation. As such, we can accurately retain
201
+ 188 quantitative intensity data at the original scale/units with minimal distortion and/or stitching artifacts.
202
+ 189 Unification: this is a general term that, here, refers to the algorithm that is used to derive a single
203
+ 190 CSRS image and multi-label segmentation from multiple CSRS sub-images (not necessarily isotropic
204
+ 191 patches as in training). In 2D, multiple input images are typically generated from a single input by
205
+ 192 “augmentation” e.g. random flipping, translation, etc thus allowing a practitioner to gain multiple
206
+ 193 “votes” about how the SR image should appear at any given voxel. Such a step is used in most PSR
207
+ 194 competitions to reduce aliasing or artifacts and may involve averaging, sharpening or more complex
208
+ 195 modeling such as joint intensity fusion, multi-channel deep learning or other ensemble methods.
209
+ 196 Due to the high memory and computation cost of running CSRS on 3D images, we instead apply
210
+ 197 CSRS to either sub-regions of interest or, when a full T1w brain image is desired, each hemisphere.
211
+ 198 The unification step then maps each local patch intensity range back to the original MRI range and
212
+ 199 then joins the sub-regions back together to complete the SR reconstruction. Augmentation can be
213
+ 200 employed beyond this but at substantial increase in computation time (e.g. 10x to see meaningful
214
+ 201 gains due to augmentation).
215
+ 202 Loss functions for CSRS: We employ a loss function that seeks to balance reconstruction error
216
+ 203 (intensity difference, abbreviated here as R), edge preserving denoising (total variation, abbreviated
217
+ 204 as TV), perceptual quality (based on VGG or ResNet) and segmentation overlap (Dice, abbreviated
218
+ 205 as D). Each of these terms can be up or down weighted to control the network’s performance where
219
+ 206 mean squared error (L2 intensity error) leads to smoother results, L1 (or total variation) provides
220
+ 207 denoising and the perceptual loss yields more natural appearing output textures and shapes. The
221
+ 208 Dice loss term seeks to minimize distortions in the shape of segmentation objects on the output
222
+ 209 of CSRS. The Dice loss is only applied to the second output channel of the network which uses a
223
+ 210 sigmoid activation function appropriate for probabilistic/binary data. We refer to CSRS trained with
224
+ 211 specific combinations of these losses by concatenation of the abbreviations above. For example,
225
+ 212 CSRS.R.TV.D.Res6 refers to a network trained with reconstruction loss, TV regularization, Dice loss
226
+ 213 and the 6th layer of the T1wQRResNet for perceptual loss.
227
+
228
+ Recent research demonstrates that deep learning models trained on large-scale object detection reference datasets (e.g. imagenet) encode a feature space that may mimic human perception [26]. Such perceptual spaces typically arise from the activations that occur within the layers of convolutional networks trained on massive classification datasets. Here, however, we compare a standard VGG based perceptual space (block2_conv2) (mapped to 3D as described before) to those defined by the T1wQRResNet. From T1wQRResNet, we choose two different deep layers that have similar numbers of parameters to the 3D version of the VGG19 block2_conv2 network: res_conv_block_6 (the 2nd convolutional block) and res_conv_block_21 (the 7th convolutional block). This allows us to compare perceptual metrics based on either pseudo-3D VGG19 or our intrinsically 3D res_conv_block choices.
229
+
230
+ 24 Quantification of medical images requires a high degree of faithfulness to the input data. "Halluci
231
+ 25 nated" features are undesirable. As such, our baseline loss function focuses on reconstruction error
232
+ 226 and TV for both intensity and segmentation images. We then add perceptual and Dice losses for
233
+ 227 further comparison. If we denote $I$ as the estimated super-resolution, $I _ { s }$ as the estimated segmentation
234
+ 228 from the sigmoid output channel, $J$ as the real high resolution image, $J _ { s }$ as the real high resolution
235
+ 229 segmentation, then the final loss function that we optimize is:
236
+
237
+ ![](images/c1c932135400cbcabfbf50ed1c493f50e263d8d369711c3faf4f78969e9debd1.jpg)
238
+ Figure 2: Best model CSRS applied to three categories of anatomy where row (A) is the original resolution (OR) and segmentation and row (B) is the output of CSRS.R.TV.D.Res6.
239
+
240
+ $$
241
+ \begin{array} { r } { I - J \| ^ { 2 } w _ { r } ^ { i } + \| I _ { s } - J _ { s } \| ^ { 2 } w _ { r } ^ { s } + T V ( I , J ) w _ { t } ^ { i } + T V ( I _ { s } , J _ { s } ) w _ { t } ^ { s } + \| f _ { n } ( I ) - f _ { n } ( J ) \| ^ { 2 } w _ { f } + D i c e ( I _ { s } , J _ { s } ) w _ { d } } \end{array}
242
+ $$
243
+
244
+ 230 where the term $\| \cdot \|$ indicates the euclidean norm, $T V ( \cdot , \cdot )$ indicates the total variation norm (which
245
+ 231 provides denoising), $w _ { r , t , f , d }$ (superscripts for intensity or segmentation) indicates a term-specific
246
+ 232 scalar weight and $f _ { n } ( . )$ indicates a perceptual feature map. The weight terms can be tuned for
247
+ 233 performance and application area given an objective and quantitative evaluation metric. We initially
248
+ 234 manually tuned the training of a DBPN model with only the reconstruction metrics $( \| I - J \| ^ { 2 } w _ { r } ^ { I } \dot { + }$
249
+ 235 $\lVert I _ { s } - \dot { J _ { s } } \rVert ^ { 2 } w _ { r } ^ { s }$ with $w _ { r } ^ { i } = 5 e - 4$ and $w _ { r } ^ { s } = 1$ ) using adam optimizer and learning rate 5e-5. We
250
+ 236 then set weights relative to the value of the reconstruction error after convergence such that: the TV
251
+ 237 loss is roughly $2 / 3$ the reconstruction term (R); the perceptual loss is roughly $3 \mathrm { x } \ \mathrm { R }$ ; the Dice loss is
252
+ 238 roughly equivalent to the perceptual loss. This strategy, based on our task-specific goals, enables us
253
+ 239 to compare models consistently and add/subtract terms without extensive weight optimization.
254
+ 40 Computation and inference: All models were implemented with tensorflow. The computation to
255
+ 241 double magnification – for a single T1w – takes (generally on a modern computational platform)
256
+ 42 between 10 and 40 minutes. Results are computed region-wise over the set of segmentation labels
257
+ 243 where CSRS is run on each cropped label and its associated intensity. When multiple regions are
258
+ 244 used (as is done here), then results are stitched back together while using a linear mapping back
259
+ 245 to the original intensity space and a arg_max operation to define the hard segmentation labels at
260
+ 46 every voxel in the stitched, joint intensity/probability double magnification space. See Figure 2 for
261
+ 47 an example result of CSRS as applied to the variety of brain regions in this study. Figure 3 shows a
262
+ 48 zoomed visual comparison of the impact on intensity and the lack of stitching artifacts.
263
+
264
+ # 2.2 Quantification of CSRS impact on segmentation and intensity in ground truth data
265
+
266
+ Evaluation of PSR results on simulated downsampled-upsampled data does not constitute real world conditions. However, for reference, we include evaluation results based on an independent set of labeled brain images [27]. For these images, we downsample with nearest neighbor interpolation and upsample with linear interpolation (for the intensity) and a “generic label” interpolation that is designed for multi-label images [28] thereby allowing us to report standard metrics of Dice overlap, PSNR and SSIM to complement our study of brain atrophy detection. Figure 4 demonstrates example results illustrating this component of our evaluation.
267
+
268
+ ![](images/e5ad374190f490e8c5abd0d89955a3089fdac304feb8b087fbb3b132df729771.jpg)
269
+ Figure 3: Comparison of CSRS with different loss functions to original resolution and linear upsampling. The bold (panel E) is the best performing model according to quantitative criteria. However, visual differences between the perceptual models (D,E,F) are not easy to discern.
270
+
271
+ ![](images/f3b1e61e60f74e47e18322e106c4ced735805a3652dae28f93cd6626678bbe98.jpg)
272
+ Figure 4: Panel (A) shows the original $\mathrm { 1 m m ^ { 3 } }$ resolution ground truth image and its segmentation. Panel (B) shows the impact of linear/generic label upsampling of ground truth data artifically downsampled to $2 \mathrm { m m ^ { 3 } }$ . Panel (C) shows a CSRS result where other models are visually similar to this. Panel (D) demonstrates that all regions improve with CSRS (all differences $> 0$ ) and that regions with lower Dice overlap under the linear/generic label model improve more when upsampled with CSRS.
273
+
274
+ # 257 2.3 Quantification of effect sizes in frontotemporal disorder atrophy
275
+
276
+ The frontotemporal disorders produce a profound and debilitating effect on patients with concomitant, symptom-related atrophy. Measuring this atrophy is critical to detecting the effects, for instance, of disease modifying therapies that may slow atrophy. Such measurements are challenged by low resolution and this challenge is compounded by the degeneration process itself.
277
+
278
+ 262 We use statistical modeling to determine if CSRS can mitigate the known limitations of resolution on
279
+ 263 atrophy measurement. We adopt an interpretable mixed effects modeling approach (lmer)[29] to
280
+ 264 estimate effect sizes per brain region, per diagnostic category and per resolution/CSRS model. The
281
+ 265 baseline performance is determined by the effect sizes estimated on the original resolution (OR) data.
282
+ 266 We estimate effect sizes following [30, 31]. Better methods, under this design, should more reliably
283
+ 267 identify disease-related atrophy which will be reflected in increased effect sizes for a given set of $a$
284
+ 268 priori diagnosis-specific regions. The model for the region of interest $i$ $( R O I _ { i } )$ ) is:
285
+
286
+ $$
287
+ R O I _ { i } \approx A g e _ { b } + S e x + B V _ { b } + D X + \Delta T * D X + ( 1 | I D ) ,
288
+ $$
289
+
290
+ 269 with $( 1 | I D )$ representing a subject-specific random effect, $A g e _ { b }$ is the subject’s age at the first visit,
291
+ 270 $B V _ { b }$ is the first visit brain volume, $D X$ is the diagnosis for the subject, $\Delta T$ is the change in time
292
+ 271 since baseline and the $\Delta T * D X$ represents an interaction between time and diagnosis. The $R O I _ { i }$
293
+ 272 represents the volume for all regions. However, for cortical regions, we also use the region’s thickness
294
+ 273 measurement as a second outcome (as this is a standard measurement in morphometry of the human
295
+ 274 cortex). We estimate effect sizes for cross-sectional effects via the model’s parameter fit for the
296
+ 275 diagnosis $( D X )$ term; we estimate longitudinal effect sizes via the parameter on the interaction term.
297
+
298
+ Table 1: Summary of results where the comparison of the model impact on effect size is computed by bootstrapped $\scriptstyle ( \mathrm { n = 1 0 0 0 } )$ ) paired t.test. The number of pairs is 274 (see Table 2 for further breakdown by category). CSRS losses are abbreviated as $\mathbf { R } =$ reconstruction, $\mathrm { T V } { = }$ total variation, $\scriptstyle \mathbf { D = }$ dice, VGG $\circeq$ VGG19 pseudo 3D features, Res6 is from the 6th layer of T1wQRResNet and Res21 is the 21st layer of T1wQRResNet. srmeanES indicates the mean effect size for the model averaged over all a priori regions; boot.95ci is the 95 percent confidence interval for the improvement in effect size due to the model. t represents the $t$ -statistic and boot.p represents the bootstrapped p-value for the significance of the improvement in effect size. Columns psnr and ssim show the standard PSNR and SSIM values for an image for which we have ground truth high-resolution intensity and segmentation. The dice columns show the mean and standard deviation of the Dice overlap between ground truth and the upsampled simulated data with each model, estimated over all regions. Best $=$ bold.
299
+
300
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>srmeanES</td><td rowspan=1 colspan=1>boot.95ci</td><td rowspan=1 colspan=1>t</td><td rowspan=1 colspan=1>boot.p</td><td rowspan=1 colspan=1>psnr</td><td rowspan=1 colspan=1>ssim</td><td rowspan=1 colspan=1>dice.mean</td><td rowspan=1 colspan=1>dice.sd</td></tr><tr><td rowspan=1 colspan=1>OR</td><td rowspan=1 colspan=1>0.559</td><td rowspan=1 colspan=1>0/0</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td></tr><tr><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>0.468</td><td rowspan=1 colspan=1>-0.1006/-0.08163</td><td rowspan=1 colspan=1>-18.61</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>40.6</td><td rowspan=1 colspan=1>0.996</td><td rowspan=1 colspan=1>0.769</td><td rowspan=1 colspan=1>0.047</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV</td><td rowspan=1 colspan=1>0.574</td><td rowspan=1 colspan=1>0.01124/0.01854</td><td rowspan=1 colspan=1>7.96</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.0</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D</td><td rowspan=1 colspan=1>0.582</td><td rowspan=1 colspan=1>0.01868/0.0273</td><td rowspan=1 colspan=1>10.38</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>41.8</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.883</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01775/0.02559</td><td rowspan=1 colspan=1>10.76</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.0</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.885</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.VGG</td><td rowspan=1 colspan=1>0.577</td><td rowspan=1 colspan=1>0.01403/0.02209</td><td rowspan=1 colspan=1>8.86</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>41.9</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.Res6</td><td rowspan=1 colspan=1>0.572</td><td rowspan=1 colspan=1>0.009741/0.01665</td><td rowspan=1 colspan=1>7.49</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.4</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.886</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>0.588</td><td rowspan=1 colspan=1>0.02497/0.0331</td><td rowspan=1 colspan=1>14.02</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.4</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.885</td><td rowspan=1 colspan=1>0.032</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.Res21</td><td rowspan=1 colspan=1>0.577</td><td rowspan=1 colspan=1>0.01462/0.02143</td><td rowspan=1 colspan=1>10.40</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.3</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res21</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01814/0.02627</td><td rowspan=1 colspan=1>10.59</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.3</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.887</td><td rowspan=1 colspan=1>0.03</td></tr></table>
301
+
302
+ ![](images/2b07a81d2d8a589a8b1bb114132c9aa7f9a79ccb050cea1dd7e921d7dc6686f0.jpg)
303
+ Figure 5: Bland-Altman plots for model CSRS.R.TV.D.Res6 demonstrate variability in the performance by type of anatomy and by diagnostic grouping with some individual points generating substantially greater $\%$ improvement than suggested by the overall trend. Similarly, a few points show decreased performance relative to OR.
304
+
305
+ # 276 3 Results
306
+
307
+ Table 1 summarizes overall results where we show original resolution and results from linear upsampling, as baseline, and compare to eight variants of CSRS. Two of these do not use perceptual metrics. The remaining six add or subtract Dice loss and each of our candidate perceptual losses. Table 1 shows both the aggregate impact of model on effect size estimates in the neurodegeneration data as well as intensity similarity (reconstruction) and Dice overlap in the ground truth data. Dice overlap (a measure that varies between zero and one) improves by a margin of 0.11 to 0.123 $9 5 \%$ CI bootstrapped percentile confidence interval, $p < 1 e - 1 6$ . See Figure 4.
308
+
309
+ 277
310
+ 278
311
+ 279
312
+ 280
313
+ 281
314
+ 282
315
+ 283
316
+ 284
317
+ 285
318
+ 286
319
+ 287
320
+ 288
321
+
322
+ Table 2 focuses on the two perceptual models with the greatest improvement from original resolution as assessed by pairwise $t$ -test. It breaks down the effect size results in relation to which type of effect size is being analyzed (cross-sectional or longitudinal) and by brain region / diagnostic grouping. Relatedly, Figure 5 shows a Bland-Altman style plot that demonstrates, for the CSRS.R.TV.D.Res6 model, the range of effect size changes due to CSRS across all 274 measurement points.
323
+
324
+ Table 2: Summary of results for the two best perceptual models broken down by anatomical class, type of predictor (longitudinal or cross-sectional) and diagnostic groups. The n column indicates the number of samples used in the statistical testing. The codes in the AnatClass column are: CtxV - cortical volume; CtxT - cortical thickness; MB - deep brain (for CBS/PSP); MTL - medial temporal lobe (for svPPA). The columns that have non-NA DX2 means that both DX and DX2 groups were aggregated in the computation of the bootstrapped paired $t$ -test for the given group of anatomy.
325
+
326
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>AnatClass</td><td rowspan=1 colspan=1>isLong</td><td rowspan=1 colspan=1>DX</td><td rowspan=1 colspan=1>DX2</td><td rowspan=1 colspan=1>n</td><td rowspan=1 colspan=1>srmeanES</td><td rowspan=1 colspan=1>boot.95ci</td><td rowspan=1 colspan=1>t</td><td rowspan=1 colspan=1>boot.p</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>Both</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>274</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01775/0.02559</td><td rowspan=1 colspan=1>10.763</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.826</td><td rowspan=1 colspan=1>0.007153/0.01626</td><td rowspan=1 colspan=1>4.936</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>1.016</td><td rowspan=1 colspan=1>-0.009547/0.01006</td><td rowspan=1 colspan=1>0.033</td><td rowspan=1 colspan=1>0.9769</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.600</td><td rowspan=1 colspan=1>0.03683/0.1208</td><td rowspan=1 colspan=1>3.458</td><td rowspan=1 colspan=1>0.0246</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>1.003</td><td rowspan=1 colspan=1>0.02801/0.06981</td><td rowspan=1 colspan=1>4.190</td><td rowspan=1 colspan=1>0.0112</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.645</td><td rowspan=1 colspan=1>0.01848/0.03313</td><td rowspan=1 colspan=1>6.719</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.527</td><td rowspan=1 colspan=1>0.03521/0.05297</td><td rowspan=1 colspan=1>9.445</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.201</td><td rowspan=1 colspan=1>0.01409/0.03941</td><td rowspan=1 colspan=1>3.924</td><td rowspan=1 colspan=1>0.0110</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>0.701</td><td rowspan=1 colspan=1>-0.0159/0.002513</td><td rowspan=1 colspan=1>-1.309</td><td rowspan=1 colspan=1>0.2652</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>Both</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>274</td><td rowspan=1 colspan=1>0.588</td><td rowspan=1 colspan=1>0.02497/0.0331</td><td rowspan=1 colspan=1>14.021</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.831</td><td rowspan=1 colspan=1>0.01199/0.02182</td><td rowspan=1 colspan=1>6.573</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>1.023</td><td rowspan=1 colspan=1>-0.002896/0.01832</td><td rowspan=1 colspan=1>1.394</td><td rowspan=1 colspan=1>0.1604</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.589</td><td rowspan=1 colspan=1>0.02166/0.1131</td><td rowspan=1 colspan=1>2.718</td><td rowspan=1 colspan=1>0.0454</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>SvPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>1.004</td><td rowspan=1 colspan=1>0.02782/0.07253</td><td rowspan=1 colspan=1>4.021</td><td rowspan=1 colspan=1>0.0102</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.658</td><td rowspan=1 colspan=1>0.03203/0.04756</td><td rowspan=1 colspan=1>9.751</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.545</td><td rowspan=1 colspan=1>0.05421/0.06995</td><td rowspan=1 colspan=1>15.151</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.198</td><td rowspan=1 colspan=1>0.006017/0.04464</td><td rowspan=1 colspan=1>2.233</td><td rowspan=1 colspan=1>0.0166</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>0.704</td><td rowspan=1 colspan=1>-0.0177/0.01214</td><td rowspan=1 colspan=1>-0.369</td><td rowspan=1 colspan=1>0.7511</td></tr></table>
327
+
328
+ # 289 4 Discussion
329
+
330
+ The PSNR and SSIM improve similarly across all CSRS models and do not substantively differentiate performance. Dice overlap is consistently superior than linear upsampling across all models but shows little difference between models with perhaps a small advantage for the ResNet features. Greater stratification may be seen when looking at results that relate to quantifying the phenotypic heterogeneity of brain atrophy in frontotemporal spectrum diagnostic groups. Model CSRS.R.TV.D.Res6 stands out under this criteria with Table 2 suggesting that the majority of the improvement arises for cortical measurements, particularly longitudinally. Performance improvements are not, however, perfectly consistent. Figure 5 shows that CSRS augments effect size in the large majority of regions (some greatly so) but a few regions are subtly better at OR. Additional discussion of performance implications with respect to individual regions and diagnoses is in supplementary information.
331
+
332
+ 300 The extension of PSR to 3D raises opportunities as well as challenges. Parameter exploration is
333
+ 301 fundamentally limited because training a model on our patch dataset for 1 epoch takes over 12 hours
334
+ 302 (we trained each model for 2 epochs or until convergence). Other architectures than DBPN may
335
+ 303 perform better with CSRS such as ESRGAN [32] or, potentially, methods with stronger modality
336
+ 304 specific priors on the convolutional kernels [33]. Specifically, fast-training, fewer parameter models
337
+ 305 may ease some of the computational burden and facilitate more parameter exploration.
338
+ 306 CSRS performance is fundamentally limited by the quality of its segmentation inputs. It may be
339
+ 307 more beneficial to develop new methods that operate at high resolution (HR) – adding substantial
340
+ 308 computational cost if the goal is to take advantage of HR features – or that take advantage of
341
+ 309 intrinsically HR ground truth data. The primary barrier to such an effort is the current lack of HR
342
+ 310 ground truth labels for neuroimaging and in particular for neurodegenerative disease. Moreover,
343
+ 311 most methods embed resolution assumptions in their own processing choices and optimize for these
344
+ 312 choices. As such, CSRS bridges a performance gap with a practical solution readily available today.
345
+ 313 Retooling existing methods and segmentation labels for HR (e.g. 7T MRI) is costly both computation
346
+ 314 ally and in terms of the effort of human experts due to the already high volume of 3D neuroimaging.
347
+ 315 We demonstrated that CSRS, in most of its variants, leads to significant performance improvements
348
+ 316 over our reference of original resolution $\mathrm { { ( l m m ^ { 3 } ) } }$ ) image processing and ground truth labels. Because
349
+ 317 CSRS operates on existing images and labels, new HR method and segmentation development is
350
+ 318 not required. Thus, CSRS may be used to improve existing ground truth datasets and existing
351
+ 319 processed data, today. However, comparison to other and/or larger real world datasets is needed to
352
+ 320 help determine the extent to which our results may be deployed to new data without concern.
353
+ 321 References
354
+ 322 1. Mulder MJ, Keuken MC, Bazin PL, Alkemade A, Forstmann BU. Size and shape matter: The
355
+ 323 impact of voxel geometry on the identification of small nuclei. PLoS ONE. 2019. https://doi.
356
+ 324 org/10.1371/journal.pone.0215382.
357
+ 325 2. Veitch DP, Weiner MW, Aisen PS, Beckett LA, Cairns NJ, Green RC, et al. Understanding disease
358
+ 326 progression and improving Alzheimer’s disease clinical trials: Recent highlights from the Alzheimer’s
359
+ 327 disease neuroimaging initiative. Alzheimer’s & Dementia : the Journal of the Alzheimer’s Association.
360
+ 328 2019;15:106–52.
361
+ 329 3. Boxer AL, Gold M, Feldman H, Boeve BF, Dickinson SL-J, Fillit H, et al. New directions in
362
+ 330 clinical trials for frontotemporal lobar degeneration: Methods and outcome measures. Alzheimer’s &
363
+ 331 dementia : the journal of the Alzheimer’s Association. 2020;16:131–43.
364
+ 332 4. Blau Y, Michaeli T. The perception-distortion tradeoff. Proceedings of the IEEE Conference
365
+ 333 on Computer Vision and Pattern Recognition, pp 6228-6237, 2018. 2017. https://doi.org/10.
366
+ 334 1109/CVPR.2018.00652.
367
+ 335 5. Haris M, Shakhnarovich G, Ukita N. Deep back-projection networks for single image super
368
+ 336 resolution. IEEE Transactions on Pattern Analysis and Machine Intelligence. 2020; 43(12):4323-
369
+ 337 4337.
370
+ 338 6. Agustsson E, Timofte R. NTIRE 2017 challenge on single image super-resolution: Dataset and
371
+ 339 study. In: Proceedings of the IEEE conference on computer vision and pattern recognition workshops
372
+ 340 2017. pp. 126-135.
373
+ 341 7. Gu S, Danelljan M, Timofte R, Haris M, Akita K, Shakhnarovic G, et al. AIM 2019 challenge on
374
+ 342 image extreme super-resolution: Methods and results. In: 2019 IEEE/CVF International Conference
375
+ 343 on Computer Vision Workshop (ICCVW). Seoul, Korea (South): IEEE. pp. 3556–64.
376
+ 344 8. Blau Y, Mechrez R, Timofte R, Michaeli T, Zelnik-Manor L. The 2018 PIRM challenge on
377
+ 345 perceptual image super-resolution. In: 2018 Proceedings of the European Conference on Computer
378
+ 346 Vision (ECCV) Workshops. pp. 334–55.
379
+ 347 9. Tian Q, Bilgic B, Fan Q, Ngamsombat C, Zaretskaya N, Fultz NE, et al. Improving in vivo human
380
+ 348 cerebral cortical surface reconstruction using data-driven super-resolution. Cerebral cortex (New
381
+ 349 York, NY : 1991). 2021;31:463–82.
382
+ 350 10. Glasser MF, Smith SM, Marcus DS, Andersson JLR, Auerbach EJ, Behrens TEJ, et al. The human
383
+ 351 connectome project’s neuroimaging approach. Nature Neuroscience. 2016; 19(9): pp. 1175-1187.
384
+ 352 11. Elam JS, Glasser MF, Harms MP, Sotiropoulos SN, Andersson JL, Burgess GC, et al. The human
385
+ 353 connectome project: A retrospective. NeuroImage. 2021;244:118543.
386
+ 354 12. Zhang K, Hu H, Philbrick K, Conte GM, Sobek JD, Rouzrokh P, et al. SOUP-gan: Super
387
+ 355 resolution mri using generative adversarial networks. Tomography (Ann Arbor, Mich). 2022;8:905–
388
+ 356 19.
389
+ 357 13. Shan H, Zhang Y, Yang Q, Kruger U, Kalra MK, Sun L, et al. 3-d convolutional encoder-decoder
390
+ 358 network for low-dose ct via transfer learning from a 2-d trained network. IEEE Transactions on
391
+ 359 Medical Imaging. 2018. https://doi.org/10.1109/TMI.2018.2832217.
392
+ 360 14. Avants B, Greenblatt E, Hesterman J, Tustison N. Deep volumetric feature encoding for biomedical
393
+ 361 images. In: Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial
394
+ 362 Intelligence and Lecture Notes in Bioinformatics). 2020.
395
+ 363 15. Zhang R, Isola P, Efros AA, Shechtman E, Wang O. The unreasonable effectiveness of deep
396
+ 364 features as a perceptual metric. In: Proceedings of the IEEE Computer Society Conference on
397
+ 365 Computer Vision and Pattern Recognition. 2018.
398
+ 366 16. Tustison NJ, Cook PA, Holbrook AJ, Johnson HJ, Muschelli J, Devenyi GA, et al. The antsx
399
+ 367 ecosystem for quantitative biological and medical imaging. Scientific reports. 2021;11:9068.
400
+ 368 17. Illán-Gala I, Nigro S, VandeVrede L, Falgàs N, Heuer HW, Painous C, et al. Diagnostic
401
+ 369 accuracy of magnetic resonance imaging measures of brain atrophy across the spectrum of progressive
402
+ 370 supranuclear palsy and corticobasal degeneration. JAMA network open. 2022;5:e229588.
403
+ 371 18. Whitwell JL. FTD spectrum: Neuroimaging across the ftd spectrum. 2019;187–223.
404
+ 372 19. Whitwell JL, Josephs KA. Neuroimaging in frontotemporal lobar degeneration—predicting
405
+ 373 molecular pathology. 2012;8:131–42.
406
+ 374 20. Binney RJ, Pankov A, Marx G, He X, McKenna F, Staffaroni AM, et al. Data-driven regions of
407
+ 375 interest for longitudinal change in three variants of frontotemporal lobar degeneration. Brain and
408
+ 376 behavior. 2017;7:e00675.
409
+ 377 21. McCarthy J, Collins DL, Ducharme S. Morphometric mri as a diagnostic biomarker of fron
410
+ 378 totemporal dementia: A systematic review to determine clinical applicability. NeuroImage Clinical.
411
+ 379 2018;20:685–96.
412
+ 380 22. Gunawardena D, Ash S, McMillan C, Avants B, Gee J, Grossman M. Why are patients with
413
+ 381 progressive nonfluent aphasia nonfluent? Neurology. 2010;75.
414
+ 382 23. C.T. M, J.B. T, B.B. A, P.A. C, E.M. W, E. S, et al. Genetic and neuroanatomic associations in
415
+ 383 sporadic frontotemporal lobar degeneration. Neurobiology of Aging. 2014.
416
+ 384 24. Massimo L, Powers C, Moore P, Vesely L, Avants B, Gee J, et al. Neuroanatomy of apathy
417
+ 385 and disinhibition in frontotemporal lobar degeneration. Dementia and Geriatric Cognitive Disorders.
418
+ 386 2009. https://doi.org/10.1159/000194658.
419
+ 387 25. Haris M, Shakhnarovich G, Ukita N. Deep back-projection networks for super-resolution. In:
420
+ 388 Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition.
421
+ 389 2018.
422
+ 390 26. Zhang R, Isola P, Efros AA, Shechtman E, Wang O. The unreasonable effectiveness of deep
423
+ 391 features as a perceptual metric. In: Proceedings of the IEEE Computer Society Conference on
424
+ 392 Computer Vision and Pattern Recognition. 2018.
425
+ 393 27. Klein A, Tourville J. 101 labeled brain images and a consistent human cortical labeling protocol.
426
+ 394 Frontiers in neuroscience. 2012;6:171.
427
+ 395 28. Schaerer J, Roche F, Belaroussi B. A generic interpolator for multi-label images. 2014. https:
428
+ 396 //doi.org/10.54294/nr6iii.
429
+ 397 29. Bates D, Mächler M, Bolker B, Walker S. Fitting linear mixed-effects models using lme4 | bates |
430
+ 398 journal of statistical software. Journal of Statistical Software. 2015;67.
431
+ 399 30. Brysbaert M, Stevens M. Power analysis and effect size in mixed effects models: A tutorial.
432
+ 400 Journal of Cognition. 2018;1.
433
+ 401 31. Ben-Shachar M, Lüdecke D, Makowski D. Effectsize: Estimation of effect size indices and
434
+ 402 standardized parameters. Journal of Open Source Software. 2020;5.
435
+ 403 32. Wang X, Yu K, Wu S, Gu J, Liu Y, Dong C, et al. ESRGAN: Enhanced super-resolution generative
436
+ 404 adversarial networks. arXiv e-prints. 2018;arXiv:1809.00219.
437
+ 405 33. Bell-Kligler S, Shocher A, Irani M. Blind super-resolution kernel estimation using an internal-gan.
438
+ 406 In: Advances in Neural Information Processing Systems. 2019.
439
+
440
+ 1. For all authors...
441
+
442
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
443
+ (b) Did you describe the limitations of your work? [Yes]
444
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
445
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
446
+
447
+ 2. If you are including theoretical results...
448
+
449
+ (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]
450
+
451
+ 3. If you ran experiments...
452
+
453
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We provide the data, in supplementary material, that is needed to generate the tables shown in the paper. The raw data is publicly available but we do not have permission to redistribute these data. However, we do provide the ability to reproduce key results in the Tables of the main manuscript via supplementary information.
454
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
455
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
456
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See beginning of Methods section and CSRS methods section.
457
+
458
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
459
+
460
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
461
+ (b) Did you mention the license of the assets? [Yes] in supplemental information.
462
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
463
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] in supplemental information.
464
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] in supplemental information.
465
+
466
+ 5. If you used crowdsourcing or conducted research with human subjects...
467
+
468
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
469
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
470
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/vcNjibzV3P/vcNjibzV3P.md ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Complete Neural Networks for Complete Euclidean Graphs
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Neural networks for point clouds, which respect their natural invariance to per
11
+ 2 mutation and rigid motion, have enjoyed recent success in modeling geometric
12
+ 3 phenomena, from molecular dynamics Reiser et al. [2022] to recommender systems
13
+ 4 Yi et al. [2023]. Yet, to date, no architecture with polynomial complexity is known
14
+ 5 to be complete, that is, able to distinguish between any pair of non-isomorphic
15
+ 6 point clouds. We fill this theoretical gap by showing that point clouds can be
16
+ 7 completely determined, up to permutation and rigid motion, by applying the 3-WL
17
+ 8 graph isomorphism test to the point cloud’s centralized Gram matrix. Moreover, we
18
+ 9 formulate a Euclidean variant of the 2-WL test and show that it is also sufficient to
19
+ 10 achieve completeness. We then show how our complete Euclidean WL tests can be
20
+ 11 simulated by a Euclidean graph neural network of moderate size and demonstrate
21
+ 12 their separation capability on highly-symmetrical point clouds.
22
+
23
+ # 13 1 Introduction
24
+
25
+ 14 A point cloud is a collection of $n$ points in $\mathbb { R } ^ { d }$ , where typically in applications $d = 3$ . Machine
26
+ 15 learning on point clouds is an important task with applications in chemistry Gilmer et al. [2017],
27
+ 16 Wang et al. [2022], physical systems Finzi et al. [2021] and image processing Ma et al. [2023]. Many
28
+ 17 successful architectures for point clouds are invariant by construction to the natural symmetries of
29
+ 18 point clouds: permutations and rigid motions.
30
+ 19 The rapidly increasing literature on point-cloud networks with permutation and rigid-motion sym
31
+ 20 metries has motivated research aimed at theoretically understanding the expressive power of the
32
+ 21 various architectures. This analysis typically focuses on two closely related concepts: Separation
33
+ 22 and Universality. We say an invariant architecture is separating, or complete, if it can assign distinct
34
+ 23 values to any pair of point clouds that are not related by symmetry. An invariant architecture is
35
+ 24 universal if it can approximate all continuous invariant functions on compact sets. Generally speaking,
36
+ 25 these two concepts are essentially equivalent, as discussed in Villar et al. [2021], Joshi et al. [2022],
37
+ 26 Chen et al. [2019], and in our context, in Appendix A.
38
+ 27 Dym and Maron [2020] proved that the well-known Tensor Field Network Thomas et al. [2018]
39
+ 28 invariant architecture is universal, but the construction in their proof requires arbitrarily high-order
40
+ 29 representations of the rotation group. Similarly, universality can be obtained using high-order
41
+ 30 representations of the permutation group Lim et al. [2022]. However, prior to this work, it was not
42
+ 31 known whether the same theoretical guarantees can be achieved by realistic point-cloud architectures
43
+ 32 that use low-dimensional representations, and whose complexity has a mild polynomial dependency
44
+ 33 on the data dimension. In the words of Pozdnyakov and Ceriotti [2022]: "...provably universal
45
+ 34 equivariant frameworks are such in the limit in which they generate high-order correlations. . . It is
46
+ 35 an interesting, and open, question whether a given order suffices to guarantee complete resolving
47
+ 36 power." (p. 6). We note that it is known that separation of point clouds in polynomial time in $n$
48
+ 37 is possible, assuming that $d$ is fixed (e.g., $d = 3$ ) Arvind and Rattan [2014], Dym and Kovalsky
49
+ 38 [2019], Kurlin [2022]. What still remains to be established is whether separation is achievable for
50
+ 39 common invariant machine learning models, and more generally, whether separation can be achieved
51
+ 40 by computing a continuous invariant feature that is piecewise differentiable.
52
+ 41 In this paper, we give what seems to be the first positive answer to this question. We focus on analyzing
53
+ 42 a popular method for the construction of invariant point-cloud networks via Graph Neural Networks
54
+ 43 (GNNs). This is done in two steps: first, point clouds are represented as a Euclidean graph- which we
55
+ 44 define to be a complete weighted graph whose edge features are simple, rotation-invariant features:
56
+ 45 the inner products between pairs of (centralized) points. We then apply permutation-invariant Graph
57
+ 46 Neural Networks (GNNs) to the Euclidean graphs to obtain a rotation- and permutation-invariant
58
+ 47 global point-cloud feature. This leads to a rich family of invariant point-cloud architectures, which is
59
+ 48 determined by the type of GNN chosen.
60
+ 49 The most straightforward implementation of this idea would be to apply the popular message passing
61
+ 50 GNNs to the Euclidean graphs. One could also consider applying more expressive GNNs. For
62
+ 51 combinatorial graphs, it is known that message-passing GNNs are only as expressive as the 1-WL
63
+ 52 graph isomorphism test. There exists a hierarchy of $k$ -WL graph isomorphism tests, where larger
64
+ 53 values of $k$ correspond to more expressive, and more expensive, graph isomorphism tests. There
65
+ 54 are also corresponding GNNs that simulate the $k$ -WL tests and have an equivalent separation power
66
+ 55 Morris et al. [2018], Maron et al. [2019]. One could then consider applying these more expressive
67
+ 56 architectures to Euclidean graphs, as suggested in Lim et al. [2022]. Accordingly, we aim to answer
68
+ 57 the following questions:
69
+
70
+ Question 1 For which $k$ is the $k$ -WL test, when applied to Euclidean graphs, complete?
71
+
72
+ Question 2 Can this test be implemented in polynomial time by a continuous, piecewise-differentiable architecture?
73
+
74
+ 61 We begin by addressing Question 1. First, we consider a variation of the WL-test adapted for point
75
+ 62 clouds, which we refer to as 1-EWL (’E’ for Euclidean). This test was first proposed by Pozdnyakov
76
+ 63 and Ceriotti [2022], where it was shown that it cannot distinguish between all 3-dimensional point
77
+ 64 clouds, and consequently, neither can GNNs like Victor Garcia Satorras [2021], Schütt et al. [2017],
78
+ 65 which can be shown to simulate it. Our first result, described in Section 2.1, balances this by showing
79
+ 66 that two iterations of 1-EWL are enough to separate almost any pair of point clouds.
80
+ 67 To achieve complete separationfor all point clouds, we consider higher-order $k$ -EWL tests. We first
81
+ 68 consider a natural adaptation of $k$ -WL for Euclidean graphs, which we name the Vanilla- $k$ -EWL test.
82
+ 69 In this test, the standard $k$ -WL is applied to the Euclidean graph induced by the point clouds. We
83
+ 70 show that when $k = 3$ , this test is complete for 3-dimensional point clouds. Additionally, we propose
84
+ 71 a variant of the Vanilla 2-EWL, which incorporates additional geometric information while having
85
+ 72 the same complexity. We call this test the 2-EWL test, and show that it is complete on 3D point
86
+ 73 clouds. We also propose a natural variation of 2-EWL called 2-SEWL, which can distinguish between
87
+ 74 point clouds that are related by a reflection. This ability is important for chemical applications, as
88
+ 75 most biological molecules that are related by a reflection are not chemically identical Kapon et al.
89
+ 76 [2021] (this molecular property is called chirality).
90
+ 77 We next address the second question of how to construct a GNN for Euclidean data with the same
91
+ 78 separation power as that of the various $k$ -EWL tests we describe. For combinatorial graphs, such
92
+ 79 equivalence results rely on injective functions defined on multisets of discrete features Xu et al. [2018].
93
+ 80 For Euclidean graphs, one can similarly rely on injective functions for multisets with continuous
94
+ 81 features, such as those proposed in Dym and Gortler [2023]. However, a naive application of this
95
+ 82 approach leads to a very large number of hidden features, which grows exponentially with the number
96
+ 83 of message-passing iterations (see Figure 2). We show how this problem can be remedied, so that the
97
+ 84 number of features needed depends only linearly on the number of message-passing iterations.
98
+
99
+ 85 To summarize, our main results in this paper are:
100
+
101
+ 1. We show that two iterations of 1-EWL can separate almost all point clouds in any dimension. 2. We prove the completeness of a single iteration of the vanilla 3-EWL for point clouds in $\mathbb { R } ^ { 3 }$ . 3. We formulate the 2-SEWL and 2-EWL tests, and prove their completeness for point clouds in $\mathbb { R } ^ { 3 }$ .
102
+
103
+ 4. We explain how to build differentiable architectures for point clouds with the same separation power as Euclidean $k$ -WL tests, with reasonable complexity.
104
+
105
+ 2 Experiments In Section 5 we present synthetic experiments that demonstrate that 2-SEWL can
106
+ 3 separate challenging point-cloud pairs that cannot be separated by several popular architectures.
107
+ 94 Disambiguation: Euclidean Graphs In this paper we use a simple definition of a Euclidean graph
108
+ 95 as the centralized Gram matrix of a point cloud, and focus on a fundamental theoretical question
109
+ 96 related to this representation. In the learning literature, terms like ‘geometric graphs’ (not used here)
110
+ 97 could refer to graphs that have both geometric and non-geometric edge and vertex features, or graphs
111
+ 98 where pairwise distances are only available for specific point pairs (edges in an incomplete graph).
112
+
113
+ # 99 1.1 Related Work
114
+
115
+ 100 Euclidean WL Pozdnyakov and Ceriotti [2022] showed that 1-EWL is incomplete for 3-
116
+ 101 dimensional point clouds. Joshi et al. [2022] defines separation for a more general definition
117
+ 102 of geometric graph, which combines geometric and combinatorial features. This work holds various
118
+ 103 interesting insights for this more general problem but they do not prove completeness as we do here.
119
+ 104 Other complete constructions As mentioned earlier, Dym and Maron [2020] proved universality
120
+ 105 with respect to permutations and rigid motions for architectures using high-dimensional represen
121
+ 106 tations of the rotation group. Similar results were obtained inFinkelshtein et al. [2022], Gasteiger
122
+ 107 et al. [2021]. In Lim et al. [2022] universality was proven for Euclidean GNNs with very high-order
123
+ 108 permutation representations. In the planar case $d = 2$ , universality using low-dimensional features
124
+ 109 was achieved in Bökman et al. [2022]. For $d \geq 3$ our construction seems to be the first to achieve
125
+ 110 universality using low dimensional representations.
126
+ 111 For general fixed $d$ , there do exist algorithms that can separate point clouds up to equivalence
127
+ 112 in polynomial time, but they do not seem to lend themselves directly to neural architectures. In
128
+ 113 Kurlin [2022], Widdowson and Kurlin [2023] complete tests are described, but they represent each
129
+ 114 point cloud as a ‘multiset of multisets’ rather than as a vector as we do, and so are not suitable for
130
+ 115 gradient descent based learning. Efficient tests for equivalence of Euclidean graphs were described in
131
+ 116 Brass and Knauer [2000], Arvind and Rattan [2014], but they compute features that do not depend
132
+ 117 continuously on the point cloud.
133
+ 118 Weaker notions of universality In Widdowson and Kurlin [2022] the authors suggest a method
134
+ 119 for distinguishing almost every point clouds up to equivalence, similar to our result here on 1-EWL.
135
+ 120 Similarly, efficient separation/universality can also be obtained for point clouds with distinct principal
136
+ 121 axes Puny et al. [2021], Kurlin [2022]. Another setting in which universality is easier to obtain is
137
+ 122 when only rigid symmetries are considered and permutation symmetries are ignored Wang et al.
138
+ 123 [2022], Villar et al. [2021], Victor Garcia Satorras [2021]. All these results do not provide universality
139
+ 124 for all point clouds, with respect to the joint action of permutations and rigid motions.
140
+
141
+ # 125 Mathematical notation
142
+
143
+ A (finite) multiset $\left\{ { y _ { 1 } , \dotsc , y _ { N } } \right\}$ is an unordered collection of elements where repetitions are allowed.
144
+
145
+ Let $\mathcal { G }$ be a group acting on a set $\mathcal { X }$ . For $X , Y \in { \mathcal { X } }$ , we say that $X = Y$ if $Y = g X$ for some $g \in { \mathcal { G } }$
146
+
147
+ 128 We say that a function $f : \mathcal { X } \mathcal { Y }$ is invariant if $f ( g x ) = f ( x )$ for all $x \in X , g \in G$ . We say that $f$
148
+ 129 is equivariant if $\mathcal { V }$ is also endowed with some action of $G$ and $f ( g x ) = g f ( x )$ for all $x \in \mathcal { X } , g \in \mathcal { G }$
149
+ 30 A separating invariant mapping is an invariant mapping that is injective, up to group equivalence:
150
+
151
+ 131 Definition 1.1 (Separating Invariant). Let $\mathcal { G }$ be a group acting on a set $\mathcal { X }$ . We say $F : \mathcal { X } \to \mathbb { R } ^ { K }$ is a $\mathcal { G }$ - separating invariant with embedding dimension 132 $K$ if for all $X , Y \in { \mathcal { X } }$ , $F ( X ) = F ( Y ) \Leftrightarrow X \frac { \ d Y } { \ d g } Y$ .
152
+
153
+ 133 We focus on the case where $\mathcal { X }$ is some Euclidean domain. To enable gradient-based learning, we
154
+ 134 shall need separating mappings that are continuous everywhere and differentiable almost everywhere.
155
+
156
+ ![](images/669014ea9bdfcfae89a3a9d4d1eebe79fad709f1080f0db81377608134311455.jpg)
157
+ Figure 1: Distance matrices (Left), geometric degree histogram (Right) of pairs of point clouds. The generic pair is a randomly sampled pair of point clouds. Notice each of the nodes in each of the clouds has a distinct geometric degree. The Hard pair exhibits a distinct geometric degree for each node, but only within each point cloud, that is the pair shares an identical geometric degree histogram. The Harder example is a pair of point clouds with identical geometric degree histogram, and each point cloud is comprised of three pairs of points, with each pair having an identical geometric degree. Examples from Pozdnyakov and Ceriotti [2022] and Pozdnyakov et al. [2020].
158
+
159
+ The symmetry group we consider for point clouds $( x _ { 1 } , \ldots , x _ { n } ) \in \mathbb { R } ^ { d \times n }$ is generated by a rotation matrix $R \in S { \mathcal { O } } ( d )$ , and a permutation $\sigma \in S _ { n }$ . These act on a point cloud by
160
+
161
+ $$
162
+ ( R , \sigma ) _ { * } ( x _ { 1 } , \ldots , x _ { n } ) = ( R x _ { \sigma ^ { - 1 } ( 1 ) } , \ldots , R x _ { \sigma ^ { - 1 } ( n ) } ) .
163
+ $$
164
+
165
+ 135 We denote this group by $s \mathcal { O } [ d , n ]$ . In some instances, reflections $R \in { \mathcal { O } } ( d )$ are also permitted,
166
+ 136 leading to a slightly larger symmetry group, which we denote by $\mathcal { O } [ d , n ]$ . Our goal shall be to
167
+ 137 construct separating invariants for these groups. For the sake of brevity, we do not discuss translation
168
+ 138 invariance and separation, as these can easily be achieved by centering the input point clouds, once
169
+ 139 $s \mathcal { O } [ d , n ]$ (or ${ \mathcal { O } } [ d , n ] )$ separating invariants are constructed, see Dym and Gortler [2023].
170
+
171
+ For simplicity of notation, throughout this paper, we focus on the case $d = 3$ . In Appendix $\textrm { C }$ we explain how our constructions and theorems can be generalized to $d > 3$ .
172
+
173
+ # 142 2 Euclidean Graph Isomorphism Tests
174
+
175
+ 143 The $k$ -WL Graph Isomorphism Test Weisfeiler and Leman [1968] is a classical paradigm for testing
176
+ 144 the isomorphism of combinatorial graphs, which we shall now briefly describe. Let $\mathcal { G }$ be a graph with
177
+ 145 vertices indexed by $[ n ] = \{ 1 , 2 , \dots , \bar { n } \}$ . We denote each ordered $k$ -tuple of vertices by a multi-index
178
+ 146 $\mathbf { i } = ( i _ { 1 } , \dots , i _ { k } ) \in [ n ] ^ { k }$ . Essentially, for each such $k$ -tuple i, the test maintains a coloring $\mathbf { C } ( \mathbf { i } )$ that
179
+ 147 belongs to a discrete set, and updates it iteratively. First, the coloring of each $k$ -tuple is assigned an
180
+ 148 initial value that encodes the isomorphism type of the corresponding $k$ -dimensional subgraph:
181
+
182
+ $$
183
+ \mathbf { C } _ { ( 0 ) } = \mathbf { C } _ { ( 0 ) } ( \mathbf { i } ) , \mathbf { i } \in [ n ] ^ { k } .
184
+ $$
185
+
186
+ 149 Then the color of each $k$ -tuple $\mathbf { i }$ is iteratively refined according to the colors of its ‘neighboring’
187
+ 150 $k$ -tuples. The update rule is given by
188
+
189
+ $$
190
+ \mathbf { C } _ { ( \mathsf { t } + 1 ) } ( \mathbf { i } ) = \mathbf { E m b e d } ^ { ( t + 1 ) } \left( \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } ) , \ P \left( \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } [ j \setminus 1 ] ) , \ldots , \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } [ j \setminus k ] ) \right) \mid j \in [ n ] \ P \right) ,
191
+ $$
192
+
193
+ where $\mathbf { i } [ j \mathbf { \theta } \backslash t ]$ is the multi-index i with its $t$ -th coordinate replaced by $j$ ; e.g. for $j = 1$ , $\mathbf { i } [ j \setminus 1 ] =$ $( j , i _ { 2 } , \ldots , i _ { k } )$ . Embed is a function that maps its input injectively to some discrete set. This process is repeated $T$ times to obtain a final coloring $\mathfrak { Y } \mathbf { C } _ { ( \mathbf { T } ) } ( \mathbf { i } ) \mathbb { Y } _ { \mathbf { i } \in [ n ] ^ { k } }$ . A global label is then calculated by
194
+
195
+ $$
196
+ \mathbf { C } _ { \mathcal { G } } = \mathbf { E m b e d } ^ { ( T + 1 ) } \left( \left\{ \mathbf { C } _ { ( \mathbf { T } ) } ( \mathbf { i } ) \ | \ \mathbf { i } \in [ n ] ^ { k } \right\} \right) ,
197
+ $$
198
+
199
+ where 151 $\mathbf { E m b e d } ^ { ( T + 1 ) }$ is a function that maps label-multisets injectively to some discrete set.
200
+
201
+ 152 To test whether two graphs $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ are isomorphic, the $k$ -WL test computes the corresponding
202
+ 153 colorings $\mathbf { C } _ { \mathcal { G } }$ and $\mathbf { C } _ { \mathcal { G } ^ { \prime } }$ for some chosen $T$ . If $\mathbf { C } _ { \mathcal { G } } \neq \mathbf { C } _ { \mathcal { G } ^ { \prime } }$ then $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ are guaranteed not to be
203
+ 154 isomorphic, whereas if $\mathbf { C } _ { \mathcal { G } } = \mathbf { C } _ { \mathcal { G } ^ { \prime } }$ , then $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ may either be isomorphic or not, and the test does
204
+ 155 not, in general, provide a decisive answer for combinatorial graphs. It is known that this test is able
205
+ 156 to distinguish a strictly larger class of combinatorial graphs for every strict increase in the value of $\mathrm { k }$ ,
206
+ 157 i.e. it is a strict hierarchy of tests in terms of distinguishing power Cai et al. [1992], Grohe [2017].
207
+ 158 Vanilla- $k$ -WL tests As a first step from a combinatorial to a Euclidean setting, we identify each
208
+ 159 point cloud $\boldsymbol { X } = ( x _ { 1 } , \ldots , x _ { n } ) \in \mathbb { R } ^ { { \hat { d } } \times n }$ with a complete graph on $n$ vertices, wherein each edge $( i , j )$
209
+ 160 is endowed with the weight $w _ { i j } ( X ) = \langle x _ { i } , x _ { j } \rangle$ . We name such a graph a Euclidean graph. Similarly
210
+ 161 to $k$ -WL for combinatorial graphs, $k$ -WL for Euclidean graphs maintains a coloring of the $k$ -tuples of
211
+ 162 vertices. However, the initial color of each $k$ -tuple i is not a discrete label as in the combinatorial case,
212
+ 163 but rather a $k \times k$ matrix of continuous features, which represent all edge weights $w _ { i j }$ corresponding
213
+ 164 to pairs of indices from i. We will call the $k$ -WL test defined by this initial coloring the vanilla $k$ -WL
214
+ 165 test. This test is invariant by construction to reflections, rotations, and permutations. We note that our
215
+ 166 definition of the vanilla $k$ -EWL test via inner products follows that of Lim et al. [2022]. Another
216
+ 167 popular, and essentially equivalent, formulation, uses distances instead.
217
+ 168 $k$ -EWL tests An inherent limitation of the Vanilla-1-EWL test is that no pairwise Euclidean
218
+ 169 information is passed, yielding it rather uninformative. Indeed, Pozdnyakov and Ceriotti [2022]
219
+ 170 proposed a Euclidean analog of the 1-WL test, where the update rule (2) is replaced with
220
+
221
+ $$
222
+ { \bf C } _ { \left( { \bf t } + { \bf 1 } \right) } ( i ) = { \bf E m b e d } ^ { \left( { \bf t } \right) } \left( { \bf C } _ { \left( { \bf t } \right) } ( i ) , \left\{ \left( { \bf C } _ { \left( { \bf t } \right) } ( j ) , \left. x _ { i } - x _ { j } \right. \right) , j \neq i \right\} \right) .
223
+ $$
224
+
225
+ 171 We call this test the 1-EWL test. This formulation is motivated by the fact that many symmetry
226
+ 172 preserving networks for point clouds are in fact a realization of it, though they use Embed functions
227
+ 173 that are continuous and, in general, may assign the same value to different multisets. Consequently,
228
+ 174 the separation power of these architectures is at most that of 1-EWL with discrete injective hash
229
+ 175 functions. Moreover, the separation power will be equivalent if continuous injective multiset functions
230
+ 176 are used for embedding, as we discuss in Section 4.
231
+ 177 The 1-EWL test strengthens the Vanilla-1-EWL test by allowing the messages passed to a node
232
+ 178 in each step to contain not only previous colorings but also geometric information in the form of
233
+ 179 pairwise distances. More generally, we shall use the term $k$ -EWL to refer to tests that follow the
234
+ 180 Euclidean $k$ -WL paradigm, but incorporate geometric invariants into the message-passing procedure.
235
+ 181 In particular, for point clouds with dimension 3, we define the 2-SEWL test (’SE’ for Special
236
+ 182 Euclidean) by replacing the update step (2) with
237
+
238
+ $$
239
+ \mathbf { C } _ { ( \mathsf { t } + 1 ) } ( i , j ) = \mathbf { E m b e d } ^ { ( t ) } \left( \mathbf { C } _ { ( \mathsf { t } ) } ( i , j ) , \ P \left( \mathbf { C } _ { ( \mathsf { t } ) } ( k , j ) , \mathbf { C } _ { ( \mathsf { t } ) } ( i , k ) , \langle x _ { i } \times x _ { j } , x _ { k } \rangle \right) \ P _ { k = 1 } ^ { n } \right) .
240
+ $$
241
+
242
+ 83 Note that $\langle x _ { i } \times x _ { j } , x _ { k } \rangle$ is equal to the determinant of the $3 \times 3$ matrix whose rows are the three vectors
243
+ 84 $x _ { i } , x _ { j } , x _ { k }$ , which makes this a natural choice as all polynomial invariants of $s \mathcal { O } ( 3 )$ are generated by
244
+ 85 these determinants and the inner products we use for the initial coloring Kraft and Procesi [1996].
245
+ 186 We note that, Using the fact that $O ( 3 )$ is just two copies of $S O ( 3 )$ , it is not difficult to generalize
246
+ 187 2-SEWL to a complete $\mathcal { O } [ 3 , n ]$ test, which we name 2-EWL. for general $d$ , similar complete $( d - 1 )$ -
247
+ 188 SEWL and $( d - 1 )$ -EWL tests can be formulated for point clouds in $\mathbb { R } ^ { d }$ via the Hodge-star operator;
248
+ 189 see Appendix C for more details.
249
+ 190 In the rest of this section, we shall prove that the 2-SEWL, 2-EWL and vanilla 3-EWL tests are
250
+ 191 complete when applied to $\mathbb { R } ^ { 3 \times n }$ , even when using a single iteration $T = 1$ ). We shall also show that
251
+ 192 two iterations of the 1-EWL test is complete, except on a set of measure zero.
252
+
253
+ # 193 2.1 Generic completeness of 1-EWL
254
+
255
+ The separation power of 1-EWL is closely linked to the notion of geometric degree: For a point cloud $X = ( x _ { 1 } , \ldots , x _ { n } )$ , we define the geometric degree $d ( i , X )$ of the $i$ th point, and the induced geometric degree histogram $d _ { H } ( X )$ , to be the multisets
256
+
257
+ $$
258
+ d ( i , X ) = \{ \| x _ { 1 } - x _ { i } \| , \ldots , \| x _ { n } - x _ { i } \| \} , \quad d _ { H } ( X ) = \{ d ( 1 , X ) , \ldots , d ( n , X ) \} .
259
+ $$
260
+
261
+ It is not difficult to see that if $d _ { H } ( X ) \neq d _ { H } ( Y )$ then $X$ and $Y$ can be separated by a single 1-EWL iteration . An example of such a pair is shown in the left of Figure 1. With two 1-EWL iterations, we show that can separate $X$ and $Y$ even if $d _ { H } ( X ) = d _ { H } ( Y )$ , provided that they both belong to the set of point clouds defined by
262
+
263
+ $$
264
+ \mathbb { R } _ { d i s t i n c t } ^ { 3 \times n } = \{ X \in \mathbb { R } ^ { 3 \times n } | d ( i , X ) \neq d ( j , X ) \ \forall i \neq j \} .
265
+ $$
266
+
267
+ 94 Such an example, taken from Pozdnyakov et al. [2020], is visualized in the middle column of Figure
268
+
269
+ Theorem 2.1. Two iterations of the 1-EWL test assign two point clouds $\mathcal { X } , Y \in \mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ the same $X \underset { \mathcal { O } [ 3 , n ] } { = } Y$
270
+
271
+ In the appendix we show that the complement of 198 $\mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ has measure zero. Thus this result complements long-standing results for combinatorial graphs, stating that 1-WL can classify almost 200 all such graphs as the number of nodes tends to infinity Babai et al. [1980].
272
+
273
+ The right-most pair of point clouds (’Harder’) in Figure 1 is taken from Pozdnyakov and Ceriotti [2022]. The degree histograms of these point clouds are identical, and they are not in $\mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ . Pozdnyakov and Ceriotti [2022] show that this pair cannot be separated by any number of 1-EWL iterations.
274
+
275
+ # 2.2 Is 1-EWL All You Need?
276
+
277
+ Theorem 2.1 shows that the probability of a failure of the 1-EWL is zero. A natural question to ask is whether more powerful tests are needed. We believe the answer to this question is yes. Typical hypothesis classes used for machine learning, such as neural networks, are Lipschitz continuous Gama et al. [2020]. In this setting, failure to separate on a measure zero set could have implications for non-trivial positive measure. This phenomenon is depicted in the figure in the inset. On the right, a plot of a Gaussian distribution centered at $x \in \mathbb { R }$ , depicting a target function is shown in blue. In red, a schematic plot of how a Lipschitz continuous function that does not distinguish $x$ from $y$ would model the target function.
278
+
279
+ ![](images/e2038e59f05f70d7e4b89040a148a46c0e26959eaf0c74509809f79752553fc9.jpg)
280
+
281
+ # 3 2-SEWL and Vanilla 3-EWL are complete
282
+
283
+ We now prove that the vanilla 3-EWL test is complete.
284
+
285
+ Theorem 3.1. For every $X , Y \in \mathbb { R } ^ { 3 \times n }$ , a single iteration of the vanilla 3-EWL test assigns $X$ and $Y$ the same value if and only if $\cdot _ { X } \underset { \mathcal { O } [ 3 , n ] } { = } Y$ .
286
+
287
+ Proof. First, it is clear that if $X \_ { \phantom { } _ { \mathcal { O } [ 3 . n ] } } Y$ then $\mathbf { C } _ { \mathcal { G } } ( X ) = \mathbf { C } _ { \mathcal { G } } ( Y )$ since the vanilla 3-EWL test is invariant by construction. The challenge is proving the other direction. To this end, let us assume that $\mathbf { C } _ { \mathcal { G } } ( X ) = \mathbf { C } _ { \mathcal { G } } ( Y )$ , and assume without loss of generality that $r : = \mathrm { r a n k } ( X ) \geq \mathrm { r a n k } ( Y )$ . Note that $X$ has rank $r \leq 3$ , and so it must contain some three points whose rank is also $r$ . By applying a permutation to $X$ we can assume without loss of generality that these three points are the first three points. The initial coloring ${ \bf C _ { 0 } } ( 1 , 2 , 3 ) ( X )$ of this triplet is their Gram matrix $( \langle x _ { i } , x _ { j } \rangle ) _ { 1 \leq i , j \leq 3 }$ , which has the same rank $r$ as the space spanned by the three points. Next, since $\mathbf { C } _ { \mathcal { G } } ( X ) = \bar { \mathbf { C } } _ { \mathcal { G } } ( \bar { Y } )$ are the same, there exists a triplet of points $i , j , k$ such that $\mathbf { C } _ { ( 1 ) } ( 1 , 2 , 3 ) ( X ) = \mathbf { C } _ { ( 1 ) } ( i , j , k ) ( Y )$ which implies that the initial colorings are also the same. By applying a permutation to $Y$ we can assume without loss of generality that $i = 1 , j = 2 , k = 3$ . Next, since the Gram matrix of $x _ { 1 } , x _ { 2 } , x _ { 3 }$ and $y _ { 1 } , y _ { 2 } , y _ { 3 }$ are identical, there is an orthogonal transformation that takes $x _ { i }$ to $y _ { i }$ for $i = { 1 , 2 , 3 }$ , and by applying this transformation to all points in $X$ we can assume without loss of generality that $x _ { i } = y _ { i }$ for $i = { 1 , 2 , 3 }$ . It remains to show that the rest of the points of $X$ and $Y$ are equal, up to permutation. To see this, first note that $X$ and $Y$ have the same rank since
288
+
289
+ $$
290
+ r = \operatorname { r a n k } ( X ) \geq \operatorname { r a n k } ( Y ) \geq \operatorname { r a n k } ( y _ { 1 } , y _ { 2 } , y _ { 3 } ) = \operatorname { r a n k } ( x _ { 1 } , x _ { 2 } , x _ { 3 } ) = r .
291
+ $$
292
+
293
+ Thus the space spanned by $x _ { 1 } = y _ { 1 } , x _ { 2 } = y _ { 2 } , x _ { 3 } = y _ { 3 }$ contains all points in $X$ and $Y$ . Next, we can deduce from the aggregation rule defining $\mathbf { C _ { 1 } } ( 1 , 2 , 3 ) ( X )$ in (2), that
294
+
295
+ $$
296
+ \begin{array} { r } { \sharp ( \langle x _ { j } , x _ { 1 } \rangle , \langle x _ { j } , x _ { 2 } \rangle , \langle x _ { j } , x _ { 3 } \rangle ) \mid j \in [ n ] \mathbb { J } = \mathbb { f } ( \langle y _ { j } , y _ { 1 } \rangle , \langle y _ { j } , y _ { 2 } \rangle , \langle y _ { j } , y _ { 3 } \rangle ) \mid j \in [ n ] \mathbb { J } . } \end{array}
297
+ $$
298
+
299
+ 222 Since all points in $X$ and $Y$ belong to the span of $x _ { 1 } = y _ { 1 } , x _ { 2 } = y _ { 2 } , x _ { 3 } = y _ { 3 }$ , $X$ and $Y$ are the same
300
+ 223 up to permutation of the last $n - 3$ coordinates. This concludes the proof of the theorem. □
301
+
302
+ 224 We next outline the completeness proof of the more efficient 2-SEWL.
303
+
304
+ Theorem 3.2. For every 25 $X , Y \in \mathbb { R } ^ { 3 \times n }$ , a single iteration of the 2-SEWL test assigns $X$ and $Y$ the same value if and only if 26 $X _ { \_ { S O [ 3 , n ] } } Y$ .
305
+
306
+ Proof idea. The completeness of Vanilla-3-EWL was based on the fact that its initial coloring captures the Gram matrix of triplets of vectors that span the space spanned by $X$ , and on the availability of projections onto this basis in the aggregation step defined in (2). Our proof for 2-EWL completeness relies on the fact that a pair of non-degenerate vectors $x _ { i } , x _ { j }$ induces a basis $x _ { i } , x _ { j } , x _ { i } \times x _ { j }$ of $\mathbb { R } ^ { 3 }$ The Gram matrix of this basis can be recovered from the Gram matrix of the first two points $x _ { i } , x _ { j }$ and the projection onto this basis can be obtained from the extra geometric information we added in (18). A full proof is given in the appendix. □
307
+
308
+ To conclude this section, we note that the above theorem can be readily used to also show that the 2-EWL test us also complete with respect to $\mathcal { O } [ 3 , n ]$ . For details see Appendix A.
309
+
310
+ # 236 4 WL-equivalent GNNs with continuous features
311
+
312
+ In the previous section we discussed the generic completeness of 1-EWL and the completeness of 2-SEWL and vanilla 3-EWL. The Embed functions in these tests are hash functions, which can be redefined independently for each pair of point clouds $X , Y$ . In this section, our goal is to explain how to construct GNNs with equivalent separation power to that of these tests, while choosing continuous, piecewise differentiable Embed functions that are injective. While this question is well studied for combinatorial graphs with discrete features Xu et al. [2018], Morris et al. [2018], Maron et al. [2019], Aamand et al. [2022], here we focus on addressing it for Euclidean graphs with continuous features.
313
+
314
+ # 44 4.1 Multiset injective functions
315
+
316
+ 245 Let us first review some known results on injective multiset functions. Recall that a function defined on
317
+ 246 multisets with $n$ elements coming from some alphabet $\Omega \subseteq \mathbb { R } ^ { D }$ can be identified with a permutation
318
+ 247 invariant function defined on $\Omega ^ { n }$ . A multiset function is injective if and only if its corresponding
319
+ 248 function on $\Omega ^ { n }$ is separating with respect to the action of the permutation group (see Definition 1.1).
320
+ 249 In Corso et al. [2020], Wagstaff et al. [2022] it was shown that for any separating, permutation
321
+ 250 invariant mappings from $\mathbb { R } ^ { n }$ to $\mathbb { R } ^ { K }$ , the embedding dimension $K$ will be at least $n$ . Two famous
322
+ 251 examples of continuous functions that achieve this bound are
323
+
324
+ $$
325
+ \Psi _ { s o r t } ( x _ { 1 } , \ldots , x _ { n } ) = \mathrm { s o r t } ( x _ { 1 } , \ldots , x _ { n } ) \quad { \mathrm { a n d } } \quad \Psi _ { p o w } ( x _ { 1 } , \ldots , x _ { n } ) = \left( \sum _ { i = 1 } ^ { n } x _ { i } ^ { t } \right) _ { t = 1 } ^ { n } .
326
+ $$
327
+
328
+ 252 When the multiset elements are in $\mathbb { R } ^ { D }$ , the picture is similar: if there exists a continuous, permutation
329
+ 253 invariant and separating mapping from $\mathbb { R } ^ { D \times n }$ to $\mathbb { R } ^ { K }$ , then necessarily $K \geq n \cdot D$ Joshi et al. [2022].
330
+ 254 In Dym and Gortler [2023] it is shown that continuous separating invariants for $D > 1$ , with near
331
+ 255 optimal dimension, can be derived from the $D = 1$ separating invariants $\Psi = \Psi _ { p o w }$ or $\Psi = \Psi _ { s o r t }$ ,
332
+ 256 by considering random invariants of the form
333
+
334
+ $$
335
+ \mathbf { E m b e d } _ { \theta } ( x _ { 1 } , \dots , x _ { n } ) = \langle b _ { j } , \Psi \left( a _ { j } ^ { T } x _ { 1 } \dots , a _ { j } ^ { T } x _ { n } \right) \rangle , j = 1 , \dots , K .
336
+ $$
337
+
338
+ 257 where each $a _ { j }$ and $b _ { j }$ are $d$ and $n$ dimensional random vectors, and we denote $\theta \quad =$
339
+ 258 $( a _ { 1 } , \dots , a _ { K } , b _ { 1 } , \dots , b _ { K } ) \in \mathbb { R } ^ { K ( D + n ) }$ . When $K = 2 n D + 1$ , for almost any choice of $\theta$ , the
340
+ 259 function $\mathbf { E m b e d } _ { \theta }$ will be separating on $\mathbb { R } ^ { D \times n }$ . Thus the embedding dimension in this construction is
341
+ 260 optimal up to a multiplicative constant of two.
342
+ 261 An important property of this results of Dym and Gortler [2023] for our discussion, is that the
343
+ 262 embedding dimension $K$ can be reduced if the domain of interest is a non-linear subset of $\mathbb { R } ^ { D \times n }$
344
+ 263 of low dimension. For example, if the domain of interest is a finite union of lines in $\mathbb { R } ^ { D \times n }$ , then
345
+ 264 the instrinsic dimension of the domain is 1, and so we will only need an embedding dimension of
346
+ 265 $K = 2 \cdot 1 + 1 = 3$ . Thus, the required embedding dimension depends on the intrinsic dimension of
347
+ 266 the domain rather than on its ambient dimension, which in our case is $n \cdot D$ .
348
+ 267 To formulate these results precisely we will need to introduce some real algebraic geometry terminol
349
+ 268 ogy (see Basu et al. [2006] for more details): A semi-algebraic subset of a real finite-dimensional
350
+ 269 vector space is a finite union of subsets that are defined by polynomial equality and inequality
351
+ 270 constraints. For example, polygons, hyperplanes, spheres, and finite unions of these sets, are all
352
+ 271 semi-algebraic sets. A semi-algebraic set is always a finite union of manifolds, and its dimension is
353
+ 272 the maximal dimension of the manifolds in this union. Using these notions, we can now state the
354
+ 273 ‘intrinsic version’ of the results in Dym and Gortler [2023]:
355
+ 74 Theorem 4.1 (Dym and Gortler [2023]). Let $\mathcal { X }$ be an $S _ { n }$ -invariant semi-algebraic subset of $\mathbb { R } ^ { D \times n }$ of
356
+ 75 dimension $D _ { \mathcal { X } }$ . Denote $K = 2 D _ { \mathcal { X } } + 1$ . Then for Lebesgue almost every $\bar { \theta \in \mathbb { R } ^ { K ( D + n ) } }$ the mapping
357
+ 76 $E m b e d _ { \theta } : \mathcal { X } \mathbb { R } ^ { K }$ is $S _ { n }$ invariant and separating.
358
+
359
+ # 4.2 Multiset injective functions for GNNs
360
+
361
+ 78 We now return to discuss GNNs and explain the importance of the distinction between the intrinsic and ambient dimensions in our context. Suppose we are given 279 $n$ initial features $( h _ { 1 } ^ { ( 0 ) } , \ldots , h _ { n } ^ { ( 0 ) } )$ in 80 $\mathbb { R } ^ { d }$ , and for simplicity let us assume they are recursively refined via the simple aggregation rule:
362
+
363
+ $$
364
+ h _ { i } ^ { ( t + 1 ) } = \mathbf { E m b e d } ^ { ( t ) } \left( \{ h _ { j } ^ { ( t ) } \} _ { j = 1 , j \neq i } ^ { n } \right) .
365
+ $$
366
+
367
+ 281 Let us assume that each $\mathbf { E m b e d } ^ { ( t ) }$ is injective on the space of all multisets with $n - 1$ elements in
368
+ 282 the ambient space of ${ h } _ { j } ^ { ( t ) }$ . Then the injectivity of $\mathbf { E m b e d } ^ { ( 1 ) }$ implies that $h _ { i } ^ { ( 1 ) }$ is of dimension at least
369
+ 283 $( n - 1 ) \cdot d$ . The requirement that $\mathbf { E m b e d } ^ { ( 2 ) }$ is injective on a mult-set of $n - 1$ features in $\mathbb { R } ^ { ( n - 1 ) \cdot d }$
370
+ 284 implies that ${ h } _ { i } ^ { ( 2 ) }$ will be of dimension at least $( n - 1 ) ^ { 2 } \cdot d$ . Continuing recursively with this argument
371
+ 285 we obtain an estimate of $\sim ( n - 1 ) ^ { T } d$ for the dimensions of each $h _ { i } ^ { ( T ) }$ after $T$ iterations of (7).
372
+
373
+ Fortunately the analysis presented above is overly pessimistic, because it focused only on 9 the ambient dimension. Let us denote the matrix containing all $n$ features at time $t$ by $H ^ { ( t ) }$ . Then $H ^ { ( t ) } = \bar { F _ { t } } ( H ^ { ( 0 ) } )$ , where $F _ { t }$ is the con2 catenation of all $\mathbf { E m b e d } ^ { ( t ^ { \prime } ) }$ functions from all 3 previous time-steps. Thus $H ^ { ( t ) }$ resides in the set $\mathbf { \widehat { F } } _ { t } ( \mathbb { R } ^ { d \times n } )$ . Here we again rely on results from algebraic geometry: if $F _ { t }$ is a composition of piecewise linear and polynomial mappings, then it is a semi-algebraic mapping, which means that $F _ { t } ( H ^ { ( 0 ) } )$ will be a semi-algebraic set of di9 mension $\mathrm { d i m } ( \mathbb { R } ^ { n \times d } ) = n \cdot d$ . This point will be 0 explained in more detail in the proof of Theorem 4.2. By Theorem 4.1 we can then use $\mathbf { E m b e d } _ { \theta }$ as a multiset injective function on $\mathcal { X } _ { t }$ with a fixed embedding dimension of $2 n \cdot d + 1$ which does not depend on $T$ . This is visualized in Figure 2.
374
+
375
+ ![](images/55233fb32c73b264590f496c5a0ea16351dfd20a2210362779987f3b803cfd7c.jpg)
376
+ Figure 2: The exponential growth in the dimension that would result from only considering the ambient feature dimension can be avoided by exploiting the constant intrinsic dimension.
377
+
378
+ 2-SEWLnet Based on the discussion above, we can devise architectures that simulate the various tests discussed in this paper and have reasonable feature dimensions throughout the construction, In particular, we can simulate $T$ iterations of the 2-SEWL test by replacing all $\mathbf { E m b e d } ^ { ( t ) }$ functions1with $\mathbf { E m b e d } _ { \theta } ^ { ( t ) }$ , where in our implementation we choose $\Psi = \Psi _ { s o r t }$ in (6). The embedding dimension for all $t$ is taken to be $6 n + 1$ , since the input is in $\mathbb { R } ^ { 3 \times n }$ . We denote the obtained parametric function by $F _ { \phi }$ . Based on a formalization of the discussion above, we prove in the appendix that $F _ { \phi }$ has the separation power of the complete 2-SEWL test, and therefore $F _ { \phi }$ is separating.
379
+
380
+ 10 Theorem 4.2. Let $F _ { \phi }$ denote the parametric function simulating the 2-SEWL test. Then for Lebesgue almost every 311 $\phi$ the function $F _ { \phi } : \mathbb { R } ^ { 3 \times n } \mathbb { R } ^ { 6 n + 1 }$ is separating with respect to the action of $s \mathcal { O } [ 3 , n ]$
381
+
382
+ To conclude this subsection, we note that while sort-based permutation invariants are used as aggregators in GNNs Zhang et al. [2020, 2018], Blondel et al. [2020], the polynomial-based aggregators $\Psi _ { p o w }$ are not as common. To a certain extent, one can use the approach in $\mathrm { X u }$ et al. [2018], Maron et al. [2019], replace the polynomials in $\Psi _ { p o w }$ by MLPs, and justify this by the universal approximation power of MLPs. A limitation of this approach is that it only guarantees separation at the limit.
383
+
384
+ # 317 5 Synthetic Experiments
385
+
386
+ In this section we implement 2-SEWLnet, described in Section 4, and empirically evaluate its separation power, and the separation power of alternative $s \mathcal { O } [ 3 , n ]$ invariant point cloud architectures. We trained the architectures on permuted and rotated variations of highly-challenging point-cloud pairs, and measured separation by the test classification accuracy. We considered three pairs of point clouds (Hard1-Hard3) from Pozdnyakov et al. [2020]. These pairs were designed to be challenging for distance-based invariant methods. However, our analysis reveals that they are in fact separable by two iterations of the 1-EWL test. We then consider a pair of point clouds from Pozdnyakov and Ceriotti [2022] which was proven to be indstinguishable by the 1-EWL tests. The results of this experiment are given in Table 1. Further details on the experimental setup appear in Appendix B.
387
+
388
+ Table 1: Separation accuracy on challenging 3D point clouds. Hard examples correspond to point clouds which cannot be distinguished by a single 1-EWL iteration but can be distinguished by two iterations, according to Theorem 2.1. The Harder example is a point cloud not distinguishable by 1-EWL Pozdnyakov and Ceriotti [2022]. GNN implementations and code pipeline based on Joshi et al. [2022].
389
+
390
+ <table><tr><td>Separation</td><td>complete</td><td>≌1-EWL</td><td>unknown</td><td>unknown</td><td>unknown</td></tr><tr><td>Point Clouds</td><td>2-SEWLnet</td><td>EGNN</td><td>MACE</td><td>TFN</td><td>GVPGNN</td></tr><tr><td>Hard1</td><td>100 %</td><td>100 %</td><td>100%</td><td>100 %</td><td>100 %</td></tr><tr><td>Hard2</td><td>100 %</td><td>100 %</td><td>100 %</td><td>100 %</td><td>50%</td></tr><tr><td>Hard3</td><td>100 %</td><td>100 %</td><td>100 %</td><td>100 %</td><td>95.0 ± 15.0 %</td></tr><tr><td>Harder</td><td>100 %</td><td>50%</td><td>100 %</td><td>100 %</td><td>53.7 ± 13.1 %</td></tr></table>
391
+
392
+ 327 As expected, we find that 2-SEWLnet, which has complete separation power, succeeded in perfectly
393
+ 328 separating all examples. We also found that EGNN Victor Garcia Satorras [2021], which is essentially
394
+ 329 an implementation of 1-EWL, does not separate the Harder example, but does separate the Hard
395
+ 330 example after two iterations, as predicted by Theorem 2.1. We also considered three additional
396
+ 331 invariant point cloud models whose separation power is not as well understood. We find that MACE
397
+ 332 Batatia et al. [2022] and TFN Thomas et al. [2018] achieve perfect separation, (when applying them
398
+ 333 with at least 3-order correlations and three-order $S O ( 3 )$ representations). The third GVPGNN Jing
399
+ 334 et al. [2021] architecture attains mixed results. We note that we cannot necessarily deduce from our
400
+ 335 empirical results that MACE and TFN are complete. While it is true that TFN is complete when
401
+ 336 considering arbitrarily high order representations Dym and Maron [2020], it is not clear whether
402
+ 337 order three representation suffices for complete separation. We conjecture that this is not the case.
403
+ 338 However, finding counterexamples is a challenging problem we leave for future work.
404
+
405
+ Future Work In this work, we presented several invariant tests for point clouds that are provably complete, and have presented and implemented 2-SEWL-net which simulates the complete 2-SEWL test. Currently, this is a basic implementation that only serves to corroborate our theoretical results. A practically useful implementation requires addressing several challenges, including dealing with point clouds of different sizes, the non-trivial $\sim n ^ { 4 }$ complexity of computing even the relatively efficient 2-SEWL-net, and finding learning tasks where complete separation leads to gains in performance. We are actively researching these directions and hope this paper will inspire others to do the same.
406
+
407
+ References
408
+ 347 Patrick Reiser, Marlen Neubert, Andr’e Eberhard, Luca Torresi, Chen Zhou, Chen Shao, Houssam Metni, Clint van Hoesel, Henrik Schopmans, Timo Sommer, and Pascal Friederich. Graph neural networks for materials science and chemistry. Communications Materials, 3(1):93, 2022. doi: 10.1038/s43246-022-00315-6. Zixuan Yi, Iadh Ounis, and Craig Macdonald. Graph contrastive learning with positional representation for recommendation. In Jaap Kamps, Lorraine Goeuriot, Fabio Crestani, Maria Maistro, Hideo Joho, Brian Davis, Cathal Gurrin, Udo Kruschwitz, and Annalina Caputo, editors, Advances in Information Retrieval, pages 288–303, Cham, 2023. Springer Nature Switzerland. ISBN 978-3-031-28238-6.
409
+ 356 Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. CoRR, 2017. Limei Wang, Yi Liu, Yuchao Lin, Haoran Liu, and Shuiwang Ji. Comenet: Towards complete and efficient message passing for 3d molecular graphs, 2022.
410
+ 360 Marc Finzi, Max Welling, and Andrew Gordon Wilson. A practical method for constructing equivariant multilayer perceptrons for arbitrary matrix groups. arXiv preprint arXiv:2104.09459, 2021.
411
+ 362 Xu Ma, Yuqian Zhou, Huan Wang, Can Qin, Bin Sun, Chang Liu, and Yun Fu. Image as set of points, 2023.
412
+ 364 Soledad Villar, David W Hogg, Kate Storey-Fisher, Weichi Yao, and Ben Blum-Smith. Scalars are universal: Equivariant machine learning, structured like classical physics. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, volume 34, pages 28848–28863. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper_files/paper/2021/file/ f1b0775946bc0329b35b823b86eeb5f5-Paper.pdf. Chaitanya K. Joshi, Cristian Bodnar, Simon V. Mathis, Taco Cohen, and Pietro Liò. On the expressive power of geometric graph neural networks. NeurIPS Workshop on Symmetry and Geometry in Neural Representations, 2022.
413
+ 373 Zhengdao Chen, Soledad Villar, Lei Chen, and Joan Bruna. On the equivalence between graph isomorphism testing and function approximation with gnns. Advances in neural information processing systems, 32, 2019.
414
+ 376 Nadav Dym and Haggai Maron. On the universality of rotation equivariant point cloud networks. ArXiv, abs/2010.02449, 2020.
415
+ 378 Nathaniel Thomas, Tess Smidt, Steven Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation-and translation-equivariant neural networks for 3d point clouds. arXiv preprint arXiv:1802.08219, 2018. Derek Lim, Joshua Robinson, Lingxiao Zhao, Tess Smidt, Suvrit Sra, Haggai Maron, and Stefanie Jegelka. Sign and basis invariant networks for spectral graph representation learning. arXiv preprint arXiv:2202.13013, 2022. Sergey N. Pozdnyakov and Michele Ceriotti. Incompleteness of graph neural networks for points clouds in three dimensions, 2022. Vikraman Arvind and Gaurav Rattan. The complexity of geometric graph isomorphism. In Electron. Colloquium Comput. Complex., volume 21, page 70, 2014. Nadav Dym and Shahar Ziv Kovalsky. Linearly converging quasi branch and bound algorithms for global rigid registration. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1628–1636, 2019.
416
+ 391 V. Kurlin. Computable complete invariants for finite clouds of unlabeled points under euclidean isometry. ArXiv, abs/2207.08502, 2022.
417
+ 393 Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gurkirt Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. arXiv preprint arXiv:1810.02244, 2018.
418
+ 396 Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks, 2019. URL https://arxiv.org/abs/1905.11136. Emiel Hoogeboom. Max Welling Victor Garcia Satorras. E(n) equivariant graph neural networks. Proceedings of the 38-th International Conference on Machine Learning, PMLR(139), 2021. Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper_ files/paper/2017/file/303ed4c69846ab36c2904d3ba8573050-Paper.pdf. Yael Kapon, Abhijit Saha, Tal Duanis-Assaf, Thijs Stuyver, Amir Ziv, Tzuriel Metzger, Shira Yochelis, Sason Shaik, Ron Naaman, Meital Reches, et al. Evidence for new enantiospecific interaction force in chiral biomolecules. Chem, 7(10):2787–2799, 2021. Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks?, 2018.
419
+ 411 Nadav Dym and Steven J. Gortler. Low dimensional invariant embeddings for universal geometric learning, 2023.
420
+ 413 Ben Finkelshtein, Chaim Baskin, Haggai Maron, and Nadav Dym. A simple and universal rotation equivariant point-cloud network. arXiv preprint arXiv:2203.01216, 2022.
421
+ 415 Johannes Gasteiger, Florian Becker, and Stephan Günnemann. Gemnet: Universal directional graph neural networks for molecules, 2021. URL https://arxiv.org/abs/2106.08903. Georg Bökman, Fredrik Kahl, and Axel Flinth. Zz-net: A universal rotation equivariant architecture for 2d point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10976–10985, 2022. Daniel Widdowson and Vitaliy Kurlin. Recognizing rigid patterns of unlabeled point clouds by complete and continuous isometry invariants with no false negatives and no false positives. arXiv preprint arXiv:2303.15385, 2023.
422
+ 423 Peter Brass and Christian Knauer. Testing the congruence of d-dimensional point sets. In Proceedings of the sixteenth annual symposium on Computational geometry, pages 310–314, 2000.
423
+ 425 Daniel Widdowson and Vitaliy Kurlin. Resolving the data ambiguity for periodic crystals. In Advances in Neural Information Processing Systems, 2022.
424
+ 427 Omri Puny, Matan Atzmon, Edward J Smith, Ishan Misra, Aditya Grover, Heli Ben-Hamu, and Yaron Lipman. Frame averaging for invariant and equivariant network design. In International Conference on Learning Representations, 2021.
425
+ 430 Sergey N Pozdnyakov, Michael J Willatt, Albert P Bartók, Christoph Ortner, Gábor Csányi, and Michele Ceriotti. Incompleteness of atomic structure representations. Physical Review Letters, 125(16):166001, 2020.
426
+ 433 Boris Weisfeiler and A. A. Leman. The reduction of a graph to canonical form and the algebra which appears therein. Nauchno-Technicheskaya Informatsia, 2:12–16, 1968.
427
+ 435 Jin-Yi Cai, Martin Fürer, and Neil Immerman. An optimal lower bound on the number of variables for graph identification. Combinatorica, 12(4):389–410, 1992. doi: 10.1007/BF01305232.
428
+ 437 Martin Grohe. Descriptive complexity, canonisation, and definable graph structure theory, volume 47. Cambridge University Press, 2017.
429
+
430
+ 439 Hanspeter Kraft and Claudio Procesi. Classical invariant theory, a primer. Lecture Notes. Preliminary
431
+ 440 version, 1996.
432
+ 441 László Babai, Paul Erdos, and Stanley M Selkow. Random graph isomorphism. ˝ SIAM Journal on
433
+ 442 Computing, 9(3):628–635, 1980.
434
+ 443 Fernando Gama, Joan Bruna, and Alejandro Ribeiro. Stability properties of graph neural networks.
435
+ 444 IEEE Transactions on Signal Processing, 68:5680–5695, 2020. doi: 10.1109/tsp.2020.3026980.
436
+ 445 URL https://doi.org/10.1109%2Ftsp.2020.3026980.
437
+ 446 Anders Aamand, Justin Chen, Piotr Indyk, Shyam Narayanan, Ronitt Rubinfeld, Nicholas Schiefer,
438
+ 447 Sandeep Silwal, and Tal Wagner. Exponentially improving the complexity of simulating the
439
+ 448 weisfeiler-lehman test with graph neural networks. Advances in Neural Information Processing
440
+ 449 Systems, 35:27333–27346, 2022.
441
+ 450 Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´
442
+ 451 neighbourhood aggregation for graph nets. Advances in Neural Information Processing Systems,
443
+ 452 33:13260–13271, 2020.
444
+ 453 Edward Wagstaff, Fabian B Fuchs, Martin Engelcke, Michael A Osborne, and Ingmar Posner.
445
+ 454 Universal approximation of functions on sets. Journal of Machine Learning Research, 23(151):
446
+ 455 1–56, 2022.
447
+ 456 Saugata Basu, Richard Pollack, and Marie-Françoise Roy. Algorithms in real algebraic geometry,
448
+ 457 volume 10. Springer, 2006.
449
+ 458 Yan Zhang, Jonathon Hare, and Adam Prügel-Bennett. Fspool: Learning set representations with
450
+ 459 featurewise sort pooling, 2020.
451
+ 460 Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning
452
+ 461 architecture for graph classification. In Proceedings of the AAAI conference on artificial intelligence,
453
+ 462 volume 32, 2018.
454
+ 463 Mathieu Blondel, Olivier Teboul, Quentin Berthet, and Josip Djolonga. Fast differentiable sorting
455
+ 464 and ranking. In International Conference on Machine Learning, pages 950–959. PMLR, 2020.
456
+ 465 Ilyes Batatia, David P Kovacs, Gregor Simm, Christoph Ortner, and Gabor Csanyi. Mace:
457
+ 466 Higher order equivariant message passing neural networks for fast and accurate force fields.
458
+ 467 In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in
459
+ 468 Neural Information Processing Systems, volume 35, pages 11423–11436. Curran Associates,
460
+ 469 Inc., 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/
461
+ 470 4a36c3c51af11ed9f34615b81edb5bbc-Paper-Conference.pdf.
462
+ 471 Bowen Jing, Stephan Eismann, Patricia Suriana, Raphael John Lamarre Townshend, and Ron Dror.
463
+ 472 Learning from protein structure with geometric vector perceptrons. In International Conference on
464
+ 473 Learning Representations, 2021. URL https://openreview.net/forum?id $\underset { . } { = }$ 1YLJDvSx6J4.
465
+ 474 J.R. Munkres. Topology. Featured Titles for Topology. Prentice Hall, Incorporated, 2000. ISBN
466
+ 475 9780131816299. URL https://books.google.co.il/books?id=XjoZAQAAIAAJ.
md/dev/wmwgLEPjL9/wmwgLEPjL9.md ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # In Defense of the Unitary Scalarization for Deep Multi-Task Learning
2
+
3
+ Vitaly Kurin∗ University of Oxford vitaly.kurin@cs.ox.ac.uk
4
+
5
+ Alessandro De Palma∗ University of Oxford adepalma@robots.ox.ac.uk
6
+
7
+ Shimon Whiteson University of Oxford
8
+
9
+ Ilya Kostrikov University of California, Berkeley New York University
10
+
11
+ M. Pawan Kumar University of Oxford
12
+
13
+ # Abstract
14
+
15
+ Recent multi-task learning research argues against unitary scalarization, where training simply minimizes the sum of the task losses. Several ad-hoc multi-task optimization algorithms have instead been proposed, inspired by various hypotheses about what makes multi-task settings difficult. The majority of these optimizers require per-task gradients, and introduce significant memory, runtime, and implementation overhead. We show that unitary scalarization, coupled with standard regularization and stabilization techniques from single-task learning, matches or improves upon the performance of complex multi-task optimizers in popular supervised and reinforcement learning settings. We then present an analysis suggesting that many specialized multi-task optimizers can be partly interpreted as forms of regularization, potentially explaining our surprising results. We believe our results call for a critical reevaluation of recent research in the area.
16
+
17
+ # 1 Introduction
18
+
19
+ Multi-Task Learning (MTL) [5] exploits similarities between tasks to yield models that are more accurate, generalize better and require less training data. Owing to the success of MTL on traditional machine learning models [3, 16, 22] and of deep single-task learning across a variety of domains, a growing body of research has focused on deep MTL. The most straightforward way to train a neural network for multiple tasks at once is to minimize the sum of per-task losses. Adopting terminology from multi-objective optimization, we call this approach unitary scalarization.
20
+
21
+ While some work shows that multi-task networks trained via unitary scalarization exhibit superior performance to independent per-task models [29, 35], others suggest the opposite [30, 54, 58]. As a result, many explanations for the difficulty of MTL have been proposed, each motivating a new Specialized Multi-Task Optimizer (SMTO) [11, 42, 54, 62, 66]. These works typically claim that the proposed SMTO outperforms unitary scalarization, in addition to relevant prior work. However, SMTOs usually require access to per-task gradients either with respect to the shared parameters, or to the shared representation. Therefore, their reported performance gain comes at significant computation and memory cost, the overhead scaling linearly with the number of tasks. By contrast, unitary scalarization requires only the average of the gradients across tasks, which can be computed via a single backpropagation.
22
+
23
+ Existing SMTOs were introduced to solve challenges related to the optimization of the deep MTL problem. We instead postulate that the reported weakness of unitary scalarization is linked to experimental variability or to a lack of regularization, leading to the following contributions:
24
+
25
+ • A comprehensive experimental evaluation $( \ S 4 )$ of recent SMTOs on popular multi-task benchmarks, showing that no SMTO consistently outperforms unitary scalarization in spite of the added complexity and overhead. In particular, either the differences between unitary scalarization and SMTOs are not statistically significant, or they can be bridged by standard regularization and stabilization techniques from the single-task literature. Our reinforcement learning (RL) experiments include optimizers previously applied only to supervised learning. • An empirical and technical analysis of the considered SMTOs, suggesting that they reduce overfitting on the multi-task problem and hence act as regularizers (§5). We conduct an ablation study and provide a collection of novel and existing technical results that support this hypothesis. • Code to reproduce the experiments, including a unified PyTorch [50] implementation of the considered SMTOs, is available at https://github.com/yobibyte/ unitary-scalarization-dmtl.
26
+
27
+ We believe that our results suggest that the considered SMTOs can be often replaced by less expensive techniques. We hope that these surprising results stimulate the search for a deeper understanding of MTL.
28
+
29
+ # 2 Related Work
30
+
31
+ Before diving into details of specific SMTOs in Section 5, we provide a high-level overview of the deep MTL research. Seminal work in MTL includes hard parameter sharing [6]: sharing neural network parameters between all tasks with, possibly, a separate part of the model for each task. Hard parameter sharing is still the major MTL approach adopted in natural language processing [9, 12], computer vision [46], and speech recognition [53]. In this work, we implicitly assume that each parameter update employs information from all tasks. However, not all works satisfy this assumption, either due to a large number of tasks [4, 36], or simply as an implementation decision [25, 37]. In this setting, MTL resembles other problems dealing with multiple tasks, i.e., continual [32], curriculum [47], and meta-learning [24], which are not the focus of this work.
32
+
33
+ Many works strive to improve the performance of deep multi-task models. One line of research hypothesizes that conflicting per-task gradient directions lead to suboptimal models, and focuses on explicitly removing such conflicts [11, 28, 41, 42, 62, 66]. Some authors postulate that loss imbalances across tasks hinder learning, proposing loss reweighting methods [10, 30, 40]. Sener and Koltun [54] and Navon et al. [48] propose that tasks compete for model capacity and interpret MTL as multi-objective optimization in order to cope with inter-task competition. Here, we focus on algorithms that explicitly rely on per-task gradients to try to outperform unitary scalarization (§5). Research on multi-task architectures [19, 46] or MTL algorithms exclusively motivated by deterministic loss reweighting [18, 30, 43] are orthogonal to our work. Both topics are investigated by a recent survey on pixel-level multi-task computer vision problems [61], which found that the minimization of tuned weighted sums of losses (scalarizations) is empirically competitive with deterministic loss reweighting and MGDA in the considered settings. These results are extended to popular SMTOs by a critical review from Xin et al. [63], concurrent to our work, which argues that the optimization and generalization performance of SMTOs can be matched by tuning scalarization coefficients. Our work reaches a similar conclusion, demonstrating that unitary scalarization performs on par with SMTOs when coupled with standard and inexpensive regularization or stabilization techniques. In other words, Xin et al. [63] provide complementary support for the link between SMTOs and regularization by showing that tuning scalarization weights positively affects generalization.
34
+
35
+ In addition to the common supervised settings, we also consider multi-task RL, whose research can be grouped into three categories: the first adds auxiliary tasks providing additional inductive biases to speed up learning [27] on a target task. The second, based on policy distillation, uses per-task teacher models to provide labels for a multi-task model or per-task policies as regularizers [49, 51, 57]. The third directly learns a shared policy [29], possibly via an SMTO [66]. We focus on the third category, whose literature reports varying performance for unitary scalarization (better [29] or worse [66] than per-task models), indicating confounding factors in evaluation pipelines and further motivating our work. PopArt [23, 60] performs scale-invariant value function updates in order to address differences in returns across environments, showing improvements in the multi-task setting while still using unitary scalarization. PopArt does not require per-task gradients but introduces additional hyperparameters. In our work, we address the differences in rewards by normalizing them at the replay buffer level. However, we believe both unitary scalarization and SMTOs might equally benefit from PopArt.
36
+
37
+ # 3 Multi-Task Learning Optimizers
38
+
39
+ We will now describe the deep MTL training problem and popular algorithms employed for its solution. Let $( X , Y ) \in \mathbb { R } ^ { d \times n } \times \mathbb { R } ^ { o \times n }$ be the training set, composed of $^ { n d }$ -dimensional points and $o$ -dimensional labels. In addition, $\mathcal { L } _ { i } : \mathbb { R } ^ { o \times n } \times \mathbb { R } ^ { o \times n ^ { \top } } \mathbb { R }$ denotes the loss for the $i$ -th task, $\pmb \theta \in \mathbb { R } ^ { S }$ the parameter space, $\mathcal { T } : = \{ 1 , \dots , m \}$ the set of $m$ tasks. The goal of MTL is to learn a single (generally task-aware) parametrized model $f : \mathbb { R } ^ { S } \times \mathbb { R } ^ { d \times n } \times \mathcal { T } \mathbb { R } ^ { o \times n }$ that performs well on all tasks $\tau$ . The parameter space is often split into a set of shared parameters across tasks (generally the majority of the architecture), denoted $\theta _ { \parallel }$ , and (possibly empty) task-specific parameters, denoted $\pmb { \theta } _ { \bot }$ , so that $\pmb { \theta } : = [ \pmb { \theta } _ { | | } , \pmb { \theta } _ { \perp } ] ^ { T }$ . In this context, the model $f$ often takes on an encoder-decoder architecture, where the encoder $g$ learns a shared representation across tasks, and the decoders $h _ { i }$ are task-specific predictive heads: $f ( \pmb \theta , X , i ) = h _ { i } ( g ( \pmb \theta _ { \parallel } , X ) , \pmb \theta _ { \perp } )$ . In this case, we denote by $\mathbf { z } = g ( \pmb { \theta } _ { \parallel } , X ) \in \mathbb { R } ^ { r \times n }$ the $r .$ -dimensional shared representation of $X$ .
40
+
41
+ The training problem for MTL is typically formulated as the sum of the per-task losses [11, 54, 66]:
42
+
43
+ $$
44
+ \begin{array} { r } { \underset { \pmb { \theta } } { \operatorname* { m i n } } \left[ \begin{array} { l } { \mathcal { L } ^ { \mathrm { M T } } ( \pmb { \theta } ) : = \sum _ { i \in \mathcal { T } } \mathcal { L } _ { i } ( f ( \pmb { \theta } , X , i ) , Y ) } \end{array} \right] . } \end{array}
45
+ $$
46
+
47
+ Unitary Scalarization The obvious way to minimize the multi-task training objective in equation (1) is to rely on a standard gradient-based algorithm. While, for simplicity, we focus on standard gradient descent rather than mini-batch stochastic gradient descent, the notation can be adapted by replacing the dataset size $n$ by the mini-batch size $b$ . Equation (1) corresponds to a linear scalarization with unitary weights under a multi-objective interpretation of MTL; hence, we call the direct application of gradient descent on equation (1) unitary scalarization. For vanilla gradient descent, this corresponds to taking a step in the opposite direction as the one given by the sum of per-task gradients: $\begin{array} { r } { \nabla _ { \theta } \mathcal { L } ^ { \mathrm { { M T } } } = \sum _ { i \in \mathcal { T } } \bar { \nabla _ { \theta } } \mathcal { L } _ { i } } \end{array}$ . Per-task gradients are not required, as it suffices to directly compute the gradient of the sum $\mathcal { L } ^ { \mathrm { M T } }$ . Hence, when relying on deep learning frameworks based on reverse-mode differentiation, such as PyTorch [50], the backward pass is performed once per iteration (rather than $m$ times). Furthermore, the memory cost is a factor $m$ less than most SMTOs, which require access to each $\nabla _ { \pmb { \theta } } \mathcal { L } _ { i }$ . As a consequence, unitary scalarization is simple, fast, and memory efficient. Our experiments demonstrate that, when possibly coupled with single-task regularization such as early stopping, $\ell _ { 2 }$ penalty or dropout layers [56], this simple optimizer is strongly competitive with SMTOs.
48
+
49
+ MGDA Sener and Koltun [54] point out that equation (1) can be cast as a multi-objective optimization problem with the following objective: $\mathcal { L } ^ { \mathrm { M T } } ( \pmb { \theta } ) : = [ \mathcal { L } _ { 1 } ( \pmb { \theta } ) , \dots , \mathcal { L } _ { m } ( \pmb { \theta } ) ] ^ { T }$ . A commonly employed solution concept in multi-objective optimization is Pareto optimality. A point $\pmb { \theta } ^ { * }$ is called Pareto-optimal if, for any another point $\mathbf { \hat { \theta } } ^ { \dagger }$ such that $\exists i \in T : \bar { \mathcal { L } } _ { i } ( \pmb { \theta } ^ { \dagger } ) ^ { \cdot } < \bar { \mathcal { L } } _ { i } ( \pmb { \theta } ^ { * } )$ , then $\exists j \in \mathcal { T } : \mathcal { L } _ { j } ( \pmb { \theta } ^ { \dag } ) > \mathcal { L } _ { j } ( \pmb { \theta } ^ { * } )$ . A necessary condition for Pareto optimality at a point is Pareto stationarity, defined as the lack of a shared descent direction across all losses at that point. Sener and Koltun [54] rely on Multiple-Gradient Descent Algorithm (MGDA) [14] to reach a Pareto-stationary point for shared parameters $\theta _ { \parallel }$ . Intuitively, MGDA proceeds by repeatedly stepping in a shared descent direction [14, 17], which can be found by solving the following optimization problem:
50
+
51
+ $$
52
+ \operatorname* { m i n } _ { \mathbf { g } , \epsilon } \left[ \epsilon + 1 / 2 \left. \mathbf { g } \right. _ { 2 } ^ { 2 } \right] \quad \mathrm { s . t . } \ \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } ^ { T } \mathbf { g } \leq \epsilon \quad \forall \ : i \in \mathcal { T } ,
53
+ $$
54
+
55
+ whose dual takes the following form (corresponding to the formulation from Désidéri [14]):
56
+
57
+ $$
58
+ \operatorname* { m a x } _ { \alpha \geq 0 } - 1 / 2 \left\| \mathbf { g } \right\| _ { 2 } ^ { 2 } \quad \mathrm { s . t . } \ \sum _ { i } \alpha _ { i } \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } = - \mathbf { g } , \quad \sum _ { i \in \mathcal { T } } \alpha _ { i } = 1 .
59
+ $$
60
+
61
+ In other words, MGDA takes a step in a direction $\mathbf { g }$ given by the negative convex combination of per-task gradients, whose coefficients are given by solving equation (3). In practice, per-task gradients are rescaled before applying MGDA: the original authors’ implementation [54] relies on $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \gets \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \Big / \Big \| \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \Big \| \mathcal { L } _ { i } ( \pmb { \theta } )$ . The convergence of MGDA to a Pareto-stationary point is still guaranteed after normalization [14].
62
+
63
+ IMTL Impartial Multi-Task Learning (IMTL) [42] is presented as an SMTO that is not biased against any single task. It is composed of two complementary algorithmic blocks: IMTL-L, acting on task losses, and IMTL-G, acting on per-task gradients. IMTL-G follows the intuition that a multi-task optimizer should proceed along a direction $\begin{array} { r } { \mathbf { g } = - \sum _ { i } \alpha _ { i } \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } } \end{array}$ that equally represents per-task gradients. This is formulated analytically by requiring that the cosine similarity between $\mathbf { g }$ and each $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i }$ be the same. To prevent the resulting problem from being underdetermined, Liu et al. [42] add the constraint $\textstyle \sum _ { i \in { \mathcal { T } } } \alpha _ { i } = 1$ , resulting in a problem that admits a closed-form solution for $\mathbf { g }$ :
64
+
65
+ $$
66
+ \begin{array} { r } { \mathbf { g } ^ { T } \frac { \nabla \theta _ { \parallel } \mathcal { L } _ { 1 } } { \left\| \nabla \theta _ { \parallel } \mathcal { L } _ { 1 } \right\| } = \mathbf { g } ^ { T } \frac { \nabla \theta _ { \parallel } \mathcal { L } _ { i } } { \left\| \nabla \theta _ { \parallel } \mathcal { L } _ { i } \right\| } \ \forall i \in \mathcal { T } \setminus \{ 1 \} , \quad \mathbf { g } = - \sum _ { i } \alpha _ { i } \nabla \theta _ { \parallel } \mathcal { L } _ { i } , \quad \sum _ { i \in \mathcal { T } } \alpha _ { i } = 1 . } \end{array}
67
+ $$
68
+
69
+ IMTL-L, instead, aims to reweight task losses so that they are all constant over time, and equal to 1. In order to limit oscillations of the scaling factors, the authors propose to learn them jointly with the network by minimizing a common objective via gradient descent. In particular, given $s _ { i } \in \mathbb { R } \forall i \in \mathcal { T }$ , Liu et al. [42] derive the following form for the joint minimization problem: $\begin{array} { r } { \operatorname* { m i n } _ { \mathbf { s } , \pmb { \theta } } \left[ \sum _ { i } \left( e ^ { s _ { i } } \mathcal { L } _ { i } ( \pmb { \theta } ) - s _ { i } \right) \right] . } \end{array}$ . As proved by Liu et al. [42], IMTL-L only has a rescaling effect on the update direction of IMTL-G. Unlike IMTL-G and the other SMTOs presented in this section, IMTL-L rescaling is designed to affect the updates for task-specific parameters $\pmb { \theta } _ { \perp }$ as well.
70
+
71
+ PCGrad Let us write $\cos ( \mathbf { x } , \mathbf { z } )$ for the cosine similarity between vectors $\mathbf { x }$ and $\mathbf { z }$ . Yu et al. [66] postulate that multi-task convergence is severely slowed down if the following three conditions (named the tragic triad) hold at once: (i) conflicting gradient directions: $\cos ( \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } , \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { j } ) < 0$ for some $i , j \in \mathcal { T }$ ; (ii) differing gradient magnitudes: $\lVert \nabla _ { { \pmb \theta } _ { \parallel } } \mathcal { L } _ { i } \rVert \gg \lVert \nabla _ { { \pmb \theta } _ { \parallel } } \mathcal { L } _ { j } \rVert$ for some $i , j \in \mathcal { T }$ ; and (iii) the unitary scalarization $\mathcal { L } ^ { \mathrm { M T } }$ has high curvature along $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { \vphantom { \parallel } } ^ { \mathrm { M T } }$ . The PCGrad [66] SMTO is presented as a solution to the tragic triad, targeted at the first condition. Consistent with the previous sections, let us denote the update direction by g. Furthermore, let $[ \mathbf { x } ] _ { + } : = \mathrm { m a x } ( \mathbf { x } , \mathbf { 0 } )$ . Given per-task gradients $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i }$ , PCGrad iteratively projects each task gradient onto the normal plane of all the gradients with which it conflicts:
72
+
73
+ $$
74
+ \left[ \mathbf { g } _ { i } \gets \nabla _ { \theta _ { 1 } } \mathcal { L } _ { i } , \ \mathbf { g } _ { i } \gets \mathbf { g } _ { i } + \left[ \frac { - \mathbf { g } _ { i } ^ { T } \nabla _ { \theta _ { 1 } } \mathcal { L } _ { j } ( \mathbf { x } ) } { \left\| \nabla _ { \theta _ { 1 } } \mathcal { L } _ { j } \right\| ^ { 2 } } \right] \nabla _ { \theta _ { 1 } } \mathcal { L } _ { j } \ \forall j \in T \setminus \{ i \} \right] \forall i \in T , \quad \mathbf { g } = - \sum _ { i \in T } \mathbf { g } _ { i } ,
75
+ $$
76
+
77
+ where the iterative updates of $\mathbf { g } _ { i }$ with respect to $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { j }$ are performed in random order.
78
+
79
+ GradDrop Chen et al. [11] focus on conflicting signs across task gradient entries, arguing that such conflicts lead to gradient “tug-of-wars". The GradDrop SMTO [11], presented as a solution to this problem, proposes to randomly mask per-task gradients $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i }$ so as to minimize such conflicts. Specifically, GradDrop computes the “positive sign purity" $p _ { j }$ for the task gradient’s $j$ -th entry and then masks the $j$ -th entry of each per-task gradient with probability increasing with $p _ { j }$ , if the entry is negative, or decreasing with $p _ { j }$ , if the entry is positive. Let us write $\mathbf { p } : = [ p _ { 1 } , \hdots , p _ { S } ]$ , where $S$ is the dimensionality of the parameter space (see $\ S 3$ ), $\odot$ for the Hadamard product and $\mathbb { 1 } _ { \mathbf { a } }$ for the indicator vector on condition a. Given a vector $\mathbf { u } _ { i }$ , uniformly sampled in $[ \mathbf { 0 } , \mathbf { 1 } ]$ at each iteration, GradDrop takes a step in the direction given by:
80
+
81
+ $$
82
+ \mathbf { g } = \sum _ { i \in \mathcal { T } } \left( \begin{array} { l } { - \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } \odot \mathbb { 1 } _ { \left( \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } > 0 \right) } \odot \mathbb { 1 } _ { \left( \mathbf { u } _ { i } > \mathbf { p } \right) } } \\ { - \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } \odot \mathbb { 1 } _ { \left( \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } < 0 \right) } \odot \mathbb { 1 } _ { \left( \mathbf { u } _ { i } < \mathbf { p } \right) } } \end{array} \right) , \mathrm { w i t h } \mathbf { p } = \frac { 1 } { 2 } \left( 1 + \frac { \sum _ { i \in \mathcal { T } } \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } } { \sum _ { i \in \mathcal { T } } \left| \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } \right| } \right) .
83
+ $$
84
+
85
+ # 4 Experimental Evaluation
86
+
87
+ Relying on a unified experimental pipeline, we present an empirical evaluation on common MTL benchmarks of unitary scalarization (§3), of the popular SMTOs presented in $\ S 3$ , and of the recent RLW algorithms [40] due to their similarities with PCGrad and GradDrop (see $\ S 5 . 2 )$ . We benchmark against the two RLW instances that showed the best average performance in the original paper: RLW with weights sampled from a Dirichlet distribution (“RLW Diri.”), and RLW with weights sampled from a Normal distribution (“RLW Norm.”). The goal of this section is to assess the efficacy of a popular line of previous work, focusing on a few representative or well-established optimizers. Therefore, we forego comparison with more recent SMTOs [28, 41, 48]. Nevertheless, we point out that these algorithms often lack significant enough improvements over the optimizers we consider, or may have substantial commonalities with them (see $\ S 5 . 2$ for Nash-MTL [48], which was published concurrently to the finalization of this work). Whenever appropriate, we employ “Unit. Scal.” as shorthand for unitary scalarization. We first present supervised learning experiments $( \ S 4 . 1 )$ , and then evaluate on a popular reinforcement learning benchmark $( \ S 4 . 2 )$ .
88
+
89
+ ![](images/3e6d1f6fac82c7221116148e1d71c64b740123233254debc0bfd37cace4b7fe5.jpg)
90
+ (a) Avg. task test accuracy: mean and $9 5 \%$ CI (10 runs). (b) Box plots for the training time of an epoch (10 runs).
91
+
92
+ ![](images/d0efb2673a33c099679df8f887db8f0ef022ffc82b83d2c6298dfe5b7541ca31.jpg)
93
+ Figure 1: No algorithm outperforms unitary scalarization on the Multi-MNIST dataset.
94
+
95
+ Our experiments indicate that the performance of unitary scalarization has been consistently underestimated in the literature. By showing the variability between runs and by relying on standard regularization and stabilization techniques from the single-task literature, we demonstrate that no SMTO consistently outperforms unitary scalarization across the considered settings. This result holds in spite of the added complexity and computational overhead associated with most SMTOs. Furthermore, in supervised learning, most methods drive the training loss of all tasks in the proximity of the respective global minima. This suggests that the main difficulty of MTL is not associated with the optimization of its training objective, but rather to incorporating adequate regularization (cf. $\ S 5 _ { , }$ ).
96
+
97
+ # 4.1 Supervised Learning
98
+
99
+ All the architectures employed in the supervised learning experiments conform to the encoder-decoder structure detailed in $\ S 3$ . Whenever suggested by the original authors for this context, the SMTO implementations rely on per-task gradients with respect to the last shared activation, $\nabla _ { \mathbf { z } }$ , rather than on the usually more expensive $\nabla _ { \theta } \mathcal { L } _ { i }$ . In particular, this is the case for MGDA, IMTL and GradDrop. See appendix B for details concerning each individual algorithm. Surprisingly, several MTL works [11, 40, 42, 66] report validation results, making it easier to overfit. Instead, following standard machine learning practice, we select a model on the validation set, and later report test metrics for all benchmarks. Validation results are also available in appendix D. Appendix C.1 reports dataset descriptions, the computational setup, hyperparameter and tuning details.
100
+
101
+ # 4.1.1 Multi-MNIST
102
+
103
+ We present results on the Multi-MNIST [54] dataset, a simple two-task supervised learning benchmark. We employ a popular architecture from previous work [54, 66] (see appendix C.1), where a single dropout layer [56] (with dropout probability 0.5) is employed in both the encoder and the decoder. $\ell _ { 2 }$ regularization did not improve validation performance and was therefore omitted. Figure 1 reports the average task test accuracy, and the training time per epoch. For each run, the test model was selected as the model with the largest average task validation accuracy across the training epochs. Appendix D presents the results of Figure 1 in tabular form, as well as the average task validation accuracy per epoch. As seen from the overlapping confidence intervals, none of the considered algorithms clearly outperforms the others. However, GradDrop displays higher experimental variability. Furthermore, Figure 7(b) shows that the sums of the task cross-entropy losses is driven nearly to zero by most methods. Finally, Figure 1(b) shows that unitary scalarization also has among the lowest training times.
104
+
105
+ # 4.1.2 CelebA
106
+
107
+ We now show results for the CelebA [44] dataset, a challenging 40-task multi-label classification problem. We employ the same architecture as many previous studies [40, 42, 54, 66] (see appendix C.1). We tuned $\ell _ { 2 }$ regularization terms $\lambda$ for all SMTOs in the following grid: $\lambda \in \{ 0 , 1 0 ^ { - 4 } , \bar { 1 } 0 ^ { - 3 } \} .$ . The best validation performance was attained with $\lambda = 1 0 ^ { - 3 }$ for unitary scalarization, IMTL and PCGrad, and with $\lambda = \mathrm { \dot { 1 0 } ^ { - 4 } }$ for MGDA, GradDrop, and RLW. Validation performance was further stabilized
108
+
109
+ (a) Avg. task test accuracy: mean and $9 5 \%$ CI (3 runs).
110
+
111
+ ![](images/6759bba4c1c5a7db189ecab127a3e7bd7370782372e131691606cebf0528a0a7.jpg)
112
+ Figure 2: While SMTOs display larger runtimes, none of them outperforms the unitary scalarization on the CelebA dataset.
113
+
114
+ ![](images/708c195d894dddd75e563a9e9b77ffced02008599d0ce72e837641bb849a3406.jpg)
115
+ (b) Box plots for the training time of an epoch (10 runs).
116
+
117
+ ![](images/e7af88dfc03f8016831847d95cb720e9ac842e275688d0027362e1e05cfc1b91.jpg)
118
+ (e) Box plots for the training time of an epoch (10 runs).
119
+ algorithm. Subfigures (a)-(d) report means for three runs, and their $9 5 \%$ CIs.
120
+
121
+ by the addition of several dropout layers (see Figure 5), with dropout probabilities from 0.25 to 0.5. We present an ablation study on the effect of regularization on this experiment in $\ S 5 . 1$ . Figure 10 (appendix D.2) shows that regularization improves the peak average validation performance for all the considered methods. Analogously to our Multi-MNIST results, Figure 2 plots the distribution of the training time per epoch, and the average test task accuracy. As with Multi-MNIST, the test model for each run was the one with maximal average validation task accuracy across epochs. In other words, if the peak is attained before the last epoch, we perform early stopping: as shown in Figure 8(a) in appendix D this is the case for most methods. Due to the large number of tasks, Figure 2(b) shows relatively large runtime differences across methods. PCGrad is the slowest (roughly 35 times slower than unitary scalarization). In fact, amongst the considered algorithms, it is the only one that computes per-task gradients over the parameters $( \nabla _ { \pmb { \theta } } \mathcal { L } _ { i } \forall i \in \mathcal { T } )$ at each iteration. GradDrop, MGDA and IMTL have overhead factors (compared to unitary scalarization) ranging from roughly 1.05 to 2.4 due to the relatively small size of $\mathbf { z }$ for the employed architecture. The overhead of RLW is negligible: roughly $5 \%$ . Nevertheless, due to largely overlapping confidence intervals in Figure 2(a), none of the methods consistently outperforms unitary scalarization. In fact, owing to our adoption of explicit regularization techniques (see $\ S 5 . 1 \ r ,$ ) its average performance is superior to that reported in the literature [42, 54]. As with Multi-MNIST, Figure 9(a) demonstrates that the cross-entropy loss of each task can be driven near to its global optimum by most optimizers.
122
+
123
+ # 4.1.3 Cityscapes
124
+
125
+ In order to complement the multi-task classification experiments for Multi-MNIST and CelebA, we present results for Cityscapes [13], a dataset for semantic understanding of urban street scenes. We rely on a common encoder architecture from the literature [40, 42] (see appendix C.1), with a single dropout layer in the task-specific heads [40]. As for CelebA, unitary scalarization, IMTL, and PCGrad benefit from more regularization than the other optimizers: we employ $\lambda = 1 0 ^ { - 5 }$ for these three algorithms, as it resulted in better validation performance on the majority of metrics, and $\lambda = 0$ for the remaining methods. Cityscapes is a heterogeneous MTL problem: it contains tasks of different types whose validation metrics cannot be averaged to perform model selection. Considering the lack of an established procedure in this context, we potentially evaluate a different model for each metric, chosen as the one with the best (maximal or minimal, depending on the metric) validation performance across epochs (we perform per-run early stopping). This procedure maximizes per-task performance, at the cost of increased inference time. If inference time is a priority, an alternative model selection procedure could rely on relative task improvement [28, 41, 48], assuming that per-metric improvements are to be weighted linearly. Nevertheless, any consistently applied model selection scheme serves the main goal of our work: evaluating all SMTOs on a fair ground. Figure 3 shows test results for two metrics per task, and the distribution of the training time per epoch. As with Multi-MNIST and CelebA, no training algorithm clearly outperforms unitary scalarization (significant overlaps across confidence intervals exist), which is again the least expensive method. In contrast with a popular hypothesis [10, 30, 42], this holds in spite of relatively large loss imbalances. In fact, the loss for the depth task is roughly 10 times smaller than that of the segmentation task: see figures 17(f)-17(g). Nevertheless, both losses are rapidly driven towards their respective global minima. Unlike CelebA (see Figure 2(b)), IMTL, MGDA and GradDrop are significantly slower than unitary scalarization (factors from 1.6 to 2.3), due to the relatively (compared to the parameter space) large size of $\mathbf { z }$ in the employed architecture. PCGrad, instead, appears to be less expensive $3 0 \%$ more than the baseline), demonstrating the benefits of working on $\nabla _ { \pmb { \theta } } \mathcal { L } _ { i }$ on this model.
126
+
127
+ ![](images/2b6e0a95fef758832bb2662ed820ad7af2165b09f6e409675682d1eaf9d88ea4.jpg)
128
+ Figure 4: On Metaworld, none of the SMTOs significantly outperforms Unit. Scal., which is the least expensive method. Subfigures (a)-(b) report mean and $9 5 \%$ CI for the best (over the updates) average success rate. Subfigures (c)-(d) show box plots for the training time of 10,000 updates.
129
+
130
+ # 4.2 Reinforcement Learning
131
+
132
+ For RL experiments, we use Meta-World [65] and the Soft Actor-Critic [20] implementation from [55]. Unlike $\ S 4 . 1$ , the employed network architecture (see appendix C.1) is fully shared across tasks. Therefore, all SMTO implementations for these experiments rely on per-task gradients with respect to network parameters $\nabla _ { \pmb { \theta } } \mathcal { L } _ { i }$ (see $\ S 5$ ). Among the SMTOs we consider, PCGrad is the only one developed with the RL setting in mind. For fairness and completeness, we add all the other SMTOs from the supervised learning experiments, and are the first to test these optimizers in the RL setting. To stabilize learning, we increase the replay buffer size, a well known technique in single-task RL, add actor $l _ { 2 }$ regularization, and modify the reward normalization employed by Sodhani et al. [55]. The unitary scalarization performance reported by Yu et al. [66] is considerably lower than that of Sodhani et al. [55], which we believe is due to the lack of reward normalization in the former. Sodhani et al. [55] keep a moving average of rewards in the environment, with a hyperparameter controlling the speed of the moving average. As we show in Figure 16, the learning algorithm is sensitive to that hyperparameter. Moreover, such normalization might make similar transitions have drastically different rewards stored in the replay buffer. To alleviate these issues, we store the raw rewards in the buffer, and normalize only when a mini-batch is sampled.
133
+
134
+ Figure 4 reports the best average success rate across the updates and the runtime for 10,000 updates. In addition to these summary statistics, reported for consistency with $\ S 4 . 1$ , the learning curves are shown in appendix E. Our MT10 (10 tasks) results in Figure 4(a) show that by stabilizing the baseline using standard RL techniques, unitary scalarization performs on par with other SMTOs, mirroring our findings in $\ S 4 . 1$ . This is in contrast with the previous literature, which reported that PCGrad outperforms unitary scalarization [55, 66]. Figure 4(b) presents results on MT50 (50 tasks): similarly to MT10, none of the SMTOs significantly outperforms unitary scalarization, with PCGrad’s average being slightly above unitary scalarization. We speculate that the stochastic loss rescaling performed by PCGrad (see Proposition 3) reduces the differences in task return scales, and expect that methods like PopArt [60] would have a similar effect without requiring access to per-task gradients. While we did not tune hyperparameters for MT50 (we employed those found for MT10), it would be much easier to do that for unitary scalarization due to its lower runtime. In fact, Figure 4(d) shows that a single unitary scalarization run takes roughly 15 hours, whereas PCGrad, MGDA and GradDrop require more than a week. Similarly to MT10, actor regularization pushes the average performance of unitary scalarization higher (see in appendix E.2). Overall, as in the supervised learning setting, unitary scalarization performs comparably to SMTOs despite being simpler and less demanding in both memory and compute. IMTL was unstable on this RL benchmark and all of the runs crashed due to numerical overflow. We hence omit IMTL results from the main body of the paper and show its results in Figure 13 in appendix E, which also describes a possible explanation. We hypothesize that the instability of IMTL is due to lack of bounds on scaling coefficients. See appendix C.2 for hyperparameter settings and ablation studies.
135
+
136
+ # 5 Regularization in Specialized Multi-Task Optimizers
137
+
138
+ The empirical results presented in $\ S 4$ motivate the need to carefully analyze existing SMTOs. We make an initial attempt in this direction by viewing their effects through the lens of regularization. Let us define a regularizer as a technique to reduce overfitting [15]. We first show that the SMTOs considered in $\ S 4$ empirically act as regularizers via an ablation study (§5.1). We then take a closer look at their behavior, presenting technical results that support their alternative interpretation as regularizers (§5.2). Finally, $\ S 5 . 3$ provides additional empirical backing for some of the technical results. Unless otherwise stated, we assume that MTL methods apply only to $\theta _ { \parallel }$ and that standard gradient-based updates are employed for tasks-specific parameters $\theta _ { \perp }$ . We furthermore adopt the following shorthands: $\mathcal { L } _ { i } ( \pmb { \theta } )$ for $\bar { \mathcal { L } _ { i } } ( f ( \pmb { \theta } , X , i ) , \bar { Y ) }$ , and $\nabla _ { \theta } \mathcal { L } _ { i }$ for $\nabla _ { \pmb { \theta } } \mathcal { L } _ { i } ( f ( \pmb { \theta } , X , i ) , Y )$ .
139
+
140
+ # 5.1 Ablation Study
141
+
142
+ We repeat the experiment from $\ S 4 . 1 . 2$ and remove explicit regularization: no dropout layers are added to the encoder-decoder architecture, and $\lambda = 0$ for all optimizers. In addition, we examine the behavior of two different $\ell _ { 2 }$ -regularized instances of unitary scalarization: $\lambda = 1 0 ^ { - 4 }$ for “Unit. Scal. $\ell _ { 2 } { } ^ { , , }$ , $\lambda = 2 \times 1 0 ^ { - 3 }$ for “Unit. Scal. $\ell _ { 2 } + \mathbf { \vec { \mu } } ^ { \mathbf { > } }$ . Figure 5 shows that SMTOs behave similarly to an $\ell _ { 2 }$ -penalized unitary scalarization. Importantly, SMTOs delay overfitting, requiring less early stopping compared to unitary scalarization to obtain comparable performance. In other words, early stopping is sufficient for unitary scalarization to perform on par with SMTOs. Finally, overfitting is further reduced by “Unit. Scal. Reg.”, which plots the regularized unitary scalarization from $\ S 4 . 1 . 2$ , with dropout layers and a weight decay of $\lambda \overset { \cdot } { = } 1 0 ^ { - 3 }$ . Further results are presented in appendix D.2.
143
+
144
+ # 5.2 Technical Results
145
+
146
+ All the methods considered in $\ S 5 . 1$ regularize more than unitary scalarization. While RLW was shown to reduce overfitting by the original authors [40, theorem 2], we now provide a collection of novel and existing technical results that potentially explain the regularizing behavior of each of the other algorithms, complementing the presentation from $\ S 3$ . In particular, we show that MGDA, IMTL and PCGrad have a larger convergence set than unitary scalarization, reducing the chances to land on sharp local minima [15]. Furthermore, GradDrop and PCGrad introduce significant stochasticity, which is often linked to the same effect [31, 34]. We hope these observations will steer further research.
147
+
148
+ MGDA Let us denote the convex hull of a set $\mathcal { A }$ by $\operatorname { C o n v } ( \mathcal { A } )$ . We now recall a well-known property of MGDA [14] and relate it to the behavior of unitary scalarization.
149
+
150
+ Proposition 1. The MGDA SMTO [54] converges to a superset of the convergence points of unitary scalarization. More specifically, it converges to any point $\theta _ { \parallel } ^ { * }$ such that: $\mathbf { 0 } \in C o n \nu ( \{ \nabla _ { \theta _ { \parallel } ^ { * } } \mathcal { L } _ { i } | i \in \mathcal { T } \} )$ .
151
+
152
+ See appendix B.1 for a simple proof. As a consequence of Proposition 1, MGDA does not necessarily reach a stationary point for $\dot { \mathcal { L } } ^ { \mathrm { M T } }$ (that is, a point for which $\begin{array} { r } { \sum _ { i \in \mathcal { T } } \nabla _ { \theta _ { \parallel } } \mathcal { L } _ { i } = \mathbf { 0 } ) } \end{array}$ or for any of the losses $\mathcal { L } _ { i }$ $\nabla _ { \pmb { \theta } _ { | | } } \mathcal { L } _ { i } = \mathbf { 0 }$ ). For example, any point $\theta _ { \parallel }$ for which two per-task gradients point in opposite directions is Pareto stationary. On account of the well-known [15] relationship between underoptimizing (e.g., early stopping [7, 39]) and overfitting, proposition 1 supports the interpretation of MGDA as a regularizer for equation (1). Empirical evidence that MGDA under-optimizes is provided in $\ S 5 . 3$ , Figure 9(a), and Figure 5, which shows over-regularization. Proposition 1 can be trivially extended to the recent Nash-MTL, which shares the same convergence set [48, Theorem 5.4].
153
+
154
+ ![](images/918d04c55f10f371d73b30104771ea4c65399c75a25d2013e38c9f681f36db7a.jpg)
155
+ Figure 5: Mean and $9 5 \%$ CI (3 runs) avg. task validation accuracy over epochs on CelebA. SMTOs postpone the onset of overfitting, mirroring the effect of $\ell _ { 2 }$ regularization on unitary scalarization.
156
+
157
+ ![](images/eeda2ef992f489e36977c25574ff25ff2061d29a9f4156da12cfdd12d6d455a1.jpg)
158
+ Figure 6: Mean and $9 5 \%$ CI (3 runs) for $\begin{array} { r } { \big \| \breve { \sum } _ { i \in \mathcal { T } } \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \big \| _ { 2 } } \end{array}$ on CelebA. MGDA and IMTL converge away from stationary points of unitary scalarization, indicating under-optimization.
159
+
160
+ IMTL We now show that aggregating per-task gradients so that their cosine similarity is the same (equation (4)) yields a constrained steepest-descent algorithm (Proposition 2). This view on the update step of IMTL leads to a novel analysis of its convergence points (corollary 1). Proofs can be found in appendix B.2. We will denote by $\operatorname { A f f } ( A )$ the affine hull of a set $\mathcal { A }$ .
161
+
162
+ Proposition 2. IMTL by Liu et al. [42] updates $\theta _ { \parallel }$ by taking a step in the steepest descent direction whose cosine similarity with per-task gradients is the same across tasks.
163
+
164
+ Corollary 1. IMTL by Liu et al. $I 4 2 J$ converges to a superset of the Pareto-stationary points for $\theta _ { \parallel }$ (and hence of the convergence points of the unitary scalarization). More specifically, it converges to any point $\theta _ { \parallel } ^ { * }$ such that: $\mathbf { 0 } \in \bar { A } \bar { f f } \left( \left\{ \nabla _ { \pmb { \theta } _ { \parallel } ^ { * } } \mathcal { L } _ { i } / \left\| \nabla _ { \pmb { \theta } _ { \parallel } ^ { * } } \mathcal { L } _ { i } \right\| | i \in T \right\} \right)$ .
165
+
166
+ As seen for MGDA, corollary 1 implies that, even if the employed model $f$ has the capacity to reach the minimal loss on ${ \mathcal { L } } ^ { \mathrm { M } \mathbf { \bar { T } } }$ , IMTL may stop before reaching a stationary point. Recalling the relationship between under-optimizing and overfitting [15], this supports the interpretation of IMTL as a regularizer for equation (1). This is empirically shown in $\ S 5 . 3$ , Figures 5, 9(a). In particular, unitary scalarization reaches the same average performance of IMTL but requires earlier stopping.
167
+
168
+ PCGrad We provide an alternative characterization of the PCGrad update rule, highlighting its stochasticity in the context of its interpretation as loss rescaling [40, 42]. See appendix B.3 for a proof.
169
+
170
+ Proposition 3. PCGrad is equivalent to a dynamic, and possibly stochastic, loss rescaling for $\theta _ { \parallel }$ . $A t$ each iteration, per-task gradients are rescaled as follows:
171
+
172
+ $$
173
+ \begin{array} { r } { \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \gets \left( 1 + \sum _ { j \in \mathcal { T } \backslash \{ i \} } d _ { j i } \right) \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } , d _ { j i } \in \left[ 0 , \frac { \left\| \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { j } \right\| } { \left\| \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \right\| } \right] . } \end{array}
174
+ $$
175
+
176
+ Furthermore, $i f | \mathcal { T } | > 2$ , $d _ { j i }$ is a random variable, and the above range contains its support.
177
+
178
+ The results from proposition 3 can be easily extended to GradVac [62], which generalizes PCGrad’s projection onto the normal vector to arbitrary target cosine similarities between per-task gradients. When $| \mathcal T | > 2$ , PCGrad corresponds to a stochastic loss re-weighting. As such, PCGrad bears many similarities with Random Loss Weighting (RLW) [40]. RLW proposes to sample scalarization weights from standard probability distributions at each iteration, and proves that this leads the better generalization [40, theorem 2]. Indeed, it is well-known that adding noise to stochastic gradient estimations leads the optimization towards flatter minima, and that such minima may reduce overfitting [31, 34]. In line with the main technical results by Yu et al. [66], we now restrict our focus to two-task problems, which allow for an easy description of PCGrad’s convergence points. The result is largely based on [66, theorem 1]: we relax some of the assumptions and provide a proof in appendix B.3.
179
+
180
+ Corollary 2. If $| \tau | = 2$ , PCGrad will stop at any point where $\cos ( \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { 1 } , \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { 2 } ) = - 1 .$ . Furthermore, if $\mathcal { L } _ { 1 }$ and $\mathcal { L } _ { 2 }$ are differentiable, and $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } ^ { M T }$ is $L$ -Lipschitz with $L > 0$ , PCGrad with step size $\begin{array} { r } { t < \frac { 1 } { L } } \end{array}$ converges to a superset of the convergence points of the unitary scalarization.
181
+
182
+ Corollary 2 implies that, when $| \tau | = 2$ , PCGrad may under-optimize equation (1) as MGDA and IMTL. In particular, if $\cos ( \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { 1 } , \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { 2 } ) = - 1$ , then $\mathbf { 0 } \in \mathrm { C o n v } ( \{ { \nabla } \theta _ { \parallel } \mathcal { L } _ { 1 } , \nabla \theta _ { \parallel } \mathcal { L } _ { 2 } \} )$ (see proposition 1). We believe that PCGrad’s stochasticity and enlarged convergence set potentially explain its regularizing effect.
183
+
184
+ GradDrop While the motivation behind GradDrop is to avoid entry-wise gradient conflicts across tasks, the main property of the method is to drive the optimization towards “joint minima": points that are stationary for all the individual tasks at once [11, proposition 1]. In other words: $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } = \mathbf { 0 } \forall i \in$ $\tau$ . While this property is desirable, we show that it holds beyond GradDrop, and independently of the gradient directions. Under strong assumptions on the model capacity, the above property would trivially hold for unitary scalarization (proposition 5, appendix B.4). Proposition 4 shows that it holds for a simple randomized version of unitary scalarization, which we name Random Grad Drop (RGD).
185
+
186
+ Proposition 4. Let $\begin{array} { r } { \mathcal { L } ^ { R G D } ( \pmb { \theta } _ { \parallel } ) : = \sum _ { i \in \mathcal { T } } u _ { i } \mathcal { L } _ { i } ( \pmb { \theta } _ { \parallel } ) } \end{array}$ , where $u _ { i } \sim B e r n o u l l i ( p ) \forall i \in \mathcal { T }$ and $p \in ( 0 , 1 ]$ The gradient $\nabla _ { \pmb { \theta } _ { | | } } \mathcal { L } _ { \mathbf { \lambda } } ^ { R G D }$ is always zero if and only if $\nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } = \mathbf { 0 } \forall i \in \mathcal { T }$ . In other words, the result from $_ { I I I }$ , proposition $I J$ can be obtained without any information on the sign of per-task gradients.
187
+
188
+ Proposition 4 (see appendix B.4 for a simple proof) shows that an inexpensive sign-independent stochastic scalarization shares GradDrop’s main reported property. $\mathcal { L } ^ { \mathrm { { R G D } } }$ can be directly cast an instance of RLW, and hence as a regularization method [31, 34]. Furthermore, Figure 12 in appendix D.3 shows that the empirical results of GradDrop on CelebA [44] are closely matched by a sign-agnostic gradient masking, partly undermining the conflicting gradients assumption. We believe that the above results, along with the authors’ original experiments showing that GradDrop delays overfitting on CelebA [11, figure 3], suggest that GradDrop behaves as a regularizer.
189
+
190
+ # 5.3 Under-Optimization: Empirical Study
191
+
192
+ As seen in $\ S 5 . 2$ , MGDA and IMTL might under-optimize equation (1) compared to unitary scalarization due to their larger convergence sets. In order to assess whether this is empirically the case, we estimate $\begin{array} { r } { \big \| \sum _ { i \in \mathcal { T } } \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \big \| _ { 2 } } \end{array}$ , the norm of the unitary scalarization update on shared parameters $\theta _ { \parallel }$ , for all optimizers throughout the unregularized CelebA experiment from $\ S 5 . 1$ . Large magnitudes for $\begin{array} { r } { \big \| \sum _ { i \in \mathcal { T } } \mathbf { \dot { V } } _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \big \| _ { 2 } } \end{array}$ towards convergence would indicate that SMTOs steer optimization far from stationary points of unitary scalarization, resulting in under-optimization. We compute the update norm on the mini-batch loss every 100 updates, and report the per-epoch average in Figure 6. Most SMTOs have a smaller update magnitude than unitary scalarization in the first 15 epochs. However, towards convergence, SMTOs display larger $\begin{array} { r } { \big \| \sum _ { i \in \mathcal { T } } \nabla _ { \pmb { \theta } _ { \parallel } } \mathcal { L } _ { i } \big \| _ { 2 } } \end{array}$ compared to unitary scalarization. In particular, IMTL and MGDA have the largest norm, denoting significant empirical under-optimization. The additional stochasticity of RLW, PCGrad, and GradDrop also appears to lead to larger norm values than unitary scalarization, yet to a lesser degree. Given that MGDA and IMTL incur a larger loss than unitary scalarization in later epochs (see Figure 9(a) in appendix D.2), we can conclude that they guide optimization towards regions of the parameter space that under-optimize equation (1), providing empirical support for our analysis.
193
+
194
+ # 6 Conclusions
195
+
196
+ This paper made two main contributions. First, we evaluated popular SMTOs using a single experimental pipeline, including previously unpublished results of MGDA, IMTL, RLW, and GradDrop in the RL setting. Surprisingly, our evaluation showed that none of the SMTOs consistently outperform unitary scalarization, the simplest and least expensive method. Second, in order to explain our surprising results, we postulate that SMTOs act as regularizers and present an analysis that supports our hypothesis. We believe our work calls for further reevaluation of progress in developing principled and efficient MTL algorithms.
197
+
198
+ We conclude by addressing the limitations of our work. While we covered a wide range of popular benchmarks, we do not exclude the existence of settings where unitary scalarization underperforms: discovering them is an interesting direction for future work. Furthermore, our experimental results were obtained via grid searches under limited compute resources: some of the methods might benefit from further fine-tuning. Nevertheless, we remark that fine-tuning will be easier for unitary scalarization due to its shorter runtimes. Finally, we presented the regularization hypothesis only as a partial explanation of our results: we hope it will steer further analysis and consequently improve the understanding of MTL.
199
+
200
+ # Acknowledgements
201
+
202
+ VK was funded by Samsung R&D Institute UK through the EPSRC Centre for Doctoral Training (CDT) in Autonomous Intelligent Machines and Systems (AIMS) at the University of Oxford . ADP was funded by EPSRC for the AIMS CDT, grant EP/L015987/1, and by an IBM PhD fellowship. SW has received funding from the European Research Council under the European Union’s Horizon 2020 research and innovation programme (grant agreement number 637713). The experiments were made possible by a generous equipment grant from NVIDIA. We would like to thank Lin et al. [40], Sodhani et al. [55] and Sener and Koltun [54] for publicly releasing their code. The authors thank Kristian Hartikainen for helpful comments on the RL experiments. VK thanks Ryota Tomioka for useful discussions on multitask optimization.
203
+
204
+ # References
205
+
206
+ [1] Z. Allen-Zhu, Y. Li, and Z. Song. A convergence theory for deep learning via overparameterization. In International Conference on Machine Learning, 2019.
207
+ [2] V. Badrinarayanan, A. Kendall, and R. Cipolla. Segnet: A deep convolutional encoder-decoder architecture for image segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017.
208
+ [3] B. Bakker and T. Heskes. Task clustering and gating for bayesian multitask learning. Journal of Machine Learning Research, 2003.
209
+ [4] Q. Cappart, D. Chételat, E. B. Khalil, A. Lodi, C. Morris, and P. Velickovic. Combinatorial optimization and reasoning with graph neural networks. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, IJCAI 2021, Virtual Event / Montreal, Canada, 19-27 August 2021, 2021.
210
+ [5] R. Caruana. Multitask learning. Machine Learning, 28(1):41–75, 1997.
211
+ [6] R. Caruana. Multitask learning. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213, 1997.
212
+ [7] R. Caruana, S. Lawrence, and L. Giles. Overfitting in neural nets: Backpropagation, conjugate gradient, and early stopping. In Neural Information Processing Systems, 2000. [8] L.-C. Chen, Y. Zhu, G. Papandreou, F. Schroff, and H. Adam. Encoder-decoder with atrous separable convolution for semantic image segmentation. In European Conference on Computer Vision, 2018.
213
+ [9] S. Chen, Y. Zhang, and Q. Yang. Multi-task learning in natural language processing: An overview. CoRR, 2021.
214
+ [10] Z. Chen, V. Badrinarayanana, C.-Y. Lee, and A. Rabinovich. Gradnorm: Gradient normalization for adaptive loss balancing in deep multitask networks. In International Conference on Machine Learning, 2018.
215
+ [11] Z. Chen, J. Ngiam, Y. Huang, T. Luong, H. Kretzschmar, Y. Chai, and D. Anguelov. Just pick a sign: Optimizing deep multitask models with gradient sign dropout. In Neural Information Processing Systems, 2020.
216
+ [12] R. Collobert and J. Weston. A unified architecture for natural language processing: deep neural networks with multitask learning. In Machine Learning, Proceedings of the Twenty-Fifth International Conference (ICML 2008), Helsinki, Finland, June 5-9, 2008, 2008.
217
+ [13] M. Cordts, M. Omran, S. Ramos, T. Rehfeld, M. Enzweiler, R. Benenson, U. Franke, S. Roth, and B. Schiele. The cityscapes dataset for semantic urban scene understanding. In Conference on Computer Vision and Pattern Recognition, 2016.
218
+ [14] J. Désidéri. Multiple-gradient descent algorithm (MGDA) for multiobjective optimization. Comptes Rendus Mathematique, 350:313–318, 2012.
219
+ [15] T. Dietterich. Overfitting and undercomputing in machine learning. ACM Computing Surveys, page 326–327, sep 1995.
220
+ [16] T. Evgeniou and M. Pontil. Regularized multi–task learning. In ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2004.
221
+ [17] J. Fliege and B. F. Svaiter. Steepest descent methods for multicriteria optimization. Mathematical Methods of Operations Research, 2000.
222
+ [18] M. Guo, A. Haque, D.-A. Huang, S. Yeung, and L. Fei-Fei. Dynamic task prioritization for multitask learning. In Proceedings of the European Conference on Computer Vision (ECCV), September 2018.
223
+ [19] P. Guo, C.-Y. Lee, and D. Ulbricht. Learning to branch for multi-task learning. 2020.
224
+ [20] T. Haarnoja, A. Zhou, P. Abbeel, and S. Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International Conference on Machine Learning, 2018.
225
+ [21] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. Conference on Computer Vision and Pattern Recognition, 2016.
226
+ [22] T. Heskes. Empirical bayes for learning to learn. In International Conference on Machine Learning, 2000.
227
+ [23] M. Hessel, H. Soyer, L. Espeholt, W. Czarnecki, S. Schmitt, and H. van Hasselt. Multi-task deep reinforcement learning with popart. In The Thirty-Third AAAI Conference on Artificial Intelligence, AAAI 2019, The Thirty-First Innovative Applications of Artificial Intelligence Conference, IAAI 2019, The Ninth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2019, Honolulu, Hawaii, USA, January 27 - February 1, 2019, pages 3796–3803. AAAI Press, 2019.
228
+ [24] T. M. Hospedales, A. Antoniou, P. Micaelli, and A. J. Storkey. Meta-learning in neural networks: A survey. CoRR, 2020.
229
+ [25] W. Huang, I. Mordatch, and D. Pathak. One policy to control them all: Shared modular policies for agent-agnostic control. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, 2020.
230
+ [26] S. Ioffe and C. Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International Conference on Machine Learning, 2015.
231
+ [27] M. Jaderberg, V. Mnih, W. M. Czarnecki, T. Schaul, J. Z. Leibo, D. Silver, and K. Kavukcuoglu. Reinforcement learning with unsupervised auxiliary tasks. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017.
232
+ [28] A. Javaloy and I. Valera. Rotograd: Gradient homogenization in multitask learning. In International Conference on Learning Representations, 2022.
233
+ [29] D. Kalashnikov, J. Varley, Y. Chebotar, B. Swanson, R. Jonschkowski, C. Finn, S. Levine, and K. Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. CoRR, 2021.
234
+ [30] A. Kendall, Y. Gal, and R. Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
235
+ [31] N. S. Keskar, D. Mudigere, J. Nocedal, M. Smelyanskiy, and P. T. P. Tang. On large-batch training for deep learning: Generalization gap and sharp minima. International Conference on Learning Representations, 2017.
236
+ [32] K. Khetarpal, M. Riemer, I. Rish, and D. Precup. Towards continual reinforcement learning: A review and perspectives. arXiv preprint arXiv:2012.13490, 2020.
237
+ [33] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. In Y. Bengio and Y. LeCun, editors, International Conference on Learning Representations, 2015.
238
+ [34] B. Kleinberg, Y. Li, and Y. Yuan. An alternative view: When does SGD escape local minima? In International Conference on Machine Learning, 2018.
239
+ [35] I. Kokkinos. Ubernet: Training a universal convolutional neural network for low-, mid-, and high-level vision using diverse datasets and limited memory. IEEE Conference on Computer Vision and Pattern Recognition, 2017.
240
+ [36] V. Kurin, S. Godil, S. Whiteson, and B. Catanzaro. Can q-learning with graph networks learn a generalizable branching heuristic for a SAT solver? In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
241
+ [37] V. Kurin, M. Igl, T. Rocktäschel, W. Boehmer, and S. Whiteson. My body is a cage: the role of morphology in graph-based incompatible control. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021, 2021.
242
+ [38] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. IEEE, 1998.
243
+ [39] M. Li, M. Soltanolkotabi, and S. Oymak. Gradient descent with early stopping is provably robust to label noise for overparameterized neural networks. In International Conference on Artificial Intelligence and Statistics, 2020.
244
+ [40] B. Lin, F. Ye, and Y. Zhang. A closer look at loss weighting in multi-task learning. In arXiv preprint arXiv:2111.10603, 2022.
245
+ [41] B. Liu, X. Liu, X. Jin, P. Stone, and Q. Liu. Conflict-averse gradient descent for multi-task learning. Advances in Neural Information Processing Systems, 2021.
246
+ [42] L. Liu, Y. Li, Z. Kuang, J.-H. Xue, Y. Chen, W. Yang, Q. Liao, and W. Zhang. Towards impartial multi-task learning. In International Conference on Learning Representations, 2021.
247
+ [43] S. Liu, E. Johns, and A. J. Davison. End-to-end multi-task learning with attention. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1871–1880, 2019.
248
+ [44] Z. Liu, P. Luo, X. Wang, and X. Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), 2015.
249
+ [45] S. Ma, R. Bassily, and M. Belkin. The power of interpolation: Understanding the effectiveness of sgd in modern over-parametrized learning. In International Conference on Machine Learning, 2018.
250
+ [46] I. Misra, A. Shrivastava, A. Gupta, and M. Hebert. Cross-stitch networks for multi-task learning. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, 2016.
251
+ [47] S. Narvekar, B. Peng, M. Leonetti, J. Sinapov, M. E. Taylor, and P. Stone. Curriculum learning for reinforcement learning domains: A framework and survey. J. Mach. Learn. Res., 2020.
252
+ [48] A. Navon, A. Shamsian, I. Achituve, H. Maron, K. Kawaguchi, G. Chechik, and E. Fetaya. Multi-task learning as a bargaining game. In International Conference on Machine Learning, 2022.
253
+ [49] E. Parisotto, L. J. Ba, and R. Salakhutdinov. Actor-mimic: Deep multitask and transfer reinforcement learning. In Y. Bengio and Y. LeCun, editors, 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016.
254
+ [50] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, A. Desmaison, A. Kopf, E. Yang, Z. DeVito, M. Raison, A. Tejani, S. Chilamkurthy, B. Steiner, L. Fang, J. Bai, and S. Chintala. Pytorch: An imperative style, high-performance deep learning library. In Neural Information Processing Systems. 2019.
255
+ [51] A. A. Rusu, S. G. Colmenarejo, Ç. Gülçehre, G. Desjardins, J. Kirkpatrick, R. Pascanu, V. Mnih, K. Kavukcuoglu, and R. Hadsell. Policy distillation. In Y. Bengio and Y. LeCun, editors, 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016.
256
+ [52] S. Sabour, N. Frosst, and G. E. Hinton. Dynamic Routing between Capsules. 2017.
257
+ [53] M. L. Seltzer and J. Droppo. Multi-task learning in deep neural networks for improved phoneme recognition. In IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP 2013, Vancouver, BC, Canada, May 26-31, 2013, 2013.
258
+ [54] O. Sener and V. Koltun. Multi-task learning as multi-objective optimization. In Neural Information Processing Systems, 2018.
259
+ [55] S. Sodhani, A. Zhang, and J. Pineau. Multi-task reinforcement learning with context-based representations. In M. Meila and T. Zhang, editors, International Conference on Machine Learning, 2021.
260
+ [56] N. Srivastava, G. Hinton, A. Krizhevsky, I. Sutskever, and R. Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 2014.
261
+ [57] Y. W. Teh, V. Bapst, W. M. Czarnecki, J. Quan, J. Kirkpatrick, R. Hadsell, N. Heess, and R. Pascanu. Distral: Robust multitask reinforcement learning. In I. Guyon, U. von Luxburg, S. Bengio, H. M. Wallach, R. Fergus, S. V. N. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 4496–4506, 2017.
262
+ [58] Y. W. Teh, V. Bapst, W. M. Czarnecki, J. Quan, J. Kirkpatrick, R. Hadsell, N. Heess, and R. Pascanu. Distral: Robust multitask reinforcement learning. In Neural Information Processing Systems, 2017.
263
+ [59] W.-C. Tseng. Weichengtseng/pytorch-pcgrad, 2020. URL https://github.com/ WeiChengTseng/Pytorch-PCGrad.git.
264
+ [60] H. P. van Hasselt, A. Guez, M. Hessel, V. Mnih, and D. Silver. Learning values across many orders of magnitude. Advances in Neural Information Processing Systems, 29:4287–4295, 2016.
265
+ [61] S. Vandenhende, S. Georgoulis, W. Van Gansbeke, M. Proesmans, D. Dai, and L. Van Gool. Multi-task learning for dense prediction tasks: A survey. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
266
+ [62] Z. Wang, Y. Tsvetkov, O. Firat, and Y. Cao. Gradient vaccine: Investigating and improving multi-task optimization in massively multilingual models. In International Conference on Learning Representations, 2021.
267
+ [63] D. Xin, B. Ghorbani, A. Garg, O. Firat, and J. Gilmer. Do current multi-task optimization methods in deep learning even help? In Neural Information Processing Systems, 2022.
268
+ [64] F. Yu, V. Koltun, and T. Funkhouser. Dilated residual networks. In Computer Vision and Pattern Recognition, 2017.
269
+ [65] T. Yu, D. Quillen, Z. He, R. Julian, K. Hausman, C. Finn, and S. Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In L. P. Kaelbling, D. Kragic, and K. Sugiura, editors, 3rd Annual Conference on Robot Learning, 2019.
270
+ [66] T. Yu, S. Kumar, A. Gupta, S. Levine, K. Hausman, and C. Finn. Gradient surgery for multi-task learning. In Neural Information Processing Systems, 2020.
271
+
272
+ # Checklist
273
+
274
+ 1. For all authors...
275
+
276
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
277
+ (b) Did you describe the limitations of your work? [Yes] see $\ S 6$ .
278
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] due to space constraints, we provide a discussion in appendix A.
279
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
280
+
281
+ 2. If you are including theoretical results...
282
+
283
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes] we provide full proofs in the Appendix, and refer to them in the main body of the paper.
284
+
285
+ 3. If you ran experiments...
286
+
287
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] we provide the code and the instructions in the supplemental material.
288
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
289
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
290
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] see appendix C.1.
291
+
292
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
293
+
294
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
295
+ (b) Did you mention the license of the assets? [Yes] appendix C.3 describes licenses of all benchmarks and implementations we used for our work.
296
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] we include the code and the instructions on how to replicate the experiments into the supplemental material.
297
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
298
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
299
+
300
+ 5. If you used crowdsourcing or conducted research with human subjects...
301
+
302
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
303
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
304
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/xxgp42Qz6dL/xxgp42Qz6dL.md ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EGSDE: Unpaired Image-to-Image Translation via Energy-Guided Stochastic Differential Equations
2
+
3
+ Min Zhao1, Fan Bao1, Chongxuan $\mathbf { L i ^ { 2 , 3 * } }$ , $\mathbf { J u n \ : Z h u ^ { 1 * } }$ 1Dept. of Comp. Sci. & Tech., BNRist Center, THU-Bosch ML Center, Tsinghua University, China 2 Gaoling School of Artificial Intelligence, Renmin University of China, Beijing, China 3 Beijing Key Laboratory of Big Data Management and Analysis Methods , Beijing, China 4 Pazhou Laboratory (Huangpu), Guangzhou, China gracezhao1997@gmail.com; bf19@mails.tsinghua.edu.cn; chongxuanli@ruc.edu.cn; dcszj@tsinghua.edu.cn
4
+
5
+ # Abstract
6
+
7
+ Score-based diffusion models (SBDMs) have achieved the SOTA FID results in unpaired image-to-image translation (I2I). However, we notice that existing methods totally ignore the training data in the source domain, leading to sub-optimal solutions for unpaired I2I. To this end, we propose energy-guided stochastic differential equations (EGSDE) that employs an energy function pretrained on both the source and target domains to guide the inference process of a pretrained SDE for realistic and faithful unpaired I2I. Building upon two feature extractors, we carefully design the energy function such that it encourages the transferred image to preserve the domain-independent features and discard domain-specific ones. Further, we provide an alternative explanation of the EGSDE as a product of experts, where each of the three experts (corresponding to the SDE and two feature extractors) solely contributes to faithfulness or realism. Empirically, we compare EGSDE to a large family of baselines on three widely-adopted unpaired I2I tasks under four metrics. EGSDE not only consistently outperforms existing SBDMs-based methods in almost all settings but also achieves the SOTA realism results without harming the faithful performance. Furthermore, EGSDE allows for flexible trade-offs between realism and faithfulness and we improve the realism results further (e.g., FID of 51.04 in $\mathrm { C a t } \to \mathrm { D o g }$ and FID of 50.43 in Wild $ \mathrm { D o g }$ on AFHQ) by tuning hyper-parameters. The code is available at https://github.com/ML-GSAI/EGSDE.
8
+
9
+ # 1 Introduction
10
+
11
+ Unpaired image-to-image translation (I2I) aims to transfer an image from a source domain to a related target domain, which involves a wide range of computer vision tasks such as style transfer, super-resolution and pose estimation [35]. In I2I, the translated image should be realistic to fit the style of the target domain by changing the domain-specific features accordingly, and faithful to preserve the domain-independent features of the source image. Over the past few years, generative adversarial networks [12] (GANs)-based methods [10, 60, 54, 36, 3, 57, 44, 19, 17, 26, 10] dominated this field due to their ability to generate high-quality samples.
12
+
13
+ In contrast to GANs, score-based diffusion models (SBDMs) [48, 16, 34, 49, 2, 31] perturb data to a Gaussian noise by a diffusion process and learn the reverse process to transform the noise back to the data distribution. Recently, SBDMs achieved competitive or even superior image generation performance to GANs [9] and thus were naturally applied to unpaired I2I [7, 32], which have achieved the state-of-the-art FID [13] and KID [4] results empirically. However, we notice that these methods did not leverage the training data in the source domain at all. Indeed, they trained a diffusion model solely on the target domain and exploited the test source image during inference (see details in Sec. 2.2). Therefore, we argue that if the training data in the source domain can be exploited together with those in the target domain, one can learn domain-specific and domain-independent features to improve both the realism and faithfulness of the SBDMs in unpaired I2I.
14
+
15
+ ![](images/e4f9c517b6ab668bf48e33cada856c01394347a9d7995779d0fca2fd5ec2550e.jpg)
16
+ Figure 1: (a) Apart from the SDE, the EGSDE incorporates a realism expert and a faithful expert to preserve the domain-independent features and discard domain-specific ones. (b) Representative translation results on three unpaired I2I tasks.
17
+
18
+ To this end, we propose energy-guided stochastic differential equations (EGSDE) that employs an energy function pretrained across the two domains to guide the inference process of a pretrained SDE for realistic and faithful unpaired I2I. Formally, EGSDE defines a valid conditional distribution via a reverse time SDE that composites the energy function and the pretrained SDE. Ideally, the energy function should encourage the transferred image to preserve the domain-independent features and discard domain-specific ones. To achieve this, we introduce two feature extractors that learn domainindependent features and domain-specific ones respectively, and define the energy function upon the similarities between the features extracted from the transferred image and the test source image. Further, we provide an alternative explanation of the discretization of EGSDE in the formulation of product of experts [15]. In particular, the pretrained SDE and the two feature extractors in the energy function correspond to three experts and each solely contributes to faithfulness or realism.
19
+
20
+ Empirically, we validate our method on the widely-adopted AFHQ [8] and CelebA-HQ [20] datasets including $\mathrm { C a t } \to \mathrm { D o g }$ , Wild $ \mathrm { D o g }$ and Male Female tasks. We compare to a large family of baselines, including the GANs-based ones [36, 60, 17, 26, 3, 10, 57, 58] and SBDMs-based ones [7, 32] under four metrics (e.g., FID). EGSDE not only consistently outperforms SBDMs-based methods in almost all settings but also achieves the SOTA realism results without harming the faithful performance. Furthermore, EGSDE allows for flexible trade-offs between realism and faithfulness and we improve the FID further (e.g., 51.04 in $\mathbf { C a t } \to \mathbf { D o g }$ and 50.43 in Wild $ \mathrm { D o g }$ ) by tuning hyper-parameters. EGSDE can also be extended to multi-domain translation easily.
21
+
22
+ # 2 Background
23
+
24
+ # 2.1 Score-based Diffusion Models
25
+
26
+ Score-based diffusion models (SBDMs) gradually perturb data by a forward diffusion process, and then reverse it to recover the data [49, 2, 47, 16, 9]. Let $q ( \pmb { y } _ { 0 } )$ be the unknown data distribution
27
+
28
+ on $\mathbb { R } ^ { D }$ . The forward diffusion process $\{ y _ { t } \} _ { t \in [ 0 , T ] }$ , indexed by time $t$ , can be represented by the following forward SDE:
29
+
30
+ $$
31
+ \begin{array} { r } { d \pmb { y } = \pmb { f } ( \pmb { y } , t ) d t + \pmb { g } ( t ) d \pmb { w } , } \end{array}
32
+ $$
33
+
34
+ where ${ \pmb w } \in \mathbb { R } ^ { D }$ is a standard Wiener process, $\pmb { f } ( \cdot , t ) : \mathbb { R } ^ { D } \mathbb { R } ^ { D }$ is the drift coefficient and $g ( t ) \in \mathbb { R }$ is the diffusion coefficient. The $f ( { \boldsymbol { \mathbf { \mathit { y } } } } , t )$ and $g ( t )$ is related into the noise size and determines the perturbation kernel $q _ { t \mid 0 } ( { \pmb y } _ { t } | { \pmb y } _ { 0 } )$ from time 0 to $t$ . In practice, the $f ( { \boldsymbol { \mathbf { \mathit { y } } } } , t )$ is usually affine so that the the perturbation kernel is a linear Gaussian distribution and can be sampled in one step.
35
+
36
+ Let $q _ { t } ( \pmb { y } )$ be the marginal distribution of the SDE at time $t$ in Eq. (1). Its time reversal can be described by another SDE [49]:
37
+
38
+ $$
39
+ \mathrm { d } \pmb { y } = [ \pmb { f } ( \pmb { y } , t ) - g ( t ) ^ { 2 } \nabla _ { \pmb { y } } \log q _ { t } ( \pmb { y } ) ] \mathrm { d } t + g ( t ) \mathrm { d } \overline { { \ b { w } } } ,
40
+ $$
41
+
42
+ where $\overline { { { \bf w } } }$ is a reverse-time standard Wiener process, and $\mathrm { d } t$ is an infinitesimal negative timestep. [49] adopts a score-based model $s ( \boldsymbol { y } , t )$ to approximate the unknown $\nabla _ { \boldsymbol { y } } \log q _ { t } ( \boldsymbol { y } )$ by score matching, thus inducing a score-based diffusion model (SBDM), which is defined by a SDE:
43
+
44
+ $$
45
+ \mathrm { d } \pmb { y } = [ \pmb { f } ( \pmb { y } , t ) - g ( t ) ^ { 2 } \pmb { s } ( \pmb { y } , t ) ] \mathrm { d } t + g ( t ) \mathrm { d } \overline { { \pmb { w } } } .
46
+ $$
47
+
48
+ There are numerous SDE solver to solve the Eq. (3) to generate images. [49] discretizes it using the Euler-Maruyama solver. Formally, adopting a step size of $h$ , the iteration rule from $s$ to $t = s - h$ is:
49
+
50
+ $$
51
+ y _ { t } = y _ { s } - [ f ( y _ { s } , s ) - g ( s ) ^ { 2 } s ( y _ { s } , s ) ] h + g ( s ) \sqrt { h } z , \quad z \sim \mathcal { N } ( \mathbf { 0 } , I ) .
52
+ $$
53
+
54
+ # 2.2 SBDMs in Unpaired Image to Image Translation
55
+
56
+ Given unpaired images from the source domain $\boldsymbol { \mathcal { X } } \subset \mathbb { R } ^ { D }$ and the target domain $\mathcal { V } \subset \mathbb { R } ^ { D }$ as the training data, the goal of unpaired I2I is to transfer an image from the source domain to the target domain. Such a process can be formulated as designing a distribution $p ( \pmb { y } _ { 0 } | \pmb { x } _ { 0 } )$ on the target domain $\mathcal { V }$ conditioned on an image $\mathbf { \boldsymbol { x } } _ { 0 } \in \mathcal { X }$ to transfer. The translated image should be realistic for the target domain by changing the domain-specific features and faithful for the source image by preserving the domain-independent features.
57
+
58
+ ILVR [7] uses a diffusion model on the target domain for realism. Formally, ILVR starts from ${ \pmb y } _ { T } \sim \mathcal { N } ( { \bf 0 } , I )$ and samples from the diffusion model according to Eq. (4) to obtain ${ \mathbf { } } _ { \pmb { y } _ { t } }$ . For faithfulness, it further refines ${ \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \Xi } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \textbf { } _ { \mathbf { } } \textbf { } \textbf { } _ { \mathrm { } }$ by adding the residual between the sample ${ \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \Xi } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \textbf { } _ { \mathbf { } } \textbf { } \textbf { } _ { \mathrm { } }$ and the perturbed source image $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ through a non-trainable low-pass filter
59
+
60
+ $$
61
+ \begin{array} { r } { \pmb { y } _ { t } \pmb { y } _ { t } + \Phi ( \pmb { x } _ { t } ) - \Phi ( \pmb { y } _ { t } ) , \quad \pmb { x } _ { t } \sim q _ { t | 0 } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } ) , } \end{array}
62
+ $$
63
+
64
+ where $\Phi ( \cdot )$ is a low-pass filter and $q _ { t | 0 } ( \cdot | \cdot )$ is the perturbation kernel determined by the forward SDE in Eq. (1).
65
+
66
+ Similarly, SDEdit [32] also adopts a SBDM on the target domain for realism, i.e., sampling from the SBDM according to Eq. (4). For faithfulness, SDEdit starts the generation process from the noisy source image ${ \pmb y } _ { M } \sim q _ { M | 0 } ( { \pmb y } _ { M } | { \pmb x } _ { 0 } )$ , where $M$ is a middle time between 0 and $T$ , and is chosen to preserve the original overall structure and discard local details. We use $p _ { r 1 } ( \pmb { y } _ { 0 } \vert \pmb { x } _ { 0 } )$ to denote the marginal distribution defined by such SDE conditioned on $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ .
67
+
68
+ Notably, these methods did not leverage the training data in the source domain at all and thus can be sub-optimal in terms of both the realism and faithfulness in unpaired I2I.
69
+
70
+ # 3 Method
71
+
72
+ To overcome the limitations of existing methods [7, 32] as highlighted in Sec. 2.2, we propose energy-guided stochastic differential equations (EGSDE) that employs an energy function pre-trained across the two domains to guide the inference process of a pretrained SDE for realistic and faithful unpaired I2I (see Fig. 2). EGSDE defines a valid conditional distribution $p ( \pmb { y } _ { 0 } | \pmb { x } _ { 0 } )$ by compositing a pretrained SDE and a pretrained energy function under mild regularity conditions2 as follows:
73
+
74
+ $$
75
+ \mathrm { d } \pmb { y } = [ \pmb { f } ( \pmb { y } , t ) - g ( t ) ^ { 2 } ( \pmb { s } ( \pmb { y } , t ) - \nabla _ { \pmb { y } } \pmb { \mathcal { E } } ( \pmb { y } , \pmb { x } _ { 0 } , t ) ) ] \mathrm { d } t + g ( t ) \mathrm { d } \overline { { \pmb { w } } } ,
76
+ $$
77
+
78
+ ![](images/f02446ab0e0da6321a04bce1eaa21fccc13f8b9fa4d36838329497b13c199608.jpg)
79
+ Figure 2: The overview of our EGSDE. Starting from the noisy source image, we can run the EGSDE for unpaired I2I, which employs an energy function $\boldsymbol { \mathcal { E } } ( \boldsymbol { y } , \boldsymbol { x } , t )$ pretrained on both the source and target domains to guide the inference process of a pretrained SDE $( s ( \pmb { y } , t )$ , realism expert 1). The energy function is decomposed into two terms further, where the realistic expert 2 $\mathcal { E } _ { s } ( \pmb { y } , \pmb { x } , t )$ encourages the transferred image to discard domain-specific features and the faithful expert $\mathcal { E } _ { i } ( \pmb { y } , \pmb { x } , t )$ aims to preserve the domain-independent ones.
80
+
81
+ where $\overline { { { \bf w } } }$ is a reverse-time standard Wiener process, $\mathrm { d } t$ is an infinitesimal negative timestep, $s ( \cdot , \cdot ) :$ $\mathbb { R } ^ { D } \times \mathbb { R } \mathbb { R } ^ { D }$ is the score-based model in the pretrained SDE and $\mathcal { E } ( \cdot , \cdot , \cdot ) : \bar { \mathbb { R } ^ { D } } \times \mathbb { R } ^ { D } \times \bar { \mathbb { R } } \stackrel { \cdot } { } \bar { \mathbb { R } }$ is the energy function. The start point ${ \pmb y } _ { M }$ is sampled from the perturbation distribution $q _ { M | 0 } ( { \pmb y } _ { M } | { \pmb x } _ { 0 } )$ [32], where $M = 0 . 5 T$ typically. We obtain the transferred images by taking the samples at endpoint $t = 0$ following the SDE in Eq. (6).
82
+
83
+ Similar to the prior work [7, 32], EGSDE employs an SDE trained solely in the target domain as in Eq. (2), which defines a marginal distribution of the target images and mainly contributes to the realism of the transferred samples. In contrast, the energy function involves the training data across both the source and target domain, making EGSDE distinct from the prior work [7, 32]. Notably, although many other possibilities exist, we carefully design the energy function such that it (approximately) encourages the sample to retain the domain-independent features and discard the domain-specific ones to improve both the faithfulness and realism of the transferred sample. Below, we formally formulate the energy function.
84
+
85
+ # 3.1 Choice of Energy
86
+
87
+ In this section, we show how to design the energy function. Intuitively, during the translation, the domain-independent features (pose, color, etc. on $\mathbf { C a t } \to \mathbf { D o g }$ ) should be preserved while the domain-specific features (beard, nose, etc. on $\mathrm { C a t } \to \mathrm { D o g }$ ) should be changed accordingly. Motivated by this, we decompose the energy function $\mathcal { E } ( \boldsymbol { y } , \boldsymbol { x } , t )$ as the sum of two log potential functions [5]:
88
+
89
+ $$
90
+ \begin{array} { r l } & { \mathcal { E } ( { \pmb y } , { \pmb x } , t ) = \lambda _ { s } \mathcal { E } _ { s } ( { \pmb y } , { \pmb x } , t ) + \lambda _ { i } \mathcal { E } _ { i } ( { \pmb y } , { \pmb x } , t ) } \\ & { \qquad = \lambda _ { s } \mathbb { E } _ { q _ { t \vert 0 } ( { \pmb x } _ { t } \vert { \pmb x } ) } \mathcal { S } _ { s } ( { \pmb y } , { \pmb x } _ { t } , t ) - \lambda _ { i } \mathbb { E } _ { q _ { t \vert 0 } ( { \pmb x } _ { t } \vert { \pmb x } ) } \mathcal { S } _ { i } ( { \pmb y } , { \pmb x } _ { t } , t ) , } \end{array}
91
+ $$
92
+
93
+ where $\mathcal { E } _ { i } ( \cdot , \cdot , \cdot ) : \mathbb { R } ^ { D } \times \mathbb { R } ^ { D } \times \mathbb { R } \mathbb { R }$ and $\mathcal { E } _ { s } ( \cdot , \cdot , \cdot ) : \mathbb { R } ^ { D } \times \mathbb { R } ^ { D } \times \mathbb { R } \mathbb { R }$ are the log potential functions, $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ is the perturbed source image in the forward SDE, $q _ { t | 0 } ( \cdot | \cdot )$ is the perturbation kernel from time 0 to time $t$ in the forward SDE, $S _ { s } ( \cdot , \cdot , \cdot ) : \mathbb { R } ^ { D } \times \mathbb { R } ^ { D } \times \mathbb { R } \mathbb { R }$ and $S _ { i } ( \cdot , \cdot , \cdot ) : \mathbb { R } ^ { D } \times \mathbb { R } ^ { D } \times \mathbb { R } \mathbb { R }$ are two functions measuring the similarity between the sample and perturbed source image, and $\lambda _ { s } \in \mathbb { R } _ { > 0 } , \lambda _ { i } \in \mathbb { R } _ { > 0 }$ are two weighting hyper-parameters. Note that the expectation w.r.t. $q _ { t | 0 } ( \pmb { x } _ { t } | \pmb { x } )$ in Eq. (7) guarantees that the energy function changes slowly over the trajectory to satisfy the regularity conditions in Appendix A.1.
94
+
95
+ To specify $S _ { s } ( \cdot , \cdot , \cdot )$ , we introduce a time-dependent domain-specific feature extractor $E _ { s } ( \cdot , \cdot ) :$ $\mathbb { R } ^ { D } \times \mathbb { R } \stackrel { \cdot } { \to } \mathbb { R } ^ { C \times H \times W }$ , where $C$ is the channel-wise dimension, $H$ and $W$ are the dimension of height and width. In particular, $E _ { s } ( \cdot , \cdot )$ is the all but the last layer of a classifier that is trained on both domains to predict whether an image is from the source domain or the target domain. Intuitively, $E _ { s } ( \cdot , \cdot )$ will preserve the domain-specific features and discard the domain-independent features for accurate predictions. Building upon it, $S _ { s } ( \cdot , \cdot , \cdot )$ is defined as the cosine similarity between the features extracted from the generated sample and the source image as follows:
96
+
97
+ $$
98
+ \displaystyle \mathcal { S } _ { s } ( { \pmb y } , { \pmb x } _ { t } , t ) = \frac { 1 } { H W } \sum _ { h , w } \frac { E _ { s } ^ { h w } ( { \pmb x } _ { t } , t ) ^ { \top } E _ { s } ^ { h w } ( { \pmb y } , t ) } { | | E _ { s } ^ { h w } ( { \pmb x } _ { t } , t ) | | _ { 2 } | | E _ { s } ^ { h w } ( { \pmb y } , t ) | | _ { 2 } } ,
99
+ $$
100
+
101
+ where $E _ { s } ^ { h w } ( \cdot , \cdot ) \in \mathbb { R } ^ { C }$ denote the channel-wise feature at spatial position $( h , w )$ . Here we employ the cosine similarity since it preserves the spatial information and helps to improve the FID score empirically (see Appendix C.1 for the ablation study). Intuitively, reducing the energy value in Eq. (7) encourages the transferred sample to discard the domain-specific features to improve realism.
102
+
103
+ To specify $S _ { i } ( \cdot , \cdot , \cdot )$ , we introduce a domain-independent feature extractor $E _ { i } ( \cdot , \cdot ) : \mathbb { R } ^ { D } \times \mathbb { R } \to \mathbb { R } ^ { D }$ , which is a low-pass filter. Intuitively, $E _ { i } ( \cdot , \cdot )$ will preserve the overall structures (i.e., domainindependent features) and discard local information like textures (i.e., domain-specific features). Building upon it, $S _ { i } ( \cdot , \cdot , \cdot )$ is defined as the negative squared $L _ { 2 }$ distance between the features extracted from the generated sample and source image as follows:
104
+
105
+ $$
106
+ \begin{array} { r } { S _ { i } ( { \pmb y } , { \pmb x } _ { t } , t ) = - | | E _ { i } ( { \pmb y } , t ) - E _ { i } ( { \pmb x } _ { t } , t ) | | _ { 2 } ^ { 2 } . } \end{array}
107
+ $$
108
+
109
+ Here, we choose negative squared $L _ { 2 }$ distance as the similarity metric because it helps to preserve more domain-independent features empirically (see Appendix C.1 for the ablation study). Intuitively, reducing the energy value in Eq. (7) encourages the transferred sample to preserve the domainindependent features to improve faithfulness. In this paper we employ a low-pass filter for its simpleness and effectiveness while we can train more sophisticated $E _ { i }$ , e.g., based on disentangled representation learning methods [42, 6, 14, 23, 28], on the data in the two domains.
110
+
111
+ In our preliminary experiment, alternative to Eq. (7), we consider a simpler energy function that only involves the original source image $_ { \textbf { \em x } }$ as follows:
112
+
113
+ $$
114
+ \begin{array} { r } { \mathcal { E } ( \pmb { y } , \pmb { x } , t ) = \lambda _ { s } S _ { s } ( \pmb { y } , \pmb { x } , t ) - \lambda _ { i } S _ { i } ( \pmb { y } , \pmb { x } , t ) , } \end{array}
115
+ $$
116
+
117
+ which does not require to take the expectation w.r.t. $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ . We found that it did not perform well because it is not reasonable to measure the similarity between the noise-free source image and the transferred sample in a gradual denoising process. See Appendix C.2 for empirical results.
118
+
119
+ # 3.2 Solving the Energy-guided Reverse-time SDE
120
+
121
+ Based on the pretrained score-based model $s ( \boldsymbol { y } , t )$ and energy function $\boldsymbol { \mathcal { E } } ( \boldsymbol { y } , \boldsymbol { x } , t )$ , we can solve the proposed energy-guided SDE to generate samples from conditional distribution $p ( \pmb { y } _ { 0 } | \pmb { x } _ { 0 } )$ . There are numerical solvers to approximate trajectories from SDEs. In this paper, we take the Euler-Maruyama solver following [32] for a fair comparison. Given the EGSDE as in Eq. (6) and adopting a step size $h$ , the iteration rule from $s$ to $t = s - h$ is:
122
+
123
+ $$
124
+ y _ { t } = y _ { s } - [ f ( y , s ) - g ( s ) ^ { 2 } ( s ( y _ { s } , s ) - \nabla _ { y } \mathcal { E } ( y _ { s } , x _ { 0 } , s ) ) ] h + g ( s ) \sqrt { h } z , \quad z \sim \mathcal { N } ( \mathbf { 0 } , I ) .
125
+ $$
126
+
127
+ The expectation in $\mathcal { E } ( \pmb { y } _ { s } , \pmb { x } _ { 0 } , s )$ is estimated by the Monte Carlo method of a single sample for efficiency. For brevity, we present the general sampling procedure of our method in Algorithm 1. In experiments, we use the variance preserve energy-guided SDE (VP-EGSDE) [49, 16] and the details are explained in Appendix A.3, where we can modify the noise prediction network to $\tilde { \epsilon } ( \pmb { y } , \pmb { x } _ { 0 } , t ) = \epsilon ( \pmb { y } , t ) + \sqrt { \bar { \beta } _ { t } } \nabla _ { \pmb { y } } \mathcal { E } ( \pmb { y } , \pmb { x } _ { 0 } , t )$ and take it into the sampling procedure in DDPM [16]. Following SDEdit [32], we further extend this by repeating the Algorithm 1 $K$ times (see details in Appendix A.2). Further, we explain the connection with classifier guidance[9] in Appendix A.5.
128
+
129
+ # 3.3 EGSDE as Product of Experts
130
+
131
+ Inspired by the posterior inference process in diffusion models [46], we present a product of experts [15] explanation for the discretized sampling process of EGSDE, which formalizes our motivation in an alternative perspective and provides insights on the role of each component in EGSDE.
132
+
133
+ We first define a conditional distribution $\tilde { p } ( \boldsymbol y _ { t } | \boldsymbol x _ { 0 } )$ at time $t$ as a product of experts:
134
+
135
+ $$
136
+ \tilde { p } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) = \frac { p _ { r 1 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) p _ { e } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) } { Z _ { t } } ,
137
+ $$
138
+
139
+ <table><tr><td>Require: the source image xo, the initial time M,denoising steps N, weighting hyper-parameters Xs,入i, the similarity function Ss(·,:,·),Si(·,:,·), the score function s(·,·) y~qm|o(y|xo) # the start point h= N fori=Nto1do</td></tr><tr><td></td></tr><tr><td>s←ih</td></tr><tr><td>x ~ qs|o(x|xo) # sample perturbed source image from the perturbation kernel</td></tr><tr><td>£(y,x,s) ← λsSs(y,x,s) - XiSi(y,x,s) # compute energy with one Monte Carlo</td></tr><tr><td>y ← y-[f(y,s) - g(s)²(s(y,s) - Vyε(y,x,s))]h# the update rule in Eq. (12) z~N(0,I)ifi&gt;1,else z=0</td></tr><tr><td>y←y+g(s)√hz</td></tr><tr><td>end for yo←y</td></tr></table>
140
+
141
+ where $Z _ { t }$ is the partition function, $p _ { e } ( { \pmb y } _ { t } | { \pmb x } _ { 0 } ) \propto \exp ( - \mathcal { E } ( { \pmb y } _ { t } , { \pmb x } _ { 0 } , t ) )$ and $p _ { r 1 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } )$ is the marginal distribution at time $t$ defined by SDEdit based on a pretrained SDE on the target domain.
142
+
143
+ To sample from $\tilde { p } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } )$ , we need to construct a transition kernel $\tilde { p } ( \boldsymbol { y } _ { t } | \boldsymbol { y } _ { s } )$ , where $t = s - h$ and $h$ is small. Following [46], using the desirable equilibrium $\begin{array} { r } { \tilde { p } ( { \pmb y } _ { t } | { \pmb x } _ { 0 } ) = \int \tilde { p } ( { \pmb y } _ { t } | { \pmb y } _ { s } ) \tilde { p } ( { \pmb y } _ { s } | { \pmb x } _ { 0 } ) d { \pmb y } _ { s } } \end{array}$ , we construct the $\tilde { p } ( y _ { t } | y _ { s } )$ as follows:
144
+
145
+ $$
146
+ \tilde { p } ( { \pmb y } _ { t } | { \pmb y } _ { s } ) = \frac { p ( { \pmb y } _ { t } | { \pmb y } _ { s } ) p _ { e } ( { \pmb y } _ { t } | { \pmb x } _ { 0 } ) } { \tilde { Z } _ { t } ( { \pmb y } _ { s } ) } ,
147
+ $$
148
+
149
+ where $\tilde { Z } _ { t } ( y _ { s } )$ is the partition function and $p ( \pmb { y } _ { t } | \pmb { y } _ { s } ) = \mathcal { N } ( \pmb { \mu } ( \pmb { y } _ { s } , h ) , \Sigma ( s , h ) \pmb { I } )$ is the transition kernel of the pretrained SDE in Eq. (4), i.e., $\pmb { \mu } ( \pmb { y } _ { s } , h ) = \pmb { y } _ { s } - [ \pmb { f } ( \pmb { y } _ { s } , s ) - g ( s ) ^ { 2 } \pmb { s } ( \pmb { y } _ { s } , s ) ] h$ and $\Sigma ( s , h ) = g ( \dot { s } ) ^ { 2 } h$ . Assuming that $\mathcal { E } ( \boldsymbol { y } _ { t } , \boldsymbol { x } _ { 0 } , t )$ has low curvature relative to $\Sigma ( s , h ) ^ { - 1 }$ , it can be approximated using Taylor expansion around $\dot { \mu } ( y _ { s } , h )$ and further we can obtain
150
+
151
+ $$
152
+ \tilde { p } ( \boldsymbol { y } _ { t } | \boldsymbol { y } _ { s } ) \approx \mathcal { N } ( \mu ( \boldsymbol { y } _ { s } , h ) - \Sigma ( s , h ) \nabla _ { \boldsymbol { y } ^ { \prime } } \mathcal { E } ( \boldsymbol { y } ^ { \prime } , \boldsymbol { x } _ { 0 } , t ) | _ { \boldsymbol { y } ^ { \prime } = \mu ( \boldsymbol { y } _ { s } , h ) } , \Sigma ( s , h ) I ) .
153
+ $$
154
+
155
+ More details about derivation are available in Appendix A.4. We can observe the transition kernel $\tilde { p } ( y _ { t } | y _ { s } )$ in (15) is equal to the discretization of our EGSDE in Eq. (12). Therefore, solving the energy-guided SDE in a discretization manner is approximately equivalent to drawing samples from a product of experts in Eq. (13). Note that $\begin{array} { r } { \mathcal { E } ( { \bf y } _ { t } , { \bf x } _ { 0 } , t ) = \lambda _ { s } \mathcal { E } _ { s } ( { \bf y } _ { t } , { \bf x } _ { 0 } , t ) + \lambda _ { i } \mathcal { E } _ { i } ( { \bf y } _ { t } , { \bf x } _ { 0 } , t ) } \end{array}$ , the $\tilde { p } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } )$ can be rewritten as:
156
+
157
+ $$
158
+ \tilde { p } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) = \frac { p _ { r 1 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) p _ { r 2 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) p _ { f } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) } { Z _ { t } } ,
159
+ $$
160
+
161
+ $$
162
+ \begin{array} { r } { p _ { r 2 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) \propto \exp ( - \lambda _ { s } \pmb { \mathcal { E } } _ { s } ( \pmb { y } _ { t } , \pmb { x } _ { 0 } , t ) ) , p _ { f } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } ) \propto \exp ( - \lambda _ { i } \pmb { \mathcal { E } } _ { i } ( \pmb { y } _ { t } , \pmb { x } _ { 0 } , t ) ) . } \end{array}
163
+ $$
164
+
165
+ In Eq. (16), by setting $t = 0$ , we can explain that the transferred samples approximately follow the distribution defined by the product of three experts, where $p _ { r 1 } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } )$ and $p _ { r 2 } ( { \pmb y } _ { t } | { \pmb x } _ { 0 } )$ are the realism experts and $p _ { f } ( \pmb { y } _ { t } | \pmb { x } _ { 0 } )$ is the faithful expert, corresponding to the score function $s ( \pmb { y } , t )$ and the log potential functions $\mathcal { E } _ { s } ( \pmb { y } , \pmb { x } , t )$ and $\mathcal { E } _ { i } ( \pmb { y } , \pmb { x } , t )$ respectively. Such a formulation clearly explains the role of each expert in EGSDE and supports our empirical results.
166
+
167
+ # 4 Related work
168
+
169
+ Apart from the prior work mentioned before, we discuss other related work including GANs-based methods for unpaired I2I and SBDMs-based methods for image translation.
170
+
171
+ GANs-based methods for Unpaired I2I. Although previous paired image translation methods have also achieved remarkable performances [18, 51, 50, 37, 55, 59], we mainly focus on unpaired image translation in this work. The methods for two-domain unpaired I2I are mainly divided into two classes: two-side and one-side mapping [35, 57]. In the two-side framework [60, 54, 25, 29, 27, 24, 11, 1, 53, 56, 21], the cycle-consistency constraint is the most widely-used strategy such as in
172
+
173
+ ![](images/7e5f3d8c47fa9b4d68b3c9eb2833fd0a2841ad7f41bb5d2ed150deabeb7f64f1.jpg)
174
+ Figure 3: The qualitative comparison on $\mathrm { C a t } \to \mathrm { D o g }$ , Wild Dog and Male Female. Our method achieved better visual quality for both realism and faithfulness. For example, in the forth column, we successfully preserve the domain-independent features (i.e. green ground, pose and yellow color of body) and discard the domain-specific ones (i.e. leopard print).
175
+
176
+ CycleGAN [60], DualGAN [54] and DiscoGAN [25]. The key idea is that the translated image should be able to be reconstructed by an inverse mapping. More recently, there are numerical studies to improve this such as SCAN [27] and U-GAT-IT [24]. Specifically, U-GAT-IT [24] applies an attention module to let the generator and discriminator focus on more important regions instead of the whole regions through the auxiliary classifier. Since such bijective projection is too restrictive, several studies are devoted to one-side mapping [36, 3, 10, 60, 57, 38, 19]. One representative approach is to design some kind of geometry distance to preserve content [35]. For example, DistanceGAN [3] keeps the distances between images within domains. GCGAN [10] maintains geometry-consistency between input and output. CUT [36] maximizes the mutual information between the input and output using contrastive learning. LSeSim [57] learns spatially-correlative representation to preserve scene structure consistency via self-similarities.
177
+
178
+ SBDMs-based methods for Image Translation. Several studies leveraged SBDMs for image translation due to their powerful generative ability and achieved good results. For example, DiffusionCLIP [22] fine-tune the score network with CLIP [39] loss, which is applied on text-driven image manipulation, zero-shot image manipulation and multi-attribute transfer successfully. GLIDE [33] and SDG [30] has achieved great performance on text-to-image translation. As for I2I, SR3 [41] and Palette [40] learn a conditional SBDM and outperform state-of-art GANs-based methods on super-resolution, colorization and so on, which needs paired data. For unpaired I2I, UNIT-DDPM [43] learns two SBDMs and two domain translation models using cycle-consistency loss. Compared with it, our method only needs one SBDM on the target domain, which is a kind of one-side mapping. ILVR [7] and SDEdit [32] utilize a SBDM on the target domain and exploited the test source image to refine inference, which ignored the training data in the source domain. Compared with these methods, our method employs an energy function pretrained across both the source and target domains to improve the realism and faithfulness of translated images.
179
+
180
+ # 5 Experiment
181
+
182
+ Datasets. We validated the EGSDE on following datasets, where all images are resized to $2 5 6 \times 2 5 6$ : (1) CelebA-HQ [20] contains high quality face images and is separated into two domains: male and female. Each category has 1000 testing images. We perform Male Female on this dataset.
183
+
184
+ (2) AFHQ [8] consists of high-resolution animal face images including three domains: cat, dog and wild, which has relatively large variations. Each domain has 500 testing images. We perform Cat Dog and Wild Dog on this dataset. We also perform multi-domain translation on AFHQ dataset and the experimental results are reported in Appendix D.
185
+
186
+ Implementation. The time-dependent domain-specific extractor $E _ { s } ( { \boldsymbol { x } } , t )$ is trained based on the backbone in [9]. The resize function including downsampling and upsampling operation is used as low-pass filter and is implemented by [45]. For generation process, by default, the weight parameter $\lambda _ { s }$ , $\lambda _ { i }$ is set 500 and 2 respectively. The initial time $M$ and denoising steps $N$ is set $0 . 5 T$ and 500 by default. More details about implementation are available in Appendix B.
187
+
188
+ Evaluation Metrics. We evaluate translated images from two aspects: realism and faithfulness. For realism, we report the widely-used Frechet Inception Score (FID) [13] between translated images and the target dataset. To quantify faithfulness, we report the $L _ { 2 }$ distance, PSNR and SSIM [52] between each input-output pair. To quantify both faithfulness and realism, we leverage Amazon Mechanical Turk(AMT) human evaluation to perform pairwise comparisons between the baselines and EGSDE. More details is available in Appendix B.6.
189
+
190
+ # 5.1 Two-Domain Unpaired Image Translation
191
+
192
+ In this section, we compare EGSDE with the following state-of-the-art I2I methods in three tasks: SBDMs-based methods including ILVR [7] and SDEdit [32], and GANs-based methods including CUT [36], which are reproduced using public code. On the most popular benchmark $\mathbf { C a t } \to \mathbf { D o g }$ we also report the performance of other state-of-the-art GANs-methods , where StarGAN v2 [8] is evaluated by the provided public checkpoint and the others are public results from CUT[36] and ITTR [58]. We provide more details about reproductions in Appendix B.7.
193
+
194
+ The quantitative comparisons and qualitative results are shown in Table 1 and Figure 3. We can derive several observations. First, our method outperforms the SBDMs-based methods significantly in almost all realism and faithfulness metrics, suggesting the effectiveness of employing energy function pretrained on both domains to guide the generation process. Especially, compared with the most direct competitor, i.e., SDEdit, with a lower $L _ { 2 }$ distance at the same time, EGSDE improves the FID score by 8.35, 8.76 and 7.5 on $\mathrm { C a t } \to \mathrm { D o g }$ , W $\mathrm { \Delta / i l d } \to \mathrm { D o g }$ and Male Female respectively. Second, EGSDE† outperforms the current state-of-art GANs-based methods by a large margin on the challenging AFHQ dataset. For example, compared with CUT [36], we achieve an improvement of FID score with 25.17 and 42.51 on the $\mathrm { C a t } \to \mathrm { D o g }$ and Wi $\lvert \mathbf { d } \to \mathbf { D o g }$ tasks respectively. In addition, the human evaluation shows that EGSDE are preferred compared to all baselines $( > 5 0 \% )$ . The qualitative results in Figure 3 agree with quantitative comparisons in Table 1, where our method achieved the results with the best visual quality for both realism and faithfulness. We show more qualitative results and select some failure cases in Appendix C.6.
195
+
196
+ # 5.2 Ablation Studies
197
+
198
+ The function of each expert. We validate the function of realistic expert $\mathcal { E } _ { s } ( \pmb { y } , \pmb { x } , t )$ and faithful expert $\mathcal { E } _ { i } ( \pmb { y } , \pmb { x } , t )$ by changing the weighting hyper-parameter $\lambda _ { s }$ and $\lambda _ { i }$ . As shown in Table 3 and Figure 1, larger $\lambda _ { s }$ results in more realistic images and larger $\lambda _ { i }$ results in more faithful images. More results is available in Appendix C.5.
199
+
200
+ The choice of initial time $M$ . We explore the effect of the initial time $M$ of EGSDE. As shown in Figure 4, the larger $M$ results in more realistic and less faithful image. More results is available in Appendix C.3.
201
+
202
+ Repeating $K$ Times. Following SDEdit [32], we show the results of repeating the Algorithm 1 $K$ times. The quantitative and qualitative results are depicted in Table 2 and Figure 4. The experimental results show the EGSDE outperforms SDEdit in each $K$ step in all metrics. With the increase of $K$ , the SDEdit generates more realism images but the faithful metrics decrease sharply, because it only utilizes the source image at the initial time $M$ . As shown in Figure 4, when $K { = } 3$ , SDEdit discard the domain-independent information of the source image (i.e., color and background) while our method still preserves them without harming realism.
203
+
204
+ Table 1: Quantitative comparison. ILVR [7], SDEdit [32] and CUT [36] are reproduced using public code. StarGAN v2 [8] is evaluated by the provided public checkpoint and the other methods marked by \* are public results from CUT[36] and ITTR [58]. All SBDMs-based methods and StarGAN v2 are repeated 5 times to eliminate randomness. CUT is conducted once since it learns a deterministic mapping. AMT show the preference rate of EGSDE against baselines via human evaluation. The EGSDE use the default-parameters $( \lambda _ { s } = 5 0 0 , \lambda _ { i } = 2 , M = 0 . 5 T )$ and EGSDE† use the parameters with $\lambda _ { s } = 7 0 0 , \lambda _ { i } = 0 . 5 , M = 0 . 6 T$ .
205
+
206
+ <table><tr><td>Model</td><td>FID↓</td><td>L2↓</td><td>PSNR ↑</td><td>SSIM ↑</td><td>AMT个</td></tr><tr><td colspan="6">Cat → Dog</td></tr><tr><td>CycleGAN* [60] MUNIT*[17]</td><td>85.9 104.4</td><td>=</td><td></td><td></td><td></td></tr><tr><td>DRIT* [26]</td><td>123.4</td><td></td><td></td><td></td><td></td></tr><tr><td>Distance*[3]</td><td>155.3</td><td></td><td></td><td></td><td></td></tr><tr><td>SelfDistance* [3]</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>144.4</td><td>=</td><td></td><td></td><td></td></tr><tr><td>GCGAN*[10]</td><td>96.6</td><td></td><td></td><td></td><td></td></tr><tr><td>LSeSim* [57]</td><td>72.8</td><td></td><td></td><td></td><td></td></tr><tr><td>ITTR(CUT)*[58]</td><td>68.6</td><td>=</td><td></td><td></td><td>=</td></tr><tr><td>StarGAN v2 [8]</td><td>54.88 ± 1.01</td><td>133.65 ± 1.54</td><td>10.63 ± 0.10</td><td>0.27 ± 0.003</td><td></td></tr><tr><td>CUT* [36]</td><td>76.21</td><td>59.78</td><td>17.48</td><td>0.601</td><td>79.6%</td></tr><tr><td>ILVR [7]</td><td>74.37 ± 1.55</td><td>56.95 ± 0.14</td><td>17.77 ± 0.02</td><td>0.363 ± 0.001</td><td>75.4%</td></tr><tr><td>SDEdit [32]</td><td>74.17 ± 1.01</td><td>47.88 ± 0.06</td><td>19.19 ± 0.01</td><td>0.423 ± 0.001</td><td>65.2%</td></tr><tr><td>EGSDE</td><td>65.82 ± 0.77</td><td>47.22 ± 0.08</td><td>19.31 ± 0.02</td><td>0.415 ± 0.001</td><td>=</td></tr><tr><td>EGSDEt</td><td>51.04 ± 0.37</td><td>62.06 ± 0.10</td><td>17.17 ± 0.02</td><td>0.361 ± 0.001</td><td>=</td></tr><tr><td colspan="6">Wild →Dog</td></tr><tr><td>CUT [36]</td><td>92.94</td><td>62.21</td><td>17.2</td><td>0.592</td><td>82.4%</td></tr><tr><td>ILVR [7]</td><td>75.33 ± 1.22</td><td>63.40 ± 0.15</td><td>16.85 ± 0.02</td><td>0.287 ± 0.001</td><td>73.4%</td></tr><tr><td>SDEdit [32]</td><td>68.51 ± 0.65</td><td>55.36 ± 0.05</td><td>17.98 ± 0.01</td><td>0.343 ± 0.001</td><td>57.2%</td></tr><tr><td>EGSDE</td><td>59.75 ± 0.62</td><td>54.34 ± 0.08</td><td>18.14 ± 0.01</td><td>0.343 ± 0.001</td><td>=</td></tr><tr><td>EGSDE†</td><td>50.43± 0.52</td><td>66.52± 0.09</td><td>16.40± 0.01</td><td>0.300± 0.001</td><td>=</td></tr><tr><td colspan="6">Male→Female</td></tr><tr><td>CUT [36]</td><td>31.94</td><td>46.61</td><td>19.87</td><td>0.74</td><td>58.6%</td></tr><tr><td>ILVR [7]</td><td>46.12 ± 0.33</td><td>52.17 ± 0.10</td><td>18.59 ± 0.02</td><td>0.510 ± 0.001</td><td>88.2%</td></tr><tr><td>SDEdit [32]</td><td>49.43 ± 0.47</td><td>43.70 ± 0.03</td><td>20.03 ± 0.01</td><td>0.572 ± 0.000</td><td>74.4%</td></tr><tr><td>EGSDE</td><td>41.93 ± 0.11</td><td>42.04 ± 0.03</td><td>20.35 ± 0.01</td><td>0.574 ± 0.000</td><td>=</td></tr><tr><td>EGSDE†</td><td>30.61 ± 0.19</td><td>53.44 ± 0.09</td><td>18.32 ± 0.02</td><td>0.510 ± 0.001</td><td>1</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
207
+
208
+ # 6 Conclusions and Discussions
209
+
210
+ In this paper, we propose energy-guided stochastic differential equations (EGSDE) for realistic and faithful unpaired I2I, which employs an energy function pretrained on both domains to guide the generation process of a pretrained SDE. Building upon two feature extractors, we carefully design the energy function to preserve the domain-independent features and discard domain-specific ones of the source image. We demonstrate the EGSDE by outperforming state-of-art I2I methods on three widely-adopted unpaired I2I tasks.
211
+
212
+ One limitation of this paper is we employ a low-pass filter as the domain-independent feature extractor for its simpleness and effectiveness while we can train more sophisticated extractor, e.g. based on disentangled representation learning methods [42, 6, 14, 23, 28], on the data in the two domains. We leave this issue in future work. In addition, we must take care to exploit the method to avoid the potential negative social impact (i.e., generating fake images to mislead people).
213
+
214
+ ![](images/a5d855901863fe17e8ecff09a3307e6d0e6a80e0b650ae5b8fe40e5d231c2649.jpg)
215
+ Figure 4: (a) The results of different initial time $M$ . The larger $M$ results in more realistic and less faithful images. (b) The results of repeating the Algorithm 1 $K$ times. With the increase of K, SDEdit [32] tend to discard the domain-independent information of the source image (e.g., color and background) while our method still preserve them without harming realism.
216
+
217
+ Table 2: Comparison with SDEdit [32] under different $K$ times on Male Female. The results on other tasks are reported in Appendix C.4.
218
+
219
+ <table><tr><td>Methods</td><td>K</td><td>FID↓</td><td>L2↓</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>SDEdit [32]</td><td></td><td>49.95</td><td>43.71</td><td>20.03</td><td>0.572</td></tr><tr><td>EGSDE</td><td>1</td><td>42.17</td><td>42.07</td><td>20.35</td><td>0.573</td></tr><tr><td>SDEdit [32]</td><td>2</td><td>46.26</td><td>50.70</td><td>18.77</td><td>0.542</td></tr><tr><td>EGSDE</td><td></td><td>38.68</td><td>47.10</td><td>19.40</td><td>0.548</td></tr><tr><td>SDEdit [32]</td><td>3</td><td>45.19</td><td>55.03</td><td>18.08</td><td>0.527</td></tr><tr><td>EGSDE</td><td></td><td>37.55</td><td>49.63</td><td>18.96</td><td>0.536</td></tr></table>
220
+
221
+ Table 3: The results of different $\lambda _ { s }$ and $\lambda _ { i }$ on Wild $ \mathrm { D o g }$ . $\lambda _ { s } = \lambda _ { i } = 0$ corresponds to SDEdit [32].
222
+
223
+ <table><tr><td>入s,入</td><td>FID↓</td><td>L2↓</td><td>PSNR ↑</td><td>SSIM↑</td></tr><tr><td>λs=0,λ=0</td><td>67.87</td><td>55.39</td><td>17.97</td><td>0.344</td></tr><tr><td>x=100,x=0</td><td>60.80</td><td>56.19</td><td>17.85</td><td>0.341</td></tr><tr><td>入s= 500,入i=0</td><td>53.72</td><td>58.65</td><td>17.47</td><td>0.335</td></tr><tr><td>=800,入=0</td><td>53.01</td><td>60.02</td><td>17.27</td><td>0.331</td></tr><tr><td>X=0,x7=0.5</td><td>68.31</td><td>53.23</td><td>18.32</td><td>0.347</td></tr><tr><td>入s=0,入=2</td><td>71.10</td><td>51.99</td><td>18.52</td><td>0.349</td></tr><tr><td>入s=0,=5</td><td>72.70</td><td>51.44</td><td>18.61</td><td>0.351</td></tr></table>
224
+
225
+ # Acknowledgement
226
+
227
+ We thank Cheng Lu, Yuhao Zhou, Haoyu Liang and Shuyu Cheng for helpful discussions about the method and its limitations. This work was supported by the National Key Research and Development Program of China (2020AAA0106302); NSF of China Projects (Nos. 62061136001, 61620106010, 62076145, U19B2034, U1811461, U19A2081, 6197222); Beijing NSF Project (No. JQ19016); Beijing Outstanding Young Scientist Program NO. BJJWZYJH012019100020098; a grant from Tsinghua Institute for Guo Qiang; the High Performance Computing Center, Tsinghua University; the Fundamental Research Funds for the Central Universities, and the Research Funds of Renmin University of China (22XNKJ13). Part of the computing resources supporting this work, totaled 500 A100 GPU hours, were provided by High-Flyer AI. (Hangzhou High-Flyer AI Fundamental Research Co., Ltd.). J.Z was also supported by the XPlorer Prize.
228
+
229
+ References
230
+ [1] Matthew Amodio and Smita Krishnaswamy. Travelgan: Image-to-image translation by transformation vector learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8975–8984, 2019.
231
+ [2] Fan Bao, Chongxuan Li, Jun Zhu, and Bo Zhang. Analytic-dpm: an analytic estimate of the optimal reverse variance in diffusion probabilistic models. In International Conference on Learning Representations, 2021.
232
+ [3] Sagie Benaim and Lior Wolf. One-sided unsupervised domain mapping. Advances in Neural Information Processing Systems, 30, 2017.
233
+ [4] Mikołaj Binkowski, Danica J Sutherland, Michael Arbel, and Arthur Gretton. Demystifying ´ mmd gans. In International Conference on Learning Representations, 2018.
234
+ [5] Christopher M. Bishop. Pattern Recognition and Machine Learning. 2006.
235
+ [6] Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. Infogan: Interpretable representation learning by information maximizing generative adversarial nets. Advances in Neural Information Processing Systems, 29, 2016.
236
+ [7] Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. Ilvr: Conditioning method for denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 14367–14376, 2021.
237
+ [8] Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. Stargan v2: Diverse image synthesis for multiple domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8188–8197, 2020.
238
+ [9] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34, 2021.
239
+ [10] Huan Fu, Mingming Gong, Chaohui Wang, Kayhan Batmanghelich, Kun Zhang, and Dacheng Tao. Geometry-consistent generative adversarial networks for one-sided unsupervised domain mapping. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2427–2436, 2019.
240
+ [11] Aaron Gokaslan, Vivek Ramanujan, Daniel Ritchie, Kwang In Kim, and James Tompkin. Improving shape deformation in unsupervised image-to-image translation. In Proceedings of the European Conference on Computer Vision, pages 649–665, 2018.
241
+ [12] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in Neural Information Processing Systems, 27, 2014.
242
+ [13] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in Neural Information Processing Systems, 30, 2017.
243
+ [14] Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. 2016.
244
+ [15] Geoffrey E Hinton. Training products of experts by minimizing contrastive divergence. Neural computation, 14(8):1771–1800, 2002.
245
+ [16] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
246
+ [17] Xun Huang, Ming-Yu Liu, Serge Belongie, and Jan Kautz. Multimodal unsupervised imageto-image translation. In Proceedings of the European Conference on Computer Vision, pages 172–189, 2018.
247
+ [18] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1125–1134, 2017.
248
+ [19] Liming Jiang, Changxu Zhang, Mingyang Huang, Chunxiao Liu, Jianping Shi, and Chen Change Loy. Tsit: A simple and versatile framework for image-to-image translation. In Proceedings of the European Conference on Computer Vision, pages 206–222, 2020.
249
+ [20] Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. In International Conference on Learning Representations, 2018.
250
+ [21] Oren Katzir, Dani Lischinski, and Daniel Cohen-Or. Cross-domain cascaded deep translation. In Proceedings of the European Conference on Computer Vision, pages 673–689, 2020.
251
+ [22] Gwanghyun Kim, Taesung Kwon, and Jong Chul Ye. Diffusionclip: Text-guided diffusion models for robust image manipulation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2426–2435, 2022.
252
+ [23] Hyunjik Kim and Andriy Mnih. Disentangling by factorising. In International Conference on Machine Learning, pages 2649–2658, 2018.
253
+ [24] Junho Kim, Minjae Kim, Hyeonwoo Kang, and Kwang Hee Lee. U-gat-it: Unsupervised generative attentional networks with adaptive layer-instance normalization for image-to-image translation. In International Conference on Learning Representations, 2019.
254
+ [25] Taeksoo Kim, Moonsu Cha, Hyunsoo Kim, Jung Kwon Lee, and Jiwon Kim. Learning to discover cross-domain relations with generative adversarial networks. In International Conference on Machine Learning, pages 1857–1865, 2017.
255
+ [26] Hsin-Ying Lee, Hung-Yu Tseng, Jia-Bin Huang, Maneesh Singh, and Ming-Hsuan Yang. Diverse image-to-image translation via disentangled representations. In Proceedings of the European Conference on Computer Vision, pages 35–51, 2018.
256
+ [27] Minjun Li, Haozhi Huang, Lin Ma, Wei Liu, Tong Zhang, and Yugang Jiang. Unsupervised image-to-image translation with stacked cycle-consistent adversarial networks. In Proceedings of the European Conference on Computer Vision, pages 184–199, 2018.
257
+ [28] Alexander H Liu, Yen-Cheng Liu, Yu-Ying Yeh, and Yu-Chiang Frank Wang. A unified feature disentangler for multi-domain image translation and manipulation. Advances in Neural Information Processing Systems, 31, 2018.
258
+ [29] Ming-Yu Liu, Thomas Breuel, and Jan Kautz. Unsupervised image-to-image translation networks. Advances in Neural Information Processing Systems, 30, 2017.
259
+ [30] Xihui Liu, Dong Huk Park, Samaneh Azadi, Gong Zhang, Arman Chopikyan, Yuxiao Hu, Humphrey Shi, Anna Rohrbach, and Trevor Darrell. More control for free! image synthesis with semantic diffusion guidance. arXiv preprint arXiv:2112.05744, 2021.
260
+ [31] Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. arXiv preprint arXiv:2206.00927, 2022.
261
+ [32] Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. Sdedit: Guided image synthesis and editing with stochastic differential equations. In International Conference on Learning Representations, 2021.
262
+ [33] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
263
+ [34] Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pages 8162–8171, 2021.
264
+
265
+ [35] Yingxue Pang, Jianxin Lin, Tao Qin, and Zhibo Chen. Image-to-image translation: Methods and applications. IEEE Transactions on Multimedia, 2021.
266
+
267
+ [36] Taesung Park, Alexei A Efros, Richard Zhang, and Jun-Yan Zhu. Contrastive learning for unpaired image-to-image translation. In Proceedings of the European Conference on Computer Vision, pages 319–345, 2020.
268
+
269
+ [37] Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2337–2346, 2019.
270
+
271
+ [38] Taesung Park, Jun-Yan Zhu, Oliver Wang, Jingwan Lu, Eli Shechtman, Alexei Efros, and Richard Zhang. Swapping autoencoder for deep image manipulation. Advances in Neural Information Processing Systems, 33:7198–7211, 2020.
272
+
273
+ [40] Chitwan Saharia, William Chan, Huiwen Chang, Chris Lee, Jonathan Ho, Tim Salimans, David Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. In ACM SIGGRAPH, pages 1–10, 2022.
274
+
275
+ [41] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
276
+
277
+ [42] Eduardo Hugo Sanchez, Mathieu Serrurier, and Mathias Ortner. Learning disentangled representations via mutual information estimation. In Proceedings of the European Conference on Computer Vision, pages 205–221, 2020.
278
+
279
+ [43] Hiroshi Sasaki, Chris G Willcocks, and Toby P Breckon. Unit-ddpm: Unpaired image translation with denoising diffusion probabilistic models. arXiv preprint arXiv:2104.05358, 2021.
280
+
281
+ [44] Zhiqiang Shen, Mingyang Huang, Jianping Shi, Xiangyang Xue, and Thomas S Huang. Towards instance-level image-to-image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3683–3692, 2019.
282
+
283
+ [45] Assaf Shocher. Resizeright. https://github.com/assafshocher/ResizeRight, 2018.
284
+
285
+ [46] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265, 2015.
286
+
287
+ [47] Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum likelihood training of score-based diffusion models. Advances in Neural Information Processing Systems, 34, 2021.
288
+
289
+ [48] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
290
+
291
+ [49] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2020.
292
+
293
+ [51] Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. High-resolution image synthesis and semantic manipulation with conditional gans. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 8798–8807, 2018.
294
+
295
+ [52] Zhou Wang, Alan C Bovik, Hamid R Sheikh, and Eero P Simoncelli. Image quality assessment: from error visibility to structural similarity. IEEE Transactions on Image Processing, 13(4):600– 612, 2004.
296
+
297
+ [53] Wayne Wu, Kaidi Cao, Cheng Li, Chen Qian, and Chen Change Loy. Transgaga: Geometryaware unsupervised image-to-image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8012–8021, 2019.
298
+
299
+ [54] Zili Yi, Hao Zhang, Ping Tan, and Minglun Gong. Dualgan: Unsupervised dual learning for image-to-image translation. In Proceedings of the IEEE International Conference on Computer Vision, pages 2849–2857, 2017.
300
+
301
+ [55] Pan Zhang, Bo Zhang, Dong Chen, Lu Yuan, and Fang Wen. Cross-domain correspondence learning for exemplar-based image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5143–5153, 2020.
302
+
303
+ [56] Yihao Zhao, Ruihai Wu, and Hao Dong. Unpaired image-to-image translation using adversarial consistency loss. In Proceedings of the European Conference on Computer Vision, pages 800–815, 2020.
304
+
305
+ [57] Chuanxia Zheng, Tat-Jen Cham, and Jianfei Cai. The spatially-correlative loss for various image translation tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16407–16417, 2021.
306
+
307
+ [58] Wanfeng Zheng, Qiang Li, Guoxin Zhang, Pengfei Wan, and Zhongyuan Wang. Ittr: Unpaired image-to-image translation with transformers. arXiv preprint arXiv:2203.16015, 2022.
308
+
309
+ [59] Xingran Zhou, Bo Zhang, Ting Zhang, Pan Zhang, Jianmin Bao, Dong Chen, Zhongfei Zhang, and Fang Wen. Cocosnet v2: Full-resolution correspondence learning for image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11465–11475, 2021.
310
+
311
+ [60] Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE International Conference on Computer Vision, pages 2223–2232, 2017.
312
+
313
+ # Checklist
314
+
315
+ 1. For all authors...
316
+
317
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
318
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
319
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
320
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
321
+
322
+ 2. If you are including theoretical results...
323
+
324
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Appendix A.1 (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix A.4
325
+
326
+ 3. If you ran experiments...
327
+
328
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section 5 and Appendix B
329
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix B and Appendix C
330
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Table 1
331
+
332
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix B
333
+
334
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
335
+
336
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 5 and Appendix B
337
+ (b) Did you mention the license of the assets? [Yes] See Appendix B
338
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] See Appendix B
339
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] We use the public datasets.
340
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] We use the public datasets.
341
+
342
+ 5. If you used crowdsourcing or conducted research with human subjects...
343
+
344
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
345
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
346
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/ySQH0oDyp7/ySQH0oDyp7.md ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # QDROP: RANDOMLY DROPPING QUANTIZATION FOR EXTREMELY LOW-BIT POST-TRAINING QUANTIZATION
2
+
3
+ Xiuying Wei1, 2∗, Ruihao Gong1, 2∗, Yuhang $\mathbf { L i } ^ { 2 }$ , Xianglong $\mathbf { L i u ^ { 1 \boxtimes } }$ , Fengwei $\mathbf { Y } \mathbf { u } ^ { 2 }$ 1State Key Lab of Software Development Environment, Beihang University, 2SenseTime Research {weixiuying,gongruihao,liyuhang1}@sensetime.com,xlliu@buaa.edu.cn
4
+
5
+ # ABSTRACT
6
+
7
+ Recently, post-training quantization (PTQ) has driven much attention to produce efficient neural networks without long-time retraining. Despite its low cost, current PTQ works tend to fail under the extremely low-bit setting. In this study, we pioneeringly confirm that properly incorporating activation quantization into the PTQ reconstruction benefits the final accuracy. To deeply understand the inherent reason, a theoretical framework is established, indicating that the flatness of the optimized low-bit model on calibration and test data is crucial. Based on the conclusion, a simple yet effective approach dubbed as QDROP is proposed, which randomly drops the quantization of activations during PTQ. Extensive experiments on various tasks including computer vision (image classification, object detection) and natural language processing (text classification and question answering) prove its superiority. With QDROP, the limit of PTQ is pushed to the 2-bit activation for the first time and the accuracy boost can be up to $5 1 . 4 9 \%$ . Without bells and whistles, QDROP establishes a new state of the art for PTQ. Our code is available at https://github.com/wimh966/QDrop and has been integrated into MQBench (https://github.com/ModelTC/MQBench).
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ In recent years, deep learning has been applied to all walks of life and offered substantial convenience for people’s production and activities. While the performance of deep neural networks continues to increase, the memory and computation cost also scale up fastly and bring new challenges for edge devices. Model compression techniques such as network pruning (Han et al., 2015), distillation (Hinton et al., 2015), network quantization (Jacob et al., 2018) and neural architecture search (Zoph & Le, 2016) etc., are dedicated to reduce calculation and storage overhead. In this paper, we study quantization which adopts low-bit representation for weights and activations to enable fixed-point computation and less memory space.
12
+
13
+ Based on the cost of a quantization algorithm, researchers usually divide the quantization work into two categories: (1) Quantization-Aware Training (QAT) and (2) Post-Training Quantization (PTQ). QAT finetunes a pre-trained model by leveraging the whole dataset and GPU effort. On the contrary, PTQ demands much less computation to obtain a quantized model since it does not require end-toend training. Therefore, much attention has recently been paid to PTQ (Cai et al., 2020; Wang et al., 2020; Hubara et al., 2021; Banner et al., 2019; Nahshan et al., 2019; Zhang et al., 2021a; Li et al., 2021c) due to its low cost and easy-to-use characteristics in practice.
14
+
15
+ Traditionally, PTQ pursues accuracy by performing the rounding-to-nearest operation, which focuses on minimizing the distance from the full-precision (FP) model in parameter space. In recent progress, Nagel et al. (2020); Li et al. (2021a) considered minimizing the distance in model space, i.e. the final loss objective. They use Taylor Expansion to analyze the change of loss value and derive a method to reconstruct the pre-trained model’s feature by learning the rounding scheme. Such methods are efficient and effective in 4-bit quantization and can even push the limit of weight quantization to 2-bit. However, the extremely low-bit activation quantization, which faces more challenges, still fails to achieve satisfactory accuracy. We argue that one key reason is that existing theoretical analyses only model the weight quantization as perturbation while ignoring activation’s. This will lead to the same optimized model no matter which bit the activations use, which is obviously counter-intuitive and thus causes a sub-optimal solution.
16
+
17
+ In this work, the effect of activation quantization in PTQ is deeply investigated for the first time. We empirically observe that perceiving the activation quantization benefits the extremely low-bit PTQ reconstruction and surprisingly find that only partial activation quantization is more preferable. An intuitive understanding is that incorporating activation will lead to a different optimized weight. Inspired by this, we conduct theoretical studies on how activation quantization affects the weight tuning, and the conclusion is that involving activation quantization into the reconstruction helps the flatness of model on calibration data and dropping partial quantization contributes to the flatness on test data. Motivated by both empirical and theoretical findings, we propose QDROP that randomly drops quantization during the PTQ reconstruction to pursue the flatness from a general perspective. With this simple and effective approach, we set up a new state of the art for PTQ on various tasks including image classification, object detection for computer vision, and text classification and question answering for natural language processing.
18
+
19
+ To this end, this paper makes the following contributions:
20
+
21
+ 1. We confirm the benefits unprecedentedly from involving activation quantization in the PTQ reconstruction and surprisingly observe that partial involvement of activation quantization performs better than the whole.
22
+ 2. A theoretical framework is established to deeply analyze the influence of incorporating activation quantization into weight tuning. Using this framework, we conclude that the flatness of the optimized low-bit model on calibration data and test data is crucial for the final accuracy.
23
+ 3. Based on the empirical and theoretical analyses, we propose a simple yet effective method QDROP that achieves the flatness from a general perspective. QDROP is easy to implement and can consistently boost existing methods as a plug-and-play module for various neural networks including CNNs like ResNets and Transformers like BERT.
24
+ 4. Extensive experiments on a large variety of tasks and models prove that our method set up a new state of the art for PTQ. With QDROP, the 2-bit post-training quantization becomes possible for the first time.
25
+
26
+ # 2 PRELIMINARIES
27
+
28
+ Basic Notations. Throughout this paper, matrices (or tensors) are marked as $\boldsymbol { X }$ , whereas the vectors are denoted by $_ { \textbf { \em x } }$ . Sometimes we use $\textbf { \em w }$ to represent the flattened version of the weight matrix $W$ . Operator $\ast$ is marked as scalar multiplication, $\odot$ is marked as element-wise multiplication for matrices or vectors. For matrix multiplication, we denote $W x$ as matrix-vector multiplication or $W X$ as matrix-matrix multiplication.
29
+
30
+ For a feedforward neural network with activation function, we denote it as $\mathcal { G } ( \pmb { w } , \pmb { x } )$ and the loss function as $L ( { \pmb w } , { \pmb x } )$ , where $_ { \textbf { \em x } }$ and $\pmb { w }$ are the network inputs and weights, respectively. Note that we assume $_ { \textbf { \em x } }$ is sampled from training dataset $\mathcal { D } _ { t }$ , thus the final loss is denoted by $\mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { t } } [ L ( \pmb { w } , \pmb { x } ) ]$ . For the network forward function, we can write it as:
31
+
32
+ $$
33
+ z _ { i } ^ { ( \ell + 1 ) } = \sum _ { j } W _ { i , j } ^ { ( \ell ) } \cdot a _ { j } ^ { ( \ell ) } , ~ f ( z _ { i } ^ { ( \ell + 1 ) } ) = a _ { i } ^ { ( \ell + 1 ) } ,
34
+ $$
35
+
36
+ where $W _ { i , j }$ denotes weight connecting the $j ^ { t h }$ activation neuron and the $i ^ { t h }$ output. The bracket superscript $( \ell )$ is the layer index. $f ( \cdot )$ indicates the activation function.
37
+
38
+ Post-training Quantization. Uniform quantizer maps continuous values $x \in \mathbb { R }$ into fixed-point integers. For instance, the activation quantization function can be written as ${ \hat { x } } = \left\lfloor { \frac { x } { s } } \right\rceil \cdot s$ , where $\lfloor \cdot \rceil$ denotes the rounding-to-nearest operator, $s$ is the step size between two subsequent quantization levels. While rounding-to-nearest operation minimizes the mean squared error between $\hat { x }$ and $x$ , the minimization of parameter space certainly cannot equal to the minimization in final task loss (Li et al., 2021a), i.e., $\mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { t } } [ L ( \hat { \pmb { w } } , \pmb { x } ) ]$ . However, in the post-training setting, we only have a tiny subset $\mathcal { D } _ { c } \in \mathcal { D } _ { t }$ that only contains 1k images. Thus, it is hard to minimize the final loss objective with limited data.
39
+
40
+ Recently, a series of works (Nagel et al., 2020; Li et al., 2021a) learn to either round up or down and view the new rounding mechanism as weight perturbation, i.e., $\begin{array} { r } { \hat { \pmb { w } } = \pmb { w } + \Delta \pmb { w } } \end{array}$ . Take a pre-trained network $\mathcal { G }$ as an example, they leverage Taylor Expansion to analyze the target, which reveals the quantization interactions among weights:
41
+
42
+ $$
43
+ \operatorname* { m i n } _ { \hat { \boldsymbol { w } } } \mathbb { E } \left[ \boldsymbol { L } ( \hat { \boldsymbol { w } } , \boldsymbol { x } ) - \boldsymbol { L } ( \boldsymbol { w } , \boldsymbol { x } ) \right] \approx \operatorname* { m i n } _ { \hat { \boldsymbol { w } } } \mathbb { E } \left[ \frac { 1 } { 2 } \Delta \boldsymbol { w } ^ { \top } \mathbf { H } ^ { \boldsymbol { w } } \Delta \boldsymbol { w } \right] ,
44
+ $$
45
+
46
+ where $\mathbf { H } ^ { w } \ = \ \mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { t } } \nabla _ { \pmb { w } } ^ { 2 } L ( \pmb { w } , \pmb { x } )$ is the expected second-order derivative. The above objective could be transformed into the change of output weighted by the output Hessian.
47
+
48
+ $$
49
+ \operatorname* { m i n } _ { \hat { w } } \mathbb { E } \left[ { \Delta { w } ^ { \top } } { \mathbf H } ^ { w } { \Delta w } \right] \approx \operatorname* { m i n } _ { \hat { w } } \mathbb { E } \left[ { \Delta { { a } ^ { \top } } { \mathbf H } ^ { { a } } } { \Delta { { a } } } \right]
50
+ $$
51
+
52
+ About the above minimization, they finetune only the weight by reconstructing each block/layer output (See Fig. 1). But they did not explore the activation quantization during output reconstruction with only modeling weight quantization as noise. The step size for activation quantization is determined after the reconstruction stage.
53
+
54
+ Intuitively, when quantizing the activations of a full-precision model to 2-bit or 3-bit, there should be different suitable weights. However, the existing works result in the same optimized weight due to the neglect of activation quantization. Therefore, we argue that when quantizing the neural network, the noise caused by activation quantization should be considered coherently with weights.
55
+
56
+ # 3 METHODOLOGY
57
+
58
+ In this section, to reveal the influence of introducing activation quantization before output reconstruction, we first conduct empirical experiments and present two observations. Then a theoretical framework is built to investigate how the activation quantization affects the optimized weights. Last, equipped with the analysis conclusions, a simple yet effective method dubbed QDROP is proposed.
59
+
60
+ ![](images/1562cf588de55b5220fb4a3a952e4dd6a884d7b4c4ed988ec4386059f70d6e82.jpg)
61
+ Figure 1: 3 cases to involve activation quantization when optimizing the $k _ { t h }$ block’s weight rounding. Activations are quantized inside the blue block and not quantized inside the orange block.
62
+
63
+ <table><tr><td>Case</td><td>1</td><td>2</td><td>3</td></tr><tr><td>ResNet-18</td><td>18.88</td><td>45.74</td><td>48.07</td></tr><tr><td>ResNet-50</td><td>4.34</td><td>46.98</td><td>49.07</td></tr><tr><td>MobileNetV2</td><td>5.83</td><td>50.71</td><td>51.20</td></tr><tr><td>RegNet-600MF</td><td>42.77</td><td>60.94</td><td>62.07</td></tr><tr><td>MnasNet</td><td>26.62</td><td>58.79</td><td>60.19</td></tr></table>
64
+
65
+ Table 1: 2-bit or 3-bit post-training quantization accuracy on ImageNet dataset across different cases and different models.
66
+
67
+ # 3.1 EMPIRICAL OBSERVATIONS
68
+
69
+ To investigate the influence of activation quantization when reconstructing the layer/block output, we conduct preliminary experiments on the ImageNet (Russakovsky et al., 2015) dataset. Our experiments are based on the open-sourced code Li et al. (2021a) except that we will introduce activation quantization from 1 to $k - 1$ blocks before the $k _ { t h }$ block’s reconstruction. We give a simple visualization in Fig. 1 to show 3 cases for putting activation quantization in different stages. Case 1 means that all activations are kept in 32-bit full-precision during the reconstruction of block output, which is also adopted in existing work Nagel et al. (2020); Li et al. (2021a). Case 2 and Case 3 are used for incorporating activation quantization into the reconstruction stage. However, Case 3 will omit the current block’s quantization while Case 2 will not. The detailed results of these three cases are listed in Table 1 (Comparisons on 2-bit (W2A2) quantization for ResNet-18, ResNet-50 and W3A3 for others for the sake of the crashed results on 2-bit.) and the algorithm is put in algorithm 2. According to the comparison, we can obtain two observations:
70
+
71
+ 1. For extremely low-bit quantization (e.g., W2A2), there will be huge accuracy improvement when considering activation quantization during weight tuning. This is confirmed by comparing with Case 1 and Case 2. We find Case 1 barely converges while Case 2 achieves good accuracy. It reveals that a separate optimization of weights and activations cannot find an optimal solution. After introducing the activation quantization, the weights will learn to diminish the influence of activation quantization.
72
+
73
+ 2. Partially introducing block-wise activation quantization surpasses introducing the whole activation quantization. Case 3 does not quantize the activations inside the current tuning block but achieves better results than Case 2. This inspires us that how much activation quantization we introduce for weight tuning will affect the final accuracy.
74
+
75
+ # 3.2 HOW DOES ACTIVATION QUANTIZATION AFFECT WEIGHT TUNING
76
+
77
+ The empirical observations have highlighted the importance of activation quantization during the PTQ pipeline. To further explore how activation quantization will affect the weight tuning, we build a theoretical framework that analyzes the final loss objective with both weights and activations being quantized, which presents clues of high accuracy for extremely low-bit post-training quantization.
78
+
79
+ Conventionally, the activation quantization could be modeled as injecting some form of noise imposed on the full-precision counterpart, defined as $e = ( { \hat { a } } - a )$ . To remove the influence of activation range on $e$ , we translate the noise into a multiplicative form, i.e., $\hat { a } = a \cdot ( 1 + u )$ , where the range of $u$ is affected by bit-width and rounding error. Detailed illustration of the new form noise can be found in Appendix A.
80
+
81
+ Here, $\mathbf { 1 } + \pmb { u } ( \pmb { x } )$ is adopted to present the activation noise since it is related to specific input data point $_ { \textbf { \em x } }$ . Equipped with the noise, we add another argument in calculating the loss function and define our optimization objective in PTQ as:
82
+
83
+ $$
84
+ \operatorname* { m i n } _ { \hat { w } } \mathbb { E } _ { { \pmb x } \sim \mathcal { D } _ { c } } [ L ( { \pmb w } + \Delta { \pmb w } , { \pmb x } , { \bf 1 } + { \pmb u } ( { \pmb x } ) ) - L ( { \pmb w } , { \pmb x } , { \bf 1 } ) ] .
85
+ $$
86
+
87
+ We hereby use a transformation that can absorb the noise on activation and transfer to weight, where the perturbation on weight is denoted as ${ \bf 1 } + { \pmb v } ( { \pmb x } )$ ( $\mathbf { \nabla } V ( { \boldsymbol { \mathbf { x } } } )$ is used in matrix multiplication format). Consider a simple matrix-vector multiplication ${ \cal W } a$ in forward pass, we have $W ( \bar { \bf { a } } \odot ( { \bf { 1 } } + { \bf { u } } ( { \bf { x } } ) ) ) =$ $( W \odot ( \mathbf { 1 } + V ( \mathbf { x } ) ) ) \mathbf { ) } a$ , given by
88
+
89
+ $$
90
+ W ( \pmb { a } \odot \left[ \begin{array} { r } { 1 + u _ { 1 } ( \pmb { x } ) } \\ { 1 + u _ { 2 } ( \pmb { x } ) } \\ { \dots } \\ { 1 + u _ { n } ( \pmb { x } ) } \end{array} \right] ) = \left( W \odot \left[ \begin{array} { r r r r } { 1 + u _ { 1 } ( \pmb { x } ) } & { 1 + u _ { 2 } ( \pmb { x } ) } & { \dots } & { 1 + u _ { n } ( \pmb { x } ) } \\ { 1 + u _ { 1 } ( \pmb { x } ) } & { 1 + u _ { 2 } ( \pmb { x } ) } & { \dots } & { 1 + u _ { n } ( \pmb { x } ) } \\ { \dots } & { 1 } & { \dots } & { 1 + u _ { n } ( \pmb { x } ) } \end{array} \right] \right) \pmb { a } .
91
+ $$
92
+
93
+ By taking $V _ { i , j } ( { \pmb x } ) = { \pmb u } _ { j } ( { \pmb x } )$ , quantization noise on the activation vector $( { \bf 1 } + { \pmb u } ( { \pmb x } ) )$ can be transplanted into perturbation on weight $( { \bf 1 } + { \pmb v } ( { \pmb x } ) )$ . Note that for a specific input data point $_ { \textbf { \em x } }$ , there are two distinct ${ \pmb u } ( { \pmb x } )$ and ${ \pmb v } ( { \pmb x } )$ . Proof is available at Sec. B.1.
94
+
95
+ Also note that for a convolutional layer, we cannot apply such transformation since the input to convolution is a matrix and will cause different $V$ . Nonetheless, we can give a formal lemma that absorbs ${ \pmb u } ( { \pmb x } )$ and holds corresponding ${ \pmb v } ( { \pmb x } )$ (See the Appendix Sec. B.2 for rigorous proof):
96
+
97
+ Lemma 1. For a quantized (convolutional) neural network, the influence of activation quantization on the final loss objective in post-training quantization can be transformed into weight perturbation.
98
+
99
+ $$
100
+ \mathbb { E } _ { \alpha \sim \mathcal { D } _ { c } } [ L ( \hat { w } , x , \mathbf { 1 } + u ( x ) ) - L ( w , x , \mathbf { 1 } ) ] \approx \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , x , \mathbf { 1 } ) - L ( w , x , \mathbf { 1 } ) ]
101
+ $$
102
+
103
+ By interpolating $L ( \hat { \mathbf { \psi } } _ { } \hat { \mathbf { \psi } } _ { } , \mathbf { r } , \mathbf { 1 } )$ into Lemma 1, we can obtain the final theorem:
104
+
105
+ Theorem 1. For a neural network $\mathcal { G }$ with quantized weight wˆ and activation perturbation $\mathbf { 1 } + \pmb { u } ( \pmb { x } )$ , we have:
106
+
107
+ $$
108
+ \begin{array} { r l } & { \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } , \mathbf { x } , \mathbf { 1 } + u ( x ) ) - L ( w , \mathbf { x } , \mathbf { 1 } ) ] \approx } \\ & { \qquad \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ \underbrace { \big ( L ( \hat { w } , \mathbf { x } , \mathbf { 1 } ) - L ( w , \mathbf { x } , \mathbf { 1 } ) \big ) } _ { ( 7 - 1 ) } + \underbrace { \big ( L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , \mathbf { x } , \mathbf { 1 } ) - L ( \hat { w } , \mathbf { x } , \mathbf { 1 } ) \big ) } _ { ( 7 - 2 ) } ] . } \end{array}
109
+ $$
110
+
111
+ Here, Theorem 1 divides optimization objective into two terms. Term (7-1) is the same as Eq. (2) explored in (Nagel et al., 2020; Li et al., 2021a), which reveals how weight quantization interacts with loss function. Term (7-2) is the additional loss change by introducing activation quantization. In another way to interpret Eq. (7), the term (7-2) stands for the loss change with jitters on the weight quantized network $\mathcal { G } ( \bar { \pmb w } , { \pmb x } )$ . This type of noise correlates with certain kinds of robustness.
112
+
113
+ ![](images/fa6d1f7af0df5e5df312b6fcafd5d2d814c4c636bfcee8ff04fdb808b7175dee.jpg)
114
+ Figure 2: Measure sharpness on different data distributions among three cases. We adopt the measurement defined in (Keskar et al., 2016). With the same degree of loss change ratio, those who can tolerate a larger perturbation magnitude enjoy a flatter loss landscape.
115
+
116
+ As stated in some works about generalization and flatness (Dinh et al., 2017; Hochreiter & Schmidhuber, 1997), intuitively, flat minimum means relatively small loss change under perturbation in the parameters, otherwise, the minimum is sharp. In this paper, we follow the notion of flatness defined in (Neyshabur et al., 2017), which considers loss change from the perspective of statistical expectation. And as (Neyshabur et al., 2017) and (Jiang et al., 2019) refer to, we consider the magnitude of the perturbation with respect to the magnitude of parameters and take the formulation as $\mathbb { E } _ { v \sim \mathcal { D } } [ L ( f _ { w \odot ( \mathbf { 1 } + v ) } ) - L ( f _ { w } ) ]$ , where each element of $\textbf { { v } }$ is a random variable sampled from a noise distribution $\mathcal { D }$ and $L$ represents for optimization objective on the training set. From this perspective, the term (7-2) can be interpreted as the flatness with perturbation related to input data, and thereby we could achieve the following corollary.
117
+
118
+ Corollary 1. On calibration data $_ { \textbf { \em x } }$ , with activation quantization noise ${ \pmb u } ( { \pmb x } )$ , there exists the corresponding weight perturbation ${ \pmb v } ( { \pmb x } )$ which satisfies that the trained quantized model is flatter under the perturbation ${ \pmb v } ( { \pmb x } )$ .
119
+
120
+ With Corollary 1, Case 2 and 3 discussed in Sec. 3.1 enjoy a flatter loss landscape benefited from perceiving the activation quantization. This explains their superiority compared with Case 1. The measurement of sharpness on calibration data (left part) in Fig. 2 further validates this point. With similar perturbation magnitude, Case 2 and 3 suffer less loss degradation than Case 1.
121
+
122
+ # 3.3 QDROP
123
+
124
+ As aforementioned, introducing activation quantization is theoretically proved to produce a flatter model than existing works and the directions of flatness depend on the data distribution. Since the PTQ is especially sensitive to calibration data (Yu et al., 2021), we need to transfer the investigations in Sec. 3.2 on calibration data into the test setting for a thorough understanding. In specific, we consider Eq. (7) on test set and inspect two terms separately in the following. Based on the analyses, our method QDROP will be derived to pursue an excellent performance on test data.
125
+
126
+ Term (7-1) on test set. As suggested in Sec. 3.2, with both quantized activations and weights, we additionally optimize the term (7-2) representing the flatness on calibration data. This term will encourage the quantized model to learn a flat minimum. As a result, the traditional objective of AdaRound (term (7-1)) can naturally generalize better for test data (i.e., $\pmb { x } { \sim } \mathcal { D } _ { t } \left( \hat { L } ( \hat { w } , \pmb { x } , \mathbf { 1 } ) - \hat { L } ( \pmb { w } , \pmb { x } , \mathbf { 1 } ) \right) ,$ ).
127
+
128
+ Term (7-2) on test set. Furthermore, we should also concern about the term (7-2) on test data, i.e. $\begin{array} { r } { \mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { t } } \big [ L ( \pmb { \hat { w } } \odot ( \pmb { 1 } + \pmb { v } ( \pmb { x } ) ) , \pmb { x } , \pmb { 1 } ) - L ( \pmb { \hat { w } } , \pmb { x } , \pmb { 1 } ) \big ] } \end{array}$ . As revealed in Sec. 3.2, the term (7-2) implies the flatness where its situation on calibration data has been exploited. Here, we further investigate the flatness on test samples. Note that ${ \pmb v } ( { \pmb x } )$ is converted from ${ \pmb u } ( { \pmb x } )$ and this activation quantization noise varies with input data. Fig. 2 shows that there is a gap between the test data and calibration data for the flatness of the 3 cases. According to Corollary 1, these 3 cases actually introduce different $\textbf { \em u }$ mathematically and thus will result in different flatness directions, given by
129
+
130
+ $$
131
+ \mathrm { ~ s e ~ } 1 \colon u = \mathbf { 0 } ; \mathrm { ~ C a s e 2 } \colon u = \frac { \hat { a } } { a } - 1 ; \mathrm { ~ C a s e ~ } 3 \colon u = \left\{ \begin{array} { l l } { \frac { \hat { a } } { a } - 1 , } & { \mathrm { b l o c k } _ { 1 } \sim \mathrm { b l o c k } _ { k - 1 } } \\ { \mathbf { 0 } , } & { \mathrm { b l o c k } _ { k } } \end{array} \right. .
132
+ $$
133
+
134
+ Input: the $k _ { t h }$ block from layer $i$ to layer $j$ , a minibatch of quantized block input $\hat { \mathbf { a } } ^ { i - 1 }$ , FP32 block input $\mathbf { \delta } _ { a ^ { i - 1 } }$ , FP32 block output $\mathbf { \Delta } \mathbf { a } ^ { j }$ , quantization dropping probability $p$ .
135
+ $\{ 1$ . Forward propagation: $\}$
136
+ During training phase, substitute $\hat { \mathbf { a } } ^ { i - 1 }$ with corresponding $\mathbf { \delta } _ { a ^ { i - 1 } }$ at neuron-level with
137
+ probability $p$ and mark the replaced input as $\tilde { \mathbf { a } } ^ { i - \mathrm { 1 } }$ ;
138
+ for $l = i$ to $j$ do $\pmb { a } ^ { l } \gets \pmb { W } ^ { l } \tilde { \pmb { a } } ^ { l - 1 }$ ; aˆl ← Quantize(al); During training phase, randomly drop some $\hat { \mathbf { } a } ^ { l }$ with $\mathbf { \delta } _ { \mathbf { { a } } } l$ as defined in Eq. (9) and get $\tilde { \mathbf { \ b { a } } } ^ { l }$ ;
139
+ {2. Backward propagation:}
140
+ Compute $\Delta \pmb { a } ^ { j } = \bar { \tilde { \pmb { a } } } ^ { j } - \pmb { a } ^ { j }$ ;
141
+ Tune the weight by gradient descent ;
142
+ return Quantized block ;
143
+
144
+ For Case 1, there is no activation quantization during calibration without taking flatness into account. Case 2 suggests the activation perturbation totally and therefore enjoys a good flatness on calibration data. However, due to the mismatch on calibration data and test one, it is highly possible that Case 2 causes overfitting (See Table 8 for more details). Case 3, in fact achieves the best performance by dropping some activation quantization along with a little different weight perturbation and might not be restricted to flatness on calibration data (More evidence can be found in Table 9). This inspires us to pursue a flat minimum from a general perspective, that only optimizing the target on calibration set is suboptimal to test set.
145
+
146
+ QDROP. Inspired by this, we propose QDROP to further increase the flatness on as many directions as possible. In particular, we randomly disable and enable the quantization of the activation each forward pass:
147
+
148
+ $$
149
+ \mathrm { Q D R O P : ~ } u = \left\{ \begin{array} { l l } { { 0 } } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } p } } \\ { { \frac { \hat { a } } { a } - 1 } } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } 1 - p } } \end{array} \right. .
150
+ $$
151
+
152
+ We name it QDROP because it randomly drops the quantization of activation. Theoretically, by masking some ${ \pmb u } ( { \pmb x } )$ randomly, QDROP can have more diverse ${ \pmb v } ( { \pmb x } )$ and cover more directions of flatness thus flatter on test samples, which contributes to the final high accuracy. Fig. 3 support our analysis where QDROP has smoother loss landscape than Case 3, the winner among 3 cases on test data. Meanwhile, it is indeed a fine-grained version of Case 3 since Case 3 drops the quantization in a block-wise manner, whereas our QDROP operates in an element-wise way.
153
+
154
+ Discussions. QDROP can be viewed as a generalized form of the existing schemes. Case 1 and 2 respectively corresponds to the dropping probability of $p = 1$ and $p = 0$ . Case 3 is equivalent to setting the block being optimized with dropping probability $p = 1$ and remains the quantization of other parts. Note that the $p$ obeys Bernoulli distribution and thus can be set as 0.5 for the maximal entropy (Qin et al., 2020), which is helpful for flatness across various directions.
155
+
156
+ ![](images/b38a77f1f96da2499d5906243de31425280f74fe0e6b7b85b7a0773f9a910867.jpg)
157
+ Figure 3: Loss surface of the quantized weight for QDROP, Case 1 and 3 on test data and ResNet-18 W3A3. To better distinguish Case 1 and 3, we zoom into the local loss surface with perturbation ${ \pmb v } _ { 1 }$ and $\mathbf { \boldsymbol { v } } _ { 2 }$ magnitude in [-0.025,0.025].
158
+
159
+ Table 2: Effect of QDROP.
160
+
161
+ <table><tr><td>Method</td><td>Bits (W/A)</td><td>ResNet-18</td><td>ResNet-50</td><td>MobileNetV2</td><td>RegNet-600MF</td><td>RegNet-3.2GF</td><td>MNasNet-2.0</td></tr><tr><td>No Drop</td><td>2/2</td><td>46.64</td><td>47.90</td><td>4.55</td><td>25.52</td><td>39.76</td><td>9.51</td></tr><tr><td>QDROP</td><td>2/2</td><td>51.14</td><td>54.74</td><td>8.46</td><td>38.90</td><td>52.36</td><td>22.70</td></tr><tr><td>No Drop</td><td>2/4</td><td>64.16</td><td>69.60</td><td>51.61</td><td>61.52</td><td>70.29</td><td>60.00</td></tr><tr><td>QDROP</td><td>2/4</td><td>64.66</td><td>70.08</td><td>52.92</td><td>63.10</td><td>70.95</td><td>62.36</td></tr></table>
162
+
163
+ QDROP is easy to implement for various neural networks including CNNs and Transformers, and plug-and-play with little additional computational complexity. With QDROP, the complicated problem of choosing optimization order, i.e. different cases in Sec. 3.1, can be avoided.
164
+
165
+ # 4 EXPERIMENTS
166
+
167
+ In this section, we conduct two sets of experiments to verify the effectiveness of QDROP. In Sec. 4.1, we first conduct an ablation study for the impact with and without dropping quantization and analyze the option of distinct dropping rates. In Sec. 4.2, we compare our method with other existing approaches across vision and language tasks including image classification on ImageNet, object detection on MS COCO, and natural language processing on GLUE benchmark and SQuAD.
168
+
169
+ Implementation Details. Our code is based on PyTorch Paszke et al. (2019). We set the default dropping probability $p$ as 0.5, except we explicitly mention it. The weight tuning method is the same with Nagel et al. (2020); Li et al. (2021a). Each block or layer output is reconstructed for 20k iterations. For ImageNet dataset, we sample 1024 images as calibration set, while COCO we use 256 images. In NLP, we sample 1024 examples. We also keep the first and the last layer in 8-bit except NLP tasks and adopt per-channel weight quantization. We use W4A4 to represent 4-bit weight and activation quantization. More model choices and other setting is described in Appendix E.
170
+
171
+ But to be noted, regular first and last layer 8-bit means 8-bit weight and input in first and last layer while BRECQ uses another setting which not only keeps the first layer’s input 8-bit but also the first layer’s output (second layer’s input). This would indeed perform better than the regular one with leaving one more layer’s input 8-bit but may not be practical on the hardware. Therefore, we both compare with BRECQ’s setting to show the superiority of our approach and experiment on the usual one to provide a practical baseline. Symbol $\dagger$ is used to mark BRECQ’s setting.
172
+
173
+ # 4.1 ABLATION STUDY
174
+
175
+ Effect of QDROP. We propose QDROP and here we would like to test the effect of PTQ with or without QDROP. We use ImageNet classification benchmark and quantize the weight parameters to 2-bit and quantize activation to $2 / 4$ -bit. As shown in Table 2, QDROP improves the accuracy across all bit settings evaluated for 6 models on ImageNet. Furthermore, the gains are more obvious when applying QDROP to lightweight network architecture: $2 . 3 6 \%$ increment for MNasNet under W2A4 and $12 . 6 \%$ for RegNet-3.2GF with W2A2.
176
+
177
+ Effect of Dropping Probability. We also explore the dropping probability in PTQ. We choose $p$ in [0,0.25,0.5,0.75,1] and test on MobileNetV2 and RegNet-600MF. The results are summarized in Fig. 5. We find 0.5 generally performs best among 5 candidates. Although there could be a fine-grained best solution for each architecture, we shall avoid cumbersome hyperparameter search and continue using 0.5.
178
+
179
+ ![](images/dbcf1838da873cfd654c8bdaa0b2b2fc2c5fbf7e1368c5c75730f21ba59c3976.jpg)
180
+ Figure 5: Impact of dropping probability on ImageNet.
181
+
182
+ # 4.2 LITERATURE COMPARISON
183
+
184
+ ImageNet. We choose ResNet-18 and -50 (He et al., 2016), MobileNetV2 (Sandler et al., 2018), searched MNasNet (Tan et al., 2019) and RegNet (Radosavovic et al., 2020). We summarize the results in Table 3. First, the W4A4 quantization is investigated. It can be observed that QDROP provides $0 \sim 3 \%$ accuracy uplift when compared to strong baselines including AdaRound, BRECQ. As for the gap between our method and AdaQuant on W4A4, we argue that there are some discrepancies on settings such as positions of quantization nodes and put this explaination in Sec. C.3. With W2A4 quantization, QDROP can improve the accuracy of ResNet-50 by $0 . 5 \%$ , and RegNet-3.2GF by $4 . 6 \%$ . In addition, to fully exploit the limit of QDROP, we conduct more challenging cases with 2/3-bit weights and activations. According to the last two rows of Table 3, our proposed QDROP consistently achieves good results while existing methods suffer from non-negligible accuracy drop. For W3A3, the difference is even larger on MobileNetV2, where our method reaches $58 \%$ accuracy and BRECQ only gets $23 \%$ . In the W2A2 setting, the PTQ becomes much harder. QDROP outperforms the competing method by a large margin: $1 2 . 1 8 \%$ upswings for ResNet-18, $2 9 . 6 6 \%$ for ResNet-50 and $5 1 . 4 9 \%$ for RegNet-3.2GF.
185
+
186
+ Table 3: Comparison among different post-training quantization strategies with low-bit activation in terms of accuracy on ImageNet. \* represents for our implementation according to open-source codes and $^ \dagger$ means using BRECQ’s first and last layer 8-bit setting, which also keeps first layer’s output 8-bit besides input and weight in the first and last layer.
187
+
188
+ <table><tr><td>Methods</td><td>Bits (W/A)</td><td>Res18</td><td>Res50</td><td>MNV2</td><td>Reg600M</td><td>Reg3.2G</td><td>MNasx2</td></tr><tr><td>Full Prec.</td><td>32/32</td><td>71.06</td><td>77.00</td><td>72.49</td><td>73.71</td><td>78.36</td><td>76.68</td></tr><tr><td>ACIQ-Mix (Banner et al., 2019)</td><td>4/4</td><td>67.00</td><td>73.80</td><td>1</td><td>1</td><td>1</td><td>-</td></tr><tr><td>ZeroQ (Cai et al., 2020)*</td><td>4/4</td><td>21.71</td><td>2.94</td><td>26.24</td><td>28.54</td><td>12.24</td><td>3.89</td></tr><tr><td>LAPQ (Nahshan et al., 2019)</td><td>4/4</td><td>60.30</td><td>70.00</td><td>49.70</td><td>57.71*</td><td>55.89*</td><td>65.32*</td></tr><tr><td>AdaQuant (Hubara et al., 2021)</td><td>4/4</td><td>69.60</td><td>75.90</td><td>47.16*</td><td>-</td><td>=</td><td>-</td></tr><tr><td>Bit-Split (Wang et al., 2020)</td><td>4/4</td><td>67.56</td><td>73.71</td><td>=</td><td>-</td><td>-</td><td>=</td></tr><tr><td>AdaRound (Nagel et al.,2020)*</td><td>4/4</td><td>67.96</td><td>73.88</td><td>61.52</td><td>68.20</td><td>73.85</td><td>68.86</td></tr><tr><td>QDROP (Ours)</td><td>4/4</td><td>69.10</td><td>75.03</td><td>67.89</td><td>70.62</td><td>76.33</td><td>72.39</td></tr><tr><td>AdaRound† (Nagel et al., 2020)*</td><td>4/4</td><td>69.36</td><td>74.76</td><td>64.33</td><td>-</td><td>=</td><td>-</td></tr><tr><td>BRECQt (Li et al., 2021a)</td><td>4/4</td><td>69.60</td><td>75.05</td><td>66.57</td><td>68.33</td><td>74.21</td><td>73.56</td></tr><tr><td>QDROPt (Ours)</td><td>4/4</td><td>69.62</td><td>75.45</td><td>68.84</td><td>71.18</td><td>76.66</td><td>73.71</td></tr><tr><td>LAPQ (Nahshan et al., 2019)*</td><td>2/4</td><td>0.18</td><td>0.14</td><td>0.13</td><td>0.17</td><td>0.12</td><td>0.18</td></tr><tr><td>AdaQuant (Hubara et al., 2021)*</td><td>2/4</td><td>0.11</td><td>0.12</td><td>0.15</td><td>-</td><td>-</td><td>-</td></tr><tr><td>AdaRound (Nagel et al., 2020)*</td><td>2/4</td><td>62.12</td><td>66.11</td><td>36.31</td><td>57.00</td><td>63.89</td><td>46.73</td></tr><tr><td>QDROP (Ours)</td><td>2/4</td><td>64.66</td><td>70.08</td><td>52.92</td><td>63.10</td><td>70.95</td><td>62.36</td></tr><tr><td>AdaRoundt (Nagel et al., 2020)*</td><td>2/4</td><td>64.14</td><td>68.40</td><td>41.52</td><td>59.27</td><td>65.33</td><td>53.77</td></tr><tr><td>BRECQt (Li et al., 2021a)</td><td>2/4</td><td>64.80</td><td>70.29</td><td>53.34</td><td>59.31</td><td>67.15</td><td>63.01</td></tr><tr><td>QDROPt (Ours)</td><td>2/4</td><td>65.25</td><td>70.65</td><td>54.22</td><td>63.80</td><td>71.70</td><td>64.24</td></tr><tr><td>AdaQuant (Hubara et al., 2021)*</td><td>3/3</td><td>60.09</td><td>67.46</td><td>2.23</td><td>1</td><td>-</td><td>-</td></tr><tr><td>QDROP (Ours)</td><td>3/3</td><td>65.56</td><td>71.07</td><td>54.27</td><td>64.53</td><td>71.43</td><td>63.47</td></tr><tr><td>AdaRoundt (Nagel et al.,2020)*</td><td>3/3</td><td>64.66</td><td>66.66</td><td>15.20</td><td>51.01</td><td>56.79</td><td>47.89</td></tr><tr><td>BRECQt (Li et al., 2021a)*</td><td>3/3</td><td>65.87</td><td>68.96</td><td>23.41</td><td>55.16</td><td>57.12</td><td>49.78</td></tr><tr><td>QDROPt (Ours)</td><td>3/3</td><td>66.75</td><td>72.38</td><td>57.98</td><td>65.54</td><td>72.51</td><td>66.81</td></tr><tr><td>QDROP (Ours)</td><td>2/2</td><td>51.14</td><td>54.74</td><td>8.46</td><td>38.90</td><td>52.36</td><td>22.70</td></tr><tr><td>BRECQt (Li et al., 2021a)*</td><td>2/2</td><td>42.54</td><td>29.01</td><td>0.24</td><td>3.58</td><td>3.62</td><td>0.61</td></tr><tr><td>QDROPt (Ours)</td><td>2/2</td><td>54.72</td><td>58.67</td><td>13.05</td><td>41.47</td><td>55.11</td><td>28.77</td></tr></table>
189
+
190
+ MS COCO. In this part, we validate the performance of QDROP on object detection task using MS COCO dataset. We use both two-stage Faster RCNN (Ren et al., 2015) and one-stage RetinaNet (Lin et al., 2017) models. Backbone are selected from ResNet-18, ResNet-50, and MobileNetV2. Note that we set the first layer and the last layer to 8-bit and do not quantize the head of the model, however, the neck (FPN) is quantized. Experiments show that W4A4 quantization using QDROP nearly do not affect Faster RCNN’s mAP. For RethinaNet, our method has 5 mAP improvement on MobileNetV2 backbone. In low bit setting W2A4, our method shows great improvement both on Faster-RCNN and RetinaNet, up to $6 . 5 \mathrm { \ m A P } .$ .
191
+
192
+ GLUE benchmark and SQuAD. We test QDROP in NLP tasks including the GLUE benchmark and SQuAD1.1. They are all conducted on the typical NLP model, i.e, BERT (Devlin et al., 2018). Compared with those QAT methods (Bai et al., 2020), which usually adopt data augmentation trick to achieve dozens of times the original data, we only randomly extract 1024 examples without any extra data processing. Besides AdaQuant and BRECQ, which suffer a huge accuracy degradation, our QDROP surpasses No Drop all the tasks, specifically on QNLI $( 8 . 7 \% )$ , $\mathrm { Q Q P } ( 4 . 6 \% )$ and $\mathrm { R T E } ( 7 . 2 \% )$ .
193
+
194
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Bits (W/A)</td><td colspan="3">Faster RCNN</td><td colspan="3">RetinaNet</td></tr><tr><td>ResNet-18</td><td>ResNet-50</td><td>MobileNetV2</td><td>ResNet-18</td><td>ResNet-50</td><td>MobileNetV2</td></tr><tr><td>Full Prec.</td><td>32/32</td><td>34.60</td><td>38.56</td><td>33.47</td><td>33.22</td><td>36.80</td><td>32.63</td></tr><tr><td>AdaRound*</td><td>4/4</td><td>32.57</td><td>34.47</td><td>26.11</td><td>31.04</td><td>33.51</td><td>24.99</td></tr><tr><td>BRECQ+*</td><td>4/4</td><td>32.58</td><td>34.59</td><td>26.58</td><td>31.21</td><td>33.47</td><td>24.84</td></tr><tr><td>QDROP</td><td>4/4</td><td>33.37</td><td>36.96</td><td>30.88</td><td>31.99</td><td>35.67</td><td>29.75</td></tr><tr><td>AdaRound*</td><td>2/8</td><td>30.54</td><td>33.15</td><td>25.35</td><td>29.30</td><td>32.22</td><td>24.22</td></tr><tr><td>BRECQ†</td><td>2/8</td><td>31.82</td><td>34.23</td><td>27.54</td><td>31.42</td><td>34.75</td><td>27.59</td></tr><tr><td>QDROP</td><td>2/8</td><td>32.20</td><td>36.14</td><td>28.48</td><td>31.03</td><td>34.84</td><td>27.42</td></tr><tr><td>BRECQ+*</td><td>2/4</td><td>29.92</td><td>30.23</td><td>19.35</td><td>28.73</td><td>29.47</td><td>18.46</td></tr><tr><td>QDROP</td><td>2/4</td><td>31.01</td><td>34.23</td><td>25.04</td><td>29.69</td><td>33.01</td><td>24.89</td></tr></table>
195
+
196
+ Table 4: Comparison among typical post-training quantization strategies in terms of mAP on MS COCO. Note that refer to BRECQ, we didn’t quantize head and keep the first and last layer in backbone to 8-bit. Other notations align with Table 3.
197
+
198
+ <table><tr><td>Method</td><td>SST-2 (acc)</td><td>QNLI (acc)</td><td>QQP (fl/acc)</td><td>STS-B (Pearson/Spearman corr)</td><td>MNLI (acc m/mm)</td><td>MRPC (acc)</td><td>RTE (acc)</td><td>CoLA (Matthews corr)</td><td>SQuAD1.1 (f1)</td></tr><tr><td>Full Prec.</td><td>92.43</td><td>91.54</td><td>87.81/90.91</td><td>88.04/ 87.63</td><td>84.57/84.46</td><td>87.71</td><td>72.56</td><td>53.39</td><td>88.42</td></tr><tr><td>AdaQuant*</td><td></td><td>-</td><td></td><td></td><td></td><td>=</td><td>■</td><td>-</td><td>5.17</td></tr><tr><td>BRECQ*</td><td>50.86</td><td>50.72</td><td>4.47/62.28</td><td>5.94/ 6.39</td><td>31.91/31.81</td><td>31.69</td><td>52.34</td><td>0.946</td><td>68.58</td></tr><tr><td>No DROP</td><td>87.94</td><td>68.05</td><td>68.09/76.69</td><td>82.24/81.68</td><td>69.19/71.28</td><td>77.39</td><td>53.43</td><td>40.17</td><td>75.97</td></tr><tr><td>QDROP</td><td>88.06</td><td>76.75</td><td>72.66/79.04</td><td>82.39/81.88</td><td>71.43/73.70</td><td>79.15</td><td>60.65</td><td>40.85</td><td>77.26</td></tr></table>
199
+
200
+ Table 5: Performance on NLP tasks compared to other methods on E8W4A4. Here, we use symbol EeWwAa to additionally express the embedding bit and conduct experiments on GLUE and SQuAD1.1.
201
+
202
+ As for SST-2, despite little enhancement by dropping quantization, it is indeed close to the FP32 value within $4 . 4 \%$ . And for STS-B, we argue that the original fine-tuned model is trained with limited data, which might not be very representative.
203
+
204
+ # 4.3 ROBUSTNESS OF QDROP
205
+
206
+ In this part, we discuss the effectiveness of QDROP under more challenging situations including even less data and cross-domain ones. Concerning about size of calibration data, we consider another 4 options. It can be observed that dropping some quantization behaves better under each setting and is even comparable with No Drop with half of the original calibration data. Motivated by Yu et al. (2021), we also reconstruct block output by 1024 examples from out-of-domain data, i.e, CIFAR100 (Krizhevsky et al., 2009), MS COCO, and test on ImageNet. Results are available in Table 6, where our QDROP still works steadily.
207
+
208
+ ![](images/c051bb5803e1d6cdedb4399b1ed146ef8a8dccaa04293da31abe5b24292ae943.jpg)
209
+ Figure 6: Impact of calibration data size on ImageNet.
210
+
211
+ Table 6: Cross domain data.
212
+
213
+ <table><tr><td>Calibration</td><td>Bits (W/A)</td><td>No Drop</td><td>QDROP</td></tr><tr><td>MS COCO</td><td>4/4</td><td>68.64</td><td>68.94</td></tr><tr><td>MS COCO</td><td>3/3</td><td>64.12</td><td>65.15</td></tr><tr><td>CIFAR100</td><td>4/4</td><td>46.83</td><td>52.88</td></tr><tr><td>CIFAR100</td><td>3/3</td><td>21.74</td><td>28.58</td></tr></table>
214
+
215
+ # 5 CONCLUSION
216
+
217
+ In this paper, we have introduced QDROP, a novel mechanism for post-training quantization. QDrop aims to achieve good test accuracy given a tiny calibration set. This is done by optimization towards a flat minima. We dissect the PTQ objective theoretically into a flatness problem and improve the flatness from a general perspective. We comprehensively verify the effectiveness of QDROP on a large variety of tasks. It can achieve a nearly lossless 4-bit quantized network and can significantly improve the 2-bit quantization results.
218
+
219
+ # ACKNOWLEDGMENT
220
+
221
+ We sincerely thank the anonymous reviewers for their serious reviews and valuable suggestions to make this better. And we thank Xiangguo Zhang and Sheng Chen for their kind of help of this work. This work was supported in part by the National Natural Science Foundation of China under Grant 62022009 and Grant 61872021, the SenseTime Research Fund for Young Scholars, and the Beijing Nova Program of Science and Technology under Grant Z191100001119050.
222
+
223
+ # REFERENCES
224
+
225
+ Haoli Bai, Wei Zhang, Lu Hou, Lifeng Shang, Jing Jin, Xin Jiang, Qun Liu, Michael Lyu, and Irwin King. Binarybert: Pushing the limit of bert quantization. arXiv preprint arXiv:2012.15701, 2020.
226
+
227
+ Ron Banner, Yury Nahshan, and Daniel Soudry. Post training 4-bit quantization of convolutional networks for rapid-deployment. In Advances in Neural Information Processing Systems, 2019.
228
+
229
+ Yaohui Cai, Zhewei Yao, Zhen Dong, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Zeroq: A novel zero shot quantization framework. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13169–13178, 2020.
230
+
231
+ Yoni Choukroun, Eli Kravchik, Fan Yang, and Pavel Kisilev. Low-bit quantization of neural networks for efficient inference. In ICCV Workshops, pp. 3009–3018, 2019.
232
+
233
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
234
+
235
+ Laurent Dinh, Razvan Pascanu, Samy Bengio, and Yoshua Bengio. Sharp minima can generalize for deep nets, 2017.
236
+
237
+ Zhen Dong, Zhewei Yao, Yaohui Cai, Daiyaan Arfeen, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Hawq-v2: Hessian aware trace-weighted quantization of neural networks. arXiv preprint arXiv:1911.03852, 2019.
238
+
239
+ Steven K Esser, Jeffrey L McKinstry, Deepika Bablani, Rathinakumar Appuswamy, and Dharmendra S Modha. Learned step size quantization. arXiv preprint arXiv:1902.08153, 2019.
240
+
241
+ Angela Fan, Pierre Stock, Benjamin Graham, Edouard Grave, Remi Gribonval, Herve Jegou, and ´ Armand Joulin. Training with quantization noise for extreme model compression. arXiv preprint arXiv:2004.07320, 2020.
242
+
243
+ Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. arXiv preprint arXiv:2010.01412, 2020.
244
+
245
+ Yonggan Fu, Qixuan Yu, Meng Li, Vikas Chandra, and Yingyan Lin. Double-win quant: Aggressively winning robustness of quantized deep neural networks via random precision training and inference. In International Conference on Machine Learning, pp. 3492–3504. PMLR, 2021.
246
+
247
+ Song Han, Huizi Mao, and William J Dally. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. arXiv preprint arXiv:1510.00149, 2015.
248
+
249
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
250
+
251
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
252
+
253
+ Sepp Hochreiter and Jurgen Schmidhuber. Flat minima. ¨ Neural computation, 9(1):1–42, 1997.
254
+
255
+ Itay Hubara, Yury Nahshan, Yair Hanani, Ron Banner, and Daniel Soudry. Accurate post training quantization with small calibration sets. In International Conference on Machine Learning, pp. 4466–4475. PMLR, 2021.
256
+
257
+ Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. arXiv preprint arXiv:1803.05407, 2018.
258
+
259
+ Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2704–2713, 2018.
260
+
261
+ Yiding Jiang, Behnam Neyshabur, Hossein Mobahi, Dilip Krishnan, and Samy Bengio. Fantastic generalization measures and where to find them. arXiv preprint arXiv:1912.02178, 2019.
262
+
263
+ Prad Kadambi, Karthikeyan Natesan Ramamurthy, and Visar Berisha. Comparing fisher information regularization with distillation for dnn quantization. 2020.
264
+
265
+ Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016.
266
+
267
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
268
+
269
+ Yuhang Li, Xin Dong, and Wei Wang. Additive powers-of-two quantization: An efficient nonuniform discretization for neural networks. arXiv preprint arXiv:1909.13144, 2019.
270
+
271
+ Yuhang Li, Ruihao Gong, Xu Tan, Yang Yang, Peng Hu, Qi Zhang, Fengwei Yu, Wei Wang, and Shi Gu. Brecq: Pushing the limit of post-training quantization by block reconstruction. arXiv preprint arXiv:2102.05426, 2021a.
272
+
273
+ Yuhang Li, Mingzhu Shen, Jian Ma, Yan Ren, Mingxin Zhao, Qi Zhang, Ruihao Gong, Fengwei Yu, and Junjie Yan. MQBench: Towards reproducible and deployable model quantization benchmark. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021b. URL https://openreview.net/forum?id $=$ TUplOmF8DsM.
274
+
275
+ Yuhang Li, Feng Zhu, Ruihao Gong, Mingzhu Shen, Xin Dong, Fengwei Yu, Shaoqing Lu, and Shi Gu. Mixmix: All you need for data-free compression are feature and data mixing. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4410–4419, 2021c.
276
+
277
+ Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense ´ object detection. In Proceedings of the IEEE international conference on computer vision, pp. 2980–2988, 2017.
278
+
279
+ Markus Nagel, Mart van Baalen, Tijmen Blankevoort, and Max Welling. Data-free quantization through weight equalization and bias correction. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1325–1334, 2019.
280
+
281
+ Markus Nagel, Rana Ali Amjad, Mart Van Baalen, Christos Louizos, and Tijmen Blankevoort. Up or down? adaptive rounding for post-training quantization. In International Conference on Machine Learning, pp. 7197–7206. PMLR, 2020.
282
+
283
+ Yury Nahshan, Brian Chmiel, Chaim Baskin, Evgenii Zheltonozhskii, Ron Banner, Alex M Bronstein, and Avi Mendelson. Loss aware post-training quantization. arXiv preprint arXiv:1911.07190, 2019.
284
+
285
+ Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nathan Srebro. Exploring generalization in deep learning, 2017.
286
+
287
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32: 8026–8037, 2019.
288
+
289
+ Haotong Qin, Ruihao Gong, Xianglong Liu, Mingzhu Shen, Ziran Wei, Fengwei Yu, and Jingkuan Song. Forward and backward information retention for accurate binary neural networks. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
290
+
291
+ Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428–10436, 2020.
292
+
293
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In Advances in neural information processing systems, pp. 91–99, 2015.
294
+
295
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
296
+
297
+ Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4510–4520, 2018.
298
+
299
+ Mingzhu Shen, Feng Liang, Ruihao Gong, Yuhang Li, Chuming Li, Chen Lin, Fengwei Yu, Junjie Yan, and Wanli Ouyang. Once quantization-aware training: High performance extremely lowbit architecture search. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 5340–5349, 2021.
300
+
301
+ Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2820–2828, 2019.
302
+
303
+ Peisong Wang, Qiang Chen, Xiangyu He, and Jian Cheng. Towards accurate post-training network quantization via bit-split and stitching. In Proc. 37nd Int. Conf. Mach. Learn.(ICML), 2020.
304
+
305
+ Dongxian Wu, Shu-Tao Xia, and Yisen Wang. Adversarial weight perturbation helps robust generalization. arXiv preprint arXiv:2004.05884, 2020.
306
+
307
+ Guandao Yang, Tianyi Zhang, Polina Kirichenko, Junwen Bai, Andrew Gordon Wilson, and Chris De Sa. Swalp: Stochastic weight averaging in low precision training. In International Conference on Machine Learning, pp. 7015–7024. PMLR, 2019.
308
+
309
+ Haichao Yu, Linjie Yang, and Humphrey Shi. Is in-domain data really needed? a pilot study on cross-domain calibration for network quantization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, pp. 3043–3052, June 2021.
310
+
311
+ Xiangguo Zhang, Haotong Qin, Yifu Ding, Ruihao Gong, Qinghua Yan, Renshuai Tao, Yuhang Li, Fengwei Yu, and Xianglong Liu. Diversifying sample generation for accurate data-free quantization. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2021a.
312
+
313
+ Xiangguo Zhang, Haotong Qin, Yifu Ding, Ruihao Gong, Qinghua Yan, Renshuai Tao, Yuhang Li, Fengwei Yu, and Xianglong Liu. Diversifying sample generation for accurate data-free quantization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15658–15667, 2021b.
314
+
315
+ Yaowei Zheng, Richong Zhang, and Yongyi Mao. Regularizing neural networks via adversarial model perturbation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8156–8165, 2021.
316
+
317
+ Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.
318
+
319
+ # A NOISE FORM CHOICE
320
+
321
+ As mentioned in Sec. 2, we refer the quantizer to $\hat { a } = \left\lfloor \frac { a } { s } \right\rceil \cdot s$ , where $s$ is the step size that can be learned or be determined by collecting activation distribution in PTQ. By marking the rounding error as $c$ , which subjects to $\mathcal { U } [ - 0 . 5 , 0 . 5 ]$ , the additive noise $e = { \hat { a } } - a$ can be denoted as $c \cdot s$ . However, this traditional noise does not decouple the noise from step size $s$ and the range of activations. The range of noise $e$ will vary when the range of activations change, making it complicated to analyze across the whole network in a unified form. Some existing papers (Jiang et al., 2019) also indicate the problem that the additive noise doesn’t take parameters’ magnitude into account and suggest a multiplicative form form (Keskar et al., 2016). To be specific, they claim that:
322
+
323
+ Perturbing the parameters without taking their magnitude into account can cause many of them to switch signs. Therefore, one cannot apply large perturbations to the model without changing the loss significantly. One possible modification to improve the perturbations is to choose the perturbation magnitude based on the magnitude of the parameter. In that case, it is guaranteed that if the magnitude of perturbation is less than the magnitude of the parameter, then the sign of the parameter does not change.
324
+
325
+ To eliminate the influence induced by the range of activations, we take the noise of multiplicative form: $\hat { a } = ( 1 + \boldsymbol { u } ) \cdot \boldsymbol { a }$ . In the quantization background, we denote the fixed-point integer value with respect to $a$ as $\bar { a }$ ( $\overset { \cdot } { a } = ( \overset { - } { a } + \overset { \cdot } { c } ) \cdot \overset { \cdot } { s }$ and ${ \hat { a } } = { \bar { a } } \cdot s$ ). And then $u$ can be denoted as:
326
+
327
+ $$
328
+ \begin{array} { l } { { u = \displaystyle \frac { \hat { a } } { a } - 1 } } \\ { { \ } } \\ { { \displaystyle = \frac { \hat { a } \cdot s } { ( \bar { a } + c ) \cdot s } - 1 } } \\ { { \ } } \\ { { \displaystyle = \frac { \bar { a } } { \bar { a } + c } - 1 } } \\ { { \ } } \\ { { \displaystyle = \frac { - c } { \bar { a } + c } . } } \end{array}
329
+ $$
330
+
331
+ To be noted, $u$ is derived from the definition of the quantizer and can be equivalently transformed from the generalized noise here.
332
+
333
+ From this formulation, we can find that the range of $u$ is not related to the activation range or step size $s$ and is only influenced by the rounding error and the bit-width. In a word, the multiplicative form has its pysical meaning in quantization background and is beneficial as discussed above.
334
+
335
+ # B PROOF OF LEMMA 1 AND THEOREM 1
336
+
337
+ We demonstrate them by considering the situation of (1) fully connected and (2) convolutional networks separately. As transformation with fully connected ones has been revealed in main body, we add some extra illustration here and mainly target at the convolutional layers.
338
+
339
+ # B.1 FULLY CONNECTED NETWORKS
340
+
341
+ Here, we give the proof of Eq. (5) by leveraging the definition of FC layers in Eq. (1). We first look at each input sample and temporarily omit $_ { \textbf { \em x } }$ in the notation below for simplicity.
342
+
343
+ With activation noise $\textbf { \em u }$
344
+
345
+ $$
346
+ \begin{array} { r } { z _ { i } ^ { ( \ell + 1 ) } = \displaystyle \sum _ { j } \mathbf { W } _ { i , j } ^ { ( \ell ) } \cdot ( 1 + \mathbf { \boldsymbol { u } } _ { j } ^ { ( \ell ) } ) \cdot \mathbf { \boldsymbol { a } } _ { j } ^ { ( \ell ) } } \\ { = \displaystyle \sum _ { j } ( 1 + \mathbf { \boldsymbol { u } } _ { j } ^ { ( \ell ) } ) \cdot \mathbf { \boldsymbol { W } } _ { i , j } ^ { ( \ell ) } \cdot \mathbf { \boldsymbol { a } } _ { j } ^ { ( \ell ) } . } \end{array}
347
+ $$
348
+
349
+ By taking $V _ { i , j } ^ { ( \ell ) } = \pmb { u } _ { j } ^ { ( \ell ) }$ , we have
350
+
351
+ $$
352
+ z _ { i } ^ { ( \ell + 1 ) } = \sum _ { j } ( 1 + V _ { i , j } ^ { ( \ell ) } ) \cdot W _ { i , j } ^ { ( \ell ) } \cdot a _ { j } ^ { ( \ell ) } .
353
+ $$
354
+
355
+ Thus, with proper constructed $\pmb { v }$ , the noise on activation $( { \pmb u } )$ can be viewed as the perturbation on weight $( v )$ .
356
+
357
+ For every layer, we can conduct this transformation from $\textbf { \em u }$ to $\textbf { { v } }$ . Therefore, considering operating on the quantized weight and calibration data, optimizing $\mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { c } } [ L ( \hat { \pmb { w } } , \pmb { x } , \mathbf { 1 } + \pmb { u } ( \pmb { x } ) ) ]$ can be approximated to optimizing $\mathbb { E } _ { \pmb { x } \sim \mathcal { D } _ { c } } \big [ L \big ( \hat { \pmb { w } } \odot ( \mathbf { 1 } + \pmb { v } ( \hat { \pmb { x } } ) ) , \pmb { x } , \mathbf { 1 } \big ) \big ]$ . Then we have
358
+
359
+ $$
360
+ \begin{array} { r } { \mathbb { E } _ { \alpha \sim \mathcal { D } _ { c } } \big [ L ( \hat { w } , x , \mathbf { 1 } + u ( x ) ) - L ( w , x , \mathbf { 1 } ) \big ] \approx \mathbb { E } _ { \alpha \sim \mathcal { D } _ { c } } \big [ L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , x , \mathbf { 1 } ) - L ( w , x , \mathbf { 1 } ) \big ] . } \end{array}
361
+ $$
362
+
363
+ Now, Lemma 1 is proved for the case of fully connected networks.
364
+
365
+ # B.2 CONVOLUTIONAL NETWORKS
366
+
367
+ We first look at each input sample and temporarily omit $_ { \textbf { \em x } }$ in the notation below for simplicity. One layer in the network $\mathcal { G }$ can be interpreted as:
368
+
369
+ $$
370
+ A _ { i , j } ^ { ( \ell + 1 ) } = f ( Z _ { i , j } ^ { ( \ell + 1 ) } ) = f ( \sum _ { p , q } W _ { p , q } ^ { ( \ell ) } \cdot A _ { i + p , j + q } ^ { ( \ell ) } ) ,
371
+ $$
372
+
373
+ where the $f ( \cdot )$ is the activation function, $( p , q )$ pair represents for one element in weight matrix and $( i , j )$ pair represents for one element in activation matrix.
374
+
375
+ Due to the complicated design of convolutional structure, based on $\mathcal { G }$ we introduce two networks $\mathcal { G } _ { 1 } , \mathcal { G } _ { 2 }$ to make proofs more clearly.
376
+
377
+ Definition 1. $\mathcal { G } _ { 1 }$ means inserting random noise on activations, $\mathcal { G } _ { 2 }$ means sticking random variables into weights.
378
+
379
+ $$
380
+ \begin{array} { l } { { \displaystyle \mathcal { G } _ { 1 } : A _ { i , j } ^ { ( \ell + 1 ) } = f ( \boldsymbol { Z } _ { i , j } ^ { ( \ell + 1 ) } ) = f ( \sum _ { p , q } W _ { p , q } ^ { ( \ell ) } \cdot ( 1 + U _ { i + p , j + q } ^ { ( \ell ) } ) \cdot A _ { i + p , j + q } ^ { ( \ell ) } ) } } \\ { { \displaystyle \mathcal { G } _ { 2 } : A _ { i , j } ^ { ( \ell + 1 ) } = f ( \boldsymbol { Z } _ { i , j } ^ { ( \ell + 1 ) } ) = f ( \sum _ { p , q } ( 1 + V _ { p , q } ^ { ( \ell ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i + p , j + q } ^ { ( \ell ) } ) ) } } \end{array}
381
+ $$
382
+
383
+ Definition 2. We mark losses of network $\mathcal { G } _ { 1 }$ and $\mathcal { G } _ { 2 }$ in the following way:
384
+
385
+ With the definitions, we first prove that $\mathcal { G } _ { 1 }$ and $\mathcal { G } _ { 2 }$ share common parts in their first-order derivative to its noise in Lemma 2.
386
+
387
+ Lemma 2. Assuming the same weight and taking ${ \pmb u } = { \bf 0 }$ and $\mathbf { \nabla } _ { v } = \mathbf { 0 }$ for $\mathcal { G } _ { 1 }$ and $\mathcal { G } _ { 2 }$ , we have
388
+
389
+ $$
390
+ \begin{array} { r l r } & { } & { \frac { \partial L ( w , x , \mathbf { 1 } ) } { \partial U _ { i , j } ^ { ( \ell ) } } = \displaystyle \sum _ { p , q } \pmb { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } } \\ & { } & { \frac { \partial L ( w \odot \mathbf { 1 } , x ) } { \partial V _ { p , q } ^ { ( \ell ) } } = \displaystyle \sum _ { i , j } \pmb { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } , } \end{array}
391
+ $$
392
+
393
+ where
394
+
395
+ $$
396
+ \begin{array} { r } { \pmb { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } = \frac { \partial L ( w , x , \mathbf { 1 } ) } { \partial \pmb { A } _ { i - p , j - q } ^ { ( \ell + 1 ) } } \cdot f ^ { \prime } ( \pmb { Z } _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot \pmb { W } _ { p , q } ^ { ( \ell ) } \cdot \pmb { A } _ { i , j } ^ { ( \ell ) } } \\ { = \frac { \partial L ( w \odot \mathbf { 1 } , \pmb { x } ) } { \partial \pmb { A } _ { i - p , j - q } ^ { ( \ell + 1 ) } } \cdot f ^ { \prime } ( \pmb { Z } _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot \pmb { W } _ { p , q } ^ { ( \ell ) } \cdot \pmb { A } _ { i , j } ^ { ( \ell ) } . } \end{array}
397
+ $$
398
+
399
+ Note that with ${ \pmb u } = { \bf 0 }$ and $\mathbf { \nabla } _ { v } = \mathbf { 0 }$ , the activations are the same for the two networks so we don’t use different notations here.
400
+
401
+ Proof.
402
+
403
+ $$
404
+ \frac { \partial L ( w , x , \mathbf { 1 } ) } { \partial U _ { i , j } ^ { ( \ell ) } } = \sum _ { p , q } \frac { \partial L ( w , x , \mathbf { 1 } ) } { \partial A _ { i - p , j - q } ^ { ( \ell + 1 ) } } \cdot f ^ { \prime } ( Z _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i , j } ^ { ( \ell ) }
405
+ $$
406
+
407
+ $$
408
+ \begin{array} { r } { \displaystyle \frac { \partial L ( w \odot \mathbf { 1 } , \boldsymbol { x } ) } { \partial V _ { p , q } ^ { ( \ell ) } } = \sum _ { i , j } \frac { \partial L ( w \odot \mathbf { 1 } , \boldsymbol { x } ) } { \partial A _ { i , j } ^ { ( \ell + 1 ) } } \cdot f ^ { \prime } ( Z _ { i , j } ^ { ( \ell + 1 ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i + p , j + q } ^ { ( \ell ) } } \\ { = \sum _ { i , j } \frac { \partial L ( w \odot \mathbf { 1 } , \boldsymbol { x } ) } { \partial A _ { i - p , j - q } ^ { ( \ell + 1 ) } } \cdot f ^ { \prime } ( Z _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i , j } ^ { ( \ell ) } } \end{array}
409
+ $$
410
+
411
+ Because of taking the same weight, and calculating the derivatives to U (ℓ)i,j at ${ \pmb u } = 0$ and derivatives to V (ℓ) at $v = 0$ , we have the same activation values for these two networks. Therefore, Eq. (21) holds.
412
+
413
+ $$
414
+ \frac { \partial L ( w , \boldsymbol { x } , \mathbf { 1 } ) } { \partial A _ { i - p , j - q } ( \ell + 1 ) } \cdot f ^ { \prime } ( Z _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i , j } ^ { ( \ell ) } = \frac { \partial L ( w \odot \mathbf { 1 } , \boldsymbol { x } ) } { \partial A _ { i - p , j - q } ( \ell + 1 ) } \cdot f ^ { \prime } ( Z _ { i - p , j - q } ^ { ( \ell + 1 ) } ) \cdot W _ { p , q } ^ { ( \ell ) } \cdot A _ { i , j } ^ { ( \ell ) }
415
+ $$
416
+
417
+ By marking the above value as T (ℓ)(i,j),(p,q), we can get Lemma 2.
418
+
419
+ Based on Lemma 2, we further derive Theorem 2 as the pre-condition of the final Lemma 1.
420
+
421
+ Theorem 2. By taking
422
+
423
+ $$
424
+ V _ { p , q } ^ { ( \ell ) } = \frac { \sum _ { i , j } U _ { i , j } ^ { ( \ell ) } \cdot \mathbf { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } } { \sum _ { i , j } \mathbf { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } } ,
425
+ $$
426
+
427
+ we have
428
+
429
+ $$
430
+ \begin{array} { r } { \pmb { u } ^ { \top } \nabla _ { \pmb { u } } L ( \pmb { w } , \pmb { x } , \mathbf { 1 } ) = \pmb { v } ^ { \top } \nabla _ { \pmb { v } } L ( \pmb { w } \odot \mathbf { 1 } , \pmb { x } ) . } \end{array}
431
+ $$
432
+
433
+ Proof. According to Lemma 2,
434
+
435
+ $$
436
+ \begin{array} { r l } { u ^ { \top } \nabla _ { u } t ; \{ w , x , 1 \} = } & { \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - \frac { \lambda ( i ( w , x , 1 ) ) } { \delta W _ { \xi , j ^ { \prime } } ^ { ( i ) } } } \\ & { = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } \cdot \sum _ { \xi \neq j ^ { \prime } } ^ { \xi ^ { \prime } } U _ { \xi , j ( z ) , \eta ( z ) } ^ { ( i ) } } \\ & { = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } \sum _ { \xi \neq \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ { ( \xi ) , \eta ( z ) , \eta ( z ) } ^ { ( i ) } } \\ & { = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } \sum _ { \xi \neq \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ { ( \xi ) , \eta ( z ) , \eta ( z ) } ^ { ( i ) } } \\ & { = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } \sum _ { \xi \neq \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ { ( \xi ) , \eta ( z ) , \eta ( z ) } ^ { ( i ) } } \\ & { = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } \sum _ { \xi \neq \xi } \frac { \sum _ { i , j ^ { \prime } } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ { ( \xi ) , \eta ( z ) , \eta } ^ { ( i ) } } { \sum _ { \xi , j ^ { \prime } } \int _ { \xi , \xi \neq \xi } ^ { \xi ^ { \prime } } ( x _ { i } ) _ { i , \xi \neq \xi } } \cdot \sum _ { \xi \neq \xi } T _ { ( \xi ) , \xi \neq \xi } ^ { ( i ) } } \\ & = \displaystyle \sum _ { \xi ^ { \prime } \neq \xi } \sum _ { \xi \neq \xi } \frac { \sum _ { i , j ^ { \prime } } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ { ( \xi ) , \xi \neq \xi } ^ { ( i ) } } \sum _ { \xi , j ^ { \prime } } \int _ { \xi , \xi \neq \xi } \int _ { \xi , \xi } U _ { \xi , j ^ { \prime } } ^ { ( i ) } - T _ \end{array}
437
+ $$
438
+
439
+ By taking $\begin{array} { r } { V _ { p , q } ^ { ( \ell ) } = \frac { \sum _ { i , j } \pmb { U } _ { i , j } ^ { ( \ell ) } \cdot \pmb { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } } { \sum _ { i , j } \pmb { T } _ { ( i , j ) , ( p , q ) } ^ { ( \ell ) } } } \end{array}$ ,
440
+
441
+ $$
442
+ \begin{array} { r l } & { \mathbf { \boldsymbol { u } } ^ { \top } \nabla _ { \boldsymbol { u } } L ( \boldsymbol { w } , \boldsymbol { x } , \mathbf { 1 } ) = \displaystyle \sum _ { \ell } \sum _ { p , q } V _ { p , q } ^ { ( \ell ) } \cdot \frac { \partial L ( \boldsymbol { w } \odot \mathbf { 1 } , \boldsymbol { x } ) } { \partial V _ { p , q } ^ { ( \ell ) } } } \\ & { \quad \quad \quad = \boldsymbol { v } ^ { \top } \nabla _ { \boldsymbol { v } } L ( \boldsymbol { w } \odot \mathbf { 1 } , \boldsymbol { x } ) . } \end{array}
443
+ $$
444
+
445
+ Thus Theorem 2 is affirmed.
446
+
447
+ We now prove Lemma 1 equipped with Taylor Expansion technique and Theorem 2.
448
+
449
+ Proof. First, by adopting Taylor Expansions at ${ \pmb u } = { \bf 0 }$ , we can get that:
450
+
451
+ $$
452
+ L ( \hat { w } , x , \mathbf { 1 } + u ) - L ( w , x , \mathbf { 1 } ) \approx L ( \hat { w } , x , \mathbf { 1 } ) + u ^ { \top } \nabla _ { u } L ( \hat { w } , x , \mathbf { 1 } ) - L ( w , x , \mathbf { 1 } ) .
453
+ $$
454
+
455
+ Then, according to Theorem 2, the above equation can be rewritten as:
456
+
457
+ $$
458
+ L ( \hat { w } , x , 1 + u ) - L ( w , x , 1 ) \approx L ( \hat { w } \odot \mathbf { 1 } , \pmb { x } ) + v ^ { \top } \nabla _ { v } L ( \hat { w } \odot \mathbf { 1 } , \pmb { x } ) - L ( w , \pmb { x } , \mathbf { 1 } ) .
459
+ $$
460
+
461
+ Again, by adopting Taylor Expansions at $\mathbf { \nabla } _ { v } = \mathbf { 0 }$ for the right part of Eq. (27), we arrive at:
462
+
463
+ $$
464
+ L ( \hat { w } , x , \mathbf { 1 } + u ) - L ( w , x , \mathbf { 1 } ) \approx L ( \hat { w } \odot ( \mathbf { 1 } + v ) , x ) - L ( w , x , \mathbf { 1 } ) .
465
+ $$
466
+
467
+ Finally, apply expectation on Eq. (28), and Lemma 1 is proved:
468
+
469
+ $$
470
+ \begin{array} { r l } & { \mathbb { E } _ { { \pmb x } \sim { \mathcal { D } } _ { c } } [ L ( { \pmb \hat { w } } , { \pmb x } , { \bf 1 } + { \pmb u } ( { \pmb x } ) ) - L ( { \pmb w } , { \pmb x } , { \bf 1 } ) ] } \\ & { \qquad \approx \mathbb { E } _ { { \pmb x } \sim { \mathcal { D } } _ { c } } [ L ( { \pmb \hat { w } } \odot ( { \bf 1 } + { \pmb v } ( { \pmb x } ) ) , { \pmb x } ) - L ( { \pmb w } , { \pmb x } , { \bf 1 } ) ] . } \end{array}
471
+ $$
472
+
473
+ With the Lemma 1 proved, we can easily derive Theorem 1 by the following transformation:
474
+
475
+ $$
476
+ \begin{array} { r l } & { \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } , x , \mathbf { 1 } + u ( x ) ) - L ( w , \mathbf { x } , \mathbf { 1 } ) ] } \\ & { \qquad \approx \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , x ) - L ( w , x , \mathbf { 1 } ) ] } \\ & { \qquad = \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , x , \mathbf { 1 } ) - L ( w , x , \mathbf { 1 } ) + L ( \hat { w } , x , \mathbf { 1 } ) - L ( \hat { w } , x , \mathbf { 1 } ) ] } \\ & { \qquad = \mathbb { E } _ { \mathbf { x } \sim \mathcal { D } _ { c } } [ L ( \hat { w } , x , \mathbf { 1 } ) - L ( w , x , \mathbf { 1 } ) + L ( \hat { w } \odot ( \mathbf { 1 } + v ( x ) ) , x , \mathbf { 1 } ) - L ( \hat { w } , x , \mathbf { 1 } ) ] . } \end{array}
477
+ $$
478
+
479
+ # C EXPERIMENTS
480
+
481
+ # C.1 SUPPLEMENTARY EXPERIMENTS OF SEC. 3.1
482
+
483
+ To explore the upper limit of PTQ, we concern two key parts of the algorithm (weight quantization and activation one). As is generally known, QAT is a popular way to produce favor quantization results, thus we use QAT’s learning mechanism to replace each of the two parts in PTQ and record outcomes in Table 7. In detail, about weight quantization, QAT’s settings we used include the whole ImageNet, STE learning strategy and end-to-end training for 40 epochs while PTQ’ settings only cover 1024 samples, training block by block. But we both keep the rounding-up-or-down parameter optimization space. About activation quantization, QAT’ settings we used include the whole ImageNet, LSQ (Esser et al., 2019) scheme and end-to-end training for 5 epochs.
484
+
485
+ However, results in Table 7 are surprising that although the optimization space in weight is kept very restricted, leveraging the whole data to implement weight tuning can achieve a large accuracy boost. And the activation quantization step size might not be as important as weight. These findings indicate that exploring a quantization-friendly weight may be the fresh insight for the accurate PTQ, where this work dedicates to.
486
+
487
+ # C.2 SUPPLEMENTARY EXPERIMENTS OF SEC. 3.3
488
+
489
+ Overfitting phenomenon. To analyze the overfitting problem refered in Sec. 3.3, we have conducted experiments to compare the accuracy on test data and calibration data, respectively. The table below is an example of ResNet-18 W2A2. It can be seen that with extremely low-bit quantization, both Case 2 and Case 3 perform well on calibration data but on test data Case 2 performs worse than Case 3. This is a shred of clear evidence that Case 2 suffers a more severe overfitting problem.
490
+
491
+ <table><tr><td>Methods</td><td>Test accuracy</td><td>Train accuracy</td></tr><tr><td>Case 1</td><td>18.88</td><td>19.82</td></tr><tr><td>Case 2</td><td>45.77</td><td>69.54</td></tr><tr><td>Case 3</td><td>48.07</td><td>69.92</td></tr><tr><td>QDROP</td><td>51.14</td><td>66.11</td></tr></table>
492
+
493
+ Table 7: Ablation study of quantization settings on ResNet-18 W2A2.
494
+
495
+ <table><tr><td>Activation setting</td><td>Weight setting</td><td> Accuracy</td></tr><tr><td>PTQ</td><td>PTQ</td><td>46.64</td></tr><tr><td>QAT</td><td>PTQ</td><td>49.53</td></tr><tr><td>PTQ</td><td>QAT</td><td>57.49</td></tr></table>
496
+
497
+ Table 8: Train and test accuracy on ResNet-18 W2A2.
498
+
499
+ Rethinking Theorem 1, both Case 2 and Case 3 introduce the term (7-2) that implies flatness against the perturbation ${ \pmb v } ( { \pmb x } )$ . However, Case 2 completely introduces the quantization noise ${ \pmb u } ( { \pmb x } )$ according to the calibration data. Thus the resulting flatness fits calibration data but does not generalize well on test data. Case 3 drops partial of ${ \pmb u } ( { \pmb x } )$ and improves the possibility of flatness on test data instead. The two accuracy of QDROP also confirmed this phenomenon with more diverse directions of flatness. As for Case 1, its accuracy on both calibration data and test data is low. This is because that it does not introduce activation quantization during weight tuning and thus behaves worst without taking flatness term even on calibration data into account.
500
+
501
+ Hessian information. As Hessian information is known to be a metric to characterize flatness property (Keskar et al., 2016; Dong et al., 2019), we also calculate the top-1, top-5 Hessian eigenvalues $( \lambda _ { 1 } , \lambda _ { 5 } )$ and the Hessian trace $( \mathrm { T r } )$ among 3 cases and QDROP to better support our analysis. In table Table 9, QDROP has the smallest value of Hessian information, which matches with our theoretical framework and observations of loss landscape.
502
+
503
+ Table 9: Hessian information of the ResNet-18 W3A3 model. $\lambda _ { 1 }$ represents for the top-1 Hessian eigenvalue, $\lambda _ { 5 }$ for top-5 Hessian eigenvalues and $\mathrm { T r }$ for Hessian trace.
504
+
505
+ <table><tr><td>Method</td><td>入1</td><td>15</td><td>Tr</td></tr><tr><td>Case 1</td><td>14770</td><td>6746</td><td>122894</td></tr><tr><td>Case 2</td><td>8423</td><td>4050</td><td>86287</td></tr><tr><td>Case 3</td><td>8258</td><td>3821</td><td>84044</td></tr><tr><td>QDROP</td><td>6850</td><td>3044</td><td>66371</td></tr></table>
506
+
507
+ # C.3 SUPPLEMENTARY EXPERIMENTS OF SEC. 4
508
+
509
+ To clarify the gap between AdaQuant and our method in classification task on 4-bit ResNet-18 and -50, we analyze the difference on settings between these two algorithms. There are two major discrepancies which would influence the final accuracy. One is the position of activation quantization nodes, the other is the FP32 accuracy of pretrain-models. As shown in Fig. 7, by inserting the quantizer like the right side one, AdaQuant would introduce two different quantizers for the same input with learned quantization parameters such as step size. We find this can bring $\sim 0 . 4 \%$ upswings on ResNet-18 and -50 W4A4 and improve more on ultra low-bit with experiments of our algorithm. However, this way to insert quantization nodes is not practical in real deployment, because two different quantizers for the same input would make it impossible to follow the so-called Requantize procedure (Li et al., 2021b). As for the pretrain-models, they use $7 1 . 9 7 \%$ and $7 7 . 2 \%$ , higher than ours $( 7 1 . 0 6 \%$ and $7 7 . 0 \%$ ), which can indeed improve the accuracy. Replacing our settings with the two adopted in AdaQuant, we finally reach $7 1 . 0 7 \%$ and $7 6 . 6 7 \%$ .
510
+
511
+ ![](images/81ca3bdd5318bb26de42494bb97e51d612a5d7812d2a59395e5f054b7803d919.jpg)
512
+ Figure 7: Different ways of inserting activation quantization nodes. Our method obeys the left side one while AdaQuant adopts the right side one.
513
+
514
+ <table><tr><td>Method</td><td>Bits (W/A)</td><td>ResNet-18</td><td>SWA20</td></tr><tr><td rowspan="3"></td><td>FP32</td><td>71.06</td><td>71.50</td></tr><tr><td>8/8</td><td>70.94</td><td>71.40</td></tr><tr><td>4/8</td><td>52.33</td><td>65.26</td></tr><tr><td rowspan="3">OMSE* (Choukroun et al., 2019)</td><td>4/4</td><td>26.05</td><td>44.37</td></tr><tr><td>32/4</td><td>64.15</td><td>65.99</td></tr><tr><td>4/4</td><td>38.32</td><td>55.86</td></tr><tr><td>BRECQ+*</td><td>2/4</td><td>65.35</td><td>66.33</td></tr><tr><td>(Li et al., 2021a)</td><td>2/2</td><td>41.74</td><td>44.30</td></tr></table>
515
+
516
+ Table 10: Experiments between ResNet-18 and $\mathrm { S W A _ { 2 0 } }$ when adopting different PTQ methods. $\mathrm { S W A _ { 2 0 } }$ is acquired by finetuning ResNet-18 using SWA technique for 20 epochs.
517
+
518
+ # C.4 FLATNESS AND POST-TRAINING QUANTIZATION
519
+
520
+ While there are plenty of works exploring the correlation between flatness and generalization, the interaction between quantization and flatness has not been exploited much. In this paper, we first connect flatter quantized weight with activation quantization from PTQ view, as implied in Sec. 3.2. From this, we conjecture that flatness and quantization might be helpful to each other.
521
+
522
+ By leveraging some mechanisms devoting to produce a smoother loss surface for better generalization, such as (Izmailov et al., 2018), the improved FP32 model is obtained and used to validate the performance on quantization compared with the naive one. In Table 10, model $\mathrm { S W A _ { 2 0 } }$ is enabled by applying the SWA technique (Izmailov et al., 2018) to ResNet-18 with 20 epochs fintuning process on the whole ImageNet. From the table, the observation is that the promotion on generalization can not fully represent the enhancement induced by SWA on quantization. With even lower bits thus larger noise, $\mathrm { S W A _ { 2 0 } }$ surpasses the naive one by a large margin. It also reveals that distinct FP32 models with analogous accuracy might contribute to surprisingly disparate outcomes after PTQ, particularly for those naive methods without any weight tuning.
523
+
524
+ In turn, there have been some studies that delve into robustness boost by applying quantization. (Fu et al., 2021) advocates that quantization can be properly leveraged to enhance DNNs’ robustness, even beyond their full-precision counterparts. They propose a random bit training strategy to accomplish it, where our work illustrates the correlation with bit and perturbation in Appendix A.
525
+
526
+ # D RELATED WORKS
527
+
528
+ Post-training quantization. Unlike QAT Esser et al. (2019); Li et al. (2019); Shen et al. (2021) where the quantized model is finetuned with full training dataset and over 100 epochs training, PTQ is much more faster. Rounding-to-nearest operation is known to be the direct and easy way for quantizing parameters or activations in PTQ. Although there is almost no accuracy drop when quantizing to 8-bit, lower bit quantization is yet a hard task and worth exploring. (Choukroun et al., 2019) transforms quantization to a Minimum Mean Squared Error problem both for weights and activations. (Nagel et al., 2019) equalizes weight ranges among channels thus be more favorable to per-layer quantization and employs bias correction to absorb the output error induced by quantization. However, such methods neglect the task loss thus lead to a sub-optimal. AdaRound (Nagel et al., 2020), which proposes to learn the rounding mechanism by reconstructing output layer by layer brings more opportunities for 4-bit quantization. Besides layer reconstruction, BRECQ (Li et al., 2021a) discusses more choices and advises to do block reconstruction with better accuracy at 2-bit weight quantization. Nonetheless, we argue that AdaRound and BRECQ isolate weight quantization and activation one theoretically and experimentally, which might be a key point of failures on extremely low-bit quantization. Recently, there is another trend of utilizing synthetic data for PTQ, which explicitly do backpropagation on the learned input tensor Cai et al. (2020); Zhang et al. (2021b); Li et al. (2021c).
529
+
530
+ Flatness. The idea of “flat” minima might date back to (Hochreiter & Schmidhuber, 1997), where the benefits are recognized in recent years, such as generalization (Jiang et al., 2019; Keskar et al., 2016) and adversarial training (Wu et al., 2020; Zheng et al., 2021). Some previous works (Izmailov et al., 2018; Foret et al., 2020) devote to improve the flatness of the trained weight for robustness under perturbation or distribution shift. Other ideas try to model flatness or sharpness formally by visualization of loss landscape or mathematical formulas. And for quantization, which could be viewed as some kind of noise, a flat model has been implied to be preferable, (Dong et al., 2019; Yang et al., 2019; Kadambi et al., 2020). Despite the natural fact that flatness helps with weight quantization, how does activation quantization involves with smoother loss surface has not been discussed deeply, particularly for post-training quantization. In this work, we introduce noise scheme by randomly dropping activation quantization and achieve a general flatness. Another paper (Fan et al., 2020) also utilizes randomness by adding noise to weight for the simulation of weight quantization. But they target at reducing the induced bias of Straight Through Estimation (STE) in QAT and also have different motivations and solve different problems from us.
531
+
532
+ # E IMPLEMENTATION DETAILS
533
+
534
+ Observation. Here, we give the concrete implementation of experiments in Sec. 3.1. We actually consider three ways of introducing activation for Case 2, but we find the differences of outcomes among them are negligible thus employing one of them for clearer clarification.
535
+
536
+ ImageNet. We randomly extract 1024 training examples from ImageNet as calibration dataset based on the standard pre-process. Pretrain-models are downloaded from BRECQ’s open source code. Hyper-parameters we keep it as BRECQ, such as batch size 32, learning rate for activation step size 4e-5, learning rate for weight tuning 1e-3, iterations 20000. Following BRECQ, we first fold batch normalization layer into convolution then reconstruct output block-wise to learn the weight
537
+
538
+ # Algorithm 2: Implementations of three cases in Sec. 3.1
539
+
540
+ ![](images/aa0abd9b704bb6ad9c1b00f2bc3ef59e4f4240c523cc8e8d69fb1de0fb2cd1d4.jpg)
541
+
542
+ rounding policy and meanwhile use LSQ (Esser et al., 2019) to parameterize activation step size. For QDROP, we learn the weight and activation parameters together and use $50 \%$ rate to drop some activation quantization.
543
+
544
+ Object detection. Here, we also obey BRECQ’ settings and use the same pretrain-models with 256 training samples taken from MS COCO dataset for calibration. Parameters about resolution is set to 800 (max size 1333) and 600 (max size 1000) for ResNets and MobileNetV2, respectively and batch size is set to 2 while others are the same with classification task. To be noted, we didn’t quantize the head but applied block reconstruction to backbone and layer reconstruction to neck like BRECQ.
545
+
546
+ GLUE benchmark and SQuAD. The BERT fine-tuned models are taken from huggingface group (https://huggingface.co/). And we sampled 1024 examples from training set. We keep the maximum sequence length to be 128 for GLUE benchmark but maximum sequence length 384 with doc stride 128 for SQuAD1.1. Also, we quantize all the part in BERT as well as the internal structure of the attention module with only affirming the embedding weight to 8-bit. Other settings and hyperparameters are chosen in the same way with ImageNet experiments.
547
+
548
+ Baselines. We run baseline methods from open-source codes, such as AdaQuant, BRECQ and Adaround. And we try our best to align some optimal settings like per-channel quantization for fair comparisons.
md/dev/ztcfHweENtU/ztcfHweENtU.md ADDED
@@ -0,0 +1,759 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Distributive Justice as the Foundational Premise of Fair ML: Unification, Extension, and Interpretation of Group Fairness Metrics
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Group fairness metrics are an established way of assessing the fairness of prediction
11
+ 2 based decision-making systems. However, these metrics are still insufficiently
12
+ 3 linked to philosophical theories, and their moral meaning is often unclear. We
13
+ 4 propose a general framework for analyzing the fairness of decision systems based
14
+ 5 on theories of distributive justice, encompassing different established “patterns
15
+ 6 of justice” that correspond to different normative positions. We show that the
16
+ 7 most popular group fairness metrics can be interpreted as special cases of our
17
+ 8 approach. Thus, we provide a unifying and interpretative framework for group
18
+ 9 fairness metrics that reveals the normative choices associated with each of them
19
+ 10 and that allows understanding their moral substance. At the same time, we provide
20
+ 11 an extension of the space of possible fairness metrics beyond the ones currently
21
+ 12 discussed in the fair ML literature. Our framework also allows overcoming several
22
+ 13 limitations of group fairness metrics that have been criticized in the literature, most
23
+ 14 notably (1) that they are parity-based, i.e., that they demand some form of equality
24
+ 15 between groups, which may sometimes be harmful to marginalized groups, (2) that
25
+ 16 they only compare decisions across groups, but not the resulting consequences for
26
+ 17 these groups, and (3) that the full breadth of the distributive justice literature is not
27
+ 18 sufficiently represented.
28
+
29
+ # 19 1 Introduction
30
+
31
+ 20 Supervised machine learning (ML) is increasingly being used for prediction-based decision making
32
+ 21 in various consequential applications, such as credit lending, school admission, and recruitment.
33
+ 22 Recent work has shown that the use of algorithms for decision making can reinforce existing biases
34
+ 23 or introduce new ones [8]. Consequently, fairness has emerged as an important desideratum for
35
+ 24 automated decision making. As recent cases in practice have shown, this is crucial in order to mitigate
36
+ 25 unjustified disadvantages towards certain demographic groups (see, e.g., [2, 46, 21, 40]). However,
37
+ 26 quantifying the fairness of decision making systems is not straightforward as any morally appropriate
38
+ 27 notion of fairness heavily depends on the given context.
39
+ 28 Many different measures have emerged in the algorithmic fairness literature to assess and mitigate
40
+ 29 unfairness towards marginalized groups in decision making systems. Many of the proposed notions of
41
+ 30 fairness are in the category of so-called group fairness criteria [7], some of which are mathematically
42
+ 31 incompatible in practice Kleinberg et al. [32], Chouldechova [14]. Therefore, satisfying such a
43
+ 32 fairness criterion comes at the expense of not being able to satisfy others Kleinberg et al. [31], Wong
44
+ 33 [55]. AllMost existing group fairness criteria demand equality of a certain value between different
45
+ 34 socio-demographic groups [12]. However, our framework is also compatible with other notions of
46
+ 35 fairness that concern groups of individuals, such as preference-based fairness [56, 30]. However,
47
+ 36 this stands, which is in contrast to the comparison of individuals, as it is done with other types of
48
+ 37 fairness such as individual fairness [18, 52], envy-freeness [6] or counterfactual fairness Kusner
49
+ 38 et al. [34]. Readers unfamiliar with group fairness may refer to [38, Chapter 2], [53], and [7] for an
50
+ 39 overview of the topic. We briefly introduce and formally define the most-discussed group fairness
51
+ 40 criteria in Appendix A.
52
+ 41 Much of the algorithmic fairness literature evolves around a limited set of group fairness metrics
53
+ 42 and is often not clearly linked to the many philosophical theories of justice that have been well
54
+ 43 discussed. Kuppler et al. [33] find that there is little to no overlap between philosophical theories
55
+ 44 of justice and metrics in the algorithmic fairness literature and conclude that “apparently, the fair
56
+ 45 machine learning literature has not taken full advantage of the rich and longstanding literature on
57
+ 46 distributive justice” [33, p. 17]. Therefore, the definitions of group fairness could be described as
58
+ 47 quite narrow when viewed from a philosophical perspective. This becomes evident when thinking
59
+ 48 about an example: Group fairness metrics typically demand that groups are equal with respect to
60
+ 49 some metric. Demanding equality between groups often makes sense, but consider a case in which we
61
+ 50 could increase the utility of one group without harming another: Should we do this? While we cannot
62
+ 51 say that this is always a good idea, it at least seems to be a reasonable objection to group fairness
63
+ 52 metrics, which demand equality at all costs. Therefore, this paper asks whether group fairness metrics
64
+ 53 can be extended to compare groups in other ways.
65
+ 54 As of today, only a limited number of fairness metrics have been discussed, forcing stakeholders to
66
+ 55 choose between a set of pre-defined metrics that they then have to justify for their context. This paper,
67
+ 56 in contrast, presents a general framework for the derivation of targeted and context-specific fairness
68
+ 57 metrics, starting from values and moral views, and connects these to the philosophical literature, in
69
+ 58 particular to theories of distributive justice.
70
+
71
+ 59 Our main contributions can be summarized as follows:
72
+
73
+ 1. We propose a general framework for assessing the fairness of prediction-based decision systems, based on theories of distributive justice, and allowing for different established “patterns of justice” that correspond to different normative positions. The framework is based on an analysis of how utility is distributed between groups. “Pattern of justice” refers to normative ideas of what constitutes a just distribution.
74
+ 2. We show that the most popular group fairness metrics can be interpreted as special cases of this approach, which thus establishes a unifying framework that includes established metrics, but also shows how new ones can be constructed.
75
+
76
+ 68 We first present existing literature on group fairness (including its limitations) in Section 2. In
77
+ 69 Section 3, we present our unified framework for utility-based definitions of group fairness. We focus
78
+ 70 on the mathematical formalization of different aspects of the distributive justice literature while
79
+ 71 keeping the review of the philosophical side short. More details about the philosophical side can be
80
+ 72 found in the companion paper [3]. Section 4 then demonstrates that existing group fairness metrics
81
+ 73 are special cases of our utility-based approach. Finally, we discuss the implications of this and
82
+ 74 possible future work in Section 5.
83
+
84
+ # 75 2 Limitations of current group fairness criteria
85
+
86
+ 76 Existing group fairness criteria pursue an egalitarian approach. This means that they demand equality
87
+ 77 of a certain value between different socio-demographic groups [12]. The fulfillment of these criteria
88
+ 78 is easy to assess, as this only requires access to a few variables (e.g., to check whether statistical
89
+ 79 parity is satisfied, we only need the decisions and the group membership of individuals). However,
90
+ 80 they also come with several limitations:
91
+ 81 The "leveling down objection" As has been shown by [27], in some cases, enforcing group
92
+ 82 fairness criteria can yield worse results for all groups in order to ensure parity between the groups.
93
+ 83 This is what is known as the "leveling down objection", which is often brought forward to challenge
94
+ 84 egalitarianism in philosophical literature [41, 17]: In a case in which equality requires us to worsen
95
+ 85 the outcomes for everyone, should we really demand equality or should we rather tolerate some
96
+ 86 inequalities? As criticized by Cooper and Abrams [15], Weerts et al. [54], existing definitions of
97
+ 7 group fairness lack this differentiation as they always minimize inequality.
98
+ 88 No consideration of consequences As pointed out by Hertweck et al. [24] and Weerts et al. [54],
99
+ 89 a large part of the existing work on fairness criteria seems to focus on an equal distribution of
100
+ 90 favorable decisions and not on the consequences of these decisions. Binns [11] notes that these
101
+ 91 criteria "[assume] a uniform valuation of decision outcomes across different populations" [11, p. 6],
102
+ 92 and notes that this assumption does not always hold. Whether a loan approval has a positive effect on
103
+ 93 one’s life or not arguably depends on one’s ability to repay this loan (and possibly on other individual
104
+ 94 attributes). This narrow focus on the algorithm’s decisions instead of its consequences makes it
105
+ 95 difficult to use existing group fairness criteria for a moral assessment of unfairness in decision making
106
+ 96 systems. Parity-based criteria that only consider the decisions but not their consequences do not allow
107
+ 97 us to deliberately give positive decisions to a larger share of the disadvantaged group as this would
108
+ 98 be a form of unequal treatment. However, Kasy and Abebe [29] argue that in such a case, unequal
109
+ 99 treatment can be required by justice to reduce overall inequalities. Several works have therefore taken
110
+ 100 a utility-based view of fairness. Heidari et al. [22]’s utility-based definitions of fairness focus on the
111
+ 101 effects of decisions while [13] developed a method that follows the Rawlsian leximin principle to
112
+ 102 increase the welfare of the worse off groups. However, none of them provides a general framework
113
+ 103 that encompasses different theories of distributive justice.
114
+ 104 Limited set of fairness definitions Another limitation of existing group fairness criteria is that
115
+ 105 they represent a limited set of alternatives. One has to choose one over the others, as they are
116
+ 106 mathematically incompatible [32, 14]. [47, 28] have highlighted that the criteria differ with respect
117
+ 107 to underlying moral values. Thus, solely choosing one among the limited set of criteria might fail
118
+ 108 adequately represent a morally appropriate definition of fairness for a given context. Heidari et al.
119
+ 109 [23] show how existing group fairness criteria can be viewed as instantiations of the equality of
120
+ 110 opportunity (EOP) principle. Similarly, [10] show that they can be viewed as special cases of a
121
+ 111 more general principle of fairness they call fair equality of chances (FEC). This way, they provide a
122
+ 112 framework through which the existing fairness criteria can be viewed. However, the conditions under
123
+ 113 which the existing fairness criteria map to EOP (or to FEC, respectively) are not always given. We
124
+ 114 cannot expect every application to fall neatly into one of these conditions and thus cannot expect to
125
+ 115 find a fitting fairness criterion among the ones already proposed in the group fairness literature.
126
+ 116 These more general notions of fairness might be suitable to grasp the different existing notions of
127
+ 117 group fairness. However, they do not adequately represent the complexity of the distributive justice
128
+ 118 literature Kuppler et al. [33]. In this paper, we want to bridge the gap between fair machine learning
129
+ 119 and philosophical theories of distributive justice.
130
+
131
+ # 120 3 A framework for fairness evaluations based on distributive justice
132
+
133
+ 121 As discussed in Section 2, current group fairness criteria have some serious shortcomings. Clearly,
134
+ 122 they do not reflect the full breadth of the literature on distributive justice [33]. To address this issue
135
+ 123 (at least partially), we propose a utility-based extension of group fairness. This section introduces this
136
+ 124 approach from a rather technical perspective. More details on its links to the literature on distributive
137
+ 125 justice can be found in [3]. Our approach is based on the observation that each decision system
138
+ 126 creates a distribution of utility among individuals and groups. Theories of distributive justice are
139
+ 127 concerned with the question of when such a distribution can be considered just. As we will later
140
+ 128 show, some of these theories can be mapped to classical group fairness concepts from the fair ML
141
+ 129 literature (see Section 4).
142
+ 130 We consider a decision making system that takes binary decisions $D$ on decision subjects $D S$ of
143
+ 131 a given population $P$ , based on a decision rule $r$ . The decision rule assigns each individual $i \in P$
144
+ 132 a binary decision $d _ { i } \in \{ 0 , 1 \}$ , applying the decision rule to some input data, which includes an
145
+ 133 unknown but decision-relevant binary random variable $Y$ . It does not matter how the decision rule
146
+ 134 functions. It could, for example, be an automated rule that takes decisions based on predictions of $Y$
147
+ 135 from an ML model or the decisions could be made by humans. We further assume that at least two
148
+ 136 social groups are defined, denoted with different values for the sensitive attribute $A$ .
149
+ 138 As previously discussed, current definitions of group fairness only consider the decisions themselves,
150
+ 139 but not their consequences — even though the same decision could be beneficial for some and harmful
151
+ 140 for others [54]. Our approach explicitly considers the consequences of decisions, i.e., the resulting
152
+ 141 utility (or welfare), which could be positive in the case of a benefit or negative in the case of a harm.
153
+ 142 We model the consequences with a utility function $u$ which, in our binary context, may depend on
154
+ 143 both the decision $d _ { i }$ and the value $y _ { i }$ of $Y$ .
155
+
156
+ 144 The utility $u _ { D S , i }$ of a decision subject $i$ is given by:
157
+
158
+ $$
159
+ u _ { D S , i } = w _ { 1 1 } \cdot d _ { i } \cdot y _ { i } + w _ { 1 0 } \cdot d _ { i } \cdot ( 1 - y _ { i } ) + w _ { 0 1 } \cdot ( 1 - d _ { i } ) \cdot y _ { i } + w _ { 0 0 } \cdot ( 1 - d _ { i } ) \cdot ( 1 - y _ { i } ) ,
160
+ $$
161
+
162
+ 145 where the utility weights $w _ { d y }$ denote the four different utility values that might be realized for the four combinations of the random variables146 $Y$ and $D$ .1
163
+
164
+ 147 The utility $u _ { D S , i }$ is a realization of a random variable $U _ { D S }$ . For assessing the fairness of a decision
165
+ 148 rule, we are interested in systematic differences between groups. Our framework is based on the
166
+ 149 assumption that such differences correspond to differentThis means that we are interested in the
167
+ 150 expectation values $E ( U _ { D S } )$ of the individual utility, for different groups in $A$ . Note that this is
168
+ 151 a normative choice and that other ways of comparing groups are imaginable, e.g., comparing their
169
+ 152 aggregated utilities.
170
+
171
+ # 3.2 Relevant groups to compare
172
+
173
+ 154 Theories of distributive justice are typically concerned with individuals [48] while group fairness is
174
+ 155 concerned with socially salient groups. Group fairness focuses on comparisons of different groups
175
+ 156 as this is what theories of discrimination are concerned with [1]. This poses the question of how
176
+ 157 the comparison of individuals in distributive justice and the comparison of socially salient groups in
177
+ 158 group fairness can be combined? John Rawls’s concept of "relevant positions" [42, $\ S 1 6$ , pp. 81-86]
178
+ 159 is a concept that unites both ideas. We view "relevant positions" as the groups whose expected
179
+ 160 utility we want to compare and refer to them as the relevant groups (to compare).2 As defined in [3],
180
+ 161 relevant groups to compare have comparable moral claims3 to receive the same utility, but probably
181
+ 162 do not receive the same utility. Our approach thus views the theories of distributive justice, which we
182
+ 163 introduced in Section 2, from the perspective of relevant groups to compare.
183
+ 164 To be more specific, relevant groups are defined by two concepts: (1) claims differentiator $J$ : What
184
+ 165 makes it the case that some people have the same claims to utility while others have different claims
185
+ 166 to utility?; (2) causes of inequality (resulting in socially salient groups $A$ ): What are the most likely
186
+ 167 causes of inequalities?
187
+
188
+ As described in [3], the claims differentiator identifies people who have equal moral claims. In other words, the utility should be distributed equally between these people. This means we only consider people with equal claims for our fairness evaluation. 4 Within the group of all individuals that have equal claims to utility (i.e., that are equal in their value for $J$ ) we specify groups that are unlikely to end up receiving equal utility, on average, based on the known causes of inequality (i.e., that are different in their value for $A$ , which is sometimes also referred to as protected attribute). $J$ and $A$ define the relevant groups that group fairness criteria compare. For simplicity, we will assume that there are only two groups $A = \{ 0 , 1 \}$ that are unlikely to receive the same utility. It is, for example, common to expect individuals of a different race or gender to not derive the same utility from decision systems.
189
+
190
+ 178 In the next step, we want to compare the utilities of the relevant groups. Specifically, we will
191
+ 179 compare the expectation value of utility over all decisions made for a given population under a given
192
+ 180 a decision rule. We denote this as the expected utility that takes the relevant groups into account,
193
+ 181 $E ( U _ { D S } | J = j , A = a )$ , where $J$ denotes the claims differentiator and $j$ corresponds to a possible
194
+ 182 value of the variable $J$ , and $a \in A$ denotes the different socially salient group to be compared with
195
+ 183 each other. In our framework, assessing fairness means comparing relevant groups with the same $j$ ,
196
+ 184 but different $a$ , with respect to the distribution of utility.
197
+
198
+ # 185 3.3 Patterns for a just distribution of utility
199
+
200
+ 86 The claims differentiator $J$ tells us which individuals have equal moral claims to the utility distributed
201
+ 87 by the decision process. However, in some cases, an equal distribution of utility among the relevant
202
+ 88 groups (defined by $J$ and $A$ ) may not be the primary concern for justice (see below). Our approach
203
+ 89 offers different choices, which we refer to as patterns of justice. For each of them, we will briefly
204
+ 90 explain their normative view of what constitutes justice. For each pattern, we formulate a fairness
205
+ 1 constraint and a fairness metric: A fairness constraint is a mathematical formalization of a pattern
206
+ 92 of justice, which can either be satisfied or not. A fairness metric $F$ , on the other hand, can measure
207
+ 93 the degree to which this criterion is fulfilled. Note that we construct fairness metrics for a binary
208
+ 4 $A = { \bar { \{ 0 , 1 \} } }$ . Therefore, all patterns of justice that we present compare the expected utility of
209
+ 95 two relevant groups: $A = 0 \land J = j$ (i.e., $E ( U _ { D S } | J = j , A = 0 ) $ and $A = 1 \land J = j$ (i.e.,
210
+ 96 $E ( U _ { D S } | J = j , A = 1 )$ ). However, the patterns of justice that we introduce here (egalitarianism,
211
+ 7 maximin, prioritarianism, sufficientiarianism) can easily be translated to cases of more groups.
212
+
213
+ In the following, we introduce only a few patterns of justice (representing fairness principles for the allocation of goods) that are widely discussed in philosophical literature. However, our utility-based definition of group fairness should in no way be seen as limited to these patterns. Our approach can easily be extended to other patterns of justice and one may also implement their own pattern of justice. Our goal here is simply to highlight a few popular patterns of justice and how they can be embedded in our approach.
214
+
215
+ # 3.3.1 Egalitarianism
216
+
217
+ Egalitarianism – as the name suggests – demands equality [5]. Egalitarianism as a broad concept does not, however, specify what should be equalized. This is subject of the equality of what debate initiated by Sen [48]. One could, for example, aim to equalize the opportunities (equality of opportunity) or outcomes (equality of outcomes).
218
+
219
+ Fairness criterion The egalitarian fairness criterion is satisfied if the expected utility is equal for the relevant groups:
220
+
221
+ $$
222
+ E ( U _ { D S } | J = j , A = 0 ) = E ( U _ { D S } | J = j , A = 1 )
223
+ $$
224
+
225
+ 211 Fairness metric The degree to which egalitarianism is fulfilled is measured as the absolute difference between the two groups’ expected utilities (lower values are better):5212
226
+
227
+ $$
228
+ \begin{array} { r } { F _ { \mathrm { e g a l i t a r i a n i s m } } = | E ( U _ { D S } | J = j , A = 0 ) - E ( U _ { D S } | J = j , A = 1 ) | } \end{array}
229
+ $$
230
+
231
+ # 3.3.2 Maximin
232
+
233
+ Maximin describes the principle that among a set of possible distributions, the one that maximizes the expected utility of the relevant group that is worst-off should be chosen [35]. In contrast to egalitarianism, inequalities are thus tolerated if the worst-off group benefits from them. This has been defended by Rawls in the form of the "difference principle" [42, 43].
234
+
235
+ Fairness criterion The maximin fairness criterion is satisfied if there is no other possible distribu$U _ { D S } ^ { w o r s t - o f f } = m i n _ { a \in A } \bar { \biggl ( } E ( U _ { D S } | \bar { J } = j , A = a ) \biggr )$ the worst-off relevant group, which we. It thus requires that the decision rule $r ^ { \prime }$ note by(which
236
+
237
+ 2 than the 222 represents the decision taken for each individual) results in a U worst−of fDS (r′21 ) that is greater or equalworst−of f for any other decision rule from the set of all possible decision rules :
238
+
239
+ $$
240
+ U _ { D S } ^ { w o r s t - o f f } ( r ^ { \prime } ) \geq m a x _ { r \in R } \left( U _ { D S } ^ { w o r s t - o f f } ( r ) \right)
241
+ $$
242
+
243
+ 223 Fairness metric The degree to which maximin is fulfilled is measured as the value of the lowest
244
+ 224 expected utility between all relevant groups (higher values are better):
245
+
246
+ $$
247
+ F _ { \mathrm { m a x i m i n } } = m i n _ { a \in A } { \Big ( } E ( U _ { D S } | J = j , A = a ) { \Big ) }
248
+ $$
249
+
250
+ # 225 3.3.3 Prioritarianism
251
+
252
+ 226 Prioritarianism describes the principle that among a set of possible distributions, the one that maxi
253
+ 227 mizes the weighted sum of utilities across all people [26]. In contrast to egalitarianism, inequalities
254
+ 228 are thus tolerated if they increase this weighted sum of expected utilities. In this weighted sum, the
255
+ 229 expected utility of the worst-off relevant groups is given a higher weight (the maximin principle can
256
+ 230 be seen as the extreme version of this as an infinite weight is given to the worst-off relevant groups).
257
+ 231 Fairness criterion The prioritarian fairness criterion is satisfied if there is no other possible
258
+ 232 distribution that would lead to a greater overall expected utility, which is measured as a weighted
259
+ 233 aggregation of the relevant groups’ expected utilities, where the expected utility of the worst-off
260
+ 234 235 relevautility $\tilde { U } _ { D S } ( \bar { r ^ { \prime } } ) = k \cdot U _ { D S } ^ { w o r \bar { s } t - o f f } ( \bar { r ^ { \prime } } ) + U _ { D S } ^ { b e t t e r - \bar { o } f f } ( r ^ { \prime } )$ at the decthat is gre on rule er or eq $r ^ { \prime }$ results inl than the $\tilde { U } _ { D S } ( \boldsymbol { r } )$ ted for
261
+ 236 any other decision rule $r$ from the set of all possible decision rules $R$ :
262
+
263
+ $$
264
+ \tilde { U } _ { D S } ( \boldsymbol { r } ^ { \prime } ) \geq m a x _ { r \in R } \left( \tilde { U } _ { D S } ( \boldsymbol { r } ) \right) ,
265
+ $$
266
+
267
+ where 237 $\tilde { U } _ { D S }$ denotes the sum of decision subject utilities for all groups with a weight $k > 1$ applied to 238 the worst-off group.
268
+
269
+ 239 Fairness metric The degree to which prioritarianism is fulfilled is measured as an aggregate of the
270
+ 240 (weighted) expected utilities (higher values are better):
271
+
272
+ $$
273
+ \begin{array} { l } { F _ { \mathrm { p r i o n i t a r i a n i s m } } = k \cdot m i n \Big ( E ( U _ { D S } | J = j , A = 0 ) , E ( U _ { D S } | J = j , A = 1 ) \Big ) } \\ { \qquad + m a x \Big ( E ( U _ { D S } | J = j , A = 0 ) , E ( U _ { D S } | J = j , A = 1 ) \Big ) } \end{array}
274
+ $$
275
+
276
+ # 3.3.4 Sufficientarianism
277
+
278
+ Sufficientarianism [50] describes the principle that there is a minimum threshold of utility that should be reached by everyone in expectation. Inequalities between relevant groups above this minimum threshold are acceptable according to this principle. Inequalities are thus tolerated as long as all groups achieve a minimum level of utility in expectation.
279
+
280
+ 246 Fairness criterion The sufficientarian fairness criterion is satisfied if all groups’ expected utilities
281
+ 247 are above a given threshold $t$ :
282
+
283
+ $$
284
+ \forall a \in A \ E ( U _ { D S } | J = j , A = a ) ( r ^ { \prime } ) \geq t
285
+ $$
286
+
287
+ 248 Fairness metric The degree to which sufficientarianism is fulfilled is measured as the number of
288
+ 249 groups whose expected utility is above the given threshold $t$ (higher values are better):
289
+
290
+ $$
291
+ F _ { \mathrm { s u f f i c i e n t a r i a n i s m } } = \sum _ { a \in A } T _ { a } { \mathrm { , ~ w h e r e ~ } } T _ { a } = \left\{ { 1 , \mathrm { ~ i f ~ } } E ( U _ { D S } | J = j , A = a ) \geq t \right.
292
+ $$
293
+
294
+ Based on the mathematical framework outlined in this section, we suggest an extension of the current understanding of group fairness as described in Section 2. Instead of seeing group fairness as demanding equality between socio-demographic groups with respect to some value, we instead propose the following definition:
295
+
296
+ 55 Definition 1 (Group fairness). Group fairness is the just distribution of utility among relevant groups.
297
+
298
+ What makes a distribution just depends on the pattern of justice. Thus, our extended understanding of group fairness does not necessarily require equal expected utilities across groups. Furthermore, our definition ensures that only relevant groups are being compared (in the most familiar case, these correspond to socio-demographic groups).
299
+
300
+ Group fairness criteria, in our sense, specify when group fairness is satisfied by a decision-making system. From this, it follows that there are more group fairness criteria than previously acknowledged. This extension of group fairness criteria alleviates some of the criticisms of currently popular group fairness criteria as we will show in Section 5.
301
+
302
+ # 264 4 Relation to existing group fairness criteria
303
+
304
+ 265 Existing group fairness criteria are special cases of the utility-based extension we propose. In this
305
+ 266 section, we formally show under which conditions our approach maps to existing group fairness
306
+ 267 criteria (see Table 1 for a summary of the results). In particular, we look at well-known group
307
+ 268 fairness criteria: (conditional) statistical parity, equality of opportunity, false positive rate (FPR)
308
+ 269 parity, equalized odds, predictive parity, false omission rate (FOR) parity, and sufficiency. The
309
+ 270 mathematical definitions of these criteria can be found in Table 2 in Appendix A. Furthermore, we
310
+ 271 show how the utility-based group fairness metrics relate to existing ones. In this section, we only
311
+ 272 demonstrate when our utility-based approach results in one of three often discussed group fairness
312
+ 273 criteria: statistical parity, equality of opportunity, and predictive parity. We refer the interested reader
313
+ 274 to the Appendix B.2 where we provide a similar mapping for other existing group fairness criteria.
314
+ 275 The findings we present in this section extend the ones of [23], [36], and [10]. While [23] consider
315
+ 276 the distribution of undeserved utility (what they call the difference between an individual’s actual and
316
+ 277 effort-based utility), [36] and [10] use the decision subject utility $U _ { D S }$ to derive a morally appropriate
317
+ 278 group fairness definition. This is similar to our approach presented in this paper; however, they only
318
+ 279 consider two options $U _ { D S } = D$ and $U _ { D S } = Y$ , while our approach allows for arbitrary functions $f$
319
+ 280 for the utility: $U _ { D S } = f ( D , Y )$ .
320
+
321
+ Statistical parity (also called demographic parity or group fairness [18]) is defined as $P ( D = 1 | A =$ $0 ) = \bar { P ( \bar { D = } 1 | A = 1 ) }$ . For specific decision subject utility weights $w _ { d y }$ and without any claims differentiator $J$ , the condition of our utility-based fairness criteria derived from our framework is equivalent to statistical parity:
322
+
323
+ Proposition 2 (Statistical parity as utility-based fairness). If the utility weights of all possible outcomes (as described in Section 3.1) do not depend on the group membership $( w _ { d y } \perp a )$ , and $w _ { 1 1 } = w _ { 1 0 } \ne w _ { 0 1 } = w _ { 0 0 }$ , then the egalitarian pattern fairness condition with $J = \emptyset$ is equivalent to statistical parity.
324
+
325
+ The formal proof of Proposition 2 can be found in Appendix B.1.1.
326
+
327
+ We use ${ w _ { 1 y } } ^ { 6 }$ to denote the decision subject utility associated with a positive decision ( $D = 1$ ) and $w _ { 0 y }$ to denote the decision subject utility associated with a negative decision $\simeq 0$ ). As we showed above, requiring statistical parity can be equivalent to requiring the fulfillment of a utility-based group fairness criterion. However, even if the two criteria are equivalent, this is not necessarily true if we compare the group fairness metrics that specify the degree to which these two criteria are fulfilled, i.e., if we compare the degree to which statistical parity is fulfilled with the degree to which a utility-based fairness metric is fulfilled:
328
+
329
+ 297 Corollary 3 (Partial fulfillment of statistical parity in terms of utility-based fairness). Suppose that
330
+ 298 the degree to which statistical parity is fulfilled is defined as the absolute difference in decision ratios
331
+ 299 across groups, i.e., $| P ( D = \bar { 1 } | A = 0 ) - P ( D = 1 | A = 1 ) |$ . If the utility weights of all possible
332
+ 300 outcomes do not depend on the group membership $( w _ { d y } \perp a )$ , and $w _ { 1 1 } = w _ { 1 0 } \neq w _ { 0 1 } = w _ { 0 0 }$ (i.e.,
333
+ 301 $w _ { 1 y } \ne w _ { 0 y } ,$ ), and $J = \emptyset$ , then the degree to which egalitarianism is fulfilled is equivalent to the
334
+ 302 degree to which statistical parity is fulfilled, multiplied by $| w _ { 1 y } - w _ { 0 y } |$ .
335
+ 303 The formal proof of Corollary 3 can be found in Appendix B.1.2. Intuitively, $F _ { \mathrm { e g a l i t a r i a n i s m } }$ , which is
336
+ 304 derived from the utility-based fairness approach and represents the degree to which egalitarianism is
337
+ 305 fulfilled, can be seen as the degree to which statistical parity is fulfilled, weighted by the absolute
338
+ 306 difference in utility for the decision received (decision subject utility for a positive versus a negative
339
+ 307 decision).
340
+
341
+ Equality of opportunity (also called TPR parity) is defined as $P ( D = 1 | Y = 1 , A = 0 ) = P ( D =$ $1 | Y = 1 , A = 1 )$ , i.e., it requires parity of true positive rates (TPR) across groups $a \in A$ [20].
342
+
343
+ Proposition 4 (Equality of opportunity as utility-based fairness). If $w _ { 1 1 }$ and $w _ { 0 1 }$ do not depend on the group membership $( w _ { d 1 } \perp a )$ , and $w _ { 1 1 } \neq w _ { 0 1 }$ , then the egalitarian pattern fairness condition with $J = Y$ and $j = \{ 1 \}$ is equivalent to equality of opportunity.
344
+
345
+ 313 The formal proof of Proposition 4 can be found in Appendix B.1.3. Compared to statistical parity,
346
+ 314 equality of opportunity only requires equal acceptance rates across those subgroups of $A$ who are
347
+ 315 of type $Y = 1$ . This corresponds to the claims differentiator $j = \{ 1 \}$ for $J = Y$ . Thus, we simply
348
+ 316 require the utility weights $w _ { 1 1 }$ and $w _ { 0 1 }$ to be unequal and independent of $a$ (which means that the
349
+ 317 utility weights $w _ { 1 1 }$ and $w _ { 0 1 }$ are constant across groups). As is the case for statistical parity, there are
350
+ 318 differences when looking at the degree to which the two notions of fairness are fulfilled (equality of
351
+ 319 opportunity and the utility-based fairness under the conditions specified in Proposition 4):
352
+
353
+ Corollary 5 (Partial fulfillment of equality of opportunity in terms of utility-based fairness). Suppose that the degree to which equality of opportunity is fulfilled is defined as the absolute difference in decision ratios for individuals of type $Y = 1$ across groups, i.e., $| P ( D = 1 | Y = 1 , A = 0 ) - P ( D =$ $1 | Y = 1 , A = 1 )$ |. If $w _ { 1 1 }$ and $w _ { 0 1 }$ do not depend on the group membership $( w _ { d 1 } \perp a )$ , $w _ { 1 1 } \neq w _ { 0 1 }$ , $J = Y$ , and $j = \{ 1 \}$ , then the degree to which egalitarianism is fulfilled is equivalent to the degree to which equality of opportunity is fulfilled, multiplied by $\left| \left( w _ { 1 1 } - w _ { 0 1 } \right) \right|$ .
354
+
355
+ 26 The formal proof of Corollary 5 can be found in Appendix B.1.4.
356
+
357
+ Predictive parity (also called PPV parity [9] or outcome test [51]) is defined as $P ( Y = 1 | D = 1 , A =$ $0 ) = P ( \overset { \cdot } { Y } = \overset { \cdot } { 1 } | D = 1 , A = 1 )$ , i.e., it requires parity of positive predictive value (PPV) rates across groups $a \in A$ .
358
+
359
+ Proposition 6 (Predictive parity as utility-based fairness). If $w _ { 1 1 }$ and $w _ { 1 0 }$ do not depend on the group membership $( w _ { 1 y } \perp a )$ , and $w _ { 1 1 } \neq w _ { 1 0 }$ , then the egalitarian pattern fairness condition with $J = D$ and $j = \{ 1 \}$ is equivalent to predictive parity.
360
+
361
+ 333 The formal proof of Proposition 6 can be found in Appendix B.1.5. Compared to equality of
362
+ 334 opportunity, predictive parity requires an equal share of individuals to be of type $Y = 1$ among
363
+ 335 those subgroups of $A$ who receive the decision $D = 1$ . This corresponds to the claims differentiator
364
+ 336 $j = \{ 1 \}$ for $J = D$ . Thus, we simply require the utility weights $w _ { 1 1 }$ and $w _ { 1 0 }$ to be unequal and
365
+ 337 independent of $a$ . As is the case for the other group fairness criteria, there are differences regarding
366
+ 338 the degree to which the two notions of fairness are fulfilled (predictive parity and the utility-based
367
+ 339 fairness under the conditions specified in Proposition 6):
368
+ 340 Corollary 7 (Partial fulfillment of predictive parity in terms of utility-based fairness). Suppose that
369
+ 341 the degree to which predictive parity is fulfilled is defined as the absolute difference in the ratio of
370
+ 342 individuals that are of type $Y = 1$ among all those that are assigned the decision $D = 1$ across
371
+ 343 groups, i.e., $| P ( Y = 1 | \bar { D } = 1 , A = 0 ) - \bar { P } ( Y = 1 | D = 1 , A = 1 \bar { ) } |$ . If $w _ { 1 1 }$ and $w _ { 1 0 }$ do not depend
372
+ 344 on the group membership $( w _ { 1 y } \perp a )$ , $w _ { 1 1 } \neq w _ { 1 0 }$ , $J = D$ , and $j = \{ 1 \}$ , then the degree to which
373
+ 345 egalitarianism is fulfilled is equivalent to the degree to which predictive parity is fulfilled, multiplied
374
+ 346 by $| w _ { 1 1 } - w _ { 1 0 } |$ .
375
+
376
+ 47 The formal proof of Corollary 7 can be found in Appendix B.1.6.
377
+
378
+ 348 Considering Table 1, we see that existing group fairness criteria have a narrow understanding of utility
379
+ 349 and do not tolerate inequalities, which can ultimately be harmful to already marginalized groups as
380
+ 350 previous work has shown [27]. Moreover, existing group fairness criteria embed assumptions about
381
+ 351 who has equal or different moral claims to utility. If we were to, for example, demand equalized
382
+ 352 odds for credit lending (where $D$ is the bank’s decision to either approve a loan $D = 1$ ) or reject it
383
+ 353 $D = 0$ ), and $Y$ is the loan applicant’s ability to repay the loan $\ N = 1$ ) or not $( Y = 0 )$ ), we would
384
+ 354 make the following assumptions: People who are different in their ability to repay their loans have
385
+ 355 different claims to utility. We must thus equalize the expected utilities between people who are able
386
+ 356 to repay their loans and we must also equalize the expected utilities between people who are not
387
+ 357 able to repay their loans. However, the assumptions listed in Table 1 may not be met for all decision
388
+ 358 making systems. Our utility-based extension is thus necessary to implement other views of justice.
389
+
390
+ Table 1: Mapping of existing group fairness metrics to our utility-based approach under Egalitarianism
391
+
392
+ <table><tr><td rowspan=1 colspan=4>Conditions</td><td rowspan=1 colspan=1>Equivalent fairness criterion</td></tr><tr><td rowspan=1 colspan=1>UDs weights (for groups a ∈ {0,1})</td><td rowspan=1 colspan=1>J</td><td rowspan=1 colspan=2>1</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>W11 = w1o ≠ wo1 = woo ∧ wdy ⊥a</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=2>-</td><td rowspan=1 colspan=1>Statistical parity</td></tr><tr><td rowspan=1 colspan=1>W11 = W10 ≠ wo1 = Woo ∧ wdy ⊥a</td><td rowspan=1 colspan=1>L</td><td rowspan=1 colspan=2>1</td><td rowspan=1 colspan=1>Conditional statistical parity</td></tr><tr><td rowspan=1 colspan=1>W11≠woi ∧ wdi⊥a</td><td rowspan=1 colspan=1>Y</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>①</td><td rowspan=1 colspan=1>Equality of opportunity</td></tr><tr><td rowspan=1 colspan=1>W10woo ∧wdo⊥a</td><td rowspan=1 colspan=1>Y</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>False positive rate parity</td></tr><tr><td rowspan=1 colspan=1>W11 ≠wo1∧w1o ≠ woo A Wdy ⊥a</td><td rowspan=1 colspan=1>Y</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>{0,1}</td><td rowspan=1 colspan=1>Equalized odds</td></tr><tr><td rowspan=1 colspan=1>W11≠w1o Aw1y⊥a</td><td rowspan=1 colspan=1>D</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>①</td><td rowspan=1 colspan=1>Predictive parity</td></tr><tr><td rowspan=1 colspan=1>W01 ≠ woo ∧ woy ⊥a</td><td rowspan=1 colspan=1>D</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>False omission rate parity</td></tr><tr><td rowspan=1 colspan=1>W11≠ w1o ∧ wo1 woo ∧ wdy ⊥a</td><td rowspan=1 colspan=1>D</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>{0,1}</td><td rowspan=1 colspan=1>Sufficiency</td></tr></table>
393
+
394
+ # 359 5 Discussion
395
+
396
+ As we have seen, existing group fairness criteria are special cases of our utility-based approach. This approach addresses several of the limitations of existing group fairness criteria that we discussed in Section 2.
397
+
398
+ 363 The "leveling down objection" The "leveling down objection" is a prevalent anti-egalitarianism
399
+ 364 argument [41, 17] saying that less inequality is not desirable if this requires lowering the better-off
400
+ 365 group’s welfare to match the one of the worse-off group. On this basis, choosing egalitarianism as the
401
+ 366 pattern of justice has been criticized in the algorithmic fairness literature (see, e.g., [36, 27, 54]). Our
402
+ 367 approach allows using other patterns of justice, such as maximin, prioritarianism, or sufficientarianism
403
+ 368 (see Section 3.3). Other patterns that can be formalized as mathematical formulas may also be used.
404
+ 369 One could, for example, combine several patterns into one and require equal expected utilities across
405
+ 370 groups as long as none of the groups is better off than it would be without any fairness requirement.
406
+ 371 This would represent a combination of egalitarianism and a group-specific baseline threshold (similar
407
+ 372 to sufficientarianism), making a "leveling down" of the better-off group impossible and adhering
408
+ 373 to the Pareto principle. Therefore, our approach links group fairness to a much larger part of the
409
+ 374 literature on distributive justice than current group fairness criteria.
410
+ 375 No consideration of consequences Existing group fairness criteria only consider the distribution
411
+ 376 of either $D$ or $Y$ . This could be interpreted as analyzing the distribution of utility but assuming
412
+ 377 that utility is equivalent to either $D$ or $Y$ instead of, for example, the combination of $D$ and $Y$ .
413
+ 378 Existing group fairness criteria thus represent a very confining definition of utility. Our approach
414
+ 379 acknowledges that the utility of the decision subjects does not only depend on the decision itself but
415
+ 380 also on other attributes such as one’s ability to repay a loan or one’s socioeconomic status (see, e.g.,
416
+ 381 [24, 54, 11]. This is represented through the utility function described in Section 3.1.
417
+ 382 Limited set of fairness definitions Previous attempts to guide stakeholders in choosing appropriate
418
+ 383 fairness criteria have taken on the form of explicit rules, such as in [45, 37, 44]. Such rules, however,
419
+ 384 presuppose a limited set of fairness definitions between which stakeholders can choose. Instead,
420
+ 385 we provide a method to construct ad-hoc fairness criteria that reflect the values decided on by the
421
+ 386 stakeholders by combining the definition of the utility function for decision subjects (Section 3.1), the
422
+ 387 relevant groups to compare (Section 3.2) and the pattern for a just distribution of utility (Section 3.3).
423
+ 388 Many important questions remain and may be the subject of future research: What are relevant trade
424
+ 389 offs when imposing utility-based group fairness criteria as requirements? Optimal decision rules for
425
+ 390 existing group fairness criteria have been derived by [20, 16, 9] – do they change for the fairness
426
+ 391 criteria defined by our approach? Further, while our approach creates a link between group fairness
427
+ 392 and different theories of justice, it does not cover theories of distributive justice that are structurally
428
+ 393 different from the ones we discussed, e.g., Nozick’s entitlement theory [39]. It is unclear how such
429
+ 394 theories could be represented in formalized fairness criteria. Moreover, there is a risk that decision
430
+ 395 makers simply use our approach to bluewash their decision making system, which they may claim
431
+ 396 to be "fair" and "unbiased" after coming up with a fairness criterion that neatly fits their own goals.
432
+ 397 This is an issue with other fairness criteria as well. Therefore, it is important to make the process
433
+ 398 of defining fairness criteria accessible to the public, so that decision subjects can get involved and
434
+ 399 hold decision makers accountable. This raises the question: with utility functions being notoriously
435
+ 400 hard to define [49, 19], how could our approach be accessible enough for practical use? What may
436
+ 401 be needed is a process for eliciting values from stakeholders. One may object that this makes group
437
+ 402 fairness criteria similarly difficult to implement as individual fairness and counterfactual fairness.
438
+ 403 Our response to this is that existing group fairness criteria might seem easier to use, but they still
439
+ 404 embed values and assumptions about the context in which they are used. Our approach helps to make
440
+ 405 these assumptions explicit.
441
+
442
+ 406 References [1] Andrew Altman. 2020. Discrimination. In The Stanford Encyclopedia of Philosophy (Winter 2020 ed.), Edward N. Zalta (Ed.). Metaphysics Research Lab, Stanford University. [2] Julia Angwin, Jeff Larson, Surya Mattu, and Lauren Kirchner. 2016. Machine Bias. ProPublica (2016). https://www.propublica.org/article/machine-bias-risk-assessmentsin-criminal-sentencing [3] Anonymous. 2022. A Justice-Based Framework for the Analysis of Algorithmic Fairness-Utility Trade-Offs. (2022). Unpublished manuscript. [4] Anonymous. 2022. Representative Individuals. (2022). Unpublished manuscript. [5] Richard Arneson. 2013. Egalitarianism. In The Stanford Encyclopedia of Philosophy (Summer 2013 ed.), Edward N. Zalta (Ed.). Metaphysics Research Lab, Stanford University. [6] Maria-Florina F Balcan, Travis Dick, Ritesh Noothigattu, and Ariel D Procaccia. 2019. Envy-Free Classification. In Advances in Neural Information Processing Systems, H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (Eds.), Vol. 32. Curran Associates, Inc. https://proceedings.neurips.cc/paper/2019/file/ e94550c93cd70fe748e6982b3439ad3b-Paper.pdf [7] Solon Barocas, Moritz Hardt, and Arvind Narayanan. 2020. Fairness and Machine Learning. http://fairmlbook.org Incomplete Working Draft. [8] Solon Barocas and Andrew D Selbst. 2016. Big Data’s Disparate Impact. California Law Review 104, 3 (2016), 671–732. http://www.jstor.org/stable/24758720 [9] Joachim Baumann, Anikó Hannák, and Christoph Heitz. 2022. Enforcing Group Fairness in Algorithmic Decision Making: Utility Maximization Under Sufficiency. In Proceedings of the 2022 ACM Conference on Fairness, Accountability, and Transparency (FAccT ’22). Association for Computing Machinery, New York, NY, USA. https://doi.org/10.1145/3531146. 3534645 [10] Joachim Baumann and Christoph Heitz. 2022. Group Fairness in Prediction-Based Decision Making: From Moral Assessment to Implementation. In 2022 9th Swiss Conference on Data Science (forthcoming). [11] Reuben Binns. 2018. Fairness in Machine Learning: Lessons from Political Philosophy. In Proceedings of the 1st Conference on Fairness, Accountability and Transparency (Proceedings of Machine Learning Research, Vol. 81), Sorelle A. Friedler and Christo Wilson (Eds.). PMLR, New York, NY, USA, 149–159. http://proceedings.mlr.press/v81/binns18a.html [12] Reuben Binns. 2020. On the apparent conflict between individual and group fairness. In Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency. 514–524. [13] Violet Xinying Chen and JN Hooker. 2022. Combining leximax fairness and efficiency in a mathematical programming model. European Journal of Operational Research 299, 1 (2022), 235–248. [14] Alexandra Chouldechova. 2017. Fair prediction with disparate impact: A study of bias in recidivism prediction instruments. Big data 5, 2 (2017), 153–163. [15] A. Feder Cooper and Ellen Abrams. 2021. Emergent Unfairness in Algorithmic FairnessAccuracy Trade-Off Research. In Proceedings of the 2021 AAAI/ACM Conference on AI, Ethics, and Society (Virtual Event, USA) (AIES ’21). Association for Computing Machinery, New York, NY, USA, 46–54. https://doi.org/10.1145/3461702.3462519 [16] Sam Corbett-Davies, Emma Pierson, Avi Feller, Sharad Goel, and Aziz Huq. 2017. Algorithmic decision making and the cost of fairness. In Proceedings of the 23rd acm sigkdd international conference on knowledge discovery and data mining. 797–806. [17] Roger Crisp. 2003. Equality, Priority, and Compassion. 113, 4 (2003), 745–763. https: //doi.org/10.1086/373954
443
+
444
+ 454 [18] Cynthia Dwork, Moritz Hardt, Toniann Pitassi, Omer Reingold, and Richard Zemel. 2012. Fairness through awareness. In Proceedings of the 3rd innovations in theoretical computer science conference. 214–226.
445
+
446
+ [19] Charles Elkan. 2001. The Foundations of Cost-Sensitive Learning. In Proceedings of the 17th International Joint Conference on Artificial Intelligence - Volume 2 (IJCAI’01). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 973–978.
447
+ [20] Moritz Hardt, Eric Price, and Nathan Srebro. 2016. Equality of opportunity in supervised learning. arXiv preprint arXiv:1610.02413 (2016).
448
+ [21] Elisa Harlan and Oliver Schnuck. 2021. Objective or biased: On the questionable use of Artificial Intelligence for job applications. Bayerischer Rundfunk (BR) (2021). https: //interaktiv.br.de/ki-bewerbung/en/
449
+ [22] Hoda Heidari, Claudio Ferrari, Krishna Gummadi, and Andreas Krause. 2018. Fairness behind a veil of ignorance: A welfare analysis for automated decision making. Advances in Neural Information Processing Systems 31 (2018).
450
+ [23] Hoda Heidari, Michele Loi, Krishna P Gummadi, and Andreas Krause. 2019. A moral framework for understanding fair ML through economic models of equality of opportunity. In Proceedings of the Conference on Fairness, Accountability, and Transparency. 181–190.
451
+ [24] Corinna Hertweck, Christoph Heitz, and Michele Loi. 2021. On the Moral Justification of Statistical Parity. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency (Virtual Event, Canada) (FAccT ’21). Association for Computing Machinery, New York, NY, USA, 747–757. https://doi.org/10.1145/3442188.3445936
452
+ [25] Sune Holm. 2022. The Fairness in Algorithmic Fairness. Res Publica (2022), 1–17.
453
+ [26] Nils Holtug. 2017. Prioritarianism. In Oxford Research Encyclopedia of Politics.
454
+ [27] Lily Hu and Yiling Chen. 2020. Fair classification and social welfare. In Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency. 535–545.
455
+ [28] Abigail Z Jacobs and Hanna Wallach. 2021. Measurement and fairness. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency. 375–385.
456
+ [29] Maximilian Kasy and Rediet Abebe. 2021. Fairness, equality, and power in algorithmic decision-making. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency. 576–586.
457
+ [30] Michael P. Kim, Aleksandra Korolova, Guy N. Rothblum, and Gal Yona. 2019. PreferenceInformed Fairness. CoRR abs/1904.01793 (2019). arXiv:1904.01793 http://arxiv.org/ abs/1904.01793
458
+ [31] Jon Kleinberg, Jens Ludwig, Sendhil Mullainathan, and Cass R Sunstein. 2019. Discrimination in the Age of Algorithms. Journal of Legal Analysis 10 (2019), 113–174. https://doi.org/ 10.1093/jla/laz001
459
+ [32] Jon Kleinberg, Sendhil Mullainathan, and Manish Raghavan. 2016. Inherent trade-offs in the fair determination of risk scores. arXiv preprint arXiv:1609.05807 (2016).
460
+ [33] Matthias Kuppler, Christoph Kern, Ruben L. Bach, and Frauke Kreuter. 2021. Distributive Justice and Fairness Metrics in Automated Decision-making: How Much Overlap Is There? arXiv:2105.01441 [stat.ML]
461
+ [34] Matt J Kusner, Joshua R Loftus, Chris Russell, and Ricardo Silva. 2017. Counterfactual fairness. arXiv preprint arXiv:1703.06856 (2017).
462
+ [35] Christian List. 2022. Social Choice Theory. In The Stanford Encyclopedia of Philosophy (Spring 2022 ed.), Edward N. Zalta (Ed.). Metaphysics Research Lab, Stanford University.
463
+ [36] Michele Loi, Anders Herlitz, and Hoda Heidari. 2019. A Philosophical Theory of Fairness for Prediction-Based Decisions. Available at SSRN 3450300 (2019).
464
+ 501 [37] Karima Makhlouf, Sami Zhioua, and Catuscia Palamidessi. 2021. On the Applicability of Machine Learning Fairness Notions. SIGKDD Explor. Newsl. 23, 1 (may 2021), 14–23. https: //doi.org/10.1145/3468507.3468511 [38] Arvind Narayanan. 2018. Translation tutorial: 21 fairness definitions and their politics. In Conference on Fairness, Accountability and Transparency. [39] Robert Nozick. 1974. Anarchy, state, and utopia. Vol. 5038. new york: Basic Books. [40] Ziad Obermeyer, Brian Powers, Christine Vogeli, and Sendhil Mullainathan. 2019. Dissecting racial bias in an algorithm used to manage the health of populations. Science 366, 6464 (2019), 447–453.
465
+ 510 [41] Derek Parfit. 1995. Equality or priority. Department of Philosophy, University of Kansas.
466
+ 511 [42] John Rawls. 1999. A Theory of Justice (2 ed.). Harvard University Press, Cambridge, Massachussets. [43] John Rawls. 2001. Justice as fairness: A restatement. Harvard University Press.
467
+ 514 [44] Boris Ruf and Marcin Detyniecki. 2022. A Tool Bundle for AI Fairness in Practice. In CHI Conference on Human Factors in Computing Systems Extended Abstracts. 1–3. [45] Pedro Saleiro, Benedict Kuester, Loren Hinkson, Jesse London, Abby Stevens, Ari Anisfeld, Kit T Rodolfa, and Rayid Ghani. 2018. Aequitas: A bias and fairness audit toolkit. arXiv preprint arXiv:1811.05577 (2018). [46] Aaron Sankin, Dhruv Mehrotra, Surya Mattu, and Annie Gilbertson. 2021. Crime Prediction Software Promised to Be Free of Biases. New Data Shows It Perpetuates Them. The Markup (2021). https://themarkup.org/prediction-bias/2021/12/02/crimeprediction-software-promised-to-be-free-of-biases-new-data-shows-itperpetuates-them [47] Andrew D Selbst, Danah Boyd, Sorelle A Friedler, Suresh Venkatasubramanian, and Janet Vertesi. 2019. Fairness and abstraction in sociotechnical systems. In Proceedings of the conference on fairness, accountability, and transparency. 59–68.
468
+ 527 [48] Amartya Sen. 1980. Equality of what? The Tanner lecture on human values 1 (1980), 197–220.
469
+ 528 [49] Amartya Sen. 1985. The Standard of Living. The Tanner lecture on human values (1985). https://tannerlectures.utah.edu/_resources/documents/a-to-z/s/sen86.pdf [50] Liam Shields. 2020. Sufficientarianism. Philosophy Compass 15, 11 (2020), e12704. https: //doi.org/10.1111/phc3.12704 [51] Camelia Simoiu, Sam Corbett-Davies, Sharad Goel, et al. 2017. The problem of inframarginality in outcome tests for discrimination. The Annals of Applied Statistics 11, 3 (2017), 1193–1216. [52] Till Speicher, Hoda Heidari, Nina Grgic-Hlaca, Krishna P. Gummadi, Adish Singla, Adrian Weller, and Muhammad Bilal Zafar. 2018. A Unified Approach to Quantifying Algorithmic Unfairness: Measuring Individual & Group Unfairness via Inequality Indices. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (London, United Kingdom) (KDD ’18). Association for Computing Machinery, New York, NY, USA, 2239–2248. https://doi.org/10.1145/3219819.3220046 [53] Sahil Verma and Julia Rubin. 2018. Fairness definitions explained. In 2018 ieee/acm international workshop on software fairness (fairware). IEEE, 1–7. [54] Hilde Weerts, Lambèr Royakkers, and Mykola Pechenizkiy. 2022. Does the End Justify the Means? On the Moral Justification of Fairness-Aware Machine Learning. arXiv preprint arXiv:2202.08536 (2022). [55] Pak-Hang Wong. 2020. Democratizing Algorithmic Fairness. Philosophy & Technology 33, 2 (2020), 225–244. https://doi.org/10.1007/s13347-019-00355-w
470
+
471
+ [56] Muhammad Bilal Zafar, Isabel Valera, Manuel Gomez Rodriguez, Krishna P. Gummadi, and Adrian Weller. 2017. From Parity to Preference-Based Notions of Fairness in Classification. In Proceedings of the 31st International Conference on Neural Information Processing Systems (Long Beach, California, USA) (NIPS’17). Curran Associates Inc., Red Hook, NY, USA, 228–238.
472
+
473
+ # Checklist
474
+
475
+ 1. For all authors...
476
+
477
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
478
+ (b) Did you describe the limitations of your work? [Yes] The limitations are described in Section 5
479
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] The potential negative effect of decision makers misusing our approach for bluewashing is briefly discussed in Section 5. However, it should be noted that this is a potential negative effect of all approaches to measuring fairness.
480
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
481
+
482
+ 2. If you are including theoretical results...
483
+
484
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Sections 3, 4, and B. (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix B.
485
+
486
+ 3. If you ran experiments...
487
+
488
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [N/A]
489
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A]
490
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
491
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [N/A]
492
+
493
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
494
+
495
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
496
+ (b) Did you mention the license of the assets? [N/A]
497
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
498
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
499
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
500
+
501
+ 5. If you used crowdsourcing or conducted research with human subjects...
502
+
503
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
504
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
505
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
506
+
507
+ # 94 A Existing group fairness criteria
508
+
509
+ 595 Here, we briefly introduce the most discussed group fairness criteria. Table 2 list the parity require
510
+ 596 ments associated with these criteria. Statistical parity demands that the share of positive decisions
511
+ 597 is equal between socio-demographic groups (defined by the sensitive attribute $A = \{ 0 , 1 \}$ ) [18] –
512
+ 598 this is only required for a set of so-called legitimate attributes $l \in L$ for the criterion conditional
513
+ 599 statistical parity [16]. Equality of opportunity, similarly, demands equal shares of positive decisions
514
+ 600 between socio-demographic groups, but only for those whose target variable is positive $( Y = 1$ ) [20]
515
+ 601 – thus, it is sometimes also referred to as true positive rate (TPR) parity. Equalized odds – sometimes
516
+ 602 also called separation – requires both equality of opportunity and FPR parity (which is similar to
517
+ 603 equality of opportunity, however, it is limited to individuals of type $Y = 0$ ). In contrast, predictive
518
+ 604 parity demands equal shares of individuals of type $Y = 1$ across socio-demographic groups, but only
519
+ 605 for those who received a positive decision $D = 1$ – thus, it is sometimes also referred to as positive
520
+ 606 predictive value (PPV) parity. Sufficiency requires both PPV parity and false omission rate (FOR)
521
+ 607 parity (which is similar to PPV parity, however, it is limited to individuals who received a negative
522
+ 608 decision $D = 0$ ).
523
+
524
+ Table 2: Existing group fairness metrics
525
+
526
+ <table><tr><td rowspan=1 colspan=1>Fairness criterion</td><td rowspan=1 colspan=4>Parityrequirement</td></tr><tr><td rowspan=1 colspan=1>Statistical parity</td><td rowspan=1 colspan=1>P(D=1</td><td rowspan=1 colspan=2>P(D=1A=0)=P(D=1A=1)</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>Conditional statistical parity</td><td rowspan=1 colspan=1>P(D=1</td><td rowspan=1 colspan=2>L=l,A=O)=P(D=1</td><td rowspan=1 colspan=1>L=l,A=1)</td></tr><tr><td rowspan=1 colspan=1>Equalityof opportunity</td><td rowspan=1 colspan=1>P(D=1</td><td rowspan=1 colspan=1>Y=1,A=0</td><td rowspan=1 colspan=1>=P(D=1</td><td rowspan=1 colspan=1>Y=1,A=1)</td></tr><tr><td rowspan=1 colspan=1>False positive rate parity</td><td rowspan=1 colspan=1>P(D=1</td><td rowspan=1 colspan=1>Y=0,A=0</td><td rowspan=1 colspan=1>=P(D=1</td><td rowspan=1 colspan=1>Y=0,A=1)</td></tr><tr><td rowspan=1 colspan=1>Equalized odds</td><td rowspan=1 colspan=1>P(D=1</td><td rowspan=1 colspan=1>Y=y,A=0</td><td rowspan=1 colspan=1>=P(D=1</td><td rowspan=1 colspan=1>Y=y,A=1),fory∈{0,1}</td></tr><tr><td rowspan=1 colspan=1>Predictive parity</td><td rowspan=1 colspan=1>P(Y=1</td><td rowspan=1 colspan=1>D=1,A=0</td><td rowspan=1 colspan=1>=P(Y=1</td><td rowspan=1 colspan=1>D=1,A=1)</td></tr><tr><td rowspan=1 colspan=1>False omission rate parity</td><td rowspan=1 colspan=1>P(Y=1</td><td rowspan=1 colspan=1>D=0,A=0</td><td rowspan=1 colspan=1>=P(Y=1</td><td rowspan=1 colspan=1>D=0,A=1)</td></tr><tr><td rowspan=1 colspan=1>Sufficiency</td><td rowspan=1 colspan=1>P(Y=1</td><td rowspan=1 colspan=1>D=d,A=0</td><td rowspan=1 colspan=1>=P(Y=1</td><td rowspan=1 colspan=1>D=d,A=1),ford∈{0,1}</td></tr></table>
527
+
528
+ # B Mapping existing group fairness criteria to our utility-based approach
529
+
530
+ # B.1 Omitted proofs
531
+
532
+ # B.1.1 Proof of Proposition 2
533
+
534
+ Recall that the utility-based fairness following the pattern of egalitarianism requires equal expected utilities between groups:
535
+
536
+ $$
537
+ E ( U _ { D S } | J = j , A = 0 ) = E ( U _ { D S } | J = j , A = 1 )
538
+ $$
539
+
540
+ 614 Since there is no claims differentiator (i.e., $J = \emptyset$ ), this can be simplified to:
541
+
542
+ $$
543
+ E ( U _ { D S } | A = 0 ) = E ( U _ { D S } | A = 1 )
544
+ $$
545
+
546
+ 615 For $w _ { 1 1 } = w _ { 1 0 }$ and $w _ { 0 1 } = w _ { 0 0 }$ , the decision subject utility (see Equation 1) is:
547
+
548
+ $$
549
+ \begin{array} { r } { u _ { D S , i } = w _ { 0 y } + \left( w _ { 1 y } - w _ { 0 y } \right) \cdot d _ { i } , } \end{array}
550
+ $$
551
+
552
+ 616 where $w _ { 1 y }$ denotes the decision subject utility associated with a positive decision ( $D = 1$ ) and $w _ { 0 y }$
553
+ 617 denotes the decision subject utility associated with a negative decision ( $D = 0$ ). Thus, the expected
554
+ 618 utility for individuals of group $a$ can be written as:
555
+
556
+ $$
557
+ E ( U _ { D S } | A = a ) = w _ { 0 y } + ( w _ { 1 y } - w _ { 0 y } ) \cdot P ( D = 1 | A = a ) .
558
+ $$
559
+
560
+ 619 If the utility weights of all possible outcomes do not depend on the group membership $( w _ { d y } \perp a )$ , and
561
+ 620 $w _ { 1 y } \ne w _ { 0 y } { } ^ { 7 }$ , then the utility-based fairness following the pattern of egalitarianism (see Equation B.10)
562
+ 621 requires:
563
+
564
+ $$
565
+ \begin{array} { r l } & { w _ { 0 y } + ( w _ { 1 y } - w _ { 0 y } ) \cdot P ( D = 1 | A = 0 ) = w _ { 0 y } + ( w _ { 1 y } - w _ { 0 y } ) \cdot P ( D = 1 | A = 1 ) } \\ & { \quad \Leftrightarrow ( w _ { 1 y } - w _ { 0 y } ) \cdot P ( D = 1 | A = 0 ) = ( w _ { 1 y } - w _ { 0 y } ) \cdot P ( D = 1 | A = 1 ) } \\ & { \quad \quad \Leftrightarrow P ( D = 1 | A = 0 ) = P ( D = 1 | A = 1 ) , } \end{array}
566
+ $$
567
+
568
+ 622 where the last line is identical to statistical parity.
569
+
570
+ 624 Recall that the degree to which egalitarianism is fulfilled is defined as $F _ { \mathrm { e g a l i t a r i a n i s m } } = | E ( U _ { D S } | J =$
571
+ 625 $j , A = 0 ) - E ( U _ { D S } | J = j , A = 1 ) |$ (see Equation 3). If the utility weights of all possible outcomes
572
+ 626 do not depend on the group membership $( w _ { d y } \perp a )$ , and $w _ { 1 1 } = w _ { 1 0 } \ne w _ { 0 1 } = w _ { 0 0 }$ (i.e., $w _ { 1 y } \ne w _ { 0 y }$
573
+ 627 $J = \emptyset$ , this can be written as (see Equations B.10 and B.12):
574
+
575
+ $$
576
+ \begin{array} { r l } & { F _ { \mathrm { e g a l i t a r i a n i s m } } = | \left( w _ { 0 y } + \left( w _ { 1 y } - w _ { 0 y } \right) \cdot P ( D = 1 | A = 0 ) \right) } \\ & { \qquad - \left( w _ { 0 y } + \left( w _ { 1 y } - w _ { 0 y } \right) \cdot P ( D = 1 | A = 1 ) \right) | } \\ & { \qquad = | \left( \left( w _ { 1 y } - w _ { 0 y } \right) \cdot P ( D = 1 | A = 0 ) \right) - \left( \left( w _ { 1 y } - w _ { 0 y } \right) \cdot P ( D = 1 | A = 1 ) \right) | } \\ & { \qquad = | \left( w _ { 1 y } - w _ { 0 y } \right) \cdot \left( P ( D = 1 | A = 0 ) - P ( D = 1 | A = 1 ) \right) | } \end{array}
577
+ $$
578
+
579
+ 28 where the last line corresponds to a multiplication of $| w _ { 1 y } - w _ { 0 y } |$ with the degree to which statistical
580
+ 29 parity is fulfilled.
581
+
582
+ # B.1.3 Proof of Proposition 4
583
+
584
+ Recall that the utility-based fairness following the pattern of egalitarianism requires equal expected utilities between groups:
585
+
586
+ $$
587
+ E ( U _ { D S } | J = j , A = 0 ) = E ( U _ { D S } | J = j , A = 1 )
588
+ $$
589
+
590
+ Since the claims differentiator is the same as the attribute $Y = 1$ , i.e., $J = Y$ and the only morally relevant value of $Y$ is 1 (i.e., $j = \{ 1 \}$ ), this can be simplified to:
591
+
592
+ $$
593
+ E ( U _ { D S } | Y = 1 , A = 0 ) = E ( U _ { D S } | Y = 1 , A = 1 )
594
+ $$
595
+
596
+ 635 For $y _ { i } = 1$ , the decision subject utility (see Equation 1) is:
597
+
598
+ $$
599
+ u _ { D S , i } = w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot d _ { i } .
600
+ $$
601
+
602
+ 636 Thus, the expected utility for individuals of type $Y = 1$ in group $a$ can be written as:
603
+
604
+ $$
605
+ E ( U _ { D S } | Y = 1 , A = a ) = w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = a ) .
606
+ $$
607
+
608
+ 637 If $w _ { 1 1 }$ and $w _ { 0 1 }$ do not depend on the group membership $( w _ { d 1 } \perp a )$ , and $w _ { 1 1 } \ne w _ { 0 1 } ^ { 8 }$ , then the
609
+ 638 utility-based fairness following the pattern of egalitarianism (see Equation B.16) requires:
610
+
611
+ $$
612
+ \begin{array} { r l } & { w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 0 ) = w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 1 ) } \\ & { \quad \Leftrightarrow ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 0 ) = ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 1 ) } \\ & { \quad \quad \quad \Leftrightarrow P ( D = 1 | Y = 1 , A = 0 ) = P ( D = 1 | Y = 1 , A = 1 ) , } \end{array}
613
+ $$
614
+
615
+ 639 where the last line is identical to equality of opportunity.
616
+
617
+ # B.1.4 Proof of Corollary 5
618
+
619
+ 641 Recall that the degree to which egalitarianism is fulfilled is defined as $F _ { \mathrm { e g a l i t a r i a n i s m } } = | E ( U _ { D S } | J =$
620
+ 642 $j , A = 0 ) - E ( U _ { D S } | J = j , A = 1 )$ | (see Equation 3). If $w _ { 1 1 }$ and $w _ { 0 1 }$ do not depend on the group
621
+ 643 membership $( w _ { d 1 } \perp a )$ , $w _ { 1 1 } \neq w _ { 0 1 }$ , $J = Y$ , and $j = \{ 1 \}$ , this can be written as (see Equations B.16
622
+ 644 and B.18):
623
+
624
+ $$
625
+ \begin{array} { r l } & { F _ { \mathrm { e g a l t a r i a n i s m } } = \vert \left( w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 0 ) \right) } \\ & { \qquad - \left( w _ { 0 1 } + ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 1 ) \right) \vert } \\ & { = \vert \left( ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 0 ) \right) } \\ & { \qquad - \left( ( w _ { 1 1 } - w _ { 0 1 } ) \cdot P ( D = 1 | Y = 1 , A = 1 ) \right) \vert } \\ & { = \vert \left( w _ { 1 1 } - w _ { 0 1 } \right) \cdot \left( P ( D = 1 | Y = 1 , A = 0 ) - P ( D = 1 | Y = 1 , A = 1 ) \right) \vert } \end{array}
626
+ $$
627
+
628
+ 645 where the last line corresponds to a multiplication of $| w _ { 1 1 } - w _ { 0 1 } |$ with the degree to which equality
629
+ 646 of opportunity is fulfilled.
630
+
631
+ # 47 B.1.5 Proof of Proposition 6
632
+
633
+ 48 Recall that the utility-based fairness following the pattern of egalitarianism requires equal expected
634
+ 49 utilities between groups:
635
+
636
+ $$
637
+ E ( U _ { D S } | J = j , A = 0 ) = E ( U _ { D S } | J = j , A = 1 )
638
+ $$
639
+
640
+ 50 Since the claims differentiator is the same as the decision $D = 1$ , i.e., $J = D$ and the only morally
641
+ 51 relevant value of $D$ is 1 (i.e., $j = \{ 1 \}$ ), this can be simplified to:
642
+
643
+ $$
644
+ E ( U _ { D S } | D = 1 , A = 0 ) = E ( U _ { D S } | D = 1 , A = 1 )
645
+ $$
646
+
647
+ 652 For $d _ { i } = 1$ , the decision subject utility (see Equation 1) is:
648
+
649
+ $$
650
+ \begin{array} { r } { u _ { D S , i } = w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot y _ { i } . } \end{array}
651
+ $$
652
+
653
+ 653 Thus, the expected utility for individuals in group $a$ that are assigned the decision $D = 1$ can be
654
+ 654 written as:
655
+
656
+ $$
657
+ E ( U _ { D S } | D = 1 , A = a ) = w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = a ) .
658
+ $$
659
+
660
+ 655 If $w _ { 1 1 }$ and $w _ { 1 0 }$ do not depend on the group membership $( w _ { 1 y } \perp a )$ , and $w _ { 1 1 } \ne w _ { 1 0 } { } ^ { 9 }$ , then the
661
+ 656 utility-based fairness following the pattern of egalitarianism (see Equation B.22) requires:
662
+
663
+ $$
664
+ \begin{array} { r l } & { w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 0 ) = w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 1 ) } \\ & { \quad \Leftrightarrow ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 0 ) = ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 1 ) } \\ & { \quad \quad \quad \Leftrightarrow P ( Y = 1 | D = 1 , A = 0 ) = P ( Y = 1 | D = 1 , A = 1 ) , } \end{array}
665
+ $$
666
+
667
+ 657 where the last line is identical to predictive parity.
668
+
669
+ # B.1.6 Proof of Corollary 7
670
+
671
+ Recall that the degree to which egalitarianism is fulfilled is defined as $F _ { \mathrm { e g a l i t a r i a n i s m } } = | E ( U _ { D S } | J =$ $j , A = 0 ) - E ( \bar { U _ { D S } } | J = j , A = \mathrm { \bar { 1 } } )$ | (see Equation 3). If $w _ { 1 1 }$ and $w _ { 1 0 }$ do not depend on the group membership $( w _ { 1 y } \perp a )$ , $w _ { 1 1 } \neq w _ { 1 0 }$ , $J = D$ , and $j = \{ 1 \}$ , this can be written as (see Equations B.22 and B.24):
672
+
673
+ $$
674
+ \begin{array} { r l } & { F _ { \mathrm { e g a l t a r i a n i s m } } = \vert \left( w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 0 ) \right) } \\ & { \qquad - \left( w _ { 1 0 } + ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 1 ) \right) \vert } \\ & { = \vert \left( ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 0 ) \right) } \\ & { \qquad - \left( ( w _ { 1 1 } - w _ { 1 0 } ) \cdot P ( Y = 1 | D = 1 , A = 1 ) \right) \vert } \\ & { = \vert \left( w _ { 1 1 } - w _ { 1 0 } \right) \cdot \left( P ( Y = 1 | D = 1 , A = 0 ) - P ( Y = 1 | D = 1 , A = 1 ) \right) \vert } \end{array}
675
+ $$
676
+
677
+ 63 where the last line corresponds to a multiplication of $| w _ { 1 1 } - w _ { 1 0 } |$ with the degree to which predictive
678
+ 664 parity is fulfilled.
679
+
680
+ # B.2 Mapping to other group fairness criteria
681
+
682
+ In Section 4, we mapped our utility-based approach to the three group fairness criteria statistical parity, equality of opportunity, and predictive parity. Here, we additionally show under which conditions our utility-based approach is equivalent to other group fairness criteria: conditional statistical parity, false positive rate parity, equalized odds, false omission rate parity, and sufficiency.
683
+
684
+ # B.2.1 Conditional statistical parity
685
+
686
+ Conditional statistical parity is defined as $P ( D = 1 | L = l , A = 0 ) = P ( D = 1 | L = l , A = 1 )$ , where $L$ is what [16] refer to as the legitimate attributes. Thus, conditional statistical parity requires equality of acceptance rates across all subgroups in $A = 0$ and $A = 1$ who are equal in their value $l$ for $L$ , where $L$ can be any (combination of) feature(s) besides $D$ and $A$ .
687
+
688
+ Proposition 8 (Conditional statistical parity as utility-based fairness). If the utility weights of all possible outcomes do not depend on the group membership $( w _ { d y } \perp a )$ , and $w _ { 1 1 } = w _ { 1 0 } \ne w _ { 0 1 } = w _ { 0 0 }$ then the egalitarian pattern fairness condition with $J = L$ is equivalent to conditional statistical parity.
689
+
690
+ The proof of Proposition 8 is similar to the one of Proposition 2.
691
+
692
+ Under these conditions, the degree to which $F _ { \mathrm { e g a l i t a r i a n i s m } }$ is fulfilled is equivalent to the degree to which conditional statistical parity is fulfilled, multiplied by $| w _ { 1 y } - w _ { 0 y } |$ . This could easily be proved – similar to the proof of Corollary 3 but with the conditions of the utility-based fairness stated in Proposition 8.
693
+
694
+ # B.2.2 False positive rate (FPR) parity
695
+
696
+ FPR parity (also called predictive equality [16]) is defined as $P ( D = 1 | Y = 0 , A = 0 ) = P ( D =$ $1 | Y \bar { = } 0 , \dot { A } = 1 \rangle$ ), i.e., it requires parity of false positive rates (FPR) across groups $a \in A$ .
697
+
698
+ Proposition 9 (FPR parity as utility-based fairness). If $w _ { 1 0 }$ and $w _ { 0 0 }$ do not depend on the group membership $( w _ { d 0 } \perp a )$ , and $w _ { 1 0 } \ne w _ { 0 0 }$ , then the egalitarian pattern fairness condition with $J = Y$ and $j = \{ 0 \}$ is equivalent to FPR parity.
699
+
700
+ 690 For $y _ { i } = 0$ , the decision subject utility (see Equation 1) is:
701
+
702
+ $$
703
+ \begin{array} { r } { u _ { D S , i } = w _ { 0 0 } + \left( w _ { 1 0 } - w _ { 0 0 } \right) \cdot d _ { i } . } \end{array}
704
+ $$
705
+
706
+ 91 Thus, the expected utility for individuals of type $Y = 0$ in group $a$ can be written as:
707
+
708
+ $$
709
+ E ( U _ { D S } | Y = 0 , A = a ) = w _ { 0 } + ( w _ { 1 0 } - w _ { 0 0 } ) \cdot P ( D = 1 | Y = 0 , A = a ) .
710
+ $$
711
+
712
+ Hence, we simply require the utility weights $w _ { 1 0 }$ and $w _ { 0 0 }$ to be unequal and independent of $a$ . Then, the proof of Proposition 9 is similar to the one of Proposition 4.
713
+
714
+ If $w _ { 1 0 }$ and $w _ { 0 0 }$ do not depend on the group membership $( w _ { d 0 } \perp a )$ , and $w _ { 1 0 } \ne w _ { 0 0 }$ , then the degree to which $F _ { \mathrm { e g a l i t a r i a n i s m } }$ is fulfilled is equivalent to the degree to which FPR parity is fulfilled, multiplied by $| w _ { 1 0 } - \check { w } _ { 0 0 } |$ . This could easily be proved – similar to the proof of Corollary 5.
715
+
716
+ # B.2.3 Equalized odds
717
+
718
+ Equalized odds (sometimes also referred to as separation [7]) is defined as $P ( D = 1 | Y = y , A =$ $0 ) = P ( D = 1 | Y = y , A = 1 )$ , for $y \in \{ 0 , 1 \}$ .
719
+
720
+ Proposition 10 (Equalized odds as utility-based fairness). If the utility weights of all possible outcomes do not depend on the group membership $( w _ { d y } \perp a )$ , $w _ { 1 1 } \neq w _ { 0 1 }$ , and $w _ { 1 0 } \ne w _ { 0 0 }$ , then the egalitarian pattern fairness condition with $J = Y$ and $\dot { j } = \{ 0 , 1 \}$ is equivalent to equalized odds.
721
+
722
+ The conditions under which the utility-based fairness criteria is equivalent is shown separately for equality of opportunity (see Proposition 4) and FPR parity (see Proposition 9). Since equalized odds requires equality of opportunity and FPR parity, the the conditions for both fairness criteria must be met (i.e., $w _ { d y } \perp a )$ , $w _ { 1 1 } \neq w _ { 0 1 }$ , $w _ { 1 0 } \ne w _ { 0 0 }$ , $J = Y$ , and $j = \{ 0 , 1 \}$ ), so that the utility-based fairness constraint is equivalent to equalized odds.
723
+
724
+ # B.2.4 False omission rate (FOR) parity
725
+
726
+ 9 FOR parity is defined as $P ( Y = 1 | D = 0 , A = 0 ) = P ( Y = 1 | D = 0 , A = 1 )$ , i.e., it requires parity of false omission rates (FOR) across groups $a \in A$ .
727
+
728
+ Proposition 11 (FOR parity as utility-based fairness). If $w _ { 0 1 }$ and $w _ { 0 0 }$ do not depend on the group membership $( w _ { 0 y } \perp a )$ , and $w _ { 0 1 } \ne w _ { 0 0 }$ , then the egalitarian pattern fairness condition with $J = D$ , and $j = \{ 0 \}$ is equivalent to FOR parity.
729
+
730
+ 714 For $d _ { i } = 0$ , the decision subject utility (see Equation 1) is:
731
+
732
+ $$
733
+ \begin{array} { r } { u _ { D S , i } = w _ { 0 0 } + \left( w _ { 0 1 } - w _ { 0 0 } \right) \cdot y _ { i } . } \end{array}
734
+ $$
735
+
736
+ 715 Thus, the expected utility for individuals in group $a$ that are assigned the decision $D = 0$ can be
737
+ 716 written as:
738
+
739
+ $$
740
+ E ( U _ { D S } | D = 0 , A = a ) = w _ { 0 0 } + ( w _ { 0 1 } - w _ { 0 0 } ) \cdot P ( Y = 1 | D = 0 , A = a ) .
741
+ $$
742
+
743
+ 717 Hence, we simply require the utility weights $w _ { 0 1 }$ and $w _ { 0 0 }$ to be unequal and independent of $a$ . Then,
744
+ 718 the proof of Proposition 11 is similar to the one of Proposition 6.
745
+ 19 If $w _ { 0 1 }$ and $w _ { 0 0 }$ do not depend on the group membership $( w _ { 0 y } \perp a )$ , and $w _ { 0 1 } \ne w _ { 0 0 }$ , then the degree
746
+ 20 to which $F _ { \mathrm { e g a l i t a r i a n i s m } }$ is fulfilled is equivalent to the degree to which FoR parity is fulfilled, multiplied
747
+ 21 by $| w _ { 0 1 } - \check { w } _ { 0 0 } |$ . This could easily be proved – similar to the proof of Corollary 7.
748
+
749
+ # B.2.5 Sufficiency
750
+
751
+ Sufficiency is defined as $P ( Y = 1 | D = d , A = 0 ) = P ( Y = 1 | D = d , A = 1 )$ , for $d \in \{ 0 , 1 \}$ [7].
752
+
753
+ Proposition 12 (Sufficiency as utility-based fairness). If the utility weights of all possible outcomes do not depend on the group membership $( w _ { d y } \perp a )$ , $w _ { 1 1 } \neq w _ { 1 0 }$ , and $w _ { 0 1 } \ne w _ { 0 0 }$ , then the egalitarian pattern fairness condition with $J = D$ and $j = \{ 0 , 1 \}$ is equivalent to sufficiency.
754
+
755
+ 727 The conditions under which the utility-based fairness criteria is equivalent is shown separately for
756
+ 728 predictive parity (see Proposition 6) and FOR parity (see Proposition 11). Since sufficiency requires
757
+ 729 predictive parity and FOR parity, the the conditions for both fairness criteria must be met (i.e.,
758
+ 730 $w _ { d y } \perp a )$ , $w _ { 1 1 } \neq w _ { 1 0 }$ , $w _ { 0 1 } \ne w _ { 0 0 }$ , $J = D$ , and $j = \{ 0 , 1 \}$ ), so that the utility-based fairness
759
+ 731 constraint is equivalent to sufficiency.
split_metadata/test.json ADDED
The diff for this file is too large to render. See raw diff