While Large Language Models (LLMs) demonstrate impressive proficiency in generating SQL queries, they fundamentally lack the capability to self-evaluate correctness without an execution oracle. This limitation creates a stark Generation-Selection Gap, where high potential accuracy (Pass@K) fails to translate into execution accuracy (Pass@1). Although supervised verifiers offer mitigation, they incur prohibitive annotation costs and suffer from domain fragility. Consequently, recent research has pivoted to the training-free setting. However, existing methods--such as Self-Consistency or LLM-as-a-Judge--remain hampered by systematic bias (consensus on hallucinations) and symbolic blindness (inability to simulate execution states). We introduce DPC (Dual-Paradigm Consistency), a multi-agent framework that reformulates SQL selection from a probabilistic guessing task on hidden data into a deterministic verification task on visible data. Specifically, DPC employs a SLICER and a TESTER agent to collaboratively construct a Minimal Distinguishing Database (MDD)--an adversarial, fully observable micro-environment engineered to expose logical discrepancies between candidates. To break the self-correction bias, a SOLVER agent then verifies the SQL candidates by cross-referencing their execution against a parallel Python/Pandas solution. By validating execution consistency between declarative (SQL) and imperative (Python) paradigms, DPC robustly discriminates correct logic from systematic hallucinations. Experiments on BIRD and Spider across multiple LLMs demonstrate that our method consistently outperforms existing selection baselines, achieving absolute accuracy improvements of up to 2.2% over strong competitors like Self-Consistency.
翻译:尽管大型语言模型在生成SQL查询方面展现出卓越的能力,但它们本质上缺乏在没有执行环境的情况下自我评估正确性的能力。这一局限导致了显著的"生成-选择差距"——高潜在准确率(Pass@K)无法转化为实际执行准确率(Pass@1)。虽然监督验证器提供了缓解方案,但需要高昂的标注成本且存在领域脆弱性。因此,近期研究转向了免训练设置。然而,现有方法(如自一致性或语言模型即评判者)仍受困于系统性偏差(对幻觉的一致认同)和符号盲目性(无法模拟执行状态)。我们提出DPC(双范式一致性)——一种多智能体框架,将SQL选择从基于隐藏数据的概率性猜测任务重构为基于可见数据的确定性验证任务。具体而言,DPC采用切片器(SLICER)和测试器(TESTER)智能体协同构建最小判别数据库——一个对抗性的、完全可观测的微型环境,旨在暴露候选SQL之间的逻辑差异。为打破自我纠正偏差,求解器(SOLVER)智能体通过将SQL候选的执行结果与并行实现的Python/Pandas解决方案进行交叉验证,验证其执行一致性。通过验证声明式(SQL)与命令式(Python)范式间的执行一致性,DPC能稳健地区分正确逻辑与系统性幻觉。在BIRD和Spider数据集上基于多种大型语言模型的实验表明,我们的方法持续优于现有选择基线,相较于自一致性等强竞争方法实现了最高2.2%的绝对准确率提升。