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.
翻译:尽管大型语言模型(LLMs)在生成SQL查询方面展现出卓越能力,但其本质上缺乏无需执行预言机即可自我评估正确性的能力。这一限制导致了显著的生成-选择鸿沟:高潜在准确率(Pass@K)无法转化为执行准确率(Pass@1)。虽然监督验证器可提供缓解方案,但其需要高昂的标注成本且存在领域脆弱性。因此,近期研究转向了免训练设置。然而,现有方法——如自一致性或LLM-as-a-Judge——仍受制于系统性偏差(对幻觉的共识)与符号盲区(无法模拟执行状态)。我们提出DPC(双范式一致性),该多智能体框架将SQL选择从对隐藏数据的概率猜测任务重构为对可见数据的确定性验证任务。具体而言,DPC采用SLICER与TESTER两个智能体协作构建最小区分数据库(MDD)——一种对抗性、完全可观测的微环境,旨在暴露候选SQL间的逻辑差异。为打破自我修正偏差,SOLVER智能体通过交叉比对SQL与并行Python/Pandas解决方案的执行结果来验证候选SQL。通过验证声明式(SQL)与命令式(Python)范式间的执行一致性,DPC能稳健区分正确逻辑与系统性幻觉。在BIRD和Spider数据集上基于多种LLMs的实验表明,我们的方法持续优于现有选择基线,相较于自一致性等强基线方法实现了高达2.2%的绝对准确率提升。