arXiv:2509.00272cs.AIcs.SE2025-09被引 2

用状态机框架让大模型按专家经验做事,提升复杂任务表现

SHERPA: A Model-Driven Framework for Large Language Model Execution

  • 用分层状态机显式注入领域最佳实践,控制大模型执行流程
  • 在代码生成、问答等任务上显著提升输出质量,尤其适合有经验但无数据的场景
  • 适合作为复杂任务的系统级框架,对研究者和工程落地者都有价值

大语言模型(LLMs)虽广泛应用,但在需要领域专业知识的复杂任务中缺乏结构化推理能力,而这些知识往往未出现在训练数据中。尽管链式思维、树状思维等多步提示方法流行,却缺乏通用行为控制机制。本文提出SHERPA——一种模型驱动的框架,通过将领域最佳实践融入分层状态机,结构化地管理大模型的执行过程。状态机以规则或机器学习驱动的决策实现细粒度控制,支持多种大模型。实验表明,该框架可有效应用于代码生成、类名生成和问答任务,优于基线方法。系统性评估显示,设计良好的状态机能显著提升输出质量,尤其在具有成熟人类经验但缺乏训练数据的任务中优势明显。

原文摘要 · Abstract (English)

Recently, large language models (LLMs) have achieved widespread application across various fields. Despite their impressive capabilities, LLMs suffer from a lack of structured reasoning ability, particularly for complex tasks requiring domain-specific best practices, which are often unavailable in the training data. Although multi-step prompting methods incorporating human best practices, such as chain-of-thought and tree-of-thought, have gained popularity, they lack a general mechanism to control LLM behavior. In this paper, we propose SHERPA, a model-driven framework to improve the LLM performance on complex tasks by explicitly incorporating domain-specific best practices into hierarchical state machines. By structuring the LLM execution processes using state machines, SHERPA enables more fine-grained control over their behavior via rules or decisions driven by machine learning-based approaches, including LLMs. We show that SHERPA is applicable to a wide variety of tasks-specifically, code generation, class name generation, and question answering-replicating previously proposed approaches while further improving the performance. We demonstrate the effectiveness of SHERPA for the aforementioned tasks using various LLMs. Our systematic evaluation compares different state machine configurations against baseline approaches without state machines. Results show that integrating well-designed state machines significantly improves the quality of LLM outputs, and is particularly beneficial for complex tasks with well-established human best practices but lacking data used for training LLMs.

大模型推理状态机任务优化专家知识

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。