arXiv:2601.15709cs.AIcs.DB2026-01被引 13

用可解释的语义记忆提升智能体文本转SQL的效率与准确性

AgentSM: Semantic Memory for Agentic Text-to-SQL

  • 构建结构化语义记忆,复用过往推理路径
  • 在Spider 2.0上减少25%令牌使用量,35%推理轨迹长度
  • 适合需要处理复杂数据库的企业级应用

基于大语言模型的文本转SQL系统在BIRD和Spider等公开基准上取得了显著进展,但在企业级复杂场景下仍面临挑战:大规模复杂模式、多样化的SQL方言以及高成本的多步推理。现有代理方法虽具自适应推理潜力,但存在效率低、不稳定等问题,如重复访问数据库、输出不一致,甚至无法生成有效答案。为此,我们提出代理语义记忆(AgentSM),一种面向文本转SQL的代理框架,通过捕获或合成历史执行轨迹,构建可解释的结构化程序作为语义记忆,直接指导未来推理。该设计实现了推理路径的系统性复用,使代理能高效可靠地应对更大模式、更复杂问题和更长推理序列。相比当前最优系统,AgentSM在Spider 2.0基准上平均令牌使用量减少25%,轨迹长度降低35%;同时在Spider 2.0 Lite上达到44.8%的最高执行准确率。

原文摘要 · Abstract (English)

Recent advances in LLM-based Text-to-SQL have achieved remarkable gains on public benchmarks such as BIRD and Spider. Yet, these systems struggle to scale in realistic enterprise settings with large, complex schemas, diverse SQL dialects, and expensive multi-step reasoning. Emerging agentic approaches show potential for adaptive reasoning but often suffer from inefficiency and instability-repeating interactions with databases, producing inconsistent outputs, and occasionally failing to generate valid answers. To address these challenges, we introduce Agent Semantic Memory (AgentSM), an agentic framework for Text-to-SQL that builds and leverages interpretable semantic memory. Instead of relying on raw scratchpads or vector retrieval, AgentSM captures prior execution traces-or synthesizes curated ones-as structured programs that directly guide future reasoning. This design enables systematic reuse of reasoning paths, which allows agents to scale to larger schemas, more complex questions, and longer trajectories efficiently and reliably. Compared to state-of-the-art systems, AgentSM achieves higher efficiency by reducing average token usage and trajectory length by 25% and 35%, respectively, on the Spider 2.0 benchmark. It also improves execution accuracy, reaching a state-of-the-art accuracy of 44.8% on the Spider 2.0 Lite benchmark.

文本转SQL智能体语义记忆大模型应用

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