StateFlow: Enhancing LLM Task-Solving through State-Driven Workflows

Yiran Wu,Tianwei Yue,Shaokun Zhang,Chi Wang,Qingyun Wu
2024-09-15
Abstract:It is a notable trend to use Large Language Models (LLMs) to tackle complex tasks, e.g., tasks that require a sequence of actions and dynamic interaction with tools and external environments. In this paper, we propose StateFlow, a novel LLM-based task-solving paradigm that conceptualizes complex task-solving processes as state machines. In StateFlow, we distinguish between "process grounding" (via state and state transitions) and "sub-task solving" (through actions within a state), enhancing control and interpretability of the task-solving procedure. A state represents the status of a running process. The transitions between states are controlled by heuristic rules or decisions made by the LLM, allowing for a dynamic and adaptive progression. Upon entering a state, a series of actions is executed, involving not only calling LLMs guided by different prompts, but also the utilization of external tools as needed. Our results show that StateFlow significantly enhances LLMs' efficiency. For instance, StateFlow achieves 13% and 28% higher success rates compared to ReAct in InterCode SQL and ALFWorld benchmark, with 5x and 3x less cost respectively. We also show that StateFlow can be combined with iterative refining methods like Reflexion to further improve performance.
Computation and Language,Artificial Intelligence
What problem does this paper attempt to address?
The problem that this paper attempts to solve is how to improve the control precision and efficiency of large - language models (LLMs) when solving complex tasks. Specifically, the author proposes a new framework named StateFlow, which achieves this goal by modeling the workflow of the LLM as a state machine. This method aims to enhance the control over the task - solving process and improve the ability of the LLM to interact dynamically with external tools and the environment. The paper mentions that although the traditional single - prompt method can guide the model to solve problems according to a certain procedure, it is difficult to reliably track the state judgment of the model and its subsequent action trajectory. Therefore, StateFlow enhances the controllability and interpretability of the task - solving process by clearly distinguishing between "process positioning" (through states and state transitions) and "sub - task solving" (through actions within states). Experimental results show that StateFlow significantly improves the success rate of the LLM in the InterCode SQL and ALFWorld benchmark tests and reduces the cost.