arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.15728cs.AIcs.SE
收藏

对文本到Python与文本到SQL的基准测试:显式逻辑和歧义的影响

Benchmarking Text-to-Python against Text-to-SQL: The Impact of Explicit Logic and Ambiguity

Zhejiang University of Technology(浙江工业大学);University of Aberdeen(阿伯丁大学)

Hangle Hu, Chenyu Hou, Bin Cao, Ruizhe Li

AI总结:

本文提出BIRD-Python基准测试,通过逻辑完成框架解决文本到Python与SQL的性能差异问题,证明Python在分析代理中的可行性。

摘要:

尽管文本到SQL仍然是数据库交互的主要方法,现实世界中的分析越来越多地需要通用编程语言如Python或Pandas的灵活性,以管理基于文件的数据和复杂的分析工作流程。尽管这种需求日益增长,但文本到Python在核心数据检索中的可靠性相对于成熟的SQL生态系统仍处于探索阶段。为了解决这一差距,我们引入了BIRD-Python,一个用于跨范式评估的基准测试。我们系统地优化了原始数据集以减少标注噪声并对齐执行语义,从而建立了一致且标准化的比较基础。我们的分析揭示了一个根本的范式差异:虽然SQL通过其声明性结构利用隐式数据库管理系统行为,而Python需要显式的程序逻辑,使其对未明确指定的用户意图高度敏感。为缓解这一挑战,我们提出了逻辑完成框架(LCF),它通过在生成过程中整合潜在领域知识来解决歧义。实验结果表明,(1)性能差异主要源于缺失的领域上下文,而不是代码生成本身的固有限制,(2)当这些差距得到解决时,文本到Python在性能上与文本到SQL持平。这些发现确立了Python作为分析代理的基础——前提是系统能够有效地将歧义的自然语言输入转换为可执行的逻辑规范。资源可在https://anonymous.4open.science/r/Bird-Python-43B7/上获得。

英文摘要:

While Text-to-SQL remains the dominant approach for database interaction, real-world analytics increasingly require the flexibility of general-purpose programming languages such as Python or Pandas to manage file-based data and complex analytical workflows. Despite this growing need, the reliability of Text-to-Python in core data retrieval remains underexplored relative to the mature SQL ecosystem. To address this gap, we introduce BIRD-Python, a benchmark designed for cross-paradigm evaluation. We systematically refined the original dataset to reduce annotation noise and align execution semantics, thereby establishing a consistent and standardized baseline for comparison. Our analysis reveals a fundamental paradigmatic divergence: whereas SQL leverages implicit DBMS behaviors through its declarative structure, Python requires explicit procedural logic, making it highly sensitive to underspecified user intent. To mitigate this challenge, we propose the Logic Completion Framework (LCF), which resolves ambiguity by incorporating latent domain knowledge into the generation process. Experimental results show that (1) performance differences primarily stem from missing domain context rather than inherent limitations in code generation, and (2) when these gaps are addressed, Text-to-Python achieves performance parity with Text-to-SQL. These findings establish Python as a viable foundation for analytical agents-provided that systems effectively ground ambiguous natural language inputs in executable logical specifications. Resources are available at https://anonymous.4open.science/r/Bird-Python-43B7/.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑