# The Impact of Prompting Techniques on the Security of the LLMs and the Systems to Which They Belong
## 2 Domain Overview
### ReAct: Synergizing Reasoning and Acting in Language Models  
All of the papers we discussed so far were focused on enhancing the performance of LLMs on specific tasks. Unfortunately, often, the LLMs suffer from issues like fact hallucination and error propagation, because they lack access to the external world and cannot update their knowledge. \"ReAct: Synergizing reasoning and acting in language models\" [4] is a framework where the LLM can create reasoning tracks and task-specific actions in an interwoven manner. This way, a better synergy between the two is created. Our LM can now reason and dynamically adapt the action plan as well as properly understand and handle exceptions. Actions allow interaction with external resources, allowing the model to gather additional information. Figure 6: An example from the PaL paper [3] which shows a prompt used in the object counting task together with its corresponding question. The authors expect the model to convert the input into a dictionary that stores as keys the valid entities’ names and as values their corresponding quantity. The result should be the the sum of the dictionary values. The authors examine a scenario in which an agent, based on a large language model, is required to engage with an environment to accomplish a specific task. They provide a formal description of the entire process as follows: At time step t, the agent obtains an observation \(o_{t}\in O\) from the environment and takes an action \(a_{t}\in A\) following some policy \(\pi(a_{t}|c_{t})\), where \(c_{t}=(o1,a1,...,o_{t-1},a_{t-1},o_{t})\) is the context to the agent. Adapting to a policy can be particularly challenging when the mapping \(c_{t}\mapsto a_{t}\) is implicit and computationally demanding. For instance, the agent depicted in Figure 7(1c) fails to complete the QA task correctly due to its inability to perform complex reasoning over the provided context (Question, Act 1-3, Obs 1-3). Similarly, the agent in Figure 7(2a) misinterprets the context and ends up hallucinating, incorrectly believing that sink basin 1 contains pepper shaker 1. To fix that, the ReAct authors present a simple idea. They create an augmented action space uniting the \(A\) (action space) and \(L\) (language space), creating \(\hat{A}=A\cup L\). The authors refer to actions from the language space as \"thoughts\" or \"reasoning trace\". These do not affect the external environment but rather gather useful information from the current context and update it to enhance future reasoning or acting. Figure 7 demonstrates that these thoughts can take various forms, such as breaking down the task's goal and devising action plans (2b, Act 1; 1d, Thought 1), incorporating commonsense knowledge relevant to solving the task (2b, Act 1), handling unexpected situations and updating previously created action plans (1d, Thought 3), and more. The primary challenge with this approach appears to be that the space \(L\) is infinite, and learning it is a complex task that requires strong language priors. Figure 7: Example of a comparison of 4 prompting methods from the paper [4]. **(1a)** Standard, **(1b)** Chain-of-thought (CoT, Reason Only), **(1c)** Act-only, and **(1d)** ReAct (Reason + Act), solving a HotpotQA [24] question. (2) Comparison of **(2a)** Act-only and **(2b)** ReAct prompting to solve an AlfWorld [25] game. ReAct's performance on \"Knowledge-Intensive Reasoning Tasks\" is tested using two datasets, HotPotQA [24] and FEAVER [26], as domains, and the action space consists of a Wikipedia web API with three types of actions that support interactive information retrieval:  
* Search[entity];
* Lookup[string];
* Finish[answer]. Wanting to simulate the human, these actions are implemented such that they fetch a small part of an excerpt based on its name. This forces the LLMs to retrieve using clear language thinking.