用智能代理提升自然语言转SQL的准确率,让普通人也能轻松查询时空数据。
From Queries to Insights: Agentic LLM Pipelines for Spatio-Temporal Text-to-SQL
- 设计智能代理分步规划、分解并优化用户查询,结合数据库结构与可视化反馈。
- 在纽约和东京签到数据集上,准确率达91.4%,远超基础模型的28.6%。
- 适合无编程基础或不懂数据库的人使用,提升人机交互自然性。
自然语言转SQL(NL-to-SQL)系统有望降低结构化数据访问门槛,使用户无需掌握SQL即可查询数据库。然而现有系统在真实场景下的时空查询中表现不佳,需应对模糊表述与模式特定分类对齐、时间推理及输出选择等挑战。本文提出一种基于Mistral ReAct代理的智能代理流水线,扩展了基础模型llama-3-sqlcoder-8b,通过模式检查、SQL生成、执行与可视化工具实现查询规划、分解与自适应。我们在包含空间、时间及多数据集推理的35个自然语言查询上进行评估,覆盖纽约和东京签到数据集。代理系统准确率达到91.4%,显著优于基线模型的28.6%。同时,通过地图、图表和结构化自然语言摘要增强可用性。关键发现是,智能代理编排比单纯强化SQL生成器更适合作为交互式地理空间助手的基础。
原文摘要 · Abstract (English)
Natural-language-to-SQL (NL-to-SQL) systems hold promise for democratizing access to structured data, allowing users to query databases without learning SQL. Yet existing systems struggle with realistic spatio-temporal queries, where success requires aligning vague user phrasing with schema-specific categories, handling temporal reasoning, and choosing appropriate outputs. We present an agentic pipeline that extends a naive text-to-SQL baseline (llama-3-sqlcoder-8b) with orchestration by a Mistral-based ReAct agent. The agent can plan, decompose, and adapt queries through schema inspection, SQL generation, execution, and visualization tools. We evaluate on 35 natural-language queries over the NYC and Tokyo check-in dataset, covering spatial, temporal, and multi-dataset reasoning. The agent achieves substantially higher accuracy than the naive baseline 91.4% vs. 28.6% and enhances usability through maps, plots, and structured natural-language summaries. Crucially, our design enables more natural human-database interaction, supporting users who lack SQL expertise, detailed schema knowledge, or prompting skill. We conclude that agentic orchestration, rather than stronger SQL generators alone, is a promising foundation for interactive geospatial assistants.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。