发表机构
Luddy School of Informatics, Computing and Engineering, Indiana University(印第安纳大学卢迪信息学、计算与工程学院)
机构由 AI 辅助整理,请以论文原文为准。AI 中文总结
本研究构建了一个六节点LangGraph智能体,通过提示工程实现文本到SQL,在芝加哥犯罪数据集上达到93%的有效SQL率和60%的执行准确率,验证了无需微调即可端到端弥合非技术用户与数据库之间鸿沟的可行性。
AI 中文摘要
非技术利益相关者通常无法编写从运营数据库中提取见解所需的SQL。我们构建并评估了一个端到端弥合这一差距的文本到SQL智能体:一个六节点的LangGraph StateGraph,用于检查问题相关性、获取实时模式、生成PostgreSQL、通过试运行进行验证、失败时重试、执行查询,并用通俗英语叙述结果集。该智能体仅使用提示工程;未对任何模型进行微调。我们在芝加哥犯罪数据集(约850万条记录,22个属性)上,针对一个手工构建的包含100个自然语言问题及真实SQL的基准进行了评估,该基准按难度分层为30个简单、40个中等和30个困难项。比较同一智能体的两个提示修订版本,修订后的系统(V2)的有效SQL率达到了93%(从87%提升),在混合关系等价指标下的执行准确率为60%(从47%提升;在严格JSON匹配下从12%提升至19%),平均综合质量评分为4.34分(满分5分,从3.91分提升)。最大的单一驱动因素是移除了系统提示中的LIMIT 10指令,该指令此前会截断多行答案。错误分析将残余失败归因于相关性检查器的误拒、模糊的问题语义以及免费层API速率限制,而非语言生成步骤。我们未报告与外部基线系统或公共基准的比较;该研究是一项单模型的工程评估。
英文摘要
Non-technical stakeholders frequently cannot write the SQL needed to extract insights from operational databases. We built and evaluated a Text-to-SQL agent that closes this gap end to end: a six-node LangGraph StateGraph checks question relevance, fetches the live schema, generates PostgreSQL, validates it with a dry run, retries on failure, executes the query, and narrates the result set in plain English. The agent uses prompt engineering only; no model was fine-tuned. We evaluated it on the Chicago Crime dataset (approximately 8.5 million records, 22 attributes) against a hand-built benchmark of 100 natural language questions with ground-truth SQL, stratified into 30 Easy, 40 Medium and 30 Hard items. Comparing two prompt revisions of the same agent, the revised system (V2) reached a Valid SQL Rate of 93% (from 87%), an Execution Accuracy of 60% under a hybrid relational equivalence metric (from 47%; 19% from 12% under strict JSON matching), and a mean Synthesis Quality of 4.34 out of 5 (from 3.91). The single largest driver was removing a LIMIT 10 instruction from the system prompt, which had been truncating multi-row answers. Error analysis attributes the residual failures to relevance-checker false rejections, ambiguous question semantics, and free-tier API rate limits rather than to the language generation step. We report no comparison against an external baseline system or a public benchmark; the study is a single-model engineering evaluation.