ZHANGYUXUAN-zR commited on
Commit
cd6ab3a
·
verified ·
1 Parent(s): 440bb8d

Add files using upload-large-folder tool

Browse files
parse/test/6LNTSrJjBe/6LNTSrJjBe.md ADDED
@@ -0,0 +1,667 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LANGUAGE AGENT TREE SEARCH UNIFIES REASONING ACTING AND PLANNING IN LANGUAGE MODELS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ While large language models (LLMs) have demonstrated impressive performance on a range of decision-making tasks, they rely on simple acting processes and fall short of broad deployment as autonomous agents. We introduce LATS (Language Agent Tree Search), a general framework that synergizes the capabilities of LLMs in planning, acting, and reasoning. Drawing inspiration from Monte Carlo tree search commonly used in model-based reinforcement learning, LATS employs LLMs as agents, value functions, and optimizers, repurposing their latent strengths for enhanced decision-making. What is crucial in this method is the use of an environment for external feedback, which offers a more deliberate and adaptive problem-solving mechanism that moves beyond the limitations of existing techniques. Our experimental evaluation across diverse domains, such as programming, HotPotQA, and WebShop, illustrates the applicability of LATS for decision-making while maintaining competitive reasoning performance. In particular, LATS achieves $9 4 . 4 \%$ for programming on HumanEval with GPT-4 and an average score of 75.9 for web browsing on WebShop with GPT-3.5, demonstrating the effectiveness and generality of our method.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ General autonomous agents capable of reasoning and decision-making in a variety of environments (Wooldridge & Jennings, 1995) have been of longstanding interest in the field of artificial intelligence. While this has traditionally been studied in reinforcement learning, the recent rise of large language models (LLMs) (Brown et al., 2020; Chowdhery et al., 2022; Touvron et al., 2023; OpenAI, 2023) with strong reasoning and general adaptability offers an alternative paradigm. Not only have LLMs excelled on standard NLP tasks such as text summarization (Nallapati et al., 2016) or natural language inference (Bowman et al., 2015), but they have been adapted to an increasingly diverse set of tasks that often require advanced common-sense reasoning or quantitative skills (Cobbe et al., 2021; Saparov & He, 2022). LLMs are also capable of performing in complex environments that involve knowledge and reasoning, such as web navigation (Yao et al., 2022; Deng et al., 2023), tool-use (Schick et al., 2023), or open-ended games (Fan et al., 2022).
12
+
13
+ Reasoning and acting abilities have also been improved by prompting techniques that augment LLMs with feedback or observations from an external environment (Yao et al., 2023b; Gao et al., 2022; Shinn et al., 2023). This eliminates the need to rely entirely on the base abilities of the Language Model (LM), enhancing it through external tools or semantic feedback. Despite this strength, these methods are reflexive and fall short of humans’ deliberate and thoughtful decision-making characteristics to solve problems (Sloman, 1996; Evans, 2010). In particular, such methods fail to consider multiple reasoning paths or to plan ahead. Recent search-guided LLM works (Xie et al., 2023; Yao et al., 2023a; Hao et al., 2023) address this
14
+
15
+ ![](images/c8a3617eb40fd2724fa3c553184a8cf017742b2ec23e0636bfa2b489c857c70e.jpg)
16
+ Figure 1: An overview of LATS. LATS uses an external environment and self-reflection to improve reasoning and decision-making. Prior states, values, and reflections are stored in external memory.
17
+
18
+ <table><tr><td>Approach</td><td>Reasoning</td><td>Acting</td><td> Planning</td><td>Self Reflection</td><td>External Memory</td></tr><tr><td>CoT (Wei et al., 2022)</td><td>√</td><td></td><td></td><td></td><td></td></tr><tr><td>ReAct (Yao et al., 2023b)</td><td>√</td><td></td><td></td><td></td><td></td></tr><tr><td>ToT (Yao et al., 2023a)</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RAP (Hao et al., 2023)</td><td></td><td></td><td>x×/√</td><td>××√×</td><td>××/√&gt;</td></tr><tr><td>Self-Refine (Madaan et al., 2023)</td><td></td><td></td><td></td><td>√</td><td>×</td></tr><tr><td>Beam Search (Xie et al., 2023)</td><td></td><td></td><td></td><td>√</td><td></td></tr><tr><td>Reflexion (Shinn et al.,2023)</td><td></td><td>x/××××/</td><td>×××</td><td></td><td>×√</td></tr><tr><td>LATS (Ours)</td><td></td><td>√</td><td>J</td><td></td><td>√</td></tr></table>
19
+
20
+ Table 1: A summary of related work on reasoning, acting, and planning. LATS is the first work incorporating designs from all three domains, allowing use in all corresponding tasks.We refer to planning as the use of a search algorithm, self-reflection as the use of LM-generated feedback, and external memory as storaging past text context for future updates of solution.
21
+
22
+ issue by searching over multiple reasoning chains. While these methods enable planning, these methods operate in isolation and do not incorporate external feedback that can improve reasoning.
23
+
24
+ To help address these issues, we propose LATS (Language Agent Tree Search), a general framework for decision-making and reasoning with language models. LATS unifies LM planning, acting, and reasoning strategies by expanding ReAct (Yao et al., 2023b) into a search over a combinatorial space of possible reasoning and acting steps. We adapt Monte Carlo tree search (MCTS) from model-based reinforcement learning (Silver et al., 2017; Anthony et al., 2017; Jiang et al., 2018) to language agents, repurposing a pretrained LLM as an agent, value function, and optimizer. Utilizing the strong natural language understanding and in-context learning ability of modern LMs, we use text as an interface between each component of the framework, allowing LATS to adapt planning to environmental conditions without additional training. To the best of our knowledge, LATS is the first framework that combines reasoning, acting, and planning to enhance LLMs. Notably, LATS doubles the performance of GPT-3.5 on HotPotQA (Yang et al., 2018) over ReAct (Yao et al., 2023b) and raises the average score by 22.1 on WebShop (Yao et al., 2022). When used with GPT-4, LATS achieves a $9 4 . 4 \ P a s s { @ 1 }$ rate for programming on HumanEval (Chen et al., 2021), setting the state of the art. To summarize, our contributions are the following:
25
+
26
+ • We introduce an LM-based Monte Carlo tree search variant to deliberately construct the best trajectory from sampled actions, enabling more flexible and adaptive problem-solving compared to reflexive prompting methods. This is guided by heuristics from the LM. • By integrating external feedback and self-reflection, LATS enhances model sensibility and enables agents to learn from experience, surpassing reasoning-based search methods. • Through experiments across diverse domains like programming, interactive QA, and web navigation, we demonstrate the versatility of LATS in harnessing LLMs for autonomous reasoning and decision-making.
27
+
28
+ # 2 RELATED WORK
29
+
30
+ LLMs for reasoning. For LLMs, reasoning typically involves decomposing complex inputs into sequential intermediate steps towards a final answer (Cobbe et al., 2021), demonstrated with Chainof-Thought (CoT) prompting (Wei et al., 2022) and its variants (Wei et al., 2022; Kojima et al., 2022; Wang et al., 2022). However, these methods, which create chains autoregressively in a single step, often suffer from error propagation as the number of steps increases (Guo et al., 2018; Chen et al., 2022b) due to compound errors. Various advancements aim to mitigate this issue; some approaches, such as Self-Consistency (Wang et al., 2022), employ majority voting over sampled chains, while others focus on multi-step decomposition, such as least-to-most prompting (Zhou et al., 2022), or use of external tools such as a scratchpad (Nye et al., 2021) or compiler (Gao et al., 2022). Recently, CoT has been improved with search algorithms (Yao et al., 2023a; Hao et al., 2023; Besta et al., 2023) that can sample trajectories more effectively. Tree-of-thought (ToT) prompting (Yao et al., 2023a) uses DFS or BFS-based search guided by an LM-generated heuristic while Reasoning via Planning (RAP) (Hao et al., 2023) uses MCTS with rollouts simulated by the LM. However, they rely solely on LM internal knowledge and cannot adapt to useful external feedback.
31
+
32
+ ![](images/0de2aad97f1ec5df982d6f27044420036089cfa58ef62dfb532fbbfb1ddc43c8.jpg)
33
+ Figure 2: An overview of the differences between LATS and recently proposed LM search algorithms ToT (Yao et al., 2023a) and RAP (Hao et al., 2023). LATS leverages environmental feedback and self-reflection to further adapt search and improve performance.
34
+
35
+ LLMs for acting. The strong reasoning and common-sense abilities of LLMs have also been adapted for decision-making or acting tasks as a policy model in interactive environments. In the realm of robotics LLMs have been employed as high-level controllers of control policies (Ahn et al., 2022; Huang et al., 2022; Driess et al., 2023). Similar work (Baker et al., 2022; Wang et al., 2023; Zhu et al., 2023) has also adapted LLM agents to complex multimodal games such as Minecraft (Guss et al., 2019; Fan et al., 2022). LLMs are particularly useful in text-based environments (Liu et al., 2018; Shridhar et al., 2020; Liu et al., 2023), where acting-based prompting techniques such as ReAct (Yao et al., 2023b) have seen success. Similar to CoT, ReAct is limited by its simplicity and cannot effectively adapt to environment conditions. Many extensions have been proposed to address this, including Self-refine (Madaan et al., 2023) and Reflexion (Shinn et al., 2023; Yao et al., 2023c), which uses self-reflection to enhance reasoning and decision-making, and AdaPlanner (Sun et al., 2023), which incorporates both positive and negative environmental feedback. However these methods focus on refining an individual plan or trajectory and do not consider alternative choices at each step. In addition, recent work (Huang et al., 2023) has suggested LLMs cannot self-correct their internal reasoning, making it critical to use external feedback. Alternatively to pure decisionmaking environments, the reasoning and practical abilities of LLMs have been enhanced by access to external tools, such as APIs, search engines, calculators, or other models (Schick et al., 2023; Shen et al., 2023; Sur´ıs et al., 2023). Contrary to reasoning-based approaches, these methods have not been improved with planning, limiting their effectiveness. We summarize them in Tab. 1.
36
+
37
+ Tree-based search. Tree-based search, where multiple branches of outcomes are explored during search, is widely used in many planning algorithms (Swiechowski et al. ´ , 2023; LaValle et al., 2001) and Reinforcement Learning (RL) (Hafner et al., 2019; Du et al., 2023; Wu et al., 2023) algorithms for its good exploration-exploitation trade-off. Though tree-based search requires an environment model that can expand from arbitrary state (Vodopivec et al., 2017), which often requires extra training in RL (Hafner et al., 2023), such problem does not exist for LM tasks as we can conveniently backup to any state by setting the input to be the context and corresponding previous output by the LM. Thus, we work on the tree-based framework and use MCTS (Swiechowski et al. ´ , 2023) to fully release the potential of LMs, while avoiding the cost of training a value function over language descriptions by leveraging the in-context learning (Brown et al., 2020) abilities of LLMs.
38
+
39
+ # 3 PRELIMINARIES
40
+
41
+ # 3.1 PROBLEM SETTING AND PROMPTING
42
+
43
+ Before describing LATS, we first define our problem and outline a few established methods that leverage large language models for reasoning or decision-making. In LM reasoning or decision making, we are given an input $x$ in natural language and a pretrained language model $p _ { \theta } ( x )$ parameterized by $\theta$ ; our goal is to generate a final output $y \sim p _ { \theta } ( x )$ corresponding to the answer (reasoning) or completes the task (decision-making). Both $x$ and $y$ are language sequences, which are comprised of a list of tokens (the basic elements of natural language, often words), denoted as $x = ( x [ 1 ] , \dot { \ldots } , x [ n ] )$ and $y = ( y [ 1 ] , \dots , y [ n ] )$ . The LM decodes text autoregressively, i.e., without other inputs, the probability for an LM to generate a sequence $x$ is given by $\begin{array} { r } { \overline { { p } } _ { \theta } ( x ) = \mathbf { \dot { \prod } } _ { i = 1 } ^ { n } p _ { \theta } ( x [ i ] | x [ 1 \ldots i - 1 ] ) } \end{array}$ . Usually, to improve the LM, prompts are provided along with the input $x$ , which are specific instructions or few-shot input-output examples. We denote the generic process where an input $x$ is transformed into an output $y$ by LM: $y \sim p _ { \boldsymbol \theta } ( y | _ { \mathrm { P } } \mathrm { r o m p t } _ { I O } ( x ) )$ , where prompt $_ { I O } ( x )$ denotes the input $x$ .
44
+
45
+ Chain-of-thought $\mathbf { ( C o T ) }$ Prompting (Wei et al., 2022) was introduced to cater to scenarios where direct mapping from $x$ to $y$ is intricate, such as when $x$ is from a mathematical query or challenging question. This method hinges on creating thoughts $z _ { 1 } , \ldots , z _ { n }$ that act as stepping stones between $x$ and $y$ ; each thought $z _ { i }$ is a language sequence. To employ CoT prompting, thoughts are extracted sequentially as $z _ { i } \sim p _ { \theta } ^ { C o T } ( z _ { i } | x , z _ { 1 } . . . _ { i - 1 } ) ^ { - }$ , with the final output being $y \overset { \cdot } { \sim } p _ { \theta } ^ { C o T } ( y | x , z _ { 1 } . . . n )$ .
46
+
47
+ Tree-of-thought (ToT) Prompting (Yao et al., 2023a) extends CoT prompting by exploring multiple reasoning paths over thoughts. It frames problems as a search over a tree where each node $s { \dot { = } } \left[ x , z _ { 1 \cdot i } \right]$ represents a partial solution state comprising the original input $x$ and thought sequence $z _ { 1 } . . . i$ . Thoughts $z _ { i }$ are generated by proposal or sampling with CoT $z _ { i } \stackrel { \bar { \sim } } { \sim } p _ { \theta } ^ { C o T } ( z _ { i } | x , z _ { 1 } . . . _ { i - 1 } \bar { ) }$ . Deliberate search algorithms like breadth-first or depth-first search are used to systematically explore the tree, guided by heuristics based on language model evaluations $V ( s )$ of each state.
48
+
49
+ Reasoning via Planning (RAP) (Hao et al., 2023) is similar to ToT, except that MCTS is used over DFS or BFS. Heuristics are designed from an LM, such as the likelihood or confidence of an action, and the LM is used as a world model to predict subsequent states during the simulation step.
50
+
51
+ ReAct (Yao et al., 2023b) extends language models to tasks where the mapping from $x$ to $y$ is enhanced by or requires interactions with an external environment, such as a game or API. This technique constructs an action space ${ \hat { A } } = A \cup Z$ that adds permissible actions $a$ to the reasoning traces $z$ from CoT. Observations $o$ from the environment are used to improve both reasoning and acting. To solve problems with ReAct, after each observation, actions are generated from $p _ { \theta }$ sequentially as $a _ { i } \sim p _ { \theta } ^ { R e \cdot A c t } ( a _ { i } | x , o _ { 1 \cdots i - 1 } , a _ { 1 \cdots i - 1 } )$ , with the final output being pReActθ (y | x, o1···n, a1···n).
52
+
53
+ While the previously described prompting techniques improve LM performance on reasoning tasks, they falter on difficult tasks that involve multifaceted decision-making due to several shortcomings: 1) Flexibility: Base prompting methods (CoT or ReAct) autoregressively sample from the LM, neglecting potential alternative continuations from specific states. 2) Sensibility: Reasoning-based methods (CoT, RAP, or ToT) rely solely on the internal representations of the LM and cannot consider external observations. This dependency risks fact hallucination and error propagation while setting a performance ceiling. 3) Adaptability: Current planning frameworks (RAP or ToT) use simple search algorithms such as BFS or cannot leverage environmental feedback to improve planning. Additionally, the agent is static and cannot reuse previous experience or learn from trial and error. While RAP also adopts MCTS, it is constrained to tasks where the LM can become a world model and accurately predict states. These shortcomings limit the ability of LMs to be deployed as general problem-solving agents and form the motivation for LATS.
54
+
55
+ # 3.2 MONTE-CARLO TREE SEARCH (MCTS)
56
+
57
+ Monte-Carlo Tree Search (MCTS) is a heuristic search algorithm that is proved successful on many decision-making environments such as Atari (Ye et al., 2021) and Go (Silver et al., 2016). MCTS builds a decision tree where every node in the tree is a state and edge is an action. MCTS runs for $\cdot$ episodes; for each episode, it starts from the root (i.e., initial state) and iteratively conducts two steps to expand the tree: 1) Expansion, where multiple children states $s$ are explored from the current parent state $\cdot$ by sampling $\cdot$ actions, and 2) Selection, where the children with the highest UCT (Upper Confidence bounds applied to Trees) (Kocsis & Szepesvari ´ , 2006) value is selected by the next iteration. The UCT of a child state $\cdot$ is calculated as follows:
58
+
59
+ $$
60
+ \cdot
61
+ $$
62
+
63
+ ![](images/2e8d5ec327cfd394a10021ac0fbf1f40c3b981dd4e625660420f84fe96251819.jpg)
64
+ Figure 3: An overview of the six operations of LATS. A node is selected, expanded, evaluated, then simulated until a terminal node is reached, then the resulting value is backpropagated. If the trajectory fails, a reflection is generated and used as additional context for future trials. These operations are performed in succession until the budget is reached or task is successful.
65
+
66
+ where $\cdot$ is the number of visits to a node $\cdot$ , $V ( s )$ is the value function (expected return) from the subtree of $\cdot$ , $\cdot$ is the exploration weight, and $\cdot$ is the parent node of $s$ . The child node with the highest UCT value is selected for expansion in the next iteration. When the end of an episode is reached, a backpropagation is carried out: the return $\cdot$ is used for updating every $V ( s )$ along the path with the formula $\begin{array} { r } { V ( s ) = \frac { V _ { \mathrm { o l d } } ( s ) ( N ( s ) - 1 ) + r } { N ( s ) } } \end{array}$ , where $\cdot$ is the old value function. Normally, the major shortcoming of MCTS is that it requires an environment model to undo previous steps and form a searching tree, which is often a strong assumption. However, such a limitation does not exist for LMs, as we can conveniently reset to any step by simply copy-pasting historical text input. Such a special property is the key motivation of our work.
67
+
68
+ # 4 UNIFYING PLANNING, REASONING, AND ACTING
69
+
70
+ # 4.1 LM AGENT
71
+
72
+ LATS supports sequential reasoning or decision-making tasks on the basis of ReAct. At time step $t$ , an agent receives an observation $o _ { t } \in O$ from the environment and takes an action $a _ { t } \in A$ following some policy $\pi ( a _ { t } | x , o _ { 1 } . . . i - 1 , a _ { 1 } . . . i - 1 )$ , where $x$ consists of the task instruction and a number of few-shot examples. We initialize the agent with $p _ { \theta }$ to leverage the useful language representations of an LM as a base decision-maker. We follow the ReAct instantiation in which the action space ${ \hat { A } } = A \cup Z$ consists of both the space of permissible actions $A$ and language space of reasoning traces $Z$ . Actions directly affect the environment and result in observation, while thoughts are used to formalize decisions by organizing information, planning future actions, or injecting internal knowledge. The exact instantiation of the action space depends on the particular environment; for decision-making tasks actions might consist of commands on a website while for reasoning tasks the action space might be limited to a few external tools or APIs.
73
+
74
+ Instead of greedily decoding one trajectory or solution, we sample $n$ actions from $p _ { \theta }$ using the current state. This is based on the intuition that for complex decision-making tasks, there is likely to be a range of potential trajectories or reasoning paths that are correct (Evans, 2010). Sampling a diverse set of candidates at each step mitigates the stochastic nature of LM text generation and enables greater exploration in both the decision-making and reasoning space. We wrap $p _ { \theta }$ within our proposed search algorithm to deliberately construct the best trajectory from sampled actions.
75
+
76
+ # 4.2 LATS
77
+
78
+ The main component of LATS is a search algorithm that controls the overall problem-solving process with deliberate planning. To find the most promising trajectory and systemically balance exploration with exploitation, we adopt a variant of Monte Carlo Tree Search (MCTS) that frames decisionmaking as a tree search, in which each node $s = [ x , a _ { 1 } . . . i , o _ { 1 } . . . i ]$ represents a state comprising the original input $x$ , action sequence $a _ { 1 \cdot i }$ , and observation sequence $O _ { 1 \cdot i }$ .
79
+
80
+ To adapt MCTS for language agents, LATS repurposes $p _ { \theta }$ as an agent, state evaluator, and feedback generator, leveraging the useful language priors of modern LMs to facilitate planning. While standard MCTS and RAP Hao et al. (2023) rely on internal dynamics models to facilitate simulation, LATS is model-free and uses environment interaction. LATS consists of a series of operations, selection, expansion, evaluation, simulation, backpropagation, and reflection, performed in succession until the task is successfully completed or a computational limit is reached. The full psuedocode of LATS can be found in Sec. A in the Appendix.
81
+
82
+ Selection. In the first operation, the algorithm identifies a segment of the current tree most suitable for subsequent expansion. Starting from the root node, denoted as the initial state $s _ { 0 }$ , a child node is selected at each tree level until a leaf node is reached. To balance exploration and exploitation, we use the UCT algorithm as shown in Eq. 1.
83
+
84
+ Expansion. After selecting a node, the second operation expands the tree by sampling $n$ actions from $p _ { \theta }$ , as described in the prior section. The environment receives each action and returns corresponding feedback as an observation. This results in $n$ new child nodes added to the tree. This tree is stored in an external long-term memory structure.
85
+
86
+ Evaluation. The third operation assigns a scalar value to each new child node to be used for selection and backpropagation. This value effectively quantifies the agent’s progress in task completion, serving as a heuristic to steer the search algorithm towards the most promising regions of the tree. Following Yao et al. (2023a) we repurpose $p _ { \theta }$ into a value function by prompting it to reason about a given state. To obtain a scalar value, we instruct $p _ { \theta }$ to end its reasoning trace with a score indicating the correctness of the trajectory. This method offers enhanced flexibility over programmed heuristics (Campbell et al., 2002) and greater efficiency than learned heuristics (Silver et al., 2017).
87
+
88
+ Simulation. The fourth operation expands the currently selected node until a terminal state is reached. At each depth level we sample and evaluate nodes with the same operations, but prioritize nodes of highest value. Reaching a terminal state provides objective feedback on the correctness of a trajectory. If the task is completed successfully, then LATS terminates the search. If the solution is partially successful or unsuccessful, then we perform two additional operations as described below.
89
+
90
+ Backpropagation. This operation updates the values of the tree based on the outcome of a trajectory. For each node $\_$ in the trajectory from root (initial state $s _ { 0 }$ ) of the searching tree to leaf (terminal state $s _ { n }$ ), its value is updated to reflect the outcome of the simulation by $N ( s _ { i } ) =$ $N _ { \mathrm { o l d } } ( s _ { i } ) + 1$ and $\_$ , where $\cdot$ is the return and $\cdot$ are the old number of visits and value function. These updated values are used in the UCT formula (Eq. 1) to guide the selection of the next node for exploration.
91
+
92
+ Reflection. In addition to the environmental feedback, we also leverage self-reflection to further refine the decision-making process (Shinn et al., 2023; Madaan et al., 2023). Upon encountering an unsuccessful terminal node, $p _ { \theta }$ is prompted with the trajectory and final reward to provide a verbal self-reflection that summarizes the errors in the reasoning or acting process and proposes superior alternatives. We store both failed trajectories and corresponding reflections in the memory. In subsequent iterations, these are integrated as additional context to the agent and value function, refining both through in-context learning. This imparts a semantic gradient signal more useful than a scalar value, enabling the agent to learn from trial and error without the cost of expensive optimization processes such as reinforcement learning.
93
+
94
+ Conceptually, LATS has the following advantages as a general framework for reasoning and decision-making with LM agents. (1) Generality: LATS supports both reasoning and decisionmaking tasks by defining a shared space of thoughts and actions. (2) Deliberate: The use of MCTS and LM value function ensures a principled search that selects options with high value while exploring promising alternatives. (3) Adaptability: LATS is designed around the use of external feedback through observations and self-reflection, enabling greater adaptation during problem-solving. (4) Flexibility: LATS can accommodate different scenarios, environments, and resource stipulations by modifying state design and tree dimensions. (5) Modularity: The base LM agent, reflection generator, and value function can be independently altered and adapted to individual LM properties.
95
+
96
+ Table 2: GPT-3.5 reasoning-based prompting (left) and acting-based prompting (right) results on HotpotQA. LATS achieves the highest exact match (EM) for acting and is competitive on reasoning. Unless otherwise specified, we sample $n = 5$ nodes during expansion and $k = 5 0$ trajectories.
97
+
98
+ <table><tr><td>Prompt Method</td><td>HotpotQA (EM)</td><td>Prompt Method</td><td>HotpotQA (EM)</td></tr><tr><td>I/0</td><td>0.32</td><td> ReAct (est ol 0236)</td><td>0.3</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>CoT -SC 23)2</td><td>0.34</td><td> RAlexion (Shin eal)</td><td>0.51</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>RaTP (yaetal</td><td>0.55</td><td>LATS (n = 1)</td><td>0.48</td></tr><tr><td>RAP (n = 10)</td><td>0.60</td><td>LATS (n = 3)</td><td>0.56</td></tr><tr><td>LATS (CoT)</td><td>0.60</td><td>LATS (=T + ReAct)</td><td>0.64</td></tr></table>
99
+
100
+ # 5 EXPERIMENTS
101
+
102
+ To demonstrate the general applicability of LATS, we evaluate our method on a variety of decisionmaking domains that requires both reasoning and acting ability: programming (Chen et al., 2021; Austin et al., 2021), HotPotQA (Yang et al., 2018), and WebShop (Yao et al., 2022).
103
+
104
+ # 5.1 HOTPOTQA
105
+
106
+ For a task that can be approached with both reasoning-based and acting-based strategies, we consider HotPotQA (Yang et al., 2018), a multi-hop question-answering benchmark that requires retrieval over two or more Wikipedia passages. For the action space, in addition to LM thoughts we follow the setup from Yao et al. (2023b), which provides the agent with API calls to search and lookup information. The output of these API calls and self-generated reflections form the observation space. We use a subset of 100 questions and three few-shot examples for each method. For ToT, we use DFS as the base search algorithm and scoring with the LM as the heuristic. For all methods that involve sampling, including LATS, we sample $k = 5 0$ trajectories. More details and prompts can be found in Sec. D and Sec. E in the Appendix.
107
+
108
+ We evaluate internal reasoning strategies by removing actions and observations from the context, corresponding to CoT (Wei et al., 2022) and its variants, CoT-SC (Wang et al., 2022), ToT (Yao et al., 2023a), and RAP (Hao et al., 2023). These methods rely solely on the agent’s existing knowledge to answer the question. We also consider acting-based methods ReAct, Reflexion, and LATS, which augment the agent with the interactive API environment and primarily evaluate its information retrieval abilities. While LATS is designed for scenarios where external feedback can enhance reasoning, we also implement a reasoning-only version with CoT as the base prompt. We also combine internal and external reasoning in LATS by first prompting with a CoT-based prompt, then switching to a ReAct-based prompt upon failure. This is closer to how humans might approach this task, by using tools to lookup additional information only when the answer is not already known.
109
+
110
+ Results. We observe in Tab. 2 that both internal reasoning and external retrieval strategies perform well on HotPotQA. Due to their large-scale training corpus, modern LLMs already encode factual knowledge and can often directly answer the question correctly. While CoT can slightly enhance performance on questions requiring reasoning, larger gains are observed with search methods ToT and RAP, which can sample and explore more outputs. We observe similar results for acting-based methods. LATS surpasses ReAct, even when sampling the same number of trajectories, by expanding more nodes with principled search (see Fig. 5 in Appendix D for a qualitative sample). This is demonstrated when modifying $n$ , the number of nodes expanded during each iteration. Increasing $n$ can consistently improve performance, although at greater computational and inference costs. LATS is also competitive to RAP on internal reasoning but performs worse than acting. Combining internal and external reasoning in LATS results in the highest performance, indicating the importance of external feedback in augmenting reasoning even in tasks the base LM can already perform.
111
+
112
+ Table 3: GPT-3.5 and GPT-4 Pass $@ 1$ accuracy on HumanEval (Chen et al., 2021) and MBPP (Austin et al., 2021). Prompting with LATS achieves the highest performance. We sample 5 solutions during expansion for 8 iterations.
113
+
114
+ <table><tr><td>Prompt Method</td><td>Model</td><td>Pass@1</td></tr><tr><td>CoT (Wei et al., 2022)</td><td>GPT-3.5</td><td>46.9</td></tr><tr><td>ReAct (Yao et al.,2023b)</td><td>GPT-3.5</td><td>56.9</td></tr><tr><td>Reflexion (Shin etal.,3)</td><td>GPT-3.5</td><td>68.1</td></tr><tr><td>ToT (Yao et al., 2023a)</td><td>GPT-3.5</td><td>54.4</td></tr><tr><td>RAP (Hao et al.,2023)</td><td>GPT-3.5</td><td>63.1</td></tr><tr><td>LATS (Ours)</td><td>GPT-3.5</td><td>86.9</td></tr><tr><td>1/0</td><td>GPT-4</td><td>80.1</td></tr><tr><td>Reflexion</td><td>GPT-4</td><td>91.0</td></tr><tr><td>LATS</td><td>GPT-4</td><td>94.4</td></tr></table>
115
+
116
+ <table><tr><td>Prompt Method</td><td>Pass@1</td></tr><tr><td>CoT (Wei et al., 2022)</td><td>54.9</td></tr><tr><td>ReAct (Wei et al., 2022)</td><td>67.0</td></tr><tr><td>Reflexion (Shinetal.,023)</td><td>70.0</td></tr><tr><td>ToT (Yao et al., 2023a)</td><td>65.8</td></tr><tr><td>RAP (Hao et al.,2023)</td><td>71.4</td></tr><tr><td>LATS (Ours)</td><td>81.1</td></tr></table>
117
+
118
+ # 5.2 PROGRAMMING
119
+
120
+ To demonstrate the importance of external observations for complex reasoning tasks, we evaluate the baselines and LATS on programming with Humaneval (Chen et al., 2021) and MBPP (Austin et al., 2021). Both datasets measure the correctness of synthesized programs in Python from natural language docstrings. We use individual solutions as the action space and test suite and compiler feedback as the external observation. We follow Chen et al. (2022a) and use an LLM to generate a synthetic test suite of syntactically valid “assert” statements for each question. For each step, the solution is evaluated on this test suite, and the results including successful and failed tests and compiler output, are added to the context as an observation. We use the same test suite for Reflexion.
121
+
122
+ For this task, the reasoning and acting baselines share an action space, but acting methods are able to incorporate observations as additional context. For LATS, since each action corresponds to a complete solution, we skip the simulation step of LATS and directly use the percentage of passed tests as the backpropagated reward. We use $\cdot$ iterations, set the number of generated tests at 4, and sample $n = 5$ solutions during expansion. After the search is completed, we select the solution with the highest value and evaluate it on the real test suite for the pass $@ 1$ accuracy evaluation. More details and prompts can be found in Sec. D and Sec. F in the Appendix.
123
+
124
+ Results. We find in Tab 3 that both search and semantic feedback are crucial for better performance. Despite not using observations, ToT and RAP are competitive with Reflexion. LATS has the highest performance on both datasets. Since RAP uses a similar search algorithm as LATS, this reveals the importance of external feedback for difficult reasoning tasks such as programming. With GPT-4, using LATS sets the state of the art for HumanEval, showing LATS can be used with more advanced LLMs for higher performance.
125
+
126
+ # 5.3 WEBSHOP
127
+
128
+ For a complex decision-making environment with practical applications, we consider WebShop (Yao et al., 2022), an online shopping environment composed of a website with 1.18M real-world products and 12k human instructions. Agents must navigate a website through a variety of commands to purchase an item matching a user specification. We use the preconstructed action space of search and click commands and browser feedback and reflections for the observation. The performance is gauged using two metrics: an average score, reflecting the percentage of user-specified attributes met by the selected product, and a success rate, indicating the frequency with which the chosen product fulfills all given conditions. We compare against acting-based prompting methods and RL-based approaches. We evaluate on 50 instructions, expand $n = 5$ children for LATS, and set $\cdot$ for LATS, ReAct best of $k$ , and Reflexion. More details and prompts are in Appendix $\cdot$ and G.
129
+
130
+ Table 4: Score and success rate (SR) on Webshop, separated into prompting, training, and human performance. For the same number of iterations, LATS improves both score and success rate and surpasses RL-based training.
131
+
132
+ <table><tr><td>Method</td><td>Score</td><td>SR</td></tr><tr><td>ReAct (Yao et al.,2023b) ReAct (best of k)</td><td>53.8 59.1</td><td>28.0</td></tr><tr><td>Reflexion (Shinn et al.,2023)</td><td>64.2</td><td>32.0 35.0</td></tr><tr><td>LATS</td><td>75.9</td><td>38.0</td></tr><tr><td>IL Yao et al. (2022)</td><td>59.9</td><td>29.1</td></tr><tr><td>IL+RL Yao et al. (2022) Fine-tuning (Furuta et al.,023)</td><td>62.4</td><td>28.7</td></tr><tr><td></td><td>67.5</td><td>45.0</td></tr><tr><td>Expert</td><td>82.1</td><td>59.6</td></tr></table>
133
+
134
+ Table 5: Standardized comparisons between LATS, ToT, and RAP; we use ReAct as the base prompt for all methods and sample $n = 5$ children for MCTS and DFS and $\cdot$ maximum trajectories.
135
+
136
+ <table><tr><td>Prompt Method</td><td>HotPotQA</td></tr><tr><td>ReAct (best k = 250)</td><td>0.42</td></tr><tr><td>CoT-SC (k = 250)</td><td>0.40</td></tr><tr><td>ToT (ReAct)</td><td>0.49</td></tr><tr><td>RAP (ReAct)</td><td>0.54</td></tr><tr><td>LATS (DFS) LATS (No Reflection)</td><td>0.53</td></tr><tr><td></td><td>0.56</td></tr><tr><td>LATS</td><td>0.61</td></tr></table>
137
+
138
+ Results. We find in Tab. 4 that GPT-3.5 with ReAct is competitive to imitation learning, and can exceed reinforcement learning techniques with stronger prompting strategies. Sampling $k = 3 0$ trajectories with ReAct and Reflexion results in a similar performance, suggesting the semantic feedback is not as helpful in complex environments like WebShop. Indeed like in Shinn et al. (2023), we find that generated reflections are often generic and do not provide useful feedback, resulting in a tendency for the agent to become stuck in local minima. However, using LATS indeed results in a noticeable improvement, indicating a more effective exploration for the same number of iterations.
139
+
140
+ # 5.4 ADDITIONAL OBSERVATIONS
141
+
142
+ We also conduct additional experiments on HotPotQA to demonstrate the effect of each component of LATS. We also design a version of ToT and RAP with ReAct prompt and can handle external observations. We use HotPotQA as our setup incorporates both reasoning (through thoughts) and acting (through API calls); the results are shown in Tab. 5. More ablations for token consumption on HotPotQA are in Tab. 7 in Appendix C. Note that baselines generally perform worse than the reasoning-only setting of HotPotQA, which indicates that the acting-based setting is more challenging and adaption of search algorithms to decision-making scenarios is non-trivial.
143
+
144
+ Self-reflection. We use self-reflection to provide additional semantic signals for the agent. We observe a 0.05 performance drop when removed from LATS, suggesting this is useful. This is a smaller gain Reflexion (Shinn et al., 2023) observes over ReAct (Yao et al., 2023b) as shown in Tab. 2, suggesting overlap between the types of questions where there is an improvement with selfreflection and search. This variant outperforms RAP-ReAct, reflecting our improvements to MCTS.
145
+
146
+ Search Algorithm. MCTS is a more principled search algorithm than variants like $\mathbf { A } ^ { * }$ or DFS search and the basis for observed performance gains. We observe the effects of using DFS, and incorporate the LM-based heuristic used in ToT (Yao et al., 2023a) in which branches with low values are pruned. This removes the selection and backpropagation operations, and we observe a 0.08 drop in performance when sampling the same number of nodes, but outperforms ToT-ReAct.
147
+
148
+ # 6 CONCLUSION
149
+
150
+ In this work, we introduce Language Agent Tree Search (LATS), the first framework to unify planning, acting, and reasoning for enhanced LLM problem solving. By deliberately constructing trajectories with search algorithms, incorporating external feedback, and enabling agents to learn from experience, LATS addresses key limitations of prior prompting techniques. Our evaluations demonstrate the ability of LATS to harness LLM capabilities for a variety of decision-making tasks while keeping its reasoning ability without additional training. The proposed synergies between search, interaction, and reflection offer a versatile approach to autonomous decision-making, highlighting the potential of LLMs as generalist agents. A full discussion of the limitations and broader impacts is in Appendix B.
151
+
152
+ # REFERENCES
153
+
154
+ Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Chuyuan Fu, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Daniel Ho, Jasmine Hsu, Julian Ibarz, Brian Ichter, Alex Irpan, Eric Jang, Rosario Jauregui Ruano, Kyle Jeffrey, Sally Jesmonth, Nikhil J Joshi, Ryan Julian, Dmitry Kalashnikov, Yuheng Kuang, Kuang-Huei Lee, Sergey Levine, Yao Lu, Linda Luu, Carolina Parada, Peter Pastor, Jornell Quiambao, Kanishka Rao, Jarek Rettinghouse, Diego Reyes, Pierre Sermanet, Nicolas Sievers, Clayton Tan, Alexander Toshev, Vincent Vanhoucke, Fei Xia, Ted Xiao, Peng Xu, Sichun Xu, Mengyuan Yan, and Andy Zeng. Do as i can, not as i say: Grounding language in robotic affordances. arXiv:2204.01691, 2022.
155
+
156
+ T. Anthony, Z. Tian, and D. Barber. Thinking fast and slow with deep learning and tree search. In NIPS, 2017.
157
+ Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. Program synthesis with large language models. arXiv:2108.07732, 2021.
158
+ Bowen Baker, Ilge Akkaya, Peter Zhokhov, Joost Huizinga, Jie Tang, Adrien Ecoffet, Brandon Houghton, Raul Sampedro, and Jeff Clune. Video pretraining (vpt): Learning to act by watching unlabeled online videos. arXiv:2206.11795, 2022.
159
+ Maciej Besta, Nils Blach, Ales Kubicek, Robert Gerstenberger, Lukas Gianinazzi, Joanna Gajda, Tomasz Lehmann, Michal Podstawski, Hubert Niewiadomski, Piotr Nyczyk, and Torsten Hoefler. Graph of thoughts: Solving elaborate problems with large language models. arXiv:2308.09687, 2023.
160
+ Samuel R Bowman, Gabor Angeli, Christopher Potts, and Christopher D Manning. A large annotated corpus for learning natural language inference. In EMNLP, 2015.
161
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS, 2020.
162
+ Murray Campbell, A Joseph Hoane Jr, and Feng-hsiung Hsu. Deep blue. Artificial intelligence, 2002.
163
+ Bei Chen, Fengji Zhang, Anh Nguyen, Daoguang Zan, Zeqi Lin, Jian-Guang Lou, and Weizhu Chen. Codet: Code generation with generated tests. arXiv:2207.10397, 2022a.
164
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv:2107.03374, 2021.
165
+ Wenhu Chen, Xueguang Ma, Xinyi Wang, and William W Cohen. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. arXiv preprint arXiv:2211.12588, 2022b.
166
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv:2204.02311, 2022.
167
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems. arXiv:2110.14168, 2021.
168
+ 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. arXiv:2306.06070, 2023.
169
+ Danny Driess, Fei Xia, Mehdi S. M. Sajjadi, Corey Lynch, Aakanksha Chowdhery, Brian Ichter, Ayzaan Wahid, Jonathan Tompson, Quan Vuong, Tianhe Yu, Wenlong Huang, Yevgen Chebotar, Pierre Sermanet, Daniel Duckworth, Sergey Levine, Vincent Vanhoucke, Karol Hausman, Marc Toussaint, Klaus Greff, Andy Zeng, Igor Mordatch, and Pete Florence. Palm-e: An embodied multimodal language model. arXiv:2303.03378, 2023.
170
+ Yilun Du, Mengjiao Yang, Bo Dai, Hanjun Dai, Ofir Nachum, Joshua B. Tenenbaum, Dale Schuurmans, and Pieter Abbeel. Learning universal policies via text-guided video generation. arXiv:2302.00111, 2023.
171
+ Jonathan St BT Evans. Intuition and reasoning: A dual-process perspective. Psychological Inquiry, 2010.
172
+ 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 NeurIPS Datasets and Benchmarks Track, 2022.
173
+ Hiroki Furuta, Ofir Nachum, Kuang-Huei Lee, Yutaka Matsuo, Shixiang Shane Gu, and Izzeddin Gur. Multimodal web navigation with instruction-finetuned foundation models. arXiv preprint arXiv:2305.11854, 2023.
174
+ Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. Pal: Program-aided language models. arXiv preprint arXiv:2211.10435, 2022.
175
+ Jiaxian Guo, Sidi Lu, Han Cai, Weinan Zhang, Yong Yu, and Jun Wang. Long text generation via adversarial training with leaked information. AAAI, 2018.
176
+ William H. Guss, Brandon Houghton, Nicholay Topin, Phillip Wang, Cayden Codel, Manuela Veloso, and Ruslan Salakhutdinov. Minerl: A large-scale dataset of minecraft demonstrations. In IJCAI, 2019.
177
+ Danijar Hafner, Timothy Lillicrap, Ian Fischer, Ruben Villegas, David Ha, Honglak Lee, and James Davidson. Learning latent dynamics for planning from pixels. In ICML, 2019.
178
+ Danijar Hafner, Jurgis Pasukonis, Jimmy Ba, and Timothy Lillicrap. Mastering diverse domains through world models. arXiv:2301.04104, 2023.
179
+ Shibo Hao, Yi Gu, Haodi Ma, Joshua Jiahua Hong, Zhen Wang, Daisy Zhe Wang, and Zhiting Hu. Reasoning with language model is planning with world model. arXiv:2305.14992, 2023.
180
+ Jie Huang, Xinyun Chen, Swaroop Mishra, Huaixiu Steven Zheng, Adams Wei Yu, Xinying Song, and Denny Zhou. Large language models cannot self-correct reasoning yet. arXiv:2310.01798, 2023.
181
+ Wenlong Huang, Fei Xia, Ted Xiao, Harris Chan, Jacky Liang, Pete Florence, Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, et al. Inner monologue: Embodied reasoning through planning with language models. arXiv:2207.05608, 2022.
182
+ D. Jiang, E. Ekwedike, and H. Liu. Feedback-based tree search for reinforcement learning. In ICML, 2018.
183
+ Levente Kocsis and Csaba Szepesvari. Bandit based monte-carlo planning. In ´ ECML, 2006.
184
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv:2205.11916, 2022.
185
+ Steven M LaValle, James J Kuffner, BR Donald, et al. Rapidly-exploring random trees: Progress and prospects. Algorithmic and computational robotics: new directions, 2001.
186
+ Evan Zheran Liu, Kelvin Guu, Panupong Pasupat, Tianlin Shi, and Percy Liang. Reinforcement learning on web interfaces using workflow-guided exploration. In ICLR, 2018.
187
+ Xiao Liu, Hao Yu, Hanchen Zhang, Yifan Xu, Xuanyu Lei, Hanyu Lai, Yu Gu, Hangliang Ding, Kaiwen Men, Kejuan Yang, Shudan Zhang, Xiang Deng, Aohan Zeng, Zhengxiao Du, Chenhui
188
+ Zhang, Sheng Shen, Tianjun Zhang, Yu Su, Huan Sun, Minlie Huang, Yuxiao Dong, and Jie Tang. Agentbench: Evaluating llms as agents. arXiv:2308.03688, 2023.
189
+ Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, Shashank Gupta, Bodhisattwa Prasad Majumder, Katherine Hermann, Sean Welleck, Amir Yazdanbakhsh, and Peter Clark. Self-refine: Iterative refinement with self-feedback. arXiv:2303.17651, 2023.
190
+ Ramesh Nallapati, Bowen Zhou, Cicero dos Santos, Caglar Gulcehre, and Bing Xiang. Abstractive text summarization using sequence-to-sequence rnns and beyond. In SIGNLL, 2016.
191
+ Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv:2112.00114, 2021.
192
+ OpenAI. Gpt-4 technical report. arXiv:2303.08774, 2023.
193
+ Abulhair Saparov and He He. Language models are greedy reasoners: A systematic formal analysis of chain-of-thought. arXiv:2210.01240, 2022.
194
+ 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:2302.04761, 2023.
195
+ Yongliang Shen, Kaitao Song, Xu Tan, Dongsheng Li, Weiming Lu, and Yueting Zhuang. Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface. arXiv:2303.17580, 2023.
196
+ Noah Shinn, Federico Cassano, Beck Labash, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. Reflexion: Language agents with verbal reinforcement learning. arXiv:2303.11366, 2023.
197
+ Mohit Shridhar, Xingdi Yuan, Marc-Alexandre Cotˆ e, Yonatan Bisk, Adam Trischler, and Matthew ´ Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. arXiv:2010.03768, 2020.
198
+ David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 2016.
199
+ David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas baker, Matthew Lai, Adrian Bolton, Yutian Chen, Timothy P. Lillicrap, Fan Hui, L. Sifre, George van den Driessche, Thore Graepel, and Demis Hassabis. Mastering the game of go without human knowledge. Nature, 2017.
200
+ Steven A. Sloman. The empirical case for two systems of reasoning. Psychological Bulletin, 1996.
201
+ Haotian Sun, Yuchen Zhuang, Lingkai Kong, Bo Dai, and Chao Zhang. Adaplanner: Adaptive planning from feedback with language models. arXiv:2305.16653, 2023.
202
+ D´ıdac Sur´ıs, Sachit Menon, and Carl Vondrick. Vipergpt: Visual inference via python execution for reasoning. arXiv preprint arXiv:2303.08128, 2023.
203
+ Maciej Swiechowski, Konrad Godlewski, Bartosz Sawicki, and Jacek Ma ´ ndziuk. Monte carlo tree ´ search: A review of recent modifications and applications. Artificial Intelligence Review, 2023.
204
+ Hugo Touvron, Louis Martin, Kevin R. Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Daniel M. 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 S. Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel M. Kloumann, A. V. 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, R. Subramanian, Xia Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zhengxu 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. arXiv:2307.09288, 2023.
205
+ Tom Vodopivec, Spyridon Samothrakis, and Branko Ster. On monte carlo tree search and reinforcement learning. Journal of Artificial Intelligence Research, 2017.
206
+ 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:2305.16291, 2023.
207
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv:2203.11171, 2022.
208
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv:2201.11903, 2022.
209
+ Michael Wooldridge and Nicholas R Jennings. Intelligent agents: Theory and practice. The knowledge engineering review, 1995.
210
+ Philipp Wu, Alejandro Escontrela, Danijar Hafner, Pieter Abbeel, and Ken Goldberg. Daydreamer: World models for physical robot learning. In CoRL. PMLR, 2023.
211
+ Yuxi Xie, Kenji Kawaguchi, Yiran Zhao, Xu Zhao, Min-Yen Kan, Junxian He, and Qizhe Xie. Decomposition enhances reasoning via self-evaluation guided decoding. arXiv:2305.00633, 2023.
212
+ Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William W Cohen, Ruslan Salakhutdinov, and Christopher D Manning. Hotpotqa: A dataset for diverse, explainable multi-hop question answering. arXiv:1809.09600, 2018.
213
+ Shunyu Yao, Howard Chen, John Yang, and Karthik R Narasimhan. Webshop: Towards scalable real-world web interaction with grounded language agents. In NeurIPS, 2022.
214
+ 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:2305.10601, 2023a.
215
+ Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. ReAct: Synergizing reasoning and acting in language models. In ICLR, 2023b.
216
+ Weiran Yao, Shelby Heinecke, Juan Carlos Niebles, Zhiwei Liu, Yihao Feng, Le Xue, Rithesh Murthy, Zeyuan Chen, Jianguo Zhang, Devansh Arpit, Ran Xu, Phil Mui, Huan Wang, Caiming Xiong, and Silvio Savarese. Retroformer: Retrospective large language agents with policy gradient optimization. arXiv preprint arXiv:2308.02151, 2023c.
217
+ Weirui Ye, Shaohuai Liu, Thanard Kurutach, Pieter Abbeel, and Yang Gao. Mastering atari games with limited data. In NeurIPS, 2021.
218
+ Denny Zhou, Nathanael Scharli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schu- ¨ urmans, Olivier Bousquet, Quoc Le, and Ed Chi. Least-to-most prompting enables complex reasoning in large language models. arXiv:2205.10625, 2022.
219
+ Xizhou Zhu, Yuntao Chen, Hao Tian, Chenxin Tao, Weijie Su, Chenyu Yang, Gao Huang, Bin Li, Lewei Lu, Xiaogang Wang, Yu Qiao, Zhaoxiang Zhang, and Jifeng Dai. Ghost in the minecraft: Generally capable agents for open-world environments via large language models with text-based knowledge and memory. arXiv:2305.17144, 2023.
220
+
221
+ # 7 APPENDIX
222
+
223
+ The appendix is organized as follows. First in Sec. A, we show the pseudocode of our proposed algorithm, LATS; then in Sec. B, we provide further discussion of our method and its limitations, future direction and broader impact; then in Sec. C we provide additional experimental results; then in Sec. D, we specify the environment details in our experiments; finally, we list our prompts used for the three environments in Sec. E (HotPotQA), Sec. F (Programming) and Sec. G (Webshop) respectively.
224
+
225
+ # A LATS PSEUDOCODE
226
+
227
+ Alg. 1 shows the pseudocode of our algorithm LATS. Nodes are stored explicitly in the memory.
228
+ Unless otherwise specified, in all experiments we use $n = 5$ and $w = 1$ .
229
+
230
+ <table><tr><td>Algorithm 1LATS(So,pe, Pv, Pref,d, k,n, w)</td><td></td><td></td><td>Require: Initial state S1,action generator po,value function pv,reflection generator pref, number</td><td></td><td></td><td></td><td>of generated actions n,depth limit L,number of roll-outs K,context c,and exploration weight w</td><td></td><td></td><td></td><td></td></tr><tr><td>Initialize action space A,observation space O</td><td>fork←0,...,K-1do</td><td>Initialize the state-action value function pv : S × A → R and visit counter N : S → N to zero</td><td></td><td></td><td></td><td>&gt;Expansion &amp; Simulation</td><td></td></tr><tr><td>fort←0,...,L-1do if st not terminal then</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>fori←1,...,ndo</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Samplea</td><td>~pe(a|st)</td><td></td><td></td><td></td><td>②,a(②),c←(,)</td></tr><tr><td>Evaluate V</td><td></td><td>Get o) fromenviroment,s</td><td>(c(), ↑</td><td></td><td>Evaluation</td></tr><tr><td>V(st)← V t</td><td></td><td>~ pv(s() (i)</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>Add s(𝑖) to children</td><td></td><td></td><td></td></tr><tr><td></td><td>end for</td><td></td><td></td><td></td><td></td></tr><tr><td>if st is terminal then</td><td>end if</td><td></td><td></td><td></td><td>Reflection</td></tr><tr><td>Getr from environment</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>if r not success then</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>reflection ← Pref(Ct)</td><td></td><td></td><td></td></tr><tr><td>end if</td><td></td><td>c←reflection</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>end if</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>at ← arg maxa∈e(st)</td><td></td><td>V(st)+w√</td><td>nN(1</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>N(st+1)←N(st+1)+1</td><td></td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td>if at is an output action then break</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>T← the actual number of steps</td><td></td><td></td><td>&gt;Backpropagation</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>fort←T-1,...,0do</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>V(st) ← V(st)(N(st)-1)+r</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>N(st)</td><td></td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></table>
231
+
232
+ # B DISCUSSION
233
+
234
+ Limitations. Although LATS can improve reasoning and decision-making, this arrives at a higher computational cost relative to simpler prompting methods like ReAct or Reflexion. The search process takes more time than standard prompting or simpler techniques, and requires greater inference costs. While such an issue is mitigated by the fact that the number of nodes $n$ expanded at every step provides a natural trade-off between performance and efficiency (setting $\cdot$ makes the method as effecient as ReAct with multiple trials or CoT-SC), in practice we recommend using LATS for difficult tasks like programming or for situations where performance is prioritized over efficiency.
235
+
236
+ Table 6: Ablation results on LATS and baseline variants in HotPotQA measured by Exact Match (EM). We test different depth $\cdot$ , exploration factor $\cdot$ , and versions of LATS using CoT and without the LM value function. We sample $\cdot$ and $\cdot$ trajectories.
237
+
238
+ <table><tr><td>Prompt Method</td><td>HotpotQA (EM)</td></tr><tr><td>LATS (w=0.5) LATS (w=2.0) LATS (d=4) LATS (CoT)</td><td>0.55 0.61 0.58</td></tr></table>
239
+
240
+ ![](images/90ea2aa71a5718f43da23e22df7d090316d3a958b585cd57b841f0c8c23f5a5d.jpg)
241
+ Figure 4: Performance over successive iterations on HumanEval with GPT-3.5.
242
+
243
+ We hope that continued advancements in LLMs will reduce costs and increase the practicality of LATS.
244
+
245
+ Additionally, the benchmarks we use in this paper are relatively simple and focused on decisionmaking, compared to the complexity of real-world interactive environments. In addition, some environments might not easily support rollbacks to previous states. However, the design of LATS is flexible and can be adjusted to various resource constraints. Using planning-based prompting methods like LATS in environments like Minecraft (Fan et al., 2022) and more reasoning benchmarks would be interesting avenues for future work.
246
+
247
+ Broader impact. LATS is a framework that enhances LLM performance through interactions with an environment. This improvement in autonomous decision-making may facilitate harmful uses of LLMs. Alternatively, LATS enhances interpretability and the potential for greater alignment, as it generates understandable, high-level linguistic reasoning and actions through several rounds of decision-making and reflection, rather than relying on implicit, low-level token values.
248
+
249
+ # C ABLATIONS
250
+
251
+ In this section, we ablate various designs of LATS. Experiments are conducted on HotPotQA with a maximum of $\cdot$ trajectories and sampling size of $\cdot$ and HumanEval with a maximum of $k = 8$ trajectories and sampling size of $\cdot$ . The result for HotPotQA is shown in Tab. 5 and HumanEval in Fig. 4.
252
+
253
+ Exploration weight. We find that there is lower performance on HotPotQA when the exploration weight $w$ in the selection formula is decreased to 0.5, suggesting that this reduces the effectiveness of the search. Increasing $\cdot$ to 2.0 does not lead to a performance improvement, but we tend to observe faster convergence. The optimal setting depends on the particular environment and complexity of the state space.
254
+
255
+ Depth. In our main experiments we use a maximum depth of $\cdot$ on HotPotQA for all methods, following previous work (Yao et al., 2023b). We ablate the effect on LATS after reducing it to $d = 4$ . This results in only a slight drop in performance. We find that most questions can be answered within four steps, and using a greater number of steps tends to force the agent into local minima and rarely improves success.
256
+
257
+ LM value function. The LM value function scores states based on expected future reward. Without this heuristic, the only signal to guide search would be from environment rewards for completed trajectories, which are scarce and often binary. When we remove the evaluation operation, we observe a dramatic 0.24 drop in performance.
258
+
259
+ Performance over time. To see the effects of increasing the number of trajectories sampled, we change $k$ to different values. We conduct this experiment on HumanEval, which has a more noticeable difference due to sampling less trajectories. The results are shown in Fig. 4, in which LATS scales better with more iterations than Reflexion.
260
+
261
+ ![](images/54a0a04c339f3e47b9ba69ff362557fdc47cdbd77063e93b19c7874dcb6b1b29.jpg)
262
+ Figure 5: Example trajectories on HotPotQA for ReAct (left) and LATS (right). LATS can sample more actions and avoid failure from previous mistakes by evaluating states with an LM to guide the search toward promising areas of the tree.
263
+
264
+ Sample complexity and Token cost. One possible concern of LATS is that the tree-structured search might consume much more tokens than existing methods. To further study the computational cost of LATS compared to prior methods, we examine the sample complexity (i.e. asymptotic token cost) of all methods considered in this paper, and count the average number of nodes expanded by our method and other tree-structured methods (ToT and RAP) upon successful search on HotPotQA. We present the results in Tab. 7; the result shows that our method has the same sample complexity as other tree-based search methods, and has less average number of nodes expanded upon success, which indicates less token cost. The token cost gap will be even larger when taking failed trajectories into account, since our method has higher success rate and reaches computational budget limit less often.
265
+
266
+ <table><tr><td>Method</td><td></td><td></td><td>Performance (↑)|Sample complexity (↓)|Avg. #nodes upon success(↓)|Nodes expanded</td><td></td></tr><tr><td>ReAct (Best k = 250)</td><td>0.42</td><td>0(k)</td><td>N/A</td><td></td></tr><tr><td>CoT-SC (n = 1,k = 250)</td><td>0.40</td><td>O(k)</td><td>N/A</td><td></td></tr><tr><td>LATS (n=1,k= 50)</td><td>0.48</td><td>O(k)</td><td>N/A</td><td></td></tr><tr><td>ToT (ReAct)</td><td>0.49</td><td>O(kn)</td><td>84.05</td><td>210215</td></tr><tr><td>RAP (ReAct)</td><td>0.54</td><td>O(kn)</td><td>70.60</td><td>176500</td></tr><tr><td>LATS (n= 5,k = 50)</td><td>0.61</td><td>O(kn)</td><td>66.65</td><td>173290</td></tr></table>
267
+
268
+ Table 7: The performance, sample complexity of different methods and average number of nodes expanded upon success by methods with tree-based search. $\cdot$ is the number of children nodes expanded at every step and $\cdot$ is the number of trajectories. Our method has the same sample complexity as other methods with tree-based search and expands less nodes upon success, which indicates lower token cost.
269
+
270
+ # D ENVIRONMENT DETAILS
271
+
272
+ # D.1 HOTPOTQA
273
+
274
+ HotPotQA (Yang et al., 2018) is a question-answering dataset that requires reasoning over multiple supporting documents to answer questions. It contains 113k Wikipedia-based question-answer pairs crafted by crowdworkers to be diverse, multi-hop, and explainable. Questions cover a range of types like entities, locations, dates, and comparison of shared properties between two entities. Crowdworkers also provide supporting facts from the documents that justify the answer. We use the HotPotQA benchmark setting with all the Wikipedia paragraphs to test retrieval. We use a randomly selected subset of 100 questions for our experiments and a maximum depth limit of 6. Fig. 5 illustrates how ReAct and LATS work on an example task of HotPotQA, and gives a qualitative example on how LATS outperforms ReAct on the task.
275
+
276
+ Action Space. We adopt the Wikipedia web API proposed in Yao et al. (2023b), with three types of actions to support interactive information retrieval:
277
+
278
+ (1) search[entity], which returns the first 5 sentences from the corresponding entity wiki page if it exists, or else suggests top-5 similar entities from the Wikipedia search engine,
279
+
280
+ (2) lookup[string], which returns the next sentence in the page containing string, (3) finish[answer], which finishes the current task with answer.
281
+
282
+ These API calls and free-form thoughts form the action space for this environment.
283
+
284
+ # D.2 PROGRAMMING
285
+
286
+ The HumanEval dataset (Chen et al., 2021) is a collection of 164 handwritten programming problems introduced to evaluate the functional correctness of models for synthesizing programs from natural language descriptions. Each problem includes a function signature, docstring description, reference implementation, and multiple unit tests, with an average of 7.7 tests per problem. The programming tasks assess comprehension of natural language, reasoning, algorithms, and basic mathematics, at a difficulty level comparable to simple software interview questions. Pass rates are evaluated with the pass $@ \mathbf { k }$ metric, where k samples are generated per problem and a problem is considered solved if any sample passes all tests. We use all 164 problems for our experiments and a maximum depth limit of 8.
287
+
288
+ The Mostly Basic Programming Problems (MBPP) Austin et al. (2021) benchmark contains 974 short Python functions designed to evaluate program synthesis techniques. The dataset was constructed by crowdsourcing from workers with basic Python knowledge. Each data point consists of a natural language description of a programming task, a reference solution implementation, and three test cases for functional correctness. The natural language prompts are typically short, onesentence descriptions. Solutions cover common programming constructs including mathematical operations, list processing, string manipulation, and usage of the Python standard library. On average, solutions are 6.8 lines of code. The dataset is also supplemented with an additional set of 426 problems that were manually verified for unambiguous specifications, standard function signatures, and accurate test cases. We use a randomly selected subset of 397 problems for our experiments.
289
+
290
+ # D.3 WEBSHOP
291
+
292
+ WebShop (Yao et al., 2022) is an interactive web-based environment designed to evaluate agents on grounded language understanding and decision-making. It simulates an e-commerce shopping task by providing agents with over 1 million real-world products scraped from Amazon, spanning 5 categories and 113 subcategories. These products contain rich linguistic information, with an average text length of 262 words and a vocabulary size of $2 2 4 \mathrm { k }$ . In addition, there are over $8 0 0 \mathrm { k }$ unique product options available for customization. The environment renders webpages in two modes: HTML mode provides pixel-level observations with interactive elements, while simple mode converts the raw HTML into a structured text observation more amenable for training agents. The action space consists of query searches and button clicks, which transition between 4 page types: search, results, item and item-detail. Instructions are crowdsourced natural language specifying product attributes and options, with a total of $1 2 \mathrm { k }$ collected. Automatic rewards are computed by comparing the product purchased by the agent against the attributes and options specified in the instruction, using both lexical matching and semantic similarity metrics.
293
+
294
+ There are two evaluation metrics used in WebShop: (1) Task Score: defined as ( ${ \bf 1 0 0 } \times { \bf a v g }$ . reward), which captures the average reward obtained across episodes; and (2) Success Rate (SR) defined as the portion of instructions where $r = 1$ . The reward is calculated based on the number of attributes satisfied by the selected item. We use 50 environments for our experiments and a maximum depth limit of 15.
295
+
296
+ Table 8: Action space of webshop.
297
+
298
+ <table><tr><td>Type</td><td>Argument</td><td>State →Next State</td></tr><tr><td>search</td><td>[Query]</td><td>Search →Results</td></tr><tr><td>choose</td><td>Back to search</td><td>*→ Search</td></tr><tr><td>choose</td><td>Prev/Next page</td><td>Results →Results</td></tr><tr><td>choose</td><td>[Product title]</td><td>Results → Item</td></tr><tr><td>choose</td><td>[Option]</td><td>Item→ Item</td></tr><tr><td>choose</td><td>Desc/Overview</td><td>Item→Item-Detail</td></tr><tr><td>choose</td><td>Previous</td><td>Item-Detail → Item</td></tr><tr><td>choose</td><td>Buy</td><td>Item →Episode End</td></tr></table>
299
+
300
+ # E HOTPOTQA PROMPTS
301
+
302
+ # E.1 BASE ACTING PROMPT
303
+
304
+ Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
305
+
306
+ (1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
307
+
308
+ (2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
309
+
310
+ (3) Finish[answer], which returns the answer and finishes the task.
311
+
312
+ After each observation, provide the next Thought and next Action.
313
+
314
+ Here are some examples:
315
+
316
+ Question: Which magazine was started first Arthur’s Magazine or First for Women?
317
+
318
+ Thought 1: I need to search Arthur’s Magazine and First for Women, and find which was started first.
319
+
320
+ Action 1: Search[Arthur’s Magazine]
321
+
322
+ Observation 1: Arthur’s Magazine (184400e2 ˘ 0080 ˘ 00931846) was an American literary periodical ˘ published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey’s Lady’s Book.[3]
323
+
324
+ Thought 2: Arthur’s Magazine was started in 1844. I need to search First for Women next.
325
+
326
+ Action 2: Search[First for Women]
327
+
328
+ Observation 2: First for Women is a woman’s magazine published by Bauer Media Group in the USA.[1] The magazine was started in 1989. It is based in Englewood Cliffs, New Jersey.[2] In 2011 the circulation of the magazine was 1,310,696 copies.[3]
329
+
330
+ Thought 3: First for Women was started in 1989. 1844 (Arthur’s Magazine) ¡ 1989 (First for Women), so Arthur’s Magazine was started first.
331
+
332
+ Action 3: Finish[Arthur’s Magazine]
333
+
334
+ (examples)
335
+
336
+ You have attempted to answer the following question before and failed. The following reflection(s) give a plan to avoid failing to answer the question in the same way you did previously. Use them to improve your strategy of correctly answering the given question.
337
+
338
+ (trajectories) (input)
339
+
340
+ # E.2 BASE REASONING PROMPT
341
+
342
+ Solve a question answering task by having a Thought, then Finish with your answer. Thought can reason about the current situation. Finish[answer] returns the answer and finishes the task. You will be given context that you should use to help you answer the question. Start your response with either Action or an indexed Thought
343
+
344
+ Here are some examples:
345
+
346
+ Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
347
+
348
+ Let’s think step by step.
349
+
350
+ Thought 1: The eastern sector of Colorado orogeny extends into the High Plains.
351
+
352
+ Thought 2: High Plains rise in elevation from around 1,800 to 7,000 ft
353
+
354
+ Thought 3: The answer is 1,800 to 7,000 ft.
355
+
356
+ Action: Finish[1,800 to 7,000 ft]
357
+
358
+ (examples)
359
+ Previous trial: (trajectories)
360
+ (input)
361
+
362
+ # E.3 VALUE FUNCTION PROMPT
363
+
364
+ Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
365
+
366
+ (1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
367
+
368
+ (2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
369
+
370
+ (3) Finish[answer], which returns the answer and finishes the task.
371
+
372
+ Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude ”Thus the correctness score is ${ \boldsymbol { \mathrm { s } } } ^ { \flat }$ , where s is an integer from 1 to 10.
373
+
374
+ Question: Which magazine was started first Arthur’s Magazine or First for Women?
375
+
376
+ Thought 1: I need to search Arthur’s Magazine and First for Women, and find which was started first.
377
+
378
+ Action 1: Search[Arthur’s Magazine]
379
+
380
+ Observation 1: Arthur’s Magazine (184400e2 ˘ 0080 ˘ 00931846) was an American literary periodical ˘ published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey’s Lady’s Book.[3]
381
+
382
+ This trajectory is correct as it is reasonable to search for the first magazine provided in the question.
383
+ It is also better to have simple searches corresponding to a single entity, making this the best action.
384
+ Thus the correctness score is 10
385
+ (other examples)
386
+ (failed trajectories)
387
+ (context)
388
+
389
+ # E.4 REFLECTION PROMPT
390
+
391
+ Analyze the trajectories of a solution to a question answering task. The trajectories are labeled by environmental observations about the situation, thoughts that can reason about the current situation and actions that can be three types:
392
+
393
+ (1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
394
+
395
+ (2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
396
+
397
+ (3) Finish[answer], which returns the answer and finishes the task.
398
+
399
+ Given a question and a trajectory, evaluate its correctness and provide your reasoning and analysis in detail. Focus on the latest thought, action, and observation. Incomplete trajectories can be correct if the thoughts and actions so far are correct, even if the answer is not found yet. Do not generate additional thoughts or actions. Then at the last line conclude ”Thus the correctness score is ${ \boldsymbol { \mathrm { s } } } ^ { \flat }$ , where s is an integer from 1 to 10.
400
+
401
+ Question: Which magazine was started first Arthur’s Magazine or First for Women?
402
+
403
+ Thought 1: I need to search Arthur’s Magazine and First for Women, and find which was started first.
404
+
405
+ Action 1: Search[Arthur’s Magazine]
406
+
407
+ Observation 1: Arthur’s Magazine (184400e2 ˘ 0080 ˘ 00931846) was an American literary periodical ˘ published in Philadelphia in the 19th century. Edited by Timothy Shay Arthur, it featured work by Edgar A. Poe, J.H. Ingraham, Sarah Josepha Hale, Thomas G. Spear, and others.[1][2] In May 1846 it was merged into Godey’s Lady’s Book.[3]
408
+
409
+ This trajectory is correct as it is reasonable to search for the first magazine provided in the question.
410
+ It is also better to have simple searches corresponding to a single entity, making this the best action.
411
+ Thus the correctness score is 10
412
+ (other examples)
413
+ (failed trajectories)
414
+ (context)
415
+
416
+ # F PROGRAMMING PROMPTS
417
+
418
+ F.1 HUMANEVAL FUNCTION IMPLEMENTATION EXAMPLE
419
+
420
+ Sample function signature:
421
+
422
+ d e f minSubArraySum ( nums ) : G i v e n a n a r r a y o f i n t e g e r s nums , f i n d t h e minimum sum o f a n y non − empty sub − a r r a y o f nums . Example $\begin{array} { l } { \operatorname* { m i n } _ { \Delta \mathbf { u } \mathbf { b } } \mathrm { A r r a y } \mathrm { S u m } \left( \left[ 2 , \ 3 , \ 4 , \ 1 , \ 2 , \ 4 \right] \right) \ = = \ 1 } \\ { \operatorname* { m i n } _ { \mathrm { S u b } \mathrm { A r r a y } \mathrm { S u m } \left( \left[ - 1 , \ - 2 , \ - 3 \right] \right) \ = \ - 6 } \ = \ - 6 } \end{array}$
423
+
424
+ Sample function body implementation:
425
+
426
+ min sum $=$ f l o a t ( ’ i n f ’ )
427
+ f o r i i n r a n g e ( l e n ( nums ) ) : c u r r e n t s u m $\mathit { \Theta } = \mathit { \Theta } 0$ f o r j i n r a n g e ( i , l e n ( nums ) ) : c u r r e n t s u m $+ =$ nums [ j ] i f c u r r e n t s u m $< \mathrm { \ m i r }$ s u m : min sum $=$ c u r r e n t s u m
428
+ r e t u r n m i n s u m
429
+
430
+ # F.2 BASE ACTING/REASONING PROMPT
431
+
432
+ You are an AI Python assistant. You will be given your previous implementation of a function, a series of unit tests results, and your self-reflection on your previous implementation. Write your full implementation (restate the function signature).
433
+
434
+ Example 1:
435
+
436
+ [previous impl]:
437
+
438
+ d e f a d d ( a : i n t , b : i n t ) $- >$ i n t : G i v e n i n t e g e r s a a n d b , r e t u r n t h e t o t a l v a l u e o f a a n d b . r e t u r n a − b
439
+
440
+ [unit test results from previous impl]:
441
+
442
+ Tested passed:
443
+
444
+ Tests failed: assert add $( 1 , 2 ) = = 3 .$ # output: -1 assert add $( 1 , 2 ) = = 4$ # output: -1 [reflection on previous impl]:
445
+
446
+ The implementation failed the test cases where the input integers are 1 and 2. The issue arises because the code does not add the two integers together, but instead subtracts the second integer from the first. To fix this issue, we should change the operator from $\cdot _ { - } \cdot$ to $^ { \bullet } + ^ { \bullet }$ in the return statement. This will ensure that the function returns the correct output for the given input.
447
+
448
+ [improved impl]:
449
+
450
+ d e f a d d ( a : i n t , b : i n t ) $- >$ i n t : G i v e n i n t e g e r s a a n d b , r e t u r n t h e t o t a l v a l u e o f a a n d b . r e t u r n a + b
451
+
452
+ # F.3 REFLECTION PROMPT
453
+
454
+ You are a Python programming assistant. You will be given a function implementation and a series of unit test results. Your goal is to write a few sentences to explain why your implementation is wrong as indicated by the tests. You will need this as guidance when you try again later. Only provide the few sentence description in your answer, not the implementation. You will be given a few examples by the user.
455
+
456
+ Example 1: [previous impl]:
457
+
458
+ d e f a d d ( a : i n t , b : i n t ) $- >$ i n t :
459
+
460
+ G i v e n i n t e g e r s a a n d b , r e t u r n t h e t o t a l v a l u e o f a a n d b . r e t u r n a − b
461
+
462
+ [unit test results from previous impl]:
463
+
464
+ Tested passed:
465
+ Tests failed:
466
+ assert add $( 1 , 2 ) = = 3$ # output: -1 assert ad $1 ( 1 , 2 ) = = 4$ # output: -1
467
+
468
+ [reflection on previous impl]:
469
+
470
+ The implementation failed the test cases where the input integers are 1 and 2. The issue arises because the code does not add the two integers together, but instead subtracts the second integer from the first. To fix this issue, we should change the operator from ‘-‘ to $^ { \bullet } + ^ { \bullet }$ in the return statement. This will ensure that the function returns the correct output for the given input.
471
+
472
+ # F.4 TEST CASE GENERATION PROMPT
473
+
474
+ You are an AI coding assistant that can write unique, diverse, and intuitive unit tests for functions given the signature and docstring.
475
+
476
+ (input)
477
+
478
+ # G WEBSHOP PROMPTS
479
+
480
+ G.1 ACTING PROMPT
481
+
482
+ Webshop
483
+
484
+ Instruction:
485
+
486
+ i would like a 3 ounce bottle of bright citrus deodorant for sensitive skin, and price lower than 50.00 dollars
487
+
488
+ [Search]
489
+
490
+ Action: search[3 ounce bright citrus deodorant sensitive skin]
491
+
492
+ Observation:
493
+
494
+ [Back to Search]
495
+
496
+ Page 1 (Total results: 50)
497
+
498
+ [Next ] [B078GWRC1J]
499
+
500
+ Bright Citrus Deodorant by Earth Mama — Natural and Safe for Sensitive Skin, Pregnancy and Breastfeeding, Contains Organic Calendula 3-Ounce
501
+
502
+ $\$ 10.99$ [B078GTKVXY]
503
+
504
+ Ginger Fresh Deodorant by Earth Mama — Natural and Safe for Sensitive Skin, Pregnancy and Breastfeeding, Contains Organic Calendula 3-Ounce
505
+
506
+ $\$ 10.99$ [B08KBVJ4XN]
507
+
508
+ Barrel and Oak - Aluminum-Free Deodorant, Deodorant for Men, Essential Oil-Based Scent, 24- Hour Odor Protection, Cedar & Patchouli Blend, Gentle on Sensitive Skin (Mountain Sage, 2.7 oz, 2-Pack)
509
+
510
+ $\$ 15.95$
511
+
512
+ Action: think[B078GWRC1J and B078GTKVXY are bright citrus deodorant less then 50 dollars. I can check B078GWRC1J first.]
513
+
514
+ Observation: OK.
515
+
516
+ Action: click[B078GWRC1J]
517
+ Observation:
518
+ [Back to Search]
519
+ [Prev]
520
+
521
+ scent [assorted scents][bright citrus][calming lavender][ginger fresh][simply non-scents] size [travel set (4-pack)][3 ounce (pack of 1)][3-ounce (2-pack)] Bright Citrus Deodorant by Earth Mama — Natural and Safe for Sensitive Skin, Pregnancy and Breastfeeding, Contains Organic Calendula 3- Ounce
522
+
523
+ Price: $\$ 10.99$
524
+
525
+ Rating: N.A. [Description] [Features] [Reviews] [Buy Now]
526
+
527
+ Action: think[For 3 ounce bottle of bright citrus deodorant for sensitive skin, the item has options ’bright citrus’ and ’3 ounce (pack of 1)’ and seems good to buy.]
528
+
529
+ Observation: OK.
530
+
531
+ Action: click[bright citrus] Observation: You have clicked bright citrus.
532
+
533
+ Action: click[3 ounce (pack of 1)] Observation: You have clicked 3 ounce (pack of 1).
534
+
535
+ Action: click[Buy Now]
536
+
537
+ # G.2 VALUE FUNCTION PROMPT
538
+
539
+ Given an item to purchase and a trajectory that aims to buy an item that exactly matches the specification, which corresponds to the ideal score of 1.0, analyze the following trajectory, then at the last line conclude ”Thus the correctness score is $\mathbf { s } ^ { \flat }$ , where s is an integer from 1 to 10.
540
+
541
+ Here are some examples
542
+
543
+ Webshop Instruction:
544
+
545
+ i am looking for dairy free and apple variety pack of chips, and price lower than 30.00 dollars [Search]
546
+
547
+ Action: search[dairy free and apple variety pack of chips]
548
+
549
+ Observation:
550
+ [Back to Search]
551
+ Page 1 (Total results: 50)
552
+ [Next]
553
+ [B07HRFJWP8]
554
+
555
+ Enjoy Life Foods Soft Baked Ovals, Breakfast Bars, Nut Free Bars, Soy Free, Dairy Free, Non GMO, Gluten Free, Vegan, Variety Pack, 4 Boxes (20 Bars Total)
556
+
557
+ $\$ 100.0$
558
+
559
+ [B01KMHY5PG]
560
+ Enjoy Life Soft Baked Chewy Bars, Variety Pack, Nut Free Bars, Soy Free, Dairy Free, Gluten Free,
561
+ 6 Boxes (30 Total Bars)
562
+
563
+ $\$ 21.49$
564
+
565
+ [B008D2X8C4]
566
+
567
+ Enjoy Life Lentil Chips Variety Pack, Dairy Free Chips, Soy Free, Nut Free, Non GMO, Vegan, Gluten Free, 24 Bags (0.8 oz)
568
+
569
+ $\$ 100.0$
570
+
571
+ Action: think[The first two items are not what I want. The third item is the dairy free and apple variety pack of chips I want.]
572
+
573
+ Observation: OK.
574
+
575
+ Action: click[B008D2X8C4]
576
+ Observation:
577
+ [Back to Search]
578
+ [Prev]
579
+ flavor name [dill and sour cream][garlic & parmesan][light sea salt][margherita pizza][thai chili
580
+ lime][variety pack] size [0.8 ounce (pack of 24)][4 ounce (pack of 12)]
581
+
582
+ Price: $\$ 100.0$ Rating: N.A. [Description] [Features] [Reviews] [Buy Now]
583
+
584
+ Action: think[The item has options ’variety pack’ and ’0.8 ounce (pack of 24)’ and seems good to buy.]
585
+
586
+ Observation: OK.
587
+
588
+ Action: click[variety pack]
589
+
590
+ Observation: You have clicked variety pack.
591
+
592
+ Action: click[0.8 ounce (pack of 24)]
593
+
594
+ Observation: You have clicked 0.8 ounce (pack of 24).
595
+
596
+ Action: click[Buy Now]
597
+
598
+ Reflection: In this attempt, I was unsuccessful. I accidentally bought a product that was $\$ 100$ , which is more than my budget of $\$ 30$ . Either way, the initial search results were not good. Next time, I will do search[”variety pack of chips”] and then check if the results meet the dairy free and the $\$ 30$ budget constraints. I will continue to refine my searches so that I can find more products.
599
+
600
+ Thus the correctness score is 5
601
+
602
+ # G.3 REFLECTION PROMPT
603
+
604
+ Given an item to purchase and a trajectory that aims to buy an item that exactly matches the specification, which corresponds to the ideal score of 1.0, analyze the following trajectory, then at the last line conclude ”Thus the correctness score is $\mathbf { s } ^ { \flat }$ , where s is an integer from 1 to 10.
605
+
606
+ Here are some examples
607
+
608
+ Webshop
609
+
610
+ Instruction: i am looking for dairy free and apple variety pack of chips, and price lower than 30.00 dollars
611
+
612
+ [Search]
613
+
614
+ Action: search[dairy free and apple variety pack of chips]
615
+
616
+ Observation:
617
+ [Back to Search]
618
+ Page 1 (Total results: 50)
619
+ [Next]
620
+
621
+ [B07HRFJWP8]
622
+
623
+ Enjoy Life Foods Soft Baked Ovals, Breakfast Bars, Nut Free Bars, Soy Free, Dairy Free, Non GMO, Gluten Free, Vegan, Variety Pack, 4 Boxes (20 Bars Total)
624
+
625
+ $\$ 100.0$
626
+
627
+ [B01KMHY5PG]
628
+ Enjoy Life Soft Baked Chewy Bars, Variety Pack, Nut Free Bars, Soy Free, Dairy Free, Gluten Free,
629
+ 6 Boxes (30 Total Bars)
630
+
631
+ $\$ 21.49$
632
+
633
+ [B008D2X8C4]
634
+
635
+ Enjoy Life Lentil Chips Variety Pack, Dairy Free Chips, Soy Free, Nut Free, Non GMO, Vegan, Gluten Free, 24 Bags (0.8 oz)
636
+
637
+ Action: think[The first two items are not what I want. The third item is the dairy free and apple variety pack of chips I want.]
638
+
639
+ Observation: OK.
640
+
641
+ Action: click[B008D2X8C4]
642
+
643
+ Observation:
644
+
645
+ [Back to Search]
646
+
647
+ [Prev]
648
+
649
+ flavor name [dill and sour cream][garlic & parmesan][light sea salt][margherita pizza][thai chili lime][variety pack] size [0.8 ounce (pack of 24)][4 ounce (pack of 12)]
650
+
651
+ Price: $\$ 100.0$
652
+
653
+ Rating: N.A. [Description] [Features] [Reviews] [Buy Now]
654
+
655
+ Action: think[The item has options ’variety pack’ and ’0.8 ounce (pack of 24)’ and seems good to buy.]
656
+
657
+ Observation: OK.
658
+
659
+ Action: click[variety pack] Observation: You have clicked variety pack.
660
+
661
+ Action: click[0.8 ounce (pack of 24)] Observation: You have clicked 0.8 ounce (pack of 24).
662
+
663
+ Action: click[Buy Now]
664
+
665
+ Reflection: In this attempt, I was unsuccessful. I accidentally bought a product that was $\$ 100$ , which is more than my budget of $\$ 30$ . Either way, the initial search results were not good. Next time, I will do search[”variety pack of chips”] and then check if the results meet the dairy free and the $\$ 30$ budget constraints. I will continue to refine my searches so that I can find more products.
666
+
667
+ Reflection:
parse/test/6LNTSrJjBe/6LNTSrJjBe_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/6LNTSrJjBe/6LNTSrJjBe_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/6LNTSrJjBe/6LNTSrJjBe_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/BrwIZVSc7b/BrwIZVSc7b_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DwgRm72GQF/DwgRm72GQF.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DwgRm72GQF/DwgRm72GQF_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DwgRm72GQF/DwgRm72GQF_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/DwgRm72GQF/DwgRm72GQF_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/TQeT7UupFk/TQeT7UupFk.md ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # One-for-All: Generalized LoRA for Parameter-Efficient Fine-tuning
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # Abstract
6
+
7
+ We present Generalized LoRA (GLoRA), a flexible approach for universal parameter-efficient fine-tuning tasks. Enhancing Low-Rank Adaptation (LoRA), GLoRA employs a generalized prompt module to optimize pre-trained model weights and adjust intermediate activations, providing more flexibility and capability across diverse tasks and datasets. Moreover, GLoRA facilitates efficient parameter adaptation by employing a scalable, modular, and layer-wise structure search that learns the individual adapter of each layer. Originating from a unified mathematical formulation, GLoRA exhibits strong transfer learning, fewshot learning and domain generalization abilities, as it adapts to new tasks through not only weights but also additional dimensions like activations. Comprehensive experiments demonstrate that GLoRA outperforms all previous methods in natural, specialized, and structured benchmarks in the field of vision, achieving superior accuracy with fewer parameters and computations. To demonstrate the applicability in the language domain, we perform GLoRA on LLaMA-1/2 models, which also achieve considerable enhancements compared to the original LoRA. Furthermore, our structural re-parameterization design ensures that GLoRA incurs no extra inference cost, rendering it a practical solution for resourcelimited applications.
8
+
9
+ # 1 Introduction
10
+
11
+ The remarkable achievements of large-scale deep neural networks in recent years have revolutionized the field of artificial intelligence, demonstrating unprecedented performance across various tasks and domains. These highly complex models, often with millions or even billions of parameters, have demonstrated remarkable capabilities in areas such as computer vision (Dosovitskiy et al., 2021), natural language understanding (Vaswani et al., 2017), and speech recognition (Radford et al., 2022). Typically, these colossal models are pre-trained on general and large-scale datasets, such as ImageNet (Deng et al., 2009a), and are subsequently adapted to downstream target scenarios through fine-tuning or transfer learning. Given the immense computational resources required by large pre-trained architectures, many parameter-efficient finetuning (PEFT) methods (Hu et al., 2021; Shen et al., 2021; Jia et al., 2022; Zhang et al., 2022; Luo et al., 2023) have been proposed. For instance, Low-Rank Adaptation (LoRA) (Hu et al., 2021) aims to reduce the number of trainable parameters by exclusively learning pairs of rank-decomposition matrices whilst keeping the original model parameter static. Adapter (Houlsby et al., 2019) implements bottleneck adapter modules and incorporates a modest number of task-specific parameters into a fixed pre-trained model. Similarly, Visual Prompt Tuning (VPT) (Jia et al., 2022) introduces a minimal number of learnable parameters to the input of the Transformer, leaving the entire backbone frozen during fine-tuning.
12
+
13
+ However, distinct downstream datasets often possess unique characteristics, such as natural, specialized, and structured data, which differ significantly in distribution and composition. A static fine-tuning strategy may not sufficiently account for these disparities, thereby hindering its capacity to adapt to diverse datasets. To rectify this, we propose a flexible, parameter-efficient fine-tuning scheme in this work to manage the variations of multiple downstream datasets within a consolidated formulation. Our approach presents a generalized version of LoRA from a unified parameter-efficient fine-tuning perspective, amplifying LoRA’s capability, scalability, and adaptability by rescaling and shifting intermediate activations, in conjunction with implementing a structural re-parameterization design, etc. It is challenging to devise a unified method that integrates all adjustable dimensions and possibilities when tuning a pre-trained network, especially in the case of transformer architectures, while our proposed approach presents a practicable solution to navigate this complexity.
14
+
15
+ In detail, our approach proposes a unified framework that can achieve comprehensive fine-tuning paradigms from a single formulation, i.e., a One-for-All fine-tuning architecture. It comprises a supernet, which, when optimized cost-effectively through evolutionary search, yields results that surpass those of prevailing fine-tuning methodologies necessitating expensive data-dependent hyperparameter search. The proposed approach exhibits the following advantages: (1) It concurrently takes into account multiple dimensions to enhance capability and flexibility during fine-tuning, encompassing weights, features, and input tokens. (2) It conducts an implicit search devoid of any manual hyperparameter tuning, thus justifying the increased training time. (3) It incurs no additional inference cost thanks to our structural re-parameterization architecture, whereby the extra fine-tuning parameters will be fused to the proximate projection weights post-training.
16
+
17
+ We conduct comprehensive experiments on VTAB-1K (Zhai et al., 2020), ImageNet (Deng et al., 2009a) and its variants (Recht et al., 2019; Wang et al., 2019; Hendrycks et al., 2021b;a), and Huggingface leaderboard benchmarks (Edward Beeching, 2023) for evaluating on language domain. The VTAB-1K dataset comprises 19 heterogeneous vision datasets, enveloping a broad spectrum of visual domains that include natural objects and scenes, textures and shapes, satellite imagery, among others. GLoRA surpasses all previous state-ofthe-art PEFT methods by a substantial margin in terms of average accuracy. Additionally, we evaluate the model’s few-shot learning capacity on five fine-grained visual recognition datasets, akin to prior works (Zhang et al., 2022; Jia et al., 2022), along with its ability for domain generalization and robustness on ImageNetV2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b), and ImageNet-R (Hendrycks et al., 2021a) datasets. GLoRA significantly outperforms previous methods across all these benchmarks, without incurring any extra computational overhead during the inference phase.
18
+
19
+ Our contributions:
20
+
21
+ • We propose Generalized LoRA (GLoRA), a novel parameter-efficient fine-tuning framework. GLoRA enhances the low-rank adaptation approach with a more generalized prompt module design per layer, offering enhanced capability and flexibility in finetuning. GLoRA offers a unified framework that achieves universal fine-tuning paradigms from a single formulation, i.e., a One-for-All $^ { 1 }$ fine-tuning architecture. During inference, the adapters yielded through GLoRA seamlessly integrate into the base network, resulting in no additional model weights. Thus, it incurs no extra inference computational load.
22
+ • We conduct extensive experiments on large vision (ViT-B) and language models (LLaMA-1 and 2) with downstream fine-tuning, few-shot learning, and domain generalization using various datasets. Our experimental results demonstrate that GLoRA outperforms all previous methods on these benchmarks while requiring only a modest amount of additional training compute and a small number of extra trainable parameters but crucially no additional inference cost.
23
+
24
+ # 2 GLoRA
25
+
26
+ In this section, we start from providing a mathematical overview of existing state-of-the-art PEFT methods and discuss the advantages and disadvantages for them. Then, we introduce a unified formulation of integrating all existing SOTA PEFT methods and elaborate our proposed generalized LoRA in detail following this unified formulation perspective. After that, a structural re-parameterization design is presented to show the inference efficiency without additional cost. An evolutionary search for optimal layer-wise configurations is also introduced to achieve the goal of generalized LoRA. We further give the theoretical analysis and discussions on the higher capability of the proposed method.
27
+
28
+ # 2.1 Previous Solutions with Limitations
29
+
30
+ Visual Prompt Tuning (Jia et al., 2022): VPT introduces a small amount of task-specific learnable parameters into the input space while freezing the entire pre-trained Transformer backbone during downstream fine-tuning. They propose two strategies:
31
+
32
+ VPT-Shallow, i.e., only input space has the trainable prompt:
33
+
34
+ $$
35
+ \begin{array} { r l } & { [ { \bf x } _ { 1 } , { \bf Z } _ { 1 } , { \bf E } _ { 1 } ] = L _ { 1 } \left( [ { \bf x } _ { 0 } , { \bf P } , { \bf E } _ { 0 } ] \right) } \\ & { [ { \bf x } _ { i } , { \bf Z } _ { i } , { \bf E } _ { i } ] = L _ { i } \left( [ { \bf x } _ { i - 1 } , { \bf Z } _ { i - 1 } , { \bf E } _ { i - 1 } ] \right) } \end{array}
36
+ $$
37
+
38
+ VPT-Deep, i.e., every layer has the trainable prompt. The formulation is:
39
+
40
+ $$
41
+ [ { \bf x } _ { i } , \ldots , { \bf E } _ { i } ] = L _ { i } \left( [ { \bf x } _ { i - 1 } , { \bf P } _ { i - 1 } , { \bf E } _ { i - 1 } ] \right)
42
+ $$
43
+
44
+ where $\mathbf { P } = \left\{ p ^ { k } \in \mathbb { R } ^ { d } \mid k \in \mathbb { N } , 1 \leq k \leq p \right\}$ is a collection of $p$ trainable prompts, $\mathbf { Z _ { i } } \in \mathbb { R } ^ { p \times d }$ represents the features computed by the $i ^ { t h }$ Transformer layer, $\mathbf { x _ { 0 } } \in \mathbb { R } ^ { d }$ is the [CLS] token, $\mathbf { E _ { i } } = \left\{ e _ { i } ^ { j } \in \mathbb { R } ^ { d } \mid j \in \mathbb { N } , 1 \leq j \leq m \right\}$ are the image patch embeddings, $\boldsymbol { L } _ { i }$ denotes the $i ^ { t h }$ transformer layer and $m$ denotes the fixed-sized patches. Prompts use ${ < } 1 \%$ trainable parameters as compared to the original model. VTP-Deep outperforms full fine-tuning on many vision tasks and also has better accuracy in a low data regime. However, VPT increases cost in the inference stage which is not negligible.
45
+
46
+ AdaptFormer (Chen et al., 2022): AdaptFormer introduces a parallel learnable branch of two linear layers and ReLU over the MLP block and updates only this path while freezing other parts.
47
+
48
+ $$
49
+ \tilde { x } _ { \ell } = \mathbf { R e L U } \left( \mathbf { L N } \left( x _ { \ell } ^ { \prime } \right) \cdot \mathbf { W } _ { \mathrm { d o w n } } \right) \cdot \mathbf { W } _ { \mathrm { u p } }
50
+ $$
51
+
52
+ $$
53
+ x _ { \ell } = \mathbf { M L P } \left( \operatorname { L N } \left( x _ { \ell } ^ { \prime } \right) \right) + s \cdot \tilde { x } _ { \ell } + x _ { \ell } ^ { \prime }
54
+ $$
55
+
56
+ where $ { \boldsymbol { { x } } } _ { \ell } ^ { \prime }$ are the tokens after Multi-head self-attention at the $\ell$ -th layer. $\mathbf { W } _ { \mathrm { d o w n } } \in \mathbb { R } ^ { d \times \hat { d } }$ and $\mathbf { W } _ { \mathrm { u p } } \in \mathbb { R } ^ { \hat { d } \times d }$ are weights corresponding to a down-projection layer and an up-projection layer from the parallel branch, respectively; and $s$ denotes a scale factor. AdaptFormer also increases the inference cost due to the presence of a parallel branch.
57
+
58
+ LoRA (Hu et al., 2021): LoRA proposes to freeze the pre-trained model weights and injects trainable lowrank decomposition matrices into each layer. It learns only the residual from pre-trained weight. Assuming $\mathbf { W } _ { 0 }$ , $\mathbf { b } _ { 0 }$ , $x$ are pre-trained weights, bias and input, let $f$ be a linear layer, thus $f ( x ) = \mathbf { W } _ { 0 } x + \mathbf { b } _ { 0 }$ . During fine-tuning, $\mathbf { W } _ { 0 }$ and $\mathbf { b } _ { 0 }$ are frozen, the learning process can be:
59
+
60
+ $$
61
+ f ( x ) = \mathbf { W } _ { 0 } x + \Delta \mathbf { W } x + \mathbf { b } _ { 0 } = \mathbf { W } _ { \mathrm { L o R A } } x + \mathbf { b } _ { 0 }
62
+ $$
63
+
64
+ where $\Delta \mathbf { W }$ is the low-rank decomposition weights that are learnable.
65
+
66
+ Scaling & Shifting Features (SSF) (Lian et al., 2022): SSF module scales and shifts features after every MLP, MHSA, Layernorm module during training, and performs re-parameterization during inference as it is a linear structure.
67
+
68
+ $$
69
+ \pmb { y } = \pmb { \gamma } \odot \pmb { x } + \pmb { \beta }
70
+ $$
71
+
72
+ where $\mathbf { \pmb { y } }$ is the output features. $\gamma \in \mathbb { R } ^ { d }$ and $\beta \in \mathbb { R } ^ { d }$ are the scale and shift factors, $\odot$ is the dot product.
73
+ This method has no increase in inference but the capability is limited to feature adaptation.
74
+
75
+ FacT (Jie & Deng, 2022): FacT proposes to use a tensorization-decomposition method to store the additional weight, the weights of the model are tensorized into a single 3D tensor, and their additions are then decomposed into lightweight factors. In fine-tuning, only the factors will be updated and stored. They propose two strategies:
76
+
77
+ $$
78
+ f ( x ) = \mathbf { W } _ { 0 } x + \mathbf { b } _ { 0 } + \mathbf { U } \Sigma \mathbf { V } x = \left( \mathbf { W } _ { 0 } + \mathbf { U } \Sigma \mathbf { V } \right) x + \mathbf { b } _ { 0 }
79
+ $$
80
+
81
+ where $\Delta \mathbf { W }$ in LoRA is decomposed into $\mathbf { U } \in \mathbb { R } ^ { d \times r _ { 1 } }$ , $\mathbf { V } \in \mathbb { R } ^ { d \times r _ { 2 } }$ , $\pmb { \Sigma } \in \mathbb { R } ^ { 1 2 L \times r _ { 1 } \times r _ { 2 } }$ and $L$ denotes the total number of layers in the network. This is Tensor-Train format.
82
+
83
+ $$
84
+ f ( x ) = \mathbf { W } _ { 0 } x + \mathbf { b } _ { 0 } + \mathbf { U C P V } x = \left( \mathbf { W } _ { 0 } + \mathbf { U C P V } \right) x + \mathbf { b } _ { 0 }
85
+ $$
86
+
87
+ where $\Delta \mathbf { W }$ in LoRA is decomposed into $\mathbf { U } \in \mathbb { R } ^ { d \times r _ { 2 } }$ , $\mathbf { V } \in \mathbb { R } ^ { d \times r _ { 3 } }$ , $\mathbf { C } \in \mathbb { R } ^ { r _ { 1 } \times r _ { 2 } \times r _ { 3 } }$ and $\mathbf { P } \in \mathbb { R } ^ { 1 2 L \times r _ { 1 } }$ . This is Tucker format.
88
+
89
+ RepAdapter (Luo et al., 2023): RepAdapter inserts lightweight networks into the pre-trained models, and the additional parameters will be re-parameterized to the nearby projection weights after training. Adding sequential (not parallel) adapter to both MHA and MLP, adapter is linear thus can be re-parameterized, and has two layers: downsampling dense FC layer to downsample inputs; upsampling downsampled features that are divided into group, and each group has an upsampling layer. The group of upsampling layers can be merged into a single sparse upsampling layer and can be re-parameterized directly into the original Multi-Layer Perceptron or Multi-head self-attention layers. The formulation can be:
90
+
91
+ $$
92
+ \begin{array} { r l } { f ( x ) } & { = \mathbf { W } _ { 0 } \left( x + \mathbf { W } _ { u } \left( \mathbf { W } _ { d } x + \mathbf { b } _ { d } \right) + \mathbf { b } _ { u } \right) + \mathbf { b } _ { 0 } } \\ & { = \left( \mathbf { W } _ { 0 } + \mathbf { W } _ { 0 } \mathbf { W } _ { u } \mathbf { W } _ { d } \right) x + \mathbf { W } _ { 0 } \mathbf { W } _ { u } \mathbf { b } _ { d } + \mathbf { W } _ { 0 } \mathbf { b } _ { u } + \mathbf { b } _ { 0 } } \end{array}
93
+ $$
94
+
95
+ # where $\mathbf { W } _ { u } \in \mathbb { R } ^ { d \times d }$ , $\mathbf { W } _ { d } \in \mathbb { R } ^ { \hat { d } \times d }$ , $\mathbf { b } _ { u } \in \mathbb { R } ^ { d }$ and $\mathbf { b } _ { b } \in \mathbb { R } ^ { d }$ are learnable weights and biases, respectively.
96
+
97
+ Limitations: In general, many existing PEFT methods such as (VPT, Adapter) increase the inference time since the proposed structure cannot be re-parameterized. Direct prompt tuning is also hard to design as it brings in computational burden and requires hyper-parameter tuning i.e., how and where to place prompts. LoRA can be re-parameterized at inference but requires manual rank search and hence doesn’t scale up automatically for larger matrices. Also, the adaptation ability is constrained in the weight space. SSF / Repadaptor cannot learn the weight change i.e., $\Delta \mathbf { W }$ in weight space, whereas LoRA / FacT cannot efficiently learn the scaling and shifting of feature change i.e., $\Delta \mathbf { H }$ in features space. Both feature and weight space need flexibility while performing transfer learning from a large model. Our proposed idea in this work attempts at: $\Delta \mathbf { W }$ tuning, $\Delta \mathbf { H }$ tuning, along with $\mathbf { W }$ and $\mathbf { H }$ scale and shift learning.
98
+
99
+ # 2.2 A Unified Formulation of One-for-All
100
+
101
+ For model fine-tuning, we propose a unified formulation that encompasses tuning in both weight and feature space along with VPT-Deep level prompt design. Additionally, we adopt a re-parameterization strategy to incorporate auxiliary parameters into the adjacent projection weights during the inference stage. Broadly speaking, our method serves as a superset of all prior solutions, i.e., one-for-all mechanism. By setting different support tensors to zero, our GLoRA can be reduced to any of these predecessor methods. Unlike NOAH (Zhang et al., 2022), our architecture can be succinctly articulated as a unified mathematical equation. The consolidated formulation to represent all tunable spaces can be represented as follows:
102
+
103
+ ![](images/2ab79b026fd54b215b513d64f5291e3054cb546a0fcdbf1bd6ee1cb7874ae345.jpg)
104
+ Figure 1: Schematic representation of a linear layer adapted with GLoRA.
105
+
106
+ $$
107
+ f \left( x \right) = \left( \mathbf { W } _ { 0 } + \mathbf { W } _ { 0 } \mathbf { A } + \mathbf { B } \right) x + \mathbf { C W } _ { 0 } + \mathbf { D } \mathbf { b } _ { 0 } + \mathbf { E } + \mathbf { b } _ { 0 }
108
+ $$
109
+
110
+ where A, $\mathbf { B }$ , $\mathbf { C }$ , $\mathbf { D }$ , $\mathbf { E }$ are the trainable support tensors for downstream tasks in our GLoRA, $\mathbf { W } _ { 0 }$ and $\mathbf { b } _ { 0 }$ are frozen during whole fine-tuning. A is utilized to scale the weight. $\mathbf { B }$ has the role to scale the input and shift the weight. $\mathbf { C }$ is the layer-wise prompt serving a similar function of VPT-Deep, $\mathbf { D }$ and $\mathbf { E }$ are used to scale and shift the bias, respectively. A detailed illustration is shown in Figure 1.
111
+
112
+ Module Design. In this subsection, we delineate the methodology for designing layer-wise adaptors or prompt modules for A, B, $\mathbf { C }$ , D, E. In a broad sense, these can take the form of scalars, vectors, low-rank decompositions, or none. scalar denotes a matrix-scaler product, vector denotes a matrixvector product, low-rank decompositions denotes two low-rank matrices used to generate a final matrix and an element-wise matrix-matrix product being employed. Based on the role of these trainable support tensors, they can be sampled from the following respective search spaces:
113
+
114
+ $$
115
+ \begin{array} { r l } & { \mathbf { A } = \{ \mathrm { L o R A } , \mathrm { v e c t o r } , \mathrm { s c a l a r } , \mathrm { n o n e } \} } \\ & { \mathbf { B } = \{ \mathrm { L o R A } , \mathrm { v e c t o r } , \mathrm { s c a l a r } , \mathrm { n o n e } \} } \\ & { \mathbf { C } = \{ \mathrm { L o R A } , \mathrm { v e c t o r } , \mathrm { n o n e } \} } \\ & { \mathbf { D } = \{ \mathrm { v e c t o r } , \mathrm { s c a l a r } , \mathrm { n o n e } \} } \\ & { \mathbf { E } = \{ \mathrm { v e c t o r } , \mathrm { s c a l a r } , \mathrm { n o n e } \} } \end{array}
116
+ $$
117
+
118
+ where none indicates zero, if all the trainable support tensors are zero, the model will be degraded to the original formulation and training recipe. In particular, suppose $\mathbf { W } _ { 0 } \in \mathbb { R } ^ { d \times d }$ is the original weight matrix. For every layer, we define $\mathbf { A } _ { d } \in \mathbb { R } ^ { d \times r }$ , $\mathbf { A } _ { u } \in \mathbb { R } ^ { r \times d }$ , $\mathbf { B } _ { d } \in \mathbb { R } ^ { d \times r }$ , $\mathbf { B } _ { u } \in \mathbb { R } ^ { r \times d }$ , $\mathbf { C } _ { d } \in \mathbb { R } ^ { d \times r }$ , $\mathbf { C } _ { u } \in \mathbb { R } ^ { r \times 1 }$ , $\mathbf { D } \in \mathbb { R } ^ { d \times 1 }$ and $\mathbf { E } \in \mathbb { R } ^ { d \times 1 }$ . We also define a multi-path supernet of all possible subnets and randomly sample a subnet during any given supernet training iteration for optimization. A subnet comprises of a single path network with different layerwise support tensors sampled from 11. Depending upon the current subnet configuration, in case of LoRA with rank $r _ { 1 } < r$ , $\mathbf { A } _ { d } ^ { r _ { 1 } } \in \mathbb { R } ^ { d \times r _ { 1 } }$ , $\mathbf { A } _ { u } ^ { r _ { 1 } } \in \mathbb { R } ^ { r _ { 1 } \times d }$ is indexed from $\mathbf { A } _ { d }$ and $\mathbf { A } _ { u }$ respectively; and $\mathbf { A } = \mathbf { A } _ { d } ^ { r _ { 1 } } \times \mathbf { A } _ { u } ^ { r _ { 1 } }$ is used as the final tensor, in case of vector $\mathbf { A } \in \mathbb { R } ^ { d \times 1 }$ is indexed from $\mathbf { A } _ { d }$ and in case of scalar $\mathbf { A } \in \mathbb { R } ^ { 1 \times 1 }$ is indexed from $\mathbf { A } _ { d }$ . A similar strategy is followed for all other support tensors depending upon the current sampled configuration in the subnet. This weight entanglement strategy helps to increase the search space without increasing the number of parameters substantially and also shows faster convergence due to weight sharing in different subnets.
119
+
120
+ Moreover, without defining any existing adapter/module in the network explicitly, GLoRA proposes a much more general formulation that implicitly mimics the behavior of many existing works. In Table 1, we show how GLoRA is able to approximately mimic the behavior of many existing works by setting support tensors to specific attributes of the search space.
121
+
122
+ <table><tr><td>Method</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td></tr><tr><td>LoRA</td><td>None</td><td>LoRA</td><td>None</td><td>None</td><td>None</td></tr><tr><td>VPT</td><td>None</td><td>None</td><td>Vector</td><td>None</td><td>None</td></tr><tr><td>SSF</td><td>Vector</td><td>None</td><td>Vector</td><td>Vector</td><td>None</td></tr><tr><td>RepAdapter</td><td>LoRA</td><td>None</td><td>None</td><td>Vector</td><td>None</td></tr></table>
123
+
124
+ Table 1: Support tensor attributes for mimicking prior methods using GLoRA’s formulation.
125
+
126
+ # 2.3 Structural Re-parameterization Design and Inference Efficiency Analysis
127
+
128
+ The fundamental aspect enabling re-parameterization (Ding et al., 2021; Hu et al., 2021) is the elimination of non-linearity amidst adjacent transformations, thereby permitting the absorption of supplementary parameters into the preceding ones. As mentioned in RepAdapter (Luo et al., 2023), the removal of such non-linear layers does not detrimentally impact the performance of the networks. The precise concept of GLoRA re-parameterization is explicated as follows:
129
+
130
+ $$
131
+ f ( x ) = \mathbf { W } _ { \mathrm { u n i } } x + \mathbf { b } _ { \mathrm { u n i } }
132
+ $$
133
+
134
+ where $\mathbf { W } _ { \mathrm { u n i } }$ and ${ \bf b } _ { \mathrm { u n i } }$ are our final unified trained weight and bias in GLoRA. They are re-parameterized according to Eq 10:
135
+
136
+ $$
137
+ \mathbf { W } _ { \mathrm { u n i } } = \mathbf { W } _ { 0 } + \mathbf { W } _ { 0 } \mathbf { A } + \mathbf { B }
138
+ $$
139
+
140
+ $$
141
+ \mathbf { b } _ { \mathrm { u n i } } = \mathbf { C } \mathbf { W } _ { 0 } + \mathbf { D } \mathbf { b } _ { 0 } + \mathbf { E } + \mathbf { b } _ { 0 }
142
+ $$
143
+
144
+ As a result, the re-parameterization strategy we employ, which integrates learnable parameters into the existing weight matrix offers a distinct advantage as it imposes no additional computational burden during the inference phase. This is further discussed in Section 4 where we provide thorough inference efficiency analysis of GLoRA compared to exisitng works.
145
+
146
+ # 2.4 Evolutionary Search for Optimal Layer-wise Configurations
147
+
148
+ Our design for a unified adaptor is implemented on a per-layer basis, thus allowing for heterogeneity across different layers. To identify the optimal configuration for each layer, we employ the evolutionary search method (Zhang et al., 2022; Shen et al., 2021), which offers a balance of efficiency and effectiveness. Although the training time may increase due to this search process, it is important to note that existing work (Zhang et al., 2022) necessitate an extensive hyperparameter search (such as low-rank in LoRA and FacT, as well as position and size of adapter modules in Adapter (Houlsby et al., 2019), dimension and structure configuration in RepAdapter (Luo et al., 2023), among others), as presented in the appendix. Our unified support tensor design conducts an implicit search that eliminates the need for manual hyperparameter tuning. Therefore, any augmentation in training time is reasonable and well-justified.
149
+
150
+ Evolutionary search consists of reproduction, crossover, and mutation stages. In our scenario, first, a population of support tensor strategies is embedded in vectors and initialized randomly. Each individual strategy consists of a description of a single subnet. After the training of supernet, we start to evaluate each individual subnet to obtain its accuracy on the validation set. Among these evaluated subnets, we select the top $K$ as parents to produce posterity subnets. The next generation subnets are made by mutation and crossover stages. By repeating this process over iterations, we can find the best parameter-efficient fine-tuned subnet with the best validation performance. We first randomly sample 50 subnets from the supernet and then perform an evolutionary search for 20 and 5 epochs on vision and language tasks, respectively. Each step of random pick / crossover / mutation produces 50 new subnets. The probability for crossover and mutation is set to 0.2. Note that we did not perform any hyperparameter search over the evolution hyperparameters and directly use the hyperparameters presented in Zhang et al. (2022). It is potentially possible that conducting this hyperparameter search may improve the performance further.
151
+
152
+ # 3 Experiments
153
+
154
+ Datasets. We thoroughly evaluate GLoRA on VTAB-1K (Zhai et al., 2020) benchmark for various parameter budgets. VTAB-1K comprises 19 image classification tasks clustered into three domains: i) Natural images ii) Specialized tasks consisting of remote sensing and medical datasets; and iii) Structured tasks focusing on scene structure understanding. To test the ability on few-shot learning, we evaluate GLoRA on five fine-grained visual recognition few-shot datasets: Food101 (Bossard et al., 2014), OxfordFlowers102 (Nilsback & Zisserman, 2006), StandfordCars (Krause et al., 2013), OxfordPets (Parkhi et al., 2012), and FGVCAircraft (Maji et al., 2013). Following previous work (Jie & Deng, 2022), we evaluate 1, 2, 4, 8, and 16 shot settings. Next, to show the domain generalization capabilities of GLoRA, we train it on ImageNet (Deng et al., 2009b) for a 16-shot setting and test on four out-of-domain datasets including ImageNetV2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b), and ImageNetR (Hendrycks et al., 2021a). Finally, we show the performance of GLoRA on the Open LLM Leaderboard which consists of four datasets with varying prompt shots, namely AI2 Reasoning Challenge (25-shot) (Clark et al., 2018), TruthfulQA (0-shot) (Lin et al., 2022), HellaSwag (10-shot) (Zellers et al., 2019) and MMLU (5-shot) (Hendrycks et al., 2020).
155
+
156
+ Network Architecture and Implementation Details. For all the vision experiments, we utilize ViTB (Dosovitskiy et al., 2021), a model pre-trained on ImageNet-21K, as our foundational model. For the language experiments, we consider two foundational base models: LLaMA-1-7B (Touvron et al., 2023a) and LLaMA-2-7B (Touvron et al., 2023b).
157
+
158
+ Our supernets undergo a training process spanning 500 epochs and 15 epochs for vision and language datasets respectively, operating with a constant batch size of 64 and a cosine learning rate scheduler. It is crucial to highlight that this precise policy demonstrates robust efficacy across all settings, regardless of the dataset in use. Post the training of supernet, we randomly sample 50 subnets from the supernet and then perform an evolutionary search for 20 and 5 epochs on vision and language tasks, respectively. Each step of random pick / crossover / mutation produces 50 new subnets. The probability for crossover and mutation is set to 0.2. Note that we did not perform any hyperparameter search over the evolution hyperparameters, and hence the performance might even improve after tuning the evolution hyperparameters. Finally, we report the performance of the searched subnet on the test set. The appendix provides further insights into datasetspecific learning rates and specific settings for different datasets.
159
+
160
+ # 3.1 Results on VTAB-1K
161
+
162
+ We train three different GLoRA supernet configurations to vary the number of trainable parameters. The difference in these is only the LoRA dimensions in the search space which varies from 8 and 4 in the largest model, 4 and 2 in the intermediate model, and 2 in the smallest model. This added parameter flexibility in our method allows for user-defined trainable parameter count in the final models. Results on the VTAB-1k benchmark are shown in Table 3.1. We push the state-of-the-art in parameter-efficient transfer learning by up to 2.9%, Even our smallest model outperforms all existing methods by a substantial margin. It is worth noting that GLoRA performs competitively across datasets in contrast to all existing works which fail on at least one dataset, proving GLoRA’s high generalization capabilities. GLoRA pushes the state of the art in as many as 14 out of 19 datasets in the VTAB-1k benchmark while performing competitively on the remaining datasets too.
163
+
164
+ <table><tr><td></td><td>(IN) ure.rd</td><td>4sopeouə.IəJu[</td><td>Natural sted NHAS</td><td>Specialized</td><td></td><td>Structured oT-Jdsp 1O-idsp</td></tr><tr><td>Traditional Finetuning</td><td>井</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Full</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Linear</td><td>85.8 0</td><td></td><td>68.9 87.7 64.3 97.2 86.9 87.4 38.879.7 95.7 84.2 73.9|56.3 58.6 41.7 65.5 57.5 46.7 25.7 29.168.9 64.4 85.0 63.2 97.0 86.3 36.6 51.078.5 87.5 68.5 74.034.3 30.6 33.2 55.4 12.5 20.0 9.6 19.2|57.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="2">PEFTmethods</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>BitFit</td><td>0.10</td><td>-</td><td>72.8 87.0 59.2 97.5 85.3 59.9 51.478.7 91.6 72.9 69.861.5 55.6 32.4 55.9 66.6 40.0 15.7 25.165.2</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>VPT-Shallow</td><td>0.06</td><td></td><td>77.7 86.9 62.6 97.5 87.3 74.5 51.278.2 92.0 75.6 72.9|50.5 58.6 40.5 67.1 68.7 36.1 20.2 34.167.8</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>VPT-Deep</td><td>0.53</td><td>个</td><td>78.8 90.8 65.8 98.0 88.3 78.1 49.681.8 96.1 83.4 68.468.5 60.0 46.5 72.8 73.6 47.9 32.9 37.872.0</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Adapter</td><td>0.16</td><td></td><td>69.2 90.1 68.0 98.8 89.9 82.8 54.384.0 94.9 81.9 75.580.9 65.3 48.6 78.3 74.8 48.5 29.9 41.673.9</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AdaptFormer0.16</td><td></td><td>→</td><td>70.8 91.2 70.5 99.1 90.9 86.6 54.883.0 95.8 84.4 76.381.9 64.3 49.3 80.3 76.3 45.7 31.7 41.174.7</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LoRA</td><td>0.29</td><td>-</td><td>67.1 91.4 69.4 98.8 90.4 85.3 54.084.9 95.3 84.4 73.682.9 69.2 49.8 78.5 75.7 47.1 31.0 44.074.5</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>NOAH</td><td>0.36 0.07</td><td></td><td>69.6 92.7 70.2 99.1 90.4 86.1 53.784.4 95.4 83.9 75.882.8 68.9 49.9 81.7 81.8 48.3 32.8 44.275.5</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FacT SSF</td><td>0.24</td><td>=</td><td>70.6 90.6 70.8 99.1 90.7 88.6 54.184.8 96.2 84.5 75.782.6 68.2 49.8 80.7 80.8 47.4 33.2 43.075.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RepAdapter</td><td>0.22</td><td>=</td><td>69.0 92.6 75.1 99.4 91.8 90.2 52.987.4 95.9 87.4 75.575.9 62.3 53.3 80.6 77.3 54.9 29.5 37.975.7</td><td></td><td>72.4 91.6 71.0 99.2 91.4 90.7 55.185.3 95.9 84.6 75.982.3 68.0 50.4 79.9 80.4 49.2 38.6 41.076.1</td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td>0.86</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td>0.44</td><td>- =</td><td>76.4 92.9 74.6 99.6 92.5 91.557.8|87.3 96.8 88.0 76.083.1 67.3 54.586.283.8 52.9 37.0 41.478.0 76.5 92.3 75.2 99.6 92.3 91.2 57.587.3 96.7 88.1 76.180.6 67.2 53.4 84.5 83.5 52.8 35.2 40.877.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td></td><td>-</td><td>76.1 92.7 75.399.6 92.4 90.5 57.287.5 96.7 88.1 76.181.0 66.2 52.4 84.9 81.8 53.3 33.3 39.877.3</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>0.29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
165
+
166
+ Table 2: Full results on VTAB-1K benchmark. “# params” specifies the number of trainable parameters in backbones. Average accuracy and $\#$ params are averaged over group-wise mean values.
167
+
168
+ # 3.2 Results on Large Language Models
169
+
170
+ <table><tr><td>Model</td><td>Dataset</td><td>Param (M)</td><td>ARC (25-s)</td><td>HellaSwag (10-s)</td><td>MMLU (5-s)</td><td>TruthfulQA (0-s)</td><td>Average</td></tr><tr><td>LLaMA-1-7B</td><td></td><td>-</td><td>51.0</td><td>77.8</td><td>35.7</td><td>34.3</td><td>49.7</td></tr><tr><td>LoRA</td><td>Alpaca</td><td>3.1</td><td>53.5</td><td>77.3</td><td>33.8</td><td>34.8</td><td>49.8</td></tr><tr><td>AdaLoRA</td><td>Alpaca</td><td>2.9</td><td>53.1</td><td>77.4</td><td>35.6</td><td>34.4</td><td>50.1</td></tr><tr><td>GLoRA</td><td>Alpaca</td><td>1.9</td><td>52.9</td><td>78.1</td><td>34.5</td><td>37.8</td><td>50.8</td></tr><tr><td>LoRA</td><td>ShareGPT</td><td>3.1</td><td>51.7</td><td>77.9</td><td>36.1</td><td>39.2</td><td>51.2</td></tr><tr><td>GLoRA</td><td>ShareGPT</td><td>2.2</td><td>53.2</td><td>77.4</td><td>36.2</td><td>43.9</td><td>52.7</td></tr><tr><td>LLaMA-2-7B</td><td></td><td></td><td>53.1</td><td>78.5</td><td>46.9</td><td>38.8</td><td>54.3</td></tr><tr><td>LoRA</td><td>ShareGPT</td><td>3.1</td><td>53.3</td><td>78.4</td><td>45.8</td><td>41.2</td><td>54.7</td></tr><tr><td>GLoRA</td><td> ShareGPT</td><td>1.8</td><td>53.7</td><td>78.5</td><td>46.5</td><td>45.1</td><td>56.1</td></tr></table>
171
+
172
+ Table 3: Performance of GLoRA on few-shot generative language tasks with LLM as backbones.
173
+
174
+ ![](images/3ba54bd364878449cf4e07148e949a813aafcf4792225e8955f11530067e8072.jpg)
175
+ Figure 2: Results on few-shot learning datasets. The baseline methods include Adapter, LoRA, VPT, NOAH. GLoRA consistently performs better across five datasets and a varying number of training examples per class.
176
+
177
+ We apply GLoRA for LLMs by solely tuning the attention layers. This contrasts with vision tasks where all linear layers are adapted, to maintain a fair comparison with vanilla LoRA. We start from the publicly available LLaMA-1-7B (Touvron et al., 2023a) and LLaMA-2-7B (Touvron et al., 2023b) models and finetune it on the Alpaca (Taori et al., 2023) and ShareGPT dataset with only GLoRA support tensors trainable. For the evolutionary search, we use 5% random data sampled from the 4 given datasets for model validation during the evolutions. We finally report the searched model’s performance on the standard Open LLM Leaderboard2. GLoRA consistently outperforms the pre-trained LLM and the corresponding LoRA finetuned variants. We keep the hyperparameters consistent between LoRA and GLoRA for a fair comparison, more details are in the appendix.
178
+
179
+ # 3.3 Few-shot Learning
180
+
181
+ To extend the evaluation of GLoRA under conditions of limited data availability, we present the performance of GLoRA on fine-grained visual recognition datasets as the few-show learning, comparing it with LoRA, Adapter, VPT, and NOAH. The results at 1, 2, 4, 8, and 16 shots are illustrated in Figure 2. GLoRA demonstrates superior performance across the majority of the few-shot learning datasets, consistently outperforming the performance of existing methods by a large margin with similar parameter counts. Interestingly, on the Flowers102 dataset, all methods yield similar accuracy levels, attributable to the already exceptional overall performance. On the Food101 dataset, the average accuracy of GLoRA is on par with NOAH. From the first plot, we can observe, the average performance boost becomes more pronounced at higher shot scenarios, nevertheless, even at lower shot settings, the gains remain significant.
182
+
183
+ # 3.4 Domain Generalization
184
+
185
+ <table><tr><td rowspan="2"></td><td>Source</td><td colspan="4">Target</td><td rowspan="2">#Param(M)</td></tr><tr><td>ImageNet</td><td>-Sketch</td><td>-V2</td><td>-A</td><td>-R</td></tr><tr><td>Adapter Houlsby et al. (2019)</td><td>70.5</td><td>16.4</td><td>59.1</td><td>5.5</td><td>22.1</td><td>0.16</td></tr><tr><td>VPT Jia et al. (2022)</td><td>70.5</td><td>18.3</td><td>58.0</td><td>4.6</td><td>23.2</td><td>0.53</td></tr><tr><td>LoRA Hu et al. (2021)</td><td>70.8</td><td>20.0</td><td>59.3</td><td>6.9</td><td>23.3</td><td>0.29</td></tr><tr><td>NOAH Zhang et al. (2022)</td><td>71.5</td><td>24.8</td><td>66.1</td><td>11.9</td><td>28.5</td><td>0.36</td></tr><tr><td>GLoRA</td><td>78.3</td><td>30.6</td><td>67.5</td><td>13.3</td><td>31.0</td><td>0.29</td></tr></table>
186
+
187
+ Table 4: Results on domain generalization. GLoRA is significantly better than the existing works.
188
+
189
+ The capacity of out-of-domain generalization holds significant value for large-scale neural networks (Zhou et al., 2021). Models fine-tuned via PEFT methods should exhibit enhanced domain generalization aptitude, thereby making them more applicable in real-world scenarios. We demonstrate the out-of-domain generalization capabilities of GLoRA in Table 3.4, where a single ImageNet-1K (Deng et al., 2009b) fine-tuned GLoRA model is subjected to testing on out-of-domain datasets. Aligning with preceding research, we limit the number of training examples per class to 16 for this experiment. It is noteworthy that the performance for the fully-scaled ImageNet-1K fine-tuned model stands at $8 3 . 9 7 \%$ (Dosovitskiy et al., 2021), and our approach manages to narrow this performance gap, even within a 16-shot setting $( 7 8 . 3 \%$ ), thereby exhibiting superior few-shot learning on ImageNet-level datasets. Furthermore, the out-of-domain performance also witnesses a substantial boost in comparison to existing methods. When compared with LoRA, GLoRA enhances out-of-domain performance by as much as $1 0 0 \%$ (ImageNet-A) and 50% (ImageNet-Sketch).
190
+
191
+ # 4 Analysis and Discussion
192
+
193
+ Computational Cost. We show the final inference throughput of various PEFT methods in Table 4, computed on an NVIDIA 3090 GPU. It is in this context that GLoRA significantly outperforms other methods, as GLoRA benefits from zero parameter or FLOPs overhead during the inference process. An ancillary advantage is the expedited adaptability in real-world scenarios where previous models are already deployed. The weights of GLoRA can be directly loaded without necessitating any manual system modifications. As previously mentioned, GLoRA supports VPT-Deep level prompts via the support tensor $\mathbf { C }$ , however, it does not impose any computational overhead due to its complete structural re-parameterization design.
194
+
195
+ Quantitatively GLoRA requires an additional 5.6 folds of training time compared to a single run of LoRA amounting to a total of 142 minutes for each VTAB-1k task. The GPU memory consumption of GLoRA is 13 GB compared to 9 GB for LoRA. Most of it is primarily because GLoRA requires roughly $5 \times$ more epochs than LoRA for appropriate convergence and the additional time is spent on the evolutionary search process. This extra time of GLoRA leads to an average increase of $4 . 5 \ \%$ accuracy across 19 vision tasks as compared to LoRA. We have also observed that GLoRA uses this additional time to surpass the combined performance of the other Top-5 methods. More details related to this experiment can be found in Appendix C.
196
+
197
+ Table 5: Inference efficiency comparison of GLoRA with existing methods.
198
+
199
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">↑#Param(M)</td><td rowspan="2">↑FLOPs(G)</td><td colspan="3">Throughput (imgs/sec)</td></tr><tr><td>bs=1</td><td>bs=4</td><td>bs=16</td></tr><tr><td>Full tuning</td><td>0</td><td>0</td><td>91.5</td><td>375.7</td><td>539.5</td></tr><tr><td>VPT Jia et al. (2022)</td><td>0.55</td><td>5.60</td><td>86.1</td><td>283.5</td><td>381.5</td></tr><tr><td>Adapter Houlsby et al. (2019)</td><td>0.16</td><td>0.03</td><td>70.9</td><td>306.6</td><td>504.7</td></tr><tr><td>AdaptFormer Chen et al. (2022)</td><td>0.16</td><td>0.03</td><td>71.4</td><td>309.9</td><td>508.1</td></tr><tr><td>NOAH Zhang et al. (2022)</td><td>0.12</td><td>0.02</td><td>72.1</td><td>312.7</td><td>492.9</td></tr><tr><td>LoRA Hu et al (2021)</td><td>0</td><td>0</td><td>91.5</td><td>375.7</td><td>539.6</td></tr></table>
200
+
201
+ ![](images/9eb320a5aefcc9a2effe711788057bf11c06998c2f871a3908bd45e4a3521622.jpg)
202
+ Figure 3: Distribution of GLoRA (0.86M) parameters across layer types on VTAB-1K. Q-K-V and Projection are linear layers in MHSA module and FC1 and FC2 are linear layers in MLP module.
203
+
204
+ ![](images/ff2756a13b1acbc2f1cb88d90fc11d8ff9c7a5ec2e12129573159dba4254d1c1.jpg)
205
+ Figure 4: Layerwise configuration of support tensors of GLoRA (0.86M) on VTAB-1K dataset.
206
+
207
+ Visualizations of searched fine-tuning strategy for each layer. Figure 3 visually shows the distribution of trainable parameters across the four types of linear layers embodied in ViT-B. Notably, the projection layer possesses the minimum quantity of trainable parameters spanning across VTAB-1K categories. Generally, the MLP module hosts a substantially higher number of parameters compared to the MHSA. As anticipated, the structured group necessitates a greater number of parameters for adaptation due to a pronounced domain drift relative to ImageNet-1K (Deng et al., 2009b). Figure 4 illustrates the layerwise configuration of the support tensors as searched by the GLoRA algorithm. Each support tensor at every layer can potentially undergo 72 distinct adaptations across datasets. Support tensors $\mathbf { D }$ and $\mathbf { E }$ exhibit relatively low adaptation due to the prevalence of none adaptations, whereas A and $\mathbf { B }$ demonstrate a higher number of adaptations, though without a discernible pattern regarding the type of adaptation. It’s important to underscore that even a basic scalar can function effectively as a support tensor, enabling GLoRA to maintain superior parameter efficiency despite adapting every linear layer.
208
+
209
+ # 5 Related Work
210
+
211
+ Given the rapid expansion in model size, numerous methods for parameter-efficient fine-tuning (PEFT) have been introduced in the field of Natural Language Processing (NLP) to streamline the optimization of large language models (LLMs). (Liu et al., 2021a; Zhang et al.; Hu et al.; Liu et al., 2021b; Li & Liang, 2021; Lester et al., 2021; Zaken et al., 2022; Houlsby et al., 2019). The effectiveness of parameter-efficient fine-tuning has been proven in a wide range of natural language processing tasks (Fu et al., 2022). With the advent growth in the size of vision models (Dehghani et al., 2023; Kolesnikov et al., 2020), methods specifically focused on image models have also been put forward (Jie & Deng, 2022; Lian et al., 2022; Chen et al., 2022; Luo et al., 2023; Zhang et al., 2022; Jia et al., 2022; He et al., 2023).
212
+
213
+ Among these methods, LoRA (Hu et al.) has proven to transfer well across modalities and tasks. This is partly due to the simplistic design strategy of LoRA which directly works over weight tensors, irrespective of model type or configuration. Additionally, unlike Adapters (Houlsby et al., 2019; Chen et al., 2022) and Prompt tuning (Jia et al., 2022), LoRA does not add any additional inference parameters or latency due to structural re-parameterization (SR) design. RepAdapter (Luo et al., 2023) and SSF (Lian et al., 2022) also propose an SR design for PEFT, however RepAdapter is specific to model architectures and required manual designing for different layer configurations, SSF provides a very simple baseline but suffers from low flexibility and capability due to adaptation limited in the activation space. FacT (Jie & Deng, 2022) further decomposes LoRA matrices for better parameter efficiency, but we argue that $<$ <1M parameter scale is fairly efficient for fine-tuning on a single GPU. Thus, due to the advantages of LoRA over other related works, it is of importance to increase the flexibility, scalability and adaptability of LoRA.
214
+
215
+ # 6 Conclusion
216
+
217
+ We have presented GLoRA, a generalized parameter-efficient fine-tuning approach that has successfully demonstrated the effectiveness in enhancing the fine-tuning and transfer learning ability for the large-scale pre-trained models. By adopting a generalized low-rank adaptation and re-parameterization framework, GLoRA significantly reduces the number of parameters and computation required for fine-tuning, making it a more resource-efficient and practical method for real-world applications. The experiments conducted on a diverse range of tasks and datasets have substantiated the superiority of GLoRA over existing PEFT techniques, showcasing its scalability and adaptability. Moreover, the ablation studies have provided valuable insights into the inner workings and the relative importance of different GLoRA components. This work not only contributes to the improvement of the fine-tuning process for large-scale pre-trained models but also opens up new avenues for future work, including further exploration of generalized low-rank adaptation techniques, the development of hybrid approaches, and the refinement of search and optimization algorithms. These areas of research may continue to expand the accessibility and efficiency of transfer learning across a broader range of applications.
218
+
219
+ Reproducibility. We provide detailed training recipes in Section 3 and the Appendix. Code is also provided for reproducibility.
220
+
221
+ # References
222
+
223
+ Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014.
224
+ Minghao Chen, Houwen Peng, Jianlong Fu, and Haibin Ling. Autoformer: Searching transformers for visual recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 12270–12280, October 2021.
225
+ Shoufa Chen, Chongjian Ge, Zhan Tong, Jiangliu Wang, Yibing Song, Jue Wang, and Ping Luo. Adaptformer: Adapting vision transformers for scalable visual recognition. arXiv preprint arXiv:2205.13535, 2022.
226
+ Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.
227
+ Mostafa Dehghani, Josip Djolonga, Basil Mustafa, Piotr Padlewski, Jonathan Heek, Justin Gilmer, Andreas Steiner, Mathilde Caron, Robert Geirhos, Ibrahim Alabdulmohsin, et al. Scaling vision transformers to 22 billion parameters. arXiv preprint arXiv:2302.05442, 2023.
228
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, 2009a.
229
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 248–255. Ieee, 2009b.
230
+ Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, and Jian Sun. Repvgg: Making vgg-style convnets great again. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 13733–13742, 2021.
231
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
232
+ Nathan Habib Sheon Han Nathan Lambert Nazneen Rajani Omar Sanseviero Lewis Tunstall Thomas Wolf Edward Beeching, Clémentine Fourrier. Open llm leaderboard. https://huggingface.co/spaces/ HuggingFaceH4/open_llm_leaderboard, 2023.
233
+ Zihao Fu, Haoran Yang, Anthony Man-Cho So, Wai Lam, Lidong Bing, and Nigel Collier. On the effectiveness of parameter-efficient fine-tuning. arXiv preprint arXiv:2211.15583, 2022.
234
+ Haoyu He, Jianfei Cai, Jing Zhang, Dacheng Tao, and Bohan Zhuang. Sensitivity-aware visual parameterefficient tuning, 2023. URL https://openreview.net/forum?id=9GOjmbRQ2o.
235
+ Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. In International Conference on Learning Representations, 2020.
236
+ Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of outof-distribution generalization. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 8340–8349, 2021a.
237
+ Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 15262–15271, 2021b.
238
+ Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In International Conference on Machine Learning, pp. 2790–2799. PMLR, 2019.
239
+ Edward J Hu, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen, et al. Lora: Low-rank adaptation of large language models. In International Conference on Learning Representations.
240
+ 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.
241
+ Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and SerNam Lim. Visual prompt tuning. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXXIII, pp. 709–727. Springer, 2022.
242
+ Shibo Jie and Zhi-Hong Deng. Fact: Factor-tuning for lightweight adaptation on vision transformer. arXiv preprint arXiv:2212.03145, 2022.
243
+ Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part V 16, pp. 491–507. Springer, 2020.
244
+ Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In Proceedings of the IEEE international conference on computer vision workshops, pp. 554–561, 2013.
245
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 3045– 3059, 2021.
246
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 4582–4597, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.353. URL https: //aclanthology.org/2021.acl-long.353.
247
+ Dongze Lian, Daquan Zhou, Jiashi Feng, and Xinchao Wang. Scaling & shifting your features: A new baseline for efficient model tuning. arXiv preprint arXiv:2210.08823, 2022.
248
+ Stephanie Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. pp. 3214–3252, 01 2022. doi: 10.18653/v1/2022.acl-long.229.
249
+ Xiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. CoRR, abs/2110.07602, 2021a. URL https://arxiv.org/abs/2110.07602.
250
+ Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. Gpt understands, too, 2021b.
251
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations.
252
+ Gen Luo, Minglang Huang, Yiyi Zhou, Xiaoshuai Sun, Guannan Jiang, Zhiyu Wang, and Rongrong Ji. Towards efficient visual adaption via structural re-parameterization. arXiv preprint arXiv:2302.08106, 2023.
253
+ Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013.
254
+ M-E Nilsback and Andrew Zisserman. A visual vocabulary for flower classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), volume 2, pp. 1447–1454. IEEE, 2006.
255
+ Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3498–3505. IEEE, 2012.
256
+ Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, and Ilya Sutskever. Robust speech recognition via large-scale weak supervision. arXiv preprint arXiv:2212.04356, 2022.
257
+ Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning (ICML), pp. 5389–5400. PMLR, 2019.
258
+ Zhiqiang Shen, Zechun Liu, Jie Qin, Marios Savvides, and Kwang-Ting Cheng. Partial is better than all: revisiting fine-tuning strategy for few-shot learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 9594–9602, 2021.
259
+ Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/ tatsu-lab/stanford_alpaca, 2023.
260
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023a.
261
+ 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, 2023b.
262
+ Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
263
+ Vladimir N Vapnik and A Ya Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Measures of complexity: festschrift for alexey chervonenkis, pp. 11–30, 2015.
264
+ 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.
265
+ Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. Advances in Neural Information Processing Systems (NeuIPS), 32, 2019.
266
+ Elad Ben Zaken, Yoav Goldberg, and Shauli Ravfogel. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 1–9, 2022.
267
+ Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. HellaSwag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4791–4800, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1472. URL https://aclanthology.org/P19-1472.
268
+ Xiaohua Zhai, Joan Puigcerver, Alexander Kolesnikov, Pierre Ruyssen, Carlos Riquelme, Mario Lucic, Josip Djolonga, Andre Susano Pinto, Maxim Neumann, Alexey Dosovitskiy, Lucas Beyer, Olivier Bachem, Michael Tschannen, Marcin Michalski, Olivier Bousquet, Sylvain Gelly, and Neil Houlsby. The visual task adaptation benchmark, 2020. URL https://openreview.net/forum?id=BJena3VtwS.
269
+ Qingru Zhang, Minshuo Chen, Alexander Bukharin, Pengcheng He, Yu Cheng, Weizhu Chen, and Tuo Zhao. Adaptive budget allocation for parameter-efficient fine-tuning. In The Eleventh International Conference on Learning Representations.
270
+ Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022.
271
+ Kaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization in vision: A survey. arXiv preprint arXiv:2103.02503, 2021.
272
+
273
+ # Appendix
274
+
275
+ A Hyperparameters
276
+ Table 6: Learning rate of dataset-specific supernet training on VTAB-1K datastet.
277
+
278
+ <table><tr><td>Dataset</td><td></td><td></td><td></td><td></td><td></td><td>sd</td><td>NHAS</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>ooT-Idsp</td><td>uo-Idsp</td><td></td><td></td></tr><tr><td>LR</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td></td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>1e-4</td><td>1e-4</td><td>1e-4</td><td>5e-4</td><td></td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td></td><td>5e-41e-4</td></tr></table>
279
+
280
+ Our approach necessitate minimal adjustments to hyperparameters, with optimizer hyperparameters being the sole exception, thanks to the inherent search mechanism. Following prior studies (Dehghani et al., 2023; Chen et al., 2022; Zhang et al., 2022), we employ the AdamW optimizer (Loshchilov $\&$ Hutter) for all our experiments.
281
+
282
+ For the hyperparameter search in vision tasks, we primarily concentrate on the exploration of the learning rate for supernet training, limiting our search scope to two potential alternatives: $1 e ^ { - 4 }$ and $5 e ^ { - 4 }$ . For a detailed account of dataset-specific learning rates, please refer to Table A. All other training particulars strictly adhere to the exact training policy delineated in the works of (Jie & Deng, 2022; Luo et al., 2023). In the case of few-shot learning datasets and ImageNet, we use learning rates of $5 e ^ { - 4 }$ and $1 e ^ { - 4 }$ respectively, as the few-shot learning datasets are smaller as compared to 16-shot ImageNet.
283
+
284
+ For language modeling experiments we use a learning rate of $2 e ^ { - 5 }$ with cosine annealing and an equivalent batch size of 32 (using gradient accumulation) for both LoRA and GLoRA. Consequently, LoRA is trained for 3 epochs, and due to the supernet structure of GLoRA, we train it for 15 epochs. This is in line with vision experiments where LoRA is trained for 100 epochs and GLoRA supernet for 500 epochs. We justify these extra training epochs due to the fact that LoRA requires hyperparameter tuning (dropout rate, adaptation layer choice, alpha, etc.) while GLoRA being a searched-based method requires no such tuning. We provide more such method-specific hyperparameters in Appendix C which justifies GLoRA’s extra training time.
285
+
286
+ # B Hierarchical Transformer
287
+
288
+ We show the performance of GLoRA on the Swin-B backbone in Table B. We follow a dataset-specific learning rate search similar to ViT-B and also add GLoRA to the reduction linear layer in Swin architecture to maintain uniformity and avoid architecture-specific tuning. GLoRA can adapt to any layer irrespective of architecture configuration and perform well across tasks and datasets which can be clearly seen in Table B where GLoRA outperforms all existing works by a fair margin.
289
+
290
+ Table 7: Performance on VTAB-1K benchmark with Swin-B pre-trained on ImageNet-21K as the backbone.
291
+
292
+ <table><tr><td>Method</td><td>Natural</td><td>Specialized</td><td>Structured</td><td> Average</td></tr><tr><td>Full</td><td>79.2</td><td>86.2</td><td>59.7</td><td>75.0</td></tr><tr><td>Linear</td><td>73.5</td><td>80.8</td><td>33.5</td><td>62.6</td></tr><tr><td>BitFit</td><td>74.2</td><td>80.1</td><td>42.4</td><td>65.6</td></tr><tr><td>VPT</td><td>76.8</td><td>84.5</td><td>53.4</td><td>71.6</td></tr><tr><td>FacT</td><td>82.7</td><td>87.5</td><td>62.0</td><td>77.4</td></tr><tr><td>RepAdapter</td><td>83.1</td><td>86.9</td><td>62.1</td><td>77.4</td></tr><tr><td>GLoRA</td><td>83.7</td><td>88.7</td><td>61.9</td><td>78.1</td></tr></table>
293
+
294
+ # C Training Time
295
+
296
+ GLoRA, being a search-based approach for PEFT, naturally incurs increased training time due to the requirements of supernet training and evolutionary search. It is, however, critical to underscore that all
297
+
298
+ Table 8: Manual design choices in existing works
299
+
300
+ <table><tr><td>Method</td><td>Design Choices/Hyperparameters</td></tr><tr><td>VPT AdaptFormer</td><td>Prompt Length, Prompt Location,Prompt Depth Adapter Location, Scaling Factor, Hidden dimension, Insertion Form</td></tr><tr><td>NOAH RepAdapter</td><td>VPT choices,Adapter choices, LoRA rank Adapter Location,Number of groups,Hidden dimension,Adapter variants</td></tr><tr><td>FacT GLoRA</td><td>Decomposition method, Scaling factor, Decomposition Rank LoRA ranks in search space</td></tr></table>
301
+
302
+ <table><tr><td>Method</td><td>Training Time</td><td>Inference Time</td><td>Natural</td><td>Specialized</td><td>Structured</td><td>Average</td></tr><tr><td>NOAH</td><td>6x</td><td>个</td><td>80.3</td><td>84.9</td><td>61.3</td><td>75.5</td></tr><tr><td>Best-5</td><td>10.1x</td><td></td><td>82.5</td><td>86.7</td><td>63.3</td><td>77.5</td></tr><tr><td>GLoRA</td><td>6.6x</td><td>1</td><td>83.6</td><td>87.0</td><td>63.3</td><td>78.0</td></tr></table>
303
+
304
+ Table 9: Best-5 indicates the average task-specific best-performing model across LoRA, NOAH, FacT, SSF and RepAdapter. x indicates the training time of LoRA.
305
+
306
+ current methods necessitate a manual search for design choices, as evidenced in Table C. This necessity significantly inflates the total training time for a specific dataset, due to the broad search within these design choices. GLoRA streamlines this process through an automated evolutionary search mechanism, thus leveraging the benefit of an expansive search space.
307
+
308
+ Additionally, we consider 5 best-performing methods on the VTAB-1k dataset - LoRA, NOAH, FacT, SSF and RepAdapter; and pick the task-specific best-performing models across them. We denote the training time of LoRA as x and the corresponding training time of NoAH, FacT, SSF and RepAdapter are 6x, x, 1.2x and 0.9x respectively. GLoRA’s total training time including architecture search is 6.6x. The table below shows the performance and training time of Best-5 methods and GLoRA. This is to indicate that the combined training time of 5 best existing methods is more than that of GLoRA and yet it delivers a superior performance over its counterpart. It is important to note that this gain is reported assuming that the other adaptation methods do not require any hyperparameter search. However, unlike GLoRA, needing minimal hyperparameter search, some of the other adaptation methods require thorough data-specific hyperparameter search for optimal performance. If we had considered this aspect also, then the training time required by GLoRA would be very significantly lower in a relative sense.
309
+
310
+ # D Search Space
311
+
312
+ In this section, we undertake the computation of the possible number of subnets within our GLoRA-adapted supernet. Each layer offers $4 , 4 , 3 , 3$ , and 3 options for the support tensor A, $\mathbf { B }$ , $\mathbf { C }$ , $\mathbf { D }$ , and $\mathbf { E }$ , respectively. This results in 432 possible configurations for a single linear layer. In our implementation, we incorporate 48 such layers within ViT-B, yielding a total of $4 3 2 \times 4 8 = 2 0 , 7 3$ 6 subnets being explored within GLoRA. This figure can escalate if multiple LoRA ranks coexist within the same search space. For instance, we allow ranks 8 and 4 in our largest GLoRA models, leading to $8 2 , 9 4 4$ distinct subnets. Furthermore, owing to the phenomenon of weight entanglement as per (Chen et al., 2021), comparable performance is maintained across all subnets, even if they are not all explored during the training of the supernet.
313
+
314
+ # E Support Tensor
315
+
316
+ In this section, we justify the choices of support tensors in our framework. Consider a linear layer that facilitates the transformation of inputs from a $d _ { 1 }$ dimensional space to a $d _ { 2 }$ dimensional space, with a corresponding weight matrix $\mathbf { W } _ { 0 } \in \mathbb { R } ^ { d _ { 2 } \times d _ { 1 } }$ . Given that $\mathbf { A }$ is tasked with scaling $\mathbf { W } _ { 0 }$ , $\mathbf { A }$ could feasibly belong to $\mathbb { R } ^ { d _ { 2 } \times d _ { 1 } } , \mathbb { R } ^ { d _ { 2 } \times 1 }$ , or $\mathbb { R } ^ { 1 \times 1 }$ . These matrix dimensions are respectively indicative of LoRA, vector, and scalar operations. It’s pertinent to note that in scenarios where $\mathbf { A } \in \mathbb { R } ^ { d _ { 2 } \times d _ { 1 } }$ , LoRA is realized via corresponding matrices $\mathbf { A } _ { d } \in \mathbb { R } ^ { d _ { 2 } \times r }$ and $\mathbf { A } _ { u } \in \mathbb { R } ^ { r \times d _ { 1 } }$ . A parallel scrutiny of other support tensors would result in determining the appropriate support tensor choice, as elaborated in Section 2.3 of the main paper.
317
+
318
+ # F Fine-tuned Embedding Visualization
319
+
320
+ ![](images/a262e2977a1bb538766e8fe072afdd3d34ee38571c410e264698b66a8ac4cc08.jpg)
321
+ Figure 5: Visualization of features from SVHN dataset by t-SNE (Van der Maaten & Hinton, 2008).
322
+
323
+ We present feature visualizations of the ViT-B model adapted via GLoRA and FacT (Jie & Deng, 2022) methods applied to the SVHN dataset. We selected FacT as opposed to LoRA (Hu et al.), given that FacT constitutes a direct mathematical enhancement over LoRA and presently represents the state-of-the-art. A clear distinction can be discerned whereby GLoRA exhibits superiorly segregated clusters in comparison to FacT. Further, the delineations are broader, and the clusters demonstrate a higher degree of concentration, signaling the heightened discriminative capacity of the GLoRA-adapted model features.
324
+
325
+ # G GLoRA with Higher Capacity
326
+
327
+ Model capacity refers to the capability of a model to approximate a diverse range of functions. A method for regulating the capacity of a learning algorithm involves selecting an appropriate hypothesis space, essentially a set of functions that the learning algorithm is permitted to consider as potential solutions. The VapnikChervonenkis Dimension (VC Dimension) (Vapnik & Chervonenkis, 2015) is a measure of the capacity (complexity, expressiveness) of a set of functions that can be learned by a statistical classification algorithm. It is defined as the cardinality of the largest set of points that the algorithm can shatter. By estimating the VC Dimension of a deep model, we can get an idea of how capable the model is of fitting complex datasets. A very high VC Dimension could indicate that the model has enough capacity to learn the training data perfectly but might overfit and generalize poorly on new data.
328
+
329
+ Theorem 1. Suppose $\mathbf { d } _ { \mathrm { v c } } ( \mathcal { H } )$ is the VC dimension of any finite hypothesis $\mathcal { H }$ . If $\mathcal { H } _ { \mathrm { i } } \subseteq \mathcal { H } _ { \mathrm { u n i } }$
330
+
331
+ $$
332
+ \mathbf { d } _ { \mathrm { v c } } ( \mathcal { H } _ { \mathrm { u n i } } ) - \mathbf { d } _ { \mathrm { v c } } ( \mathcal { H } _ { \mathrm { i } } ) \geq \epsilon \qquad s . t . \quad \epsilon \geq 0
333
+ $$
334
+
335
+ In the context of GLoRA, $\mathcal { H } _ { \mathrm { i } }$ denotes the hypothesis space of a randomly sampled subnet and ${ \mathcal { H } } _ { \mathrm { u n i } }$ denotes the hypothesis space of the complete supernet. The validity of this theorem stems from the inherent property of our problem context, where the hypothesis space $\mathcal { H } _ { \mathrm { i } }$ is a subset of ${ \mathcal { H } } _ { \mathrm { u n i } }$ in our context. ${ \mathcal { H } } _ { \mathrm { u n i } }$ encompasses all possible shattered scenarios of $\mathcal { H } _ { \mathrm { i } }$ . For the extreme case where the VC dimension $\mathbf { d } _ { \mathrm { v c } } ( \mathcal { H } _ { \mathrm { o } } )$ ( $\mathcal { H } _ { \mathrm { o } }$ is the difference set of ${ \mathcal { H } } _ { \mathrm { u n i } }$ and $\mathcal { H } _ { \mathrm { i } }$ ) is $0$ , the error $\epsilon$ will be zero. As per learning theory, a higher VC dimension implies greater model flexibility and capability of our approach. Clearly, Theorem 1 holds for GLoRA and thus it experiences a greater model capacity.
parse/test/TQeT7UupFk/TQeT7UupFk_content_list.json ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "One-for-All: Generalized LoRA for Parameter-Efficient Fine-tuning ",
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": "We present Generalized LoRA (GLoRA), a flexible approach for universal parameter-efficient fine-tuning tasks. Enhancing Low-Rank Adaptation (LoRA), GLoRA employs a generalized prompt module to optimize pre-trained model weights and adjust intermediate activations, providing more flexibility and capability across diverse tasks and datasets. Moreover, GLoRA facilitates efficient parameter adaptation by employing a scalable, modular, and layer-wise structure search that learns the individual adapter of each layer. Originating from a unified mathematical formulation, GLoRA exhibits strong transfer learning, fewshot learning and domain generalization abilities, as it adapts to new tasks through not only weights but also additional dimensions like activations. Comprehensive experiments demonstrate that GLoRA outperforms all previous methods in natural, specialized, and structured benchmarks in the field of vision, achieving superior accuracy with fewer parameters and computations. To demonstrate the applicability in the language domain, we perform GLoRA on LLaMA-1/2 models, which also achieve considerable enhancements compared to the original LoRA. Furthermore, our structural re-parameterization design ensures that GLoRA incurs no extra inference cost, rendering it a practical solution for resourcelimited applications. ",
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": "The remarkable achievements of large-scale deep neural networks in recent years have revolutionized the field of artificial intelligence, demonstrating unprecedented performance across various tasks and domains. These highly complex models, often with millions or even billions of parameters, have demonstrated remarkable capabilities in areas such as computer vision (Dosovitskiy et al., 2021), natural language understanding (Vaswani et al., 2017), and speech recognition (Radford et al., 2022). Typically, these colossal models are pre-trained on general and large-scale datasets, such as ImageNet (Deng et al., 2009a), and are subsequently adapted to downstream target scenarios through fine-tuning or transfer learning. Given the immense computational resources required by large pre-trained architectures, many parameter-efficient finetuning (PEFT) methods (Hu et al., 2021; Shen et al., 2021; Jia et al., 2022; Zhang et al., 2022; Luo et al., 2023) have been proposed. For instance, Low-Rank Adaptation (LoRA) (Hu et al., 2021) aims to reduce the number of trainable parameters by exclusively learning pairs of rank-decomposition matrices whilst keeping the original model parameter static. Adapter (Houlsby et al., 2019) implements bottleneck adapter modules and incorporates a modest number of task-specific parameters into a fixed pre-trained model. Similarly, Visual Prompt Tuning (VPT) (Jia et al., 2022) introduces a minimal number of learnable parameters to the input of the Transformer, leaving the entire backbone frozen during fine-tuning. ",
33
+ "page_idx": 0
34
+ },
35
+ {
36
+ "type": "text",
37
+ "text": "However, distinct downstream datasets often possess unique characteristics, such as natural, specialized, and structured data, which differ significantly in distribution and composition. A static fine-tuning strategy may not sufficiently account for these disparities, thereby hindering its capacity to adapt to diverse datasets. To rectify this, we propose a flexible, parameter-efficient fine-tuning scheme in this work to manage the variations of multiple downstream datasets within a consolidated formulation. Our approach presents a generalized version of LoRA from a unified parameter-efficient fine-tuning perspective, amplifying LoRA’s capability, scalability, and adaptability by rescaling and shifting intermediate activations, in conjunction with implementing a structural re-parameterization design, etc. It is challenging to devise a unified method that integrates all adjustable dimensions and possibilities when tuning a pre-trained network, especially in the case of transformer architectures, while our proposed approach presents a practicable solution to navigate this complexity. ",
38
+ "page_idx": 0
39
+ },
40
+ {
41
+ "type": "text",
42
+ "text": "",
43
+ "page_idx": 1
44
+ },
45
+ {
46
+ "type": "text",
47
+ "text": "In detail, our approach proposes a unified framework that can achieve comprehensive fine-tuning paradigms from a single formulation, i.e., a One-for-All fine-tuning architecture. It comprises a supernet, which, when optimized cost-effectively through evolutionary search, yields results that surpass those of prevailing fine-tuning methodologies necessitating expensive data-dependent hyperparameter search. The proposed approach exhibits the following advantages: (1) It concurrently takes into account multiple dimensions to enhance capability and flexibility during fine-tuning, encompassing weights, features, and input tokens. (2) It conducts an implicit search devoid of any manual hyperparameter tuning, thus justifying the increased training time. (3) It incurs no additional inference cost thanks to our structural re-parameterization architecture, whereby the extra fine-tuning parameters will be fused to the proximate projection weights post-training. ",
48
+ "page_idx": 1
49
+ },
50
+ {
51
+ "type": "text",
52
+ "text": "We conduct comprehensive experiments on VTAB-1K (Zhai et al., 2020), ImageNet (Deng et al., 2009a) and its variants (Recht et al., 2019; Wang et al., 2019; Hendrycks et al., 2021b;a), and Huggingface leaderboard benchmarks (Edward Beeching, 2023) for evaluating on language domain. The VTAB-1K dataset comprises 19 heterogeneous vision datasets, enveloping a broad spectrum of visual domains that include natural objects and scenes, textures and shapes, satellite imagery, among others. GLoRA surpasses all previous state-ofthe-art PEFT methods by a substantial margin in terms of average accuracy. Additionally, we evaluate the model’s few-shot learning capacity on five fine-grained visual recognition datasets, akin to prior works (Zhang et al., 2022; Jia et al., 2022), along with its ability for domain generalization and robustness on ImageNetV2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b), and ImageNet-R (Hendrycks et al., 2021a) datasets. GLoRA significantly outperforms previous methods across all these benchmarks, without incurring any extra computational overhead during the inference phase. ",
53
+ "page_idx": 1
54
+ },
55
+ {
56
+ "type": "text",
57
+ "text": "Our contributions: ",
58
+ "page_idx": 1
59
+ },
60
+ {
61
+ "type": "text",
62
+ "text": "• We propose Generalized LoRA (GLoRA), a novel parameter-efficient fine-tuning framework. GLoRA enhances the low-rank adaptation approach with a more generalized prompt module design per layer, offering enhanced capability and flexibility in finetuning. GLoRA offers a unified framework that achieves universal fine-tuning paradigms from a single formulation, i.e., a One-for-All $^ { 1 }$ fine-tuning architecture. During inference, the adapters yielded through GLoRA seamlessly integrate into the base network, resulting in no additional model weights. Thus, it incurs no extra inference computational load. \n• We conduct extensive experiments on large vision (ViT-B) and language models (LLaMA-1 and 2) with downstream fine-tuning, few-shot learning, and domain generalization using various datasets. Our experimental results demonstrate that GLoRA outperforms all previous methods on these benchmarks while requiring only a modest amount of additional training compute and a small number of extra trainable parameters but crucially no additional inference cost. ",
63
+ "page_idx": 1
64
+ },
65
+ {
66
+ "type": "text",
67
+ "text": "2 GLoRA ",
68
+ "text_level": 1,
69
+ "page_idx": 1
70
+ },
71
+ {
72
+ "type": "text",
73
+ "text": "In this section, we start from providing a mathematical overview of existing state-of-the-art PEFT methods and discuss the advantages and disadvantages for them. Then, we introduce a unified formulation of integrating all existing SOTA PEFT methods and elaborate our proposed generalized LoRA in detail following this unified formulation perspective. After that, a structural re-parameterization design is presented to show the inference efficiency without additional cost. An evolutionary search for optimal layer-wise configurations is also introduced to achieve the goal of generalized LoRA. We further give the theoretical analysis and discussions on the higher capability of the proposed method. ",
74
+ "page_idx": 1
75
+ },
76
+ {
77
+ "type": "text",
78
+ "text": "2.1 Previous Solutions with Limitations ",
79
+ "text_level": 1,
80
+ "page_idx": 2
81
+ },
82
+ {
83
+ "type": "text",
84
+ "text": "Visual Prompt Tuning (Jia et al., 2022): VPT introduces a small amount of task-specific learnable parameters into the input space while freezing the entire pre-trained Transformer backbone during downstream fine-tuning. They propose two strategies: ",
85
+ "page_idx": 2
86
+ },
87
+ {
88
+ "type": "text",
89
+ "text": "VPT-Shallow, i.e., only input space has the trainable prompt: ",
90
+ "page_idx": 2
91
+ },
92
+ {
93
+ "type": "equation",
94
+ "img_path": "images/0c41f480d9430708de48cda461b1edce05a71b9b8147a1ffad5c00dc56923975.jpg",
95
+ "text": "$$\n\\begin{array} { r l } & { [ { \\bf x } _ { 1 } , { \\bf Z } _ { 1 } , { \\bf E } _ { 1 } ] = L _ { 1 } \\left( [ { \\bf x } _ { 0 } , { \\bf P } , { \\bf E } _ { 0 } ] \\right) } \\\\ & { [ { \\bf x } _ { i } , { \\bf Z } _ { i } , { \\bf E } _ { i } ] = L _ { i } \\left( [ { \\bf x } _ { i - 1 } , { \\bf Z } _ { i - 1 } , { \\bf E } _ { i - 1 } ] \\right) } \\end{array}\n$$",
96
+ "text_format": "latex",
97
+ "page_idx": 2
98
+ },
99
+ {
100
+ "type": "text",
101
+ "text": "VPT-Deep, i.e., every layer has the trainable prompt. The formulation is: ",
102
+ "page_idx": 2
103
+ },
104
+ {
105
+ "type": "equation",
106
+ "img_path": "images/04a562c5b477bbf3fde4c720da1ff39ccf85a6be825a26e3d00412177400e7e9.jpg",
107
+ "text": "$$\n[ { \\bf x } _ { i } , \\ldots , { \\bf E } _ { i } ] = L _ { i } \\left( [ { \\bf x } _ { i - 1 } , { \\bf P } _ { i - 1 } , { \\bf E } _ { i - 1 } ] \\right)\n$$",
108
+ "text_format": "latex",
109
+ "page_idx": 2
110
+ },
111
+ {
112
+ "type": "text",
113
+ "text": "where $\\mathbf { P } = \\left\\{ p ^ { k } \\in \\mathbb { R } ^ { d } \\mid k \\in \\mathbb { N } , 1 \\leq k \\leq p \\right\\}$ is a collection of $p$ trainable prompts, $\\mathbf { Z _ { i } } \\in \\mathbb { R } ^ { p \\times d }$ represents the features computed by the $i ^ { t h }$ Transformer layer, $\\mathbf { x _ { 0 } } \\in \\mathbb { R } ^ { d }$ is the [CLS] token, $\\mathbf { E _ { i } } = \\left\\{ e _ { i } ^ { j } \\in \\mathbb { R } ^ { d } \\mid j \\in \\mathbb { N } , 1 \\leq j \\leq m \\right\\}$ are the image patch embeddings, $\\boldsymbol { L } _ { i }$ denotes the $i ^ { t h }$ transformer layer and $m$ denotes the fixed-sized patches. Prompts use ${ < } 1 \\%$ trainable parameters as compared to the original model. VTP-Deep outperforms full fine-tuning on many vision tasks and also has better accuracy in a low data regime. However, VPT increases cost in the inference stage which is not negligible. ",
114
+ "page_idx": 2
115
+ },
116
+ {
117
+ "type": "text",
118
+ "text": "AdaptFormer (Chen et al., 2022): AdaptFormer introduces a parallel learnable branch of two linear layers and ReLU over the MLP block and updates only this path while freezing other parts. ",
119
+ "page_idx": 2
120
+ },
121
+ {
122
+ "type": "equation",
123
+ "img_path": "images/135deb240ea89470ee003d4d485031479ddec704bf91ac82dc9e9ca07911a955.jpg",
124
+ "text": "$$\n\\tilde { x } _ { \\ell } = \\mathbf { R e L U } \\left( \\mathbf { L N } \\left( x _ { \\ell } ^ { \\prime } \\right) \\cdot \\mathbf { W } _ { \\mathrm { d o w n } } \\right) \\cdot \\mathbf { W } _ { \\mathrm { u p } }\n$$",
125
+ "text_format": "latex",
126
+ "page_idx": 2
127
+ },
128
+ {
129
+ "type": "equation",
130
+ "img_path": "images/365d2e90707d5c9df394c9ef893fc52374684830ad25748feeeac91e2a0aaa82.jpg",
131
+ "text": "$$\nx _ { \\ell } = \\mathbf { M L P } \\left( \\operatorname { L N } \\left( x _ { \\ell } ^ { \\prime } \\right) \\right) + s \\cdot \\tilde { x } _ { \\ell } + x _ { \\ell } ^ { \\prime }\n$$",
132
+ "text_format": "latex",
133
+ "page_idx": 2
134
+ },
135
+ {
136
+ "type": "text",
137
+ "text": "where $ { \\boldsymbol { { x } } } _ { \\ell } ^ { \\prime }$ are the tokens after Multi-head self-attention at the $\\ell$ -th layer. $\\mathbf { W } _ { \\mathrm { d o w n } } \\in \\mathbb { R } ^ { d \\times \\hat { d } }$ and $\\mathbf { W } _ { \\mathrm { u p } } \\in \\mathbb { R } ^ { \\hat { d } \\times d }$ are weights corresponding to a down-projection layer and an up-projection layer from the parallel branch, respectively; and $s$ denotes a scale factor. AdaptFormer also increases the inference cost due to the presence of a parallel branch. ",
138
+ "page_idx": 2
139
+ },
140
+ {
141
+ "type": "text",
142
+ "text": "LoRA (Hu et al., 2021): LoRA proposes to freeze the pre-trained model weights and injects trainable lowrank decomposition matrices into each layer. It learns only the residual from pre-trained weight. Assuming $\\mathbf { W } _ { 0 }$ , $\\mathbf { b } _ { 0 }$ , $x$ are pre-trained weights, bias and input, let $f$ be a linear layer, thus $f ( x ) = \\mathbf { W } _ { 0 } x + \\mathbf { b } _ { 0 }$ . During fine-tuning, $\\mathbf { W } _ { 0 }$ and $\\mathbf { b } _ { 0 }$ are frozen, the learning process can be: ",
143
+ "page_idx": 2
144
+ },
145
+ {
146
+ "type": "equation",
147
+ "img_path": "images/8fd6c7178a42b19878090af7a99c235c7e891c27a17818f5472e1df7b042f97f.jpg",
148
+ "text": "$$\nf ( x ) = \\mathbf { W } _ { 0 } x + \\Delta \\mathbf { W } x + \\mathbf { b } _ { 0 } = \\mathbf { W } _ { \\mathrm { L o R A } } x + \\mathbf { b } _ { 0 }\n$$",
149
+ "text_format": "latex",
150
+ "page_idx": 2
151
+ },
152
+ {
153
+ "type": "text",
154
+ "text": "where $\\Delta \\mathbf { W }$ is the low-rank decomposition weights that are learnable. ",
155
+ "page_idx": 2
156
+ },
157
+ {
158
+ "type": "text",
159
+ "text": "Scaling & Shifting Features (SSF) (Lian et al., 2022): SSF module scales and shifts features after every MLP, MHSA, Layernorm module during training, and performs re-parameterization during inference as it is a linear structure. ",
160
+ "page_idx": 2
161
+ },
162
+ {
163
+ "type": "equation",
164
+ "img_path": "images/13f9d2209407b3324e49558383228e029a0890c22335f2ddcba88c5dda549d0b.jpg",
165
+ "text": "$$\n\\pmb { y } = \\pmb { \\gamma } \\odot \\pmb { x } + \\pmb { \\beta }\n$$",
166
+ "text_format": "latex",
167
+ "page_idx": 2
168
+ },
169
+ {
170
+ "type": "text",
171
+ "text": "where $\\mathbf { \\pmb { y } }$ is the output features. $\\gamma \\in \\mathbb { R } ^ { d }$ and $\\beta \\in \\mathbb { R } ^ { d }$ are the scale and shift factors, $\\odot$ is the dot product. \nThis method has no increase in inference but the capability is limited to feature adaptation. ",
172
+ "page_idx": 2
173
+ },
174
+ {
175
+ "type": "text",
176
+ "text": "FacT (Jie & Deng, 2022): FacT proposes to use a tensorization-decomposition method to store the additional weight, the weights of the model are tensorized into a single 3D tensor, and their additions are then decomposed into lightweight factors. In fine-tuning, only the factors will be updated and stored. They propose two strategies: ",
177
+ "page_idx": 2
178
+ },
179
+ {
180
+ "type": "equation",
181
+ "img_path": "images/eda8ebf0ca0f901e9997f436481a3fe2a4c5d2a7b351730a92b50a5ea1b25669.jpg",
182
+ "text": "$$\nf ( x ) = \\mathbf { W } _ { 0 } x + \\mathbf { b } _ { 0 } + \\mathbf { U } \\Sigma \\mathbf { V } x = \\left( \\mathbf { W } _ { 0 } + \\mathbf { U } \\Sigma \\mathbf { V } \\right) x + \\mathbf { b } _ { 0 }\n$$",
183
+ "text_format": "latex",
184
+ "page_idx": 2
185
+ },
186
+ {
187
+ "type": "text",
188
+ "text": "where $\\Delta \\mathbf { W }$ in LoRA is decomposed into $\\mathbf { U } \\in \\mathbb { R } ^ { d \\times r _ { 1 } }$ , $\\mathbf { V } \\in \\mathbb { R } ^ { d \\times r _ { 2 } }$ , $\\pmb { \\Sigma } \\in \\mathbb { R } ^ { 1 2 L \\times r _ { 1 } \\times r _ { 2 } }$ and $L$ denotes the total number of layers in the network. This is Tensor-Train format. ",
189
+ "page_idx": 2
190
+ },
191
+ {
192
+ "type": "equation",
193
+ "img_path": "images/66a72f78878ed0127cf6b127381f896ee7fead35c73f2b1367eb651b5df9e114.jpg",
194
+ "text": "$$\nf ( x ) = \\mathbf { W } _ { 0 } x + \\mathbf { b } _ { 0 } + \\mathbf { U C P V } x = \\left( \\mathbf { W } _ { 0 } + \\mathbf { U C P V } \\right) x + \\mathbf { b } _ { 0 }\n$$",
195
+ "text_format": "latex",
196
+ "page_idx": 2
197
+ },
198
+ {
199
+ "type": "text",
200
+ "text": "where $\\Delta \\mathbf { W }$ in LoRA is decomposed into $\\mathbf { U } \\in \\mathbb { R } ^ { d \\times r _ { 2 } }$ , $\\mathbf { V } \\in \\mathbb { R } ^ { d \\times r _ { 3 } }$ , $\\mathbf { C } \\in \\mathbb { R } ^ { r _ { 1 } \\times r _ { 2 } \\times r _ { 3 } }$ and $\\mathbf { P } \\in \\mathbb { R } ^ { 1 2 L \\times r _ { 1 } }$ . This is Tucker format. ",
201
+ "page_idx": 3
202
+ },
203
+ {
204
+ "type": "text",
205
+ "text": "RepAdapter (Luo et al., 2023): RepAdapter inserts lightweight networks into the pre-trained models, and the additional parameters will be re-parameterized to the nearby projection weights after training. Adding sequential (not parallel) adapter to both MHA and MLP, adapter is linear thus can be re-parameterized, and has two layers: downsampling dense FC layer to downsample inputs; upsampling downsampled features that are divided into group, and each group has an upsampling layer. The group of upsampling layers can be merged into a single sparse upsampling layer and can be re-parameterized directly into the original Multi-Layer Perceptron or Multi-head self-attention layers. The formulation can be: ",
206
+ "page_idx": 3
207
+ },
208
+ {
209
+ "type": "equation",
210
+ "img_path": "images/581de9ea20257d5cf75db4d1eca9577cfcfa8b329d9230d8adef847f3cd7a091.jpg",
211
+ "text": "$$\n\\begin{array} { r l } { f ( x ) } & { = \\mathbf { W } _ { 0 } \\left( x + \\mathbf { W } _ { u } \\left( \\mathbf { W } _ { d } x + \\mathbf { b } _ { d } \\right) + \\mathbf { b } _ { u } \\right) + \\mathbf { b } _ { 0 } } \\\\ & { = \\left( \\mathbf { W } _ { 0 } + \\mathbf { W } _ { 0 } \\mathbf { W } _ { u } \\mathbf { W } _ { d } \\right) x + \\mathbf { W } _ { 0 } \\mathbf { W } _ { u } \\mathbf { b } _ { d } + \\mathbf { W } _ { 0 } \\mathbf { b } _ { u } + \\mathbf { b } _ { 0 } } \\end{array}\n$$",
212
+ "text_format": "latex",
213
+ "page_idx": 3
214
+ },
215
+ {
216
+ "type": "text",
217
+ "text": "where $\\mathbf { W } _ { u } \\in \\mathbb { R } ^ { d \\times d }$ , $\\mathbf { W } _ { d } \\in \\mathbb { R } ^ { \\hat { d } \\times d }$ , $\\mathbf { b } _ { u } \\in \\mathbb { R } ^ { d }$ and $\\mathbf { b } _ { b } \\in \\mathbb { R } ^ { d }$ are learnable weights and biases, respectively. ",
218
+ "text_level": 1,
219
+ "page_idx": 3
220
+ },
221
+ {
222
+ "type": "text",
223
+ "text": "Limitations: In general, many existing PEFT methods such as (VPT, Adapter) increase the inference time since the proposed structure cannot be re-parameterized. Direct prompt tuning is also hard to design as it brings in computational burden and requires hyper-parameter tuning i.e., how and where to place prompts. LoRA can be re-parameterized at inference but requires manual rank search and hence doesn’t scale up automatically for larger matrices. Also, the adaptation ability is constrained in the weight space. SSF / Repadaptor cannot learn the weight change i.e., $\\Delta \\mathbf { W }$ in weight space, whereas LoRA / FacT cannot efficiently learn the scaling and shifting of feature change i.e., $\\Delta \\mathbf { H }$ in features space. Both feature and weight space need flexibility while performing transfer learning from a large model. Our proposed idea in this work attempts at: $\\Delta \\mathbf { W }$ tuning, $\\Delta \\mathbf { H }$ tuning, along with $\\mathbf { W }$ and $\\mathbf { H }$ scale and shift learning. ",
224
+ "page_idx": 3
225
+ },
226
+ {
227
+ "type": "text",
228
+ "text": "2.2 A Unified Formulation of One-for-All ",
229
+ "text_level": 1,
230
+ "page_idx": 3
231
+ },
232
+ {
233
+ "type": "text",
234
+ "text": "For model fine-tuning, we propose a unified formulation that encompasses tuning in both weight and feature space along with VPT-Deep level prompt design. Additionally, we adopt a re-parameterization strategy to incorporate auxiliary parameters into the adjacent projection weights during the inference stage. Broadly speaking, our method serves as a superset of all prior solutions, i.e., one-for-all mechanism. By setting different support tensors to zero, our GLoRA can be reduced to any of these predecessor methods. Unlike NOAH (Zhang et al., 2022), our architecture can be succinctly articulated as a unified mathematical equation. The consolidated formulation to represent all tunable spaces can be represented as follows: ",
235
+ "page_idx": 3
236
+ },
237
+ {
238
+ "type": "image",
239
+ "img_path": "images/2ab79b026fd54b215b513d64f5291e3054cb546a0fcdbf1bd6ee1cb7874ae345.jpg",
240
+ "image_caption": [
241
+ "Figure 1: Schematic representation of a linear layer adapted with GLoRA. "
242
+ ],
243
+ "image_footnote": [],
244
+ "page_idx": 3
245
+ },
246
+ {
247
+ "type": "equation",
248
+ "img_path": "images/24a6dd9dd68c562858a71edae0f5a646e38b9fde0cad9ca3d0fe8f1573048262.jpg",
249
+ "text": "$$\nf \\left( x \\right) = \\left( \\mathbf { W } _ { 0 } + \\mathbf { W } _ { 0 } \\mathbf { A } + \\mathbf { B } \\right) x + \\mathbf { C W } _ { 0 } + \\mathbf { D } \\mathbf { b } _ { 0 } + \\mathbf { E } + \\mathbf { b } _ { 0 }\n$$",
250
+ "text_format": "latex",
251
+ "page_idx": 3
252
+ },
253
+ {
254
+ "type": "text",
255
+ "text": "where A, $\\mathbf { B }$ , $\\mathbf { C }$ , $\\mathbf { D }$ , $\\mathbf { E }$ are the trainable support tensors for downstream tasks in our GLoRA, $\\mathbf { W } _ { 0 }$ and $\\mathbf { b } _ { 0 }$ are frozen during whole fine-tuning. A is utilized to scale the weight. $\\mathbf { B }$ has the role to scale the input and shift the weight. $\\mathbf { C }$ is the layer-wise prompt serving a similar function of VPT-Deep, $\\mathbf { D }$ and $\\mathbf { E }$ are used to scale and shift the bias, respectively. A detailed illustration is shown in Figure 1. ",
256
+ "page_idx": 3
257
+ },
258
+ {
259
+ "type": "text",
260
+ "text": "Module Design. In this subsection, we delineate the methodology for designing layer-wise adaptors or prompt modules for A, B, $\\mathbf { C }$ , D, E. In a broad sense, these can take the form of scalars, vectors, low-rank decompositions, or none. scalar denotes a matrix-scaler product, vector denotes a matrixvector product, low-rank decompositions denotes two low-rank matrices used to generate a final matrix and an element-wise matrix-matrix product being employed. Based on the role of these trainable support tensors, they can be sampled from the following respective search spaces: ",
261
+ "page_idx": 3
262
+ },
263
+ {
264
+ "type": "text",
265
+ "text": "",
266
+ "page_idx": 4
267
+ },
268
+ {
269
+ "type": "equation",
270
+ "img_path": "images/7210905c24658bc58edb16813bcce5ed4de88cf334015efeaed6c17320423e12.jpg",
271
+ "text": "$$\n\\begin{array} { r l } & { \\mathbf { A } = \\{ \\mathrm { L o R A } , \\mathrm { v e c t o r } , \\mathrm { s c a l a r } , \\mathrm { n o n e } \\} } \\\\ & { \\mathbf { B } = \\{ \\mathrm { L o R A } , \\mathrm { v e c t o r } , \\mathrm { s c a l a r } , \\mathrm { n o n e } \\} } \\\\ & { \\mathbf { C } = \\{ \\mathrm { L o R A } , \\mathrm { v e c t o r } , \\mathrm { n o n e } \\} } \\\\ & { \\mathbf { D } = \\{ \\mathrm { v e c t o r } , \\mathrm { s c a l a r } , \\mathrm { n o n e } \\} } \\\\ & { \\mathbf { E } = \\{ \\mathrm { v e c t o r } , \\mathrm { s c a l a r } , \\mathrm { n o n e } \\} } \\end{array}\n$$",
272
+ "text_format": "latex",
273
+ "page_idx": 4
274
+ },
275
+ {
276
+ "type": "text",
277
+ "text": "where none indicates zero, if all the trainable support tensors are zero, the model will be degraded to the original formulation and training recipe. In particular, suppose $\\mathbf { W } _ { 0 } \\in \\mathbb { R } ^ { d \\times d }$ is the original weight matrix. For every layer, we define $\\mathbf { A } _ { d } \\in \\mathbb { R } ^ { d \\times r }$ , $\\mathbf { A } _ { u } \\in \\mathbb { R } ^ { r \\times d }$ , $\\mathbf { B } _ { d } \\in \\mathbb { R } ^ { d \\times r }$ , $\\mathbf { B } _ { u } \\in \\mathbb { R } ^ { r \\times d }$ , $\\mathbf { C } _ { d } \\in \\mathbb { R } ^ { d \\times r }$ , $\\mathbf { C } _ { u } \\in \\mathbb { R } ^ { r \\times 1 }$ , $\\mathbf { D } \\in \\mathbb { R } ^ { d \\times 1 }$ and $\\mathbf { E } \\in \\mathbb { R } ^ { d \\times 1 }$ . We also define a multi-path supernet of all possible subnets and randomly sample a subnet during any given supernet training iteration for optimization. A subnet comprises of a single path network with different layerwise support tensors sampled from 11. Depending upon the current subnet configuration, in case of LoRA with rank $r _ { 1 } < r$ , $\\mathbf { A } _ { d } ^ { r _ { 1 } } \\in \\mathbb { R } ^ { d \\times r _ { 1 } }$ , $\\mathbf { A } _ { u } ^ { r _ { 1 } } \\in \\mathbb { R } ^ { r _ { 1 } \\times d }$ is indexed from $\\mathbf { A } _ { d }$ and $\\mathbf { A } _ { u }$ respectively; and $\\mathbf { A } = \\mathbf { A } _ { d } ^ { r _ { 1 } } \\times \\mathbf { A } _ { u } ^ { r _ { 1 } }$ is used as the final tensor, in case of vector $\\mathbf { A } \\in \\mathbb { R } ^ { d \\times 1 }$ is indexed from $\\mathbf { A } _ { d }$ and in case of scalar $\\mathbf { A } \\in \\mathbb { R } ^ { 1 \\times 1 }$ is indexed from $\\mathbf { A } _ { d }$ . A similar strategy is followed for all other support tensors depending upon the current sampled configuration in the subnet. This weight entanglement strategy helps to increase the search space without increasing the number of parameters substantially and also shows faster convergence due to weight sharing in different subnets. ",
278
+ "page_idx": 4
279
+ },
280
+ {
281
+ "type": "text",
282
+ "text": "Moreover, without defining any existing adapter/module in the network explicitly, GLoRA proposes a much more general formulation that implicitly mimics the behavior of many existing works. In Table 1, we show how GLoRA is able to approximately mimic the behavior of many existing works by setting support tensors to specific attributes of the search space. ",
283
+ "page_idx": 4
284
+ },
285
+ {
286
+ "type": "table",
287
+ "img_path": "images/1ae89d91d7ca418c11deaa4a8a723812d1f3e04de239f2d19812644d53f36823.jpg",
288
+ "table_caption": [],
289
+ "table_footnote": [],
290
+ "table_body": "<table><tr><td>Method</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td></tr><tr><td>LoRA</td><td>None</td><td>LoRA</td><td>None</td><td>None</td><td>None</td></tr><tr><td>VPT</td><td>None</td><td>None</td><td>Vector</td><td>None</td><td>None</td></tr><tr><td>SSF</td><td>Vector</td><td>None</td><td>Vector</td><td>Vector</td><td>None</td></tr><tr><td>RepAdapter</td><td>LoRA</td><td>None</td><td>None</td><td>Vector</td><td>None</td></tr></table>",
291
+ "page_idx": 4
292
+ },
293
+ {
294
+ "type": "text",
295
+ "text": "Table 1: Support tensor attributes for mimicking prior methods using GLoRA’s formulation. ",
296
+ "page_idx": 4
297
+ },
298
+ {
299
+ "type": "text",
300
+ "text": "2.3 Structural Re-parameterization Design and Inference Efficiency Analysis ",
301
+ "text_level": 1,
302
+ "page_idx": 4
303
+ },
304
+ {
305
+ "type": "text",
306
+ "text": "The fundamental aspect enabling re-parameterization (Ding et al., 2021; Hu et al., 2021) is the elimination of non-linearity amidst adjacent transformations, thereby permitting the absorption of supplementary parameters into the preceding ones. As mentioned in RepAdapter (Luo et al., 2023), the removal of such non-linear layers does not detrimentally impact the performance of the networks. The precise concept of GLoRA re-parameterization is explicated as follows: ",
307
+ "page_idx": 4
308
+ },
309
+ {
310
+ "type": "equation",
311
+ "img_path": "images/e89f1e04226a21f27b424f3c38c25416b9872bea88101535b621cdc6d5f6d6e3.jpg",
312
+ "text": "$$\nf ( x ) = \\mathbf { W } _ { \\mathrm { u n i } } x + \\mathbf { b } _ { \\mathrm { u n i } }\n$$",
313
+ "text_format": "latex",
314
+ "page_idx": 4
315
+ },
316
+ {
317
+ "type": "text",
318
+ "text": "where $\\mathbf { W } _ { \\mathrm { u n i } }$ and ${ \\bf b } _ { \\mathrm { u n i } }$ are our final unified trained weight and bias in GLoRA. They are re-parameterized according to Eq 10: ",
319
+ "page_idx": 4
320
+ },
321
+ {
322
+ "type": "equation",
323
+ "img_path": "images/451cbfb49b2fcf8767c5a8c6fae3979e45b59272181b9a769ff23f9ea274e2c2.jpg",
324
+ "text": "$$\n\\mathbf { W } _ { \\mathrm { u n i } } = \\mathbf { W } _ { 0 } + \\mathbf { W } _ { 0 } \\mathbf { A } + \\mathbf { B }\n$$",
325
+ "text_format": "latex",
326
+ "page_idx": 4
327
+ },
328
+ {
329
+ "type": "equation",
330
+ "img_path": "images/c969d520d349967338d02f8314671b164949ac258c34ae00dcbaab014e5a9941.jpg",
331
+ "text": "$$\n\\mathbf { b } _ { \\mathrm { u n i } } = \\mathbf { C } \\mathbf { W } _ { 0 } + \\mathbf { D } \\mathbf { b } _ { 0 } + \\mathbf { E } + \\mathbf { b } _ { 0 }\n$$",
332
+ "text_format": "latex",
333
+ "page_idx": 4
334
+ },
335
+ {
336
+ "type": "text",
337
+ "text": "As a result, the re-parameterization strategy we employ, which integrates learnable parameters into the existing weight matrix offers a distinct advantage as it imposes no additional computational burden during the inference phase. This is further discussed in Section 4 where we provide thorough inference efficiency analysis of GLoRA compared to exisitng works. ",
338
+ "page_idx": 4
339
+ },
340
+ {
341
+ "type": "text",
342
+ "text": "2.4 Evolutionary Search for Optimal Layer-wise Configurations ",
343
+ "text_level": 1,
344
+ "page_idx": 5
345
+ },
346
+ {
347
+ "type": "text",
348
+ "text": "Our design for a unified adaptor is implemented on a per-layer basis, thus allowing for heterogeneity across different layers. To identify the optimal configuration for each layer, we employ the evolutionary search method (Zhang et al., 2022; Shen et al., 2021), which offers a balance of efficiency and effectiveness. Although the training time may increase due to this search process, it is important to note that existing work (Zhang et al., 2022) necessitate an extensive hyperparameter search (such as low-rank in LoRA and FacT, as well as position and size of adapter modules in Adapter (Houlsby et al., 2019), dimension and structure configuration in RepAdapter (Luo et al., 2023), among others), as presented in the appendix. Our unified support tensor design conducts an implicit search that eliminates the need for manual hyperparameter tuning. Therefore, any augmentation in training time is reasonable and well-justified. ",
349
+ "page_idx": 5
350
+ },
351
+ {
352
+ "type": "text",
353
+ "text": "Evolutionary search consists of reproduction, crossover, and mutation stages. In our scenario, first, a population of support tensor strategies is embedded in vectors and initialized randomly. Each individual strategy consists of a description of a single subnet. After the training of supernet, we start to evaluate each individual subnet to obtain its accuracy on the validation set. Among these evaluated subnets, we select the top $K$ as parents to produce posterity subnets. The next generation subnets are made by mutation and crossover stages. By repeating this process over iterations, we can find the best parameter-efficient fine-tuned subnet with the best validation performance. We first randomly sample 50 subnets from the supernet and then perform an evolutionary search for 20 and 5 epochs on vision and language tasks, respectively. Each step of random pick / crossover / mutation produces 50 new subnets. The probability for crossover and mutation is set to 0.2. Note that we did not perform any hyperparameter search over the evolution hyperparameters and directly use the hyperparameters presented in Zhang et al. (2022). It is potentially possible that conducting this hyperparameter search may improve the performance further. ",
354
+ "page_idx": 5
355
+ },
356
+ {
357
+ "type": "text",
358
+ "text": "3 Experiments ",
359
+ "text_level": 1,
360
+ "page_idx": 5
361
+ },
362
+ {
363
+ "type": "text",
364
+ "text": "Datasets. We thoroughly evaluate GLoRA on VTAB-1K (Zhai et al., 2020) benchmark for various parameter budgets. VTAB-1K comprises 19 image classification tasks clustered into three domains: i) Natural images ii) Specialized tasks consisting of remote sensing and medical datasets; and iii) Structured tasks focusing on scene structure understanding. To test the ability on few-shot learning, we evaluate GLoRA on five fine-grained visual recognition few-shot datasets: Food101 (Bossard et al., 2014), OxfordFlowers102 (Nilsback & Zisserman, 2006), StandfordCars (Krause et al., 2013), OxfordPets (Parkhi et al., 2012), and FGVCAircraft (Maji et al., 2013). Following previous work (Jie & Deng, 2022), we evaluate 1, 2, 4, 8, and 16 shot settings. Next, to show the domain generalization capabilities of GLoRA, we train it on ImageNet (Deng et al., 2009b) for a 16-shot setting and test on four out-of-domain datasets including ImageNetV2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b), and ImageNetR (Hendrycks et al., 2021a). Finally, we show the performance of GLoRA on the Open LLM Leaderboard which consists of four datasets with varying prompt shots, namely AI2 Reasoning Challenge (25-shot) (Clark et al., 2018), TruthfulQA (0-shot) (Lin et al., 2022), HellaSwag (10-shot) (Zellers et al., 2019) and MMLU (5-shot) (Hendrycks et al., 2020). ",
365
+ "page_idx": 5
366
+ },
367
+ {
368
+ "type": "text",
369
+ "text": "Network Architecture and Implementation Details. For all the vision experiments, we utilize ViTB (Dosovitskiy et al., 2021), a model pre-trained on ImageNet-21K, as our foundational model. For the language experiments, we consider two foundational base models: LLaMA-1-7B (Touvron et al., 2023a) and LLaMA-2-7B (Touvron et al., 2023b). ",
370
+ "page_idx": 5
371
+ },
372
+ {
373
+ "type": "text",
374
+ "text": "Our supernets undergo a training process spanning 500 epochs and 15 epochs for vision and language datasets respectively, operating with a constant batch size of 64 and a cosine learning rate scheduler. It is crucial to highlight that this precise policy demonstrates robust efficacy across all settings, regardless of the dataset in use. Post the training of supernet, we randomly sample 50 subnets from the supernet and then perform an evolutionary search for 20 and 5 epochs on vision and language tasks, respectively. Each step of random pick / crossover / mutation produces 50 new subnets. The probability for crossover and mutation is set to 0.2. Note that we did not perform any hyperparameter search over the evolution hyperparameters, and hence the performance might even improve after tuning the evolution hyperparameters. Finally, we report the performance of the searched subnet on the test set. The appendix provides further insights into datasetspecific learning rates and specific settings for different datasets. ",
375
+ "page_idx": 5
376
+ },
377
+ {
378
+ "type": "text",
379
+ "text": "",
380
+ "page_idx": 6
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "3.1 Results on VTAB-1K ",
385
+ "text_level": 1,
386
+ "page_idx": 6
387
+ },
388
+ {
389
+ "type": "text",
390
+ "text": "We train three different GLoRA supernet configurations to vary the number of trainable parameters. The difference in these is only the LoRA dimensions in the search space which varies from 8 and 4 in the largest model, 4 and 2 in the intermediate model, and 2 in the smallest model. This added parameter flexibility in our method allows for user-defined trainable parameter count in the final models. Results on the VTAB-1k benchmark are shown in Table 3.1. We push the state-of-the-art in parameter-efficient transfer learning by up to 2.9%, Even our smallest model outperforms all existing methods by a substantial margin. It is worth noting that GLoRA performs competitively across datasets in contrast to all existing works which fail on at least one dataset, proving GLoRA’s high generalization capabilities. GLoRA pushes the state of the art in as many as 14 out of 19 datasets in the VTAB-1k benchmark while performing competitively on the remaining datasets too. ",
391
+ "page_idx": 6
392
+ },
393
+ {
394
+ "type": "table",
395
+ "img_path": "images/7fa06b8d6a29cde7c43ad4b2fc63adefe472f0004061899bbe184daa61798480.jpg",
396
+ "table_caption": [],
397
+ "table_footnote": [],
398
+ "table_body": "<table><tr><td></td><td>(IN) ure.rd</td><td>4sopeouə.IəJu[</td><td>Natural sted NHAS</td><td>Specialized</td><td></td><td>Structured oT-Jdsp 1O-idsp</td></tr><tr><td>Traditional Finetuning</td><td>井</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Full</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Linear</td><td>85.8 0</td><td></td><td>68.9 87.7 64.3 97.2 86.9 87.4 38.879.7 95.7 84.2 73.9|56.3 58.6 41.7 65.5 57.5 46.7 25.7 29.168.9 64.4 85.0 63.2 97.0 86.3 36.6 51.078.5 87.5 68.5 74.034.3 30.6 33.2 55.4 12.5 20.0 9.6 19.2|57.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan=\"2\">PEFTmethods</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>BitFit</td><td>0.10</td><td>-</td><td>72.8 87.0 59.2 97.5 85.3 59.9 51.478.7 91.6 72.9 69.861.5 55.6 32.4 55.9 66.6 40.0 15.7 25.165.2</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>VPT-Shallow</td><td>0.06</td><td></td><td>77.7 86.9 62.6 97.5 87.3 74.5 51.278.2 92.0 75.6 72.9|50.5 58.6 40.5 67.1 68.7 36.1 20.2 34.167.8</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>VPT-Deep</td><td>0.53</td><td>个</td><td>78.8 90.8 65.8 98.0 88.3 78.1 49.681.8 96.1 83.4 68.468.5 60.0 46.5 72.8 73.6 47.9 32.9 37.872.0</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Adapter</td><td>0.16</td><td></td><td>69.2 90.1 68.0 98.8 89.9 82.8 54.384.0 94.9 81.9 75.580.9 65.3 48.6 78.3 74.8 48.5 29.9 41.673.9</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AdaptFormer0.16</td><td></td><td>→</td><td>70.8 91.2 70.5 99.1 90.9 86.6 54.883.0 95.8 84.4 76.381.9 64.3 49.3 80.3 76.3 45.7 31.7 41.174.7</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LoRA</td><td>0.29</td><td>-</td><td>67.1 91.4 69.4 98.8 90.4 85.3 54.084.9 95.3 84.4 73.682.9 69.2 49.8 78.5 75.7 47.1 31.0 44.074.5</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>NOAH</td><td>0.36 0.07</td><td></td><td>69.6 92.7 70.2 99.1 90.4 86.1 53.784.4 95.4 83.9 75.882.8 68.9 49.9 81.7 81.8 48.3 32.8 44.275.5</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FacT SSF</td><td>0.24</td><td>=</td><td>70.6 90.6 70.8 99.1 90.7 88.6 54.184.8 96.2 84.5 75.782.6 68.2 49.8 80.7 80.8 47.4 33.2 43.075.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RepAdapter</td><td>0.22</td><td>=</td><td>69.0 92.6 75.1 99.4 91.8 90.2 52.987.4 95.9 87.4 75.575.9 62.3 53.3 80.6 77.3 54.9 29.5 37.975.7</td><td></td><td>72.4 91.6 71.0 99.2 91.4 90.7 55.185.3 95.9 84.6 75.982.3 68.0 50.4 79.9 80.4 49.2 38.6 41.076.1</td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td>0.86</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td>0.44</td><td>- =</td><td>76.4 92.9 74.6 99.6 92.5 91.557.8|87.3 96.8 88.0 76.083.1 67.3 54.586.283.8 52.9 37.0 41.478.0 76.5 92.3 75.2 99.6 92.3 91.2 57.587.3 96.7 88.1 76.180.6 67.2 53.4 84.5 83.5 52.8 35.2 40.877.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GLoRA</td><td></td><td>-</td><td>76.1 92.7 75.399.6 92.4 90.5 57.287.5 96.7 88.1 76.181.0 66.2 52.4 84.9 81.8 53.3 33.3 39.877.3</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>0.29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>",
399
+ "page_idx": 6
400
+ },
401
+ {
402
+ "type": "text",
403
+ "text": "Table 2: Full results on VTAB-1K benchmark. “# params” specifies the number of trainable parameters in backbones. Average accuracy and $\\#$ params are averaged over group-wise mean values. ",
404
+ "page_idx": 6
405
+ },
406
+ {
407
+ "type": "text",
408
+ "text": "3.2 Results on Large Language Models ",
409
+ "text_level": 1,
410
+ "page_idx": 6
411
+ },
412
+ {
413
+ "type": "table",
414
+ "img_path": "images/ccb699fc66ea6f4d79e435c0f989c582a1c5c595e62e60483d275983c638eb8d.jpg",
415
+ "table_caption": [],
416
+ "table_footnote": [],
417
+ "table_body": "<table><tr><td>Model</td><td>Dataset</td><td>Param (M)</td><td>ARC (25-s)</td><td>HellaSwag (10-s)</td><td>MMLU (5-s)</td><td>TruthfulQA (0-s)</td><td>Average</td></tr><tr><td>LLaMA-1-7B</td><td></td><td>-</td><td>51.0</td><td>77.8</td><td>35.7</td><td>34.3</td><td>49.7</td></tr><tr><td>LoRA</td><td>Alpaca</td><td>3.1</td><td>53.5</td><td>77.3</td><td>33.8</td><td>34.8</td><td>49.8</td></tr><tr><td>AdaLoRA</td><td>Alpaca</td><td>2.9</td><td>53.1</td><td>77.4</td><td>35.6</td><td>34.4</td><td>50.1</td></tr><tr><td>GLoRA</td><td>Alpaca</td><td>1.9</td><td>52.9</td><td>78.1</td><td>34.5</td><td>37.8</td><td>50.8</td></tr><tr><td>LoRA</td><td>ShareGPT</td><td>3.1</td><td>51.7</td><td>77.9</td><td>36.1</td><td>39.2</td><td>51.2</td></tr><tr><td>GLoRA</td><td>ShareGPT</td><td>2.2</td><td>53.2</td><td>77.4</td><td>36.2</td><td>43.9</td><td>52.7</td></tr><tr><td>LLaMA-2-7B</td><td></td><td></td><td>53.1</td><td>78.5</td><td>46.9</td><td>38.8</td><td>54.3</td></tr><tr><td>LoRA</td><td>ShareGPT</td><td>3.1</td><td>53.3</td><td>78.4</td><td>45.8</td><td>41.2</td><td>54.7</td></tr><tr><td>GLoRA</td><td> ShareGPT</td><td>1.8</td><td>53.7</td><td>78.5</td><td>46.5</td><td>45.1</td><td>56.1</td></tr></table>",
418
+ "page_idx": 6
419
+ },
420
+ {
421
+ "type": "text",
422
+ "text": "Table 3: Performance of GLoRA on few-shot generative language tasks with LLM as backbones. ",
423
+ "page_idx": 6
424
+ },
425
+ {
426
+ "type": "image",
427
+ "img_path": "images/3ba54bd364878449cf4e07148e949a813aafcf4792225e8955f11530067e8072.jpg",
428
+ "image_caption": [
429
+ "Figure 2: Results on few-shot learning datasets. The baseline methods include Adapter, LoRA, VPT, NOAH. GLoRA consistently performs better across five datasets and a varying number of training examples per class. "
430
+ ],
431
+ "image_footnote": [],
432
+ "page_idx": 7
433
+ },
434
+ {
435
+ "type": "text",
436
+ "text": "We apply GLoRA for LLMs by solely tuning the attention layers. This contrasts with vision tasks where all linear layers are adapted, to maintain a fair comparison with vanilla LoRA. We start from the publicly available LLaMA-1-7B (Touvron et al., 2023a) and LLaMA-2-7B (Touvron et al., 2023b) models and finetune it on the Alpaca (Taori et al., 2023) and ShareGPT dataset with only GLoRA support tensors trainable. For the evolutionary search, we use 5% random data sampled from the 4 given datasets for model validation during the evolutions. We finally report the searched model’s performance on the standard Open LLM Leaderboard2. GLoRA consistently outperforms the pre-trained LLM and the corresponding LoRA finetuned variants. We keep the hyperparameters consistent between LoRA and GLoRA for a fair comparison, more details are in the appendix. ",
437
+ "page_idx": 7
438
+ },
439
+ {
440
+ "type": "text",
441
+ "text": "3.3 Few-shot Learning ",
442
+ "text_level": 1,
443
+ "page_idx": 7
444
+ },
445
+ {
446
+ "type": "text",
447
+ "text": "To extend the evaluation of GLoRA under conditions of limited data availability, we present the performance of GLoRA on fine-grained visual recognition datasets as the few-show learning, comparing it with LoRA, Adapter, VPT, and NOAH. The results at 1, 2, 4, 8, and 16 shots are illustrated in Figure 2. GLoRA demonstrates superior performance across the majority of the few-shot learning datasets, consistently outperforming the performance of existing methods by a large margin with similar parameter counts. Interestingly, on the Flowers102 dataset, all methods yield similar accuracy levels, attributable to the already exceptional overall performance. On the Food101 dataset, the average accuracy of GLoRA is on par with NOAH. From the first plot, we can observe, the average performance boost becomes more pronounced at higher shot scenarios, nevertheless, even at lower shot settings, the gains remain significant. ",
448
+ "page_idx": 7
449
+ },
450
+ {
451
+ "type": "text",
452
+ "text": "3.4 Domain Generalization ",
453
+ "text_level": 1,
454
+ "page_idx": 8
455
+ },
456
+ {
457
+ "type": "table",
458
+ "img_path": "images/32da065ee598a35829adffc587219cbe232b17422d11ad75a66b7ae5b6f44967.jpg",
459
+ "table_caption": [],
460
+ "table_footnote": [
461
+ "Table 4: Results on domain generalization. GLoRA is significantly better than the existing works. "
462
+ ],
463
+ "table_body": "<table><tr><td rowspan=\"2\"></td><td>Source</td><td colspan=\"4\">Target</td><td rowspan=\"2\">#Param(M)</td></tr><tr><td>ImageNet</td><td>-Sketch</td><td>-V2</td><td>-A</td><td>-R</td></tr><tr><td>Adapter Houlsby et al. (2019)</td><td>70.5</td><td>16.4</td><td>59.1</td><td>5.5</td><td>22.1</td><td>0.16</td></tr><tr><td>VPT Jia et al. (2022)</td><td>70.5</td><td>18.3</td><td>58.0</td><td>4.6</td><td>23.2</td><td>0.53</td></tr><tr><td>LoRA Hu et al. (2021)</td><td>70.8</td><td>20.0</td><td>59.3</td><td>6.9</td><td>23.3</td><td>0.29</td></tr><tr><td>NOAH Zhang et al. (2022)</td><td>71.5</td><td>24.8</td><td>66.1</td><td>11.9</td><td>28.5</td><td>0.36</td></tr><tr><td>GLoRA</td><td>78.3</td><td>30.6</td><td>67.5</td><td>13.3</td><td>31.0</td><td>0.29</td></tr></table>",
464
+ "page_idx": 8
465
+ },
466
+ {
467
+ "type": "text",
468
+ "text": "The capacity of out-of-domain generalization holds significant value for large-scale neural networks (Zhou et al., 2021). Models fine-tuned via PEFT methods should exhibit enhanced domain generalization aptitude, thereby making them more applicable in real-world scenarios. We demonstrate the out-of-domain generalization capabilities of GLoRA in Table 3.4, where a single ImageNet-1K (Deng et al., 2009b) fine-tuned GLoRA model is subjected to testing on out-of-domain datasets. Aligning with preceding research, we limit the number of training examples per class to 16 for this experiment. It is noteworthy that the performance for the fully-scaled ImageNet-1K fine-tuned model stands at $8 3 . 9 7 \\%$ (Dosovitskiy et al., 2021), and our approach manages to narrow this performance gap, even within a 16-shot setting $( 7 8 . 3 \\%$ ), thereby exhibiting superior few-shot learning on ImageNet-level datasets. Furthermore, the out-of-domain performance also witnesses a substantial boost in comparison to existing methods. When compared with LoRA, GLoRA enhances out-of-domain performance by as much as $1 0 0 \\%$ (ImageNet-A) and 50% (ImageNet-Sketch). ",
469
+ "page_idx": 8
470
+ },
471
+ {
472
+ "type": "text",
473
+ "text": "4 Analysis and Discussion ",
474
+ "text_level": 1,
475
+ "page_idx": 8
476
+ },
477
+ {
478
+ "type": "text",
479
+ "text": "Computational Cost. We show the final inference throughput of various PEFT methods in Table 4, computed on an NVIDIA 3090 GPU. It is in this context that GLoRA significantly outperforms other methods, as GLoRA benefits from zero parameter or FLOPs overhead during the inference process. An ancillary advantage is the expedited adaptability in real-world scenarios where previous models are already deployed. The weights of GLoRA can be directly loaded without necessitating any manual system modifications. As previously mentioned, GLoRA supports VPT-Deep level prompts via the support tensor $\\mathbf { C }$ , however, it does not impose any computational overhead due to its complete structural re-parameterization design. ",
480
+ "page_idx": 8
481
+ },
482
+ {
483
+ "type": "text",
484
+ "text": "Quantitatively GLoRA requires an additional 5.6 folds of training time compared to a single run of LoRA amounting to a total of 142 minutes for each VTAB-1k task. The GPU memory consumption of GLoRA is 13 GB compared to 9 GB for LoRA. Most of it is primarily because GLoRA requires roughly $5 \\times$ more epochs than LoRA for appropriate convergence and the additional time is spent on the evolutionary search process. This extra time of GLoRA leads to an average increase of $4 . 5 \\ \\%$ accuracy across 19 vision tasks as compared to LoRA. We have also observed that GLoRA uses this additional time to surpass the combined performance of the other Top-5 methods. More details related to this experiment can be found in Appendix C. ",
485
+ "page_idx": 8
486
+ },
487
+ {
488
+ "type": "table",
489
+ "img_path": "images/021731e09130c4c3901c7ebfdec2802dbe837b7518ff078649c6837ab7b574b3.jpg",
490
+ "table_caption": [
491
+ "Table 5: Inference efficiency comparison of GLoRA with existing methods. "
492
+ ],
493
+ "table_footnote": [],
494
+ "table_body": "<table><tr><td rowspan=\"2\">Method</td><td rowspan=\"2\">↑#Param(M)</td><td rowspan=\"2\">↑FLOPs(G)</td><td colspan=\"3\">Throughput (imgs/sec)</td></tr><tr><td>bs=1</td><td>bs=4</td><td>bs=16</td></tr><tr><td>Full tuning</td><td>0</td><td>0</td><td>91.5</td><td>375.7</td><td>539.5</td></tr><tr><td>VPT Jia et al. (2022)</td><td>0.55</td><td>5.60</td><td>86.1</td><td>283.5</td><td>381.5</td></tr><tr><td>Adapter Houlsby et al. (2019)</td><td>0.16</td><td>0.03</td><td>70.9</td><td>306.6</td><td>504.7</td></tr><tr><td>AdaptFormer Chen et al. (2022)</td><td>0.16</td><td>0.03</td><td>71.4</td><td>309.9</td><td>508.1</td></tr><tr><td>NOAH Zhang et al. (2022)</td><td>0.12</td><td>0.02</td><td>72.1</td><td>312.7</td><td>492.9</td></tr><tr><td>LoRA Hu et al (2021)</td><td>0</td><td>0</td><td>91.5</td><td>375.7</td><td>539.6</td></tr></table>",
495
+ "page_idx": 8
496
+ },
497
+ {
498
+ "type": "image",
499
+ "img_path": "images/9eb320a5aefcc9a2effe711788057bf11c06998c2f871a3908bd45e4a3521622.jpg",
500
+ "image_caption": [
501
+ "Figure 3: Distribution of GLoRA (0.86M) parameters across layer types on VTAB-1K. Q-K-V and Projection are linear layers in MHSA module and FC1 and FC2 are linear layers in MLP module. "
502
+ ],
503
+ "image_footnote": [],
504
+ "page_idx": 9
505
+ },
506
+ {
507
+ "type": "image",
508
+ "img_path": "images/ff2756a13b1acbc2f1cb88d90fc11d8ff9c7a5ec2e12129573159dba4254d1c1.jpg",
509
+ "image_caption": [
510
+ "Figure 4: Layerwise configuration of support tensors of GLoRA (0.86M) on VTAB-1K dataset. "
511
+ ],
512
+ "image_footnote": [],
513
+ "page_idx": 9
514
+ },
515
+ {
516
+ "type": "text",
517
+ "text": "Visualizations of searched fine-tuning strategy for each layer. Figure 3 visually shows the distribution of trainable parameters across the four types of linear layers embodied in ViT-B. Notably, the projection layer possesses the minimum quantity of trainable parameters spanning across VTAB-1K categories. Generally, the MLP module hosts a substantially higher number of parameters compared to the MHSA. As anticipated, the structured group necessitates a greater number of parameters for adaptation due to a pronounced domain drift relative to ImageNet-1K (Deng et al., 2009b). Figure 4 illustrates the layerwise configuration of the support tensors as searched by the GLoRA algorithm. Each support tensor at every layer can potentially undergo 72 distinct adaptations across datasets. Support tensors $\\mathbf { D }$ and $\\mathbf { E }$ exhibit relatively low adaptation due to the prevalence of none adaptations, whereas A and $\\mathbf { B }$ demonstrate a higher number of adaptations, though without a discernible pattern regarding the type of adaptation. It’s important to underscore that even a basic scalar can function effectively as a support tensor, enabling GLoRA to maintain superior parameter efficiency despite adapting every linear layer. ",
518
+ "page_idx": 9
519
+ },
520
+ {
521
+ "type": "text",
522
+ "text": "5 Related Work ",
523
+ "text_level": 1,
524
+ "page_idx": 9
525
+ },
526
+ {
527
+ "type": "text",
528
+ "text": "Given the rapid expansion in model size, numerous methods for parameter-efficient fine-tuning (PEFT) have been introduced in the field of Natural Language Processing (NLP) to streamline the optimization of large language models (LLMs). (Liu et al., 2021a; Zhang et al.; Hu et al.; Liu et al., 2021b; Li & Liang, 2021; Lester et al., 2021; Zaken et al., 2022; Houlsby et al., 2019). The effectiveness of parameter-efficient fine-tuning has been proven in a wide range of natural language processing tasks (Fu et al., 2022). With the advent growth in the size of vision models (Dehghani et al., 2023; Kolesnikov et al., 2020), methods specifically focused on image models have also been put forward (Jie & Deng, 2022; Lian et al., 2022; Chen et al., 2022; Luo et al., 2023; Zhang et al., 2022; Jia et al., 2022; He et al., 2023). ",
529
+ "page_idx": 9
530
+ },
531
+ {
532
+ "type": "text",
533
+ "text": "",
534
+ "page_idx": 10
535
+ },
536
+ {
537
+ "type": "text",
538
+ "text": "Among these methods, LoRA (Hu et al.) has proven to transfer well across modalities and tasks. This is partly due to the simplistic design strategy of LoRA which directly works over weight tensors, irrespective of model type or configuration. Additionally, unlike Adapters (Houlsby et al., 2019; Chen et al., 2022) and Prompt tuning (Jia et al., 2022), LoRA does not add any additional inference parameters or latency due to structural re-parameterization (SR) design. RepAdapter (Luo et al., 2023) and SSF (Lian et al., 2022) also propose an SR design for PEFT, however RepAdapter is specific to model architectures and required manual designing for different layer configurations, SSF provides a very simple baseline but suffers from low flexibility and capability due to adaptation limited in the activation space. FacT (Jie & Deng, 2022) further decomposes LoRA matrices for better parameter efficiency, but we argue that $<$ <1M parameter scale is fairly efficient for fine-tuning on a single GPU. Thus, due to the advantages of LoRA over other related works, it is of importance to increase the flexibility, scalability and adaptability of LoRA. ",
539
+ "page_idx": 10
540
+ },
541
+ {
542
+ "type": "text",
543
+ "text": "6 Conclusion ",
544
+ "text_level": 1,
545
+ "page_idx": 10
546
+ },
547
+ {
548
+ "type": "text",
549
+ "text": "We have presented GLoRA, a generalized parameter-efficient fine-tuning approach that has successfully demonstrated the effectiveness in enhancing the fine-tuning and transfer learning ability for the large-scale pre-trained models. By adopting a generalized low-rank adaptation and re-parameterization framework, GLoRA significantly reduces the number of parameters and computation required for fine-tuning, making it a more resource-efficient and practical method for real-world applications. The experiments conducted on a diverse range of tasks and datasets have substantiated the superiority of GLoRA over existing PEFT techniques, showcasing its scalability and adaptability. Moreover, the ablation studies have provided valuable insights into the inner workings and the relative importance of different GLoRA components. This work not only contributes to the improvement of the fine-tuning process for large-scale pre-trained models but also opens up new avenues for future work, including further exploration of generalized low-rank adaptation techniques, the development of hybrid approaches, and the refinement of search and optimization algorithms. These areas of research may continue to expand the accessibility and efficiency of transfer learning across a broader range of applications. ",
550
+ "page_idx": 10
551
+ },
552
+ {
553
+ "type": "text",
554
+ "text": "Reproducibility. We provide detailed training recipes in Section 3 and the Appendix. Code is also provided for reproducibility. ",
555
+ "page_idx": 10
556
+ },
557
+ {
558
+ "type": "text",
559
+ "text": "References ",
560
+ "text_level": 1,
561
+ "page_idx": 10
562
+ },
563
+ {
564
+ "type": "text",
565
+ "text": "Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014. \nMinghao Chen, Houwen Peng, Jianlong Fu, and Haibin Ling. Autoformer: Searching transformers for visual recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 12270–12280, October 2021. \nShoufa Chen, Chongjian Ge, Zhan Tong, Jiangliu Wang, Yibing Song, Jue Wang, and Ping Luo. Adaptformer: Adapting vision transformers for scalable visual recognition. arXiv preprint arXiv:2205.13535, 2022. \nPeter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018. \nMostafa Dehghani, Josip Djolonga, Basil Mustafa, Piotr Padlewski, Jonathan Heek, Justin Gilmer, Andreas Steiner, Mathilde Caron, Robert Geirhos, Ibrahim Alabdulmohsin, et al. Scaling vision transformers to 22 billion parameters. arXiv preprint arXiv:2302.05442, 2023. \nJia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, 2009a. \nJia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 248–255. Ieee, 2009b. \nXiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, and Jian Sun. Repvgg: Making vgg-style convnets great again. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 13733–13742, 2021. \nAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. \nNathan Habib Sheon Han Nathan Lambert Nazneen Rajani Omar Sanseviero Lewis Tunstall Thomas Wolf Edward Beeching, Clémentine Fourrier. Open llm leaderboard. https://huggingface.co/spaces/ HuggingFaceH4/open_llm_leaderboard, 2023. \nZihao Fu, Haoran Yang, Anthony Man-Cho So, Wai Lam, Lidong Bing, and Nigel Collier. On the effectiveness of parameter-efficient fine-tuning. arXiv preprint arXiv:2211.15583, 2022. \nHaoyu He, Jianfei Cai, Jing Zhang, Dacheng Tao, and Bohan Zhuang. Sensitivity-aware visual parameterefficient tuning, 2023. URL https://openreview.net/forum?id=9GOjmbRQ2o. \nDan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. In International Conference on Learning Representations, 2020. \nDan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of outof-distribution generalization. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 8340–8349, 2021a. \nDan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 15262–15271, 2021b. \nNeil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In International Conference on Machine Learning, pp. 2790–2799. PMLR, 2019. \nEdward J Hu, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen, et al. Lora: Low-rank adaptation of large language models. In International Conference on Learning Representations. \nEdward 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. \nMenglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and SerNam Lim. Visual prompt tuning. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXXIII, pp. 709–727. Springer, 2022. \nShibo Jie and Zhi-Hong Deng. Fact: Factor-tuning for lightweight adaptation on vision transformer. arXiv preprint arXiv:2212.03145, 2022. \nAlexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part V 16, pp. 491–507. Springer, 2020. \nJonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In Proceedings of the IEEE international conference on computer vision workshops, pp. 554–561, 2013. \nBrian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 3045– 3059, 2021. \nXiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 4582–4597, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.353. URL https: //aclanthology.org/2021.acl-long.353. \nDongze Lian, Daquan Zhou, Jiashi Feng, and Xinchao Wang. Scaling & shifting your features: A new baseline for efficient model tuning. arXiv preprint arXiv:2210.08823, 2022. \nStephanie Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. pp. 3214–3252, 01 2022. doi: 10.18653/v1/2022.acl-long.229. \nXiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. CoRR, abs/2110.07602, 2021a. URL https://arxiv.org/abs/2110.07602. \nXiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. Gpt understands, too, 2021b. \nIlya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations. \nGen Luo, Minglang Huang, Yiyi Zhou, Xiaoshuai Sun, Guannan Jiang, Zhiyu Wang, and Rongrong Ji. Towards efficient visual adaption via structural re-parameterization. arXiv preprint arXiv:2302.08106, 2023. \nSubhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013. \nM-E Nilsback and Andrew Zisserman. A visual vocabulary for flower classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), volume 2, pp. 1447–1454. IEEE, 2006. \nOmkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3498–3505. IEEE, 2012. \nAlec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, and Ilya Sutskever. Robust speech recognition via large-scale weak supervision. arXiv preprint arXiv:2212.04356, 2022. \nBenjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning (ICML), pp. 5389–5400. PMLR, 2019. \nZhiqiang Shen, Zechun Liu, Jie Qin, Marios Savvides, and Kwang-Ting Cheng. Partial is better than all: revisiting fine-tuning strategy for few-shot learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 9594–9602, 2021. \nRohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/ tatsu-lab/stanford_alpaca, 2023. \nHugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023a. \nHugo 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, 2023b. \nLaurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008. \nVladimir N Vapnik and A Ya Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Measures of complexity: festschrift for alexey chervonenkis, pp. 11–30, 2015. \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. \nHaohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. Advances in Neural Information Processing Systems (NeuIPS), 32, 2019. \nElad Ben Zaken, Yoav Goldberg, and Shauli Ravfogel. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 1–9, 2022. \nRowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. HellaSwag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4791–4800, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1472. URL https://aclanthology.org/P19-1472. \nXiaohua Zhai, Joan Puigcerver, Alexander Kolesnikov, Pierre Ruyssen, Carlos Riquelme, Mario Lucic, Josip Djolonga, Andre Susano Pinto, Maxim Neumann, Alexey Dosovitskiy, Lucas Beyer, Olivier Bachem, Michael Tschannen, Marcin Michalski, Olivier Bousquet, Sylvain Gelly, and Neil Houlsby. The visual task adaptation benchmark, 2020. URL https://openreview.net/forum?id=BJena3VtwS. \nQingru Zhang, Minshuo Chen, Alexander Bukharin, Pengcheng He, Yu Cheng, Weizhu Chen, and Tuo Zhao. Adaptive budget allocation for parameter-efficient fine-tuning. In The Eleventh International Conference on Learning Representations. \nYuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022. \nKaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization in vision: A survey. arXiv preprint arXiv:2103.02503, 2021. ",
566
+ "page_idx": 10
567
+ },
568
+ {
569
+ "type": "text",
570
+ "text": "",
571
+ "page_idx": 11
572
+ },
573
+ {
574
+ "type": "text",
575
+ "text": "",
576
+ "page_idx": 12
577
+ },
578
+ {
579
+ "type": "text",
580
+ "text": "",
581
+ "page_idx": 13
582
+ },
583
+ {
584
+ "type": "text",
585
+ "text": "Appendix ",
586
+ "text_level": 1,
587
+ "page_idx": 14
588
+ },
589
+ {
590
+ "type": "table",
591
+ "img_path": "images/dd4c601aa98665e9300784723c85029629a6ffe6742ebdc5acb5fddedf47fdd5.jpg",
592
+ "table_caption": [
593
+ "A Hyperparameters ",
594
+ "Table 6: Learning rate of dataset-specific supernet training on VTAB-1K datastet. "
595
+ ],
596
+ "table_footnote": [],
597
+ "table_body": "<table><tr><td>Dataset</td><td></td><td></td><td></td><td></td><td></td><td>sd</td><td>NHAS</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>ooT-Idsp</td><td>uo-Idsp</td><td></td><td></td></tr><tr><td>LR</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td></td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td>1e-4</td><td>1e-4</td><td>1e-4</td><td>5e-4</td><td></td><td>5e-4</td><td>5e-4</td><td>5e-4</td><td></td><td>5e-41e-4</td></tr></table>",
598
+ "page_idx": 14
599
+ },
600
+ {
601
+ "type": "text",
602
+ "text": "Our approach necessitate minimal adjustments to hyperparameters, with optimizer hyperparameters being the sole exception, thanks to the inherent search mechanism. Following prior studies (Dehghani et al., 2023; Chen et al., 2022; Zhang et al., 2022), we employ the AdamW optimizer (Loshchilov $\\&$ Hutter) for all our experiments. ",
603
+ "page_idx": 14
604
+ },
605
+ {
606
+ "type": "text",
607
+ "text": "For the hyperparameter search in vision tasks, we primarily concentrate on the exploration of the learning rate for supernet training, limiting our search scope to two potential alternatives: $1 e ^ { - 4 }$ and $5 e ^ { - 4 }$ . For a detailed account of dataset-specific learning rates, please refer to Table A. All other training particulars strictly adhere to the exact training policy delineated in the works of (Jie & Deng, 2022; Luo et al., 2023). In the case of few-shot learning datasets and ImageNet, we use learning rates of $5 e ^ { - 4 }$ and $1 e ^ { - 4 }$ respectively, as the few-shot learning datasets are smaller as compared to 16-shot ImageNet. ",
608
+ "page_idx": 14
609
+ },
610
+ {
611
+ "type": "text",
612
+ "text": "For language modeling experiments we use a learning rate of $2 e ^ { - 5 }$ with cosine annealing and an equivalent batch size of 32 (using gradient accumulation) for both LoRA and GLoRA. Consequently, LoRA is trained for 3 epochs, and due to the supernet structure of GLoRA, we train it for 15 epochs. This is in line with vision experiments where LoRA is trained for 100 epochs and GLoRA supernet for 500 epochs. We justify these extra training epochs due to the fact that LoRA requires hyperparameter tuning (dropout rate, adaptation layer choice, alpha, etc.) while GLoRA being a searched-based method requires no such tuning. We provide more such method-specific hyperparameters in Appendix C which justifies GLoRA’s extra training time. ",
613
+ "page_idx": 14
614
+ },
615
+ {
616
+ "type": "text",
617
+ "text": "B Hierarchical Transformer ",
618
+ "text_level": 1,
619
+ "page_idx": 14
620
+ },
621
+ {
622
+ "type": "text",
623
+ "text": "We show the performance of GLoRA on the Swin-B backbone in Table B. We follow a dataset-specific learning rate search similar to ViT-B and also add GLoRA to the reduction linear layer in Swin architecture to maintain uniformity and avoid architecture-specific tuning. GLoRA can adapt to any layer irrespective of architecture configuration and perform well across tasks and datasets which can be clearly seen in Table B where GLoRA outperforms all existing works by a fair margin. ",
624
+ "page_idx": 14
625
+ },
626
+ {
627
+ "type": "table",
628
+ "img_path": "images/ef58bbdc45cc32487591fba08d68633ba08045347429c25f16be327204108a15.jpg",
629
+ "table_caption": [
630
+ "Table 7: Performance on VTAB-1K benchmark with Swin-B pre-trained on ImageNet-21K as the backbone. "
631
+ ],
632
+ "table_footnote": [],
633
+ "table_body": "<table><tr><td>Method</td><td>Natural</td><td>Specialized</td><td>Structured</td><td> Average</td></tr><tr><td>Full</td><td>79.2</td><td>86.2</td><td>59.7</td><td>75.0</td></tr><tr><td>Linear</td><td>73.5</td><td>80.8</td><td>33.5</td><td>62.6</td></tr><tr><td>BitFit</td><td>74.2</td><td>80.1</td><td>42.4</td><td>65.6</td></tr><tr><td>VPT</td><td>76.8</td><td>84.5</td><td>53.4</td><td>71.6</td></tr><tr><td>FacT</td><td>82.7</td><td>87.5</td><td>62.0</td><td>77.4</td></tr><tr><td>RepAdapter</td><td>83.1</td><td>86.9</td><td>62.1</td><td>77.4</td></tr><tr><td>GLoRA</td><td>83.7</td><td>88.7</td><td>61.9</td><td>78.1</td></tr></table>",
634
+ "page_idx": 14
635
+ },
636
+ {
637
+ "type": "text",
638
+ "text": "C Training Time ",
639
+ "text_level": 1,
640
+ "page_idx": 14
641
+ },
642
+ {
643
+ "type": "text",
644
+ "text": "GLoRA, being a search-based approach for PEFT, naturally incurs increased training time due to the requirements of supernet training and evolutionary search. It is, however, critical to underscore that all ",
645
+ "page_idx": 14
646
+ },
647
+ {
648
+ "type": "table",
649
+ "img_path": "images/0b50d465f9ae878fec6abeecfffcd4dc00fac86f937c93ca67d2021e4b24d7c6.jpg",
650
+ "table_caption": [
651
+ "Table 8: Manual design choices in existing works "
652
+ ],
653
+ "table_footnote": [],
654
+ "table_body": "<table><tr><td>Method</td><td>Design Choices/Hyperparameters</td></tr><tr><td>VPT AdaptFormer</td><td>Prompt Length, Prompt Location,Prompt Depth Adapter Location, Scaling Factor, Hidden dimension, Insertion Form</td></tr><tr><td>NOAH RepAdapter</td><td>VPT choices,Adapter choices, LoRA rank Adapter Location,Number of groups,Hidden dimension,Adapter variants</td></tr><tr><td>FacT GLoRA</td><td>Decomposition method, Scaling factor, Decomposition Rank LoRA ranks in search space</td></tr></table>",
655
+ "page_idx": 15
656
+ },
657
+ {
658
+ "type": "table",
659
+ "img_path": "images/5976f61d40c3f4100766c215ae85ce6f8336dc80920b9a1a60b73ab7ebe11473.jpg",
660
+ "table_caption": [],
661
+ "table_footnote": [],
662
+ "table_body": "<table><tr><td>Method</td><td>Training Time</td><td>Inference Time</td><td>Natural</td><td>Specialized</td><td>Structured</td><td>Average</td></tr><tr><td>NOAH</td><td>6x</td><td>个</td><td>80.3</td><td>84.9</td><td>61.3</td><td>75.5</td></tr><tr><td>Best-5</td><td>10.1x</td><td></td><td>82.5</td><td>86.7</td><td>63.3</td><td>77.5</td></tr><tr><td>GLoRA</td><td>6.6x</td><td>1</td><td>83.6</td><td>87.0</td><td>63.3</td><td>78.0</td></tr></table>",
663
+ "page_idx": 15
664
+ },
665
+ {
666
+ "type": "text",
667
+ "text": "Table 9: Best-5 indicates the average task-specific best-performing model across LoRA, NOAH, FacT, SSF and RepAdapter. x indicates the training time of LoRA. ",
668
+ "page_idx": 15
669
+ },
670
+ {
671
+ "type": "text",
672
+ "text": "current methods necessitate a manual search for design choices, as evidenced in Table C. This necessity significantly inflates the total training time for a specific dataset, due to the broad search within these design choices. GLoRA streamlines this process through an automated evolutionary search mechanism, thus leveraging the benefit of an expansive search space. ",
673
+ "page_idx": 15
674
+ },
675
+ {
676
+ "type": "text",
677
+ "text": "Additionally, we consider 5 best-performing methods on the VTAB-1k dataset - LoRA, NOAH, FacT, SSF and RepAdapter; and pick the task-specific best-performing models across them. We denote the training time of LoRA as x and the corresponding training time of NoAH, FacT, SSF and RepAdapter are 6x, x, 1.2x and 0.9x respectively. GLoRA’s total training time including architecture search is 6.6x. The table below shows the performance and training time of Best-5 methods and GLoRA. This is to indicate that the combined training time of 5 best existing methods is more than that of GLoRA and yet it delivers a superior performance over its counterpart. It is important to note that this gain is reported assuming that the other adaptation methods do not require any hyperparameter search. However, unlike GLoRA, needing minimal hyperparameter search, some of the other adaptation methods require thorough data-specific hyperparameter search for optimal performance. If we had considered this aspect also, then the training time required by GLoRA would be very significantly lower in a relative sense. ",
678
+ "page_idx": 15
679
+ },
680
+ {
681
+ "type": "text",
682
+ "text": "D Search Space ",
683
+ "text_level": 1,
684
+ "page_idx": 15
685
+ },
686
+ {
687
+ "type": "text",
688
+ "text": "In this section, we undertake the computation of the possible number of subnets within our GLoRA-adapted supernet. Each layer offers $4 , 4 , 3 , 3$ , and 3 options for the support tensor A, $\\mathbf { B }$ , $\\mathbf { C }$ , $\\mathbf { D }$ , and $\\mathbf { E }$ , respectively. This results in 432 possible configurations for a single linear layer. In our implementation, we incorporate 48 such layers within ViT-B, yielding a total of $4 3 2 \\times 4 8 = 2 0 , 7 3$ 6 subnets being explored within GLoRA. This figure can escalate if multiple LoRA ranks coexist within the same search space. For instance, we allow ranks 8 and 4 in our largest GLoRA models, leading to $8 2 , 9 4 4$ distinct subnets. Furthermore, owing to the phenomenon of weight entanglement as per (Chen et al., 2021), comparable performance is maintained across all subnets, even if they are not all explored during the training of the supernet. ",
689
+ "page_idx": 15
690
+ },
691
+ {
692
+ "type": "text",
693
+ "text": "E Support Tensor ",
694
+ "text_level": 1,
695
+ "page_idx": 15
696
+ },
697
+ {
698
+ "type": "text",
699
+ "text": "In this section, we justify the choices of support tensors in our framework. Consider a linear layer that facilitates the transformation of inputs from a $d _ { 1 }$ dimensional space to a $d _ { 2 }$ dimensional space, with a corresponding weight matrix $\\mathbf { W } _ { 0 } \\in \\mathbb { R } ^ { d _ { 2 } \\times d _ { 1 } }$ . Given that $\\mathbf { A }$ is tasked with scaling $\\mathbf { W } _ { 0 }$ , $\\mathbf { A }$ could feasibly belong to $\\mathbb { R } ^ { d _ { 2 } \\times d _ { 1 } } , \\mathbb { R } ^ { d _ { 2 } \\times 1 }$ , or $\\mathbb { R } ^ { 1 \\times 1 }$ . These matrix dimensions are respectively indicative of LoRA, vector, and scalar operations. It’s pertinent to note that in scenarios where $\\mathbf { A } \\in \\mathbb { R } ^ { d _ { 2 } \\times d _ { 1 } }$ , LoRA is realized via corresponding matrices $\\mathbf { A } _ { d } \\in \\mathbb { R } ^ { d _ { 2 } \\times r }$ and $\\mathbf { A } _ { u } \\in \\mathbb { R } ^ { r \\times d _ { 1 } }$ . A parallel scrutiny of other support tensors would result in determining the appropriate support tensor choice, as elaborated in Section 2.3 of the main paper. ",
700
+ "page_idx": 15
701
+ },
702
+ {
703
+ "type": "text",
704
+ "text": "",
705
+ "page_idx": 16
706
+ },
707
+ {
708
+ "type": "text",
709
+ "text": "F Fine-tuned Embedding Visualization ",
710
+ "text_level": 1,
711
+ "page_idx": 16
712
+ },
713
+ {
714
+ "type": "image",
715
+ "img_path": "images/a262e2977a1bb538766e8fe072afdd3d34ee38571c410e264698b66a8ac4cc08.jpg",
716
+ "image_caption": [
717
+ "Figure 5: Visualization of features from SVHN dataset by t-SNE (Van der Maaten & Hinton, 2008). "
718
+ ],
719
+ "image_footnote": [],
720
+ "page_idx": 16
721
+ },
722
+ {
723
+ "type": "text",
724
+ "text": "We present feature visualizations of the ViT-B model adapted via GLoRA and FacT (Jie & Deng, 2022) methods applied to the SVHN dataset. We selected FacT as opposed to LoRA (Hu et al.), given that FacT constitutes a direct mathematical enhancement over LoRA and presently represents the state-of-the-art. A clear distinction can be discerned whereby GLoRA exhibits superiorly segregated clusters in comparison to FacT. Further, the delineations are broader, and the clusters demonstrate a higher degree of concentration, signaling the heightened discriminative capacity of the GLoRA-adapted model features. ",
725
+ "page_idx": 16
726
+ },
727
+ {
728
+ "type": "text",
729
+ "text": "G GLoRA with Higher Capacity ",
730
+ "text_level": 1,
731
+ "page_idx": 16
732
+ },
733
+ {
734
+ "type": "text",
735
+ "text": "Model capacity refers to the capability of a model to approximate a diverse range of functions. A method for regulating the capacity of a learning algorithm involves selecting an appropriate hypothesis space, essentially a set of functions that the learning algorithm is permitted to consider as potential solutions. The VapnikChervonenkis Dimension (VC Dimension) (Vapnik & Chervonenkis, 2015) is a measure of the capacity (complexity, expressiveness) of a set of functions that can be learned by a statistical classification algorithm. It is defined as the cardinality of the largest set of points that the algorithm can shatter. By estimating the VC Dimension of a deep model, we can get an idea of how capable the model is of fitting complex datasets. A very high VC Dimension could indicate that the model has enough capacity to learn the training data perfectly but might overfit and generalize poorly on new data. ",
736
+ "page_idx": 16
737
+ },
738
+ {
739
+ "type": "text",
740
+ "text": "Theorem 1. Suppose $\\mathbf { d } _ { \\mathrm { v c } } ( \\mathcal { H } )$ is the VC dimension of any finite hypothesis $\\mathcal { H }$ . If $\\mathcal { H } _ { \\mathrm { i } } \\subseteq \\mathcal { H } _ { \\mathrm { u n i } }$ ",
741
+ "page_idx": 16
742
+ },
743
+ {
744
+ "type": "equation",
745
+ "img_path": "images/f2e03a47c1bca7efb6f00ec492f1bf0c3b1b1bbfce9b57bdfe82cb53c9d0f356.jpg",
746
+ "text": "$$\n\\mathbf { d } _ { \\mathrm { v c } } ( \\mathcal { H } _ { \\mathrm { u n i } } ) - \\mathbf { d } _ { \\mathrm { v c } } ( \\mathcal { H } _ { \\mathrm { i } } ) \\geq \\epsilon \\qquad s . t . \\quad \\epsilon \\geq 0\n$$",
747
+ "text_format": "latex",
748
+ "page_idx": 16
749
+ },
750
+ {
751
+ "type": "text",
752
+ "text": "In the context of GLoRA, $\\mathcal { H } _ { \\mathrm { i } }$ denotes the hypothesis space of a randomly sampled subnet and ${ \\mathcal { H } } _ { \\mathrm { u n i } }$ denotes the hypothesis space of the complete supernet. The validity of this theorem stems from the inherent property of our problem context, where the hypothesis space $\\mathcal { H } _ { \\mathrm { i } }$ is a subset of ${ \\mathcal { H } } _ { \\mathrm { u n i } }$ in our context. ${ \\mathcal { H } } _ { \\mathrm { u n i } }$ encompasses all possible shattered scenarios of $\\mathcal { H } _ { \\mathrm { i } }$ . For the extreme case where the VC dimension $\\mathbf { d } _ { \\mathrm { v c } } ( \\mathcal { H } _ { \\mathrm { o } } )$ ( $\\mathcal { H } _ { \\mathrm { o } }$ is the difference set of ${ \\mathcal { H } } _ { \\mathrm { u n i } }$ and $\\mathcal { H } _ { \\mathrm { i } }$ ) is $0$ , the error $\\epsilon$ will be zero. As per learning theory, a higher VC dimension implies greater model flexibility and capability of our approach. Clearly, Theorem 1 holds for GLoRA and thus it experiences a greater model capacity. ",
753
+ "page_idx": 16
754
+ },
755
+ {
756
+ "type": "text",
757
+ "text": "",
758
+ "page_idx": 17
759
+ }
760
+ ]
parse/test/TQeT7UupFk/TQeT7UupFk_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/TQeT7UupFk/TQeT7UupFk_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/XII0Wp1XA9/XII0Wp1XA9.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/XII0Wp1XA9/XII0Wp1XA9_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/XII0Wp1XA9/XII0Wp1XA9_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/XII0Wp1XA9/XII0Wp1XA9_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/test/pzpWBbnwiJ/pzpWBbnwiJ.md ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNIVERSAL GUIDANCE FOR DIFFUSION MODELS
2
+
3
+ Arpit Bansal\* University of Maryland bansal01@umd.edu
4
+
5
+ Hong-Min Chu\* University of Maryland
6
+
7
+ Avi Schwarzschild University of Maryland
8
+
9
+ Soumyadip Sengupta University of North Carolina
10
+
11
+ Micah Goldblum New York University
12
+
13
+ Jonas Geiping University of Maryland
14
+
15
+ Tom Goldstein University of Maryland
16
+
17
+ # ABSTRACT
18
+
19
+ Typical diffusion models are trained to accept a particular form of conditioning, most commonly text, and cannot be conditioned on other modalities without retraining. In this work, we propose a universal guidance algorithm that enables diffusion models to be controlled by arbitrary guidance modalities without the need to retrain any use-specific components. We show that our algorithm successfully generates quality images with guidance functions including segmentation, face recognition, object detection, and classifier signals. Code is available at github.com/arpitbansal297/Universal-Guided-Diffusion.
20
+
21
+ ![](images/3f7a4433d41d370a31de7b104f18207cd63152f2139a3f7c0a357bebd19f13f1.jpg)
22
+ Figure 1: Diffusion guided by off-the-shelf networks. Top left: segmentation guidance, top-right: face recognition guidance, bottom-left: object detection guidance, bottom-right: style-transfer.
23
+
24
+ # 1 INTRODUCTION
25
+
26
+ Diffusion models are powerful tools for creating digital art and graphics. Much of their success stems from our ability to carefully control their outputs, customizing results for each user’s individual needs. Most models today are controlled through conditioning. With conditioning, the diffusion model is built from the ground up to accept a particular modality of input from the user, be it descriptive text, segmentation maps, class labels, etc. While conditioning is a powerful tool, it results in models that are handcuffed to a single conditioning modality. If another modality is needed, a new model has to be trained, often from scratch. Unfortunately, the high cost of training makes this prohibitive for most users.
27
+
28
+ A more flexible approach to controlling model outputs is to use guidance. In this approach, the diffusion model acts as a generic image generator, and is not required to understand a user’s instructions. The user pairs this model with a guidance function that measures whether some criterion has been met. For example, one could guide the model to minimize the CLIP score between the generated image and a text description of the user’s choice. During each iteration of image creation, the iterates are nudged down the gradient of the guidance function, causing the final generated image to satisfy the user’s criterion.
29
+
30
+ In this paper, we study guidance methods that enable any off-the-shelf model or loss function to be used as guidance for diffusion. Because guidance functions can be used without re-training or modification, this form of guidance is universal in that it enables a diffusion model to be adapted for nearly any purpose.
31
+
32
+ From a user perspective, guidance is superior to conditioning, as a single diffusion network is treated like a foundational model that provides universal coverage across many use cases, both commonplace and bespoke. Unfortunately, it is widely believed that this approach is infeasible. While early diffusion models relied on classifier guidance (Dhariwal & Nichol, 2021), the community quickly turned to classifier-free schemes (Ho & Salimans, 2022) that require a model to be trained from scratch on class labels with a particular frozen ontology that cannot be changed (Nichol et al., 2021; Rombach et al., 2022; Bansal et al., 2022).
33
+
34
+ The difficulty of using guidance stems from the domain shift between the noisy images used by the diffusion sampling process and the clean images on which the guidance models are trained. When this gap is closed, guidance can be performed successfully. For example, Nichol et al. (2021) successfully use a CLIP model as guidance, but only after re-training CLIP from scratch using noisy inputs. Noisy retraining closes the domain gap, but at a very high financial and engineering cost. To avoid the additional cost, we study methods for closing this gap by changing the sampling scheme, rather than the model.
35
+
36
+ To this end, our contributions are summarized as follows:
37
+
38
+ • We propose an algorithm that enables universal guidance for diffusion models. Our proposed sampler evaluates the guidance models only on denoised images, rather than noisy latent states. By doing so, we close the domain gap that has plagued standard guidance methods. This strategy provides the end-user with the flexibility to work with a wide range of guidance modalities and even multiple modalities simultaneously. The underlying diffusion model remains fixed and no fine-tuning of any kind is necessary.
39
+ • We demonstrate the effectiveness of our approach for a variety of different constraints such as classifier labels, human identities, segmentation maps, annotations from object detectors, and constraints arising from inverse linear problems.
40
+
41
+ # 2 BACKGROUND
42
+
43
+ We first briefly review the recent literature on the core framework behind diffusion models. Then, we define the problem setting of controlled image generation and discuss previous related works.
44
+
45
+ # 2.1 DIFFUSION MODELS
46
+
47
+ Diffusion models are strong generative models that proved powerful even when first introduced for image generation (Song & Ermon, 2019; Ho et al., 2020). The approach has been successfully extended to a number of domains, such as audio and text generation (Kong et al., 2020; Huang et al., 2022; Austin et al., 2021; Li et al., 2022).
48
+
49
+ We introduce (unconditional) diffusion formally, as it is helpful in describing the nuances of different types of models. A diffusion model is defined as a combination of a $T$ -step forward process and a $T$ -step reverse process. Conceptually, the forward process gradually adds Gaussian noise of different magnitudes to a clean data point $z _ { \mathrm { 0 } }$ , while the reverse process attempts to gradually denoise a noisy input in hopes of recovering a clean data point. More concretely, given an array of scalars representing noise scales $\{ \alpha _ { t } \} _ { t = 1 } ^ { T }$ and an initial, clean data point $z _ { 0 }$ , applying $t$ steps of the forward process to $z _ { 0 }$ yields a noisy data point
50
+
51
+ $$
52
+ z _ { t } = \sqrt { \alpha _ { t } } z _ { 0 } + ( \sqrt { 1 - \alpha _ { t } } ) \epsilon , \epsilon \sim \mathcal { N } ( 0 , \mathbf { I } ) .
53
+ $$
54
+
55
+ A diffusion model is a learned denoising network $\epsilon _ { \theta }$ . It is trained so that for any pair $( z _ { 0 } , t )$ and any sample of $\epsilon$ ,
56
+
57
+ $$
58
+ \epsilon _ { \theta } ( z _ { t } , t ) \approx \epsilon = \frac { z _ { t } - \sqrt { \alpha _ { t } } z _ { 0 } } { \sqrt { 1 - \alpha _ { t } } } .
59
+ $$
60
+
61
+ The reverse process takes the form $q \big ( z _ { t - 1 } | z _ { t } , z _ { 0 } \big )$ with various detail definitions, where $q ( \cdot | \cdot )$ is generally parameterized as a Gaussian distribution. Different works also studied different approximations of the unknown $q \big ( z _ { t - 1 } | z _ { t } , z _ { 0 } \big )$ used to perform sampling. For example, denoising diffusion implicit model (DDIM) (Song et al., 2021a) first computed a predicted clean data point
62
+
63
+ $$
64
+ \hat { z } _ { 0 } = \frac { z _ { t } - ( \sqrt { 1 - \alpha _ { t } } ) \epsilon _ { \theta } ( z _ { t } , t ) } { \sqrt { \alpha _ { t } } } ,
65
+ $$
66
+
67
+ and sample $z _ { t - 1 }$ from $q \big ( z _ { t - 1 } | z _ { t } , \hat { z } _ { 0 } \big )$ by replacing unknown $z _ { 0 }$ with $\hat { z } _ { 0 }$ . On the other hand, while the details of individual sampling methods vary, all sampling methods produce $z _ { t - 1 }$ based on current sample $z _ { t }$ , current time step $t$ and a predicted noise $\hat { \epsilon }$ . To ease the notation burden, we define a function $S ( \cdot , \cdot , \cdot )$ as an abstraction of the sampling method, where $\boldsymbol { z } _ { t - 1 } = \boldsymbol { S } ( \boldsymbol { z } _ { t } , \hat { \epsilon } , t )$ .
68
+
69
+ # 2.2 CONTROLLED IMAGE GENERATION
70
+
71
+ In this paper, we focus on controlled image generation with various constraints. Consider a differentiable guidance function $f$ , for example a CLIP feature extractor or a segmentation network. When applied to an image, we obtain a vector $c = f ( x )$ . We also consider a function $\ell ( \cdot , \cdot )$ that measures the closeness of two vectors $c$ and $c ^ { \prime }$ . Given a particular choice of $c$ , which we call a prompt, the corresponding constraint (based on $c , \ell$ , and $f$ ) is formalized as $\ell ( c , f ( z ) ) \approx 0$ , and we aim to generate a sample $z$ from the image distribution satisfying the constraint. In plain words, we want to generate an in-distribution image that matches the prompt.
72
+
73
+ Prior work on controlled generative diffusion falls into two main categories. We refer to the first category as conditional image generation, and the second category as guided image generation. Next, we discuss the characteristics of each category and better situate our work among existing methods.
74
+
75
+ Conditional Image Generation. Methods from this category require training new diffusion models that accept the prompt as an additional input (Ho & Salimans, 2022; Bansal et al., 2022; Nichol et al., 2021; Whang et al., 2022; Wang et al., 2022a; Li et al., 2023; Zhang & Agrawala, 2023). For example, Ho & Salimans (2022) proposed classifier-free guidance using class labels as prompts, and trained a diffusion model by linear interpolation between unconditional and conditional outputs of the denoising networks. Bansal et al. (2022) studied the case where the guidance function is a known linear degradation operator, and trained a conditional model to solve linear inverse problems. Nichol et al. (2021) further extended classifier-free guidance to text-conditional image generation with descriptive phrases as prompts, and trained a diffusion model to enforce the similarity between the CLIP (Radford et al., 2021) representations of the generated images and the text prompts. These methods are successful across different types of constraints, however the requirement to retrain the diffusion model makes them computationally intensive.
76
+
77
+ Guided Image Generation. Works in this category employed a frozen pre-trained diffusion model as a foundation model, but modify the sampling method to guide the image generation with feedback from the guidance function. Our method falls into this category. Prior work that studied guided image generation did so with a variety of restrictions and external guidance functions (Dhariwal & Nichol, 2021; Kawar et al., 2022; Wang et al., 2022b; Chung et al., 2022a; Lugmayr et al., 2022; Chung et al., 2022b; Graikos et al., 2022). For example, Dhariwal & Nichol (2021) proposed classifier guidance, where they trained a classifier on images of different noise scales as the guidance function $f$ , and included gradients of the classifier during the sampling process. However, a classifier for noisy images is domain-specific and generally not readily available – an issue our method circumvents. Wang et al. (2022b) assumed the external guidance functions to be linear operators, and generated the component of images residing in the null space of linear operators with the foundation model. Unfortunately, extending that method to handle non-linear guidance functions is non-trivial. Chung et al. (2022a) studied general guidance functions, and modified the sampling process with the gradient of guidance function calculated on the expected denoised images. Nevertheless, the authors only presented results with simpler non-linear guidance functions such as non-linear blurring.
78
+
79
+ In this work, we study universal guidance algorithms for guided image generation with diffusion models using any off-the-shelf guidance functions $f$ , such as object detection or segmentation networks.
80
+
81
+ # 3 UNIVERSAL GUIDANCE
82
+
83
+ We propose a guidance algorithm that augments the image sampling method of a diffusion model to include guidance from an off-the-shelf auxiliary network. Our algorithm is motivated by an empirical observation that the reconstructed clean image $\hat { z } _ { 0 }$ obtained by Eq. (3), while naturally imperfect, is still appropriate for a generic guidance function to provide informative feedback to guide the image generation. In Sec. 3.1, we motivate our forward universal guidance by extending classifier guidance Dhariwal & Nichol (2021) to leverage this observation and handle generic guidance functions. In Sec. 3.2, we propose a supplementary backward universal guidance to help enforce the generated image to satisfy the constraint based on the guidance function $f$ . In Sec. 3.3, we discuss a simple yet helpful stepwise refinement trick to empirically improve the fidelity of generated images.
84
+
85
+ # 3.1 FORWARD UNIVERSAL GUIDANCE
86
+
87
+ To guide the generation with information from the external guidance function $f$ and the loss function $\ell$ , an immediate thought is to extend classifier guidance (Dhariwal $\&$ Nichol, 2021) to accept any general guidance function. Concretely, given a class prompt $c$ , classifier guidance performs classification-guided sampling by replacing $\epsilon _ { \theta } ( z _ { t } , t )$ in each sampling step $S ( \boldsymbol { z } _ { t } , t )$ with
88
+
89
+ $$
90
+ \begin{array} { r } { \hat { \epsilon } _ { \theta } ( z _ { t } , t ) = \epsilon _ { \theta } ( z _ { t } , t ) - \sqrt { 1 - \alpha _ { t } } \nabla _ { z _ { t } } \log { p ( c | z _ { t } ) } . } \end{array}
91
+ $$
92
+
93
+ Defining $\ell _ { c e } ( \cdot , \cdot )$ to be the cross-entropy loss and $f _ { c l }$ to be the guidance function that outputs classification probability, Eq. (4) can be re-written as
94
+
95
+ $$
96
+ \hat { \epsilon } _ { \theta } ( z _ { t } , t ) = \epsilon _ { \theta } ( z _ { t } , t ) + \sqrt { 1 - \alpha _ { t } } \nabla _ { z _ { t } } \ell _ { c e } ( c , f _ { c l } ( z _ { t } ) ) .
97
+ $$
98
+
99
+ However, directly replacing $f _ { c l }$ and $\ell _ { c e }$ with any off-the-shelf guidance and loss functions does not work in practice, as $f$ is most likely trained on clean images and fails to provide meaningful guidance when the input is noisy.
100
+
101
+ To address the issue, we observe that
102
+
103
+ $$
104
+ p ( c | z _ { t } ) = \int p ( c | z _ { 0 } , z _ { t } ) p ( z _ { 0 } | z _ { t } ) d z _ { 0 } = \mathbb { E } _ { z _ { 0 } \sim p ( z _ { 0 } | z _ { t } ) } [ p ( c | z _ { 0 } ) ] .
105
+ $$
106
+
107
+ where $c$ is conditionally-independent with $z _ { t }$ given $z _ { 0 }$ . Leveraging the fact that we can obtain a predicted clean image $\hat { z } _ { 0 }$ by Eq. (3) with $\epsilon _ { \theta } ( z _ { t } , t )$ , we approximate the expectation in Eq. (6) as $\mathbb { \tilde { E } } _ { z _ { 0 } \sim p ( z _ { 0 } | z _ { t } ) } [ p ( c | z _ { 0 } ) ] \tilde { \mathbf { \Omega } } \approx p ( c | \hat { z } _ { 0 } )$ . This leads to our proposed guided sampling procedure
108
+
109
+ $$
110
+ \hat { \boldsymbol { \epsilon } } _ { \theta } ( z _ { t } , t ) = \boldsymbol { \epsilon } _ { \theta } ( z _ { t } , t ) + \boldsymbol { s } ( t ) \cdot \nabla _ { z _ { t } } \ell ( \boldsymbol { c } , f ( \hat { \boldsymbol { z } } _ { 0 } ) )
111
+ $$
112
+
113
+ where $s ( t )$ controls the guidance strength for each sampling step and
114
+
115
+ $$
116
+ \nabla _ { z _ { t } } \ell ( c , f ( \hat { z } _ { 0 } ) ) = \nabla _ { z _ { t } } \ell \left( c , f \left( \frac { z _ { t } - \sqrt { 1 - \alpha _ { t } } \epsilon _ { \theta } ( z _ { t } , t ) } { \sqrt { \alpha _ { t } } } \right) \right)
117
+ $$
118
+
119
+ as in Eq. (3). We term Eq. (7) forward universal guidance, or forward guidance in short. In practice, applying forward guidance effectively brings the generated image closer to the prompt while keeping the generation trajectory in the data manifold. We note that a related approach is also studied in Chung et al. (2022a), where the guidance step is computed based on $E [ z _ { 0 } | z _ { t } ]$ . The approach drew inspiration from the score-based generative framework (Song et al., 2021b), but resulted in a different update method.
120
+
121
+ # 3.2 BACKWARD UNIVERSAL GUIDANCE
122
+
123
+ As will be shown in Sec. 4.2, we observe that forward guidance sometimes over-prioritizes maintaining the “realness” of the image, resulting in an unsatisfactory match with the given prompt. Simply increasing the guidance strength $s ( t )$ is suboptimal, as this often results in instability as the image moves off the manifold faster than the denoiser can correct it.
124
+
125
+ # Algorithm 1 Universal Guidance
126
+
127
+ Parameter: Refinement steps $k$ , backward guidance
128
+ steps $m$ , and guidance strength $s ( t )$ ,
129
+ Required: $z _ { t }$ the noisy vector at a given time-step $t$
130
+ diffusion model $\epsilon _ { \theta }$ , noise scale $\alpha _ { t }$ , guidance function
131
+ $f$ , loss function $\ell$ , and prompt $c$
132
+ for $n = 1 , 2 , \ldots , k$ do Calculate $\hat { z } _ { 0 }$ as in Eq. (3). Calculate $\hat { \epsilon } _ { \theta }$ using forward universal guidance as in Eq. (7). if $m > 0$ then Calculate $\Delta z _ { 0 }$ by minimizing Eq. (8) with $m$ steps of gradient descent. Perform backward universal guidance by $\hat { \epsilon } _ { \theta } \gets \hat { \epsilon } _ { \theta } - \sqrt { \alpha _ { t } / ( 1 - \alpha _ { t } ) } \Delta z _ { 0 }$ (see Eq. (10)). end if $\boldsymbol { z } _ { t - 1 } \gets \boldsymbol { S } ( \boldsymbol { z } _ { t } , \hat { \boldsymbol { \epsilon } } _ { \theta } , t )$ . $\epsilon ^ { \prime } \sim \mathcal { N } ( 0 , \dot { I } )$ . $z _ { t } \gets \sqrt { \alpha _ { t } / \alpha _ { t - 1 } } z _ { t - 1 } + \sqrt { 1 - \alpha _ { t } / \alpha _ { t - 1 } } \epsilon ^ { \prime } .$
133
+ end for
134
+ Return zt−1
135
+
136
+ To address the issue, we propose backward universal guidance, or backward guidance in short, to supplement forward guidance and help enforce the generated image to satisfy the constraint. The key idea of backward guidance is to optimize for a clean image that best matches the prompt based on $\hat { z } _ { 0 }$ , and linearly translate the guided change back to the noisy image space at step $t$ Concretely, instead of directly calculating $\nabla _ { z _ { t } } \ell ( \dot { c } , f ( \hat { z } _ { 0 } ) )$ , we compute a guided change $\Delta z _ { 0 }$ in clean data space as
137
+
138
+ $$
139
+ \Delta z _ { 0 } = \arg \operatorname* { m i n } _ { \Delta } \ell ( c , f ( \hat { z } _ { 0 } + \Delta ) ) .
140
+ $$
141
+
142
+ Empirically, we solve Eq. (8) with $m$ -step gradient descent, where we use $\Delta = 0$ as a starting point. Since $\hat { z } _ { 0 } + \Delta z _ { 0 }$ minimizes $\ell ( c , f ( \bar { z } ) )$ directly, $\Delta z _ { 0 }$ is the change in clean data space that best enforces the constraint. Then, we translate $\Delta z _ { 0 }$ back to the noisy data space of $z _ { t }$ by calculating the guided denoising prediction ϵ˜ that satisfies
143
+
144
+ $$
145
+ z _ { t } = \sqrt { \alpha _ { t } } ( \hat { z } _ { 0 } + \Delta z _ { 0 } ) + \sqrt { 1 - \alpha _ { t } } \tilde { \epsilon } .
146
+ $$
147
+
148
+ Reusing Eq. (3), we can rewrite ϵ˜ as an augmentation to the original denoising prediction $\epsilon _ { \theta } ( z _ { t } , t )$ by
149
+
150
+ $$
151
+ \tilde { \epsilon } = \epsilon _ { \theta } ( z _ { t } , t ) - \sqrt { \alpha _ { t } / ( 1 - \alpha _ { t } ) } \Delta z _ { 0 } .
152
+ $$
153
+
154
+ Comparing to forward guidance, backward guidance (as Eq. (10)) produces an optimized direction for the generated image to match the given prompt, and hence prioritizes enforcing the constraint. Furthermore, calculation of a gradient step for Eq. (8) is computationally cheaper than forward guidance (Eq. (7)), and we can therefore afford to solve Eq. (8) with multiple gradient steps, further improving the match with the given prompt.
155
+
156
+ We note that the names “forward” and “backward” are used analogously to the forward and backward Euler methods.
157
+
158
+ # 3.3 UNIVERSAL STEPWISE REFINEMENT
159
+
160
+ Upon applying our universal guidance to standard generation pipelines, we observe that in some instances, the images generated exhibit artifacts or unusual behaviors that differentiate them from natural images. Similar findings have been reported in (Lugmayr et al., 2022; Wang et al., 2022b), where linear guidance functions were explored. Although we attempted to enhance the realism by adjusting the guidance strength $s ( t )$ , finding an optimal balance that
161
+
162
+ ![](images/2a92c679abd282ca8aa8cc1e6674127de3604a8361b95af6462df57508e0219b.jpg)
163
+ Figure 2: An example of how the Universal Stepwise Refinement (USR) helps segmentation-guided generation. The left-most figure is the given segmentation map, and the images generated with USR steps 1, 4 and 10 follow in order. Notice the increase of quality with USR steps.
164
+
165
+ both guarantees image realism and adherence to guidance constraints proved challenging, particularly with complex guidance functions. We hypothesize that the direction of guidance offered by our universal method might not always correlate with image realism, diverting the image from a natural image sampling trajectory.
166
+
167
+ Drawing motivation from Lugmayr et al. (2022); Wang et al. (2022b), we propose a more nuanced approach, termed Universal Stepwise Refinement (USR), to navigate these challenges. Specifically, after sampling $\boldsymbol { z } _ { t - 1 } = \boldsymbol { S } ( \boldsymbol { z } _ { t } , \hat { \epsilon } _ { t } , t )$ , we reintroduce Gaussian noise $\epsilon ^ { \prime } \sim \mathcal { N } ( 0 , \bf { I } )$ to $z _ { t - 1 }$ , deriving $z _ { t } ^ { \prime }$ as per the equation:
168
+
169
+ $$
170
+ z _ { t } ^ { \prime } = \sqrt { \alpha _ { t } / \alpha _ { t - 1 } } \cdot z _ { t - 1 } + \sqrt { 1 - \alpha _ { t } / \alpha _ { t - 1 } } \cdot \epsilon ^ { \prime } .
171
+ $$
172
+
173
+ Equation 11 ensures $z _ { t } ^ { \prime }$ retains the appropriate noise scale for input at time step $t$ . Given a refinement step $k$ , we repeat the Universal Stepwise Refinement $k$ times before advancing with the sampling for step $t - 1$ . This refined process enables the exploration of various regions of the data manifold at a consistent noise scale to reach a solution that aligns with both the guidance and image quality requisites. Our empirical assessments indicate that using USR mechanism on top of proper guidance strength $s ( t )$ significantly enhanced the image realism while still maintaining the adherence to the prompt, as shown in Fig. 2.
174
+
175
+ We summarize our universal guidance algorithm composed of forward universal guidance, backward universal guidance and universal stepwise refinement for a single sampling step in Algorithm 1. For simplicity, the algorithm assumes only one guidance function, but can be easily adapted to handle multiple pairs of $( f , l )$ . Additionally, the objectives of the forward and backward guidance do not have to be identical, allowing different ways to simultaneously utilize multiple guidance functions.
176
+
177
+ # 4 EXPERIMENTS
178
+
179
+ In this section, we present results testing our proposed universal guidance algorithm against a wide variety of guidance functions. Specifically, we experiment with Stable Diffusion (Rombach et al., 2022), a diffusion model that is able to perform text-conditional generation by accepting text prompt as additional input, and experiment with a purely unconditional diffusion model trained on ImageNet (Deng et al., 2009), where we use pre-trained model provided by OpenAI (Dhariwal & Nichol, 2021). We note that Stable Diffusion, while being a text-conditional generative model, can also perform unconditional image generation by simply using an empty string as the text prompt. We first present the experiment on Stable Diffusion for different guidance functions in Sec. 4.1, and present the results on ImageNet diffusion model in Sec. 4.2. Hyper-parameters used for different guidance functions, further ablation studies and selection procedures for suitable guidance strength $s ( t )$ and refinement step $k$ can be found in the appendix.
180
+
181
+ # 4.1 RESULTS FOR STABLE DIFFUSION
182
+
183
+ In this section, we present the results of guided image generation using Stable Diffusion as the foundation model. The guidance functions we experiment with include a segmentation network, a face recognition network, an object detection network and style guidance with CLIP feature extractor (Radford et al., 2021). For experiments on Stable Diffusion, we discover that applying forward guidance already produce high-quality images that match the given prompt, and hence set $m = 0$ . To perform forward guidance on Stable Diffusion, we forward the predicted clean latent variable computed by Eq. (3) through the image decoder of Stable Diffusion to obtain predicted clean images. We discuss the qualitative results and implementation details for each guidance function in its corresponding subsection. We summarize our quantitative evaluation in Tab. 1, where we evaluate how well the generated images match the external guidance with task-specific metrics, and include the similarity of CLIP embedding between text prompts and images generated with and without guidance. For all tasks, the minimum difference between CLIP similarities indicates that our algorithm performs guidance without sacrificing the effectiveness of the underlying diffusion model. We also include additional quantitative and qualitative results for text-guided generation in the appendix.
184
+
185
+ ![](images/575e2bcf78e27300302fb165597259606d1e7d49a5e3edda0be61978b300db20.jpg)
186
+ Figure 3: In addition to matching the text prompts (above each column), these images are guided by an image segmentation pipeline. Each column contains examples of images generated to match the prompt and the segmentation map in the left-most column. The top-most row contains examples generated without guidance.
187
+
188
+ ![](images/58693702722a538861bf09a0f460adcb40b3118130c2feff57090ac3afce6c70.jpg)
189
+ Figure 4: Each column contains examples of images generated to match the prompt and the identity of the images in the left-most column. The top-most row contains examples generated without guidance.
190
+
191
+ Segmentation Map Guidance. To guide image generation using a segmentation map as prompt, we use a MobileNetV3-Large (Howard et al., 2019) with a segmentation head, and a publicly available pre-trained model in PyTorch (Paszke et al., 2019). We use standard perpixel cross-entropy loss between a given prompt and the predicted segmentation of generated images as our loss function $\ell$ .
192
+
193
+ In our experiment, we combine segmentation maps that depict objects of different shapes with
194
+
195
+ Table 1: Quantitative analysis of different guidance applied on Stable Diffusion. The reference value in parenthesis is obtained with no external guidance.
196
+
197
+ <table><tr><td>Task</td><td>Metric</td><td>Value</td></tr><tr><td>Segmentation</td><td>CLIPsimiaity</td><td>0.24700.249</td></tr><tr><td>Face</td><td>CLe similariy</td><td>(0.28760.234</td></tr><tr><td>Object detection</td><td>cLmAPmi1aity</td><td>0.263)0.246</td></tr></table>
198
+
199
+ new text prompts. We use the text prompt as a fixed additional input to Stable Diffusion to perform text-conditional sampling, and guide the text-conditional generated images to match the given segmentation maps. Qualitative results are presented in Fig. 3. From Fig. 3, we see that the generated images show a clear separation between object and background that matches the given segmentation map nearly perfectly. The generated object and background also each match their descriptive text (i.e. dog breed and environment description). Furthermore, the generated images are overall highly realistic. In Tab. 1, we evaluate mIoU between the ground truth segmentation map and the predicted segmentation of generated images to assess the match with constraint.
200
+
201
+ Face Recognition Guidance. For guiding generation to include a specific person’s likeness, we propose combining face detection and facial recognition modules into one guidance function. This setup produces a facial attribute embedding from an image of a face. We use multi-task cascaded convolutional networks (MTCNN) (Zhang et al., 2016) for face detection, and we use facenet (Schroff et al., 2015) for facial recognition. The guidance function $f$ then crops out the detected face and outputs a facial attribute embedding as a prompt and we use an $l _ { 1 }$ -loss between embeddings as the loss function $\ell$ .
202
+
203
+ ![](images/8c2900b3ac5ee0176c519a72b4f2cb8bc9db301e88120c477bd0c7e58e45693a.jpg)
204
+ Figure 5: In addition to text prompts (above each column), these images are guided by an object detector. Each column contains examples of images generated to match the prompt and the bounding boxes used for guidance.
205
+ Figure 6: In addition to text prompts, these images are guided by a style image. Each column contains examples of images generated to match the text prompt and the style used for guidance.
206
+
207
+ We explore different combinations of face guidance and text prompts. Similarly to the segmentation case, we use the text prompt as a fixed additional conditioning to Stable Diffusion and guide this text-conditional trajectory with our algorithm so that the face in the generated image looks similar to the face prompt. In Fig. 4, we clearly see that the facial characteristics of a given face prompt are reproduced almost perfectly on the generated images. The descriptive text of either background, material, or style is also realized correctly and blends nicely with the generated faces. We again summarize our quantitative evaluation in Tab. 1. We evaluate the similarity between facial attributes of ground-truth identity and the generated faces. In general, two faces are considered to be from the same person if the similarity is over 0.5, and our algorithm can effectively guide the generated face to meet the criteria.
208
+
209
+ Object Location Guidance For Stable Diffusion, we also present the results of guided image generation with an object detection network. For this experiment, we use Faster-RCNN (Ren et al., 2015) with Resnet-50-FPN backbone (Li et al., 2021), a publicly available pre-trained model in Pytorch, as our object detector. We use bounding boxes with class labels as our object location prompt. We construct a loss function $\ell$ by the sum of three individual losses, namely (1) anchor classification loss, (2) bounding box regression loss and (3) region label classification loss.
210
+
211
+ We again experiment with different combinations of text prompt and object location prompt, and similarly use the text prompt as a fixed conditioning to Stable Diffusion. Using our proposed guidance algorithm, we perform guided image generation that generates and matches the objects presented in the text prompt to the given object locations. The results are presented in Fig. 5. We observe from Fig. 5 that objects in the descriptive text all appear in the designated location with the appropriate size indicated by the given bounding boxes. Each location is filled with appropriate, high-quality generations that align with varied image content prompts, ranging from “beach” to “oil painting”. In Tab. 1, we use mAP $\textcircled { a } 5 0$ to measure how well the generated images satisfy the constraint.
212
+
213
+ Style Guidance Finally, we conclude our experiments on Stable Diffusion by guiding the image generation based on a reference style given by a style image. To achieve so, we capture the reference style from the style image by the image feature extractor from CLIP, and use the resulting image embedding as prompts. The loss function calculates the negative cosine similarity between the embedding of generated images and the embedding of the style image. Similar to previous experiments, we control the content using text input as additional conditioning to the Stable Diffusion model. We experiment with combinations of different style images and different text prompts, and present the results in Fig. 6. From Fig. 6, we can see that the generated images contain contents that match the given text prompts, while exhibiting style that matches the given style images.
214
+
215
+ ![](images/a8f25b94ed6d9313a40e037afaad24a356a92ecad35e2ad2b44e19fe5491c152.jpg)
216
+ Figure 7: Generation guided by object detection with the unconditional ImageNet model. While both forward and backward guidance produces realistic images with the desired objects in the designated locations, forward guidance alone produces the wrong objects or the wrong locations/sizes.
217
+ Figure 8: Our guidance algorithm can incorporate feedback from multiple guidance functions. Left to right: The inpainting prompt; The classifierguided inpainting output; Images generated with both classifier and segmentation guidance, where realistic dogs are generated exactly on the mask.
218
+
219
+ # 4.2 RESULTS FOR IMAGENET DIFFUSION
220
+
221
+ In this section, we present results for guided image generation using an unconditional diffusion model trained on ImageNet. We experiment with object location guidance and a hybrid guided image generation task which we term segmentation-guided inpainting. We also include additional experiments for CLIP guidance in the appendix. We will discuss results of each guidance separately.
222
+
223
+ Object Location Guidance. Similar to object location guidance for Stable Diffusion, we also use the same network architecture and the same pre-trained model as our object detection network, and construct an identical loss function $\ell$ for our guidance algorithm. However, unlike Stable Diffusion, object locations are the only prompts available for guided image generation. We experiment with different object location prompts using either (1) only forward universal
224
+
225
+ Table 2: Quantitative analysis of forward guidance only versus combination of forward and backward guidance for object detection guidance on ImageNet with bounding boxes in Fig. 7. The metric is mAP $\textcircled { a } 5 0$ .
226
+
227
+ <table><tr><td>Object Location</td><td>Fwd. Only</td><td>Fwd. + Bkd.</td></tr><tr><td>Bounding box 1</td><td>0.39</td><td>0.90</td></tr><tr><td>Bounding box 2</td><td>0.18</td><td>0.36</td></tr></table>
228
+
229
+ guidance and (2) both forward and backward universal guidance. We observe from Fig. 7 that applying both forward and backward guidance generates images that are realistic and the objects match the prompt nicely. On the other hand, while images generated using only forward guidance remain realistic, they feature objects with mismatching categories and locations. The observation is further backed by quantitative evaluation presented in Tab. 2. The evaluation is based on $\operatorname* { m A P @ 5 0 }$ between the ground truth object locations and the predicted bounding boxes of generated images, and clearly shows that the combination of forward and backward guidance leads to a much better match with the constraint. The results demonstrate the effectiveness of our universal guidance algorithm, and also validate the necessity of our backward guidance.
230
+
231
+ Segmentation-Guided Inpainting. In this experiment, we aim to explore the ability of our algorithm to handle multiple guidance functions. We perform guided image generation with combined guidance from an inpainting mask, a classifier and a segmentation network. We first generate images with masked regions as the prompt for inpainting. We then pick an object class $c$ as the prompt for classification and generate a segmentation mask where the masked regions are considered foreground objects of the same class $c$ . We use $\ell _ { 2 }$ loss on the non-masked region as the loss function for inpainting, and set the corresponding $s ( t ) = 0$ , or equivalently only use backward guidance for inpainting. We use the same segmentation network as described in Sec. 4.1. For classification guidance, we use the classifier that accepts noisy input (Dhariwal & Nichol, 2021), and perform the original classifier guidance as Eq. (4) instead of our forward guidance. The results in Fig. 8 show that when using both inpainting and classifier as guidance, our algorithm generates realistic images that both match the inpainting prompt and are classified correctly to the given object class. Adding in segmentation guidance, our algorithm further improves by making a near-perfect match to both the segmentation map and the inpainting prompt while maintaining realism, demonstrating that our algorithm effectively combines feedback from multiple guidance functions.
232
+
233
+ # 5 CONCLUSION
234
+
235
+ We propose a universal guidance algorithm that is able to perform guided image generation with any off-the-shelf guidance function based on a fixed foundation diffusion model. Our algorithm only needs guidance and loss functions to be differentiable, and avoids any retraining to adapt the guidance function or the foundation model to a specific type of prompt. We demonstrate promising results with our algorithm on complex guidance including segmentation, face recognition and object detection systems – and multiple guidance functions can even be used together.
236
+
237
+ # 6 ACKNOWLEDGEMENTS
238
+
239
+ This work was made possible by the ONR MURI program and the AFOSR MURI program. Commercial support was provided by Capital One Bank, the Amazon Research Award program, and Open Philanthropy. Further support was provided by the National Science Foundation (IIS-2212182), and by the NSF TRAILS Institute (2229885).
240
+
241
+ # REPRODUCIBILITY STATEMENT
242
+
243
+ we describe guidance functions and foundation diffusion models for experiments presented in Sec. 4 in the corresponding subsections. Hyperparameters for experiments described in Sec. 4 of the main paper can be found in Sec. B in the appendix. We also include the source code used to conduct the experiments described in the paper in our supplementary material.
244
+
245
+ # REFERENCES
246
+
247
+ Jacob Austin, Daniel D Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces. Advances in Neural Information Processing Systems, 34:17981– 17993, 2021.
248
+ Arpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie S Li, Hamid Kazemi, Furong Huang, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Cold diffusion: Inverting arbitrary image transforms without noise. arXiv preprint arXiv:2208.09392, 2022.
249
+ Hyungjin Chung, Jeongsol Kim, Michael T Mccann, Marc L Klasky, and Jong Chul Ye. Diffusion posterior sampling for general noisy inverse problems. arXiv preprint arXiv:2209.14687, 2022a.
250
+ Hyungjin Chung, Byeongsu Sim, Dohoon Ryu, and Jong Chul Ye. Improving diffusion models for inverse problems using manifold constraints. arXiv preprint arXiv:2206.00941, 2022b.
251
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
252
+ Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat gans on image synthesis. volume 34, 2021.
253
+ Alexandros Graikos, Nikolay Malkin, Nebojsa Jojic, and Dimitris Samaras. Diffusion models as plug-and-play priors. arXiv preprint arXiv:2206.09012, 2022.
254
+ Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022.
255
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 32, 2020.
256
+ Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, et al. Searching for mobilenetv3. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 1314–1324, 2019.
257
+ Rongjie Huang, Max WY Lam, Jun Wang, Dan Su, Dong Yu, Yi Ren, and Zhou Zhao. Fastdiff: A fast conditional diffusion model for high-quality speech synthesis. arXiv preprint arXiv:2204.09934, 2022.
258
+ Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. arXiv preprint arXiv:2201.11793, 2022.
259
+ Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. Diffwave: A versatile diffusion model for audio synthesis. arXiv preprint arXiv:2009.09761, 2020.
260
+ Xiang Lisa Li, John Thickstun, Ishaan Gulrajani, Percy Liang, and Tatsunori B Hashimoto. Diffusion-lm improves controllable text generation. arXiv preprint arXiv:2205.14217, 2022.
261
+ Yanghao Li, Saining Xie, Xinlei Chen, Piotr Dollar, Kaiming He, and Ross Girshick. Benchmarking detection transfer learning with vision transformers. arXiv preprint arXiv:2111.11429, 2021.
262
+ 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, 2023.
263
+ Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. Repaint: Inpainting using denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11461–11471, 2022.
264
+ Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
265
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019.
266
+ 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.
267
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015.
268
+ Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High-resolution image ¨ synthesis with latent diffusion models. In Proceedings of CVPR, 2022.
269
+ 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.
270
+ Florian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 815–823, 2015.
271
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. International Conference on Learning Representations, 2021a.
272
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
273
+ Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. International Conference on Learning Representations, 2021b.
274
+ Weilun Wang, Jianmin Bao, Wengang Zhou, Dongdong Chen, Dong Chen, Lu Yuan, and Houqiang Li. Semantic image synthesis via diffusion models. arXiv preprint arXiv:2207.00050, 2022a.
275
+ Yinhuai Wang, Jiwen Yu, and Jian Zhang. Zero-shot image restoration using denoising diffusion null-space model. arXiv preprint arXiv:2212.00490, 2022b.
276
+ Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16293–16303, 2022.
277
+ Kaipeng Zhang, Zhanpeng Zhang, Zhifeng Li, and Yu Qiao. Joint face detection and alignment using multitask cascaded convolutional networks. IEEE signal processing letters, 23(10):1499–1503, 2016.
278
+ Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023.
279
+
280
+ # A LIMITATIONS
281
+
282
+ Generation using universal guidance is typically slower than standard conditional generation for several reasons. Empirically, more than one iteration of denoising is required for the given noise level $t$ to generate high-quality images with complex guidance functions. However, the time complexity of our algorithm scales linearly with the number of refinement steps $k$ , which slows down image generation when $k$ is large. That being said, for the applications presented in this paper, we were successful in generating images with smaller values of $k$ . Also, as demonstrated in the main paper, backward guidance is required in certain scenarios to help generate images that match the given constraint. Computing backward guidance requires performing minimization with a multi-step gradient descent inner loop. While proper choices of gradient-based optimization algorithms and learning rate schedules significantly speed up the convergence of minimization, the time it takes to compute backward guidance inevitably becomes longer when the guidance function is itself a very-large neural network. Finally, we note that, to get optimal results, sampling hyper-parameters must be chosen individually for each guidance network.
283
+
284
+ # B HYPER-PARAMETERS
285
+
286
+ In this section, we present the hyper-parameters for the different guidance functions i.e. face, segmentation, object location, and style guidance. We present the hyperparameters for experiments on Stable Diffusion in Sec. 4.1 in the Tab. 3, where we include coefficient √ $s _ { 0 }$ to compute $s _ { t } =$ $s _ { 0 } \sqrt { 1 - \alpha _ { t } }$ and the number of Universal Stepwise Refinement $( k )$ . We also provide hyperparameters for experiments on ImageNet in Sec. 4.2 in Tab. 4
287
+
288
+ Table 3: Hyper-parameters used in this paper for different guidance functions to reproduce the results for Stable Diffusion.
289
+
290
+ <table><tr><td>Guidance</td><td>S0</td><td>k</td></tr><tr><td>Face</td><td>20000</td><td>2</td></tr><tr><td>Object Location</td><td>100</td><td>3</td></tr><tr><td>Style Transfer</td><td>6</td><td>6</td></tr><tr><td>Segmentation</td><td>400</td><td>10</td></tr></table>
291
+
292
+ Table 4: Hyper-parameters used in this paper for different guidance functions to reproduce the results for ImageNet.
293
+
294
+ <table><tr><td>Guidance</td><td>S0</td><td>k</td></tr><tr><td>Object Location</td><td>100</td><td>3</td></tr><tr><td>Segmentation</td><td>200</td><td>10</td></tr></table>
295
+
296
+ # C CLIP GUIDANCE FOR STABLE DIFFUSION
297
+
298
+ CLIP (Radford et al., 2021) is a state-of-the-art text-to-image similarity model developed by OpenAI. We use the image feature extractor of CLIP to do text-guided image generation with our algorithm. We construct a loss function that calculates the negative cosine similarity between an image embedding√ and the CLIP text embedding produced by a given text prompt. We use $s ( t ) = 1 0 \sqrt { 1 - \alpha _ { t } }$ and $k = 8$ and use Stable Diffusion as an unconditional image generator.
299
+
300
+ We generate images guided by a number of text prompts. To further assess our universal guidance algorithm and compare guidance and conditioning, we also generate images using classical, textconditional generation by Stable Diffusion with identical prompts as inputs, and summarize the results in Fig. 9. The results in Fig. 9 show that our algorithm can guide the generation to produce high-quality images that match the given text description, and are comparable with images generated by the specialized text-conditioning model. We also include qualitative results from experiments on DrawBench (Saharia et al., 2022). DrawBench is a widely-used and diverse list of text prompts. We randomly select 20 prompts and generate 10 images for each individual prompt. We compute CLIP
301
+
302
+ A photograph of an astronaut riding a horse.
303
+
304
+ ![](images/3c3c821d7967493fd9f7481f2b698afcfe143ba4a813ecca36e64330e8b50d86.jpg)
305
+ Figure 9: We compare the ability to match given text prompts between our universal guidance algorithm and text-conditional model trained from scratch. The results demonstrate that our universal algorithm is comparable to specialized conditional model on the ability to generate quality images that satisfy the text constraints.
306
+
307
+ score, the cosine similarity between CLIP feature of the text prompt and the associated generated image, on both Stable Diffusion and our algorithm, and report the average in Tab. 5. As demonstrated in the table, the performance of our algorithm is quantitatively similar to a dedicated text-conditional generator, while requiring no additional training at all for the underlying unconditional diffusion model.
308
+
309
+ Table 5: Quantitative results on DrawBench for Stable Diffusion and our algorithm.
310
+
311
+ <table><tr><td></td><td>Stable Diffusion</td><td>Universal Guidance</td></tr><tr><td>CLIP Score</td><td>0.2818</td><td>0.2632</td></tr></table>
312
+
313
+ D CLIP GUIDANCE FOR IMAGENET DIFFUSION MODEL
314
+
315
+ English foxhound by Edward Hopper
316
+
317
+ Van Gogh Style
318
+
319
+ Cake
320
+
321
+ ![](images/6d2f2fb8de6cb38b22b60e29daeae29109d92b1286b739593070bf12ac9c116f.jpg)
322
+ Figure 10: We show that unconditional diffusion models trained on ImageNet can be guided with CLIP to generate high-quality images that match the text prompts, even if these generated images should be out of distribution.
323
+
324
+ CLIP Guidance. We use the same construction of $f$ and $\ell$ for Stable Diffusion to perform CLIPguided generation. We use only forward guidance for this experiment. To assess the limit of our universal guidance algorithm, we hand-crafted text prompts such that the matching images are expected to be out of distribution. In particular, our text prompts either designate art styles that are far from realistic or designate objects that do not belong to any possible class label of ImageNet. We present the results in Fig. 10, and from the results, we clearly see that our algorithm still successfully guides the generation to produce quality images that also match the text prompts. For all three images,√ we have $s ( \overline { { t } } ) = w \cdot \sqrt { 1 - \alpha _ { t } }$ , where $w$ is 2, 5 and 2 respectively and $k$ is 10, 5 and 10 respectively.
325
+
326
+ ![](images/aa7ce0ac9f549141c1669197bce6dc17c09d4bc29ac177aaa813d5783ecc130c.jpg)
327
+ Figure 11: The qualitative results for effect of different guidance strength $s ( t )$ and universal refinement√ step $k$ on segmentation guidance for Stable Diffusion. Here we use $s \bar { ( } t ) = \dot { c } \cdot \sqrt { 1 - \alpha _ { t } }$ , and compare different $c$ instead.
328
+
329
+ # E ABLATION STUDY AND PROCEDURE TO PICK HYPERPARAMETERS
330
+
331
+ In this section we present our ablation study on the effect of different parameters, namely guidance strength $s ( t )$ and refinement step $k$ , for our algorithm. We summarize the qualitative results in Fig. 11 on segmentation guidance for Stable Diffusion. From the figure, we observe that increasing $c$ alone leads to better matching between the segmentation map and the position of the generated dogs, but the quality of images also degrades, especially when $c$ is large $c > = 2 0 0 ^ { \cdot }$ ). On the other hand, increasing $k$ noticeably improves the quality of images. For example, comparing the best image from $( k , c ) = \bar { ( 4 , 8 0 0 ) }$ and $\bar { ( k , c ) } = ( 1 0 , 8 0 \bar { 0 } )$ , the latter clearly exhibits significantly better realness. We also quantitatively evaluate the effectiveness of the two parameters, and present the results in Tab. 6. We calculate the mIOU between the ground truth segmentation map and the segmentation map of generated images predicted by the given segmentation network, which assesses the match between generation and the given constraint. We also show cosine similarity between the clip attribute vectors of the generated images and the given text phrase. High cosine similarity indicates that generation guided with segmentation does not stray away from the text-conditional generation of the underlying diffusion model. In Tab. 6, we observe that when the step $m$ is fixed, increasing the guidance strength $c$ leads to a better match with external guidance. On the other hand, the clip similarity score is stable for $c$ in range of (10, 200) before showing a sudden drop when $c > = 4 0 0$ , indicating that it is more difficult for the underlying diffusion model to control the guided generation to match the text when $c$ is large. As for universal refinement step $k$ , increasing $k$ generally improves both mIOU and clip similarity.
332
+
333
+ <table><tr><td>Metric</td><td>Refinement step</td><td>c=10</td><td>c=20</td><td>c=50</td><td>c=100</td><td>c =200</td><td>c =400</td><td>c =800</td></tr><tr><td rowspan="3">mIoU</td><td>k=2</td><td>0.52</td><td>0.52</td><td>0.67</td><td>0.79</td><td>0.87</td><td>0.89</td><td>0.89</td></tr><tr><td>k=4</td><td>0.50</td><td>0.59</td><td>0.71</td><td>0.80</td><td>0.87</td><td>0.89</td><td>0.88</td></tr><tr><td>k=10</td><td>0.57</td><td>0.62</td><td>0.76</td><td>0.80</td><td>0.89</td><td>0.90</td><td>0.92</td></tr><tr><td rowspan="3">CLIP sim.</td><td>k=2</td><td>0.26</td><td>0.26</td><td>0.25</td><td>0.24</td><td>0.24</td><td>0.20</td><td>0.16</td></tr><tr><td>k=4</td><td>0.26</td><td>0.27</td><td>0.26</td><td>0.25</td><td>0.25</td><td>0.21</td><td>0.14</td></tr><tr><td>k=10</td><td>0.24</td><td>0.25</td><td>0.26</td><td>0.26</td><td>0.25</td><td>0.22</td><td>0.18</td></tr></table>
334
+
335
+ Table 6: Quantitative evaluation for different combination of parameters of segmentation guidance on Stable Diffusion.
336
+
337
+ We also want to remark that the ablation study formalizes a principled way to pick suitable $k$ and $s ( t )$ for different guidance functions. In particular, increasing $k$ is always beneficial to the generation quality, and the value of $k$ is limited only by the computational budget. Given a fixed $k$ , there is generally a sweet spot for $s ( t )$ that ensures both a match to the target and sufficient quality, and this sweet spot can be found with standard parameter search, as described above.
338
+
339
+ ![](images/a3438ccddb2dca002582dd6f1126e38d68177453f411ced588ca38a0fda1d369.jpg)
340
+ (c) Walker hound, Walker foxhound as an oil painting.
341
+ Figure 12: More images to show Segmentation guidance. In each subfigure, the first image is the segmentation map used to guide the image generation with its caption as its text prompt.
342
+
343
+ ![](images/5df8d9692d2299e1e391bce13b6aaa10182e5aea34c120bd13cf33b1ba3e848e.jpg)
344
+
345
+ ![](images/8b606ebc2f55856f888dbd6651558aaaa014553bd9d07e323f21e3247b0a36e1.jpg)
346
+ (a) Headshot of a person with blonde hair with space background.
347
+ (c) A headshot of a blonde woman as a sketch.
348
+ Figure 13: More images to show Face guidance. In each subfigure, the first image is the human identity used to guide the image generation with its caption as its text prompt.
349
+
350
+ (b) A headshot of a woman looking like a lara croft.
351
+
352
+ ![](images/2444dcc7b7364732a1561002e5e203b224aaafa86c84d663e626d6585084a2e8.jpg)
353
+ (c) An oil painting of a headshot of a woman with a dog.
354
+ Figure 14: More images to show Object Location guidance. In each subfigure, the first image is the object location used to guide the image generation with its caption as its text prompt.
355
+
356
+ ![](images/2d92d60d352460377934f4e487811b0b45028118b6438cf64ca09027fa0fda02.jpg)
357
+ (a) A colorful photo of an Eiffel Tower.
358
+
359
+ ![](images/8c23bddc7e1f7274f527607fad7aaf45881dcc60f85031f2b7d905aa208b009a.jpg)
360
+ (c) A fantasy photo of volcanoes.
361
+ Figure 15: More images to show Style Transfer. In each subfigure, the first image is the styling image used to guide the image generation with its caption as its text prompt.
parse/test/pzpWBbnwiJ/pzpWBbnwiJ_content_list.json ADDED
@@ -0,0 +1,841 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "UNIVERSAL GUIDANCE FOR DIFFUSION MODELS ",
5
+ "text_level": 1,
6
+ "page_idx": 0
7
+ },
8
+ {
9
+ "type": "text",
10
+ "text": "Arpit Bansal\\* University of Maryland bansal01@umd.edu ",
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "Hong-Min Chu\\* University of Maryland ",
16
+ "page_idx": 0
17
+ },
18
+ {
19
+ "type": "text",
20
+ "text": "Avi Schwarzschild University of Maryland ",
21
+ "page_idx": 0
22
+ },
23
+ {
24
+ "type": "text",
25
+ "text": "Soumyadip Sengupta University of North Carolina ",
26
+ "page_idx": 0
27
+ },
28
+ {
29
+ "type": "text",
30
+ "text": "Micah Goldblum New York University ",
31
+ "page_idx": 0
32
+ },
33
+ {
34
+ "type": "text",
35
+ "text": "Jonas Geiping University of Maryland ",
36
+ "page_idx": 0
37
+ },
38
+ {
39
+ "type": "text",
40
+ "text": "Tom Goldstein University of Maryland ",
41
+ "page_idx": 0
42
+ },
43
+ {
44
+ "type": "text",
45
+ "text": "ABSTRACT ",
46
+ "text_level": 1,
47
+ "page_idx": 0
48
+ },
49
+ {
50
+ "type": "text",
51
+ "text": "Typical diffusion models are trained to accept a particular form of conditioning, most commonly text, and cannot be conditioned on other modalities without retraining. In this work, we propose a universal guidance algorithm that enables diffusion models to be controlled by arbitrary guidance modalities without the need to retrain any use-specific components. We show that our algorithm successfully generates quality images with guidance functions including segmentation, face recognition, object detection, and classifier signals. Code is available at github.com/arpitbansal297/Universal-Guided-Diffusion. ",
52
+ "page_idx": 0
53
+ },
54
+ {
55
+ "type": "image",
56
+ "img_path": "images/3f7a4433d41d370a31de7b104f18207cd63152f2139a3f7c0a357bebd19f13f1.jpg",
57
+ "image_caption": [
58
+ "Figure 1: Diffusion guided by off-the-shelf networks. Top left: segmentation guidance, top-right: face recognition guidance, bottom-left: object detection guidance, bottom-right: style-transfer. "
59
+ ],
60
+ "image_footnote": [],
61
+ "page_idx": 0
62
+ },
63
+ {
64
+ "type": "text",
65
+ "text": "1 INTRODUCTION ",
66
+ "text_level": 1,
67
+ "page_idx": 1
68
+ },
69
+ {
70
+ "type": "text",
71
+ "text": "Diffusion models are powerful tools for creating digital art and graphics. Much of their success stems from our ability to carefully control their outputs, customizing results for each user’s individual needs. Most models today are controlled through conditioning. With conditioning, the diffusion model is built from the ground up to accept a particular modality of input from the user, be it descriptive text, segmentation maps, class labels, etc. While conditioning is a powerful tool, it results in models that are handcuffed to a single conditioning modality. If another modality is needed, a new model has to be trained, often from scratch. Unfortunately, the high cost of training makes this prohibitive for most users. ",
72
+ "page_idx": 1
73
+ },
74
+ {
75
+ "type": "text",
76
+ "text": "A more flexible approach to controlling model outputs is to use guidance. In this approach, the diffusion model acts as a generic image generator, and is not required to understand a user’s instructions. The user pairs this model with a guidance function that measures whether some criterion has been met. For example, one could guide the model to minimize the CLIP score between the generated image and a text description of the user’s choice. During each iteration of image creation, the iterates are nudged down the gradient of the guidance function, causing the final generated image to satisfy the user’s criterion. ",
77
+ "page_idx": 1
78
+ },
79
+ {
80
+ "type": "text",
81
+ "text": "In this paper, we study guidance methods that enable any off-the-shelf model or loss function to be used as guidance for diffusion. Because guidance functions can be used without re-training or modification, this form of guidance is universal in that it enables a diffusion model to be adapted for nearly any purpose. ",
82
+ "page_idx": 1
83
+ },
84
+ {
85
+ "type": "text",
86
+ "text": "From a user perspective, guidance is superior to conditioning, as a single diffusion network is treated like a foundational model that provides universal coverage across many use cases, both commonplace and bespoke. Unfortunately, it is widely believed that this approach is infeasible. While early diffusion models relied on classifier guidance (Dhariwal & Nichol, 2021), the community quickly turned to classifier-free schemes (Ho & Salimans, 2022) that require a model to be trained from scratch on class labels with a particular frozen ontology that cannot be changed (Nichol et al., 2021; Rombach et al., 2022; Bansal et al., 2022). ",
87
+ "page_idx": 1
88
+ },
89
+ {
90
+ "type": "text",
91
+ "text": "The difficulty of using guidance stems from the domain shift between the noisy images used by the diffusion sampling process and the clean images on which the guidance models are trained. When this gap is closed, guidance can be performed successfully. For example, Nichol et al. (2021) successfully use a CLIP model as guidance, but only after re-training CLIP from scratch using noisy inputs. Noisy retraining closes the domain gap, but at a very high financial and engineering cost. To avoid the additional cost, we study methods for closing this gap by changing the sampling scheme, rather than the model. ",
92
+ "page_idx": 1
93
+ },
94
+ {
95
+ "type": "text",
96
+ "text": "To this end, our contributions are summarized as follows: ",
97
+ "page_idx": 1
98
+ },
99
+ {
100
+ "type": "text",
101
+ "text": "• We propose an algorithm that enables universal guidance for diffusion models. Our proposed sampler evaluates the guidance models only on denoised images, rather than noisy latent states. By doing so, we close the domain gap that has plagued standard guidance methods. This strategy provides the end-user with the flexibility to work with a wide range of guidance modalities and even multiple modalities simultaneously. The underlying diffusion model remains fixed and no fine-tuning of any kind is necessary. \n• We demonstrate the effectiveness of our approach for a variety of different constraints such as classifier labels, human identities, segmentation maps, annotations from object detectors, and constraints arising from inverse linear problems. ",
102
+ "page_idx": 1
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "2 BACKGROUND ",
107
+ "text_level": 1,
108
+ "page_idx": 1
109
+ },
110
+ {
111
+ "type": "text",
112
+ "text": "We first briefly review the recent literature on the core framework behind diffusion models. Then, we define the problem setting of controlled image generation and discuss previous related works. ",
113
+ "page_idx": 1
114
+ },
115
+ {
116
+ "type": "text",
117
+ "text": "2.1 DIFFUSION MODELS ",
118
+ "text_level": 1,
119
+ "page_idx": 2
120
+ },
121
+ {
122
+ "type": "text",
123
+ "text": "Diffusion models are strong generative models that proved powerful even when first introduced for image generation (Song & Ermon, 2019; Ho et al., 2020). The approach has been successfully extended to a number of domains, such as audio and text generation (Kong et al., 2020; Huang et al., 2022; Austin et al., 2021; Li et al., 2022). ",
124
+ "page_idx": 2
125
+ },
126
+ {
127
+ "type": "text",
128
+ "text": "We introduce (unconditional) diffusion formally, as it is helpful in describing the nuances of different types of models. A diffusion model is defined as a combination of a $T$ -step forward process and a $T$ -step reverse process. Conceptually, the forward process gradually adds Gaussian noise of different magnitudes to a clean data point $z _ { \\mathrm { 0 } }$ , while the reverse process attempts to gradually denoise a noisy input in hopes of recovering a clean data point. More concretely, given an array of scalars representing noise scales $\\{ \\alpha _ { t } \\} _ { t = 1 } ^ { T }$ and an initial, clean data point $z _ { 0 }$ , applying $t$ steps of the forward process to $z _ { 0 }$ yields a noisy data point ",
129
+ "page_idx": 2
130
+ },
131
+ {
132
+ "type": "equation",
133
+ "img_path": "images/78c8f337e055d4e4bbd4110c9f4bbdb3f8f290b3daee6bc542254f11924a9e42.jpg",
134
+ "text": "$$\nz _ { t } = \\sqrt { \\alpha _ { t } } z _ { 0 } + ( \\sqrt { 1 - \\alpha _ { t } } ) \\epsilon , \\epsilon \\sim \\mathcal { N } ( 0 , \\mathbf { I } ) .\n$$",
135
+ "text_format": "latex",
136
+ "page_idx": 2
137
+ },
138
+ {
139
+ "type": "text",
140
+ "text": "A diffusion model is a learned denoising network $\\epsilon _ { \\theta }$ . It is trained so that for any pair $( z _ { 0 } , t )$ and any sample of $\\epsilon$ , ",
141
+ "page_idx": 2
142
+ },
143
+ {
144
+ "type": "equation",
145
+ "img_path": "images/49668070a87543fc6ec810ceda738d55a4958d23f0203587b6ccde84a88d524d.jpg",
146
+ "text": "$$\n\\epsilon _ { \\theta } ( z _ { t } , t ) \\approx \\epsilon = \\frac { z _ { t } - \\sqrt { \\alpha _ { t } } z _ { 0 } } { \\sqrt { 1 - \\alpha _ { t } } } .\n$$",
147
+ "text_format": "latex",
148
+ "page_idx": 2
149
+ },
150
+ {
151
+ "type": "text",
152
+ "text": "The reverse process takes the form $q \\big ( z _ { t - 1 } | z _ { t } , z _ { 0 } \\big )$ with various detail definitions, where $q ( \\cdot | \\cdot )$ is generally parameterized as a Gaussian distribution. Different works also studied different approximations of the unknown $q \\big ( z _ { t - 1 } | z _ { t } , z _ { 0 } \\big )$ used to perform sampling. For example, denoising diffusion implicit model (DDIM) (Song et al., 2021a) first computed a predicted clean data point ",
153
+ "page_idx": 2
154
+ },
155
+ {
156
+ "type": "equation",
157
+ "img_path": "images/84d1cc131237a3b7953eb8dd3d00c5c18f94215f7a6b18d15aa3d4c8dae65f84.jpg",
158
+ "text": "$$\n\\hat { z } _ { 0 } = \\frac { z _ { t } - ( \\sqrt { 1 - \\alpha _ { t } } ) \\epsilon _ { \\theta } ( z _ { t } , t ) } { \\sqrt { \\alpha _ { t } } } ,\n$$",
159
+ "text_format": "latex",
160
+ "page_idx": 2
161
+ },
162
+ {
163
+ "type": "text",
164
+ "text": "and sample $z _ { t - 1 }$ from $q \\big ( z _ { t - 1 } | z _ { t } , \\hat { z } _ { 0 } \\big )$ by replacing unknown $z _ { 0 }$ with $\\hat { z } _ { 0 }$ . On the other hand, while the details of individual sampling methods vary, all sampling methods produce $z _ { t - 1 }$ based on current sample $z _ { t }$ , current time step $t$ and a predicted noise $\\hat { \\epsilon }$ . To ease the notation burden, we define a function $S ( \\cdot , \\cdot , \\cdot )$ as an abstraction of the sampling method, where $\\boldsymbol { z } _ { t - 1 } = \\boldsymbol { S } ( \\boldsymbol { z } _ { t } , \\hat { \\epsilon } , t )$ . ",
165
+ "page_idx": 2
166
+ },
167
+ {
168
+ "type": "text",
169
+ "text": "2.2 CONTROLLED IMAGE GENERATION ",
170
+ "text_level": 1,
171
+ "page_idx": 2
172
+ },
173
+ {
174
+ "type": "text",
175
+ "text": "In this paper, we focus on controlled image generation with various constraints. Consider a differentiable guidance function $f$ , for example a CLIP feature extractor or a segmentation network. When applied to an image, we obtain a vector $c = f ( x )$ . We also consider a function $\\ell ( \\cdot , \\cdot )$ that measures the closeness of two vectors $c$ and $c ^ { \\prime }$ . Given a particular choice of $c$ , which we call a prompt, the corresponding constraint (based on $c , \\ell$ , and $f$ ) is formalized as $\\ell ( c , f ( z ) ) \\approx 0$ , and we aim to generate a sample $z$ from the image distribution satisfying the constraint. In plain words, we want to generate an in-distribution image that matches the prompt. ",
176
+ "page_idx": 2
177
+ },
178
+ {
179
+ "type": "text",
180
+ "text": "Prior work on controlled generative diffusion falls into two main categories. We refer to the first category as conditional image generation, and the second category as guided image generation. Next, we discuss the characteristics of each category and better situate our work among existing methods. ",
181
+ "page_idx": 2
182
+ },
183
+ {
184
+ "type": "text",
185
+ "text": "Conditional Image Generation. Methods from this category require training new diffusion models that accept the prompt as an additional input (Ho & Salimans, 2022; Bansal et al., 2022; Nichol et al., 2021; Whang et al., 2022; Wang et al., 2022a; Li et al., 2023; Zhang & Agrawala, 2023). For example, Ho & Salimans (2022) proposed classifier-free guidance using class labels as prompts, and trained a diffusion model by linear interpolation between unconditional and conditional outputs of the denoising networks. Bansal et al. (2022) studied the case where the guidance function is a known linear degradation operator, and trained a conditional model to solve linear inverse problems. Nichol et al. (2021) further extended classifier-free guidance to text-conditional image generation with descriptive phrases as prompts, and trained a diffusion model to enforce the similarity between the CLIP (Radford et al., 2021) representations of the generated images and the text prompts. These methods are successful across different types of constraints, however the requirement to retrain the diffusion model makes them computationally intensive. ",
186
+ "page_idx": 2
187
+ },
188
+ {
189
+ "type": "text",
190
+ "text": "Guided Image Generation. Works in this category employed a frozen pre-trained diffusion model as a foundation model, but modify the sampling method to guide the image generation with feedback from the guidance function. Our method falls into this category. Prior work that studied guided image generation did so with a variety of restrictions and external guidance functions (Dhariwal & Nichol, 2021; Kawar et al., 2022; Wang et al., 2022b; Chung et al., 2022a; Lugmayr et al., 2022; Chung et al., 2022b; Graikos et al., 2022). For example, Dhariwal & Nichol (2021) proposed classifier guidance, where they trained a classifier on images of different noise scales as the guidance function $f$ , and included gradients of the classifier during the sampling process. However, a classifier for noisy images is domain-specific and generally not readily available – an issue our method circumvents. Wang et al. (2022b) assumed the external guidance functions to be linear operators, and generated the component of images residing in the null space of linear operators with the foundation model. Unfortunately, extending that method to handle non-linear guidance functions is non-trivial. Chung et al. (2022a) studied general guidance functions, and modified the sampling process with the gradient of guidance function calculated on the expected denoised images. Nevertheless, the authors only presented results with simpler non-linear guidance functions such as non-linear blurring. ",
191
+ "page_idx": 3
192
+ },
193
+ {
194
+ "type": "text",
195
+ "text": "In this work, we study universal guidance algorithms for guided image generation with diffusion models using any off-the-shelf guidance functions $f$ , such as object detection or segmentation networks. ",
196
+ "page_idx": 3
197
+ },
198
+ {
199
+ "type": "text",
200
+ "text": "3 UNIVERSAL GUIDANCE ",
201
+ "text_level": 1,
202
+ "page_idx": 3
203
+ },
204
+ {
205
+ "type": "text",
206
+ "text": "We propose a guidance algorithm that augments the image sampling method of a diffusion model to include guidance from an off-the-shelf auxiliary network. Our algorithm is motivated by an empirical observation that the reconstructed clean image $\\hat { z } _ { 0 }$ obtained by Eq. (3), while naturally imperfect, is still appropriate for a generic guidance function to provide informative feedback to guide the image generation. In Sec. 3.1, we motivate our forward universal guidance by extending classifier guidance Dhariwal & Nichol (2021) to leverage this observation and handle generic guidance functions. In Sec. 3.2, we propose a supplementary backward universal guidance to help enforce the generated image to satisfy the constraint based on the guidance function $f$ . In Sec. 3.3, we discuss a simple yet helpful stepwise refinement trick to empirically improve the fidelity of generated images. ",
207
+ "page_idx": 3
208
+ },
209
+ {
210
+ "type": "text",
211
+ "text": "3.1 FORWARD UNIVERSAL GUIDANCE ",
212
+ "text_level": 1,
213
+ "page_idx": 3
214
+ },
215
+ {
216
+ "type": "text",
217
+ "text": "To guide the generation with information from the external guidance function $f$ and the loss function $\\ell$ , an immediate thought is to extend classifier guidance (Dhariwal $\\&$ Nichol, 2021) to accept any general guidance function. Concretely, given a class prompt $c$ , classifier guidance performs classification-guided sampling by replacing $\\epsilon _ { \\theta } ( z _ { t } , t )$ in each sampling step $S ( \\boldsymbol { z } _ { t } , t )$ with ",
218
+ "page_idx": 3
219
+ },
220
+ {
221
+ "type": "equation",
222
+ "img_path": "images/bf928022c34ec058d366dd6e5df5f1e93421d0e93f0feca0c42f71d281a36197.jpg",
223
+ "text": "$$\n\\begin{array} { r } { \\hat { \\epsilon } _ { \\theta } ( z _ { t } , t ) = \\epsilon _ { \\theta } ( z _ { t } , t ) - \\sqrt { 1 - \\alpha _ { t } } \\nabla _ { z _ { t } } \\log { p ( c | z _ { t } ) } . } \\end{array}\n$$",
224
+ "text_format": "latex",
225
+ "page_idx": 3
226
+ },
227
+ {
228
+ "type": "text",
229
+ "text": "Defining $\\ell _ { c e } ( \\cdot , \\cdot )$ to be the cross-entropy loss and $f _ { c l }$ to be the guidance function that outputs classification probability, Eq. (4) can be re-written as ",
230
+ "page_idx": 3
231
+ },
232
+ {
233
+ "type": "equation",
234
+ "img_path": "images/921ef0e7754a62ca3ce1555a6e06a4f0c4427fe96c1e556c2150c02ad0647ad9.jpg",
235
+ "text": "$$\n\\hat { \\epsilon } _ { \\theta } ( z _ { t } , t ) = \\epsilon _ { \\theta } ( z _ { t } , t ) + \\sqrt { 1 - \\alpha _ { t } } \\nabla _ { z _ { t } } \\ell _ { c e } ( c , f _ { c l } ( z _ { t } ) ) .\n$$",
236
+ "text_format": "latex",
237
+ "page_idx": 3
238
+ },
239
+ {
240
+ "type": "text",
241
+ "text": "However, directly replacing $f _ { c l }$ and $\\ell _ { c e }$ with any off-the-shelf guidance and loss functions does not work in practice, as $f$ is most likely trained on clean images and fails to provide meaningful guidance when the input is noisy. ",
242
+ "page_idx": 3
243
+ },
244
+ {
245
+ "type": "text",
246
+ "text": "To address the issue, we observe that ",
247
+ "page_idx": 3
248
+ },
249
+ {
250
+ "type": "equation",
251
+ "img_path": "images/189fe581896faadc3078c79cbc5fd9ca01ce0f9209907b382f504877c32150ab.jpg",
252
+ "text": "$$\np ( c | z _ { t } ) = \\int p ( c | z _ { 0 } , z _ { t } ) p ( z _ { 0 } | z _ { t } ) d z _ { 0 } = \\mathbb { E } _ { z _ { 0 } \\sim p ( z _ { 0 } | z _ { t } ) } [ p ( c | z _ { 0 } ) ] .\n$$",
253
+ "text_format": "latex",
254
+ "page_idx": 3
255
+ },
256
+ {
257
+ "type": "text",
258
+ "text": "where $c$ is conditionally-independent with $z _ { t }$ given $z _ { 0 }$ . Leveraging the fact that we can obtain a predicted clean image $\\hat { z } _ { 0 }$ by Eq. (3) with $\\epsilon _ { \\theta } ( z _ { t } , t )$ , we approximate the expectation in Eq. (6) as $\\mathbb { \\tilde { E } } _ { z _ { 0 } \\sim p ( z _ { 0 } | z _ { t } ) } [ p ( c | z _ { 0 } ) ] \\tilde { \\mathbf { \\Omega } } \\approx p ( c | \\hat { z } _ { 0 } )$ . This leads to our proposed guided sampling procedure ",
259
+ "page_idx": 3
260
+ },
261
+ {
262
+ "type": "equation",
263
+ "img_path": "images/ee393d0b4a1d18b77792db01869830bc10b80ee6594e067987917a354400a0d2.jpg",
264
+ "text": "$$\n\\hat { \\boldsymbol { \\epsilon } } _ { \\theta } ( z _ { t } , t ) = \\boldsymbol { \\epsilon } _ { \\theta } ( z _ { t } , t ) + \\boldsymbol { s } ( t ) \\cdot \\nabla _ { z _ { t } } \\ell ( \\boldsymbol { c } , f ( \\hat { \\boldsymbol { z } } _ { 0 } ) )\n$$",
265
+ "text_format": "latex",
266
+ "page_idx": 4
267
+ },
268
+ {
269
+ "type": "text",
270
+ "text": "where $s ( t )$ controls the guidance strength for each sampling step and ",
271
+ "page_idx": 4
272
+ },
273
+ {
274
+ "type": "equation",
275
+ "img_path": "images/59d221e8f7c5441a09f1a2955162ddcc339e528f1f0e74e6c086693feea1df97.jpg",
276
+ "text": "$$\n\\nabla _ { z _ { t } } \\ell ( c , f ( \\hat { z } _ { 0 } ) ) = \\nabla _ { z _ { t } } \\ell \\left( c , f \\left( \\frac { z _ { t } - \\sqrt { 1 - \\alpha _ { t } } \\epsilon _ { \\theta } ( z _ { t } , t ) } { \\sqrt { \\alpha _ { t } } } \\right) \\right)\n$$",
277
+ "text_format": "latex",
278
+ "page_idx": 4
279
+ },
280
+ {
281
+ "type": "text",
282
+ "text": "as in Eq. (3). We term Eq. (7) forward universal guidance, or forward guidance in short. In practice, applying forward guidance effectively brings the generated image closer to the prompt while keeping the generation trajectory in the data manifold. We note that a related approach is also studied in Chung et al. (2022a), where the guidance step is computed based on $E [ z _ { 0 } | z _ { t } ]$ . The approach drew inspiration from the score-based generative framework (Song et al., 2021b), but resulted in a different update method. ",
283
+ "page_idx": 4
284
+ },
285
+ {
286
+ "type": "text",
287
+ "text": "3.2 BACKWARD UNIVERSAL GUIDANCE ",
288
+ "text_level": 1,
289
+ "page_idx": 4
290
+ },
291
+ {
292
+ "type": "text",
293
+ "text": "As will be shown in Sec. 4.2, we observe that forward guidance sometimes over-prioritizes maintaining the “realness” of the image, resulting in an unsatisfactory match with the given prompt. Simply increasing the guidance strength $s ( t )$ is suboptimal, as this often results in instability as the image moves off the manifold faster than the denoiser can correct it. ",
294
+ "page_idx": 4
295
+ },
296
+ {
297
+ "type": "text",
298
+ "text": "Algorithm 1 Universal Guidance ",
299
+ "text_level": 1,
300
+ "page_idx": 4
301
+ },
302
+ {
303
+ "type": "text",
304
+ "text": "Parameter: Refinement steps $k$ , backward guidance \nsteps $m$ , and guidance strength $s ( t )$ , \nRequired: $z _ { t }$ the noisy vector at a given time-step $t$ \ndiffusion model $\\epsilon _ { \\theta }$ , noise scale $\\alpha _ { t }$ , guidance function \n$f$ , loss function $\\ell$ , and prompt $c$ \nfor $n = 1 , 2 , \\ldots , k$ do Calculate $\\hat { z } _ { 0 }$ as in Eq. (3). Calculate $\\hat { \\epsilon } _ { \\theta }$ using forward universal guidance as in Eq. (7). if $m > 0$ then Calculate $\\Delta z _ { 0 }$ by minimizing Eq. (8) with $m$ steps of gradient descent. Perform backward universal guidance by $\\hat { \\epsilon } _ { \\theta } \\gets \\hat { \\epsilon } _ { \\theta } - \\sqrt { \\alpha _ { t } / ( 1 - \\alpha _ { t } ) } \\Delta z _ { 0 }$ (see Eq. (10)). end if $\\boldsymbol { z } _ { t - 1 } \\gets \\boldsymbol { S } ( \\boldsymbol { z } _ { t } , \\hat { \\boldsymbol { \\epsilon } } _ { \\theta } , t )$ . $\\epsilon ^ { \\prime } \\sim \\mathcal { N } ( 0 , \\dot { I } )$ . $z _ { t } \\gets \\sqrt { \\alpha _ { t } / \\alpha _ { t - 1 } } z _ { t - 1 } + \\sqrt { 1 - \\alpha _ { t } / \\alpha _ { t - 1 } } \\epsilon ^ { \\prime } .$ \nend for \nReturn zt−1 ",
305
+ "page_idx": 4
306
+ },
307
+ {
308
+ "type": "text",
309
+ "text": "To address the issue, we propose backward universal guidance, or backward guidance in short, to supplement forward guidance and help enforce the generated image to satisfy the constraint. The key idea of backward guidance is to optimize for a clean image that best matches the prompt based on $\\hat { z } _ { 0 }$ , and linearly translate the guided change back to the noisy image space at step $t$ Concretely, instead of directly calculating $\\nabla _ { z _ { t } } \\ell ( \\dot { c } , f ( \\hat { z } _ { 0 } ) )$ , we compute a guided change $\\Delta z _ { 0 }$ in clean data space as ",
310
+ "page_idx": 4
311
+ },
312
+ {
313
+ "type": "equation",
314
+ "img_path": "images/430daa55c9cc7717607bb17ebdadb6a6cc5e7463402de7d7f75b5fdbaa2e74ab.jpg",
315
+ "text": "$$\n\\Delta z _ { 0 } = \\arg \\operatorname* { m i n } _ { \\Delta } \\ell ( c , f ( \\hat { z } _ { 0 } + \\Delta ) ) .\n$$",
316
+ "text_format": "latex",
317
+ "page_idx": 4
318
+ },
319
+ {
320
+ "type": "text",
321
+ "text": "Empirically, we solve Eq. (8) with $m$ -step gradient descent, where we use $\\Delta = 0$ as a starting point. Since $\\hat { z } _ { 0 } + \\Delta z _ { 0 }$ minimizes $\\ell ( c , f ( \\bar { z } ) )$ directly, $\\Delta z _ { 0 }$ is the change in clean data space that best enforces the constraint. Then, we translate $\\Delta z _ { 0 }$ back to the noisy data space of $z _ { t }$ by calculating the guided denoising prediction ϵ˜ that satisfies ",
322
+ "page_idx": 4
323
+ },
324
+ {
325
+ "type": "equation",
326
+ "img_path": "images/e42dca324571f7ea5881e8dd4c56e7751e64b9b2dc69c71680fb6a83d95ae543.jpg",
327
+ "text": "$$\nz _ { t } = \\sqrt { \\alpha _ { t } } ( \\hat { z } _ { 0 } + \\Delta z _ { 0 } ) + \\sqrt { 1 - \\alpha _ { t } } \\tilde { \\epsilon } .\n$$",
328
+ "text_format": "latex",
329
+ "page_idx": 4
330
+ },
331
+ {
332
+ "type": "text",
333
+ "text": "Reusing Eq. (3), we can rewrite ϵ˜ as an augmentation to the original denoising prediction $\\epsilon _ { \\theta } ( z _ { t } , t )$ by ",
334
+ "page_idx": 4
335
+ },
336
+ {
337
+ "type": "equation",
338
+ "img_path": "images/1fbfcac1d77bb0bd5eeb1d2d10bf68d82f427bc3748a93d4df3505b3ccca36cd.jpg",
339
+ "text": "$$\n\\tilde { \\epsilon } = \\epsilon _ { \\theta } ( z _ { t } , t ) - \\sqrt { \\alpha _ { t } / ( 1 - \\alpha _ { t } ) } \\Delta z _ { 0 } .\n$$",
340
+ "text_format": "latex",
341
+ "page_idx": 4
342
+ },
343
+ {
344
+ "type": "text",
345
+ "text": "Comparing to forward guidance, backward guidance (as Eq. (10)) produces an optimized direction for the generated image to match the given prompt, and hence prioritizes enforcing the constraint. Furthermore, calculation of a gradient step for Eq. (8) is computationally cheaper than forward guidance (Eq. (7)), and we can therefore afford to solve Eq. (8) with multiple gradient steps, further improving the match with the given prompt. ",
346
+ "page_idx": 4
347
+ },
348
+ {
349
+ "type": "text",
350
+ "text": "We note that the names “forward” and “backward” are used analogously to the forward and backward Euler methods. ",
351
+ "page_idx": 4
352
+ },
353
+ {
354
+ "type": "text",
355
+ "text": "3.3 UNIVERSAL STEPWISE REFINEMENT ",
356
+ "text_level": 1,
357
+ "page_idx": 5
358
+ },
359
+ {
360
+ "type": "text",
361
+ "text": "Upon applying our universal guidance to standard generation pipelines, we observe that in some instances, the images generated exhibit artifacts or unusual behaviors that differentiate them from natural images. Similar findings have been reported in (Lugmayr et al., 2022; Wang et al., 2022b), where linear guidance functions were explored. Although we attempted to enhance the realism by adjusting the guidance strength $s ( t )$ , finding an optimal balance that ",
362
+ "page_idx": 5
363
+ },
364
+ {
365
+ "type": "image",
366
+ "img_path": "images/2a92c679abd282ca8aa8cc1e6674127de3604a8361b95af6462df57508e0219b.jpg",
367
+ "image_caption": [
368
+ "Figure 2: An example of how the Universal Stepwise Refinement (USR) helps segmentation-guided generation. The left-most figure is the given segmentation map, and the images generated with USR steps 1, 4 and 10 follow in order. Notice the increase of quality with USR steps. "
369
+ ],
370
+ "image_footnote": [],
371
+ "page_idx": 5
372
+ },
373
+ {
374
+ "type": "text",
375
+ "text": "both guarantees image realism and adherence to guidance constraints proved challenging, particularly with complex guidance functions. We hypothesize that the direction of guidance offered by our universal method might not always correlate with image realism, diverting the image from a natural image sampling trajectory. ",
376
+ "page_idx": 5
377
+ },
378
+ {
379
+ "type": "text",
380
+ "text": "Drawing motivation from Lugmayr et al. (2022); Wang et al. (2022b), we propose a more nuanced approach, termed Universal Stepwise Refinement (USR), to navigate these challenges. Specifically, after sampling $\\boldsymbol { z } _ { t - 1 } = \\boldsymbol { S } ( \\boldsymbol { z } _ { t } , \\hat { \\epsilon } _ { t } , t )$ , we reintroduce Gaussian noise $\\epsilon ^ { \\prime } \\sim \\mathcal { N } ( 0 , \\bf { I } )$ to $z _ { t - 1 }$ , deriving $z _ { t } ^ { \\prime }$ as per the equation: ",
381
+ "page_idx": 5
382
+ },
383
+ {
384
+ "type": "equation",
385
+ "img_path": "images/ff22ebf441aef7a210d2c1db8b804f5d418e1901327251202b4da42daacb4c91.jpg",
386
+ "text": "$$\nz _ { t } ^ { \\prime } = \\sqrt { \\alpha _ { t } / \\alpha _ { t - 1 } } \\cdot z _ { t - 1 } + \\sqrt { 1 - \\alpha _ { t } / \\alpha _ { t - 1 } } \\cdot \\epsilon ^ { \\prime } .\n$$",
387
+ "text_format": "latex",
388
+ "page_idx": 5
389
+ },
390
+ {
391
+ "type": "text",
392
+ "text": "Equation 11 ensures $z _ { t } ^ { \\prime }$ retains the appropriate noise scale for input at time step $t$ . Given a refinement step $k$ , we repeat the Universal Stepwise Refinement $k$ times before advancing with the sampling for step $t - 1$ . This refined process enables the exploration of various regions of the data manifold at a consistent noise scale to reach a solution that aligns with both the guidance and image quality requisites. Our empirical assessments indicate that using USR mechanism on top of proper guidance strength $s ( t )$ significantly enhanced the image realism while still maintaining the adherence to the prompt, as shown in Fig. 2. ",
393
+ "page_idx": 5
394
+ },
395
+ {
396
+ "type": "text",
397
+ "text": "We summarize our universal guidance algorithm composed of forward universal guidance, backward universal guidance and universal stepwise refinement for a single sampling step in Algorithm 1. For simplicity, the algorithm assumes only one guidance function, but can be easily adapted to handle multiple pairs of $( f , l )$ . Additionally, the objectives of the forward and backward guidance do not have to be identical, allowing different ways to simultaneously utilize multiple guidance functions. ",
398
+ "page_idx": 5
399
+ },
400
+ {
401
+ "type": "text",
402
+ "text": "4 EXPERIMENTS ",
403
+ "text_level": 1,
404
+ "page_idx": 5
405
+ },
406
+ {
407
+ "type": "text",
408
+ "text": "In this section, we present results testing our proposed universal guidance algorithm against a wide variety of guidance functions. Specifically, we experiment with Stable Diffusion (Rombach et al., 2022), a diffusion model that is able to perform text-conditional generation by accepting text prompt as additional input, and experiment with a purely unconditional diffusion model trained on ImageNet (Deng et al., 2009), where we use pre-trained model provided by OpenAI (Dhariwal & Nichol, 2021). We note that Stable Diffusion, while being a text-conditional generative model, can also perform unconditional image generation by simply using an empty string as the text prompt. We first present the experiment on Stable Diffusion for different guidance functions in Sec. 4.1, and present the results on ImageNet diffusion model in Sec. 4.2. Hyper-parameters used for different guidance functions, further ablation studies and selection procedures for suitable guidance strength $s ( t )$ and refinement step $k$ can be found in the appendix. ",
409
+ "page_idx": 5
410
+ },
411
+ {
412
+ "type": "text",
413
+ "text": "4.1 RESULTS FOR STABLE DIFFUSION ",
414
+ "text_level": 1,
415
+ "page_idx": 5
416
+ },
417
+ {
418
+ "type": "text",
419
+ "text": "In this section, we present the results of guided image generation using Stable Diffusion as the foundation model. The guidance functions we experiment with include a segmentation network, a face recognition network, an object detection network and style guidance with CLIP feature extractor (Radford et al., 2021). For experiments on Stable Diffusion, we discover that applying forward guidance already produce high-quality images that match the given prompt, and hence set $m = 0$ . To perform forward guidance on Stable Diffusion, we forward the predicted clean latent variable computed by Eq. (3) through the image decoder of Stable Diffusion to obtain predicted clean images. We discuss the qualitative results and implementation details for each guidance function in its corresponding subsection. We summarize our quantitative evaluation in Tab. 1, where we evaluate how well the generated images match the external guidance with task-specific metrics, and include the similarity of CLIP embedding between text prompts and images generated with and without guidance. For all tasks, the minimum difference between CLIP similarities indicates that our algorithm performs guidance without sacrificing the effectiveness of the underlying diffusion model. We also include additional quantitative and qualitative results for text-guided generation in the appendix. ",
420
+ "page_idx": 5
421
+ },
422
+ {
423
+ "type": "image",
424
+ "img_path": "images/575e2bcf78e27300302fb165597259606d1e7d49a5e3edda0be61978b300db20.jpg",
425
+ "image_caption": [
426
+ "Figure 3: In addition to matching the text prompts (above each column), these images are guided by an image segmentation pipeline. Each column contains examples of images generated to match the prompt and the segmentation map in the left-most column. The top-most row contains examples generated without guidance. "
427
+ ],
428
+ "image_footnote": [],
429
+ "page_idx": 6
430
+ },
431
+ {
432
+ "type": "image",
433
+ "img_path": "images/58693702722a538861bf09a0f460adcb40b3118130c2feff57090ac3afce6c70.jpg",
434
+ "image_caption": [
435
+ "Figure 4: Each column contains examples of images generated to match the prompt and the identity of the images in the left-most column. The top-most row contains examples generated without guidance. "
436
+ ],
437
+ "image_footnote": [],
438
+ "page_idx": 6
439
+ },
440
+ {
441
+ "type": "text",
442
+ "text": "",
443
+ "page_idx": 6
444
+ },
445
+ {
446
+ "type": "text",
447
+ "text": "Segmentation Map Guidance. To guide image generation using a segmentation map as prompt, we use a MobileNetV3-Large (Howard et al., 2019) with a segmentation head, and a publicly available pre-trained model in PyTorch (Paszke et al., 2019). We use standard perpixel cross-entropy loss between a given prompt and the predicted segmentation of generated images as our loss function $\\ell$ . ",
448
+ "page_idx": 6
449
+ },
450
+ {
451
+ "type": "text",
452
+ "text": "In our experiment, we combine segmentation maps that depict objects of different shapes with ",
453
+ "page_idx": 6
454
+ },
455
+ {
456
+ "type": "table",
457
+ "img_path": "images/9addb3e819ad8eca430a9266510f6f2d3c7470f116b8052ef8eb5eadb9222e3b.jpg",
458
+ "table_caption": [
459
+ "Table 1: Quantitative analysis of different guidance applied on Stable Diffusion. The reference value in parenthesis is obtained with no external guidance. "
460
+ ],
461
+ "table_footnote": [],
462
+ "table_body": "<table><tr><td>Task</td><td>Metric</td><td>Value</td></tr><tr><td>Segmentation</td><td>CLIPsimiaity</td><td>0.24700.249</td></tr><tr><td>Face</td><td>CLe similariy</td><td>(0.28760.234</td></tr><tr><td>Object detection</td><td>cLmAPmi1aity</td><td>0.263)0.246</td></tr></table>",
463
+ "page_idx": 6
464
+ },
465
+ {
466
+ "type": "text",
467
+ "text": "new text prompts. We use the text prompt as a fixed additional input to Stable Diffusion to perform text-conditional sampling, and guide the text-conditional generated images to match the given segmentation maps. Qualitative results are presented in Fig. 3. From Fig. 3, we see that the generated images show a clear separation between object and background that matches the given segmentation map nearly perfectly. The generated object and background also each match their descriptive text (i.e. dog breed and environment description). Furthermore, the generated images are overall highly realistic. In Tab. 1, we evaluate mIoU between the ground truth segmentation map and the predicted segmentation of generated images to assess the match with constraint. ",
468
+ "page_idx": 6
469
+ },
470
+ {
471
+ "type": "text",
472
+ "text": "Face Recognition Guidance. For guiding generation to include a specific person’s likeness, we propose combining face detection and facial recognition modules into one guidance function. This setup produces a facial attribute embedding from an image of a face. We use multi-task cascaded convolutional networks (MTCNN) (Zhang et al., 2016) for face detection, and we use facenet (Schroff et al., 2015) for facial recognition. The guidance function $f$ then crops out the detected face and outputs a facial attribute embedding as a prompt and we use an $l _ { 1 }$ -loss between embeddings as the loss function $\\ell$ . ",
473
+ "page_idx": 6
474
+ },
475
+ {
476
+ "type": "image",
477
+ "img_path": "images/8c2900b3ac5ee0176c519a72b4f2cb8bc9db301e88120c477bd0c7e58e45693a.jpg",
478
+ "image_caption": [
479
+ "Figure 5: In addition to text prompts (above each column), these images are guided by an object detector. Each column contains examples of images generated to match the prompt and the bounding boxes used for guidance. ",
480
+ "Figure 6: In addition to text prompts, these images are guided by a style image. Each column contains examples of images generated to match the text prompt and the style used for guidance. "
481
+ ],
482
+ "image_footnote": [],
483
+ "page_idx": 7
484
+ },
485
+ {
486
+ "type": "text",
487
+ "text": "",
488
+ "page_idx": 7
489
+ },
490
+ {
491
+ "type": "text",
492
+ "text": "We explore different combinations of face guidance and text prompts. Similarly to the segmentation case, we use the text prompt as a fixed additional conditioning to Stable Diffusion and guide this text-conditional trajectory with our algorithm so that the face in the generated image looks similar to the face prompt. In Fig. 4, we clearly see that the facial characteristics of a given face prompt are reproduced almost perfectly on the generated images. The descriptive text of either background, material, or style is also realized correctly and blends nicely with the generated faces. We again summarize our quantitative evaluation in Tab. 1. We evaluate the similarity between facial attributes of ground-truth identity and the generated faces. In general, two faces are considered to be from the same person if the similarity is over 0.5, and our algorithm can effectively guide the generated face to meet the criteria. ",
493
+ "page_idx": 7
494
+ },
495
+ {
496
+ "type": "text",
497
+ "text": "Object Location Guidance For Stable Diffusion, we also present the results of guided image generation with an object detection network. For this experiment, we use Faster-RCNN (Ren et al., 2015) with Resnet-50-FPN backbone (Li et al., 2021), a publicly available pre-trained model in Pytorch, as our object detector. We use bounding boxes with class labels as our object location prompt. We construct a loss function $\\ell$ by the sum of three individual losses, namely (1) anchor classification loss, (2) bounding box regression loss and (3) region label classification loss. ",
498
+ "page_idx": 7
499
+ },
500
+ {
501
+ "type": "text",
502
+ "text": "We again experiment with different combinations of text prompt and object location prompt, and similarly use the text prompt as a fixed conditioning to Stable Diffusion. Using our proposed guidance algorithm, we perform guided image generation that generates and matches the objects presented in the text prompt to the given object locations. The results are presented in Fig. 5. We observe from Fig. 5 that objects in the descriptive text all appear in the designated location with the appropriate size indicated by the given bounding boxes. Each location is filled with appropriate, high-quality generations that align with varied image content prompts, ranging from “beach” to “oil painting”. In Tab. 1, we use mAP $\\textcircled { a } 5 0$ to measure how well the generated images satisfy the constraint. ",
503
+ "page_idx": 7
504
+ },
505
+ {
506
+ "type": "text",
507
+ "text": "Style Guidance Finally, we conclude our experiments on Stable Diffusion by guiding the image generation based on a reference style given by a style image. To achieve so, we capture the reference style from the style image by the image feature extractor from CLIP, and use the resulting image embedding as prompts. The loss function calculates the negative cosine similarity between the embedding of generated images and the embedding of the style image. Similar to previous experiments, we control the content using text input as additional conditioning to the Stable Diffusion model. We experiment with combinations of different style images and different text prompts, and present the results in Fig. 6. From Fig. 6, we can see that the generated images contain contents that match the given text prompts, while exhibiting style that matches the given style images. ",
508
+ "page_idx": 7
509
+ },
510
+ {
511
+ "type": "image",
512
+ "img_path": "images/a8f25b94ed6d9313a40e037afaad24a356a92ecad35e2ad2b44e19fe5491c152.jpg",
513
+ "image_caption": [
514
+ "Figure 7: Generation guided by object detection with the unconditional ImageNet model. While both forward and backward guidance produces realistic images with the desired objects in the designated locations, forward guidance alone produces the wrong objects or the wrong locations/sizes. ",
515
+ "Figure 8: Our guidance algorithm can incorporate feedback from multiple guidance functions. Left to right: The inpainting prompt; The classifierguided inpainting output; Images generated with both classifier and segmentation guidance, where realistic dogs are generated exactly on the mask. "
516
+ ],
517
+ "image_footnote": [],
518
+ "page_idx": 8
519
+ },
520
+ {
521
+ "type": "text",
522
+ "text": "",
523
+ "page_idx": 8
524
+ },
525
+ {
526
+ "type": "text",
527
+ "text": "4.2 RESULTS FOR IMAGENET DIFFUSION ",
528
+ "text_level": 1,
529
+ "page_idx": 8
530
+ },
531
+ {
532
+ "type": "text",
533
+ "text": "In this section, we present results for guided image generation using an unconditional diffusion model trained on ImageNet. We experiment with object location guidance and a hybrid guided image generation task which we term segmentation-guided inpainting. We also include additional experiments for CLIP guidance in the appendix. We will discuss results of each guidance separately. ",
534
+ "page_idx": 8
535
+ },
536
+ {
537
+ "type": "text",
538
+ "text": "Object Location Guidance. Similar to object location guidance for Stable Diffusion, we also use the same network architecture and the same pre-trained model as our object detection network, and construct an identical loss function $\\ell$ for our guidance algorithm. However, unlike Stable Diffusion, object locations are the only prompts available for guided image generation. We experiment with different object location prompts using either (1) only forward universal ",
539
+ "page_idx": 8
540
+ },
541
+ {
542
+ "type": "table",
543
+ "img_path": "images/d9a90f9f3d3b9f8bf2ec7b0944723d3a82eab6682ba4c1e2487cc87e38d3dc56.jpg",
544
+ "table_caption": [
545
+ "Table 2: Quantitative analysis of forward guidance only versus combination of forward and backward guidance for object detection guidance on ImageNet with bounding boxes in Fig. 7. The metric is mAP $\\textcircled { a } 5 0$ . "
546
+ ],
547
+ "table_footnote": [],
548
+ "table_body": "<table><tr><td>Object Location</td><td>Fwd. Only</td><td>Fwd. + Bkd.</td></tr><tr><td>Bounding box 1</td><td>0.39</td><td>0.90</td></tr><tr><td>Bounding box 2</td><td>0.18</td><td>0.36</td></tr></table>",
549
+ "page_idx": 8
550
+ },
551
+ {
552
+ "type": "text",
553
+ "text": "guidance and (2) both forward and backward universal guidance. We observe from Fig. 7 that applying both forward and backward guidance generates images that are realistic and the objects match the prompt nicely. On the other hand, while images generated using only forward guidance remain realistic, they feature objects with mismatching categories and locations. The observation is further backed by quantitative evaluation presented in Tab. 2. The evaluation is based on $\\operatorname* { m A P @ 5 0 }$ between the ground truth object locations and the predicted bounding boxes of generated images, and clearly shows that the combination of forward and backward guidance leads to a much better match with the constraint. The results demonstrate the effectiveness of our universal guidance algorithm, and also validate the necessity of our backward guidance. ",
554
+ "page_idx": 8
555
+ },
556
+ {
557
+ "type": "text",
558
+ "text": "Segmentation-Guided Inpainting. In this experiment, we aim to explore the ability of our algorithm to handle multiple guidance functions. We perform guided image generation with combined guidance from an inpainting mask, a classifier and a segmentation network. We first generate images with masked regions as the prompt for inpainting. We then pick an object class $c$ as the prompt for classification and generate a segmentation mask where the masked regions are considered foreground objects of the same class $c$ . We use $\\ell _ { 2 }$ loss on the non-masked region as the loss function for inpainting, and set the corresponding $s ( t ) = 0$ , or equivalently only use backward guidance for inpainting. We use the same segmentation network as described in Sec. 4.1. For classification guidance, we use the classifier that accepts noisy input (Dhariwal & Nichol, 2021), and perform the original classifier guidance as Eq. (4) instead of our forward guidance. The results in Fig. 8 show that when using both inpainting and classifier as guidance, our algorithm generates realistic images that both match the inpainting prompt and are classified correctly to the given object class. Adding in segmentation guidance, our algorithm further improves by making a near-perfect match to both the segmentation map and the inpainting prompt while maintaining realism, demonstrating that our algorithm effectively combines feedback from multiple guidance functions. ",
559
+ "page_idx": 8
560
+ },
561
+ {
562
+ "type": "text",
563
+ "text": "",
564
+ "page_idx": 9
565
+ },
566
+ {
567
+ "type": "text",
568
+ "text": "5 CONCLUSION ",
569
+ "text_level": 1,
570
+ "page_idx": 9
571
+ },
572
+ {
573
+ "type": "text",
574
+ "text": "We propose a universal guidance algorithm that is able to perform guided image generation with any off-the-shelf guidance function based on a fixed foundation diffusion model. Our algorithm only needs guidance and loss functions to be differentiable, and avoids any retraining to adapt the guidance function or the foundation model to a specific type of prompt. We demonstrate promising results with our algorithm on complex guidance including segmentation, face recognition and object detection systems – and multiple guidance functions can even be used together. ",
575
+ "page_idx": 9
576
+ },
577
+ {
578
+ "type": "text",
579
+ "text": "6 ACKNOWLEDGEMENTS ",
580
+ "text_level": 1,
581
+ "page_idx": 9
582
+ },
583
+ {
584
+ "type": "text",
585
+ "text": "This work was made possible by the ONR MURI program and the AFOSR MURI program. Commercial support was provided by Capital One Bank, the Amazon Research Award program, and Open Philanthropy. Further support was provided by the National Science Foundation (IIS-2212182), and by the NSF TRAILS Institute (2229885). ",
586
+ "page_idx": 9
587
+ },
588
+ {
589
+ "type": "text",
590
+ "text": "REPRODUCIBILITY STATEMENT ",
591
+ "text_level": 1,
592
+ "page_idx": 9
593
+ },
594
+ {
595
+ "type": "text",
596
+ "text": "we describe guidance functions and foundation diffusion models for experiments presented in Sec. 4 in the corresponding subsections. Hyperparameters for experiments described in Sec. 4 of the main paper can be found in Sec. B in the appendix. We also include the source code used to conduct the experiments described in the paper in our supplementary material. ",
597
+ "page_idx": 9
598
+ },
599
+ {
600
+ "type": "text",
601
+ "text": "REFERENCES ",
602
+ "text_level": 1,
603
+ "page_idx": 9
604
+ },
605
+ {
606
+ "type": "text",
607
+ "text": "Jacob Austin, Daniel D Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces. Advances in Neural Information Processing Systems, 34:17981– 17993, 2021. \nArpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie S Li, Hamid Kazemi, Furong Huang, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Cold diffusion: Inverting arbitrary image transforms without noise. arXiv preprint arXiv:2208.09392, 2022. \nHyungjin Chung, Jeongsol Kim, Michael T Mccann, Marc L Klasky, and Jong Chul Ye. Diffusion posterior sampling for general noisy inverse problems. arXiv preprint arXiv:2209.14687, 2022a. \nHyungjin Chung, Byeongsu Sim, Dohoon Ryu, and Jong Chul Ye. Improving diffusion models for inverse problems using manifold constraints. arXiv preprint arXiv:2206.00941, 2022b. \nJia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009. \nPrafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat gans on image synthesis. volume 34, 2021. \nAlexandros Graikos, Nikolay Malkin, Nebojsa Jojic, and Dimitris Samaras. Diffusion models as plug-and-play priors. arXiv preprint arXiv:2206.09012, 2022. \nJonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. \nJonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 32, 2020. \nAndrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, et al. Searching for mobilenetv3. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 1314–1324, 2019. \nRongjie Huang, Max WY Lam, Jun Wang, Dan Su, Dong Yu, Yi Ren, and Zhou Zhao. Fastdiff: A fast conditional diffusion model for high-quality speech synthesis. arXiv preprint arXiv:2204.09934, 2022. \nBahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. arXiv preprint arXiv:2201.11793, 2022. \nZhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. Diffwave: A versatile diffusion model for audio synthesis. arXiv preprint arXiv:2009.09761, 2020. \nXiang Lisa Li, John Thickstun, Ishaan Gulrajani, Percy Liang, and Tatsunori B Hashimoto. Diffusion-lm improves controllable text generation. arXiv preprint arXiv:2205.14217, 2022. \nYanghao Li, Saining Xie, Xinlei Chen, Piotr Dollar, Kaiming He, and Ross Girshick. Benchmarking detection transfer learning with vision transformers. arXiv preprint arXiv:2111.11429, 2021. \nYuheng 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, 2023. \nAndreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. Repaint: Inpainting using denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11461–11471, 2022. \nAlex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021. \nAdam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019. \nAlec 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. \nShaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015. \nRobin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High-resolution image ¨ synthesis with latent diffusion models. In Proceedings of CVPR, 2022. \nChitwan 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. \nFlorian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 815–823, 2015. \nJiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. International Conference on Learning Representations, 2021a. \nYang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019. \nYang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. International Conference on Learning Representations, 2021b. \nWeilun Wang, Jianmin Bao, Wengang Zhou, Dongdong Chen, Dong Chen, Lu Yuan, and Houqiang Li. Semantic image synthesis via diffusion models. arXiv preprint arXiv:2207.00050, 2022a. \nYinhuai Wang, Jiwen Yu, and Jian Zhang. Zero-shot image restoration using denoising diffusion null-space model. arXiv preprint arXiv:2212.00490, 2022b. \nJay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16293–16303, 2022. \nKaipeng Zhang, Zhanpeng Zhang, Zhifeng Li, and Yu Qiao. Joint face detection and alignment using multitask cascaded convolutional networks. IEEE signal processing letters, 23(10):1499–1503, 2016. \nLvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023. ",
608
+ "page_idx": 9
609
+ },
610
+ {
611
+ "type": "text",
612
+ "text": "",
613
+ "page_idx": 10
614
+ },
615
+ {
616
+ "type": "text",
617
+ "text": "",
618
+ "page_idx": 11
619
+ },
620
+ {
621
+ "type": "text",
622
+ "text": "A LIMITATIONS ",
623
+ "text_level": 1,
624
+ "page_idx": 12
625
+ },
626
+ {
627
+ "type": "text",
628
+ "text": "Generation using universal guidance is typically slower than standard conditional generation for several reasons. Empirically, more than one iteration of denoising is required for the given noise level $t$ to generate high-quality images with complex guidance functions. However, the time complexity of our algorithm scales linearly with the number of refinement steps $k$ , which slows down image generation when $k$ is large. That being said, for the applications presented in this paper, we were successful in generating images with smaller values of $k$ . Also, as demonstrated in the main paper, backward guidance is required in certain scenarios to help generate images that match the given constraint. Computing backward guidance requires performing minimization with a multi-step gradient descent inner loop. While proper choices of gradient-based optimization algorithms and learning rate schedules significantly speed up the convergence of minimization, the time it takes to compute backward guidance inevitably becomes longer when the guidance function is itself a very-large neural network. Finally, we note that, to get optimal results, sampling hyper-parameters must be chosen individually for each guidance network. ",
629
+ "page_idx": 12
630
+ },
631
+ {
632
+ "type": "text",
633
+ "text": "B HYPER-PARAMETERS ",
634
+ "text_level": 1,
635
+ "page_idx": 12
636
+ },
637
+ {
638
+ "type": "text",
639
+ "text": "In this section, we present the hyper-parameters for the different guidance functions i.e. face, segmentation, object location, and style guidance. We present the hyperparameters for experiments on Stable Diffusion in Sec. 4.1 in the Tab. 3, where we include coefficient √ $s _ { 0 }$ to compute $s _ { t } =$ $s _ { 0 } \\sqrt { 1 - \\alpha _ { t } }$ and the number of Universal Stepwise Refinement $( k )$ . We also provide hyperparameters for experiments on ImageNet in Sec. 4.2 in Tab. 4 ",
640
+ "page_idx": 12
641
+ },
642
+ {
643
+ "type": "table",
644
+ "img_path": "images/325cfa58ab5bfa7f7a1c8bc25bbe09b101351c2ea0e643a9fbf117f989219ff8.jpg",
645
+ "table_caption": [
646
+ "Table 3: Hyper-parameters used in this paper for different guidance functions to reproduce the results for Stable Diffusion. "
647
+ ],
648
+ "table_footnote": [],
649
+ "table_body": "<table><tr><td>Guidance</td><td>S0</td><td>k</td></tr><tr><td>Face</td><td>20000</td><td>2</td></tr><tr><td>Object Location</td><td>100</td><td>3</td></tr><tr><td>Style Transfer</td><td>6</td><td>6</td></tr><tr><td>Segmentation</td><td>400</td><td>10</td></tr></table>",
650
+ "page_idx": 12
651
+ },
652
+ {
653
+ "type": "table",
654
+ "img_path": "images/a6818e113c6786ae9c10887a7468fec1f1b308f60206c4c0269cdbfd5a76bd66.jpg",
655
+ "table_caption": [
656
+ "Table 4: Hyper-parameters used in this paper for different guidance functions to reproduce the results for ImageNet. "
657
+ ],
658
+ "table_footnote": [],
659
+ "table_body": "<table><tr><td>Guidance</td><td>S0</td><td>k</td></tr><tr><td>Object Location</td><td>100</td><td>3</td></tr><tr><td>Segmentation</td><td>200</td><td>10</td></tr></table>",
660
+ "page_idx": 12
661
+ },
662
+ {
663
+ "type": "text",
664
+ "text": "C CLIP GUIDANCE FOR STABLE DIFFUSION ",
665
+ "text_level": 1,
666
+ "page_idx": 12
667
+ },
668
+ {
669
+ "type": "text",
670
+ "text": "CLIP (Radford et al., 2021) is a state-of-the-art text-to-image similarity model developed by OpenAI. We use the image feature extractor of CLIP to do text-guided image generation with our algorithm. We construct a loss function that calculates the negative cosine similarity between an image embedding√ and the CLIP text embedding produced by a given text prompt. We use $s ( t ) = 1 0 \\sqrt { 1 - \\alpha _ { t } }$ and $k = 8$ and use Stable Diffusion as an unconditional image generator. ",
671
+ "page_idx": 12
672
+ },
673
+ {
674
+ "type": "text",
675
+ "text": "We generate images guided by a number of text prompts. To further assess our universal guidance algorithm and compare guidance and conditioning, we also generate images using classical, textconditional generation by Stable Diffusion with identical prompts as inputs, and summarize the results in Fig. 9. The results in Fig. 9 show that our algorithm can guide the generation to produce high-quality images that match the given text description, and are comparable with images generated by the specialized text-conditioning model. We also include qualitative results from experiments on DrawBench (Saharia et al., 2022). DrawBench is a widely-used and diverse list of text prompts. We randomly select 20 prompts and generate 10 images for each individual prompt. We compute CLIP ",
676
+ "page_idx": 12
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "A photograph of an astronaut riding a horse. ",
681
+ "page_idx": 13
682
+ },
683
+ {
684
+ "type": "image",
685
+ "img_path": "images/3c3c821d7967493fd9f7481f2b698afcfe143ba4a813ecca36e64330e8b50d86.jpg",
686
+ "image_caption": [
687
+ "Figure 9: We compare the ability to match given text prompts between our universal guidance algorithm and text-conditional model trained from scratch. The results demonstrate that our universal algorithm is comparable to specialized conditional model on the ability to generate quality images that satisfy the text constraints. "
688
+ ],
689
+ "image_footnote": [],
690
+ "page_idx": 13
691
+ },
692
+ {
693
+ "type": "text",
694
+ "text": "score, the cosine similarity between CLIP feature of the text prompt and the associated generated image, on both Stable Diffusion and our algorithm, and report the average in Tab. 5. As demonstrated in the table, the performance of our algorithm is quantitatively similar to a dedicated text-conditional generator, while requiring no additional training at all for the underlying unconditional diffusion model. ",
695
+ "page_idx": 13
696
+ },
697
+ {
698
+ "type": "table",
699
+ "img_path": "images/53be0e87b0d789c2808c7df50d68523138bd155346f85bc3248621f0e3404890.jpg",
700
+ "table_caption": [
701
+ "Table 5: Quantitative results on DrawBench for Stable Diffusion and our algorithm. "
702
+ ],
703
+ "table_footnote": [],
704
+ "table_body": "<table><tr><td></td><td>Stable Diffusion</td><td>Universal Guidance</td></tr><tr><td>CLIP Score</td><td>0.2818</td><td>0.2632</td></tr></table>",
705
+ "page_idx": 13
706
+ },
707
+ {
708
+ "type": "text",
709
+ "text": "D CLIP GUIDANCE FOR IMAGENET DIFFUSION MODEL ",
710
+ "page_idx": 14
711
+ },
712
+ {
713
+ "type": "text",
714
+ "text": "English foxhound by Edward Hopper ",
715
+ "page_idx": 14
716
+ },
717
+ {
718
+ "type": "text",
719
+ "text": "Van Gogh Style ",
720
+ "page_idx": 14
721
+ },
722
+ {
723
+ "type": "text",
724
+ "text": "Cake ",
725
+ "page_idx": 14
726
+ },
727
+ {
728
+ "type": "image",
729
+ "img_path": "images/6d2f2fb8de6cb38b22b60e29daeae29109d92b1286b739593070bf12ac9c116f.jpg",
730
+ "image_caption": [
731
+ "Figure 10: We show that unconditional diffusion models trained on ImageNet can be guided with CLIP to generate high-quality images that match the text prompts, even if these generated images should be out of distribution. "
732
+ ],
733
+ "image_footnote": [],
734
+ "page_idx": 14
735
+ },
736
+ {
737
+ "type": "text",
738
+ "text": "CLIP Guidance. We use the same construction of $f$ and $\\ell$ for Stable Diffusion to perform CLIPguided generation. We use only forward guidance for this experiment. To assess the limit of our universal guidance algorithm, we hand-crafted text prompts such that the matching images are expected to be out of distribution. In particular, our text prompts either designate art styles that are far from realistic or designate objects that do not belong to any possible class label of ImageNet. We present the results in Fig. 10, and from the results, we clearly see that our algorithm still successfully guides the generation to produce quality images that also match the text prompts. For all three images,√ we have $s ( \\overline { { t } } ) = w \\cdot \\sqrt { 1 - \\alpha _ { t } }$ , where $w$ is 2, 5 and 2 respectively and $k$ is 10, 5 and 10 respectively. ",
739
+ "page_idx": 14
740
+ },
741
+ {
742
+ "type": "image",
743
+ "img_path": "images/aa7ce0ac9f549141c1669197bce6dc17c09d4bc29ac177aaa813d5783ecc130c.jpg",
744
+ "image_caption": [
745
+ "Figure 11: The qualitative results for effect of different guidance strength $s ( t )$ and universal refinement√ step $k$ on segmentation guidance for Stable Diffusion. Here we use $s \\bar { ( } t ) = \\dot { c } \\cdot \\sqrt { 1 - \\alpha _ { t } }$ , and compare different $c$ instead. "
746
+ ],
747
+ "image_footnote": [],
748
+ "page_idx": 15
749
+ },
750
+ {
751
+ "type": "text",
752
+ "text": "E ABLATION STUDY AND PROCEDURE TO PICK HYPERPARAMETERS ",
753
+ "text_level": 1,
754
+ "page_idx": 15
755
+ },
756
+ {
757
+ "type": "text",
758
+ "text": "In this section we present our ablation study on the effect of different parameters, namely guidance strength $s ( t )$ and refinement step $k$ , for our algorithm. We summarize the qualitative results in Fig. 11 on segmentation guidance for Stable Diffusion. From the figure, we observe that increasing $c$ alone leads to better matching between the segmentation map and the position of the generated dogs, but the quality of images also degrades, especially when $c$ is large $c > = 2 0 0 ^ { \\cdot }$ ). On the other hand, increasing $k$ noticeably improves the quality of images. For example, comparing the best image from $( k , c ) = \\bar { ( 4 , 8 0 0 ) }$ and $\\bar { ( k , c ) } = ( 1 0 , 8 0 \\bar { 0 } )$ , the latter clearly exhibits significantly better realness. We also quantitatively evaluate the effectiveness of the two parameters, and present the results in Tab. 6. We calculate the mIOU between the ground truth segmentation map and the segmentation map of generated images predicted by the given segmentation network, which assesses the match between generation and the given constraint. We also show cosine similarity between the clip attribute vectors of the generated images and the given text phrase. High cosine similarity indicates that generation guided with segmentation does not stray away from the text-conditional generation of the underlying diffusion model. In Tab. 6, we observe that when the step $m$ is fixed, increasing the guidance strength $c$ leads to a better match with external guidance. On the other hand, the clip similarity score is stable for $c$ in range of (10, 200) before showing a sudden drop when $c > = 4 0 0$ , indicating that it is more difficult for the underlying diffusion model to control the guided generation to match the text when $c$ is large. As for universal refinement step $k$ , increasing $k$ generally improves both mIOU and clip similarity. ",
759
+ "page_idx": 15
760
+ },
761
+ {
762
+ "type": "table",
763
+ "img_path": "images/3dd8cb074d6fd46a5f5355a4e13270ddc369353ab1931f22a696432a472c80bd.jpg",
764
+ "table_caption": [],
765
+ "table_footnote": [],
766
+ "table_body": "<table><tr><td>Metric</td><td>Refinement step</td><td>c=10</td><td>c=20</td><td>c=50</td><td>c=100</td><td>c =200</td><td>c =400</td><td>c =800</td></tr><tr><td rowspan=\"3\">mIoU</td><td>k=2</td><td>0.52</td><td>0.52</td><td>0.67</td><td>0.79</td><td>0.87</td><td>0.89</td><td>0.89</td></tr><tr><td>k=4</td><td>0.50</td><td>0.59</td><td>0.71</td><td>0.80</td><td>0.87</td><td>0.89</td><td>0.88</td></tr><tr><td>k=10</td><td>0.57</td><td>0.62</td><td>0.76</td><td>0.80</td><td>0.89</td><td>0.90</td><td>0.92</td></tr><tr><td rowspan=\"3\">CLIP sim.</td><td>k=2</td><td>0.26</td><td>0.26</td><td>0.25</td><td>0.24</td><td>0.24</td><td>0.20</td><td>0.16</td></tr><tr><td>k=4</td><td>0.26</td><td>0.27</td><td>0.26</td><td>0.25</td><td>0.25</td><td>0.21</td><td>0.14</td></tr><tr><td>k=10</td><td>0.24</td><td>0.25</td><td>0.26</td><td>0.26</td><td>0.25</td><td>0.22</td><td>0.18</td></tr></table>",
767
+ "page_idx": 15
768
+ },
769
+ {
770
+ "type": "text",
771
+ "text": "Table 6: Quantitative evaluation for different combination of parameters of segmentation guidance on Stable Diffusion. ",
772
+ "page_idx": 15
773
+ },
774
+ {
775
+ "type": "text",
776
+ "text": "We also want to remark that the ablation study formalizes a principled way to pick suitable $k$ and $s ( t )$ for different guidance functions. In particular, increasing $k$ is always beneficial to the generation quality, and the value of $k$ is limited only by the computational budget. Given a fixed $k$ , there is generally a sweet spot for $s ( t )$ that ensures both a match to the target and sufficient quality, and this sweet spot can be found with standard parameter search, as described above. ",
777
+ "page_idx": 15
778
+ },
779
+ {
780
+ "type": "image",
781
+ "img_path": "images/a3438ccddb2dca002582dd6f1126e38d68177453f411ced588ca38a0fda1d369.jpg",
782
+ "image_caption": [
783
+ "(c) Walker hound, Walker foxhound as an oil painting. ",
784
+ "Figure 12: More images to show Segmentation guidance. In each subfigure, the first image is the segmentation map used to guide the image generation with its caption as its text prompt. "
785
+ ],
786
+ "image_footnote": [],
787
+ "page_idx": 16
788
+ },
789
+ {
790
+ "type": "image",
791
+ "img_path": "images/5df8d9692d2299e1e391bce13b6aaa10182e5aea34c120bd13cf33b1ba3e848e.jpg",
792
+ "image_caption": [],
793
+ "image_footnote": [],
794
+ "page_idx": 17
795
+ },
796
+ {
797
+ "type": "image",
798
+ "img_path": "images/8b606ebc2f55856f888dbd6651558aaaa014553bd9d07e323f21e3247b0a36e1.jpg",
799
+ "image_caption": [
800
+ "(a) Headshot of a person with blonde hair with space background. ",
801
+ "(c) A headshot of a blonde woman as a sketch. ",
802
+ "Figure 13: More images to show Face guidance. In each subfigure, the first image is the human identity used to guide the image generation with its caption as its text prompt. "
803
+ ],
804
+ "image_footnote": [],
805
+ "page_idx": 17
806
+ },
807
+ {
808
+ "type": "text",
809
+ "text": "(b) A headshot of a woman looking like a lara croft. ",
810
+ "page_idx": 17
811
+ },
812
+ {
813
+ "type": "image",
814
+ "img_path": "images/2444dcc7b7364732a1561002e5e203b224aaafa86c84d663e626d6585084a2e8.jpg",
815
+ "image_caption": [
816
+ "(c) An oil painting of a headshot of a woman with a dog. ",
817
+ "Figure 14: More images to show Object Location guidance. In each subfigure, the first image is the object location used to guide the image generation with its caption as its text prompt. "
818
+ ],
819
+ "image_footnote": [],
820
+ "page_idx": 18
821
+ },
822
+ {
823
+ "type": "image",
824
+ "img_path": "images/2d92d60d352460377934f4e487811b0b45028118b6438cf64ca09027fa0fda02.jpg",
825
+ "image_caption": [
826
+ "(a) A colorful photo of an Eiffel Tower. "
827
+ ],
828
+ "image_footnote": [],
829
+ "page_idx": 19
830
+ },
831
+ {
832
+ "type": "image",
833
+ "img_path": "images/8c23bddc7e1f7274f527607fad7aaf45881dcc60f85031f2b7d905aa208b009a.jpg",
834
+ "image_caption": [
835
+ "(c) A fantasy photo of volcanoes. ",
836
+ "Figure 15: More images to show Style Transfer. In each subfigure, the first image is the styling image used to guide the image generation with its caption as its text prompt. "
837
+ ],
838
+ "image_footnote": [],
839
+ "page_idx": 19
840
+ }
841
+ ]
parse/test/pzpWBbnwiJ/pzpWBbnwiJ_model.json ADDED
The diff for this file is too large to render. See raw diff