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

**Authors:** Yiran Wu, Tianwei Yue, Shaokun Zhang, Chi Wang, Qingyun Wu  
**arXiv:** [2403.11322](https://arxiv.org/abs/2403.11322)  
**Date:** 2024-03-17  
**Summary page:** https://www.summarizepaper.com/en/paper/2403.11322v3/

## Key points

- Large Language Models (LLMs) are being used for complex task-solving involving sequences of actions and interactions with tools and environments.
- StateFlow is a novel paradigm introduced to conceptualize task-solving processes as state machines, enhancing control and interpretability.
- In StateFlow, states represent ongoing process status with transitions guided by heuristic rules or LLM decisions, leading to efficient task-solving.
- Implementing StateFlow has shown significant improvements in efficiency, achieving higher success rates in tasks like InterCode SQL and ALFWorld benchmarks with reduced costs.
- Combining StateFlow with iterative refining methods like Reflexion further enhances performance.
- Detailed guidelines on constructing models using the StateFlow framework are provided, along with a case study illustrating the building process.
- Three different tasks demonstrate the effectiveness and efficiency of StateFlow, showcasing performance improvements and cost reductions.
- An ablation study offers insights into how different states contribute to StateFlow's performance.

## Summary

, , , , 

In the realm of utilizing Large Language Models (LLMs) for complex task-solving, a notable trend has emerged. These tasks often involve a sequence of actions and dynamic interactions with tools and external environments. Addressing this challenge, a novel paradigm called StateFlow has been introduced in this paper. StateFlow conceptualizes complex task-solving processes as state machines, distinguishing between "process grounding" through states and transitions, and "sub-task solving" via actions within each state. This approach enhances control and interpretability of the task-solving procedure. In StateFlow, a state represents the status of an ongoing process, with transitions between states guided by heuristic rules or decisions made by the LLM. This dynamic and adaptive progression allows for efficient task-solving. Upon entering a state, a series of actions is executed, involving not only calling LLMs based on different prompts but also utilizing external tools as necessary. Results from implementing StateFlow show significant improvements in efficiency compared to existing methods. For instance, StateFlow achieves higher success rates in tasks like InterCode SQL and ALFWorld benchmarks with significantly reduced costs. Furthermore, combining StateFlow with iterative refining methods such as Reflexion further enhances performance. The paper provides detailed guidelines on constructing models using the StateFlow framework and illustrates the building process through a case study. Additionally, three different tasks are used to demonstrate the effectiveness and efficiency of StateFlow, showcasing performance improvements and cost reductions. An ablation study offers deeper insights into how different states contribute to StateFlow's performance. Furthermore, the background section introduces finite-state machines as the basis for formulating the framework. The model is based on transducer finite-state machines rather than acceptors to determine actions to be performed between states effectively. Overall, this refined summary highlights how StateFlow revolutionizes LLM-based task-solving through its state-driven workflows, offering enhanced efficiency and control in tackling complex tasks.
