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 environments. In this paper, we propose StateFlow, a novel LLM-based task-solving paradigm that conceptualizes complex task-solving processes backed by LLMs as state machines. With proper construction of states and definition of state transitions, StateFlow grounds the progress of task-solving, ensuring clear tracking and management of LLMs' responses throughout the task-solving process. Within each state, StateFlow allows execution of a series of actions, involving not only the generation of LLM's responses guided by a specific prompt, but also the utilization of external tools as needed. State transitions are controlled by specific rules or decisions made by the LLM, allowing for a dynamic and adaptive progression through the task's pre-defined StateFlow model. Evaluations on the InterCode SQL and Bash benchmarks show that StateFlow significantly enhances LLMs' efficiency.
翻译:使用大型语言模型(LLMs)处理复杂任务(例如需要一系列操作以及与工具和环境动态交互的任务)已成为显著趋势。本文提出StateFlow——一种基于LLM的新型任务求解范式,将LLM支持的复杂任务求解过程概念化为状态机。通过适当构建状态并定义状态转换,StateFlow为任务求解过程奠定了基础,确保在任务求解全过程中清晰跟踪和管理LLM的响应。在每个状态内,StateFlow允许执行一系列操作,不仅包括特定提示引导下的LLM响应生成,还涉及按需使用外部工具。状态转换由特定规则或LLM的决策控制,从而通过任务预定义的StateFlow模型实现动态自适应的进展。在InterCode SQL和Bash基准上的评估表明,StateFlow显著提升了LLM的效率。