ZHANGYUXUAN-zR commited on
Commit
8725a52
·
verified ·
1 Parent(s): 6b3ea1d

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. parse/test/8Wuvhh0LYW/8Wuvhh0LYW.md +0 -0
  2. parse/test/8Wuvhh0LYW/8Wuvhh0LYW_content_list.json +0 -0
  3. parse/test/8Wuvhh0LYW/8Wuvhh0LYW_middle.json +0 -0
  4. parse/test/8Wuvhh0LYW/8Wuvhh0LYW_model.json +0 -0
  5. parse/test/DS5qRs0tQz/DS5qRs0tQz.md +435 -0
  6. parse/test/DS5qRs0tQz/DS5qRs0tQz_content_list.json +0 -0
  7. parse/test/DS5qRs0tQz/DS5qRs0tQz_middle.json +0 -0
  8. parse/test/DS5qRs0tQz/DS5qRs0tQz_model.json +0 -0
  9. parse/test/GEcwtMk1uA/GEcwtMk1uA.md +0 -0
  10. parse/test/GEcwtMk1uA/GEcwtMk1uA_content_list.json +0 -0
  11. parse/test/GEcwtMk1uA/GEcwtMk1uA_middle.json +0 -0
  12. parse/test/GEcwtMk1uA/GEcwtMk1uA_model.json +0 -0
  13. parse/test/IB1HqbA2Pn/IB1HqbA2Pn.md +0 -0
  14. parse/test/IB1HqbA2Pn/IB1HqbA2Pn_content_list.json +0 -0
  15. parse/test/IB1HqbA2Pn/IB1HqbA2Pn_middle.json +0 -0
  16. parse/test/IB1HqbA2Pn/IB1HqbA2Pn_model.json +0 -0
  17. parse/test/K7KQkiHanD/K7KQkiHanD_model.json +0 -0
  18. parse/test/Oho3UxCkKr/Oho3UxCkKr.md +501 -0
  19. parse/test/Oho3UxCkKr/Oho3UxCkKr_content_list.json +1166 -0
  20. parse/test/Oho3UxCkKr/Oho3UxCkKr_middle.json +0 -0
  21. parse/test/Oho3UxCkKr/Oho3UxCkKr_model.json +0 -0
  22. parse/test/hFALpTb4fR/hFALpTb4fR.md +631 -0
  23. parse/test/hFALpTb4fR/hFALpTb4fR_content_list.json +0 -0
  24. parse/test/hFALpTb4fR/hFALpTb4fR_middle.json +0 -0
  25. parse/test/hFALpTb4fR/hFALpTb4fR_model.json +0 -0
  26. parse/test/lPw8Xdzw5f/lPw8Xdzw5f.md +314 -0
  27. parse/test/lPw8Xdzw5f/lPw8Xdzw5f_content_list.json +701 -0
  28. parse/test/lPw8Xdzw5f/lPw8Xdzw5f_middle.json +0 -0
  29. parse/test/lPw8Xdzw5f/lPw8Xdzw5f_model.json +0 -0
  30. parse/test/oKn9c6ytLx/oKn9c6ytLx.md +456 -0
  31. parse/test/oKn9c6ytLx/oKn9c6ytLx_content_list.json +1084 -0
  32. parse/test/oKn9c6ytLx/oKn9c6ytLx_middle.json +0 -0
  33. parse/test/oKn9c6ytLx/oKn9c6ytLx_model.json +0 -0
  34. parse/test/tBRNC6YemY/tBRNC6YemY.md +415 -0
  35. parse/test/tBRNC6YemY/tBRNC6YemY_content_list.json +1011 -0
  36. parse/test/tBRNC6YemY/tBRNC6YemY_middle.json +0 -0
  37. parse/test/tBRNC6YemY/tBRNC6YemY_model.json +0 -0
  38. parse/test/tr0KidwPLc/tr0KidwPLc.md +0 -0
  39. parse/test/tr0KidwPLc/tr0KidwPLc_content_list.json +0 -0
  40. parse/test/tr0KidwPLc/tr0KidwPLc_middle.json +0 -0
  41. parse/test/tr0KidwPLc/tr0KidwPLc_model.json +0 -0
  42. parse/test/uREj4ZuGJE/uREj4ZuGJE.md +365 -0
  43. parse/test/uREj4ZuGJE/uREj4ZuGJE_content_list.json +846 -0
  44. parse/test/uREj4ZuGJE/uREj4ZuGJE_middle.json +0 -0
  45. parse/test/uREj4ZuGJE/uREj4ZuGJE_model.json +0 -0
  46. parse/test/v3XXtxWKi6/v3XXtxWKi6.md +0 -0
  47. parse/test/v3XXtxWKi6/v3XXtxWKi6_content_list.json +0 -0
  48. parse/test/v3XXtxWKi6/v3XXtxWKi6_middle.json +0 -0
  49. parse/test/v3XXtxWKi6/v3XXtxWKi6_model.json +0 -0
  50. parse/test/xbjSwwrQOe/xbjSwwrQOe_model.json +0 -0
parse/test/8Wuvhh0LYW/8Wuvhh0LYW.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/8Wuvhh0LYW/8Wuvhh0LYW_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/8Wuvhh0LYW/8Wuvhh0LYW_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/8Wuvhh0LYW/8Wuvhh0LYW_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DS5qRs0tQz/DS5qRs0tQz.md ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GROUNDING DINO:MARRYING DINO WITH GROUNDED PRE-TRAININGFOR OPEN-SET OBJECT DETECTION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ ![](images/5bc59b3cf8a49bb9f00a3edc1bad0db5f0b6029950f31bb57bbba65edb5af382.jpg)
6
+ Figure 1: (a) Closed-set object detection requires models to detect objects of pre-defined categories. (b) We evaluate models on novel objects and standard Referring expression comprehension (REC) benchmarks for model generalizations on novel objects with attributes. (c) We present an image editing application by combining Grounding DINO and Stable Diffusion Rombach et al. (2021). Best viewed in colors.
7
+
8
+ # ABSTRACT
9
+
10
+ In this paper, we develop an open-set object detector, called Grounding DINO, by marrying Transformer-based detector DINO with grounded pre-training, which can detect arbitrary objects with human inputs such as category names or referring expressions. The key solution of open-set object detection is introducing language to a closed-set detector for open-set concept generalization. To effectively fuse language and vision modalities, we conceptually divide a closed-set detector into three phases and propose a tight fusion solution, which includes a feature enhancer, a language-guided query selection, and a cross-modality decoder for modalities fusion. While previous works mainly evaluate open-set object detection on novel categories, we propose to also perform evaluations on referring expression comprehension for objects specified with attributes. Grounding DINO performs remarkably well on all three settings, including benchmarks on COCO, LVIS, ODinW, and $\operatorname { R e f C O C O } / + / \mathrm { g }$ . Grounding DINO achieves a 52.5 AP on the COCO detection zero-shot transfer benchmark, i.e., without any training data from COCO. It sets a new record on the ODinW zero-shot benchmark with a mean 26.1 AP.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ Understanding novel concepts is a fundamental capability of visual intelligence. In this work, we aim to develop a strong system to detect arbitrary objects specified by human language inputs, which we name as open-set object detection1. The task has wide applications for its great potential as a generic object detector. For example, we can cooperate it with generative models for image editing (as shown in Fig. 1 (b)).
15
+
16
+ The key to open-set detection is introducing language for unseen object generalization (Li et al., 2021; Anderson et al., 2017; Deng et al., 2021). For example, GLIP (Li et al., 2021) reformulates object detection as a phrase grounding task and introduces contrastive training between object regions and language phrases. It shows a great flexibility for heterogeneous datasets and remarkable performance on both closed-set and open-set detection. Despite its impressive results, GLIP’s performance can be constrained since it is designed based on a traditional one-stage detector Dynamic Head (Dai et al., 2021a). As open-set and closed-set detection are closely related, we believe a stronger closed-set object detector can result in an even better open-set detector.
17
+
18
+ Motivated by the encouraging progress of Transformer-based detectors (Zhang et al., 2022a; Liu et al., 2022; Li et al., 2022b; 2023a), in this work, we propose to build a strong open-set detector based on DINO (Zhang et al., 2022a), which not only offers the state-of-the-art object detection performance, but also allows us to integrate multi-level text information into its algorithm by grounded pre-training. We name the model as Grounding DINO. Grounding DINO has several advantages over GLIP. First, its Transformer-based architecture is similar to language models, making it easier to process both image and language data. For example, as all the image and language branches are built with Transformers, we can easily fuse cross-modality features in its whole pipeline. Second, Transformerbased detectors have demonstrated a superior capability of leveraging large-scale datasets. Lastly, as a DETR-like model, DINO can be optimized end-to-end without using any hand-crafted modules such as NMS (Non-Maximum Suppression), which greatly simplifies the overall grounding model.
19
+
20
+ Most existing open-set detectors are developed by extending closed-set detectors to open-set scenarios with language information. As shown in Fig. 2, a closed-set detector typically has three important modules, a backbone for feature extraction, a neck for feature enhancement, and a head for region refinement (or box prediction). A closedset detector can be generalized to detect novel objects by learning language-aware region embeddings so that each region can
21
+
22
+ ![](images/344c55bca7da7b21274e3082780c02d52b2fac17f7c8fd67b082244493cf4ce0.jpg)
23
+ Figure 2: Existing approaches to extending closed-set detectors to open-set scenarios. Note that some closed-set detectors can have only partial phases of the figure.
24
+
25
+ be classified into novel categories in a language-aware semantic space. The key to achieving this goal is using contrastive loss between region outputs and language features at the neck and/or head outputs. To help a model align cross-modality information, some work tried to fuse features before the final loss stage. Fig. 2 shows that feature fusion can be performed in three phases: neck (phase A), query initialization (phase B), and head (phase C). For example, GLIP (Li et al., 2021) performs early fusion in the neck module (phase A), and OV-DETR (Zang et al., 2022) uses language-aware queries as head inputs (phase B).
26
+
27
+ We argue that more feature fusion in the pipeline enables the model to perform better. It is worth noting that retrieval tasks prefer a CLIP-like two-tower architecture which only performs multimodality feature comparison at the end for efficiency. However, for open-set detection, the model is normally given both an image and a text input that specifies the target object categories or a specific object. In such a case, a tight (and early) fusion model is more preferred for a better performance (Anderson et al., 2017; Li et al., 2021) as both image and text are available at beginning. Although conceptually simple, it is hard for previous work to perform feature fusion in all three phases. The design of classical detectors like Faster RCNN makes it hard to interact with language information in most blocks. Unlike classical detectors, the Transformer-based detector DINO has a consistent structure with language blocks. The layer-by-layer design enables it to interact with language information easily. Under this principle, we design three feature fusion approaches in the neck, query initialization, and head phases. More specifically, we design a feature enhancer by stacking self-attention, text-to-image cross-attention, and image-to-text cross-attention as the neck module. We then develop a language-guided query selection method to initialize queries for head. We also design a cross-modality decoder for the head phase with image and text cross-attention layers to boost query representations. The three fusion phases effectively help the model achieve better performance on existing benchmarks, which will be shown in Sec. 4.4.
28
+
29
+ Although significant improvements have been achieved in multi-modal learning, most existing openset detection work evaluates their models on objects of novel categories, as shown in the left column of Fig. 1 (b). We argue that another important scenario, where objects are described with attributes, should also be considered. In the literature, the task is named Referring Expression Comprehension (REC) (Miao et al., 2022; Liu et al., $2 0 1 7 ) ^ { 2 }$ . We present some examples of REC in the right column of Fig. 1 (b). It is a closely related field but tends to be overlooked in previous open-set detection work. In this work, we extend open-set detection to support REC and also evaluate its performance on REC datasets.
30
+
31
+ We conduct experiments on all three settings, including closed-set detection, open-set detection, and referring object detection, to comprehensively evaluate open-set detection performance. Grounding DINO outperforms competitors by a large margin. For example, Grounding DINO reaches a 52.5 AP on COCO minival without any COCO training data. It also establishes a new state of the art on the ODinW (Li et al., 2022a) zero-shot benchmark with a 26.1 mean AP.
32
+
33
+ <table><tr><td rowspan="2">Model</td><td colspan="2">Baseei</td><td rowspan="2"></td><td rowspan="2"></td><td rowspan="2">Cosed-et etigs</td><td colspan="3">coCOZro-ShtTransfeDiWw</td><td rowspan="2">RerinoCOlectior</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ViLD (Gu et al., 2021)</td><td>Mask R-CNN</td><td></td><td>√</td><td>sentence</td><td>√</td><td>partial labelpartial label</td><td></td><td></td><td></td></tr><tr><td>RegionCLIP (Zhong et al., 2022)</td><td>Faster RCNN</td><td>=</td><td>√</td><td>sentence</td><td>√</td><td>partial labelpartial label</td><td></td><td></td><td></td></tr><tr><td>FindIt (Kuo et al., 2022)</td><td>Faster RCNN</td><td>A</td><td></td><td>sentence</td><td>√</td><td>partial label</td><td></td><td></td><td>fine-tune</td></tr><tr><td>MDETR (Kamath et al., 2021)</td><td>DETR</td><td>A.C</td><td></td><td>word</td><td></td><td></td><td>fine-tune</td><td>zero-shot </td><td>fine-tune</td></tr><tr><td>DQ-DETR (Shilong et al.,2023)</td><td>DETR</td><td>A.C</td><td></td><td>word</td><td>√</td><td></td><td>zero-shot</td><td></td><td>fine-tune</td></tr><tr><td>GLIP (Li et al., 2021)</td><td>DyHead</td><td>A</td><td></td><td>word</td><td>√</td><td>zero-shot</td><td>zero-shot</td><td>zero-shot</td><td></td></tr><tr><td>GLIPv2 (Zhang et al., 2022c)</td><td>DyHead</td><td>A</td><td></td><td>word</td><td>√</td><td>zero-shot</td><td>zero-shot</td><td>zero-shot</td><td></td></tr><tr><td>OV-DETR (Zang et al., 2022)</td><td>Deformable DETR</td><td>B</td><td></td><td>sentence</td><td>√</td><td>partial labelpartial label</td><td></td><td></td><td></td></tr><tr><td>OWL-ViT(Minderer et al., 2022)</td><td></td><td>·</td><td>&gt;&gt;&gt;</td><td>sentence</td><td>√</td><td>partial labelpartial labelzero-shot</td><td></td><td></td><td></td></tr><tr><td>DetCLIP (Yao et al.,2)</td><td>ATSS</td><td>-</td><td></td><td>sentence</td><td></td><td></td><td>zero-shot</td><td>zero-shot</td><td></td></tr><tr><td>OmDet (Zhao et al., 2022)</td><td>Sparse R-CNN</td><td>C</td><td></td><td>sentence</td><td>√</td><td></td><td></td><td>zero-shot</td><td></td></tr><tr><td>Grounding DINO (Ours)</td><td>DINO</td><td>A,B.C</td><td></td><td>sub-sentence</td><td>√</td><td>zero-shot</td><td>zero-shot</td><td>zero-shot</td><td>zero-shot</td></tr></table>
34
+
35
+ Table 1: A comparison of previous open-set object detectors. Our summarization is based on the experiments in their paper, but not the ability to extend their models to other tasks. It is worth noting that some related works may not (only) be designed for the open-set object detection initially, like MDETR (Kamath et al., 2021) and GLIPv2(Zhang et al., 2022c), but we list them here for a comprehensive comparison with existing work. We use the term “partial label” for the settings, where models are trained on partial data (e.g. base categories) and evaluated on other cases. (Zareian et al., 2021)
36
+
37
+ # 2 RELATED WORK
38
+
39
+ Detection Transformers. Grounding DINO is built upon the DETR-like model DINO (Zhang et al., 2022a), which is an end-to-end Transformer-based detector. DETR was first proposed in (Carion et al., 2020) and then has been improved from many directions (Zhu et al., 2021; Meng et al., 2021; Gao et al., 2021b; Dai et al., 2021a; Wang et al., 2021; Jia et al., 2022; Chen et al., 2022) in the past few years. DAB-DETR (Liu et al., 2022) introduces anchor boxes as DETR queries for more accurate box prediction. DN-DETR (Li et al., 2022b) proposes a query denoising approach to stabilizing the bipartite matching. DINO (Zhang et al., 2022a) further develops several techniques including contrastive de-noising and set a new record on the COCO object detection benchmark. However, such detectors mainly focus on closed-set detection and are difficult to generalize to novel classes because of the limited pre-defined categories.
40
+
41
+ Open-Set Object Detection. Open-set object detection is trained using existing bounding box annotations and aims at detecting arbitrary classes with the help of language generalization. OVDETR (Zareian et al., 2021) uses image and text embedding encoded by a CLIP model as queries to decode the category-specified boxes in the DETR framework (Carion et al., 2020). ViLD (Gu et al., 2021) distills knowledge from a CLIP teacher model into a R-CNN-like detector so that the learned region embeddings contain the semantics of language. GLIP (Gao et al., 2021a) formulates object detection as a grounding problem and leverages additional grounding data to help learn aligned semantics at phrase and region levels. It shows that such a formulation can even achieve stronger performance on fully-supervised detection benchmarks. DetCLIP (Yao et al., 2022) involves large-scale image captioning datasets and uses the generated pseudo labels to expand the knowledge database. The generated pseudo labels effectively help extend the generalization ability.
42
+
43
+ ![](images/efae78e80dd209bde66b66ad388cd5e44ed549080c8e430f0428cc2725714958.jpg)
44
+ Figure 3: The framework of Grounding DINO. We present the overall framework, a feature enhancer layer, and a decoder layer in block 1, block 2, and block 3, respectively.
45
+
46
+ However, previous works only fuse multi-modal information in partial phases, which may lead to sub-optimal language generalization ability. For example, GLIP only considers fusion in the feature enhancement (phase A) and OV-DETR only injects language information at the decoder inputs (phase B). Moreover, the REC task is normally overlooked in evaluation, which is an important scenario for open-set detection. We compare our model with other open-set methods in Table 1.
47
+
48
+ # 3 GROUNDING DINO
49
+
50
+ Grounding DINO outputs multiple pairs of object boxes and noun phrases for a given (Image, Text) pair. For example, as shown in Fig. 3, the model locates a cat and a table from the input image and extracts word cat and table from the input text as corresponding labels. Both object detection and REC tasks can be aligned with the pipeline. Following GLIP (Li et al., 2021), we concatenate all category names as input texts for object detection tasks. REC requires a bounding box for each text input. We use the output object with the largest scores as the output for the REC task.
51
+
52
+ Grounding DINO is a dual-encoder-single-decoder architecture. It contains an image backbone for image feature extraction, a text backbone for text feature extraction, a feature enhancer for image and text feature fusion (Sec. 3.1), a language-guided query selection module for query initialization (Sec. 3.2), and a cross-modality decoder for box refinement (Sec. 3.3).
53
+
54
+ For each (Image, Text) pair, we first extract vanilla image features and vanilla text features using an image backbone and a text backbone, respectively. The two vanilla features are fed into a feature enhancer module for cross-modality feature fusion. After obtaining cross-modality text and image features, we use a language-guided query selection module to select cross-modality queries from image features. Like the object queries in most DETR-like models, these cross-modality queries will be fed into a cross-modality decoder to probe desired features from the two modal features and update themselves. The output queries of the last decoder layer will be used to predict object boxes and extract corresponding phrases.
55
+
56
+ # 3.1 FEATURE EXTRACTION AND ENHANCER
57
+
58
+ Given an (Image, Text) pair, we extract multi-scale image features with an image backbone like Swin Transformer (Liu et al., 2021), and text features with a text backbone like BERT (Devlin et al., 2018). Following previous DETR-like detectors (Zhu et al., 2021; Zhang et al., 2022a), multi-scale features are extracted from the outputs of different blocks. After extracting vanilla image and text features,
59
+
60
+ ![](images/118fe71716e44b4ff0dced5fc130342eb602d8db99fee56440319e2f625ec79d.jpg)
61
+ Figure 4: Comparisons of text representations.
62
+
63
+ we fed them into a feature enhancer for cross-modality feature fusion. The feature enhancer includes multiple feature enhancer layers. We illustrate a feature enhancer layer in Fig. 3 block 2. We leverage the Deformable self-attention to enhance image features and the vanilla self-attention for text feature enhancers. Inspired by GLIP (Li et al., 2021), we add an image-to-text and a text-to-image cross-attention modules for feature fusion. These modules help align features of different modalities.
64
+
65
+ # 3.2 LANGUAGE-GUIDED QUERY SELECTION
66
+
67
+ Grounding DINO aims to detect objects from an image specified by an input text. To effectively leverage the input text to guide object detection, we design a language-guided query selection module to select features that are more relevant to the input text as decoder queries.
68
+
69
+ Let’s denote the image feature as ${ \bf X } _ { I } \in { \mathbb R } ^ { N _ { I } \times d }$ and the text features as ${ \bf X } _ { T } \in { \mathbb R } ^ { N _ { T } \times d }$ . Here, $N _ { I }$ represents the number of image tokens, $N _ { T }$ indicates the number of text tokens, and $d$ corresponds to the feature dimension. In our experiments, we specifically utilize a feature dimension of $d = 2 5 6$ . Typically, in our models, the value of $N _ { I }$ exceeds $1 0 , 0 0 0$ , while $N _ { T }$ remains below 256. Our objective is to extract $N _ { q }$ queries from the encoder’s image features to be used as inputs for the decoder. In alignment with the DINO method, we set $N _ { q }$ to be 900. The top $N _ { q }$ query indices for the image feature, denoted as $\mathbf { I } _ { N _ { q } }$ , are selected using the following expression:
70
+
71
+ $$
72
+ \mathbf { I } _ { N _ { q } } = \mathrm { T o p } _ { N _ { q } } ( \mathrm { M a x } ^ { ( - 1 ) } ( \mathbf { X } _ { I } \mathbf { X } _ { T } ^ { \intercal } ) ) .
73
+ $$
74
+
75
+ In this expression, $\mathrm { T o p } _ { N _ { q } }$ represents the operation to pick the top $N _ { q }$ indices. The function $\mathrm { { M a x } ^ { ( - 1 ) } }$ executes the max operation along the $- 1$ dimension, and the symbol denotes matrix transposition. We present the query selection process in Algorithm 1 in PyTorch style. The language-guided query selection module outputs $N _ { q }$ indices. We can extract features based on the selected indices to initialize queries. Following DINO (Zhang et al., 2022a), we use mixed query selection to initialize decoder queries. Each decoder query contains two parts: content part and positional part (Meng et al., 2021), respectively. We formulate the positional part as dynamic anchor boxes (Liu et al., 2022), which are initialized with encoder outputs. The other part, the content queries, are set to be learnable during training.
76
+
77
+ # 3.3 CROSS-MODALITY DECODER
78
+
79
+ We develop a cross-modality decoder to combine image and text modality features, as shown in Fig. 3 block 3. Each cross-modality query is fed into a self-attention layer, an image cross-attention layer to combine image features, a text cross-attention layer to combine text features, and an FFN layer in each cross-modality decoder layer. Each decoder layer has an extra text cross-attention layer compared with the DINO decoder layer, as we need to inject text information into queries for better modality alignment.
80
+
81
+ <table><tr><td>Model</td><td>Backbone</td><td>Pre-Training Data</td><td>Zero-Shot 2017val</td><td>Fine-Tuning 2017val/test-dev</td></tr><tr><td>Faster R-CNN</td><td>RN50-FPN</td><td></td><td>/</td><td>40.2/-</td></tr><tr><td>Faster R-CNN</td><td>RN101-FPN</td><td></td><td></td><td>42.0/-</td></tr><tr><td>DyHead-T (Dai et al.,2021a)</td><td>Swin-T</td><td></td><td></td><td>49.7/-</td></tr><tr><td>DyHead-L (Dai et al.,2021a)</td><td>Swin-L</td><td></td><td></td><td>58.4/58.7</td></tr><tr><td>DyHead-L (Dai et al.,2021a)</td><td>Swin-L</td><td>O365,ImageNet21K</td><td></td><td>60.3 /60.6</td></tr><tr><td>SoftTeacher (Xu et al.,2021)</td><td>Swin-L</td><td>0365,SS-COCO</td><td></td><td>60.7/ 61.3</td></tr><tr><td>DINO(Swin-L) (Zhang et al.,2022a)</td><td>Swin-L</td><td>0365</td><td>=</td><td>62.5/-</td></tr><tr><td>DyHead-Tt(Dai et al.,2021a)</td><td>Swin-T</td><td>0365</td><td>43.6</td><td>53.3/-</td></tr><tr><td>GLIP-T(B) (Li et al.,2021)</td><td>Swin-T</td><td>0365</td><td>44.9</td><td>53.8/-</td></tr><tr><td>GLIP-T (C) (Li et al., 2021)</td><td>Swin-T</td><td>O365,GoldG</td><td>46.7</td><td>55.1/-</td></tr><tr><td>GLIP-L (Li et al.,2021)</td><td>Swin-L</td><td>FourODs,GoldG,Cap24M</td><td>49.8</td><td>60.8/ 61.0</td></tr><tr><td>DINO(Swin-T)t(Zhang et al., 2022a)</td><td>Swin-T</td><td>0365</td><td>46.2</td><td>56.9/-</td></tr><tr><td>Grounding DINO T (Ours)</td><td>Swin-T Swin-T</td><td>0365</td><td>46.7</td><td>56.9/-</td></tr><tr><td>Grounding DINO T (Ours)</td><td>Swin-T</td><td>0365,GoldG</td><td>48.1</td><td>57.1/-</td></tr><tr><td>Grounding DINO T (Ours) Grounding DINO L (Ours)</td><td>Swin-L</td><td>0365,GoldG,Cap4M 0365,OI(Krasin et al.,2017),GoldG</td><td>48.4</td><td>57.2/ -</td></tr><tr><td></td><td></td><td></td><td>52.5</td><td>62.6 / 62.7 (63.0 / 63.0)*</td></tr><tr><td>Grounding DINO L (Ours)</td><td>Swin-L</td><td>0365,OI,GoldG,Cap4M,COCO,RefC</td><td>60.7</td><td>62.6/ -</td></tr></table>
82
+
83
+ Table 2: Zero-shot domain transfer and fine-tuning on COCO. \* The results in brackets are trained with $1 . 5 \times$ image sizes, i.e., with a maximum image size of 2000. $^ \dagger$ The models map a subset of O365 categories to COCO for zero-shot evaluations.
84
+
85
+ # 3.4 SUB-SENTENCE LEVEL TEXT FEATURE
86
+
87
+ Two kinds of text prompts are explored in previous works, which we named as sentence level representation and word level representation, as shown in Fig. 4. Sentence level representation (Yao et al., 2022; Minderer et al., 2022) encodes a whole sentence to one feature. If some sentences in phrase grounding data have multiple phrases, it extracts these phrases and discards other words. In this way, it removes the influence between words while losing fine-grained information in sentences. Word level representation (Gao et al., 2021a; Kamath et al., 2021) enables encoding multiple category names with one forward but introduces unnecessary dependencies among categories, especially when the input text is a concatenation of multiple category names in an arbitrary order. As shown in Fig. 4 (b), some unrelated words interact during attention. To avoid unwanted word interactions, we introduce attention masks to block attentions among unrelated category names, named “sub-sentence” level representation. It eliminates the influence between different category names while keeping per-word features for fine-grained understanding.
88
+
89
+ # 3.5 LOSS FUNCTION
90
+
91
+ Following previous DETR-like works (Carion et al., 2020; Zhu et al., 2021; Meng et al., 2021; Liu et al., 2022; Li et al., 2022b; Zhang et al., 2022a), we use the L1 loss and the GIOU (Rezatofighi et al., 2019) loss for bounding box regressions. We follow GLIP (Li et al., 2021) and use contrastive loss between predicted objects and language tokens for classification. Specifically, we dot product each query with text features to predict logits for each text token and then compute focal loss (Lin et al., 2017) for each logit. Box regression and classification costs are first used for bipartite matching between predictions and ground truths. We then calculate final losses between ground truths and matched predictions with the same loss components. Following DETR-like models, we add auxiliary loss after each decoder layer and after the encoder outputs.
92
+
93
+ # 4 EXPERIMENTS
94
+
95
+ # 4.1 SETUP
96
+
97
+ We conduct extensive experiments on three settings: a closed-set setting on the COCO detection benchmark (Sec. D.1), an open-set setting on zero-shot COCO, LVIS, and ODinW (Sec. 4.2), and a referring detection setting on $\operatorname { R e f C O C O } / + / \mathrm { g }$ (Sec. 4.3). Ablations are then conducted to show the effectiveness of our model design (Sec. 4.4). We also explore a way to transfer a well-trained DINO to the open-set scenario by training a few plug-in modules in Sec. 4.5. The test of our model efficiency is presented in Sec. J.
98
+
99
+ Implementation Details We trained two model variants, Grounding DINO T with Swin-T (Liu et al., 2021), and Grounding DINO L with Swin-L (Liu et al., 2021) as an image backbone, respectively. We leveraged BERT-base (Devlin et al., 2018) from Hugging Face (Wolf et al., 2019) as text backbones. As we focus more on the model performance on novel classes, we list zero-shot transfer and referring detection results in the main text. More implementation details are available in the Appendix Sec. B.
100
+
101
+ # 4.2 ZERO-SHOT TRANSFER OF GROUNDING DINO
102
+
103
+ In this setting, we pre-train models on large-scale datasets and directly evaluate models on new datasets. We also list some fine-tuned results for a more thorough comparison of our model with prior works.
104
+
105
+ COCO Benchmark We compare Grounding DINO with GLIP and DINO in Table 2. We pre-train models on large-scale datasets and directly evaluate our model on the COCO benchmark. As the O365 dataset (Shao et al., 2019) has (nearly3) covered all categories in COCO, we evaluate an O365 pre-trined DINO on COCO as a zero-shot baseline. The result shows that DINO performs better on the COCO zero-shot transfer than DyHead. Grounding DINO outperforms all previous models on the zero-shot transfer setting, with $+ 0 . 5 \mathrm { A P }$ and $+ 1 . 8 \mathrm { A P }$ compared with DINO and GLIP under the same setting. Grounding data is still helpful for Grounding DINO, introducing more than 1AP (48.1 vs. 46.7) on the zero-shot transfer setting. With stronger backbones and larger data, Grounding DINO sets a new record of 52.5 AP on the COCO object detection benchmark without seeing any COCO images during training. Grounding DINO obtains a $6 2 . 6 ~ \mathrm { A P }$ on COCO minival, outperforming DINO’s 62.5 AP. When enlarging the input images by $1 . 5 \times$ , the benefits reduce. We suspect that the text branch enlarges the gap between models with different input images. Even though the performance plateaus with larger input size, Grounding DINO gets an impressive 63.0 AP on COCO test-dev with fine-tuning on the COCO dataset(See the number in brackets of Table 2).
106
+
107
+ LVIS Benchmark LVIS (Gupta et al., 2019) is a dataset for long-tail objects. It contains more than 1000 categories for evaluation. We use LVIS as a downstream task to test the zero-shot abilities of our model. We use GLIP and DetCLIPv2 as baselines for our models. The results are shown in Table 3.
108
+
109
+ We found two interesting phenomena in the results. First, Grounding DINO works better than common objects than GLIP, but worse on rare categories. The other phenomenon is that Grounding DINO has larger gains with more data than GLIP. For example, Grounding DINO introduces $+ 1 . 8$ AP gains with the caption data Cap4M, whereas GLIP has only $+ 1 . 1$ AP. We believe that Grounding DINO has better scalability compared with GLIP. A larger-scale training will be left as our future work.
110
+
111
+ Table 3: Model results on LVIS.
112
+
113
+ <table><tr><td>Model</td><td>Backbone</td><td>Pre-Training Data</td><td>MiiVal(Kar/A eta2021)</td><td></td></tr><tr><td colspan="5">Zero-Shot Setting</td></tr><tr><td>GLIP-T (C)</td><td>Swin-T</td><td>0365,GoldG</td><td>24.9</td><td>17.7/19.5/31.0</td></tr><tr><td>GLIP-T</td><td>Swin-T</td><td>O365,GoldG,Cap4M</td><td>26.0</td><td>20.8/21.4/31.0</td></tr><tr><td>DetCLIPv2</td><td>Swin-T</td><td>0365,GoldG,CC15M</td><td>40.4</td><td>36.0/41.7/40.0</td></tr><tr><td>Grounding DINO T</td><td>Swin-T</td><td>0365,GoldG</td><td>25.6</td><td>14.4/19.6/32.2</td></tr><tr><td>Grounding DINO T</td><td>Swin-T</td><td>0365,GoldG,Cap4M</td><td>27.4</td><td>18.1/23.3/32.7</td></tr><tr><td>Grounding DINO L</td><td>Swin-L</td><td>0365.01GoldG.Cap4M,</td><td>33.9</td><td>22.2/30.7/38.8</td></tr><tr><td colspan="5">Fine-TuneSetting</td></tr><tr><td>MDETR</td><td>RN101</td><td>GoldG,RefC</td><td>24.2</td><td>20.9/24.9/24.3</td></tr><tr><td>Mask R-CNN</td><td>RN101</td><td>=</td><td>33.3</td><td>26.3/34.0/33.9</td></tr><tr><td>DetCLIPv2(Yao et al.,2023)Swin-T</td><td></td><td>0365,GoldG.CC15M</td><td>50.7</td><td>44.3/52.4/50.3</td></tr><tr><td>Grounding DINO T</td><td>Swin-T</td><td>0365,GoldG</td><td>52.1</td><td>35.4/51.3/55.7</td></tr></table>
114
+
115
+ To assess whether the number of queries affects performance, further ablations were conducted on query numbers as detailed in Sec. K. The findings indicate that the impact varies with the training dataset. Specifically, models trained exclusively on O365 experience a decline in performance as the number of queries increases. In contrast, models trained on both O365 and GoldG demonstrate improved performance with an increased number of queries.
116
+
117
+ Although achieving better results than GLIP, we found that Grounding DINO is inferior to DetCLIPv2, which is trained on a larger scale data. This performance difference might be attributed to the disparity in data distribution between the training dataset and the LVIS dataset.
118
+
119
+ To unveil the full potential of Grounding DINO, we fine-tuned it on the LVIS dataset. Table 3 highlights the commendable capability of our model. Remarkably, despite being pre-trained only on the O365 and GoldG datasets, Grounding DINO outperforms DetCLIPv2-T by a margin of 1.5 AP.
120
+
121
+ This result shows that Grounding DINO might have learned a better object-level representation which helps yield a better performance after fine-tuning (aligning with the target dataset). In our future work, we will perform more studies, including varying the semantic concept coverage of the training data and increasing the scale of the training data, to further improve the zero-shot generalization performance.
122
+
123
+ Table 4: Results on the ODinW benchmark.
124
+
125
+ <table><tr><td>Model</td><td>Language Input</td><td>Backbone</td><td>Model Size</td><td>Pre-Training Data</td><td colspan="2">Tes APmedan APaverage</td></tr><tr><td colspan="7">Zero-Shot Setting</td></tr><tr><td>MDETR (Kamath et al., 2021)</td><td>√</td><td>ENB5 (Tan&amp;Le,2019)</td><td>169M</td><td>GoldG,RefC</td><td>10.7</td><td>3.0</td></tr><tr><td>OWL-ViT(Minderer et al.,2022)</td><td>√</td><td>ViTL/14(CLIP)</td><td>&gt;1243M</td><td>0365,VG</td><td>18.8</td><td>9.8</td></tr><tr><td>GLIP-T(Li et al.,2021)</td><td>√</td><td>Swin-T</td><td>232M</td><td>0365,GoldG,Cap4M</td><td>19.6</td><td>5.1</td></tr><tr><td>OmDet (Zhao et al., 2022)</td><td>√</td><td>ConvNeXt-B</td><td>230M</td><td>COCO.O365,LVIS,PhraseCut</td><td>19.7</td><td>10.8</td></tr><tr><td>GLIPv2-T (Zhang et al.,2022b)</td><td>√</td><td>Swin-T</td><td>232M</td><td>0365,GoldG,Cap4M</td><td>22.3</td><td>8.9</td></tr><tr><td>DetCLIP(Yao et al.,2022)</td><td>√ √</td><td>Swin-L</td><td>267M</td><td>0365,GoldG,YFCC1M</td><td>24.9</td><td>18.3</td></tr><tr><td>Florence (Yuan et al., 2022)</td><td></td><td>CoSwinH</td><td>~841M</td><td>FLD900M,O365,GoldG</td><td>25.8</td><td>14.3</td></tr><tr><td>Grounding DINO T(Ours)</td><td>√</td><td>Swin-T</td><td>172M</td><td>0365,GoldG</td><td>20.0</td><td>9.5</td></tr><tr><td>Grounding DINO T(Ours)</td><td></td><td>Swin-T</td><td>172M</td><td>0365.GoldG.Cap4M</td><td>22.3</td><td>11.9</td></tr><tr><td>Grounding DINO L(Ours)</td><td>√</td><td>Swin-L</td><td>341M</td><td>0365,OI,GoldG,Cap4M,COCO,RefC</td><td>26.1</td><td>18.4</td></tr><tr><td colspan="7">Few-Shot Setting</td></tr><tr><td>DyHead-T(Dai et al.,2021a)</td><td>X</td><td>Swin-T</td><td>~100M</td><td>0365</td><td>37.5</td><td>36.7</td></tr><tr><td>GLIP-T (Li et al.,2021)</td><td>√</td><td>Swin-T</td><td>232M</td><td>0365,GoldG,Cap4M</td><td>38.9</td><td>33.7</td></tr><tr><td>DINO-Swin-T(Zhang et al.,2022a) OmDet (Zhao et al., 2022)</td><td>X</td><td>Swin-T</td><td>49M</td><td>0365</td><td>41.2</td><td>41.1</td></tr><tr><td>Grounding DINO T(Ours)</td><td>√</td><td>ConvNeXt-B</td><td>230M</td><td>COCO,O365,LVIS,PhraseCut</td><td>42.4</td><td>41.7</td></tr><tr><td></td><td>√</td><td>Swin-T</td><td>172M</td><td>0365,GoldG</td><td>46.4</td><td>51.1</td></tr><tr><td colspan="7">Full-Shot Setting</td></tr><tr><td>GLIP-T(Li et al., 2021)</td><td>√</td><td>Swin-T</td><td>232M</td><td>0365,GoldG,Cap4M</td><td>62.6</td><td></td></tr><tr><td>DyHead-T(Dai et al., 2021a)</td><td>X</td><td>Swin-T</td><td>~100M</td><td>0365</td><td>63.2</td><td>62.1 64.9</td></tr><tr><td>DINO-Swin-T(Zhang et al.,2022a)</td><td>X</td><td>Swin-T</td><td>49M</td><td>0365</td><td>66.7</td><td>68.5</td></tr><tr><td>OmDet (Zhao et al.,2022)</td><td>√</td><td>ConvNeXt-B</td><td>230M</td><td>COCO,O365,LVIS.PhraseCut</td><td>67.1</td><td>71.2</td></tr><tr><td>DINO-Swin-L (Zhang et al.,222a)</td><td>X</td><td>Swin-L</td><td>218M</td><td>0365</td><td>68.8</td><td>70.7</td></tr><tr><td>Grounding DINO T(Ours)</td><td>√</td><td>Swin-T</td><td>172M</td><td>0365,GoldG</td><td>70.7</td><td>76.2</td></tr></table>
126
+
127
+ ODinW Benchmark ODinW (Object Detection in the Wild) (Li et al., 2022a) is a more challenging benchmark to test model performance under real-world scenarios. It collects more than 35 datasets for evaluation. We report three settings, zero-shot, few-shot, and full-shot results in Table 4. Grounding DINO performs well on this benchmark. With only O365 and GoldG for pre-train, Grounding DINO T outperforms DINO on few-shot and full-shot settings. Impressively, Grounding DINO with a Swin-T backbone outperforms DINO with Swin-L on the full-shot setting.
128
+
129
+ Grounding DINO outperforms GLIP under the same backbone for the zero-shot setting. Grounding DINO and GLIPv2-T show similar $A P _ { a v e r a g e }$ . However, a key distinction lies in the $A P _ { m e d i a n }$ where Grounding DINO significantly outperforms GLIPv2-T (11.9 vs 8.9). This suggests that while GLIPv2 may exhibit larger performance variance across different datasets, Grounding DINO maintains a more consistent performance level. GLIPv2 incorporates advanced techniques like masked text training and cross-instance contrastive learning, making it more complex than our Grounding DINO model. Moreover, our model is more compact (172M parameters) compared to GLIPv2 (232M parameters). These factors combined—performance consistency, model complexity, and size—should address concerns about our model’s capability in true open-set scenarios.
130
+
131
+ Grounding DINO L set a new record on ODinW zero-shot with a 26.1 AP, even outperforming the giant Florence models (Yuan et al., 2022). The results show the generalization and scalability of Grounding DINO.
132
+
133
+ # 4.3 REFERRING OBJECT DETECTION SETTINGS
134
+
135
+ We further explore our models’ performances on the REC task. We leverage GLIP (Li et al., 2021) as our baseline. We evaluate the model performance on $\operatorname { R e f C O C O } / + / \mathrm { g }$ directly.4 The results are shown in Table 5. Grounding DINO outperforms GLIP under the same setting. Nevertheless, both GLIP and Grounding DINO perform not well without REC data. More training data like caption data or larger models help the final performance, but quite minor. After injecting $\operatorname { R e f C O C O } / + / \mathrm { g }$ data into training, Grounding DINO obtains significant gains. The results reveal that most nowadays open-set object detectors need to pay more attention for a more fine-grained detection.
136
+
137
+ Table 5: Top-1 accuracy comparison on the referring expression comprehension task. We mark the best results in bold. All models are trained with a ResNet-101 backbone. We use the notations “CC”, “SBU”, “VG”, “OI”, $\mathbf { \hat { O } } 3 6 5 \mathbf { \ ' }$ , and “YFCC” for Conceptual Captions (Sharma et al., 2018), SBU Captions (Ordonez et al., 2011), Visual Genome (Krishna et al., 2017), OpenImage (Kuznetsova et al., 2018), Objects365 (Zhou et al., 2019), YFCC100M (Thomee et al., 2016) respectively. The term “RefC” is used for RefCOCO, RefCOCO+, and RefCOCOg three datasets. \* There might be a data leak since COCO includes validation images in RefC. But the annotations of the two datasets are different.
138
+
139
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Backbone</td><td rowspan="2">Pre-Training Data</td><td rowspan="2">Fine-tuning</td><td colspan="3">RefCoCo</td><td colspan="3">RefCOCO+</td><td colspan="2">RefCOCOg</td></tr><tr><td>val</td><td>testA</td><td>testB</td><td>val</td><td>testA</td><td>testB</td><td>val</td><td>test</td></tr><tr><td>MAttNet (Yu et al.,218)</td><td>R101</td><td>None</td><td>√</td><td>76.65</td><td>81.14</td><td>69.99</td><td>65.33</td><td>71.62</td><td>56.02</td><td>66.58</td><td>67.27</td></tr><tr><td>VGTR (Du et al., 2021)</td><td>R101</td><td>None</td><td>√</td><td>79.20</td><td>82.32</td><td>73.78</td><td>63.91</td><td>70.09</td><td>56.51</td><td>65.73</td><td>67.23</td></tr><tr><td>TransVG (Deng etal.,021)</td><td>R101</td><td>None</td><td>√</td><td>81.02</td><td>82.72</td><td>78.35</td><td>64.82</td><td>70.70</td><td>56.94</td><td>68.67</td><td>67.73</td></tr><tr><td>VILLA_L* (Gan et al.,2020)</td><td>R101</td><td>CC,SBU,COCO,VG</td><td></td><td>82.39</td><td>87.48</td><td>74.84</td><td>76.17</td><td>81.54</td><td>66.84</td><td>76.18</td><td>76.71</td></tr><tr><td>RefTR (Li&amp; Sigal,2021)</td><td>R101</td><td>VG</td><td></td><td>85.65</td><td>88.73</td><td>81.16</td><td>77.55</td><td>82.26</td><td>68.99</td><td>79.25</td><td>80.01</td></tr><tr><td>MDETR (Kamath et al.,2021)</td><td>R101</td><td>GoldG,RefC</td><td>√</td><td>86.75</td><td>89.58</td><td>81.41</td><td>79.52</td><td>84.09</td><td>70.62</td><td>81.64</td><td>80.89</td></tr><tr><td>DQ-DETR (Shilong et al.,2023)</td><td>R101</td><td>GoldG,RefC</td><td>√</td><td>88.63</td><td>91.04</td><td>83.51</td><td>81.66</td><td>86.15</td><td>73.21</td><td>82.76</td><td>83.44</td></tr><tr><td>GLIP-T(B)</td><td>Swin-T</td><td>0365,GoldG</td><td></td><td>49.96</td><td>54.69</td><td>43.06</td><td>49.01</td><td>53.44</td><td>43.42</td><td>65.58</td><td>66.08</td></tr><tr><td>GLIP-T</td><td>Swin-T</td><td>0365,GoldG,Cap4M</td><td></td><td>50.42</td><td>54.30</td><td>43.83</td><td>49.50</td><td>52.78</td><td>44.59</td><td>66.09</td><td>66.89</td></tr><tr><td>Grounding DINO T (Ours)</td><td>Swin-T</td><td>0365,GoldG</td><td></td><td>50.41</td><td>57.24</td><td>43.21</td><td>51.40</td><td>57.59</td><td>45.81</td><td>67.46</td><td>67.13</td></tr><tr><td>Grounding DINO T (Ours)</td><td>Swin-T</td><td>0365,GoldG,RefC</td><td></td><td>73.98</td><td>74.88</td><td>59.29</td><td>66.81</td><td>69.91</td><td>56.09</td><td>71.06</td><td>72.07</td></tr><tr><td>Grounding DINO T(Ours)</td><td>Swin-T</td><td>0365,GoldG,RefC</td><td>√</td><td>89.19</td><td>91.86</td><td>85.99</td><td>81.09</td><td>87.40</td><td>74.71</td><td>84.15</td><td>84.94</td></tr><tr><td>Grounding DINO L (Ours)*</td><td>Swin-L</td><td>0365,OL,GoldG,Cap4M,COCO,RefC</td><td>√</td><td>90.56</td><td>93.19</td><td>88.24</td><td>82.75</td><td>88.95</td><td>75.92</td><td>86.13</td><td>87.02</td></tr></table>
140
+
141
+ # 4.4 ABLATIONS
142
+
143
+ We conduct ablation studies in this section. We propose a tight fusion grounding model for open-set object detection and a sub-sentence level text prompt. To verify the effectiveness of the model design, we remove some fusion blocks for different variants. Results are shown in Table 6. All models are pre-trained on O365 with a Swin-T backbone.
144
+
145
+ The results show that encoder fusion significantly improves model performance on both COCO and LVIS datasets. The results from comparing model $\# 1$ with the baseline model $\# 0$ validate this observation. Other techniques, such as language-guided query selection, text cross-attention, and sub-sentence text prompt, also contribute positively to the LVIS performance, yielding significant gains of $+ 3 . 0$ AP, $+ 1 . 8$ AP, and $+ 0 . 5$ AP, respectively. Additionally, these methods enhance the COCO zero-shot performance, further underscoring their effectiveness. However, we observed that language-guided query selection and sub-sentence text prompt had minimal impact on the COCO fine-tune performance. This outcome is reasonable, given that these methods do not alter model parameters or add computational burdens. Text cross-attention, while introducing fewer parameters than encoder fusion, showed less performance improvement compared to encoder fusion $( + 0 . 6$ vs. $+ 0 . 8 )$ . This finding suggests that fine-tuning performance is predominantly influenced by the model’s parameters, indicating that scaling models is a promising direction for enhancing performance.
146
+
147
+ # 4.5 TRANSFER FROM DINO TO GROUNDING DINO
148
+
149
+ Recent work has presented many large-scale image models for detection with DINO architecture5. It is computationally expensive to train a Grounding DINO model from scratch. However, the cost can be significantly reduced if we leverage pre-trained DINO weights. Hence, we conduct some experiments to transfer pretrained DINO to Grounding DINO models. We freeze the modules co-existing in DINO and Grounding DINO and fine-tune the other parameters only. (We compare DINO and Grounding DINO in Sec. F.) The results are available in Table 7.
150
+
151
+ Table 6: Ablations for our model. All models are trained on the O365 dataset with a Swin Transformer Tiny backbone.
152
+
153
+ <table><tr><td rowspan="2">#ID</td><td rowspan="2">Model</td><td colspan="2">ZeroCSOcO minivaune</td><td rowspan="2">LVis minival</td></tr><tr><td></td><td></td></tr><tr><td>0</td><td>Grounding DINO (Full Model)</td><td>46.7</td><td>56.9</td><td>16.1</td></tr><tr><td>1</td><td>w/o encoder fusion</td><td>45.8</td><td>56.1</td><td>13.1</td></tr><tr><td>23</td><td>static query selection</td><td>46.3</td><td>56.6</td><td>13.6</td></tr><tr><td></td><td>w/o text cross-attention</td><td>46.1</td><td>56.3</td><td>14.3</td></tr><tr><td>4</td><td>word-level text prompt</td><td>46.4</td><td>56.6</td><td>15.6</td></tr></table>
154
+
155
+ It shows that we can achieve similar performances with Grounding DINO-Training only text and fusion blocks using a pre-trained DINO. Interestingly, the DINO-pre-trained Grounding DINO outperforms standard Grounding DINO on LVIS under the same setting. The results show that there might be much room for model training improvement, which will be our future work to explore.
156
+
157
+ # 5 CONCLUSION
158
+
159
+ 5!We have presented a Grounding DINO model in this paper. Grounding DINO extends DINO to open-set object detection, enabling it to detect arbitrary objects given texts as queries. We review open-set object detector designs and propose a tight fusion approach to better fusing cross-modality information. We propose a subsentence level representation to use detection data for text prompts in a more reasonable way.
160
+
161
+ Table 7: Transfer pre-trained DINO to Grounding DINO. We freeze shared modules between DINO and Grounding DINO during grounded fine-tuning. All models are trained with a Swin Transformer
162
+
163
+ <table><tr><td rowspan="2">Model</td><td colspan="2">DINPei</td><td rowspan="2">COcO minival</td><td rowspan="2">LVIS minival</td><td rowspan="2">ODisWt</td></tr><tr><td></td><td></td></tr><tr><td>GroundigDINOT</td><td>:</td><td>0366lG</td><td>467</td><td>162</td><td></td></tr><tr><td>GroundingDINO T</td><td>0365</td><td>0365</td><td>46.5</td><td>17</td><td>13.6</td></tr><tr><td>(from pre-trained DINO)</td><td>0365</td><td>0365,GoldG</td><td>46.4</td><td></td><td>18.5</td></tr></table>
164
+
165
+ Tiny backbone.The results show the effectiveness of our model design and fusion approach. Moreover, we extend open-set object detection to REC tasks and perform evaluation accordingly. We show that existing open-set detectors do not work well for REC data without fine-tuning. Hence we call extra attention to REC zero-shot performance in future studies.
166
+
167
+ Limitations: Despite the great performance on open-set object detection setting, Grounding DINO cannot be used for segmentation tasks like GLIPv2. Our training data is less than the largest GLIP model, which may limit our final performance. Moreover, we find that our model will produce false positive results in some cases, which may need more techniques or data to reduce the hallucination.
168
+
169
+ Reproducibility We will make our code open-source, as well as our online demo. Additionally, we will elucidate our model training parameters, implementation details, and details of training data within this paper, as shown in Sec. 4, Sec. B, and Sec. C, to ensure transparency and reproducibility of our model.
170
+
171
+ REFERENCES
172
+ Peter Anderson, Xiaodong He, Chris Buehler, Damien Teney, Mark Johnson, Stephen Gould, and Lei Zhang. Bottom-up and top-down attention for image captioning and visual question answering. computer vision and pattern recognition, 2017.
173
+ 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, pp. 213–229. Springer, 2020.
174
+ Kai Chen, Jiangmiao Pang, Jiaqi Wang, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jianping Shi, Wanli Ouyang, et al. Hybrid task cascade for instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4974–4983, 2019.
175
+ Qiang Chen, Xiaokang Chen, Jian Wang, Haocheng Feng, Junyu Han, Errui Ding, Gang Zeng, and Jingdong Wang. Group detr: Fast detr training with group-wise one-to-many assignment. 2022.
176
+ Xiyang Dai, Yinpeng Chen, Bin Xiao, Dongdong Chen, Mengchen Liu, Lu Yuan, and Lei Zhang. Dynamic head: Unifying object detection heads with attentions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7373–7382, 2021a.
177
+ Xiyang Dai, Yinpeng Chen, Jianwei Yang, Pengchuan Zhang, Lu Yuan, and Lei Zhang. Dynamic detr: End-to-end object detection with dynamic attention. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 2988–2997, October 2021b.
178
+ Jiajun Deng, Zhengyuan Yang, Tianlang Chen, Wengang Zhou, and Houqiang Li. Transvg: Endto-end visual grounding with transformers. arXiv: Computer Vision and Pattern Recognition, 2021.
179
+ 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.
180
+ Ye Du, Zehua Fu, Qingjie Liu, and Yunhong Wang. Visual grounding with transformers. 2021.
181
+ Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. neural information processing systems, 2020.
182
+ Peng Gao, Shijie Geng, Renrui Zhang, Teli Ma, Rongyao Fang, Yongfeng Zhang, Hongsheng Li, and Yu Qiao. Clip-adapter: Better vision-language models with feature adapters. arXiv preprint arXiv:2110.04544, 2021a.
183
+ Peng Gao, Minghang Zheng, Xiaogang Wang, Jifeng Dai, and Hongsheng Li. Fast convergence of detr with spatially modulated co-attention. arXiv preprint arXiv:2101.07448, 2021b.
184
+ Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. Learning, 2021.
185
+ Agrim Gupta, Piotr Dollar, and Ross Girshick. Lvis: A dataset for large vocabulary instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5356–5364, 2019.
186
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016.
187
+ Ding Jia, Yuhui Yuan, † ‡ Haodi He, † Xiaopei Wu, Haojun Yu, Weihong Lin, Lei Sun, Chao Zhang, and Han Hu. Detrs with hybrid matching. 2022.
188
+
189
+ Aishwarya Kamath, Mannat Singh, Yann LeCun, Gabriel Synnaeve, Ishan Misra, and Nicolas Carion. Mdetr-modulated detection for end-to-end multi-modal understanding. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1780–1790, 2021.
190
+
191
+ Ivan Krasin, Tom Duerig, Neil Alldrin, Vittorio Ferrari, Sami Abu-El-Haija, Alina Kuznetsova, Hassan Rom, Jasper Uijlings, Stefan Popov, Andreas Veit, et al. Openimages: A public dataset for large-scale multi-label and multi-class image classification. Dataset available from https://github. com/openimages, 2(3):18, 2017.
192
+ Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A. Shamma, Michael S. Bernstein, and Li Fei-Fei. Visual genome: Connecting language and vision using crowdsourced dense image annotations. International Journal of Computer Vision, 2017.
193
+ Weicheng Kuo, Fred Bertsch, Wei Li, AJ Piergiovanni, Mohammad Saffar, and Anelia Angelova. Findit: Generalized localization with natural language queries. 2022.
194
+ Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, Tom Duerig, and Vittorio Ferrari. The open images dataset v4: Unified image classification, object detection, and visual relationship detection at scale. arXiv: Computer Vision and Pattern Recognition, 2018.
195
+ Chunyuan Li, Haotian Liu, Liunian Harold Li, Pengchuan Zhang, Jyoti Aneja, Jianwei Yang, Ping Jin, Yong Jae Lee, Houdong Hu, Zicheng Liu, and Jianfeng Gao. Elevater: A benchmark and toolkit for evaluating language-augmented visual models. 2022a.
196
+ Feng Li, Hao Zhang, Shilong Liu, Jian Guo, Lionel M Ni, and Lei Zhang. Dn-detr: Accelerate detr training by introducing query denoising. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13619–13627, 2022b.
197
+ Feng Li, Hao Zhang, Huaizhe Xu, Shilong Liu, Lei Zhang, Lionel M Ni, and Heung-Yeung Shum. Mask dino: Towards a unified transformer-based framework for object detection and segmentation. 2023a.
198
+ Liunian Harold Li, Pengchuan Zhang, Haotian Zhang, Jianwei Yang, Chunyuan Li, Yiwu Zhong, Lijuan Wang, Lu Yuan, Lei Zhang, Jenq-Neng Hwang, et al. Grounded language-image pre-training. arXiv preprint arXiv:2112.03857, 2021.
199
+ Muchen Li and Leonid Sigal. Referring transformer: A one-step approach to multi-task visual grounding. arXiv: Computer Vision and Pattern Recognition, 2021.
200
+ Yuheng Li, Haotian Liu, Qingyang Wu, Fangzhou Mu, Jianwei Yang, Jianfeng Gao, Chunyuan Li, and Yong Jae Lee. Gligen: Open-set grounded text-to-image generation. CVPR, 2023b.
201
+ 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.
202
+ 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.
203
+ Jingyu Liu, Liang Wang, and Ming-Hsuan Yang. Referring expression generation and comprehension via attributes. international conference on computer vision, 2017.
204
+ Shilong Liu, Feng Li, Hao Zhang, Xiao Yang, Xianbiao Qi, Hang Su, Jun Zhu, and Lei Zhang. DAB-DETR: Dynamic anchor boxes are better queries for DETR. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id= oMI9PjOb9Jl.
205
+ 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.
206
+ Depu Meng, Xiaokang Chen, Zejia Fan, Gang Zeng, Houqiang Li, Yuhui Yuan, Lei Sun, and Jingdong Wang. Conditional detr for fast training convergence. arXiv preprint arXiv:2108.06152, 2021.
207
+ Peihan Miao, Wei Su, Lian Wang, Yongjian Fu, and Xi Li. Referring expression comprehension via cross-level multi-modal fusion. ArXiv, abs/2204.09957, 2022.
208
+ Matthias Minderer, Alexey Gritsenko, Austin Stone, Maxim Neumann, Dirk Weissenborn, Alexey Dosovitskiy, Aravindh Mahendran, Anurag Arnab, Mostafa Dehghani, Zhuoran Shen, Xiao Wang, Xiaohua Zhai, Thomas Kipf, and Neil Houlsby. Simple open-vocabulary object detection with vision transformers. 2022.
209
+ Vicente Ordonez, Girish Kulkarni, and Tamara L. Berg. Im2text: Describing images using 1 million captioned photographs. neural information processing systems, 2011.
210
+ Bryan A Plummer, Liwei Wang, Chris M Cervantes, Juan C Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models. In Proceedings of the IEEE international conference on computer vision, pp. 2641–2649, 2015a.
211
+ Bryan A. Plummer, Liwei Wang, Christopher M. Cervantes, Juan C. Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models. International Journal of Computer Vision, 2015b.
212
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(6):1137–1149, 2017.
213
+ 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/CVF Conference on Computer Vision and Pattern Recognition, pp. 658–666, 2019.
214
+ Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- ¨ resolution image synthesis with latent diffusion models, 2021.
215
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. meeting of the association for computational linguistics, 2015.
216
+ Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE international conference on computer vision, pp. 8430–8439, 2019.
217
+ Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. meeting of the association for computational linguistics, 2018.
218
+ Liu Shilong, Liang Yaoyuan, Huang Shijia, Li Feng, Zhang Hao, Su Hang, Zhu Jun, and Zhang Lei. DQ-DETR: Dual query detection transformer for phrase extraction and grounding. In Proceedings of the AAAI Conference on Artificial Intelligence, 2023.
219
+ Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. international conference on machine learning, 2019.
220
+ Bart Thomee, David A. Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas N. Poland, Damian Borth, and Li-Jia Li. Yfcc $1 0 0 \mathrm { m }$ : the new data in multimedia research. Communications of The ACM, 2016.
221
+ Yingming Wang, Xiangyu Zhang, Tong Yang, and Jian Sun. Anchor detr: Query design for transformer-based detector. national conference on artificial intelligence, 2021.
222
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, et al. Huggingface’s transformers: ´ State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019.
223
+ Mengde Xu, Zheng Zhang, Han Hu, Jianfeng Wang, Lijuan Wang, Fangyun Wei, Xiang Bai, and Zicheng Liu. End-to-end semi-supervised object detection with soft teacher. arXiv preprint arXiv:2106.09018, 2021.
224
+ Lewei Yao, Jianhua Han, Youpeng Wen, Xiaodan Liang, Dan Xu, Wei Zhang, Zhenguo Li, Chunjing Xu, and Hang Xu. Detclip: Dictionary-enriched visual-concept paralleled pre-training for openworld detection. 2022.
225
+ Lewei Yao, Jianhua Han, Xiaodan Liang, Dan Xu, Wei Zhang, Zhenguo Li, and Hang Xu. DetCLIPv2: Scalable Open-Vocabulary Object Detection Pre-training via Word-Region Alignment, 2023.
226
+ Licheng Yu, Zhe Lin, Xiaohui Shen, Jimei Yang, Xin Lu, Mohit Bansal, and Tamara L. Berg. Mattnet: Modular attention network for referring expression comprehension. computer vision and pattern recognition, 2018.
227
+ 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. 2022.
228
+ Yuhang Zang, Wei Li, Kaiyang Zhou, Chen Huang, and Chen Change Loy. Open-vocabulary detr with conditional matching. 2022.
229
+ Alireza Zareian, Kevin Dela Rosa, Derek Hao Hu, and Shih-Fu Chang. Open-vocabulary object detection using captions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14393–14402, 2021.
230
+ Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu, Lionel M. Ni, and Heung-Yeung Shum. Dino: Detr with improved denoising anchor boxes for end-to-end object detection, 2022a.
231
+ Haotian Zhang, Pengchuan Zhang, Xiaowei Hu, Yen-Chun Chen, Liunian Harold Li, Xiyang Dai, Lijuan Wang, Lu Yuan, Jenq-Neng Hwang, and Jianfeng Gao. Glipv2: Unifying localization and vision-language understanding. 2022b.
232
+ Haotian Zhang, Pengchuan Zhang, Xiaowei Hu, Yen-Chun Chen, Liunian Harold Li, Xiyang Dai, Lijuan Wang, Lu Yuan, Jenq-Neng Hwang, and Jianfeng Gao. GLIPv2: Unifying Localization and Vision-Language Understanding, 2022c.
233
+ Tiancheng Zhao, Peng Liu, Xiaopeng Lu, and Kyusong Lee. Omdet: Language-aware object detection with large-scale vision-language multi-dataset pre-training. 2022.
234
+ Yiwu Zhong, Jianwei Yang, Pengchuan Zhang, Chunyuan Li, Noel Codella, Liunian Harold Li, Luowei Zhou, Xiyang Dai, Lu Yuan, Yin Li, and Jianfeng Gao. Regionclip: Region-based language-image pretraining. 2022.
235
+ Xingyi Zhou, Dequan Wang, and Philipp Krahenb ¨ uhl. Objects as points. ¨ arXiv preprint arXiv:1904.07850, 2019.
236
+ Xingyi Zhou, Rohit Girdhar, Armand Joulin, Philipp Krahenb ¨ uhl, and Ishan Misra. Detecting ¨ twenty-thousand classes using image-level supervision. In ECCV, 2022.
237
+ Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. In ICLR 2021: The Ninth International Conference on Learning Representations, 2021.
238
+ Xueyan Zou\*, Zi-Yi Dou\*, Jianwei Yang\*, Zhe Gan, Linjie Li, Chunyuan Li, Xiyang Dai, Jianfeng Wang, Lu Yuan, Nanyun Peng, Lijuan Wang, Yong Jae Lee,andJ ianfengGao. Generalizeddecodingforpixel, imageandlanguage. 2022.
239
+
240
+ With a pre-trained DINO initialization, the model converges faster than Grounding DINO from scratch, as shown in Fig. 5. Notably, we use the results without exponential moving average (EMA) for the curves in Fig. 5, which results in a different final performance that in Table 7. As the model trained from scratch need more training time, we only show results of early epochs.
241
+
242
+ # B MORE IMPLEMENTATION DETAILS
243
+
244
+ ![](images/8b85f45556c1fb9c25ff9cc8b9b4caf8ea4f6e0e9c7a78780d75f32996b5fde7.jpg)
245
+ Figure 5: Comparison between two Grounding DINO variants: Training from scratch and transfer from DINO-pretrained models. The models are trained on O365 and evaluated on COCO.
246
+
247
+ By default, we use 900 queries in our model following DINO. We set the maximum text token number as 256. Using BERT as our text encoder, we follow BERT to tokenize texts with a BPE scheme (Sennrich et al., 2015). We use six feature enhancer layers in the feature enhancer module. The cross-modality decoder is composed of six decoder layers as well. We leverage deformable attention (Zhu et al., 2021) in image cross-attention layers.
248
+
249
+ Both matching costs and final losses include classification losses (or contrastive losses), box L1 losses, and GIOU (Rezatofighi et al., 2019) losses. Following DINO, we set the weight of classification costs, box L1 costs, and GIOU costs as 2.0, 5.0, and 2.0, respectively, during Hungarian matching. The corresponding loss weights are 1.0, 5.0, and 2.0 in the final loss calculation.
250
+
251
+ Our Swin Transformer Tiny models are trained on 16 Nvidia V100 GPUs with a total batch size of 32. We extract three image feature scales, from $8 \times$ to $3 2 \times$ . It is named “4scale” in DINO since we downsample the $3 2 \times$ feature map to $6 4 \times$ as an extra feature scale. For the model with Swin Transformer Large, we extract four image feature scales from backbones, from $4 \times$ to $3 2 \times$ . The model is trained on 64 Nvidia A100 GPUs with a total batch size of 64.
252
+
253
+ Table 8: Hyper-parameters used in our pre-trained models.
254
+
255
+ <table><tr><td>Item optimizer</td><td>Value AdamW</td></tr><tr><td>lr lr of image backbone lr of text backbone weight decay clip max norm number of encoder layers number of decoder layers dim feedforward hidden dim dropout nheads number of queries set cost class set cost bbox set cost giou ce loss coef bbox loss coef</td><td>1e-4 1e-5 1e-5 0.0001 0.1 6 6 2048 256 0.0 8 900 1.0 5.0 2.0 2.0 5.0</td></tr></table>
256
+
257
+ # Algorithm 1: Pseudocode of Language-guided Query Selection in PyTorch-like style.
258
+
259
+ """
260
+ Input:
261
+ image_feat: (bs, num_img_tokens, ndim) text_feat: (bs, num_text_tokens, ndim) num_query: int.
262
+ Output:
263
+ topk_idx: (bs, num_query)
264
+ "
265
+ logits $=$ torch.einsum("bic,btc->bit", image_feat, text_feat) # bs, num_img_tokens, num_text_tokens
266
+ logits_per_img_feat $=$ logits.max(-1)[0]# bs, num_img_tokens
267
+ topk_idx $=$ torch.topk(logits_per_img_feature, num_query, dim $^ { 1 = 1 }$ )[1] # bs, num_query
268
+
269
+ The variables image feat and text feat are used for image and text features, respectively. num query is the number of queries in the decoder, which is set to 900 in our implementation. We use bs and ndim for batch size and feature dimension in the pseudo-code. num img tokens and num text tokens are used for the number of image and text tokens, respectively.
270
+
271
+ # C DATA USAGE
272
+
273
+ We use three types of data in our model pre-train.
274
+
275
+ 1. Detection data. Following GLIP (Li et al., 2021), we reformulate the object detection task to a phrase grounding task by concatenating the category names into text prompts. We use COCO (Lin et al., 2014), O365 (Shao et al., 2019), and OpenImage(OI) (Krasin et al., 2017) for our model pretrain. To simulate different text inputs, we randomly sampled category names from all categories in a dataset on the fly during training.
276
+
277
+ 2. Grounding data. We use the GoldG and RefC data as grounding data. Both GoldG and RefC are preprocessed by MDETR (Kamath et al., 2021). These data can be fed into Grounding DINO directly. GoldG contains images in Flickr30k entities (Plummer et al., 2015a;b) and Visual Genome (Krishna et al., 2017). RefC contains images in RefCOCO, RefCOCO $^ +$ , and RefCOCOg.
278
+
279
+ 3. Caption data. To enhance the model performance on novel categories, we feed the semanticrich caption data to our model. Following GLIP, we use the pseudo-labeled caption data for model training. In our experiments, we use the same data with GLIP under comparable settings. More specifically, we use GLIP-T annotated caption data for Grounding DINO T, while GLIP-L annotated caption data for Grounding DINO L.
280
+
281
+ There are two versions of the O365 dataset, which we termed O365v1 and O365v2, respectively. O365v1 is a subset of O365v2. O365v1 contains about 600K images, while O365v2 contains about 1.7M images. Following previous works (Li et al., 2021; Yao et al., 2022), we pre-train the Grounding DINO T on O365v1 for a fair comparison. The Grounding DINO L is pre-trained on O365v2 for a better result.
282
+
283
+ # D MORE RESULTS ON COCO DETECTION BENCHMARKS
284
+
285
+ # D.1 COCO DETECTION RESULTS UNDER THE $1 \times$ SETTING
286
+
287
+ We present the performance of Grounding DINO on standard COCO detection benchmark in Table 9. All models are trained with a ResNet-50 (He et al., 2016) backbone for 12 epochs. Grounding DINO achieves 48.1 AP under the research setting, which shows that Grounding DINO is a strong closed-set detector. However, it is inferior compared with the original DINO. We suspect that the new components may make the model harder to optimize than DINO.
288
+
289
+ Table 9: Results for Grounding DINO and other detection models with the ResNet50 backbone on COCO val2017 trained with 12 epochs (the so called $1 \times$ setting).
290
+
291
+ <table><tr><td>Model</td><td>Epochs</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>Faster-RCNN(5scale) (Ren et al., 2017)</td><td>12</td><td>37.9</td><td>58.8</td><td>41.1</td><td>22.4</td><td>41.1</td><td>49.1</td></tr><tr><td>DETR(DC5) (Carion et al., 2020)</td><td>12</td><td>15.5</td><td>29.4</td><td>14.5</td><td>4.3</td><td>15.1</td><td>26.7</td></tr><tr><td>Deformable DETR(4scale)(Zhu et al.,2021)</td><td>12</td><td>41.1</td><td>1</td><td>1</td><td></td><td></td><td></td></tr><tr><td>DAB-DETR(DC5)† (Liu et al., 2022)</td><td>12</td><td>38.0</td><td>60.3</td><td>39.8</td><td>19.2</td><td>40.9</td><td>55.4</td></tr><tr><td>Dynamic DETR(5scale) (Dai et al.,2021b)</td><td>12</td><td>42.9</td><td>61.0</td><td>46.3</td><td>24.6</td><td>44.9</td><td>54.4</td></tr><tr><td>Dynamic Head(5scale) (Dai et al.,2021a)</td><td>12</td><td>43.0</td><td>60.7</td><td>46.8</td><td>24.7</td><td>46.4</td><td>53.9</td></tr><tr><td>HTC(5scale) (Chen et al.,2019)</td><td>12</td><td>42.3</td><td></td><td></td><td></td><td>一</td><td></td></tr><tr><td>DN-Deformable-DETR(4scale)(Li etal.,2022b)</td><td>12</td><td>43.4</td><td>61.9</td><td>47.2</td><td>24.8</td><td>46.8</td><td>59.4</td></tr><tr><td>DINO-4scale (Zhang et al.,2022a)</td><td>12</td><td>49.0</td><td>66.6</td><td>53.5</td><td>32.0</td><td>52.3</td><td>63.0</td></tr><tr><td>Grounding DINO (4scale)</td><td>12</td><td>48.1</td><td>65.8</td><td>52.3</td><td>30.4</td><td>51.3</td><td>62.3</td></tr></table>
292
+
293
+ ![](images/2a938feaec9aa1993def0e15439f8d51094f30cea11c603daeeee48e4ffd75e5.jpg)
294
+ Figure 6: Comparison between DINO and our Grounding DINO. We mark the modifications in blue. Best view in color.
295
+
296
+ # E DETAILED RESULTS ON ODINW
297
+
298
+ We present detailed results of Grounding DINO on ODinW35(Li et al., 2022a) in Table 10, Table 11, and Table 12.
299
+
300
+ # E.1 COMPARISON BETWEEN GROUNDING DINO AND GLIP ON ODINW
301
+
302
+ In our comparison of Grounding DINO and GLIP across various datasets in ODinW, as presented in Table 13, we observe that Grounding DINO underperforms on certain uncommon datasets where both models generally show limited effectiveness. For instance, in the PlantDoc dataset, Grounding DINO scores 0.36 compared to GLIP’s 1.1. This dataset includes infrequent categories such as ”Tomato leaf mosaic virus,” which are not well-represented in the training data. These findings highlight the need for improving data quality to enhance overall model performance.
303
+
304
+ <table><tr><td>Dataset</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td> AerialMaritimeDrone_large</td><td>9.48</td><td>15.61</td><td>8.35</td><td>8.72</td><td>10.28</td><td>2.91</td></tr><tr><td>AerialMaritimeDrone_tiled</td><td>17.56</td><td>26.35</td><td>13.89</td><td>0</td><td>1.61</td><td>28.7</td></tr><tr><td>AmericanSignLanguageLetters</td><td>1.45</td><td>2.21</td><td>1.39</td><td>-1</td><td>-1</td><td>1.81</td></tr><tr><td>Aquarium</td><td>18.83</td><td>34.32</td><td>18.19</td><td>10.65</td><td>20.64</td><td>21.52</td></tr><tr><td>BCCD_BCCD</td><td>6.17</td><td>11.31</td><td>6.04</td><td>1.27</td><td>9.09</td><td>6.89</td></tr><tr><td>ChessPiece</td><td>6.99</td><td>11.13</td><td>9.03</td><td>-1</td><td>-1</td><td>8.11</td></tr><tr><td>CottontailRabbits</td><td>71.93</td><td>85.05</td><td>85.05</td><td>-1</td><td>70</td><td>73.58</td></tr><tr><td>DroneControl_Drone_Control</td><td>6.15</td><td>10.95</td><td>6.23</td><td>2.08</td><td>6.91</td><td>6.16</td></tr><tr><td>EgoHands_generic</td><td>48.07</td><td>75.06</td><td>56.52</td><td>1.48</td><td>11.42</td><td>51.84</td></tr><tr><td>EgoHands_specific</td><td>0.66</td><td>1.25</td><td>0.64</td><td>0</td><td>0.02</td><td>0.92</td></tr><tr><td>HardHatWorkers</td><td>2.39</td><td>9.17</td><td>1.07</td><td>2.13</td><td>4.32</td><td>4.6</td></tr><tr><td>MaskWearing</td><td>0.58</td><td>1.43</td><td>0.56</td><td>0.12</td><td>0.51</td><td>4.66</td></tr><tr><td>MountainDewCommercial</td><td>18.22</td><td>29.73</td><td>21.33</td><td>0</td><td>23.23</td><td>49.8</td></tr><tr><td>NorthAmericaMushrooms</td><td>65.48</td><td>71.26</td><td>66.18</td><td>-1</td><td>-1</td><td>65.49</td></tr><tr><td>OxfordPets_by-breed</td><td>0.27</td><td>0.6</td><td>0.21</td><td>-1</td><td>1.38</td><td>0.33</td></tr><tr><td>OxfordPets_by-species</td><td>1.66</td><td>5.02</td><td>1</td><td>-1</td><td>0.65</td><td>1.89</td></tr><tr><td>PKLot_640</td><td>0.08</td><td>0.26</td><td>0.02</td><td>0.14</td><td>0.79</td><td>0.11</td></tr><tr><td>Packages</td><td>56.34</td><td>68.65</td><td>68.65</td><td>-1</td><td>-1</td><td>56.34</td></tr><tr><td>PascalVOC</td><td>47.21</td><td>57.59</td><td>51.28</td><td>16.53</td><td>39.51</td><td>58.5</td></tr><tr><td>Raccoon_Raccoon</td><td>44.82</td><td>76.44</td><td>46.16</td><td>-1</td><td>17.08</td><td>48.56</td></tr><tr><td>ShellfishOpenImages</td><td>23.08</td><td>32.21</td><td>26.94</td><td>-1</td><td>18.82</td><td>23.28</td></tr><tr><td>ThermalCheetah</td><td>12.9</td><td>19.65</td><td>14.72</td><td>0</td><td>8.35</td><td>50.15</td></tr><tr><td>UnoCards</td><td>0.87</td><td>1.52</td><td>0.96</td><td>2.91</td><td>2.18</td><td>-1</td></tr><tr><td>VehiclesOpenImages</td><td>59.24</td><td>71.88</td><td>64.69</td><td>7.42</td><td>32.38</td><td>72.21</td></tr><tr><td>WildfireSmoke</td><td>25.6</td><td>43.96</td><td>25.34</td><td>5.03</td><td>18.85</td><td>42.59</td></tr><tr><td>boggleBoards</td><td>0.81</td><td>2.92</td><td>0.12</td><td>2.96</td><td>1.13</td><td>-1</td></tr><tr><td>brackishUnderwater</td><td>1.3</td><td>1.88</td><td>1.4</td><td>0.99</td><td>1.75</td><td>11.39</td></tr><tr><td>dice_mediumColor</td><td>0.16</td><td>0.72</td><td>0.07</td><td>0.38</td><td>3.3</td><td>2.23</td></tr><tr><td>openPoetry Vision</td><td>0.18</td><td>0.5</td><td>0.06</td><td>-1</td><td>0.25</td><td>0.17</td></tr><tr><td>pistols</td><td>46.4</td><td>66.47</td><td>47.98</td><td>4.51</td><td>22.94</td><td>55.03</td></tr><tr><td>plantdoc</td><td>0.34</td><td>0.51</td><td>0.35</td><td>-1</td><td>0.28</td><td>0.86</td></tr><tr><td>pothole</td><td>19.87</td><td>28.94</td><td>22.23</td><td>12.49</td><td>15.6</td><td>28.78</td></tr><tr><td>selfdrivingCa</td><td>9.46</td><td>19.13</td><td>8.19</td><td>0.85</td><td>6.82</td><td>16.51</td></tr><tr><td> thermalDogsAndPeople</td><td>72.67</td><td>86.65</td><td>79.98</td><td>33.93</td><td>30.2</td><td>86.71</td></tr><tr><td>websiteScreenshots</td><td>1.51</td><td>2.8</td><td>1.42</td><td>0.85</td><td>2.06</td><td>2.59</td></tr></table>
305
+
306
+ Table 10: Detailed results on 35 datasets in ODinW of Grounding DINO with Swin-T pre-trained on O365 and GoldG.
307
+
308
+ <table><tr><td>Dataset</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td> AerialMaritimeDrone_large</td><td>10.3</td><td>18.17</td><td>9.21</td><td>8.92</td><td>11.2</td><td>7.35</td></tr><tr><td>AerialMaritimeDrone_tiled</td><td>17.5</td><td>28.04</td><td>18.58</td><td>0</td><td>3.64</td><td>24.16</td></tr><tr><td>AmericanSignLanguageLetters</td><td>0.78</td><td>1.17</td><td>0.76</td><td>-1</td><td>-1</td><td>1.02</td></tr><tr><td>Aquarium</td><td>18.64</td><td>35.27</td><td>17.29</td><td>11.33</td><td>17.8</td><td>21.34</td></tr><tr><td>BCCD_BCCD</td><td>11.96</td><td>22.77</td><td>8.65</td><td>0.16</td><td>5.02</td><td>13.15</td></tr><tr><td>ChessPiece</td><td>15.62</td><td>22.02</td><td>20.19</td><td>-1</td><td>-1</td><td>15.72</td></tr><tr><td>CottontailRabbits</td><td>67.61</td><td>78.82</td><td>78.82</td><td>-1</td><td>70</td><td>68.09</td></tr><tr><td>DroneControl_Drone_Control</td><td>4.99</td><td>8.76</td><td>5</td><td>0.65</td><td>5.03</td><td>8.61</td></tr><tr><td>EgoHands_generic</td><td>57.64</td><td>90.18</td><td>66.78</td><td>3.74</td><td>24.67</td><td>61.33</td></tr><tr><td>EgoHands_specific</td><td>0.69</td><td>1.37</td><td>0.63</td><td>0</td><td>0.02</td><td>1.03</td></tr><tr><td>HardHatWorkers</td><td>4.05</td><td>13.16</td><td>1.96</td><td>2.29</td><td>7.55</td><td>9.81</td></tr><tr><td>MaskWearing</td><td>0.25</td><td>0.81</td><td>0.15</td><td>0.09</td><td>0.13</td><td>2.78</td></tr><tr><td>MountainDewCommercial</td><td>25.46</td><td>39.08</td><td>28.89</td><td>0</td><td>32.53</td><td>58.38</td></tr><tr><td>NorthAmericaMushrooms</td><td>68.18</td><td>72.89</td><td>69.75</td><td>-1</td><td>-1</td><td>68.62</td></tr><tr><td>OxfordPets_by-breed</td><td>0.21</td><td>0.42</td><td>0.22</td><td>-1</td><td>2.91</td><td>0.17</td></tr><tr><td>OxfordPets_by-species</td><td>1.3</td><td>3.95</td><td>0.71</td><td>-1</td><td>0.28</td><td>1.62</td></tr><tr><td>PKLot_640</td><td>0.06</td><td>0.18</td><td>0.02</td><td>0.03</td><td>0.59</td><td>0.15</td></tr><tr><td>Packages</td><td>60.53</td><td>76.24</td><td>76.24</td><td>-1</td><td>-1</td><td>60.53</td></tr><tr><td>PascalVOC</td><td>55.65</td><td>66.51</td><td>60.47</td><td>19.61</td><td>44.25</td><td>67.21</td></tr><tr><td>Raccoon_Raccoon</td><td>60.07</td><td>84.81</td><td>66.5</td><td>-1</td><td>11.23</td><td>65.86</td></tr><tr><td>ShellfishOpenImages</td><td>29.56</td><td>38.08</td><td>33.5</td><td>-1</td><td>6.38</td><td>29.95</td></tr><tr><td>ThermalCheetah</td><td>17.72</td><td>25.93</td><td>19.61</td><td>1.04</td><td>20.02</td><td>63.69</td></tr><tr><td>UnoCards</td><td>0.81</td><td>1.3</td><td>1</td><td>2.6</td><td>1.01</td><td>-1</td></tr><tr><td>VehiclesOpenImages</td><td>58.49</td><td>71.56</td><td>63.64</td><td>8.22</td><td>28.03</td><td>71.1</td></tr><tr><td>WildfireSmoke</td><td>20.04</td><td>39.74</td><td>22.49</td><td>4.13</td><td>15.71</td><td>30.41</td></tr><tr><td>boggleBoards</td><td>0.29</td><td>1.15</td><td>0.04</td><td>1.8</td><td>0.57</td><td>-1</td></tr><tr><td>brackishUnderwater</td><td>1.47</td><td>2.34</td><td>1.58</td><td>2.32</td><td>3.31</td><td>9.96</td></tr><tr><td>dice_mediumColor</td><td>0.33</td><td>1.38</td><td>0.15</td><td>0.03</td><td>1.05</td><td>12.57</td></tr><tr><td>openPoetry Vision</td><td>0.05</td><td>0.19</td><td>0</td><td>-1</td><td>0.09</td><td>0.21</td></tr><tr><td>pistols</td><td>66.99</td><td>86.34</td><td>72.65</td><td>16.25</td><td>39.24</td><td>75.98</td></tr><tr><td>plantdoc</td><td>0.36</td><td>0.47</td><td>0.39</td><td>-1</td><td>0.24</td><td>0.82</td></tr><tr><td>pothole</td><td>25.21</td><td>38.21</td><td>26.01</td><td>8.94</td><td>18.45</td><td>39.28</td></tr><tr><td>selfdrivingCa</td><td>9.95</td><td>20.55</td><td>8.28</td><td>1.36</td><td>7.27</td><td>15.46</td></tr><tr><td> thermalDogsAndPeople</td><td>67.89</td><td>80.85</td><td>78.66</td><td>45.05</td><td>30.24</td><td>85.56</td></tr><tr><td>websiteScreenshots</td><td>1.3</td><td>2.26</td><td>1.21</td><td>0.95</td><td>1.81</td><td>2.23</td></tr></table>
309
+
310
+ Table 11: Detailed results on 35 datasets in ODinW of Grounding DINO with Swin-T pre-trained on O365, GoldG, and Cap4M.
311
+
312
+ <table><tr><td>Dataset</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>AerialMaritimeDrone_large</td><td>12.64</td><td>18.44</td><td>14.75</td><td>9.15</td><td>19.16</td><td>0.98</td></tr><tr><td>AerialMaritimeDrone_tiled</td><td>20.47</td><td>34.81</td><td>12.79</td><td>0</td><td>7.61</td><td>26.93</td></tr><tr><td>AmericanSignLanguageLetters</td><td>3.94</td><td>4.84</td><td>4</td><td>-1</td><td>-1</td><td>4.48</td></tr><tr><td>Aquarium</td><td>28.14</td><td>45.47</td><td>30.97</td><td>12.1</td><td>24.71</td><td>39.42</td></tr><tr><td>BCCD_BCCD</td><td>23.85</td><td>36.92</td><td>28.88</td><td>0.3</td><td>10.8</td><td>24.43</td></tr><tr><td>ChessPiece</td><td>18.44</td><td>26.3</td><td>23.33</td><td>-1</td><td>-1</td><td>18.62</td></tr><tr><td>CottontailRabbits</td><td>71.66</td><td>88.48</td><td>88.48</td><td>-1</td><td>66</td><td>73.04</td></tr><tr><td>DroneControl_Drone_Control</td><td>7.16</td><td>11.56</td><td>7.67</td><td>2.29</td><td>10.6</td><td>7.68</td></tr><tr><td>EgoHands_generic</td><td>52.08</td><td>81.57</td><td>59.15</td><td>1.12</td><td>31.78</td><td>55.46</td></tr><tr><td>EgoHands_specific</td><td>1.22</td><td>2.28</td><td>1.2</td><td>0</td><td>0.05</td><td>1.5</td></tr><tr><td>HardHatWorkers</td><td>9.14</td><td>23.64</td><td>5.6</td><td>5.09</td><td>15.34</td><td>13.59</td></tr><tr><td>MaskWearing</td><td>1.64</td><td>4.69</td><td>1.18</td><td>0.44</td><td>1.05</td><td>8.67</td></tr><tr><td>MountainDewCommercial</td><td>33.28</td><td>53.59</td><td>32.76</td><td>0</td><td>35.86</td><td>80</td></tr><tr><td>NorthAmericaMushrooms</td><td>72.33</td><td>73.18</td><td>73.18</td><td>-1</td><td>-1</td><td>72.39</td></tr><tr><td>OxfordPets_by-breed</td><td>0.58</td><td>1.05</td><td>0.59</td><td>-1</td><td>4.46</td><td>0.6</td></tr><tr><td>OxfordPets_by-species</td><td>1.64</td><td>4.8</td><td>0.87</td><td>-1</td><td>1.51</td><td>1.8</td></tr><tr><td>PKLot_640</td><td>0.25</td><td>0.71</td><td>0.05</td><td>0.31</td><td>1.44</td><td>0.4</td></tr><tr><td>Packages</td><td>63.86</td><td>76.24</td><td>76.24</td><td>-1</td><td>-1</td><td>63.86</td></tr><tr><td>PascalVOC</td><td>66.01</td><td>76.65</td><td>71.8</td><td>32.01</td><td>55.7</td><td>75.37</td></tr><tr><td>Raccoon_Raccoon</td><td>65.81</td><td>90.39</td><td>69.93</td><td>-1</td><td>26</td><td>68.97</td></tr><tr><td> ShellfishOpenImages</td><td>62.47</td><td>74.25</td><td>70.07</td><td>-1</td><td>26</td><td>63.06</td></tr><tr><td>ThermalCheetah</td><td>21.33</td><td>26.11</td><td>24.92</td><td>2.39</td><td>15.84</td><td>75.34</td></tr><tr><td>UnoCards</td><td>0.52</td><td>0.84</td><td>0.66</td><td>3.02</td><td>0.92</td><td>-1</td></tr><tr><td>VehiclesOpenImages</td><td>62.74</td><td>75.15</td><td>67.23</td><td>10.66</td><td>47.46</td><td>76.36</td></tr><tr><td>WildfireSmoke</td><td>23.66</td><td>45.72</td><td>25.06</td><td>1.58</td><td>22.22</td><td>35.27</td></tr><tr><td>boggleBoards</td><td>0.28</td><td>1.04</td><td>0.05</td><td>5.64</td><td>0.7</td><td>-1</td></tr><tr><td>brackishUnderwater</td><td>2.41</td><td>3.39</td><td>2.79</td><td>4.43</td><td>3.88</td><td>21.22</td></tr><tr><td>dice_mediumColor</td><td>0.26</td><td>1.15</td><td>0.03</td><td>0</td><td>1.09</td><td>4.07</td></tr><tr><td>openPoetry Vision</td><td>0.08</td><td>0.35</td><td>0.01</td><td>-1</td><td>0.15</td><td>0.11</td></tr><tr><td>pistols</td><td>71.4</td><td>90.69</td><td>77.21</td><td>18.74</td><td>39.58</td><td>80.78</td></tr><tr><td>plantdoc</td><td>2.02</td><td>2.64</td><td>2.37</td><td>-1</td><td>0.5</td><td>2.82</td></tr><tr><td>pothole</td><td>30.4</td><td>44.22</td><td>33.84</td><td>12.27</td><td>18.84</td><td>48.57</td></tr><tr><td>selfdrivingCa</td><td>9.25</td><td>17.72</td><td>8.39</td><td>1.93</td><td>7.03</td><td>13.02</td></tr><tr><td>thermalDogsAndPeople</td><td>72.02</td><td>86.02</td><td>79.47</td><td>29.16</td><td>68.05</td><td>86.75</td></tr><tr><td>websiteScreenshots</td><td>1.32</td><td>2.64</td><td>1.16</td><td>0.79</td><td>1.8</td><td>2.46</td></tr></table>
313
+
314
+ Table 12: Detailed results on 35 datasets in ODinW of Grounding DINO with Swin-L pre-trained on O365, OI, GoldG, Cap4M, COCO, and RefC.
315
+
316
+ Table 13: Comparison of Grounding DINO and GLIP on ODinW. Both models are trained on O365, GoldG, and Cap4M with Swin-Tiny backbones.
317
+
318
+ <table><tr><td>Metric</td><td>GLIP-T</td><td>Grounding DINO T</td></tr><tr><td>Average Score (↑)</td><td>19.6</td><td>22.3</td></tr><tr><td>Median Score (↑)</td><td>5.1</td><td>11.9</td></tr><tr><td>AerialMaritimeDrone_large (↑)</td><td>13.70</td><td>10.30</td></tr><tr><td>AerialMaritimeDrone_tiled (↑)</td><td>12.60</td><td>17.50</td></tr><tr><td>AmericanSignLanguageLetters_American_Sign_Language_Letters (↑)</td><td>2.50</td><td>0.78</td></tr><tr><td>Aquarium_Aquarium_Combined (↑)</td><td>18.30</td><td>18.64</td></tr><tr><td>BCCD_BCCD (1)</td><td>1.00</td><td>11.96</td></tr><tr><td>ChessPieces_Chess_Pieces (↑)</td><td>10.00</td><td>15.62</td></tr><tr><td>CottontailRabbits (↑)</td><td>69.70</td><td>67.61</td></tr><tr><td>DroneControl_Drone_Control (↑)</td><td>5.10</td><td>4.99</td></tr><tr><td>EgoHands_generic (↑)</td><td>50.00</td><td>57.64</td></tr><tr><td>EgoHands_specific (↑)</td><td>0.80</td><td>0.69</td></tr><tr><td>HardHatWorkers (↑)</td><td>3.00</td><td>4.05</td></tr><tr><td>MaskWearing (↑)</td><td>1.10</td><td>0.25</td></tr><tr><td>MountainDewCommercial (↑)</td><td>21.60</td><td>25.46</td></tr><tr><td>NorthAmericaMushrooms_North_American_Mushrooms (↑)</td><td>75.10</td><td>68.18</td></tr><tr><td>OxfordPets_by-breed (↑)</td><td>0.40</td><td>0.21</td></tr><tr><td>OxfordPets_by-species (↑)</td><td>1.10</td><td>1.30</td></tr><tr><td>PKLot_640 (1)</td><td>0.00</td><td>0.06</td></tr><tr><td>Packages_Raw (↑)</td><td>72.30</td><td>60.53</td></tr><tr><td>PascalVOC (↑)</td><td>56.10</td><td>55.65</td></tr><tr><td>Raccoon_Raccoon (↑)</td><td>57.80</td><td>60.07</td></tr><tr><td>ShellfishOpenImages (↑)</td><td>25.90</td><td>29.56</td></tr><tr><td>ThermalCheetah (1)</td><td>2.70</td><td>17.72</td></tr><tr><td>UnoCards (1)</td><td>0.20</td><td>0.81</td></tr><tr><td>VehiclesOpenImages (↑)</td><td>56.00</td><td>58.49</td></tr><tr><td>WildfireSmoke (↑)</td><td>2.30</td><td>20.04</td></tr><tr><td>boggleBoards_416x416AutoOrient_export (↑)</td><td>0.00</td><td>0.29</td></tr><tr><td>brackishUnderwater (↑)</td><td>3.70</td><td>1.47</td></tr><tr><td>dice_mediumColor_export (↑)</td><td>1.10</td><td>0.33</td></tr><tr><td>openPoetryVision (↑)</td><td>0.00</td><td>0.05</td></tr><tr><td>pistols_export (↑)</td><td>49.80</td><td>66.99</td></tr><tr><td>plantdoc (↑)</td><td>1.10</td><td>0.36</td></tr><tr><td>pothole (↑)</td><td>17.20</td><td>25.21</td></tr><tr><td>selfdrivingCar_fixedLarge_export (↑)</td><td>8.00</td><td>9.95</td></tr><tr><td>thermalDogsAndPeople (↑)</td><td>43.70</td><td>67.89</td></tr><tr><td>websiteScreenshots (↑)</td><td>0.50</td><td>1.30</td></tr></table>
319
+
320
+ ![](images/f5071ec26df5ce9e424a82b762f5e7d1a18055bf543185423e32fb0a429ebe76.jpg)
321
+ Figure 7: Visualizations of model outputs.
322
+
323
+ # F COMPARISON BETWEEN DINO AND GROUNDING DINO
324
+
325
+ To illustrate the difference between DINO and Grounding DINO, we compare DINO and Grounding DINO in Fig. 6. We mark the DINO blocks in gray, while the newly proposed modules are shaded in blue.
326
+
327
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Pre-Train</td><td colspan="2">ZeroCOco miniva une</td><td rowspan="2">LVIS minival</td><td rowspan="2">ODisWt</td></tr><tr><td></td><td></td></tr><tr><td>Grounding DINO T</td><td>0365,GoldG</td><td>48.1</td><td>57.1</td><td>25.6</td><td>20.0</td></tr><tr><td>Grounding DINO T</td><td>0365,GoldG,RefC</td><td>48.5</td><td>57.3</td><td>21.9</td><td>17.7</td></tr><tr><td>Grounding DINO T</td><td>0365,GoldG,RefC,COCO</td><td>56.1</td><td>57.5</td><td>22.3</td><td>17.4</td></tr></table>
328
+
329
+ Table 14: Impacts of RefC and COCO data for open-set settings. All models are trained with a Swin Transformer Tiny backbone.
330
+
331
+ # G VISUALIZATIONS
332
+
333
+ We present some visualizations in Fig. 7. Our model presents great generalization on different scenes and text inputs. For example, Grounding DINO accurately locates man in blue and child in red in the last image.
334
+
335
+ # H MARRY GROUNDING DINO WITH STABLE DIFFUSION
336
+
337
+ We present an image editing application in Fig. 1 (b). The results in Fig. 1 (b) are generated by two processes. First, we detect objects with Grounding DINO and generate masks by masking out the detected objects or backgrounds. After that, we feed original images, image masks, and generation prompts to an inpainting model (typical Stable Diffusion (Rombach et al., 2021)) to render new images. We use the released checkpoints in https://github.com/Stability-AI/ stablediffusion for new image generation. More results are available in Figure 8.
338
+
339
+ The “detection prompt” is the language input for Grounding DINO, while the “generation prompt” is for the inpainting model.
340
+
341
+ Using GLIGEN for Grounded Generation To enable fine-grained image editing, we combine the Grounding DINO with GLIGEN (Li et al., 2023b). We use the “phrase prompt” in Figure 9 as the input phrases of each box for GLIGEN.
342
+
343
+ GLIGEN supports grounding results as inputs and can generate objects on specific positions. We can assign each bounding box an object with GLIGEN, as shown in Figure 9 (c) (d). Moreover, GLIGEN can full fill each bounding box, which results in better visualization, as that in Figure 9 (a) (b). For example, we use the same generative prompt in Figure 8 (b) and Figure 9 (b). The GLIGEN results ensure each bounding box with an object and fulfills the detected regions.
344
+
345
+ # I EFFECTS OF REFC AND COCO DATA
346
+
347
+ We add the $\operatorname { R e f C O C O } / + / \mathrm { g }$ (we note it as “RefC” in tables) and COCO into training in some settings. We explore the influence of these data in Table 14. The results show that RefC helps improve the COCO zero-shot and fine-tuning performance but hurts the LVIS and ODinW results. With COCO introduced, the COCO results is greatly improved. It shows that COCO brings marginal improvements on LVIS and slightly decreases on ODinW.
348
+
349
+ Table 15: Comparison of model size and model efficiency between GLIP and Grounding DINO.
350
+
351
+ <table><tr><td>Model</td><td>params</td><td>GFLOPS</td><td>FPS</td></tr><tr><td>GLIP-T (Li et al., 2021)</td><td>232M</td><td>488G</td><td>6.11</td></tr><tr><td>Grounding DINO T (Ours)</td><td>172M</td><td>464G</td><td>8.37</td></tr></table>
352
+
353
+ # J MODEL EFFICIENCY
354
+
355
+ We compare the model size and efficiency between Grounding DINO T and GLIP-T in Table 15. The results show that our model has a smaller parameter size and better efficiency than GLIP.
356
+
357
+ ![](images/45c5f2d7a57a58c9a6cac7f772c9fae79a91d7267cb56e02667f80f82528dab5.jpg)
358
+
359
+ (a) Detection Prompt: green mountain Generation Prompt: red mountain.
360
+
361
+ ![](images/05823cfe3b3061dd86463ada1d3c9eb294cbc278337edecdbdbca0fd1af0789b.jpg)
362
+
363
+ Detection Prompt: pandas(b) Generation Prompt: dogs and birthday cakes
364
+
365
+ ![](images/441eeb3838423c59895548a14b29f974d81cef8e7370c5e96ae81d39e2dfa274.jpg)
366
+ (c) Detection Prompt: black cat Generation Prompt: cats and apples
367
+
368
+ ![](images/2dd3df2429a0f9dabe2c47f90522c0e7f7e2e83e98f2b725afa943e427ad91d7.jpg)
369
+
370
+ Detection Prompt: the running girl(d) Generation Prompt (modify background): The Wandering Earth (e)\* Detection Prompt: face Generation Prompt (modify background): a girl with short hair (a) Detection Prompt: sign Generation Prompt: flying birds. Phrase Prompt: flying birds.
371
+
372
+ ![](images/15f96111202bcea8f5a9fc65b0652dd3cdaa441de37690a7c1f0bc551ded8ad6.jpg)
373
+ Figure 8: Combination of Grounding DINO and Stable Diffusion. We first detect objects with Grounding DINO and then perform image inpainting with Stable Diffusion. “Detection Prompt” and “Generation Prompt” are inputs for Grounding DINO and Stable Diffusion, respectively. \*The input human face in the row (e) is generated by StyleGAN.
374
+
375
+ ![](images/9d8b2ecbbd59a149aa8d9b068c1a386b0d8ac6b8741f44d7910db719ad23735f.jpg)
376
+
377
+ ![](images/f3f144845ec620d2a01adf3ff9454475a1c3801ef6de4517067e7c49160f3610.jpg)
378
+
379
+ (b) Detection Prompt: pandas Generation Prompt: dogs and birthday cakes. Phrase Prompt\*: a dog; a cake.
380
+
381
+ ![](images/8f0cdc318e48206ed20f7be5632015235512c5ac212f6238a429fdc36724b993.jpg)
382
+
383
+ (c) Detection Prompt: dog, cat Generation Prompt: a cake and a phone Phrase Prompt\*: a cake; a phone.
384
+
385
+ ![](images/f60ccf1043acc4fd71f0927a3a93342b8745576da60cffd3d502a15eb7af7b64.jpg)
386
+
387
+ (d) Detection Prompt: a sketch person Generation Prompt: a woman and a man are talking Phrase Prompt\*: a woman; a man.
388
+
389
+ Figure 9: Combination of Grounding DINO and GLIGEN. We first detect objects with Grounding DINO and then perform image inpainting with GLIGEN. “Detection Prompt” and “Generation Prompt” are inputs for Grounding DINO and Stable Diffusion, respectively. “Phrase Prompt” are language inputs for each bounding box. The phrase prompts are separated by semicolons. $\ast _ { \mathrm { W e } }$ assign phrase prompts to bounding boxes randomly.
390
+
391
+ # K ABLATIONS FOR MORE DECODER QUERIES
392
+
393
+ To verify the model performance with more decoder queries, we conducted additional experiments with 1200 and 1500 queries on the COCO and LVIS datasets, detailed in Table R.1 below. We trained two model variants: one on O365 and another on O365+GoldG. Both models were initialized with corresponding checkpoints, except for the learnable queries (‘tgt embed‘), to ensure a fair comparison.
394
+
395
+ For training, the O365 model underwent 3 epochs with a learning rate drop at the end of the 2nd epoch, while the O365+GoldG model was trained for 2 epochs with a learning rate reduction at the end of the 1st epoch. All experiments were carried out on 8xA100 GPUs. It’s important to note that due to time and resource constraints, these results might not represent the models’ optimal performance. For instance, the LVIS model could potentially benefit from additional training time post-learning rate drop.
396
+
397
+ The results indicate that models with 1200 and 1500 queries slightly outperform the 900-query version on LVIS rare classes, suggesting better coverage of rare classes. However, the improvement is marginal, as the 900-query model already sufficiently covers all objects in both COCO and LVIS. Additionally, introducing more queries exacerbates data imbalance during training, as the model is trained on objects from sampled categories. This imbalance could offset the benefits of additional queries.
398
+
399
+ <table><tr><td rowspan="2">Pretrain Data</td><td rowspan="2"> Query Num</td><td colspan="4">APSOCPM</td><td colspan="4">APLVIAP</td></tr><tr><td>AP</td><td></td><td></td><td>APL</td><td>AP</td><td></td><td></td><td>APf</td></tr><tr><td>O365+GoldG</td><td>900</td><td>48.2</td><td>34.2</td><td>51.2</td><td>62.1</td><td>21.8</td><td>10.4</td><td>16.2</td><td>28.7</td></tr><tr><td>O365+GoldG</td><td>1200</td><td>48.0</td><td>34.6</td><td>51.2</td><td>62.2</td><td>21.5</td><td>10.9</td><td>15.8</td><td>28.4</td></tr><tr><td>O365+GoldG</td><td>1500</td><td>48.1</td><td>34.7</td><td>51.2</td><td>62.3</td><td>21.8</td><td>11.0</td><td>16.2</td><td>28.7</td></tr><tr><td>0365</td><td>900</td><td>46.4</td><td>33.1</td><td>49.8</td><td>60.2</td><td>14.4</td><td>6.6</td><td>8.0</td><td>21.4</td></tr><tr><td>0365</td><td>1200</td><td>46.5</td><td>32.6</td><td>49.5</td><td>60.4</td><td>14.6</td><td>6.4</td><td>8.4</td><td>21.7</td></tr><tr><td>0365</td><td>1500</td><td>46.3</td><td>32.7</td><td>49.3</td><td>60.3</td><td>14.8</td><td>6.3</td><td>8.6</td><td>21.8</td></tr></table>
400
+
401
+ Table 16: Results for Grounding DINO Tiny with more decoder queries
402
+
403
+ # L RESULTS WITH DIFFERENT LANGUAGE ENCODER FOR REC
404
+
405
+ To verify the impacts of language encoders with different sizes, we conducted experiments using two variants of BERT: bert-base-uncased (BERT-B) and bert-large-uncased (BERT-L). These models were trained on a combined dataset consisting of RefCOCO, RefCOCO $^ +$ , and RefCOCOg. We removed the leaked data in the combined dataset for a fair comparison. It’s important to note that training on this combined dataset, as opposed to tuning each dataset separately, might result in slightly lower performance. For a fair comparison, we initialized the models with the O365+GoldG $^ { + }$ Cap4M checkpoint, except for the BERT parameters. Limited by time and resources, the training duration was capped at 18 epochs.
406
+
407
+ Interestingly, our results showed that Grounding DINO with BERT-B outperformed or matched the BERT-L variant in most metrics (as shown in Table 18). This suggests that our default use of BERT-B during the pretrain stage may have contributed to its better performance. Moreover, we didn’t observe significant improvements in the late stages of training, indicating that both models were nearing their optimal performance.
408
+
409
+ This outcome suggests that the main limitation in enhancing REC performance lies within the detection branch, rather than the language processing module. A dedicated model for REC data might be helpful for REC tasks.
410
+
411
+ # M MODEL COMPARISONS WITH RELATED WORK
412
+
413
+ Table 17: Results for Grounding DINO with different language encoders
414
+
415
+ <table><tr><td rowspan="2">Model</td><td colspan="3">RefCOCO</td><td colspan="3">RefCOCO+</td><td colspan="3">RefCOCOg</td></tr><tr><td>val</td><td>testA</td><td>testB</td><td>val</td><td>testA</td><td>testB</td><td>val</td><td></td><td>test</td></tr><tr><td>Grounding DINO T (BERT-B)</td><td>87.4</td><td>91.6</td><td>84.2</td><td>78.6</td><td>86.5</td><td></td><td>73.4</td><td>81.6</td><td>83.3</td></tr><tr><td>Grounding DINO T (BERT-L)</td><td>87.0</td><td>91.4</td><td>84.0</td><td></td><td>78.1</td><td>86.4</td><td>73.0</td><td>81.7</td><td>83.3</td></tr></table>
416
+
417
+ We discuss the similarities and difference of the feature enhancer and cross-modality decoder in Grounding DINO with two recent works: GLIP and X-Decoder $Z _ { \mathrm { O U } } { } ^ { * }$ et al., 2022). In summary, our feature enhancer is similar with GLIP but more reasonable in our pure Transformer architectures. X-Decoder has no similar modules like our feature enhancer. Our cross-modality decoder, especially the text cross-attention, is unique from the designs in GLIP and X-Decoder. Below are detailed comparisons:
418
+
419
+ # Comparison with GLIP:
420
+
421
+ 1. Feature Enhancer: Our feature enhancer, though similar to GLIP’s, is more aligned with our pure Transformer architecture. While GLIP uses DyHead for enhancing visual features, our method employs a Deformable Transformer for image encoder features, ensuring a more consistent architecture across different modalities.
422
+ 2. Cross-Modality Decoder: Unlike GLIP, which uses the same head as ATSS/RetinaNet, our DETR-like model uniquely incorporates a cross-modality decoder. This decoder leverages the Transformer’s capability to attend to features from both text and image modalities, a distinction we’ve validated through our ablation studies.
423
+
424
+ # Comparison with X-Decoder:
425
+
426
+ 1. Feature Fusion: X-Decoder utilizes a standard image encoder and object decoder for different tasks, without integrating visual and text features during the encoding phase. In contrast, our model employs a feature enhancer for fusing features from both modalities.
427
+ 2. Queries in Decoder: Our model’s queries in the decoder aggregate features from both image and text, unlike X-Decoder’s approach where the interactions are limited to queries and image features only.
428
+
429
+ # N DETIC PSEUDO-LABELED DATA FOR LVIS
430
+
431
+ To illustrate the potential of our model under similar conditions, we conducted oracle experiments. We pseudo-labeled the ImageNet dataset using a pre-trained Detic(Zhou et al., 2022) model and filtered out LVIS-related images for training, creating a new pseudo-labeled dataset named IN22K-LVIS-1M. It contains about 1M pseudo-labeled images for training. Note that our model under the setting may be not a real zero-shot setting, as our pseudo labeler Detic is trained with LVIS data. The results from these experiments suggest that Grounding DINO can achieve promising LVIS performance, even without direct LVIS training data. A similarly distributed dataset can help the model to generalize well.
432
+
433
+ <table><tr><td>Model</td><td>Pre-train Data</td><td colspan="2">Zero-LVIs Minival-APcnetu</td></tr><tr><td>DetCLIPv2-T</td><td></td><td></td><td></td></tr><tr><td rowspan="2">Grounding DINO T</td><td>OG + CC15M</td><td>40.4 (36.0 / 41.7 / 40.0)</td><td>50.7 (44.3 / 52.4 / 50.3)</td></tr><tr><td>0G+IN22K-LVIS-1M</td><td>40.6 (38.5 /41.1 / 40.4)</td><td>54.5 (47.3 / 53.9 / 56.1)</td></tr></table>
434
+
435
+ Table 18: Oracle experiments on LVIS. Note that our model under the setting may be not a real zero-shot setting, as our pseudo labeler Detic is trained with LVIS data.
parse/test/DS5qRs0tQz/DS5qRs0tQz_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DS5qRs0tQz/DS5qRs0tQz_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DS5qRs0tQz/DS5qRs0tQz_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/GEcwtMk1uA/GEcwtMk1uA.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/GEcwtMk1uA/GEcwtMk1uA_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/GEcwtMk1uA/GEcwtMk1uA_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/GEcwtMk1uA/GEcwtMk1uA_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/IB1HqbA2Pn/IB1HqbA2Pn.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/IB1HqbA2Pn/IB1HqbA2Pn_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/IB1HqbA2Pn/IB1HqbA2Pn_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/IB1HqbA2Pn/IB1HqbA2Pn_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/K7KQkiHanD/K7KQkiHanD_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/Oho3UxCkKr/Oho3UxCkKr.md ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SCREWS : A MODULAR FRAMEWORK FOR REASONING WITH REVISIONS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Large language models (LLMs) can improve their accuracy on various tasks through iteratively refining and revising their output based on feedback. We observe that these revisions can introduce errors, in which case it is better to roll back to a previous result. Further, revisions are typically homogeneous: they use the same reasoning method that produced the initial answer, which may not correct errors. To enable exploration in this space, we present SCREWS, a modular framework for reasoning with revisions. It is comprised of three main modules: Sampling, Conditional Resampling, and Selection, each consisting of sub-modules that can be hand-selected per task. We show that SCREWS not only unifies several previous approaches under a common framework, but also reveals several novel strategies for identifying improved reasoning chains. We evaluate our framework with state-of-the-art LLMs (ChatGPT and GPT-4) on a diverse set of reasoning tasks and uncover useful new reasoning strategies for each: arithmetic word problems, multi-hop question answering, and code analysis. Heterogeneous revision strategies prove to be important, as does selection between original and revised candidates.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Large Language Models (LLMs) have proven effective on a variety of reasoning tasks (OpenAI, 2023). However, the LLM output is not always correct on its first attempt, and it is often necessary to iteratively refine the outputs to ensure that the desired goal is achieved (Madaan et al., 2023; Welleck et al., 2022; Zheng et al., 2023). These refinement methods assume that subsequent outputs (either by the same model, or by an external model or some tool) lead to better performance. However, there is no guarantee that subsequent versions must be better; as Fig. 1 illustrates, refinement can lead to a wrong answer. This motivates a Selection strategy whereby the model can select an earlier output.
12
+
13
+ In addition, past work on iterative refinement typically assumes a single, fixed reasoning strategy (Welleck et al., 2022; Huang et al., 2022; Madaan et al., 2023; Zheng et al., 2023). Humans, however, are more flexible. A student preparing for an exam may use deductive reasoning to solve problems and inductive reasoning to verify the results; or a product manager may use a brainstorming strategy to list several ideas and then a prioritization strategy to rank them based on their feasibility or impact. Thus, we propose a modular approach to answer refinements, allowing us to test different strategies.
14
+
15
+ In this work, we introduce SCREWS, a modular framework for reasoning with revisions.1 Fig. 2 introduces the three main modules of the framework in detail, namely Sampling, Conditional Resampling, and Selection. For a given task and input sequence, we instantiate SCREWS by fixing the submodules for each module (for example, we might select “Chain of Thought” for Sampling). The initial outputs generated by Sampling are passed to Conditional Resampling, which decides whether to generate a revision conditioned on the initial sample, and does so if needed. Finally, all samples and revisions are given to the Selection module, which selects the best one. Given the modular nature of our framework, several recently proposed self-refining methods can be improved by using other components of the framework. An example is the combination of the self-refinement method (Madaan et al., 2023) with our model-based selection strategy, which can improve overall performance; more such strategies are described in Sec. 5.
16
+
17
+ We evaluate SCREWS on a variety of reasoning tasks: arithmetic reasoning, multi-hop question answering, and code analysis, using ChatGPT (Brown et al., 2020) or GPT4 (OpenAI, 2023). Our proposed strategies achieve substantial improvements $( 1 0 \mathrm { - } 1 5 \% )$ over vanilla strategies of sampling and resampling. We demonstrate the usefulness of heterogeneous resampling, whereby the model modifies its reasoning, leading to a substantial improvement over the baselines at a very low overall cost. We also discuss the importance of a model-based selection strategy that allows the model to roll back to its previous more confident outputs, an important component for modern LLMs.
18
+
19
+ ![](images/0f594b5ee923ddf00fc7d6ea380fbc7af188fef26e53c2f5e2638f18409f7544.jpg)
20
+ Figure 1: An example demonstrating that Conditional Resampling (also known as “refinement”) can lead to incorrect modification of the original answer. The Selection module can retract it, if needed.
21
+
22
+ # 2 BACKGROUND
23
+
24
+ Sampling Prompting LLMs to generate a series of intermediate steps has proven to be effective for improving their reasoning capabilities (Wei et al., 2022; Lewkowycz et al., 2022; Kojima et al., 2022; Wang et al., 2022). Some approaches in this direction include Chain of Thought (Wei et al., 2022; Zhang et al., 2022; Wang et al., 2022) and adding “Let’s think step by step” to the prompt (Kojima et al., 2022). Another approach is “question decomposition”, which decomposes the main problem into simpler problems and solves them iteratively (Min et al., 2019; Shridhar et al., 2022; Zhou et al., 2022; Jhamtani et al., 2023; Radhakrishnan et al., 2023). Each of these approaches has its own advantages depending on the underlying task (Shridhar et al., 2023). However, we are not aware of work combining these methods.
25
+
26
+ Conditional Resampling The use of feedback to improve generated samples has been well studied, where the feedback can come either from humans (Tandon et al., 2021; Bai et al., 2022; Elgohary et al., 2021), from reward models (Ziegler et al., 2019; Lu et al., 2022; Shridhar et al., 2022; Christiano et al., 2017; Lightman et al., 2023), from external tools such as code interpreters (Schick et al., 2023; Chen et al., 2022), or from other LLMs (Madaan et al., 2023; Welleck et al., 2022; Fu et al., 2023; Peng et al., 2023; Yang et al., 2022; Zheng et al., 2023; Cohen et al., 2023; Ling et al., 2023; Khalifa et al., 2023). However, even if these feedback mechanisms are infallible, the resulting revisions may introduce new errors. While prior work uses the term “refinement,” we do not because refinement implies finer (improved) responses, which is not always the case.
27
+
28
+ Selection When using LLMs revise the output, a common selection technique is to select the final result (Madaan et al., 2023; Shinn et al., 2023; Zheng et al., 2023; Yao et al., 2022; Chen et al., 2023; Weng et al., 2022). However, this can lead to accepting incorrect changes made to previously correct results. Other selection methods involve ranking multiple sampled outputs (Burges et al., 2005; Cobbe et al., 2021) or majority voting (Wang et al., 2022; Lewkowycz et al., 2022; Zheng et al., 2023). These methods often use a homogeneous sampling strategy with changes in hyperparameters. Our work extends the strategy to heterogeneous sampling and selection.
29
+
30
+ # 3 SCREWS: METHODOLOGY
31
+
32
+ In this section, we describe SCREWS, our proposed modular framework for reasoning with revisions to tackle different reasoning tasks. Given a problem $_ \textrm { x }$ , the goal is to generate an answer $a$ , which in our experiments may be a string or a number. SCREWS consists of three main modules: Sampling, Conditional Resampling, and Selection. Different variants of SCREWS are obtained by instantiating these modules in different ways. The options for each module are described below and illustrated schematically in Fig. 2. Note that there are other possible ways to instantiate each module. However in this work, we study only the instantiations described below.
33
+
34
+ ![](images/24b643326014996ce5901c20ec8f2c7f49005bc5b52378decda1453e0c866be1.jpg)
35
+ Figure 2: Overview of our modular framework for reasoning with revisions, SCREWS. Each of the three large boxes (“modules”) contains several alternatives (“submodules”). Several past works can be viewed as instances of our framework, namely Self-Refine (Madaan et al., 2023), Least to Most (Zhou et al., 2022), LLMs Know (Mostly) (Kadavath et al., 2022), Self-Consistency (Wang et al., 2022), Self-Improve (Huang et al., 2022), PHP CoT (Zheng et al., 2023), Self-Correct (Welleck et al., 2022), Socratic CoT (Shridhar et al., 2022), Program of Thoughts (Chen et al., 2022), among many others. (...) represents other sub-components that can be added to each module, like cached memory or web search for Sampling, among others.
36
+
37
+ All of our methods will invoke one or more stochastic functions, where each function $\psi$ maps a tuple of input strings to a result string y that contains useful information. In practice, $\psi$ deterministically constructs a prompt from the input strings and then samples y from a large pretrained language model as a stochastic continuation of this prompt. For a given tuple of input strings, the prompt constructed for $\psi$ will typically be a formatted encoding of this tuple, preceded by a task specific instruction and several demonstrations (few-shot examples) that illustrate how $\psi$ should map other encoded input tuples to their corresponding continuations (Brown et al., 2020).
38
+
39
+ # 3.1 SAMPLING
40
+
41
+ We consider three instantiations of the Sampling module, each may be suitable for different tasks.
42
+
43
+ Answer Only In this method, for a given problem $_ \textrm { x }$ , the model $\psi$ directly generates the answer ${ \mit \Psi } = \psi ( { \bf x } )$ without any intermediate steps. This is the simplest and most naive sampling method. The value of y is returned as the answer $a$ (if there is no further revision of y).
44
+
45
+ Chain of Thought $\mathbf { ( C o T ) }$ For many reasoning tasks today, generating explanations improves the quality of the final answer (Wei et al., 2022; Kojima et al., 2022). Chain of Thought sampling encourages the model to explain the intermediate step-by-step reasoning en route to a decision. This approach is now commonly used in several reasoning tasks. Again, we define $\boldsymbol { \mathrm { y } } = \boldsymbol { \psi } ( \mathbf { x } )$ , but now we expect the prompt continuation to consist of step-by-step reasoning culminating in the step by step answer y, as demonstrated by the few-shot examples included in the prompt. The answer $a$ is extracted from y using a simple deterministic pattern-matching heuristic.
46
+
47
+ Sub-question decomposition This method decomposes the problem $_ \textrm { x }$ into simpler sub-questions $[ x _ { 1 } , x _ { 2 } , \ldots , x _ { n } ]$ . For each sub-question $x _ { i }$ in turn $( i = 1 , 2 , \ldots , n )$ , the model is called to generate the corresponding sub-answer $y _ { i } = \psi ( \mathbf { x } , x _ { 1 } , y _ { 1 } , \ldots , x _ { i - 1 } , y _ { i - 1 } , x _ { i } )$ . Note that we generate all questions before seeing any answers; that choice follows Shridhar et al. (2023), who found this approach to work better than interleaved generation of questions and answers. The sequence of questions may be generated in a single step, either by a call to a stochastic function $\psi _ { \mathrm { q u e s t i o n } }$ , or by a custom question generation module that has been fine-tuned on human-written questions as in Cobbe et al. (2021). The answer $a$ is extracted from $y _ { n }$ with a simple heuristic as in CoT.
48
+
49
+ # 3.2 CONDITIONAL RESAMPLING
50
+
51
+ The result y from the Sampling module can be viewed as a provisional result, $\mathtt { Y } \mathrm { c u r r }$ . This is passed to the Conditional Resampling module where a decision is made whether or not to revise it. This is done in two steps: first deciding whether or not to revise, and then if so, resampling a new result $\mathrm { Y n e x t }$ using one of the sampling methods mentioned above. The resampling is conditional because ynext may depend on $\mathtt { Y } \mathrm { c u r r }$ . Our work focuses on the following instantiations for Conditional Resampling:
52
+
53
+ Self-Ask Kadavath et al. (2022) uses a function $\psi _ { \mathrm { a s k } } ( \mathrm { x } , \mathrm { y } _ { \mathrm { c u r r } } )$ . The first token of the result indicates whether $\mathtt { Y } _ { \mathrm { c u r r } }$ is correct, for example by starting with “Yes” or “No”. If “Yes”, we do not resample; if “No”, we must resample a revised answer $\mathrm { Y n e x t }$ . In principle, the revision could be iterated, although Kadavath et al. (2022) did not do this, nor do our experiments in this paper.
54
+
55
+ In our version of self-ask, $\psi _ { \mathrm { a s k } }$ is formulated so that $\mathrm { Y } _ { \mathrm { n e x t } }$ appears in the result string $\psi _ { \mathrm { a s k } } ( \mathrm { x } , \mathrm { y } _ { \mathrm { c u r r } } )$ following the token “No”. Thus, both steps are efficiently performed by a single call to $\psi _ { \mathrm { a s k } } ( \bf x , \bf y _ { \mathrm { c u r r } } )$ . For this method, we always use greedy decoding (temperature 0) to deterministically select whichever of “Yes” or “No” is more probable.2
56
+
57
+ When the sampling module (Sec. 3.1) used sub-question decomposition to produce a chain of subanswers $\mathtt { y _ { c u r r } } = [ y _ { 1 } , \dots , y _ { n } ]$ , rather than checking and revising only the final result step $y _ { n }$ by calling $\psi _ { \mathrm { a s k } } ( \mathbf { x } , y _ { n } )$ , we can instead check and revise each step, at the cost of more calls to $\psi _ { \mathrm { a s k } }$ . For each provisional sub-answer $y _ { i }$ in turn (starting with $i = 1$ ), we predict whether it is correct by calling $\psi _ { \mathrm { a s k } } ( \mathbf { x } , x _ { 1 } , y _ { 1 } , \dots , x _ { i - 1 } , y _ { i - 1 } , x _ { i } , y _ { i } )$ . The first time the output is “No”, we resample $y _ { i } ^ { \prime }$ through $y _ { n } ^ { \prime }$ , yielding the revised result $\mathbf { \cal { Y } } _ { \mathrm { n e x t } } = [ y _ { 1 } , \dots , y _ { i - 1 } , y _ { i } ^ { \prime } , \dots , y _ { n } ^ { \prime } ]$ . In principle, self-ask could then be applied again at later steps $> i$ of both the original and revised chains; then choosing among the many resulting chains, using the selection procedures of the next section, would resemble branching in a reasoning tree (Yao et al., 2023).
58
+
59
+ Tool use For some tasks, we construct $\psi _ { \mathrm { a s k } }$ so that it is allowed to use tools (Schick et al., 2023). The reason is that in tasks like fact-checking, it is futile to ask the LLM to check $\mathtt { Y } _ { \mathrm { c u r r } }$ because it might not have the requisite knowledge for evaluation. The tools can be used to collect additional information to help the model detect and fix problems in its own generated answer. Tools like search engines or fact retrievers can be used to evaluate correctness and generate a new revision. Other tools like code interpreters are not capable of generating text, but can still be used to evaluate correctness.
60
+
61
+ # 3.3 SELECTION
62
+
63
+ The last module in SCREWS is the Selection module. In this step, we use either a model $\psi _ { \mathrm { s e l e c t } }$ or simple heuristics to select the final result y from which we then extract the final answer $a$ . In effect, this allows us to construct a simple ensemble of multiple systems.
64
+
65
+ LLM-Based Selection Just as an LLM was used above to evaluate whether $\mathtt { Y } \mathrm { c u r r }$ is good, an LLM can be used to evaluate whether $\mathrm { Y n e x t }$ is better. We call $\psi _ { \mathrm { s e l e c t } } ( \mathrm { x , y _ { c u r r } , y _ { n e x t } ) }$ to choose between two result strings.3 Note that it could be naturally extended to choose among more than two answers. When selection and sampling are implemented using the same LLM, we refer to the method as self-select (e.g., in Fig. 2).
66
+
67
+ Rule-Based Selection We consider the other methods we study to be rule-based. Past work on iterative refinement (Madaan et al., 2023; Huang et al., 2022; Zheng et al., 2023) always selects the most recent revision. Majority voting is a simple traditional ensembling method that has been used for selection (Wang et al., 2022; Lewkowycz et al., 2022), but it is costly since it requires several samples.
68
+
69
+ # 4 EXPERIMENTS
70
+
71
+ # 4.1 TASKS
72
+
73
+ We test the effectiveness and flexibility of SCREWS on three categories of reasoning tasks: GSM8K (Cobbe et al., 2021) for arithmetic reasoning, StrategyQA (Geva et al., 2021) for multi-hop question answering, and Big-Bench (BIG-bench authors, 2023) Auto Debugging4 for code analysis. GSM8K is a grade-school-level math word problem dataset with a test set of 1319 samples, each requiring two to eight steps to solve. GSM8K includes sub-questions that were generated by a fine-tuned GPT-3 model and correspond to the steps in a particular correct CoT solution. Since these subquestions were generated with oracle knowledge of a correct CoT solution, we refer to experiments using them as “Subq $\mathrm { ( O r ) ^ { , } }$ . We use “Subq (QG)” for the fairer experimental condition where we instead generated the sub-questions from ChatGPT using 2-shot prompts (shown in Appendix B.4).
74
+
75
+ Following Magister et al. (2023) and Shridhar et al. (2023), we test on the first 490 samples from the training set of StrategyQA (since their test set is unlabeled). The demonstration examples for our various stochastic functions $\psi$ were drawn randomly from the rest of the training set. StrategyQA also includes human-annotated oracle subquestions (again denoted with “Subq $\left( \mathrm { O r } \right) ^ { \mathbf { \eta } , \mathbf { \eta } } ,$ ) and related facts that can assist in answering the main question (which we use for tool-based conditional resampling as in Sec. 3.2). The Auto Debugging dataset tests whether a model can answer questions about the intermediate state of a program without executing the code. The dataset consists of 34 coding examples, of which 33 were used as test examples and 1 as a demonstration example in the prompt.
76
+
77
+ # 4.2 EXPERIMENTAL SETUP
78
+
79
+ We always report exact-match accuracy: the percentage of examples on which our final answer $a$ matches the gold answer. For all of our experiments, we use the ChatGPT API (Brown et al., 2020) from July 2023 (gpt-3.5-turbo-0301).
80
+
81
+ Sampling With all choices of the Sampling module, we use 5-shot sampling for GSM8K and StrategyQA and 1-shot sampling for Auto Debugging (Appendix B.1). Greedy decoding (temp $=$ 0) is used for the main experiments while higher temperature (0.7) is used for the majority voting experiments (one sample was generated greedily and the others at temp $= 0 . 7$ ).
82
+
83
+ Conditional Resampling Greedy decoding is used to first make a binary resampling decision and then to sample. 4-shot prompts (with two correct and two incorrect samples) are used for the GSM8K and StrategyQA datasets, while a 2-shot prompt (with one correct and one incorrect sample) is used for Auto Debugging (Appendix B.2). For StrategyQA, we use tool-based resampling by including the provided facts from the dataset into the prompt to simulate a (perfect) fact retrieval tool.
84
+
85
+ Selection For the self-select strategy, the prompts (Appendix B.3) include two examples and selection was produced with greedy decoding. For majority voting, a majority vote on the final answers was taken over $k \in \{ 1 , \bar { 3 , 4 , 5 } \}$ samples. Ties were broken randomly.
86
+
87
+ # 5 RESULTS
88
+
89
+ # 5.1 GSM8K
90
+
91
+ Conditional Resampling Works Better with Method Change Previous work (Madaan et al., 2023) has shown that when a chain-of-thought method is used for initial Sampling, reasoning ability is improved by Resampling with the same method, taking the previous sample into account.
92
+
93
+ We reproduced this previous finding: the CoT scores for GSM8K improved by 1.4 points after resampling with CoT (71.6 to 73.0), as shown in Tab. 1. However, when the initial Sampling used subquestion decomposition, we found that resampling with subquestion decomposition actually harmed accuracy (71.9 to 71.3 with Subq (QG), 78.6 to 78.2 with Subq (Or)).
94
+
95
+ What gave the best results—for all three Sampling methods—was Conditional Resampling with a different method from the originally chosen one. It gave a large gain over Sampling when the original Sampling used CoT and Resampling used subquestion decomposition (71.6 to 73.7, with generated subquestions) and vice versa (71.9 to 74.0). Even with oracle subquestions, moderate gains are still seen when resampling with CoT (78.6 to 79.0). This demonstrates that it is useful to change methods using Conditional Resampling, a novel finding with our framework.
96
+
97
+ Table 1: The improvements achieved by using Conditional Resampling for the GSM8K dataset, where $\mathrm { y } _ { \mathrm { n e x t } }$ is always selected (\* indicates statistical significance with $p < 0 . 0 5 $ ). Sec. 4.1 describes CoT, Subq (QG), and Subq $( \mathrm { O r } )$ in more detail.
98
+
99
+ <table><tr><td>Sampling</td><td>Accuracy</td><td>Conditional Resampling</td><td>Accuracy</td></tr><tr><td>CoT: Chain of thought</td><td>71.64</td><td>CoT Subq (QG) Subq (Or)</td><td>73.00* 73.99* 73.69 *</td></tr><tr><td>Subq (QG): Subquestion decomposition with ChatGPT-generated questions</td><td>71.87</td><td>CoT Subq (QG) Subq (Or)</td><td>73.99* 71.26 72.80</td></tr><tr><td>Subq (Or): Subquestion decomposition with oracle questions present in GSM8K</td><td>78.62</td><td>CoT Subq (QG) Subq(Or)</td><td>78.99 78.86 78.24</td></tr></table>
100
+
101
+ Table 2: Impact of Selection on the GSM8K data set on Independent Sampling and Conditional Resampling. The upper bound from using a Selection oracle is given in square brackets.
102
+
103
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Independent Sampling</td><td colspan="3">Conditional Resampling</td></tr><tr><td>CoT</td><td>Subq (QG)</td><td>Subq (Or)</td><td>CoT</td><td>Subq (QG)</td><td>Subq (Or)</td></tr><tr><td>CoT</td><td>71.64</td><td></td><td>74.90 [85.36]81.34 [89.08]</td><td></td><td>72.93[73.08]73.76[73.76]73.99[73.99]</td><td></td></tr><tr><td>Subq (QG)74.90 [85.36]</td><td></td><td>71.87</td><td></td><td></td><td>79.99 [87.26]73.99 [75.43]72.40 [72.40]</td><td>73.84 [76.04]</td></tr><tr><td>Subq (Or)</td><td>81.34[89.08]</td><td>79.99 [87.26]</td><td>78.62</td><td></td><td>78.99 [81.50]79.75[80.97]79.22 [79.22]</td><td></td></tr></table>
104
+
105
+ Importance of Selection Module Conditional Resampling does not invariably improve every output. In fact, we saw in Tab. 1 that for some settings, it may harm the output quality even on average. This is why the Selection module is useful—to detect and reject cases of harmful revisions.
106
+
107
+ First, as a starting point, the left half of Tab. 2 considers using Selection only as an ensembling technique to combine the outputs of two independent Sampling strategies. (Note that this matrix is symmetric.) Although CoT and subquestion decomposition are about equally good Sampling strategies (71.6 and 71.9), using a Selection module to select the better of the two achieves a 3-point gain (to 74.9). Much larger gains (up to 85.4) are potentially available from improving Selection— the upper bound on performance (if Selection always chose the better option) is shown in square brackets. This shows that the two Sampling strategies have largely complementary errors. A similar pattern applies when the subquestion decomposition method is permitted to use oracle subquestions, which improves performance across the board to 81.34.
108
+
109
+ The right half of Tab. 2 shows Selection between the Sampled and Conditionally Resampled predictions from Tab. 1. (This matrix is asymmetric.) For CoT, the results remain the same at 73.99, which is due to the fact that the upper bound is at 73.99, showing no room for further improvement. For other cases with subquestioning, we see an improvement of up to 1 point. Finally, we observe that the Selection module is far from perfect and has room for further improvement, as seen from the upper bounds. A Selection method ought to look at features of the two answers that turn out to be correlated with correctness, and we hypothesize that models fine-tuned specifically for Selection may prove more effective than few-shot learning at identifying these features.
110
+
111
+ The right half of Tab. 2 is the cheaper method, because we observe $\psi _ { \mathrm { a s k } }$ resamples on only $5 . 1 5 \%$ of the examples rather than all of them. A tradeoff between accuracy and cost is shown in Fig. 4.
112
+
113
+ ![](images/aee01d64294ebc2dbda75aa69cfd318314ae5a6ef40b5186a030f06d2f3f08a7.jpg)
114
+
115
+ (a) Impact of the number of samples on accuracy when majority voting is used for selection.
116
+
117
+ ![](images/5536602b0de3a6f72bd7e8f17340b944dd4c6780cfaeb1dcfff3f99dab5cc2c2.jpg)
118
+ (b) Comparison of perfect selection $^ { 6 6 } +$ perfect”) vs. majority voting $^ { * * } +$ maj”) across different strategies.
119
+ Figure 3: The $^ +$ in graph (a) shows that majority voting with 3 diverse samples $( \mathbf { C o T } + \mathbf { S u b q } ( \mathbf { O r } ) +$ Subq(QG)) outperforms both CoT and Subq(Or) even with 5 samples. Graph (b) shows the potential of the selection method when a perfect selector is used. It can be thought of as the upper bound of the selection mechanism. Both figures are for the GSM8K dataset.
120
+
121
+ Selection and Voting Unweighted majority vote has been one of the most popular Selection methods in past work (Wang et al., 2022; Lewkowycz et al., 2022; Zheng et al., 2023), since it requires no training. The two lines in Fig. 3(a) generally show improvement from Sampling more times from the same model (at temperature 0.7) and Selecting by majority vote.
122
+
123
+ Recalling that the left half of Tab. 2 showed benefit from ensembling independent samples from 2 different Sampling methods (up to 81.34 accuracy when oracle subquestions are allowed), we observe that majority vote is a convenient way to do so for 3 different methods (where all methods can now use temperature 0). This achieves 83.62 accuracy, as shown by the $\star$ in Fig. 3(a). Of course, model-based Selection could potentially do even better than majority voting. The 7 points for $k \geq 3$ in (a) are repeated as the dark bars in Fig. 3(b), with the light bars showing the upper bounds that could be achieved by replacing majority voting with a perfect Selection method. The best upper bound corresponds again to the use of 3 different methods. In principle, one could ensemble over a larger set by allowing each of the 3 methods to contribute multiple samples.
124
+
125
+ # 5.2 STRATEGYQA
126
+
127
+ Simply resampling does not discover the unknown $ \mathbf { A }$ need for tools For this question answering task, we observe in Tab. 3 that accuracy is harmed by Conditional Resampling with the same Sampling method, without Selection, as was sometimes the case for GSM8K. Here, however, Selection usually does not repair the problem, perhaps because StrategyQA requires factual knowledge. When the model lacks the necessary knowledge, Self-Ask will be insufficient. A real example at the bottom of Fig. 5 shows how resampling can preserve an incorrect model-generated claim.
128
+
129
+ To help the model decide whether and how to revise the answer, we try including relevant facts (provided by StrategyQA) into the resampling prompt to simulate the result one may get by using an external tool like a fact retriever. As Tab. 3 shows, this yields a 2-point improvement (“Factsre” vs. “Internals”) over Sampling, for both CoT and Subq (QG).
130
+
131
+ We assume that tool invocations are expensive, which is why we include facts only during Conditional Resampling. In practice, the initial result is revised only $10 \mathrm { - } 3 5 \%$ of the time, and therefore “Facts” does not need to invoke a tool call for every input example.5 To achieve this speedup, we do not include facts in the prompt when initially calling to $\psi _ { \mathrm { a s k } }$ to decide whether to resample, but only when we actually generate $\mathrm { Y } _ { \mathrm { n e x t } }$ .
132
+
133
+ Table 3: Comparing different strategies for the StrategyQA (top) and Auto Debugging (bottom) datasets. For StrategyQA, external facts are provided to the model (“Facts”) versus relying on the model’s internal capabilities (“Internal”). The upper bound from using a Selection oracle is given in square brackets. Subscripts “s” and $\stackrel { \cdot \cdot } { \mathrm { \Delta } } _ { \mathrm { { r e } } } \stackrel { \cdot \cdot } { \mathrm { \Delta } }$ refer to Sampling and Resampling respectively.
134
+
135
+ <table><tr><td rowspan="2">Method Knowledge Source:</td><td rowspan="2">Sampling Internals</td><td colspan="2">Conditional Resampling</td><td colspan="2">Selection</td></tr><tr><td>Internalre</td><td>Factsre</td><td>Ints vs. Intre</td><td>Ints vs.Factsre</td></tr><tr><td colspan="7"> StrategyQA</td></tr><tr><td>CoT</td><td>77.18</td><td>74.54</td><td>79.02</td><td>75.76</td><td>78.41</td></tr><tr><td>Subq (Or)</td><td>85.91</td><td>78.97</td><td>84.69</td><td>85.30</td><td>86.30</td></tr><tr><td>Subq (QG)</td><td>78.16</td><td>74.69</td><td>80.40</td><td>78.78</td><td>80.00</td></tr><tr><td colspan="6">Auto Debugging</td></tr><tr><td>Answer Only</td><td>73.52</td><td>82.35</td><td></td><td>88.23[91.20]</td><td></td></tr><tr><td>CoT</td><td>70.58</td><td>73.52</td><td></td><td>73.52 [73.52]</td><td></td></tr><tr><td>Answer Only-→CoT</td><td></td><td>1</td><td></td><td>-85.29[88.23]</td><td></td></tr></table>
136
+
137
+ # 5.3 CODE DEBUGGING
138
+
139
+ The effectiveness of SCREWS For the code analysis task, we observed that the Answer Only method achieves similar scores to $\mathrm { C o T } , ^ { 6 }$ as reported in the bottom half of Tab. 3, suggesting that no particular Sampling method is superior on all datasets. However, we see the benefits of using SCREWS, as we find that with Answer Only, adding Conditional Resampling followed by Selection leads to a performance boost of 15 points (from 73.52 to 88.23). While the dataset size limits our ability to make concrete conclusions, the findings here support the conclusions drawn on other datasets: Resampling and Selection lead to benefits and heterogenous sampling can prove effective.
140
+
141
+ # 6 ADDITIONAL ANALYSIS
142
+
143
+ Total Cost SCREWS supports many methods with different cost/accuracy tradeoffs. Fig. 4 displays the strategies that use CoT and Subq (QG) on GSM8K. The cost is represented as the total count of input tokens (prompt $^ +$ query) and output tokens for all LLM calls needed by that strategy, averaged over test examples. Generally, Subq (QG) is expensive as it is costly to call $\psi _ { \mathrm { q u e s t i o n } }$ . However, it is affordable to use it in Conditional Resampling only $( \mathbb { E } ^ { } )$ , since resampling only occurs $1 0 { - } 1 5 \%$ o f the time. This method is both cheaper and more accurate than Sampling either with Subq (QG) $( + )$ or 3 times with CoT (•). Appendix A discusses a detailed breakdown of each module’s input and output token costs.
144
+
145
+ More Revision Steps Sec.5.1 showed that on GSM8K, Sampling with Subq (Or) (78.62 accuracy) is improved slightly by Conditional Resampling with CoT (78.99) and then Selection (79.22). Like Madaan et al. (2023), we did not find much benefit from additional iterations of Conditional Resampling $^ +$ Selection: a second iteration gives 79.45, and a third gives 79.52. These small improvements probably do not justify the added cost.
146
+
147
+ ![](images/0347c54c9f11b54caea3829e7a8e4727cf2c959d7b89a2a993e3f3e416582ecb.jpg)
148
+ Figure 4: On GSM8K, sampling cost vs. accuracy. The blue line (copied from Fig. 3(a)) shows a baseline of majority voting over $k \in$ $\{ 1 , 3 , 4 , 5 \}$ CoT samples. The shaped points are the other strategies from Sec. 5.1 that use CoT and Subq (QG).
149
+
150
+ Larger LLMs Replacing ChatGPT with GPT-4 (OpenAI, 2023) greatly increased the Sampling accuracy on GSM8K, to 91.45 for CoT and 90.80 for Subq (Or). Choosing between those two samples with GPT-4-based Selection further increased the accuracy to 93.10, which falls between the accuracy of majority voting over $k { = } 3$ and $k { = } 4 \mathrm { C o T }$ samples from GPT-4 (92.94 and 93.93 respectively). Even using ChatGPT-based Selection achieved 92.58, which improves over CoT alone.
151
+
152
+ Selected Examples The top two examples of Fig. 5, on the GSM8K dataset, demonstrate the effectiveness of the Selection module. The first example shows how an error introduced by Conditional Resampling can be reverted by Selection. The second example shows how a correction found by Conditional Resampling can be kept by Selection. The last example in Fig. 5, on the StrategyQA dataset, illustrates that ordinary Resampling is unlikely to correct an incorrect fact generated by the LLM. However, providing the correct facts during Resampling gives the model access to new information, leading to the correct answer.
153
+
154
+ ![](images/66c41c403c01f89537385eb35a42f38f412a29459239b8f861c117a7a7829ee5.jpg)
155
+ Figure 5: The top two examples demonstrate the importance of the Selection module for the GSM8K dataset. The last example shows how tool use (“Facts”) can be helpful for the StrategyQA dataset.
156
+
157
+ # 7 CONCLUSION AND FUTURE WORK
158
+
159
+ We have proposed SCREWS, a modular reasoning-with-revisions framework to answer reasoning questions with LLMs. Based on our experiments we conclude the following: 1) Selection plays an important role: Although Conditional Resampling often improves the result of Sampling, Selection can help avoid errors from the case where it does not. It was beneficial on all three datasets; 2) Heterogeneous vs. homogeneous resampling: Using different reasoning methods for Sampling and Conditional Resampling can lead to higher accuracy, with or without Selection; 3) Missing external knowledge hurts Conditional Resampling: Resampling cannot fix incorrect facts generated by the model. Tool-based resampling can therefore get better results (as simulated using StrategyQA); and 4) No uniformly best strategy: There was no clear winning method for each of the modules. Simple baseline methods sometimes beat more complex ones: CoT uses only one call to $\psi$ and beats Subq (QG) in GSM8K, always selecting $\mathrm { Y } _ { \mathrm { n e x t } }$ beats self-select for StrategyQA with “Facts,” and Answer Only works surprisingly well for Code Debugging.
160
+
161
+ SCREWS combines the three important modules Sampling, Conditional Resampling and Selection in a modular framework. However, the best configuration of modules may vary by task and could be identified through a method such as exhaustive search, Monte Carlo Tree Search, or reinforcement learning. The modules themselves could be fine-tuned to improve end-to-end performance. We leave this for future work.
162
+
163
+ # REFERENCES
164
+
165
+ Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, T. J. Henighan, Nicholas Joseph, Saurav Kadavath, John Kernion, Tom Conerly, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Tristan Hume, Scott Johnston, Shauna Kravec, Liane Lovitt, Neel Nanda, Catherine Olsson, Dario Amodei, Tom B. Brown, Jack Clark, Sam McCandlish, Christopher Olah, Benjamin Mann, and Jared Kaplan. Training a helpful and harmless assistant with reinforcement learning from human feedback. ArXiv, abs/2204.05862, 2022.
166
+
167
+ BIG-bench authors. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. Transactions on Machine Learning Research, 2023. ISSN 2835-8856.
168
+ 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.
169
+ Chris Burges, Tal Shaked, Erin Renshaw, Ari Lazier, Matt Deeds, Nicole Hamilton, and Greg Hullender. Learning to rank using gradient descent. In Proceedings of the 22nd International Conference on Machine Learning, ICML ’05, pp. 89–96, New York, NY, USA, 2005. Association for Computing Machinery. ISBN 1595931805.
170
+ Wenhu Chen, Xueguang Ma, Xinyi Wang, and William W. Cohen. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. ArXiv, abs/2211.12588, 2022.
171
+ Xinyun Chen, Maxwell Lin, Nathanael Scharli, and Denny Zhou. ¨ Teaching large language models to self-debug. ArXiv, abs/2304.05128, 2023.
172
+ Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
173
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. ArXiv, abs/2110.14168, 2021.
174
+ Roi Cohen, May Hamri, Mor Geva, and Amir Globerson. LM vs LM: Detecting factual errors via cross examination. ArXiv, abs/2305.13281, 2023.
175
+ Ahmed Elgohary, Christopher Meek, Matthew Richardson, Adam Fourney, Gonzalo Ramos, and Ahmed Hassan Awadallah. NL-EDIT: Correcting semantic parse errors through natural language interaction. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 5599–5610, Online, June 2021. Association for Computational Linguistics.
176
+ Jinlan Fu, See-Kiong Ng, and Zhengbao Jiangan wd Pengfei Liu. GPTScore: Evaluate as you desire. ArXiv, abs/2302.04166, 2023.
177
+ Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did Aristotle use a laptop? A question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9:346–361, 2021.
178
+ Jiaxin Huang, Shixiang Shane Gu, Le Hou, Yuexin Wu, Xuezhi Wang, Hongkun Yu, and Jiawei Han. Large language models can self-improve. ArXiv, abs/2210.11610, 2022.
179
+
180
+ Harsh Jhamtani, Hao Fang, Patrick Xia, Eran Levy, Jacob Andreas, and Benjamin Van Durme. Natural language decomposition and interpretation of complex utterances. ArXiv, abs/2305.08677, 2023.
181
+
182
+ 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, Yuntao 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, abs/2207.05221, 2022.
183
+ Muhammad Khalifa, Lajanugen Logeswaran, Moontae Lee, Ho Hin Lee, and Lu Wang. Discriminator-guided multi-step reasoning with language models. ArXiv, abs/2305.14934, 2023.
184
+ Takeshi Kojima, Shixiang (Shane) Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh (eds.), Advances in Neural Information Processing Systems, volume 35, pp. 22199–22213. Curran Associates, Inc., 2022.
185
+ Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. Solving quantitative reasoning problems with language models. ArXiv, abs/2206.14858, 2022.
186
+ Hunter Lightman, Vineet Kosaraju, Yura Burda, Harrison Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. ArXiv, abs/2305.20050, 2023.
187
+ Z. Ling, Yunhao Fang, Xuanlin Li, Zhiao Huang, Mingu Lee, Roland Memisevic, and Hao Su. Deductive verification of Chain-of-Thought reasoning. ArXiv, abs/2306.03872, 2023.
188
+ Ximing Lu, Sean Welleck, Liwei Jiang, Jack Hessel, Lianhui Qin, Peter West, Prithviraj Ammanabrolu, and Yejin Choi. Quark: Controllable text generation with reinforced unlearning. ArXiv, abs/2205.13636, 2022.
189
+ Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, Sean Welleck, Bodhisattwa Prasad Majumder, Shashank Gupta, Amir Yazdanbakhsh, and Peter Clark. Self-Refine: Iterative refinement with self-feedback. ArXiv, abs/2303.17651, 2023.
190
+ Lucie Charlotte Magister, Jonathan Mallinson, Jakub Adamek, Eric Malmi, and Aliaksei Severyn. Teaching small language models to reason. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 1773–1781, Toronto, Canada, July 2023. Association for Computational Linguistics.
191
+ Sewon Min, Victor Zhong, Luke Zettlemoyer, and Hannaneh Hajishirzi. Multi-hop reading comprehension through question decomposition and rescoring. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 6097–6109, Florence, Italy, July 2019. Association for Computational Linguistics.
192
+ OpenAI. GPT-4 technical report. ArXiv, abs/2303.08774, 2023.
193
+ Baolin Peng, Michel Galley, Pengcheng He, Hao Cheng, Yujia Xie, Yu Hu, Qiuyuan Huang, Lars Liden, Zhou Yu, Weizhu Chen, and Jianfeng Gao. ´ Check your facts and try again: Improving large language models with external knowledge and automated feedback. ArXiv, abs/2302.12813, 2023.
194
+ Ansh Radhakrishnan, Karina Nguyen, Anna Chen, Carol Chen, Carson E. Denison, Danny Hernandez, Esin Durmus, Evan Hubinger, John Kernion, Kamil.e Lukovsiut.e, Newton Cheng, Nicholas Joseph, Nicholas Schiefer, Oliver Rausch, Sam McCandlish, Sheer El Showk, Tamera Lanham, Tim Maxwell, Venkat Chandrasekaran, Zac Hatfield-Dodds, Jared Kaplan, Janina Brauner, Sam Bowman, and Ethan Perez. Question decomposition improves the faithfulness of model-generated reasoning. ArXiv, abs/2307.11768, 2023.
195
+
196
+ 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, abs/2302.04761, 2023.
197
+
198
+ Noah Shinn, Federico Cassano, Beck Labash, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. Reflexion: Language agents with verbal reinforcement learning, 2023.
199
+ Kumar Shridhar, Jakub Macina, Mennatallah El-Assady, Tanmay Sinha, Manu Kapur, and Mrinmaya Sachan. Automatic generation of socratic subquestions for teaching math word problems. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 4136–4149, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics.
200
+ Kumar Shridhar, Alessandro Stolfo, and Mrinmaya Sachan. Distilling reasoning capabilities into smaller language models. In Findings of the Association for Computational Linguistics: ACL 2023, pp. 7059–7073, Toronto, Canada, July 2023. Association for Computational Linguistics.
201
+ Niket Tandon, Aman Madaan, Peter Clark, Keisuke Sakaguchi, and Yiming Yang. Interscript: A dataset for interactive learning of scripts through error feedback. ArXiv, abs/2112.07867, 2021.
202
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Huai hsin Chi, and Denny Zhou. SelfConsistency improves chain of thought reasoning in language models. ArXiv, abs/2203.11171, 2022.
203
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc V. Le, and Denny Zhou. Chain-of-thought prompting elicits reasoning in large language models. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh (eds.), Advances in Neural Information Processing Systems, volume 35, pp. 24824–24837. Curran Associates, Inc., 2022.
204
+ Sean Welleck, Ximing Lu, Peter West, Faeze Brahman, Tianxiao Shen, Daniel Khashabi, and Yejin Choi. Generating sequences by learning to self-correct. ArXiv, abs/2211.00053, 2022.
205
+ Yixuan Weng, Minjun Zhu, Fei Xia, Bin Li, Shizhu He, Kang Liu, and Jun Zhao. Large language models are better reasoners with self-verification. volume abs/2212.09561, 2022.
206
+ Miao Xiong, Zhiyuan Hu, Xinyang Lu, Yifei Li, Jie Fu, Junxian He, and Bryan Hooi. Can LLMs express their uncertainty? an empirical evaluation of confidence elicitation in llms. ArXiv, abs/2306.13063, 2023.
207
+ Kevin Yang, Yuandong Tian, Nanyun Peng, and Dan Klein. Re3: Generating longer stories with recursive reprompting and revision. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 4393–4479, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics.
208
+ Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. ReAct: Synergizing reasoning and acting in language models. ArXiv, abs/2210.03629, 2022.
209
+ Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. ArXiv, abs/2305.10601, 2023.
210
+ Zhuosheng Zhang, Aston Zhang, Mu Li, and Alexander J. Smola. Automatic chain of thought prompting in large language models. ArXiv, abs/2210.03493, 2022.
211
+ Chuanyang Zheng, Zhengying Liu, Enze Xie, Zhenguo Li, and Yu Li. Progressive-Hint Prompting improves reasoning in large language models. ArXiv, abs/2304.09797, 2023.
212
+ Denny Zhou, Nathanael Scharli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Huai hsin Chi. Least-to-most prompting enables complex reasoning in large language models. ArXiv, abs/2205.10625, 2022.
213
+ Daniel M. Ziegler, Nisan Stiennon, Jeff Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. ArXiv, abs/1909.08593, 2019.
214
+
215
+ # A TOKEN COST
216
+
217
+ Tab. A shows the token cost of input and output for each module in SCREWS. Due to its iterative nature, subquestion decomposition requires on average four times more input tokens than the other modules. For Conditional Resampling, the model first predicts whether it wants to modify its output or not, using one token (“Yes” or “No”) for each sample and then only for the answers starting with “No”, it resamples. For the Selection module, the model chooses one of the two samples presented to it, using one token (A or B) for the output.
218
+
219
+ <table><tr><td>Method</td><td>Input Tokens</td><td>Output Tokens</td><td>Total Tokens</td></tr><tr><td colspan="4"> Subquestion generation step question</td></tr><tr><td>Subq (QG)</td><td>360</td><td>180</td><td>540</td></tr><tr><td colspan="4">Sampling step </td></tr><tr><td>CoT</td><td>774</td><td>307</td><td>1081</td></tr><tr><td>CoT(k = 5)</td><td>3870</td><td>1530</td><td>5400</td></tr><tr><td>Subq (Or)</td><td>3187</td><td>413</td><td>3600</td></tr><tr><td>Subq (QG)</td><td>3121</td><td>434</td><td>3555</td></tr><tr><td colspan="4">Conditional Resampling step ask</td></tr><tr><td>CoT</td><td>869</td><td>105</td><td>1184</td></tr><tr><td>Subq (Or)</td><td>3525</td><td>131</td><td>3656</td></tr><tr><td>Subq (QG)</td><td>3780</td><td>136</td><td>3916</td></tr><tr><td colspan="4"> Selection step select</td></tr><tr><td>Selection</td><td>1296</td><td>1</td><td>1297</td></tr></table>
220
+
221
+ Table 4: Average counts of input and output tokens for each choice of each module (step) in SCREWS. Many of the methods in Tab. 1 need to call multiple modules. We remark that the input tokens at each step include output tokens from previous steps. The counts shown for later steps average not only over examples, but also over choices of method for the previous steps.
222
+
223
+ # B PROMPTS
224
+
225
+ Below are abbreviated versions of the prompts used in the experiments, including instructions and demonstrations. For readability, we show only 1–2 demonstrations in each prompt. In each demonstration, the demonstrated result string is highlighted for the reader’s convenience, but this highlighting is not included in the prompt. Each prompt shown would be followed by the test question and then the cue (e.g., “Answer:”) that indicates that a result string should follow.
226
+
227
+ # B.1 SAMPLING
228
+
229
+ For Chain of Thought (CoT) and Subquestion Decomposition for GSM8K and StrategyQA, 5-shot prompts were used. For Auto Debugging, a 1-shot prompt was used.
230
+
231
+ # B.1.1 CHAIN OF THOUGHT
232
+
233
+ # GSM8K
234
+
235
+ I am a highly intelligent question answering bot. I will answer the last question ‘Question’ providing equation in $< < > >$ format in step by step manner.
236
+
237
+ Question: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year?
238
+
239
+ <table><tr><td colspan="10">Answer: He writes each friend 3*2= &lt;&lt;3*2 =6&gt;&gt;6 pages a week. So he writes</td></tr><tr><td colspan="11">6 * 2 = &lt;&lt;6 *2 = 12&gt;&gt;12 pages every week. That means he writes 12 * 52 = &lt;&lt;12 * 52 = 624&gt;&gt;624</td></tr><tr><td colspan="11">pages a year. The answer is 624</td></tr></table>
240
+
241
+ # StrategyQA
242
+
243
+ You are a highly intelligent question answering bot. You will answer the question ‘Question’ in as details as possible.
244
+
245
+ Question: Is coal needed to practice parachuting?
246
+
247
+ Answer: Parachuting requires a parachute. Parachutes are made from nylon. Nylon is made from coal. The answer is True
248
+
249
+ # Auto Debugging
250
+
251
+ Answer the ’Question’ based on the provided code and provide explanation.
252
+
253
+ Question:
254
+
255
+ def f1(): return str(x) $^ +$ 'hello'
256
+ def f2(): return f1 $( 2 + \mathbf { x } )$ )
257
+ $\mathrm { ~ ~ x ~ } = \mathrm { ~ ~ f 2 ~ }$ (524)
258
+
259
+ What is the value of $\mathbf { X }$ at the end of this program? Output: First, x = 2 \* 524 = 1048 and then ‘hello’ is appended to it. So x becomes 1048hello
260
+
261
+ # B.1.2 SUBQUESTION DECOMPOSITION
262
+
263
+ While subquestion decomposition uses a single prompt, each example requires multiple API calls because the next subquestion needs to be appended to the prompt.
264
+
265
+ # GSM8K
266
+
267
+ I am a highly intelligent question answering bot. I will answer the last question ‘Q’ providing equation in $< <$ $> >$ format keeping the Problem and previous Q and A into account.
268
+
269
+ Problem: There are 5 houses on a street, and each of the first four houses has 3 gnomes in the garden. If there are a total of 20 gnomes on the street, how many gnomes does the fifth house have?
270
+
271
+ Q: How many gnomes are in the first four houses?
272
+
273
+ A: In the first four houses, there are a total of 4 houses \* 3 gnomes = <<4 ∗ 3 = 12>>12 gnomes. The answer is 12
274
+ Q: How many gnomes does the fifth house have?
275
+ A: Therefore, the fifth house had 20 total gnomes - 12 gnomes = <<20 − 12 = 8>>8 gnomes. The answer is 8
276
+
277
+ # StrategyQA
278
+
279
+ You are a highly intelligent question answering bot. You will answer the last question ‘Q’ keeping the Problem and previous Q and A into account and then answer the Final Question based on all the previous answer ‘A’.
280
+
281
+ Problem: Is coal needed to practice parachuting?
282
+ Q: What is one of the most important item that you need to go parachuting? A: Parachuting requires a parachute.
283
+ Q: What is #1 made out of?
284
+ A: Parachutes are made from nylon.
285
+ Q: Is #2 originally made from coal?
286
+ A: Nylon is made from coal.
287
+ Final Question: Is coal needed to practice parachuting?
288
+ Final Answer: True
289
+
290
+ # B.1.3 ANSWER ONLY
291
+
292
+ Answer Only was only used for Auto Debugging in a 1-shot manner and that one example is provided below:
293
+
294
+ Input: def f1(): return str(x) + 'hello'
295
+
296
+ def f2(): return f1 $( 2 + \mathbf { x } )$
297
+ x = f2(524)
298
+
299
+ What is the value of $\mathbf { X }$ at the end of this program?
300
+
301
+ Output: 1048hello
302
+
303
+ # B.2 CONDITIONAL RESAMPLING
304
+
305
+ We used 4-shot prompting for conditional resampling (two positive and two negative) for GSM8K and StrategyQA and 2-shot (one positive and one negative) for Auto Debugging. One pair of each is presented below:
306
+
307
+ # B.2.1 CHAIN OF THOUGHT
308
+
309
+ # GSM8K
310
+
311
+ Question: Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?
312
+ Answer: In April, Natalia sold 48 clips. In May, Natalia sold half of the toal clips meaning $7 2 / 2 { < } { < } 7 2 / 2 =$ $3 6 > > 3 6$ clips. So, Natalia sold a total of $4 8 + 3 6 < < 4 8 + 3 6 = 8 4 > > 8 4$ clips in April and May. The answer is 84
313
+ You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
314
+ Answer: No, the reasoning is incorrect. Final Answer: Natalia sold 48/2 = <<48/2 = 24>>24 clips in May. So she sold a total of 48 + 24<<48 + 24 = 72>>72 clips. The answer is 72
315
+
316
+ Question: There are 5 houses on a street, and each of the first four houses has 3 gnomes in the garden. If there are a total of 20 gnomes on the street, how many gnomes does the fifth house have?
317
+
318
+ Answer:In the first four houses, there are a total of 4 houses $^ \ast \ 3$ gnomes $= \mathit { < } \mathit { < } 4 \ast 3 = 1 2 \textgreater \mathrm { > } 1 2$ gnomes. Therefore, the fifth house had 20 total gnomes - 12 gnomes $= < < 2 0 - 1 2 = 8 > > 8$ gnomes. The answer is 8 You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
319
+
320
+ Answer: Yes, the reasoning is correct. Final Answer: In the first four houses, there are a total of 4 houses \* 3 gnomes = <<4 ∗ 3 = 12>>12 gnomes. Therefore, the fifth house had 20 total gnomes - 12 gnomes = <<20 − 12 = 8>>8 gnomes. The answer is 8
321
+
322
+ # StrategyQA
323
+
324
+ Question: Could Durian cause someone’s stomach to feel unwell?
325
+
326
+ Answer: Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel excited and they like it. The answer is False You are an expert teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. Answer: No, the reasoning is incorrect. Final Answer: Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel nauseous. The answer is True
327
+
328
+ Question: Was Daniel thrown into the lion’s den in the New Testament?
329
+
330
+ Answer:The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False
331
+ You are an expert teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
332
+ Answer: Yes, the reasoning is correct. Final Answer: The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False
333
+
334
+ # StrategyQA (Resampling with facts)
335
+
336
+ You are a highly intelligent question answering bot. You will answer the question ’Question’ in as details as possible. ’Facts’ are provided to assist you in answering the questions.
337
+ Question: Are vinegar pickled cucumbers rich in lactobacillus?
338
+ Facts: Pickles made with vinegar are not probiotic and are simply preserved. Pickles made through a soak in a
339
+
340
+ salt brine solution begin to ferment because of lactobacillus. Answer: No, vinegar does not contain lactobacillus. The answer is False
341
+
342
+ Question: Does Masaharu Morimoto rely on glutamic acid?
343
+
344
+ Facts: Masaharu Morimoto is a Japanese chef. Japanese cuisine relies on several forms of seaweed as ingredients and flavorings for broth like kombu dashi. Glutamic acid has been identified as the flavoring component in kombu seaweed.
345
+
346
+ Answer: Yes, Japanese chef uses a lot of glutamic acid. The answer is True
347
+
348
+ # Auto Debugging
349
+
350
+ Input: def f1(): return str(x) + 'hello' def f2(): return f1 $[ 2 \star \mathbf { x } ]$ ) x = f2(524)
351
+
352
+ What is the value of $\mathbf { X }$ at the end of this program? Output: 1048hello
353
+ Verdict: Yes, the answer is correct.
354
+ Final Answer: 1048hello
355
+
356
+ Input:
357
+
358
+ def f1(): return str(x) $^ +$ 'hello'
359
+ def f2(): return f1 $( 2 \ast \times )$ )
360
+ $\textbf { x } = \textrm { f } 2 \ : ( 5 2 4 )$ ) What is the value of $\mathbf { X }$ at the end of this program? Output: 524
361
+ Verdict: No, the answer is incorrect.
362
+ Final Answer: 1048hello
363
+
364
+ # B.2.2 SUBQUESTION DECOMPOSITION
365
+
366
+ # GSM8K
367
+
368
+ For each subquestion, the main problem and all previous subquestions along with the model-generated solutions are provided in order to solve the current subquestion.
369
+
370
+ Here is a math question and its solution.
371
+
372
+ Problem: Noah is a painter. He paints pictures and sells them at the park. He charges $\$ 60$ for a large painting and $\$ 30$ for a small painting. Last month he sold eight large paintings and four small paintings. If he sold twice as much this month, how much is his sales for this month?
373
+ How much did Noah earn from the large paintings? Noah earned $\$ 60$ /large painting $\textbf { \em X } 8$ large paintings $=$ $\$ < <60*8=480 > > 480$ for the large paintings. The answer is 480
374
+ Question: How much did Noah earn from the small paintings?
375
+ Answer: He also earned $\$ 60/\mathrm { s m a l l }$ painting $\texttt { x 4 }$ small paintings $= \ S < < 6 0 * 4 = 2 4 0 > > 2 4 0$ for the small paintings. The answer is 240
376
+ You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
377
+ Answer: No, the reasoning is incorrect. Final Answer: He also earned \$30/small painting x 4 small paintings = \$<<30 ∗ 4 = 120>>120 for the small paintings. The answer is 120
378
+
379
+ Here is a math question and its solution.
380
+
381
+ Problem: To make pizza, together with other ingredients, Kimber needs 10 cups of water, 16 cups of flour, and 1/2 times as many teaspoons of salt as the number of cups of flour. Calculate the combined total number of cups of water, flour, and teaspoons of salt that she needs to make the pizza. How many teaspoons of salt does Kimber need? To make the pizza, Kimber half as many teaspoons of salt as the number of cups of flour, meaning she needs $1 / 2 ^ { * } 1 6 = < < 1 6 * 1 / 2 = 8 > > 8$ teaspoons of salt. The answer is 8
382
+
383
+ How many cups of flour and teaspoons of salt does Kimber need? The total number of cups of flour and teaspoons of salt she needs is $8 + 1 6 = < < 8 + 1 6 = 2 4 > > 2 4$ . The answer is 24
384
+
385
+ Question: How many cups of water, flour, and salt does Kimber need?
386
+
387
+ Answer: She also needs 10 cups of water, which means the total number of cups of water and flour and teaspoons of salt she needs is $2 4 + 1 0 = < < 2 4 + 1 0 = 3 4 > > 3 4 .$ . The answer is 34
388
+
389
+ You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
390
+
391
+ Answer: Yes, the reasoning is correct. Final Answer: She also needs 10 cups of water, which means the total number of cups of water and flour and teaspoons of salt she needs is 24 + 10 = <<24 + 10 = 34 > >>34. The answer is 34
392
+
393
+ # StrategyQA
394
+
395
+ Here is a question and its answer.
396
+
397
+ Context: Would a diet of ice eventually kill a person?
398
+
399
+ Ice is the solid state of what? Ice can be melted into water, which consists of hydrogen and oxygen.
400
+
401
+ What nutrients are needed to sustain human life? Humans need carbohydrates, proteins, and fats that are contained in foods.
402
+
403
+ Question: Are most of $\# 2$ absent from $\# 1 2$
404
+
405
+ Answer: Water does not contain fat, carbohydrates or protein.
406
+
407
+ You are an expert teacher. Based on the provided context, do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
408
+
409
+ Answer: Yes, the reasoning is correct. Final Answer: Water does not contain fat, carbohydrates or protein.
410
+
411
+ Here is a question and its answer.
412
+
413
+ Context: Can binary numbers and standard alphabet satisfy criteria for a strong password?
414
+
415
+ Which characters make up binary numbers? Binary numbers only contain 0 and
416
+
417
+ Which characters make up the standard English alphabet? The standard alphabet contains twenty six letters but no special characters.
418
+
419
+ Question: Does #1 or #2 include special characters or symbols?
420
+
421
+ Answer: Yes, it contains all the special characters.
422
+
423
+ You are an expert teacher. Based on the provided context, do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’.
424
+
425
+ Answer: No, the reasoning is incorrect. Final Answer: Neither binary digits nor English alphabets consists of any special characters which is needed for a strong password.
426
+
427
+ # B.3 SELECTION
428
+
429
+ The LLM-based selection module $\psi _ { \mathrm { s e l e c t } }$ uses a 2-shot prompt. The 2 demonstrations in the prompt are shown below, for each dataset.
430
+
431
+ # GSM8K
432
+
433
+ You are an expert math teacher. You are provided with a question and two answers. Lets check the ‘Answer choices’ step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’
434
+
435
+ Question: Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?
436
+
437
+ Answer choices:
438
+
439
+ (A) In April, Natalia sold 48 clips. In May, Natalia sold 24 clips. So, Natalia sold a total of 72 clips in April and May. The answer is 72. So in May she sold 48 clips. Total clips sold in April and May $=$ $7 \bar { 2 } + 4 8 = < < 7 2 + 4 8 = 1 2 0 > > 1 2 0$ . The answer is 120
440
+ (B) Natalia sold $4 8 / 2 = < < 4 8 / 2 = 2 4 > > 2 4$ clips in May. The answer is 24. Natalia sold $4 8 + 2 4 = < < 4 8 + 2 4 = 7 2 > >$ clips altogether. The answer is 72
441
+ Answer: (B)
442
+
443
+ You are an expert math teacher. You are provided with a question and two answers. Lets check the ‘Answer choices’ step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’
444
+
445
+ Question: Dolly has two books. Pandora has one. If both Dolly and Pandora read each others’ books as well as their own, how many books will they collectively read by the end?
446
+
447
+ Answer choices:
448
+
449
+ (A) There are a total of $2 + 1 = < < 2 + 1 = 3 > > 3$ books. The answer is 3. Dolly and Pandora both read all 3 books, so 3 books/person $_ { \textrm { X 2 } }$ people $= < < 3 * 2 = 6 { > } { > } 6$ books total. The answer is 6 (B) The total number of books are $2 * 1 = < < 2 * 1 = 2 > > 2$ books. The answer is 2. Dolly and Pandora read each other’s books as well as their own, so the total number of books they read is 3 books. The answer is 3
450
+
451
+ Answer: (A)
452
+
453
+ # StrategyQA
454
+
455
+ You are the expert in the field. You are provided with a question and two answers. Lets check the reasoning process of each of the answer step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ Question: Could Durian cause someone’s stomach to feel unwell?
456
+
457
+ Answer choices:
458
+
459
+ (A) Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel nauseous. The answer is True
460
+ (B) Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel excited and they like it. The answer is False
461
+
462
+ Answer: (A)
463
+
464
+ You are the expert in the field. You are provided with a question and two answers. Lets check the reasoning process of each of the answer step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ Question: Was Daniel thrown into the lion’s den in the New Testament?
465
+
466
+ Answer choices:
467
+
468
+ (A) The Book of Daniel is a book in the New Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on the life of Daniel. The answer is True (B) The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False
469
+
470
+ Answer: ( B)
471
+
472
+ # Auto Debugging
473
+
474
+ You are an expert Python debugger. You are provided with a question and two answers. Your job is to decide
475
+ which answer is correct ‘(A)’ or ‘(B)’
476
+ Question:
477
+ def f1(): return str(x) $^ +$ 'hello'
478
+ def f2(): return f1 $( 2 + \tt x )$
479
+ $\mathrm { ~ ~ x ~ } = \mathrm { ~ ~ f 2 ~ }$ (524)
480
+
481
+ What is the value of $\mathbf { X }$ at the end of this program? Answer choices:
482
+
483
+ (A) 524hello (B) 1048hello Answer: (B)
484
+
485
+ # B.4 QUESTION GENERATION
486
+
487
+ 5-shot prompts were used for generating subquestions for GSM8K dataset. An example is provided below:
488
+
489
+ # GSM8K
490
+
491
+ I am a highly intelligent question generation bot. I will take the given question ‘Q’ and will decompose the main question into all ‘subquestions’ required to solve the question step by step.
492
+
493
+ Q: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? Subquestions: How many pages does he write each week? How many pages does he write every week? How many pages does he write a year?
494
+
495
+ # StrategyQA
496
+
497
+ I am a highly intelligent question generation bot. I will take the given question $\mathbf { \bar { Q } } ^ { \star }$ and will decompose the main question into all ‘subquestions’ required to solve the question step by step.
498
+
499
+ Q: Can you buy Casio products at Petco?
500
+ Subquestions: What kind of products does Casio manufacture? What kind of products does Petco sell? Does
501
+ #1 overlap with #2?
parse/test/Oho3UxCkKr/Oho3UxCkKr_content_list.json ADDED
@@ -0,0 +1,1166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "SCREWS : A MODULAR FRAMEWORK FOR REASONING WITH REVISIONS ",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Anonymous authors Paper under double-blind review ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "ABSTRACT ",
16
+ "text_level": 1,
17
+ "page_idx": 0
18
+ },
19
+ {
20
+ "type": "text",
21
+ "text": "Large language models (LLMs) can improve their accuracy on various tasks through iteratively refining and revising their output based on feedback. We observe that these revisions can introduce errors, in which case it is better to roll back to a previous result. Further, revisions are typically homogeneous: they use the same reasoning method that produced the initial answer, which may not correct errors. To enable exploration in this space, we present SCREWS, a modular framework for reasoning with revisions. It is comprised of three main modules: Sampling, Conditional Resampling, and Selection, each consisting of sub-modules that can be hand-selected per task. We show that SCREWS not only unifies several previous approaches under a common framework, but also reveals several novel strategies for identifying improved reasoning chains. We evaluate our framework with state-of-the-art LLMs (ChatGPT and GPT-4) on a diverse set of reasoning tasks and uncover useful new reasoning strategies for each: arithmetic word problems, multi-hop question answering, and code analysis. Heterogeneous revision strategies prove to be important, as does selection between original and revised candidates. ",
22
+ "page_idx": 0
23
+ },
24
+ {
25
+ "type": "text",
26
+ "text": "1 INTRODUCTION ",
27
+ "text_level": 1,
28
+ "page_idx": 0
29
+ },
30
+ {
31
+ "type": "text",
32
+ "text": "Large Language Models (LLMs) have proven effective on a variety of reasoning tasks (OpenAI, 2023). However, the LLM output is not always correct on its first attempt, and it is often necessary to iteratively refine the outputs to ensure that the desired goal is achieved (Madaan et al., 2023; Welleck et al., 2022; Zheng et al., 2023). These refinement methods assume that subsequent outputs (either by the same model, or by an external model or some tool) lead to better performance. However, there is no guarantee that subsequent versions must be better; as Fig. 1 illustrates, refinement can lead to a wrong answer. This motivates a Selection strategy whereby the model can select an earlier output. ",
33
+ "page_idx": 0
34
+ },
35
+ {
36
+ "type": "text",
37
+ "text": "In addition, past work on iterative refinement typically assumes a single, fixed reasoning strategy (Welleck et al., 2022; Huang et al., 2022; Madaan et al., 2023; Zheng et al., 2023). Humans, however, are more flexible. A student preparing for an exam may use deductive reasoning to solve problems and inductive reasoning to verify the results; or a product manager may use a brainstorming strategy to list several ideas and then a prioritization strategy to rank them based on their feasibility or impact. Thus, we propose a modular approach to answer refinements, allowing us to test different strategies. ",
38
+ "page_idx": 0
39
+ },
40
+ {
41
+ "type": "text",
42
+ "text": "In this work, we introduce SCREWS, a modular framework for reasoning with revisions.1 Fig. 2 introduces the three main modules of the framework in detail, namely Sampling, Conditional Resampling, and Selection. For a given task and input sequence, we instantiate SCREWS by fixing the submodules for each module (for example, we might select “Chain of Thought” for Sampling). The initial outputs generated by Sampling are passed to Conditional Resampling, which decides whether to generate a revision conditioned on the initial sample, and does so if needed. Finally, all samples and revisions are given to the Selection module, which selects the best one. Given the modular nature of our framework, several recently proposed self-refining methods can be improved by using other components of the framework. An example is the combination of the self-refinement method (Madaan et al., 2023) with our model-based selection strategy, which can improve overall performance; more such strategies are described in Sec. 5. ",
43
+ "page_idx": 0
44
+ },
45
+ {
46
+ "type": "text",
47
+ "text": "",
48
+ "page_idx": 1
49
+ },
50
+ {
51
+ "type": "text",
52
+ "text": "We evaluate SCREWS on a variety of reasoning tasks: arithmetic reasoning, multi-hop question answering, and code analysis, using ChatGPT (Brown et al., 2020) or GPT4 (OpenAI, 2023). Our proposed strategies achieve substantial improvements $( 1 0 \\mathrm { - } 1 5 \\% )$ over vanilla strategies of sampling and resampling. We demonstrate the usefulness of heterogeneous resampling, whereby the model modifies its reasoning, leading to a substantial improvement over the baselines at a very low overall cost. We also discuss the importance of a model-based selection strategy that allows the model to roll back to its previous more confident outputs, an important component for modern LLMs. ",
53
+ "page_idx": 1
54
+ },
55
+ {
56
+ "type": "image",
57
+ "img_path": "images/0f594b5ee923ddf00fc7d6ea380fbc7af188fef26e53c2f5e2638f18409f7544.jpg",
58
+ "image_caption": [
59
+ "Figure 1: An example demonstrating that Conditional Resampling (also known as “refinement”) can lead to incorrect modification of the original answer. The Selection module can retract it, if needed. "
60
+ ],
61
+ "image_footnote": [],
62
+ "page_idx": 1
63
+ },
64
+ {
65
+ "type": "text",
66
+ "text": "2 BACKGROUND ",
67
+ "text_level": 1,
68
+ "page_idx": 1
69
+ },
70
+ {
71
+ "type": "text",
72
+ "text": "Sampling Prompting LLMs to generate a series of intermediate steps has proven to be effective for improving their reasoning capabilities (Wei et al., 2022; Lewkowycz et al., 2022; Kojima et al., 2022; Wang et al., 2022). Some approaches in this direction include Chain of Thought (Wei et al., 2022; Zhang et al., 2022; Wang et al., 2022) and adding “Let’s think step by step” to the prompt (Kojima et al., 2022). Another approach is “question decomposition”, which decomposes the main problem into simpler problems and solves them iteratively (Min et al., 2019; Shridhar et al., 2022; Zhou et al., 2022; Jhamtani et al., 2023; Radhakrishnan et al., 2023). Each of these approaches has its own advantages depending on the underlying task (Shridhar et al., 2023). However, we are not aware of work combining these methods. ",
73
+ "page_idx": 1
74
+ },
75
+ {
76
+ "type": "text",
77
+ "text": "Conditional Resampling The use of feedback to improve generated samples has been well studied, where the feedback can come either from humans (Tandon et al., 2021; Bai et al., 2022; Elgohary et al., 2021), from reward models (Ziegler et al., 2019; Lu et al., 2022; Shridhar et al., 2022; Christiano et al., 2017; Lightman et al., 2023), from external tools such as code interpreters (Schick et al., 2023; Chen et al., 2022), or from other LLMs (Madaan et al., 2023; Welleck et al., 2022; Fu et al., 2023; Peng et al., 2023; Yang et al., 2022; Zheng et al., 2023; Cohen et al., 2023; Ling et al., 2023; Khalifa et al., 2023). However, even if these feedback mechanisms are infallible, the resulting revisions may introduce new errors. While prior work uses the term “refinement,” we do not because refinement implies finer (improved) responses, which is not always the case. ",
78
+ "page_idx": 1
79
+ },
80
+ {
81
+ "type": "text",
82
+ "text": "Selection When using LLMs revise the output, a common selection technique is to select the final result (Madaan et al., 2023; Shinn et al., 2023; Zheng et al., 2023; Yao et al., 2022; Chen et al., 2023; Weng et al., 2022). However, this can lead to accepting incorrect changes made to previously correct results. Other selection methods involve ranking multiple sampled outputs (Burges et al., 2005; Cobbe et al., 2021) or majority voting (Wang et al., 2022; Lewkowycz et al., 2022; Zheng et al., 2023). These methods often use a homogeneous sampling strategy with changes in hyperparameters. Our work extends the strategy to heterogeneous sampling and selection. ",
83
+ "page_idx": 1
84
+ },
85
+ {
86
+ "type": "text",
87
+ "text": "3 SCREWS: METHODOLOGY ",
88
+ "text_level": 1,
89
+ "page_idx": 1
90
+ },
91
+ {
92
+ "type": "text",
93
+ "text": "In this section, we describe SCREWS, our proposed modular framework for reasoning with revisions to tackle different reasoning tasks. Given a problem $_ \\textrm { x }$ , the goal is to generate an answer $a$ , which in our experiments may be a string or a number. SCREWS consists of three main modules: Sampling, Conditional Resampling, and Selection. Different variants of SCREWS are obtained by instantiating these modules in different ways. The options for each module are described below and illustrated schematically in Fig. 2. Note that there are other possible ways to instantiate each module. However in this work, we study only the instantiations described below. ",
94
+ "page_idx": 1
95
+ },
96
+ {
97
+ "type": "image",
98
+ "img_path": "images/24b643326014996ce5901c20ec8f2c7f49005bc5b52378decda1453e0c866be1.jpg",
99
+ "image_caption": [
100
+ "Figure 2: Overview of our modular framework for reasoning with revisions, SCREWS. Each of the three large boxes (“modules”) contains several alternatives (“submodules”). Several past works can be viewed as instances of our framework, namely Self-Refine (Madaan et al., 2023), Least to Most (Zhou et al., 2022), LLMs Know (Mostly) (Kadavath et al., 2022), Self-Consistency (Wang et al., 2022), Self-Improve (Huang et al., 2022), PHP CoT (Zheng et al., 2023), Self-Correct (Welleck et al., 2022), Socratic CoT (Shridhar et al., 2022), Program of Thoughts (Chen et al., 2022), among many others. (...) represents other sub-components that can be added to each module, like cached memory or web search for Sampling, among others. "
101
+ ],
102
+ "image_footnote": [],
103
+ "page_idx": 2
104
+ },
105
+ {
106
+ "type": "text",
107
+ "text": "All of our methods will invoke one or more stochastic functions, where each function $\\psi$ maps a tuple of input strings to a result string y that contains useful information. In practice, $\\psi$ deterministically constructs a prompt from the input strings and then samples y from a large pretrained language model as a stochastic continuation of this prompt. For a given tuple of input strings, the prompt constructed for $\\psi$ will typically be a formatted encoding of this tuple, preceded by a task specific instruction and several demonstrations (few-shot examples) that illustrate how $\\psi$ should map other encoded input tuples to their corresponding continuations (Brown et al., 2020). ",
108
+ "page_idx": 2
109
+ },
110
+ {
111
+ "type": "text",
112
+ "text": "3.1 SAMPLING ",
113
+ "text_level": 1,
114
+ "page_idx": 2
115
+ },
116
+ {
117
+ "type": "text",
118
+ "text": "We consider three instantiations of the Sampling module, each may be suitable for different tasks. ",
119
+ "page_idx": 2
120
+ },
121
+ {
122
+ "type": "text",
123
+ "text": "Answer Only In this method, for a given problem $_ \\textrm { x }$ , the model $\\psi$ directly generates the answer ${ \\mit \\Psi } = \\psi ( { \\bf x } )$ without any intermediate steps. This is the simplest and most naive sampling method. The value of y is returned as the answer $a$ (if there is no further revision of y). ",
124
+ "page_idx": 2
125
+ },
126
+ {
127
+ "type": "text",
128
+ "text": "Chain of Thought $\\mathbf { ( C o T ) }$ For many reasoning tasks today, generating explanations improves the quality of the final answer (Wei et al., 2022; Kojima et al., 2022). Chain of Thought sampling encourages the model to explain the intermediate step-by-step reasoning en route to a decision. This approach is now commonly used in several reasoning tasks. Again, we define $\\boldsymbol { \\mathrm { y } } = \\boldsymbol { \\psi } ( \\mathbf { x } )$ , but now we expect the prompt continuation to consist of step-by-step reasoning culminating in the step by step answer y, as demonstrated by the few-shot examples included in the prompt. The answer $a$ is extracted from y using a simple deterministic pattern-matching heuristic. ",
129
+ "page_idx": 2
130
+ },
131
+ {
132
+ "type": "text",
133
+ "text": "Sub-question decomposition This method decomposes the problem $_ \\textrm { x }$ into simpler sub-questions $[ x _ { 1 } , x _ { 2 } , \\ldots , x _ { n } ]$ . For each sub-question $x _ { i }$ in turn $( i = 1 , 2 , \\ldots , n )$ , the model is called to generate the corresponding sub-answer $y _ { i } = \\psi ( \\mathbf { x } , x _ { 1 } , y _ { 1 } , \\ldots , x _ { i - 1 } , y _ { i - 1 } , x _ { i } )$ . Note that we generate all questions before seeing any answers; that choice follows Shridhar et al. (2023), who found this approach to work better than interleaved generation of questions and answers. The sequence of questions may be generated in a single step, either by a call to a stochastic function $\\psi _ { \\mathrm { q u e s t i o n } }$ , or by a custom question generation module that has been fine-tuned on human-written questions as in Cobbe et al. (2021). The answer $a$ is extracted from $y _ { n }$ with a simple heuristic as in CoT. ",
134
+ "page_idx": 2
135
+ },
136
+ {
137
+ "type": "text",
138
+ "text": "",
139
+ "page_idx": 3
140
+ },
141
+ {
142
+ "type": "text",
143
+ "text": "3.2 CONDITIONAL RESAMPLING ",
144
+ "text_level": 1,
145
+ "page_idx": 3
146
+ },
147
+ {
148
+ "type": "text",
149
+ "text": "The result y from the Sampling module can be viewed as a provisional result, $\\mathtt { Y } \\mathrm { c u r r }$ . This is passed to the Conditional Resampling module where a decision is made whether or not to revise it. This is done in two steps: first deciding whether or not to revise, and then if so, resampling a new result $\\mathrm { Y n e x t }$ using one of the sampling methods mentioned above. The resampling is conditional because ynext may depend on $\\mathtt { Y } \\mathrm { c u r r }$ . Our work focuses on the following instantiations for Conditional Resampling: ",
150
+ "page_idx": 3
151
+ },
152
+ {
153
+ "type": "text",
154
+ "text": "Self-Ask Kadavath et al. (2022) uses a function $\\psi _ { \\mathrm { a s k } } ( \\mathrm { x } , \\mathrm { y } _ { \\mathrm { c u r r } } )$ . The first token of the result indicates whether $\\mathtt { Y } _ { \\mathrm { c u r r } }$ is correct, for example by starting with “Yes” or “No”. If “Yes”, we do not resample; if “No”, we must resample a revised answer $\\mathrm { Y n e x t }$ . In principle, the revision could be iterated, although Kadavath et al. (2022) did not do this, nor do our experiments in this paper. ",
155
+ "page_idx": 3
156
+ },
157
+ {
158
+ "type": "text",
159
+ "text": "In our version of self-ask, $\\psi _ { \\mathrm { a s k } }$ is formulated so that $\\mathrm { Y } _ { \\mathrm { n e x t } }$ appears in the result string $\\psi _ { \\mathrm { a s k } } ( \\mathrm { x } , \\mathrm { y } _ { \\mathrm { c u r r } } )$ following the token “No”. Thus, both steps are efficiently performed by a single call to $\\psi _ { \\mathrm { a s k } } ( \\bf x , \\bf y _ { \\mathrm { c u r r } } )$ . For this method, we always use greedy decoding (temperature 0) to deterministically select whichever of “Yes” or “No” is more probable.2 ",
160
+ "page_idx": 3
161
+ },
162
+ {
163
+ "type": "text",
164
+ "text": "When the sampling module (Sec. 3.1) used sub-question decomposition to produce a chain of subanswers $\\mathtt { y _ { c u r r } } = [ y _ { 1 } , \\dots , y _ { n } ]$ , rather than checking and revising only the final result step $y _ { n }$ by calling $\\psi _ { \\mathrm { a s k } } ( \\mathbf { x } , y _ { n } )$ , we can instead check and revise each step, at the cost of more calls to $\\psi _ { \\mathrm { a s k } }$ . For each provisional sub-answer $y _ { i }$ in turn (starting with $i = 1$ ), we predict whether it is correct by calling $\\psi _ { \\mathrm { a s k } } ( \\mathbf { x } , x _ { 1 } , y _ { 1 } , \\dots , x _ { i - 1 } , y _ { i - 1 } , x _ { i } , y _ { i } )$ . The first time the output is “No”, we resample $y _ { i } ^ { \\prime }$ through $y _ { n } ^ { \\prime }$ , yielding the revised result $\\mathbf { \\cal { Y } } _ { \\mathrm { n e x t } } = [ y _ { 1 } , \\dots , y _ { i - 1 } , y _ { i } ^ { \\prime } , \\dots , y _ { n } ^ { \\prime } ]$ . In principle, self-ask could then be applied again at later steps $> i$ of both the original and revised chains; then choosing among the many resulting chains, using the selection procedures of the next section, would resemble branching in a reasoning tree (Yao et al., 2023). ",
165
+ "page_idx": 3
166
+ },
167
+ {
168
+ "type": "text",
169
+ "text": "Tool use For some tasks, we construct $\\psi _ { \\mathrm { a s k } }$ so that it is allowed to use tools (Schick et al., 2023). The reason is that in tasks like fact-checking, it is futile to ask the LLM to check $\\mathtt { Y } _ { \\mathrm { c u r r } }$ because it might not have the requisite knowledge for evaluation. The tools can be used to collect additional information to help the model detect and fix problems in its own generated answer. Tools like search engines or fact retrievers can be used to evaluate correctness and generate a new revision. Other tools like code interpreters are not capable of generating text, but can still be used to evaluate correctness. ",
170
+ "page_idx": 3
171
+ },
172
+ {
173
+ "type": "text",
174
+ "text": "3.3 SELECTION ",
175
+ "text_level": 1,
176
+ "page_idx": 3
177
+ },
178
+ {
179
+ "type": "text",
180
+ "text": "The last module in SCREWS is the Selection module. In this step, we use either a model $\\psi _ { \\mathrm { s e l e c t } }$ or simple heuristics to select the final result y from which we then extract the final answer $a$ . In effect, this allows us to construct a simple ensemble of multiple systems. ",
181
+ "page_idx": 3
182
+ },
183
+ {
184
+ "type": "text",
185
+ "text": "LLM-Based Selection Just as an LLM was used above to evaluate whether $\\mathtt { Y } \\mathrm { c u r r }$ is good, an LLM can be used to evaluate whether $\\mathrm { Y n e x t }$ is better. We call $\\psi _ { \\mathrm { s e l e c t } } ( \\mathrm { x , y _ { c u r r } , y _ { n e x t } ) }$ to choose between two result strings.3 Note that it could be naturally extended to choose among more than two answers. When selection and sampling are implemented using the same LLM, we refer to the method as self-select (e.g., in Fig. 2). ",
186
+ "page_idx": 3
187
+ },
188
+ {
189
+ "type": "text",
190
+ "text": "Rule-Based Selection We consider the other methods we study to be rule-based. Past work on iterative refinement (Madaan et al., 2023; Huang et al., 2022; Zheng et al., 2023) always selects the most recent revision. Majority voting is a simple traditional ensembling method that has been used for selection (Wang et al., 2022; Lewkowycz et al., 2022), but it is costly since it requires several samples. ",
191
+ "page_idx": 3
192
+ },
193
+ {
194
+ "type": "text",
195
+ "text": "4 EXPERIMENTS ",
196
+ "text_level": 1,
197
+ "page_idx": 4
198
+ },
199
+ {
200
+ "type": "text",
201
+ "text": "4.1 TASKS ",
202
+ "text_level": 1,
203
+ "page_idx": 4
204
+ },
205
+ {
206
+ "type": "text",
207
+ "text": "We test the effectiveness and flexibility of SCREWS on three categories of reasoning tasks: GSM8K (Cobbe et al., 2021) for arithmetic reasoning, StrategyQA (Geva et al., 2021) for multi-hop question answering, and Big-Bench (BIG-bench authors, 2023) Auto Debugging4 for code analysis. GSM8K is a grade-school-level math word problem dataset with a test set of 1319 samples, each requiring two to eight steps to solve. GSM8K includes sub-questions that were generated by a fine-tuned GPT-3 model and correspond to the steps in a particular correct CoT solution. Since these subquestions were generated with oracle knowledge of a correct CoT solution, we refer to experiments using them as “Subq $\\mathrm { ( O r ) ^ { , } }$ . We use “Subq (QG)” for the fairer experimental condition where we instead generated the sub-questions from ChatGPT using 2-shot prompts (shown in Appendix B.4). ",
208
+ "page_idx": 4
209
+ },
210
+ {
211
+ "type": "text",
212
+ "text": "Following Magister et al. (2023) and Shridhar et al. (2023), we test on the first 490 samples from the training set of StrategyQA (since their test set is unlabeled). The demonstration examples for our various stochastic functions $\\psi$ were drawn randomly from the rest of the training set. StrategyQA also includes human-annotated oracle subquestions (again denoted with “Subq $\\left( \\mathrm { O r } \\right) ^ { \\mathbf { \\eta } , \\mathbf { \\eta } } ,$ ) and related facts that can assist in answering the main question (which we use for tool-based conditional resampling as in Sec. 3.2). The Auto Debugging dataset tests whether a model can answer questions about the intermediate state of a program without executing the code. The dataset consists of 34 coding examples, of which 33 were used as test examples and 1 as a demonstration example in the prompt. ",
213
+ "page_idx": 4
214
+ },
215
+ {
216
+ "type": "text",
217
+ "text": "4.2 EXPERIMENTAL SETUP ",
218
+ "text_level": 1,
219
+ "page_idx": 4
220
+ },
221
+ {
222
+ "type": "text",
223
+ "text": "We always report exact-match accuracy: the percentage of examples on which our final answer $a$ matches the gold answer. For all of our experiments, we use the ChatGPT API (Brown et al., 2020) from July 2023 (gpt-3.5-turbo-0301). ",
224
+ "page_idx": 4
225
+ },
226
+ {
227
+ "type": "text",
228
+ "text": "Sampling With all choices of the Sampling module, we use 5-shot sampling for GSM8K and StrategyQA and 1-shot sampling for Auto Debugging (Appendix B.1). Greedy decoding (temp $=$ 0) is used for the main experiments while higher temperature (0.7) is used for the majority voting experiments (one sample was generated greedily and the others at temp $= 0 . 7$ ). ",
229
+ "page_idx": 4
230
+ },
231
+ {
232
+ "type": "text",
233
+ "text": "Conditional Resampling Greedy decoding is used to first make a binary resampling decision and then to sample. 4-shot prompts (with two correct and two incorrect samples) are used for the GSM8K and StrategyQA datasets, while a 2-shot prompt (with one correct and one incorrect sample) is used for Auto Debugging (Appendix B.2). For StrategyQA, we use tool-based resampling by including the provided facts from the dataset into the prompt to simulate a (perfect) fact retrieval tool. ",
234
+ "page_idx": 4
235
+ },
236
+ {
237
+ "type": "text",
238
+ "text": "Selection For the self-select strategy, the prompts (Appendix B.3) include two examples and selection was produced with greedy decoding. For majority voting, a majority vote on the final answers was taken over $k \\in \\{ 1 , \\bar { 3 , 4 , 5 } \\}$ samples. Ties were broken randomly. ",
239
+ "page_idx": 4
240
+ },
241
+ {
242
+ "type": "text",
243
+ "text": "5 RESULTS ",
244
+ "text_level": 1,
245
+ "page_idx": 4
246
+ },
247
+ {
248
+ "type": "text",
249
+ "text": "5.1 GSM8K ",
250
+ "text_level": 1,
251
+ "page_idx": 4
252
+ },
253
+ {
254
+ "type": "text",
255
+ "text": "Conditional Resampling Works Better with Method Change Previous work (Madaan et al., 2023) has shown that when a chain-of-thought method is used for initial Sampling, reasoning ability is improved by Resampling with the same method, taking the previous sample into account. ",
256
+ "page_idx": 4
257
+ },
258
+ {
259
+ "type": "text",
260
+ "text": "We reproduced this previous finding: the CoT scores for GSM8K improved by 1.4 points after resampling with CoT (71.6 to 73.0), as shown in Tab. 1. However, when the initial Sampling used subquestion decomposition, we found that resampling with subquestion decomposition actually harmed accuracy (71.9 to 71.3 with Subq (QG), 78.6 to 78.2 with Subq (Or)). ",
261
+ "page_idx": 4
262
+ },
263
+ {
264
+ "type": "text",
265
+ "text": "What gave the best results—for all three Sampling methods—was Conditional Resampling with a different method from the originally chosen one. It gave a large gain over Sampling when the original Sampling used CoT and Resampling used subquestion decomposition (71.6 to 73.7, with generated subquestions) and vice versa (71.9 to 74.0). Even with oracle subquestions, moderate gains are still seen when resampling with CoT (78.6 to 79.0). This demonstrates that it is useful to change methods using Conditional Resampling, a novel finding with our framework. ",
266
+ "page_idx": 4
267
+ },
268
+ {
269
+ "type": "table",
270
+ "img_path": "images/3655b59583a5a9d2f6575891e83afe84ea692bef0e6a2c1c66c3f1724beb9465.jpg",
271
+ "table_caption": [
272
+ "Table 1: The improvements achieved by using Conditional Resampling for the GSM8K dataset, where $\\mathrm { y } _ { \\mathrm { n e x t } }$ is always selected (\\* indicates statistical significance with $p < 0 . 0 5 $ ). Sec. 4.1 describes CoT, Subq (QG), and Subq $( \\mathrm { O r } )$ in more detail. "
273
+ ],
274
+ "table_footnote": [],
275
+ "table_body": "<table><tr><td>Sampling</td><td>Accuracy</td><td>Conditional Resampling</td><td>Accuracy</td></tr><tr><td>CoT: Chain of thought</td><td>71.64</td><td>CoT Subq (QG) Subq (Or)</td><td>73.00* 73.99* 73.69 *</td></tr><tr><td>Subq (QG): Subquestion decomposition with ChatGPT-generated questions</td><td>71.87</td><td>CoT Subq (QG) Subq (Or)</td><td>73.99* 71.26 72.80</td></tr><tr><td>Subq (Or): Subquestion decomposition with oracle questions present in GSM8K</td><td>78.62</td><td>CoT Subq (QG) Subq(Or)</td><td>78.99 78.86 78.24</td></tr></table>",
276
+ "page_idx": 5
277
+ },
278
+ {
279
+ "type": "text",
280
+ "text": "",
281
+ "page_idx": 5
282
+ },
283
+ {
284
+ "type": "table",
285
+ "img_path": "images/acec47667513c82eea4d882652a65cdd1c7e9c9b8e4246ea63761d8960e3c4f3.jpg",
286
+ "table_caption": [
287
+ "Table 2: Impact of Selection on the GSM8K data set on Independent Sampling and Conditional Resampling. The upper bound from using a Selection oracle is given in square brackets. "
288
+ ],
289
+ "table_footnote": [],
290
+ "table_body": "<table><tr><td rowspan=\"2\">Method</td><td colspan=\"3\">Independent Sampling</td><td colspan=\"3\">Conditional Resampling</td></tr><tr><td>CoT</td><td>Subq (QG)</td><td>Subq (Or)</td><td>CoT</td><td>Subq (QG)</td><td>Subq (Or)</td></tr><tr><td>CoT</td><td>71.64</td><td></td><td>74.90 [85.36]81.34 [89.08]</td><td></td><td>72.93[73.08]73.76[73.76]73.99[73.99]</td><td></td></tr><tr><td>Subq (QG)74.90 [85.36]</td><td></td><td>71.87</td><td></td><td></td><td>79.99 [87.26]73.99 [75.43]72.40 [72.40]</td><td>73.84 [76.04]</td></tr><tr><td>Subq (Or)</td><td>81.34[89.08]</td><td>79.99 [87.26]</td><td>78.62</td><td></td><td>78.99 [81.50]79.75[80.97]79.22 [79.22]</td><td></td></tr></table>",
291
+ "page_idx": 5
292
+ },
293
+ {
294
+ "type": "text",
295
+ "text": "Importance of Selection Module Conditional Resampling does not invariably improve every output. In fact, we saw in Tab. 1 that for some settings, it may harm the output quality even on average. This is why the Selection module is useful—to detect and reject cases of harmful revisions. ",
296
+ "page_idx": 5
297
+ },
298
+ {
299
+ "type": "text",
300
+ "text": "First, as a starting point, the left half of Tab. 2 considers using Selection only as an ensembling technique to combine the outputs of two independent Sampling strategies. (Note that this matrix is symmetric.) Although CoT and subquestion decomposition are about equally good Sampling strategies (71.6 and 71.9), using a Selection module to select the better of the two achieves a 3-point gain (to 74.9). Much larger gains (up to 85.4) are potentially available from improving Selection— the upper bound on performance (if Selection always chose the better option) is shown in square brackets. This shows that the two Sampling strategies have largely complementary errors. A similar pattern applies when the subquestion decomposition method is permitted to use oracle subquestions, which improves performance across the board to 81.34. ",
301
+ "page_idx": 5
302
+ },
303
+ {
304
+ "type": "text",
305
+ "text": "The right half of Tab. 2 shows Selection between the Sampled and Conditionally Resampled predictions from Tab. 1. (This matrix is asymmetric.) For CoT, the results remain the same at 73.99, which is due to the fact that the upper bound is at 73.99, showing no room for further improvement. For other cases with subquestioning, we see an improvement of up to 1 point. Finally, we observe that the Selection module is far from perfect and has room for further improvement, as seen from the upper bounds. A Selection method ought to look at features of the two answers that turn out to be correlated with correctness, and we hypothesize that models fine-tuned specifically for Selection may prove more effective than few-shot learning at identifying these features. ",
306
+ "page_idx": 5
307
+ },
308
+ {
309
+ "type": "text",
310
+ "text": "The right half of Tab. 2 is the cheaper method, because we observe $\\psi _ { \\mathrm { a s k } }$ resamples on only $5 . 1 5 \\%$ of the examples rather than all of them. A tradeoff between accuracy and cost is shown in Fig. 4. ",
311
+ "page_idx": 5
312
+ },
313
+ {
314
+ "type": "image",
315
+ "img_path": "images/aee01d64294ebc2dbda75aa69cfd318314ae5a6ef40b5186a030f06d2f3f08a7.jpg",
316
+ "image_caption": [],
317
+ "image_footnote": [],
318
+ "page_idx": 6
319
+ },
320
+ {
321
+ "type": "text",
322
+ "text": "(a) Impact of the number of samples on accuracy when majority voting is used for selection. ",
323
+ "page_idx": 6
324
+ },
325
+ {
326
+ "type": "image",
327
+ "img_path": "images/5536602b0de3a6f72bd7e8f17340b944dd4c6780cfaeb1dcfff3f99dab5cc2c2.jpg",
328
+ "image_caption": [
329
+ "(b) Comparison of perfect selection $^ { 6 6 } +$ perfect”) vs. majority voting $^ { * * } +$ maj”) across different strategies. ",
330
+ "Figure 3: The $^ +$ in graph (a) shows that majority voting with 3 diverse samples $( \\mathbf { C o T } + \\mathbf { S u b q } ( \\mathbf { O r } ) +$ Subq(QG)) outperforms both CoT and Subq(Or) even with 5 samples. Graph (b) shows the potential of the selection method when a perfect selector is used. It can be thought of as the upper bound of the selection mechanism. Both figures are for the GSM8K dataset. "
331
+ ],
332
+ "image_footnote": [],
333
+ "page_idx": 6
334
+ },
335
+ {
336
+ "type": "text",
337
+ "text": "Selection and Voting Unweighted majority vote has been one of the most popular Selection methods in past work (Wang et al., 2022; Lewkowycz et al., 2022; Zheng et al., 2023), since it requires no training. The two lines in Fig. 3(a) generally show improvement from Sampling more times from the same model (at temperature 0.7) and Selecting by majority vote. ",
338
+ "page_idx": 6
339
+ },
340
+ {
341
+ "type": "text",
342
+ "text": "Recalling that the left half of Tab. 2 showed benefit from ensembling independent samples from 2 different Sampling methods (up to 81.34 accuracy when oracle subquestions are allowed), we observe that majority vote is a convenient way to do so for 3 different methods (where all methods can now use temperature 0). This achieves 83.62 accuracy, as shown by the $\\star$ in Fig. 3(a). Of course, model-based Selection could potentially do even better than majority voting. The 7 points for $k \\geq 3$ in (a) are repeated as the dark bars in Fig. 3(b), with the light bars showing the upper bounds that could be achieved by replacing majority voting with a perfect Selection method. The best upper bound corresponds again to the use of 3 different methods. In principle, one could ensemble over a larger set by allowing each of the 3 methods to contribute multiple samples. ",
343
+ "page_idx": 6
344
+ },
345
+ {
346
+ "type": "text",
347
+ "text": "5.2 STRATEGYQA ",
348
+ "text_level": 1,
349
+ "page_idx": 6
350
+ },
351
+ {
352
+ "type": "text",
353
+ "text": "Simply resampling does not discover the unknown $ \\mathbf { A }$ need for tools For this question answering task, we observe in Tab. 3 that accuracy is harmed by Conditional Resampling with the same Sampling method, without Selection, as was sometimes the case for GSM8K. Here, however, Selection usually does not repair the problem, perhaps because StrategyQA requires factual knowledge. When the model lacks the necessary knowledge, Self-Ask will be insufficient. A real example at the bottom of Fig. 5 shows how resampling can preserve an incorrect model-generated claim. ",
354
+ "page_idx": 6
355
+ },
356
+ {
357
+ "type": "text",
358
+ "text": "To help the model decide whether and how to revise the answer, we try including relevant facts (provided by StrategyQA) into the resampling prompt to simulate the result one may get by using an external tool like a fact retriever. As Tab. 3 shows, this yields a 2-point improvement (“Factsre” vs. “Internals”) over Sampling, for both CoT and Subq (QG). ",
359
+ "page_idx": 6
360
+ },
361
+ {
362
+ "type": "text",
363
+ "text": "We assume that tool invocations are expensive, which is why we include facts only during Conditional Resampling. In practice, the initial result is revised only $10 \\mathrm { - } 3 5 \\%$ of the time, and therefore “Facts” does not need to invoke a tool call for every input example.5 To achieve this speedup, we do not include facts in the prompt when initially calling to $\\psi _ { \\mathrm { a s k } }$ to decide whether to resample, but only when we actually generate $\\mathrm { Y } _ { \\mathrm { n e x t } }$ . ",
364
+ "page_idx": 6
365
+ },
366
+ {
367
+ "type": "table",
368
+ "img_path": "images/e42854618c9ee358b8ef90889438c87ca74af0ab00d2bdb97920f45a90924f7f.jpg",
369
+ "table_caption": [
370
+ "Table 3: Comparing different strategies for the StrategyQA (top) and Auto Debugging (bottom) datasets. For StrategyQA, external facts are provided to the model (“Facts”) versus relying on the model’s internal capabilities (“Internal”). The upper bound from using a Selection oracle is given in square brackets. Subscripts “s” and $\\stackrel { \\cdot \\cdot } { \\mathrm { \\Delta } } _ { \\mathrm { { r e } } } \\stackrel { \\cdot \\cdot } { \\mathrm { \\Delta } }$ refer to Sampling and Resampling respectively. "
371
+ ],
372
+ "table_footnote": [],
373
+ "table_body": "<table><tr><td rowspan=\"2\">Method Knowledge Source:</td><td rowspan=\"2\">Sampling Internals</td><td colspan=\"2\">Conditional Resampling</td><td colspan=\"2\">Selection</td></tr><tr><td>Internalre</td><td>Factsre</td><td>Ints vs. Intre</td><td>Ints vs.Factsre</td></tr><tr><td colspan=\"7\"> StrategyQA</td></tr><tr><td>CoT</td><td>77.18</td><td>74.54</td><td>79.02</td><td>75.76</td><td>78.41</td></tr><tr><td>Subq (Or)</td><td>85.91</td><td>78.97</td><td>84.69</td><td>85.30</td><td>86.30</td></tr><tr><td>Subq (QG)</td><td>78.16</td><td>74.69</td><td>80.40</td><td>78.78</td><td>80.00</td></tr><tr><td colspan=\"6\">Auto Debugging</td></tr><tr><td>Answer Only</td><td>73.52</td><td>82.35</td><td></td><td>88.23[91.20]</td><td></td></tr><tr><td>CoT</td><td>70.58</td><td>73.52</td><td></td><td>73.52 [73.52]</td><td></td></tr><tr><td>Answer Only-→CoT</td><td></td><td>1</td><td></td><td>-85.29[88.23]</td><td></td></tr></table>",
374
+ "page_idx": 7
375
+ },
376
+ {
377
+ "type": "text",
378
+ "text": "5.3 CODE DEBUGGING ",
379
+ "text_level": 1,
380
+ "page_idx": 7
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "The effectiveness of SCREWS For the code analysis task, we observed that the Answer Only method achieves similar scores to $\\mathrm { C o T } , ^ { 6 }$ as reported in the bottom half of Tab. 3, suggesting that no particular Sampling method is superior on all datasets. However, we see the benefits of using SCREWS, as we find that with Answer Only, adding Conditional Resampling followed by Selection leads to a performance boost of 15 points (from 73.52 to 88.23). While the dataset size limits our ability to make concrete conclusions, the findings here support the conclusions drawn on other datasets: Resampling and Selection lead to benefits and heterogenous sampling can prove effective. ",
385
+ "page_idx": 7
386
+ },
387
+ {
388
+ "type": "text",
389
+ "text": "6 ADDITIONAL ANALYSIS ",
390
+ "text_level": 1,
391
+ "page_idx": 7
392
+ },
393
+ {
394
+ "type": "text",
395
+ "text": "Total Cost SCREWS supports many methods with different cost/accuracy tradeoffs. Fig. 4 displays the strategies that use CoT and Subq (QG) on GSM8K. The cost is represented as the total count of input tokens (prompt $^ +$ query) and output tokens for all LLM calls needed by that strategy, averaged over test examples. Generally, Subq (QG) is expensive as it is costly to call $\\psi _ { \\mathrm { q u e s t i o n } }$ . However, it is affordable to use it in Conditional Resampling only $( \\mathbb { E } ^ { } )$ , since resampling only occurs $1 0 { - } 1 5 \\%$ o f the time. This method is both cheaper and more accurate than Sampling either with Subq (QG) $( + )$ or 3 times with CoT (•). Appendix A discusses a detailed breakdown of each module’s input and output token costs. ",
396
+ "page_idx": 7
397
+ },
398
+ {
399
+ "type": "text",
400
+ "text": "More Revision Steps Sec.5.1 showed that on GSM8K, Sampling with Subq (Or) (78.62 accuracy) is improved slightly by Conditional Resampling with CoT (78.99) and then Selection (79.22). Like Madaan et al. (2023), we did not find much benefit from additional iterations of Conditional Resampling $^ +$ Selection: a second iteration gives 79.45, and a third gives 79.52. These small improvements probably do not justify the added cost. ",
401
+ "page_idx": 7
402
+ },
403
+ {
404
+ "type": "image",
405
+ "img_path": "images/0347c54c9f11b54caea3829e7a8e4727cf2c959d7b89a2a993e3f3e416582ecb.jpg",
406
+ "image_caption": [
407
+ "Figure 4: On GSM8K, sampling cost vs. accuracy. The blue line (copied from Fig. 3(a)) shows a baseline of majority voting over $k \\in$ $\\{ 1 , 3 , 4 , 5 \\}$ CoT samples. The shaped points are the other strategies from Sec. 5.1 that use CoT and Subq (QG). "
408
+ ],
409
+ "image_footnote": [],
410
+ "page_idx": 7
411
+ },
412
+ {
413
+ "type": "text",
414
+ "text": "",
415
+ "page_idx": 7
416
+ },
417
+ {
418
+ "type": "text",
419
+ "text": "Larger LLMs Replacing ChatGPT with GPT-4 (OpenAI, 2023) greatly increased the Sampling accuracy on GSM8K, to 91.45 for CoT and 90.80 for Subq (Or). Choosing between those two samples with GPT-4-based Selection further increased the accuracy to 93.10, which falls between the accuracy of majority voting over $k { = } 3$ and $k { = } 4 \\mathrm { C o T }$ samples from GPT-4 (92.94 and 93.93 respectively). Even using ChatGPT-based Selection achieved 92.58, which improves over CoT alone. ",
420
+ "page_idx": 7
421
+ },
422
+ {
423
+ "type": "text",
424
+ "text": "",
425
+ "page_idx": 8
426
+ },
427
+ {
428
+ "type": "text",
429
+ "text": "Selected Examples The top two examples of Fig. 5, on the GSM8K dataset, demonstrate the effectiveness of the Selection module. The first example shows how an error introduced by Conditional Resampling can be reverted by Selection. The second example shows how a correction found by Conditional Resampling can be kept by Selection. The last example in Fig. 5, on the StrategyQA dataset, illustrates that ordinary Resampling is unlikely to correct an incorrect fact generated by the LLM. However, providing the correct facts during Resampling gives the model access to new information, leading to the correct answer. ",
430
+ "page_idx": 8
431
+ },
432
+ {
433
+ "type": "image",
434
+ "img_path": "images/66c41c403c01f89537385eb35a42f38f412a29459239b8f861c117a7a7829ee5.jpg",
435
+ "image_caption": [
436
+ "Figure 5: The top two examples demonstrate the importance of the Selection module for the GSM8K dataset. The last example shows how tool use (“Facts”) can be helpful for the StrategyQA dataset. "
437
+ ],
438
+ "image_footnote": [],
439
+ "page_idx": 8
440
+ },
441
+ {
442
+ "type": "text",
443
+ "text": "7 CONCLUSION AND FUTURE WORK ",
444
+ "text_level": 1,
445
+ "page_idx": 8
446
+ },
447
+ {
448
+ "type": "text",
449
+ "text": "We have proposed SCREWS, a modular reasoning-with-revisions framework to answer reasoning questions with LLMs. Based on our experiments we conclude the following: 1) Selection plays an important role: Although Conditional Resampling often improves the result of Sampling, Selection can help avoid errors from the case where it does not. It was beneficial on all three datasets; 2) Heterogeneous vs. homogeneous resampling: Using different reasoning methods for Sampling and Conditional Resampling can lead to higher accuracy, with or without Selection; 3) Missing external knowledge hurts Conditional Resampling: Resampling cannot fix incorrect facts generated by the model. Tool-based resampling can therefore get better results (as simulated using StrategyQA); and 4) No uniformly best strategy: There was no clear winning method for each of the modules. Simple baseline methods sometimes beat more complex ones: CoT uses only one call to $\\psi$ and beats Subq (QG) in GSM8K, always selecting $\\mathrm { Y } _ { \\mathrm { n e x t } }$ beats self-select for StrategyQA with “Facts,” and Answer Only works surprisingly well for Code Debugging. ",
450
+ "page_idx": 8
451
+ },
452
+ {
453
+ "type": "text",
454
+ "text": "SCREWS combines the three important modules Sampling, Conditional Resampling and Selection in a modular framework. However, the best configuration of modules may vary by task and could be identified through a method such as exhaustive search, Monte Carlo Tree Search, or reinforcement learning. The modules themselves could be fine-tuned to improve end-to-end performance. We leave this for future work. ",
455
+ "page_idx": 8
456
+ },
457
+ {
458
+ "type": "text",
459
+ "text": "REFERENCES ",
460
+ "text_level": 1,
461
+ "page_idx": 9
462
+ },
463
+ {
464
+ "type": "text",
465
+ "text": "Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, T. J. Henighan, Nicholas Joseph, Saurav Kadavath, John Kernion, Tom Conerly, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Tristan Hume, Scott Johnston, Shauna Kravec, Liane Lovitt, Neel Nanda, Catherine Olsson, Dario Amodei, Tom B. Brown, Jack Clark, Sam McCandlish, Christopher Olah, Benjamin Mann, and Jared Kaplan. Training a helpful and harmless assistant with reinforcement learning from human feedback. ArXiv, abs/2204.05862, 2022. ",
466
+ "page_idx": 9
467
+ },
468
+ {
469
+ "type": "text",
470
+ "text": "BIG-bench authors. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. Transactions on Machine Learning Research, 2023. ISSN 2835-8856. \nTom 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. \nChris Burges, Tal Shaked, Erin Renshaw, Ari Lazier, Matt Deeds, Nicole Hamilton, and Greg Hullender. Learning to rank using gradient descent. In Proceedings of the 22nd International Conference on Machine Learning, ICML ’05, pp. 89–96, New York, NY, USA, 2005. Association for Computing Machinery. ISBN 1595931805. \nWenhu Chen, Xueguang Ma, Xinyi Wang, and William W. Cohen. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. ArXiv, abs/2211.12588, 2022. \nXinyun Chen, Maxwell Lin, Nathanael Scharli, and Denny Zhou. ¨ Teaching large language models to self-debug. ArXiv, abs/2304.05128, 2023. \nPaul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. \nKarl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. ArXiv, abs/2110.14168, 2021. \nRoi Cohen, May Hamri, Mor Geva, and Amir Globerson. LM vs LM: Detecting factual errors via cross examination. ArXiv, abs/2305.13281, 2023. \nAhmed Elgohary, Christopher Meek, Matthew Richardson, Adam Fourney, Gonzalo Ramos, and Ahmed Hassan Awadallah. NL-EDIT: Correcting semantic parse errors through natural language interaction. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 5599–5610, Online, June 2021. Association for Computational Linguistics. \nJinlan Fu, See-Kiong Ng, and Zhengbao Jiangan wd Pengfei Liu. GPTScore: Evaluate as you desire. ArXiv, abs/2302.04166, 2023. \nMor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did Aristotle use a laptop? A question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9:346–361, 2021. \nJiaxin Huang, Shixiang Shane Gu, Le Hou, Yuexin Wu, Xuezhi Wang, Hongkun Yu, and Jiawei Han. Large language models can self-improve. ArXiv, abs/2210.11610, 2022. ",
471
+ "page_idx": 9
472
+ },
473
+ {
474
+ "type": "text",
475
+ "text": "Harsh Jhamtani, Hao Fang, Patrick Xia, Eran Levy, Jacob Andreas, and Benjamin Van Durme. Natural language decomposition and interpretation of complex utterances. ArXiv, abs/2305.08677, 2023. ",
476
+ "page_idx": 10
477
+ },
478
+ {
479
+ "type": "text",
480
+ "text": "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, Yuntao 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, abs/2207.05221, 2022. \nMuhammad Khalifa, Lajanugen Logeswaran, Moontae Lee, Ho Hin Lee, and Lu Wang. Discriminator-guided multi-step reasoning with language models. ArXiv, abs/2305.14934, 2023. \nTakeshi Kojima, Shixiang (Shane) Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh (eds.), Advances in Neural Information Processing Systems, volume 35, pp. 22199–22213. Curran Associates, Inc., 2022. \nAitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. Solving quantitative reasoning problems with language models. ArXiv, abs/2206.14858, 2022. \nHunter Lightman, Vineet Kosaraju, Yura Burda, Harrison Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. ArXiv, abs/2305.20050, 2023. \nZ. Ling, Yunhao Fang, Xuanlin Li, Zhiao Huang, Mingu Lee, Roland Memisevic, and Hao Su. Deductive verification of Chain-of-Thought reasoning. ArXiv, abs/2306.03872, 2023. \nXiming Lu, Sean Welleck, Liwei Jiang, Jack Hessel, Lianhui Qin, Peter West, Prithviraj Ammanabrolu, and Yejin Choi. Quark: Controllable text generation with reinforced unlearning. ArXiv, abs/2205.13636, 2022. \nAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, Sean Welleck, Bodhisattwa Prasad Majumder, Shashank Gupta, Amir Yazdanbakhsh, and Peter Clark. Self-Refine: Iterative refinement with self-feedback. ArXiv, abs/2303.17651, 2023. \nLucie Charlotte Magister, Jonathan Mallinson, Jakub Adamek, Eric Malmi, and Aliaksei Severyn. Teaching small language models to reason. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 1773–1781, Toronto, Canada, July 2023. Association for Computational Linguistics. \nSewon Min, Victor Zhong, Luke Zettlemoyer, and Hannaneh Hajishirzi. Multi-hop reading comprehension through question decomposition and rescoring. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 6097–6109, Florence, Italy, July 2019. Association for Computational Linguistics. \nOpenAI. GPT-4 technical report. ArXiv, abs/2303.08774, 2023. \nBaolin Peng, Michel Galley, Pengcheng He, Hao Cheng, Yujia Xie, Yu Hu, Qiuyuan Huang, Lars Liden, Zhou Yu, Weizhu Chen, and Jianfeng Gao. ´ Check your facts and try again: Improving large language models with external knowledge and automated feedback. ArXiv, abs/2302.12813, 2023. \nAnsh Radhakrishnan, Karina Nguyen, Anna Chen, Carol Chen, Carson E. Denison, Danny Hernandez, Esin Durmus, Evan Hubinger, John Kernion, Kamil.e Lukovsiut.e, Newton Cheng, Nicholas Joseph, Nicholas Schiefer, Oliver Rausch, Sam McCandlish, Sheer El Showk, Tamera Lanham, Tim Maxwell, Venkat Chandrasekaran, Zac Hatfield-Dodds, Jared Kaplan, Janina Brauner, Sam Bowman, and Ethan Perez. Question decomposition improves the faithfulness of model-generated reasoning. ArXiv, abs/2307.11768, 2023. ",
481
+ "page_idx": 10
482
+ },
483
+ {
484
+ "type": "text",
485
+ "text": "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, abs/2302.04761, 2023. ",
486
+ "page_idx": 11
487
+ },
488
+ {
489
+ "type": "text",
490
+ "text": "Noah Shinn, Federico Cassano, Beck Labash, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. Reflexion: Language agents with verbal reinforcement learning, 2023. \nKumar Shridhar, Jakub Macina, Mennatallah El-Assady, Tanmay Sinha, Manu Kapur, and Mrinmaya Sachan. Automatic generation of socratic subquestions for teaching math word problems. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 4136–4149, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. \nKumar Shridhar, Alessandro Stolfo, and Mrinmaya Sachan. Distilling reasoning capabilities into smaller language models. In Findings of the Association for Computational Linguistics: ACL 2023, pp. 7059–7073, Toronto, Canada, July 2023. Association for Computational Linguistics. \nNiket Tandon, Aman Madaan, Peter Clark, Keisuke Sakaguchi, and Yiming Yang. Interscript: A dataset for interactive learning of scripts through error feedback. ArXiv, abs/2112.07867, 2021. \nXuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Huai hsin Chi, and Denny Zhou. SelfConsistency improves chain of thought reasoning in language models. ArXiv, abs/2203.11171, 2022. \nJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc V. Le, and Denny Zhou. Chain-of-thought prompting elicits reasoning in large language models. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh (eds.), Advances in Neural Information Processing Systems, volume 35, pp. 24824–24837. Curran Associates, Inc., 2022. \nSean Welleck, Ximing Lu, Peter West, Faeze Brahman, Tianxiao Shen, Daniel Khashabi, and Yejin Choi. Generating sequences by learning to self-correct. ArXiv, abs/2211.00053, 2022. \nYixuan Weng, Minjun Zhu, Fei Xia, Bin Li, Shizhu He, Kang Liu, and Jun Zhao. Large language models are better reasoners with self-verification. volume abs/2212.09561, 2022. \nMiao Xiong, Zhiyuan Hu, Xinyang Lu, Yifei Li, Jie Fu, Junxian He, and Bryan Hooi. Can LLMs express their uncertainty? an empirical evaluation of confidence elicitation in llms. ArXiv, abs/2306.13063, 2023. \nKevin Yang, Yuandong Tian, Nanyun Peng, and Dan Klein. Re3: Generating longer stories with recursive reprompting and revision. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 4393–4479, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. \nShunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. ReAct: Synergizing reasoning and acting in language models. ArXiv, abs/2210.03629, 2022. \nShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. ArXiv, abs/2305.10601, 2023. \nZhuosheng Zhang, Aston Zhang, Mu Li, and Alexander J. Smola. Automatic chain of thought prompting in large language models. ArXiv, abs/2210.03493, 2022. \nChuanyang Zheng, Zhengying Liu, Enze Xie, Zhenguo Li, and Yu Li. Progressive-Hint Prompting improves reasoning in large language models. ArXiv, abs/2304.09797, 2023. \nDenny Zhou, Nathanael Scharli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Huai hsin Chi. Least-to-most prompting enables complex reasoning in large language models. ArXiv, abs/2205.10625, 2022. \nDaniel M. Ziegler, Nisan Stiennon, Jeff Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. ArXiv, abs/1909.08593, 2019. ",
491
+ "page_idx": 11
492
+ },
493
+ {
494
+ "type": "text",
495
+ "text": "A TOKEN COST ",
496
+ "text_level": 1,
497
+ "page_idx": 12
498
+ },
499
+ {
500
+ "type": "text",
501
+ "text": "Tab. A shows the token cost of input and output for each module in SCREWS. Due to its iterative nature, subquestion decomposition requires on average four times more input tokens than the other modules. For Conditional Resampling, the model first predicts whether it wants to modify its output or not, using one token (“Yes” or “No”) for each sample and then only for the answers starting with “No”, it resamples. For the Selection module, the model chooses one of the two samples presented to it, using one token (A or B) for the output. ",
502
+ "page_idx": 12
503
+ },
504
+ {
505
+ "type": "table",
506
+ "img_path": "images/c3a450f247dfc6a29977c81f4c2163d8c8b127edb21c6b678450d1769c2fa9dc.jpg",
507
+ "table_caption": [],
508
+ "table_footnote": [],
509
+ "table_body": "<table><tr><td>Method</td><td>Input Tokens</td><td>Output Tokens</td><td>Total Tokens</td></tr><tr><td colspan=\"4\"> Subquestion generation step question</td></tr><tr><td>Subq (QG)</td><td>360</td><td>180</td><td>540</td></tr><tr><td colspan=\"4\">Sampling step </td></tr><tr><td>CoT</td><td>774</td><td>307</td><td>1081</td></tr><tr><td>CoT(k = 5)</td><td>3870</td><td>1530</td><td>5400</td></tr><tr><td>Subq (Or)</td><td>3187</td><td>413</td><td>3600</td></tr><tr><td>Subq (QG)</td><td>3121</td><td>434</td><td>3555</td></tr><tr><td colspan=\"4\">Conditional Resampling step ask</td></tr><tr><td>CoT</td><td>869</td><td>105</td><td>1184</td></tr><tr><td>Subq (Or)</td><td>3525</td><td>131</td><td>3656</td></tr><tr><td>Subq (QG)</td><td>3780</td><td>136</td><td>3916</td></tr><tr><td colspan=\"4\"> Selection step select</td></tr><tr><td>Selection</td><td>1296</td><td>1</td><td>1297</td></tr></table>",
510
+ "page_idx": 12
511
+ },
512
+ {
513
+ "type": "text",
514
+ "text": "Table 4: Average counts of input and output tokens for each choice of each module (step) in SCREWS. Many of the methods in Tab. 1 need to call multiple modules. We remark that the input tokens at each step include output tokens from previous steps. The counts shown for later steps average not only over examples, but also over choices of method for the previous steps. ",
515
+ "page_idx": 12
516
+ },
517
+ {
518
+ "type": "text",
519
+ "text": "B PROMPTS ",
520
+ "text_level": 1,
521
+ "page_idx": 12
522
+ },
523
+ {
524
+ "type": "text",
525
+ "text": "Below are abbreviated versions of the prompts used in the experiments, including instructions and demonstrations. For readability, we show only 1–2 demonstrations in each prompt. In each demonstration, the demonstrated result string is highlighted for the reader’s convenience, but this highlighting is not included in the prompt. Each prompt shown would be followed by the test question and then the cue (e.g., “Answer:”) that indicates that a result string should follow. ",
526
+ "page_idx": 12
527
+ },
528
+ {
529
+ "type": "text",
530
+ "text": "B.1 SAMPLING ",
531
+ "text_level": 1,
532
+ "page_idx": 12
533
+ },
534
+ {
535
+ "type": "text",
536
+ "text": "For Chain of Thought (CoT) and Subquestion Decomposition for GSM8K and StrategyQA, 5-shot prompts were used. For Auto Debugging, a 1-shot prompt was used. ",
537
+ "page_idx": 12
538
+ },
539
+ {
540
+ "type": "text",
541
+ "text": "B.1.1 CHAIN OF THOUGHT ",
542
+ "text_level": 1,
543
+ "page_idx": 12
544
+ },
545
+ {
546
+ "type": "text",
547
+ "text": "GSM8K ",
548
+ "text_level": 1,
549
+ "page_idx": 12
550
+ },
551
+ {
552
+ "type": "text",
553
+ "text": "I am a highly intelligent question answering bot. I will answer the last question ‘Question’ providing equation in $< < > >$ format in step by step manner. ",
554
+ "page_idx": 12
555
+ },
556
+ {
557
+ "type": "text",
558
+ "text": "Question: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? ",
559
+ "page_idx": 12
560
+ },
561
+ {
562
+ "type": "table",
563
+ "img_path": "images/c1b23adfcd2ed2cb62985e411065e07076d4057605e9be194bca04d98b58ff02.jpg",
564
+ "table_caption": [],
565
+ "table_footnote": [],
566
+ "table_body": "<table><tr><td colspan=\"10\">Answer: He writes each friend 3*2= &lt;&lt;3*2 =6&gt;&gt;6 pages a week. So he writes</td></tr><tr><td colspan=\"11\">6 * 2 = &lt;&lt;6 *2 = 12&gt;&gt;12 pages every week. That means he writes 12 * 52 = &lt;&lt;12 * 52 = 624&gt;&gt;624</td></tr><tr><td colspan=\"11\">pages a year. The answer is 624</td></tr></table>",
567
+ "page_idx": 12
568
+ },
569
+ {
570
+ "type": "text",
571
+ "text": "StrategyQA ",
572
+ "text_level": 1,
573
+ "page_idx": 13
574
+ },
575
+ {
576
+ "type": "text",
577
+ "text": "You are a highly intelligent question answering bot. You will answer the question ‘Question’ in as details as possible. ",
578
+ "page_idx": 13
579
+ },
580
+ {
581
+ "type": "text",
582
+ "text": "Question: Is coal needed to practice parachuting? ",
583
+ "page_idx": 13
584
+ },
585
+ {
586
+ "type": "text",
587
+ "text": "Answer: Parachuting requires a parachute. Parachutes are made from nylon. Nylon is made from coal. The answer is True ",
588
+ "page_idx": 13
589
+ },
590
+ {
591
+ "type": "text",
592
+ "text": "Auto Debugging ",
593
+ "text_level": 1,
594
+ "page_idx": 13
595
+ },
596
+ {
597
+ "type": "text",
598
+ "text": "Answer the ’Question’ based on the provided code and provide explanation. ",
599
+ "page_idx": 13
600
+ },
601
+ {
602
+ "type": "text",
603
+ "text": "Question: ",
604
+ "page_idx": 13
605
+ },
606
+ {
607
+ "type": "text",
608
+ "text": "def f1(): return str(x) $^ +$ 'hello' \ndef f2(): return f1 $( 2 + \\mathbf { x } )$ ) \n$\\mathrm { ~ ~ x ~ } = \\mathrm { ~ ~ f 2 ~ }$ (524) ",
609
+ "page_idx": 13
610
+ },
611
+ {
612
+ "type": "text",
613
+ "text": "What is the value of $\\mathbf { X }$ at the end of this program? Output: First, x = 2 \\* 524 = 1048 and then ‘hello’ is appended to it. So x becomes 1048hello ",
614
+ "page_idx": 13
615
+ },
616
+ {
617
+ "type": "text",
618
+ "text": "B.1.2 SUBQUESTION DECOMPOSITION ",
619
+ "text_level": 1,
620
+ "page_idx": 13
621
+ },
622
+ {
623
+ "type": "text",
624
+ "text": "While subquestion decomposition uses a single prompt, each example requires multiple API calls because the next subquestion needs to be appended to the prompt. ",
625
+ "page_idx": 13
626
+ },
627
+ {
628
+ "type": "text",
629
+ "text": "GSM8K ",
630
+ "text_level": 1,
631
+ "page_idx": 13
632
+ },
633
+ {
634
+ "type": "text",
635
+ "text": "I am a highly intelligent question answering bot. I will answer the last question ‘Q’ providing equation in $< <$ $> >$ format keeping the Problem and previous Q and A into account. ",
636
+ "page_idx": 13
637
+ },
638
+ {
639
+ "type": "text",
640
+ "text": "Problem: There are 5 houses on a street, and each of the first four houses has 3 gnomes in the garden. If there are a total of 20 gnomes on the street, how many gnomes does the fifth house have? ",
641
+ "page_idx": 13
642
+ },
643
+ {
644
+ "type": "text",
645
+ "text": "Q: How many gnomes are in the first four houses? ",
646
+ "page_idx": 13
647
+ },
648
+ {
649
+ "type": "text",
650
+ "text": "A: In the first four houses, there are a total of 4 houses \\* 3 gnomes = <<4 ∗ 3 = 12>>12 gnomes. The answer is 12 \nQ: How many gnomes does the fifth house have? \nA: Therefore, the fifth house had 20 total gnomes - 12 gnomes = <<20 − 12 = 8>>8 gnomes. The answer is 8 ",
651
+ "page_idx": 13
652
+ },
653
+ {
654
+ "type": "text",
655
+ "text": "StrategyQA ",
656
+ "text_level": 1,
657
+ "page_idx": 13
658
+ },
659
+ {
660
+ "type": "text",
661
+ "text": "You are a highly intelligent question answering bot. You will answer the last question ‘Q’ keeping the Problem and previous Q and A into account and then answer the Final Question based on all the previous answer ‘A’. ",
662
+ "page_idx": 13
663
+ },
664
+ {
665
+ "type": "text",
666
+ "text": "",
667
+ "page_idx": 13
668
+ },
669
+ {
670
+ "type": "text",
671
+ "text": "Problem: Is coal needed to practice parachuting? \nQ: What is one of the most important item that you need to go parachuting? A: Parachuting requires a parachute. \nQ: What is #1 made out of? \nA: Parachutes are made from nylon. \nQ: Is #2 originally made from coal? \nA: Nylon is made from coal. \nFinal Question: Is coal needed to practice parachuting? \nFinal Answer: True ",
672
+ "page_idx": 13
673
+ },
674
+ {
675
+ "type": "text",
676
+ "text": "B.1.3 ANSWER ONLY ",
677
+ "text_level": 1,
678
+ "page_idx": 13
679
+ },
680
+ {
681
+ "type": "text",
682
+ "text": "Answer Only was only used for Auto Debugging in a 1-shot manner and that one example is provided below: ",
683
+ "page_idx": 13
684
+ },
685
+ {
686
+ "type": "text",
687
+ "text": "Input: def f1(): return str(x) + 'hello' ",
688
+ "page_idx": 13
689
+ },
690
+ {
691
+ "type": "text",
692
+ "text": "def f2(): return f1 $( 2 + \\mathbf { x } )$ \nx = f2(524) ",
693
+ "page_idx": 14
694
+ },
695
+ {
696
+ "type": "text",
697
+ "text": "What is the value of $\\mathbf { X }$ at the end of this program? ",
698
+ "page_idx": 14
699
+ },
700
+ {
701
+ "type": "text",
702
+ "text": "Output: 1048hello ",
703
+ "page_idx": 14
704
+ },
705
+ {
706
+ "type": "text",
707
+ "text": "B.2 CONDITIONAL RESAMPLING ",
708
+ "text_level": 1,
709
+ "page_idx": 14
710
+ },
711
+ {
712
+ "type": "text",
713
+ "text": "We used 4-shot prompting for conditional resampling (two positive and two negative) for GSM8K and StrategyQA and 2-shot (one positive and one negative) for Auto Debugging. One pair of each is presented below: ",
714
+ "page_idx": 14
715
+ },
716
+ {
717
+ "type": "text",
718
+ "text": "B.2.1 CHAIN OF THOUGHT ",
719
+ "text_level": 1,
720
+ "page_idx": 14
721
+ },
722
+ {
723
+ "type": "text",
724
+ "text": "GSM8K ",
725
+ "text_level": 1,
726
+ "page_idx": 14
727
+ },
728
+ {
729
+ "type": "text",
730
+ "text": "Question: Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? \nAnswer: In April, Natalia sold 48 clips. In May, Natalia sold half of the toal clips meaning $7 2 / 2 { < } { < } 7 2 / 2 =$ $3 6 > > 3 6$ clips. So, Natalia sold a total of $4 8 + 3 6 < < 4 8 + 3 6 = 8 4 > > 8 4$ clips in April and May. The answer is 84 \nYou are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. \nAnswer: No, the reasoning is incorrect. Final Answer: Natalia sold 48/2 = <<48/2 = 24>>24 clips in May. So she sold a total of 48 + 24<<48 + 24 = 72>>72 clips. The answer is 72 ",
731
+ "page_idx": 14
732
+ },
733
+ {
734
+ "type": "text",
735
+ "text": "Question: There are 5 houses on a street, and each of the first four houses has 3 gnomes in the garden. If there are a total of 20 gnomes on the street, how many gnomes does the fifth house have? ",
736
+ "page_idx": 14
737
+ },
738
+ {
739
+ "type": "text",
740
+ "text": "Answer:In the first four houses, there are a total of 4 houses $^ \\ast \\ 3$ gnomes $= \\mathit { < } \\mathit { < } 4 \\ast 3 = 1 2 \\textgreater \\mathrm { > } 1 2$ gnomes. Therefore, the fifth house had 20 total gnomes - 12 gnomes $= < < 2 0 - 1 2 = 8 > > 8$ gnomes. The answer is 8 You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. ",
741
+ "page_idx": 14
742
+ },
743
+ {
744
+ "type": "text",
745
+ "text": "Answer: Yes, the reasoning is correct. Final Answer: In the first four houses, there are a total of 4 houses \\* 3 gnomes = <<4 ∗ 3 = 12>>12 gnomes. Therefore, the fifth house had 20 total gnomes - 12 gnomes = <<20 − 12 = 8>>8 gnomes. The answer is 8 ",
746
+ "page_idx": 14
747
+ },
748
+ {
749
+ "type": "text",
750
+ "text": "StrategyQA ",
751
+ "text_level": 1,
752
+ "page_idx": 14
753
+ },
754
+ {
755
+ "type": "text",
756
+ "text": "Question: Could Durian cause someone’s stomach to feel unwell? ",
757
+ "page_idx": 14
758
+ },
759
+ {
760
+ "type": "text",
761
+ "text": "Answer: Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel excited and they like it. The answer is False You are an expert teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. Answer: No, the reasoning is incorrect. Final Answer: Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel nauseous. The answer is True ",
762
+ "page_idx": 14
763
+ },
764
+ {
765
+ "type": "text",
766
+ "text": "Question: Was Daniel thrown into the lion’s den in the New Testament? ",
767
+ "page_idx": 14
768
+ },
769
+ {
770
+ "type": "text",
771
+ "text": "Answer:The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False \nYou are an expert teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. \nAnswer: Yes, the reasoning is correct. Final Answer: The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False ",
772
+ "page_idx": 14
773
+ },
774
+ {
775
+ "type": "text",
776
+ "text": "StrategyQA (Resampling with facts) ",
777
+ "text_level": 1,
778
+ "page_idx": 14
779
+ },
780
+ {
781
+ "type": "text",
782
+ "text": "You are a highly intelligent question answering bot. You will answer the question ’Question’ in as details as possible. ’Facts’ are provided to assist you in answering the questions. \nQuestion: Are vinegar pickled cucumbers rich in lactobacillus? \nFacts: Pickles made with vinegar are not probiotic and are simply preserved. Pickles made through a soak in a ",
783
+ "page_idx": 14
784
+ },
785
+ {
786
+ "type": "text",
787
+ "text": "salt brine solution begin to ferment because of lactobacillus. Answer: No, vinegar does not contain lactobacillus. The answer is False ",
788
+ "page_idx": 15
789
+ },
790
+ {
791
+ "type": "text",
792
+ "text": "Question: Does Masaharu Morimoto rely on glutamic acid? ",
793
+ "page_idx": 15
794
+ },
795
+ {
796
+ "type": "text",
797
+ "text": "Facts: Masaharu Morimoto is a Japanese chef. Japanese cuisine relies on several forms of seaweed as ingredients and flavorings for broth like kombu dashi. Glutamic acid has been identified as the flavoring component in kombu seaweed. ",
798
+ "page_idx": 15
799
+ },
800
+ {
801
+ "type": "text",
802
+ "text": "Answer: Yes, Japanese chef uses a lot of glutamic acid. The answer is True ",
803
+ "page_idx": 15
804
+ },
805
+ {
806
+ "type": "text",
807
+ "text": "Auto Debugging ",
808
+ "text_level": 1,
809
+ "page_idx": 15
810
+ },
811
+ {
812
+ "type": "text",
813
+ "text": "Input: def f1(): return str(x) + 'hello' def f2(): return f1 $[ 2 \\star \\mathbf { x } ]$ ) x = f2(524) ",
814
+ "page_idx": 15
815
+ },
816
+ {
817
+ "type": "text",
818
+ "text": "What is the value of $\\mathbf { X }$ at the end of this program? Output: 1048hello \nVerdict: Yes, the answer is correct. \nFinal Answer: 1048hello ",
819
+ "page_idx": 15
820
+ },
821
+ {
822
+ "type": "text",
823
+ "text": "Input: ",
824
+ "page_idx": 15
825
+ },
826
+ {
827
+ "type": "text",
828
+ "text": "def f1(): return str(x) $^ +$ 'hello' \ndef f2(): return f1 $( 2 \\ast \\times )$ ) \n$\\textbf { x } = \\textrm { f } 2 \\ : ( 5 2 4 )$ ) What is the value of $\\mathbf { X }$ at the end of this program? Output: 524 \nVerdict: No, the answer is incorrect. \nFinal Answer: 1048hello ",
829
+ "page_idx": 15
830
+ },
831
+ {
832
+ "type": "text",
833
+ "text": "",
834
+ "page_idx": 15
835
+ },
836
+ {
837
+ "type": "text",
838
+ "text": "B.2.2 SUBQUESTION DECOMPOSITION ",
839
+ "text_level": 1,
840
+ "page_idx": 15
841
+ },
842
+ {
843
+ "type": "text",
844
+ "text": "GSM8K ",
845
+ "text_level": 1,
846
+ "page_idx": 15
847
+ },
848
+ {
849
+ "type": "text",
850
+ "text": "For each subquestion, the main problem and all previous subquestions along with the model-generated solutions are provided in order to solve the current subquestion. ",
851
+ "page_idx": 15
852
+ },
853
+ {
854
+ "type": "text",
855
+ "text": "Here is a math question and its solution. ",
856
+ "page_idx": 15
857
+ },
858
+ {
859
+ "type": "text",
860
+ "text": "Problem: Noah is a painter. He paints pictures and sells them at the park. He charges $\\$ 60$ for a large painting and $\\$ 30$ for a small painting. Last month he sold eight large paintings and four small paintings. If he sold twice as much this month, how much is his sales for this month? \nHow much did Noah earn from the large paintings? Noah earned $\\$ 60$ /large painting $\\textbf { \\em X } 8$ large paintings $=$ $\\$ < <60*8=480 > > 480$ for the large paintings. The answer is 480 \nQuestion: How much did Noah earn from the small paintings? \nAnswer: He also earned $\\$ 60/\\mathrm { s m a l l }$ painting $\\texttt { x 4 }$ small paintings $= \\ S < < 6 0 * 4 = 2 4 0 > > 2 4 0$ for the small paintings. The answer is 240 \nYou are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. \nAnswer: No, the reasoning is incorrect. Final Answer: He also earned \\$30/small painting x 4 small paintings = \\$<<30 ∗ 4 = 120>>120 for the small paintings. The answer is 120 ",
861
+ "page_idx": 15
862
+ },
863
+ {
864
+ "type": "text",
865
+ "text": "Here is a math question and its solution. ",
866
+ "page_idx": 15
867
+ },
868
+ {
869
+ "type": "text",
870
+ "text": "Problem: To make pizza, together with other ingredients, Kimber needs 10 cups of water, 16 cups of flour, and 1/2 times as many teaspoons of salt as the number of cups of flour. Calculate the combined total number of cups of water, flour, and teaspoons of salt that she needs to make the pizza. How many teaspoons of salt does Kimber need? To make the pizza, Kimber half as many teaspoons of salt as the number of cups of flour, meaning she needs $1 / 2 ^ { * } 1 6 = < < 1 6 * 1 / 2 = 8 > > 8$ teaspoons of salt. The answer is 8 ",
871
+ "page_idx": 15
872
+ },
873
+ {
874
+ "type": "text",
875
+ "text": "",
876
+ "page_idx": 16
877
+ },
878
+ {
879
+ "type": "text",
880
+ "text": "How many cups of flour and teaspoons of salt does Kimber need? The total number of cups of flour and teaspoons of salt she needs is $8 + 1 6 = < < 8 + 1 6 = 2 4 > > 2 4$ . The answer is 24 ",
881
+ "page_idx": 16
882
+ },
883
+ {
884
+ "type": "text",
885
+ "text": "Question: How many cups of water, flour, and salt does Kimber need? ",
886
+ "page_idx": 16
887
+ },
888
+ {
889
+ "type": "text",
890
+ "text": "Answer: She also needs 10 cups of water, which means the total number of cups of water and flour and teaspoons of salt she needs is $2 4 + 1 0 = < < 2 4 + 1 0 = 3 4 > > 3 4 .$ . The answer is 34 ",
891
+ "page_idx": 16
892
+ },
893
+ {
894
+ "type": "text",
895
+ "text": "You are a math teacher. Do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. ",
896
+ "page_idx": 16
897
+ },
898
+ {
899
+ "type": "text",
900
+ "text": "Answer: Yes, the reasoning is correct. Final Answer: She also needs 10 cups of water, which means the total number of cups of water and flour and teaspoons of salt she needs is 24 + 10 = <<24 + 10 = 34 > >>34. The answer is 34 ",
901
+ "page_idx": 16
902
+ },
903
+ {
904
+ "type": "text",
905
+ "text": "StrategyQA ",
906
+ "text_level": 1,
907
+ "page_idx": 16
908
+ },
909
+ {
910
+ "type": "text",
911
+ "text": "Here is a question and its answer. ",
912
+ "page_idx": 16
913
+ },
914
+ {
915
+ "type": "text",
916
+ "text": "Context: Would a diet of ice eventually kill a person? ",
917
+ "page_idx": 16
918
+ },
919
+ {
920
+ "type": "text",
921
+ "text": "Ice is the solid state of what? Ice can be melted into water, which consists of hydrogen and oxygen. ",
922
+ "page_idx": 16
923
+ },
924
+ {
925
+ "type": "text",
926
+ "text": "What nutrients are needed to sustain human life? Humans need carbohydrates, proteins, and fats that are contained in foods. ",
927
+ "page_idx": 16
928
+ },
929
+ {
930
+ "type": "text",
931
+ "text": "Question: Are most of $\\# 2$ absent from $\\# 1 2$ ",
932
+ "page_idx": 16
933
+ },
934
+ {
935
+ "type": "text",
936
+ "text": "Answer: Water does not contain fat, carbohydrates or protein. ",
937
+ "page_idx": 16
938
+ },
939
+ {
940
+ "type": "text",
941
+ "text": "You are an expert teacher. Based on the provided context, do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. ",
942
+ "page_idx": 16
943
+ },
944
+ {
945
+ "type": "text",
946
+ "text": "Answer: Yes, the reasoning is correct. Final Answer: Water does not contain fat, carbohydrates or protein. ",
947
+ "page_idx": 16
948
+ },
949
+ {
950
+ "type": "text",
951
+ "text": "Here is a question and its answer. ",
952
+ "page_idx": 16
953
+ },
954
+ {
955
+ "type": "text",
956
+ "text": "Context: Can binary numbers and standard alphabet satisfy criteria for a strong password? ",
957
+ "page_idx": 16
958
+ },
959
+ {
960
+ "type": "text",
961
+ "text": "Which characters make up binary numbers? Binary numbers only contain 0 and ",
962
+ "page_idx": 16
963
+ },
964
+ {
965
+ "type": "text",
966
+ "text": "Which characters make up the standard English alphabet? The standard alphabet contains twenty six letters but no special characters. ",
967
+ "page_idx": 16
968
+ },
969
+ {
970
+ "type": "text",
971
+ "text": "Question: Does #1 or #2 include special characters or symbols? ",
972
+ "page_idx": 16
973
+ },
974
+ {
975
+ "type": "text",
976
+ "text": "Answer: Yes, it contains all the special characters. ",
977
+ "page_idx": 16
978
+ },
979
+ {
980
+ "type": "text",
981
+ "text": "You are an expert teacher. Based on the provided context, do you think the reasoning process for the given problem is correct? Let’s check the ‘Answer’ in details, and then decide ‘Yes’ or ‘No’ and then write the correct ‘Final Answer’. ",
982
+ "page_idx": 16
983
+ },
984
+ {
985
+ "type": "text",
986
+ "text": "Answer: No, the reasoning is incorrect. Final Answer: Neither binary digits nor English alphabets consists of any special characters which is needed for a strong password. ",
987
+ "page_idx": 16
988
+ },
989
+ {
990
+ "type": "text",
991
+ "text": "B.3 SELECTION ",
992
+ "text_level": 1,
993
+ "page_idx": 16
994
+ },
995
+ {
996
+ "type": "text",
997
+ "text": "The LLM-based selection module $\\psi _ { \\mathrm { s e l e c t } }$ uses a 2-shot prompt. The 2 demonstrations in the prompt are shown below, for each dataset. ",
998
+ "page_idx": 16
999
+ },
1000
+ {
1001
+ "type": "text",
1002
+ "text": "GSM8K ",
1003
+ "text_level": 1,
1004
+ "page_idx": 16
1005
+ },
1006
+ {
1007
+ "type": "text",
1008
+ "text": "You are an expert math teacher. You are provided with a question and two answers. Lets check the ‘Answer choices’ step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ ",
1009
+ "page_idx": 16
1010
+ },
1011
+ {
1012
+ "type": "text",
1013
+ "text": "Question: Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? ",
1014
+ "page_idx": 16
1015
+ },
1016
+ {
1017
+ "type": "text",
1018
+ "text": "Answer choices: ",
1019
+ "page_idx": 16
1020
+ },
1021
+ {
1022
+ "type": "text",
1023
+ "text": "(A) In April, Natalia sold 48 clips. In May, Natalia sold 24 clips. So, Natalia sold a total of 72 clips in April and May. The answer is 72. So in May she sold 48 clips. Total clips sold in April and May $=$ $7 \\bar { 2 } + 4 8 = < < 7 2 + 4 8 = 1 2 0 > > 1 2 0$ . The answer is 120 \n(B) Natalia sold $4 8 / 2 = < < 4 8 / 2 = 2 4 > > 2 4$ clips in May. The answer is 24. Natalia sold $4 8 + 2 4 = < < 4 8 + 2 4 = 7 2 > >$ clips altogether. The answer is 72 \nAnswer: (B) ",
1024
+ "page_idx": 16
1025
+ },
1026
+ {
1027
+ "type": "text",
1028
+ "text": "You are an expert math teacher. You are provided with a question and two answers. Lets check the ‘Answer choices’ step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ ",
1029
+ "page_idx": 16
1030
+ },
1031
+ {
1032
+ "type": "text",
1033
+ "text": "Question: Dolly has two books. Pandora has one. If both Dolly and Pandora read each others’ books as well as their own, how many books will they collectively read by the end? ",
1034
+ "page_idx": 17
1035
+ },
1036
+ {
1037
+ "type": "text",
1038
+ "text": "Answer choices: ",
1039
+ "page_idx": 17
1040
+ },
1041
+ {
1042
+ "type": "text",
1043
+ "text": "(A) There are a total of $2 + 1 = < < 2 + 1 = 3 > > 3$ books. The answer is 3. Dolly and Pandora both read all 3 books, so 3 books/person $_ { \\textrm { X 2 } }$ people $= < < 3 * 2 = 6 { > } { > } 6$ books total. The answer is 6 (B) The total number of books are $2 * 1 = < < 2 * 1 = 2 > > 2$ books. The answer is 2. Dolly and Pandora read each other’s books as well as their own, so the total number of books they read is 3 books. The answer is 3 ",
1044
+ "page_idx": 17
1045
+ },
1046
+ {
1047
+ "type": "text",
1048
+ "text": "Answer: (A) ",
1049
+ "page_idx": 17
1050
+ },
1051
+ {
1052
+ "type": "text",
1053
+ "text": "StrategyQA ",
1054
+ "text_level": 1,
1055
+ "page_idx": 17
1056
+ },
1057
+ {
1058
+ "type": "text",
1059
+ "text": "You are the expert in the field. You are provided with a question and two answers. Lets check the reasoning process of each of the answer step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ Question: Could Durian cause someone’s stomach to feel unwell? ",
1060
+ "page_idx": 17
1061
+ },
1062
+ {
1063
+ "type": "text",
1064
+ "text": "Answer choices: ",
1065
+ "page_idx": 17
1066
+ },
1067
+ {
1068
+ "type": "text",
1069
+ "text": "(A) Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel nauseous. The answer is True \n(B) Durian has a pungent odor that many people describe as being similar to feet and onions. Unpleasant smells can make people feel excited and they like it. The answer is False ",
1070
+ "page_idx": 17
1071
+ },
1072
+ {
1073
+ "type": "text",
1074
+ "text": "Answer: (A) ",
1075
+ "page_idx": 17
1076
+ },
1077
+ {
1078
+ "type": "text",
1079
+ "text": "You are the expert in the field. You are provided with a question and two answers. Lets check the reasoning process of each of the answer step by step, and then decide which answer is correct ‘(A)’ or ‘(B)’ Question: Was Daniel thrown into the lion’s den in the New Testament? ",
1080
+ "page_idx": 17
1081
+ },
1082
+ {
1083
+ "type": "text",
1084
+ "text": "Answer choices: ",
1085
+ "page_idx": 17
1086
+ },
1087
+ {
1088
+ "type": "text",
1089
+ "text": "(A) The Book of Daniel is a book in the New Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on the life of Daniel. The answer is True (B) The Book of Daniel is a book in the Old Testament of the Bible. The Bible is divided into the Old Testament and the New Testament. The New Testament focuses on four Gospels regarding the life of Jesus. The answer is False ",
1090
+ "page_idx": 17
1091
+ },
1092
+ {
1093
+ "type": "text",
1094
+ "text": "Answer: ( B) ",
1095
+ "page_idx": 17
1096
+ },
1097
+ {
1098
+ "type": "text",
1099
+ "text": "Auto Debugging ",
1100
+ "text_level": 1,
1101
+ "page_idx": 17
1102
+ },
1103
+ {
1104
+ "type": "text",
1105
+ "text": "You are an expert Python debugger. You are provided with a question and two answers. Your job is to decide \nwhich answer is correct ‘(A)’ or ‘(B)’ \nQuestion: \ndef f1(): return str(x) $^ +$ 'hello' \ndef f2(): return f1 $( 2 + \\tt x )$ \n$\\mathrm { ~ ~ x ~ } = \\mathrm { ~ ~ f 2 ~ }$ (524) ",
1106
+ "page_idx": 17
1107
+ },
1108
+ {
1109
+ "type": "text",
1110
+ "text": "",
1111
+ "page_idx": 17
1112
+ },
1113
+ {
1114
+ "type": "text",
1115
+ "text": "What is the value of $\\mathbf { X }$ at the end of this program? Answer choices: ",
1116
+ "page_idx": 17
1117
+ },
1118
+ {
1119
+ "type": "text",
1120
+ "text": "(A) 524hello (B) 1048hello Answer: (B) ",
1121
+ "page_idx": 17
1122
+ },
1123
+ {
1124
+ "type": "text",
1125
+ "text": "B.4 QUESTION GENERATION ",
1126
+ "text_level": 1,
1127
+ "page_idx": 17
1128
+ },
1129
+ {
1130
+ "type": "text",
1131
+ "text": "5-shot prompts were used for generating subquestions for GSM8K dataset. An example is provided below: ",
1132
+ "page_idx": 17
1133
+ },
1134
+ {
1135
+ "type": "text",
1136
+ "text": "GSM8K ",
1137
+ "text_level": 1,
1138
+ "page_idx": 17
1139
+ },
1140
+ {
1141
+ "type": "text",
1142
+ "text": "I am a highly intelligent question generation bot. I will take the given question ‘Q’ and will decompose the main question into all ‘subquestions’ required to solve the question step by step. ",
1143
+ "page_idx": 17
1144
+ },
1145
+ {
1146
+ "type": "text",
1147
+ "text": "Q: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? Subquestions: How many pages does he write each week? How many pages does he write every week? How many pages does he write a year? ",
1148
+ "page_idx": 18
1149
+ },
1150
+ {
1151
+ "type": "text",
1152
+ "text": "StrategyQA ",
1153
+ "text_level": 1,
1154
+ "page_idx": 18
1155
+ },
1156
+ {
1157
+ "type": "text",
1158
+ "text": "I am a highly intelligent question generation bot. I will take the given question $\\mathbf { \\bar { Q } } ^ { \\star }$ and will decompose the main question into all ‘subquestions’ required to solve the question step by step. ",
1159
+ "page_idx": 18
1160
+ },
1161
+ {
1162
+ "type": "text",
1163
+ "text": "Q: Can you buy Casio products at Petco? \nSubquestions: What kind of products does Casio manufacture? What kind of products does Petco sell? Does \n#1 overlap with #2? ",
1164
+ "page_idx": 18
1165
+ }
1166
+ ]
parse/test/Oho3UxCkKr/Oho3UxCkKr_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/Oho3UxCkKr/Oho3UxCkKr_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/hFALpTb4fR/hFALpTb4fR.md ADDED
@@ -0,0 +1,631 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLM-grounded Diffusion: Enhancing Prompt Understanding of Text-to-Image Diffusion Models with Large Language Models
2
+
3
+ Long Lian UC Berkeley
4
+
5
+ longlian@berkeley.edu
6
+
7
+ Boyi Li UC Berkeley
8
+
9
+ boyili@berkeley.edu
10
+
11
+ Adam Yala UC Berkeley, UCSF
12
+
13
+ yala@berkeley.edu
14
+
15
+ Trevor Darrell UC Berkeley
16
+
17
+ trevordarrell@berkeley.edu
18
+
19
+ Reviewed on OpenReview: https://openreview.net/forum?id=hFALpTb4fR
20
+
21
+ # Abstract
22
+
23
+ Recent advancements in text-to-image diffusion models have yielded impressive results in generating realistic and diverse images. However, these models still struggle with complex prompts, such as those that involve numeracy and spatial reasoning. This work proposes to enhance prompt understanding capabilities in diffusion models. Our method leverages a pretrained large language model (LLM) for grounded generation in a novel two-stage process. In the first stage, the LLM generates a scene layout that comprises captioned bounding boxes from a given prompt describing the desired image. In the second stage, a novel controller guides an off-the-shelf diffusion model for layout-grounded image generation. Both stages utilize existing pretrained models without additional model parameter optimization. Our method significantly outperforms the base diffusion model and several strong baselines in accurately generating images according to prompts that require various capabilities, doubling the generation accuracy across four tasks on average. Furthermore, our method enables instruction-based multi-round scene specification and can handle prompts in languages not supported by the underlying diffusion model. We anticipate that our method will unleash users’ creativity by accurately following more complex prompts. Our code, demo, and benchmark are available at: https://llm-grounded-diffusion.github.io.
24
+
25
+ # 1 Introduction
26
+
27
+ The field of text-to-image generation has witnessed significant advancements, particularly with the emergence of diffusion models. These models have showcased remarkable capabilities in generating realistic and diverse images in response to textual prompts. However, despite the impressive results, diffusion models often struggle to accurately follow complex prompts that require specific capabilities to understand. Fig. 1 shows that Stable Diffusion (Rombach et al., 2022), even the latest SDXL (Podell et al., 2023), often could not generate a certain number of objects or understand negation in the prompt. It also struggles with spatial reasoning or associating attributes correctly with objects.
28
+
29
+ One potential solution to address this issue is of course to gather a comprehensive multi-modal dataset comprising intricate captions and train a text-to-image diffusion model for enhanced prompt understanding.
30
+
31
+ ![](images/fbc07744c1306aa50c9a7f23aec2b3b6556e6c2bf04c94089ce5c67ce08f98ca.jpg)
32
+ Figure 1: (a) Text-to-image diffusion models such as SDXL (Podell et al., 2023) often struggles to accurately follow prompts that involve negation, numeracy, attribute binding, or spatial relationships. (b) Our method LMD achieves enhanced prompt understanding capabilities and accurately follows these types of prompts.
33
+
34
+ ![](images/196bb4939474142436a9445a6d95d8423e69c2542b865f2d3e742142b70de1e7.jpg)
35
+ Figure 2: Our proposed LMD enhances prompt understanding in text-to-image diffusion models through a novel two-stage generation process: 1) An LLM layout generator takes a prompt from the user and outputs an image layout in the form of captioned bounding boxes. 2) A stable diffusion model guided by our layout-grounded controller generates the final image. Both stages utilize frozen pretrained models, which makes our method applicable to off-the-shelf LLMs and other diffusion models without grounding in their training objectives.
36
+
37
+ Nonetheless, this approach presents notable drawbacks. It requires considerable time and resources to curate a diverse and high-quality multi-modal dataset, not to mention the challenges associated with training or fine-tuning a diffusion model on such extensive data.
38
+
39
+ In contrast, we propose a novel training-free method that equips the diffusion model with an LLM that provides grounding for enhanced prompt understanding. Our method LLM-grounded Diffusion (LMD) consists of a two-stage generation process as shown in Fig. 2.
40
+
41
+ In the first stage of our method, we adapt an LLM to be a text-grounded layout generator through in-context learning. Given a prompt describing the desired image, the LLM generates scene layouts in the form of captioned bounding boxes, with a background caption and a negative prompt for what to avoid in generation.
42
+
43
+ In the second stage, we introduce a novel controller that guides an existing diffusion model without grounding in its training objective (e.g., Stable Diffusion) to follow the layout grounding generated in the first stage. In contrast to previous and concurrent works on region control (e.g., Bar-Tal et al. (2023); Chen et al. (2023); Xie et al. (2023)) that apply semantic control to certain spatial regions, our approach allows precise control over object instances in designated regions.
44
+
45
+ Notably, both stages utilize frozen pretrained models off-the-shelf, making our method applicable to LLMs and diffusion models trained independently without any LLM or diffusion model parameter optimization.
46
+
47
+ In addition to enhanced prompt understanding, our method also naturally enables instruction-based scene specification with multiple rounds of user requests (Fig. 3) and image generation from prompts in languages not supported by the base diffusion model (Fig. I.1) without additional training.
48
+
49
+ Shown in Fig. 1, LMD provides a unified solution to several caveats in prompt understanding at once and enables accurate and high-quality image generation from complex prompts. We demonstrate that a diffusion model grounded with LLM-generated layouts outperforms its base diffusion model and several recent baselines, doubling the average generation accuracy across four tasks. Our primary contributions include:
50
+
51
+ ![](images/6fc99a8f40b898e4a25a662d7be10020441283797b214d2013c7d13e221beb0c.jpg)
52
+ Figure 3: LMD naturally enables instruction-based multi-round scene specification and is able to adapt subsequent rounds of generation according to users’ followup instructions and clarifications.
53
+
54
+ 1. We propose a training-free two-stage generation pipeline that introduces LLMs to improve the prompt understanding ability of text-to-image diffusion models.
55
+ 2. We introduce layout-grounded Stable Diffusion, a novel controller that steers an off-the-shelf diffusion model to generate images grounded on instance-level box layouts from the LLM.
56
+ 3. LMD enables instruction-based scene specification and allows broader language support in the prompts.
57
+ 4. We propose a benchmark to assess the prompt understanding ability of a text-to-image model and demonstrate the superior performance of LMD over recent baselines.
58
+
59
+ We expect LMD to empower users with more precise control of text-to-image diffusion models. Our code, demo, and benchmark are publicly available.
60
+
61
+ # 2 Related Work
62
+
63
+ Text-to-image diffusion models. High-quality image generation from textual descriptions with diffusion models has been popular recently (Ramesh et al., 2022; Saharia et al., 2022; Rombach et al., 2022; Podell et al., 2023). Despite the impressive visual quality, these models still tend to exhibit unsatisfactory performance when it comes to complex prompts that involve skills such as binding attributes to objects and spatial reasoning (Ramesh et al., 2022).
64
+
65
+ LLMs for visual grounding. Many multi-modal models benefit from integrating LLMs for grounding vision models. BLIP-2 (Li et al., 2023a) bootstraps vision-language pre-training from a frozen image encoder and an LLM. Flamingo (Alayrac et al., 2022) tackles tasks such as few-shot visual question-answering and captioning tasks. Gupta et al. (2021) uses Transformer (Vaswani et al., 2017) for layout prediction but focuses on generating layouts for a limited closed set of object classes in the annotated training set and thus is not able to generate layouts for objects not in the training set. Wu et al. (2023) and Koh et al. (2023) also involve LLMs in conditional image generation. However, these methods still rely on CLIP text embeddings to convey the information to the diffusion model. Therefore, they often exhibit insufficient control compared to our method, which explicitly asks the LLM to reason about the spatial composition of different objects and poses direct spatial control. Concurrent to our work, LayoutGPT (Feng et al., 2023) proposes prompting an LLM for layout generation in a CSS structure. While LayoutGPT depends on a dataset annotated with boxes and captions to retrieve relevant in-context examples for the LLM, our method demonstrates that the ability for generating high-quality layouts is already present in pretrained LLM weights and can be prompted with a fixed set of in-context examples without external annotations.
66
+
67
+ ![](images/ea53a0522026a81fce4826fefdbedb80c54a7e1112422eb609cea007093cbb2b.jpg)
68
+ Figure 4: In stage 1, LMD generates an image layout from a user prompt. LMD embeds the user prompt into a template with instructions and in-context examples. An LLM is then queried for completion. Finally, the LLM completion is parsed to obtain a set of captioned bounding boxes, a background caption, and an optional negative prompt.
69
+
70
+ Spatially-conditioned image generation methods. These methods create images based on given priors such as poses, segmentation maps, strokes, and layouts. Prior to the popularity of diffusion models, SPADE (Park et al., 2019), BlobGAN (Epstein et al., 2022), and Layout2Im (Zhao et al., 2019) synthesize photorealistic images from a given layout. Xu et al. (2017); Johnson et al. (2018); Herzig et al. (2020) generate images with scene graphs. ControlNet (Zhang & Agrawala, 2023), SpaText (Avrahami et al., 2023), LayoutDiffuse (Cheng et al., 2023), LayoutDiffusion, (Zheng et al., 2023), GLIGEN (Li et al., 2023b) and ReCo (Yang et al., 2023) propose training-based adaptation on the diffusion models for spatially-conditioned image generation, with Li et al. (2023b) and Yang et al. (2023) supporting open-vocabulary labels for layout boxes. However, these methods rely on annotated external datasets such as COCO (Lin et al., 2014) to supply images with annotations such as boxes and captions. Furthermore, training-based adaptation makes the model incompatible to add-ons such as LoRA weights (Hu et al., 2021) and renders it difficult to train a new LoRA model from a training set without box annotations. In contrast, we propose a training-free generation controller that steers existing text-to-image diffusion models that are not specifically trained for layout-grounded image generation and does not require external datasets. Furthermore, our method can also integrate with training-based methods for further improvements.
71
+
72
+ Very recently, Bar-Tal et al. (2023); Chen et al. (2023); Xie et al. (2023) allow training-free region control in image generation and share a similar task formulation to our layout-to-image stage. However, these works ground the image generation on the region semantics and pose little control over the number of object instances inside each semantic region, whereas our method focuses on grounding generation on instances.
73
+
74
+ Similar to our instruction-based scene specification, Brooks et al. (2023) recently proposed instruction-based image editing. Wu et al. (2023) and Gupta & Kembhavi (2023) also allow using external image editing models in an LLM-driven dialog. Different from these methods, we aim to edit the scene layout rather than the image pixels, which easily allows support for a greater set of instructions such as swapping/moving objects.
75
+
76
+ # 3 LLM-grounded Diffusion
77
+
78
+ In this section, we introduce our method LLM-grounded Diffusion (LMD). LMD focuses on the text-to-image generation setting, which involves generating image $\mathbf { x } _ { \mathrm { 0 } }$ given text prompt y. Our method generates an image in two stages: text-grounded layout generation (Section 3.1) and layout-grounded image generation (Section 3.2). The layout-to-image stage of our method LMD builds upon the latent diffusion framework (Rombach et al., 2022), for which we refer readers to Appendix A for preliminaries.
79
+
80
+ # 3.1 LLM-based Layout Generation
81
+
82
+ To generate the layout of an image, our method embeds the input text prompt y into a template and queries an LLM for completion (Fig. 4).
83
+
84
+ Layout representation. LMD’s layout representation comprises two components: 1) a captioned bounding box for each foreground object, with coordinates specified in the (x, y, width, height) format, and 2) a simple and concise caption describing the image background along with an optional negative prompt indicating what should not appear in a generated image. The negative prompt is an empty string when the layout does not impose restrictions on what should not appear.
85
+
86
+ Instructions. Our text instructions to the LLM consist of two parts:
87
+
88
+ 1. Task specification:
89
+
90
+ Your task is to generate the bounding boxes for the objects mentioned in the caption, along with $\boldsymbol { a }$ background prompt describing the scene.
91
+
92
+ 2. Supporting details:
93
+
94
+ The images are of size 512×512... Each bounding box should be in the format of ... If needed, you can make reasonable guesses.
95
+
96
+ In-context learning. Similar to Brooks et al. (2023), we provide the LLM with manually curated examples after the task description. Through these examples, we clarify the layout representation and provide preferences to disperse ambiguity. An example is shown as follows:
97
+
98
+ Caption: A watercolor painting of a wooden table in the living room with an apple on it
99
+ Objects: [(‘a wooden table’, [65, 243, 344, 206]), (‘an apple’, [206, 306, 81, 69])]
100
+ Background prompt: A watercolor painting of a living room
101
+ Negative prompt:
102
+
103
+ To ensure precise layout control, we adhere to two key principles in our example design: 1) Each object instance is represented by a single bounding box. For instance, if the prompt mentions four apples, we include four boxes with “an apple” in each caption. 2) We leave no foreground objects specified in the boxes to the background caption to ensure all foreground objects are controlled by our layout-grounded image generator (Section 3.2). These principles allow for accurate and instance-controlled layout generation.
104
+
105
+ LLM completion. After providing the in-context examples, we query the LLM for completion:
106
+
107
+ Caption: [input prompt from the user] Objects: [start of LLM completion]
108
+
109
+ The resulting layout from the LLM completion is then parsed and used for the subsequent image generation process. We refer readers to the Appendix K for our complete prompt.
110
+
111
+ # 3.2 Layout-grounded Stable Diffusion
112
+
113
+ In this stage, we introduce a controller to ground the image generation on the LLM-generated layout. While previous training-free region control methods (Bar-Tal et al., 2023; Chen et al., 2023; Xie et al., 2023) apply semantic guidance through regional denoising or attention manipulation, these methods lack the ability to control the number of objects within a semantic region. This limitation arises as the different instances are often indistinguishable in either the latent space or the attention map, hindering instance-level control.
114
+
115
+ In contrast, LMD enables instance-level grounding by first generating masked latents for each individual bounding box and then composing the masked latents as priors to guide the overall image generation. This allows for precise placement and attribute binding for each object instance.
116
+
117
+ Per-box masked latents. While diffusion models lack inherent instance-level distinction in their latent space or attention maps for fine-grained control, we observe that they are often able to generate images with one specified instance. Hence, we process one foreground box at a time for instance-level grounding.
118
+
119
+ As depicted in Fig. 5(a), for each foreground object $i$ , we first generate an image with a single instance by denoising from $\mathbf { z } _ { T } ^ { ( i ) }$ i ) to z ( i )0 , where $\mathbf { z } _ { t } ^ { ( i ) }$ refers to the latents of object $i$ at denoising timestep $t$ .1 In this denoising process, we use “[background prompt] with [box caption]” (e.g., “a realistic image of an indoor scene with a gray cat”) as the text prompt for denoising. The initial noise latent is shared for all boxes to ensure globally coherent viewpoint, style, and lighting (i.e., $\mathbf { z } _ { T } ^ { ( i ) } = \mathbf { z } _ { T } , \forall i$ ).
120
+
121
+ ![](images/226e397156ee6c93b45090364b7e50ab7edce3455d2daf62fa642cc34ead4796.jpg)
122
+ Figure 5: In stage 2, we introduce a novel layout-grounded controller that guides stable diffusion to generate images based on the layout obtained from the previous stage. Our layout-grounded image generation process consists of two steps: (a) generating masked latents for each box specified in the layout, with attention control ensuring that the object is placed in the designated box; and (b) composing the masked latents as priors to guide the image generation to adhere to the specified layout.
123
+
124
+ To ensure the object aligns with the bounding box, we manipulate the cross-attention maps $\mathbf { A } ^ { ( i ) }$ of the noise-prediction network.2 Each map describes the affinity from pixels to text tokens:
125
+
126
+ where $\mathbf { q } _ { u }$ and $\mathbf { k } _ { v }$ are linearly transformed image feature at spatial location $u$ and text feature at token index $v$ in the prompt, respectively.
127
+
128
+ Following Chen et al. (2023); Xie et al. (2023), we strengthen the cross-attention from pixels inside the box to tokens associated with the box caption while attenuating the cross-attention from pixels outside the box. To achieve this, we define a simple energy function:
129
+
130
+ $$
131
+ \begin{array} { r } { E ( \mathbf { A } ^ { ( i ) } , i , v ) = - 7 \mathsf { o p k } _ { u } ( \mathbf { A } _ { u v } \cdot \mathbf { b } ^ { ( i ) } ) \ + \omega \mathsf { T o p k } _ { u } ( \mathbf { A } _ { u v } \cdot ( 1 - \mathbf { b } ^ { ( i ) } ) ) } \end{array}
132
+ $$
133
+
134
+ where · is element-wise multiplication, $\mathbf { b } ^ { ( i ) }$ is a rectangular binary mask of the box $i$ with the region in the box set to 1, ${ \mathsf { T o p k } } _ { u }$ takes the average of top-k values across the spatial dimension $u$ , and $\omega = 4 . 0$ . The energy function is minimized by updating the latent before each denoising step:
135
+
136
+ $$
137
+ \mathbf { z } _ { t } ^ { ( i ) } \gets \mathbf { z } _ { t } ^ { ( i ) } - \eta \nabla _ { \mathbf { z } _ { t } ^ { ( i ) } } \sum _ { v \in V _ { i } } E ( \mathbf { A } ^ { ( i ) } , i , v )
138
+ $$
139
+
140
+ $$
141
+ \mathbf { z } _ { t - 1 } ^ { ( i ) } \mathsf { D e n o i s e } ( \mathbf { z } _ { t } ^ { ( i ) } )
142
+ $$
143
+
144
+ where $\eta$ is the guidance strength; the set $V _ { i }$ contains the token indices for the box caption in the prompt for box $i$ (e.g., while generating the masked latents for a box $i$ with caption “a gray cat”, $V _ { i }$ indicates the indices of tokens that correspond to the box caption in the per-box denoising text prompt “[background prompt] with a gray cat”). Denoise $( \cdot )$ denotes one denoising step in the latent diffusion framework.
145
+
146
+ ![](images/99614ff8726152f94de399b76db6e166aa472988cff35b72d0f67a35ef760c20.jpg)
147
+ Figure 6: LMD and $\mathbf { L M D + }$ support instruction-based scene specification, empowering the users to add/move/remove objects, modify object attributes, and clarify the prompt in multiple rounds of dialog. (a): the initial prompt for the scene; (b)-(i): eight subsequent instructions that sequentially modify the scene. By separating the generation of each foreground object as well as the background, LMD ensures consistent image generation when the same seed is used for image generation throughout the dialog.
148
+
149
+ After generation, we obtain the cross-attention map that corresponds to the box caption, which serves as a saliency mask for the object. We optionally use SAM (Kirillov et al., 2023) to refine the quality of the mask. This can be done by querying either with the pixel location that has the highest saliency or with the layout box. The functionality of SAM can also be replaced by a simple thresholding, as experimented in Section 4.3. With the refined mask for exactly one foreground instance, denoted as $\mathbf { m } ^ { ( i ) }$ , we perform element-wise multiplication between the mask and the latent at each denoising step to create a sequence of masked instance latents $( \hat { \mathbf { z } } _ { t } ^ { ( i ) } ) _ { t = 0 } ^ { T }$ :
150
+
151
+ $$
152
+ \widehat { \mathbf { z } } _ { t } ^ { ( i ) } = \mathbf { z } _ { t } ^ { ( i ) } \otimes \mathbf { m } ^ { ( i ) }
153
+ $$
154
+
155
+ Masked latents as priors for instance-level control. The masked instance latents $( \widehat { \mathbf { z } } _ { t } ^ { ( i ) } ) _ { t = 0 } ^ { T }$ are then leveraged to provide instance-level hints to the diffusion model for the overall image generation. As illustrated in Fig. 5(b), during each denoising time step in the early denoising process, we place each masked foreground latents $\hat { \mathbf { z } } _ { t } ^ { ( i ) }$ onto the composed latents $\mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) }$ :
156
+
157
+ $$
158
+ \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } \gets \mathsf { L a t e n t C o m p o s e } \big ( \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } , \hat { \mathbf { z } } _ { t } ^ { ( i ) } , \mathbf { m } ^ { ( i ) } \big ) \quad \forall i
159
+ $$
160
+
161
+ where (comp) is initialized from for foreground generation for consistency, and TLatentCompose $( \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } , \hat { \mathbf { z } } _ { t } ^ { ( i ) } , \mathbf { m } ^ { ( i ) } )$ simply puts the masked foreground latents $\hat { \mathbf { z } } _ { t } ^ { ( i ) }$ onto the corresponding location on z(comp)t .
162
+
163
+ Since diffusion models tend to generate the object placement in the initial denoising steps and then object details in later steps (Bar-Tal et al., 2023), we only compose the latents from timestep $T$ to $r T ^ { 3 }$ , where $r \in [ 0 , 1 ]$ balances instance control and image coherency. By primarily intervening during the steps for object placement, our method merely provides instance-level layout hints rather than forcing each masked region of the resulting generation to look the same as the per-box generation.
164
+
165
+ To make our guidance more robust, we further transfer the cross-attention maps from per-box generation to the corresponding regions in the composed generation by adapting the energy function:
166
+
167
+ $$
168
+ E ^ { ( \mathrm { c o m p ) } } ( \mathbf { A } ^ { ( \mathrm { c o m p ) } } , \mathbf { A } ^ { ( i ) } , i , v ) = E ( \mathbf { A } ^ { ( \mathrm { c o m p ) } } , i , v ) + \lambda \sum _ { u \in V _ { i } ^ { \prime } } \left| \mathbf { A } _ { u v } ^ { ( \mathrm { c o m p ) } } - \mathbf { A } _ { u v } ^ { ( i ) } \right|
169
+ $$
170
+
171
+ where $\lambda = 2 . 0$ and the energy value of each box $i$ is summed up for optimization. $V _ { i } ^ { \prime }$ denotes the indices of tokens that correspond to the box caption in the text prompt for the overall denoising process, similar to the definition of $V _ { i }$ in Eq. (3).
172
+
173
+ In this way, our controller conditions the diffusion model to generate one instance at each masked location, with the final generation natural and coherent in terms of foreground-background composition.
174
+
175
+ Finally, we decode latents $\mathbf { z } _ { 0 } ^ { ( \mathrm { c o m p } ) }$ to pixels $\mathbf { x } _ { 0 }$ via the diffusion image decoder. We refer readers to Appendix B for the overall pseudo-code for layout grounding.
176
+
177
+ Integration with training-based methods. Our training-free controller can also be applied along with training-based methods such as GLIGEN (Li et al., 2023b) to leverage instance-annotated external datasets when available. Since GLIGEN trains adapter layers taking box inputs, the integration with GLIGEN, denoted as LMD $^ +$ , involves adopting its adapter weights and passing the layout guidance to the adapter layers. Note that $\mathrm { L M D + }$ uses adapters along with the instance-level guidance introduced above, which greatly surpasses only using GLIGEN adapters, as shown in Table 2. We achieve further enhanced instance and attribute control without additional training through this integration.
178
+
179
+ ![](images/582ddac0427489930a682686343eb9c02b5962a48476f9ab39344b07e10aa1e1.jpg)
180
+ Figure 7: LMD outperforms its base text-to-image diffusion model Podell et al. (2023) in accurately following the prompts that require spatial and language reasoning. Best viewed when zoomed in.
181
+
182
+ # 3.3 Additional Capabilities of LMD
183
+
184
+ Our LLM-grounded generation pipeline allows for two additional capabilities without additional training.
185
+
186
+ Instruction-based scene specification. Leveraging an LLM that supports multi-round dialog (e.g., GPT-3.5/4), LMD empowers the users to specify the desired image with multiple instructions following an initial prompt (Fig. 3). Specifically, after the initial image generation, a user can simply give clarifications or additional requests to the LLM. With the updated layout from the LLM, we can leverage LMD again to generate images with the updated layout. Updating the layout rather than the raw image gives LMD several advantages, as demonstrated in Fig. 6: 1) Our generation remains consistent after multiple rounds of requests instead of gradually drifting away from the intial image. 2) LMD can handle requests that involve spatial reasoning, which are the limitations of previous instruction-based image editing method Brooks et al. (2023). In contrast, we demonstrate that VisualChatGPT Wu et al. (2023), which equips ChatGPT with tools such as Brooks et al. (2023), is not able to follow the instructions in Fig. 6, especially for spatial instructions over multiple iterations of dialog. We refer interested readers to Appendix G for the comparison. This capability applies to both LMD and LMD $^ +$ . We also show additional use cases in Fig. C.1 in Appendix C. Our LMD can handle requests for open-ended scene adjustments, offer suggestions for the current scene, understand user requests within the dialog context, and allow the users to try out different detailed adjustments while preserving the overall image style and layout, facilitating fine-grained content creation.
187
+
188
+ Supporting more languages. By giving an in-content example of a non-English user prompt and an English layout output $^ 4$ , the LLM layout generator accepts non-English user prompts and outputs layouts with English captions. This allows generation from prompts in languages not supported by the underlying diffusion model without additional training (Fig. I.1). We refer readers to Appendix I for additional details.
189
+
190
+ # 4 Evaluation
191
+
192
+ # 4.1 Qualitative Comparison
193
+
194
+ Setup. We qualitatively compare our approach with Stable Diffusion (SD, Rombach et al. (2022); Podell et al. (2023)). SD family is also chosen as our underlying base model for layout-grounded image generation given its strong capabilities and widespread adoption in text-to-image generation research. Thanks to the training-free nature of our work, our method is applicable to various diffusion models without additional training. Therefore, for Fig. 1, 7, and 9, we use the largest Stable Diffusion model SDXL as the base model of LMD and compare against SDXL as a baseline (see Appendix H for details). For all other settings, we use Stable Diffusion v1.5 as the base model unless stated otherwise. We use gpt-4 (OpenAI, 2023) for layout generation for all qualitative comparisons. Results. In Fig. 1 and 7, we observe that our two-stage text-to-image generation approach greatly enhances prompt following ability compared to our base model by generating images that align with the layouts from the LLM.
195
+
196
+ ![](images/815afd0577902c050aed635de524e39fe347a70c5112af15867b60351b509431.jpg)
197
+ Figure 8: We qualitatively compare with VisualChatGPT (Wu et al., 2023) and GILL (Koh et al., 2023) that also leverage LLMs in the image generation pipelines. Both baselines lack the ability to accurately follow the prompts for three out of four tasks that our method can solve in Fig. 1 and F.1.
198
+
199
+ Table 1: With guidance from the LLM-based layout generator and our novel layout-grounded controller, our LMD significantly outperforms the Stable Diffusion model (SD) that we use under the hood in four tasks benchmarking prompt-following abilities. LMD denotes our method directly applied on SD. LMD+ denotes additionally integrating pretrained GLIGEN (Li et al., 2023b) adapters into our controller.
200
+
201
+ <table><tr><td rowspan="2">Tasks</td><td colspan="3">Accuracy</td></tr><tr><td>SD</td><td>LMD</td><td>LMD+</td></tr><tr><td>Negation Generative Numeracy 39% 62% (1.6×)</td><td></td><td></td><td>28% 100% (3.6x) 100% (3.6x) 86% (2.2x)</td></tr><tr><td>Attribute Binding</td><td></td><td>52% 65% (1.3x)</td><td>69% (1.3x)</td></tr><tr><td> Spatial Relationships 28% 79% (2.8×)</td><td></td><td></td><td>67% (2.4x)</td></tr><tr><td>Average</td><td></td><td> 37% 77% (2.1x)</td><td>81% (2.2x)</td></tr></table>
202
+
203
+ Comparing with other LLM-based image generators. VisualChatGPT (Wu et al., 2023) and GILL (Koh et al., 2023) also leverage LLMs as a part of the image generation pipelines. Both works leverage SD as the underlying image generation model. VisualChatGPT treats SD as a module that can be used by the LLM and passes text caption to it, and GILL outputs a embedding in place of the text embedding for SD. Since both methods utilize LLMs to only provide conditions to SD in the form of text embeddings, these methods still inherit the problems of insufficient control of text embeddings from the base SD model. In contrast, our method asks the LLM to explicitly reason about the spatial relationships and applies direct spatial control on our underlying diffusion model, thereby bypassing the bottleneck of the text embedding representation that does not accurately convey spatial information. As shown in Fig. 8, neither method accurately follows text prompts of several categories that our method is able to correctly generate in Fig. 1 and Fig. F.1 in Appendix F. Furthermore, although the involvement of LLM in VisualChatGPT and GILL also potentially allows multi-round instruction-based scene specification (Section 3.3), we empirically observe that the generated images quickly deviate from the scene of “a wooden table” starting from the second iteration in Fig. G.1 in Appendix G, with the final generation being incomprehensible.
204
+
205
+ <table><tr><td rowspan="2"> Stage 1/Stage 2</td><td colspan="5">Accuracy</td></tr><tr><td>Negation</td><td>Numeracy</td><td>Attribute</td><td>Spatial</td><td>Average</td></tr><tr><td> Training-free methods:</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LMD/MultiDiffusion (Bar-Tal et al., 2023)</td><td>100%</td><td>30%</td><td>42%</td><td>36%</td><td>52.0%</td></tr><tr><td>LMD/Backward Guidance (Chen et al., 2023) 100%</td><td></td><td>42%</td><td>36%</td><td>61%</td><td>59.8%</td></tr><tr><td>LMD/BoxDiff (Xie et al., 2023)</td><td>100%</td><td>32%</td><td>55%</td><td>62%</td><td>62.3%</td></tr><tr><td> LMD/LMD (Ours)</td><td>100%</td><td>62%</td><td>65%</td><td>79%</td><td>76.5% (+ 14.2)</td></tr><tr><td>Training-based methods:</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LMD/GLIGEN (Li et al., 2023b)</td><td>100%</td><td>57%</td><td>57%</td><td>45%</td><td>64.8%</td></tr><tr><td> LMD/LMD+ (Ours)</td><td>100%</td><td>86%</td><td>69%</td><td>67%</td><td>80.5% (+ 15.7)</td></tr><tr><td> LMD/LMD+ (Ours, GPT-4)</td><td>100%</td><td>84%</td><td>79%</td><td>82%</td><td>86.3% (+ 21.5)</td></tr><tr><td> Eualuating generated layouts only (upper bound for image generation):</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LMD/-</td><td>100%</td><td>97%</td><td>100%</td><td>99%</td><td>99.0%</td></tr></table>
206
+
207
+ Table 2: Ablations on layout-to-image methods as stage 2 with our LLM layout generator as stage 1. Our proposed layout-grounded controller performs the best among them. Our controller could also be applied on top of training-based GLIGEN (Li et al., 2023b), denoted as LMD $^ +$ , for additional improvements. Finally, the LLM-generated layouts almost always align with the prompt, highlighting that the bottleneck is the layout-grounded image generation. The scores for negation task are high because we pass the negative prompts generated by the LLM to the underlying diffusion model, which does not depend on the stage 2 implementation.
208
+
209
+ # 4.2 Quantitative evaluation
210
+
211
+ # 4.2.1 Proposed benchmark
212
+
213
+ We propose a text-to-image evaluation benchmark that includes four tasks: negation, generative numeracy, attribute binding, and spatial reasoning. Negation and generative numeracy involve generating a specific number of objects or not generating specific objects. Attribute binding involves assigning the right attribute to the right object with multiple objects in the prompt. Spatial reasoning involves understanding words that describe the relative locations of objects. For each task, we programmatically compose 100 prompts and query each model for text-to-image generation, with 400 prompts in total. gpt-3.5-turbo (Brown et al., 2020) is used in LMD for the benchmarks. We also implemented LMD $^ +$ , a LMD variant that integrate pretrained GLIGEN (Li et al., 2023b) adapters into our controller without further training. We refer readers to Appendix J for details.
214
+
215
+ Detection-based evaluation. We use an open-vocabulary object detector, OWL-ViT (Minderer et al., 2022), to obtain bounding boxes for the objects of interest. We then check whether each generated image satisfies the requirements in the prompt. The accuracy of each task is computed by calculating the proportion of the image generations that match their corresponding prompts over all generations.
216
+
217
+ Results. As presented in Table 1, our model shows significant improvements in generation accuracy, ranging from $1 . 3 \times$ to $3 . 6 \times$ compared to SD across four tasks and doubling the accuracy on average. Notably, LMD achieves image generation accuracy that is more than twice of the SD accuracy for the spatial relationships and the negation task. This highlights the utility of the grounding image generation on the LLM layout generator. Furthermore, when additionally integrating GLIGEN to our pipeline to leverage in-domain instance-annotated data, our method, denoted as LMD $^ +$ , achieves additional improvements.
218
+
219
+ # 4.3 Ablation Study
220
+
221
+ Layout-to-image stage. Comparing with other layout-to-image methods. As shown in Table 2, compared with training-free layout-to-image generation methods that perform semantic-level grounding, our proposed layout-grounded controller provides much better instance-level grounding. This is justified by the fact that our training-free controller even surpasses training-based method GLIGEN (Li et al., 2023b) in the generative numeracy task, despite not trained with any instance-level annotation. Furthermore, our controller also sigficantly surpasses training-based method GLIGEN (Li et al., 2023b) in attribute binding and spatial reasoning task. When integrated with GLIGEN to leverage instance-annotated datasets, our integration, denoted as LMD $^ +$ , allows for further improvements without the need for additional training. Switching the base diffusion model without hyperparameter tuning. As shown in Table 3, thanks to our training-free nature, LMD maintains the gains to the base model (around $2 \times$ performance boost) when we switch the base diffusion model from SDv1.5 to SDv2.1 without tuning any hyperparameters, including $\lambda$ and $\omega$ that are introduced by our method.5 This showcases the potential of integrating LMD with future diffusion models. Using SAM vs a simple attention threshold to obtain the per-box mask. Instead of using SAM to obtain the mask for each box, we also explored an approach that does not require an additional segmentation module. Alternatively, we sort the pixels in each box according to their attention value with respect to the box caption and pick the top $7 5 \%$ pixels in each box with the highest attention as the mask for the box. As shown in Table 4, the impact of SAM is different for LMD/LMD $^ +$ . In LMD, since the attention-based guidance is less spatially accurate with respect to the layout boxes, SAM helps to obtain the right mask that covers the object. Therefore, removing SAM leads to a slight degradation in LMD. In LMD $^ +$ , since the guidance is more spatially accurate, SAM is no longer necessary most of the time. Instead, SAM sometimes picks a region that includes the background, causing confusion and reduced performance. Therefore, removing SAM slightly improves the results in LMD $^ +$ . We make SAM an optional choice (as described in Fig. 2) but still recommend it for LMD and enable it by default. We refer readers to Appendix D for additional ablations on the values of the hyperparameters.
222
+
223
+ <table><tr><td rowspan="2">Method</td><td colspan="2"> Image Accuracy</td></tr><tr><td>Average of 4 tasks</td><td></td></tr><tr><td> SD v1.5 (Default)</td><td>37%</td><td></td></tr><tr><td>LMD (on SDv1.5) (Ours, default)</td><td></td><td>77% (2.1×)</td></tr><tr><td>SD v2.1</td><td>38%</td><td></td></tr><tr><td>LMD (on SDv2.1) (Ours)</td><td></td><td>77% (2.0x)</td></tr></table>
224
+
225
+ Table 3: LMD achieves comparable gains when adapted to Stable Diffusion v2.1 without any hyperparameter tuning or model training. This shows a promising signal that the gains from our method could carry along with the enhancement of diffusion models. The performance of our method could potentially be improved further with additional hyperparameter tuning.
226
+ Table 4: Ablations on using SAM vs using simple attention thresholding in stage 2. While removing SAM leads to a slight degradation in LMD, removing SAM leads to even better performance in $\mathrm { L M D + }$ .
227
+
228
+ <table><tr><td></td><td> Image Accuracy</td></tr><tr><td>Method</td><td>Average of 4 tasks</td></tr><tr><td>LMD (w/o SAM) LMD (with SAM)</td><td>72.8% 76.5%</td></tr><tr><td>LMD+ (w/o SAM)</td><td>82.8%</td></tr><tr><td>LMD+ (with SAM)</td><td>80.5%</td></tr></table>
229
+
230
+ Text-to-layout stage. Ablating in-context examples. In addition to using the seven fixed in-context examples provided in Table K.2 by default, we also vary the number of in-context examples given to the LLM (i.e., “shots”). We show in Table 5 that while GPT-3.5 benefits from more in-context examples, GPT-4 is able to successfully generate all the layouts even when given only one in-context example. Note that we also observe GPT-4 to still be able to generate layouts without any in-context examples (i.e., given only the text instructions). However, since no examples are offered as references in this zero-shot setting, the format of LLM outputs are observed to differ in different runs, making it hard to parse with a program. Since it is much easier to convey the format through an example than through language instructions, we recommend having at least one example. Our observation shows that LLMs already learn the ability to generate object boxes during pretraining and do not need us to convey through many in-context examples. Varying the model types and the sizes of the LLMs. We also ablate the LLMs used for text-to-layout generation, including using self-hosted LLMs with public weights (Mahan et al., 2023; Touvron et al., 2023; Mukherjee et al., 2023; Jiang et al., 2024). The results show that the capability to generate high-quality layouts are not limited to proprietary LLMs, and larger LLMs offer much better layout generation capabilities. We refer the readers to Appendix D and Appendix E for more ablations and investigations.
231
+
232
+ <table><tr><td rowspan="2"></td><td colspan="2">Layout Accuracy (4 tasks)</td></tr><tr><td>gpt-3.5-turbo</td><td>gpt-4</td></tr><tr><td>#shots 1 Shot</td><td>89.8%</td><td>100.0%</td></tr><tr><td>4 Shots</td><td>96.3%</td><td>100.0%</td></tr><tr><td>7 Shots</td><td>99.0%</td><td>100.0%</td></tr></table>
233
+
234
+ <table><tr><td></td><td>Color</td><td>Shape</td><td>Texture</td><td>Spatial</td></tr><tr><td>SDv1</td><td>0.3765</td><td>0.3576</td><td>0.4156</td><td>0.1246</td></tr><tr><td>LMD (on SDv1)</td><td>0.5495</td><td>0.5462</td><td>0.5241</td><td>0.2570</td></tr><tr><td>SDv2</td><td>0.5065</td><td>0.4221</td><td>0.4922</td><td>0.1342</td></tr><tr><td>LMD (on SDv2)</td><td>0.5736</td><td>0.5334</td><td>0.5227</td><td>0.2704</td></tr></table>
235
+
236
+ Table 5: Ablations on the number of incontext examples (“shots”) given to the LLM. While GPT-3.5 benefits from more incontext examples, GPT-4 already excels in layout generation even with only one example.
237
+
238
+ Table 6: Our method surpasses the base diffusion models SDv1 and SDv2 on T2ICompBench (Huang et al., 2023) on all four tasks without additional training.
239
+
240
+ ![](images/51aed1e9bd234e358e8839b2d86168305753b3f5f2574bf22e0a494f0edcecd2.jpg)
241
+ Figure 9: A failure case occurs when our method, shown in (c), generates objects in unintentional viewpoints and sizes due to the ambiguity in the generated layout. The LLM-generated layout (b) is suitable for close-up top-down view of a small table, but the layout-to-image model assumes a side view and thus fails to generate a feasible image. Nevertheless, our method still provides more interpretability through the intermediate layout (b) compared to baseline SDXL (a). With an additional request for the side view and correct object sizes, the LLM adjusted the layout in (d) and the final generation (e) is aligned with the text prompt.
242
+
243
+ # 4.4 T2I-CompBench
244
+
245
+ In addition to our proposed benchmark with detection-based evaluation, we evaluate our method on T2ICompBench (Huang et al., 2023) that additionally uses visual question answering (VQA) models for generation evaluation. The color, shape, and texture tasks employ BLIP (Li et al., 2022) in a VQA setting, while the spatial task uses UniDet (Zhou et al., 2022) for evaluation. As shown in Table 6, our method LMD, when applied on either SDv1 or SDv2, improves the performance on all four tasks. Additional ablations are in Table D.4.
246
+
247
+ # 4.5 Evaluator-based Assessment
248
+
249
+ Setting. We also assess the prompt following ability of our method and vanilla SD, the base diffusion model that our method uses under the hood. We randomly selected 10 text prompts from our proposed benchmark and generated a pair of images per text prompt, one with our LMD $^ +$ and one with the base model SD.6 We then invited 11 evaluators to compare each image pair and answer two questions:
250
+
251
+ 1. Question 1: Which image aligns better with the text prompt?
252
+ 2. Question 2: Which image has a more natural and coherent foreground-background composition?
253
+
254
+ In addition to an option for preferring each image, a “similar” option is also provided for each pair.
255
+
256
+ Results. We average the scores across 110 responses. The results show that our method LMD $^ +$ got 88.18% (vs $1 0 . 9 0 \%$ for SD) for the first question and $3 5 . 4 5 \%$ (vs $3 1 . 8 1 \%$ for SD) for the second question. This indicates that our method generates images that accurately align with the prompt compared to the baseline SD without degradation of naturalness or coherency.
257
+
258
+ # 5 Discussions
259
+
260
+ Since we use models off-the-shelf, the LLM may generate layouts that are ambiguous to the diffusion model. For example, the layout in Fig. 9(b) is feasible for a top-down close-up image, but the diffusion model generates an image viewing from the side. This makes the apples not on the table in Fig. 9(c). Prompting or fine-tuning the LLM to be more explicit about its assumptions in the layouts (e.g., viewpoints) may alleviate this problem. The intermediate layout in our two-stage generation allows for more interpretability compared to our base model stable diffusion. After diagnosing the point of failure, we give an additional request for the side view and correct object sizes to the LLM. The LLM adjusted the subsequent layout generation, which allows generating images that align with the input prompt in round 2, as shown in Fig. 9(d,e). Our method also inherits biases from the base diffusion model (Luccioni et al., 2023). Moreover, although our method can handle objects not mentioned in the in-context examples (e.g., the bear and the deer in Fig. 7), the LLM may still generate better layouts for objects mentioned in the in-context examples by referencing layout examples. Our method could also be distilled into a one-stage text-to-image diffusion model to improve its prompt understanding abilities without leveraging LLMs at inference time for the ease of deployment.
261
+
262
+ # 6 Summary
263
+
264
+ In this paper, we enhance the prompt understanding capabilities of text-to-image diffusion models. We present a novel training-free two-stage generation process that incorporates LLM-based text-grounded layout generation and layout-grounded image generation. Our method also enables instruction-based scene specification and generation from prompts in languages unsupported by the base diffusion model. Our method outperforms strong baselines in accurately following the prompts in text-to-image generation.
265
+
266
+ Acknowledgements. The authors would like to thank Aleksander Holynski for the helpful discussions.
267
+
268
+ # References
269
+
270
+ Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in Neural Information Processing Systems, 35:23716–23736, 2022.
271
+
272
+ Omri Avrahami, Thomas Hayes, Oran Gafni, Sonal Gupta, Yaniv Taigman, Devi Parikh, Dani Lischinski, Ohad Fried, and Xi Yin. Spatext: Spatio-textual representation for controllable image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18370–18380, 2023.
273
+ Omer Bar-Tal, Lior Yariv, Yaron Lipman, and Tali Dekel. Multidiffusion: Fusing diffusion paths for controlled image generation. arXiv preprint arXiv:2302.08113, 2, 2023.
274
+ Tim Brooks, Aleksander Holynski, and Alexei A Efros. Instructpix2pix: Learning to follow image editing instructions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18392–18402, 2023.
275
+ 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.
276
+ Minghao Chen, Iro Laina, and Andrea Vedaldi. Training-free layout control with cross-attention guidance. arXiv preprint arXiv:2304.03373, 2023.
277
+ Jiaxin Cheng, Xiao Liang, Xingjian Shi, Tong He, Tianjun Xiao, and Mu Li. Layoutdiffuse: Adapting foundational diffusion models for layout-to-image generation. arXiv preprint arXiv:2302.08908, 2023.
278
+ Dave Epstein, Taesung Park, Richard Zhang, Eli Shechtman, and Alexei A Efros. Blobgan: Spatially disentangled scene representations. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XV, pp. 616–635. Springer, 2022.
279
+ Weixi Feng, Wanrong Zhu, Tsu-jui Fu, Varun Jampani, Arjun Akula, Xuehai He, Sugato Basu, Xin Eric Wang, and William Yang Wang. Layoutgpt: Compositional visual planning and generation with large language models. arXiv preprint arXiv:2305.15393, 2023.
280
+ Kamal Gupta, Justin Lazarow, Alessandro Achille, Larry S Davis, Vijay Mahadevan, and Abhinav Shrivastava. Layouttransformer: Layout generation and completion with self-attention. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1004–1014, 2021.
281
+ Tanmay Gupta and Aniruddha Kembhavi. Visual programming: Compositional visual reasoning without training. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14953–14962, 2023.
282
+ Roei Herzig, Amir Bar, Huijuan Xu, Gal Chechik, Trevor Darrell, and Amir Globerson. Learning canonical representations for scene graph to image generation. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part XXVI 16, pp. 210–227. Springer, 2020.
283
+ Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022.
284
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
285
+ Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
286
+ Kaiyi Huang, Kaiyue Sun, Enze Xie, Zhenguo Li, and Xihui Liu. T2i-compbench: A comprehensive benchmark for open-world compositional text-to-image generation. arXiv preprint arXiv:2307.06350, 2023.
287
+ Albert Q Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, et al. Mixtral of experts. arXiv preprint arXiv:2401.04088, 2024.
288
+ Justin Johnson, Agrim Gupta, and Li Fei-Fei. Image generation from scene graphs. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1219–1228, 2018.
289
+ 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. arXiv:2304.02643, 2023.
290
+ Jing Yu Koh, Daniel Fried, and Ruslan Salakhutdinov. Generating images with multimodal language models. arXiv preprint arXiv:2305.17216, 2023.
291
+ Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. Blip: Bootstrapping language-image pre-training for unified vision-language understanding and generation. In International Conference on Machine Learning, pp. 12888–12900. PMLR, 2022.
292
+ Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrapping language-image pre-training with frozen image encoders and large language models. arXiv preprint arXiv:2301.12597, 2023a.
293
+ Yuheng Li, Haotian Liu, Qingyang Wu, Fangzhou Mu, Jianwei Yang, Jianfeng Gao, Chunyuan Li, and Yong Jae Lee. Gligen: Open-set grounded text-to-image generation. arXiv preprint arXiv:2301.07093, 2023b.
294
+ 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 Computer Vision–ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pp. 740–755. Springer, 2014.
295
+ Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver++: Fast solver for guided sampling of diffusion probabilistic models. arXiv preprint arXiv:2211.01095, 2022.
296
+ Alexandra Sasha Luccioni, Christopher Akiki, Margaret Mitchell, and Yacine Jernite. Stable bias: Analyzing societal representations in diffusion models. arXiv preprint arXiv:2303.11408, 2023.
297
+ Dakota Mahan, Ryan Carlow, Louis Castricato, Nathan Cooper, and Christian Laforte. Stable beluga models, 2023. URL [https://huggingface.co/stabilityai/StableBeluga2](https://huggingface.co/ stabilityai/StableBeluga2).
298
+ Matthias Minderer, Alexey Gritsenko, Austin Stone, Maxim Neumann, Dirk Weissenborn, Alexey Dosovitskiy, Aravindh Mahendran, Anurag Arnab, Mostafa Dehghani, Zhuoran Shen, et al. Simple open-vocabulary object detection with vision transformers. arXiv preprint arXiv:2205.06230, 2022.
299
+ Subhabrata Mukherjee, Arindam Mitra, Ganesh Jawahar, Sahaj Agarwal, Hamid Palangi, and Ahmed Awadallah. Orca: Progressive learning from complex explanation traces of gpt-4, 2023.
300
+ OpenAI. Gpt-4 technical report. arXiv preprint arXiv:2303.08774, 2023.
301
+ Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatiallyadaptive normalization. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 2337–2346, 2019.
302
+ Dustin Podell, Zion English, Kyle Lacey, Andreas Blattmann, Tim Dockhorn, Jonas Müller, Joe Penna, and Robin Rombach. Sdxl: improving latent diffusion models for high-resolution image synthesis. arXiv preprint arXiv:2307.01952, 2023.
303
+ 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, pp. 8748–8763. PMLR, 2021.
304
+
305
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
306
+
307
+ Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684–10695, 2022.
308
+
309
+ Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted Intervention–MICCAI 2015: 18th International Conference, Munich, Germany, October 5-9, 2015, Proceedings, Part III 18, pp. 234–241. Springer, 2015.
310
+
311
+ Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily L Denton, Kamyar Ghasemipour, Raphael Gontijo Lopes, Burcu Karagol Ayan, Tim Salimans, et al. Photorealistic text-to-image diffusion models with deep language understanding. Advances in Neural Information Processing Systems, 35: 36479–36494, 2022.
312
+
313
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
314
+
315
+ Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. Llama 2: Open foundation and fine-tuned chat models, 2023.
316
+
317
+ 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.
318
+
319
+ Chenfei Wu, Shengming Yin, Weizhen Qi, Xiaodong Wang, Zecheng Tang, and Nan Duan. Visual chatgpt: Talking, drawing and editing with visual foundation models. arXiv preprint arXiv:2303.04671, 2023.
320
+
321
+ Jinheng Xie, Yuexiang Li, Yawen Huang, Haozhe Liu, Wentian Zhang, Yefeng Zheng, and Mike Zheng Shou. Boxdiff: Text-to-image synthesis with training-free box-constrained diffusion. arXiv preprint arXiv:2307.10816, 2023.
322
+
323
+ Danfei Xu, Yuke Zhu, Christopher B Choy, and Li Fei-Fei. Scene graph generation by iterative message passing. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5410–5419, 2017.
324
+
325
+ Zhengyuan Yang, Jianfeng Wang, Zhe Gan, Linjie Li, Kevin Lin, Chenfei Wu, Nan Duan, Zicheng Liu, Ce Liu, Michael Zeng, et al. Reco: Region-controlled text-to-image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14246–14255, 2023.
326
+
327
+ Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023.
328
+
329
+ Bo Zhao, Lili Meng, Weidong Yin, and Leonid Sigal. Image generation from layout. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8584–8593, 2019.
330
+
331
+ Guangcong Zheng, Xianpan Zhou, Xuewei Li, Zhongang Qi, Ying Shan, and Xi Li. Layoutdiffusion: Controllable diffusion model for layout-to-image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 22490–22499, 2023. Xingyi Zhou, Vladlen Koltun, and Philipp Krähenbühl. Simple multi-dataset detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7571–7580, 2022.
332
+
333
+ # A Preliminary introduction to latent diffusion models
334
+
335
+ The layout-to-image stage (i.e., the image generation stage) of our method LMD builds on off-the-shelf text-to-image Stable Diffusion models, which is based on the latent diffusion framework (Rombach et al., 2022). We present a preliminary introduction to the latent diffusion framework in this section and define the key terms used in our work. We encourage the readers to check Rombach et al. (2022) for a detailed explanation of the latent diffusion framework.
336
+
337
+ Latent diffusion models (Rombach et al., 2022) are powerful generative models that learn the data distribution of complex, high-resolution image datasets. Before training a latent diffusion model, Rombach et al. (2022) first trains an image encoder that converts an image $\mathbf { x }$ into a vector $\mathbf { z }$ in the high-dimensional latent space and a decoder that converts $\mathbf { z }$ back to a vector in the image space that is similar to $\mathbf { x }$ in appearance. By training and sampling a diffusion model in the latent space, latent diffusion lowers the cost of training and sampling from high-resolution diffusion models and is widely used in text-to-image generation, with Stable Diffusion as a popular model based on the latent diffusion framework. Our method improves the prompt understanding of Stable Diffusion without adapting the weights.
338
+
339
+ During training, the latent diffusion framework first maps each training image, denoted as $\mathbf { x } _ { \mathrm { 0 } }$ , into latent $\mathbf { z } _ { 0 }$ with the image encoder that is frozen during the diffusion training stage:
340
+
341
+ $$
342
+ \mathbf { z } _ { 0 } = \mathsf { E n c o d e } ( \mathbf { x } _ { 0 } )
343
+ $$
344
+
345
+ A timestep $t$ is sampled uniformly from $\{ 1 , . . . , T \}$ , where $T$ is a hyperparameter.
346
+
347
+ Noise $\epsilon$ is then sampled from a Gaussian distribution parameterized by timestep $t$ and added to the latent $\mathbf { z } _ { 0 }$ to obtain noisy latent $\mathbf { z } _ { t }$ . A neural network with parameter $\theta$ learns to predict the added noise $\epsilon$ for the forward process by minimizing the training objective:
348
+
349
+ $$
350
+ \mathcal { L } = | | \epsilon - \epsilon _ { \theta } ( \mathbf { z } _ { t } , t ) | | ^ { 2 }
351
+ $$
352
+
353
+ The neural network described above often uses a variant of U-Net (Ronneberger et al., 2015) architecture that has attention layers (Vaswani et al., 2017), and thus is also referred to as the diffusion U-Net.
354
+
355
+ At inference time, there are many sampling methods that allow the synthesis of samples from a diffusion model trained in the fashion described above. The general intuition is to go through a reverse process (also called denoising process) in which the diffusion model $\epsilon \theta$ iteratively predicts a noise vector $\boldsymbol { \epsilon } _ { \theta } ( \mathbf { z } _ { t } , t )$ from $\mathbf { z } _ { t }$ and subtracts it to transform $\mathbf { z } _ { t }$ into a sample $\mathbf { z } _ { t - 1 }$ that has less noise and is closer to the distribution of the training set, with $t$ initialized as $T$ and $\mathbf { z } _ { T } \sim \mathcal { N } ( 0 , \mathbf { I } )$ . The denoised sample $\mathbf { z } _ { 0 }$ resembles the clean data in the latent space.
356
+
357
+ One can use DDPM (Ho et al., 2020) to perform sampling from a noise prediction model $\epsilon \theta$ . DDPM predicts the noise $\epsilon$ for each of the $T$ denoising steps and then obtains $\mathbf { z } _ { t - 1 }$ from $\mathbf { z } _ { t }$ using this formula:
358
+
359
+ $$
360
+ \mathbf { z } _ { t - 1 } = \frac { 1 } { \sqrt { \alpha _ { t } } } \bigg ( \mathbf { z } _ { t } - \frac { 1 - \alpha _ { t } } { \sqrt { 1 - \prod _ { i = 1 } ^ { t } \alpha _ { i } } } \mathbf { \epsilon } _ { \theta } ( \mathbf { z } _ { t } , t ) \bigg ) + \sigma _ { t } \mathbf { \epsilon } _ { t }
361
+ $$
362
+
363
+ where $\epsilon _ { t } \sim \mathcal { N } ( 0 , \bf { I } )$ , $\alpha _ { t }$ and $\sigma _ { t }$ are parameterized by a variance schedule $\{ \beta _ { t } \in ( 0 , 1 ) \} _ { t = 1 } ^ { T }$ that controls the size of the denoising step.
364
+
365
+ Denoising diffusion implicit models (DDIM, Song et al. (2020)) are a generalization to DDPM which allows sampling with fewer iterations. DDIM applies the following update rule:
366
+
367
+ $$
368
+ \mathbf { z } _ { t - 1 } = \sqrt { \alpha _ { t - 1 } } \bigg ( \frac { \mathbf { z } _ { t } - \sqrt { 1 - \alpha _ { t } } \epsilon _ { \theta } ( \mathbf { z } _ { t } , t ) } { \sqrt { \alpha _ { t } } } \bigg ) + \sigma _ { t } \epsilon _ { t }
369
+ $$
370
+
371
+ Note that DDIM shares the same training procedure with DDPM, which means we can choose to perform DDIM or DDPM for a trained diffusion model. When $\sigma _ { t }$ is set to $0$ , which is the case for our setting, the
372
+
373
+ denoising becomes deterministic given $\mathbf { z } _ { T }$ . The results shown in our work are obtained with DDIM with $\sigma _ { t } = 0$ , with other faster sampling methods such as Lu et al. (2022) also applicable to our method.
374
+
375
+ Since there are many sampling methods given a trained diffusion model that are applicable in the latent diffusion framework, we denote the denoising process, such as the one in Eq. (10) and Eq. (11), as
376
+
377
+ $$
378
+ \mathbf z _ { t - 1 } \gets \mathsf { D e n o i s e } ( \mathbf z _ { t } )
379
+ $$
380
+
381
+ After getting the denoised sample $\mathbf { z } _ { 0 }$ , we then decode the image with an image decoder:
382
+
383
+ $$
384
+ \mathbf { x } _ { 0 } = { \mathsf { D e c o d e } } ( \mathbf { z } _ { 0 } )
385
+ $$
386
+
387
+ Text-conditional generation through cross-attention. The above formulation describes the unconditional generation process of latent diffusion models. Models such as Stable Diffusion take text as input and perform conditional generation. The difference between conditional and unconditional generation process involves processing the input text into text features, passing the feature tokens to diffusion U-Net, and performing classifier-free guidance (Ho $\&$ Salimans, 2022), which is described as follows.
388
+
389
+ Rather than only taking the noisy input $\mathbf { x } _ { t }$ and timestep $t$ , the conditional diffusion U-Net $\epsilon _ { \theta } ( \mathbf { z } _ { t } , t , \tau _ { \theta } ( \mathbf { y } ) )$ takes in an additional text condition y processed by a text encoder $\tau _ { \theta } ( \cdot )$ . The text encoder is a CLIP (Radford et al., 2021) text encoder in Stable Diffusion. After $\mathbf { y }$ is tokenized by the tokenizer into discrete tokens, it is processed by a Transformer (Vaswani et al., 2017) to text features $\tau _ { \theta } ( \mathbf { y } ) \in \mathbb { R } ^ { l \times d _ { \mathrm { t e x t } } }$ , where $\it l$ is the number of text tokens in y after tokenization and $d _ { \mathrm { t e x t } }$ is the dimension of features.
390
+
391
+ The text features $\tau _ { \theta } ( \mathbf { y } )$ are then processed by the cross-attention layers in the diffusion U-Net so that the output of the U-Net can also change depending on the text. For simplicity, we only consider one cross-attention head in this preliminary introduction and refer the readers to Rombach et al. (2022) and Vaswani et al. (2017) for details with the multi-head cross-attention used in the U-Net in the latent diffusion framework.
392
+
393
+ Specifically, each cross-attention layer linearly maps the text features $\tau _ { \theta } ( \mathbf { y } )$ into key and value vectors $\mathbf { k } , \mathbf { v } \in \mathbb { R } ^ { l \times d _ { \mathrm { a t t n } } }$ , where $d _ { \mathrm { a t t r } }$ is the attention dimension. Each cross-attention layer also takes in the flattened 2D feature from the previous layer in the U-Net and linearly maps the feature into a query vector $\mathbf { q } \in \mathbb { R } ^ { m \times d _ { \mathrm { { a t t n } } } }$ where $m$ is the dimension of the previous flattened 2D image feature.
394
+
395
+ Then, a cross-attention map $\mathbf { A }$ is computed from the query $\mathbf { q }$ , key $\mathbf { k }$ , and value $\mathbf { v }$ vectors, which describes the affinity from the image feature to the text token feature:
396
+
397
+ $$
398
+ \mathbf { A } _ { u v } = \mathsf { S o f t m a x } ( \mathbf { q } _ { u } ^ { T } \mathbf { k } _ { v } )
399
+ $$
400
+
401
+ where $\mathbf { q } _ { u }$ and $\mathbf { k } _ { v }$ are linearly transformed image feature at spatial location $u$ and text feature at token index $v$ in the prompt, respectively.
402
+
403
+ The attention map is then used for computing a weighted combination of the values $\mathbf { v }$ :
404
+
405
+ $$
406
+ \mathbf { o } _ { u } = \sum _ { v } \mathbf { A } _ { u v } \mathbf { v } _ { v }
407
+ $$
408
+
409
+ $\mathbf { o } \in \mathbb { R } ^ { m \times d _ { \mathrm { { a t t n } } } }$ is then linearly transformed to become the output of the cross-attention layer. The residual connections and layer norms are omitted in this introduction for simplicity.
410
+
411
+ Samples are generated by classifier-free guidance to ensure alignment with text prompt y. At training time, with a small probability, the input condition $\tau _ { \theta } ( \mathbf { y } )$ is randomly replaced with a learnable null token $\tau _ { \emptyset }$ . At inference time, classifier-free guidance uses the following term $\tilde { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t , \tau _ { \theta } ( \mathbf { y } ) )$ in place of the predicted noise $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ in the update rule for unconditional generation:
412
+
413
+ $$
414
+ \tilde { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t , \tau _ { \theta } ( \mathbf { y } ) ) = w \epsilon _ { \theta } ( \mathbf { x } _ { t } , t , \tau _ { \theta } ( \mathbf { y } ) ) + ( 1 - w ) \epsilon _ { \theta } ( \mathbf { x } _ { t } , t , \tau _ { \mathcal { O } } )
415
+ $$
416
+
417
+ where $w$ is the strength of classifier-free guidance, set to 7.5 by default in Stable Diffusion.
418
+
419
+ Algorithm 1 Layout-grounded image generation.
420
+
421
+ Input: A set of captioned bounding boxes $\{ ( \mathbf { b } ^ { ( i ) } , \mathbf { y } ^ { ( i ) } ) \} _ { i = 1 } ^ { N }$ . Background caption $\mathbf { y } ^ { ( \mathrm { b g } ) }$ .
422
+ Output: Image $\mathbf { x } _ { \mathrm { 0 } }$ . 1: $\mathbf { z } _ { T } \gets$ SampleGaussian $( \mathbf { 0 } , \mathbf { I } )$ 2: Per-box masked latent generation:
423
+ 3: for each captioned box $( \mathbf { b } ^ { ( i ) } , \mathbf { y } ^ { ( i ) } )$ do 4: 1 $\mathbf { z } _ { T } ^ { ( i ) } \mathbf { z } _ { T }$ 5: T y(i) ← PromptForBox(y(i), y(bg)) 7: for $t T$ to 1 do(i) ← AttnControl(z(i)t , y(i), b(i)) Denoise(z(i)t , y(i))
424
+ 9: end for
425
+ 10: $A ^ { ( i ) } $ TemporalAverage $( A _ { t } ^ { ( i ) } )$
426
+ 11: m(i) ← SAMRefine $( A ^ { ( i ) } , \mathbf { z } _ { 0 } ^ { ( i ) } )$ (Optional: This could be replaced with an attention thresholding instead.)
427
+ 12: $\hat { \mathbf { z } } _ { t } ^ { ( i ) } \gets \mathbf { z } _ { t } ^ { ( i ) } \otimes \mathbf { m } ^ { ( i ) }$
428
+ 13: end for
429
+ 14: Composed image generation:
430
+ 15: ${ \bf z } _ { T } ^ { \left( \mathrm { c o m p } \right) } \gets { \bf z } _ { T }$
431
+ 16: $\mathbf { y } ^ { \bullet } \substack { \mathsf { C o m p o s e d P r o m p t } ( ( \mathbf { y } ^ { ( i ) } ) _ { i = 1 } ^ { N } , \mathbf { y } ^ { ( \mathrm { b g } ) } ) }$
432
+ 17: for $t \gets T$ to 1 do
433
+ 18: 19: if $t \geq r T$ $\begin{array} { r l } & { \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } \gets \mathsf { L a t e n t C o m p o s e } ( \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } , \hat { \mathbf { z } } _ { t } ^ { ( i ) } , \mathbf { m } ^ { ( i ) } ) \quad \forall i } \\ & { \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } \gets \mathsf { A t t n T r a n s f e r } ( \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } , \mathbf { y } ^ { ( \mathrm { c o m p } ) } , ( A _ { t } ^ { ( i ) } ) _ { i = 1 } ^ { N } ) } \end{array}$
434
+ 21: end if
435
+ 22: $\mathbf { z } _ { t - 1 } ^ { ( \mathrm { c o m p } ) } \gets \mathsf { D e n o i s e } ( \mathbf { z } _ { t } ^ { ( \mathrm { c o m p } ) } , \mathbf { y } ^ { ( \mathrm { c o m p } ) } )$
436
+ 23: end for
437
+ 24: x0 ← Decode(z(comp)0 )
438
+
439
+ # B Pseudo-code for layout-grounded image generation
440
+
441
+ We present the pseudo-code for our layout-grounding stage (stage 2) in Algorithm 1. We explain the functionality of the functions used in the pseudo-code:
442
+
443
+ 1. SampleGaussian samples i.i.d standard Gaussian as the initial noise for the latent tensor.
444
+ 2. PromptForBox simply sets “[background prompt] with [box caption]” (e.g., “a realistic image of an indoor scene with a gray cat”) as the denoising prompt.
445
+ 3. AttnControl performs backward guidance to minimize the energy function Eq. (2) described in Section 3 to encourage the attention to the area within the box and discourage the attention on area outside the box. The cross-attention maps $A _ { t } ^ { ( i ) }$ are also returned in order to allow obtaining a mask for each box.
446
+ 4. Denoise denotes one denoising step by the diffusion model.
447
+ 5. TemporalAverage averages the cross-attention map across the timestep dimension.
448
+ 6. SAMRefine refines the attention map by internally decoding the latent and refining with SAM. If SAM is not enabled, we perform an attention thresholding instead.
449
+ 7. ComposedPrompt composes the prompt for overall generation. We offer two options for the overall prompt: using the original input prompt or composing the prompt as “[background prompt] with [box caption 1], [box caption 2], ...”. The former one allows capturing the object as well as forgroundbackground interactions that are not captured in the layout. The latter allows captions in languages unsupported by the diffusion model and stays robust when the caption is misleading (e.g., “neither of the apples is red"). We use the latter by default but also allow the former for fine-grained adjustments.
450
+ 8. LatentCompose spatially composes each of the latents $\mathbf { z } ^ { ( i ) }$ with respect to the corresponding mask $\mathbf { m } ^ { ( i ) }$ , replacing the content of the destination latent on the masked locations. As for the order of composition, we compose the masked latents with the largest area after masking first.
451
+ 9. AttnTransfer performs backward guidance to minimize the energy function Eq. (7) in Section 3 to encourage the attention in overall generation within the box to be similar to the attention in per-box generation in addition to attention control.
452
+
453
+ # C Additional features and use cases from instruction-based scene specification
454
+
455
+ As shown in Section 3.3, LMD, equipped with instruction-based scene specification, allows the user to apply follow-up instruction requests in addition to the initial prompt.
456
+
457
+ Furthermore, we demonstrate two additional use cases supported by instruction-based scene specification in Fig. C.1 without additional training.
458
+ In Fig. C.1(a), instruction-based scene specification allows the users to try out different adjustments on the same generation while preserving the overall image style and layout, facilitating fine-grained content creation. The LLM equipped in LMD can also respond to open-ended requests and present suggestions for improving the scene. Moreover, different from instruction-based image editing methods that only take one instruction without context, our instruction-based scene specification parses the instruction in its context, allowing for more natural dialog with users. For example, in Fig. C.1(b), our method can respond to instructions with phrases such as “What are some objects that you can add to make it lively?”, “undo the last edit”, and “adding a small pond instead”.
459
+
460
+ ![](images/988fe9e1056778d5f67ebba2b3d0eb28f78106d6bd9cd4ca6a60e433c8827f81.jpg)
461
+
462
+ (a) LMD allows the users to try out different detailed adjustments while preserving the overall image style and layout, enabling fine-grained content creation.
463
+
464
+ ![](images/2cb1c09c0f604371073dd03278c2e2c8f94a706ecb7157ed28660e71f2815e4f.jpg)
465
+ (b) The LLM used by LMD can perform open-ended scene adjustments, give suggestions, and understand user requests based on the contexts over multiple rounds of user dialog.
466
+
467
+ Figure C.1: Additional features and use cases enabled by instruction-based scene specification.
468
+
469
+ # D Additional ablation studies
470
+
471
+ # D.1 Text-to-layout stage
472
+
473
+ Varying the LLM types. All LLMs in Table D.1 generate layouts that almost perfectly follow the requirements in the prompts, indicating the bottleneck to be the layout-to-image stage. gpt-4 shows improved results in layout and the subsequent image generation, compared to gpt-3.5-turbo. The capability to generate high-quality layouts are not limited to proprietary LLMs, with Llama2-based StableBeluga2 (Mahan et al., 2023; Touvron et al., 2023; Mukherjee et al., 2023) and Mixtral-8x7B-Instruct-v0.1 (Jiang et al., 2024) also able to perform text-to-layout generation in the stage 1. We believe that fine-tuning these models will lead to even better performance in terms of text-to-layout generation.
474
+
475
+ <table><tr><td></td><td>Layout Accuracy</td></tr><tr><td>Stage 1 Model</td><td>Average of 4 tasks</td></tr><tr><td>StableBeluga-7B</td><td>59.3%</td></tr><tr><td>StableBeluga-13B StableBeluga2 (70B)</td><td>84.0%</td></tr><tr><td></td><td>96.5%</td></tr></table>
476
+
477
+ Table D.2: Ablations on the LLM model size on StableBeluga Models (Mahan et al., 2023) based on Llama-2 (Touvron et al., 2023) for layout generation (stage 1 only). Larger LLMs offer more accurate layout generation compared to smaller LLMs.
478
+
479
+ <table><tr><td></td><td>Layout (Image) Accuracy</td></tr><tr><td>Stage 1 Model StableBeluga2</td><td>Average of 4 tasks 96.5%</td></tr><tr><td>Mixtral-8x7B-Instruct-v0.1 98.3%</td><td>(67.0%) (77.5%)</td></tr><tr><td>gpt-3.5-turbo</td><td>99.0% (80.5%)</td></tr><tr><td>gpt-4</td><td>100.0% (86.3%)</td></tr></table>
480
+
481
+ Table D.1: Ablations on different LLMs in stage 1. Although proprietary models such as GPT-3.5 and GPT-4 perform the best, the ability to generate highquality layouts is also present in open-source models Mahan et al. (2023); Jiang et al. (2024); Touvron et al. (2023). The image accuracy is benchmarked using LMD+ as stage 2.
482
+
483
+ <table><tr><td rowspan="2">Method</td><td colspan="4"> Image Accuracy (Average of 4 tasks)</td></tr><tr><td>w=1</td><td>w=2</td><td>ε=4</td><td>ε=8</td></tr><tr><td>LMD</td><td>72.3%</td><td>75.8%</td><td>76.5%</td><td>72.5%</td></tr><tr><td>LMD+</td><td>79.8%</td><td>80.0%</td><td>80.5%</td><td>78.3%</td></tr></table>
484
+
485
+ (a) Ablations on hyperparameter $\omega$ .
486
+
487
+ <table><tr><td colspan="6"> Image Accuracy (Average of 4 tasks)</td></tr><tr><td>Method λ=0 λ=1 λ=2 λ=3λ=4</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LMD</td><td>70.8%</td><td>75.0%76.5%</td><td></td><td></td><td>77.3%75.0%</td></tr><tr><td>LMD+ 79.3%79.5%80.5%</td><td></td><td></td><td></td><td>81.8%78.8%</td><td></td></tr></table>
488
+
489
+ (b) Ablations on hyperparameter $\lambda$
490
+
491
+ Table D.3: Ablations on hyperparameter $\omega$ and $\lambda$ . Our method is relatively stable in terms of hyperparameter values $\omega$ and $\lambda$ . While we did not perform hyperparameter search, our default hyperparameter $\omega = 4$ allows optimal performance for both LMD and LMD $^ +$ . For the hyperparameter $\lambda$ , we found that setting $\lambda = 3$ leads to better performance compared to our default hyperparameter setting with $\lambda = 2$ , which indicates that the performance of our method can be further improved through hyperparameter tuning. Underlined numbers indicate performance with our default hyperparameter selection ( $\omega = 4$ , $\lambda = 2$ ). Bold numbers indicate the best performance among all the hyperparameters ablated.
492
+
493
+ Varying the LLM sizes. We also tested the ability of layout generation on LLMs of different model sizes.
494
+ As shown in Table D.2, larger LLMs offer much better layout generation capabilities.
495
+
496
+ # D.2 Layout-to-image stage
497
+
498
+ Varying $\omega$ . $\omega$ is the weight for balancing the loss term on the foreground and the term on the background (Eq. (2)). While we set $\omega = 4$ by default, we ablate this design choice. As shown by the experimental results in Table D.3a, our method is relatively stable in terms of hyperparameter selection. Moreover, even though we did not perform hyperparameter search prior to determining our default hyperparameter value, our default hyperparameter $\omega = 4$ already leads to the optimal performance among the hyperparameter values that we searched in this ablation for both LMD and LMD $^ +$ .
499
+
500
+ Varying $\lambda$ . $\lambda$ is the weight for the attention transfer term in Eq. (7). As shown in Table D.3b, we found that setting $\lambda = 3$ leads to better performance compared to our default hyperparameter setting with $\lambda = 2$ , which indicates that the performance of our method can be further improved through hyperparameter tuning.
501
+
502
+ Ablation results on T2I-CompBench (Huang et al., 2023). In addition to comparing our method with the baseline method Stable Diffusion in Table 6, we further combine our text-to-layout stage (stage 1) with other layout-to-image methods as stage 2 in this ablation, similar to Table 2. The results are in Table D.4, with the results for the SD baseline from Huang et al. (2023). Our method surpasses not only the base diffusion model SD but also several variants of our method that combine our stage 1 with previous layout-to-image methods as stage 2, which shows the effectiveness of our layout-grounded controller.
503
+
504
+ <table><tr><td>Stage 1/Stage 2</td><td>Color</td><td>Shape</td><td>Texture</td><td>Spatial</td></tr><tr><td>SD</td><td>0.3765</td><td>0.3576</td><td>0.4156</td><td>0.1246</td></tr><tr><td>LMD/MultiDiffusion</td><td>0.4631</td><td>0.4497</td><td>0.4007</td><td>0.1604</td></tr><tr><td>LMD/Backward Guidance</td><td>0.4877</td><td>0.5069</td><td>0.4643</td><td>0.2361</td></tr><tr><td>LMD/Boxdiff</td><td>0.4579</td><td>0.4967</td><td>0.4720</td><td>0.1965</td></tr><tr><td>LMD/LMD (Ours)</td><td>0.5495</td><td>0.5462</td><td>0.5241</td><td>0.2570</td></tr></table>
505
+
506
+ Table D.4: Our method surpasses the base diffusion model SD as well as several variants of our method that combines our stage 1 with previous layout-to-image methods as stage 2 on T2I-CompBench (Huang et al., 2023).
507
+
508
+ ![](images/e1c50c9ee426d56d90970dfdf873eb4286577ef7c9379ae12003c88e52770d7b.jpg)
509
+
510
+ The only in-context example with prompt “A panda in a forest without flowers”
511
+
512
+ ![](images/e10acf0682dea4412d654f27926603fdebf4ef9123f1d328dda090976f71b36d.jpg)
513
+ Generated layout for prompt “An apple”
514
+
515
+ The only in-context example with prompt $^ { \circ \circ } A$ realistic scene of three skiers standing in a line on the snow near a palm tree”
516
+
517
+ ![](images/401c022a34e642aae33a19234d87ef23ad35132c0199cb2dd7c55495d6cd2a1b.jpg)
518
+ Figure E.1: The generated layouts are not necessarily similar to the in-context examples in terms of the spatial distribution of boxes. We present the LLM with only one in-context example and query it with a prompt that is similar to the example. Top: While the query and the example shares a similar structure (only one object), the LLM generates a box for “an apple” that is very different from “a panda” in terms of the size and position. Bottom: The LLM does not simply copy boxes for the three skiers in the in-context example to generate the boxes for three bears.
519
+
520
+ ![](images/e9a69498e3383628fa04d3c253227c5051a53c169a0b1bbb63bf2ddbbfb74fe8.jpg)
521
+ Generated layout for prompt “A realistic scene of three bears”
522
+
523
+ # E Are the generated layouts distributed similarly to the in-context examples?
524
+
525
+ Since our LLM takes a few in-context examples in our text-to-layout stage, it is possible that the LLM prefers to generate samples that are similar to the in-context examples in terms of spatial distribution. To test whether this is the case, we present the LLM with only one in-context example and query it with a prompt that is similar to the example. The results are shown in Fig. E.1. Even though each of the query prompts shares a similar form to the corresponding in-context example, the LLM still generates layouts that are tailored to the objects in the query prompt (e.g., the apple and the bears) rather than copying or mimicking the layout boxes from the in-context examples. This qualitative analysis shows that even with the in-context examples as references, the LLM often generates natural layouts according to the prompts, relieving the users from heavy prompt engineering to prevent overly similar layouts between the generation and the examples.
526
+
527
+ # F Additional visualizations
528
+
529
+ We also present Fig. F.1, which includes a qualitative comparison with Stable Diffusion v1.5 (abbreviated as SDv1) and shares the prompts with Fig. 1.
530
+
531
+ ![](images/1117dcd2d014a4ff6bbb113e7eeb90cadb7916ae22f181890deaa8f006cdf075.jpg)
532
+ Figure F.1: We also generate images with the same text prompts as Fig. 1 with SDv1.5 and LMD on SDv1.5. We observe similar results which show that while Stable Diffusion Rombach et al. (2022) (a) often struggles to accurately follow several types of complex prompts, our method LMD (b) achieves enhanced prompt understanding capabilities and accurately follows these types of prompts.
533
+
534
+ # G Benchmarking VisualChatGPT and GILL for multi-round instruction-based scene specification
535
+
536
+ VisualChatGPT (Wu et al., 2023) and GILL (Koh et al., 2023) involve LLM in their image generation pipelines and thus could potentially take instructions from multiple rounds of dialog for image generation. Therefore, in addition to the qualitative benchmark in Fig. 8, we also benchmark both methods for multi-round scene specification. As shown in Fig. G.1, the generated images quickly degrade starting from the second iteration, showing that neither method is able to take instructions from multiple rounds of dialog for image generation. In contrast, our method is able to handle several rounds of sequential requests on image generation without generation degradation, shown in Fig. 6.
537
+
538
+ # H Details for SDXL integration
539
+
540
+ Thanks to the training-free nature of our work, our method is applicable to various diffusion models without additional training. Therefore, we also apply our method on SDXL 1.0 (Podell et al., 2023), the latest stable diffusion model which has a $3 \times$ larger U-Net module compared to previous stable diffusion models (Rombach et al., 2022).
541
+
542
+ It is straightforward to apply the LMD pipeline directly to SDXL UNet, which has a very similar procedure to applying the LMD pipeline to SD v1/v2. This approach only requires marginal modifications of the LMD pipeline: different from SD v1/v2 that use only one text encoder for encoding the prompts, SDXL involves two text encoders for text feature generation, and the attention control proposed in LMD needs to be applied to the cross-attention with both text encoders taken into account. The rest follows from the standard LMD pipeline.
543
+
544
+ Inspired by methods such as Ramesh et al. (2022) that generate low resolution images and then upsample the generation to the target resolution, an alternative approach is to perform denoising with the standard LMD with a standard SDv1/v2 resolution (i.e., $5 1 2 \times 5 1 2$ ) and then perform upsampling with SDXL refiner for a few steps to the intended resolution (e.g., $1 0 2 4 \times 1 0 2 4$ ). Since most of the generation still happens in the standard resolution latent space, with the SDXL only involved a limited number of steps for high-resolution latents, this approach is more efficient compared to the former approach. We compare the generation for the same scene with SDXL baseline and both approaches in Fig. H.1. Both approaches present much better prompt following ability compared to SDXL baseline. We observe similar generation quality on both approaches. Therefore, we use the latter approach by default.
545
+
546
+ For Fig. 1 and Fig. 7, we use SDXL 1.0 as the base model of LMD and compare against SDXL as a strong baseline. For all other settings, including the qualitative evaluation setting, we use Stable Diffusion v1.5 (denoted as SDv1) unless stated otherwise. For fair comparison with Wu et al. (2023) and Koh et al. (2023) that only use Stable Diffusion v1.5, we also generate images for the same set of prompts of Fig. 1 with Stable Diffusion v1.5 in Fig. F.1.
547
+
548
+ ![](images/237b632bfb0e2467aac76c0f9d5b47c885b9f0260f5994e9d48863dfea60327c.jpg)
549
+ Figure G.1: VisualChatGPT Wu et al. (2023) and GILL Koh et al. (2023) generally cannot handle more than one round of image generation requests, with the generated image degraded starting from the second request. In contrast, our method is able to handle several rounds of sequential requests on image generation without generation degradation, shown in Fig. 6.
550
+
551
+ # I Generating images from languages not supported by the underlying diffusion model
552
+
553
+ As shown in Fig. I.1, by asking the LLM to always output layouts in English even if the prompt is nonEnglish (e.g., Korean or Chinese as in Fig. I.1) and providing an in-context example of non-English input and English layout, LMD is able to generate images from prompts in languages not supported by the underlying
554
+
555
+ ![](images/cd303eab62367b4cd02c1b70cbc9bcb71fbcef2acd581f8b6558bcd4445b5c39.jpg)
556
+ Figure H.1: LMD can be easily applied on the latest stable diffusion model SDXL (Podell et al., 2023). We compare generated images from text prompt “A realistic photo of a gray cat and an orange dog on the grass”. (a) directly generates the image from the text prompt. SDXL does not accurately generate the image from the prompt, showing that simply scaling the diffusion model does not necessarily lead to improved prompt following ability. (b) Thanks to our method being training-free, our method can be directly applied on SDXL without additional training. (c) An alternative way to integrate our method with SDXL is to use our method to generate low-resolution images with SD and then refine the image in high-resolution in SDXL. Since most denoising is completed in low-resolution latents, this approach is more efficient.
557
+
558
+ ![](images/cfe5e011225cba3da5b78aed0ffcdafe4fb887f3b11018db4dc7cac2f6368a85.jpg)
559
+ Figure I.1: By asking the LLM to always output layouts in English, LMD is naturally able to generate images from prompts in languages not supported by the underlying diffusion model.
560
+
561
+ diffusion model. We simply translate the prompt input of the last in-context example to non-English, while keeping the output in this example in English. No adaptation is needed on the diffusion model since the underlying diffusion model still takes in an English layout as input.
562
+
563
+ # J Details for text-to-image benchmarks
564
+
565
+ We pick 10 common object types from the COCO dataset Lin et al. (2014) for generation7.
566
+
567
+ For negation and generative numeracy task, each prompt requires the model to generate a layout of a scene with some number of a certain object or without a certain object. Then we count the number of objects and consider the layout to be correct if the number of the object of that particular type matches the one in the prompt, with the number ranging from 1 to 5.
568
+
569
+ The objective for each prompt in the attribute binding task is to generate an object of a color and another object of another color, for which the evaluation is similar to other tasks.
570
+
571
+ For the spatial relationship task, we generate an object at a certain location and another object at an opposite location (left/right and top/bottom). We then check the spatial coordinates of the boxes to ensure the layout exactly matches the prompt. In each task, we generate 100 text prompts, with 400 text prompts in total.
572
+
573
+ Prompts. For the negation benchmark, we use the prompt $A$ realistic photo of a scene without [object name].
574
+
575
+ For generative numeracy, we use the prompt $A$ realistic photo of a scene with [number] [object name].
576
+
577
+ For attribute assignment, we use the prompt $A$ realistic photo of a scene with [modifier 1] [object name 1] and [modifier 2] [object name 2], where the two modifiers are randomly chosen from a list of colors (red, orange, yellow, green, blue, purple, pink, brown, black, white, and gray).
578
+
579
+ For the spatial relationship benchmark, we use the prompt A realistic photo of a scene with [object name 1] on the [location] and [modifier 2] [object name2] on the [opposite location], where the location is chosen from left, right, top, and bottom.
580
+
581
+ Implementation details. For LMD, we use Stable Diffusion v1.5 by default. For LMD+, we use GLIGEN (Li et al., 2023b) model without additional training or adaptation. We selected the GLIGEN (Li et al., 2023b) model trained based on Stable Diffusion v1.4, which is the latest at the time of writing. We use $\eta = 5$ , $\lambda = 2 . 0$ , $r = 0 . 4$ , guidance scale 7.5. The energy minimization is repeated 5 times for each denoising timestep and linearly decreases for every five denoising steps until the repetition is reduced to 1, and we do not perform guidance after 30 steps. $k$ in the Topk $( \cdot )$ in Eq. (2) is set to 20% of the area of the mask for each mask. The background part (second term) of Eq. (2) is weighted by $\omega = 4 . 0$ . We run the denoising process with 50 steps by default. We only perform latent compose in the first half of the denoising process (first 25 steps). The qualitative visualizations/quantitative comparisons are generated by LMD $^ +$ /LMD, respectively, by default unless stated otherwise.
582
+
583
+ # K Our LLM prompt
584
+
585
+ Our LLM prompt is listed in Table K.1. Our in-context examples are listed in Table K.2.
586
+
587
+ 1 You are an intelligent bounding box generator . I will provide you with a caption for a photo , image , or painting . Your task is to generate the bounding boxes for the objects mentioned in the caption , along with a background prompt describing the scene . The images are of size $5 1 2 \times 5 1 2$ . The top - left corner has coordinate [0 , 0]. The bottom - right corner has coordinnate [512 , 512]. The bounding boxes should not overlap or go beyond the image boundaries . Each bounding box should be in the format of ( object name , [ top - left x coordinate , top - left y coordinate , box width , box height ]) and should not include more than one object . Do not put objects that are already provided in the bounding boxes into the background prompt . Do not include non - existing or excluded objects in the background prompt . Use " A realistic scene " as the background prompt if no background is given in the prompt . If needed , you can make reasonable guesses . Please refer to the example below for the desired format .
588
+
589
+ Table K.1: Our full prompt to the LLM for layout generation. LLM starts completion from “Objects:”.
590
+
591
+ 1 Caption : A realistic image of landscape scene depicting a green car parking on the left of a
592
+ blue truck , with a red air balloon and a bird in the sky
593
+ 2 Objects : [('a green car ', [21 , 281 , 211 , 159]) , ('a blue truck ', [269 , 283 , 209 , 160]) , ('a red
594
+ air balloon ', [66 , 8 , 145 , 135]) , ('a bird ', [296 , 42 , 143 , 100]) ]
595
+ 3 Background prompt : A realistic landscape scene
596
+ 4 Negative prompt :
597
+ 5
598
+ 6 Caption : A realistic top - down view of a wooden table with two apples on it
599
+ 7 Objects : [('a wooden table ', [20 , 148 , 472 , 216]) , ('an apple ', [150 , 226 , 100 , 100]) , ('an
600
+ apple ', [280 , 226 , 100 , 100]) ]
601
+ 8 Background prompt : A realistic top - down view
602
+ 9 Negative prompt :
603
+ 10
604
+ 11 Caption : A realistic scene of three skiers standing in a line on the snow near a palm tree
605
+ 12 Objects : [('a skier ', [5 , 152 , 139 , 168]) , ('a skier ', [278 , 192 , 121 , 158]) , ('a skier ', [148 ,
606
+ 173 , 124 , 155]) , ('a palm tree ', [404 , 105 , 103 , 251]) ]
607
+ 13 Background prompt : A realistic outdoor scene with snow
608
+ 14 Negative prompt :
609
+ 15
610
+ 16 Caption : An oil painting of a pink dolphin jumping on the left of a steam boat on the sea
611
+ 17 Objects : [('a steam boat ', [232 , 225 , 257 , 149]) , ('a jumping pink dolphin ', [21 , 249 , 189 ,
612
+ 123]) ]
613
+ 18 Background prompt : An oil painting of the sea
614
+ 19 Negative prompt :
615
+ 20
616
+ 21 Caption : A cute cat and an angry dog without birds
617
+ 22 Objects : [('a cute cat ', [51 , 67 , 271 , 324]) , ('an angry dog ', [302 , 119 , 211 , 228]) ]
618
+ 23 Background prompt : A realistic scene
619
+ 24 Negative prompt : birds
620
+ 25
621
+ 26 Caption : Two pandas in a forest without flowers
622
+ 27 Objects : [('a panda ', [30 , 171 , 212 , 226]) , ('a panda ', [264 , 173 , 222 , 221]) ]
623
+ 28 Background prompt : A forest
624
+ 29 Negative prompt : flowers
625
+ 30
626
+ 31 Caption : An oil painting of a living room scene without chairs with a painting mounted on the
627
+ wall , a cabinet below the painting , and two flower vases on the cabinet
628
+ 32 Objects : [('a painting ', [88 , 85 , 335 , 203]) , ('a cabinet ', [57 , 308 , 404 , 201]) , ('a flower
629
+ vase ', [166 , 222 , 92 , 108]) , ('a flower vase ', [328 , 222 , 92 , 108]) ]
630
+ 33 Background prompt : An oil painting of a living room scene
631
+ 34 Negative prompt : chairs
parse/test/hFALpTb4fR/hFALpTb4fR_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/hFALpTb4fR/hFALpTb4fR_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/hFALpTb4fR/hFALpTb4fR_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/lPw8Xdzw5f/lPw8Xdzw5f.md ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Chaos Theory and Adversarial Robustness
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # Abstract
6
+
7
+ Neural networks, being susceptible to adversarial attacks, should face a strict level of scrutiny before being deployed in critical or adversarial applications. This paper uses ideas from Chaos Theory to explain, analyze, and quantify the degree to which neural networks are susceptible to or robust against adversarial attacks. To this end, we present a new metric, the "susceptibility ratio," given by $\hat { \Psi } ( h , \theta )$ , which captures how greatly a model’s output will be changed by perturbations to a given input.
8
+
9
+ Our results show that susceptibility to attack grows significantly with the depth of the model, which has safety implications for the design of neural networks for production environments. We provide experimental evidence of the relationship between $\hat { \Psi }$ and the post-attack accuracy of classification models, as well as a discussion of its application to tasks lacking hard decision boundaries. We also demonstrate how to quickly and easily approximate the certified robustness radii for extremely large models, which until now has been computationally infeasible to calculate directly.
10
+
11
+ # 1 Introduction
12
+
13
+ The current state of Machine Learning research presents neural networks as black boxes due to the high dimensionality of their parameter space, which means that understanding what is happening inside of a model regarding domain expertise is highly nontrivial, when it is even possible. However, the actual mechanics by which neural networks operate - the composition of multiple nonlinear transforms, with parameters optimized by a gradient method - were human-designed, and as such are well understood. In this paper, we will apply this understanding, via analogy to Chaos Theory, to the problem of explaining and measuring susceptibility of neural networks to adversarial methods.
14
+
15
+ It is well-known that neural networks can be adversarially attacked, producing obviously incorrect outputs as a result of making extremely small perturbations to the input (Goodfellow et al., 2014; Szegedy et al., 2013). Prior work, like Shao et al. (2021); Wang et al. (2018) and Carmon et al. (2019) discuss "adversarial robustness" in terms of metrics like accuracy after being attacked or the success rates of attacks, which can limit the discussion entirely to models with hard decision boundaries like classifiers, ignoring tasks like segmentation or generative modeling (He et al., 2018). Other work, like Li et al. (2020) and Weber et al. (2020), develop "certification radii," which can be used to guarantee that a given input cannot be misclassified by a model without an adversarial perturbation with a size exceeding that radius. However, calculating these radii is computationally onerous when it is even possible, and is again limited only to models with hard decision boundaries.
16
+
17
+ Gowal et al. (2021) provides a brief study of the effects of changes in model scale, but admits that there has been a dearth of experiments that vary the depth and width of models in the context of adversarial robustness, which this paper provides. Huang et al. (2022a) also studies the effects of architectural design decisions on robustness, and provides theoretical justification on the basis of deeper and wider models having a greater upper bound on the Lipschitz constant of the function represented by those models. Our own work’s connection to the Lipschitz constant is discussed in Appendix C. Wu et al. (2021a) studies the effects of model width on robustness, and specifically discusses how robust accuracy is closely related to the perturbation stability of the underlying model, with an additional connection to the local Lipschitzness of the represented function. Our experimental results contradict those found in these papers in a few places, namely as to the relationship between depth and robustness. Additionally, previous work is limited to studying advanced State-of-the-Art CNN architectures, which introduces a number of effects that are never accounted for during their ablations.
18
+
19
+ ![](images/aa2111eff704d3fba41676dcbea30dbfb9fedd7385fcf3d36b4bd1324d3be807.jpg)
20
+ Figure 1: In a dynamical system, two trajectories with similar starting points may, over time, drift farther and farther away from one another, typically modeled as exponential growth in the distance between them. This growth characterizes a system as exhibiting "sensitive dependence," known colloquially as the "butterfly effect," where small changes in initial conditions eventually grow into very large changes in the eventual results.
21
+
22
+ Regarding the existence of adversarial attacks ab origine, Pedraza et al. (2020) and Prabhu et al. (2018) have explained this behaviour of neural networks on the basis that they are dynamical systems, and then use results from that analysis to try and classify adversarial inputs based on their Lyapunov exponents. However, this classification methodology rests on loose theoretical ground, as the Lyapunov exponents of a single input must be relative to those of similar inputs, and it is entirely possible to construct a scenario wherein an input does not become more potent a basis for further attack solely because it is itself adversarial.
23
+
24
+ In this work, we re-do these Chaos Theoretic analyses in order to understand, not particular inputs, but the neural networks themselves. We show that neural networks are dynamical systems, and then continuing that analogy past where Pedraza et al. (2020) and Prabhu et al. (2018) leave off, investigate what neuralnetworks-as-dynamical-systems means for their susceptibility to attack, through a combination of analysis and experimentation. We develop this into a theory of adversarial susceptibility, the "susceptibility ratio" as a measure of how effective attacks will be against a neural network, and show how to numerically approximate this value. Returning to the work in Li et al. (2020) and Weber et al. (2020), we use the susceptibility ratio to quickly and accurately estimate the certification radii of very large neural networks, aligning this paper with prior work.
25
+
26
+ # 2 Neural Networks as Dynamical Systems
27
+
28
+ We will now re-write the conventional feed-forward neural network formulation in the language of dynamical systems, in order to facilitate the transfer of the analysis of dynamical systems back to neural networks. To begin with, we first introduce the definition of a dynamical system, per standard literature (Alligood et al., 1998).
29
+
30
+ # 2.1 Dynamical Systems
31
+
32
+ In Chaos Theory, a dynamical system is defined as a tuple of three basic components, written in standard notation as $( T , X , \Phi )$ . The first, $T$ , referred to as "time," takes the form of a domain obeying time-like algebraic properties, namely associative addition. The second, $X$ , is the state space. Depending on the system, elements of $X$ might describe the positions of a pendulum, the states of memory in a computer program, or the arrangements of particles in an enclosed volume, with $X$ being the space of all possibilities thereof. The final component, $\Phi : T \times X \to X$ , is the "evolution function" of the system. When $\Phi$ is given a state $x _ { i , t } \in X$ and a change in time $\Delta t$ , it returns $x _ { i , t + \Delta t }$ , which is the new state of the system after $\Delta t$ time has elapsed. The $x _ { i , t }$ notation will be explained in greater detail later. We will write this as
33
+
34
+ $$
35
+ x _ { i , t + \Delta t } = \Phi ( \Delta t , x _ { i , t } )
36
+ $$
37
+
38
+ In order to stay well defined, this has to possess certain properties, namely a self-consistency of the evolution function over the domain $T$ . A state that is progressed forward $\Delta t _ { a }$ in $T$ by $\Phi$ and then progressed again $\Delta t _ { b }$ should yield the same state as one that is progressed $\Delta t _ { a } + \Delta t _ { b }$ in a single operation:
39
+
40
+ $$
41
+ \Phi \big ( \Delta t _ { b } , \Phi ( \Delta t _ { a } , x _ { i , t } ) \big ) = \Phi ( \Delta t _ { a } + \Delta t _ { b } , x _ { i , t } )
42
+ $$
43
+
44
+ Relying partially on this self-consistency, we can take a "trajectory" of the initial state $x _ { i , 0 }$ over time, a set containing elements represented by $\{ \left( t , \Phi ( t , x _ { i , 0 } ) \right) \big | \forall t \in T \}$ . To clarify; because each element within $X$ can be progressed through time by the injective and self-consistent function $\Phi$ , and therefore belongs to a given trajectory,1 it becomes both explanatory and efficient to denote every element in the same trajectory with the same subscript index $i$ , and to differentiate between the elements in the same trajectory at different times with $t$ . In order to simplify the notation, and following on from the notion that the evolution of state within a dynamic system over time is equivalent to the composition of multiple instances of the evolution function, we will write the elements of this trajectory as
45
+
46
+ $$
47
+ \Phi ( t , x _ { i , 0 } ) = \Phi ^ { t } ( x _ { i } ) = x _ { i , t }
48
+ $$
49
+
50
+ with an additional simplification of notation using $x _ { i } = x _ { i , 0 }$ , omitting the subscript $t$ when $t = 0$ .
51
+
52
+ From these trajectories we may derive our notion of chaos, which concerns the relationship between trajectories with similar initial conditions. Consider $x _ { i }$ , and $x _ { i } + \delta x$ , where $\delta x$ is of limited magnitude, and may be contextualized as a subtle reorientation of the arms of a double pendulum prior to setting it into motion. We also require some notion of the distance between two elements of the state space, but we will assume that the space is a vector space equipped with a length or distance metric written with $| \cdot |$ , and proceed from there. For the initial condition, we may immediately take
53
+
54
+ $$
55
+ \left| \Phi ^ { 0 } ( x _ { i } ) - \Phi ^ { 0 } ( x _ { i } + \delta x ) \right| = | \delta x |
56
+ $$
57
+
58
+ However, meaningful analysis only arises when we model the progression of this difference over time. In some systems, minor differences in the initial condition result in negligible effect, such as with the state of a damped oscillator; regardless of its initial position or velocity, it approaches the resting state as time progresses, and no further activity of significance occurs. However, in some systems, minor differences in the initial condition end up compounding on themselves, like the flaps of a butterfly’s wings eventually resulting in a hurricane. Both of these can be approximately or heuristically modeled by an exponential function,
59
+
60
+ $$
61
+ | \Phi ^ { t } ( x _ { i } ) - \Phi ^ { t } ( x _ { i } + \delta x ) | \approx | \delta x | e ^ { \lambda t }
62
+ $$
63
+
64
+ In each of these cases, the growing or shrinking differences between the trajectories are described by $\lambda$ , also called the Lyapunov exponent. If $\lambda < 0$ , these differences disappear over time, and the trajectories of two similar initial conditions will eventually align with one another. However, if $\lambda > 0$ , these differences increase over time, and the trajectories of two similar initial conditions will grow farther and farther apart, with their relationship becoming indistinguishable from that of two trajectories with wholly different initial conditions. This is called "sensitive dependence," and is the mark of a chaotic system.2 It must be noted, however, that the exponential nature of this growth is a shorthand model, with obvious limits, and is not fully descriptive of the underlying behavior.
65
+
66
+ # 2.2 Neural Networks
67
+
68
+ Conventionally, a neural network is given a formulation along the following lines (Schmidhuber, 2015). It is denoted by a function $h : \Theta \times X \to Y$ , where $\Theta$ is the space of possible learned parameters, subdivided into the entries of multiplicative weight matrices $W _ { l }$ and additive bias vectors $b _ { l }$ . $X$ is the vector space of possible inputs, and $Y$ is the vector space of possible outputs. Each of the $L$ layers in the neural network is given by a matrix multiplication, a bias addition, and the application of a nonlinear activation function $\sigma$ , with hidden states $z _ { i , l }$ representing the intermediate values taken during the inference operation:
69
+
70
+ $$
71
+ z _ { i , 0 } : = x _ { i }
72
+ $$
73
+
74
+ $$
75
+ z _ { i , l + 1 } = \sigma ( W _ { l } z _ { i , l } + b _ { l } ) | W _ { l } , b _ { l } \subset \theta
76
+ $$
77
+
78
+ $$
79
+ h ( \theta ; x _ { i } ) = \hat { y } _ { i } : = z _ { i , L }
80
+ $$
81
+
82
+ Without loss of generality, we may transcribe this formulation as a dynamical system by taking its components as analogues. The first is $[ L ] = \{ 0 , 1 , 2 \ldots L \}$ , which here will be used to represent the current depth of the hidden state, from 0 for the initial condition up to $L$ for the eventual output. Because it progresses forward during the inference operation, and is associative insofar as increases in depth are additive, $\lfloor L \rfloor$ functions as an analogue for $T$ . The second is $Z$ , which is the vector space of all possible hidden states, and thus replaces $X$ . The final component is $g : [ L ] \times Z \to Z$ , which here we will write as
83
+
84
+ $$
85
+ z _ { i , l + 1 } = g ( 1 , z _ { i , l } ) = \sigma ( W _ { l } z _ { i , l } + b _ { l } )
86
+ $$
87
+
88
+ A further discussion of the function $g$ is given in Appendix A. The generalization to $g ( \Delta l , z _ { i , l } )$ then follows from the same rule of composition applied to the dynamical systems, at least for integer values of $\Delta \boldsymbol { l }$ , under the condition that it never leaves $[ L ]$ . This allows us to replace $\Phi$ with $g$ . We can also then re-write the notation along the lines of that for the dynamical systems
89
+
90
+ $$
91
+ g ( l , z _ { i , 0 } ) = g ^ { l } ( x _ { i } )
92
+ $$
93
+
94
+ Noting of course that we have defined $z _ { i , 0 }$ as $x _ { i }$ . Thus, the neural network inference operation can be rewritten as the triplet $( [ L ] , Z , g )$ , and mapped to the dynamical system formulation of $( T , X , \Phi )$ . We can now start to discuss the trajectories of the hidden states of the neural network, and what happens when their inputs are changed slightly. For the first hidden state, defined as the input, we can immediately say that
95
+
96
+ $$
97
+ | g ^ { 0 } ( x _ { i } ) - g ^ { 0 } ( x _ { i } + \delta x ) | = | \delta x |
98
+ $$
99
+
100
+ and then by once again mapping to the dynamical systems perspective, we model the difference between the two trajectories at depth $\textit { l }$ with
101
+
102
+ $$
103
+ | g ^ { l } ( x _ { i } ) - g ^ { l } ( x _ { i } + \delta x ) | \approx | \delta x | e ^ { \lambda l }
104
+ $$
105
+
106
+ While, as per the dynamical system, using an exponential model is typically the most illustrative despite the growth not necessarily being exponential, a basic theoretical justification for an exponential model is provided in Appendix B. Continuing, when the value of $\lambda$ is greater than $0$ , we may call the neural network sensitive to its input, in precisely the same manner as a dynamical system is sensitive to its initial conditions. We may also say that, when the value of $e ^ { \lambda L }$ is very large, it being the ratio of the magnitude of the change of the output to the magnitude of the change in the input, $\delta x$ becomes an adversarial perturbation. If this analogy holds, we should expect that when we adversarially attack a neural network, the difference between the two corresponding hidden states should grow as they progress through the model. This is our first experimental result.
107
+
108
+ As an aside, there is a tangential connection to be made between the Chaos Theoretic formulation of neural networks and Algorithmic Stability, like that discussed in Kearns & Ron (1997); Bousquet & Elisseeff (2000; 2002) and Hardt et al. (2016). However, while Algorithmic Stability also treats a notion of the effects of small changes in Machine Learning models, this is from the perspective of changes being made to the learning problem itself, such as to the training dataset, and the resulting effects on the learned model, rather than the effects of small changes being made to individual inference inputs and their respective outputs once the model has already been produced.
109
+
110
+ # 3 Experimental Design
111
+
112
+ For our experiments, we used two different model architectures: ResNets (He et al., 2015), as per the default Torchvision implementation (Marcel & Rodriguez, 2010), and a basic custom CNN architecture in order to have finer-grained control over the depth and number of channels in the model. The ResNets were modified, and the custom models built as to allow for recording all of the hidden states during the inference operation. These models, unless specified that they were left untrained, were trained on the Food101 dataset from Bossard et al. (2014) for 50 epochs with a batch size of 64 and a learning rate of 0.0001 with the Adam optimizer against cross entropy loss. The ResNet models used were ResNet18, ResNet34, ResNet50, ResNet101, and ResNet152.
113
+
114
+ In the Torchvision ResNet class, models consist of operations named conv1, bn1, relu, maxpool, layer1, layer2, layer3, layer4, avgpool, and $f c$ , with the first four representing a downsampling intake, then four more blocks of ResNet layers, and then a final operation that converts the rank 3 encoding tensor into a rank 1 class weight tensor. Hidden states are recorded at the input, after conv1, layer1, layer2, layer3, layer4, and at the output.
115
+
116
+ The custom models, specified with $C$ and $D$ , consist of $D$ tuples of convolutional layers, batch normalization operations, and ReLU nonlinearities, with the first tuple having a downsampling convolution and a maxpool operation after the ReLU. Each of these convolutions, besides the first which takes in three channels, has $C$ channels. Finally, there is a $1 \times 1$ convolution, a channel-wise averaging, and then a single fully connected layer with 101 outputs, one for each class in the Food-101 dataset. Hidden states are recorded after every tuple, and also include the input and the output of the model. The first tuple approximates the downsampling intake of the ResNet models.
117
+
118
+ In order to better handle the high dimensionality and changes in scale of the inputs, outputs, and hidden states, rather than using the Euclidean $L 2$ norm as the distance metric, we used a modified Euclidean distance
119
+
120
+ $$
121
+ | \vec { v } | : = \sqrt { \frac { 1 } { \mathbf { d i m } ( \vec { v } ) } \sum _ { i } v _ { i } ^ { 2 } }
122
+ $$
123
+
124
+ which will be applied for every instance of length and distance of and between hidden states, including attack radii. Adversarial perturbations $\delta x _ { a d v }$ against a neural network $h ( \theta ; \cdot )$ of a given radius $r$ for a given input $x _ { i }$ were generated by using five steps of gradient descent with a learning rate of 0.01, maximizing
125
+
126
+ $$
127
+ \left| h ( \theta ; x _ { i } ) - h ( \theta ; x _ { i } + \delta x _ { a d v } ) \right|
128
+ $$
129
+
130
+ and projecting back to the hypersphere of radius $r$ after every update. These attacks closely resemble those in Zhang et al. (2021); Wu et al. (2021b; 2022); Xie et al. (2021) and Shao et al. (2021), and their use of attacks with $l _ { p }$ -norm decay metrics or boundaries. For comparison, random perturbations were also generated, by projecting randomly sampled Gaussian noise to the same hypersphere. In order to perform these experiments under optimal conditions, the inputs that were adversarially perturbed were selected only from the subset of the Food-101 testing set for which every single trained model was correct in its estimate of the Top-1 output class. A Jupyter Notebook implementing these training regimes and attacks will be made available alongside this manuscript, pending review.
131
+
132
+ # 4 Hidden State Drift
133
+
134
+ An example of the approximately exponential growth in the distance between the hidden state trajectories associated with normal and adversarially perturbed inputs hypothesized in section 2.2 for 32 inputs is shown in Figure 2. Between the initial perturbations, generated with a radius of 0.0001, and the outputs, the differences grew by a factor of $\sim 7 4 7 \times$ . Given that ResNet18 has 18 layers, using $7 4 7 \approx e ^ { 1 8 \lambda }$ , we can calculate $\lambda \approx 0 . 3 6 8$ , an average measure of this drift per layer. However, the Lyapunov exponent for each layer is of less interest to an adversarial attacker or defender, with the actual value of interest being given by this new metric, $\psi$ , the adversarial susceptibility for a particular input and attack, given by
135
+
136
+ $$
137
+ \psi ( h , \theta , x _ { i } , \delta x _ { a d v } ) : = e ^ { \lambda L } = \frac { | h ( \theta ; x _ { i } ) - h ( \theta ; x _ { i } + \delta x _ { a d v } ) | } { | \delta x _ { a d v } | }
138
+ $$
139
+
140
+ ![](images/2d437c17bfd39c0e1ff0f86bfe9a40ba917c8302c50e096357c9e1334ee08630.jpg)
141
+ Figure 2: Example of hidden state drift while performing inference with the ResNet18 model. Note the logarithmic scaling on the $y$ -axis.
142
+
143
+ ![](images/a39a85b51f239ba8dfada1ef49cd8350732dbbf0e05bd0ab86210ee9b8bead5a.jpg)
144
+ Figure 3: Despite a change in the radius of the adversarial perturbation by three orders of magnitude, the value of $\psi$ associated with those attacks remains relatively stable.
145
+
146
+ This is the "susceptibility ratio," the ratio of the change inflicted by a given adversarial perturbation to its original magnitude. If this is a meaningful metric by which to judge a neural network architecture, it should remain relatively stable despite changes in the radius of the adversarial attack. This is our second experimental result, demonstrated in Figure 3. By sampling $\psi$ over a number of inputs $x _ { i }$ from a dataset $\mathcal { D }$ and a variety of attack radii $r _ { m i n } \le | \delta x _ { a d v } | \le r _ { m a x }$ and taking the geometric mean $^ { 3 }$ , we can come to a single value, written as
147
+
148
+ $$
149
+ \Psi ( h , \theta ) = e ^ { \mathbb { E } _ { x _ { i } \sim \mathcal { D } , | \delta x _ { a d v } | \sim [ r _ { m i n } , r _ { m a x } ] } [ \ln ( \psi ( h , \theta , x _ { i } , \delta x _ { a d v } ) ) ] }
150
+ $$
151
+
152
+ and approximated with $\hat { \Psi } ( h , \theta )$ , giving the susceptibility ratio for the model as a whole. These values have been calculated for the trained ResNet models, and are given in Table 1. These experimental results are more in line with those of Cazenavette et al. (2020) and Huang et al. (2022b) than with the predictions that we will make in the next section, at which point we will begin using our custom model architectures to tease out the relationships between a neural network’s architecture and its susceptibility ratio. A discussion of this metric’s relationship to the Lipschitz constant is provided in Appendix C.
153
+
154
+ Table 1: Overall susceptibility ratio of trained ResNet models.
155
+
156
+ <table><tr><td></td><td>ResNet18</td><td>ResNet34</td><td>ResNet50</td><td>ResNet101</td><td>ResNet152</td></tr><tr><td>亚(h,0)</td><td>781.2</td><td>790.7</td><td>854.4</td><td>893.2</td><td>846.5</td></tr></table>
157
+
158
+ <table><tr><td colspan="5">重(h,0)</td></tr><tr><td></td><td>32</td><td>Channels (C) 64</td><td>128</td><td>256</td></tr><tr><td>2</td><td>0.749</td><td>0.523</td><td>0.651</td><td>0.560</td></tr><tr><td>4</td><td>1.021</td><td>0.695</td><td>0.775</td><td>0.610</td></tr><tr><td>8</td><td>2.788</td><td>2.134</td><td>1.505</td><td>1.276</td></tr><tr><td>16</td><td>15.491</td><td>12.935</td><td>8.423</td><td>7.123</td></tr><tr><td>(a) s.aner 32</td><td>109.340</td><td>135.472</td><td>98.834</td><td>92.404</td></tr><tr><td>64</td><td>96.037</td><td>63.785</td><td>60.443</td><td>48.721</td></tr></table>
159
+
160
+ Table 2: Susceptibility ratio of randomly initialized convolutional models with custom architectures on inputs consisting of random noise.
161
+
162
+ # 5 Architectural Effects on Adversarial Susceptibility
163
+
164
+ Returning to the definition of $\psi$ given in equation 1, we might model it as being proportional to the exponent of $L$ , the depth of the neural network. Yet, despite ResNet152 having more than eight times as many layers as ResNet18, its susceptibility is only marginally higher. This effect was explored to a greater experimental degree in Cazenavette et al. (2020) and Huang et al. (2022b), demonstrating a remarkable tendency towards robustness in residual model architectures. Interestingly, Huang et al. (2022b) found that deeper models were more robust than wider models, which runs counter to both the experimental and theoretical evidence provided here. Proceeding, this makes the use of an exponential model, at least to explain these experimental results, limited. In order to explore this reasoning further in a more numerically ideal setting, we present our third experimental result, in Table 2, and replicated in Figure 4. Here, using randomly initialized, untrained models with custom architectures as described in the experimental methods section (3), having them perform inference on random inputs, and then adversarially attacking the same models on the same inputs, we can tease apart the relationship between model architecture and the resulting susceptibility ratio, for the case where both parameters and input dimensions are given as Gaussian noise.
165
+
166
+ We immediately find an approximately exponential relationship between the susceptibility ratio and the depth of the model that was expected based on equation 1, however the slight dip upon moving from 32 to 64 layers is unexpected, and while exploring its potential causes and implications is outside of the scope of this paper, it may warrant further experimentation and analysis.
167
+
168
+ Also of interest is the effect, or lack thereof, of increasing the number of channels in the neural network. While a quadratic increase in the number of parameters in the model might be expected to increase its susceptibility ratio, especially per the theoretical analysis in Huang et al. (2022a), no experiment that we performed yielded such a result. Some theoretical analysis and discussion is provided in Appendix B.
169
+
170
+ We repeated the susceptibility ratio measurement on the same model architectures, this time with trained parameters, again sampling the inputs from the Food-101 testing subset for which all models produced correct Top-1 class estimates. These results are in Table 3, and replicated in Figure 5.
171
+
172
+ The largest resulting difference is the increase of susceptibility for every model by multiple orders of magnitude. Training the models and switching to an information-rich input domain has resulted in trained models being far more sensitive to attack. Yet, following earlier experiments, we can again see that the number of channels has minimal and unclear effects on the susceptibility ratio of the model, while the number of layers increases it significantly. However, for these experimental results, the relationship between the number of layers and the susceptibility has changed, more closely resembling logarithmic than exponential growth, and somewhat replicates the relationship found between depth and susceptibility among the trained ResNet
173
+
174
+ ![](images/2fd036eaa559817349a7e770c84cce2d9fb328803b0f85431437abce4de06e53.jpg)
175
+ Figure 4: Graphical replication of Table 2; susceptibility ratios of models with random weights.
176
+
177
+ <table><tr><td colspan="5">重(h,0)</td></tr><tr><td></td><td>32</td><td>Channels (C) 64</td><td>128</td><td>256</td></tr><tr><td></td><td>24 578.602</td><td>610.207</td><td>586.503</td><td>576.759</td></tr><tr><td>(a) s.aker</td><td>1470.399</td><td>1658.209</td><td>1631.561</td><td>1695.993</td></tr><tr><td>8</td><td>2144.418</td><td>2224.467</td><td>2536.745</td><td>2370.648</td></tr><tr><td>16</td><td>2361.251</td><td>2401.381</td><td>2485.030</td><td>2846.418</td></tr><tr><td>32</td><td>3162.568</td><td>3018.758</td><td>2987.640</td><td>3256.967</td></tr><tr><td>64</td><td>2045.765</td><td>2213.575</td><td>3103.335</td><td>2471.823</td></tr></table>
178
+
179
+ Table 3: Susceptibility ratios of trained custom convolutional models on inputs sampled from Food-101.
180
+
181
+ ![](images/67e518108d00f4dc43f54da0042530a5ca385214f041c715c3163f8dd3195bd6.jpg)
182
+ Figure 5: Graphical replication of Table 3; susceptibility ratios of trained models.
183
+
184
+ models. Interestingly, this is reasonably analogous to the testing accuracy of the models, for which increases in depth yield diminishing returns, and it may be theorized that both of these effects are due to changes in the encoding of information based on model architecture. However, it must be noted that the increase in susceptibility is greater than the increase in accuracy. Making models deeper makes them more vulnerable faster than it makes them more accurate, with additional costs in memory, runtime, and energy consumption.
185
+
186
+ # 6 Relationships to Other Metrics
187
+
188
+ # 6.1 Approximation of Certified Robustness Radii
189
+
190
+ In the work of Weber et al. (2020) and Li et al. (2020), they attempt to calculate what they refer to as "certified robustness radii." For a model with hard decision boundaries, e.g. a top-1 classification model, its certified robustness radius is the largest value $\epsilon _ { h }$ such that, for any input $x _ { i }$ and any adversarial perturbation $\lvert \delta x _ { a d v } \rvert$ , the ultimate classification given by the model argm $\operatorname { u x } _ { c } h ( \theta ; x _ { i } ) = \operatorname { a r g m a x } _ { c } h ( \theta ; x _ { i } + \delta x _ { a d v } )$ for all perturbations with radius smaller than $\epsilon _ { h }$ . In their work, however, they state explicitly that these values are highly demanding to calculate for small models, and computationally infeasible for larger models. However, using the susceptibility ratio for a model, one can quickly approximate this certified robustness radius for even very large models. It is simply the distance to the nearest decision boundary, divided by $\hat { \Psi } ( h , \theta )$ .
191
+
192
+ We demonstrate with an example: a five-class model outputs the following weights for a given input, $\hat { y } =$ $\{ 2 . 1 , 0 . 6 , 0 . 1 , - 0 . 5 , - 1 . 1 \}$ . Thus, the nearest decision boundary occurs where the first and second classes become equal, at $\hat { y } ^ { \prime } = \{ 1 . 3 5 , 1 . 3 5 , 0 . 1 , - 0 . 5 , - 1 . 1 \}$ . The modified Euclidean distance between these two vectors is 0.4703. Suppose that thradius would then be estimated as tibility ratio of . One could the $\hat { \Psi } = 2 5 . 0$ . Its certified robustnesse mean or minimum over $\begin{array} { r } { \hat { \epsilon } _ { h } = \frac { 0 . 4 7 0 3 } { 2 5 . 0 } = 0 . 0 1 8 9 7 } \end{array}$
193
+ must be noted that this will produce a substantial overestimate of the actual certified robustness radius, as the susceptibility ratio is a geometric mean rather than a supremum, and is produced via experimental approximation rather than a numerical solution. However, this "approximated robustness radius" is also useful in practice, as it provides a much larger radius wherein the associated model is highly probably immune from attack, rather than an extremely small radius wherein the associated model is provably immune from attack.
194
+
195
+ Finally, an over-all criticism has to be made regarding the use of these certified robustness radii in general. Consider two models used for a binary classification problem, inferring on the same input, which has been perturbed by adversarial attacks of equal radii. The first model, moving from the vanilla to the adversarial input, changes its output from $\{ 0 . 9 , 0 . 1 \}$ to $\{ 0 . 6 , 0 . 4 \}$ . The second model, under the same conditions, changes its output from $\{ 0 . 5 5 , 0 . 4 5 \}$ to $\{ 0 . 4 5 , 0 . 5 5 \}$ . Using a certified robustness radius, it would be concluded that the first model is the more robust, while a more direct reading of the change in probabilities would declare the second model to be more robust. These certified robustness radii represent a dense and inscrutable encoding of information about both the model and the input distribution, such that it can be difficult to use them as a meaningful metric. Consider as a hypothetical if, in the previous example, the first model produced a highly confident output solely because it was significantly overfit, and the underlying domain of the dataset is non-separable near the input. Although this improves its robustness radius, it makes it more susceptible to attack in the field.
196
+
197
+ # 6.2 Post-Adversarial Accuracy
198
+
199
+ One of the existing standard measures of Adversarial Robustness is to measure the accuracy of models on adversarially perturbed inputs. If our analyses and experimental results thus far are correct, we should see an inverse relationship between measured susceptibility ratios and the post-adversarial accuracy for any given attack radius. This is our fourth experimental result, shown in Figure 6. In it, we observe that among ResNets, which possess similar values of $\hat { \Psi } ( h , \theta )$ , post-attack accuracies are close between models, with an approximate but minor correspondence between higher susceptibilities and lower post-attack accuracy. We also observe, among the custom architectures, represented in Figure 6 by the subset of models with 32 channels and in their entirety in Figure 4, a very close inverse relationship between higher susceptibility and lower post-attack accuracy, particularly at the 0.01 attack radius. We also observe that the custom architecture with $D = 2$ , which experimentally had $\Uparrow = 5 7 8 . 6 0 2$ , has a post-attack accuracy curve that closely resembles those of the ResNet models, each of which had a similar susceptibility.
200
+
201
+ ![](images/c87780fe451e19988278d488055376b81359364a97c7c0545368f67fdf2e09cc.jpg)
202
+ Figure 6: Post-Attack Accuracies
203
+
204
+ ![](images/8a1c8b669d055fba6fcf16be02cd9b55f88e0f61608fd9d289d4aca449f77aa6.jpg)
205
+ Figure 7: Relationship between Adversarial Susceptibility and Post-Attack Accuracy, with a radius of 0.01. Linear best fit shown, with a correlation coefficient of -0.911.
206
+
207
+ # 7 Conclusions and Future Work
208
+
209
+ Our experiments have shown, with some variation due to the inscrutable black-box nature of Deep Learning, that there is an extremely strong, analytically valuable, and experimentally valid connection between neural networks and dynamical systems as they exist in Chaos Theory. This connection can be used to make accurate and meaningful predictions about different neural network architectures, as well as to efficiently measure how susceptible they are to adversarial attacks. We have shown a correspondence, both experimentally and analytically, between these new measurements, and those developed in prior works. Thus, a new tool has been added to the toolbox of practitioners looking to make decisions about neural networks.
210
+
211
+ Future work will include further exploration in this area, and the utilization of more advanced techniques and analysis from Chaos Theory, as well as the development of new, more precise metrics that may tell us more about how models are affected by adversarial attacks. Additionally, the relationship between the susceptibility ratio and Adversarial Robustness training regimes deserves study, as well as the relationship with different attack methodologies.
212
+
213
+ References
214
+ Kathleen T Alligood, Tim D Sauer, James A Yorke, and David Chillingworth. Chaos: an introduction to dynamical systems. SIAM Review, 40(3):732–732, 1998.
215
+ Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014.
216
+ Olivier Bousquet and André Elisseeff. Algorithmic stability and generalization performance. Advances in Neural Information Processing Systems, 13, 2000.
217
+ Olivier Bousquet and André Elisseeff. Stability and generalization. The Journal of Machine Learning Research, 2:499–526, 2002.
218
+ Yair Carmon, Aditi Raghunathan, Ludwig Schmidt, John C Duchi, and Percy S Liang. Unlabeled data improves adversarial robustness. Advances in Neural Information Processing Systems, 32, 2019.
219
+ George Cazenavette, Calvin Murdock, and Simon Lucey. Architectural adversarial robustness: The case for deep pursuit, 11 2020.
220
+ European Mathematical Society. Lipschitz constant. In Encyclopedia of Mathematics. EMS Press, May 2023.
221
+ Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
222
+ Sven Gowal, Chongli Qin, Jonathan Uesato, Timothy Mann, and Pushmeet Kohli. Uncovering the limits of adversarial training against norm-bounded adversarial examples, 2021.
223
+ Moritz Hardt, Ben Recht, and Yoram Singer. Train faster, generalize better: Stability of stochastic gradient descent. In International conference on machine learning, pp. 1225–1234. PMLR, 2016.
224
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition, 2015. URL https://arxiv.org/abs/1512.03385.
225
+ Warren He, Bo Li, and Dawn Song. Decision boundary analysis of adversarial examples. In International Conference on Learning Representations, 2018.
226
+ Hanxun Huang, Yisen Wang, Sarah Monazam Erfani, Quanquan Gu, James Bailey, and Xingjun Ma. Exploring architectural ingredients of adversarially robust deep neural networks, 2022a.
227
+ Shihua Huang, Zhichao Lu, Kalyanmoy Deb, and Vishnu Naresh Boddeti. Revisiting residual networks for adversarial robustness: An architectural perspective, 2022b.
228
+ Michael Kearns and Dana Ron. Algorithmic stability and sanity-check bounds for leave-one-out crossvalidation. In Proceedings of the tenth annual conference on Computational learning theory, pp. 152–162, 1997.
229
+ R. B. Levien and S. M. Tan. Double pendulum: An experiment in chaos. American Journal of Physics, 61(11): 1038–1044, 11 1993. ISSN 0002-9505. doi: 10.1119/1.17335. URL https://doi.org/10.1119/1.17335.
230
+ Linyi Li, Xiangyu Qi, Tao Xie, and Bo Li. Sok: Certified robustness for deep neural networks. arXiv preprint arXiv:2009.04131, 2020.
231
+ Sébastien Marcel and Yann Rodriguez. Torchvision the machine-vision package of torch. In Proceedings of the 18th ACM International Conference on Multimedia, MM ’10, pp. 1485–1488, New York, NY, USA, 2010. Association for Computing Machinery. ISBN 9781605589336. doi: 10.1145/1873951.1874254. URL https://doi.org/10.1145/1873951.1874254.
232
+ Anibal Pedraza, Oscar Deniz, and Gloria Bueno. Approaching adversarial example classification with chaos theory. Entropy, 22(11), 2020. ISSN 1099-4300. doi: 10.3390/e22111201. URL https://www.mdpi.com/ 1099-4300/22/11/1201.
233
+ Vinay Uday Prabhu, Nishant Desai, and John Whaley. On lyapunov exponents and adversarial perturbation, 2018. URL https://arxiv.org/abs/1802.06927.
234
+ Jürgen Schmidhuber. Deep learning in neural networks: An overview. Neural networks, 61:85–117, 2015.
235
+ Rulin Shao, Zhouxing Shi, Jinfeng Yi, Pin-Yu Chen, and Cho-Jui Hsieh. On the adversarial robustness of vision transformers. arXiv preprint arXiv:2103.15670, 2021.
236
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
237
+ Yizhen Wang, Somesh Jha, and Kamalika Chaudhuri. Analyzing the robustness of nearest neighbors to adversarial examples. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 5133–5142. PMLR, 10–15 Jul 2018. URL https://proceedings.mlr.press/v80/wang18c.html.
238
+ Maurice Weber, Xiaojun Xu, Bojan Karlaš, Ce Zhang, and Bo Li. Rab: Provable robustness against backdoor attacks. arXiv preprint arXiv:2003.08904, 2020.
239
+ Boxi Wu, Jinghui Chen, Deng Cai, Xiaofei He, and Quanquan Gu. Do wider neural networks really help adversarial robustness?, 2021a.
240
+ Fan Wu, Linyi Li, Zijian Huang, Yevgeniy Vorobeychik, Ding Zhao, and Bo Li. Crop: Certifying robust policies for reinforcement learning through functional smoothing. arXiv preprint arXiv:2106.09292, 2021b.
241
+ Fan Wu, Linyi Li, Chejian Xu, Huan Zhang, Bhavya Kailkhura, Krishnaram Kenthapadi, Ding Zhao, and Bo Li. Copa: Certifying robust policies for offline reinforcement learning against poisoning attacks. arXiv preprint arXiv:2203.08398, 2022.
242
+ Chulin Xie, Minghao Chen, Pin-Yu Chen, and Bo Li. Crfl: Certifiably robust federated learning against backdoor attacks. In International Conference on Machine Learning, pp. 11372–11382. PMLR, 2021.
243
+ Chaoning Zhang, Philipp Benz, Chenguo Lin, Adil Karjauv, Jing Wu, and In So Kweon. A survey on universal adversarial attack. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence. International Joint Conferences on Artificial Intelligence Organization, aug 2021. doi: 10. 24963/ijcai.2021/635. URL https://doi.org/10.24963%2Fijcai.2021%2F635.
244
+
245
+ # A The function $g$
246
+
247
+ Because the function only takes $\Delta \ell$ and as inputs, and not $\textit { l }$ itself, a modification must be made in order $g$ $z _ { i , l }$
248
+ to define $g$ such that it correctly performs the neural network layer layer operation, while still preserving the
249
+ same formulation as the evolution function $\Phi ( \Delta t , x _ { i , t } )$ . This can be achieved by replacing $Z$ with $Z ^ { \prime }$ , such
250
+ that
251
+
252
+ $$
253
+ Z ^ { \prime } : = Z \times \lbrack L \rbrack = \left\{ \forall ( z _ { i , l } , l ) \middle \vert \exists l \in [ L ] \wedge \exists z _ { i , l } \in Z \right\}
254
+ $$
255
+
256
+ Then, $g$ is replaced with $g ^ { \prime } : [ L ] \times Z ^ { \prime } \to Z ^ { \prime }$ , with
257
+
258
+ $$
259
+ g ^ { \prime } \big ( 1 , ( z _ { i , l } , l ) \big ) : = \big ( \sigma ( W _ { l } z _ { i , l } + b _ { l } ) , l + 1 \big )
260
+ $$
261
+
262
+ Drawing the index of the parameters $W _ { l }$ and $b _ { l }$ to use from the second element of the $\left( z _ { i , l } , \ l \right)$ tuple, which it iterates, and with $g ^ { \prime }$ then following from recursion. This has no bearing in practice, but helps to align theoretical analysis.
263
+
264
+ # B Theoretical Basis for Exponential Growth
265
+
266
+ The use of exponential growth to describe sensitive dependence in Chaos Theory is primarily a model rather than a theoretical result, owing to the typically bounded nature of state spaces. A classic Physical example of a chaotic system is the double pendulum (Levien & Tan, 1993), with a state space defined by the set of possible arm angles $X : = [ 0 , 2 \pi ) \times [ 0 , 2 \pi )$ , and therefore a maximum $L 1$ distance of $2 \pi$ , bounding exponential growth. For a purely Mathematical example of a chaotic system, consider the state space $[ 0 , 1 )$ with the evolution function $\Phi ( 1 , x ) : = 2 x$ mod 1. The trajectory with an initial condition at $x = 0 . 3 7$ goes 0.74, 0.48, 0.96, 0.92, 0.84, et cetera. Starting with $x = 0 . 3 8$ , it goes 0.76, 0.52, 0.04, 0.08, 0.16, et cetera. The distance between the two trajectories is bounded at 0.5, but starting with a distance of 0.01, it grew to 0.32 in only 5 time steps, for this period having a Lyanpunov exponent of $\ln ( 2 ) = 0 . 6 9 3$ ; positive, and therefore chaotic. With this caveat in mind, a neural network can, to a finite degree and for a temporary period, be expected to produce exponential growth in the hidden state drift of two similar inputs.
267
+
268
+ # B.1 Random Matrices
269
+
270
+ Consider a first-order approximation of a neural network which removes the nonlinear activation functions and biases, rendering it a product of matrices. Let us define these to be $d \times d$ real-valued square matrices $W _ { l } \in \mathbb { R } ^ { d \times d }$ , and let us make the simplifying assumption that these are random matrices with i.i.d. univariate Gaussian entries $w _ { l _ { i j } } \sim \mathcal { N } ( \mu = 0 , \sigma ^ { 2 } = 1 )$ ). Next we define a product accumulator matrix $\begin{array} { r } { H _ { L } : = \prod _ { l = 0 } ^ { L } W _ { l } } \end{array}$ with elements $\eta _ { L _ { i j } }$ . We will also rely on the following: summing distributions sums their means and variances, and the product of two zero-mean distributions has a variance equal to the product of the variances of its constituents.
271
+
272
+ For the first two weight matrices $W _ { 1 }$ and $W _ { 0 }$ with elements $w _ { 1 _ { i j } }$ and $w _ { 0 _ { i j } }$ , and defining
273
+
274
+ $$
275
+ \eta _ { 1 _ { i j } } = \sum _ { k = 1 } ^ { d } w _ { 1 _ { i k } } w _ { 0 _ { k j } }
276
+ $$
277
+
278
+ we get that σ2η1ij and $\mu _ { \eta _ { 1 _ { i j } } } ^ { 2 } = 0$ . Taking the recursion $H _ { L + 1 } = W _ { L + 1 } H _ { L }$ , we get
279
+
280
+ $$
281
+ \eta _ { L + 1 _ { i j } } = \sum _ { k = 1 } ^ { d } w _ { L + 1 _ { i k } } \eta _ { L _ { k j } }
282
+ $$
283
+
284
+ with σ2ηL+1ij $\sigma _ { \eta _ { L + 1 _ { i j } } } ^ { 2 } ~ = ~ d \sigma _ { \eta _ { L _ { i j } } } ^ { 2 }$ = dσ2ηLij and µ2ηL+1ij√ $\mu _ { \eta _ { L + 1 _ { i j } } } ^ { 2 } ~ = ~ 0$ . Trivially, this resolves to $\sigma _ { \eta _ { L _ { i j } } } ^ { 2 } = d ^ { L }$ , additionally giving us a standard deviation σηLij $\sigma _ { \eta _ { L _ { i j } } } = \sqrt { d ^ { L } } = d ^ { L / 2 }$ . This reduces the accumulator matrix parameter distribution to $\eta _ { L _ { i j } } \sim \mathcal { N } ( \mu = 0 , \sigma ^ { 2 } = d ^ { L } )$ , and the multiplication of a vector $x _ { s }$ by $H _ { L }$ becomes multiplication by a univariate Gaussian random matrix, and then by $d ^ { L / 2 }$ , given by $d ^ { L / 2 } W _ { 0 } x _ { s }$ . Substituting out $x _ { s }$ for $x _ { s } + \delta x$ , this gives us $d ^ { L / 2 } W _ { 0 } ( x _ { s } + \delta x )$ , and finally $H _ { L } x _ { s } - H _ { L } ( x _ { s } + \delta x ) = - H _ { L } \delta x$ , thus
285
+
286
+ $$
287
+ { \frac { | H _ { L } x _ { s } - H _ { L } ( x _ { s } + \delta x ) | } { | \delta x | } } = d ^ { L / 2 } = e ^ { \ln ( d ) L / 2 }
288
+ $$
289
+
290
+ which is an exponential increase in the distance between the trajectories of $x _ { s }$ and $x _ { s } + \delta x$ , returning to the earlier dynamical systems formulation.
291
+
292
+ # B.2 Activation Function
293
+
294
+ If we may assume that we know the vector $x _ { s }$ beforehand, inserting ReLU activations between each matrix multiplication becomes equivalent to substituting a 0 for each entry in a vector that is being sequentially multiplied by each matrix, itself being equivalent to preserving the vector and instead substituting a 0 for each entry in the associated columns. Because all of the Gaussian distributions discussed have been zero mean, and the probability of a Gaussian being greater than or less than its mean is always 0.5, this gives us, relying on positive/negative symmetries, that each entry in the resulting vector may equivalently be sampled as
295
+
296
+ $$
297
+ { x _ { s , l } } _ { i } = \sum _ { k = 1 } ^ { d } \sim { w _ { l } } _ { i k } { x _ { s , l } } _ { k } \cdot \mathrm { B e r n } ( p = 0 . 5 )
298
+ $$
299
+
300
+ which has the effect of halving the number of dimensions that contributed to , in essence lowering $d$ to $x _ { s , l _ { i } }$ d/2, and further decreasing the growth of the trajectory distance from eln(d)L/2 to eln(d/2)L/2.
301
+
302
+ # B.3 Batch Normalization
303
+
304
+ Consider a set of vectors that all have some existing magnitude and per-dimension standard deviation from one another. After a normalization step which subtracts out their mean and divides per-dimension by the standard deviation, the resulting vectors will have a mean of 0 and a standard deviation of 1. This resets any growth that they may previously have had away from one another. If a set of vectors including $x _ { i , 0 }$ has a standard deviation of 1, and each element thereof is multiplied by $W _ { 0 }$ with a ReLU activation applied, such that the set of vectors that includes $x _ { i , 1 }$ has a standard deviation of $\sqrt { d / 2 }$ , the normalization step will result in division by that factor. The effect of this is to curtail the spatially infinite growth of each vector as each neural network layer is applied. Trajectories will still diverge from one another, and the dynamics of the underlying system is such that small changes will still compound, e.g. one entry with a value of 0.01 will have propagating and compounding effects compared to an entry with a value of -0.01, which will simply be erased by ReLU. But it places restrictions on the otherwise infinite possible growth, much like the domain boundaries of the double pendulum or the $\Phi ( 1 , x ) : = 2 x$ mod 1 system discussed earlier.
305
+
306
+ # C Adversarial Susceptibility and the Lipschitz Constant
307
+
308
+ The Lipschitz constant M (European Mathematical Society, 2023) is defined for a function $f : X \to Y$ as
309
+
310
+ $$
311
+ M ( f ) : = \operatorname* { s u p } _ { ( x _ { i } , x _ { j } ) \in X \times X \mid x _ { i } \neq x _ { j } } { \frac { | f ( x _ { i } ) - f ( x _ { j } ) | } { | x _ { i } - x _ { j } | } }
312
+ $$
313
+
314
+ This possesses a close ontological relationship in formulation to the susceptibility ratio, as defined in equations 1 and 2. They both describe a rate of change of a function’s output with respect to its input. However, while this relationship is obvious, there are several points of differentiation. The susceptibility ratio is a numerically estimated geometric mean, whereas the Lipschitz constant is a global maximum, which cannot be produced analytically for Deep neural networks. Additionally, whereas the Lipschitz constant is a tool of Analysis, the susceptibility ratio is a construct of combining the Chaos Theoretic Lyanpunov exponent with a constant time horizon.
parse/test/lPw8Xdzw5f/lPw8Xdzw5f_content_list.json ADDED
@@ -0,0 +1,701 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "Chaos Theory and Adversarial Robustness ",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Anonymous authors Paper under double-blind review ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "Abstract ",
16
+ "text_level": 1,
17
+ "page_idx": 0
18
+ },
19
+ {
20
+ "type": "text",
21
+ "text": "Neural networks, being susceptible to adversarial attacks, should face a strict level of scrutiny before being deployed in critical or adversarial applications. This paper uses ideas from Chaos Theory to explain, analyze, and quantify the degree to which neural networks are susceptible to or robust against adversarial attacks. To this end, we present a new metric, the \"susceptibility ratio,\" given by $\\hat { \\Psi } ( h , \\theta )$ , which captures how greatly a model’s output will be changed by perturbations to a given input. ",
22
+ "page_idx": 0
23
+ },
24
+ {
25
+ "type": "text",
26
+ "text": "Our results show that susceptibility to attack grows significantly with the depth of the model, which has safety implications for the design of neural networks for production environments. We provide experimental evidence of the relationship between $\\hat { \\Psi }$ and the post-attack accuracy of classification models, as well as a discussion of its application to tasks lacking hard decision boundaries. We also demonstrate how to quickly and easily approximate the certified robustness radii for extremely large models, which until now has been computationally infeasible to calculate directly. ",
27
+ "page_idx": 0
28
+ },
29
+ {
30
+ "type": "text",
31
+ "text": "1 Introduction ",
32
+ "text_level": 1,
33
+ "page_idx": 0
34
+ },
35
+ {
36
+ "type": "text",
37
+ "text": "The current state of Machine Learning research presents neural networks as black boxes due to the high dimensionality of their parameter space, which means that understanding what is happening inside of a model regarding domain expertise is highly nontrivial, when it is even possible. However, the actual mechanics by which neural networks operate - the composition of multiple nonlinear transforms, with parameters optimized by a gradient method - were human-designed, and as such are well understood. In this paper, we will apply this understanding, via analogy to Chaos Theory, to the problem of explaining and measuring susceptibility of neural networks to adversarial methods. ",
38
+ "page_idx": 0
39
+ },
40
+ {
41
+ "type": "text",
42
+ "text": "It is well-known that neural networks can be adversarially attacked, producing obviously incorrect outputs as a result of making extremely small perturbations to the input (Goodfellow et al., 2014; Szegedy et al., 2013). Prior work, like Shao et al. (2021); Wang et al. (2018) and Carmon et al. (2019) discuss \"adversarial robustness\" in terms of metrics like accuracy after being attacked or the success rates of attacks, which can limit the discussion entirely to models with hard decision boundaries like classifiers, ignoring tasks like segmentation or generative modeling (He et al., 2018). Other work, like Li et al. (2020) and Weber et al. (2020), develop \"certification radii,\" which can be used to guarantee that a given input cannot be misclassified by a model without an adversarial perturbation with a size exceeding that radius. However, calculating these radii is computationally onerous when it is even possible, and is again limited only to models with hard decision boundaries. ",
43
+ "page_idx": 0
44
+ },
45
+ {
46
+ "type": "text",
47
+ "text": "Gowal et al. (2021) provides a brief study of the effects of changes in model scale, but admits that there has been a dearth of experiments that vary the depth and width of models in the context of adversarial robustness, which this paper provides. Huang et al. (2022a) also studies the effects of architectural design decisions on robustness, and provides theoretical justification on the basis of deeper and wider models having a greater upper bound on the Lipschitz constant of the function represented by those models. Our own work’s connection to the Lipschitz constant is discussed in Appendix C. Wu et al. (2021a) studies the effects of model width on robustness, and specifically discusses how robust accuracy is closely related to the perturbation stability of the underlying model, with an additional connection to the local Lipschitzness of the represented function. Our experimental results contradict those found in these papers in a few places, namely as to the relationship between depth and robustness. Additionally, previous work is limited to studying advanced State-of-the-Art CNN architectures, which introduces a number of effects that are never accounted for during their ablations. ",
48
+ "page_idx": 0
49
+ },
50
+ {
51
+ "type": "image",
52
+ "img_path": "images/aa2111eff704d3fba41676dcbea30dbfb9fedd7385fcf3d36b4bd1324d3be807.jpg",
53
+ "image_caption": [
54
+ "Figure 1: In a dynamical system, two trajectories with similar starting points may, over time, drift farther and farther away from one another, typically modeled as exponential growth in the distance between them. This growth characterizes a system as exhibiting \"sensitive dependence,\" known colloquially as the \"butterfly effect,\" where small changes in initial conditions eventually grow into very large changes in the eventual results. "
55
+ ],
56
+ "image_footnote": [],
57
+ "page_idx": 1
58
+ },
59
+ {
60
+ "type": "text",
61
+ "text": "",
62
+ "page_idx": 1
63
+ },
64
+ {
65
+ "type": "text",
66
+ "text": "Regarding the existence of adversarial attacks ab origine, Pedraza et al. (2020) and Prabhu et al. (2018) have explained this behaviour of neural networks on the basis that they are dynamical systems, and then use results from that analysis to try and classify adversarial inputs based on their Lyapunov exponents. However, this classification methodology rests on loose theoretical ground, as the Lyapunov exponents of a single input must be relative to those of similar inputs, and it is entirely possible to construct a scenario wherein an input does not become more potent a basis for further attack solely because it is itself adversarial. ",
67
+ "page_idx": 1
68
+ },
69
+ {
70
+ "type": "text",
71
+ "text": "In this work, we re-do these Chaos Theoretic analyses in order to understand, not particular inputs, but the neural networks themselves. We show that neural networks are dynamical systems, and then continuing that analogy past where Pedraza et al. (2020) and Prabhu et al. (2018) leave off, investigate what neuralnetworks-as-dynamical-systems means for their susceptibility to attack, through a combination of analysis and experimentation. We develop this into a theory of adversarial susceptibility, the \"susceptibility ratio\" as a measure of how effective attacks will be against a neural network, and show how to numerically approximate this value. Returning to the work in Li et al. (2020) and Weber et al. (2020), we use the susceptibility ratio to quickly and accurately estimate the certification radii of very large neural networks, aligning this paper with prior work. ",
72
+ "page_idx": 1
73
+ },
74
+ {
75
+ "type": "text",
76
+ "text": "2 Neural Networks as Dynamical Systems ",
77
+ "text_level": 1,
78
+ "page_idx": 1
79
+ },
80
+ {
81
+ "type": "text",
82
+ "text": "We will now re-write the conventional feed-forward neural network formulation in the language of dynamical systems, in order to facilitate the transfer of the analysis of dynamical systems back to neural networks. To begin with, we first introduce the definition of a dynamical system, per standard literature (Alligood et al., 1998). ",
83
+ "page_idx": 1
84
+ },
85
+ {
86
+ "type": "text",
87
+ "text": "2.1 Dynamical Systems ",
88
+ "text_level": 1,
89
+ "page_idx": 1
90
+ },
91
+ {
92
+ "type": "text",
93
+ "text": "In Chaos Theory, a dynamical system is defined as a tuple of three basic components, written in standard notation as $( T , X , \\Phi )$ . The first, $T$ , referred to as \"time,\" takes the form of a domain obeying time-like algebraic properties, namely associative addition. The second, $X$ , is the state space. Depending on the system, elements of $X$ might describe the positions of a pendulum, the states of memory in a computer program, or the arrangements of particles in an enclosed volume, with $X$ being the space of all possibilities thereof. The final component, $\\Phi : T \\times X \\to X$ , is the \"evolution function\" of the system. When $\\Phi$ is given a state $x _ { i , t } \\in X$ and a change in time $\\Delta t$ , it returns $x _ { i , t + \\Delta t }$ , which is the new state of the system after $\\Delta t$ time has elapsed. The $x _ { i , t }$ notation will be explained in greater detail later. We will write this as ",
94
+ "page_idx": 1
95
+ },
96
+ {
97
+ "type": "text",
98
+ "text": "",
99
+ "page_idx": 2
100
+ },
101
+ {
102
+ "type": "equation",
103
+ "img_path": "images/b6e6603f3b4d5723f13b6af77c57bf938ac770358d6d904ffc20ae4d0c7bb8bd.jpg",
104
+ "text": "$$\nx _ { i , t + \\Delta t } = \\Phi ( \\Delta t , x _ { i , t } )\n$$",
105
+ "text_format": "latex",
106
+ "page_idx": 2
107
+ },
108
+ {
109
+ "type": "text",
110
+ "text": "In order to stay well defined, this has to possess certain properties, namely a self-consistency of the evolution function over the domain $T$ . A state that is progressed forward $\\Delta t _ { a }$ in $T$ by $\\Phi$ and then progressed again $\\Delta t _ { b }$ should yield the same state as one that is progressed $\\Delta t _ { a } + \\Delta t _ { b }$ in a single operation: ",
111
+ "page_idx": 2
112
+ },
113
+ {
114
+ "type": "equation",
115
+ "img_path": "images/0a8da32af6fd35aaffd329807cede2f63a713ff5e76ea54e034fc6920c93250a.jpg",
116
+ "text": "$$\n\\Phi \\big ( \\Delta t _ { b } , \\Phi ( \\Delta t _ { a } , x _ { i , t } ) \\big ) = \\Phi ( \\Delta t _ { a } + \\Delta t _ { b } , x _ { i , t } )\n$$",
117
+ "text_format": "latex",
118
+ "page_idx": 2
119
+ },
120
+ {
121
+ "type": "text",
122
+ "text": "Relying partially on this self-consistency, we can take a \"trajectory\" of the initial state $x _ { i , 0 }$ over time, a set containing elements represented by $\\{ \\left( t , \\Phi ( t , x _ { i , 0 } ) \\right) \\big | \\forall t \\in T \\}$ . To clarify; because each element within $X$ can be progressed through time by the injective and self-consistent function $\\Phi$ , and therefore belongs to a given trajectory,1 it becomes both explanatory and efficient to denote every element in the same trajectory with the same subscript index $i$ , and to differentiate between the elements in the same trajectory at different times with $t$ . In order to simplify the notation, and following on from the notion that the evolution of state within a dynamic system over time is equivalent to the composition of multiple instances of the evolution function, we will write the elements of this trajectory as ",
123
+ "page_idx": 2
124
+ },
125
+ {
126
+ "type": "equation",
127
+ "img_path": "images/cd8e0371acc7f7ceea0f15ec8694cafd42fc6a5e4d8119803abb7d7d89a497f7.jpg",
128
+ "text": "$$\n\\Phi ( t , x _ { i , 0 } ) = \\Phi ^ { t } ( x _ { i } ) = x _ { i , t }\n$$",
129
+ "text_format": "latex",
130
+ "page_idx": 2
131
+ },
132
+ {
133
+ "type": "text",
134
+ "text": "with an additional simplification of notation using $x _ { i } = x _ { i , 0 }$ , omitting the subscript $t$ when $t = 0$ . ",
135
+ "page_idx": 2
136
+ },
137
+ {
138
+ "type": "text",
139
+ "text": "From these trajectories we may derive our notion of chaos, which concerns the relationship between trajectories with similar initial conditions. Consider $x _ { i }$ , and $x _ { i } + \\delta x$ , where $\\delta x$ is of limited magnitude, and may be contextualized as a subtle reorientation of the arms of a double pendulum prior to setting it into motion. We also require some notion of the distance between two elements of the state space, but we will assume that the space is a vector space equipped with a length or distance metric written with $| \\cdot |$ , and proceed from there. For the initial condition, we may immediately take ",
140
+ "page_idx": 2
141
+ },
142
+ {
143
+ "type": "equation",
144
+ "img_path": "images/d4d2e64d76d45679abacedd8b8c0c591e14ffd83ac3893e92870b591407e90c2.jpg",
145
+ "text": "$$\n\\left| \\Phi ^ { 0 } ( x _ { i } ) - \\Phi ^ { 0 } ( x _ { i } + \\delta x ) \\right| = | \\delta x |\n$$",
146
+ "text_format": "latex",
147
+ "page_idx": 2
148
+ },
149
+ {
150
+ "type": "text",
151
+ "text": "However, meaningful analysis only arises when we model the progression of this difference over time. In some systems, minor differences in the initial condition result in negligible effect, such as with the state of a damped oscillator; regardless of its initial position or velocity, it approaches the resting state as time progresses, and no further activity of significance occurs. However, in some systems, minor differences in the initial condition end up compounding on themselves, like the flaps of a butterfly’s wings eventually resulting in a hurricane. Both of these can be approximately or heuristically modeled by an exponential function, ",
152
+ "page_idx": 2
153
+ },
154
+ {
155
+ "type": "equation",
156
+ "img_path": "images/c5ccf038b8c16c8fc7337216235fa5ae8b4d91cbd9749d2df06c6c0c66c25ace.jpg",
157
+ "text": "$$\n| \\Phi ^ { t } ( x _ { i } ) - \\Phi ^ { t } ( x _ { i } + \\delta x ) | \\approx | \\delta x | e ^ { \\lambda t }\n$$",
158
+ "text_format": "latex",
159
+ "page_idx": 2
160
+ },
161
+ {
162
+ "type": "text",
163
+ "text": "In each of these cases, the growing or shrinking differences between the trajectories are described by $\\lambda$ , also called the Lyapunov exponent. If $\\lambda < 0$ , these differences disappear over time, and the trajectories of two similar initial conditions will eventually align with one another. However, if $\\lambda > 0$ , these differences increase over time, and the trajectories of two similar initial conditions will grow farther and farther apart, with their relationship becoming indistinguishable from that of two trajectories with wholly different initial conditions. This is called \"sensitive dependence,\" and is the mark of a chaotic system.2 It must be noted, however, that the exponential nature of this growth is a shorthand model, with obvious limits, and is not fully descriptive of the underlying behavior. ",
164
+ "page_idx": 2
165
+ },
166
+ {
167
+ "type": "text",
168
+ "text": "2.2 Neural Networks ",
169
+ "text_level": 1,
170
+ "page_idx": 3
171
+ },
172
+ {
173
+ "type": "text",
174
+ "text": "Conventionally, a neural network is given a formulation along the following lines (Schmidhuber, 2015). It is denoted by a function $h : \\Theta \\times X \\to Y$ , where $\\Theta$ is the space of possible learned parameters, subdivided into the entries of multiplicative weight matrices $W _ { l }$ and additive bias vectors $b _ { l }$ . $X$ is the vector space of possible inputs, and $Y$ is the vector space of possible outputs. Each of the $L$ layers in the neural network is given by a matrix multiplication, a bias addition, and the application of a nonlinear activation function $\\sigma$ , with hidden states $z _ { i , l }$ representing the intermediate values taken during the inference operation: ",
175
+ "page_idx": 3
176
+ },
177
+ {
178
+ "type": "equation",
179
+ "img_path": "images/c834e63011ad91a9c648b2c4ba89fbbb3938f006b6d14c8469634f8fa252e5bf.jpg",
180
+ "text": "$$\nz _ { i , 0 } : = x _ { i }\n$$",
181
+ "text_format": "latex",
182
+ "page_idx": 3
183
+ },
184
+ {
185
+ "type": "equation",
186
+ "img_path": "images/386034239272e5dcdc6a29be84b20de8cf97a0f4b308b4d673175d3d8030ca86.jpg",
187
+ "text": "$$\nz _ { i , l + 1 } = \\sigma ( W _ { l } z _ { i , l } + b _ { l } ) | W _ { l } , b _ { l } \\subset \\theta\n$$",
188
+ "text_format": "latex",
189
+ "page_idx": 3
190
+ },
191
+ {
192
+ "type": "equation",
193
+ "img_path": "images/ad899449ef044e7f70f8db5b5f1eb65c2f15425630b1ead4ca3d4cd6c66afc85.jpg",
194
+ "text": "$$\nh ( \\theta ; x _ { i } ) = \\hat { y } _ { i } : = z _ { i , L }\n$$",
195
+ "text_format": "latex",
196
+ "page_idx": 3
197
+ },
198
+ {
199
+ "type": "text",
200
+ "text": "Without loss of generality, we may transcribe this formulation as a dynamical system by taking its components as analogues. The first is $[ L ] = \\{ 0 , 1 , 2 \\ldots L \\}$ , which here will be used to represent the current depth of the hidden state, from 0 for the initial condition up to $L$ for the eventual output. Because it progresses forward during the inference operation, and is associative insofar as increases in depth are additive, $\\lfloor L \\rfloor$ functions as an analogue for $T$ . The second is $Z$ , which is the vector space of all possible hidden states, and thus replaces $X$ . The final component is $g : [ L ] \\times Z \\to Z$ , which here we will write as ",
201
+ "page_idx": 3
202
+ },
203
+ {
204
+ "type": "equation",
205
+ "img_path": "images/564c2643f5e47d75a76472a281a976f9b461180b3b8b7c91906f1047379cb8c8.jpg",
206
+ "text": "$$\nz _ { i , l + 1 } = g ( 1 , z _ { i , l } ) = \\sigma ( W _ { l } z _ { i , l } + b _ { l } )\n$$",
207
+ "text_format": "latex",
208
+ "page_idx": 3
209
+ },
210
+ {
211
+ "type": "text",
212
+ "text": "A further discussion of the function $g$ is given in Appendix A. The generalization to $g ( \\Delta l , z _ { i , l } )$ then follows from the same rule of composition applied to the dynamical systems, at least for integer values of $\\Delta \\boldsymbol { l }$ , under the condition that it never leaves $[ L ]$ . This allows us to replace $\\Phi$ with $g$ . We can also then re-write the notation along the lines of that for the dynamical systems ",
213
+ "page_idx": 3
214
+ },
215
+ {
216
+ "type": "equation",
217
+ "img_path": "images/047e2d93ab87f2c4022119bd87ff2e40934c15814e2e82686fe6398fe9daccbe.jpg",
218
+ "text": "$$\ng ( l , z _ { i , 0 } ) = g ^ { l } ( x _ { i } )\n$$",
219
+ "text_format": "latex",
220
+ "page_idx": 3
221
+ },
222
+ {
223
+ "type": "text",
224
+ "text": "Noting of course that we have defined $z _ { i , 0 }$ as $x _ { i }$ . Thus, the neural network inference operation can be rewritten as the triplet $( [ L ] , Z , g )$ , and mapped to the dynamical system formulation of $( T , X , \\Phi )$ . We can now start to discuss the trajectories of the hidden states of the neural network, and what happens when their inputs are changed slightly. For the first hidden state, defined as the input, we can immediately say that ",
225
+ "page_idx": 3
226
+ },
227
+ {
228
+ "type": "equation",
229
+ "img_path": "images/9d1c5c546bd989311c79168a32b43b91139662ecdd1d4e74c55cb500b9dcb40d.jpg",
230
+ "text": "$$\n| g ^ { 0 } ( x _ { i } ) - g ^ { 0 } ( x _ { i } + \\delta x ) | = | \\delta x |\n$$",
231
+ "text_format": "latex",
232
+ "page_idx": 3
233
+ },
234
+ {
235
+ "type": "text",
236
+ "text": "and then by once again mapping to the dynamical systems perspective, we model the difference between the two trajectories at depth $\\textit { l }$ with ",
237
+ "page_idx": 3
238
+ },
239
+ {
240
+ "type": "equation",
241
+ "img_path": "images/5b96f056b8460ddd02f584924fc44c81a41a891e2a4ddaff2bcf2270fd240528.jpg",
242
+ "text": "$$\n| g ^ { l } ( x _ { i } ) - g ^ { l } ( x _ { i } + \\delta x ) | \\approx | \\delta x | e ^ { \\lambda l }\n$$",
243
+ "text_format": "latex",
244
+ "page_idx": 3
245
+ },
246
+ {
247
+ "type": "text",
248
+ "text": "While, as per the dynamical system, using an exponential model is typically the most illustrative despite the growth not necessarily being exponential, a basic theoretical justification for an exponential model is provided in Appendix B. Continuing, when the value of $\\lambda$ is greater than $0$ , we may call the neural network sensitive to its input, in precisely the same manner as a dynamical system is sensitive to its initial conditions. We may also say that, when the value of $e ^ { \\lambda L }$ is very large, it being the ratio of the magnitude of the change of the output to the magnitude of the change in the input, $\\delta x$ becomes an adversarial perturbation. If this analogy holds, we should expect that when we adversarially attack a neural network, the difference between the two corresponding hidden states should grow as they progress through the model. This is our first experimental result. ",
249
+ "page_idx": 3
250
+ },
251
+ {
252
+ "type": "text",
253
+ "text": "As an aside, there is a tangential connection to be made between the Chaos Theoretic formulation of neural networks and Algorithmic Stability, like that discussed in Kearns & Ron (1997); Bousquet & Elisseeff (2000; 2002) and Hardt et al. (2016). However, while Algorithmic Stability also treats a notion of the effects of small changes in Machine Learning models, this is from the perspective of changes being made to the learning problem itself, such as to the training dataset, and the resulting effects on the learned model, rather than the effects of small changes being made to individual inference inputs and their respective outputs once the model has already been produced. ",
254
+ "page_idx": 3
255
+ },
256
+ {
257
+ "type": "text",
258
+ "text": "3 Experimental Design ",
259
+ "text_level": 1,
260
+ "page_idx": 4
261
+ },
262
+ {
263
+ "type": "text",
264
+ "text": "For our experiments, we used two different model architectures: ResNets (He et al., 2015), as per the default Torchvision implementation (Marcel & Rodriguez, 2010), and a basic custom CNN architecture in order to have finer-grained control over the depth and number of channels in the model. The ResNets were modified, and the custom models built as to allow for recording all of the hidden states during the inference operation. These models, unless specified that they were left untrained, were trained on the Food101 dataset from Bossard et al. (2014) for 50 epochs with a batch size of 64 and a learning rate of 0.0001 with the Adam optimizer against cross entropy loss. The ResNet models used were ResNet18, ResNet34, ResNet50, ResNet101, and ResNet152. ",
265
+ "page_idx": 4
266
+ },
267
+ {
268
+ "type": "text",
269
+ "text": "In the Torchvision ResNet class, models consist of operations named conv1, bn1, relu, maxpool, layer1, layer2, layer3, layer4, avgpool, and $f c$ , with the first four representing a downsampling intake, then four more blocks of ResNet layers, and then a final operation that converts the rank 3 encoding tensor into a rank 1 class weight tensor. Hidden states are recorded at the input, after conv1, layer1, layer2, layer3, layer4, and at the output. ",
270
+ "page_idx": 4
271
+ },
272
+ {
273
+ "type": "text",
274
+ "text": "The custom models, specified with $C$ and $D$ , consist of $D$ tuples of convolutional layers, batch normalization operations, and ReLU nonlinearities, with the first tuple having a downsampling convolution and a maxpool operation after the ReLU. Each of these convolutions, besides the first which takes in three channels, has $C$ channels. Finally, there is a $1 \\times 1$ convolution, a channel-wise averaging, and then a single fully connected layer with 101 outputs, one for each class in the Food-101 dataset. Hidden states are recorded after every tuple, and also include the input and the output of the model. The first tuple approximates the downsampling intake of the ResNet models. ",
275
+ "page_idx": 4
276
+ },
277
+ {
278
+ "type": "text",
279
+ "text": "In order to better handle the high dimensionality and changes in scale of the inputs, outputs, and hidden states, rather than using the Euclidean $L 2$ norm as the distance metric, we used a modified Euclidean distance ",
280
+ "page_idx": 4
281
+ },
282
+ {
283
+ "type": "equation",
284
+ "img_path": "images/f03ffa30971c1246b0632a1e1013b7a6b145bf1e4064555180248faf33df0900.jpg",
285
+ "text": "$$\n| \\vec { v } | : = \\sqrt { \\frac { 1 } { \\mathbf { d i m } ( \\vec { v } ) } \\sum _ { i } v _ { i } ^ { 2 } }\n$$",
286
+ "text_format": "latex",
287
+ "page_idx": 4
288
+ },
289
+ {
290
+ "type": "text",
291
+ "text": "which will be applied for every instance of length and distance of and between hidden states, including attack radii. Adversarial perturbations $\\delta x _ { a d v }$ against a neural network $h ( \\theta ; \\cdot )$ of a given radius $r$ for a given input $x _ { i }$ were generated by using five steps of gradient descent with a learning rate of 0.01, maximizing ",
292
+ "page_idx": 4
293
+ },
294
+ {
295
+ "type": "equation",
296
+ "img_path": "images/030853003a5c593145226a454130c4f140820528c39715485c50896280338bb3.jpg",
297
+ "text": "$$\n\\left| h ( \\theta ; x _ { i } ) - h ( \\theta ; x _ { i } + \\delta x _ { a d v } ) \\right|\n$$",
298
+ "text_format": "latex",
299
+ "page_idx": 4
300
+ },
301
+ {
302
+ "type": "text",
303
+ "text": "and projecting back to the hypersphere of radius $r$ after every update. These attacks closely resemble those in Zhang et al. (2021); Wu et al. (2021b; 2022); Xie et al. (2021) and Shao et al. (2021), and their use of attacks with $l _ { p }$ -norm decay metrics or boundaries. For comparison, random perturbations were also generated, by projecting randomly sampled Gaussian noise to the same hypersphere. In order to perform these experiments under optimal conditions, the inputs that were adversarially perturbed were selected only from the subset of the Food-101 testing set for which every single trained model was correct in its estimate of the Top-1 output class. A Jupyter Notebook implementing these training regimes and attacks will be made available alongside this manuscript, pending review. ",
304
+ "page_idx": 4
305
+ },
306
+ {
307
+ "type": "text",
308
+ "text": "4 Hidden State Drift ",
309
+ "text_level": 1,
310
+ "page_idx": 4
311
+ },
312
+ {
313
+ "type": "text",
314
+ "text": "An example of the approximately exponential growth in the distance between the hidden state trajectories associated with normal and adversarially perturbed inputs hypothesized in section 2.2 for 32 inputs is shown in Figure 2. Between the initial perturbations, generated with a radius of 0.0001, and the outputs, the differences grew by a factor of $\\sim 7 4 7 \\times$ . Given that ResNet18 has 18 layers, using $7 4 7 \\approx e ^ { 1 8 \\lambda }$ , we can calculate $\\lambda \\approx 0 . 3 6 8$ , an average measure of this drift per layer. However, the Lyapunov exponent for each layer is of less interest to an adversarial attacker or defender, with the actual value of interest being given by this new metric, $\\psi$ , the adversarial susceptibility for a particular input and attack, given by ",
315
+ "page_idx": 4
316
+ },
317
+ {
318
+ "type": "equation",
319
+ "img_path": "images/14b2da7c2678a24a9dbf4d934a0d011ea50a1f3675d6b48228631c51e0f05202.jpg",
320
+ "text": "$$\n\\psi ( h , \\theta , x _ { i } , \\delta x _ { a d v } ) : = e ^ { \\lambda L } = \\frac { | h ( \\theta ; x _ { i } ) - h ( \\theta ; x _ { i } + \\delta x _ { a d v } ) | } { | \\delta x _ { a d v } | }\n$$",
321
+ "text_format": "latex",
322
+ "page_idx": 4
323
+ },
324
+ {
325
+ "type": "image",
326
+ "img_path": "images/2d437c17bfd39c0e1ff0f86bfe9a40ba917c8302c50e096357c9e1334ee08630.jpg",
327
+ "image_caption": [
328
+ "Figure 2: Example of hidden state drift while performing inference with the ResNet18 model. Note the logarithmic scaling on the $y$ -axis. "
329
+ ],
330
+ "image_footnote": [],
331
+ "page_idx": 5
332
+ },
333
+ {
334
+ "type": "image",
335
+ "img_path": "images/a39a85b51f239ba8dfada1ef49cd8350732dbbf0e05bd0ab86210ee9b8bead5a.jpg",
336
+ "image_caption": [
337
+ "Figure 3: Despite a change in the radius of the adversarial perturbation by three orders of magnitude, the value of $\\psi$ associated with those attacks remains relatively stable. "
338
+ ],
339
+ "image_footnote": [],
340
+ "page_idx": 5
341
+ },
342
+ {
343
+ "type": "text",
344
+ "text": "This is the \"susceptibility ratio,\" the ratio of the change inflicted by a given adversarial perturbation to its original magnitude. If this is a meaningful metric by which to judge a neural network architecture, it should remain relatively stable despite changes in the radius of the adversarial attack. This is our second experimental result, demonstrated in Figure 3. By sampling $\\psi$ over a number of inputs $x _ { i }$ from a dataset $\\mathcal { D }$ and a variety of attack radii $r _ { m i n } \\le | \\delta x _ { a d v } | \\le r _ { m a x }$ and taking the geometric mean $^ { 3 }$ , we can come to a single value, written as ",
345
+ "page_idx": 5
346
+ },
347
+ {
348
+ "type": "equation",
349
+ "img_path": "images/6dd056287ec7fa07b834c43de8d4999c3b852ffbfb089764a632bdbce46597f9.jpg",
350
+ "text": "$$\n\\Psi ( h , \\theta ) = e ^ { \\mathbb { E } _ { x _ { i } \\sim \\mathcal { D } , | \\delta x _ { a d v } | \\sim [ r _ { m i n } , r _ { m a x } ] } [ \\ln ( \\psi ( h , \\theta , x _ { i } , \\delta x _ { a d v } ) ) ] }\n$$",
351
+ "text_format": "latex",
352
+ "page_idx": 5
353
+ },
354
+ {
355
+ "type": "text",
356
+ "text": "and approximated with $\\hat { \\Psi } ( h , \\theta )$ , giving the susceptibility ratio for the model as a whole. These values have been calculated for the trained ResNet models, and are given in Table 1. These experimental results are more in line with those of Cazenavette et al. (2020) and Huang et al. (2022b) than with the predictions that we will make in the next section, at which point we will begin using our custom model architectures to tease out the relationships between a neural network’s architecture and its susceptibility ratio. A discussion of this metric’s relationship to the Lipschitz constant is provided in Appendix C. ",
357
+ "page_idx": 5
358
+ },
359
+ {
360
+ "type": "table",
361
+ "img_path": "images/8f227ee4c8c356a90f142de12ca4b516dd7cac44b80cf286e8cb26bdf98bf61c.jpg",
362
+ "table_caption": [
363
+ "Table 1: Overall susceptibility ratio of trained ResNet models. "
364
+ ],
365
+ "table_footnote": [],
366
+ "table_body": "<table><tr><td></td><td>ResNet18</td><td>ResNet34</td><td>ResNet50</td><td>ResNet101</td><td>ResNet152</td></tr><tr><td>亚(h,0)</td><td>781.2</td><td>790.7</td><td>854.4</td><td>893.2</td><td>846.5</td></tr></table>",
367
+ "page_idx": 6
368
+ },
369
+ {
370
+ "type": "table",
371
+ "img_path": "images/442a7a6d89aba5243da65f93b5d60a67325f6b7f3a8be5d8d1aee2f31c031289.jpg",
372
+ "table_caption": [],
373
+ "table_footnote": [],
374
+ "table_body": "<table><tr><td colspan=\"5\">重(h,0)</td></tr><tr><td></td><td>32</td><td>Channels (C) 64</td><td>128</td><td>256</td></tr><tr><td>2</td><td>0.749</td><td>0.523</td><td>0.651</td><td>0.560</td></tr><tr><td>4</td><td>1.021</td><td>0.695</td><td>0.775</td><td>0.610</td></tr><tr><td>8</td><td>2.788</td><td>2.134</td><td>1.505</td><td>1.276</td></tr><tr><td>16</td><td>15.491</td><td>12.935</td><td>8.423</td><td>7.123</td></tr><tr><td>(a) s.aner 32</td><td>109.340</td><td>135.472</td><td>98.834</td><td>92.404</td></tr><tr><td>64</td><td>96.037</td><td>63.785</td><td>60.443</td><td>48.721</td></tr></table>",
375
+ "page_idx": 6
376
+ },
377
+ {
378
+ "type": "text",
379
+ "text": "Table 2: Susceptibility ratio of randomly initialized convolutional models with custom architectures on inputs consisting of random noise. ",
380
+ "page_idx": 6
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "5 Architectural Effects on Adversarial Susceptibility ",
385
+ "text_level": 1,
386
+ "page_idx": 6
387
+ },
388
+ {
389
+ "type": "text",
390
+ "text": "Returning to the definition of $\\psi$ given in equation 1, we might model it as being proportional to the exponent of $L$ , the depth of the neural network. Yet, despite ResNet152 having more than eight times as many layers as ResNet18, its susceptibility is only marginally higher. This effect was explored to a greater experimental degree in Cazenavette et al. (2020) and Huang et al. (2022b), demonstrating a remarkable tendency towards robustness in residual model architectures. Interestingly, Huang et al. (2022b) found that deeper models were more robust than wider models, which runs counter to both the experimental and theoretical evidence provided here. Proceeding, this makes the use of an exponential model, at least to explain these experimental results, limited. In order to explore this reasoning further in a more numerically ideal setting, we present our third experimental result, in Table 2, and replicated in Figure 4. Here, using randomly initialized, untrained models with custom architectures as described in the experimental methods section (3), having them perform inference on random inputs, and then adversarially attacking the same models on the same inputs, we can tease apart the relationship between model architecture and the resulting susceptibility ratio, for the case where both parameters and input dimensions are given as Gaussian noise. ",
391
+ "page_idx": 6
392
+ },
393
+ {
394
+ "type": "text",
395
+ "text": "We immediately find an approximately exponential relationship between the susceptibility ratio and the depth of the model that was expected based on equation 1, however the slight dip upon moving from 32 to 64 layers is unexpected, and while exploring its potential causes and implications is outside of the scope of this paper, it may warrant further experimentation and analysis. ",
396
+ "page_idx": 6
397
+ },
398
+ {
399
+ "type": "text",
400
+ "text": "Also of interest is the effect, or lack thereof, of increasing the number of channels in the neural network. While a quadratic increase in the number of parameters in the model might be expected to increase its susceptibility ratio, especially per the theoretical analysis in Huang et al. (2022a), no experiment that we performed yielded such a result. Some theoretical analysis and discussion is provided in Appendix B. ",
401
+ "page_idx": 6
402
+ },
403
+ {
404
+ "type": "text",
405
+ "text": "We repeated the susceptibility ratio measurement on the same model architectures, this time with trained parameters, again sampling the inputs from the Food-101 testing subset for which all models produced correct Top-1 class estimates. These results are in Table 3, and replicated in Figure 5. ",
406
+ "page_idx": 6
407
+ },
408
+ {
409
+ "type": "text",
410
+ "text": "The largest resulting difference is the increase of susceptibility for every model by multiple orders of magnitude. Training the models and switching to an information-rich input domain has resulted in trained models being far more sensitive to attack. Yet, following earlier experiments, we can again see that the number of channels has minimal and unclear effects on the susceptibility ratio of the model, while the number of layers increases it significantly. However, for these experimental results, the relationship between the number of layers and the susceptibility has changed, more closely resembling logarithmic than exponential growth, and somewhat replicates the relationship found between depth and susceptibility among the trained ResNet ",
411
+ "page_idx": 6
412
+ },
413
+ {
414
+ "type": "image",
415
+ "img_path": "images/2fd036eaa559817349a7e770c84cce2d9fb328803b0f85431437abce4de06e53.jpg",
416
+ "image_caption": [
417
+ "Figure 4: Graphical replication of Table 2; susceptibility ratios of models with random weights. "
418
+ ],
419
+ "image_footnote": [],
420
+ "page_idx": 7
421
+ },
422
+ {
423
+ "type": "table",
424
+ "img_path": "images/9648d5192184be6352ff2db428511c9dee3550d6bff092983fcb9cbbcc3a45e2.jpg",
425
+ "table_caption": [],
426
+ "table_footnote": [],
427
+ "table_body": "<table><tr><td colspan=\"5\">重(h,0)</td></tr><tr><td></td><td>32</td><td>Channels (C) 64</td><td>128</td><td>256</td></tr><tr><td></td><td>24 578.602</td><td>610.207</td><td>586.503</td><td>576.759</td></tr><tr><td>(a) s.aker</td><td>1470.399</td><td>1658.209</td><td>1631.561</td><td>1695.993</td></tr><tr><td>8</td><td>2144.418</td><td>2224.467</td><td>2536.745</td><td>2370.648</td></tr><tr><td>16</td><td>2361.251</td><td>2401.381</td><td>2485.030</td><td>2846.418</td></tr><tr><td>32</td><td>3162.568</td><td>3018.758</td><td>2987.640</td><td>3256.967</td></tr><tr><td>64</td><td>2045.765</td><td>2213.575</td><td>3103.335</td><td>2471.823</td></tr></table>",
428
+ "page_idx": 7
429
+ },
430
+ {
431
+ "type": "text",
432
+ "text": "Table 3: Susceptibility ratios of trained custom convolutional models on inputs sampled from Food-101. ",
433
+ "page_idx": 7
434
+ },
435
+ {
436
+ "type": "image",
437
+ "img_path": "images/67e518108d00f4dc43f54da0042530a5ca385214f041c715c3163f8dd3195bd6.jpg",
438
+ "image_caption": [
439
+ "Figure 5: Graphical replication of Table 3; susceptibility ratios of trained models. "
440
+ ],
441
+ "image_footnote": [],
442
+ "page_idx": 7
443
+ },
444
+ {
445
+ "type": "text",
446
+ "text": "models. Interestingly, this is reasonably analogous to the testing accuracy of the models, for which increases in depth yield diminishing returns, and it may be theorized that both of these effects are due to changes in the encoding of information based on model architecture. However, it must be noted that the increase in susceptibility is greater than the increase in accuracy. Making models deeper makes them more vulnerable faster than it makes them more accurate, with additional costs in memory, runtime, and energy consumption. ",
447
+ "page_idx": 8
448
+ },
449
+ {
450
+ "type": "text",
451
+ "text": "6 Relationships to Other Metrics ",
452
+ "text_level": 1,
453
+ "page_idx": 8
454
+ },
455
+ {
456
+ "type": "text",
457
+ "text": "6.1 Approximation of Certified Robustness Radii ",
458
+ "text_level": 1,
459
+ "page_idx": 8
460
+ },
461
+ {
462
+ "type": "text",
463
+ "text": "In the work of Weber et al. (2020) and Li et al. (2020), they attempt to calculate what they refer to as \"certified robustness radii.\" For a model with hard decision boundaries, e.g. a top-1 classification model, its certified robustness radius is the largest value $\\epsilon _ { h }$ such that, for any input $x _ { i }$ and any adversarial perturbation $\\lvert \\delta x _ { a d v } \\rvert$ , the ultimate classification given by the model argm $\\operatorname { u x } _ { c } h ( \\theta ; x _ { i } ) = \\operatorname { a r g m a x } _ { c } h ( \\theta ; x _ { i } + \\delta x _ { a d v } )$ for all perturbations with radius smaller than $\\epsilon _ { h }$ . In their work, however, they state explicitly that these values are highly demanding to calculate for small models, and computationally infeasible for larger models. However, using the susceptibility ratio for a model, one can quickly approximate this certified robustness radius for even very large models. It is simply the distance to the nearest decision boundary, divided by $\\hat { \\Psi } ( h , \\theta )$ . ",
464
+ "page_idx": 8
465
+ },
466
+ {
467
+ "type": "text",
468
+ "text": "We demonstrate with an example: a five-class model outputs the following weights for a given input, $\\hat { y } =$ $\\{ 2 . 1 , 0 . 6 , 0 . 1 , - 0 . 5 , - 1 . 1 \\}$ . Thus, the nearest decision boundary occurs where the first and second classes become equal, at $\\hat { y } ^ { \\prime } = \\{ 1 . 3 5 , 1 . 3 5 , 0 . 1 , - 0 . 5 , - 1 . 1 \\}$ . The modified Euclidean distance between these two vectors is 0.4703. Suppose that thradius would then be estimated as tibility ratio of . One could the $\\hat { \\Psi } = 2 5 . 0$ . Its certified robustnesse mean or minimum over $\\begin{array} { r } { \\hat { \\epsilon } _ { h } = \\frac { 0 . 4 7 0 3 } { 2 5 . 0 } = 0 . 0 1 8 9 7 } \\end{array}$ \nmust be noted that this will produce a substantial overestimate of the actual certified robustness radius, as the susceptibility ratio is a geometric mean rather than a supremum, and is produced via experimental approximation rather than a numerical solution. However, this \"approximated robustness radius\" is also useful in practice, as it provides a much larger radius wherein the associated model is highly probably immune from attack, rather than an extremely small radius wherein the associated model is provably immune from attack. ",
469
+ "page_idx": 8
470
+ },
471
+ {
472
+ "type": "text",
473
+ "text": "Finally, an over-all criticism has to be made regarding the use of these certified robustness radii in general. Consider two models used for a binary classification problem, inferring on the same input, which has been perturbed by adversarial attacks of equal radii. The first model, moving from the vanilla to the adversarial input, changes its output from $\\{ 0 . 9 , 0 . 1 \\}$ to $\\{ 0 . 6 , 0 . 4 \\}$ . The second model, under the same conditions, changes its output from $\\{ 0 . 5 5 , 0 . 4 5 \\}$ to $\\{ 0 . 4 5 , 0 . 5 5 \\}$ . Using a certified robustness radius, it would be concluded that the first model is the more robust, while a more direct reading of the change in probabilities would declare the second model to be more robust. These certified robustness radii represent a dense and inscrutable encoding of information about both the model and the input distribution, such that it can be difficult to use them as a meaningful metric. Consider as a hypothetical if, in the previous example, the first model produced a highly confident output solely because it was significantly overfit, and the underlying domain of the dataset is non-separable near the input. Although this improves its robustness radius, it makes it more susceptible to attack in the field. ",
474
+ "page_idx": 8
475
+ },
476
+ {
477
+ "type": "text",
478
+ "text": "6.2 Post-Adversarial Accuracy ",
479
+ "text_level": 1,
480
+ "page_idx": 8
481
+ },
482
+ {
483
+ "type": "text",
484
+ "text": "One of the existing standard measures of Adversarial Robustness is to measure the accuracy of models on adversarially perturbed inputs. If our analyses and experimental results thus far are correct, we should see an inverse relationship between measured susceptibility ratios and the post-adversarial accuracy for any given attack radius. This is our fourth experimental result, shown in Figure 6. In it, we observe that among ResNets, which possess similar values of $\\hat { \\Psi } ( h , \\theta )$ , post-attack accuracies are close between models, with an approximate but minor correspondence between higher susceptibilities and lower post-attack accuracy. We also observe, among the custom architectures, represented in Figure 6 by the subset of models with 32 channels and in their entirety in Figure 4, a very close inverse relationship between higher susceptibility and lower post-attack accuracy, particularly at the 0.01 attack radius. We also observe that the custom architecture with $D = 2$ , which experimentally had $\\Uparrow = 5 7 8 . 6 0 2$ , has a post-attack accuracy curve that closely resembles those of the ResNet models, each of which had a similar susceptibility. ",
485
+ "page_idx": 8
486
+ },
487
+ {
488
+ "type": "image",
489
+ "img_path": "images/c87780fe451e19988278d488055376b81359364a97c7c0545368f67fdf2e09cc.jpg",
490
+ "image_caption": [
491
+ "Figure 6: Post-Attack Accuracies "
492
+ ],
493
+ "image_footnote": [],
494
+ "page_idx": 9
495
+ },
496
+ {
497
+ "type": "image",
498
+ "img_path": "images/8a1c8b669d055fba6fcf16be02cd9b55f88e0f61608fd9d289d4aca449f77aa6.jpg",
499
+ "image_caption": [
500
+ "Figure 7: Relationship between Adversarial Susceptibility and Post-Attack Accuracy, with a radius of 0.01. Linear best fit shown, with a correlation coefficient of -0.911. "
501
+ ],
502
+ "image_footnote": [],
503
+ "page_idx": 9
504
+ },
505
+ {
506
+ "type": "text",
507
+ "text": "",
508
+ "page_idx": 9
509
+ },
510
+ {
511
+ "type": "text",
512
+ "text": "7 Conclusions and Future Work ",
513
+ "text_level": 1,
514
+ "page_idx": 9
515
+ },
516
+ {
517
+ "type": "text",
518
+ "text": "Our experiments have shown, with some variation due to the inscrutable black-box nature of Deep Learning, that there is an extremely strong, analytically valuable, and experimentally valid connection between neural networks and dynamical systems as they exist in Chaos Theory. This connection can be used to make accurate and meaningful predictions about different neural network architectures, as well as to efficiently measure how susceptible they are to adversarial attacks. We have shown a correspondence, both experimentally and analytically, between these new measurements, and those developed in prior works. Thus, a new tool has been added to the toolbox of practitioners looking to make decisions about neural networks. ",
519
+ "page_idx": 9
520
+ },
521
+ {
522
+ "type": "text",
523
+ "text": "Future work will include further exploration in this area, and the utilization of more advanced techniques and analysis from Chaos Theory, as well as the development of new, more precise metrics that may tell us more about how models are affected by adversarial attacks. Additionally, the relationship between the susceptibility ratio and Adversarial Robustness training regimes deserves study, as well as the relationship with different attack methodologies. ",
524
+ "page_idx": 9
525
+ },
526
+ {
527
+ "type": "text",
528
+ "text": "",
529
+ "page_idx": 10
530
+ },
531
+ {
532
+ "type": "text",
533
+ "text": "References \nKathleen T Alligood, Tim D Sauer, James A Yorke, and David Chillingworth. Chaos: an introduction to dynamical systems. SIAM Review, 40(3):732–732, 1998. \nLukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014. \nOlivier Bousquet and André Elisseeff. Algorithmic stability and generalization performance. Advances in Neural Information Processing Systems, 13, 2000. \nOlivier Bousquet and André Elisseeff. Stability and generalization. The Journal of Machine Learning Research, 2:499–526, 2002. \nYair Carmon, Aditi Raghunathan, Ludwig Schmidt, John C Duchi, and Percy S Liang. Unlabeled data improves adversarial robustness. Advances in Neural Information Processing Systems, 32, 2019. \nGeorge Cazenavette, Calvin Murdock, and Simon Lucey. Architectural adversarial robustness: The case for deep pursuit, 11 2020. \nEuropean Mathematical Society. Lipschitz constant. In Encyclopedia of Mathematics. EMS Press, May 2023. \nIan J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014. \nSven Gowal, Chongli Qin, Jonathan Uesato, Timothy Mann, and Pushmeet Kohli. Uncovering the limits of adversarial training against norm-bounded adversarial examples, 2021. \nMoritz Hardt, Ben Recht, and Yoram Singer. Train faster, generalize better: Stability of stochastic gradient descent. In International conference on machine learning, pp. 1225–1234. PMLR, 2016. \nKaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition, 2015. URL https://arxiv.org/abs/1512.03385. \nWarren He, Bo Li, and Dawn Song. Decision boundary analysis of adversarial examples. In International Conference on Learning Representations, 2018. \nHanxun Huang, Yisen Wang, Sarah Monazam Erfani, Quanquan Gu, James Bailey, and Xingjun Ma. Exploring architectural ingredients of adversarially robust deep neural networks, 2022a. \nShihua Huang, Zhichao Lu, Kalyanmoy Deb, and Vishnu Naresh Boddeti. Revisiting residual networks for adversarial robustness: An architectural perspective, 2022b. \nMichael Kearns and Dana Ron. Algorithmic stability and sanity-check bounds for leave-one-out crossvalidation. In Proceedings of the tenth annual conference on Computational learning theory, pp. 152–162, 1997. \nR. B. Levien and S. M. Tan. Double pendulum: An experiment in chaos. American Journal of Physics, 61(11): 1038–1044, 11 1993. ISSN 0002-9505. doi: 10.1119/1.17335. URL https://doi.org/10.1119/1.17335. \nLinyi Li, Xiangyu Qi, Tao Xie, and Bo Li. Sok: Certified robustness for deep neural networks. arXiv preprint arXiv:2009.04131, 2020. \nSébastien Marcel and Yann Rodriguez. Torchvision the machine-vision package of torch. In Proceedings of the 18th ACM International Conference on Multimedia, MM ’10, pp. 1485–1488, New York, NY, USA, 2010. Association for Computing Machinery. ISBN 9781605589336. doi: 10.1145/1873951.1874254. URL https://doi.org/10.1145/1873951.1874254. \nAnibal Pedraza, Oscar Deniz, and Gloria Bueno. Approaching adversarial example classification with chaos theory. Entropy, 22(11), 2020. ISSN 1099-4300. doi: 10.3390/e22111201. URL https://www.mdpi.com/ 1099-4300/22/11/1201. \nVinay Uday Prabhu, Nishant Desai, and John Whaley. On lyapunov exponents and adversarial perturbation, 2018. URL https://arxiv.org/abs/1802.06927. \nJürgen Schmidhuber. Deep learning in neural networks: An overview. Neural networks, 61:85–117, 2015. \nRulin Shao, Zhouxing Shi, Jinfeng Yi, Pin-Yu Chen, and Cho-Jui Hsieh. On the adversarial robustness of vision transformers. arXiv preprint arXiv:2103.15670, 2021. \nChristian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013. \nYizhen Wang, Somesh Jha, and Kamalika Chaudhuri. Analyzing the robustness of nearest neighbors to adversarial examples. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 5133–5142. PMLR, 10–15 Jul 2018. URL https://proceedings.mlr.press/v80/wang18c.html. \nMaurice Weber, Xiaojun Xu, Bojan Karlaš, Ce Zhang, and Bo Li. Rab: Provable robustness against backdoor attacks. arXiv preprint arXiv:2003.08904, 2020. \nBoxi Wu, Jinghui Chen, Deng Cai, Xiaofei He, and Quanquan Gu. Do wider neural networks really help adversarial robustness?, 2021a. \nFan Wu, Linyi Li, Zijian Huang, Yevgeniy Vorobeychik, Ding Zhao, and Bo Li. Crop: Certifying robust policies for reinforcement learning through functional smoothing. arXiv preprint arXiv:2106.09292, 2021b. \nFan Wu, Linyi Li, Chejian Xu, Huan Zhang, Bhavya Kailkhura, Krishnaram Kenthapadi, Ding Zhao, and Bo Li. Copa: Certifying robust policies for offline reinforcement learning against poisoning attacks. arXiv preprint arXiv:2203.08398, 2022. \nChulin Xie, Minghao Chen, Pin-Yu Chen, and Bo Li. Crfl: Certifiably robust federated learning against backdoor attacks. In International Conference on Machine Learning, pp. 11372–11382. PMLR, 2021. \nChaoning Zhang, Philipp Benz, Chenguo Lin, Adil Karjauv, Jing Wu, and In So Kweon. A survey on universal adversarial attack. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence. International Joint Conferences on Artificial Intelligence Organization, aug 2021. doi: 10. 24963/ijcai.2021/635. URL https://doi.org/10.24963%2Fijcai.2021%2F635. ",
534
+ "page_idx": 10
535
+ },
536
+ {
537
+ "type": "text",
538
+ "text": "",
539
+ "page_idx": 11
540
+ },
541
+ {
542
+ "type": "text",
543
+ "text": "A The function $g$ ",
544
+ "text_level": 1,
545
+ "page_idx": 11
546
+ },
547
+ {
548
+ "type": "text",
549
+ "text": "Because the function only takes $\\Delta \\ell$ and as inputs, and not $\\textit { l }$ itself, a modification must be made in order $g$ $z _ { i , l }$ \nto define $g$ such that it correctly performs the neural network layer layer operation, while still preserving the \nsame formulation as the evolution function $\\Phi ( \\Delta t , x _ { i , t } )$ . This can be achieved by replacing $Z$ with $Z ^ { \\prime }$ , such \nthat ",
550
+ "page_idx": 11
551
+ },
552
+ {
553
+ "type": "equation",
554
+ "img_path": "images/1f96162ab3de666dfb5a704e193019dab7183fdce265f22c567c534c8dba2941.jpg",
555
+ "text": "$$\nZ ^ { \\prime } : = Z \\times \\lbrack L \\rbrack = \\left\\{ \\forall ( z _ { i , l } , l ) \\middle \\vert \\exists l \\in [ L ] \\wedge \\exists z _ { i , l } \\in Z \\right\\}\n$$",
556
+ "text_format": "latex",
557
+ "page_idx": 11
558
+ },
559
+ {
560
+ "type": "text",
561
+ "text": "Then, $g$ is replaced with $g ^ { \\prime } : [ L ] \\times Z ^ { \\prime } \\to Z ^ { \\prime }$ , with ",
562
+ "page_idx": 11
563
+ },
564
+ {
565
+ "type": "equation",
566
+ "img_path": "images/7a82bf0adaa83548d7bad226d0bb84ffd01bdc08e4dff7c4402a62829051cc0a.jpg",
567
+ "text": "$$\ng ^ { \\prime } \\big ( 1 , ( z _ { i , l } , l ) \\big ) : = \\big ( \\sigma ( W _ { l } z _ { i , l } + b _ { l } ) , l + 1 \\big )\n$$",
568
+ "text_format": "latex",
569
+ "page_idx": 11
570
+ },
571
+ {
572
+ "type": "text",
573
+ "text": "Drawing the index of the parameters $W _ { l }$ and $b _ { l }$ to use from the second element of the $\\left( z _ { i , l } , \\ l \\right)$ tuple, which it iterates, and with $g ^ { \\prime }$ then following from recursion. This has no bearing in practice, but helps to align theoretical analysis. ",
574
+ "page_idx": 11
575
+ },
576
+ {
577
+ "type": "text",
578
+ "text": "B Theoretical Basis for Exponential Growth ",
579
+ "text_level": 1,
580
+ "page_idx": 12
581
+ },
582
+ {
583
+ "type": "text",
584
+ "text": "The use of exponential growth to describe sensitive dependence in Chaos Theory is primarily a model rather than a theoretical result, owing to the typically bounded nature of state spaces. A classic Physical example of a chaotic system is the double pendulum (Levien & Tan, 1993), with a state space defined by the set of possible arm angles $X : = [ 0 , 2 \\pi ) \\times [ 0 , 2 \\pi )$ , and therefore a maximum $L 1$ distance of $2 \\pi$ , bounding exponential growth. For a purely Mathematical example of a chaotic system, consider the state space $[ 0 , 1 )$ with the evolution function $\\Phi ( 1 , x ) : = 2 x$ mod 1. The trajectory with an initial condition at $x = 0 . 3 7$ goes 0.74, 0.48, 0.96, 0.92, 0.84, et cetera. Starting with $x = 0 . 3 8$ , it goes 0.76, 0.52, 0.04, 0.08, 0.16, et cetera. The distance between the two trajectories is bounded at 0.5, but starting with a distance of 0.01, it grew to 0.32 in only 5 time steps, for this period having a Lyanpunov exponent of $\\ln ( 2 ) = 0 . 6 9 3$ ; positive, and therefore chaotic. With this caveat in mind, a neural network can, to a finite degree and for a temporary period, be expected to produce exponential growth in the hidden state drift of two similar inputs. ",
585
+ "page_idx": 12
586
+ },
587
+ {
588
+ "type": "text",
589
+ "text": "B.1 Random Matrices ",
590
+ "text_level": 1,
591
+ "page_idx": 12
592
+ },
593
+ {
594
+ "type": "text",
595
+ "text": "Consider a first-order approximation of a neural network which removes the nonlinear activation functions and biases, rendering it a product of matrices. Let us define these to be $d \\times d$ real-valued square matrices $W _ { l } \\in \\mathbb { R } ^ { d \\times d }$ , and let us make the simplifying assumption that these are random matrices with i.i.d. univariate Gaussian entries $w _ { l _ { i j } } \\sim \\mathcal { N } ( \\mu = 0 , \\sigma ^ { 2 } = 1 )$ ). Next we define a product accumulator matrix $\\begin{array} { r } { H _ { L } : = \\prod _ { l = 0 } ^ { L } W _ { l } } \\end{array}$ with elements $\\eta _ { L _ { i j } }$ . We will also rely on the following: summing distributions sums their means and variances, and the product of two zero-mean distributions has a variance equal to the product of the variances of its constituents. ",
596
+ "page_idx": 12
597
+ },
598
+ {
599
+ "type": "text",
600
+ "text": "For the first two weight matrices $W _ { 1 }$ and $W _ { 0 }$ with elements $w _ { 1 _ { i j } }$ and $w _ { 0 _ { i j } }$ , and defining ",
601
+ "page_idx": 12
602
+ },
603
+ {
604
+ "type": "equation",
605
+ "img_path": "images/a8d51f02e6169e44bf54fa38139896cf295504dccb915e12b69f0e342f2cdd66.jpg",
606
+ "text": "$$\n\\eta _ { 1 _ { i j } } = \\sum _ { k = 1 } ^ { d } w _ { 1 _ { i k } } w _ { 0 _ { k j } }\n$$",
607
+ "text_format": "latex",
608
+ "page_idx": 12
609
+ },
610
+ {
611
+ "type": "text",
612
+ "text": "we get that σ2η1ij and $\\mu _ { \\eta _ { 1 _ { i j } } } ^ { 2 } = 0$ . Taking the recursion $H _ { L + 1 } = W _ { L + 1 } H _ { L }$ , we get ",
613
+ "page_idx": 12
614
+ },
615
+ {
616
+ "type": "equation",
617
+ "img_path": "images/8c371f252baf004ad6f29cbde565c45a2eda5e470146510a158bc4f688018c40.jpg",
618
+ "text": "$$\n\\eta _ { L + 1 _ { i j } } = \\sum _ { k = 1 } ^ { d } w _ { L + 1 _ { i k } } \\eta _ { L _ { k j } }\n$$",
619
+ "text_format": "latex",
620
+ "page_idx": 12
621
+ },
622
+ {
623
+ "type": "text",
624
+ "text": "with σ2ηL+1ij $\\sigma _ { \\eta _ { L + 1 _ { i j } } } ^ { 2 } ~ = ~ d \\sigma _ { \\eta _ { L _ { i j } } } ^ { 2 }$ = dσ2ηLij and µ2ηL+1ij√ $\\mu _ { \\eta _ { L + 1 _ { i j } } } ^ { 2 } ~ = ~ 0$ . Trivially, this resolves to $\\sigma _ { \\eta _ { L _ { i j } } } ^ { 2 } = d ^ { L }$ , additionally giving us a standard deviation σηLij $\\sigma _ { \\eta _ { L _ { i j } } } = \\sqrt { d ^ { L } } = d ^ { L / 2 }$ . This reduces the accumulator matrix parameter distribution to $\\eta _ { L _ { i j } } \\sim \\mathcal { N } ( \\mu = 0 , \\sigma ^ { 2 } = d ^ { L } )$ , and the multiplication of a vector $x _ { s }$ by $H _ { L }$ becomes multiplication by a univariate Gaussian random matrix, and then by $d ^ { L / 2 }$ , given by $d ^ { L / 2 } W _ { 0 } x _ { s }$ . Substituting out $x _ { s }$ for $x _ { s } + \\delta x$ , this gives us $d ^ { L / 2 } W _ { 0 } ( x _ { s } + \\delta x )$ , and finally $H _ { L } x _ { s } - H _ { L } ( x _ { s } + \\delta x ) = - H _ { L } \\delta x$ , thus ",
625
+ "page_idx": 12
626
+ },
627
+ {
628
+ "type": "equation",
629
+ "img_path": "images/89cef4c5bedc91873429f4b83080da27a95970604cd5f7636bf55f0260cf5268.jpg",
630
+ "text": "$$\n{ \\frac { | H _ { L } x _ { s } - H _ { L } ( x _ { s } + \\delta x ) | } { | \\delta x | } } = d ^ { L / 2 } = e ^ { \\ln ( d ) L / 2 }\n$$",
631
+ "text_format": "latex",
632
+ "page_idx": 12
633
+ },
634
+ {
635
+ "type": "text",
636
+ "text": "which is an exponential increase in the distance between the trajectories of $x _ { s }$ and $x _ { s } + \\delta x$ , returning to the earlier dynamical systems formulation. ",
637
+ "page_idx": 12
638
+ },
639
+ {
640
+ "type": "text",
641
+ "text": "B.2 Activation Function ",
642
+ "text_level": 1,
643
+ "page_idx": 12
644
+ },
645
+ {
646
+ "type": "text",
647
+ "text": "If we may assume that we know the vector $x _ { s }$ beforehand, inserting ReLU activations between each matrix multiplication becomes equivalent to substituting a 0 for each entry in a vector that is being sequentially multiplied by each matrix, itself being equivalent to preserving the vector and instead substituting a 0 for each entry in the associated columns. Because all of the Gaussian distributions discussed have been zero mean, and the probability of a Gaussian being greater than or less than its mean is always 0.5, this gives us, relying on positive/negative symmetries, that each entry in the resulting vector may equivalently be sampled as ",
648
+ "page_idx": 12
649
+ },
650
+ {
651
+ "type": "text",
652
+ "text": "",
653
+ "page_idx": 13
654
+ },
655
+ {
656
+ "type": "equation",
657
+ "img_path": "images/207cf40cae32c5b87928f6b6c126cb6091a8c3611582f1c83b0b1c551b09335b.jpg",
658
+ "text": "$$\n{ x _ { s , l } } _ { i } = \\sum _ { k = 1 } ^ { d } \\sim { w _ { l } } _ { i k } { x _ { s , l } } _ { k } \\cdot \\mathrm { B e r n } ( p = 0 . 5 )\n$$",
659
+ "text_format": "latex",
660
+ "page_idx": 13
661
+ },
662
+ {
663
+ "type": "text",
664
+ "text": "which has the effect of halving the number of dimensions that contributed to , in essence lowering $d$ to $x _ { s , l _ { i } }$ d/2, and further decreasing the growth of the trajectory distance from eln(d)L/2 to eln(d/2)L/2. ",
665
+ "page_idx": 13
666
+ },
667
+ {
668
+ "type": "text",
669
+ "text": "B.3 Batch Normalization ",
670
+ "text_level": 1,
671
+ "page_idx": 13
672
+ },
673
+ {
674
+ "type": "text",
675
+ "text": "Consider a set of vectors that all have some existing magnitude and per-dimension standard deviation from one another. After a normalization step which subtracts out their mean and divides per-dimension by the standard deviation, the resulting vectors will have a mean of 0 and a standard deviation of 1. This resets any growth that they may previously have had away from one another. If a set of vectors including $x _ { i , 0 }$ has a standard deviation of 1, and each element thereof is multiplied by $W _ { 0 }$ with a ReLU activation applied, such that the set of vectors that includes $x _ { i , 1 }$ has a standard deviation of $\\sqrt { d / 2 }$ , the normalization step will result in division by that factor. The effect of this is to curtail the spatially infinite growth of each vector as each neural network layer is applied. Trajectories will still diverge from one another, and the dynamics of the underlying system is such that small changes will still compound, e.g. one entry with a value of 0.01 will have propagating and compounding effects compared to an entry with a value of -0.01, which will simply be erased by ReLU. But it places restrictions on the otherwise infinite possible growth, much like the domain boundaries of the double pendulum or the $\\Phi ( 1 , x ) : = 2 x$ mod 1 system discussed earlier. ",
676
+ "page_idx": 13
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "C Adversarial Susceptibility and the Lipschitz Constant ",
681
+ "text_level": 1,
682
+ "page_idx": 13
683
+ },
684
+ {
685
+ "type": "text",
686
+ "text": "The Lipschitz constant M (European Mathematical Society, 2023) is defined for a function $f : X \\to Y$ as ",
687
+ "page_idx": 13
688
+ },
689
+ {
690
+ "type": "equation",
691
+ "img_path": "images/7c4482e6ca1a302c7a341c2fa4fc5010ce74995c576f06d04bb7bdeed79b43fc.jpg",
692
+ "text": "$$\nM ( f ) : = \\operatorname* { s u p } _ { ( x _ { i } , x _ { j } ) \\in X \\times X \\mid x _ { i } \\neq x _ { j } } { \\frac { | f ( x _ { i } ) - f ( x _ { j } ) | } { | x _ { i } - x _ { j } | } }\n$$",
693
+ "text_format": "latex",
694
+ "page_idx": 13
695
+ },
696
+ {
697
+ "type": "text",
698
+ "text": "This possesses a close ontological relationship in formulation to the susceptibility ratio, as defined in equations 1 and 2. They both describe a rate of change of a function’s output with respect to its input. However, while this relationship is obvious, there are several points of differentiation. The susceptibility ratio is a numerically estimated geometric mean, whereas the Lipschitz constant is a global maximum, which cannot be produced analytically for Deep neural networks. Additionally, whereas the Lipschitz constant is a tool of Analysis, the susceptibility ratio is a construct of combining the Chaos Theoretic Lyanpunov exponent with a constant time horizon. ",
699
+ "page_idx": 13
700
+ }
701
+ ]
parse/test/lPw8Xdzw5f/lPw8Xdzw5f_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/lPw8Xdzw5f/lPw8Xdzw5f_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/oKn9c6ytLx/oKn9c6ytLx.md ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # WE BAR E N A: A REALISTIC WEB ENVIRONMENT FOR BUILDING AUTONOMOUS AGENTS
2
+
3
+ Shuyan Zhou∗ Frank F. $\mathbf { X } \mathbf { u } ^ { * }$ Hao Zhu † Xuhui Zhou† Robert Lo† Abishek Sridhar† Xianyi Cheng Tianyue Ou Yonatan Bisk Daniel Fried Uri Alon Graham Neubig
4
+
5
+ Carnegie Mellon University {shuyanzh, fangzhex, gneubig}@cs.cmu.edu
6
+
7
+ # ABSTRACT
8
+
9
+ With advances in generative AI, there is now potential for autonomous agents to manage daily tasks via natural language commands. However, current agents are primarily created and tested in simplified synthetic environments, leading to a disconnect with real-world scenarios. In this paper, we build an environment for language-guided agents that is highly realistic and reproducible. Specifically, we focus on agents that perform tasks on the web, and create an environment with fully functional websites from four common domains: e-commerce, social forum discussions, collaborative software development, and content management. Our environment is enriched with tools (e.g., a map) and external knowledge bases (e.g., user manuals) to encourage human-like task-solving. Building upon our environment, we release a set of benchmark tasks focusing on evaluating the functional correctness of task completions. The tasks in our benchmark are diverse, long-horizon, and designed to emulate tasks that humans routinely perform on the internet. We experiment with several baseline agents, integrating recent techniques such as reasoning before acting. The results demonstrate that solving complex tasks is challenging: our best GPT-4-based agent only achieves an end-to-end task success rate of $1 4 . 4 1 \%$ , significantly lower than the human performance of $7 8 . 2 4 \%$ . These results highlight the need for further development of robust agents, that current state-of-the-art large language models are far from perfect performance in these real-life tasks, and that WebArena can be used to measure such progress. Our code, data, environment reproduction resources, and video demonstrations are publicly available at https://webarena.dev/.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Autonomous agents that perform everyday tasks via human natural language commands could significantly augment human capabilities, improve efficiency, and increase accessibility. Nonetheless, to fully leverage the power of autonomous agents, it is crucial to understand their behavior within an environment that is both authentic and reproducible. This will allow measurement of the ability of agents on tasks that human users care about in a fair and consistent manner.
14
+
15
+ Current environments for evaluate agents tend to over-simplify real-world situations. As a result, the functionality of many environments is a limited version of their real-world counterparts, leading to a lack of task diversity (Shi et al., 2017; Anderson et al., 2018; Gordon et al., 2018; Misra et al., 2016; Shridhar et al., 2020; 2021; Yao et al., 2022a). In addition, these simplifications often lower the complexity of tasks as compared to their execution in the real world (Puig et al., 2018; Shridhar et al., 2020; Yao et al., 2022a). Finally, some environments are presented as a static resource (Shi et al., 2017; Deng et al., 2023) where agents are confined to accessing only those states that were previously cached during data collection, thus limiting the breadth and diversity of exploration. For evaluation, many environments focus on comparing the textual surface form of the predicted action sequences with reference action sequences, disregarding the functional correctness of the executions and possible alternative solutions (Puig et al., 2018; Jernite et al., 2019; Xu et al., 2021; Li et al., 2020; Deng et al., 2023). These limitations often result in a discrepancy between simulated environments and the real world, and can potentially impact the generalizability of AI agents to successfully understand, adapt, and operate within complex real-world situations.
16
+
17
+ ![](images/cf45426703ea246ad839ecfea50c8fb3fe60081248cbfa6523a082150268549d.jpg)
18
+ Figure 1: WebArena is a standalone, self-hostable web environment for building autonomous agents. WebArena creates websites from four popular categories with functionality and data mimicking their real-world equivalents. To emulate human problem-solving, WebArena also embeds tools and knowledge resources as independent websites. WebArena introduces a benchmark on interpreting high-level realistic natural language command to concrete web-based interactions. We provide validators to programmatically validate the functional correctness of each task.
19
+
20
+ We introduce WebArena, a realistic and reproducible web environment designed to facilitate the development of autonomous agents capable of executing tasks (§2). An overview of WebArena is in Figure 1. Our environment comprises four fully operational, self-hosted web applications, each representing a distinct domain prevalent on the internet: online shopping, discussion forums, collaborative development, and business content management. Furthermore, WebArena incorporates several utility tools, such as map, calculator, and scratchpad, to best support possible human-like task executions. Lastly, WebArena is complemented by an extensive collection of documentation and knowledge bases that vary from general resources like English Wikipedia to more domain-specific references, such as manuals for using the integrated development tool (Fan et al., 2022). The content populating these websites is extracted from their real-world counterparts, preserving the authenticity of the content served on each platform. We deliver the hosting services using Docker containers with gym-APIs (Brockman et al., 2016), ensuring both the usability and the reproducibility of WebArena.
21
+
22
+ Along with WebArena, we release a ready-to-use benchmark with 812 long-horizon web-based tasks (§3). Each task is described as a high-level natural language intent, emulating the abstract language usage patterns typically employed by humans (Bisk et al., 2019). Two example intents are shown in the upper left of Figure 1. We focus on evaluating the functional correctness of these tasks, i.e., does the result of the execution actually achieve the desired goal (§3.2). For instance, to evaluate the example in Figure 2, our evaluation method verifies the concrete contents in the designated repository. This evaluation is not only more reliable (Zhong et al., 2017; Chen et al., 2021; Wang et al., 2022) than comparing the textual surface-form action sequences (Puig et al., 2018; Deng et al., 2023) but also accommodate a range of potential valid paths to achieve the same goal, which is a ubiquitous phenomenon in sufficiently complex tasks.
23
+
24
+ We use this benchmark to evaluate several agents that can follow NL command and perform webbased tasks $( \ S 4 )$ . These agents are implemented in a few-shot in-context learning fashion with powerful large language models (LLMs) such as GPT-4 and PALM-2. Experiment results show that the best GPT-4 agent performance is somewhat limited, with an end-to-end task success rate of only $1 4 . 4 1 \%$ , while the human performance is $7 8 . 2 4 \%$ . We hypothesize that the limited performance of current LLMs stems from a lack of crucial capabilities such as active exploration and failure recovery to successfully perform complex tasks (§5.1). These outcomes underscore the necessity for further development towards robust and effective agents (LeCun, 2022) in WebArena.
25
+
26
+ # 2 WE BAR E N A: WEBSITES AS AN ENVIRONMENT FOR AUTONOMOUS AGENTS
27
+
28
+ Our goal is to create a realistic and reproducible web environment. We achieve reproducibility by making the environment standalone, without relying on live websites. This circumvents technical challenges such as bots being subject to CAPTCHAs, unpredictable content modifications, and configuration changes, which obstruct a fair comparison across different systems over time. We achieve realism by using open-source libraries that underlie many in-use sites from several popular categories and importing data to our environment from their real-world counterparts.
29
+
30
+ ![](images/bd48369ddd165a24409b6b9a14bc4e880e18c513494a95c0adacc90d7018f6e0.jpg)
31
+ Create an efficient itinerary to visit all of Pittsburgh's art museums with minimal driving distance “ starting from Schenley Park. Log the order in my “awesome-northeast-us-travel” repository
32
+ Figure 2: A high-level task that can be fully executed in WebArena. Success requires sophisticated, long-term planning and reasoning. To accomplish the goal (top), an agent needs to (1) find Pittsburgh art museums on Wikipedia, (2) identify their locations on a map (while optimizing the itinerary), and (3) update the README file in the appropriate repository with the planned route.
33
+
34
+ # 2.1 CONTROLLING AGENTS THROUGH HIGH-LEVEL NATURAL LANGUAGE
35
+
36
+ The WebArena environment is denoted as ${ \mathcal { E } } { = \langle { S , A , \mathcal { O } } , { \mathcal { T } } \rangle }$ with state space $s$ , action space $\mathcal { A } ( \ S 2 . 4 )$ and observation space $\mathcal { O }$ (§2.3). The transition function $\mathcal { T } : \mathcal { S } \times \mathcal { A } \longrightarrow \mathcal { S }$ is deterministic, and it is defined by the underlying implementation of each website in the environment. Given a task described as a natural language intent $\mathbf { i }$ , an agent issues an action $a _ { t } \in \mathcal A$ based on intent i, the current observation $o _ { t } \in \mathcal { O }$ , the action history $\mathbf { a } _ { 1 } ^ { \overline { { t } } - 1 }$ and the observation history ot−11 . Consequently, the action results in a new state $s _ { t + 1 } \in S$ and its corresponding observation $o _ { t + 1 } \in \mathcal { O }$ . We propose a reward function $r ( \mathbf { a } _ { 1 } ^ { T } , \mathbf { s } _ { 1 } ^ { T } )$ to measure the success of a task execution, where $\mathbf { a } _ { 1 } ^ { T }$ represents the sequence of actions from start to the end time step $T$ , and $\mathbf { s } _ { 1 } ^ { T }$ denotes all intermediate states. This reward function assesses if state transitions align with the expectations of the intents. For example, with an intent to place an order, it verifies whether an order has been placed. Additionally, it evaluates the accuracy of the agent’s actions, such as checking the correctness of the predicted answer.
37
+
38
+ # 2.2 WEBSITE SELECTION
39
+
40
+ To decide which categories of websites to use, we first analyzed approximately 200 examples from the authors’ actual web browser histories. Each author delved into their browsing histories, summarizing the goal of particular segments of their browser session. Based on this, we classified the visited websites into abstract categories. We then identified the four most salient categories and implemented one instance per category based on this analysis: (1) E-commerce platforms supporting online shopping activities (e.g., Amazon, eBay), (2) social forum platforms for opinion exchanges (e.g., Reddit, StackExchange), (3) collaborative development platforms for software development (e.g., GitLab), and (4) content management systems (CMS) that manage the creation and revision of the digital content (e.g., online store management).
41
+
42
+ In addition to these platforms, we selected three utility-style tools that are frequently used in webbased tasks: (1) a map for navigation and searching for information about points of interest (POIs) such as institutions or locations (2) a calculator, and (3) a scratchpad for taking notes. As informationseeking and knowledge acquisition are critical in web-based tasks, we also incorporated various knowledge resources into WebArena. These resources range from general information hubs, such as the English Wikipedia, to more specialized knowledge bases, such as the website user manuals.
43
+
44
+ Implementation We leveraged open-source libraries relevant to each category to build our own versions of an E-commerce website (OneStopShop), GitLab, Reddit, an online store content management system (CMS), a map, and an English Wikipedia. Then we imported sampled data from their real-world counterparts. As an example, our version of GitLab was developed based on the actual GitLab project.1 We carefully emulated the features of a typical code repository by including both popular projects with many issues and pull requests and smaller, personal projects. Details of all websites in WebArena can be found in Appendix A.1. We deliver the environment as dockers and provide scripts to reset the environment to a deterministic initial state (See Appendix A.2).
45
+
46
+ ![](images/1068d1a1ee72c29ec9f17a0ef21a7f95136c5a91919766c035f7767b73bd1f9b.jpg)
47
+ Figure 3: We design the observation to be the URL and the content of a web page, with options to represent the content as a screenshot (left), HTML DOM tree (middle), and accessibility tree (right). The content of the middle and right figures are trimmed to save space.
48
+
49
+ # 2.3 OBSERVATION SPACE
50
+
51
+ We design the observation space to roughly mimic the web browser experience: a web page URL, the opened tabs , and the web page content of the focused tab. WebArena is the first web environment to consider multi-tab web-based tasks to promote tool usage, direct comparisons and references across tabs, and other functionalities. The multi-tab functionality offers a more authentic replication of human web browsing habits compared to maintaining everything in a single tab. We provide flexible configuration to render the page content in many modes: (see Figure 3 for an example): (1) the raw web page HTML, composed of a Document Object Model (DOM) tree, as commonly used in past work (Shi et al., 2017; Deng et al., 2023; Li et al., 2020); (2) a screenshot, a pixel-based representation that represents the current web page as an RGB array and (3) the accessibility tree of the web page.2 The accessibility tree is a subset of the DOM tree with elements that are relevant and useful for displaying the contents of a web page. Every element is represented as its role (e.g., a link), its text content, and its properties (e.g., whether it is focusable). Accessibility trees largely retain the structured information of a web page while being more compact than the DOM representation.
52
+
53
+ We provide an option to limit the content to the contents within a viewport for all modes. This ensures that the observation can be input into a text-based model with limited context length or an image-based model with image size or resolution requirements.
54
+
55
+ # 2.4 ACTION SPACE
56
+
57
+ Following previous work on navigation and operation in web and embodied environments (Shi et al., 2017; Liu et al., 2018), we design a compound action space that emulates the keyboard and mouse operations available on web pages. Figure 4 lists all the available actions categorized into three distinct groups. The first group includes element operations such as clicking, hovering, typing, and key combination pressing. The second comprises tab-related actions such as opening, closing, and switching between tabs. The third category consists of URL navigation actions, such as visiting a specific URL or navigating forward and backward in the browsing history.
58
+
59
+ Building on these actions, WebArena provides agents with the flexibility to refer to elements for operation in different ways. An element can be selected by its on-screen coordinates, $( x , y )$ , or by a unique element ID that is prepended to each element. This ID is generated when traversing the Document Object Model (DOM) or accessibility tree. With element IDs, the element selection is transformed into an $n$ -way classification problem, thereby eliminating any disambiguation efforts required from the agent or the underlying implementation. For example, issuing the action click [1582] clicks the button given the observation of [1582] Add to Cart. This flexible element selection allows WebArena to support agents designed in various ways (e.g., accepting input from different modalities) without compromising fair comparison metrics such as step count.
60
+
61
+ Figure 4: Action Space of WebArena
62
+
63
+ <table><tr><td>Action Type noop</td><td>Description Do nothing</td></tr><tr><td>click(elem) hover (elem) type(elem,text) press(key_comb) scroll(dir)</td><td>Click at an element Hover on an element Type to an element Press a key comb Scroll up and down</td></tr><tr><td>tab_focus(index) new_tab tab_close</td><td>focus on i-th tab Open a new tab Close current tab</td></tr><tr><td>go_back go_forward goto(URL)</td><td>Visit the last URL Undo go_back Go to URL</td></tr></table>
64
+
65
+ Figure 5: Example intents from three categories.
66
+
67
+ <table><tr><td>Category</td><td>Example</td></tr><tr><td rowspan="2">Information Seeking</td><td>When was the last time I bought shampoo</td></tr><tr><td>Compare walking and driving time from AMC Waterfront to Randyland</td></tr><tr><td rowspan="2">Site Navigation</td><td>Checkout merge requests assigned to me</td></tr><tr><td>Show me the ergonomic chair with the best rating</td></tr><tr><td rowspan="2">Content &amp; Config</td><td>Post to ask“whetherIneed a car in NYC&quot;</td></tr><tr><td>Delete the reviews from the scammer Yoke</td></tr></table>
68
+
69
+ User Role Simulation Users of the same website often have disparate experiences due to their distinct roles, permissions, and interaction histories. We emulate this scenario by generating unique user profiles on each platform. The details can be found in Appendix A.3.
70
+
71
+ # 3 BENCHMARK SUITE OF WEB-BASED TASKS
72
+
73
+ We provide a benchmark with 812 test examples on grounding high-level natural language instructions to interactions in WebArena. Each example has a metric to evaluate the functional correctness of the task execution. In this section, we first formally define the task of controlling an autonomous agent through natural language. Then we introduce the annotation process of our benchmark.
74
+
75
+ # 3.1 INTENT COLLECTION
76
+
77
+ We focus on curating realistic intents to carry out complex and creative tasks within WebArena. To start with, our annotators were guided to spend a few minutes exploring the websites to familiarize themselves with the websites’ content and functionalities. As most of our websites are virtually identical to their open-web counterparts, despite having sampled data, most annotators can quickly comprehend the websites.
78
+
79
+ Next, we instructed the annotators to formulate intents based on the following criteria:
80
+
81
+ (1) The intent should be abstract and high-level, implying that the task cannot be fulfilled with merely one or two actions. As an example, instead of “click the science subreddit”, we encouraged annotators to come up with something more complex like “post a greeting message on science subreddit”, which involves performing multiple actions.
82
+ (2) The intent should be creative. Common tasks such as account creation can be easily thought of. We encouraged the annotators to add constraints (e.g., “create a Reddit account identical to my GitLab one”) to make the intents more unique.
83
+ (3) The intent should be formulated as a template by making replaceable elements as variables. The annotators were also responsible for developing several instantiations for each variable. For example, the intent “create a Reddit account identical to my GitLab one” can be converted into “create a {{site1}} account identical to my {{site2}} one”, with an instantiation like “{site1: Reddit, site2: GitLab}” and another like “{site1: GitLab, site2: OneStopShopping}”. Notably, tasks derived from the same template can have distinct execution traces. The similarity resides primarily in the high-level semantics rather than the specific implementation.
84
+
85
+ We also provided a prompt for the annotators to use with ChatGPT3 for inspiration, that contains an overview of each website and instructs the model to describe potential tasks to be performed on these sites. Furthermore, we offered a curated list of examples for annotators to reference.
86
+
87
+ Intent Analysis In total, we curated 241 templates and 812 instantiated intents. On average, each template is instantiated to 3.3 examples. The intent distribution is shown in Figure 6. Furthermore, we classify the intents into three primary categories with examples shown in Figure 5:
88
+
89
+ (1) Information-seeking tasks expect a textual response. Importantly, these tasks in WebArena often require navigation across multiple pages or focus on user-centric content. This makes them distinct from open-domain question-answering (Yang et al., 2018; Kwiatkowski et al., 2019), which focuses on querying general knowledge with a simple retrieval step. For instance, to answer “When was the last time I bought the shampoo”, an agent traverses the user’s purchase history, checking order details to identify the most recent shampoo purchase.
90
+ (2) Site navigation: This category is composed of tasks that require navigating through web pages using a variety of interactive elements such as search functions and links. The objective is often to locate specific information or navigate to a particular section of a site.
91
+ (3) Content and configuration operation: This category encapsulates tasks that require operating in the web environment to create, revise, or configure content or settings. This includes adjusting settings, managing accounts, performing online transactions, generating new web content, and modifying existing content. Examples range from updating a social media status or README file to conducting online purchases and configuring privacy settings.
92
+
93
+ # 3.2 EVALUATION ANNOTATION
94
+
95
+ Evaluating Information Seeking Tasks To measure the correctness of information-seeking tasks where a textual answer is expected, we provide the annotated answer $a ^ { * }$ for each intent. The $a ^ { * }$ is further compared with the predicted answer $\hat { a }$ with one of the following scoring functions $r _ { \mathrm { i n f o } } ( \hat { a } , a ^ { * } )$
96
+
97
+ First, we define exact_match where only $\hat { a }$ that is identical with $a ^ { * }$ receives a score of one. This function is primarily applicable to intent types whose responses follow a more standardized format, similar to the evaluation on question answering literature (Rajpurkar et al., 2016; Yang et al., 2018).
98
+
99
+ Second, we create must_include where any $\hat { a }$ containing $a ^ { * }$ receives a score of one. This function is primarily used in when an unordered list of text is expected or where the emphasis of evaluation is on certain key concepts. In the second example in Table 1, we expect both the correct name and the email address to be presented, irrespective of the precise wording used to convey the answer.
100
+
101
+ Finally, we introduce fuzzy_match where we utilize a language model to assess whether $\hat { a }$ is semantically equivalent to $a ^ { * }$ . Specifically, in this work, we use $\mathtt { g p t - 4 - 0 6 1 3 }$ to perform this evaluation. The corresponding prompt details are provided in Appendix A.7. The fuzzy_match function applies to situations where the format of the answer is diverse. For instance, in responding to “Compare the time for walking and driving route from AMC Waterfront to Randyland”, it is essential to ensure that driving time and walking time are accurately linked with the correct terms. The fuzzy_match function could also flexibly match the time $\cdot 2 \mathrm { h } 5 8 \mathrm { m i n } ^ { \cdot \prime }$ with different forms such as $^ { 6 6 } 2$ hour 58 minutes”, $\overline { { 2 } } { : } 5 8 ^ { 3 }$ and others. We demonstrate a language model can achieve nearly perfect performance on this task in $\ S \mathrm { A } . 8$ .
102
+
103
+ Evaluating Site Navigation and Content & Config Tasks The tasks in these categories require accessing web pages that meet certain conditions or performing operations that modify the underlying data storage of the respective websites. To assess these, we establish reward functions $r _ { \mathrm { p r o g } } ( \mathbf { s } )$ that programmatically examine the intermediate states s within an execution trajectory to ascertain whether the outcome aligns with the intended result. These intermediate states are often the underlying databases of the websites, the status, and the content of a web page at each step of the execution.
104
+
105
+ Evaluating each instance involves two components. First, we provide a locator, tasked with retrieving the critical content pertinent to each intent. The implementation of this locator varies from a database query, a website-supported API call, to a JavaScript element selection on the relevant web page, depending on implementation feasibility. For example, the evaluation process for the intent of the fifth example in Table 1, first obtains the URL of the latest post by examining the last state in the state sequence s. Then it navigates to the corresponding post page and obtains the post’s content by running the Javascript “document.querySelector(‘.submission__inner’).outerText”.
106
+
107
+ Subsequently, we annotate keywords that need to exist within the located content. For example, the evaluation verifies if the post is correctly posted in the “nyc” subreddit by examining the URL of the post and if the post contains the requested content by examining the post content. We reuse the exact_match and must_include functions from information-seeking tasks for this purpose.
108
+
109
+ <table><tr><td>Function</td><td>ID</td><td>Intent</td><td>Eval Implementation</td></tr><tr><td rowspan="3">Tinfo(a*,a)</td><td>1</td><td>Tell me the name of the customer who has the most cancellations in the history</td><td>exact_mat ch(@,“Samantha Jones&quot;)</td></tr><tr><td>2</td><td>emaie</td><td>must_include(a,&quot;Sean Mimal.om&quot;)</td></tr><tr><td>3</td><td> ComAMcWlkinfrond driindyimnd</td><td>fuzzy_mat ch(a, “driving: 2h5minm)</td></tr><tr><td rowspan="2">Tprog(s)</td><td>4</td><td>Checkout merge requests assigned to me</td><td>url=locate_current_url(s) exact_match (URL,&quot;gitlab.com/merge_ requests?assignee_username=byteblaze&quot;)</td></tr><tr><td>5</td><td>Postdo ask &quot;whter I</td><td> must_include (body,&quot;a carin NYC&quot;)</td></tr></table>
110
+
111
+ Table 1: We introduce two evaluation approaches. $r _ { \mathrm { i n f o } }$ (top) measures the correctness of performing information-seeking tasks. It compares the predicted answer $\hat { a }$ with the annotated reference $a ^ { * }$ with three implementations. $r _ { \mathrm { p r o g } }$ (bottom) programmatically checks whether the intermediate states during the executions possess the anticipated properties specified by the intent.
112
+
113
+ Unachievable Tasks Due to constraints such as inadequate evidence, user permissions (§A.3), or the absence of necessary functional support on the website, humans may ask for tasks that are not possible to complete. Inspired by previous work on evaluating question-answering models on unanswerable questions (Rajpurkar et al., 2018), we design unachievable tasks in WebArena. For instance, fulfilling an intent like “Tell me the contact number of OneStopShop” is impracticable in WebArena, given that the website does not provide such contact information. We label such instances as "N/A" and expect an agent to produce an equivalent response. These examples allow us to assess an agent’s ability to avoid making unfounded claims and its adherence to factual accuracy.
114
+
115
+ Annotation Process The intents were contributed by the authors following the annotation guideline in $\ S 3 . 1$ . Every author has extensive experience with web-based tasks. The reference answers to the information-seeking tasks were curated by the authors and an external annotator. To ensure consistency and accuracy, each question was annotated twice. If the two annotators disagreed, a third annotator finalized the annotation. The programs to evaluate the remaining examples were contributed by three of the authors who are proficient in JavaScript programming. Difficult tasks were often discussed collectively to ensure the correctness of the annotation. The annotation required the annotator to undertake the full execution and scrutinize the intermediate states.
116
+
117
+ Human Performance We sample one task from each of the 170 templates and ask five computer science graduate students to perform these tasks. The human performance is on the right. Overall, the human annotators complete $7 8 . 2 4 \%$ of the tasks, with lower performance on information-seeking tasks. Through examining the recorded trajectories, we found that $50 \%$ of the failures are due to misinterpreting the intent (e.g., providing travel distance when asked for travel time), incomplete answers (e.g., providing only name when asked for name and email), and incomplete executions (e.g., partially filling the product information), while the remaining instances have more severe failures, where the executions are off-target. More discussions on human annotations can be found in $\ S _ { \mathrm { A } . 5 }$ .
118
+
119
+ <table><tr><td>Avg. Time</td><td>110s</td></tr><tr><td>Success Rateinfo</td><td>74.68%</td></tr><tr><td>Success Rateothers 81.32%</td><td></td></tr><tr><td>Success Rateall</td><td>78.24%</td></tr></table>
120
+
121
+ # 4 BASELINE WEB AGENTS
122
+
123
+ We experiment with three LLMs using two prompting strategies, both with two examples in the context. In the first setting, we ask the LLM to directly predict the next action given the current observation, the intent and the previously performed action. In the second setting, with the same information, the model first performs chain-of-thought reasoning steps in the text before the action prediction (CoT, Wei et al. (2022); Yao et al. (2022b)). Before the examples, we provide a detailed overview of the browser environment, the allowed actions, and many rules. To make the model aware of the unachievable tasks, the instruction explicitly asks the agent to stop if it believes the task is impossible to perform. We refer to this directive as Unachievable hint, or UA hint. This introduction is largely identical to the guidelines we presented to human annotators to ensure a fair comparison. We use an accessibility tree with element IDs as the observation space. The agent can identify which element to interact with by the ID of the element. For instance, the agent can issue click [1582] to click the “Add to Cart” button with the ID of 1582. The full prompts can be found in Appendix A.9. The detailed configurations of each model can be found in Appendix A.6.
124
+
125
+ # 5 RESULTS
126
+
127
+ The main results are shown on the top of Table 2. GPT-4 (OpenAI, 2023) with CoT prompting achieves a modest end-to-end task success rate of $1 1 . 7 0 \%$ , which is significantly lower than the human performance of $7 8 . 2 4 \%$ . GPT-3.5 (OpenAI, 2022) with CoT prompting is only able to successfully perform $8 . 7 5 \%$ of the tasks. The explicit reasoning procedure is somewhat helpful, it brings $2 . 3 4 \%$ improvement over the version without it. Further, TEXT-BISON-001 (Anil et al., 2023) underperforms GPT-3.5, with a success rate of $5 . 0 5 \%$ . These results underline the inherent challenges and complexities of executing tasks that span long horizons, particularly in realistic environments such as WebArena.
128
+
129
+ Table 2: The end-to-end task success rate $( \mathrm { S R } \% )$ on WebArena with different prompting strategies. CoT: the model performs step-by-step reasoning before issuing the action. UA hint: ask the model to stop when encountering unachievable questions.
130
+
131
+ <table><tr><td>CoT UA Hint</td><td></td><td>Model</td><td>SR</td><td>SRAC</td><td>SRUA</td></tr><tr><td>√</td><td></td><td>TEXT-BISON-001</td><td>5.05</td><td>4.00</td><td>27.78</td></tr><tr><td>×</td><td></td><td>GPT-3.5</td><td>6.41</td><td>4.90</td><td>38.89</td></tr><tr><td>√</td><td>√</td><td>GPT-3.5</td><td>8.75</td><td>6.44</td><td>58.33</td></tr><tr><td></td><td></td><td>GPT-4</td><td>11.70</td><td>8.63</td><td>77.78</td></tr><tr><td>×</td><td>xx</td><td>GPT-3.5</td><td>5.10</td><td>4.90</td><td>8.33</td></tr><tr><td></td><td></td><td>GPT-3.5</td><td>6.16</td><td>6.06</td><td>8.33</td></tr><tr><td></td><td>×</td><td>GPT-4</td><td>14.41</td><td>13.02</td><td>44.44</td></tr><tr><td></td><td></td><td>Human</td><td>78.24</td><td>77.30</td><td>100.00</td></tr></table>
132
+
133
+ # 5.1 ANALYSIS
134
+
135
+ Do models know when to stop? In our error analysis of the execution trajectories, we observe a prevalent error pattern of early stopping due to the model’s conclusion of unachievability. For instance, GPT-4 erroneously identifies $5 4 . 9 \%$ of feasible tasks as impossible. This issue primarily stems from the UA hint in the instruction, while this hint allows models to identify unachievable tasks, it also hinders performance on achievable tasks. To address this, we conduct an ablation study where we remove this hint. We then break down the success rate for both achievable and unachievable tasks. As shown in Table 2, eliminating this instruction led to a performance boost in achievable tasks, enhancing the overall task success rate of GPT-4 to $1 4 . 4 1 \%$ . Despite an overall decline in identifying unachievable tasks, GPT-4 retains the capacity to recognize $4 4 . 4 4 \%$ of such tasks. It does so by generating reasons of non-achievability, even without explicit instructions. On the other hand, GPT-3.5 rarely exhibits this level of reasoning. Instead, it tends to follow problematic patterns such as hallucinating incorrect answers, repeating invalid actions, or exceeding the step limits. This result suggests that even subtle differences in instruction design can significantly influence the behavior of a model in performing interactive tasks in complex environments.
136
+
137
+ Can a model maintain consistent performance across similar tasks? Tasks that originate from the same template usually follow similar reasoning and planning processes, even though their observations and executions will differ. We plot a histogram of per-template success rates for our models in Table 3. Of the 61 templates, GPT-4 manages to achieve a $100 \%$ task success rate on only four templates, while GPT-3.5 fails to achieve full task completion for any of the templates. In many cases, the models are only able to complete one task variation with a template. These observations indicate that even when tasks are derived from the same template, they can present distinct challenges. For instance, while “Fork metaseq” can be a straightforward task, “Fork all repos from Facebook” derived from the same template requires more repetitive operations, hence increasing its complexity. Therefore, WebArena provide a testbed to evaluate more sophisticated methods. In particular, those that incorporate memory components,
138
+
139
+ ![](images/9bf8b7ebd2568942bb66bb4d2794d06828dcfcd7159ab75b1b9c44342ed6afa7.jpg)
140
+ Table 3: Distribution of success rates on templates with $\geq 1$ successful executions on GPT models (no UA hint).
141
+
142
+ <table><tr><td>Benchmark</td><td>Dyramio?</td><td>Envraistent?</td><td>HuDineras?</td><td>Functional?</td></tr><tr><td>Mind2WoB (3)</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>xx/</td><td></td><td></td><td>xx</td></tr><tr><td>MiniWoB++</td><td>(Liu et al., 2018)</td><td>√</td><td>//x</td><td></td><td></td></tr><tr><td>Webshop</td><td>(Yao et al., 2022a)</td><td></td><td></td><td></td><td></td></tr><tr><td>ALFRED</td><td>(Shridhar et al.,2020)</td><td></td><td>×</td><td>//xxx/</td><td></td></tr><tr><td>VirtualHome</td><td>(Puig et al., 2018)</td><td></td><td></td><td></td><td>X</td></tr><tr><td>AndroidEnv</td><td>(Toyama et al., 2021)</td><td></td><td></td><td>X</td><td>X</td></tr><tr><td colspan="2">WebArena</td><td></td><td>√</td><td>√</td><td></td></tr></table>
143
+
144
+ Table 4: The comparison between our benchmark and existing benchmarks on grounding natural language instructions to concrete executions. Our benchmark is implemented in our fully interactable highly-realistic environment. It features diverse tasks humans may encounter in their daily routines. We design evaluation metrics to assess the functional correctness of task executions.
145
+
146
+ enabling the reuse of successful strategies from past experiments Zhou et al. (2022a); Wang et al.
147
+ (2023). More error analysis with examples can be found in Appendix A.10.
148
+
149
+ # 6 RELATED WORK
150
+
151
+ Benchmarks for Controlling Agents through Natural Language Controlling agents via natural language in the digital world have been studied in the literature (Branavan et al., 2009; Shi et al., 2017; Liu et al., 2018; Toyama et al., 2021; Deng et al., 2023; Li et al., 2020; Xu et al., 2021). However, the balance between functionality, authenticity, and support for environmental dynamics remains a challenge. Existing benchmarks often compromise these aspects, as shown in Table 4. Some works rely on static states, limiting agents’ explorations and functional correctness evaluation (Shi et al., 2017; Deng et al., 2023), while others simplify real-world complexities, restricting task variety (Yao et al., 2022a; Liu et al., 2018). While AndroidEnv (Toyama et al., 2021) replicates an Android setup, it does not guarantee the reproducibility since live Android applications are used. (Kolve et al., 2017; Shridhar et al., 2020; Puig et al., 2018) and extends to gaming environments (Fan et al., 2022; Küttler et al., 2020), where the environment mechanisms often diverge from human objectives.
152
+
153
+ Interactive Decision-Making Agents Nakano et al. (2021) introduce WebGPT which searches the web and reads the search results to answer questions. Gur et al. (2023) propose a web agent that synthesizes Javascript code for the task executions. Adding a multi-modal dimension, Lee et al. (2023) and Shaw et al. (2023) develop agents that predict actions based on screenshots of web pages rather than relying on the text-based DOM trees. Performing tasks in interactive environments requires the agents to exhibit several capabilities including hierarchical planning, state tracking, and error recovery. Existing works (Huang et al., 2022; Madaan et al., 2022; Li et al., 2023) observe LLMs could break a task into more manageable sub-tasks (Zhou et al., 2022b). This process can be further refined by representing task executions as programs, a technique that aids sub-task management and skill reuse (Zhou et al., 2022a; Liang et al., 2023; Wang et al., 2023; Gao et al., 2023). Meanwhile, search and backtracking methods introduce a more structured approach to planning while also allowing for decision reconsideration (Yao et al., 2023; Long, 2023). Existing works also incorporate failure recovery, self-correction (Shinn et al., 2023; Kim et al., 2023), observation summarization (Sridhar et al., 2023) to improve execution robustness. The complexity of WebArena presents a unique challenge and opportunity for further testing and improvement of these methods.
154
+
155
+ # 7 CONCLUSION
156
+
157
+ We present WebArena, a highly-realistic, standalone, and reproducible web environment designed for the development and testing of autonomous agents. WebArena includes fully functional web applications and organic data from popular domains. Additionally, we curate a comprehensive benchmark consisting of 812 examples that focus on mapping high-level natural language intents into concrete web interactions. We also offer outcome-based evaluation that programmatically validate the tasks success. Our experiments show that even GPT-4 only achieves a limited end-to-end task success rate of $1 4 . 4 1 \%$ , significantly lagging behind the human performance of $7 8 . 2 4 \%$ . These findings underscore the need for future research to focus on enhancing the robustness and efficacy of autonomous agents within WebArena environment.
158
+
159
+ # ACKNOWLEDGEMENT
160
+
161
+ We would like to thank Emmy Liu, Zhiruo Wang, Zhitong Guo for examining our annotations, Shunyu Yao for providing the raw Amazon product data in Webshop, Pengfei Liu, Zaid Sheikh and Aman Madaan for the helpful discussions. We are also grateful to the Center for AI Safety for providing computational resources. This material is partly based on research sponsored in part by the Air Force Research Laboratory under agreement number FA8750-19-2-0200. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the Air Force Research Laboratory or the U.S. Government. This project was also partially supported by a gift from AWS AI.
162
+
163
+ # REFERENCES
164
+
165
+ Peter Anderson, Qi Wu, Damien Teney, Jake Bruce, Mark Johnson, Niko Sünderhauf, Ian D. Reid, Stephen Gould, and Anton van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18- 22, 2018, pp. 3674–3683. IEEE Computer Society, 2018. doi: 10.1109/CVPR.2018.00387. URL http://openaccess.thecvf.com/content_cvpr_2018/html/Anderson_ Vision-and-Language_Navigation_Interpreting_CVPR_2018_paper.html.
166
+ Rohan Anil, Andrew M. Dai, Orhan Firat, Melvin Johnson, Dmitry Lepikhin, Alexandre Passos, Siamak Shakeri, Emanuel Taropa, Paige Bailey, Zhifeng Chen, Eric Chu, Jonathan H. Clark, Laurent El Shafey, Yanping Huang, Kathy Meier-Hellstern, Gaurav Mishra, Erica Moreira, Mark Omernick, Kevin Robinson, Sebastian Ruder, Yi Tay, Kefan Xiao, Yuanzhong Xu, Yujing Zhang, Gustavo Hernandez Abrego, Junwhan Ahn, Jacob Austin, Paul Barham, Jan Botha, James Bradbury, Siddhartha Brahma, Kevin Brooks, Michele Catasta, Yong Cheng, Colin Cherry, Christopher A. Choquette-Choo, Aakanksha Chowdhery, Clément Crepy, Shachi Dave, Mostafa Dehghani, Sunipa Dev, Jacob Devlin, Mark Díaz, Nan Du, Ethan Dyer, Vlad Feinberg, Fangxiaoyu Feng, Vlad Fienber, Markus Freitag, Xavier Garcia, Sebastian Gehrmann, Lucas Gonzalez, Guy Gur-Ari, Steven Hand, Hadi Hashemi, Le Hou, Joshua Howland, Andrea Hu, Jeffrey Hui, Jeremy Hurwitz, Michael Isard, Abe Ittycheriah, Matthew Jagielski, Wenhao Jia, Kathleen Kenealy, Maxim Krikun, Sneha Kudugunta, Chang Lan, Katherine Lee, Benjamin Lee, Eric Li, Music Li, Wei Li, YaGuang Li, Jian Li, Hyeontaek Lim, Hanzhao Lin, Zhongtao Liu, Frederick Liu, Marcello Maggioni, Aroma Mahendru, Joshua Maynez, Vedant Misra, Maysam Moussalem, Zachary Nado, John Nham, Eric Ni, Andrew Nystrom, Alicia Parrish, Marie Pellat, Martin Polacek, Alex Polozov, Reiner Pope, Siyuan Qiao, Emily Reif, Bryan Richter, Parker Riley, Alex Castro Ros, Aurko Roy, Brennan Saeta, Rajkumar Samuel, Renee Shelby, Ambrose Slone, Daniel Smilkov, David R. So, Daniel Sohn, Simon Tokumine, Dasha Valter, Vijay Vasudevan, Kiran Vodrahalli, Xuezhi Wang, Pidong Wang, Zirui Wang, Tao Wang, John Wieting, Yuhuai Wu, Kelvin Xu, Yunhan Xu, Linting Xue, Pengcheng Yin, Jiahui Yu, Qiao Zhang, Steven Zheng, Ce Zheng, Weikang Zhou, Denny Zhou, Slav Petrov, and Yonghui Wu. Palm 2 technical report, 2023.
167
+ Yonatan Bisk, Jan Buys, Karl Pichotta, and Yejin Choi. Benchmarking hierarchical script knowledge. 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. 4077–4085, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1412. URL https://aclanthology.org/N19-1412.
168
+ S.R.K. Branavan, Harr Chen, Luke Zettlemoyer, and Regina Barzilay. Reinforcement learning for mapping instructions to actions. In Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP, pp. 82–90, Suntec, Singapore, 2009. Association for Computational Linguistics. URL https://aclanthology.org/P09-1010.
169
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym, 2016. URL https://arxiv.org/abs/1606.01540.
170
+
171
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. ArXiv preprint, abs/2107.03374, 2021. URL https://arxiv.org/abs/2107. 03374.
172
+
173
+ Xiang Deng, Yu Gu, Boyuan Zheng, Shijie Chen, Samuel Stevens, Boshi Wang, Huan Sun, and Yu Su. Mind2web: Towards a generalist agent for the web, 2023.
174
+
175
+ Linxi Fan, Guanzhi Wang, Yunfan Jiang, Ajay Mandlekar, Yuncong Yang, Haoyi Zhu, Andrew Tang, De-An Huang, Yuke Zhu, and Anima Anandkumar. Minedojo: Building open-ended embodied agents with internet-scale knowledge. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022. URL https://openreview.net/forum? id=rc8o_j8I8PX.
176
+
177
+ Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. Pal: Program-aided language models. In International Conference on Machine Learning, pp. 10764–10799. PMLR, 2023.
178
+
179
+ Daniel Gordon, Aniruddha Kembhavi, Mohammad Rastegari, Joseph Redmon, Dieter Fox, and Ali Farhadi. IQA: visual question answering in interactive environments. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018, pp. 4089–4098. IEEE Computer Society, 2018. doi: 10.1109/CVPR. 2018.00430. URL http://openaccess.thecvf.com/content_cvpr_2018/html/ Gordon_IQA_Visual_Question_CVPR_2018_paper.html.
180
+
181
+ Izzeddin Gur, Hiroki Furuta, Austin Huang, Mustafa Safdari, Yutaka Matsuo, Douglas Eck, and Aleksandra Faust. A real-world webagent with planning, long context understanding, and program synthesis. arXiv preprint arXiv:2307.12856, 2023.
182
+
183
+ Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zeroshot planners: Extracting actionable knowledge for embodied agents. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato (eds.), International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 9118–9147. PMLR, 2022. URL https://proceedings.mlr.press/v162/huang22a.html.
184
+
185
+ Yacine Jernite, Kavya Srinet, Jonathan Gray, and Arthur Szlam. CraftAssist Instruction Parsing: Semantic Parsing for a Minecraft Assistant. ArXiv preprint, abs/1905.01978, 2019. URL https: //arxiv.org/abs/1905.01978.
186
+
187
+ Geunwoo Kim, Pierre Baldi, and Stephen McAleer. Language models can solve computer tasks. ArXiv preprint, abs/2303.17491, 2023. URL https://arxiv.org/abs/2303.17491.
188
+
189
+ Eric Kolve, Roozbeh Mottaghi, Winson Han, Eli VanderBilt, Luca Weihs, Alvaro Herrasti, Daniel Gordon, Yuke Zhu, Abhinav Gupta, and Ali Farhadi. AI2-THOR: An Interactive 3D Environment for Visual AI. arXiv, 2017.
190
+
191
+ Heinrich Küttler, Nantas Nardelli, Alexander H. Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The nethack learning environment. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and HsuanTien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.neurips.cc/paper/2020/hash/ 569ff987c643b4bedf504efda8f786c2-Abstract.html.
192
+
193
+ Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: A benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:452–466, 2019. doi: 10.1162/tacl_a_00276. URL https://aclanthology.org/Q19-1026.
194
+
195
+ Yann LeCun. A path towards autonomous machine intelligence version 0.9. 2, 2022-06-27. Open Review, 62, 2022.
196
+
197
+ Kenton Lee, Mandar Joshi, Iulia Raluca Turc, Hexiang Hu, Fangyu Liu, Julian Martin Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, and Kristina Toutanova. Pix2struct: Screenshot parsing as pretraining for visual language understanding. In International Conference on Machine Learning, pp. 18893–18912. PMLR, 2023.
198
+
199
+ Xinze Li, Yixin Cao, Muhao Chen, and Aixin Sun. Take a break in the middle: Investigating subgoals towards hierarchical script generation. ArXiv preprint, abs/2305.10907, 2023. URL https://arxiv.org/abs/2305.10907.
200
+
201
+ Yang Li, Jiacong He, Xin Zhou, Yuan Zhang, and Jason Baldridge. Mapping natural language instructions to mobile UI action sequences. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 8198–8210, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.729. URL https: //aclanthology.org/2020.acl-main.729.
202
+
203
+ Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, and Andy Zeng. Code as policies: Language model programs for embodied control. In 2023 IEEE International Conference on Robotics and Automation (ICRA), pp. 9493–9500. IEEE, 2023.
204
+
205
+ Evan Zheran Liu, Kelvin Guu, Panupong Pasupat, Tianlin Shi, and Percy Liang. Reinforcement learning on web interfaces using workflow-guided exploration. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id= ryTp3f-0-.
206
+
207
+ Jieyi Long. Large language model guided tree-of-thought. ArXiv preprint, abs/2305.08291, 2023. URL https://arxiv.org/abs/2305.08291.
208
+
209
+ Aman Madaan, Shuyan Zhou, Uri Alon, Yiming Yang, and Graham Neubig. Language models of code are few-shot commonsense learners. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 1384–1403, Abu Dhabi, United Arab Emirates, 2022. Association for Computational Linguistics. URL https://aclanthology.org/ 2022.emnlp-main.90.
210
+
211
+ Dipendra K Misra, Jaeyong Sung, Kevin Lee, and Ashutosh Saxena. Tell me dave: Context-sensitive grounding of natural language to manipulation instructions. The International Journal of Robotics Research, 35(1-3):281–300, 2016.
212
+
213
+ Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021.
214
+
215
+ OpenAI. Chatgpt: Optimizing language models for dialogue. 2022.
216
+
217
+ OpenAI. Gpt-4 technical report. arXiv, pp. 2303–08774, 2023.
218
+
219
+ Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35: 27730–27744, 2022.
220
+
221
+ Xavier Puig, Kevin Ra, Marko Boben, Jiaman Li, Tingwu Wang, Sanja Fidler, and Antonio Torralba. Virtualhome: Simulating household activities via programs. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018, pp. 8494–8502. IEEE Computer Society, 2018. doi: 10.1109/CVPR. 2018.00886. URL http://openaccess.thecvf.com/content_cvpr_2018/html/ Puig_VirtualHome_Simulating_Household_CVPR_2018_paper.html.
222
+
223
+ Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264. URL https://aclanthology.org/D16-1264.
224
+
225
+ Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for SQuAD. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 784–789, Melbourne, Australia, 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-2124. URL https://aclanthology. org/P18-2124.
226
+
227
+ Peter Shaw, Mandar Joshi, James Cohan, Jonathan Berant, Panupong Pasupat, Hexiang Hu, Urvashi Khandelwal, Kenton Lee, and Kristina Toutanova. From pixels to ui actions: Learning to follow instructions via graphical user interfaces. arXiv preprint arXiv:2306.00245, 2023.
228
+
229
+ Tianlin Shi, Andrej Karpathy, Linxi Fan, Jonathan Hernandez, and Percy Liang. World of bits: An open-domain platform for web-based agents. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, volume 70 of Proceedings of Machine Learning Research, pp. 3135– 3144. PMLR, 2017. URL http://proceedings.mlr.press/v70/shi17a.html.
230
+
231
+ Noah Shinn, Beck Labash, and Ashwin Gopinath. Reflexion: an autonomous agent with dynamic memory and self-reflection. ArXiv preprint, abs/2303.11366, 2023. URL https://arxiv. org/abs/2303.11366.
232
+
233
+ Mohit Shridhar, Jesse Thomason, Daniel Gordon, Yonatan Bisk, Winson Han, Roozbeh Mottaghi, Luke Zettlemoyer, and Dieter Fox. ALFRED: A benchmark for interpreting grounded instructions for everyday tasks. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pp. 10737–10746. IEEE, 2020. doi: 10. 1109/CVPR42600.2020.01075. URL https://doi.org/10.1109/CVPR42600.2020. 01075.
234
+
235
+ Mohit Shridhar, Xingdi Yuan, Marc-Alexandre Côté, Yonatan Bisk, Adam Trischler, and Matthew J. Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum?id= 0IOX0YcCdTn.
236
+
237
+ Abishek Sridhar, Robert Lo, Frank F Xu, Hao Zhu, and Shuyan Zhou. Hierarchical prompting assists large language model on web navigation. arXiv preprint arXiv:2305.14257, 2023.
238
+
239
+ Daniel Toyama, Philippe Hamel, Anita Gergely, Gheorghe Comanici, Amelia Glaese, Zafarali Ahmed, Tyler Jackson, Shibl Mourad, and Doina Precup. Androidenv: A reinforcement learning platform for android. ArXiv preprint, abs/2105.13231, 2021. URL https://arxiv.org/abs/2105. 13231.
240
+
241
+ Guanzhi Wang, Yuqi Xie, Yunfan Jiang, Ajay Mandlekar, Chaowei Xiao, Yuke Zhu, Linxi Fan, and Anima Anandkumar. Voyager: An open-ended embodied agent with large language models. ArXiv preprint, abs/2305.16291, 2023. URL https://arxiv.org/abs/2305.16291.
242
+
243
+ Zhiruo Wang, Shuyan Zhou, Daniel Fried, and Graham Neubig. Execution-based evaluation for open-domain code generation. ArXiv preprint, abs/2212.10481, 2022. URL https://arxiv. org/abs/2212.10481.
244
+
245
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35:24824–24837, 2022.
246
+
247
+ Nancy Xu, Sam Masling, Michael Du, Giovanni Campagna, Larry Heck, James Landay, and Monica Lam. Grounding open-domain instructions to automate web support tasks. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 1022–1032, Online, 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.80. URL https://aclanthology.org/ 2021.naacl-main.80.
248
+
249
+ Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2369–2380, Brussels, Belgium, 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1259. URL https://aclanthology.org/D18-1259.
250
+ Shunyu Yao, Howard Chen, John Yang, and Karthik Narasimhan. Webshop: Towards scalable real-world web interaction with grounded language agents. volume abs/2207.01206, 2022a. URL https://arxiv.org/abs/2207.01206.
251
+ Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. ArXiv preprint, abs/2210.03629, 2022b. URL https://arxiv.org/abs/2210.03629.
252
+ Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. ArXiv preprint, abs/2305.10601, 2023. URL https://arxiv.org/abs/2305.10601.
253
+ Victor Zhong, Caiming Xiong, and Richard Socher. Seq2sql: Generating structured queries from natural language using reinforcement learning. arxiv 2017. ArXiv preprint, abs/1709.00103, 2017. URL https://arxiv.org/abs/1709.00103.
254
+ Shuyan Zhou, Pengcheng Yin, and Graham Neubig. Hierarchical control of situated agents through natural language. In Proceedings of the Workshop on Structured and Unstructured Knowledge Integration (SUKI), pp. 67–84, Seattle, USA, 2022a. Association for Computational Linguistics. doi: 10.18653/v1/2022.suki-1.8. URL https://aclanthology.org/2022.suki-1.8.
255
+ Shuyan Zhou, Li Zhang, Yue Yang, Qing Lyu, Pengcheng Yin, Chris Callison-Burch, and Graham Neubig. Show me more details: Discovering hierarchies of procedures from semi-structured web data. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2998–3012, Dublin, Ireland, 2022b. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.214. URL https://aclanthology.org/ 2022.acl-long.214.
256
+
257
+ # A APPENDIX
258
+
259
+ # A.1 WEBSITE IMPLEMENTATION
260
+
261
+ Given the selected websites described in $\ S 2 . 2$ , we make the best attempt to reproduce the functionality of commonly used sites in a reproducible way. To achieve this, we utilized open-source frameworks for the development of the websites across various categories and imported data from their real-world counterparts. For the E-commerce category, we constructed a shopping website with approximately $9 0 k$ products, including the prices, options, detailed product descriptions, images, and reviews, spanning over 300 product categories. This website is developed using Adobe Magento, an opensource e-commerce platform4. Data resources were obtained from data from actual online sites, such as that included in the Webshop data dumpYao et al. (2022a). As for the social forum platform, we deployed an open-source software Postmill5, the open-sourced counterpart of Reddit6. We sampled from the top 50 subreddits7. We then manually selected many subreddit for northeast US cities as well as subreddit for machine learning and deep learning-related topics. This manual selection encourages cross-website tasks such as seeking information related to the northeast US on both Reddit and the map. In total, we have 95 subreddits, 127390 posts, and 661781 users. For the collaborative software development platform, we choose GitLab8. We heuristically simulate the code repository characteristics by sampling at least ten repositories for every programming language: $8 0 \%$ of them are sampled from the set of top 90 percentile wrt stars repos using a discrete probability distribution weighted proportional to their number of stars; the remaining are sampled from the bottom ten percentile set using similar weighted distribution. This is done to ensure fair representation of repos of all kinds, from popular projects with many issues and pull requests to small personal projects. In total, we have 300 repositories and more than 1000 accounts with at least one commit to a repository. For the content management system, we adapted Adobe Magento’s admin portal, deploying the sample data provided in the official guide. We employ OpenStreetMap9 for map service implementation, confining our focus to the northeast US region due to data storage constraints. We implement a calculator and a scratchpad ourselves.
262
+
263
+ Lastly, we configure the knowledge resources as individual websites, complemented with search functionality for efficient information retrieval. Specifically, we utilize Kiwix10 to host an offline version of English Wikipedia with a knowledge cutoff of May 2023. The user manuals for GitLab and Adobe Commerce Merchant documentation are scraped from the official websites.
264
+
265
+ # A.2 ENVIRONMENT DELIVERY AND RESET
266
+
267
+ One goal for our evaluation environment is ease of use and reproducibility. As a result, we deploy our websites in separate Docker images 11, one per website. The Docker images are fully self-contained with all the code of the website, database, as well as any other software dependencies. They also do not rely on external volume mounts to function, as the data of the websites are also part of the docker image. This way, the image is easy to distribution containing all the pre-populated websites for reproducible evaluation. End users can download our packaged Docker images and run them on their systems and re-deploy the exact websites together with the data used in our benchmarks for their local benchmarking.
268
+
269
+ Since some evaluation cases may require the agent to modify the data contained in the website, e.g., creating a new user, deleting a post, etc., it is crucial to be able to easily reset the website environment to its initial state. With Docker images, the users could stop and delete the currently running containers for that website and start the container from our original image again to fully reset the environment to the initial state. Depending on the website, this process may take from a few seconds to one minute. However, not all evaluation cases would require an environment reset, as many of the intents are information gathering and are read-only for the website data. Also, combined with the inference time cost for the agent LLMs, we argue that this environment reset method, through restarting Docker containers from the original images, will have a non-negligible but small impact on evaluation time.
270
+
271
+ ![](images/4453eb3ed727d83d96dd9d746537edaeb5c408cd69d1d382d35aee15bcd026d7.jpg)
272
+ Figure 6: The intent distribution across different websites. Cross-site intents necessitate interacting with multiple websites. Notably, regardless of the website, all user intents require interactions with multiple web pages.
273
+
274
+ # A.3 USER ROLES SIMULATION
275
+
276
+ Users of the same website often have disparate experiences due to their distinct roles, permissions, and interaction histories. For instance, within an E-commerce CMS, a shop owner might possess full read and write permissions across all content, whereas an employee might only be granted write permissions for products but not for customer data. We aim to emulate this scenario by generating unique user profiles on each platform.
277
+
278
+ On the shopping site, we created a customer profile that has over 35 orders within a span of two years. On GitLab, we selected a user who maintains several popular open-source projects with numerous merge requests and issues. This user also manages a handful of personal projects privately. On Reddit, our chosen profile was a user who actively participates in discussions, with many posts and comments. Lastly, on our E-commerce CMS, we set up a user profile for a shop owner who has full read-and-write access to all system contents.
279
+
280
+ All users are automatically logged into their accounts using a pre-cached cookie. To our best knowledge, this is the first publicly available agent evaluation environment to implement such a characteristic. Existing literature typically operates under the assumption of universally identical user roles Shi et al. (2017); Liu et al. (2018); Deng et al. (2023).
281
+
282
+ # A.4 INTENT DISTRIBUTION
283
+
284
+ The distribution of intents across the websites are shown in Figure 6.
285
+
286
+ # A.5 HUMAN PERFORMANCE
287
+
288
+ We acknowledge that there may be a difference in human performance when annotators with different demographics are involved. In fact, many tasks in our dataset require domain-specific knowledge. For instance, an average user may not know what a git merge request is; or how to create a product in a complex content management system. We aim to design tasks that have easy-to-imagine outcomes (e.g., a new product page is created) rather than those that are easily performed by an average user without significant domain knowledge.
289
+
290
+ Table 5: The task success rate $( \mathrm { S R } \% )$ of GPT-3.5-TURBO-16K-0613 with temperature 0.0.
291
+
292
+ <table><tr><td colspan="3">CoT UA Hint Model SR</td></tr><tr><td>「</td><td>× GPT-3.5</td><td>6.28</td></tr></table>
293
+
294
+ <table><tr><td>Dataset</td><td>gpt-4-0613</td><td>gpt-4-1106-preview</td></tr><tr><td>Date (900 examples)</td><td>100</td><td>100</td></tr><tr><td>Time duration (900 examples)</td><td>100</td><td>100</td></tr></table>
295
+
296
+ Table 6: The accuracy $( \% )$ ) of two versions of GPT-4 on judging if dates and time duration of different formats are equivalent.
297
+
298
+ # A.6 EXPERIMENT CONFIGURATIONS
299
+
300
+ We experiment with GPT-3.5-TURBO-16K-0613, GPT-4-0613, and TEXT-BISON-001 with a temperature of 1.0 and a top- $p$ parameter of 0.9. The maximum number of state transitions is set to 30. We halt execution if the same action is repeated more than three times on the same observation or if the agent generates three consecutive invalid actions. These situations typically indicate a high likelihood of execution failure and hence warrant early termination. For TEXT-BISON-001, we additionally allow ten retries until it generates a valid action.
301
+
302
+ Primarily, we use a high temperature of 1.0 to encourage the exploration. To aid replicating the results, we provide the results of GPT-3.5-TURBO-16K-0613 with temperature 0.0 in Table 5 and the execution trajectories in our code repository.
303
+
304
+ # A.7 PROMPT FOR F U Z Z Y_M A T C H
305
+
306
+ <table><tr><td>Help a teacher to grade the answer of a student given a question. Keep in mind that the student may use different phrasing or wording to answer the question. The goal is to evaluate whether the answer is semantically equivalent to the reference answer.</td></tr><tr><td>question: {{intent}} reference answer: { {reference answer}}</td></tr><tr><td> all the string &#x27;N/A&#x27; that you see is a special sequence that means &#x27;not achievable&#x27;</td></tr><tr><td>student answer: {{prediction}} Conclude the judgement by correct/incorrect/partially correct.</td></tr></table>
307
+
308
+ Predictions that are judged as “correct” will receive a score of one, while all other predictions will receive a score of zero.
309
+
310
+ # A.8 THE ACCURACY OF FUZZY MATCH FUNCTION
311
+
312
+ To evaluate this, we manually checked 40 examples and found that 39 of them are identical to our human judgment. In addition, among the 82 examples that require using GPT-4 for evaluation, the answer of 49 $( 6 0 \% )$ examples is a date (e.g., 10/23/2022) or time duration (e.g., 15 minutes). In these cases, GPT-4 is only used to judge the different format of the answers. We quantitatively evaluate the correctness of GPT-4 in this case by generating different formats of a date and time duration programmatically. We randomly sample negative examples. For instance, Nov 3, 2022, November 3, 2022, 3rd November 2022, 3 Nov 2022, 2022-11-03, and 3rd of November, 2022 are all correct variances of 2022/11/03. The accuracy of GPT-4 is shown in Table 6. We can see that two versions of GPT-4 are extremely accurate, both achieving $100 \%$ accuracy.
313
+
314
+ # A.9 THE PROMPTS OF THE BASELINE WEB AGENTS
315
+
316
+ The system message of the reasoning agent for both GPT-3.5 and GPT-4 is in Figure 7, and two examples are in Figure 8. The system message of the direct agent for GPT-3.5 is in Figure 9 and the two examples are in Figure 10. UA hint refers to the instruction of “ If you believe the task is
317
+
318
+ You are an autonomous intelligent agent tasked with navigating a web browser. You will be given web-based tasks. These tasks will be accomplished through the use of specific actions you can issue.
319
+
320
+ Here’s the information you’ll have:
321
+ The user’s objective: This is the task you’re trying to complete.
322
+ The current web page’s accessibility tree: This is a simplified representation of the webpage, providing key information.
323
+ The current web page’s URL: This is the page you’re currently navigating.
324
+ The open tabs: These are the tabs you have open.
325
+ The previous action: This is the action you just performed. It may be helpful to track your progress.
326
+
327
+ The actions you can perform fall into several categories:
328
+
329
+ Page Operation Actions
330
+
331
+ \`click [id]\`: This action clicks on an element with a specific id on the webpage.
332
+ \`type [id] [content] [press_enter_after=0|1]\`: Use this to type the content into the field with id. By default, the "Enter" key is pressed after typing unless press_enter_after is set to 0.
333
+ \`hover [id]\`: Hover over an element with id.
334
+ \`press [key_comb]\`: Simulates the pressing of a key combination on the keyboard (e.g., $\mathrm { C t r l + v } ) ,$ ).
335
+ \`scroll [direction $1 =$ down|up]\`: Scroll the page up or down.
336
+
337
+ Tab Management Actions:
338
+
339
+ \`new_tab\`: Open a new, empty browser tab.
340
+ \`tab_focus [tab_index]\`: Switch the browser’s focus to a specific tab using its index.
341
+ \`close_tab\`: Close the currently active tab.
342
+
343
+ URL Navigation Actions:
344
+
345
+ \`goto [url]\`: Navigate to a specific URL. \`go_back\`: Navigate to the previously viewed page. \`go_forward\`: Navigate to the next page (if a previous \`go_back\` action was performed).
346
+
347
+ Completion Action:
348
+
349
+ \`stop [answer]\`: Issue this action when you believe the task is complete. If the objective is to find a text-based answer, provide the answer in the bracket. If you believe the task is impossible to complete, provide the answer as "N/A" in the bracket.
350
+
351
+ Homepage:
352
+
353
+ If you want to visit other websites, check out the homepage at http://homepage.com. It has a list of websites you can visit.
354
+ http://homepage.com/password.html lists all the account names and passwords for the websites. You can use them to log in to the websites.
355
+
356
+ To be successful, it is very important to follow the following rules:
357
+
358
+ 1. You should only issue an action that is valid given the current observation
359
+ 2. You should only issue one action at a time.
360
+ 3. You should follow the examples to reason step by step and then issue the next action.
361
+ 4. Generate the action in the correct format. Start with a "In summary, the next action I will perform is“ phrase, followed by action inside . For example, "In summary, the next action I will perform is \`\`\`click [1234]\`\`\`”.
362
+ 5. Issue stop action when you think you have achieved the objective. Don’t generate anything after stop."""
363
+
364
+ impossible to complete, provide the answer as "N/A" in the bracket.”. We remove this sentence in our ablation studies.
365
+
366
+ example_user
367
+ OBSERVATION:
368
+ [1744] link ’HP CB782A#ABA 640 Inkjet Fax Machine (Renewed)’
369
+ [1749] StaticText $\$ 279.49$ ’
370
+ [1757] button ’Add to Cart’
371
+ [1760] button ’Add to Wish List’ [1761] button ’Add to Compare’
372
+ URL: http://onestopmarket.com/office-products/office-electronics.html
373
+ OBJECTIVE: What is the price of HP Inkjet Fax Machine
374
+ PREVIOUS ACTION: None
375
+
376
+ # example_assistant
377
+
378
+ Let’s think step-by-step. This page lists the information of HP Inkjet Fax Machine, which is the product identified in the objective. Its price is $\$ 279.49$ . I think I have achieved the objective. I will issue the stop action with the answer. In summary, the next action I will perform is \`\`\`stop [\$279.49]\`\`
379
+
380
+ # example_user
381
+
382
+ OBSERVATION:
383
+
384
+ [164] textbox ’Search’ focused: True required: False
385
+ [171] button ’Go’
386
+ [174] link ’Find directions between two points’
387
+ [212] heading ’Search Results’
388
+ [216] button ’Close’
389
+ URL: http://openstreetmap.org
390
+ OBJECTIVE: Show me the restaurants near ABC
391
+ PREVIOUS ACTION: None
392
+
393
+ # example_assistant
394
+
395
+ Let’s think step-by-step. This page has a search box whose ID is [164]. According to the nominatim rule of openstreetmap, I can search for the restaurants near a location by ¨restaurants near. I can submit my typing by pressing the Enter afterwards. In summary, the next action I will perform is \`type [164] [restaurants near ABC] [1]\`\`\`
396
+
397
+ Figure 8: The two examples provided as example_user and example_assistant for the reasoning agent. Before issuing the action, the agent first perform reasoning.
398
+
399
+ You are an autonomous intelligent agent tasked with navigating a web browser. You will be given web-based tasks. These tasks will be accomplished through the use of specific actions you can issue. Here’s the information you’ll have:
400
+ The user’s objective: This is the task you’re trying to complete.
401
+ The current web page’s accessibility tree: This is a simplified representation of the webpage, providing key information.
402
+ The current web page’s URL: This is the page you’re currently navigating.
403
+ The open tabs: These are the tabs you have open.
404
+ The previous action: This is the action you just performed. It may be helpful to track your progress.
405
+
406
+ The actions you can perform fall into several categories:
407
+
408
+ Page Operation Actions
409
+
410
+ \`click [id]\`: This action clicks on an element with a specific id on the webpage.
411
+
412
+ \`type [id] [content] [press_enter_after=0|1] $\because$ Use this to type the content into the field with id. By default, the "Enter" key is pressed after typing unless press_enter_after is set to 0.
413
+
414
+ \`hover [id]\`: Hover over an element with id.
415
+ \`press [key_comb]\`: Simulates the pressing of a key combination on the keyboard (e.g., $\mathrm { C t r l + v }$ ).
416
+ \`scroll [direction $1 =$ down|up]\`: Scroll the page up or down.
417
+
418
+ Tab Management Actions:
419
+
420
+ \`new_tab\`: Open a new, empty browser tab.
421
+ \`tab_focus [tab_index]\`: Switch the browser’s focus to a specific tab using its index.
422
+ \`close_tab\`: Close the currently active tab.
423
+
424
+ URL Navigation Actions:
425
+
426
+ \`goto [url]\`: Navigate to a specific URL. \`go_back\`: Navigate to the previously viewed page. \`go_forward\`: Navigate to the next page (if a previous \`go_back\` action was performed).
427
+
428
+ Completion Action:
429
+
430
+ \`stop [answer] $:$ Issue this action when you believe the task is complete. If the objective is to find a text-based answer, provide the answer in the bracket. If you believe the task is impossible to complete, provide the answer as "N/A" in the bracket.
431
+
432
+ Homepage:
433
+
434
+ If you want to visit other websites, check out the homepage at http://homepage.com. It has a list of websites you can visit.
435
+ http://homepage.com/password.html lists all the account name and password for the websites. You can use them to log in to the websites. To be successful, it is very important to follow the following rules:
436
+ To be successful, it is very important to follow the following rules:
437
+ 1. You should only issue an action that is valid given the current observation
438
+ 2. You should only issue one action at a time.
439
+ 3. Generate the action in the correct format. Always put the action inside a pair of \`\`\`. For example, \`\`\`click [1234]\`\`\`
440
+ 4. Issue stop action when you think you have achieved the objective. Don’t generate anything after stop ."""
441
+
442
+ Figure 9: The system message of the direct agent. This message has the general explanation of the task, the available actions and some notes on avoiding common failures.
443
+
444
+ ![](images/da5857d10f4f9931009e84ff833a885e1f5742688a8a76f4a7fa80f1bfbd8d1e.jpg)
445
+ Figure 10: The two examples provided as example_user and example_assistant for the direct agent. The agent directly emits the next action given the observation.
446
+
447
+ ![](images/4be48ef1e493b5824824c0cb95f02997257a84cda9fc6933e1e4b6b23f695453.jpg)
448
+ Figure 11: Two examples where the GPT-4 agent failed, along with their screenshot and the accessibility tree of the relevant sections (grey). On the left, the agent fails to proceed to the “Users” section to accomplish the task of “Fork all Facebook repos”; on the right, the agent repeats entering the same search query even though the observation indicates the input box is filled.
449
+
450
+ A.10 ADDITIONAL ERROR ANALYSIS
451
+
452
+ Observation Bias Realistic websites frequently present information on similar topics across various sections to ensure optimal user accessibility. However, a GPT-4 agent often demonstrates a tendency to latch onto the first related piece of information it encounters without sufficiently verifying its relevance or accuracy. For instance, the homepage of the E-Commerce CMS displays the best-selling items based on recent purchases, while historical best-seller data is typically accessed via a separate report. Presented with the task of “What is the top-1 best-selling product in $2 0 2 2 ^ { \circ }$ , the GPT-4 agent defaults to leveraging the readily available information on the homepage, bypassing the necessary step of generating the report to obtain the accurate data.
453
+
454
+ Failures in Observation Interpretation Interestingly, while GPT-4 is capable of summarizing the observations, it occasionally overlooks more granular information, such as the previously entered input. As in the right-hand example of Figure 11, [5172] StaticText indicates that the search term “DMV area” has already been entered. However, the agent disregards this detail and continuously issues the command type [2430] [DMV area] until it reaches the maximum step limit. Furthermore, the agent often neglects the previous action information that is provided alongside the observation.
455
+
456
+ We hypothesize that these observed failures are related to the current pretraining and supervised fine-tuning on dialogues employed in GPT models Ouyang et al. (2022). These models are primarily trained to execute instructions given immediate observations (i.e.,, the dialogue history); thereby, they may exhibit a lack of explorations. Furthermore, in dialogue scenarios, subtle differences in NL expressions often have less impact on the overall conversation. As a result, models may tend to overlook minor variations in their observations.
parse/test/oKn9c6ytLx/oKn9c6ytLx_content_list.json ADDED
@@ -0,0 +1,1084 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "WE BAR E N A: A REALISTIC WEB ENVIRONMENT FOR BUILDING AUTONOMOUS AGENTS ",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Shuyan Zhou∗ Frank F. $\\mathbf { X } \\mathbf { u } ^ { * }$ Hao Zhu † Xuhui Zhou† Robert Lo† Abishek Sridhar† Xianyi Cheng Tianyue Ou Yonatan Bisk Daniel Fried Uri Alon Graham Neubig ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "Carnegie Mellon University {shuyanzh, fangzhex, gneubig}@cs.cmu.edu ",
16
+ "page_idx": 0
17
+ },
18
+ {
19
+ "type": "text",
20
+ "text": "ABSTRACT ",
21
+ "text_level": 1,
22
+ "page_idx": 0
23
+ },
24
+ {
25
+ "type": "text",
26
+ "text": "With advances in generative AI, there is now potential for autonomous agents to manage daily tasks via natural language commands. However, current agents are primarily created and tested in simplified synthetic environments, leading to a disconnect with real-world scenarios. In this paper, we build an environment for language-guided agents that is highly realistic and reproducible. Specifically, we focus on agents that perform tasks on the web, and create an environment with fully functional websites from four common domains: e-commerce, social forum discussions, collaborative software development, and content management. Our environment is enriched with tools (e.g., a map) and external knowledge bases (e.g., user manuals) to encourage human-like task-solving. Building upon our environment, we release a set of benchmark tasks focusing on evaluating the functional correctness of task completions. The tasks in our benchmark are diverse, long-horizon, and designed to emulate tasks that humans routinely perform on the internet. We experiment with several baseline agents, integrating recent techniques such as reasoning before acting. The results demonstrate that solving complex tasks is challenging: our best GPT-4-based agent only achieves an end-to-end task success rate of $1 4 . 4 1 \\%$ , significantly lower than the human performance of $7 8 . 2 4 \\%$ . These results highlight the need for further development of robust agents, that current state-of-the-art large language models are far from perfect performance in these real-life tasks, and that WebArena can be used to measure such progress. Our code, data, environment reproduction resources, and video demonstrations are publicly available at https://webarena.dev/. ",
27
+ "page_idx": 0
28
+ },
29
+ {
30
+ "type": "text",
31
+ "text": "1 INTRODUCTION ",
32
+ "text_level": 1,
33
+ "page_idx": 0
34
+ },
35
+ {
36
+ "type": "text",
37
+ "text": "Autonomous agents that perform everyday tasks via human natural language commands could significantly augment human capabilities, improve efficiency, and increase accessibility. Nonetheless, to fully leverage the power of autonomous agents, it is crucial to understand their behavior within an environment that is both authentic and reproducible. This will allow measurement of the ability of agents on tasks that human users care about in a fair and consistent manner. ",
38
+ "page_idx": 0
39
+ },
40
+ {
41
+ "type": "text",
42
+ "text": "Current environments for evaluate agents tend to over-simplify real-world situations. As a result, the functionality of many environments is a limited version of their real-world counterparts, leading to a lack of task diversity (Shi et al., 2017; Anderson et al., 2018; Gordon et al., 2018; Misra et al., 2016; Shridhar et al., 2020; 2021; Yao et al., 2022a). In addition, these simplifications often lower the complexity of tasks as compared to their execution in the real world (Puig et al., 2018; Shridhar et al., 2020; Yao et al., 2022a). Finally, some environments are presented as a static resource (Shi et al., 2017; Deng et al., 2023) where agents are confined to accessing only those states that were previously cached during data collection, thus limiting the breadth and diversity of exploration. For evaluation, many environments focus on comparing the textual surface form of the predicted action sequences with reference action sequences, disregarding the functional correctness of the executions and possible alternative solutions (Puig et al., 2018; Jernite et al., 2019; Xu et al., 2021; Li et al., 2020; Deng et al., 2023). These limitations often result in a discrepancy between simulated environments and the real world, and can potentially impact the generalizability of AI agents to successfully understand, adapt, and operate within complex real-world situations. ",
43
+ "page_idx": 0
44
+ },
45
+ {
46
+ "type": "image",
47
+ "img_path": "images/cf45426703ea246ad839ecfea50c8fb3fe60081248cbfa6523a082150268549d.jpg",
48
+ "image_caption": [
49
+ "Figure 1: WebArena is a standalone, self-hostable web environment for building autonomous agents. WebArena creates websites from four popular categories with functionality and data mimicking their real-world equivalents. To emulate human problem-solving, WebArena also embeds tools and knowledge resources as independent websites. WebArena introduces a benchmark on interpreting high-level realistic natural language command to concrete web-based interactions. We provide validators to programmatically validate the functional correctness of each task. "
50
+ ],
51
+ "image_footnote": [],
52
+ "page_idx": 1
53
+ },
54
+ {
55
+ "type": "text",
56
+ "text": "",
57
+ "page_idx": 1
58
+ },
59
+ {
60
+ "type": "text",
61
+ "text": "We introduce WebArena, a realistic and reproducible web environment designed to facilitate the development of autonomous agents capable of executing tasks (§2). An overview of WebArena is in Figure 1. Our environment comprises four fully operational, self-hosted web applications, each representing a distinct domain prevalent on the internet: online shopping, discussion forums, collaborative development, and business content management. Furthermore, WebArena incorporates several utility tools, such as map, calculator, and scratchpad, to best support possible human-like task executions. Lastly, WebArena is complemented by an extensive collection of documentation and knowledge bases that vary from general resources like English Wikipedia to more domain-specific references, such as manuals for using the integrated development tool (Fan et al., 2022). The content populating these websites is extracted from their real-world counterparts, preserving the authenticity of the content served on each platform. We deliver the hosting services using Docker containers with gym-APIs (Brockman et al., 2016), ensuring both the usability and the reproducibility of WebArena. ",
62
+ "page_idx": 1
63
+ },
64
+ {
65
+ "type": "text",
66
+ "text": "Along with WebArena, we release a ready-to-use benchmark with 812 long-horizon web-based tasks (§3). Each task is described as a high-level natural language intent, emulating the abstract language usage patterns typically employed by humans (Bisk et al., 2019). Two example intents are shown in the upper left of Figure 1. We focus on evaluating the functional correctness of these tasks, i.e., does the result of the execution actually achieve the desired goal (§3.2). For instance, to evaluate the example in Figure 2, our evaluation method verifies the concrete contents in the designated repository. This evaluation is not only more reliable (Zhong et al., 2017; Chen et al., 2021; Wang et al., 2022) than comparing the textual surface-form action sequences (Puig et al., 2018; Deng et al., 2023) but also accommodate a range of potential valid paths to achieve the same goal, which is a ubiquitous phenomenon in sufficiently complex tasks. ",
67
+ "page_idx": 1
68
+ },
69
+ {
70
+ "type": "text",
71
+ "text": "We use this benchmark to evaluate several agents that can follow NL command and perform webbased tasks $( \\ S 4 )$ . These agents are implemented in a few-shot in-context learning fashion with powerful large language models (LLMs) such as GPT-4 and PALM-2. Experiment results show that the best GPT-4 agent performance is somewhat limited, with an end-to-end task success rate of only $1 4 . 4 1 \\%$ , while the human performance is $7 8 . 2 4 \\%$ . We hypothesize that the limited performance of current LLMs stems from a lack of crucial capabilities such as active exploration and failure recovery to successfully perform complex tasks (§5.1). These outcomes underscore the necessity for further development towards robust and effective agents (LeCun, 2022) in WebArena. ",
72
+ "page_idx": 1
73
+ },
74
+ {
75
+ "type": "text",
76
+ "text": "2 WE BAR E N A: WEBSITES AS AN ENVIRONMENT FOR AUTONOMOUS AGENTS ",
77
+ "text_level": 1,
78
+ "page_idx": 1
79
+ },
80
+ {
81
+ "type": "text",
82
+ "text": "Our goal is to create a realistic and reproducible web environment. We achieve reproducibility by making the environment standalone, without relying on live websites. This circumvents technical challenges such as bots being subject to CAPTCHAs, unpredictable content modifications, and configuration changes, which obstruct a fair comparison across different systems over time. We achieve realism by using open-source libraries that underlie many in-use sites from several popular categories and importing data to our environment from their real-world counterparts. ",
83
+ "page_idx": 1
84
+ },
85
+ {
86
+ "type": "image",
87
+ "img_path": "images/bd48369ddd165a24409b6b9a14bc4e880e18c513494a95c0adacc90d7018f6e0.jpg",
88
+ "image_caption": [
89
+ "Create an efficient itinerary to visit all of Pittsburgh's art museums with minimal driving distance “ starting from Schenley Park. Log the order in my “awesome-northeast-us-travel” repository ",
90
+ "Figure 2: A high-level task that can be fully executed in WebArena. Success requires sophisticated, long-term planning and reasoning. To accomplish the goal (top), an agent needs to (1) find Pittsburgh art museums on Wikipedia, (2) identify their locations on a map (while optimizing the itinerary), and (3) update the README file in the appropriate repository with the planned route. "
91
+ ],
92
+ "image_footnote": [],
93
+ "page_idx": 2
94
+ },
95
+ {
96
+ "type": "text",
97
+ "text": "",
98
+ "page_idx": 2
99
+ },
100
+ {
101
+ "type": "text",
102
+ "text": "2.1 CONTROLLING AGENTS THROUGH HIGH-LEVEL NATURAL LANGUAGE",
103
+ "text_level": 1,
104
+ "page_idx": 2
105
+ },
106
+ {
107
+ "type": "text",
108
+ "text": "The WebArena environment is denoted as ${ \\mathcal { E } } { = \\langle { S , A , \\mathcal { O } } , { \\mathcal { T } } \\rangle }$ with state space $s$ , action space $\\mathcal { A } ( \\ S 2 . 4 )$ and observation space $\\mathcal { O }$ (§2.3). The transition function $\\mathcal { T } : \\mathcal { S } \\times \\mathcal { A } \\longrightarrow \\mathcal { S }$ is deterministic, and it is defined by the underlying implementation of each website in the environment. Given a task described as a natural language intent $\\mathbf { i }$ , an agent issues an action $a _ { t } \\in \\mathcal A$ based on intent i, the current observation $o _ { t } \\in \\mathcal { O }$ , the action history $\\mathbf { a } _ { 1 } ^ { \\overline { { t } } - 1 }$ and the observation history ot−11 . Consequently, the action results in a new state $s _ { t + 1 } \\in S$ and its corresponding observation $o _ { t + 1 } \\in \\mathcal { O }$ . We propose a reward function $r ( \\mathbf { a } _ { 1 } ^ { T } , \\mathbf { s } _ { 1 } ^ { T } )$ to measure the success of a task execution, where $\\mathbf { a } _ { 1 } ^ { T }$ represents the sequence of actions from start to the end time step $T$ , and $\\mathbf { s } _ { 1 } ^ { T }$ denotes all intermediate states. This reward function assesses if state transitions align with the expectations of the intents. For example, with an intent to place an order, it verifies whether an order has been placed. Additionally, it evaluates the accuracy of the agent’s actions, such as checking the correctness of the predicted answer. ",
109
+ "page_idx": 2
110
+ },
111
+ {
112
+ "type": "text",
113
+ "text": "2.2 WEBSITE SELECTION ",
114
+ "text_level": 1,
115
+ "page_idx": 2
116
+ },
117
+ {
118
+ "type": "text",
119
+ "text": "To decide which categories of websites to use, we first analyzed approximately 200 examples from the authors’ actual web browser histories. Each author delved into their browsing histories, summarizing the goal of particular segments of their browser session. Based on this, we classified the visited websites into abstract categories. We then identified the four most salient categories and implemented one instance per category based on this analysis: (1) E-commerce platforms supporting online shopping activities (e.g., Amazon, eBay), (2) social forum platforms for opinion exchanges (e.g., Reddit, StackExchange), (3) collaborative development platforms for software development (e.g., GitLab), and (4) content management systems (CMS) that manage the creation and revision of the digital content (e.g., online store management). ",
120
+ "page_idx": 2
121
+ },
122
+ {
123
+ "type": "text",
124
+ "text": "In addition to these platforms, we selected three utility-style tools that are frequently used in webbased tasks: (1) a map for navigation and searching for information about points of interest (POIs) such as institutions or locations (2) a calculator, and (3) a scratchpad for taking notes. As informationseeking and knowledge acquisition are critical in web-based tasks, we also incorporated various knowledge resources into WebArena. These resources range from general information hubs, such as the English Wikipedia, to more specialized knowledge bases, such as the website user manuals. ",
125
+ "page_idx": 2
126
+ },
127
+ {
128
+ "type": "text",
129
+ "text": "Implementation We leveraged open-source libraries relevant to each category to build our own versions of an E-commerce website (OneStopShop), GitLab, Reddit, an online store content management system (CMS), a map, and an English Wikipedia. Then we imported sampled data from their real-world counterparts. As an example, our version of GitLab was developed based on the actual GitLab project.1 We carefully emulated the features of a typical code repository by including both popular projects with many issues and pull requests and smaller, personal projects. Details of all websites in WebArena can be found in Appendix A.1. We deliver the environment as dockers and provide scripts to reset the environment to a deterministic initial state (See Appendix A.2). ",
130
+ "page_idx": 2
131
+ },
132
+ {
133
+ "type": "image",
134
+ "img_path": "images/1068d1a1ee72c29ec9f17a0ef21a7f95136c5a91919766c035f7767b73bd1f9b.jpg",
135
+ "image_caption": [
136
+ "Figure 3: We design the observation to be the URL and the content of a web page, with options to represent the content as a screenshot (left), HTML DOM tree (middle), and accessibility tree (right). The content of the middle and right figures are trimmed to save space. "
137
+ ],
138
+ "image_footnote": [],
139
+ "page_idx": 3
140
+ },
141
+ {
142
+ "type": "text",
143
+ "text": "",
144
+ "page_idx": 3
145
+ },
146
+ {
147
+ "type": "text",
148
+ "text": "2.3 OBSERVATION SPACE ",
149
+ "text_level": 1,
150
+ "page_idx": 3
151
+ },
152
+ {
153
+ "type": "text",
154
+ "text": "We design the observation space to roughly mimic the web browser experience: a web page URL, the opened tabs , and the web page content of the focused tab. WebArena is the first web environment to consider multi-tab web-based tasks to promote tool usage, direct comparisons and references across tabs, and other functionalities. The multi-tab functionality offers a more authentic replication of human web browsing habits compared to maintaining everything in a single tab. We provide flexible configuration to render the page content in many modes: (see Figure 3 for an example): (1) the raw web page HTML, composed of a Document Object Model (DOM) tree, as commonly used in past work (Shi et al., 2017; Deng et al., 2023; Li et al., 2020); (2) a screenshot, a pixel-based representation that represents the current web page as an RGB array and (3) the accessibility tree of the web page.2 The accessibility tree is a subset of the DOM tree with elements that are relevant and useful for displaying the contents of a web page. Every element is represented as its role (e.g., a link), its text content, and its properties (e.g., whether it is focusable). Accessibility trees largely retain the structured information of a web page while being more compact than the DOM representation. ",
155
+ "page_idx": 3
156
+ },
157
+ {
158
+ "type": "text",
159
+ "text": "We provide an option to limit the content to the contents within a viewport for all modes. This ensures that the observation can be input into a text-based model with limited context length or an image-based model with image size or resolution requirements. ",
160
+ "page_idx": 3
161
+ },
162
+ {
163
+ "type": "text",
164
+ "text": "2.4 ACTION SPACE ",
165
+ "text_level": 1,
166
+ "page_idx": 3
167
+ },
168
+ {
169
+ "type": "text",
170
+ "text": "Following previous work on navigation and operation in web and embodied environments (Shi et al., 2017; Liu et al., 2018), we design a compound action space that emulates the keyboard and mouse operations available on web pages. Figure 4 lists all the available actions categorized into three distinct groups. The first group includes element operations such as clicking, hovering, typing, and key combination pressing. The second comprises tab-related actions such as opening, closing, and switching between tabs. The third category consists of URL navigation actions, such as visiting a specific URL or navigating forward and backward in the browsing history. ",
171
+ "page_idx": 3
172
+ },
173
+ {
174
+ "type": "text",
175
+ "text": "Building on these actions, WebArena provides agents with the flexibility to refer to elements for operation in different ways. An element can be selected by its on-screen coordinates, $( x , y )$ , or by a unique element ID that is prepended to each element. This ID is generated when traversing the Document Object Model (DOM) or accessibility tree. With element IDs, the element selection is transformed into an $n$ -way classification problem, thereby eliminating any disambiguation efforts required from the agent or the underlying implementation. For example, issuing the action click [1582] clicks the button given the observation of [1582] Add to Cart. This flexible element selection allows WebArena to support agents designed in various ways (e.g., accepting input from different modalities) without compromising fair comparison metrics such as step count. ",
176
+ "page_idx": 3
177
+ },
178
+ {
179
+ "type": "table",
180
+ "img_path": "images/2b505d8a4f95aa36fc3d718620186d35af6842ead930dea3063efbd224f61efc.jpg",
181
+ "table_caption": [
182
+ "Figure 4: Action Space of WebArena "
183
+ ],
184
+ "table_footnote": [],
185
+ "table_body": "<table><tr><td>Action Type noop</td><td>Description Do nothing</td></tr><tr><td>click(elem) hover (elem) type(elem,text) press(key_comb) scroll(dir)</td><td>Click at an element Hover on an element Type to an element Press a key comb Scroll up and down</td></tr><tr><td>tab_focus(index) new_tab tab_close</td><td>focus on i-th tab Open a new tab Close current tab</td></tr><tr><td>go_back go_forward goto(URL)</td><td>Visit the last URL Undo go_back Go to URL</td></tr></table>",
186
+ "page_idx": 4
187
+ },
188
+ {
189
+ "type": "table",
190
+ "img_path": "images/e0869fdd46c393ede7a7dd4c157f53563c93012aafb3b61e953a03452213882c.jpg",
191
+ "table_caption": [
192
+ "Figure 5: Example intents from three categories. "
193
+ ],
194
+ "table_footnote": [],
195
+ "table_body": "<table><tr><td>Category</td><td>Example</td></tr><tr><td rowspan=\"2\">Information Seeking</td><td>When was the last time I bought shampoo</td></tr><tr><td>Compare walking and driving time from AMC Waterfront to Randyland</td></tr><tr><td rowspan=\"2\">Site Navigation</td><td>Checkout merge requests assigned to me</td></tr><tr><td>Show me the ergonomic chair with the best rating</td></tr><tr><td rowspan=\"2\">Content &amp; Config</td><td>Post to ask“whetherIneed a car in NYC&quot;</td></tr><tr><td>Delete the reviews from the scammer Yoke</td></tr></table>",
196
+ "page_idx": 4
197
+ },
198
+ {
199
+ "type": "text",
200
+ "text": "User Role Simulation Users of the same website often have disparate experiences due to their distinct roles, permissions, and interaction histories. We emulate this scenario by generating unique user profiles on each platform. The details can be found in Appendix A.3. ",
201
+ "page_idx": 4
202
+ },
203
+ {
204
+ "type": "text",
205
+ "text": "3 BENCHMARK SUITE OF WEB-BASED TASKS ",
206
+ "text_level": 1,
207
+ "page_idx": 4
208
+ },
209
+ {
210
+ "type": "text",
211
+ "text": "We provide a benchmark with 812 test examples on grounding high-level natural language instructions to interactions in WebArena. Each example has a metric to evaluate the functional correctness of the task execution. In this section, we first formally define the task of controlling an autonomous agent through natural language. Then we introduce the annotation process of our benchmark. ",
212
+ "page_idx": 4
213
+ },
214
+ {
215
+ "type": "text",
216
+ "text": "3.1 INTENT COLLECTION ",
217
+ "text_level": 1,
218
+ "page_idx": 4
219
+ },
220
+ {
221
+ "type": "text",
222
+ "text": "We focus on curating realistic intents to carry out complex and creative tasks within WebArena. To start with, our annotators were guided to spend a few minutes exploring the websites to familiarize themselves with the websites’ content and functionalities. As most of our websites are virtually identical to their open-web counterparts, despite having sampled data, most annotators can quickly comprehend the websites. ",
223
+ "page_idx": 4
224
+ },
225
+ {
226
+ "type": "text",
227
+ "text": "Next, we instructed the annotators to formulate intents based on the following criteria: ",
228
+ "page_idx": 4
229
+ },
230
+ {
231
+ "type": "text",
232
+ "text": "(1) The intent should be abstract and high-level, implying that the task cannot be fulfilled with merely one or two actions. As an example, instead of “click the science subreddit”, we encouraged annotators to come up with something more complex like “post a greeting message on science subreddit”, which involves performing multiple actions. \n(2) The intent should be creative. Common tasks such as account creation can be easily thought of. We encouraged the annotators to add constraints (e.g., “create a Reddit account identical to my GitLab one”) to make the intents more unique. \n(3) The intent should be formulated as a template by making replaceable elements as variables. The annotators were also responsible for developing several instantiations for each variable. For example, the intent “create a Reddit account identical to my GitLab one” can be converted into “create a {{site1}} account identical to my {{site2}} one”, with an instantiation like “{site1: Reddit, site2: GitLab}” and another like “{site1: GitLab, site2: OneStopShopping}”. Notably, tasks derived from the same template can have distinct execution traces. The similarity resides primarily in the high-level semantics rather than the specific implementation. ",
233
+ "page_idx": 4
234
+ },
235
+ {
236
+ "type": "text",
237
+ "text": "We also provided a prompt for the annotators to use with ChatGPT3 for inspiration, that contains an overview of each website and instructs the model to describe potential tasks to be performed on these sites. Furthermore, we offered a curated list of examples for annotators to reference. ",
238
+ "page_idx": 4
239
+ },
240
+ {
241
+ "type": "text",
242
+ "text": "Intent Analysis In total, we curated 241 templates and 812 instantiated intents. On average, each template is instantiated to 3.3 examples. The intent distribution is shown in Figure 6. Furthermore, we classify the intents into three primary categories with examples shown in Figure 5: ",
243
+ "page_idx": 4
244
+ },
245
+ {
246
+ "type": "text",
247
+ "text": "(1) Information-seeking tasks expect a textual response. Importantly, these tasks in WebArena often require navigation across multiple pages or focus on user-centric content. This makes them distinct from open-domain question-answering (Yang et al., 2018; Kwiatkowski et al., 2019), which focuses on querying general knowledge with a simple retrieval step. For instance, to answer “When was the last time I bought the shampoo”, an agent traverses the user’s purchase history, checking order details to identify the most recent shampoo purchase. \n(2) Site navigation: This category is composed of tasks that require navigating through web pages using a variety of interactive elements such as search functions and links. The objective is often to locate specific information or navigate to a particular section of a site. \n(3) Content and configuration operation: This category encapsulates tasks that require operating in the web environment to create, revise, or configure content or settings. This includes adjusting settings, managing accounts, performing online transactions, generating new web content, and modifying existing content. Examples range from updating a social media status or README file to conducting online purchases and configuring privacy settings. ",
248
+ "page_idx": 5
249
+ },
250
+ {
251
+ "type": "text",
252
+ "text": "3.2 EVALUATION ANNOTATION ",
253
+ "text_level": 1,
254
+ "page_idx": 5
255
+ },
256
+ {
257
+ "type": "text",
258
+ "text": "Evaluating Information Seeking Tasks To measure the correctness of information-seeking tasks where a textual answer is expected, we provide the annotated answer $a ^ { * }$ for each intent. The $a ^ { * }$ is further compared with the predicted answer $\\hat { a }$ with one of the following scoring functions $r _ { \\mathrm { i n f o } } ( \\hat { a } , a ^ { * } )$ ",
259
+ "page_idx": 5
260
+ },
261
+ {
262
+ "type": "text",
263
+ "text": "First, we define exact_match where only $\\hat { a }$ that is identical with $a ^ { * }$ receives a score of one. This function is primarily applicable to intent types whose responses follow a more standardized format, similar to the evaluation on question answering literature (Rajpurkar et al., 2016; Yang et al., 2018). ",
264
+ "page_idx": 5
265
+ },
266
+ {
267
+ "type": "text",
268
+ "text": "Second, we create must_include where any $\\hat { a }$ containing $a ^ { * }$ receives a score of one. This function is primarily used in when an unordered list of text is expected or where the emphasis of evaluation is on certain key concepts. In the second example in Table 1, we expect both the correct name and the email address to be presented, irrespective of the precise wording used to convey the answer. ",
269
+ "page_idx": 5
270
+ },
271
+ {
272
+ "type": "text",
273
+ "text": "Finally, we introduce fuzzy_match where we utilize a language model to assess whether $\\hat { a }$ is semantically equivalent to $a ^ { * }$ . Specifically, in this work, we use $\\mathtt { g p t - 4 - 0 6 1 3 }$ to perform this evaluation. The corresponding prompt details are provided in Appendix A.7. The fuzzy_match function applies to situations where the format of the answer is diverse. For instance, in responding to “Compare the time for walking and driving route from AMC Waterfront to Randyland”, it is essential to ensure that driving time and walking time are accurately linked with the correct terms. The fuzzy_match function could also flexibly match the time $\\cdot 2 \\mathrm { h } 5 8 \\mathrm { m i n } ^ { \\cdot \\prime }$ with different forms such as $^ { 6 6 } 2$ hour 58 minutes”, $\\overline { { 2 } } { : } 5 8 ^ { 3 }$ and others. We demonstrate a language model can achieve nearly perfect performance on this task in $\\ S \\mathrm { A } . 8$ . ",
274
+ "page_idx": 5
275
+ },
276
+ {
277
+ "type": "text",
278
+ "text": "Evaluating Site Navigation and Content & Config Tasks The tasks in these categories require accessing web pages that meet certain conditions or performing operations that modify the underlying data storage of the respective websites. To assess these, we establish reward functions $r _ { \\mathrm { p r o g } } ( \\mathbf { s } )$ that programmatically examine the intermediate states s within an execution trajectory to ascertain whether the outcome aligns with the intended result. These intermediate states are often the underlying databases of the websites, the status, and the content of a web page at each step of the execution. ",
279
+ "page_idx": 5
280
+ },
281
+ {
282
+ "type": "text",
283
+ "text": "Evaluating each instance involves two components. First, we provide a locator, tasked with retrieving the critical content pertinent to each intent. The implementation of this locator varies from a database query, a website-supported API call, to a JavaScript element selection on the relevant web page, depending on implementation feasibility. For example, the evaluation process for the intent of the fifth example in Table 1, first obtains the URL of the latest post by examining the last state in the state sequence s. Then it navigates to the corresponding post page and obtains the post’s content by running the Javascript “document.querySelector(‘.submission__inner’).outerText”. ",
284
+ "page_idx": 5
285
+ },
286
+ {
287
+ "type": "text",
288
+ "text": "Subsequently, we annotate keywords that need to exist within the located content. For example, the evaluation verifies if the post is correctly posted in the “nyc” subreddit by examining the URL of the post and if the post contains the requested content by examining the post content. We reuse the exact_match and must_include functions from information-seeking tasks for this purpose. ",
289
+ "page_idx": 5
290
+ },
291
+ {
292
+ "type": "table",
293
+ "img_path": "images/b946b68f64c0c917dfdc070aa1b261b195429f19016a813667f0931e936e1e8e.jpg",
294
+ "table_caption": [],
295
+ "table_footnote": [],
296
+ "table_body": "<table><tr><td>Function</td><td>ID</td><td>Intent</td><td>Eval Implementation</td></tr><tr><td rowspan=\"3\">Tinfo(a*,a)</td><td>1</td><td>Tell me the name of the customer who has the most cancellations in the history</td><td>exact_mat ch(@,“Samantha Jones&quot;)</td></tr><tr><td>2</td><td>emaie</td><td>must_include(a,&quot;Sean Mimal.om&quot;)</td></tr><tr><td>3</td><td> ComAMcWlkinfrond driindyimnd</td><td>fuzzy_mat ch(a, “driving: 2h5minm)</td></tr><tr><td rowspan=\"2\">Tprog(s)</td><td>4</td><td>Checkout merge requests assigned to me</td><td>url=locate_current_url(s) exact_match (URL,&quot;gitlab.com/merge_ requests?assignee_username=byteblaze&quot;)</td></tr><tr><td>5</td><td>Postdo ask &quot;whter I</td><td> must_include (body,&quot;a carin NYC&quot;)</td></tr></table>",
297
+ "page_idx": 6
298
+ },
299
+ {
300
+ "type": "text",
301
+ "text": "Table 1: We introduce two evaluation approaches. $r _ { \\mathrm { i n f o } }$ (top) measures the correctness of performing information-seeking tasks. It compares the predicted answer $\\hat { a }$ with the annotated reference $a ^ { * }$ with three implementations. $r _ { \\mathrm { p r o g } }$ (bottom) programmatically checks whether the intermediate states during the executions possess the anticipated properties specified by the intent. ",
302
+ "page_idx": 6
303
+ },
304
+ {
305
+ "type": "text",
306
+ "text": "Unachievable Tasks Due to constraints such as inadequate evidence, user permissions (§A.3), or the absence of necessary functional support on the website, humans may ask for tasks that are not possible to complete. Inspired by previous work on evaluating question-answering models on unanswerable questions (Rajpurkar et al., 2018), we design unachievable tasks in WebArena. For instance, fulfilling an intent like “Tell me the contact number of OneStopShop” is impracticable in WebArena, given that the website does not provide such contact information. We label such instances as \"N/A\" and expect an agent to produce an equivalent response. These examples allow us to assess an agent’s ability to avoid making unfounded claims and its adherence to factual accuracy. ",
307
+ "page_idx": 6
308
+ },
309
+ {
310
+ "type": "text",
311
+ "text": "Annotation Process The intents were contributed by the authors following the annotation guideline in $\\ S 3 . 1$ . Every author has extensive experience with web-based tasks. The reference answers to the information-seeking tasks were curated by the authors and an external annotator. To ensure consistency and accuracy, each question was annotated twice. If the two annotators disagreed, a third annotator finalized the annotation. The programs to evaluate the remaining examples were contributed by three of the authors who are proficient in JavaScript programming. Difficult tasks were often discussed collectively to ensure the correctness of the annotation. The annotation required the annotator to undertake the full execution and scrutinize the intermediate states. ",
312
+ "page_idx": 6
313
+ },
314
+ {
315
+ "type": "text",
316
+ "text": "Human Performance We sample one task from each of the 170 templates and ask five computer science graduate students to perform these tasks. The human performance is on the right. Overall, the human annotators complete $7 8 . 2 4 \\%$ of the tasks, with lower performance on information-seeking tasks. Through examining the recorded trajectories, we found that $50 \\%$ of the failures are due to misinterpreting the intent (e.g., providing travel distance when asked for travel time), incomplete answers (e.g., providing only name when asked for name and email), and incomplete executions (e.g., partially filling the product information), while the remaining instances have more severe failures, where the executions are off-target. More discussions on human annotations can be found in $\\ S _ { \\mathrm { A } . 5 }$ . ",
317
+ "page_idx": 6
318
+ },
319
+ {
320
+ "type": "table",
321
+ "img_path": "images/156c8875bd423c2b12c355cb7347873972350a5aa46d7838208980d7c77cebdf.jpg",
322
+ "table_caption": [],
323
+ "table_footnote": [],
324
+ "table_body": "<table><tr><td>Avg. Time</td><td>110s</td></tr><tr><td>Success Rateinfo</td><td>74.68%</td></tr><tr><td>Success Rateothers 81.32%</td><td></td></tr><tr><td>Success Rateall</td><td>78.24%</td></tr></table>",
325
+ "page_idx": 6
326
+ },
327
+ {
328
+ "type": "text",
329
+ "text": "",
330
+ "page_idx": 6
331
+ },
332
+ {
333
+ "type": "text",
334
+ "text": "4 BASELINE WEB AGENTS",
335
+ "text_level": 1,
336
+ "page_idx": 6
337
+ },
338
+ {
339
+ "type": "text",
340
+ "text": "We experiment with three LLMs using two prompting strategies, both with two examples in the context. In the first setting, we ask the LLM to directly predict the next action given the current observation, the intent and the previously performed action. In the second setting, with the same information, the model first performs chain-of-thought reasoning steps in the text before the action prediction (CoT, Wei et al. (2022); Yao et al. (2022b)). Before the examples, we provide a detailed overview of the browser environment, the allowed actions, and many rules. To make the model aware of the unachievable tasks, the instruction explicitly asks the agent to stop if it believes the task is impossible to perform. We refer to this directive as Unachievable hint, or UA hint. This introduction is largely identical to the guidelines we presented to human annotators to ensure a fair comparison. We use an accessibility tree with element IDs as the observation space. The agent can identify which element to interact with by the ID of the element. For instance, the agent can issue click [1582] to click the “Add to Cart” button with the ID of 1582. The full prompts can be found in Appendix A.9. The detailed configurations of each model can be found in Appendix A.6. ",
341
+ "page_idx": 6
342
+ },
343
+ {
344
+ "type": "text",
345
+ "text": "",
346
+ "page_idx": 7
347
+ },
348
+ {
349
+ "type": "text",
350
+ "text": "5 RESULTS ",
351
+ "text_level": 1,
352
+ "page_idx": 7
353
+ },
354
+ {
355
+ "type": "text",
356
+ "text": "The main results are shown on the top of Table 2. GPT-4 (OpenAI, 2023) with CoT prompting achieves a modest end-to-end task success rate of $1 1 . 7 0 \\%$ , which is significantly lower than the human performance of $7 8 . 2 4 \\%$ . GPT-3.5 (OpenAI, 2022) with CoT prompting is only able to successfully perform $8 . 7 5 \\%$ of the tasks. The explicit reasoning procedure is somewhat helpful, it brings $2 . 3 4 \\%$ improvement over the version without it. Further, TEXT-BISON-001 (Anil et al., 2023) underperforms GPT-3.5, with a success rate of $5 . 0 5 \\%$ . These results underline the inherent challenges and complexities of executing tasks that span long horizons, particularly in realistic environments such as WebArena. ",
357
+ "page_idx": 7
358
+ },
359
+ {
360
+ "type": "table",
361
+ "img_path": "images/11ba2e9db33e39a7f881e14f97d7ef235bd074b7b44a3b2deb047393e696bb0d.jpg",
362
+ "table_caption": [
363
+ "Table 2: The end-to-end task success rate $( \\mathrm { S R } \\% )$ on WebArena with different prompting strategies. CoT: the model performs step-by-step reasoning before issuing the action. UA hint: ask the model to stop when encountering unachievable questions. "
364
+ ],
365
+ "table_footnote": [],
366
+ "table_body": "<table><tr><td>CoT UA Hint</td><td></td><td>Model</td><td>SR</td><td>SRAC</td><td>SRUA</td></tr><tr><td>√</td><td></td><td>TEXT-BISON-001</td><td>5.05</td><td>4.00</td><td>27.78</td></tr><tr><td>×</td><td></td><td>GPT-3.5</td><td>6.41</td><td>4.90</td><td>38.89</td></tr><tr><td>√</td><td>√</td><td>GPT-3.5</td><td>8.75</td><td>6.44</td><td>58.33</td></tr><tr><td></td><td></td><td>GPT-4</td><td>11.70</td><td>8.63</td><td>77.78</td></tr><tr><td>×</td><td>xx</td><td>GPT-3.5</td><td>5.10</td><td>4.90</td><td>8.33</td></tr><tr><td></td><td></td><td>GPT-3.5</td><td>6.16</td><td>6.06</td><td>8.33</td></tr><tr><td></td><td>×</td><td>GPT-4</td><td>14.41</td><td>13.02</td><td>44.44</td></tr><tr><td></td><td></td><td>Human</td><td>78.24</td><td>77.30</td><td>100.00</td></tr></table>",
367
+ "page_idx": 7
368
+ },
369
+ {
370
+ "type": "text",
371
+ "text": "5.1 ANALYSIS ",
372
+ "text_level": 1,
373
+ "page_idx": 7
374
+ },
375
+ {
376
+ "type": "text",
377
+ "text": "Do models know when to stop? In our error analysis of the execution trajectories, we observe a prevalent error pattern of early stopping due to the model’s conclusion of unachievability. For instance, GPT-4 erroneously identifies $5 4 . 9 \\%$ of feasible tasks as impossible. This issue primarily stems from the UA hint in the instruction, while this hint allows models to identify unachievable tasks, it also hinders performance on achievable tasks. To address this, we conduct an ablation study where we remove this hint. We then break down the success rate for both achievable and unachievable tasks. As shown in Table 2, eliminating this instruction led to a performance boost in achievable tasks, enhancing the overall task success rate of GPT-4 to $1 4 . 4 1 \\%$ . Despite an overall decline in identifying unachievable tasks, GPT-4 retains the capacity to recognize $4 4 . 4 4 \\%$ of such tasks. It does so by generating reasons of non-achievability, even without explicit instructions. On the other hand, GPT-3.5 rarely exhibits this level of reasoning. Instead, it tends to follow problematic patterns such as hallucinating incorrect answers, repeating invalid actions, or exceeding the step limits. This result suggests that even subtle differences in instruction design can significantly influence the behavior of a model in performing interactive tasks in complex environments. ",
378
+ "page_idx": 7
379
+ },
380
+ {
381
+ "type": "text",
382
+ "text": "Can a model maintain consistent performance across similar tasks? Tasks that originate from the same template usually follow similar reasoning and planning processes, even though their observations and executions will differ. We plot a histogram of per-template success rates for our models in Table 3. Of the 61 templates, GPT-4 manages to achieve a $100 \\%$ task success rate on only four templates, while GPT-3.5 fails to achieve full task completion for any of the templates. In many cases, the models are only able to complete one task variation with a template. These observations indicate that even when tasks are derived from the same template, they can present distinct challenges. For instance, while “Fork metaseq” can be a straightforward task, “Fork all repos from Facebook” derived from the same template requires more repetitive operations, hence increasing its complexity. Therefore, WebArena provide a testbed to evaluate more sophisticated methods. In particular, those that incorporate memory components, ",
383
+ "page_idx": 7
384
+ },
385
+ {
386
+ "type": "image",
387
+ "img_path": "images/9bf8b7ebd2568942bb66bb4d2794d06828dcfcd7159ab75b1b9c44342ed6afa7.jpg",
388
+ "image_caption": [
389
+ "Table 3: Distribution of success rates on templates with $\\geq 1$ successful executions on GPT models (no UA hint). "
390
+ ],
391
+ "image_footnote": [],
392
+ "page_idx": 7
393
+ },
394
+ {
395
+ "type": "text",
396
+ "text": "",
397
+ "page_idx": 7
398
+ },
399
+ {
400
+ "type": "table",
401
+ "img_path": "images/70227ad88f52d3b8b48f422395392cc6e02093006e2103ecad840032d9fb94a2.jpg",
402
+ "table_caption": [],
403
+ "table_footnote": [],
404
+ "table_body": "<table><tr><td>Benchmark</td><td>Dyramio?</td><td>Envraistent?</td><td>HuDineras?</td><td>Functional?</td></tr><tr><td>Mind2WoB (3)</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>xx/</td><td></td><td></td><td>xx</td></tr><tr><td>MiniWoB++</td><td>(Liu et al., 2018)</td><td>√</td><td>//x</td><td></td><td></td></tr><tr><td>Webshop</td><td>(Yao et al., 2022a)</td><td></td><td></td><td></td><td></td></tr><tr><td>ALFRED</td><td>(Shridhar et al.,2020)</td><td></td><td>×</td><td>//xxx/</td><td></td></tr><tr><td>VirtualHome</td><td>(Puig et al., 2018)</td><td></td><td></td><td></td><td>X</td></tr><tr><td>AndroidEnv</td><td>(Toyama et al., 2021)</td><td></td><td></td><td>X</td><td>X</td></tr><tr><td colspan=\"2\">WebArena</td><td></td><td>√</td><td>√</td><td></td></tr></table>",
405
+ "page_idx": 8
406
+ },
407
+ {
408
+ "type": "text",
409
+ "text": "Table 4: The comparison between our benchmark and existing benchmarks on grounding natural language instructions to concrete executions. Our benchmark is implemented in our fully interactable highly-realistic environment. It features diverse tasks humans may encounter in their daily routines. We design evaluation metrics to assess the functional correctness of task executions. ",
410
+ "page_idx": 8
411
+ },
412
+ {
413
+ "type": "text",
414
+ "text": "enabling the reuse of successful strategies from past experiments Zhou et al. (2022a); Wang et al. \n(2023). More error analysis with examples can be found in Appendix A.10. ",
415
+ "page_idx": 8
416
+ },
417
+ {
418
+ "type": "text",
419
+ "text": "6 RELATED WORK ",
420
+ "text_level": 1,
421
+ "page_idx": 8
422
+ },
423
+ {
424
+ "type": "text",
425
+ "text": "Benchmarks for Controlling Agents through Natural Language Controlling agents via natural language in the digital world have been studied in the literature (Branavan et al., 2009; Shi et al., 2017; Liu et al., 2018; Toyama et al., 2021; Deng et al., 2023; Li et al., 2020; Xu et al., 2021). However, the balance between functionality, authenticity, and support for environmental dynamics remains a challenge. Existing benchmarks often compromise these aspects, as shown in Table 4. Some works rely on static states, limiting agents’ explorations and functional correctness evaluation (Shi et al., 2017; Deng et al., 2023), while others simplify real-world complexities, restricting task variety (Yao et al., 2022a; Liu et al., 2018). While AndroidEnv (Toyama et al., 2021) replicates an Android setup, it does not guarantee the reproducibility since live Android applications are used. (Kolve et al., 2017; Shridhar et al., 2020; Puig et al., 2018) and extends to gaming environments (Fan et al., 2022; Küttler et al., 2020), where the environment mechanisms often diverge from human objectives. ",
426
+ "page_idx": 8
427
+ },
428
+ {
429
+ "type": "text",
430
+ "text": "Interactive Decision-Making Agents Nakano et al. (2021) introduce WebGPT which searches the web and reads the search results to answer questions. Gur et al. (2023) propose a web agent that synthesizes Javascript code for the task executions. Adding a multi-modal dimension, Lee et al. (2023) and Shaw et al. (2023) develop agents that predict actions based on screenshots of web pages rather than relying on the text-based DOM trees. Performing tasks in interactive environments requires the agents to exhibit several capabilities including hierarchical planning, state tracking, and error recovery. Existing works (Huang et al., 2022; Madaan et al., 2022; Li et al., 2023) observe LLMs could break a task into more manageable sub-tasks (Zhou et al., 2022b). This process can be further refined by representing task executions as programs, a technique that aids sub-task management and skill reuse (Zhou et al., 2022a; Liang et al., 2023; Wang et al., 2023; Gao et al., 2023). Meanwhile, search and backtracking methods introduce a more structured approach to planning while also allowing for decision reconsideration (Yao et al., 2023; Long, 2023). Existing works also incorporate failure recovery, self-correction (Shinn et al., 2023; Kim et al., 2023), observation summarization (Sridhar et al., 2023) to improve execution robustness. The complexity of WebArena presents a unique challenge and opportunity for further testing and improvement of these methods. ",
431
+ "page_idx": 8
432
+ },
433
+ {
434
+ "type": "text",
435
+ "text": "7 CONCLUSION ",
436
+ "text_level": 1,
437
+ "page_idx": 8
438
+ },
439
+ {
440
+ "type": "text",
441
+ "text": "We present WebArena, a highly-realistic, standalone, and reproducible web environment designed for the development and testing of autonomous agents. WebArena includes fully functional web applications and organic data from popular domains. Additionally, we curate a comprehensive benchmark consisting of 812 examples that focus on mapping high-level natural language intents into concrete web interactions. We also offer outcome-based evaluation that programmatically validate the tasks success. Our experiments show that even GPT-4 only achieves a limited end-to-end task success rate of $1 4 . 4 1 \\%$ , significantly lagging behind the human performance of $7 8 . 2 4 \\%$ . These findings underscore the need for future research to focus on enhancing the robustness and efficacy of autonomous agents within WebArena environment. ",
442
+ "page_idx": 8
443
+ },
444
+ {
445
+ "type": "text",
446
+ "text": "ACKNOWLEDGEMENT ",
447
+ "text_level": 1,
448
+ "page_idx": 9
449
+ },
450
+ {
451
+ "type": "text",
452
+ "text": "We would like to thank Emmy Liu, Zhiruo Wang, Zhitong Guo for examining our annotations, Shunyu Yao for providing the raw Amazon product data in Webshop, Pengfei Liu, Zaid Sheikh and Aman Madaan for the helpful discussions. We are also grateful to the Center for AI Safety for providing computational resources. This material is partly based on research sponsored in part by the Air Force Research Laboratory under agreement number FA8750-19-2-0200. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the Air Force Research Laboratory or the U.S. Government. This project was also partially supported by a gift from AWS AI. ",
453
+ "page_idx": 9
454
+ },
455
+ {
456
+ "type": "text",
457
+ "text": "REFERENCES ",
458
+ "text_level": 1,
459
+ "page_idx": 9
460
+ },
461
+ {
462
+ "type": "text",
463
+ "text": "Peter Anderson, Qi Wu, Damien Teney, Jake Bruce, Mark Johnson, Niko Sünderhauf, Ian D. Reid, Stephen Gould, and Anton van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18- 22, 2018, pp. 3674–3683. IEEE Computer Society, 2018. doi: 10.1109/CVPR.2018.00387. URL http://openaccess.thecvf.com/content_cvpr_2018/html/Anderson_ Vision-and-Language_Navigation_Interpreting_CVPR_2018_paper.html. \nRohan Anil, Andrew M. Dai, Orhan Firat, Melvin Johnson, Dmitry Lepikhin, Alexandre Passos, Siamak Shakeri, Emanuel Taropa, Paige Bailey, Zhifeng Chen, Eric Chu, Jonathan H. Clark, Laurent El Shafey, Yanping Huang, Kathy Meier-Hellstern, Gaurav Mishra, Erica Moreira, Mark Omernick, Kevin Robinson, Sebastian Ruder, Yi Tay, Kefan Xiao, Yuanzhong Xu, Yujing Zhang, Gustavo Hernandez Abrego, Junwhan Ahn, Jacob Austin, Paul Barham, Jan Botha, James Bradbury, Siddhartha Brahma, Kevin Brooks, Michele Catasta, Yong Cheng, Colin Cherry, Christopher A. Choquette-Choo, Aakanksha Chowdhery, Clément Crepy, Shachi Dave, Mostafa Dehghani, Sunipa Dev, Jacob Devlin, Mark Díaz, Nan Du, Ethan Dyer, Vlad Feinberg, Fangxiaoyu Feng, Vlad Fienber, Markus Freitag, Xavier Garcia, Sebastian Gehrmann, Lucas Gonzalez, Guy Gur-Ari, Steven Hand, Hadi Hashemi, Le Hou, Joshua Howland, Andrea Hu, Jeffrey Hui, Jeremy Hurwitz, Michael Isard, Abe Ittycheriah, Matthew Jagielski, Wenhao Jia, Kathleen Kenealy, Maxim Krikun, Sneha Kudugunta, Chang Lan, Katherine Lee, Benjamin Lee, Eric Li, Music Li, Wei Li, YaGuang Li, Jian Li, Hyeontaek Lim, Hanzhao Lin, Zhongtao Liu, Frederick Liu, Marcello Maggioni, Aroma Mahendru, Joshua Maynez, Vedant Misra, Maysam Moussalem, Zachary Nado, John Nham, Eric Ni, Andrew Nystrom, Alicia Parrish, Marie Pellat, Martin Polacek, Alex Polozov, Reiner Pope, Siyuan Qiao, Emily Reif, Bryan Richter, Parker Riley, Alex Castro Ros, Aurko Roy, Brennan Saeta, Rajkumar Samuel, Renee Shelby, Ambrose Slone, Daniel Smilkov, David R. So, Daniel Sohn, Simon Tokumine, Dasha Valter, Vijay Vasudevan, Kiran Vodrahalli, Xuezhi Wang, Pidong Wang, Zirui Wang, Tao Wang, John Wieting, Yuhuai Wu, Kelvin Xu, Yunhan Xu, Linting Xue, Pengcheng Yin, Jiahui Yu, Qiao Zhang, Steven Zheng, Ce Zheng, Weikang Zhou, Denny Zhou, Slav Petrov, and Yonghui Wu. Palm 2 technical report, 2023. \nYonatan Bisk, Jan Buys, Karl Pichotta, and Yejin Choi. Benchmarking hierarchical script knowledge. 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. 4077–4085, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1412. URL https://aclanthology.org/N19-1412. \nS.R.K. Branavan, Harr Chen, Luke Zettlemoyer, and Regina Barzilay. Reinforcement learning for mapping instructions to actions. In Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP, pp. 82–90, Suntec, Singapore, 2009. Association for Computational Linguistics. URL https://aclanthology.org/P09-1010. \nGreg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym, 2016. URL https://arxiv.org/abs/1606.01540. ",
464
+ "page_idx": 9
465
+ },
466
+ {
467
+ "type": "text",
468
+ "text": "Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. ArXiv preprint, abs/2107.03374, 2021. URL https://arxiv.org/abs/2107. 03374. ",
469
+ "page_idx": 10
470
+ },
471
+ {
472
+ "type": "text",
473
+ "text": "Xiang Deng, Yu Gu, Boyuan Zheng, Shijie Chen, Samuel Stevens, Boshi Wang, Huan Sun, and Yu Su. Mind2web: Towards a generalist agent for the web, 2023. ",
474
+ "page_idx": 10
475
+ },
476
+ {
477
+ "type": "text",
478
+ "text": "Linxi Fan, Guanzhi Wang, Yunfan Jiang, Ajay Mandlekar, Yuncong Yang, Haoyi Zhu, Andrew Tang, De-An Huang, Yuke Zhu, and Anima Anandkumar. Minedojo: Building open-ended embodied agents with internet-scale knowledge. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022. URL https://openreview.net/forum? id=rc8o_j8I8PX. ",
479
+ "page_idx": 10
480
+ },
481
+ {
482
+ "type": "text",
483
+ "text": "Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. Pal: Program-aided language models. In International Conference on Machine Learning, pp. 10764–10799. PMLR, 2023. ",
484
+ "page_idx": 10
485
+ },
486
+ {
487
+ "type": "text",
488
+ "text": "Daniel Gordon, Aniruddha Kembhavi, Mohammad Rastegari, Joseph Redmon, Dieter Fox, and Ali Farhadi. IQA: visual question answering in interactive environments. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018, pp. 4089–4098. IEEE Computer Society, 2018. doi: 10.1109/CVPR. 2018.00430. URL http://openaccess.thecvf.com/content_cvpr_2018/html/ Gordon_IQA_Visual_Question_CVPR_2018_paper.html. ",
489
+ "page_idx": 10
490
+ },
491
+ {
492
+ "type": "text",
493
+ "text": "Izzeddin Gur, Hiroki Furuta, Austin Huang, Mustafa Safdari, Yutaka Matsuo, Douglas Eck, and Aleksandra Faust. A real-world webagent with planning, long context understanding, and program synthesis. arXiv preprint arXiv:2307.12856, 2023. ",
494
+ "page_idx": 10
495
+ },
496
+ {
497
+ "type": "text",
498
+ "text": "Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zeroshot planners: Extracting actionable knowledge for embodied agents. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato (eds.), International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 9118–9147. PMLR, 2022. URL https://proceedings.mlr.press/v162/huang22a.html. ",
499
+ "page_idx": 10
500
+ },
501
+ {
502
+ "type": "text",
503
+ "text": "Yacine Jernite, Kavya Srinet, Jonathan Gray, and Arthur Szlam. CraftAssist Instruction Parsing: Semantic Parsing for a Minecraft Assistant. ArXiv preprint, abs/1905.01978, 2019. URL https: //arxiv.org/abs/1905.01978. ",
504
+ "page_idx": 10
505
+ },
506
+ {
507
+ "type": "text",
508
+ "text": "Geunwoo Kim, Pierre Baldi, and Stephen McAleer. Language models can solve computer tasks. ArXiv preprint, abs/2303.17491, 2023. URL https://arxiv.org/abs/2303.17491. ",
509
+ "page_idx": 10
510
+ },
511
+ {
512
+ "type": "text",
513
+ "text": "Eric Kolve, Roozbeh Mottaghi, Winson Han, Eli VanderBilt, Luca Weihs, Alvaro Herrasti, Daniel Gordon, Yuke Zhu, Abhinav Gupta, and Ali Farhadi. AI2-THOR: An Interactive 3D Environment for Visual AI. arXiv, 2017. ",
514
+ "page_idx": 10
515
+ },
516
+ {
517
+ "type": "text",
518
+ "text": "Heinrich Küttler, Nantas Nardelli, Alexander H. Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The nethack learning environment. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and HsuanTien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.neurips.cc/paper/2020/hash/ 569ff987c643b4bedf504efda8f786c2-Abstract.html. ",
519
+ "page_idx": 10
520
+ },
521
+ {
522
+ "type": "text",
523
+ "text": "Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: A benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:452–466, 2019. doi: 10.1162/tacl_a_00276. URL https://aclanthology.org/Q19-1026. ",
524
+ "page_idx": 10
525
+ },
526
+ {
527
+ "type": "text",
528
+ "text": "Yann LeCun. A path towards autonomous machine intelligence version 0.9. 2, 2022-06-27. Open Review, 62, 2022. ",
529
+ "page_idx": 11
530
+ },
531
+ {
532
+ "type": "text",
533
+ "text": "Kenton Lee, Mandar Joshi, Iulia Raluca Turc, Hexiang Hu, Fangyu Liu, Julian Martin Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, and Kristina Toutanova. Pix2struct: Screenshot parsing as pretraining for visual language understanding. In International Conference on Machine Learning, pp. 18893–18912. PMLR, 2023. ",
534
+ "page_idx": 11
535
+ },
536
+ {
537
+ "type": "text",
538
+ "text": "Xinze Li, Yixin Cao, Muhao Chen, and Aixin Sun. Take a break in the middle: Investigating subgoals towards hierarchical script generation. ArXiv preprint, abs/2305.10907, 2023. URL https://arxiv.org/abs/2305.10907. ",
539
+ "page_idx": 11
540
+ },
541
+ {
542
+ "type": "text",
543
+ "text": "Yang Li, Jiacong He, Xin Zhou, Yuan Zhang, and Jason Baldridge. Mapping natural language instructions to mobile UI action sequences. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 8198–8210, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.729. URL https: //aclanthology.org/2020.acl-main.729. ",
544
+ "page_idx": 11
545
+ },
546
+ {
547
+ "type": "text",
548
+ "text": "Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, and Andy Zeng. Code as policies: Language model programs for embodied control. In 2023 IEEE International Conference on Robotics and Automation (ICRA), pp. 9493–9500. IEEE, 2023. ",
549
+ "page_idx": 11
550
+ },
551
+ {
552
+ "type": "text",
553
+ "text": "Evan Zheran Liu, Kelvin Guu, Panupong Pasupat, Tianlin Shi, and Percy Liang. Reinforcement learning on web interfaces using workflow-guided exploration. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id= ryTp3f-0-. ",
554
+ "page_idx": 11
555
+ },
556
+ {
557
+ "type": "text",
558
+ "text": "Jieyi Long. Large language model guided tree-of-thought. ArXiv preprint, abs/2305.08291, 2023. URL https://arxiv.org/abs/2305.08291. ",
559
+ "page_idx": 11
560
+ },
561
+ {
562
+ "type": "text",
563
+ "text": "Aman Madaan, Shuyan Zhou, Uri Alon, Yiming Yang, and Graham Neubig. Language models of code are few-shot commonsense learners. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 1384–1403, Abu Dhabi, United Arab Emirates, 2022. Association for Computational Linguistics. URL https://aclanthology.org/ 2022.emnlp-main.90. ",
564
+ "page_idx": 11
565
+ },
566
+ {
567
+ "type": "text",
568
+ "text": "Dipendra K Misra, Jaeyong Sung, Kevin Lee, and Ashutosh Saxena. Tell me dave: Context-sensitive grounding of natural language to manipulation instructions. The International Journal of Robotics Research, 35(1-3):281–300, 2016. ",
569
+ "page_idx": 11
570
+ },
571
+ {
572
+ "type": "text",
573
+ "text": "Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021. ",
574
+ "page_idx": 11
575
+ },
576
+ {
577
+ "type": "text",
578
+ "text": "OpenAI. Chatgpt: Optimizing language models for dialogue. 2022. ",
579
+ "page_idx": 11
580
+ },
581
+ {
582
+ "type": "text",
583
+ "text": "OpenAI. Gpt-4 technical report. arXiv, pp. 2303–08774, 2023. ",
584
+ "page_idx": 11
585
+ },
586
+ {
587
+ "type": "text",
588
+ "text": "Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35: 27730–27744, 2022. ",
589
+ "page_idx": 11
590
+ },
591
+ {
592
+ "type": "text",
593
+ "text": "Xavier Puig, Kevin Ra, Marko Boben, Jiaman Li, Tingwu Wang, Sanja Fidler, and Antonio Torralba. Virtualhome: Simulating household activities via programs. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018, pp. 8494–8502. IEEE Computer Society, 2018. doi: 10.1109/CVPR. 2018.00886. URL http://openaccess.thecvf.com/content_cvpr_2018/html/ Puig_VirtualHome_Simulating_Household_CVPR_2018_paper.html. ",
594
+ "page_idx": 11
595
+ },
596
+ {
597
+ "type": "text",
598
+ "text": "Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264. URL https://aclanthology.org/D16-1264. ",
599
+ "page_idx": 12
600
+ },
601
+ {
602
+ "type": "text",
603
+ "text": "Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for SQuAD. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 784–789, Melbourne, Australia, 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-2124. URL https://aclanthology. org/P18-2124. ",
604
+ "page_idx": 12
605
+ },
606
+ {
607
+ "type": "text",
608
+ "text": "Peter Shaw, Mandar Joshi, James Cohan, Jonathan Berant, Panupong Pasupat, Hexiang Hu, Urvashi Khandelwal, Kenton Lee, and Kristina Toutanova. From pixels to ui actions: Learning to follow instructions via graphical user interfaces. arXiv preprint arXiv:2306.00245, 2023. ",
609
+ "page_idx": 12
610
+ },
611
+ {
612
+ "type": "text",
613
+ "text": "Tianlin Shi, Andrej Karpathy, Linxi Fan, Jonathan Hernandez, and Percy Liang. World of bits: An open-domain platform for web-based agents. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, volume 70 of Proceedings of Machine Learning Research, pp. 3135– 3144. PMLR, 2017. URL http://proceedings.mlr.press/v70/shi17a.html. ",
614
+ "page_idx": 12
615
+ },
616
+ {
617
+ "type": "text",
618
+ "text": "Noah Shinn, Beck Labash, and Ashwin Gopinath. Reflexion: an autonomous agent with dynamic memory and self-reflection. ArXiv preprint, abs/2303.11366, 2023. URL https://arxiv. org/abs/2303.11366. ",
619
+ "page_idx": 12
620
+ },
621
+ {
622
+ "type": "text",
623
+ "text": "Mohit Shridhar, Jesse Thomason, Daniel Gordon, Yonatan Bisk, Winson Han, Roozbeh Mottaghi, Luke Zettlemoyer, and Dieter Fox. ALFRED: A benchmark for interpreting grounded instructions for everyday tasks. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pp. 10737–10746. IEEE, 2020. doi: 10. 1109/CVPR42600.2020.01075. URL https://doi.org/10.1109/CVPR42600.2020. 01075. ",
624
+ "page_idx": 12
625
+ },
626
+ {
627
+ "type": "text",
628
+ "text": "Mohit Shridhar, Xingdi Yuan, Marc-Alexandre Côté, Yonatan Bisk, Adam Trischler, and Matthew J. Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum?id= 0IOX0YcCdTn. ",
629
+ "page_idx": 12
630
+ },
631
+ {
632
+ "type": "text",
633
+ "text": "Abishek Sridhar, Robert Lo, Frank F Xu, Hao Zhu, and Shuyan Zhou. Hierarchical prompting assists large language model on web navigation. arXiv preprint arXiv:2305.14257, 2023. ",
634
+ "page_idx": 12
635
+ },
636
+ {
637
+ "type": "text",
638
+ "text": "Daniel Toyama, Philippe Hamel, Anita Gergely, Gheorghe Comanici, Amelia Glaese, Zafarali Ahmed, Tyler Jackson, Shibl Mourad, and Doina Precup. Androidenv: A reinforcement learning platform for android. ArXiv preprint, abs/2105.13231, 2021. URL https://arxiv.org/abs/2105. 13231. ",
639
+ "page_idx": 12
640
+ },
641
+ {
642
+ "type": "text",
643
+ "text": "Guanzhi Wang, Yuqi Xie, Yunfan Jiang, Ajay Mandlekar, Chaowei Xiao, Yuke Zhu, Linxi Fan, and Anima Anandkumar. Voyager: An open-ended embodied agent with large language models. ArXiv preprint, abs/2305.16291, 2023. URL https://arxiv.org/abs/2305.16291. ",
644
+ "page_idx": 12
645
+ },
646
+ {
647
+ "type": "text",
648
+ "text": "Zhiruo Wang, Shuyan Zhou, Daniel Fried, and Graham Neubig. Execution-based evaluation for open-domain code generation. ArXiv preprint, abs/2212.10481, 2022. URL https://arxiv. org/abs/2212.10481. ",
649
+ "page_idx": 12
650
+ },
651
+ {
652
+ "type": "text",
653
+ "text": "Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35:24824–24837, 2022. ",
654
+ "page_idx": 12
655
+ },
656
+ {
657
+ "type": "text",
658
+ "text": "Nancy Xu, Sam Masling, Michael Du, Giovanni Campagna, Larry Heck, James Landay, and Monica Lam. Grounding open-domain instructions to automate web support tasks. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 1022–1032, Online, 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.80. URL https://aclanthology.org/ 2021.naacl-main.80. ",
659
+ "page_idx": 12
660
+ },
661
+ {
662
+ "type": "text",
663
+ "text": "Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2369–2380, Brussels, Belgium, 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1259. URL https://aclanthology.org/D18-1259. \nShunyu Yao, Howard Chen, John Yang, and Karthik Narasimhan. Webshop: Towards scalable real-world web interaction with grounded language agents. volume abs/2207.01206, 2022a. URL https://arxiv.org/abs/2207.01206. \nShunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. ArXiv preprint, abs/2210.03629, 2022b. URL https://arxiv.org/abs/2210.03629. \nShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. ArXiv preprint, abs/2305.10601, 2023. URL https://arxiv.org/abs/2305.10601. \nVictor Zhong, Caiming Xiong, and Richard Socher. Seq2sql: Generating structured queries from natural language using reinforcement learning. arxiv 2017. ArXiv preprint, abs/1709.00103, 2017. URL https://arxiv.org/abs/1709.00103. \nShuyan Zhou, Pengcheng Yin, and Graham Neubig. Hierarchical control of situated agents through natural language. In Proceedings of the Workshop on Structured and Unstructured Knowledge Integration (SUKI), pp. 67–84, Seattle, USA, 2022a. Association for Computational Linguistics. doi: 10.18653/v1/2022.suki-1.8. URL https://aclanthology.org/2022.suki-1.8. \nShuyan Zhou, Li Zhang, Yue Yang, Qing Lyu, Pengcheng Yin, Chris Callison-Burch, and Graham Neubig. Show me more details: Discovering hierarchies of procedures from semi-structured web data. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2998–3012, Dublin, Ireland, 2022b. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.214. URL https://aclanthology.org/ 2022.acl-long.214. ",
664
+ "page_idx": 13
665
+ },
666
+ {
667
+ "type": "text",
668
+ "text": "A APPENDIX ",
669
+ "text_level": 1,
670
+ "page_idx": 14
671
+ },
672
+ {
673
+ "type": "text",
674
+ "text": "A.1 WEBSITE IMPLEMENTATION ",
675
+ "text_level": 1,
676
+ "page_idx": 14
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "Given the selected websites described in $\\ S 2 . 2$ , we make the best attempt to reproduce the functionality of commonly used sites in a reproducible way. To achieve this, we utilized open-source frameworks for the development of the websites across various categories and imported data from their real-world counterparts. For the E-commerce category, we constructed a shopping website with approximately $9 0 k$ products, including the prices, options, detailed product descriptions, images, and reviews, spanning over 300 product categories. This website is developed using Adobe Magento, an opensource e-commerce platform4. Data resources were obtained from data from actual online sites, such as that included in the Webshop data dumpYao et al. (2022a). As for the social forum platform, we deployed an open-source software Postmill5, the open-sourced counterpart of Reddit6. We sampled from the top 50 subreddits7. We then manually selected many subreddit for northeast US cities as well as subreddit for machine learning and deep learning-related topics. This manual selection encourages cross-website tasks such as seeking information related to the northeast US on both Reddit and the map. In total, we have 95 subreddits, 127390 posts, and 661781 users. For the collaborative software development platform, we choose GitLab8. We heuristically simulate the code repository characteristics by sampling at least ten repositories for every programming language: $8 0 \\%$ of them are sampled from the set of top 90 percentile wrt stars repos using a discrete probability distribution weighted proportional to their number of stars; the remaining are sampled from the bottom ten percentile set using similar weighted distribution. This is done to ensure fair representation of repos of all kinds, from popular projects with many issues and pull requests to small personal projects. In total, we have 300 repositories and more than 1000 accounts with at least one commit to a repository. For the content management system, we adapted Adobe Magento’s admin portal, deploying the sample data provided in the official guide. We employ OpenStreetMap9 for map service implementation, confining our focus to the northeast US region due to data storage constraints. We implement a calculator and a scratchpad ourselves. ",
681
+ "page_idx": 14
682
+ },
683
+ {
684
+ "type": "text",
685
+ "text": "Lastly, we configure the knowledge resources as individual websites, complemented with search functionality for efficient information retrieval. Specifically, we utilize Kiwix10 to host an offline version of English Wikipedia with a knowledge cutoff of May 2023. The user manuals for GitLab and Adobe Commerce Merchant documentation are scraped from the official websites. ",
686
+ "page_idx": 14
687
+ },
688
+ {
689
+ "type": "text",
690
+ "text": "A.2 ENVIRONMENT DELIVERY AND RESET ",
691
+ "text_level": 1,
692
+ "page_idx": 14
693
+ },
694
+ {
695
+ "type": "text",
696
+ "text": "One goal for our evaluation environment is ease of use and reproducibility. As a result, we deploy our websites in separate Docker images 11, one per website. The Docker images are fully self-contained with all the code of the website, database, as well as any other software dependencies. They also do not rely on external volume mounts to function, as the data of the websites are also part of the docker image. This way, the image is easy to distribution containing all the pre-populated websites for reproducible evaluation. End users can download our packaged Docker images and run them on their systems and re-deploy the exact websites together with the data used in our benchmarks for their local benchmarking. ",
697
+ "page_idx": 14
698
+ },
699
+ {
700
+ "type": "text",
701
+ "text": "Since some evaluation cases may require the agent to modify the data contained in the website, e.g., creating a new user, deleting a post, etc., it is crucial to be able to easily reset the website environment to its initial state. With Docker images, the users could stop and delete the currently running containers for that website and start the container from our original image again to fully reset the environment to the initial state. Depending on the website, this process may take from a few seconds to one minute. However, not all evaluation cases would require an environment reset, as many of the intents are information gathering and are read-only for the website data. Also, combined with the inference time cost for the agent LLMs, we argue that this environment reset method, through restarting Docker containers from the original images, will have a non-negligible but small impact on evaluation time. ",
702
+ "page_idx": 14
703
+ },
704
+ {
705
+ "type": "image",
706
+ "img_path": "images/4453eb3ed727d83d96dd9d746537edaeb5c408cd69d1d382d35aee15bcd026d7.jpg",
707
+ "image_caption": [
708
+ "Figure 6: The intent distribution across different websites. Cross-site intents necessitate interacting with multiple websites. Notably, regardless of the website, all user intents require interactions with multiple web pages. "
709
+ ],
710
+ "image_footnote": [],
711
+ "page_idx": 15
712
+ },
713
+ {
714
+ "type": "text",
715
+ "text": "",
716
+ "page_idx": 15
717
+ },
718
+ {
719
+ "type": "text",
720
+ "text": "A.3 USER ROLES SIMULATION ",
721
+ "text_level": 1,
722
+ "page_idx": 15
723
+ },
724
+ {
725
+ "type": "text",
726
+ "text": "Users of the same website often have disparate experiences due to their distinct roles, permissions, and interaction histories. For instance, within an E-commerce CMS, a shop owner might possess full read and write permissions across all content, whereas an employee might only be granted write permissions for products but not for customer data. We aim to emulate this scenario by generating unique user profiles on each platform. ",
727
+ "page_idx": 15
728
+ },
729
+ {
730
+ "type": "text",
731
+ "text": "On the shopping site, we created a customer profile that has over 35 orders within a span of two years. On GitLab, we selected a user who maintains several popular open-source projects with numerous merge requests and issues. This user also manages a handful of personal projects privately. On Reddit, our chosen profile was a user who actively participates in discussions, with many posts and comments. Lastly, on our E-commerce CMS, we set up a user profile for a shop owner who has full read-and-write access to all system contents. ",
732
+ "page_idx": 15
733
+ },
734
+ {
735
+ "type": "text",
736
+ "text": "All users are automatically logged into their accounts using a pre-cached cookie. To our best knowledge, this is the first publicly available agent evaluation environment to implement such a characteristic. Existing literature typically operates under the assumption of universally identical user roles Shi et al. (2017); Liu et al. (2018); Deng et al. (2023). ",
737
+ "page_idx": 15
738
+ },
739
+ {
740
+ "type": "text",
741
+ "text": "A.4 INTENT DISTRIBUTION ",
742
+ "text_level": 1,
743
+ "page_idx": 15
744
+ },
745
+ {
746
+ "type": "text",
747
+ "text": "The distribution of intents across the websites are shown in Figure 6. ",
748
+ "page_idx": 15
749
+ },
750
+ {
751
+ "type": "text",
752
+ "text": "A.5 HUMAN PERFORMANCE ",
753
+ "text_level": 1,
754
+ "page_idx": 15
755
+ },
756
+ {
757
+ "type": "text",
758
+ "text": "We acknowledge that there may be a difference in human performance when annotators with different demographics are involved. In fact, many tasks in our dataset require domain-specific knowledge. For instance, an average user may not know what a git merge request is; or how to create a product in a complex content management system. We aim to design tasks that have easy-to-imagine outcomes (e.g., a new product page is created) rather than those that are easily performed by an average user without significant domain knowledge. ",
759
+ "page_idx": 15
760
+ },
761
+ {
762
+ "type": "table",
763
+ "img_path": "images/cd1de76e36cae3550559952cd20c33f6f92081280dfcc9ef1c7ad4286e245657.jpg",
764
+ "table_caption": [
765
+ "Table 5: The task success rate $( \\mathrm { S R } \\% )$ of GPT-3.5-TURBO-16K-0613 with temperature 0.0. "
766
+ ],
767
+ "table_footnote": [],
768
+ "table_body": "<table><tr><td colspan=\"3\">CoT UA Hint Model SR</td></tr><tr><td>「</td><td>× GPT-3.5</td><td>6.28</td></tr></table>",
769
+ "page_idx": 16
770
+ },
771
+ {
772
+ "type": "table",
773
+ "img_path": "images/56a69b08d813ab6d29b40251f19ba947cbe80ef884fe618aabab58b65ce00406.jpg",
774
+ "table_caption": [],
775
+ "table_footnote": [],
776
+ "table_body": "<table><tr><td>Dataset</td><td>gpt-4-0613</td><td>gpt-4-1106-preview</td></tr><tr><td>Date (900 examples)</td><td>100</td><td>100</td></tr><tr><td>Time duration (900 examples)</td><td>100</td><td>100</td></tr></table>",
777
+ "page_idx": 16
778
+ },
779
+ {
780
+ "type": "text",
781
+ "text": "Table 6: The accuracy $( \\% )$ ) of two versions of GPT-4 on judging if dates and time duration of different formats are equivalent. ",
782
+ "page_idx": 16
783
+ },
784
+ {
785
+ "type": "text",
786
+ "text": "A.6 EXPERIMENT CONFIGURATIONS ",
787
+ "text_level": 1,
788
+ "page_idx": 16
789
+ },
790
+ {
791
+ "type": "text",
792
+ "text": "We experiment with GPT-3.5-TURBO-16K-0613, GPT-4-0613, and TEXT-BISON-001 with a temperature of 1.0 and a top- $p$ parameter of 0.9. The maximum number of state transitions is set to 30. We halt execution if the same action is repeated more than three times on the same observation or if the agent generates three consecutive invalid actions. These situations typically indicate a high likelihood of execution failure and hence warrant early termination. For TEXT-BISON-001, we additionally allow ten retries until it generates a valid action. ",
793
+ "page_idx": 16
794
+ },
795
+ {
796
+ "type": "text",
797
+ "text": "Primarily, we use a high temperature of 1.0 to encourage the exploration. To aid replicating the results, we provide the results of GPT-3.5-TURBO-16K-0613 with temperature 0.0 in Table 5 and the execution trajectories in our code repository. ",
798
+ "page_idx": 16
799
+ },
800
+ {
801
+ "type": "text",
802
+ "text": "A.7 PROMPT FOR F U Z Z Y_M A T C H",
803
+ "text_level": 1,
804
+ "page_idx": 16
805
+ },
806
+ {
807
+ "type": "table",
808
+ "img_path": "images/71e8601c57ce736bd965b7663e56b438ffe026217ffff20a72c0cc0db02fa141.jpg",
809
+ "table_caption": [],
810
+ "table_footnote": [
811
+ "Predictions that are judged as “correct” will receive a score of one, while all other predictions will receive a score of zero. "
812
+ ],
813
+ "table_body": "<table><tr><td>Help a teacher to grade the answer of a student given a question. Keep in mind that the student may use different phrasing or wording to answer the question. The goal is to evaluate whether the answer is semantically equivalent to the reference answer.</td></tr><tr><td>question: {{intent}} reference answer: { {reference answer}}</td></tr><tr><td> all the string &#x27;N/A&#x27; that you see is a special sequence that means &#x27;not achievable&#x27;</td></tr><tr><td>student answer: {{prediction}} Conclude the judgement by correct/incorrect/partially correct.</td></tr></table>",
814
+ "page_idx": 16
815
+ },
816
+ {
817
+ "type": "text",
818
+ "text": "A.8 THE ACCURACY OF FUZZY MATCH FUNCTION ",
819
+ "text_level": 1,
820
+ "page_idx": 16
821
+ },
822
+ {
823
+ "type": "text",
824
+ "text": "To evaluate this, we manually checked 40 examples and found that 39 of them are identical to our human judgment. In addition, among the 82 examples that require using GPT-4 for evaluation, the answer of 49 $( 6 0 \\% )$ examples is a date (e.g., 10/23/2022) or time duration (e.g., 15 minutes). In these cases, GPT-4 is only used to judge the different format of the answers. We quantitatively evaluate the correctness of GPT-4 in this case by generating different formats of a date and time duration programmatically. We randomly sample negative examples. For instance, Nov 3, 2022, November 3, 2022, 3rd November 2022, 3 Nov 2022, 2022-11-03, and 3rd of November, 2022 are all correct variances of 2022/11/03. The accuracy of GPT-4 is shown in Table 6. We can see that two versions of GPT-4 are extremely accurate, both achieving $100 \\%$ accuracy. ",
825
+ "page_idx": 16
826
+ },
827
+ {
828
+ "type": "text",
829
+ "text": "A.9 THE PROMPTS OF THE BASELINE WEB AGENTS",
830
+ "text_level": 1,
831
+ "page_idx": 16
832
+ },
833
+ {
834
+ "type": "text",
835
+ "text": "The system message of the reasoning agent for both GPT-3.5 and GPT-4 is in Figure 7, and two examples are in Figure 8. The system message of the direct agent for GPT-3.5 is in Figure 9 and the two examples are in Figure 10. UA hint refers to the instruction of “ If you believe the task is ",
836
+ "page_idx": 16
837
+ },
838
+ {
839
+ "type": "text",
840
+ "text": "You are an autonomous intelligent agent tasked with navigating a web browser. You will be given web-based tasks. These tasks will be accomplished through the use of specific actions you can issue. ",
841
+ "page_idx": 17
842
+ },
843
+ {
844
+ "type": "text",
845
+ "text": "Here’s the information you’ll have: \nThe user’s objective: This is the task you’re trying to complete. \nThe current web page’s accessibility tree: This is a simplified representation of the webpage, providing key information. \nThe current web page’s URL: This is the page you’re currently navigating. \nThe open tabs: These are the tabs you have open. \nThe previous action: This is the action you just performed. It may be helpful to track your progress. ",
846
+ "page_idx": 17
847
+ },
848
+ {
849
+ "type": "text",
850
+ "text": "The actions you can perform fall into several categories: ",
851
+ "page_idx": 17
852
+ },
853
+ {
854
+ "type": "text",
855
+ "text": "Page Operation Actions ",
856
+ "page_idx": 17
857
+ },
858
+ {
859
+ "type": "text",
860
+ "text": "\\`click [id]\\`: This action clicks on an element with a specific id on the webpage. \n\\`type [id] [content] [press_enter_after=0|1]\\`: Use this to type the content into the field with id. By default, the \"Enter\" key is pressed after typing unless press_enter_after is set to 0. \n\\`hover [id]\\`: Hover over an element with id. \n\\`press [key_comb]\\`: Simulates the pressing of a key combination on the keyboard (e.g., $\\mathrm { C t r l + v } ) ,$ ). \n\\`scroll [direction $1 =$ down|up]\\`: Scroll the page up or down. ",
861
+ "page_idx": 17
862
+ },
863
+ {
864
+ "type": "text",
865
+ "text": "Tab Management Actions: ",
866
+ "page_idx": 17
867
+ },
868
+ {
869
+ "type": "text",
870
+ "text": "\\`new_tab\\`: Open a new, empty browser tab. \n\\`tab_focus [tab_index]\\`: Switch the browser’s focus to a specific tab using its index. \n\\`close_tab\\`: Close the currently active tab. ",
871
+ "page_idx": 17
872
+ },
873
+ {
874
+ "type": "text",
875
+ "text": "URL Navigation Actions: ",
876
+ "page_idx": 17
877
+ },
878
+ {
879
+ "type": "text",
880
+ "text": "\\`goto [url]\\`: Navigate to a specific URL. \\`go_back\\`: Navigate to the previously viewed page. \\`go_forward\\`: Navigate to the next page (if a previous \\`go_back\\` action was performed). ",
881
+ "page_idx": 17
882
+ },
883
+ {
884
+ "type": "text",
885
+ "text": "Completion Action: ",
886
+ "page_idx": 17
887
+ },
888
+ {
889
+ "type": "text",
890
+ "text": "\\`stop [answer]\\`: Issue this action when you believe the task is complete. If the objective is to find a text-based answer, provide the answer in the bracket. If you believe the task is impossible to complete, provide the answer as \"N/A\" in the bracket. ",
891
+ "page_idx": 17
892
+ },
893
+ {
894
+ "type": "text",
895
+ "text": "Homepage: ",
896
+ "page_idx": 17
897
+ },
898
+ {
899
+ "type": "text",
900
+ "text": "If you want to visit other websites, check out the homepage at http://homepage.com. It has a list of websites you can visit. \nhttp://homepage.com/password.html lists all the account names and passwords for the websites. You can use them to log in to the websites. ",
901
+ "page_idx": 17
902
+ },
903
+ {
904
+ "type": "text",
905
+ "text": "To be successful, it is very important to follow the following rules: ",
906
+ "page_idx": 17
907
+ },
908
+ {
909
+ "type": "text",
910
+ "text": "1. You should only issue an action that is valid given the current observation \n2. You should only issue one action at a time. \n3. You should follow the examples to reason step by step and then issue the next action. \n4. Generate the action in the correct format. Start with a \"In summary, the next action I will perform is“ phrase, followed by action inside . For example, \"In summary, the next action I will perform is \\`\\`\\`click [1234]\\`\\`\\`”. \n5. Issue stop action when you think you have achieved the objective. Don’t generate anything after stop.\"\"\" ",
911
+ "page_idx": 17
912
+ },
913
+ {
914
+ "type": "text",
915
+ "text": "impossible to complete, provide the answer as \"N/A\" in the bracket.”. We remove this sentence in our ablation studies. ",
916
+ "page_idx": 17
917
+ },
918
+ {
919
+ "type": "text",
920
+ "text": "example_user \nOBSERVATION: \n[1744] link ’HP CB782A#ABA 640 Inkjet Fax Machine (Renewed)’ \n[1749] StaticText $\\$ 279.49$ ’ \n[1757] button ’Add to Cart’ \n[1760] button ’Add to Wish List’ [1761] button ’Add to Compare’ \nURL: http://onestopmarket.com/office-products/office-electronics.html \nOBJECTIVE: What is the price of HP Inkjet Fax Machine \nPREVIOUS ACTION: None ",
921
+ "page_idx": 18
922
+ },
923
+ {
924
+ "type": "text",
925
+ "text": "example_assistant ",
926
+ "text_level": 1,
927
+ "page_idx": 18
928
+ },
929
+ {
930
+ "type": "text",
931
+ "text": "Let’s think step-by-step. This page lists the information of HP Inkjet Fax Machine, which is the product identified in the objective. Its price is $\\$ 279.49$ . I think I have achieved the objective. I will issue the stop action with the answer. In summary, the next action I will perform is \\`\\`\\`stop [\\$279.49]\\`\\` ",
932
+ "page_idx": 18
933
+ },
934
+ {
935
+ "type": "text",
936
+ "text": "example_user ",
937
+ "text_level": 1,
938
+ "page_idx": 18
939
+ },
940
+ {
941
+ "type": "text",
942
+ "text": "OBSERVATION: ",
943
+ "page_idx": 18
944
+ },
945
+ {
946
+ "type": "text",
947
+ "text": "[164] textbox ’Search’ focused: True required: False \n[171] button ’Go’ \n[174] link ’Find directions between two points’ \n[212] heading ’Search Results’ \n[216] button ’Close’ \nURL: http://openstreetmap.org \nOBJECTIVE: Show me the restaurants near ABC \nPREVIOUS ACTION: None ",
948
+ "page_idx": 18
949
+ },
950
+ {
951
+ "type": "text",
952
+ "text": "example_assistant ",
953
+ "text_level": 1,
954
+ "page_idx": 18
955
+ },
956
+ {
957
+ "type": "text",
958
+ "text": "Let’s think step-by-step. This page has a search box whose ID is [164]. According to the nominatim rule of openstreetmap, I can search for the restaurants near a location by ¨restaurants near. I can submit my typing by pressing the Enter afterwards. In summary, the next action I will perform is \\`type [164] [restaurants near ABC] [1]\\`\\`\\` ",
959
+ "page_idx": 18
960
+ },
961
+ {
962
+ "type": "text",
963
+ "text": "Figure 8: The two examples provided as example_user and example_assistant for the reasoning agent. Before issuing the action, the agent first perform reasoning. ",
964
+ "page_idx": 18
965
+ },
966
+ {
967
+ "type": "text",
968
+ "text": "You are an autonomous intelligent agent tasked with navigating a web browser. You will be given web-based tasks. These tasks will be accomplished through the use of specific actions you can issue. Here’s the information you’ll have: \nThe user’s objective: This is the task you’re trying to complete. \nThe current web page’s accessibility tree: This is a simplified representation of the webpage, providing key information. \nThe current web page’s URL: This is the page you’re currently navigating. \nThe open tabs: These are the tabs you have open. \nThe previous action: This is the action you just performed. It may be helpful to track your progress. ",
969
+ "page_idx": 19
970
+ },
971
+ {
972
+ "type": "text",
973
+ "text": "The actions you can perform fall into several categories: ",
974
+ "page_idx": 19
975
+ },
976
+ {
977
+ "type": "text",
978
+ "text": "Page Operation Actions ",
979
+ "page_idx": 19
980
+ },
981
+ {
982
+ "type": "text",
983
+ "text": "\\`click [id]\\`: This action clicks on an element with a specific id on the webpage. ",
984
+ "page_idx": 19
985
+ },
986
+ {
987
+ "type": "text",
988
+ "text": "\\`type [id] [content] [press_enter_after=0|1] $\\because$ Use this to type the content into the field with id. By default, the \"Enter\" key is pressed after typing unless press_enter_after is set to 0. ",
989
+ "page_idx": 19
990
+ },
991
+ {
992
+ "type": "text",
993
+ "text": "\\`hover [id]\\`: Hover over an element with id. \n\\`press [key_comb]\\`: Simulates the pressing of a key combination on the keyboard (e.g., $\\mathrm { C t r l + v }$ ). \n\\`scroll [direction $1 =$ down|up]\\`: Scroll the page up or down. ",
994
+ "page_idx": 19
995
+ },
996
+ {
997
+ "type": "text",
998
+ "text": "Tab Management Actions: ",
999
+ "page_idx": 19
1000
+ },
1001
+ {
1002
+ "type": "text",
1003
+ "text": "\\`new_tab\\`: Open a new, empty browser tab. \n\\`tab_focus [tab_index]\\`: Switch the browser’s focus to a specific tab using its index. \n\\`close_tab\\`: Close the currently active tab. ",
1004
+ "page_idx": 19
1005
+ },
1006
+ {
1007
+ "type": "text",
1008
+ "text": "URL Navigation Actions: ",
1009
+ "page_idx": 19
1010
+ },
1011
+ {
1012
+ "type": "text",
1013
+ "text": "\\`goto [url]\\`: Navigate to a specific URL. \\`go_back\\`: Navigate to the previously viewed page. \\`go_forward\\`: Navigate to the next page (if a previous \\`go_back\\` action was performed). ",
1014
+ "page_idx": 19
1015
+ },
1016
+ {
1017
+ "type": "text",
1018
+ "text": "Completion Action: ",
1019
+ "page_idx": 19
1020
+ },
1021
+ {
1022
+ "type": "text",
1023
+ "text": "\\`stop [answer] $:$ Issue this action when you believe the task is complete. If the objective is to find a text-based answer, provide the answer in the bracket. If you believe the task is impossible to complete, provide the answer as \"N/A\" in the bracket. ",
1024
+ "page_idx": 19
1025
+ },
1026
+ {
1027
+ "type": "text",
1028
+ "text": "Homepage: ",
1029
+ "page_idx": 19
1030
+ },
1031
+ {
1032
+ "type": "text",
1033
+ "text": "If you want to visit other websites, check out the homepage at http://homepage.com. It has a list of websites you can visit. \nhttp://homepage.com/password.html lists all the account name and password for the websites. You can use them to log in to the websites. To be successful, it is very important to follow the following rules: \nTo be successful, it is very important to follow the following rules: \n1. You should only issue an action that is valid given the current observation \n2. You should only issue one action at a time. \n3. Generate the action in the correct format. Always put the action inside a pair of \\`\\`\\`. For example, \\`\\`\\`click [1234]\\`\\`\\` \n4. Issue stop action when you think you have achieved the objective. Don’t generate anything after stop .\"\"\" ",
1034
+ "page_idx": 19
1035
+ },
1036
+ {
1037
+ "type": "text",
1038
+ "text": "",
1039
+ "page_idx": 19
1040
+ },
1041
+ {
1042
+ "type": "text",
1043
+ "text": "Figure 9: The system message of the direct agent. This message has the general explanation of the task, the available actions and some notes on avoiding common failures. ",
1044
+ "page_idx": 19
1045
+ },
1046
+ {
1047
+ "type": "image",
1048
+ "img_path": "images/da5857d10f4f9931009e84ff833a885e1f5742688a8a76f4a7fa80f1bfbd8d1e.jpg",
1049
+ "image_caption": [
1050
+ "Figure 10: The two examples provided as example_user and example_assistant for the direct agent. The agent directly emits the next action given the observation. "
1051
+ ],
1052
+ "image_footnote": [],
1053
+ "page_idx": 20
1054
+ },
1055
+ {
1056
+ "type": "image",
1057
+ "img_path": "images/4be48ef1e493b5824824c0cb95f02997257a84cda9fc6933e1e4b6b23f695453.jpg",
1058
+ "image_caption": [
1059
+ "Figure 11: Two examples where the GPT-4 agent failed, along with their screenshot and the accessibility tree of the relevant sections (grey). On the left, the agent fails to proceed to the “Users” section to accomplish the task of “Fork all Facebook repos”; on the right, the agent repeats entering the same search query even though the observation indicates the input box is filled. "
1060
+ ],
1061
+ "image_footnote": [],
1062
+ "page_idx": 21
1063
+ },
1064
+ {
1065
+ "type": "text",
1066
+ "text": "A.10 ADDITIONAL ERROR ANALYSIS ",
1067
+ "page_idx": 21
1068
+ },
1069
+ {
1070
+ "type": "text",
1071
+ "text": "Observation Bias Realistic websites frequently present information on similar topics across various sections to ensure optimal user accessibility. However, a GPT-4 agent often demonstrates a tendency to latch onto the first related piece of information it encounters without sufficiently verifying its relevance or accuracy. For instance, the homepage of the E-Commerce CMS displays the best-selling items based on recent purchases, while historical best-seller data is typically accessed via a separate report. Presented with the task of “What is the top-1 best-selling product in $2 0 2 2 ^ { \\circ }$ , the GPT-4 agent defaults to leveraging the readily available information on the homepage, bypassing the necessary step of generating the report to obtain the accurate data. ",
1072
+ "page_idx": 21
1073
+ },
1074
+ {
1075
+ "type": "text",
1076
+ "text": "Failures in Observation Interpretation Interestingly, while GPT-4 is capable of summarizing the observations, it occasionally overlooks more granular information, such as the previously entered input. As in the right-hand example of Figure 11, [5172] StaticText indicates that the search term “DMV area” has already been entered. However, the agent disregards this detail and continuously issues the command type [2430] [DMV area] until it reaches the maximum step limit. Furthermore, the agent often neglects the previous action information that is provided alongside the observation. ",
1077
+ "page_idx": 21
1078
+ },
1079
+ {
1080
+ "type": "text",
1081
+ "text": "We hypothesize that these observed failures are related to the current pretraining and supervised fine-tuning on dialogues employed in GPT models Ouyang et al. (2022). These models are primarily trained to execute instructions given immediate observations (i.e.,, the dialogue history); thereby, they may exhibit a lack of explorations. Furthermore, in dialogue scenarios, subtle differences in NL expressions often have less impact on the overall conversation. As a result, models may tend to overlook minor variations in their observations. ",
1082
+ "page_idx": 21
1083
+ }
1084
+ ]
parse/test/oKn9c6ytLx/oKn9c6ytLx_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/oKn9c6ytLx/oKn9c6ytLx_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tBRNC6YemY/tBRNC6YemY.md ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gorilla: Large Language Model Connected with Massive APIs
2
+
3
+ Shishir G. Patil1∗ Tianjun Zhang1∗ Xin Wang2 Joseph E. Gonzalez1
4
+
5
+ 1UC Berkeley 2Microsoft Research
6
+
7
+ shishirpatil@berkeley.edu
8
+
9
+ # Abstract
10
+
11
+ Large Language Models (LLMs) have seen an impressive wave of advances, with models now excelling in a variety of tasks, such as mathematical reasoning and program synthesis. However, their potential to effectively use tools via API calls remains unfulfilled. This is a challenging task even for today’s state-of-the-art LLMs such as GPT-4 largely due to their unawareness of what APIs are available and how to use them in a frequently updated tool set. We develop Gorilla, a finetuned LLaMA model that surpasses the performance of GPT-4 on writing API calls. Trained with the novel Retriever Aware Training (RAT), when combined with a document retriever, Gorilla demonstrates a strong capability to adapt to test-time document changes, allowing flexible user updates or version changes. It also substantially mitigates the issue of hallucination, commonly encountered when prompting LLMs directly. To evaluate the model’s ability, we introduce APIBench, a comprehensive dataset consisting of HuggingFace, TorchHub, and TensorHub APIs. The successful integration of the retrieval system with Gorilla demonstrates the potential for LLMs to use tools more accurately, keep up with frequently updated documentation, and consequently increase the reliability and applicability of their outputs. Gorilla’s code, model, data, and demo are available at: https://gorilla.cs.berkeley.edu
12
+
13
+ # 1 Introduction
14
+
15
+ The use of APIs and Large Language Models [10, 5, 31, 6, 27, 28] has changed what it means to program. Previously, building complex machine learning software and systems required extensive time and specialized skills. Now with tools like the HuggingFace API, an engineer can set up a deep learning pipeline with a few lines of code. Instead of searching through StackOverflow and documentation, developers can ask models like GPT for solutions and receive immediate, actionable code with docstrings. However, using off-the-shelf LLMs to generate API calls remains unsolved because there are millions of available APIs which are frequently updated.
16
+
17
+ We connect LLM’s and massive API’s with Gorilla, a system which takes an instruction, for example “build me a classifier for medical images”, and provides the corresponding API call and relevant packages, along with a step-by-step explanation of the pipeline. Gorilla uses self-instruct, fine-tuning, and retrieval to enable LLMs to accurately select from a large, overlapping, and changing set tools expressed using their APIs and API documentation. Further, our novel retriever-aware training (RAT) enables the model to adapt to test-time changes of APIs such as evolution in versions and arguments.
18
+
19
+ With the development of API generation methods comes a question of how to evaluate, as many APIs will have overlapping functionality with nuanced limitations and constraints. Thus, we construct
20
+
21
+ Help me find an API to convert the spoken language in a recorded audio to text using Torch Hub.
22
+
23
+ ![](images/985f72e0a4de43205cb9b6e1a2e7b7ed7f0760188e8ab6105316bea5c90160cc.jpg)
24
+ Figure 1: Examples of API calls. Example API calls generated by GPT-4 [27], Claude [2], and Gorilla for the given prompt. In this example, GPT-4 presents a model that doesn’t exist, and Claude picks an incorrect library. In contrast, our Gorilla model can identify the task correctly and suggest a fully-qualified API call.
25
+
26
+ ![](images/7efac0aab0dc42d93cc88e676322ec3eb1318032d5fffc7b12b03442db0b8a7f.jpg)
27
+ Figure 2: Accuracy (vs) hallucination in four settings, that is, zero-shot (i.e., without any retriever), and with retrievers. Commonly used BM25 and GPT retrievers, and the oracle – returns relevant documents with perfect recall, indicating an upper bound. Higher in the graph (higher accuracy) and to the left (lower hallucination) is better. Across settings, our model, Gorilla, improves accuracy while reducing hallucination.
28
+
29
+ APIBench $\sim 1 6 0 0$ APIs) by scraping a large corpus of ML APIs and developing an evaluation framework that uses AST sub-tree matching to check functional correctness. Further, we draw a distinction between accuracy and hallucination, and propose an Abstract Syntax Tree (AST) based technique to measure hallucination.
30
+
31
+ Using APIBench, we finetune Gorilla, a LLaMA-7B-based model with document retrieval and show that it significantly outperforms both open-source and closed-source models like Claude and GPT-4 in terms of API functionality accuracy as well as a reduction in API argument hallucination errors. We show an example output in Fig. 1. Lastly, we highlight Gorilla’s capability to comprehend and reason about user-defined constraints when choosing between APIs, an essential requirement for LLMs trained to accomplish tasks.
32
+
33
+ To summarize, this paper makes the following contributions:
34
+
35
+ 1. We introduce Gorilla, the first system to enable large-scale API integration with LLMs, demonstrating state-of-the-art performance in generating accurate API calls across thousands of functions and libraries.
36
+ 2. We develop Retriever-Aware Training (RAT), a novel technique that enables LLMs to effectively utilize retrieved API documentation at inference time, improving both accuracy and adaptation to API changes.
37
+ 3. We present APIBench, a comprehensive benchmark of $\sim 1 6 0 0$ machine learning APIs, along with new AST-based evaluation metrics that precisely measure both functional correctness and API hallucination.
38
+
39
+ # 2 Related Work
40
+
41
+ By empowering LLMs to use tools [33], we can grant LLMs access to vastly larger and changing knowledge bases and accomplish complex computational tasks. By providing access to search technologies and databases, [24, 39, 35] demonstrated that we can augment LLMs to address a significantly larger and more dynamic knowledge space. Similarly, by providing access to computational tools, [39, 1, 49, 36, 37] demonstrated that LLMs can accomplish complex computational tasks. Consequently, leading LLM providers [27], have started to integrate plugins to allow LLMs to invoke external tools through APIs.
42
+
43
+ Large Language Models Recent strides in the field of LLMs have renovated many downstream domains [10, 40, 48, 47], not only in traditional natural language processing tasks but also in program synthesis. Many of these advances are achieved by augmenting pre-trained LLMs by prompting [44, 14] and instruction fine-tuning [11, 30, 43, 15]. Recent open-sourced models like LLaMa [40], Alpaca [38], and Vicuna [9] have furthered the understanding of LLMs and facilitated their experimentation. While our approach, Gorilla, incorporates techniques akin to those mentioned, its primary emphasis is on enhancing the LLMs’ ability to utilize millions of tools, as opposed to refining their conversational skills. Additionally, we pioneer the study of fine-tuning a base model by supplementing it with information retrieval - a first, to the best of our knowledge.
44
+
45
+ Tool Usage The discussion of tool usage within LLMs has seen an upsurge, with models like Toolformer taking the lead [33, 19, 20, 24]. Tools often incorporated include web-browsing [32], calculators [12, 39], translation systems [39], and Python interpreters [14]. While these efforts can be seen as preliminary explorations of marrying LLMs with tool usage, they generally focus on specific tools. Our paper, in contrast, aims to explore a vast array of tools (i.e., API calls) in an open-ended fashion, potentially covering a wide range of applications.
46
+
47
+ With the recent launch of Toolformer [33] highlights the exciting potential of using large language models (LLMs) for purposes beyond traditional chatbot applications. Moreover, the application of API calls in robotics has been explored to some extent [41, 4]. However, these works primarily aim at showcasing the potential of “prompting” LLMs rather than establishing a systematic method for evaluation and training (including fine-tuning). Our work, on the other hand, concentrates on systematic evaluation and building a pipeline for future use.
48
+
49
+ LLMs for Program Synthesis Harnessing LLMs for program synthesis has historically been a challenging task [22, 7, 45, 16, 13, 29]. Researchers have proposed an array of strategies to prompt LLMs to perform better in coding tasks, including in-context learning [44, 18, 7], task decomposition [17, 46], and self-debugging [8, 34]. Besides prompting, there have also been efforts to pretrain language models specifically for code generation [25, 21, 26].
50
+
51
+ DocPrompting [49] looked at choosing the right subset of code including API along with a retriever. Gorilla presents distinct advancements over DocPrompting. First, the way the data-sets are constructed are different, leading to intersting downstream artifacts. Gorilla focuses on model usages where we also collect detailed information about parameters, performance, efficiency, etc. This helps our trained model understand and respond to finer constraints for each API. Docprompting focuses on generic API calls but not on the details within an API call. Second, Gorilla introduces and uses the AST subtreematching evaluation metric that helps measure hallucination which we find are more representative of code structure and API accuracy compared to traiditional NLP metrics. Finally, Gorilla focuses on instruction-tuning method and has "agency" to interact with users while DocPrompting focuses on building an NLP-to-Code generative model. On equal footing, we demonstrate that Gorilla performs better than DocPrompting in Appendix A.3.
52
+
53
+ # 3 Methodology
54
+
55
+ We first describe APIBench, a comprehensive benchmark constructed from TorchHub, TensorHub, and HuggingFace API Model Cards. We begin by outlining the process of collecting the API dataset and how we generated instruction-answer pairs. We then introduce Gorilla, a novel training paradigm with an information–retriever incorporated into the training and inference pipelines. Finally, we present our AST tree matching evaluation metric.
56
+
57
+ ![](images/81cc98dd40b7f509fe2e642229d8b26278967a43dcabc59838befb9bcfd45a7f.jpg)
58
+ Figure 3: Gorilla: A system for enabling LLMs to interact with APIs. The upper half represents the training procedure as described in Sec 3. This is the most exhaustive API data-set for ML to the best of our knowledge. During inference (lower half), Gorilla supports two modes - with retrieval, and zero-shot. In this example, it is able to suggest the right API call for generating the image from the user’s natural language query.
59
+
60
+ # 3.1 Dataset Curation
61
+
62
+ To curate the dataset, we aggregate all model cards from HuggingFace’s “The Model Hub”, PyTorch Hub, and TensorFlow Hub. Throughout the rest of the paper, we call these HuggingFace, Torch Hub, and TensorFlow Hub respectively for brevity.
63
+
64
+ API Documentation The HuggingFace platform hosts and servers about 203,681 models. However, many of them have poor documentation, lack dependencies, have no information in their model card, etc. To filter these out, we pick the top 20 models from each domain. We consider 7 domains in multimodal data, 8 in CV, 12 in NLP, 5 in Audio, 2 in tabular data, and 2 in reinforcement learning. Post filtering, we arrive at a total of 925 models from HuggingFace. TensorFlow Hub is versioned into v1 and v2. The latest version (v2) has 801 models in total, and we process all of them. After filtering out model cards with little to no information, we are left with 626 models. Similar to TensorFlow Hub, we extract 95 models (exhaustive) from Torch Hub. We then convert the model cards for each of these 1,645 API calls into a JSON object with the following fields: {domain, framework, functionality, api_name, api_call, api_arguments, environment_requirements, example_code, performance, description}. We provide more information in Appendix A.1. These fields were chosen to generalize beyond API calls within the ML domain, to other domains, including RESTful, SQL, and other potential API calls.
65
+
66
+ Instruction Generation Guided by the self-instruct paradigm [42], we employ GPT-4 to generate synthetic instruction data. We provide three in-context examples, along with reference API documentation, and task the model with generating real-world use cases that call upon the API. We specifically instruct the model to refrain from using any API names or hints when creating instructions. We constructed 6 examples (Instruction-API pairs) for each of the 3 model hubs. These 18 examples were the only hand-generated or modified data. For each of our 1,645 API datapoints, we generate 10 instruction-API pairs by sampling 3 of 6 corresponding instruction examples in each pair (Fig. 3).
67
+
68
+ API Call with Constraints API calls often come with inherent constraints. These constraints necessitate that the LLM not only comprehend the functionality of the API call but also categorize the calls according to different constraint parameters. Specifically, for machine learning API calls, two common sets of constraints are parameter size and a lower bound on accuracy. Consider, for instance, the following prompt: “Invoke an image classification model that uses less than 10M parameters, but maintains an ImageNet accuracy of at least $70 \%$ .” Such a prompt presents a substantial challenge for the LLM to accurately interpret and respond to. Not only must the LLM understand the user’s functional description, but it also needs to reason about the various constraints embedded within the request. This challenge underlines the intricate demands placed on LLMs in real-world API calls. It is not sufficient for the model to merely comprehend the basic functionality of an API call; it must also be capable of navigating the complex landscape of constraints that accompany such calls. We also incorporate these instructions in our training dataset.
69
+
70
+ # 3.2 Gorilla
71
+
72
+ Our model, called Gorilla, is a retriever-aware finetuned LLaMA-7B model, specifically for API calls. As shown in Fig. 3, we employ self-instruct to generate {instruction, API} pairs. To fine-tune LLaMA, we convert this to a user-agent chat-style conversation, where each datapoint is a conversation with one round each for the user and the agent. We then perform standard instruction finetuning on the base LLaMA-7B model. For our experiments, we train Gorilla with and without the retriever. We would like to highlight that though we used the LLaMA model, our fine-tuning is robust to the underlying pre-trained model (see Appendinx A.3.5).
73
+
74
+ Retriever-Aware training (RAT) In retriever-aware training, the instruction-tuned dataset also appends to the user prompt, the relevant retrieved documentation with “Use this API documentation for reference: <retrieved_API_doc_JSON>”. This is critical, because the retrieved documentation is not necessarily accurate – retrievers have imperfect re-call. By augmenting the prompt with potentially incorrect documentation, but the accurate ground-truth in the LLM response, we are in-effect teaching the LLM to ‘judge’ the retriever at inference time. During inference, if the LLM reasons that the retriever presented a relevant API document, it can use the API documentation to respond to the user’s question, filling in additional details from the user’s prompt. However, if after looking at the prompt, the LLM reasons that the retrieved API document is not relevant to the user’s prompt, RAT trains the model to not get distracted by irrelevant context. The LLM then relies on the domain-specific knowledge baked-in during RAT training, to provide the user with the relevant API. Through RAT, we aim to teach the LLM to parse the second half of the question (API documentation) to answer the first half (user’s query). We demonstrate that this (1) makes the LLM adapt to test-time changes in API documentation, (2) improves performance from in-context learning, and (3) reduces hallucination error.
75
+
76
+ Surprisingly, we find that augmenting a LLM with retrieval, does not always lead to improved performance, and can at-times hurt performance. We share more insights along with details in Sec 4.
77
+
78
+ Gorilla Inference During inference, the user provides the prompt in natural language (Fig. 3). This can be for a simple task (e.g., “I would like to identify the objects in an image”), or they can specify a vague goal, (e.g., “I am going to the zoo, and would like to track animals”). Gorilla, similar to training, can be used for inference in two modes: zero-shot and with retrieval. In the zero-shot setting, this prompt (with no additional prompt tuning) is fed to the Gorilla LLM model, which then returns the API call needed to accomplish the task or goal. In retrieval mode, the retriever (either of BM25 or GPT-Index) first retrieves the most up-to-date API documentation stored in the API Database. Before being sent to Gorilla, the API documentation is concatenated to the user prompt along with the message “Use this API documentation for reference.” The output of Gorilla is an API to be invoked. Besides the concatenation as described, we do no further prompt tuning in our system. While we also implemented a system to execute these APIs, to help the user accomplish the goal, that is not a focus of this paper.
79
+
80
+ # 3.3 Verifying APIs
81
+
82
+ Inductive program synthesis, where a program is synthesized to satisfy test cases, has found success in several avenues [3, 23]. However, test cases fall short when evaluating API calls, as it is often hard to verify the semantic correctness of the code. For example, consider the task of classifying an image. There are over 40 different models that can be used for the task. Even if we were to narrow down to a single family of densenet, there are four different configurations possible. Hence, there exist multiple correct answers and it is hard to tell if the API being used is functionally equivalent to the reference API by unit tests. Thus, to evaluate the performance of our model, we compare their functional equivalence using the dataset we collected. To trace which API in the dataset is the LLM calling, we adopt the AST tree-matching strategy. Since we only consider one API call in this paper, checking if the AST of the candidate API call is a sub-tree of the reference API call reveals which API is being used in the dataset.
83
+
84
+ ![](images/d925c7ce98b8bcb012903cabb96332a6919dc2e117050a67995a8c1f29fb00a3.jpg)
85
+ Figure 4: AST Sub-Tree Matching to evaluate API calls. On the left is an API call returned by Gorilla. We first build the associated API tree. We then compare this to our dataset, to see if the API dataset has a subtree match. In the above example, the matching subtree is highlighted in green, signifying that the API call is indeed correct. Pretrained $\cdot ^ { = }$ True is an optional argument.
86
+
87
+ Identifying and even defining hallucinations can be challenging. We use the AST matching process to directly identify the hallucinations. We define a hallucination as an API call that is not a sub-tree of any API in the database – invoking an entirely imagined tool. This form of hallucination is distinct from invoking an API incorrectly which we instead define as an error. So, in our evaluations, error, hallucination, and accuracy add up to one.
88
+
89
+ AST Sub-Tree Matching We perform AST sub-tree matching to identify which API in our dataset is the LLM calling. Since each API call can have many arguments, we need to match on each of these arguments. Further, since, Python allows for default arguments, for each API, we define which arguments to match in our database. For example, we check repo_or_dir and model arguments in our function call. In this way, we can easily check if the argument matches the reference API or not. Fig. 4 illustrates an example subtree check for a torch API call. We first build the tree, and verify that it matches a subtree in our dataset along nodes torch.hub.load, pytorch/vision, and densenet121. We do not check for match along leaf node pretrained $\equiv$ True since that is an optional argument.
90
+
91
+ # 4 Evaluation
92
+
93
+ When evaluating Gorilla, finetuned on APIBench (train set), we aim to answer the following questions: How does Gorilla compare to other LLMs on API Bench (test set)? ( 4.1). How well does Gorilla adapt to test-time changes in API documentation? ( 4.2). How well can Gorilla handle questions with constraints? (4.3)
94
+
95
+ We demonstrate that Gorilla outperforms both open-source and close-source models for in-domain function calling. Further, trained with our novel retriever-aware training (RAT) technique, the Gorilla model generalizes to APIs that are outside of its training data (out-of-domain). In addition, we assess Gorilla’s ability to reason about API calls under constraints. Lastly, we examined how integrating different retrieval methods during training influences the model’s final performance.
96
+
97
+ Baselines We primarily compare Gorilla with state-of-the-art language models in a zero-shot setting and with 3-shot in-context learning. The models under consideration include: GPT-4 by OpenAI with the $\mathtt { g p t - 4 - 0 3 1 4 }$ checkpoint; GPT-3.5-turbo with the gpt-3.5-turbo-0301 checkpoint, both of which are RLHF-tuned models specifically designed for conversation; Claude with the claude-v1 checkpoint, a language model by Anthropic, renowned for its lengthy context capabilities; and LLaMA-7B, a state-of-the-art open-source large language model by Meta.
98
+
99
+ Retrievers The term zero-shot (abbreviated as 0-shot in tables) refers to scenarios where no retriever is used. The sole input to the model is the user’s natural language prompt. For BM25, we consider each API as a separate document. During retrieval, we use the user’s query to fetch the most relevant (top-1) API. This API is concatenated with the user’s prompt to query the LLMs. Similarly, GPTIndex refers to the state-of-the-art embedding model, text-embedding-ada-002-v2 from OpenAI, where each embedding is 1,536 dimensional. Like BM25, each API call is indexed as an individual document, and the most relevant document, given a user query, is retrieved and appended to the user prompt. Lastly, we include an Oracle retriever, which serves two purposes: first, to identify the potential for performance improvement through more efficient retrievers, and second, to assist users who know which API to use but may need to help invoking it. In all cases, when a retriever is used, it is appended to the user’s prompt as follows: <user_prompt> Use this API documentation for reference: <retrieved_API_doc_JSON>. The dataset for these evaluations is detailed in Section 3. We emphasize that we have maintained a holdout test set on which we report our findings. The holdout test set was created by dividing the self-instruct dataset’s instruction, API pairs into training and testing sets.
100
+
101
+ ![](images/449c629b6e3ba8fc11a7c0dc1881f5607b2867d5af62b45529a68ff27dea46bd.jpg)
102
+ Figure 5: Accuracy with GPT-retriever. Methods to the left of the dotted line are closed source. Gorilla outperforms on Torch Hub and Hugging-Face while matching performance on Tensorflow Hub for all existing state-of-the-art LLMs - closed source, and open source.
103
+
104
+ # 4.1 AST Accuracy on API call
105
+
106
+ We test each model for different retriever settings defined above (Table 1). We report the overall accuracy, the error by hallucination and the error by selecting wrong API call. Note that for TorchHub and TensorHub, we evaluate all the models using AST tree accuracy score. However, for HuggingFace, since the dataset cannot be exhaustive given the sheer number of models hosted, for all the models except Gorilla, we only check if they can provide the correct domain names. So this problem reduces to picking one of multiple choices. Across 0-shot and few-shot prompting strategies, Gorilla outperforms close-sourced and open-sourced models (Table 5).
107
+
108
+ Finetuning without Retrieval In Table 1 we show that lightly fine-tuned Gorilla is able to match, and often surpass performance in the zero-shot setting compared to closed-source, and open-source models – $2 0 . 4 3 \%$ better than GPT-4 and $1 0 . 7 5 \%$ better than GPT-3.5 (ChatGPT). When compared to other open-source models LLAMA, the improvement is as big as $83 \%$ . This suggests quantitatively, that as a technique to augment information and enforce adherence to syntax, fine-tuning is better than naive retrieval, at-least within the scope of invoking APIs.
109
+
110
+ Finetuning with Retrieval We now discuss how incorporating retrieval (RAT) during LLM finetuning enhances model performance. In this experiment, the base LLAMA model is finetuned with a prompt (instruction-generated), a reference API document (from a golden-truth oracle), and an example output generated by an LLM (GPT-4 in this case). As shown in Table 2, incorporating a ground-truth retriever in the finetuning pipeline yields notably improved results – $1 2 . 3 7 \%$ higher accuracy than training without retrieval in Torch Hub and $2 3 . 4 6 \%$ better in HuggingFace. However, at evaluation time, current retrievers show a significant performance gap compared to the ground-truth retriever: using GPT-Index at evaluation results in $2 9 . 2 0 \%$ accuracy degradation and using BM25 results in a $5 2 . 2 7 \%$ accuracy degradation. Despite this, considering the trends across models and retrievers, our findings indicate that finetuning an LLM with effective retrieval integration is preferable to zero-shot finetuning.
111
+
112
+ Hallucination with LLM One phenomenon we observe is that zero-shot prompting with LLMs (GPT-4/GPT-3.5) to call APIs results in dire hallucination errors. These errors, while diverse, commonly manifest in erroneous behavior such as the model invoking the AutoModel.from_pretrained(dir_name) command with arbitrary GitHub repository names. Surprisingly, we also found that in TorchHub, HuggingFace and TensorFlow Hub, GPT-3.5 has less hallucination errors than GPT-4. This finding is also consistent for the settings when various retrieving methods are provided: 0-shot, BM25, GPT-Index and the oracle. This might suggest that RLHF plays a central role in turning the model to be truthful. Additional discussion in Appendix A.3.
113
+
114
+ Table 1: Evaluating LLMs on Torch Hub, HuggingFace, and Tensorflow Hub APIs
115
+
116
+ <table><tr><td rowspan="2">LLM (retriever)</td><td colspan="2">TorchHub</td><td colspan="5">HuggingFace</td><td colspan="3">TensorFlow Hub</td></tr><tr><td>overall 个</td><td>hallu ↓</td><td>err↓</td><td>overall 个</td><td>hallu↓</td><td>err↓</td><td>overall 个</td><td></td><td>hallu↓</td><td>err←</td></tr><tr><td>LLAMA (0-shot)</td><td>0</td><td>100</td><td>0</td><td>0.00</td><td>97.57</td><td>2.43</td><td>0</td><td></td><td>100</td><td>0</td></tr><tr><td>GPT-3.5 (0-shot)</td><td>48.38</td><td>18.81</td><td>32.79</td><td>16.81</td><td>35.73</td><td></td><td>47.46</td><td>41.75</td><td>47.88</td><td>10.36</td></tr><tr><td>GPT-4 (0-shot)</td><td>38.70</td><td>36.55</td><td>24.7</td><td>19.80</td><td>37.16</td><td>43.03</td><td></td><td>18.20</td><td>78.65</td><td>3.13</td></tr><tr><td>Claude (0-shot)</td><td>18.81</td><td>65.59</td><td>15.59</td><td>6.19</td><td>77.65</td><td>16.15</td><td></td><td>9.19</td><td>88.46</td><td>2.33</td></tr><tr><td>Gorilla (0-shot)</td><td>59.13</td><td>6.98</td><td>33.87</td><td>71.68</td><td>10.95</td><td>17.36</td><td></td><td>83.79</td><td>5.40</td><td>10.80</td></tr><tr><td>LLAMA (BM-25)</td><td>8.60</td><td>76.88</td><td>14.51</td><td>3.00</td><td>77.99</td><td></td><td>19.02</td><td>8.90</td><td>77.37</td><td>13.72</td></tr><tr><td>GPT-3.5 (BM-25)</td><td>38.17</td><td>6.98</td><td>54.83</td><td>17.26</td><td>8.30</td><td></td><td>74.44</td><td>54.16</td><td>3.64</td><td>42.18</td></tr><tr><td>GPT-4 (BM-25)</td><td>35.48</td><td>11.29</td><td>53.22</td><td>16.48</td><td>15.93</td><td></td><td>67.59</td><td>34.01</td><td>37.08</td><td>28.90</td></tr><tr><td>Claude (BM-25)</td><td>39.78</td><td>5.37</td><td>54.83</td><td>14.60</td><td>15.82</td><td></td><td>69.58</td><td>35.18</td><td>21.16</td><td>43.64</td></tr><tr><td>Gorilla (BM-25)</td><td>40.32</td><td>4.30</td><td>55.37</td><td>17.03</td><td>6.42</td><td>76.55</td><td></td><td>41.89</td><td>2.77</td><td>55.32</td></tr><tr><td>LLAMA (GPT-Index)</td><td>14.51</td><td>75.8</td><td>9.67</td><td>10.18</td><td>75.66</td><td></td><td>14.20</td><td>15.62</td><td>77.66</td><td>6.71</td></tr><tr><td>GPT-3.5 (GPT-Index)</td><td>60.21</td><td>1.61</td><td>38.17</td><td>29.08</td><td>7.85</td><td></td><td>44.80</td><td>65.59</td><td>3.79</td><td>30.50</td></tr><tr><td>GPT-4 (GPT-Index)</td><td>59.13</td><td>1.07</td><td>39.78</td><td>44.58</td><td>11.18</td><td></td><td>44.25</td><td>43.94</td><td>31.53</td><td>24.52</td></tr><tr><td>Claude (GPT-Index)</td><td>60.21</td><td>3.76</td><td>36.02</td><td>41.37</td><td>18.81</td><td></td><td>39.82</td><td>55.62</td><td>16.20</td><td>28.17</td></tr><tr><td>Gorilla (GPT-Index)</td><td>61.82</td><td>0</td><td>38.17</td><td>47.46</td><td>8.19</td><td></td><td>44.36</td><td>64.96</td><td>2.33</td><td>32.70</td></tr><tr><td>LLAMA (Oracle)</td><td>16.12</td><td>79.03</td><td>4.83</td><td>17.70</td><td>77.10</td><td></td><td>5.20</td><td>12.55</td><td>87.00</td><td>0.43</td></tr><tr><td>GPT-3.5 (Oracle)</td><td>66.31</td><td>1.60</td><td>32.08</td><td>89.71</td><td>6.64</td><td></td><td>3.65</td><td>95.03</td><td>0.29</td><td>4.67</td></tr><tr><td>GPT-4 (Oracle)</td><td>66.12</td><td>0.53</td><td>33.33</td><td>85.07</td><td>10.62</td><td></td><td>4.31</td><td>55.91</td><td>37.95</td><td>6.13</td></tr><tr><td>Claude (Oracle)</td><td>63.44</td><td>3.76</td><td>32.79</td><td>77.21</td><td>19.58</td><td>3.21</td><td></td><td>74.74</td><td>21.60</td><td>3.64</td></tr><tr><td>Gorilla (Oracle)</td><td>67.20</td><td>0</td><td>32.79</td><td>91.26</td><td>7.08</td><td></td><td>1.66</td><td>94.16</td><td>1.89</td><td>3.94</td></tr></table>
117
+
118
+ Table 2: Understanding the effect of different retrieval techniques used with Gorilla
119
+
120
+ <table><tr><td></td><td colspan="4">Gorilla without Retriever</td><td colspan="4">Gorilla with Oracle retriever</td></tr><tr><td></td><td>zero-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>zero-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td></tr><tr><td>Torch Hub (overall) ↑</td><td>59.13</td><td>37.63</td><td>60.21</td><td>54.83</td><td>0</td><td>40.32</td><td>61.82</td><td>67.20</td></tr><tr><td>HuggingFace (overall) ↑</td><td>71.68</td><td>11.28</td><td>28.10</td><td>45.58</td><td>0</td><td>17.04</td><td>47.46</td><td>91.26</td></tr><tr><td>TensorHub (overall) 个</td><td>83.79</td><td>34.30</td><td>52.40</td><td>82.91</td><td>0</td><td>41.89</td><td>64.96</td><td>94.16</td></tr><tr><td>Torch Hub (Hallu)↓</td><td>6.98</td><td>11.29</td><td>4.30</td><td>15.59</td><td>100</td><td>4.30</td><td>0</td><td>0</td></tr><tr><td>HuggingFace (Hallu)↓</td><td>10.95</td><td>46.46</td><td>41.48</td><td>52.77</td><td>99.67</td><td>6.42</td><td>8.19</td><td>7.08</td></tr><tr><td>TensorHub (Hallu)↓</td><td>5.40</td><td>20.43</td><td>19.70</td><td>13.28</td><td>100</td><td>2.77</td><td>2.33</td><td>1.89</td></tr></table>
121
+
122
+ AST as a Hallucination Metric We manually execute Gorilla’s API generations to evaluate how well AST works as an evaluation metric. Executing every code generated is impractical within academic setting—for example, executing the HuggingFace model needs the required library dependencies (e.g., transformers, sentencepiece, accelerate), correct coupling of software kernels (e.g., torch vision, torch, cuda, cudnn versions), and required hardware support (e.g., A100 40G gpus). Hence, to make it tractable, we sampled 100 random Gorilla generations from our evalualtion set. The accuracy from our AST subtree matching is $78 \%$ , consistent with human evaluation of $78 \%$ accuracy in calling the right API. All the generations that AST flagged as incorrect, were the same ones that were manually flagged as incorrect. Additionally, Gorilla also generates supporting code to call the API which includes installing dependencies e.g., pip install transformers[sentencepiece]), setting environment variables, etc. When we manually attempt to execute the code, $7 2 \%$ of all code generated executed successfully. It’s worth noting that the $6 \%$ discrepancy are not semantic errors, but errors that arose due to factors external to the API, and in the supporting code. We have included the full example to illustrate this further in A.3.3. Considering the significant time and effort required for manual validation of each generation, the strong correlation between human evaluation and the AST evaluation further reinforces our belief in using the proposed AST as a robust offline metric.
123
+
124
+ ![](images/d719d1a77e259ba2d44eba4f18ef02b35c7273c94b9016cfb75b51a6e04c8b8c.jpg)
125
+ Figure 6: Gorilla’s retriever–aware training enables it to react to changes in the APIs. The second column demonstrates changes in model upgrading FCN’s ResNet–50 backbone to ResNet–101. The third column demonstrate changes in model registry from pytorch/vision to NVIDIA/DeepLearningExamples:torchhub
126
+
127
+ Table 4: Evaluating LLMs on constraint-aware API invocations
128
+
129
+ <table><tr><td></td><td colspan="4">GPT-3.5</td><td colspan="4">GPT-4</td><td colspan="4">Gorilla</td></tr><tr><td></td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td></tr><tr><td>Torch Hub (overall)</td><td>73.94</td><td>62.67</td><td>81.69</td><td>80.98</td><td>62.67</td><td>56.33</td><td>71.11</td><td>69.01</td><td>71.83</td><td>57.04</td><td>71.83</td><td>78.16</td></tr><tr><td>Torch Hub (Hallu)</td><td>19.01</td><td>30.98</td><td>14.78</td><td>14.08</td><td>15.49</td><td>27.46</td><td>14.08</td><td>9.15</td><td>19.71</td><td>39.43</td><td>26.05</td><td>16.90</td></tr><tr><td>Torch Hub (err)</td><td>7.04</td><td>6.33</td><td>3.52</td><td>4.92</td><td>21.83</td><td>16.19</td><td>14.78</td><td>21.83</td><td>8.45</td><td>3.52</td><td>2.11</td><td>4.92</td></tr><tr><td>Accuracy const</td><td>43.66</td><td>33.80</td><td>33.09</td><td>69.01</td><td>43.66</td><td>29.57</td><td>29.57</td><td>59.15</td><td>47.88</td><td>30.28</td><td>26.76</td><td>67.60</td></tr><tr><td>LLAMA</td><td colspan="8"></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (overall)</td><td>0</td><td>8.45</td><td>11.97</td><td>19.71</td><td>29.92</td><td>81.69</td><td>82.39</td><td>81.69</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (Hallu)</td><td>100</td><td>91.54</td><td>88.02</td><td>78.87</td><td>67.25</td><td>16.19</td><td>15.49</td><td>13.38</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (err)</td><td>0</td><td>0</td><td>0</td><td>1.4</td><td>2.81</td><td>2.11</td><td>2.11</td><td>4.92</td><td></td><td></td><td></td><td></td></tr><tr><td>Accuracy const</td><td>0</td><td>6.33</td><td>3.52</td><td>17.60</td><td>17.25</td><td>29.57</td><td>31.69</td><td>69.71</td><td></td><td></td><td></td><td></td></tr></table>
130
+
131
+ Table 3: Proposed AST evaluation metric has strong correlation with human evaluation
132
+
133
+ <table><tr><td></td><td>Accuracy</td></tr><tr><td>Gorilla AST metric (proposed)</td><td>0.78</td></tr><tr><td>Eval by Human</td><td>0.78</td></tr><tr><td>Code Executable (Eval by Human)</td><td>0.72</td></tr></table>
134
+
135
+ # 4.2 Test-Time Documentation Change
136
+
137
+ The rapidly evolving nature of API documentation presents a significant challenge for the application of LLMs in this field. These documents are often updated at a frequency that outpaces the retraining or fine-tuning schedule of LLMs, making these models particularly brittle to changes in the information they are designed to process. This mismatch in update frequency can lead to a decline in the utility and reliability of LLMs over time.
138
+
139
+ With the introduction of Gorilla’s retriever-aware training, the RAT trained LLM readily adapts to changes in API documentation. This novel approach allows the model to remain relevant, even as the API documentation it relies on undergoes modifications. This is a pivotal advancement in the field, as it ensures that the LLM maintains its efficacy and accuracy over time, providing reliable outputs irrespective of changes in the underlying documentation.
140
+
141
+ For instance, consider the scenario illustrated in Fig. 6, where the training of Gorilla has allowed it to react effectively to changes in APIs. This includes alterations such as upgrading the FCN’s ResNet-50 backbone to ResNet-101, as demonstrated in the second column of the figure. Since the model has encountered ResNet-101 as a backbone with other architectures, it interprets an FCN with a ResNet-101 backbone (unseen during training) as a relevant document at test time. Conversely, if the retriever suggests an FCN with a ResNet-60 backbone, the model—unfamiliar with ResNet-60 from RAT—assigns low confidence to this document and defaults back to FCN with ResNet-50. The third column in Fig. 6 further illustrates Gorilla’s flexibility in adapting to shifts in model registries, such as from pytorch/vision to NVIDIA/DeepLearningExamples:torchhub, highlighting its ability to accommodate changes in preferred API sources as they evolve over time.
142
+
143
+ Table 5: Evaluating Gorilla 0-shot with GPT 3-shot incontext examples
144
+
145
+ <table><tr><td></td><td>HF (Acc ↑)</td><td>HF (Hall ↓)</td><td>TH (Acc ↑)</td><td>TH (Hall ↓)</td><td>TF (Acc ↑)</td><td>TF (Hall ↓)</td></tr><tr><td>GPT-3.5 (0-shot)</td><td>16.81</td><td>35.73</td><td>41.93</td><td>10.75</td><td>41.75</td><td>47.88</td></tr><tr><td>GPT-4 (0-shot)</td><td>19.80</td><td>37.16</td><td>54.30</td><td>34.40</td><td>18.20</td><td>78.65</td></tr><tr><td>GPT-3.5 (3 incont)</td><td>25.77</td><td>32.30</td><td>73.11</td><td>72.58</td><td>71.82</td><td>11.09</td></tr><tr><td>GPT-4 (3 incont)</td><td>26.32</td><td>35.84</td><td>75.80</td><td>13.44</td><td>77.37</td><td>11.97</td></tr><tr><td>Gorilla (0-shot)</td><td>58.05</td><td>28.32</td><td>75.80</td><td>16.12</td><td>83.79</td><td>5.40</td></tr></table>
146
+
147
+ In summary, Gorilla’s ability to adapt to test-time changes in API documentation offers numerous benefits. It maintains its accuracy and relevance over time, adapts to the rapid pace of updates in API documentation, and adjusts to modifications in underlying models and systems. This makes it a robust and reliable tool for API calls, significantly enhancing its practical utility.
148
+
149
+ # 4.3 API Call with Constraints
150
+
151
+ We now focus on the language model’s capability of understanding constraints. For any given task, which API call to invoke is typically a tradeoff between a multitude of factors. In the case of RESTFul APIs, it could be the cost of each invocation $\textcircled { \$ 5}$ or the latency of response (ms), among many others. Similarly, within the scope of ML APIs, it is desirable for Gorilla to respect constraints such as accuracy, number of learnable parameters in the model, the size on disk, peak memory consumption, FLOPS, etc. In this section, we present a study evaluating the ability of different models in zero-shot and in the presence of retrievers to respect a given accuracy constraint. : if a user requests an image classification model that achieves at least $80 \%$ top-1 accuracy on the ImageNet dataset, then among the classification models hosted by Torch Hub, ResNeXt-101 $3 2 \mathbf { x } 1 6 \mathbf { d }$ , with a top-1 accuracy of $8 4 . 2 \%$ , would be the appropriate model to call, rather than MobileNetV2, which has a top-1 accuracy of $7 1 . 8 8 \%$ .
152
+
153
+ For Table 4, we filtered a subset of the Torch Hub component of APIBench, retaining those models that had an accuracy metric defined for at least one-dataset the model was evaluated on, in its model card. We were left with $6 5 . 2 6 \%$ of TorchHub dataset from Table 1. We notice that with constraints, understandably, the accuracy drops across all models, with and without a retriever. Even in this challenging scenario, Gorilla is able to match the performance of the best-performing model GPT-3.5 when using retrievals (BM25, GPT-Index), and has the highest accuracy in the zero-shot setting. This highlights Gorilla’s ability to navigate APIs while considering the trade-offs between constraints.
154
+
155
+ # 4.4 Finetuning (vs) Prompting: Gorilla 0-shot (vs) GPT 3-shot
156
+
157
+ To assess whether finetuning is truly necessary for APIs or if prompting alone is sufficient, we compare Gorilla in a zero-shot setting with three-shot in-context prompting for GPT-3.5 and GPT-4 models. In Table 5, "3-incont" denotes evaluation using three in-context examples, while "HF," "TH," and "TF" represent the HuggingFace, TorchHub, and TensorFlow Hub subsets of APIBench, respectively. Higher accuracy (Acc) and lower hallucination (Hall) rates are preferred. From Table 5, three-shot in-context learning improves the GPT models’ ability to generate syntactically correct function calls, even matching accuracy on one subset (TorchHub). However, Gorilla 0-shot still outperforms the 3-shot GPT models on average.
158
+
159
+ # 5 Conclusion
160
+
161
+ LLMs are swiftly gaining popularity across diverse domains. APIs, serving as a universal language, are essential for enabling LLMs to communicate and operate effectively across diverse systems. In this paper, we introduced Gorilla, a state-of-the-art model for API invocation. Our Retriever Aware Training (RAT) approach empowers Gorilla with two essential capabilities: adapting dynamically to API changes at test time and reasoning through user-defined constraints when selecting suitable APIs. We also present APIBench, a comprehensive benchmark for assessing LLMs’ function-calling abilities, and propose AST-based hallucination metrics for robust evaluation. Looking forward, we believe this work represents a first step towards transitioning LLMs from knowledge-bound models into flexible interfaces that interact with the digital world.
162
+
163
+ # References
164
+
165
+ arguments with reading comprehension. arXiv preprint arXiv:1909.00109, 2019. [2] Anthropic. Claude, 2022. URL https://www.anthropic.com/index/ introducing-claude. [3] Bavishi, R., Lemieux, C., Fox, R., Sen, K., and Stoica, I. Autopandas: neural-backed generators for program synthesis. Proceedings of the ACM on Programming Languages, (OOPSLA), 2019.
166
+ [4] Brohan, A., Chebotar, Y., Finn, C., Hausman, K., Herzog, A., Ho, D., Ibarz, J., Irpan, A., Jang, E., Julian, R., et al. Do as i can, not as i say: Grounding language in robotic affordances. In Conference on robot learning. PMLR, 2023. [5] Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. Advances in neural information processing systems, 2020.
167
+ [6] Bubeck, S., Chandrasekaran, V., Eldan, R., Gehrke, J., Horvitz, E., Kamar, E., Lee, P., Lee, Y. T., Li, Y., Lundberg, S., et al. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712, 2023.
168
+ [7] Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. d. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
169
+ [8] Chen, X., Lin, M., Schärli, N., and Zhou, D. Teaching large language models to self-debug. arXiv preprint arXiv:2304.05128, 2023.
170
+ [9] Chiang, W.-L., Li, Z., Lin, Z., Sheng, Y., Wu, Z., Zhang, H., Zheng, L., Zhuang, S., Zhuang, Y., Gonzalez, J. E., Stoica, I., and Xing, E. P. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023.
171
+ [10] Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
172
+ [11] Chung, H. W., Hou, L., Longpre, S., Zoph, B., Tay, Y., Fedus, W., Li, Y., Wang, X., Dehghani, M., Brahma, S., et al. Scaling instruction-finetuned language models. Journal of Machine Learning Research, 2024.
173
+ [12] Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
174
+ [13] Devlin, J., Uesato, J., Bhupatiraju, S., Singh, R., Mohamed, A.-r., and Kohli, P. Robustfill: Neural program learning under noisy i/o. In International conference on machine learning. PMLR, 2017.
175
+ [14] Gao, L., Madaan, A., Zhou, S., Alon, U., Liu, P., Yang, Y., Callan, J., and Neubig, G. Pal: Program-aided language models. In International Conference on Machine Learning. PMLR, 2023.
176
+ [15] Iyer, S., Lin, X. V., Pasunuru, R., Mihaylov, T., Simig, D., Yu, P., Shuster, K., Wang, T., Liu, Q., Koura, P. S., et al. Opt-iml: Scaling language model instruction meta learning through the lens of generalization. arXiv preprint arXiv:2212.12017, 2022.
177
+ [16] Jain, N., Vaidyanath, S., Iyer, A., Natarajan, N., Parthasarathy, S., Rajamani, S., and Sharma, R. Jigsaw: Large language models meet program synthesis. In Proceedings of the 44th International Conference on Software Engineering, 2022.
178
+ [17] Kim, G., Baldi, P., and McAleer, S. Language models can solve computer tasks. arXiv preprint arXiv:2303.17491, 2023.
179
+ [18] Kojima, T., Gu, S. S., Reid, M., Matsuo, Y., and Iwasawa, Y. Large language models are zero-shot reasoners. Advances in neural information processing systems, 2022.
180
+ [19] Komeili, M., Shuster, K., and Weston, J. Internet-augmented dialogue generation. arXiv preprint arXiv:2107.07566, 2021.
181
+ [20] Lazaridou, A., Gribovskaya, E., Stokowiec, W., and Grigorev, N. Internet-augmented language models through few-shot prompting for open-domain question answering. arXiv preprint arXiv:2203.05115, 2022.
182
+ [21] Li, R., Allal, L. B., Zi, Y., Muennighoff, N., Kocetkov, D., Mou, C., Marone, M., Akiki, C., Li, J., Chim, J., et al. Starcoder: may the source be with you! arXiv preprint arXiv:2305.06161, 2023.
183
+ [22] Li, Y., Choi, D., Chung, J., Kushman, N., Schrittwieser, J., Leblond, R., Eccles, T., Keeling, J., Gimeno, F., Dal Lago, A., et al. Competition-level code generation with alphacode. Science, 2022.
184
+ [23] Menon, A., Tamuz, O., Gulwani, S., Lampson, B., and Kalai, A. A machine learning framework for programming by example. In International Conference on Machine Learning. PMLR, 2013.
185
+ [24] Nakano, R., Hilton, J., Balaji, S., Wu, J., Ouyang, L., Kim, C., Hesse, C., Jain, S., Kosaraju, V., Saunders, W., et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021.
186
+ [25] Nijkamp, E., Pang, B., Hayashi, H., Tu, L., Wang, H., Zhou, Y., Savarese, S., and Xiong, C. Codegen: An open large language model for code with multi-turn program synthesis. arXiv preprint arXiv:2203.13474, 2022.
187
+ [26] Nijkamp, E., Hayashi, H., Xiong, C., Savarese, S., and Zhou, Y. Codegen2: Lessons for training llms on programming and natural languages. arXiv preprint arXiv:2305.02309, 2023.
188
+ [27] OpenAI. Gpt-4 technical report, 2023.
189
+ [28] OpenAI and https://openai.com/blog/chatgpt. Chatgpt, 2022. URL https://openai.com/ blog/chatgpt.
190
+ [29] Roziere, B., Lachaux, M.-A., Chanussot, L., and Lample, G. Unsupervised translation of programming languages. Advances in neural information processing systems, 2020.
191
+ [30] Sanh, V., Webson, A., Raffel, C., Bach, S. H., Sutawika, L., Alyafeai, Z., Chaffin, A., Stiegler, A., Scao, T. L., Raja, A., et al. Multitask prompted training enables zero-shot task generalization. arXiv preprint arXiv:2110.08207, 2021.
192
+ [31] Scao, T. L., Fan, A., Akiki, C., Pavlick, E., Ilic, S., Hesslow, D., Castagné, R., Luccioni, A. S., ´ Yvon, F., Gallé, M., et al. Bloom: A 176b-parameter open-access multilingual language model. arXiv preprint arXiv:2211.05100, 2022.
193
+ [32] Schick, T. and Schütze, H. Exploiting cloze questions for few shot text classification and natural language inference. arXiv preprint arXiv:2001.07676, 2020.
194
+ [33] Schick, T., Dwivedi-Yu, J., Dessi, R., Raileanu, R., Lomeli, M., Hambro, E., Zettlemoyer, L., Cancedda, N., and Scialom, T. Toolformer: Language models can teach themselves to use tools. Advances in Neural Information Processing Systems, 2023.
195
+ [34] Shinn, N., Labash, B., and Gopinath, A. Reflexion: an autonomous agent with dynamic memory and self-reflection. arXiv preprint arXiv:2303.11366, 2023.
196
+ [35] Shuster, K., Xu, J., Komeili, M., Ju, D., Smith, E. M., Roller, S., Ung, M., Chen, M., Arora, K., Lane, J., et al. Blenderbot 3: a deployed conversational agent that continually learns to responsibly engage. arXiv preprint arXiv:2208.03188, 2022.
197
+ [36] Subramanian, S., Narasimhan, M., Khangaonkar, K., Yang, K., Nagrani, A., Schmid, C., Zeng, A., Darrell, T., and Klein, D. Modular visual question answering via code generation. arXiv preprint arXiv:2306.05392, 2023.
198
+ [37] Surís, D., Menon, S., and Vondrick, C. Vipergpt: Visual inference via python execution for reasoning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2023.
199
+ [38] Taori, R., Gulrajani, I., Zhang, T., Dubois, Y., Li, X., Guestrin, C., Liang, P., and Hashimoto, T. B. Stanford alpaca: An instruction-following llama model, 2023.
200
+ [39] Thoppilan, R., De Freitas, D., Hall, J., Shazeer, N., Kulshreshtha, A., Cheng, H.-T., Jin, A., Bos, T., Baker, L., Du, Y., et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
201
+ [40] Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
202
+ [41] Vemprala, S., Bonatti, R., Bucker, A., and Kapoor, A. Chatgpt for robotics: Design principles and model abilities. 2023, 2023.
203
+ [42] Wang, Y., Kordi, Y., Mishra, S., Liu, A., Smith, N. A., Khashabi, D., and Hajishirzi, H. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022.
204
+ [43] Wang, Y., Mishra, S., Alipoormolabashi, P., Kordi, Y., Mirzaei, A., Naik, A., Ashok, A., Dhanasekaran, A. S., Arunkumar, A., Stap, D., et al. Super-naturalinstructions: Generalization via declarative instructions on $1 6 0 0 +$ nlp tasks. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, 2022.
205
+ [44] Wei, J., Wang, X., Schuurmans, D., Bosma, M., Xia, F., Chi, E., Le, Q. V., Zhou, D., et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems, 2022.
206
+ [45] Xu, F. F., Alon, U., Neubig, G., and Hellendoorn, V. J. A systematic evaluation of large language models of code. In Proceedings of the 6th ACM SIGPLAN International Symposium on Machine Programming, 2022.
207
+ [46] Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., and Cao, Y. React: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629, 2022.
208
+ [47] Zeng, A., Liu, X., Du, Z., Wang, Z., Lai, H., Ding, M., Yang, Z., Xu, Y., Zheng, W., Xia, X., et al. Glm-130b: An open bilingual pre-trained model. arXiv preprint arXiv:2210.02414, 2022.
209
+ [48] Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, X. V., et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
210
+ [49] Zhou, S., Alon, U., Xu, F. F., Jiang, Z., and Neubig, G. Docprompting: Generating code by retrieving the docs. In The Eleventh International Conference on Learning Representations, 2022.
211
+
212
+ # A Appendix
213
+
214
+ # A.1 Dataset Details
215
+
216
+ Our dataset is multi-faceted, comprising three distinct domains: Torch Hub, Tensor Hub, and HuggingFace. Each entry within this dataset is rich in detail, carrying critical pieces of information that further illuminate the nature of the data. Delving deeper into the specifics of each domain, Torch Hub provides 95 APIs. The second domain, Tensor Hub, is more expansive with a total of 696 APIs. Finally, the most extensive of them all, HuggingFace, comprises 925 APIs.
217
+
218
+ To enhance the value and utility of our dataset, we’ve undertaken an additional initiative. With each API, we have generated a set of 10 unique instructions. These instructions, carefully crafted and meticulously tailored, serve as a guide for both training and evaluation. This initiative ensures that every API is not just represented in our dataset, but is also comprehensively understood and effectively utilizable.
219
+
220
+ In essence, our dataset is more than just a collection of APIs across three domains. It is a comprehensive resource, carefully structured and enriched with added layers of guidance and evaluation parameters.
221
+
222
+ Domain Classification The unique domain names encompassed within our dataset are illustrated in Fig. 7. The dataset consists of three sources with a diverse range of domains: Torch Hub houses 6 domains, Tensor Hub accommodates a much broader selection with 57 domains, while HuggingFace incorporates 37 domains. To exemplify the structure and nature of our dataset, we invite you to refer to the domain names represented in Fig. 8.
223
+
224
+ API Call Task In this task, we test the model’s capability to generate a single line of code, either in a zero-shot fashion or by leveraging an API reference. Primarily designed for evaluation purposes, this task effectively gauges the model’s proficiency in identifying and utilizing the appropriate API call.
225
+
226
+ API Provider Component This facet relates to the provision of the programming language. In this context, the API provider plays a vital role as it serves as a foundation upon which APIs are built and executed.
227
+
228
+ Explanation Element This component offers valuable insights into the rationale behind the usage of a particular API, detailing how it aligns with the prescribed requirements. Furthermore, when certain constraints are imposed, this segment also incorporates those limitations. Thus, the explanation element serves a dual purpose, offering a deep understanding of API selection, as well as the constraints that might influence such a selection. This balanced approach ensures a comprehensive understanding of the API usage within the given context.
229
+
230
+ Code Example code for accomplishing the task. We de-prioritize this as we haven’t tested the execution result of the code. We leave this for future works, but make this data available in-case others want to build on it.
231
+
232
+ # A.2 Gorilla Details
233
+
234
+ We provide all the training details for Gorilla in this section. This includes how we divide up the training, evaluation dataset, training hyperparameters for Gorilla.
235
+
236
+ Data For HuggingFace, we devise the entire dataset into $90 \%$ training and $10 \%$ evaluation. For Torch Hub and Tensor Hub, we devise the data in to $80 \%$ training and $20 \%$ testing.
237
+
238
+ Training We train Gorillafor 5 epochs with the 2e-5 learning rate with cosine decay. The details are provide in Table 6. We finetune it on 8xA100 with 40G memory each.
239
+
240
+ Torch Hub domain names: Classification, Semantic Segmentation, Object Detection, Audio Separation, Video Classification, Text-to-Speech
241
+
242
+ Tensor Hub domain names: text-sequence-alignment, text-embedding, text-languagemodel, text-preprocessing, text-classification, text-generation, text-question-answering, textretrieval-question-answering, text-segmentation, text-to-mel, image-classification, imagefeature-vector, image-object-detection, image-segmentation, image-generator, image-posedetection, image-rnn-agent, image-augmentation, image-classifier, image-style-transfer, image-aesthetic-quality, image-depth-estimation, image-super-resolution, image-deblurring, image-extrapolation, image-text-recognition, image-dehazing, image-deraining, imageenhancemenmt, image-classification-logits, image-frame-interpolation, image-text-detection, image-denoising, image-others, video-classification, video-feature-extraction, videogeneration, video-audio-text, video-text, audio-embedding, audio-event-classification, audiocommand-detection, audio-paralinguists-classification, audio-speech-to-text, audio-speechsynthesis, audio-synthesis, audio-pitch-extraction
243
+
244
+ ![](images/0090f07f5c38c79ad372b07e2435e852c9451bf6be6dc4aebb59c4225e347d30.jpg)
245
+ Figure 7: Domain names: Domain names with the three dataset. Tensor Hub is the smallest dataset while the other two hubs contain many more models.
246
+
247
+ Table 6: Hyperparameters for training Gorilla
248
+
249
+ <table><tr><td>Hyperparameter Name</td><td>Value</td></tr><tr><td>learning rate</td><td>2e-5</td></tr><tr><td>batch size</td><td>64</td></tr><tr><td>epochs</td><td>5</td></tr><tr><td>warmup ratio</td><td>0.03</td></tr><tr><td>weight decay</td><td>0</td></tr><tr><td>max seq length</td><td>2048</td></tr></table>
250
+
251
+ # A.3 Performance Comparison
252
+
253
+ We provide a full comparison of each model’s performance in this section. In $\mathrm { F i g ~ } 1 0$ and Fig. 11, the full set of comparisons is provided. We see that especially in zero-shot case, Gorilla surpasses the GPT-4 and GPT-3.5 by a large margin. The GPT-4 and GPT-3.5 gets around $40 \%$ accuracy in Torch Hub and Tensor Hub, which are two structured API calls. Compared to that, HuggingFace is a more flexible and diverse Hub, as a result, the performance on HuggingFace is not as competitive.
254
+
255
+ ![](images/c97a3eb528201081e90dcd029c6ca34ecc48cc98eeb8f8cfc452082748dded07.jpg)
256
+ Figure 8: Example of the Dataset: Two examples of the dataset, the above one is zero-shot (without information retrievers) and the bottom one is with information retriever.
257
+
258
+ ![](images/9f860259f746fbd80d51ea251b34cdaf9e7960e987261662c7f6dd413b7f525f.jpg)
259
+ Figure 9: Hallucination Examples: GPT-4 incurs serious hallucination errors in HuggingFace. We show a couple of examples in the figure.
260
+
261
+ # A.3.1 Evaluation
262
+
263
+ For ease of evaluation, we manually cleaned up the dataset to ensure each API domain only contains the valid call of form:
264
+
265
+ ![](images/1a58fcb711fec3bbec32f37f18169cda2a8adfd6e4bcba92a4eab97a74b79e1f.jpg)
266
+
267
+ Our framework allows the user to define any combination of the arguments to check. For Torch Hub, we check for the API name torch.hub.load with arguments repo_or_dir and model. For Tensor Hub, we check API name hub.KerasLayer and hub.load with argument handle. For HuggingFace, since there are many API function names, we don’t list all of them here. One specific note is that we require the pretrained_model_name_or_path argument for all the calls except for pipeline. For pipeline, we don’t require the pretrained_model_name_or_path argument since it automatically select a model for you once task is specified.
268
+
269
+ # A.3.2 Hallucination
270
+
271
+ We found especially in HuggingFace, the GPT-4 model incurs serious hallucination problems. It would sometimes put a GitHub name that is not associated with the HuggingFace repository in to the domain of pretrained_model_name_or_path. Fig. 9 demonstrates some examples and we also observe that GPT-4 sometimes assumes the user have a local path to the model like your_model_name. This is greatly reduced by Gorilla as we see the hallucination error comparison in Table 1.
272
+
273
+ # A.3.3 AST as a Hallucination Metric
274
+
275
+ We evaluated the generated results on $1 0 0 \mathrm { L L M }$ generations (randomly chosen from our eval set). The accuracy using AST subtree matching is $78 \%$ , consistent with human evaluation with $78 \%$ accuracy in calling the right API. All the generations that AST flagged as incorrect, were the same ones that were manually also flagged as incorrect. Additionally, Gorilla generates supporting code to call the API which includes installing dependencies (e.g., pip install transformers[sentencepiece]), environment variables, etc. When we manually attempted to execute end-to-end code, $72 \%$ of all codes generated were executed successfully. It’s worth noting that the $6 \%$ discrepancy were NOT semantic errors, but errors that arose due to factors external to the API in the supporting code - we have included an example to illustrate this further. Considering the significant time and effort required for manual validation of each generation, our evaluation highlights the efficiency of using AST as a robust offline metric.
276
+
277
+ Here is a representative example, where we are able to load the correct model API. However, in the supporting code, after we have the output from the API, the zip() function tries to combine sentiments and scores together. However, since scores is a float, it’s not iterable. zip() expects both its arguments to be iterable, resulting in an ‘float’ object is not iterable error.
278
+
279
+ ![](images/9bdbc3a5b13361c0e35836ebeec465fb5e46498a4e42929217399c376e208829.jpg)
280
+ Figure 10: Performance: We plot each model’s performance on different configurations. We see that Gorilla performs extremely well in the zero-shot setting. While even when the oracle answer is given, Gorilla is still the best.
281
+
282
+ Table 7: Evaluating Gorilla (vs) DocPrompting Gorilla improves accuracy, while lowering the hallucination.
283
+
284
+ <table><tr><td colspan="3">Accuracy ↑</td></tr><tr><td>DocPrompting</td><td>Gorilla</td><td>Hallucination ↓ DocPrompting Gorilla</td></tr><tr><td>61.72</td><td>71.68</td><td>17.36 10.95</td></tr></table>
285
+
286
+ # A.3.4 Gorilla (VS) DocPrompting
287
+
288
+ We evaluate Gorilla and DocPrompting [49] on the HuggingFace Dataset from Table 1. For a 7B model, when trained on the same number of epochs, with and the same learning rate for both the models, Gorilla improves accuracy while reducing hallucination.
289
+
290
+ # A.3.5 Sensitivity to pre-training
291
+
292
+ Gorilla’s training recipe is robust to the pre-training strategies and recipes of the underlying model. From Fig. 13 we demonstrate that all the three models can converge to within a few percentage points in accuracy independent of the pre-trained base model.
293
+
294
+ ![](images/57a1a938061357ef7a79161d505f896c8ff49e55f8091344d71e340c18fc7a08.jpg)
295
+ Figure 11: Accuracy vs Hallucination: We plot each model’s performance on different configurations. We found that in the zero-shot setting, Gorilla has the most accuracy gain while maintaining good factual capability. When prompting with different retrievers, Gorilla is still capable to avoid the hallucination errors.
296
+
297
+ ![](images/b6336ccc559a6e38ac93484fbe278a578e7498de3e1195e0941e30707bb4da12.jpg)
298
+ Figure 12: The API call by Gorilla model are accurate and bug-free, but the supporting $\tt z i p ( )$ code has a bug.
299
+
300
+ ![](images/518b79d731d0efff423245dc1dcaa276e7dd04a4ccbd0110f8a42d8a5a3d3d51.jpg)
301
+ Figure 13: For the same train-eval dataset, our fine-tuning recipe, RAT, is robust to the underlying base model.
302
+
303
+ # NeurIPS Paper Checklist
304
+
305
+ # 1. Claims
306
+
307
+ Question: Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
308
+
309
+ Answer: [Yes]
310
+
311
+ Justification: The paper provides a recipe to teach LLMs to use tools, and also presents a data-set for evaluating API calling, and a metric for measuring hallucination. The paper studies them with rigorous evaluations.
312
+
313
+ # 2. Limitations
314
+
315
+ Question: Does the paper discuss the limitations of the work performed by the authors?
316
+
317
+ Answer: [Yes]
318
+
319
+ # 3. Theory Assumptions and Proofs
320
+
321
+ Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?
322
+
323
+ Answer: [NA]
324
+
325
+ # 4. Experimental Result Reproducibility
326
+
327
+ Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?
328
+
329
+ Answer: [Yes]
330
+
331
+ Justification: All the hyperparameters are specified in the appendix, and the code and dataset is open-sourced at github.com/ShishirPatil/gorilla.
332
+
333
+ # 5. Open access to data and code
334
+
335
+ Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?
336
+
337
+ Answer: [Yes]
338
+
339
+ Justification: All code, data, and models are open-sourced under the Apache 2.0 license by the authors.
340
+
341
+ # 6. Experimental Setting/Details
342
+
343
+ Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?
344
+
345
+ Answer: [Yes]
346
+
347
+ Justification: All the hyperparameters are specified in the appendix, and all code, data, and models are open-sourced.
348
+
349
+ # 7. Experiment Statistical Significance
350
+
351
+ Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?
352
+
353
+ Answer: [NA]
354
+
355
+ Justification: All non-LLM experiments are deterministic so need no error bars, and given the GPU costs involved, we perform LLM experiments once.
356
+
357
+ # 8. Experiments Compute Resources
358
+
359
+ Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?
360
+
361
+ Answer: [Yes]
362
+
363
+ Justification: Provided in Appendix including the sample dataset.
364
+
365
+ # 9. Code Of Ethics
366
+
367
+ Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines?
368
+
369
+ Answer: [Yes]
370
+
371
+ Justification: Conform’s with NeurIPS Code of Ethics
372
+
373
+ # 10. Broader Impacts
374
+
375
+ Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?
376
+
377
+ Answer: [Yes]
378
+
379
+ Justification: Integrating language models with API calls significantly extends their utility, enabling a wide range of applications from automating customer service to generating realtime content and facilitating data analysis. This integration can lead to more personalized and efficient user experiences across various platforms, as language models can process natural language inputs and interact with different APIs to fetch, interpret, and act on data in real time. For instance, in customer service, this can mean providing instant, relevant responses to queries, reducing wait times, and improving overall satisfaction. In content generation, it can enable dynamic creation of articles, reports, or summaries based on the latest data available from web services.
380
+
381
+ # 11. Safeguards
382
+
383
+ Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?
384
+
385
+ Answer: [NA]
386
+
387
+ Justification: Unlike Images, etc where there are copyrights involved, APIs are meant to distributed. Hence, the incentives are very well aligned. For example, if Gorilla presents a particular service’s API, the service benefits from engagement.
388
+
389
+ # 12. Licenses for existing assets
390
+
391
+ Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?
392
+
393
+ Answer: [Yes]
394
+
395
+ Justification: All code, data, and models are open-sourced under the Apache 2.0 license by the authors.
396
+
397
+ # 13. New Assets
398
+
399
+ Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?
400
+
401
+ Answer: [Yes]
402
+
403
+ Justification: The open-source repository is actively maintained at github.com/ShishirPatil/gorilla
404
+
405
+ # 14. Crowdsourcing and Research with Human Subjects
406
+
407
+ Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?
408
+
409
+ Answer: [NA]
410
+
411
+ # 15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects
412
+
413
+ Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?
414
+
415
+ Answer: [NA]
parse/test/tBRNC6YemY/tBRNC6YemY_content_list.json ADDED
@@ -0,0 +1,1011 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "Gorilla: Large Language Model Connected with Massive APIs ",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Shishir G. Patil1∗ Tianjun Zhang1∗ Xin Wang2 Joseph E. Gonzalez1 ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "1UC Berkeley 2Microsoft Research ",
16
+ "page_idx": 0
17
+ },
18
+ {
19
+ "type": "text",
20
+ "text": "shishirpatil@berkeley.edu ",
21
+ "page_idx": 0
22
+ },
23
+ {
24
+ "type": "text",
25
+ "text": "Abstract ",
26
+ "text_level": 1,
27
+ "page_idx": 0
28
+ },
29
+ {
30
+ "type": "text",
31
+ "text": "Large Language Models (LLMs) have seen an impressive wave of advances, with models now excelling in a variety of tasks, such as mathematical reasoning and program synthesis. However, their potential to effectively use tools via API calls remains unfulfilled. This is a challenging task even for today’s state-of-the-art LLMs such as GPT-4 largely due to their unawareness of what APIs are available and how to use them in a frequently updated tool set. We develop Gorilla, a finetuned LLaMA model that surpasses the performance of GPT-4 on writing API calls. Trained with the novel Retriever Aware Training (RAT), when combined with a document retriever, Gorilla demonstrates a strong capability to adapt to test-time document changes, allowing flexible user updates or version changes. It also substantially mitigates the issue of hallucination, commonly encountered when prompting LLMs directly. To evaluate the model’s ability, we introduce APIBench, a comprehensive dataset consisting of HuggingFace, TorchHub, and TensorHub APIs. The successful integration of the retrieval system with Gorilla demonstrates the potential for LLMs to use tools more accurately, keep up with frequently updated documentation, and consequently increase the reliability and applicability of their outputs. Gorilla’s code, model, data, and demo are available at: https://gorilla.cs.berkeley.edu ",
32
+ "page_idx": 0
33
+ },
34
+ {
35
+ "type": "text",
36
+ "text": "1 Introduction ",
37
+ "text_level": 1,
38
+ "page_idx": 0
39
+ },
40
+ {
41
+ "type": "text",
42
+ "text": "The use of APIs and Large Language Models [10, 5, 31, 6, 27, 28] has changed what it means to program. Previously, building complex machine learning software and systems required extensive time and specialized skills. Now with tools like the HuggingFace API, an engineer can set up a deep learning pipeline with a few lines of code. Instead of searching through StackOverflow and documentation, developers can ask models like GPT for solutions and receive immediate, actionable code with docstrings. However, using off-the-shelf LLMs to generate API calls remains unsolved because there are millions of available APIs which are frequently updated. ",
43
+ "page_idx": 0
44
+ },
45
+ {
46
+ "type": "text",
47
+ "text": "We connect LLM’s and massive API’s with Gorilla, a system which takes an instruction, for example “build me a classifier for medical images”, and provides the corresponding API call and relevant packages, along with a step-by-step explanation of the pipeline. Gorilla uses self-instruct, fine-tuning, and retrieval to enable LLMs to accurately select from a large, overlapping, and changing set tools expressed using their APIs and API documentation. Further, our novel retriever-aware training (RAT) enables the model to adapt to test-time changes of APIs such as evolution in versions and arguments. ",
48
+ "page_idx": 0
49
+ },
50
+ {
51
+ "type": "text",
52
+ "text": "With the development of API generation methods comes a question of how to evaluate, as many APIs will have overlapping functionality with nuanced limitations and constraints. Thus, we construct ",
53
+ "page_idx": 0
54
+ },
55
+ {
56
+ "type": "text",
57
+ "text": "Help me find an API to convert the spoken language in a recorded audio to text using Torch Hub. ",
58
+ "page_idx": 1
59
+ },
60
+ {
61
+ "type": "image",
62
+ "img_path": "images/985f72e0a4de43205cb9b6e1a2e7b7ed7f0760188e8ab6105316bea5c90160cc.jpg",
63
+ "image_caption": [
64
+ "Figure 1: Examples of API calls. Example API calls generated by GPT-4 [27], Claude [2], and Gorilla for the given prompt. In this example, GPT-4 presents a model that doesn’t exist, and Claude picks an incorrect library. In contrast, our Gorilla model can identify the task correctly and suggest a fully-qualified API call. "
65
+ ],
66
+ "image_footnote": [],
67
+ "page_idx": 1
68
+ },
69
+ {
70
+ "type": "image",
71
+ "img_path": "images/7efac0aab0dc42d93cc88e676322ec3eb1318032d5fffc7b12b03442db0b8a7f.jpg",
72
+ "image_caption": [
73
+ "Figure 2: Accuracy (vs) hallucination in four settings, that is, zero-shot (i.e., without any retriever), and with retrievers. Commonly used BM25 and GPT retrievers, and the oracle – returns relevant documents with perfect recall, indicating an upper bound. Higher in the graph (higher accuracy) and to the left (lower hallucination) is better. Across settings, our model, Gorilla, improves accuracy while reducing hallucination. "
74
+ ],
75
+ "image_footnote": [],
76
+ "page_idx": 1
77
+ },
78
+ {
79
+ "type": "text",
80
+ "text": "APIBench $\\sim 1 6 0 0$ APIs) by scraping a large corpus of ML APIs and developing an evaluation framework that uses AST sub-tree matching to check functional correctness. Further, we draw a distinction between accuracy and hallucination, and propose an Abstract Syntax Tree (AST) based technique to measure hallucination. ",
81
+ "page_idx": 1
82
+ },
83
+ {
84
+ "type": "text",
85
+ "text": "Using APIBench, we finetune Gorilla, a LLaMA-7B-based model with document retrieval and show that it significantly outperforms both open-source and closed-source models like Claude and GPT-4 in terms of API functionality accuracy as well as a reduction in API argument hallucination errors. We show an example output in Fig. 1. Lastly, we highlight Gorilla’s capability to comprehend and reason about user-defined constraints when choosing between APIs, an essential requirement for LLMs trained to accomplish tasks. ",
86
+ "page_idx": 1
87
+ },
88
+ {
89
+ "type": "text",
90
+ "text": "To summarize, this paper makes the following contributions: ",
91
+ "page_idx": 1
92
+ },
93
+ {
94
+ "type": "text",
95
+ "text": "1. We introduce Gorilla, the first system to enable large-scale API integration with LLMs, demonstrating state-of-the-art performance in generating accurate API calls across thousands of functions and libraries. \n2. We develop Retriever-Aware Training (RAT), a novel technique that enables LLMs to effectively utilize retrieved API documentation at inference time, improving both accuracy and adaptation to API changes. \n3. We present APIBench, a comprehensive benchmark of $\\sim 1 6 0 0$ machine learning APIs, along with new AST-based evaluation metrics that precisely measure both functional correctness and API hallucination. ",
96
+ "page_idx": 1
97
+ },
98
+ {
99
+ "type": "text",
100
+ "text": "2 Related Work ",
101
+ "text_level": 1,
102
+ "page_idx": 2
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "By empowering LLMs to use tools [33], we can grant LLMs access to vastly larger and changing knowledge bases and accomplish complex computational tasks. By providing access to search technologies and databases, [24, 39, 35] demonstrated that we can augment LLMs to address a significantly larger and more dynamic knowledge space. Similarly, by providing access to computational tools, [39, 1, 49, 36, 37] demonstrated that LLMs can accomplish complex computational tasks. Consequently, leading LLM providers [27], have started to integrate plugins to allow LLMs to invoke external tools through APIs. ",
107
+ "page_idx": 2
108
+ },
109
+ {
110
+ "type": "text",
111
+ "text": "Large Language Models Recent strides in the field of LLMs have renovated many downstream domains [10, 40, 48, 47], not only in traditional natural language processing tasks but also in program synthesis. Many of these advances are achieved by augmenting pre-trained LLMs by prompting [44, 14] and instruction fine-tuning [11, 30, 43, 15]. Recent open-sourced models like LLaMa [40], Alpaca [38], and Vicuna [9] have furthered the understanding of LLMs and facilitated their experimentation. While our approach, Gorilla, incorporates techniques akin to those mentioned, its primary emphasis is on enhancing the LLMs’ ability to utilize millions of tools, as opposed to refining their conversational skills. Additionally, we pioneer the study of fine-tuning a base model by supplementing it with information retrieval - a first, to the best of our knowledge. ",
112
+ "page_idx": 2
113
+ },
114
+ {
115
+ "type": "text",
116
+ "text": "Tool Usage The discussion of tool usage within LLMs has seen an upsurge, with models like Toolformer taking the lead [33, 19, 20, 24]. Tools often incorporated include web-browsing [32], calculators [12, 39], translation systems [39], and Python interpreters [14]. While these efforts can be seen as preliminary explorations of marrying LLMs with tool usage, they generally focus on specific tools. Our paper, in contrast, aims to explore a vast array of tools (i.e., API calls) in an open-ended fashion, potentially covering a wide range of applications. ",
117
+ "page_idx": 2
118
+ },
119
+ {
120
+ "type": "text",
121
+ "text": "With the recent launch of Toolformer [33] highlights the exciting potential of using large language models (LLMs) for purposes beyond traditional chatbot applications. Moreover, the application of API calls in robotics has been explored to some extent [41, 4]. However, these works primarily aim at showcasing the potential of “prompting” LLMs rather than establishing a systematic method for evaluation and training (including fine-tuning). Our work, on the other hand, concentrates on systematic evaluation and building a pipeline for future use. ",
122
+ "page_idx": 2
123
+ },
124
+ {
125
+ "type": "text",
126
+ "text": "LLMs for Program Synthesis Harnessing LLMs for program synthesis has historically been a challenging task [22, 7, 45, 16, 13, 29]. Researchers have proposed an array of strategies to prompt LLMs to perform better in coding tasks, including in-context learning [44, 18, 7], task decomposition [17, 46], and self-debugging [8, 34]. Besides prompting, there have also been efforts to pretrain language models specifically for code generation [25, 21, 26]. ",
127
+ "page_idx": 2
128
+ },
129
+ {
130
+ "type": "text",
131
+ "text": "DocPrompting [49] looked at choosing the right subset of code including API along with a retriever. Gorilla presents distinct advancements over DocPrompting. First, the way the data-sets are constructed are different, leading to intersting downstream artifacts. Gorilla focuses on model usages where we also collect detailed information about parameters, performance, efficiency, etc. This helps our trained model understand and respond to finer constraints for each API. Docprompting focuses on generic API calls but not on the details within an API call. Second, Gorilla introduces and uses the AST subtreematching evaluation metric that helps measure hallucination which we find are more representative of code structure and API accuracy compared to traiditional NLP metrics. Finally, Gorilla focuses on instruction-tuning method and has \"agency\" to interact with users while DocPrompting focuses on building an NLP-to-Code generative model. On equal footing, we demonstrate that Gorilla performs better than DocPrompting in Appendix A.3. ",
132
+ "page_idx": 2
133
+ },
134
+ {
135
+ "type": "text",
136
+ "text": "3 Methodology ",
137
+ "text_level": 1,
138
+ "page_idx": 2
139
+ },
140
+ {
141
+ "type": "text",
142
+ "text": "We first describe APIBench, a comprehensive benchmark constructed from TorchHub, TensorHub, and HuggingFace API Model Cards. We begin by outlining the process of collecting the API dataset and how we generated instruction-answer pairs. We then introduce Gorilla, a novel training paradigm with an information–retriever incorporated into the training and inference pipelines. Finally, we present our AST tree matching evaluation metric. ",
143
+ "page_idx": 2
144
+ },
145
+ {
146
+ "type": "image",
147
+ "img_path": "images/81cc98dd40b7f509fe2e642229d8b26278967a43dcabc59838befb9bcfd45a7f.jpg",
148
+ "image_caption": [
149
+ "Figure 3: Gorilla: A system for enabling LLMs to interact with APIs. The upper half represents the training procedure as described in Sec 3. This is the most exhaustive API data-set for ML to the best of our knowledge. During inference (lower half), Gorilla supports two modes - with retrieval, and zero-shot. In this example, it is able to suggest the right API call for generating the image from the user’s natural language query. "
150
+ ],
151
+ "image_footnote": [],
152
+ "page_idx": 3
153
+ },
154
+ {
155
+ "type": "text",
156
+ "text": "3.1 Dataset Curation ",
157
+ "text_level": 1,
158
+ "page_idx": 3
159
+ },
160
+ {
161
+ "type": "text",
162
+ "text": "To curate the dataset, we aggregate all model cards from HuggingFace’s “The Model Hub”, PyTorch Hub, and TensorFlow Hub. Throughout the rest of the paper, we call these HuggingFace, Torch Hub, and TensorFlow Hub respectively for brevity. ",
163
+ "page_idx": 3
164
+ },
165
+ {
166
+ "type": "text",
167
+ "text": "API Documentation The HuggingFace platform hosts and servers about 203,681 models. However, many of them have poor documentation, lack dependencies, have no information in their model card, etc. To filter these out, we pick the top 20 models from each domain. We consider 7 domains in multimodal data, 8 in CV, 12 in NLP, 5 in Audio, 2 in tabular data, and 2 in reinforcement learning. Post filtering, we arrive at a total of 925 models from HuggingFace. TensorFlow Hub is versioned into v1 and v2. The latest version (v2) has 801 models in total, and we process all of them. After filtering out model cards with little to no information, we are left with 626 models. Similar to TensorFlow Hub, we extract 95 models (exhaustive) from Torch Hub. We then convert the model cards for each of these 1,645 API calls into a JSON object with the following fields: {domain, framework, functionality, api_name, api_call, api_arguments, environment_requirements, example_code, performance, description}. We provide more information in Appendix A.1. These fields were chosen to generalize beyond API calls within the ML domain, to other domains, including RESTful, SQL, and other potential API calls. ",
168
+ "page_idx": 3
169
+ },
170
+ {
171
+ "type": "text",
172
+ "text": "Instruction Generation Guided by the self-instruct paradigm [42], we employ GPT-4 to generate synthetic instruction data. We provide three in-context examples, along with reference API documentation, and task the model with generating real-world use cases that call upon the API. We specifically instruct the model to refrain from using any API names or hints when creating instructions. We constructed 6 examples (Instruction-API pairs) for each of the 3 model hubs. These 18 examples were the only hand-generated or modified data. For each of our 1,645 API datapoints, we generate 10 instruction-API pairs by sampling 3 of 6 corresponding instruction examples in each pair (Fig. 3). ",
173
+ "page_idx": 3
174
+ },
175
+ {
176
+ "type": "text",
177
+ "text": "API Call with Constraints API calls often come with inherent constraints. These constraints necessitate that the LLM not only comprehend the functionality of the API call but also categorize the calls according to different constraint parameters. Specifically, for machine learning API calls, two common sets of constraints are parameter size and a lower bound on accuracy. Consider, for instance, the following prompt: “Invoke an image classification model that uses less than 10M parameters, but maintains an ImageNet accuracy of at least $70 \\%$ .” Such a prompt presents a substantial challenge for the LLM to accurately interpret and respond to. Not only must the LLM understand the user’s functional description, but it also needs to reason about the various constraints embedded within the request. This challenge underlines the intricate demands placed on LLMs in real-world API calls. It is not sufficient for the model to merely comprehend the basic functionality of an API call; it must also be capable of navigating the complex landscape of constraints that accompany such calls. We also incorporate these instructions in our training dataset. ",
178
+ "page_idx": 3
179
+ },
180
+ {
181
+ "type": "text",
182
+ "text": "",
183
+ "page_idx": 4
184
+ },
185
+ {
186
+ "type": "text",
187
+ "text": "3.2 Gorilla ",
188
+ "text_level": 1,
189
+ "page_idx": 4
190
+ },
191
+ {
192
+ "type": "text",
193
+ "text": "Our model, called Gorilla, is a retriever-aware finetuned LLaMA-7B model, specifically for API calls. As shown in Fig. 3, we employ self-instruct to generate {instruction, API} pairs. To fine-tune LLaMA, we convert this to a user-agent chat-style conversation, where each datapoint is a conversation with one round each for the user and the agent. We then perform standard instruction finetuning on the base LLaMA-7B model. For our experiments, we train Gorilla with and without the retriever. We would like to highlight that though we used the LLaMA model, our fine-tuning is robust to the underlying pre-trained model (see Appendinx A.3.5). ",
194
+ "page_idx": 4
195
+ },
196
+ {
197
+ "type": "text",
198
+ "text": "Retriever-Aware training (RAT) In retriever-aware training, the instruction-tuned dataset also appends to the user prompt, the relevant retrieved documentation with “Use this API documentation for reference: <retrieved_API_doc_JSON>”. This is critical, because the retrieved documentation is not necessarily accurate – retrievers have imperfect re-call. By augmenting the prompt with potentially incorrect documentation, but the accurate ground-truth in the LLM response, we are in-effect teaching the LLM to ‘judge’ the retriever at inference time. During inference, if the LLM reasons that the retriever presented a relevant API document, it can use the API documentation to respond to the user’s question, filling in additional details from the user’s prompt. However, if after looking at the prompt, the LLM reasons that the retrieved API document is not relevant to the user’s prompt, RAT trains the model to not get distracted by irrelevant context. The LLM then relies on the domain-specific knowledge baked-in during RAT training, to provide the user with the relevant API. Through RAT, we aim to teach the LLM to parse the second half of the question (API documentation) to answer the first half (user’s query). We demonstrate that this (1) makes the LLM adapt to test-time changes in API documentation, (2) improves performance from in-context learning, and (3) reduces hallucination error. ",
199
+ "page_idx": 4
200
+ },
201
+ {
202
+ "type": "text",
203
+ "text": "Surprisingly, we find that augmenting a LLM with retrieval, does not always lead to improved performance, and can at-times hurt performance. We share more insights along with details in Sec 4. ",
204
+ "page_idx": 4
205
+ },
206
+ {
207
+ "type": "text",
208
+ "text": "Gorilla Inference During inference, the user provides the prompt in natural language (Fig. 3). This can be for a simple task (e.g., “I would like to identify the objects in an image”), or they can specify a vague goal, (e.g., “I am going to the zoo, and would like to track animals”). Gorilla, similar to training, can be used for inference in two modes: zero-shot and with retrieval. In the zero-shot setting, this prompt (with no additional prompt tuning) is fed to the Gorilla LLM model, which then returns the API call needed to accomplish the task or goal. In retrieval mode, the retriever (either of BM25 or GPT-Index) first retrieves the most up-to-date API documentation stored in the API Database. Before being sent to Gorilla, the API documentation is concatenated to the user prompt along with the message “Use this API documentation for reference.” The output of Gorilla is an API to be invoked. Besides the concatenation as described, we do no further prompt tuning in our system. While we also implemented a system to execute these APIs, to help the user accomplish the goal, that is not a focus of this paper. ",
209
+ "page_idx": 4
210
+ },
211
+ {
212
+ "type": "text",
213
+ "text": "3.3 Verifying APIs ",
214
+ "text_level": 1,
215
+ "page_idx": 4
216
+ },
217
+ {
218
+ "type": "text",
219
+ "text": "Inductive program synthesis, where a program is synthesized to satisfy test cases, has found success in several avenues [3, 23]. However, test cases fall short when evaluating API calls, as it is often hard to verify the semantic correctness of the code. For example, consider the task of classifying an image. There are over 40 different models that can be used for the task. Even if we were to narrow down to a single family of densenet, there are four different configurations possible. Hence, there exist multiple correct answers and it is hard to tell if the API being used is functionally equivalent to the reference API by unit tests. Thus, to evaluate the performance of our model, we compare their functional equivalence using the dataset we collected. To trace which API in the dataset is the LLM calling, we adopt the AST tree-matching strategy. Since we only consider one API call in this paper, checking if the AST of the candidate API call is a sub-tree of the reference API call reveals which API is being used in the dataset. ",
220
+ "page_idx": 4
221
+ },
222
+ {
223
+ "type": "image",
224
+ "img_path": "images/d925c7ce98b8bcb012903cabb96332a6919dc2e117050a67995a8c1f29fb00a3.jpg",
225
+ "image_caption": [
226
+ "Figure 4: AST Sub-Tree Matching to evaluate API calls. On the left is an API call returned by Gorilla. We first build the associated API tree. We then compare this to our dataset, to see if the API dataset has a subtree match. In the above example, the matching subtree is highlighted in green, signifying that the API call is indeed correct. Pretrained $\\cdot ^ { = }$ True is an optional argument. "
227
+ ],
228
+ "image_footnote": [],
229
+ "page_idx": 5
230
+ },
231
+ {
232
+ "type": "text",
233
+ "text": "Identifying and even defining hallucinations can be challenging. We use the AST matching process to directly identify the hallucinations. We define a hallucination as an API call that is not a sub-tree of any API in the database – invoking an entirely imagined tool. This form of hallucination is distinct from invoking an API incorrectly which we instead define as an error. So, in our evaluations, error, hallucination, and accuracy add up to one. ",
234
+ "page_idx": 5
235
+ },
236
+ {
237
+ "type": "text",
238
+ "text": "AST Sub-Tree Matching We perform AST sub-tree matching to identify which API in our dataset is the LLM calling. Since each API call can have many arguments, we need to match on each of these arguments. Further, since, Python allows for default arguments, for each API, we define which arguments to match in our database. For example, we check repo_or_dir and model arguments in our function call. In this way, we can easily check if the argument matches the reference API or not. Fig. 4 illustrates an example subtree check for a torch API call. We first build the tree, and verify that it matches a subtree in our dataset along nodes torch.hub.load, pytorch/vision, and densenet121. We do not check for match along leaf node pretrained $\\equiv$ True since that is an optional argument. ",
239
+ "page_idx": 5
240
+ },
241
+ {
242
+ "type": "text",
243
+ "text": "4 Evaluation ",
244
+ "text_level": 1,
245
+ "page_idx": 5
246
+ },
247
+ {
248
+ "type": "text",
249
+ "text": "When evaluating Gorilla, finetuned on APIBench (train set), we aim to answer the following questions: How does Gorilla compare to other LLMs on API Bench (test set)? ( 4.1). How well does Gorilla adapt to test-time changes in API documentation? ( 4.2). How well can Gorilla handle questions with constraints? (4.3) ",
250
+ "page_idx": 5
251
+ },
252
+ {
253
+ "type": "text",
254
+ "text": "We demonstrate that Gorilla outperforms both open-source and close-source models for in-domain function calling. Further, trained with our novel retriever-aware training (RAT) technique, the Gorilla model generalizes to APIs that are outside of its training data (out-of-domain). In addition, we assess Gorilla’s ability to reason about API calls under constraints. Lastly, we examined how integrating different retrieval methods during training influences the model’s final performance. ",
255
+ "page_idx": 5
256
+ },
257
+ {
258
+ "type": "text",
259
+ "text": "Baselines We primarily compare Gorilla with state-of-the-art language models in a zero-shot setting and with 3-shot in-context learning. The models under consideration include: GPT-4 by OpenAI with the $\\mathtt { g p t - 4 - 0 3 1 4 }$ checkpoint; GPT-3.5-turbo with the gpt-3.5-turbo-0301 checkpoint, both of which are RLHF-tuned models specifically designed for conversation; Claude with the claude-v1 checkpoint, a language model by Anthropic, renowned for its lengthy context capabilities; and LLaMA-7B, a state-of-the-art open-source large language model by Meta. ",
260
+ "page_idx": 5
261
+ },
262
+ {
263
+ "type": "text",
264
+ "text": "Retrievers The term zero-shot (abbreviated as 0-shot in tables) refers to scenarios where no retriever is used. The sole input to the model is the user’s natural language prompt. For BM25, we consider each API as a separate document. During retrieval, we use the user’s query to fetch the most relevant (top-1) API. This API is concatenated with the user’s prompt to query the LLMs. Similarly, GPTIndex refers to the state-of-the-art embedding model, text-embedding-ada-002-v2 from OpenAI, where each embedding is 1,536 dimensional. Like BM25, each API call is indexed as an individual document, and the most relevant document, given a user query, is retrieved and appended to the user prompt. Lastly, we include an Oracle retriever, which serves two purposes: first, to identify the potential for performance improvement through more efficient retrievers, and second, to assist users who know which API to use but may need to help invoking it. In all cases, when a retriever is used, it is appended to the user’s prompt as follows: <user_prompt> Use this API documentation for reference: <retrieved_API_doc_JSON>. The dataset for these evaluations is detailed in Section 3. We emphasize that we have maintained a holdout test set on which we report our findings. The holdout test set was created by dividing the self-instruct dataset’s instruction, API pairs into training and testing sets. ",
265
+ "page_idx": 5
266
+ },
267
+ {
268
+ "type": "image",
269
+ "img_path": "images/449c629b6e3ba8fc11a7c0dc1881f5607b2867d5af62b45529a68ff27dea46bd.jpg",
270
+ "image_caption": [
271
+ "Figure 5: Accuracy with GPT-retriever. Methods to the left of the dotted line are closed source. Gorilla outperforms on Torch Hub and Hugging-Face while matching performance on Tensorflow Hub for all existing state-of-the-art LLMs - closed source, and open source. "
272
+ ],
273
+ "image_footnote": [],
274
+ "page_idx": 6
275
+ },
276
+ {
277
+ "type": "text",
278
+ "text": "",
279
+ "page_idx": 6
280
+ },
281
+ {
282
+ "type": "text",
283
+ "text": "4.1 AST Accuracy on API call ",
284
+ "text_level": 1,
285
+ "page_idx": 6
286
+ },
287
+ {
288
+ "type": "text",
289
+ "text": "We test each model for different retriever settings defined above (Table 1). We report the overall accuracy, the error by hallucination and the error by selecting wrong API call. Note that for TorchHub and TensorHub, we evaluate all the models using AST tree accuracy score. However, for HuggingFace, since the dataset cannot be exhaustive given the sheer number of models hosted, for all the models except Gorilla, we only check if they can provide the correct domain names. So this problem reduces to picking one of multiple choices. Across 0-shot and few-shot prompting strategies, Gorilla outperforms close-sourced and open-sourced models (Table 5). ",
290
+ "page_idx": 6
291
+ },
292
+ {
293
+ "type": "text",
294
+ "text": "Finetuning without Retrieval In Table 1 we show that lightly fine-tuned Gorilla is able to match, and often surpass performance in the zero-shot setting compared to closed-source, and open-source models – $2 0 . 4 3 \\%$ better than GPT-4 and $1 0 . 7 5 \\%$ better than GPT-3.5 (ChatGPT). When compared to other open-source models LLAMA, the improvement is as big as $83 \\%$ . This suggests quantitatively, that as a technique to augment information and enforce adherence to syntax, fine-tuning is better than naive retrieval, at-least within the scope of invoking APIs. ",
295
+ "page_idx": 6
296
+ },
297
+ {
298
+ "type": "text",
299
+ "text": "Finetuning with Retrieval We now discuss how incorporating retrieval (RAT) during LLM finetuning enhances model performance. In this experiment, the base LLAMA model is finetuned with a prompt (instruction-generated), a reference API document (from a golden-truth oracle), and an example output generated by an LLM (GPT-4 in this case). As shown in Table 2, incorporating a ground-truth retriever in the finetuning pipeline yields notably improved results – $1 2 . 3 7 \\%$ higher accuracy than training without retrieval in Torch Hub and $2 3 . 4 6 \\%$ better in HuggingFace. However, at evaluation time, current retrievers show a significant performance gap compared to the ground-truth retriever: using GPT-Index at evaluation results in $2 9 . 2 0 \\%$ accuracy degradation and using BM25 results in a $5 2 . 2 7 \\%$ accuracy degradation. Despite this, considering the trends across models and retrievers, our findings indicate that finetuning an LLM with effective retrieval integration is preferable to zero-shot finetuning. ",
300
+ "page_idx": 6
301
+ },
302
+ {
303
+ "type": "text",
304
+ "text": "Hallucination with LLM One phenomenon we observe is that zero-shot prompting with LLMs (GPT-4/GPT-3.5) to call APIs results in dire hallucination errors. These errors, while diverse, commonly manifest in erroneous behavior such as the model invoking the AutoModel.from_pretrained(dir_name) command with arbitrary GitHub repository names. Surprisingly, we also found that in TorchHub, HuggingFace and TensorFlow Hub, GPT-3.5 has less hallucination errors than GPT-4. This finding is also consistent for the settings when various retrieving methods are provided: 0-shot, BM25, GPT-Index and the oracle. This might suggest that RLHF plays a central role in turning the model to be truthful. Additional discussion in Appendix A.3. ",
305
+ "page_idx": 6
306
+ },
307
+ {
308
+ "type": "table",
309
+ "img_path": "images/1403238e2ba31ad7b163e22f63d07f75b01746e028b3779be35d47f2569c3823.jpg",
310
+ "table_caption": [
311
+ "Table 1: Evaluating LLMs on Torch Hub, HuggingFace, and Tensorflow Hub APIs "
312
+ ],
313
+ "table_footnote": [],
314
+ "table_body": "<table><tr><td rowspan=\"2\">LLM (retriever)</td><td colspan=\"2\">TorchHub</td><td colspan=\"5\">HuggingFace</td><td colspan=\"3\">TensorFlow Hub</td></tr><tr><td>overall 个</td><td>hallu ↓</td><td>err↓</td><td>overall 个</td><td>hallu↓</td><td>err↓</td><td>overall 个</td><td></td><td>hallu↓</td><td>err←</td></tr><tr><td>LLAMA (0-shot)</td><td>0</td><td>100</td><td>0</td><td>0.00</td><td>97.57</td><td>2.43</td><td>0</td><td></td><td>100</td><td>0</td></tr><tr><td>GPT-3.5 (0-shot)</td><td>48.38</td><td>18.81</td><td>32.79</td><td>16.81</td><td>35.73</td><td></td><td>47.46</td><td>41.75</td><td>47.88</td><td>10.36</td></tr><tr><td>GPT-4 (0-shot)</td><td>38.70</td><td>36.55</td><td>24.7</td><td>19.80</td><td>37.16</td><td>43.03</td><td></td><td>18.20</td><td>78.65</td><td>3.13</td></tr><tr><td>Claude (0-shot)</td><td>18.81</td><td>65.59</td><td>15.59</td><td>6.19</td><td>77.65</td><td>16.15</td><td></td><td>9.19</td><td>88.46</td><td>2.33</td></tr><tr><td>Gorilla (0-shot)</td><td>59.13</td><td>6.98</td><td>33.87</td><td>71.68</td><td>10.95</td><td>17.36</td><td></td><td>83.79</td><td>5.40</td><td>10.80</td></tr><tr><td>LLAMA (BM-25)</td><td>8.60</td><td>76.88</td><td>14.51</td><td>3.00</td><td>77.99</td><td></td><td>19.02</td><td>8.90</td><td>77.37</td><td>13.72</td></tr><tr><td>GPT-3.5 (BM-25)</td><td>38.17</td><td>6.98</td><td>54.83</td><td>17.26</td><td>8.30</td><td></td><td>74.44</td><td>54.16</td><td>3.64</td><td>42.18</td></tr><tr><td>GPT-4 (BM-25)</td><td>35.48</td><td>11.29</td><td>53.22</td><td>16.48</td><td>15.93</td><td></td><td>67.59</td><td>34.01</td><td>37.08</td><td>28.90</td></tr><tr><td>Claude (BM-25)</td><td>39.78</td><td>5.37</td><td>54.83</td><td>14.60</td><td>15.82</td><td></td><td>69.58</td><td>35.18</td><td>21.16</td><td>43.64</td></tr><tr><td>Gorilla (BM-25)</td><td>40.32</td><td>4.30</td><td>55.37</td><td>17.03</td><td>6.42</td><td>76.55</td><td></td><td>41.89</td><td>2.77</td><td>55.32</td></tr><tr><td>LLAMA (GPT-Index)</td><td>14.51</td><td>75.8</td><td>9.67</td><td>10.18</td><td>75.66</td><td></td><td>14.20</td><td>15.62</td><td>77.66</td><td>6.71</td></tr><tr><td>GPT-3.5 (GPT-Index)</td><td>60.21</td><td>1.61</td><td>38.17</td><td>29.08</td><td>7.85</td><td></td><td>44.80</td><td>65.59</td><td>3.79</td><td>30.50</td></tr><tr><td>GPT-4 (GPT-Index)</td><td>59.13</td><td>1.07</td><td>39.78</td><td>44.58</td><td>11.18</td><td></td><td>44.25</td><td>43.94</td><td>31.53</td><td>24.52</td></tr><tr><td>Claude (GPT-Index)</td><td>60.21</td><td>3.76</td><td>36.02</td><td>41.37</td><td>18.81</td><td></td><td>39.82</td><td>55.62</td><td>16.20</td><td>28.17</td></tr><tr><td>Gorilla (GPT-Index)</td><td>61.82</td><td>0</td><td>38.17</td><td>47.46</td><td>8.19</td><td></td><td>44.36</td><td>64.96</td><td>2.33</td><td>32.70</td></tr><tr><td>LLAMA (Oracle)</td><td>16.12</td><td>79.03</td><td>4.83</td><td>17.70</td><td>77.10</td><td></td><td>5.20</td><td>12.55</td><td>87.00</td><td>0.43</td></tr><tr><td>GPT-3.5 (Oracle)</td><td>66.31</td><td>1.60</td><td>32.08</td><td>89.71</td><td>6.64</td><td></td><td>3.65</td><td>95.03</td><td>0.29</td><td>4.67</td></tr><tr><td>GPT-4 (Oracle)</td><td>66.12</td><td>0.53</td><td>33.33</td><td>85.07</td><td>10.62</td><td></td><td>4.31</td><td>55.91</td><td>37.95</td><td>6.13</td></tr><tr><td>Claude (Oracle)</td><td>63.44</td><td>3.76</td><td>32.79</td><td>77.21</td><td>19.58</td><td>3.21</td><td></td><td>74.74</td><td>21.60</td><td>3.64</td></tr><tr><td>Gorilla (Oracle)</td><td>67.20</td><td>0</td><td>32.79</td><td>91.26</td><td>7.08</td><td></td><td>1.66</td><td>94.16</td><td>1.89</td><td>3.94</td></tr></table>",
315
+ "page_idx": 7
316
+ },
317
+ {
318
+ "type": "table",
319
+ "img_path": "images/8d81b5a0157178318779a3a4940fb4e3015512a7375e7cf50dae02895e66a2b4.jpg",
320
+ "table_caption": [
321
+ "Table 2: Understanding the effect of different retrieval techniques used with Gorilla "
322
+ ],
323
+ "table_footnote": [],
324
+ "table_body": "<table><tr><td></td><td colspan=\"4\">Gorilla without Retriever</td><td colspan=\"4\">Gorilla with Oracle retriever</td></tr><tr><td></td><td>zero-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>zero-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td></tr><tr><td>Torch Hub (overall) ↑</td><td>59.13</td><td>37.63</td><td>60.21</td><td>54.83</td><td>0</td><td>40.32</td><td>61.82</td><td>67.20</td></tr><tr><td>HuggingFace (overall) ↑</td><td>71.68</td><td>11.28</td><td>28.10</td><td>45.58</td><td>0</td><td>17.04</td><td>47.46</td><td>91.26</td></tr><tr><td>TensorHub (overall) 个</td><td>83.79</td><td>34.30</td><td>52.40</td><td>82.91</td><td>0</td><td>41.89</td><td>64.96</td><td>94.16</td></tr><tr><td>Torch Hub (Hallu)↓</td><td>6.98</td><td>11.29</td><td>4.30</td><td>15.59</td><td>100</td><td>4.30</td><td>0</td><td>0</td></tr><tr><td>HuggingFace (Hallu)↓</td><td>10.95</td><td>46.46</td><td>41.48</td><td>52.77</td><td>99.67</td><td>6.42</td><td>8.19</td><td>7.08</td></tr><tr><td>TensorHub (Hallu)↓</td><td>5.40</td><td>20.43</td><td>19.70</td><td>13.28</td><td>100</td><td>2.77</td><td>2.33</td><td>1.89</td></tr></table>",
325
+ "page_idx": 7
326
+ },
327
+ {
328
+ "type": "text",
329
+ "text": "",
330
+ "page_idx": 7
331
+ },
332
+ {
333
+ "type": "text",
334
+ "text": "AST as a Hallucination Metric We manually execute Gorilla’s API generations to evaluate how well AST works as an evaluation metric. Executing every code generated is impractical within academic setting—for example, executing the HuggingFace model needs the required library dependencies (e.g., transformers, sentencepiece, accelerate), correct coupling of software kernels (e.g., torch vision, torch, cuda, cudnn versions), and required hardware support (e.g., A100 40G gpus). Hence, to make it tractable, we sampled 100 random Gorilla generations from our evalualtion set. The accuracy from our AST subtree matching is $78 \\%$ , consistent with human evaluation of $78 \\%$ accuracy in calling the right API. All the generations that AST flagged as incorrect, were the same ones that were manually flagged as incorrect. Additionally, Gorilla also generates supporting code to call the API which includes installing dependencies e.g., pip install transformers[sentencepiece]), setting environment variables, etc. When we manually attempt to execute the code, $7 2 \\%$ of all code generated executed successfully. It’s worth noting that the $6 \\%$ discrepancy are not semantic errors, but errors that arose due to factors external to the API, and in the supporting code. We have included the full example to illustrate this further in A.3.3. Considering the significant time and effort required for manual validation of each generation, the strong correlation between human evaluation and the AST evaluation further reinforces our belief in using the proposed AST as a robust offline metric. ",
335
+ "page_idx": 7
336
+ },
337
+ {
338
+ "type": "image",
339
+ "img_path": "images/d719d1a77e259ba2d44eba4f18ef02b35c7273c94b9016cfb75b51a6e04c8b8c.jpg",
340
+ "image_caption": [
341
+ "Figure 6: Gorilla’s retriever–aware training enables it to react to changes in the APIs. The second column demonstrates changes in model upgrading FCN’s ResNet–50 backbone to ResNet–101. The third column demonstrate changes in model registry from pytorch/vision to NVIDIA/DeepLearningExamples:torchhub "
342
+ ],
343
+ "image_footnote": [],
344
+ "page_idx": 8
345
+ },
346
+ {
347
+ "type": "table",
348
+ "img_path": "images/c86f8d5d05f958e669445a62ec5575d63889902d441267f0602723f50bfe7b5f.jpg",
349
+ "table_caption": [
350
+ "Table 4: Evaluating LLMs on constraint-aware API invocations "
351
+ ],
352
+ "table_footnote": [],
353
+ "table_body": "<table><tr><td></td><td colspan=\"4\">GPT-3.5</td><td colspan=\"4\">GPT-4</td><td colspan=\"4\">Gorilla</td></tr><tr><td></td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td></tr><tr><td>Torch Hub (overall)</td><td>73.94</td><td>62.67</td><td>81.69</td><td>80.98</td><td>62.67</td><td>56.33</td><td>71.11</td><td>69.01</td><td>71.83</td><td>57.04</td><td>71.83</td><td>78.16</td></tr><tr><td>Torch Hub (Hallu)</td><td>19.01</td><td>30.98</td><td>14.78</td><td>14.08</td><td>15.49</td><td>27.46</td><td>14.08</td><td>9.15</td><td>19.71</td><td>39.43</td><td>26.05</td><td>16.90</td></tr><tr><td>Torch Hub (err)</td><td>7.04</td><td>6.33</td><td>3.52</td><td>4.92</td><td>21.83</td><td>16.19</td><td>14.78</td><td>21.83</td><td>8.45</td><td>3.52</td><td>2.11</td><td>4.92</td></tr><tr><td>Accuracy const</td><td>43.66</td><td>33.80</td><td>33.09</td><td>69.01</td><td>43.66</td><td>29.57</td><td>29.57</td><td>59.15</td><td>47.88</td><td>30.28</td><td>26.76</td><td>67.60</td></tr><tr><td>LLAMA</td><td colspan=\"8\"></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td>0-shot</td><td>BM25</td><td>GPT-Index</td><td>Oracle</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (overall)</td><td>0</td><td>8.45</td><td>11.97</td><td>19.71</td><td>29.92</td><td>81.69</td><td>82.39</td><td>81.69</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (Hallu)</td><td>100</td><td>91.54</td><td>88.02</td><td>78.87</td><td>67.25</td><td>16.19</td><td>15.49</td><td>13.38</td><td></td><td></td><td></td><td></td></tr><tr><td>Torch Hub (err)</td><td>0</td><td>0</td><td>0</td><td>1.4</td><td>2.81</td><td>2.11</td><td>2.11</td><td>4.92</td><td></td><td></td><td></td><td></td></tr><tr><td>Accuracy const</td><td>0</td><td>6.33</td><td>3.52</td><td>17.60</td><td>17.25</td><td>29.57</td><td>31.69</td><td>69.71</td><td></td><td></td><td></td><td></td></tr></table>",
354
+ "page_idx": 8
355
+ },
356
+ {
357
+ "type": "table",
358
+ "img_path": "images/2f28935422a118789dd2c5f5ebb914d9c1edeed7752a71bf38352f9dcb9cc384.jpg",
359
+ "table_caption": [
360
+ "Table 3: Proposed AST evaluation metric has strong correlation with human evaluation "
361
+ ],
362
+ "table_footnote": [],
363
+ "table_body": "<table><tr><td></td><td>Accuracy</td></tr><tr><td>Gorilla AST metric (proposed)</td><td>0.78</td></tr><tr><td>Eval by Human</td><td>0.78</td></tr><tr><td>Code Executable (Eval by Human)</td><td>0.72</td></tr></table>",
364
+ "page_idx": 8
365
+ },
366
+ {
367
+ "type": "text",
368
+ "text": "4.2 Test-Time Documentation Change ",
369
+ "text_level": 1,
370
+ "page_idx": 8
371
+ },
372
+ {
373
+ "type": "text",
374
+ "text": "The rapidly evolving nature of API documentation presents a significant challenge for the application of LLMs in this field. These documents are often updated at a frequency that outpaces the retraining or fine-tuning schedule of LLMs, making these models particularly brittle to changes in the information they are designed to process. This mismatch in update frequency can lead to a decline in the utility and reliability of LLMs over time. ",
375
+ "page_idx": 8
376
+ },
377
+ {
378
+ "type": "text",
379
+ "text": "With the introduction of Gorilla’s retriever-aware training, the RAT trained LLM readily adapts to changes in API documentation. This novel approach allows the model to remain relevant, even as the API documentation it relies on undergoes modifications. This is a pivotal advancement in the field, as it ensures that the LLM maintains its efficacy and accuracy over time, providing reliable outputs irrespective of changes in the underlying documentation. ",
380
+ "page_idx": 8
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "For instance, consider the scenario illustrated in Fig. 6, where the training of Gorilla has allowed it to react effectively to changes in APIs. This includes alterations such as upgrading the FCN’s ResNet-50 backbone to ResNet-101, as demonstrated in the second column of the figure. Since the model has encountered ResNet-101 as a backbone with other architectures, it interprets an FCN with a ResNet-101 backbone (unseen during training) as a relevant document at test time. Conversely, if the retriever suggests an FCN with a ResNet-60 backbone, the model—unfamiliar with ResNet-60 from RAT—assigns low confidence to this document and defaults back to FCN with ResNet-50. The third column in Fig. 6 further illustrates Gorilla’s flexibility in adapting to shifts in model registries, such as from pytorch/vision to NVIDIA/DeepLearningExamples:torchhub, highlighting its ability to accommodate changes in preferred API sources as they evolve over time. ",
385
+ "page_idx": 8
386
+ },
387
+ {
388
+ "type": "table",
389
+ "img_path": "images/240835429b53ed47a56fa13669ed92eed96a6aaa0a26fd37e0458297a519b71e.jpg",
390
+ "table_caption": [
391
+ "Table 5: Evaluating Gorilla 0-shot with GPT 3-shot incontext examples "
392
+ ],
393
+ "table_footnote": [],
394
+ "table_body": "<table><tr><td></td><td>HF (Acc ↑)</td><td>HF (Hall ↓)</td><td>TH (Acc ↑)</td><td>TH (Hall ↓)</td><td>TF (Acc ↑)</td><td>TF (Hall ↓)</td></tr><tr><td>GPT-3.5 (0-shot)</td><td>16.81</td><td>35.73</td><td>41.93</td><td>10.75</td><td>41.75</td><td>47.88</td></tr><tr><td>GPT-4 (0-shot)</td><td>19.80</td><td>37.16</td><td>54.30</td><td>34.40</td><td>18.20</td><td>78.65</td></tr><tr><td>GPT-3.5 (3 incont)</td><td>25.77</td><td>32.30</td><td>73.11</td><td>72.58</td><td>71.82</td><td>11.09</td></tr><tr><td>GPT-4 (3 incont)</td><td>26.32</td><td>35.84</td><td>75.80</td><td>13.44</td><td>77.37</td><td>11.97</td></tr><tr><td>Gorilla (0-shot)</td><td>58.05</td><td>28.32</td><td>75.80</td><td>16.12</td><td>83.79</td><td>5.40</td></tr></table>",
395
+ "page_idx": 9
396
+ },
397
+ {
398
+ "type": "text",
399
+ "text": "In summary, Gorilla’s ability to adapt to test-time changes in API documentation offers numerous benefits. It maintains its accuracy and relevance over time, adapts to the rapid pace of updates in API documentation, and adjusts to modifications in underlying models and systems. This makes it a robust and reliable tool for API calls, significantly enhancing its practical utility. ",
400
+ "page_idx": 9
401
+ },
402
+ {
403
+ "type": "text",
404
+ "text": "4.3 API Call with Constraints ",
405
+ "text_level": 1,
406
+ "page_idx": 9
407
+ },
408
+ {
409
+ "type": "text",
410
+ "text": "We now focus on the language model’s capability of understanding constraints. For any given task, which API call to invoke is typically a tradeoff between a multitude of factors. In the case of RESTFul APIs, it could be the cost of each invocation $\\textcircled { \\$ 5}$ or the latency of response (ms), among many others. Similarly, within the scope of ML APIs, it is desirable for Gorilla to respect constraints such as accuracy, number of learnable parameters in the model, the size on disk, peak memory consumption, FLOPS, etc. In this section, we present a study evaluating the ability of different models in zero-shot and in the presence of retrievers to respect a given accuracy constraint. : if a user requests an image classification model that achieves at least $80 \\%$ top-1 accuracy on the ImageNet dataset, then among the classification models hosted by Torch Hub, ResNeXt-101 $3 2 \\mathbf { x } 1 6 \\mathbf { d }$ , with a top-1 accuracy of $8 4 . 2 \\%$ , would be the appropriate model to call, rather than MobileNetV2, which has a top-1 accuracy of $7 1 . 8 8 \\%$ . ",
411
+ "page_idx": 9
412
+ },
413
+ {
414
+ "type": "text",
415
+ "text": "For Table 4, we filtered a subset of the Torch Hub component of APIBench, retaining those models that had an accuracy metric defined for at least one-dataset the model was evaluated on, in its model card. We were left with $6 5 . 2 6 \\%$ of TorchHub dataset from Table 1. We notice that with constraints, understandably, the accuracy drops across all models, with and without a retriever. Even in this challenging scenario, Gorilla is able to match the performance of the best-performing model GPT-3.5 when using retrievals (BM25, GPT-Index), and has the highest accuracy in the zero-shot setting. This highlights Gorilla’s ability to navigate APIs while considering the trade-offs between constraints. ",
416
+ "page_idx": 9
417
+ },
418
+ {
419
+ "type": "text",
420
+ "text": "4.4 Finetuning (vs) Prompting: Gorilla 0-shot (vs) GPT 3-shot ",
421
+ "text_level": 1,
422
+ "page_idx": 9
423
+ },
424
+ {
425
+ "type": "text",
426
+ "text": "To assess whether finetuning is truly necessary for APIs or if prompting alone is sufficient, we compare Gorilla in a zero-shot setting with three-shot in-context prompting for GPT-3.5 and GPT-4 models. In Table 5, \"3-incont\" denotes evaluation using three in-context examples, while \"HF,\" \"TH,\" and \"TF\" represent the HuggingFace, TorchHub, and TensorFlow Hub subsets of APIBench, respectively. Higher accuracy (Acc) and lower hallucination (Hall) rates are preferred. From Table 5, three-shot in-context learning improves the GPT models’ ability to generate syntactically correct function calls, even matching accuracy on one subset (TorchHub). However, Gorilla 0-shot still outperforms the 3-shot GPT models on average. ",
427
+ "page_idx": 9
428
+ },
429
+ {
430
+ "type": "text",
431
+ "text": "5 Conclusion ",
432
+ "text_level": 1,
433
+ "page_idx": 9
434
+ },
435
+ {
436
+ "type": "text",
437
+ "text": "LLMs are swiftly gaining popularity across diverse domains. APIs, serving as a universal language, are essential for enabling LLMs to communicate and operate effectively across diverse systems. In this paper, we introduced Gorilla, a state-of-the-art model for API invocation. Our Retriever Aware Training (RAT) approach empowers Gorilla with two essential capabilities: adapting dynamically to API changes at test time and reasoning through user-defined constraints when selecting suitable APIs. We also present APIBench, a comprehensive benchmark for assessing LLMs’ function-calling abilities, and propose AST-based hallucination metrics for robust evaluation. Looking forward, we believe this work represents a first step towards transitioning LLMs from knowledge-bound models into flexible interfaces that interact with the digital world. ",
438
+ "page_idx": 9
439
+ },
440
+ {
441
+ "type": "text",
442
+ "text": "References ",
443
+ "text_level": 1,
444
+ "page_idx": 10
445
+ },
446
+ {
447
+ "type": "text",
448
+ "text": "arguments with reading comprehension. arXiv preprint arXiv:1909.00109, 2019. [2] Anthropic. Claude, 2022. URL https://www.anthropic.com/index/ introducing-claude. [3] Bavishi, R., Lemieux, C., Fox, R., Sen, K., and Stoica, I. Autopandas: neural-backed generators for program synthesis. Proceedings of the ACM on Programming Languages, (OOPSLA), 2019. \n[4] Brohan, A., Chebotar, Y., Finn, C., Hausman, K., Herzog, A., Ho, D., Ibarz, J., Irpan, A., Jang, E., Julian, R., et al. Do as i can, not as i say: Grounding language in robotic affordances. In Conference on robot learning. PMLR, 2023. [5] Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. Advances in neural information processing systems, 2020. \n[6] Bubeck, S., Chandrasekaran, V., Eldan, R., Gehrke, J., Horvitz, E., Kamar, E., Lee, P., Lee, Y. T., Li, Y., Lundberg, S., et al. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712, 2023. \n[7] Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. d. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021. \n[8] Chen, X., Lin, M., Schärli, N., and Zhou, D. Teaching large language models to self-debug. arXiv preprint arXiv:2304.05128, 2023. \n[9] Chiang, W.-L., Li, Z., Lin, Z., Sheng, Y., Wu, Z., Zhang, H., Zheng, L., Zhuang, S., Zhuang, Y., Gonzalez, J. E., Stoica, I., and Xing, E. P. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \\% *$ chatgpt quality, March 2023. \n[10] Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022. \n[11] Chung, H. W., Hou, L., Longpre, S., Zoph, B., Tay, Y., Fedus, W., Li, Y., Wang, X., Dehghani, M., Brahma, S., et al. Scaling instruction-finetuned language models. Journal of Machine Learning Research, 2024. \n[12] Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021. \n[13] Devlin, J., Uesato, J., Bhupatiraju, S., Singh, R., Mohamed, A.-r., and Kohli, P. Robustfill: Neural program learning under noisy i/o. In International conference on machine learning. PMLR, 2017. \n[14] Gao, L., Madaan, A., Zhou, S., Alon, U., Liu, P., Yang, Y., Callan, J., and Neubig, G. Pal: Program-aided language models. In International Conference on Machine Learning. PMLR, 2023. \n[15] Iyer, S., Lin, X. V., Pasunuru, R., Mihaylov, T., Simig, D., Yu, P., Shuster, K., Wang, T., Liu, Q., Koura, P. S., et al. Opt-iml: Scaling language model instruction meta learning through the lens of generalization. arXiv preprint arXiv:2212.12017, 2022. \n[16] Jain, N., Vaidyanath, S., Iyer, A., Natarajan, N., Parthasarathy, S., Rajamani, S., and Sharma, R. Jigsaw: Large language models meet program synthesis. In Proceedings of the 44th International Conference on Software Engineering, 2022. \n[17] Kim, G., Baldi, P., and McAleer, S. Language models can solve computer tasks. arXiv preprint arXiv:2303.17491, 2023. \n[18] Kojima, T., Gu, S. S., Reid, M., Matsuo, Y., and Iwasawa, Y. Large language models are zero-shot reasoners. Advances in neural information processing systems, 2022. \n[19] Komeili, M., Shuster, K., and Weston, J. Internet-augmented dialogue generation. arXiv preprint arXiv:2107.07566, 2021. \n[20] Lazaridou, A., Gribovskaya, E., Stokowiec, W., and Grigorev, N. Internet-augmented language models through few-shot prompting for open-domain question answering. arXiv preprint arXiv:2203.05115, 2022. \n[21] Li, R., Allal, L. B., Zi, Y., Muennighoff, N., Kocetkov, D., Mou, C., Marone, M., Akiki, C., Li, J., Chim, J., et al. Starcoder: may the source be with you! arXiv preprint arXiv:2305.06161, 2023. \n[22] Li, Y., Choi, D., Chung, J., Kushman, N., Schrittwieser, J., Leblond, R., Eccles, T., Keeling, J., Gimeno, F., Dal Lago, A., et al. Competition-level code generation with alphacode. Science, 2022. \n[23] Menon, A., Tamuz, O., Gulwani, S., Lampson, B., and Kalai, A. A machine learning framework for programming by example. In International Conference on Machine Learning. PMLR, 2013. \n[24] Nakano, R., Hilton, J., Balaji, S., Wu, J., Ouyang, L., Kim, C., Hesse, C., Jain, S., Kosaraju, V., Saunders, W., et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021. \n[25] Nijkamp, E., Pang, B., Hayashi, H., Tu, L., Wang, H., Zhou, Y., Savarese, S., and Xiong, C. Codegen: An open large language model for code with multi-turn program synthesis. arXiv preprint arXiv:2203.13474, 2022. \n[26] Nijkamp, E., Hayashi, H., Xiong, C., Savarese, S., and Zhou, Y. Codegen2: Lessons for training llms on programming and natural languages. arXiv preprint arXiv:2305.02309, 2023. \n[27] OpenAI. Gpt-4 technical report, 2023. \n[28] OpenAI and https://openai.com/blog/chatgpt. Chatgpt, 2022. URL https://openai.com/ blog/chatgpt. \n[29] Roziere, B., Lachaux, M.-A., Chanussot, L., and Lample, G. Unsupervised translation of programming languages. Advances in neural information processing systems, 2020. \n[30] Sanh, V., Webson, A., Raffel, C., Bach, S. H., Sutawika, L., Alyafeai, Z., Chaffin, A., Stiegler, A., Scao, T. L., Raja, A., et al. Multitask prompted training enables zero-shot task generalization. arXiv preprint arXiv:2110.08207, 2021. \n[31] Scao, T. L., Fan, A., Akiki, C., Pavlick, E., Ilic, S., Hesslow, D., Castagné, R., Luccioni, A. S., ´ Yvon, F., Gallé, M., et al. Bloom: A 176b-parameter open-access multilingual language model. arXiv preprint arXiv:2211.05100, 2022. \n[32] Schick, T. and Schütze, H. Exploiting cloze questions for few shot text classification and natural language inference. arXiv preprint arXiv:2001.07676, 2020. \n[33] Schick, T., Dwivedi-Yu, J., Dessi, R., Raileanu, R., Lomeli, M., Hambro, E., Zettlemoyer, L., Cancedda, N., and Scialom, T. Toolformer: Language models can teach themselves to use tools. Advances in Neural Information Processing Systems, 2023. \n[34] Shinn, N., Labash, B., and Gopinath, A. Reflexion: an autonomous agent with dynamic memory and self-reflection. arXiv preprint arXiv:2303.11366, 2023. \n[35] Shuster, K., Xu, J., Komeili, M., Ju, D., Smith, E. M., Roller, S., Ung, M., Chen, M., Arora, K., Lane, J., et al. Blenderbot 3: a deployed conversational agent that continually learns to responsibly engage. arXiv preprint arXiv:2208.03188, 2022. \n[36] Subramanian, S., Narasimhan, M., Khangaonkar, K., Yang, K., Nagrani, A., Schmid, C., Zeng, A., Darrell, T., and Klein, D. Modular visual question answering via code generation. arXiv preprint arXiv:2306.05392, 2023. \n[37] Surís, D., Menon, S., and Vondrick, C. Vipergpt: Visual inference via python execution for reasoning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2023. \n[38] Taori, R., Gulrajani, I., Zhang, T., Dubois, Y., Li, X., Guestrin, C., Liang, P., and Hashimoto, T. B. Stanford alpaca: An instruction-following llama model, 2023. \n[39] Thoppilan, R., De Freitas, D., Hall, J., Shazeer, N., Kulshreshtha, A., Cheng, H.-T., Jin, A., Bos, T., Baker, L., Du, Y., et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022. \n[40] Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023. \n[41] Vemprala, S., Bonatti, R., Bucker, A., and Kapoor, A. Chatgpt for robotics: Design principles and model abilities. 2023, 2023. \n[42] Wang, Y., Kordi, Y., Mishra, S., Liu, A., Smith, N. A., Khashabi, D., and Hajishirzi, H. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022. \n[43] Wang, Y., Mishra, S., Alipoormolabashi, P., Kordi, Y., Mirzaei, A., Naik, A., Ashok, A., Dhanasekaran, A. S., Arunkumar, A., Stap, D., et al. Super-naturalinstructions: Generalization via declarative instructions on $1 6 0 0 +$ nlp tasks. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, 2022. \n[44] Wei, J., Wang, X., Schuurmans, D., Bosma, M., Xia, F., Chi, E., Le, Q. V., Zhou, D., et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems, 2022. \n[45] Xu, F. F., Alon, U., Neubig, G., and Hellendoorn, V. J. A systematic evaluation of large language models of code. In Proceedings of the 6th ACM SIGPLAN International Symposium on Machine Programming, 2022. \n[46] Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., and Cao, Y. React: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629, 2022. \n[47] Zeng, A., Liu, X., Du, Z., Wang, Z., Lai, H., Ding, M., Yang, Z., Xu, Y., Zheng, W., Xia, X., et al. Glm-130b: An open bilingual pre-trained model. arXiv preprint arXiv:2210.02414, 2022. \n[48] Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, X. V., et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022. \n[49] Zhou, S., Alon, U., Xu, F. F., Jiang, Z., and Neubig, G. Docprompting: Generating code by retrieving the docs. In The Eleventh International Conference on Learning Representations, 2022. ",
449
+ "page_idx": 10
450
+ },
451
+ {
452
+ "type": "text",
453
+ "text": "",
454
+ "page_idx": 11
455
+ },
456
+ {
457
+ "type": "text",
458
+ "text": "",
459
+ "page_idx": 12
460
+ },
461
+ {
462
+ "type": "text",
463
+ "text": "A Appendix ",
464
+ "text_level": 1,
465
+ "page_idx": 13
466
+ },
467
+ {
468
+ "type": "text",
469
+ "text": "A.1 Dataset Details ",
470
+ "text_level": 1,
471
+ "page_idx": 13
472
+ },
473
+ {
474
+ "type": "text",
475
+ "text": "Our dataset is multi-faceted, comprising three distinct domains: Torch Hub, Tensor Hub, and HuggingFace. Each entry within this dataset is rich in detail, carrying critical pieces of information that further illuminate the nature of the data. Delving deeper into the specifics of each domain, Torch Hub provides 95 APIs. The second domain, Tensor Hub, is more expansive with a total of 696 APIs. Finally, the most extensive of them all, HuggingFace, comprises 925 APIs. ",
476
+ "page_idx": 13
477
+ },
478
+ {
479
+ "type": "text",
480
+ "text": "To enhance the value and utility of our dataset, we’ve undertaken an additional initiative. With each API, we have generated a set of 10 unique instructions. These instructions, carefully crafted and meticulously tailored, serve as a guide for both training and evaluation. This initiative ensures that every API is not just represented in our dataset, but is also comprehensively understood and effectively utilizable. ",
481
+ "page_idx": 13
482
+ },
483
+ {
484
+ "type": "text",
485
+ "text": "In essence, our dataset is more than just a collection of APIs across three domains. It is a comprehensive resource, carefully structured and enriched with added layers of guidance and evaluation parameters. ",
486
+ "page_idx": 13
487
+ },
488
+ {
489
+ "type": "text",
490
+ "text": "Domain Classification The unique domain names encompassed within our dataset are illustrated in Fig. 7. The dataset consists of three sources with a diverse range of domains: Torch Hub houses 6 domains, Tensor Hub accommodates a much broader selection with 57 domains, while HuggingFace incorporates 37 domains. To exemplify the structure and nature of our dataset, we invite you to refer to the domain names represented in Fig. 8. ",
491
+ "page_idx": 13
492
+ },
493
+ {
494
+ "type": "text",
495
+ "text": "API Call Task In this task, we test the model’s capability to generate a single line of code, either in a zero-shot fashion or by leveraging an API reference. Primarily designed for evaluation purposes, this task effectively gauges the model’s proficiency in identifying and utilizing the appropriate API call. ",
496
+ "page_idx": 13
497
+ },
498
+ {
499
+ "type": "text",
500
+ "text": "API Provider Component This facet relates to the provision of the programming language. In this context, the API provider plays a vital role as it serves as a foundation upon which APIs are built and executed. ",
501
+ "page_idx": 13
502
+ },
503
+ {
504
+ "type": "text",
505
+ "text": "Explanation Element This component offers valuable insights into the rationale behind the usage of a particular API, detailing how it aligns with the prescribed requirements. Furthermore, when certain constraints are imposed, this segment also incorporates those limitations. Thus, the explanation element serves a dual purpose, offering a deep understanding of API selection, as well as the constraints that might influence such a selection. This balanced approach ensures a comprehensive understanding of the API usage within the given context. ",
506
+ "page_idx": 13
507
+ },
508
+ {
509
+ "type": "text",
510
+ "text": "Code Example code for accomplishing the task. We de-prioritize this as we haven’t tested the execution result of the code. We leave this for future works, but make this data available in-case others want to build on it. ",
511
+ "page_idx": 13
512
+ },
513
+ {
514
+ "type": "text",
515
+ "text": "A.2 Gorilla Details ",
516
+ "text_level": 1,
517
+ "page_idx": 13
518
+ },
519
+ {
520
+ "type": "text",
521
+ "text": "We provide all the training details for Gorilla in this section. This includes how we divide up the training, evaluation dataset, training hyperparameters for Gorilla. ",
522
+ "page_idx": 13
523
+ },
524
+ {
525
+ "type": "text",
526
+ "text": "Data For HuggingFace, we devise the entire dataset into $90 \\%$ training and $10 \\%$ evaluation. For Torch Hub and Tensor Hub, we devise the data in to $80 \\%$ training and $20 \\%$ testing. ",
527
+ "page_idx": 13
528
+ },
529
+ {
530
+ "type": "text",
531
+ "text": "Training We train Gorillafor 5 epochs with the 2e-5 learning rate with cosine decay. The details are provide in Table 6. We finetune it on 8xA100 with 40G memory each. ",
532
+ "page_idx": 13
533
+ },
534
+ {
535
+ "type": "text",
536
+ "text": "Torch Hub domain names: Classification, Semantic Segmentation, Object Detection, Audio Separation, Video Classification, Text-to-Speech ",
537
+ "page_idx": 14
538
+ },
539
+ {
540
+ "type": "text",
541
+ "text": "Tensor Hub domain names: text-sequence-alignment, text-embedding, text-languagemodel, text-preprocessing, text-classification, text-generation, text-question-answering, textretrieval-question-answering, text-segmentation, text-to-mel, image-classification, imagefeature-vector, image-object-detection, image-segmentation, image-generator, image-posedetection, image-rnn-agent, image-augmentation, image-classifier, image-style-transfer, image-aesthetic-quality, image-depth-estimation, image-super-resolution, image-deblurring, image-extrapolation, image-text-recognition, image-dehazing, image-deraining, imageenhancemenmt, image-classification-logits, image-frame-interpolation, image-text-detection, image-denoising, image-others, video-classification, video-feature-extraction, videogeneration, video-audio-text, video-text, audio-embedding, audio-event-classification, audiocommand-detection, audio-paralinguists-classification, audio-speech-to-text, audio-speechsynthesis, audio-synthesis, audio-pitch-extraction ",
542
+ "page_idx": 14
543
+ },
544
+ {
545
+ "type": "image",
546
+ "img_path": "images/0090f07f5c38c79ad372b07e2435e852c9451bf6be6dc4aebb59c4225e347d30.jpg",
547
+ "image_caption": [
548
+ "Figure 7: Domain names: Domain names with the three dataset. Tensor Hub is the smallest dataset while the other two hubs contain many more models. "
549
+ ],
550
+ "image_footnote": [],
551
+ "page_idx": 14
552
+ },
553
+ {
554
+ "type": "table",
555
+ "img_path": "images/bec9109391b31cef12070efa67b1ac79033d4e89f3878eec317016396bdf8fe8.jpg",
556
+ "table_caption": [
557
+ "Table 6: Hyperparameters for training Gorilla "
558
+ ],
559
+ "table_footnote": [],
560
+ "table_body": "<table><tr><td>Hyperparameter Name</td><td>Value</td></tr><tr><td>learning rate</td><td>2e-5</td></tr><tr><td>batch size</td><td>64</td></tr><tr><td>epochs</td><td>5</td></tr><tr><td>warmup ratio</td><td>0.03</td></tr><tr><td>weight decay</td><td>0</td></tr><tr><td>max seq length</td><td>2048</td></tr></table>",
561
+ "page_idx": 14
562
+ },
563
+ {
564
+ "type": "text",
565
+ "text": "A.3 Performance Comparison ",
566
+ "text_level": 1,
567
+ "page_idx": 14
568
+ },
569
+ {
570
+ "type": "text",
571
+ "text": "We provide a full comparison of each model’s performance in this section. In $\\mathrm { F i g ~ } 1 0$ and Fig. 11, the full set of comparisons is provided. We see that especially in zero-shot case, Gorilla surpasses the GPT-4 and GPT-3.5 by a large margin. The GPT-4 and GPT-3.5 gets around $40 \\%$ accuracy in Torch Hub and Tensor Hub, which are two structured API calls. Compared to that, HuggingFace is a more flexible and diverse Hub, as a result, the performance on HuggingFace is not as competitive. ",
572
+ "page_idx": 14
573
+ },
574
+ {
575
+ "type": "image",
576
+ "img_path": "images/c97a3eb528201081e90dcd029c6ca34ecc48cc98eeb8f8cfc452082748dded07.jpg",
577
+ "image_caption": [
578
+ "Figure 8: Example of the Dataset: Two examples of the dataset, the above one is zero-shot (without information retrievers) and the bottom one is with information retriever. "
579
+ ],
580
+ "image_footnote": [],
581
+ "page_idx": 15
582
+ },
583
+ {
584
+ "type": "image",
585
+ "img_path": "images/9f860259f746fbd80d51ea251b34cdaf9e7960e987261662c7f6dd413b7f525f.jpg",
586
+ "image_caption": [
587
+ "Figure 9: Hallucination Examples: GPT-4 incurs serious hallucination errors in HuggingFace. We show a couple of examples in the figure. "
588
+ ],
589
+ "image_footnote": [],
590
+ "page_idx": 16
591
+ },
592
+ {
593
+ "type": "text",
594
+ "text": "A.3.1 Evaluation ",
595
+ "text_level": 1,
596
+ "page_idx": 16
597
+ },
598
+ {
599
+ "type": "text",
600
+ "text": "For ease of evaluation, we manually cleaned up the dataset to ensure each API domain only contains the valid call of form: ",
601
+ "page_idx": 16
602
+ },
603
+ {
604
+ "type": "image",
605
+ "img_path": "images/1a58fcb711fec3bbec32f37f18169cda2a8adfd6e4bcba92a4eab97a74b79e1f.jpg",
606
+ "image_caption": [],
607
+ "image_footnote": [],
608
+ "page_idx": 16
609
+ },
610
+ {
611
+ "type": "text",
612
+ "text": "Our framework allows the user to define any combination of the arguments to check. For Torch Hub, we check for the API name torch.hub.load with arguments repo_or_dir and model. For Tensor Hub, we check API name hub.KerasLayer and hub.load with argument handle. For HuggingFace, since there are many API function names, we don’t list all of them here. One specific note is that we require the pretrained_model_name_or_path argument for all the calls except for pipeline. For pipeline, we don’t require the pretrained_model_name_or_path argument since it automatically select a model for you once task is specified. ",
613
+ "page_idx": 16
614
+ },
615
+ {
616
+ "type": "text",
617
+ "text": "A.3.2 Hallucination ",
618
+ "text_level": 1,
619
+ "page_idx": 16
620
+ },
621
+ {
622
+ "type": "text",
623
+ "text": "We found especially in HuggingFace, the GPT-4 model incurs serious hallucination problems. It would sometimes put a GitHub name that is not associated with the HuggingFace repository in to the domain of pretrained_model_name_or_path. Fig. 9 demonstrates some examples and we also observe that GPT-4 sometimes assumes the user have a local path to the model like your_model_name. This is greatly reduced by Gorilla as we see the hallucination error comparison in Table 1. ",
624
+ "page_idx": 16
625
+ },
626
+ {
627
+ "type": "text",
628
+ "text": "A.3.3 AST as a Hallucination Metric ",
629
+ "text_level": 1,
630
+ "page_idx": 16
631
+ },
632
+ {
633
+ "type": "text",
634
+ "text": "We evaluated the generated results on $1 0 0 \\mathrm { L L M }$ generations (randomly chosen from our eval set). The accuracy using AST subtree matching is $78 \\%$ , consistent with human evaluation with $78 \\%$ accuracy in calling the right API. All the generations that AST flagged as incorrect, were the same ones that were manually also flagged as incorrect. Additionally, Gorilla generates supporting code to call the API which includes installing dependencies (e.g., pip install transformers[sentencepiece]), environment variables, etc. When we manually attempted to execute end-to-end code, $72 \\%$ of all codes generated were executed successfully. It’s worth noting that the $6 \\%$ discrepancy were NOT semantic errors, but errors that arose due to factors external to the API in the supporting code - we have included an example to illustrate this further. Considering the significant time and effort required for manual validation of each generation, our evaluation highlights the efficiency of using AST as a robust offline metric. ",
635
+ "page_idx": 16
636
+ },
637
+ {
638
+ "type": "text",
639
+ "text": "Here is a representative example, where we are able to load the correct model API. However, in the supporting code, after we have the output from the API, the zip() function tries to combine sentiments and scores together. However, since scores is a float, it’s not iterable. zip() expects both its arguments to be iterable, resulting in an ‘float’ object is not iterable error. ",
640
+ "page_idx": 16
641
+ },
642
+ {
643
+ "type": "image",
644
+ "img_path": "images/9bdbc3a5b13361c0e35836ebeec465fb5e46498a4e42929217399c376e208829.jpg",
645
+ "image_caption": [
646
+ "Figure 10: Performance: We plot each model’s performance on different configurations. We see that Gorilla performs extremely well in the zero-shot setting. While even when the oracle answer is given, Gorilla is still the best. "
647
+ ],
648
+ "image_footnote": [],
649
+ "page_idx": 17
650
+ },
651
+ {
652
+ "type": "table",
653
+ "img_path": "images/84c572e1580399c48c8de320d0e4241bf95fa0e6ac1dbbdcf39e9f79da9b5c12.jpg",
654
+ "table_caption": [
655
+ "Table 7: Evaluating Gorilla (vs) DocPrompting Gorilla improves accuracy, while lowering the hallucination. "
656
+ ],
657
+ "table_footnote": [],
658
+ "table_body": "<table><tr><td colspan=\"3\">Accuracy ↑</td></tr><tr><td>DocPrompting</td><td>Gorilla</td><td>Hallucination ↓ DocPrompting Gorilla</td></tr><tr><td>61.72</td><td>71.68</td><td>17.36 10.95</td></tr></table>",
659
+ "page_idx": 17
660
+ },
661
+ {
662
+ "type": "text",
663
+ "text": "A.3.4 Gorilla (VS) DocPrompting ",
664
+ "text_level": 1,
665
+ "page_idx": 17
666
+ },
667
+ {
668
+ "type": "text",
669
+ "text": "We evaluate Gorilla and DocPrompting [49] on the HuggingFace Dataset from Table 1. For a 7B model, when trained on the same number of epochs, with and the same learning rate for both the models, Gorilla improves accuracy while reducing hallucination. ",
670
+ "page_idx": 17
671
+ },
672
+ {
673
+ "type": "text",
674
+ "text": "A.3.5 Sensitivity to pre-training ",
675
+ "text_level": 1,
676
+ "page_idx": 17
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "Gorilla’s training recipe is robust to the pre-training strategies and recipes of the underlying model. From Fig. 13 we demonstrate that all the three models can converge to within a few percentage points in accuracy independent of the pre-trained base model. ",
681
+ "page_idx": 17
682
+ },
683
+ {
684
+ "type": "image",
685
+ "img_path": "images/57a1a938061357ef7a79161d505f896c8ff49e55f8091344d71e340c18fc7a08.jpg",
686
+ "image_caption": [
687
+ "Figure 11: Accuracy vs Hallucination: We plot each model’s performance on different configurations. We found that in the zero-shot setting, Gorilla has the most accuracy gain while maintaining good factual capability. When prompting with different retrievers, Gorilla is still capable to avoid the hallucination errors. "
688
+ ],
689
+ "image_footnote": [],
690
+ "page_idx": 18
691
+ },
692
+ {
693
+ "type": "image",
694
+ "img_path": "images/b6336ccc559a6e38ac93484fbe278a578e7498de3e1195e0941e30707bb4da12.jpg",
695
+ "image_caption": [
696
+ "Figure 12: The API call by Gorilla model are accurate and bug-free, but the supporting $\\tt z i p ( )$ code has a bug. "
697
+ ],
698
+ "image_footnote": [],
699
+ "page_idx": 18
700
+ },
701
+ {
702
+ "type": "image",
703
+ "img_path": "images/518b79d731d0efff423245dc1dcaa276e7dd04a4ccbd0110f8a42d8a5a3d3d51.jpg",
704
+ "image_caption": [
705
+ "Figure 13: For the same train-eval dataset, our fine-tuning recipe, RAT, is robust to the underlying base model. "
706
+ ],
707
+ "image_footnote": [],
708
+ "page_idx": 19
709
+ },
710
+ {
711
+ "type": "text",
712
+ "text": "NeurIPS Paper Checklist ",
713
+ "text_level": 1,
714
+ "page_idx": 20
715
+ },
716
+ {
717
+ "type": "text",
718
+ "text": "1. Claims ",
719
+ "text_level": 1,
720
+ "page_idx": 20
721
+ },
722
+ {
723
+ "type": "text",
724
+ "text": "Question: Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? ",
725
+ "page_idx": 20
726
+ },
727
+ {
728
+ "type": "text",
729
+ "text": "Answer: [Yes] ",
730
+ "page_idx": 20
731
+ },
732
+ {
733
+ "type": "text",
734
+ "text": "Justification: The paper provides a recipe to teach LLMs to use tools, and also presents a data-set for evaluating API calling, and a metric for measuring hallucination. The paper studies them with rigorous evaluations. ",
735
+ "page_idx": 20
736
+ },
737
+ {
738
+ "type": "text",
739
+ "text": "2. Limitations ",
740
+ "text_level": 1,
741
+ "page_idx": 20
742
+ },
743
+ {
744
+ "type": "text",
745
+ "text": "Question: Does the paper discuss the limitations of the work performed by the authors? ",
746
+ "page_idx": 20
747
+ },
748
+ {
749
+ "type": "text",
750
+ "text": "Answer: [Yes] ",
751
+ "page_idx": 20
752
+ },
753
+ {
754
+ "type": "text",
755
+ "text": "3. Theory Assumptions and Proofs ",
756
+ "text_level": 1,
757
+ "page_idx": 20
758
+ },
759
+ {
760
+ "type": "text",
761
+ "text": "Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof? ",
762
+ "page_idx": 20
763
+ },
764
+ {
765
+ "type": "text",
766
+ "text": "Answer: [NA] ",
767
+ "page_idx": 20
768
+ },
769
+ {
770
+ "type": "text",
771
+ "text": "4. Experimental Result Reproducibility ",
772
+ "text_level": 1,
773
+ "page_idx": 20
774
+ },
775
+ {
776
+ "type": "text",
777
+ "text": "Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)? ",
778
+ "page_idx": 20
779
+ },
780
+ {
781
+ "type": "text",
782
+ "text": "Answer: [Yes] ",
783
+ "page_idx": 20
784
+ },
785
+ {
786
+ "type": "text",
787
+ "text": "Justification: All the hyperparameters are specified in the appendix, and the code and dataset is open-sourced at github.com/ShishirPatil/gorilla. ",
788
+ "page_idx": 20
789
+ },
790
+ {
791
+ "type": "text",
792
+ "text": "5. Open access to data and code ",
793
+ "text_level": 1,
794
+ "page_idx": 20
795
+ },
796
+ {
797
+ "type": "text",
798
+ "text": "Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material? ",
799
+ "page_idx": 20
800
+ },
801
+ {
802
+ "type": "text",
803
+ "text": "Answer: [Yes] ",
804
+ "page_idx": 20
805
+ },
806
+ {
807
+ "type": "text",
808
+ "text": "Justification: All code, data, and models are open-sourced under the Apache 2.0 license by the authors. ",
809
+ "page_idx": 20
810
+ },
811
+ {
812
+ "type": "text",
813
+ "text": "6. Experimental Setting/Details ",
814
+ "text_level": 1,
815
+ "page_idx": 20
816
+ },
817
+ {
818
+ "type": "text",
819
+ "text": "Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results? ",
820
+ "page_idx": 20
821
+ },
822
+ {
823
+ "type": "text",
824
+ "text": "Answer: [Yes] ",
825
+ "page_idx": 20
826
+ },
827
+ {
828
+ "type": "text",
829
+ "text": "Justification: All the hyperparameters are specified in the appendix, and all code, data, and models are open-sourced. ",
830
+ "page_idx": 20
831
+ },
832
+ {
833
+ "type": "text",
834
+ "text": "7. Experiment Statistical Significance ",
835
+ "text_level": 1,
836
+ "page_idx": 20
837
+ },
838
+ {
839
+ "type": "text",
840
+ "text": "Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments? ",
841
+ "page_idx": 20
842
+ },
843
+ {
844
+ "type": "text",
845
+ "text": "Answer: [NA] ",
846
+ "page_idx": 20
847
+ },
848
+ {
849
+ "type": "text",
850
+ "text": "Justification: All non-LLM experiments are deterministic so need no error bars, and given the GPU costs involved, we perform LLM experiments once. ",
851
+ "page_idx": 20
852
+ },
853
+ {
854
+ "type": "text",
855
+ "text": "8. Experiments Compute Resources ",
856
+ "text_level": 1,
857
+ "page_idx": 20
858
+ },
859
+ {
860
+ "type": "text",
861
+ "text": "Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments? ",
862
+ "page_idx": 20
863
+ },
864
+ {
865
+ "type": "text",
866
+ "text": "Answer: [Yes] ",
867
+ "page_idx": 20
868
+ },
869
+ {
870
+ "type": "text",
871
+ "text": "Justification: Provided in Appendix including the sample dataset. ",
872
+ "page_idx": 20
873
+ },
874
+ {
875
+ "type": "text",
876
+ "text": "9. Code Of Ethics ",
877
+ "text_level": 1,
878
+ "page_idx": 21
879
+ },
880
+ {
881
+ "type": "text",
882
+ "text": "Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines? ",
883
+ "page_idx": 21
884
+ },
885
+ {
886
+ "type": "text",
887
+ "text": "Answer: [Yes] ",
888
+ "page_idx": 21
889
+ },
890
+ {
891
+ "type": "text",
892
+ "text": "Justification: Conform’s with NeurIPS Code of Ethics ",
893
+ "page_idx": 21
894
+ },
895
+ {
896
+ "type": "text",
897
+ "text": "10. Broader Impacts ",
898
+ "text_level": 1,
899
+ "page_idx": 21
900
+ },
901
+ {
902
+ "type": "text",
903
+ "text": "Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed? ",
904
+ "page_idx": 21
905
+ },
906
+ {
907
+ "type": "text",
908
+ "text": "Answer: [Yes] ",
909
+ "page_idx": 21
910
+ },
911
+ {
912
+ "type": "text",
913
+ "text": "Justification: Integrating language models with API calls significantly extends their utility, enabling a wide range of applications from automating customer service to generating realtime content and facilitating data analysis. This integration can lead to more personalized and efficient user experiences across various platforms, as language models can process natural language inputs and interact with different APIs to fetch, interpret, and act on data in real time. For instance, in customer service, this can mean providing instant, relevant responses to queries, reducing wait times, and improving overall satisfaction. In content generation, it can enable dynamic creation of articles, reports, or summaries based on the latest data available from web services. ",
914
+ "page_idx": 21
915
+ },
916
+ {
917
+ "type": "text",
918
+ "text": "11. Safeguards ",
919
+ "text_level": 1,
920
+ "page_idx": 21
921
+ },
922
+ {
923
+ "type": "text",
924
+ "text": "Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)? ",
925
+ "page_idx": 21
926
+ },
927
+ {
928
+ "type": "text",
929
+ "text": "Answer: [NA] ",
930
+ "page_idx": 21
931
+ },
932
+ {
933
+ "type": "text",
934
+ "text": "Justification: Unlike Images, etc where there are copyrights involved, APIs are meant to distributed. Hence, the incentives are very well aligned. For example, if Gorilla presents a particular service’s API, the service benefits from engagement. ",
935
+ "page_idx": 21
936
+ },
937
+ {
938
+ "type": "text",
939
+ "text": "12. Licenses for existing assets ",
940
+ "text_level": 1,
941
+ "page_idx": 21
942
+ },
943
+ {
944
+ "type": "text",
945
+ "text": "Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected? ",
946
+ "page_idx": 21
947
+ },
948
+ {
949
+ "type": "text",
950
+ "text": "Answer: [Yes] ",
951
+ "page_idx": 21
952
+ },
953
+ {
954
+ "type": "text",
955
+ "text": "Justification: All code, data, and models are open-sourced under the Apache 2.0 license by the authors. ",
956
+ "page_idx": 21
957
+ },
958
+ {
959
+ "type": "text",
960
+ "text": "13. New Assets ",
961
+ "text_level": 1,
962
+ "page_idx": 21
963
+ },
964
+ {
965
+ "type": "text",
966
+ "text": "Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets? ",
967
+ "page_idx": 21
968
+ },
969
+ {
970
+ "type": "text",
971
+ "text": "Answer: [Yes] ",
972
+ "page_idx": 21
973
+ },
974
+ {
975
+ "type": "text",
976
+ "text": "Justification: The open-source repository is actively maintained at github.com/ShishirPatil/gorilla ",
977
+ "page_idx": 21
978
+ },
979
+ {
980
+ "type": "text",
981
+ "text": "14. Crowdsourcing and Research with Human Subjects ",
982
+ "text_level": 1,
983
+ "page_idx": 21
984
+ },
985
+ {
986
+ "type": "text",
987
+ "text": "Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)? ",
988
+ "page_idx": 21
989
+ },
990
+ {
991
+ "type": "text",
992
+ "text": "Answer: [NA] ",
993
+ "page_idx": 21
994
+ },
995
+ {
996
+ "type": "text",
997
+ "text": "15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects ",
998
+ "text_level": 1,
999
+ "page_idx": 21
1000
+ },
1001
+ {
1002
+ "type": "text",
1003
+ "text": "Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained? ",
1004
+ "page_idx": 21
1005
+ },
1006
+ {
1007
+ "type": "text",
1008
+ "text": "Answer: [NA] ",
1009
+ "page_idx": 21
1010
+ }
1011
+ ]
parse/test/tBRNC6YemY/tBRNC6YemY_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tBRNC6YemY/tBRNC6YemY_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tr0KidwPLc/tr0KidwPLc.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tr0KidwPLc/tr0KidwPLc_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tr0KidwPLc/tr0KidwPLc_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/tr0KidwPLc/tr0KidwPLc_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/uREj4ZuGJE/uREj4ZuGJE.md ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IN-CONTEXT AUTOENCODER FOR CONTEXTCOMPRESSION IN A LARGE LANGUAGE MODEL
2
+
3
+ Tao $\mathbf { G e ^ { * } }$ Jing $\mathbf { H } \mathbf { u } ^ { \dag }$ Lei Wang† Xun Wang Si-Qing Chen Furu Wei Microsoft Corporation {tage,v-hjing,v-leiwang7,xunwang,sqchen,fuwei}@microsoft.com
4
+
5
+ # ABSTRACT
6
+
7
+ We propose the In-context Autoencoder (ICAE), leveraging the power of a large language model (LLM) to compress a long context into short compact memory slots that can be directly conditioned on by the LLM for various purposes. ICAE is first pretrained using both autoencoding and language modeling objectives on massive text data, enabling it to generate memory slots that accurately and comprehensively represent the original context. Then, it is fine-tuned on instruction data for producing desirable responses to various prompts. Experiments demonstrate that our lightweight ICAE, introducing about $1 \%$ additional parameters, effectively achieves $4 \times$ context compression based on Llama, offering advantages in both improved latency and GPU memory cost during inference, and showing an interesting insight in memorization as well as potential for scalability. These promising results imply a novel perspective on the connection between working memory in cognitive science and representation learning in LLMs, revealing ICAE’s significant implications in addressing the long context problem and suggesting further research in LLM context management. Our data, code and models are available at https://github.com/getao/icae.
8
+
9
+ ![](images/42572e3419c7133527e5908e4e852be7751ddca6609df0099fa1422ae0fdbfd5.jpg)
10
+ Figure 1: Compressing a long context into a short span of memory slots. The memory slots can be conditioned on by the target LLM on behalf of the original context to respond to various prompts.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ Long context modeling is a fundamental challenge for Transformer-based (Vaswani et al., 2017) LLMs due to their inherent self-attention mechanism. Much previous research (Child et al., 2019; Beltagy et al., 2020; Rae et al., 2019; Choromanski et al., 2020; Bulatov et al., 2022; Zheng et al., 2022; Wu et al., 2022; Bulatov et al., 2023; Ding et al., 2023) attempts to tackle the long context issue through architectural innovations of an LLM. While they approach long context with a significant reduction in computation and memory complexity, they often struggle to overcome the notable decline in performance on long contexts, as highlighted by Liu et al. (2023). In contrast to these efforts, we approach the long context problem from a novel angle – context compression.
15
+
16
+ ![](images/732bd72050776b6ca34a7a1240014ff01391c76c5c03751b59ed2952ff08fa3c.jpg)
17
+ Figure 2: Various context lengths (e.g., 2572 chars, 512 words, 128 memory slots) serve the same function when conditioned on by an LLM for responding to the given prompt.
18
+
19
+ Context compression is motivated by the fact that a text can be represented in different lengths in an LLM while conveying the same information. As shown in Figure 2, if we use characters to represent the text, it will have a length of 2,572; if we represent it using (sub-)words, we only need a context length of 512 without affecting the response accuracy. So, is there a more compact representation allowing us to achieve the same goal with a shorter context?
20
+
21
+ We explore this problem and propose the ICAE which leverages the power of an LLM to achieve high compression of contexts. The ICAE consists of 2 modules: a learnable encoder adapted from the LLM with LoRA (Hu et al., 2021) for encoding a long context into a small number of memory slots, and a fixed decoder, which is the LLM itself where the memory slots representing the original context are conditioned on to interact with prompts to accomplish various goals, as illustrated in Figure 1.
22
+
23
+ We first pretrain the ICAE using both autoencoding (AE) and language modeling (LM) objectives so that it can learn to generate memory slots from which the decoder (i.e., the LLM) can recover the original context or perform continuation. The pretraining with massive text data enables the ICAE to be well generalized, allowing the resulting memory slots to represent the original context more accurately and comprehensively. Then, we fine-tune the pretrained ICAE on instruction data for practical scenarios by enhancing its generated memory slots’ interaction with various prompts. We show the ICAE (based on Llama) learned with our pretraining and fine-tuning method can effectively produce memory slots with $4 \times$ context compression. We highlight our contributions as follows:
24
+
25
+ • We propose In-context Autoencoder (ICAE) – a novel approach to context compression by leveraging the power of an LLM. The ICAE either enables an LLM to express more information with the same context length or allows it to represent the same content with a shorter context, thereby enhancing the model’s ability to handle long contexts with improved latency and memory cost during inference. Its promising results and its scalability may suggest further research efforts in context management for an LLM, which is orthogonal to other long context modeling studies and can be combined with them to further improve the handling of long contexts in an LLM. • In addition to context compression, ICAE provides an access to probe how an LLM performs memorization. We observe that extensive self-supervised learning (e.g., autoencoding) in the pretraining phase is very helpful to enhance the ICAE’s capability to encode the original context into compressed memory slots. This pretraining process may share some analogies with humans enhancing their memory capacity through extensive memory training, which improves the brain’s memory encoding capabilities (Ericsson et al., 1980; Engle et al., 1999; Maguire et al., 2003). We also show that an LLM’s memorization pattern is highly similar to humans (see Table 2 and Table 3). All these results imply a novel perspective on the connection between working memory in cognitive science (Baddeley, 1992) and representation learning in LLMs (i.e., context window).
26
+
27
+ # 2 IN-CONTEXT AUTOENCODER
28
+
29
+ # 2.1 MODEL ARCHITECTURE
30
+
31
+ Like a typical autoencoder (Kramer, 1991), ICAE consists of an encoder and a decoder. Similar to the design of Gisting (Mu et al., 2023) and AutoCompressor (Chevalier et al., 2023), the ICAE performs both the encoding and decoding processes in an in-context manner, as illustrated in Figure 3.
32
+
33
+ ![](images/f2c77b7cf4f4febfa062846630c6f63c9f99c3e45313e3a29d288afe6888beca.jpg)
34
+ Figure 3: The encoder of the ICAE is a LoRA-adapted LLM, which is used for encoding the original context $\pmb { c } = ( w _ { 1 } , w _ { 2 } , \dots , w _ { L } )$ into a few memory slots $( \widetilde { m _ { 1 } } , \dots , \widetilde { m _ { k } } )$ . The decoder of the ICAE is f fthe target LLM itself that can condition on the memory slots produced by the encoder for various purposes (e.g., the autoencoding task as in this figure). $e ( \cdot )$ denotes the word embedding lookup in the target LLM and $e _ { m } ( \cdot )$ denotes the learnable embedding lookup of memory tokens that are used for producing memory slots.“[AE]” is a special token to indicate the autoencoding pretraining task.
35
+
36
+ Given the intuition, we propose to use a LoRA-adapted LLM as the encoder of the ICAE, as illustrated in Figure 3. When encoding a context $\pmb { c } = ( w _ { 1 } , \dots , w _ { L } )$ with the length $L$ , we first append $k$ $k \left( k < < L \right)$ ) memory tokens $( m _ { 1 } , \ldots , m _ { k } )$ to the context $^ c$ to obtain their outputs $( \widetilde { m _ { 1 } } , \dots , \widetilde { m _ { k } } )$ as the memory slots for the context $^ c$ f f. Therefore, the ICAE encoder is very lightweight – it only adds a LoRA adapter and an embedding lookup for memory tokens compared with the target LLM.
37
+
38
+ As introduced above, we expect the memory slots $( \widetilde { m _ { 1 } } , \dots , \widetilde { m _ { k } } )$ to be conditioned on by the target LLM on behalf of the original context $^ c$ f f. Therefore, we use the untouched target LLM as the decoder of the ICAE to ensure the compatibility of memory slots within the target LLM.
39
+
40
+ # 2.2 PRETRAINING
41
+
42
+ # 2.2.1 AUTOENCODING
43
+
44
+ Like a typical autoencoder, one of the ICAE’s pretraining objectives is to restore the original input text $^ c$ of the length $L$ from its produced memory slots $( \widetilde { m _ { 1 } } , \dots , \widetilde { m _ { k } } )$ of the length $k$ :
45
+
46
+ $$
47
+ \mathcal { L } _ { \mathrm { A E } } = \operatorname* { m a x } _ { \widetilde { m _ { 1 } } , \ldots , \widetilde { m _ { k } } } P ( c | \widetilde { m _ { 1 } } , \ldots , \widetilde { m _ { k } } ; \Theta _ { L L M } ) = \operatorname* { m a x } _ { \Theta _ { L o R A } , e _ { m } } P ( c | m _ { 1 } \ldots m _ { k } ; \Theta _ { L L M } , \Theta _ { L o R A } , e _ { m } )
48
+ $$
49
+
50
+ To indicate the autoencoding task, we append a special token “[AE]” to $( \widetilde { m _ { 1 } } , \dots , \widetilde { m _ { k } } )$ in the decoder, f fas Figure 3 shows. As this pretraining objective does not need any extra annotation, we can use massive text data to train the In-context Autoencoder.
51
+
52
+ # 2.2.2 TEXT CONTINUATION
53
+
54
+ While autoencoding pretraining offers a straightforward learning objective to encode a context, its inherent simplicity and exclusive focus on the single objective may lead to suboptimal generalization. To address this issue, we incorporate an additional objective during the pretraining phase: text continuation, as illustrated in Figure 7 in Appendix A. This self-supervised task is widely acknowledged to facilitate the learning of more generalizable representations in language models:
55
+
56
+ $$
57
+ \mathcal { L } _ { \mathrm { L M } } = \operatorname* { m a x } _ { \widetilde { m _ { 1 } } , \ldots , \widetilde { m _ { k } } } P ( \varrho | \widetilde { m _ { 1 } } , \ldots , \widetilde { m _ { k } } ; \Theta _ { L L M } ) = \operatorname* { m a x } _ { \Theta _ { L o R A } , e _ { m } } P ( o | m _ { 1 } \ldots m _ { k } ; \Theta _ { L L M } , \Theta _ { L o R A } , e _ { m } )
58
+ $$
59
+
60
+ where $\pmb { o } = ( w _ { L + 1 } , \dots , w _ { L + N } )$ denotes the continuation of context c. This objective helps improve generalization and circumvent excessive reliance on, and overfitting to, the autoencoding task.
61
+
62
+ # 2.3 INSTRUCTION FINE-TUNING
63
+
64
+ After pretraining, the memory slots produced by the pretrained ICAE are expected to represent the original context. However, for LLMs, the purpose of providing a context extends beyond rote memorization or continuation; instead, the more common use scenario is using the provided context as a basis for accurately and appropriately responding to various prompts, ultimately accomplishing the tasks we want it to perform (Wei et al., 2021; Ouyang et al., 2022).
65
+
66
+ To enhance the interaction of memory slots produced by the ICAE with diverse prompts, we further fine-tune the ICAE with the PWC dataset (Prompt-with-Context), a dataset1 introduced in this paper consisting of thousands of (context, prompt, response) samples (as shown in Figure 1).
67
+
68
+ Formally, the ICAE is fine-tuned for learning to encode the context into the memory slots based on which the decoder (i.e., the target LLM) can produce a desirable response $r _ { 1 } \ldots r _ { n }$ according to a given prompt $p _ { 1 } \ldots p _ { m }$ , as shown in Figure 8 in Appendix A:
69
+
70
+ $$
71
+ \begin{array} { l } { \mathcal { L } _ { \mathrm { F T } } = \underset { \widetilde { m _ { 1 } } \ldots \widetilde { m _ { k } } } { \operatorname* { m a x } } P ( r _ { 1 } \ldots r _ { n } | \widetilde { m _ { 1 } } \ldots \widetilde { m _ { k } } , p _ { 1 } \ldots p _ { m } ; \Theta _ { L L M } ) } \\ { \quad \quad = \underset { \Theta _ { L o R A } , e _ { m } } { \operatorname* { m a x } } P ( r _ { 1 } \ldots r _ { n } | m _ { 1 } \ldots m _ { k } , p _ { 1 } \ldots p _ { m } ; \Theta _ { L L M } , \Theta _ { L o R A } , e _ { m } ) } \end{array}
72
+ $$
73
+
74
+ # 3 EXPERIMENTS
75
+
76
+ # 3.1 EXPERIMENTAL SETTING
77
+
78
+ Data We pretrain the ICAE with the Pile (Gao et al., 2020). For instruction fine-tuning, we use the PWC dataset, as introduced in Section 2.3, which contains 240k (context, prompt, response) samples for training and 18k samples for testing. The context length distribution of test samples is shown in Figure 10. By default, the maximal token length (excluding memory slots) we set during training is 512 in both the ICAE’s encoder and decoder in our experiments.
79
+
80
+ Model Configuration We use the LlaMa (Touvron et al., 2023a;b) as the target LLM to test the ICAE’s performance in context compression. For the encoder of the ICAE, LoRA is applied to the query and value projections of the LLM’s multi-head attention. In our default setting, the memory slot length $k$ is set to 128, and the LoRA rank $r$ is set to 128 unless otherwise specified. The resulting ICAE only adds about $1 \%$ learnable parameters on top of the target LLM.
81
+
82
+ # 3.2 RESULTS
83
+
84
+ # 3.2.1 PRETRAINED ICAE
85
+
86
+ We first evaluate the autoencoding performance of the pretrained ICAE (without instruction finetuning) using the following three metrics to understand how well it restores the original context from its produced memory slots: BLEU (Papineni et al., 2002), Exact-Match $( \mathrm { E M } ) ^ { 2 }$ and cross entropy loss.
87
+
88
+ Figure 4 presents the autoencoding results of the ICAE based on the Llama-7b. The ICAE demonstrates a very low overall loss, below 0.05, indicating that the produced memory slots retain almost all the information of the original context. When the context length is within 300, the ICAE can almost perfectly reconstruct the original context, achieving nearly $100 \%$ BLEU and EM scores. As the context length increases beyond 400, both BLEU and EM scores start to decline, indicating insufficient capacity of the 128-length memory slots. However, even at a context length of 500, the median BLEU remains over 0.98, and the median EM approaches 0.6 (e.g., perfectly reconstructing about the first 300 words of a 512-token context), showing remarkable performance of ICAE.
89
+
90
+ We then analyze the effect of the memory size $k$ on the result. According to Figure 5, as the memory slot length $k$ decreases, the ICAE’s ability to memorize longer samples significantly deteriorates.
91
+
92
+ ![](images/9bd009d4f2b3ac3305f5d375e134ba0708fa071a2ad161f191abe011e18e3472.jpg)
93
+ Figure 4: Autoencoding results of the ICAE based on the Llama-7b with memory length $k = 1 2 8$ . The horizontal axis represents the original context length of test examples. For example, the horizontal axis value of 100 refers to the test examples with context lengths ranging from 95 to 105.
94
+
95
+ ![](images/0e27d1a4215a85756577600cd7265a4c07b040b5b8f00ddc954007f3062c7f5b.jpg)
96
+ Figure 5: BLEU and loss at different memory slot lengths $k$
97
+
98
+ Compared to $k = 1 2 8$ where the BLEU score can still reach over $9 5 \%$ at a context length of 500, the BLEU scores become much less satisfactory for $k$ values of 64 and 32, indicating an inability to losslessly retain the original context. This observation is also evident from the loss curve, suggesting that achieving over $4 \times$ compression is rather challenging.
99
+
100
+ Table 1: Text continuation evaluation for the pretrained ICAE. Similar to the autoencoding evaluation, a higher compression ratio tends to result in more pronounced losses in language modeling.
101
+
102
+ <table><tr><td rowspan="2">Context length</td><td colspan="2">PPL(</td><td rowspan="2">△</td></tr><tr><td></td><td></td></tr><tr><td>128→128(1×)</td><td>9.99</td><td>10.15</td><td>+0.16</td></tr><tr><td>256-→128(2x)</td><td>9.45</td><td>9.77</td><td>+0.32</td></tr><tr><td>512-→128 (4×)</td><td>9.01</td><td>9.50</td><td>+0.49</td></tr></table>
103
+
104
+ Similarly, the text continuation evaluation presented in Table 1 also illustrates that a higher compression ratio tends to result in more pronounced losses in language modeling.
105
+
106
+ Table 2 presents 1 specific example of the ICAE performing text restoration, demonstrating an interesting behavior: “large pretrained language model” is restored as “large pretrained model” and “The results prove” is restored as “The experimental evidence proves”. These restoration errors resemble mistakes humans would make when memorizing the same text. This suggests that, like humans, the model selectively emphasizes or neglects certain parts of the information during the memorization based on its own understanding. It is also consistent with Peng et al. (2023): the stronger the LLM, the fewer it needs to memorize, and thus the smaller the memorization effort. This is similar to human learning: knowledgeable individuals tend to learn more effortlessly, while those with limited knowledge often rely on rote memorization to acquire new information.
107
+
108
+ To further look into the memorization insight, we test restoration performance for different types of 512-token texts with 128 memory slots produced by ICAE to investigate whether its memorization capability is consistent across different content types. According to Table 3, in contrast to compressing normal texts which can be well restored, compressing and restoring less common texts (i.e., random texts) becomes very challenging, reflected by much worse loss and BLEU scores. All these results strongly support our intuition that an LLM’s memorization pattern is highly similar to humans.
109
+
110
+ Table 2: 1 example showing how the pretrained ICAE $k = 1 2 8 ,$ ) restores the original context.
111
+
112
+ <table><tr><td>Origin Context Large pretrained language models have shown surprising In-</td><td>Restoration Large pretrained models have shown surprising In-Context</td></tr><tr><td>Context Learning (ICL) ability. With a few demonstration input-label pairs,they can predict the label for an unseen in- put without additional parameter updates.Despite the great success in performance,the working mechanism of ICL still remains an open problem.In order to better understand how ICL works,this paper explains language models as meta- optimizers and understands ICL as a kind of implicit finetun- ing.Theoretically,we figure out that the Transformer attention has a dual form of gradient descent based optimization. On top of it, we understand ICL as follows:GPT first produces metagradients according to the demonstration examples,and then these meta-gradients are applied to the original GPT to build an ICL model. Experimentally,we comprehensively compare the behavior of ICL and explicit finetuning based on real tasks to provide empirical evidence that supports our understanding. The results prove that ICL behaves similarly to explicit finetuning at the prediction level, the representation level,and the attention behavior level. Further, inspired by our understanding of meta-optimization, we design a momentum- based attention by analogy with the momentum-based gradient descent algorithm. Its consistently better performance over vanilla attntion supports our understanding again from an- other aspect, and more importantly, it shows the potential to</td><td>Learning (ICL) ability.With a few demonstration input-label pairs,they can predict the label for an unseen input without additional parameter updates.Despite the great success in per- formance,the working mechanism of ICL still remains an open problem.In order to better understand how ICL works,this paper explains how language models as meta-optimizers and understands ICL as a kind of implicit finetuning. Theoretically, we figure out that the Transformer attention has a dual form of gradient descent based on optimization. On top of it, we understand ICL as follows: GPT first produces metagradients according to the demonstration examples,and then these meta- gradients are applied to the original GPT to build an ICL model. Experimentally,we comprehensively compare the behavior of ICL and explicit finetuning based on real tasks to provide em- pirical evidence that supports our findings. The experimental evidence proves that ICL behaves like us to the same extent. Prediction at the explicit finetuning level, the representation level,and the attention behavior level.Further, inspired by our understanding of meta-optimization,we design a momentum- based attention by analogy with the gradient descent-based momentum gradient algorithm. Its consistently better perfor- mance against vanilla atention supports us again from another aspect,and more importantly, it shows the potential to use our</td></tr></table>
113
+
114
+ Table 3: Restoration performance for different types of 512-token content with 128 memory slots. Patterned random text is obtained by adding 1 to each token_id in a normal text.
115
+
116
+ <table><tr><td>Content type</td><td>Loss</td><td>BLEU</td></tr><tr><td>Normal text</td><td>0.01</td><td>99.3</td></tr><tr><td>Patterned random text</td><td>1.63</td><td>3.5</td></tr><tr><td>Completely random text</td><td>4.55</td><td>0.2</td></tr></table>
117
+
118
+ Based on this intuition, it is very likely that a more powerful LLM may support a higher compression ratio without significant forgetting. We will discuss it in Section 3.3.1.
119
+
120
+ # 3.2.2 FINE-TUNED ICAE
121
+
122
+ In order to evaluate the fine-tuned ICAE’s performance, we evaluate on the PWC test set. We use the GPT-4 to compare the outputs of the two systems to determine which one performs better or if they are on par with each other, following Mu et al. (2023). Table 4 shows the comparison of results of the LLMs conditioned on memory slots and original contexts. For Llama-7b (fine-tuned ICAE), we compare with Alpaca and StableLM-tuned-alpha-7b since there is no official instruction-tuned Llama-1 model. The Llama-7b (ICAE) conditioned on 128 memory slots largely outperforms both Alpaca and StableLM which can access original contexts ( ${ \sim } 5 1 2$ tokens), with a win rate of $5 6 . 7 \%$ and $7 4 . 1 \%$ respectively and a win+tie rate of $7 3 \% { \sim } 8 1 \%$ . However, when compared to the GPT-4 (we regard it as the gold standard), there is still a significant gap, with around $70 \%$ of the cases underperforming the GPT-4’s results, and a win+tie ratio of about only $30 \%$ .
123
+
124
+ When we switch the base model to Llama-2-chat, we observe ICAE’s performance becomes much better than its counterpart based on Llama-1: when $k = 1 2 8$ , its win+tie rate can reach around $7 5 \%$ againt the GPT-4 although it still lags behind its counterpart conditioning on the original context as the compression is lossy. As $k$ increases, the win+tie rate further improves while the compression rate decreases. We perform the same comparative studies on Llama-2-13b-chat and observe better results of ICAE, supporting our assumption in Section 3.2.1 that the ICAE can benefit more on larger LLMs.
125
+
126
+ We investigate the impact of memory length on results. Table 5 shows pairwise comparisons between ICAE models with varying memory slot lengths. A higher compression ratio makes it harder to ensure response quality, but a larger ratio doesn’t always lead to worse performance. Table 5 highlights that a pretrained ICAE with $8 \times$ compression $\scriptstyle ( k = 6 4 )$ can match a non-pretrained ICAE with $4 \times$ compression $k { = } 1 2 8$ ). Under the same ratio, the pretrained ICAE performs much better than its non-pretrained counterpart, emphasizing the importance of pretraining. By comparing the outputs generated via the pretrained and non-pretrained ICAE, we find the pretrained ICAE suffers less from hallucination than the non-pretrained counterpart (see the examples in Table 9 in Appendix D). We assume the pretraining of ICAE improves the LLM’s working memory as it shares some analogies with humans enhancing their memory capacity via extensive memory training which improves the brain’s memory encoding capabilities. We also examine pretraining objectives and find combining3 AE and LM yields better results than using AE or LM individually (the 4th row in Table 5).
127
+
128
+ Table 4: Memory slots VS Original contexts $( \sim 5 1 2$ tokens) on the PWC test set
129
+
130
+ <table><tr><td rowspan="2">System 1 (k memory slots)</td><td rowspan="2">System 2 (original context)</td><td colspan="4"> Judgement (%)</td></tr><tr><td>win</td><td>lose</td><td>tie</td><td>on par (win+tie)</td></tr><tr><td rowspan="3">Llama-7b (ICAE, k=128)</td><td>Alpaca</td><td>56.7</td><td>26.9</td><td>16.4</td><td>73.1</td></tr><tr><td>StableLM-7b</td><td>74.1</td><td>18.8</td><td>7.2</td><td>81.3</td></tr><tr><td>GPT-4 (gold)</td><td>3.4</td><td>69.4</td><td>27.2</td><td>30.6</td></tr><tr><td rowspan="2">Llama-2-7b-chat (ICAE, k=64)</td><td>Llama-2-7b-chat</td><td>13.6</td><td>51.6</td><td>34.8</td><td>48.4</td></tr><tr><td>GPT-4 (gold)</td><td>1.9</td><td>44.7</td><td>53.4</td><td>55.3</td></tr><tr><td rowspan="2">Llama-2-7b-chat (ICAE, k=128)</td><td>Llapa-7b-chbat</td><td>19.6</td><td>45.4</td><td>354</td><td>54</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="2">Llama-2-7b-chat (ICAE, k=256)</td><td>LlaPa-2-7b-chat</td><td>22.0</td><td>22.2</td><td>55.8</td><td>77.8</td></tr><tr><td>Llama-2-13b-chat</td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="2">Llama-2-13b-chat (ICAE, k=256)</td><td>GPT-4 (gold)</td><td>21.9 4.0</td><td>20.8 19.2</td><td>57.3</td><td>79.2</td></tr><tr><td></td><td></td><td></td><td>76.8</td><td>80.8</td></tr></table>
131
+
132
+ Table 5: ICAE with different memory slot lengths and different pretraining setups. The last row is the comparison between 128-length ICAE’s memory and 128-token summary produced by the GPT-4.
133
+
134
+ <table><tr><td rowspan="2">ICAE (Llama-2-7b-chat)</td><td colspan="4"> lose udgemte ±(%)</td></tr><tr><td>win (%)</td><td></td><td></td><td> win/lose</td></tr><tr><td>k = 128 (pretrained) VS k = 64 (pretrained)</td><td>57.6</td><td>19.5</td><td>22.9</td><td>3.0</td></tr><tr><td>k = 64 (pretrained) VS k = 32 (pretrained)</td><td>44.7</td><td>21.8</td><td>33.5</td><td>2.1</td></tr><tr><td> k = 64 (pretrained) VS k = 128 (no pretraining)</td><td>33.1</td><td>28.0</td><td>38.9</td><td>1.2</td></tr><tr><td>k = 128 (pretrained) VS k = 128 (no pretraining)</td><td>60.4</td><td>9.5</td><td>30.1</td><td>6.4</td></tr><tr><td> k = 128 (pretrained) VS k = 128 (pretrained only with AE)</td><td>36.4</td><td>28.5</td><td>35.1</td><td>1.3</td></tr><tr><td>k =128 (pretrained) VS k = 128 (pretrained only with LM)</td><td>35.1</td><td>24.9</td><td>40.0</td><td>1.4</td></tr><tr><td>k = 128 (pretrained) VS 128-token summary (by GPT-4)</td><td>34.1</td><td>17.6</td><td>48.3</td><td>1.9</td></tr></table>
135
+
136
+ The last row of Table 5 compares ICAE’s 128-length memory slots with a summary4 within 128 tokens ( $\mathord { \sim } 1 0 0$ words). Memory slots significantly outperform summaries under the same context length, with ${ \sim } 2 \times$ win/lose ratio, proving to be more compact and informative than natural language.
137
+
138
+ # 3.3 ANALYSIS
139
+
140
+ # 3.3.1 SCALABILITY
141
+
142
+ As discussed above, ICAE should achieve better compression performance with a more powerful target LLM. To verify this assumption, we compare the ICAE’s performance on three target LLMs: Llama-7b, Llama-2-7b and Llama-2-13b in Table 6, which align well with our expectations – more powerful target LLMs can achieve better context compression ratios.
143
+
144
+ # 3.3.2 LATENCY
145
+
146
+ We conducted an empirical test to evaluate the impact of ICAE’s $4 \times$ context compression on inference efficiency. For this efficiency test, we fix the context (i.e., input) length to either 512 or 2048 and the generation length to 128. Table 7 shows that context compression by ICAE is helpful to improve LLM (i.e., Llama-7b) inference efficiency, achieving over $2 \times$ speedup. Its acceleration becomes even more significant – around $3 . 5 \times$ – in compute-intensive scenarios (e.g., $8 \times 2 0 4 8$ and $3 2 \times 5 1 2$ ). Given that the compressed memory slots can be cached in advance (for frequently used texts like textbooks, government reports or articles of law), ICAE may introduce over $7 \times$ inference speedup in these cases. Details of the profiling are presented in Appendix B.
147
+
148
+ Table 6: The results of pretrained ICAE $( 5 1 2 1 2 8 $ ) based on different target LLMs
149
+
150
+ <table><tr><td rowspan="2">Target LLM</td><td colspan="2"></td><td colspan="2"></td><td></td></tr><tr><td>BLEU(E</td><td>Loss</td><td></td><td></td><td>△</td></tr><tr><td>Llama-7b</td><td>99.1</td><td>0.017</td><td>9.01</td><td>9.50</td><td>+0.49</td></tr><tr><td>Llama-2-7b</td><td>99.5</td><td>0.009</td><td>8.81</td><td>9.18</td><td>+0.37</td></tr><tr><td>Llama-2-13b</td><td>99.8</td><td>0.004</td><td>8.15</td><td>8.45</td><td>+0.30</td></tr></table>
151
+
152
+ Table 7: Latency comparison of LLM (generation) and LLM+ICAE (compression then generation)
153
+
154
+ <table><tr><td>(Batch×Length)</td><td>Method</td><td>Compession Time</td><td>Decoding</td><td>Total</td></tr><tr><td>8*2048</td><td>LLM+ICAE</td><td>3.4</td><td>24.0</td><td>7.324.3x)</td></tr><tr><td>8*512</td><td>LLM+MCAE</td><td>0.6</td><td></td><td>4.3(2.2x)</td></tr><tr><td>32*512</td><td>LLM+MCAE</td><td>2.6</td><td>24.3</td><td>6.824.x)</td></tr></table>
155
+
156
+ # 3.3.3 MULTIPLE SPANS OF MEMORY SLOTS
157
+
158
+ Thus far, we have mainly discussed a single span of memory slots. In this section, we shall discuss multiple spans of memory slots. As illustrated in Figure 6(Left), we can segment a long context into $N$ chunks, compress them individually, and then concatenate them to represent the original long context. However, this did not work initially, because the model had never seen multiple span concatenation patterns during training. Fortunately, we can incorporate a small number of multiple span concatenation samples during training, enabling the model to work with concatenated spans of memory slots, as OpenAI’s work (Bavarian et al., 2022) on introducing the “fill in the middle” ability for the GPT. The results in Figure 6(Right) indicate that, using an equivalent length context, ICAE’s memory achieves better performance – because memory can represent $4 \times$ the original context length.
159
+
160
+ The ability of ICAE demonstrates great promise to handle long contexts, as it can save a significant amount of GPU memory when addressing long contexts without touching the existing LLM. As illustrated in Figure 6(Right), 2048-length memory slots can perform on par with 4096-token contexts. This means that conditioning on 2048 memory slots instead of the original 4096 context tokens can save about 20GB of GPU memory5 with minimal quality degradation.
161
+
162
+ # 4 RELATED WORK
163
+
164
+ Prompt compression and context distillation (Askell et al., 2021; Snell et al., 2022) are closely related areas to this work: Wingate et al. (2022) proposed a method to learn compact soft prompts to simulate the original natural language prompt by optimizing the KL divergence. However, this approach has a very high computational cost, as it requires performing back-propagation for each new incoming prompt to learn and obtain the compressed prompt, which severely limits its application. Qin & Van Durme (2023) propose Neural Agglomerative Embeddings named NUGGET, which encodes language into a compact representation for an encoder-decoder model.
165
+
166
+ The most closely related studies to our research are GIST (Mu et al., 2023) and AutoCompressors (Chevalier et al., 2023). GIST achieves prompt compression by fine-tuning an LLM in a similar way to ours. The resulting model can produce gist tokens as the compression of a prompt, which are similar to our memory slots. Nonetheless, this approach is limited to compressing short prompts6 and thus does not address the real issue of long contexts. Also, this method requires fine-tuning the LLM, and the obtained gist tokens also need to be used within the specially tuned LLM (for gist tokens) and seem not compatible with the untouched LLM. AutoCompressors for recursively compressing long text into summary vectors. Like Mu et al. (2023), the LLM must be tuned to work with generated summary vectors and its training is sophisticated as it involves recursive compression. In contrast, we propose a very simple, straightforward and scalable approach to generating memory slots that can be used in the target LLM with different prompts for various purposes. Moreover, our approach is much more parameter-efficient (i.e., LoRA) for tuning on top of the existing LLM. Additionally, some recent work studies how to compress prompts into more concise natural language (Jiang et al., 2023a), and approaches the context limit with divide-and-conquer methodology (Bertsch et al., 2023; Chen et al., 2023; Song et al., 2024).
167
+
168
+ ![](images/296866e98ea06089212b07bee450b99be3be01b6f8e2be777f25a72c4fcdebe8.jpg)
169
+ Figure 6: Left: Individually compress then concatenate multiple spans of memory slots; Right: Perplexity comparison with original contexts and $4 \times$ compressed memory slots – for example, 1024- length memory slots are obtained by compressing the original context with a length of 4096 tokens.
170
+
171
+ Also, there is related work studying compressing indescribable concepts into (vector) tokens for later use in other contexts. Representative work includes Gal et al. (2022) which compresses a vision object into a token and Ge et al. (2023) which compresses a text style into a token.
172
+
173
+ Considering related work from a boarder perspective of compression, Jiang et al. (2023b) examines kNN-based prediction using general-purpose compressors, such as gzip. Delétang et al. (2023) extensively investigates the compression abilities of LLMs, uncovering their potential as versatile predictors, which also provides insights into recent developments in scaling laws and tokenization.
174
+
175
+ # 5 CONCLUSION AND FUTURE WORK
176
+
177
+ We propose the In-context Autoencoder (ICAE) to leverage the power of an LLM to highly compress contexts. By generating compact and informative memory slots to represent the original context, the ICAE enables an LLM to acquire more information with the same context length or represent the same content with a shorter context, thereby enhancing the model’s capability to handle long contexts as well as reducing computation and memory overheads for inference in many practical scenarios like Retrieval Augmented Generation (Lewis et al., 2020) and advanced prompting methods (Wei et al., 2022; Wang et al., 2023; Zhang et al., 2024). Moreover, ICAE provides insight into how an LLM performs memorization, offering a novel perspective on the connection between the memory of LLMs and humans, and suggesting future research in LLM context management.
178
+
179
+ Due to computational limitations, our experiments were conducted on Llama models up to 13 billion parameters. As discussed in the paper, ICAE is expected to benefit even more from more powerful LLMs, where it should be able to achieve more significant compression ratios. In the future, we hope to have sufficient computational resources to validate the effectiveness of ICAE on larger and stronger LLMs. In addition, we plan to explore the application of ICAE in multimodal LLMs (as the context length for images, videos, and audio is often much longer and has greater compression potential) with discrete memory slots (which can be either continuous or discrete) for helping unify compact representation across modalities in the era of LLM/AGI.
180
+
181
+ REFERENCES
182
+ Amanda Askell, Yuntao Bai, Anna Chen, Dawn Drain, Deep Ganguli, Tom Henighan, Andy Jones, Nicholas Joseph, Ben Mann, Nova DasSarma, et al. A general language assistant as a laboratory for alignment. arXiv preprint arXiv:2112.00861, 2021.
183
+ Alan Baddeley. Working memory. Science, 255(5044):556–559, 1992.
184
+ Mohammad Bavarian, Heewoo Jun, Nikolas Tezak, John Schulman, Christine McLeavey, Jerry Tworek, and Mark Chen. Efficient training of language models to fill in the middle. arXiv preprint arXiv:2207.14255, 2022.
185
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
186
+ Amanda Bertsch, Uri Alon, Graham Neubig, and Matthew Gormley. Unlimiformer: Long-range transformers with unlimited length input. Advances in Neural Information Processing Systems, 36, 2023.
187
+ Aydar Bulatov, Yury Kuratov, and Mikhail Burtsev. Recurrent memory transformer. Advances in Neural Information Processing Systems, 35:11079–11091, 2022.
188
+ Aydar Bulatov, Yuri Kuratov, and Mikhail S Burtsev. Scaling transformer to 1m tokens and beyond with rmt. arXiv preprint arXiv:2304.11062, 2023.
189
+ Howard Chen, Ramakanth Pasunuru, Jason Weston, and Asli Celikyilmaz. Walking down the memory maze: Beyond context limit through interactive reading. arXiv preprint arXiv:2310.05029, 2023.
190
+ Alexis Chevalier, Alexander Wettig, Anirudh Ajith, and Danqi Chen. Adapting language models to compress contexts. arXiv preprint arXiv:2305.14788, 2023.
191
+ Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
192
+ Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamás Sarlós, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy J. Colwell, and Adrian Weller. Rethinking attention with performers. ArXiv, abs/2009.14794, 2020.
193
+ Grégoire Delétang, Anian Ruoss, Paul-Ambroise Duquenne, Elliot Catt, Tim Genewein, Christopher Mattern, Jordi Grau-Moya, Li Kevin Wenliang, Matthew Aitchison, Laurent Orseau, et al. Language modeling is compression. arXiv preprint arXiv:2309.10668, 2023.
194
+ Jiayu Ding, Shuming Ma, Li Dong, Xingxing Zhang, Shaohan Huang, Wenhui Wang, and Furu Wei. Longnet: Scaling transformers to 1,000,000,000 tokens. arXiv preprint arXiv:2307.02486, 2023.
195
+ Randall W Engle, Stephen W Tuholski, James E Laughlin, and Andrew RA Conway. Working memory, short-term memory, and general fluid intelligence: a latent-variable approach. Journal of experimental psychology: General, 128(3):309, 1999.
196
+ K Anders Ericsson, William G Chase, and Steve Faloon. Acquisition of a memory skill. Science, 208 (4448):1181–1182, 1980.
197
+ Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618, 2022.
198
+ Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, Shawn Presser, and Connor Leahy. The Pile: An 800gb dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020.
199
+ Tao Ge, Hu Jing, Li Dong, Shaoguang Mao, Yan Xia, Xun Wang, Si-Qing Chen, and Furu Wei. Extensible prompts for language models on zero-shot language style customization. In A. Oh, T. Neumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine (eds.), Advances in Neural Information Processing Systems, volume 36, pp. 35576–35591. Curran Associates, Inc., 2023. URL https://proceedings.neurips.cc/paper_files/paper/ 2023/file/6fcbfb3721c1781728b10c6685cc2f6c-Paper-Conference.pdf.
200
+
201
+ Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
202
+
203
+ Huiqiang Jiang, Qianhui Wu, Chin-Yew Lin, Yuqing Yang, and Lili Qiu. Llmlingua: Compressing prompts for accelerated inference of large language models. arXiv preprint arXiv:2310.05736, 2023a.
204
+ Zhiying Jiang, Matthew Yang, Mikhail Tsirlin, Raphael Tang, Yiqin Dai, and Jimmy Lin. “lowresource” text classification: A parameter-free classification method with compressors. In Findings of the Association for Computational Linguistics: ACL 2023, pp. 6810–6828, 2023b.
205
+ Mark A. Kramer. Nonlinear principal component analysis using autoassociative neural networks. Aiche Journal, 37:233–243, 1991.
206
+ Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in Neural Information Processing Systems, 33: 9459–9474, 2020.
207
+ Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. Lost in the middle: How language models use long contexts, 2023.
208
+ Eleanor A Maguire, Elizabeth R Valentine, John M Wilding, and Narinder Kapur. Routes to remembering: the brains behind superior memory. Nature neuroscience, 6(1):90–95, 2003.
209
+ Jesse Mu, Xiang Lisa Li, and Noah Goodman. Learning to compress prompts with gist tokens. arXiv preprint arXiv:2304.08467, 2023.
210
+ OpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023.
211
+ Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35: 27730–27744, 2022.
212
+ Kishore Papineni, Salim Roukos, Todd Ward, and Wei Jing Zhu. Bleu: a method for automatic evaluation of machine translation. 10 2002. doi: 10.3115/1073083.1073135.
213
+ Guangyue Peng, Tao Ge, Si-Qing Chen, Furu Wei, and Houfeng Wang. Semiparametric language models are scalable continual learners. arXiv preprint arXiv:2303.01421, 2023.
214
+ Guanghui Qin and Benjamin Van Durme. Nugget: Neural agglomerative embeddings of text. In Andreas Krause, Emma Brunskill, Kyunghyun Cho, Barbara Engelhardt, Sivan Sabato, and Jonathan Scarlett (eds.), Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pp. 28337–28350. PMLR, 23–29 Jul 2023. URL https://proceedings.mlr.press/v202/qin23a.html.
215
+ Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019.
216
+ Charlie Snell, Dan Klein, and Ruiqi Zhong. Learning by distilling context. arXiv preprint arXiv:2209.15189, 2022.
217
+ Woomin Song, Seunghyuk Oh, Sangwoo Mo, Jaehyung Kim, Sukmin Yun, Jung-Woo Ha, and Jinwoo Shin. Hierarchical context merging: Better long context understanding for pre-trained llms. In The Twelfth International Conference on Learning Representations, 2024.
218
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aur’elien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and efficient foundation language models. ArXiv, abs/2302.13971, 2023a.
219
+ Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023b.
220
+ 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.
221
+ Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A Smith, Daniel Khashabi, and Hannaneh Hajishirzi. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022.
222
+ Zhenhailong Wang, Shaoguang Mao, Wenshan Wu, Tao Ge, Furu Wei, and Heng Ji. Unleashing the emergent cognitive synergy in large language models: A task-solving agent through multi-persona self-collaboration. arXiv preprint arXiv:2307.05300, 2023.
223
+ Jason Wei, Maarten Bosma, Vincent Y Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M Dai, and Quoc V Le. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652, 2021.
224
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems, 35:24824–24837, 2022.
225
+ David Wingate, Mohammad Shoeybi, and Taylor Sorensen. Prompt compression and contrastive conditioning for controllability and toxicity reduction in language models. arXiv preprint arXiv:2210.03162, 2022.
226
+ Yuhuai Wu, Markus N Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. arXiv preprint arXiv:2203.08913, 2022.
227
+ Yadong Zhang, Shaoguang Mao, Tao Ge, Xun Wang, Yan Xia, Man Lan, and Furu Wei. K-level reasoning with large language models. arXiv preprint arXiv:2402.01521, 2024.
228
+ Hao Zhao, Maksym Andriushchenko, Francesco Croce, and Nicolas Flammarion. Long is more for alignment: A simple but tough-to-beat baseline for instruction fine-tuning. arXiv preprint arXiv:2402.04833, 2024.
229
+ Lin Zheng, Chong Wang, and Lingpeng Kong. Linear complexity randomized self-attention mechanism. In International Conference on Machine Learning, 2022.
230
+
231
+ # A MODEL TRAINING CONFIGURATION
232
+
233
+ We show how to perform pretraining with the text continuation objective and instruction fine-tuning in Figure 7 and 8.
234
+
235
+ We train the ICAE on 8 Nvidia A100 GPUs (80GB). The hyperparameters for pretraining and fine-tuning ICAE are presented in Table 8. We by default train the ICAE with bf16.
236
+
237
+ Table 8: Hyperparameters for training
238
+
239
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW</td></tr><tr><td>learning rate</td><td>le-4 (pretrain); 5e-5 (fine-tuning)</td></tr><tr><td>batch size</td><td>256</td></tr><tr><td>warmup</td><td>300</td></tr><tr><td>#updates</td><td>200k (pretrain); 30k (fine-tuning)</td></tr><tr><td>clip norm</td><td>2.0</td></tr></table>
240
+
241
+ ![](images/6e85d8489c2b12f4199051d95a0898aebaf79a7905c198f88676e0ae38ebe4c3.jpg)
242
+ Figure 7: Pretraining with the text continuation objective to predict next tokens
243
+
244
+ ![](images/2ed2ab058cf5c5af8b6bc7fbc10ebd6a570048bb2211989afa5e0ee5ee738112.jpg)
245
+ Figure 8: Instruct fine-tuning of the ICAE to make its produced memory slots interact with prompts for accomplishing various purposes in the target LLM. In this figure, $\left( p _ { 1 } , \ldots , p _ { m } \right)$ denotes the prompt tokens and $( r _ { 1 } , \ldots , r _ { n } )$ denotes the response tokens.
246
+
247
+ # B PROFILING SETUP
248
+
249
+ We test the latency (Section 3.3.2) on 1 Nvidia A100 GPU (80GB). The test machine has the CPU of AMD EPYC™ 7413 with 24 cores and 216GB RAM. The runtime configuration is python $\mathord { \left. \vert \right.} = 3 . 9 $ , pytorch $\phantom { - } 1 { = } 2 . 0 . 1$ , cuda $= 1 1 . 7$ , cudnn $= 8 . 5$ .
250
+
251
+ # C PROMPT-WITH-CONTEXT DATASET
252
+
253
+ We introduce the PROMPT-WITH-CONTEXT (PWC) dataset where each sample entry is a triple (text, prompt, answer), as depicted in Figure 9. To construct this dataset, we first sample $2 0 \mathrm { k }$ texts from the Pile dataset. Then, for each text, we employ the GPT-4 to provide 15 prompts (10 specific prompts and 5 general prompts) about the text and give the corresponding answers. The prompt instructing the GPT-4 is outlined in Listing 1.
254
+
255
+ The dataset is composed of 240k examples for training purposes, with an additional 18k examples for testing. The context length distribution of test samples is presented in Table 10.
256
+
257
+ # Listing 1: Prompt used by GPT4 API to generate the PWC dataset.
258
+
259
+ Design 10 prompts specified to the above text to test understanding of the above text. These prompts should be diverse and cover as many
260
+
261
+ # Context
262
+
263
+ ![](images/53a30a2591bfdb0a7a5d1f2bd1af52f9ed36bb01a27be506cd7e68c149d65fd3.jpg)
264
+ Figure 9: Construction of the PWC dataset: we use the GPT-4 to generate a variety of prompt-answer pairs according to contexts. The resulting dataset is used for instruction fine-tuning (240k for training) and evaluation (18k for testing) in this work.
265
+
266
+ aspects (e.g., topic, genre, structure, style, polarity, key information and details) of the text as possible. The first half of these prompts should be like an instruction, the other should be like a question. In addition to the prompts specified to the above text, please also design 5 general prompts like "rephrase the above text", "summarize the above text", "write a title for the above text", "extract a few keywords for the above text" and "write a paragraph (i.e., continuation) that follows the above text". Each prompt should be outputted in the following format: [{"prompt": your generated prompt, "answer": the answer to the prompt}]
267
+
268
+ # D GPT-4 EVALUATION
269
+
270
+ According to Mu et al. (2023), we formulate an evaluation prompt to be used with the GPT-4 API. The prompt, as illustrated in Listing 2, consists of a task description along with three specific examples. We supply GPT-4 with a text, a prompt, and two distinct model-generated responses. The task for GPT-4 is to determine the superior answer or recognize a tie. The chosen examples encompass scenarios where Assistant A performs better, Assistant B performs better, and when a tie occurs. This methodology enables us to effectively assess7 the model’s quality. Specially, the orders where the model responses are presented to the GPT-4 are swapped randomly to alleviate bias, as Touvron et al. (2023b) did.
271
+
272
+ Listing 2: Prompt for the GPT-4 evaluation. This prompt consists of a description of the task and three specific examples.
273
+
274
+ Given a piece of text, an instruction for this text, and two AI assistant answers, your task is to choose the better answer and provide reasons. Evaluate the answers holistically, paying special attention to whether the response (1) follows the given instruction and (2) is correct. If both answers correctly respond to the prompt, you should judge it as a tie.
275
+
276
+ ![](images/6698bdf35645699989fb23bb6524130a51e51e61c4147c88cadbc8f7a2ad4bd5.jpg)
277
+ Figure 10: The context length distribution of test samples: Most samples are longer than 500 tokens.
278
+
279
+ Example 1: 11
280
+
281
+ Text: We report the development of GPT-4, a large-scale, multimodal model which can accept image and text inputs and produce text outputs. While less capable than humans in many real-world scenarios, GPT-4 exhibits human-level performance on various professional and academic benchmarks, including passing a simulated bar exam with a score around the top $10 \%$ of test takers. GPT-4 is a Transformerbased model pre-trained to predict the next token in a document. The post-training alignment process results in improved performance on measures of factuality and adherence to desired behavior. A core component of this project was developing infrastructure and optimization methods that behave predictably across a wide range of scales. This allowed us to accurately predict some aspects of GPT-4’s performance based on models trained with no more than 1/1,000th the compute of GPT-4.
282
+
283
+ Prompt: What is GPT4?
284
+
285
+ Assistant A: GPT4 is a large-scale language-trained transformer-based model.
286
+
287
+ Assistant B: GPT4 can produce outputs. ‘‘‘
288
+
289
+ Your output should be:
290
+
291
+ {"reason": "The instruction asks what GPT4 is, and from the original
292
+ text, we know that GPT4 is a multimodal, large-scale model that can
293
+ generate text. Therefore, Assistant A is the closer answer, while
294
+ Assistant B did not follow the instruction well in providing a
295
+ response.", "choice": "A"}
296
+ 111
297
+
298
+ Example 2: ‘‘‘
299
+
300
+ Text: Making language models bigger does not inherently make them better at following a user’s intent. For example, large language models can generate outputs that are untruthful, toxic, or simply not helpful to the user. In other words, these models are not aligned with their users.
301
+
302
+ In this paper, we show an avenue for aligning language models with user intent on a wide range of tasks by fine-tuning with human feedback. Starting with a set of labeler-written prompts and prompts submitted through the OpenAI API, we collect a dataset of labeler demonstrations of the desired model behavior, which we use to fine-tune GPT-3 using supervised learning. We then collect a dataset of rankings of model outputs, which we use to further fine-tune this supervised model using reinforcement learning from human feedback. We call the resulting models InstructGPT. In human evaluations on our prompt distribution, outputs from the 1.3B parameter InstructGPT model are preferred to outputs from the 175B GPT-3, despite having $\boldsymbol { \perp 0 0 x }$ fewer parameters. Moreover, InstructGPT models show improvements in truthfulness and reductions in toxic output generation while having minimal performance regressions on public NLP datasets. Even though InstructGPT still makes simple mistakes, our results show that fine-tuning with human feedback is a promising direction for aligning language models with human intent.
303
+
304
+ Prompt: Write a title for the above text.
305
+
306
+ Assistant A: Improving Fine-Tuning for Language Models: A GPT-3-inspired
307
+ Approach
308
+ Assistant B: Training language models to follow instructions with human
309
+ feedback
310
+ ‘‘‘
311
+
312
+ Your output should be: 11
313
+
314
+ {"reason": "This text discusses how to make large language models follow user instructions better, and Assistant B’s response is more in line with the meaning of the text.", "choice": "B"}
315
+
316
+ Example 3: ‘‘‘
317
+
318
+ Text: Though technology companies announced massive layoffs last year, 2023 has been much worse. Layoffs have far outpaced last year’s cuts, as tech giants including Amazon, Facebook parent company Meta, Microsoft, Google, IBM, SAP, and Salesforce - as well as many smaller companies - announce sweeping job cuts. The problem: Big Tech went on a hiring binge during the pandemic when lockdowns sparked a tech buying spree to support remote work and an uptick in e-commerce, and now they face revenue declines. Although global IT spending is forecast to rise in 2023, with enterprise software and IT services experiencing the greatest growth, the overall increase is expected to be modest, with data center systems and communications services growing by less than 1%, according to market research firm Gartner. Meanwhile hardware sales are forecast to decline. Continuing supply chain issues, inflation, and the war in Ukraine are also having an impact on both business and consumer
319
+ spending, leading to fears of recession. According to data compiled by Layoffs.fyi, the online tracker keeping tabs on job losses in the technology sector, 784 tech companies have laid off about 208,181 staff so far this year, compared to 164,411 layoffs last year.
320
+ Prompt: How many job losses have occurred in the technology sector so far in 2023?
321
+ Assistant A: 208,181 job losses have occurred in the technology sector so far in 2023.
322
+ Assistant B: 208,181.
323
+ ‘‘‘
324
+
325
+ Your output should be: 1
326
+
327
+ {"reason": "Both answers are acceptable and correct. They should be a tie.", "choice": "Tie"}
328
+
329
+ Your response should only be in the JSON format above; THERE SHOULD BE NO OTHER CONTENT INCLUDED IN YOUR RESPONSE. Write the "reason" key before writing the "choice" key, so that you think step-by-step before making your decision. KEEP YOUR REASONING BRIEF. Again, don’t favor either A or B if they are both acceptable and correct -- judge a tie instead.
330
+
331
+ The prompt that the GPT-4 uses to generate 128-token summary is as follows:
332
+
333
+ “Write a summary for the above text. Your summary should not exceed 100 words but should include as much information of the original text as possible.”
334
+
335
+ We show examples of the GPT-4 evaluation on a pretrained and a non-pretrained ICAE in Table 9.
336
+
337
+ # Passage 1 (514 tokens):
338
+
339
+ French senior civil servant arrested on suspicion of spying for North Korea
340
+
341
+ November 27, 2018 by Joseph Fitsanakis
342
+
343
+ Table 9: Examples of outputs by the target LLM (i.e., Llama) conditioning on memory slots $k = 1 2 8$ ) produced by the pretrained and non-pretrained ICAE. The highlighted parts are not faithful to the context.
344
+
345
+ <table><tr><td>Prompt: What is the maximum prison sentence Quennedey could face if found guilty?</td></tr><tr><td>Assistant A (pretrained ICAE): Quennedey could face up to 3O years in prison if found guilty.</td></tr><tr><td> Assistant B (non-pretrained ICAE): Quennedey could face up to three years in prison if found guilty.</td></tr><tr><td>Answer (by the GPT-4): Up to 30 years.</td></tr><tr><td>GPT-4 evaluation: Asistant A correctly states the maximum prison sentence from the text, while Asstant B provides an incorrect number.</td></tr></table>
346
+
347
+ A senior civil servant in the upper house of the French parliament has been arrested on suspicion of spying for North Korea, according to prosecutors. The news of the suspected spy’s arrest was first reported on Monday by Quotidien, a daily politics and culture show on the Monaco-based television channel TMC. The show cited “a judicial source in Paris” and said that France’s domestic security and counterintelligence agency, the General Directorate for Internal Security (DGSI), was in charge of the espionage case.
348
+
349
+ # (omitted 233 words)
350
+
351
+ The senior civil servant faces up to 30 years in prison if found guilty of espionage.
352
+
353
+ # Passage 2 (506 tokens):
354
+
355
+ With Red Hat, IBM to become the leading hybrid cloud provider Watch Now
356
+
357
+ After IBM acquired Red Hat, I suggested IBM paid $\$ 34$ billion for the Linux power so it could become a hybrid-cloud power. With the news that Red Hat will acquire NooBaa, a hybrid-cloud, data-storage company, it’s become clearer than ever that the IBM-Red Hat deal is all about the hybrid cloud.
358
+
359
+ # (omitted 208 words)
360
+
361
+ As Ranga Rangachari, Red Hat’s vice president of Storage and Hyperconverged Infrastructure, said in a statement:
362
+
363
+ "Data portability is a key imperative for organizations building and deploying cloud-native applications across private and multiple clouds. NooBaa’s technologies will augment our portfolio and strengthen our ability to meet the needs of developers in today’s hybrid and multicloud world. We are thrilled to welcome a technical team of nine to the Red Hat family as we work together to further solidify Red Hat as a leading provider of open hybrid-cloud technologies.
364
+
365
+ <table><tr><td>Prompt:Discuss the role of Ranga Rangachari in the context of the text</td></tr><tr><td>Assistant A (pretrained ICAE): Ranga Rangacharis the vice presidentof Storage and Hyperconverged Infrastructure at Red Hat.He is responsible forthecompany&#x27;sstorageand hyperconvergedoferings,and he welcomes the nine-member teamof technical experts from NoaBaa to join Red Hat as a part of the IBM acquisition.</td></tr><tr><td>Assistant B(non-pretrained ICAE): Ranga Rangachari is the CEOof Red Hat,and he is excited about the acquisition of NooBaa as itwillhelpRed Hatbecomealeaderinhybrid cloud management.He believes that NooBa’stechnology wil enableRed Hattoprovideasingle,comprehensive platformfor managing dataacross multipleclouds,andthatthis willbea significant differentiator for Red Hat in the market.</td></tr><tr><td>Answer(bythe GPT-4): Ranga Rangacharis the vice presidentofStorage and Hyperconverged Infrastructure atRed Hat.He madeastatementregardingtheacquisitionofNooBaa,highlighting theimportanceofdataportabilityintoday&#x27;shybridand multicloud worldand how NooBaa’stechnologies would strengthen Red Hat&#x27;sabilityto meet theneeds of developers.</td></tr><tr><td>GPT-4 evaluation: Assistant Acorectly identifies Ranga Rangachari’s role as the vice presidentof Storage and Hypercon- vergedInfrastructureatRed Hatadaccratelydescribes hisstatementabout theacquisitionof NooBaa.AsistantBincorectly states that Ranga Rangachari is the CEO of Red Hat.</td></tr></table>
parse/test/uREj4ZuGJE/uREj4ZuGJE_content_list.json ADDED
@@ -0,0 +1,846 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "IN-CONTEXT AUTOENCODER FOR CONTEXTCOMPRESSION IN A LARGE LANGUAGE MODEL",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Tao $\\mathbf { G e ^ { * } }$ Jing $\\mathbf { H } \\mathbf { u } ^ { \\dag }$ Lei Wang† Xun Wang Si-Qing Chen Furu Wei Microsoft Corporation {tage,v-hjing,v-leiwang7,xunwang,sqchen,fuwei}@microsoft.com ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "ABSTRACT ",
16
+ "text_level": 1,
17
+ "page_idx": 0
18
+ },
19
+ {
20
+ "type": "text",
21
+ "text": "We propose the In-context Autoencoder (ICAE), leveraging the power of a large language model (LLM) to compress a long context into short compact memory slots that can be directly conditioned on by the LLM for various purposes. ICAE is first pretrained using both autoencoding and language modeling objectives on massive text data, enabling it to generate memory slots that accurately and comprehensively represent the original context. Then, it is fine-tuned on instruction data for producing desirable responses to various prompts. Experiments demonstrate that our lightweight ICAE, introducing about $1 \\%$ additional parameters, effectively achieves $4 \\times$ context compression based on Llama, offering advantages in both improved latency and GPU memory cost during inference, and showing an interesting insight in memorization as well as potential for scalability. These promising results imply a novel perspective on the connection between working memory in cognitive science and representation learning in LLMs, revealing ICAE’s significant implications in addressing the long context problem and suggesting further research in LLM context management. Our data, code and models are available at https://github.com/getao/icae. ",
22
+ "page_idx": 0
23
+ },
24
+ {
25
+ "type": "image",
26
+ "img_path": "images/42572e3419c7133527e5908e4e852be7751ddca6609df0099fa1422ae0fdbfd5.jpg",
27
+ "image_caption": [
28
+ "Figure 1: Compressing a long context into a short span of memory slots. The memory slots can be conditioned on by the target LLM on behalf of the original context to respond to various prompts. "
29
+ ],
30
+ "image_footnote": [],
31
+ "page_idx": 0
32
+ },
33
+ {
34
+ "type": "text",
35
+ "text": "1 INTRODUCTION ",
36
+ "text_level": 1,
37
+ "page_idx": 0
38
+ },
39
+ {
40
+ "type": "text",
41
+ "text": "Long context modeling is a fundamental challenge for Transformer-based (Vaswani et al., 2017) LLMs due to their inherent self-attention mechanism. Much previous research (Child et al., 2019; Beltagy et al., 2020; Rae et al., 2019; Choromanski et al., 2020; Bulatov et al., 2022; Zheng et al., 2022; Wu et al., 2022; Bulatov et al., 2023; Ding et al., 2023) attempts to tackle the long context issue through architectural innovations of an LLM. While they approach long context with a significant reduction in computation and memory complexity, they often struggle to overcome the notable decline in performance on long contexts, as highlighted by Liu et al. (2023). In contrast to these efforts, we approach the long context problem from a novel angle – context compression. ",
42
+ "page_idx": 0
43
+ },
44
+ {
45
+ "type": "text",
46
+ "text": "",
47
+ "page_idx": 1
48
+ },
49
+ {
50
+ "type": "image",
51
+ "img_path": "images/732bd72050776b6ca34a7a1240014ff01391c76c5c03751b59ed2952ff08fa3c.jpg",
52
+ "image_caption": [
53
+ "Figure 2: Various context lengths (e.g., 2572 chars, 512 words, 128 memory slots) serve the same function when conditioned on by an LLM for responding to the given prompt. "
54
+ ],
55
+ "image_footnote": [],
56
+ "page_idx": 1
57
+ },
58
+ {
59
+ "type": "text",
60
+ "text": "Context compression is motivated by the fact that a text can be represented in different lengths in an LLM while conveying the same information. As shown in Figure 2, if we use characters to represent the text, it will have a length of 2,572; if we represent it using (sub-)words, we only need a context length of 512 without affecting the response accuracy. So, is there a more compact representation allowing us to achieve the same goal with a shorter context? ",
61
+ "page_idx": 1
62
+ },
63
+ {
64
+ "type": "text",
65
+ "text": "We explore this problem and propose the ICAE which leverages the power of an LLM to achieve high compression of contexts. The ICAE consists of 2 modules: a learnable encoder adapted from the LLM with LoRA (Hu et al., 2021) for encoding a long context into a small number of memory slots, and a fixed decoder, which is the LLM itself where the memory slots representing the original context are conditioned on to interact with prompts to accomplish various goals, as illustrated in Figure 1. ",
66
+ "page_idx": 1
67
+ },
68
+ {
69
+ "type": "text",
70
+ "text": "We first pretrain the ICAE using both autoencoding (AE) and language modeling (LM) objectives so that it can learn to generate memory slots from which the decoder (i.e., the LLM) can recover the original context or perform continuation. The pretraining with massive text data enables the ICAE to be well generalized, allowing the resulting memory slots to represent the original context more accurately and comprehensively. Then, we fine-tune the pretrained ICAE on instruction data for practical scenarios by enhancing its generated memory slots’ interaction with various prompts. We show the ICAE (based on Llama) learned with our pretraining and fine-tuning method can effectively produce memory slots with $4 \\times$ context compression. We highlight our contributions as follows: ",
71
+ "page_idx": 1
72
+ },
73
+ {
74
+ "type": "text",
75
+ "text": "• We propose In-context Autoencoder (ICAE) – a novel approach to context compression by leveraging the power of an LLM. The ICAE either enables an LLM to express more information with the same context length or allows it to represent the same content with a shorter context, thereby enhancing the model’s ability to handle long contexts with improved latency and memory cost during inference. Its promising results and its scalability may suggest further research efforts in context management for an LLM, which is orthogonal to other long context modeling studies and can be combined with them to further improve the handling of long contexts in an LLM. • In addition to context compression, ICAE provides an access to probe how an LLM performs memorization. We observe that extensive self-supervised learning (e.g., autoencoding) in the pretraining phase is very helpful to enhance the ICAE’s capability to encode the original context into compressed memory slots. This pretraining process may share some analogies with humans enhancing their memory capacity through extensive memory training, which improves the brain’s memory encoding capabilities (Ericsson et al., 1980; Engle et al., 1999; Maguire et al., 2003). We also show that an LLM’s memorization pattern is highly similar to humans (see Table 2 and Table 3). All these results imply a novel perspective on the connection between working memory in cognitive science (Baddeley, 1992) and representation learning in LLMs (i.e., context window). ",
76
+ "page_idx": 1
77
+ },
78
+ {
79
+ "type": "text",
80
+ "text": "2 IN-CONTEXT AUTOENCODER ",
81
+ "text_level": 1,
82
+ "page_idx": 2
83
+ },
84
+ {
85
+ "type": "text",
86
+ "text": "2.1 MODEL ARCHITECTURE ",
87
+ "text_level": 1,
88
+ "page_idx": 2
89
+ },
90
+ {
91
+ "type": "text",
92
+ "text": "Like a typical autoencoder (Kramer, 1991), ICAE consists of an encoder and a decoder. Similar to the design of Gisting (Mu et al., 2023) and AutoCompressor (Chevalier et al., 2023), the ICAE performs both the encoding and decoding processes in an in-context manner, as illustrated in Figure 3. ",
93
+ "page_idx": 2
94
+ },
95
+ {
96
+ "type": "image",
97
+ "img_path": "images/f2c77b7cf4f4febfa062846630c6f63c9f99c3e45313e3a29d288afe6888beca.jpg",
98
+ "image_caption": [
99
+ "Figure 3: The encoder of the ICAE is a LoRA-adapted LLM, which is used for encoding the original context $\\pmb { c } = ( w _ { 1 } , w _ { 2 } , \\dots , w _ { L } )$ into a few memory slots $( \\widetilde { m _ { 1 } } , \\dots , \\widetilde { m _ { k } } )$ . The decoder of the ICAE is f fthe target LLM itself that can condition on the memory slots produced by the encoder for various purposes (e.g., the autoencoding task as in this figure). $e ( \\cdot )$ denotes the word embedding lookup in the target LLM and $e _ { m } ( \\cdot )$ denotes the learnable embedding lookup of memory tokens that are used for producing memory slots.“[AE]” is a special token to indicate the autoencoding pretraining task. "
100
+ ],
101
+ "image_footnote": [],
102
+ "page_idx": 2
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "Given the intuition, we propose to use a LoRA-adapted LLM as the encoder of the ICAE, as illustrated in Figure 3. When encoding a context $\\pmb { c } = ( w _ { 1 } , \\dots , w _ { L } )$ with the length $L$ , we first append $k$ $k \\left( k < < L \\right)$ ) memory tokens $( m _ { 1 } , \\ldots , m _ { k } )$ to the context $^ c$ to obtain their outputs $( \\widetilde { m _ { 1 } } , \\dots , \\widetilde { m _ { k } } )$ as the memory slots for the context $^ c$ f f. Therefore, the ICAE encoder is very lightweight – it only adds a LoRA adapter and an embedding lookup for memory tokens compared with the target LLM. ",
107
+ "page_idx": 2
108
+ },
109
+ {
110
+ "type": "text",
111
+ "text": "As introduced above, we expect the memory slots $( \\widetilde { m _ { 1 } } , \\dots , \\widetilde { m _ { k } } )$ to be conditioned on by the target LLM on behalf of the original context $^ c$ f f. Therefore, we use the untouched target LLM as the decoder of the ICAE to ensure the compatibility of memory slots within the target LLM. ",
112
+ "page_idx": 2
113
+ },
114
+ {
115
+ "type": "text",
116
+ "text": "2.2 PRETRAINING ",
117
+ "text_level": 1,
118
+ "page_idx": 2
119
+ },
120
+ {
121
+ "type": "text",
122
+ "text": "2.2.1 AUTOENCODING ",
123
+ "text_level": 1,
124
+ "page_idx": 2
125
+ },
126
+ {
127
+ "type": "text",
128
+ "text": "Like a typical autoencoder, one of the ICAE’s pretraining objectives is to restore the original input text $^ c$ of the length $L$ from its produced memory slots $( \\widetilde { m _ { 1 } } , \\dots , \\widetilde { m _ { k } } )$ of the length $k$ : ",
129
+ "page_idx": 2
130
+ },
131
+ {
132
+ "type": "equation",
133
+ "img_path": "images/288cde9f896ba54de0c585f5adb718270960006a62b53a22d87daa210671024b.jpg",
134
+ "text": "$$\n\\mathcal { L } _ { \\mathrm { A E } } = \\operatorname* { m a x } _ { \\widetilde { m _ { 1 } } , \\ldots , \\widetilde { m _ { k } } } P ( c | \\widetilde { m _ { 1 } } , \\ldots , \\widetilde { m _ { k } } ; \\Theta _ { L L M } ) = \\operatorname* { m a x } _ { \\Theta _ { L o R A } , e _ { m } } P ( c | m _ { 1 } \\ldots m _ { k } ; \\Theta _ { L L M } , \\Theta _ { L o R A } , e _ { m } )\n$$",
135
+ "text_format": "latex",
136
+ "page_idx": 2
137
+ },
138
+ {
139
+ "type": "text",
140
+ "text": "To indicate the autoencoding task, we append a special token “[AE]” to $( \\widetilde { m _ { 1 } } , \\dots , \\widetilde { m _ { k } } )$ in the decoder, f fas Figure 3 shows. As this pretraining objective does not need any extra annotation, we can use massive text data to train the In-context Autoencoder. ",
141
+ "page_idx": 2
142
+ },
143
+ {
144
+ "type": "text",
145
+ "text": "2.2.2 TEXT CONTINUATION ",
146
+ "text_level": 1,
147
+ "page_idx": 2
148
+ },
149
+ {
150
+ "type": "text",
151
+ "text": "While autoencoding pretraining offers a straightforward learning objective to encode a context, its inherent simplicity and exclusive focus on the single objective may lead to suboptimal generalization. To address this issue, we incorporate an additional objective during the pretraining phase: text continuation, as illustrated in Figure 7 in Appendix A. This self-supervised task is widely acknowledged to facilitate the learning of more generalizable representations in language models: ",
152
+ "page_idx": 2
153
+ },
154
+ {
155
+ "type": "equation",
156
+ "img_path": "images/d8c532d703efa805dc2f806e1a42ce393ba5c31f438d1ebff743ded05548f020.jpg",
157
+ "text": "$$\n\\mathcal { L } _ { \\mathrm { L M } } = \\operatorname* { m a x } _ { \\widetilde { m _ { 1 } } , \\ldots , \\widetilde { m _ { k } } } P ( \\varrho | \\widetilde { m _ { 1 } } , \\ldots , \\widetilde { m _ { k } } ; \\Theta _ { L L M } ) = \\operatorname* { m a x } _ { \\Theta _ { L o R A } , e _ { m } } P ( o | m _ { 1 } \\ldots m _ { k } ; \\Theta _ { L L M } , \\Theta _ { L o R A } , e _ { m } )\n$$",
158
+ "text_format": "latex",
159
+ "page_idx": 2
160
+ },
161
+ {
162
+ "type": "text",
163
+ "text": "where $\\pmb { o } = ( w _ { L + 1 } , \\dots , w _ { L + N } )$ denotes the continuation of context c. This objective helps improve generalization and circumvent excessive reliance on, and overfitting to, the autoencoding task. ",
164
+ "page_idx": 3
165
+ },
166
+ {
167
+ "type": "text",
168
+ "text": "2.3 INSTRUCTION FINE-TUNING",
169
+ "text_level": 1,
170
+ "page_idx": 3
171
+ },
172
+ {
173
+ "type": "text",
174
+ "text": "After pretraining, the memory slots produced by the pretrained ICAE are expected to represent the original context. However, for LLMs, the purpose of providing a context extends beyond rote memorization or continuation; instead, the more common use scenario is using the provided context as a basis for accurately and appropriately responding to various prompts, ultimately accomplishing the tasks we want it to perform (Wei et al., 2021; Ouyang et al., 2022). ",
175
+ "page_idx": 3
176
+ },
177
+ {
178
+ "type": "text",
179
+ "text": "To enhance the interaction of memory slots produced by the ICAE with diverse prompts, we further fine-tune the ICAE with the PWC dataset (Prompt-with-Context), a dataset1 introduced in this paper consisting of thousands of (context, prompt, response) samples (as shown in Figure 1). ",
180
+ "page_idx": 3
181
+ },
182
+ {
183
+ "type": "text",
184
+ "text": "Formally, the ICAE is fine-tuned for learning to encode the context into the memory slots based on which the decoder (i.e., the target LLM) can produce a desirable response $r _ { 1 } \\ldots r _ { n }$ according to a given prompt $p _ { 1 } \\ldots p _ { m }$ , as shown in Figure 8 in Appendix A: ",
185
+ "page_idx": 3
186
+ },
187
+ {
188
+ "type": "equation",
189
+ "img_path": "images/2c97208423731340f35665a979afb6af17dbd92eff1f61743f59cd959c94b450.jpg",
190
+ "text": "$$\n\\begin{array} { l } { \\mathcal { L } _ { \\mathrm { F T } } = \\underset { \\widetilde { m _ { 1 } } \\ldots \\widetilde { m _ { k } } } { \\operatorname* { m a x } } P ( r _ { 1 } \\ldots r _ { n } | \\widetilde { m _ { 1 } } \\ldots \\widetilde { m _ { k } } , p _ { 1 } \\ldots p _ { m } ; \\Theta _ { L L M } ) } \\\\ { \\quad \\quad = \\underset { \\Theta _ { L o R A } , e _ { m } } { \\operatorname* { m a x } } P ( r _ { 1 } \\ldots r _ { n } | m _ { 1 } \\ldots m _ { k } , p _ { 1 } \\ldots p _ { m } ; \\Theta _ { L L M } , \\Theta _ { L o R A } , e _ { m } ) } \\end{array}\n$$",
191
+ "text_format": "latex",
192
+ "page_idx": 3
193
+ },
194
+ {
195
+ "type": "text",
196
+ "text": "3 EXPERIMENTS ",
197
+ "text_level": 1,
198
+ "page_idx": 3
199
+ },
200
+ {
201
+ "type": "text",
202
+ "text": "3.1 EXPERIMENTAL SETTING ",
203
+ "text_level": 1,
204
+ "page_idx": 3
205
+ },
206
+ {
207
+ "type": "text",
208
+ "text": "Data We pretrain the ICAE with the Pile (Gao et al., 2020). For instruction fine-tuning, we use the PWC dataset, as introduced in Section 2.3, which contains 240k (context, prompt, response) samples for training and 18k samples for testing. The context length distribution of test samples is shown in Figure 10. By default, the maximal token length (excluding memory slots) we set during training is 512 in both the ICAE’s encoder and decoder in our experiments. ",
209
+ "page_idx": 3
210
+ },
211
+ {
212
+ "type": "text",
213
+ "text": "Model Configuration We use the LlaMa (Touvron et al., 2023a;b) as the target LLM to test the ICAE’s performance in context compression. For the encoder of the ICAE, LoRA is applied to the query and value projections of the LLM’s multi-head attention. In our default setting, the memory slot length $k$ is set to 128, and the LoRA rank $r$ is set to 128 unless otherwise specified. The resulting ICAE only adds about $1 \\%$ learnable parameters on top of the target LLM. ",
214
+ "page_idx": 3
215
+ },
216
+ {
217
+ "type": "text",
218
+ "text": "3.2 RESULTS ",
219
+ "text_level": 1,
220
+ "page_idx": 3
221
+ },
222
+ {
223
+ "type": "text",
224
+ "text": "3.2.1 PRETRAINED ICAE ",
225
+ "text_level": 1,
226
+ "page_idx": 3
227
+ },
228
+ {
229
+ "type": "text",
230
+ "text": "We first evaluate the autoencoding performance of the pretrained ICAE (without instruction finetuning) using the following three metrics to understand how well it restores the original context from its produced memory slots: BLEU (Papineni et al., 2002), Exact-Match $( \\mathrm { E M } ) ^ { 2 }$ and cross entropy loss. ",
231
+ "page_idx": 3
232
+ },
233
+ {
234
+ "type": "text",
235
+ "text": "Figure 4 presents the autoencoding results of the ICAE based on the Llama-7b. The ICAE demonstrates a very low overall loss, below 0.05, indicating that the produced memory slots retain almost all the information of the original context. When the context length is within 300, the ICAE can almost perfectly reconstruct the original context, achieving nearly $100 \\%$ BLEU and EM scores. As the context length increases beyond 400, both BLEU and EM scores start to decline, indicating insufficient capacity of the 128-length memory slots. However, even at a context length of 500, the median BLEU remains over 0.98, and the median EM approaches 0.6 (e.g., perfectly reconstructing about the first 300 words of a 512-token context), showing remarkable performance of ICAE. ",
236
+ "page_idx": 3
237
+ },
238
+ {
239
+ "type": "text",
240
+ "text": "We then analyze the effect of the memory size $k$ on the result. According to Figure 5, as the memory slot length $k$ decreases, the ICAE’s ability to memorize longer samples significantly deteriorates. ",
241
+ "page_idx": 3
242
+ },
243
+ {
244
+ "type": "image",
245
+ "img_path": "images/9bd009d4f2b3ac3305f5d375e134ba0708fa071a2ad161f191abe011e18e3472.jpg",
246
+ "image_caption": [
247
+ "Figure 4: Autoencoding results of the ICAE based on the Llama-7b with memory length $k = 1 2 8$ . The horizontal axis represents the original context length of test examples. For example, the horizontal axis value of 100 refers to the test examples with context lengths ranging from 95 to 105. "
248
+ ],
249
+ "image_footnote": [],
250
+ "page_idx": 4
251
+ },
252
+ {
253
+ "type": "image",
254
+ "img_path": "images/0e27d1a4215a85756577600cd7265a4c07b040b5b8f00ddc954007f3062c7f5b.jpg",
255
+ "image_caption": [
256
+ "Figure 5: BLEU and loss at different memory slot lengths $k$ "
257
+ ],
258
+ "image_footnote": [],
259
+ "page_idx": 4
260
+ },
261
+ {
262
+ "type": "text",
263
+ "text": "Compared to $k = 1 2 8$ where the BLEU score can still reach over $9 5 \\%$ at a context length of 500, the BLEU scores become much less satisfactory for $k$ values of 64 and 32, indicating an inability to losslessly retain the original context. This observation is also evident from the loss curve, suggesting that achieving over $4 \\times$ compression is rather challenging. ",
264
+ "page_idx": 4
265
+ },
266
+ {
267
+ "type": "table",
268
+ "img_path": "images/24b88b34e2f14395b300026a9f6980906cf081eb936bc939a426463a2d1d102e.jpg",
269
+ "table_caption": [
270
+ "Table 1: Text continuation evaluation for the pretrained ICAE. Similar to the autoencoding evaluation, a higher compression ratio tends to result in more pronounced losses in language modeling. "
271
+ ],
272
+ "table_footnote": [],
273
+ "table_body": "<table><tr><td rowspan=\"2\">Context length</td><td colspan=\"2\">PPL(</td><td rowspan=\"2\">△</td></tr><tr><td></td><td></td></tr><tr><td>128→128(1×)</td><td>9.99</td><td>10.15</td><td>+0.16</td></tr><tr><td>256-→128(2x)</td><td>9.45</td><td>9.77</td><td>+0.32</td></tr><tr><td>512-→128 (4×)</td><td>9.01</td><td>9.50</td><td>+0.49</td></tr></table>",
274
+ "page_idx": 4
275
+ },
276
+ {
277
+ "type": "text",
278
+ "text": "Similarly, the text continuation evaluation presented in Table 1 also illustrates that a higher compression ratio tends to result in more pronounced losses in language modeling. ",
279
+ "page_idx": 4
280
+ },
281
+ {
282
+ "type": "text",
283
+ "text": "Table 2 presents 1 specific example of the ICAE performing text restoration, demonstrating an interesting behavior: “large pretrained language model” is restored as “large pretrained model” and “The results prove” is restored as “The experimental evidence proves”. These restoration errors resemble mistakes humans would make when memorizing the same text. This suggests that, like humans, the model selectively emphasizes or neglects certain parts of the information during the memorization based on its own understanding. It is also consistent with Peng et al. (2023): the stronger the LLM, the fewer it needs to memorize, and thus the smaller the memorization effort. This is similar to human learning: knowledgeable individuals tend to learn more effortlessly, while those with limited knowledge often rely on rote memorization to acquire new information. ",
284
+ "page_idx": 4
285
+ },
286
+ {
287
+ "type": "text",
288
+ "text": "To further look into the memorization insight, we test restoration performance for different types of 512-token texts with 128 memory slots produced by ICAE to investigate whether its memorization capability is consistent across different content types. According to Table 3, in contrast to compressing normal texts which can be well restored, compressing and restoring less common texts (i.e., random texts) becomes very challenging, reflected by much worse loss and BLEU scores. All these results strongly support our intuition that an LLM’s memorization pattern is highly similar to humans. ",
289
+ "page_idx": 4
290
+ },
291
+ {
292
+ "type": "table",
293
+ "img_path": "images/03e3d08174988f425fa1cae5d30834d8176266e796673a7cfe37dd51a35ce52b.jpg",
294
+ "table_caption": [
295
+ "Table 2: 1 example showing how the pretrained ICAE $k = 1 2 8 ,$ ) restores the original context. "
296
+ ],
297
+ "table_footnote": [],
298
+ "table_body": "<table><tr><td>Origin Context Large pretrained language models have shown surprising In-</td><td>Restoration Large pretrained models have shown surprising In-Context</td></tr><tr><td>Context Learning (ICL) ability. With a few demonstration input-label pairs,they can predict the label for an unseen in- put without additional parameter updates.Despite the great success in performance,the working mechanism of ICL still remains an open problem.In order to better understand how ICL works,this paper explains language models as meta- optimizers and understands ICL as a kind of implicit finetun- ing.Theoretically,we figure out that the Transformer attention has a dual form of gradient descent based optimization. On top of it, we understand ICL as follows:GPT first produces metagradients according to the demonstration examples,and then these meta-gradients are applied to the original GPT to build an ICL model. Experimentally,we comprehensively compare the behavior of ICL and explicit finetuning based on real tasks to provide empirical evidence that supports our understanding. The results prove that ICL behaves similarly to explicit finetuning at the prediction level, the representation level,and the attention behavior level. Further, inspired by our understanding of meta-optimization, we design a momentum- based attention by analogy with the momentum-based gradient descent algorithm. Its consistently better performance over vanilla attntion supports our understanding again from an- other aspect, and more importantly, it shows the potential to</td><td>Learning (ICL) ability.With a few demonstration input-label pairs,they can predict the label for an unseen input without additional parameter updates.Despite the great success in per- formance,the working mechanism of ICL still remains an open problem.In order to better understand how ICL works,this paper explains how language models as meta-optimizers and understands ICL as a kind of implicit finetuning. Theoretically, we figure out that the Transformer attention has a dual form of gradient descent based on optimization. On top of it, we understand ICL as follows: GPT first produces metagradients according to the demonstration examples,and then these meta- gradients are applied to the original GPT to build an ICL model. Experimentally,we comprehensively compare the behavior of ICL and explicit finetuning based on real tasks to provide em- pirical evidence that supports our findings. The experimental evidence proves that ICL behaves like us to the same extent. Prediction at the explicit finetuning level, the representation level,and the attention behavior level.Further, inspired by our understanding of meta-optimization,we design a momentum- based attention by analogy with the gradient descent-based momentum gradient algorithm. Its consistently better perfor- mance against vanilla atention supports us again from another aspect,and more importantly, it shows the potential to use our</td></tr></table>",
299
+ "page_idx": 5
300
+ },
301
+ {
302
+ "type": "table",
303
+ "img_path": "images/9a805c7d12273862782357ae820703349d174d1af79d77f0e4ee73d94d84e5c2.jpg",
304
+ "table_caption": [
305
+ "Table 3: Restoration performance for different types of 512-token content with 128 memory slots. Patterned random text is obtained by adding 1 to each token_id in a normal text. "
306
+ ],
307
+ "table_footnote": [],
308
+ "table_body": "<table><tr><td>Content type</td><td>Loss</td><td>BLEU</td></tr><tr><td>Normal text</td><td>0.01</td><td>99.3</td></tr><tr><td>Patterned random text</td><td>1.63</td><td>3.5</td></tr><tr><td>Completely random text</td><td>4.55</td><td>0.2</td></tr></table>",
309
+ "page_idx": 5
310
+ },
311
+ {
312
+ "type": "text",
313
+ "text": "Based on this intuition, it is very likely that a more powerful LLM may support a higher compression ratio without significant forgetting. We will discuss it in Section 3.3.1. ",
314
+ "page_idx": 5
315
+ },
316
+ {
317
+ "type": "text",
318
+ "text": "3.2.2 FINE-TUNED ICAE ",
319
+ "text_level": 1,
320
+ "page_idx": 5
321
+ },
322
+ {
323
+ "type": "text",
324
+ "text": "In order to evaluate the fine-tuned ICAE’s performance, we evaluate on the PWC test set. We use the GPT-4 to compare the outputs of the two systems to determine which one performs better or if they are on par with each other, following Mu et al. (2023). Table 4 shows the comparison of results of the LLMs conditioned on memory slots and original contexts. For Llama-7b (fine-tuned ICAE), we compare with Alpaca and StableLM-tuned-alpha-7b since there is no official instruction-tuned Llama-1 model. The Llama-7b (ICAE) conditioned on 128 memory slots largely outperforms both Alpaca and StableLM which can access original contexts ( ${ \\sim } 5 1 2$ tokens), with a win rate of $5 6 . 7 \\%$ and $7 4 . 1 \\%$ respectively and a win+tie rate of $7 3 \\% { \\sim } 8 1 \\%$ . However, when compared to the GPT-4 (we regard it as the gold standard), there is still a significant gap, with around $70 \\%$ of the cases underperforming the GPT-4’s results, and a win+tie ratio of about only $30 \\%$ . ",
325
+ "page_idx": 5
326
+ },
327
+ {
328
+ "type": "text",
329
+ "text": "When we switch the base model to Llama-2-chat, we observe ICAE’s performance becomes much better than its counterpart based on Llama-1: when $k = 1 2 8$ , its win+tie rate can reach around $7 5 \\%$ againt the GPT-4 although it still lags behind its counterpart conditioning on the original context as the compression is lossy. As $k$ increases, the win+tie rate further improves while the compression rate decreases. We perform the same comparative studies on Llama-2-13b-chat and observe better results of ICAE, supporting our assumption in Section 3.2.1 that the ICAE can benefit more on larger LLMs. ",
330
+ "page_idx": 5
331
+ },
332
+ {
333
+ "type": "text",
334
+ "text": "We investigate the impact of memory length on results. Table 5 shows pairwise comparisons between ICAE models with varying memory slot lengths. A higher compression ratio makes it harder to ensure response quality, but a larger ratio doesn’t always lead to worse performance. Table 5 highlights that a pretrained ICAE with $8 \\times$ compression $\\scriptstyle ( k = 6 4 )$ can match a non-pretrained ICAE with $4 \\times$ compression $k { = } 1 2 8$ ). Under the same ratio, the pretrained ICAE performs much better than its non-pretrained counterpart, emphasizing the importance of pretraining. By comparing the outputs generated via the pretrained and non-pretrained ICAE, we find the pretrained ICAE suffers less from hallucination than the non-pretrained counterpart (see the examples in Table 9 in Appendix D). We assume the pretraining of ICAE improves the LLM’s working memory as it shares some analogies with humans enhancing their memory capacity via extensive memory training which improves the brain’s memory encoding capabilities. We also examine pretraining objectives and find combining3 AE and LM yields better results than using AE or LM individually (the 4th row in Table 5). ",
335
+ "page_idx": 5
336
+ },
337
+ {
338
+ "type": "table",
339
+ "img_path": "images/6bcd5053bf444a9c09f1e787e7ccc4f1a7a66fa8d1664cd99b4c4be976a91dc0.jpg",
340
+ "table_caption": [
341
+ "Table 4: Memory slots VS Original contexts $( \\sim 5 1 2$ tokens) on the PWC test set "
342
+ ],
343
+ "table_footnote": [],
344
+ "table_body": "<table><tr><td rowspan=\"2\">System 1 (k memory slots)</td><td rowspan=\"2\">System 2 (original context)</td><td colspan=\"4\"> Judgement (%)</td></tr><tr><td>win</td><td>lose</td><td>tie</td><td>on par (win+tie)</td></tr><tr><td rowspan=\"3\">Llama-7b (ICAE, k=128)</td><td>Alpaca</td><td>56.7</td><td>26.9</td><td>16.4</td><td>73.1</td></tr><tr><td>StableLM-7b</td><td>74.1</td><td>18.8</td><td>7.2</td><td>81.3</td></tr><tr><td>GPT-4 (gold)</td><td>3.4</td><td>69.4</td><td>27.2</td><td>30.6</td></tr><tr><td rowspan=\"2\">Llama-2-7b-chat (ICAE, k=64)</td><td>Llama-2-7b-chat</td><td>13.6</td><td>51.6</td><td>34.8</td><td>48.4</td></tr><tr><td>GPT-4 (gold)</td><td>1.9</td><td>44.7</td><td>53.4</td><td>55.3</td></tr><tr><td rowspan=\"2\">Llama-2-7b-chat (ICAE, k=128)</td><td>Llapa-7b-chbat</td><td>19.6</td><td>45.4</td><td>354</td><td>54</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=\"2\">Llama-2-7b-chat (ICAE, k=256)</td><td>LlaPa-2-7b-chat</td><td>22.0</td><td>22.2</td><td>55.8</td><td>77.8</td></tr><tr><td>Llama-2-13b-chat</td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=\"2\">Llama-2-13b-chat (ICAE, k=256)</td><td>GPT-4 (gold)</td><td>21.9 4.0</td><td>20.8 19.2</td><td>57.3</td><td>79.2</td></tr><tr><td></td><td></td><td></td><td>76.8</td><td>80.8</td></tr></table>",
345
+ "page_idx": 6
346
+ },
347
+ {
348
+ "type": "table",
349
+ "img_path": "images/8cdcc463e32905e3e5080781a60d34077e0e8b94b71e9b6822dd7f8106a9aede.jpg",
350
+ "table_caption": [
351
+ "Table 5: ICAE with different memory slot lengths and different pretraining setups. The last row is the comparison between 128-length ICAE’s memory and 128-token summary produced by the GPT-4. "
352
+ ],
353
+ "table_footnote": [],
354
+ "table_body": "<table><tr><td rowspan=\"2\">ICAE (Llama-2-7b-chat)</td><td colspan=\"4\"> lose udgemte ±(%)</td></tr><tr><td>win (%)</td><td></td><td></td><td> win/lose</td></tr><tr><td>k = 128 (pretrained) VS k = 64 (pretrained)</td><td>57.6</td><td>19.5</td><td>22.9</td><td>3.0</td></tr><tr><td>k = 64 (pretrained) VS k = 32 (pretrained)</td><td>44.7</td><td>21.8</td><td>33.5</td><td>2.1</td></tr><tr><td> k = 64 (pretrained) VS k = 128 (no pretraining)</td><td>33.1</td><td>28.0</td><td>38.9</td><td>1.2</td></tr><tr><td>k = 128 (pretrained) VS k = 128 (no pretraining)</td><td>60.4</td><td>9.5</td><td>30.1</td><td>6.4</td></tr><tr><td> k = 128 (pretrained) VS k = 128 (pretrained only with AE)</td><td>36.4</td><td>28.5</td><td>35.1</td><td>1.3</td></tr><tr><td>k =128 (pretrained) VS k = 128 (pretrained only with LM)</td><td>35.1</td><td>24.9</td><td>40.0</td><td>1.4</td></tr><tr><td>k = 128 (pretrained) VS 128-token summary (by GPT-4)</td><td>34.1</td><td>17.6</td><td>48.3</td><td>1.9</td></tr></table>",
355
+ "page_idx": 6
356
+ },
357
+ {
358
+ "type": "text",
359
+ "text": "",
360
+ "page_idx": 6
361
+ },
362
+ {
363
+ "type": "text",
364
+ "text": "The last row of Table 5 compares ICAE’s 128-length memory slots with a summary4 within 128 tokens ( $\\mathord { \\sim } 1 0 0$ words). Memory slots significantly outperform summaries under the same context length, with ${ \\sim } 2 \\times$ win/lose ratio, proving to be more compact and informative than natural language. ",
365
+ "page_idx": 6
366
+ },
367
+ {
368
+ "type": "text",
369
+ "text": "3.3 ANALYSIS ",
370
+ "text_level": 1,
371
+ "page_idx": 6
372
+ },
373
+ {
374
+ "type": "text",
375
+ "text": "3.3.1 SCALABILITY ",
376
+ "text_level": 1,
377
+ "page_idx": 6
378
+ },
379
+ {
380
+ "type": "text",
381
+ "text": "As discussed above, ICAE should achieve better compression performance with a more powerful target LLM. To verify this assumption, we compare the ICAE’s performance on three target LLMs: Llama-7b, Llama-2-7b and Llama-2-13b in Table 6, which align well with our expectations – more powerful target LLMs can achieve better context compression ratios. ",
382
+ "page_idx": 6
383
+ },
384
+ {
385
+ "type": "text",
386
+ "text": "3.3.2 LATENCY ",
387
+ "text_level": 1,
388
+ "page_idx": 6
389
+ },
390
+ {
391
+ "type": "text",
392
+ "text": "We conducted an empirical test to evaluate the impact of ICAE’s $4 \\times$ context compression on inference efficiency. For this efficiency test, we fix the context (i.e., input) length to either 512 or 2048 and the generation length to 128. Table 7 shows that context compression by ICAE is helpful to improve LLM (i.e., Llama-7b) inference efficiency, achieving over $2 \\times$ speedup. Its acceleration becomes even more significant – around $3 . 5 \\times$ – in compute-intensive scenarios (e.g., $8 \\times 2 0 4 8$ and $3 2 \\times 5 1 2$ ). Given that the compressed memory slots can be cached in advance (for frequently used texts like textbooks, government reports or articles of law), ICAE may introduce over $7 \\times$ inference speedup in these cases. Details of the profiling are presented in Appendix B. ",
393
+ "page_idx": 6
394
+ },
395
+ {
396
+ "type": "table",
397
+ "img_path": "images/50265225e0cea75b72fd9835b5c2328daa8330d16d827a5a6c2d48fc39d7ef2f.jpg",
398
+ "table_caption": [
399
+ "Table 6: The results of pretrained ICAE $( 5 1 2 1 2 8 $ ) based on different target LLMs "
400
+ ],
401
+ "table_footnote": [],
402
+ "table_body": "<table><tr><td rowspan=\"2\">Target LLM</td><td colspan=\"2\"></td><td colspan=\"2\"></td><td></td></tr><tr><td>BLEU(E</td><td>Loss</td><td></td><td></td><td>△</td></tr><tr><td>Llama-7b</td><td>99.1</td><td>0.017</td><td>9.01</td><td>9.50</td><td>+0.49</td></tr><tr><td>Llama-2-7b</td><td>99.5</td><td>0.009</td><td>8.81</td><td>9.18</td><td>+0.37</td></tr><tr><td>Llama-2-13b</td><td>99.8</td><td>0.004</td><td>8.15</td><td>8.45</td><td>+0.30</td></tr></table>",
403
+ "page_idx": 7
404
+ },
405
+ {
406
+ "type": "table",
407
+ "img_path": "images/b690efe014469a9b9c6e577ba0a9cb14cc47a503808d76360dee17f27e066fd8.jpg",
408
+ "table_caption": [
409
+ "Table 7: Latency comparison of LLM (generation) and LLM+ICAE (compression then generation) "
410
+ ],
411
+ "table_footnote": [],
412
+ "table_body": "<table><tr><td>(Batch×Length)</td><td>Method</td><td>Compession Time</td><td>Decoding</td><td>Total</td></tr><tr><td>8*2048</td><td>LLM+ICAE</td><td>3.4</td><td>24.0</td><td>7.324.3x)</td></tr><tr><td>8*512</td><td>LLM+MCAE</td><td>0.6</td><td></td><td>4.3(2.2x)</td></tr><tr><td>32*512</td><td>LLM+MCAE</td><td>2.6</td><td>24.3</td><td>6.824.x)</td></tr></table>",
413
+ "page_idx": 7
414
+ },
415
+ {
416
+ "type": "text",
417
+ "text": "",
418
+ "page_idx": 7
419
+ },
420
+ {
421
+ "type": "text",
422
+ "text": "3.3.3 MULTIPLE SPANS OF MEMORY SLOTS ",
423
+ "text_level": 1,
424
+ "page_idx": 7
425
+ },
426
+ {
427
+ "type": "text",
428
+ "text": "Thus far, we have mainly discussed a single span of memory slots. In this section, we shall discuss multiple spans of memory slots. As illustrated in Figure 6(Left), we can segment a long context into $N$ chunks, compress them individually, and then concatenate them to represent the original long context. However, this did not work initially, because the model had never seen multiple span concatenation patterns during training. Fortunately, we can incorporate a small number of multiple span concatenation samples during training, enabling the model to work with concatenated spans of memory slots, as OpenAI’s work (Bavarian et al., 2022) on introducing the “fill in the middle” ability for the GPT. The results in Figure 6(Right) indicate that, using an equivalent length context, ICAE’s memory achieves better performance – because memory can represent $4 \\times$ the original context length. ",
429
+ "page_idx": 7
430
+ },
431
+ {
432
+ "type": "text",
433
+ "text": "The ability of ICAE demonstrates great promise to handle long contexts, as it can save a significant amount of GPU memory when addressing long contexts without touching the existing LLM. As illustrated in Figure 6(Right), 2048-length memory slots can perform on par with 4096-token contexts. This means that conditioning on 2048 memory slots instead of the original 4096 context tokens can save about 20GB of GPU memory5 with minimal quality degradation. ",
434
+ "page_idx": 7
435
+ },
436
+ {
437
+ "type": "text",
438
+ "text": "4 RELATED WORK ",
439
+ "text_level": 1,
440
+ "page_idx": 7
441
+ },
442
+ {
443
+ "type": "text",
444
+ "text": "Prompt compression and context distillation (Askell et al., 2021; Snell et al., 2022) are closely related areas to this work: Wingate et al. (2022) proposed a method to learn compact soft prompts to simulate the original natural language prompt by optimizing the KL divergence. However, this approach has a very high computational cost, as it requires performing back-propagation for each new incoming prompt to learn and obtain the compressed prompt, which severely limits its application. Qin & Van Durme (2023) propose Neural Agglomerative Embeddings named NUGGET, which encodes language into a compact representation for an encoder-decoder model. ",
445
+ "page_idx": 7
446
+ },
447
+ {
448
+ "type": "text",
449
+ "text": "The most closely related studies to our research are GIST (Mu et al., 2023) and AutoCompressors (Chevalier et al., 2023). GIST achieves prompt compression by fine-tuning an LLM in a similar way to ours. The resulting model can produce gist tokens as the compression of a prompt, which are similar to our memory slots. Nonetheless, this approach is limited to compressing short prompts6 and thus does not address the real issue of long contexts. Also, this method requires fine-tuning the LLM, and the obtained gist tokens also need to be used within the specially tuned LLM (for gist tokens) and seem not compatible with the untouched LLM. AutoCompressors for recursively compressing long text into summary vectors. Like Mu et al. (2023), the LLM must be tuned to work with generated summary vectors and its training is sophisticated as it involves recursive compression. In contrast, we propose a very simple, straightforward and scalable approach to generating memory slots that can be used in the target LLM with different prompts for various purposes. Moreover, our approach is much more parameter-efficient (i.e., LoRA) for tuning on top of the existing LLM. Additionally, some recent work studies how to compress prompts into more concise natural language (Jiang et al., 2023a), and approaches the context limit with divide-and-conquer methodology (Bertsch et al., 2023; Chen et al., 2023; Song et al., 2024). ",
450
+ "page_idx": 7
451
+ },
452
+ {
453
+ "type": "image",
454
+ "img_path": "images/296866e98ea06089212b07bee450b99be3be01b6f8e2be777f25a72c4fcdebe8.jpg",
455
+ "image_caption": [
456
+ "Figure 6: Left: Individually compress then concatenate multiple spans of memory slots; Right: Perplexity comparison with original contexts and $4 \\times$ compressed memory slots – for example, 1024- length memory slots are obtained by compressing the original context with a length of 4096 tokens. "
457
+ ],
458
+ "image_footnote": [],
459
+ "page_idx": 8
460
+ },
461
+ {
462
+ "type": "text",
463
+ "text": "",
464
+ "page_idx": 8
465
+ },
466
+ {
467
+ "type": "text",
468
+ "text": "Also, there is related work studying compressing indescribable concepts into (vector) tokens for later use in other contexts. Representative work includes Gal et al. (2022) which compresses a vision object into a token and Ge et al. (2023) which compresses a text style into a token. ",
469
+ "page_idx": 8
470
+ },
471
+ {
472
+ "type": "text",
473
+ "text": "Considering related work from a boarder perspective of compression, Jiang et al. (2023b) examines kNN-based prediction using general-purpose compressors, such as gzip. Delétang et al. (2023) extensively investigates the compression abilities of LLMs, uncovering their potential as versatile predictors, which also provides insights into recent developments in scaling laws and tokenization. ",
474
+ "page_idx": 8
475
+ },
476
+ {
477
+ "type": "text",
478
+ "text": "5 CONCLUSION AND FUTURE WORK ",
479
+ "text_level": 1,
480
+ "page_idx": 8
481
+ },
482
+ {
483
+ "type": "text",
484
+ "text": "We propose the In-context Autoencoder (ICAE) to leverage the power of an LLM to highly compress contexts. By generating compact and informative memory slots to represent the original context, the ICAE enables an LLM to acquire more information with the same context length or represent the same content with a shorter context, thereby enhancing the model’s capability to handle long contexts as well as reducing computation and memory overheads for inference in many practical scenarios like Retrieval Augmented Generation (Lewis et al., 2020) and advanced prompting methods (Wei et al., 2022; Wang et al., 2023; Zhang et al., 2024). Moreover, ICAE provides insight into how an LLM performs memorization, offering a novel perspective on the connection between the memory of LLMs and humans, and suggesting future research in LLM context management. ",
485
+ "page_idx": 8
486
+ },
487
+ {
488
+ "type": "text",
489
+ "text": "Due to computational limitations, our experiments were conducted on Llama models up to 13 billion parameters. As discussed in the paper, ICAE is expected to benefit even more from more powerful LLMs, where it should be able to achieve more significant compression ratios. In the future, we hope to have sufficient computational resources to validate the effectiveness of ICAE on larger and stronger LLMs. In addition, we plan to explore the application of ICAE in multimodal LLMs (as the context length for images, videos, and audio is often much longer and has greater compression potential) with discrete memory slots (which can be either continuous or discrete) for helping unify compact representation across modalities in the era of LLM/AGI. ",
490
+ "page_idx": 8
491
+ },
492
+ {
493
+ "type": "text",
494
+ "text": "REFERENCES \nAmanda Askell, Yuntao Bai, Anna Chen, Dawn Drain, Deep Ganguli, Tom Henighan, Andy Jones, Nicholas Joseph, Ben Mann, Nova DasSarma, et al. A general language assistant as a laboratory for alignment. arXiv preprint arXiv:2112.00861, 2021. \nAlan Baddeley. Working memory. Science, 255(5044):556–559, 1992. \nMohammad Bavarian, Heewoo Jun, Nikolas Tezak, John Schulman, Christine McLeavey, Jerry Tworek, and Mark Chen. Efficient training of language models to fill in the middle. arXiv preprint arXiv:2207.14255, 2022. \nIz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020. \nAmanda Bertsch, Uri Alon, Graham Neubig, and Matthew Gormley. Unlimiformer: Long-range transformers with unlimited length input. Advances in Neural Information Processing Systems, 36, 2023. \nAydar Bulatov, Yury Kuratov, and Mikhail Burtsev. Recurrent memory transformer. Advances in Neural Information Processing Systems, 35:11079–11091, 2022. \nAydar Bulatov, Yuri Kuratov, and Mikhail S Burtsev. Scaling transformer to 1m tokens and beyond with rmt. arXiv preprint arXiv:2304.11062, 2023. \nHoward Chen, Ramakanth Pasunuru, Jason Weston, and Asli Celikyilmaz. Walking down the memory maze: Beyond context limit through interactive reading. arXiv preprint arXiv:2310.05029, 2023. \nAlexis Chevalier, Alexander Wettig, Anirudh Ajith, and Danqi Chen. Adapting language models to compress contexts. arXiv preprint arXiv:2305.14788, 2023. \nRewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019. \nKrzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamás Sarlós, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy J. Colwell, and Adrian Weller. Rethinking attention with performers. ArXiv, abs/2009.14794, 2020. \nGrégoire Delétang, Anian Ruoss, Paul-Ambroise Duquenne, Elliot Catt, Tim Genewein, Christopher Mattern, Jordi Grau-Moya, Li Kevin Wenliang, Matthew Aitchison, Laurent Orseau, et al. Language modeling is compression. arXiv preprint arXiv:2309.10668, 2023. \nJiayu Ding, Shuming Ma, Li Dong, Xingxing Zhang, Shaohan Huang, Wenhui Wang, and Furu Wei. Longnet: Scaling transformers to 1,000,000,000 tokens. arXiv preprint arXiv:2307.02486, 2023. \nRandall W Engle, Stephen W Tuholski, James E Laughlin, and Andrew RA Conway. Working memory, short-term memory, and general fluid intelligence: a latent-variable approach. Journal of experimental psychology: General, 128(3):309, 1999. \nK Anders Ericsson, William G Chase, and Steve Faloon. Acquisition of a memory skill. Science, 208 (4448):1181–1182, 1980. \nRinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618, 2022. \nLeo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, Shawn Presser, and Connor Leahy. The Pile: An 800gb dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020. \nTao Ge, Hu Jing, Li Dong, Shaoguang Mao, Yan Xia, Xun Wang, Si-Qing Chen, and Furu Wei. Extensible prompts for language models on zero-shot language style customization. In A. Oh, T. Neumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine (eds.), Advances in Neural Information Processing Systems, volume 36, pp. 35576–35591. Curran Associates, Inc., 2023. URL https://proceedings.neurips.cc/paper_files/paper/ 2023/file/6fcbfb3721c1781728b10c6685cc2f6c-Paper-Conference.pdf. ",
495
+ "page_idx": 9
496
+ },
497
+ {
498
+ "type": "text",
499
+ "text": "Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021. ",
500
+ "page_idx": 10
501
+ },
502
+ {
503
+ "type": "text",
504
+ "text": "Huiqiang Jiang, Qianhui Wu, Chin-Yew Lin, Yuqing Yang, and Lili Qiu. Llmlingua: Compressing prompts for accelerated inference of large language models. arXiv preprint arXiv:2310.05736, 2023a. \nZhiying Jiang, Matthew Yang, Mikhail Tsirlin, Raphael Tang, Yiqin Dai, and Jimmy Lin. “lowresource” text classification: A parameter-free classification method with compressors. In Findings of the Association for Computational Linguistics: ACL 2023, pp. 6810–6828, 2023b. \nMark A. Kramer. Nonlinear principal component analysis using autoassociative neural networks. Aiche Journal, 37:233–243, 1991. \nPatrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in Neural Information Processing Systems, 33: 9459–9474, 2020. \nNelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. Lost in the middle: How language models use long contexts, 2023. \nEleanor A Maguire, Elizabeth R Valentine, John M Wilding, and Narinder Kapur. Routes to remembering: the brains behind superior memory. Nature neuroscience, 6(1):90–95, 2003. \nJesse Mu, Xiang Lisa Li, and Noah Goodman. Learning to compress prompts with gist tokens. arXiv preprint arXiv:2304.08467, 2023. \nOpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023. \nLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35: 27730–27744, 2022. \nKishore Papineni, Salim Roukos, Todd Ward, and Wei Jing Zhu. Bleu: a method for automatic evaluation of machine translation. 10 2002. doi: 10.3115/1073083.1073135. \nGuangyue Peng, Tao Ge, Si-Qing Chen, Furu Wei, and Houfeng Wang. Semiparametric language models are scalable continual learners. arXiv preprint arXiv:2303.01421, 2023. \nGuanghui Qin and Benjamin Van Durme. Nugget: Neural agglomerative embeddings of text. In Andreas Krause, Emma Brunskill, Kyunghyun Cho, Barbara Engelhardt, Sivan Sabato, and Jonathan Scarlett (eds.), Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pp. 28337–28350. PMLR, 23–29 Jul 2023. URL https://proceedings.mlr.press/v202/qin23a.html. \nJack W Rae, Anna Potapenko, Siddhant M Jayakumar, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019. \nCharlie Snell, Dan Klein, and Ruiqi Zhong. Learning by distilling context. arXiv preprint arXiv:2209.15189, 2022. \nWoomin Song, Seunghyuk Oh, Sangwoo Mo, Jaehyung Kim, Sukmin Yun, Jung-Woo Ha, and Jinwoo Shin. Hierarchical context merging: Better long context understanding for pre-trained llms. In The Twelfth International Conference on Learning Representations, 2024. \nHugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aur’elien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and efficient foundation language models. ArXiv, abs/2302.13971, 2023a. \nHugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023b. \nAshish 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. \nYizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A Smith, Daniel Khashabi, and Hannaneh Hajishirzi. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022. \nZhenhailong Wang, Shaoguang Mao, Wenshan Wu, Tao Ge, Furu Wei, and Heng Ji. Unleashing the emergent cognitive synergy in large language models: A task-solving agent through multi-persona self-collaboration. arXiv preprint arXiv:2307.05300, 2023. \nJason Wei, Maarten Bosma, Vincent Y Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M Dai, and Quoc V Le. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652, 2021. \nJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems, 35:24824–24837, 2022. \nDavid Wingate, Mohammad Shoeybi, and Taylor Sorensen. Prompt compression and contrastive conditioning for controllability and toxicity reduction in language models. arXiv preprint arXiv:2210.03162, 2022. \nYuhuai Wu, Markus N Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. arXiv preprint arXiv:2203.08913, 2022. \nYadong Zhang, Shaoguang Mao, Tao Ge, Xun Wang, Yan Xia, Man Lan, and Furu Wei. K-level reasoning with large language models. arXiv preprint arXiv:2402.01521, 2024. \nHao Zhao, Maksym Andriushchenko, Francesco Croce, and Nicolas Flammarion. Long is more for alignment: A simple but tough-to-beat baseline for instruction fine-tuning. arXiv preprint arXiv:2402.04833, 2024. \nLin Zheng, Chong Wang, and Lingpeng Kong. Linear complexity randomized self-attention mechanism. In International Conference on Machine Learning, 2022. ",
505
+ "page_idx": 10
506
+ },
507
+ {
508
+ "type": "text",
509
+ "text": "",
510
+ "page_idx": 11
511
+ },
512
+ {
513
+ "type": "text",
514
+ "text": "A MODEL TRAINING CONFIGURATION ",
515
+ "text_level": 1,
516
+ "page_idx": 11
517
+ },
518
+ {
519
+ "type": "text",
520
+ "text": "We show how to perform pretraining with the text continuation objective and instruction fine-tuning in Figure 7 and 8. ",
521
+ "page_idx": 11
522
+ },
523
+ {
524
+ "type": "text",
525
+ "text": "We train the ICAE on 8 Nvidia A100 GPUs (80GB). The hyperparameters for pretraining and fine-tuning ICAE are presented in Table 8. We by default train the ICAE with bf16. ",
526
+ "page_idx": 11
527
+ },
528
+ {
529
+ "type": "table",
530
+ "img_path": "images/c6b9885fa01a53c8b5874e62ae5ea0c0ece297617ea839001519d0b79e87e6d7.jpg",
531
+ "table_caption": [
532
+ "Table 8: Hyperparameters for training "
533
+ ],
534
+ "table_footnote": [],
535
+ "table_body": "<table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW</td></tr><tr><td>learning rate</td><td>le-4 (pretrain); 5e-5 (fine-tuning)</td></tr><tr><td>batch size</td><td>256</td></tr><tr><td>warmup</td><td>300</td></tr><tr><td>#updates</td><td>200k (pretrain); 30k (fine-tuning)</td></tr><tr><td>clip norm</td><td>2.0</td></tr></table>",
536
+ "page_idx": 11
537
+ },
538
+ {
539
+ "type": "image",
540
+ "img_path": "images/6e85d8489c2b12f4199051d95a0898aebaf79a7905c198f88676e0ae38ebe4c3.jpg",
541
+ "image_caption": [
542
+ "Figure 7: Pretraining with the text continuation objective to predict next tokens "
543
+ ],
544
+ "image_footnote": [],
545
+ "page_idx": 12
546
+ },
547
+ {
548
+ "type": "image",
549
+ "img_path": "images/2ed2ab058cf5c5af8b6bc7fbc10ebd6a570048bb2211989afa5e0ee5ee738112.jpg",
550
+ "image_caption": [
551
+ "Figure 8: Instruct fine-tuning of the ICAE to make its produced memory slots interact with prompts for accomplishing various purposes in the target LLM. In this figure, $\\left( p _ { 1 } , \\ldots , p _ { m } \\right)$ denotes the prompt tokens and $( r _ { 1 } , \\ldots , r _ { n } )$ denotes the response tokens. "
552
+ ],
553
+ "image_footnote": [],
554
+ "page_idx": 12
555
+ },
556
+ {
557
+ "type": "text",
558
+ "text": "B PROFILING SETUP ",
559
+ "text_level": 1,
560
+ "page_idx": 12
561
+ },
562
+ {
563
+ "type": "text",
564
+ "text": "We test the latency (Section 3.3.2) on 1 Nvidia A100 GPU (80GB). The test machine has the CPU of AMD EPYC™ 7413 with 24 cores and 216GB RAM. The runtime configuration is python $\\mathord { \\left. \\vert \\right.} = 3 . 9 $ , pytorch $\\phantom { - } 1 { = } 2 . 0 . 1$ , cuda $= 1 1 . 7$ , cudnn $= 8 . 5$ . ",
565
+ "page_idx": 12
566
+ },
567
+ {
568
+ "type": "text",
569
+ "text": "C PROMPT-WITH-CONTEXT DATASET",
570
+ "text_level": 1,
571
+ "page_idx": 12
572
+ },
573
+ {
574
+ "type": "text",
575
+ "text": "We introduce the PROMPT-WITH-CONTEXT (PWC) dataset where each sample entry is a triple (text, prompt, answer), as depicted in Figure 9. To construct this dataset, we first sample $2 0 \\mathrm { k }$ texts from the Pile dataset. Then, for each text, we employ the GPT-4 to provide 15 prompts (10 specific prompts and 5 general prompts) about the text and give the corresponding answers. The prompt instructing the GPT-4 is outlined in Listing 1. ",
576
+ "page_idx": 12
577
+ },
578
+ {
579
+ "type": "text",
580
+ "text": "The dataset is composed of 240k examples for training purposes, with an additional 18k examples for testing. The context length distribution of test samples is presented in Table 10. ",
581
+ "page_idx": 12
582
+ },
583
+ {
584
+ "type": "text",
585
+ "text": "Listing 1: Prompt used by GPT4 API to generate the PWC dataset. ",
586
+ "text_level": 1,
587
+ "page_idx": 12
588
+ },
589
+ {
590
+ "type": "text",
591
+ "text": "Design 10 prompts specified to the above text to test understanding of the above text. These prompts should be diverse and cover as many ",
592
+ "page_idx": 12
593
+ },
594
+ {
595
+ "type": "text",
596
+ "text": "Context ",
597
+ "text_level": 1,
598
+ "page_idx": 13
599
+ },
600
+ {
601
+ "type": "image",
602
+ "img_path": "images/53a30a2591bfdb0a7a5d1f2bd1af52f9ed36bb01a27be506cd7e68c149d65fd3.jpg",
603
+ "image_caption": [
604
+ "Figure 9: Construction of the PWC dataset: we use the GPT-4 to generate a variety of prompt-answer pairs according to contexts. The resulting dataset is used for instruction fine-tuning (240k for training) and evaluation (18k for testing) in this work. "
605
+ ],
606
+ "image_footnote": [],
607
+ "page_idx": 13
608
+ },
609
+ {
610
+ "type": "text",
611
+ "text": "aspects (e.g., topic, genre, structure, style, polarity, key information and details) of the text as possible. The first half of these prompts should be like an instruction, the other should be like a question. In addition to the prompts specified to the above text, please also design 5 general prompts like \"rephrase the above text\", \"summarize the above text\", \"write a title for the above text\", \"extract a few keywords for the above text\" and \"write a paragraph (i.e., continuation) that follows the above text\". Each prompt should be outputted in the following format: [{\"prompt\": your generated prompt, \"answer\": the answer to the prompt}] ",
612
+ "page_idx": 13
613
+ },
614
+ {
615
+ "type": "text",
616
+ "text": "D GPT-4 EVALUATION ",
617
+ "text_level": 1,
618
+ "page_idx": 13
619
+ },
620
+ {
621
+ "type": "text",
622
+ "text": "According to Mu et al. (2023), we formulate an evaluation prompt to be used with the GPT-4 API. The prompt, as illustrated in Listing 2, consists of a task description along with three specific examples. We supply GPT-4 with a text, a prompt, and two distinct model-generated responses. The task for GPT-4 is to determine the superior answer or recognize a tie. The chosen examples encompass scenarios where Assistant A performs better, Assistant B performs better, and when a tie occurs. This methodology enables us to effectively assess7 the model’s quality. Specially, the orders where the model responses are presented to the GPT-4 are swapped randomly to alleviate bias, as Touvron et al. (2023b) did. ",
623
+ "page_idx": 13
624
+ },
625
+ {
626
+ "type": "text",
627
+ "text": "Listing 2: Prompt for the GPT-4 evaluation. This prompt consists of a description of the task and three specific examples. ",
628
+ "page_idx": 13
629
+ },
630
+ {
631
+ "type": "text",
632
+ "text": "Given a piece of text, an instruction for this text, and two AI assistant answers, your task is to choose the better answer and provide reasons. Evaluate the answers holistically, paying special attention to whether the response (1) follows the given instruction and (2) is correct. If both answers correctly respond to the prompt, you should judge it as a tie. ",
633
+ "page_idx": 13
634
+ },
635
+ {
636
+ "type": "image",
637
+ "img_path": "images/6698bdf35645699989fb23bb6524130a51e51e61c4147c88cadbc8f7a2ad4bd5.jpg",
638
+ "image_caption": [
639
+ "Figure 10: The context length distribution of test samples: Most samples are longer than 500 tokens. "
640
+ ],
641
+ "image_footnote": [],
642
+ "page_idx": 14
643
+ },
644
+ {
645
+ "type": "text",
646
+ "text": "",
647
+ "page_idx": 14
648
+ },
649
+ {
650
+ "type": "text",
651
+ "text": "Example 1: 11 ",
652
+ "page_idx": 14
653
+ },
654
+ {
655
+ "type": "text",
656
+ "text": "Text: We report the development of GPT-4, a large-scale, multimodal model which can accept image and text inputs and produce text outputs. While less capable than humans in many real-world scenarios, GPT-4 exhibits human-level performance on various professional and academic benchmarks, including passing a simulated bar exam with a score around the top $10 \\%$ of test takers. GPT-4 is a Transformerbased model pre-trained to predict the next token in a document. The post-training alignment process results in improved performance on measures of factuality and adherence to desired behavior. A core component of this project was developing infrastructure and optimization methods that behave predictably across a wide range of scales. This allowed us to accurately predict some aspects of GPT-4’s performance based on models trained with no more than 1/1,000th the compute of GPT-4. ",
657
+ "page_idx": 14
658
+ },
659
+ {
660
+ "type": "text",
661
+ "text": "Prompt: What is GPT4? ",
662
+ "page_idx": 14
663
+ },
664
+ {
665
+ "type": "text",
666
+ "text": "Assistant A: GPT4 is a large-scale language-trained transformer-based model. ",
667
+ "page_idx": 14
668
+ },
669
+ {
670
+ "type": "text",
671
+ "text": "Assistant B: GPT4 can produce outputs. ‘‘‘ ",
672
+ "page_idx": 14
673
+ },
674
+ {
675
+ "type": "text",
676
+ "text": "Your output should be: ",
677
+ "page_idx": 14
678
+ },
679
+ {
680
+ "type": "text",
681
+ "text": "{\"reason\": \"The instruction asks what GPT4 is, and from the original \ntext, we know that GPT4 is a multimodal, large-scale model that can \ngenerate text. Therefore, Assistant A is the closer answer, while \nAssistant B did not follow the instruction well in providing a \nresponse.\", \"choice\": \"A\"} \n111 ",
682
+ "page_idx": 14
683
+ },
684
+ {
685
+ "type": "text",
686
+ "text": "Example 2: ‘‘‘ ",
687
+ "page_idx": 14
688
+ },
689
+ {
690
+ "type": "text",
691
+ "text": "Text: Making language models bigger does not inherently make them better at following a user’s intent. For example, large language models can generate outputs that are untruthful, toxic, or simply not helpful to the user. In other words, these models are not aligned with their users. ",
692
+ "page_idx": 14
693
+ },
694
+ {
695
+ "type": "text",
696
+ "text": "In this paper, we show an avenue for aligning language models with user intent on a wide range of tasks by fine-tuning with human feedback. Starting with a set of labeler-written prompts and prompts submitted through the OpenAI API, we collect a dataset of labeler demonstrations of the desired model behavior, which we use to fine-tune GPT-3 using supervised learning. We then collect a dataset of rankings of model outputs, which we use to further fine-tune this supervised model using reinforcement learning from human feedback. We call the resulting models InstructGPT. In human evaluations on our prompt distribution, outputs from the 1.3B parameter InstructGPT model are preferred to outputs from the 175B GPT-3, despite having $\\boldsymbol { \\perp 0 0 x }$ fewer parameters. Moreover, InstructGPT models show improvements in truthfulness and reductions in toxic output generation while having minimal performance regressions on public NLP datasets. Even though InstructGPT still makes simple mistakes, our results show that fine-tuning with human feedback is a promising direction for aligning language models with human intent. ",
697
+ "page_idx": 15
698
+ },
699
+ {
700
+ "type": "text",
701
+ "text": "Prompt: Write a title for the above text. ",
702
+ "page_idx": 15
703
+ },
704
+ {
705
+ "type": "text",
706
+ "text": "Assistant A: Improving Fine-Tuning for Language Models: A GPT-3-inspired \nApproach \nAssistant B: Training language models to follow instructions with human \nfeedback \n‘‘‘ ",
707
+ "page_idx": 15
708
+ },
709
+ {
710
+ "type": "text",
711
+ "text": "Your output should be: 11 ",
712
+ "page_idx": 15
713
+ },
714
+ {
715
+ "type": "text",
716
+ "text": "{\"reason\": \"This text discusses how to make large language models follow user instructions better, and Assistant B’s response is more in line with the meaning of the text.\", \"choice\": \"B\"} ",
717
+ "page_idx": 15
718
+ },
719
+ {
720
+ "type": "text",
721
+ "text": "Example 3: ‘‘‘ ",
722
+ "page_idx": 15
723
+ },
724
+ {
725
+ "type": "text",
726
+ "text": "Text: Though technology companies announced massive layoffs last year, 2023 has been much worse. Layoffs have far outpaced last year’s cuts, as tech giants including Amazon, Facebook parent company Meta, Microsoft, Google, IBM, SAP, and Salesforce - as well as many smaller companies - announce sweeping job cuts. The problem: Big Tech went on a hiring binge during the pandemic when lockdowns sparked a tech buying spree to support remote work and an uptick in e-commerce, and now they face revenue declines. Although global IT spending is forecast to rise in 2023, with enterprise software and IT services experiencing the greatest growth, the overall increase is expected to be modest, with data center systems and communications services growing by less than 1%, according to market research firm Gartner. Meanwhile hardware sales are forecast to decline. Continuing supply chain issues, inflation, and the war in Ukraine are also having an impact on both business and consumer \nspending, leading to fears of recession. According to data compiled by Layoffs.fyi, the online tracker keeping tabs on job losses in the technology sector, 784 tech companies have laid off about 208,181 staff so far this year, compared to 164,411 layoffs last year. \nPrompt: How many job losses have occurred in the technology sector so far in 2023? \nAssistant A: 208,181 job losses have occurred in the technology sector so far in 2023. \nAssistant B: 208,181. \n‘‘‘ ",
727
+ "page_idx": 15
728
+ },
729
+ {
730
+ "type": "text",
731
+ "text": "Your output should be: 1 ",
732
+ "page_idx": 15
733
+ },
734
+ {
735
+ "type": "text",
736
+ "text": "{\"reason\": \"Both answers are acceptable and correct. They should be a tie.\", \"choice\": \"Tie\"} ",
737
+ "page_idx": 15
738
+ },
739
+ {
740
+ "type": "text",
741
+ "text": "Your response should only be in the JSON format above; THERE SHOULD BE NO OTHER CONTENT INCLUDED IN YOUR RESPONSE. Write the \"reason\" key before writing the \"choice\" key, so that you think step-by-step before making your decision. KEEP YOUR REASONING BRIEF. Again, don’t favor either A or B if they are both acceptable and correct -- judge a tie instead. ",
742
+ "page_idx": 15
743
+ },
744
+ {
745
+ "type": "text",
746
+ "text": "",
747
+ "page_idx": 16
748
+ },
749
+ {
750
+ "type": "text",
751
+ "text": "The prompt that the GPT-4 uses to generate 128-token summary is as follows: ",
752
+ "page_idx": 16
753
+ },
754
+ {
755
+ "type": "text",
756
+ "text": "“Write a summary for the above text. Your summary should not exceed 100 words but should include as much information of the original text as possible.” ",
757
+ "page_idx": 16
758
+ },
759
+ {
760
+ "type": "text",
761
+ "text": "We show examples of the GPT-4 evaluation on a pretrained and a non-pretrained ICAE in Table 9. ",
762
+ "page_idx": 16
763
+ },
764
+ {
765
+ "type": "text",
766
+ "text": "Passage 1 (514 tokens): ",
767
+ "text_level": 1,
768
+ "page_idx": 16
769
+ },
770
+ {
771
+ "type": "text",
772
+ "text": "French senior civil servant arrested on suspicion of spying for North Korea ",
773
+ "page_idx": 16
774
+ },
775
+ {
776
+ "type": "text",
777
+ "text": "November 27, 2018 by Joseph Fitsanakis ",
778
+ "page_idx": 16
779
+ },
780
+ {
781
+ "type": "table",
782
+ "img_path": "images/6fc9ca4ff293f69e85df3878d4cb301216c8837840f1234602cf3723756584cb.jpg",
783
+ "table_caption": [
784
+ "Table 9: Examples of outputs by the target LLM (i.e., Llama) conditioning on memory slots $k = 1 2 8$ ) produced by the pretrained and non-pretrained ICAE. The highlighted parts are not faithful to the context. "
785
+ ],
786
+ "table_footnote": [],
787
+ "table_body": "<table><tr><td>Prompt: What is the maximum prison sentence Quennedey could face if found guilty?</td></tr><tr><td>Assistant A (pretrained ICAE): Quennedey could face up to 3O years in prison if found guilty.</td></tr><tr><td> Assistant B (non-pretrained ICAE): Quennedey could face up to three years in prison if found guilty.</td></tr><tr><td>Answer (by the GPT-4): Up to 30 years.</td></tr><tr><td>GPT-4 evaluation: Asistant A correctly states the maximum prison sentence from the text, while Asstant B provides an incorrect number.</td></tr></table>",
788
+ "page_idx": 16
789
+ },
790
+ {
791
+ "type": "text",
792
+ "text": "A senior civil servant in the upper house of the French parliament has been arrested on suspicion of spying for North Korea, according to prosecutors. The news of the suspected spy’s arrest was first reported on Monday by Quotidien, a daily politics and culture show on the Monaco-based television channel TMC. The show cited “a judicial source in Paris” and said that France’s domestic security and counterintelligence agency, the General Directorate for Internal Security (DGSI), was in charge of the espionage case. ",
793
+ "page_idx": 16
794
+ },
795
+ {
796
+ "type": "text",
797
+ "text": "(omitted 233 words) ",
798
+ "text_level": 1,
799
+ "page_idx": 16
800
+ },
801
+ {
802
+ "type": "text",
803
+ "text": "The senior civil servant faces up to 30 years in prison if found guilty of espionage. ",
804
+ "page_idx": 16
805
+ },
806
+ {
807
+ "type": "text",
808
+ "text": "Passage 2 (506 tokens): ",
809
+ "text_level": 1,
810
+ "page_idx": 16
811
+ },
812
+ {
813
+ "type": "text",
814
+ "text": "With Red Hat, IBM to become the leading hybrid cloud provider Watch Now ",
815
+ "page_idx": 16
816
+ },
817
+ {
818
+ "type": "text",
819
+ "text": "After IBM acquired Red Hat, I suggested IBM paid $\\$ 34$ billion for the Linux power so it could become a hybrid-cloud power. With the news that Red Hat will acquire NooBaa, a hybrid-cloud, data-storage company, it’s become clearer than ever that the IBM-Red Hat deal is all about the hybrid cloud. ",
820
+ "page_idx": 16
821
+ },
822
+ {
823
+ "type": "text",
824
+ "text": "(omitted 208 words) ",
825
+ "text_level": 1,
826
+ "page_idx": 16
827
+ },
828
+ {
829
+ "type": "text",
830
+ "text": "As Ranga Rangachari, Red Hat’s vice president of Storage and Hyperconverged Infrastructure, said in a statement: ",
831
+ "page_idx": 16
832
+ },
833
+ {
834
+ "type": "text",
835
+ "text": "\"Data portability is a key imperative for organizations building and deploying cloud-native applications across private and multiple clouds. NooBaa’s technologies will augment our portfolio and strengthen our ability to meet the needs of developers in today’s hybrid and multicloud world. We are thrilled to welcome a technical team of nine to the Red Hat family as we work together to further solidify Red Hat as a leading provider of open hybrid-cloud technologies. ",
836
+ "page_idx": 16
837
+ },
838
+ {
839
+ "type": "table",
840
+ "img_path": "images/812bd0ee201ae9899a66490f6b6693084e246941e85be18ac78417b389aeaa1d.jpg",
841
+ "table_caption": [],
842
+ "table_footnote": [],
843
+ "table_body": "<table><tr><td>Prompt:Discuss the role of Ranga Rangachari in the context of the text</td></tr><tr><td>Assistant A (pretrained ICAE): Ranga Rangacharis the vice presidentof Storage and Hyperconverged Infrastructure at Red Hat.He is responsible forthecompany&#x27;sstorageand hyperconvergedoferings,and he welcomes the nine-member teamof technical experts from NoaBaa to join Red Hat as a part of the IBM acquisition.</td></tr><tr><td>Assistant B(non-pretrained ICAE): Ranga Rangachari is the CEOof Red Hat,and he is excited about the acquisition of NooBaa as itwillhelpRed Hatbecomealeaderinhybrid cloud management.He believes that NooBa’stechnology wil enableRed Hattoprovideasingle,comprehensive platformfor managing dataacross multipleclouds,andthatthis willbea significant differentiator for Red Hat in the market.</td></tr><tr><td>Answer(bythe GPT-4): Ranga Rangacharis the vice presidentofStorage and Hyperconverged Infrastructure atRed Hat.He madeastatementregardingtheacquisitionofNooBaa,highlighting theimportanceofdataportabilityintoday&#x27;shybridand multicloud worldand how NooBaa’stechnologies would strengthen Red Hat&#x27;sabilityto meet theneeds of developers.</td></tr><tr><td>GPT-4 evaluation: Assistant Acorectly identifies Ranga Rangachari’s role as the vice presidentof Storage and Hypercon- vergedInfrastructureatRed Hatadaccratelydescribes hisstatementabout theacquisitionof NooBaa.AsistantBincorectly states that Ranga Rangachari is the CEO of Red Hat.</td></tr></table>",
844
+ "page_idx": 16
845
+ }
846
+ ]
parse/test/uREj4ZuGJE/uREj4ZuGJE_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/uREj4ZuGJE/uREj4ZuGJE_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/v3XXtxWKi6/v3XXtxWKi6.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/v3XXtxWKi6/v3XXtxWKi6_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/v3XXtxWKi6/v3XXtxWKi6_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/v3XXtxWKi6/v3XXtxWKi6_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/xbjSwwrQOe/xbjSwwrQOe_model.json ADDED
The diff for this file is too large to render. See raw diff