SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Ziniu Hu12\*
Ahmet Iscen
Chen Sun
Kai-Wei Chang<sup>1</sup>
Yizhou Sun
David A Ross
Cordelia Schmid2
Alireza Fathi2
<sup>1</sup>University of California, Los Angeles, <sup>2</sup>Google Research
In this paper, we propose an autonomous information seeking visual question answering framework, AVIS. Our method leverages a Large Language Model (LLM) to dynamically strategize the utilization of external tools and to investigate their outputs via tree search, thereby acquiring the indispensable knowledge needed to provide answers to the posed questions. Responding to visual questions that necessitate external knowledge, such as "What event is commemorated by the building depicted in this image?", is a complex task. This task presents a combinatorial search space that demands a sequence of actions, including invoking APIs, analyzing their responses, and making informed decisions. We conduct a user study to collect a variety of instances of human decision-making when faced with this task. This data is then used to design a system comprised of three components: an LLM-powered planner that dynamically determines which tool to use next, an LLM-powered reasoner that analyzes and extracts key information from the tool outputs, and a working memory component that retains the acquired information throughout the process. The collected user behavior serves as a guide for our system in two key ways. First, we create a transition graph by analyzing the sequence of decisions made by users. This graph delineates distinct states and confines the set of actions available at each state. Second, we use examples of user decision-making to provide our LLM-powered planner and reasoner with relevant contextual instances, enhancing their capacity to make informed decisions. We show that AVIS achieves state-of-the-art results on knowledge-intensive visual question answering benchmarks such as Infoseek [7] and OK-VQA [26].
Large language models (LLMs), such as GPT3 [5], LaMDA [16], PALM [9], BLOOM [34] and LLaMA [37], have showcased the capacity to memorize and utilize a significant amount of world knowledge. They demonstrate emerging abilities [38] like in-context learning [5], code generation [19], and common sense reasoning [24]. Recently, there is a growing focus towards adapting LLMs to handle multi-modal inputs and outputs involving both vision and language. Noteworthy examples of such visual language models (VLMs) include GPT4 [29], Flamingo [4] and PALI [6]. They set the state of the art for several tasks, including image captioning, visual question answering, and open vocabulary recognition.
While LLMs excel beyond human capabilities in tasks involving textual information retrieval, the current state of the art VLMs perform inadequately on datasets designed for visual information
*This work was done when Ziniu was an intern at Google.
Figure 1: An example of AVIS's generated workflow for answering a challenging visual question using LLM with tree search to use tools. The input image is taken from the Infoseek dataset.
seeking such as Infoseek [7] and OK-VQA [26]. Many of the visual questions in these datasets are designed in such a way that they pose a challenge even for humans, often requiring the assistance of various APIs and web search to obtain the answer. Examples of such questions include "where is this church located?", "what species of butterfly is this?", or "what is the brand of this dress?"
Current state-of-the-art vision-language models (VLMs) find it challenging to answer such questions for several reasons. Firstly, they are not trained with objectives that encourage them to discern fine-grained categories and details within images. Secondly, they utilize a relatively smaller language model compared to state-of-the-art Large Language Models (LLMs), which constrains their reasoning capabilities. Lastly, they do not compare the query image against a substantial corpus of images associated with varying metadata, unlike systems that employ image search techniques.
To overcome these challenges, we introduce a novel method in this paper that achieves state-of-the-art results on visual information seeking tasks by enabling a LLM Agent use tools via tree-search decision-making. We use three types of tools: (i) computer vision tools such as object detection, OCR, image captioning models, and VQA models, which aid in extracting visual information from the image, (ii) a web search tool that assists in retrieving open world knowledge and facts, and (iii) an image search tool that enables us to glean relevant information from metadata associated with visually similar images. Our approach utilizes an LLM-powered planner to dynamically determine which tool to use at each step and what query to send to it. Furthermore, we employ an LLM-powered reasoner that scrutinizes the output returned by the tools and extracts the crucial information from them. To retain the information throughout the process, we use a working memory component. Figure 1 shows an example information seeking process performed by our method.
Several recent studies [13, 23, 36, 40, 42] have enhanced LLMs with APIs to handle multi-modal vision-language inputs. These systems generally employ a two-stage strategy, namely plan and execute. Initially, the LLM breaks down a question into a plan, typically represented as a structured
program or a sequence of instructions. Following this, the necessary APIs are activated to collect the required information. While this method has shown potential in elementary visual-language tasks, it frequently fails in more complex real-world situations. In such cases, a comprehensive plan cannot be inferred merely from the initial question. Instead, it necessitates dynamic modifications based on real-time feedback.
The primary innovation in our proposed method lies in its dynamic decision-making capability. Answering visual information seeking questions is a highly complex task, requiring the planner to take multiple steps. At each of these steps, the planner must determine which API to call and what query to send. It is unable to predict the output of complex APIs, such as image search, or to anticipate the usefulness of their responses prior to calling them. Therefore, unlike previous methods that pre-plan the steps and API calls at the beginning of the process, we opt for a dynamic approach. We make decisions at each step based on the information acquired from previous API calls, enhancing the adaptability and effectiveness of our method.
We conduct a user study to gather a wide range of instances of human decision-making when using APIs to answer questions related to visual information seeking. From this data, we formulate a structured framework that directs the Large Language Model (LLM) to use these examples for making informed decisions regarding API selection and query formulation. The collected user behavior informs our system in two significant ways. First, by analyzing the sequence of user decisions, we construct a transition graph. This graph delineates distinct states and constrains the set of actions available at each state. Second, we use the examples of user decision-making to guide our planner and reasoner with pertinent contextual instances. These contextual examples contribute to improving the performance and effectiveness of our system.
The primary contributions of this paper can be summarized as follows:
- We propose a novel visual question answering framework that leverages a large language model (LLM) to dynamically strategize the utilization of external tools and to investigate their outputs, thereby acquiring the necessary knowledge needed to provide answers to the posed questions.
- We leverage the human decision-making data collected from a user study to develop a structured framework. This framework guides the Large Language Model (LLM) to utilize examples of human decision-making in making informed choices concerning API selection and query construction.
- Our method achieves state-of-the-art results on knowledge-based visual question answering benchmarks such as Infoseek [7] and OK-VQA [26]. Notably, We achieve an accuracy of  $50.7\%$  on the Infoseek (unseen entity split) dataset which is significantly higher than the results achieved by PALI [6] with accuracy of  $16.0\%$ .
Augmenting LLMs with Tools. Large Language Models(LLMs) have shown impressive language understanding [33], and even reasoning capabilities [39]. Nevertheless, certain limitations of LLMs are evident, due to their intrinsic characteristics. Such limitations include providing up-to-date answers based on external knowledge or performing mathematical reasoning. Consequently, a recent surge of techniques have integrated LLMs with various external tools [27]. For example, TALM [31] and ToolFormer [35] use in-context learning to teach the language model how to better leverage various tools on benchmarks such as question answering and mathematical reasoning.
In the computer vision domain, LLMs also show significant improvements when combined with external visual tools. For example, Visual ChatGPT [40] and MM-ReAct [42] enable LLMs to call various vision foundation models as tools to understand visual inputs, and even better control the image generation. VisProg [13] and ViperGPT [36] explore the decomposition of visual language tasks into programs, where each line corresponds to general code or a visual API. Chameleon [23] uses an LLM as a natural language planner to infer the appropriate sequence of tools to utilize, and then executes these tools to generate the final response.
Most of these previous works follow a plan-then-execute paradigm, i.e., i) they pre-plan the sequence of actions (API calls) that they will take (either hard coded or using code generation); and ii) they execute the generated plan. One drawback of such an approach is that it cannot update and improve
its plan based on the output of the tools it calls. This is not a trivial problem, as it requires to predict the output quality of each tools beforehand. In contrast, our proposed method allows the system to dynamically decide its next steps based on the output it receives from the tools at each step.
Decision Making with LLM as an Agent. There has also been a surge of interest in applying Large Language Models (LLMs) as autonomous agents. These agents are capable of interacting with external environments, making dynamic decisions based on real-time feedback, and consequently achieving specific goals. For example, WebGPT [28] enables an LLM to access real-time information from the web search engines. ReAct [44] further improves external search engine usage via the self-reasoning of LLM in an interleaved manner. Similar ideas have also been adopted for robotic action planning. SayCan [3], for instance, uses LLMs to directly predict robot actions, and PALM-E [10] further fine-tunes LLMs to make better decisions based on instructions and open web media.
When compared to works that follow a plan-then-execute paradigm, these AI agents exhibit increased flexibility, adjusting their actions based on the feedback that they receive. However, many of these methods do not restrict the potential tools that can be invoked at each stage, leading to an immense search space. This becomes particularly critical for web search APIs [1,2] that return extensive result lists and span a combinatorial search space of multiple tools. Consequently, even the most advanced LLMs today can fall into infinite loops or propagate errors. To alleviate this issue, we propose restricting and guiding LLMs to mimic human behavior when solving complex visual questions with APIs. This idea is similar to the AI alignment research [21, 30] that teaches LLMs to follow human instructions. The difference is that our model only uses the human prior at the decision-making stage via prompt guidance, instead of re-training the model.
One concurrent work Tree-Of-Thought (ToT) [43] also utilize tree search guided by a self-critic reward model to find optimal path of problem solving. Compared with this concurrent work, our AVIS further constrains the tree search via a human-defined transition graph, and guide the decision-making via a dynamic prompt manager. In addition, though AVIS is designed for tool-use, the success of ToT shows that such idea can be generally improve many LLM Reasoning tasks.
3.1 General Framework
Our approach employs a dynamic decision-making strategy designed to respond to visual information-seeking queries. Our system is comprised of three primary components. First, we have a planner  $\mathcal{P}$ , whose responsibility is to determine the subsequent action, including the appropriate API call and the query it needs to process. Second, we have a working memory  $\mathcal{M}$  that retains information about the results obtained from API executions. Lastly, we have a reasoner  $\mathcal{R}$ , whose role is to process the outputs from the API calls. It determines whether the obtained information is sufficient to produce the final response, or if additional data retrieval is required.
Figure 2: AVIS employs dynamic decision-making to plan (find optimal tool and query), execute results, and then reason (estimate whether continue or backtrack).
Algorithm 1 Planner  $\mathcal{P}(state, \mathcal{G}, \mathcal{E}, \mathcal{M})$
1:  $\mathcal{A}_s\gets \phi (state,\mathcal{G},\mathcal{M})$ $\triangleright$  Get the list of feasible actions  $\mathcal{A}_s$  given the current state from transition graph and the information in the working memory
2:  $\mathcal{E}_s\gets \theta (\mathcal{E},\mathcal{A}_s)$  ▷ Get a list of in-context examples related to actions  $\mathcal{A}_s$
3:  $p_s \gets \psi(\mathcal{E}_s, \mathcal{M}) \triangleright$  Build a prompt based on the in-context examples  $\mathcal{E}_s$  and the current working memory  $\mathcal{M}$
4:  $t_s, q_s \gets LLM(p_s) \triangleright$  Decide the next tool  $t_s$  to use and the query  $q_s$  to pass by feeding the prompt  $p_s$  to LLM
Figure 3: Transition graph  $\mathcal{G}$  defines feasible actions the planner can take. This graph is induced by our user study introduced in Sec. 3.3.
Algorithm 2 AVIS Decision Making Workflow
1:  $\mathcal{M}\gets \{\text{input}\} ,\text{state}\gets \text{START}$    
2:  $t_s,q_s\gets \mathcal{P}(state,\mathcal{G},\mathcal{E},\mathcal{M})$  ▷Call the planner  $\mathcal{P}$  to decide the next tool to use  $t_s$  and the query to pass to it  $q_{s}$    
3:  $o_s\gets \mathrm{Exec}(t_s,q_s)$  ▷Call tool  $t_s$  with query  $q_{s}$  and get output  $o_{s}$    
4:  $\hat{o}_s\gets \mathcal{R}(o_s,\mathcal{M})$  ▷Process the output and extract the key info  $\hat{o_s}$  using the reasoner  $\mathcal{R}$    
5:  $\mathcal{M}.add(\hat{o}_s)$  ▷Update the working memory   
6: switch  $\hat{o}_s$  do   
7: case  $\hat{o}_s$  is not informative   
8: goto(2) Go to line 2 to make decision at the same state, excluding  $t_s$    
9: case  $\hat{o}_s$  has useful information   
10: state  $\leftarrow t_s$  ▷Update state   
11: goto(2) Go to line 2 to make decision for the next state.   
12: case  $\hat{o}_s$  is ready as final answer   
13: ans  $\leftarrow \hat{o}_s$  ▷Output answer
Considering the potential intricacy of the task, we conduct a user study to gather a broad range of examples of human decision-making process, when using tools to respond to visual information-seeking queries (we introduce the details of data collection in Sec. 3.3). This helps us to establish a structured framework for decision-making. We utilize the data collected from this study to construct a transition graph  $\mathcal{G}$  shown in Figure 3, which outlines all the possible actions at each given state. Additionally, we employ real-life decision-making examples  $\mathcal{E}$ , i.e., users choose which tool at different states, to guide the planner in choosing the appropriate action at each stage of the process.
The Algorithm 1 presents the operations of the planner  $\mathcal{P}$ . The planner undertakes a series of steps each time a decision is required regarding which tool to employ and what query to send to it. Firstly, based on the present state, the planner provides a range of potential subsequent actions  $\mathcal{A}_s$ . The potential action space  $\mathcal{A}_s$  may be large, making the search space intractable. To address this issue, the planner refers to the human decisions from the transition graph  $\mathcal{G}$  to eliminate irrelevant actions. The planner also excludes the actions that have already been taken before and are stored in the working memory  $\mathcal{M}$ . Formally, this procedure is  $\mathcal{A}_s \gets \phi(state, \mathcal{G}, \mathcal{M})$ .
Next, it collects a set of relevant in-context examples  $\mathcal{E}_s$  that are assembled from the decisions previously made by humans during the user study relevant to actions  $\mathcal{A}_s$ , that is  $\mathcal{E}_s \gets \theta(\mathcal{E}, \mathcal{A}_s)$ . With the gathered in-context examples  $\mathcal{E}_s$  and the working memory  $\mathcal{M}$  that holds data collected from past tool interactions, the planner formulates a prompt, denoted by  $p_s \gets \psi(\mathcal{E}_s, \mathcal{M})$ . The prompt  $p_s$  is then sent to the LLM which returns a structured answer, determining the next tool  $t_s$  to be activated and the query  $q_s$  to be dispatched to it. We denote this action by  $t_s, q_s \gets LLM(p_s)$ . This design allows the planner to be invoked multiple times throughout the process, thereby facilitating dynamic decision-making that gradually leads to answering the input query.
The Algorithm 2 shows the overall decision-making workflow of AVIS. The entire process repeats until a satisfactory answer is produced. Initially, the working memory is populated only with the input visual question  $I$ , and the initial state is set to START. At each iteration, we first invoke the planner  $\mathcal{P}$  to determine the next tool and the query to employ, as outlined in Algorithm 1. Subsequently, the selected external tool executes and delivers its output  $o_s$ . The output from the tools can be quite diverse, ranging from a list of identified objects, to a collection of similar images with their captions, to snippets of search results or knowledge graph entities.
Therefore, we employ a reasoner  $\mathcal{R}$  to analyze the output  $o_s$ , extract the useful information and decide into which category the tool output falls: informative, uninformative, or final answer. Our method utilizes the LLM with appropriate prompting and in-context examples to perform the reasoning. If the reasoner concludes that it's ready to provide an answer, it will output the final response, thus concluding the task. If it determines that the tool output is uninformative, it will revert back to the
planner to select another action based on the current state. If it finds the tool output to be useful, it will modify the state and transfer control back to the planner to make a new decision at the new state.
Our approach, which employs dynamic decision-making coupled with backtracking, differs from previous methods [23, 36] that follow a plan-then-execute paradigm. Our system is structured to make decisions grounded to the results of current executions and to conduct iterative searches for tool combinations. This process eventually yields the most effective strategy to accomplish the task.
3.2 Tools and their APIs
To respond effectively to visual queries that necessitate in-depth information retrieval, it's important to equip AVIS with a comprehensive suite of tools. In this section, we describe these tools.
Image Captioning Model: We employ the PALI 17B [8] captioning model, which obtains state-of-the-art results for image captioning. This tool has the capability to generate captions for either the entire image or for a cropped image corresponding to the bounding box of a detected object.
Visual Question Answering Model: We utilize the PALI 17B [8] VQA model, which has been fine-tuned on the VQA-v2 [11] dataset. This tool takes an image and a question as inputs and provides a text-based answer as the output.
Object Detection: We use an object detector trained on a super-set of Open Images dataset [17] categories that is provided by Google Lens API [1]. We use high confidence threshold to only keep the top-ranked detected boxes for the input image.
Image Search: We utilize Google Image Search to obtain a broad range of information related to the image crop of a detected box as provided in Google Lens API [1]. This information encompasses various details, such as knowledge graph entities, titles of associated products, and captions of analogous or identical images. The availability of these details can vary based on the image crop input provided to Google Image Search. When it comes to decision-making, our planner considers the utilization of each piece of information as a separate action. This is due to the fact that each information could contain hundreds of tokens that necessitate complex processing and reasoning.
OCR: In some cases, images may include textual content such as street names or logos. To detect and utilize this text, we take advantage of the Optical Character Recognition (OCR) feature available in the Google Lens API [1].
Web Search: Web search enables our approach to acquire up-to-date world knowledge and retrieve relevant documents on any topic of interest. For this objective, we employ the Google Web Search API [2]. It accepts a text-based query as input and produces the following outputs: (i) related document links and snippets, (ii) in certain instances, a knowledge panel providing a direct answer to the query, and (iii) up to five questions that are related to the input query. If a knowledge panel is available, we parse it into a sentence or a few sentences that summarize its information.
LLM short QA: We incorporate a Language Model (LLM) powered question-answering component as another tool. This tool accepts a query in text form and produces an answer also in text form. It is important to note that the use of the LLM here as a question-answering tool is distinct from its role in the planner or reasoner as outlined in Alg. 1 and Alg. 2.
3.3 Gathering User Behavior to Inform LLM Decision Making
Many of the visual questions in datasets such as Infoseek [7], Oven [14] and OK-VQA [26] ask for fine-grained answers, which poses a challenge even for humans, often requiring the assistance of various APIs and web searches for answers. Figure 4(a) illustrates an example visual question taken from the OK-VQA [26] dataset. In order to gather insights into human decision-making process, we carried out a user study. More specifically, our goal is to understand how humans utilize external tools to answer visual queries that involve seeking information.
The user is equipped with an identical set of tools as our method. They are presented with the input image and question, along with image crops for each detected object. Additionally, tools like PALI Caption, PALI VQA, PALM, and Web Search are made available to the user. Furthermore, based on the information obtained through image search for each cropped image, the user is offered one or multiple buttons associated with each box. These buttons provide the user with the ability
Question: In what year was this motorcycle built?
PALI Caption
PALI VQA Query
PALIVQA
Search Query:
Search
PALM Query:
PALM
Box 1
Show entity of box 1
Show caption of images similar to box 1
Show entity of box 2
Show related products to the object in box 2
Show caption of images similar to box 2
Show caption of identical images to box 2
Show entity of box 3
Useless API call
Success! Found the Answer!
Could't find the Answer!
(c) Tool Output
Box 2
(a) Input visual question and detected objects
Figure 4: We conduct a user study to gather examples of user decision-making when responding to visual information-seeking questions. Given a visual question as depicted in (a), the user makes a series of tool calls using the available APIs shown in (b). Each tool call yields an output which the user reviews whether it is useful and determines the subsequent action, illustrated in (c).