arXiv:2609.02115cs.CLcs.AI2026-09

提出可生成多目标查询的无语言依赖框架,支持零大模型推理且带置信度反馈。

text2ql: Multi-Target Natural Language Querying via a Language-Agnostic Intermediate Representation

论文配图:text2ql: Multi-Target Natural Language Querying via a Language-Agnostic Intermediate Representation
图 1 · 摘自论文原文
  • 用统一中间表示实现跨SQL与GraphQL的自然语言查询生成
  • 零大模型模式下延迟仅3.2毫秒,准确率100%且无解析错误
  • 生成结果附带0.15~0.97置信度评分,适合需要可靠输出的场景

自然语言数据库接口长期受限于三大问题:仅支持关系型SQL、查询时必须依赖大语言模型(LLM)推理、生成查询语义错误时缺乏运行时信号。本文提出text2ql,一个开源Python框架,通过语言无关的中间表示(QueryIR)和可插拔渲染架构解决上述问题。单一七阶段检测流程同时支持SQL与GraphQL目标;零LLM确定性模式在3.2毫秒中位延迟下实现100%执行准确率,且无API成本;所有生成查询均携带0.15~0.97区间的运行时置信度分数,基于加性信号模型计算。在Spider与BIRD基准上随机抽取50个查询样本评估(初步结果;完整评估待计划),基于LLM的模式达到62-70%精确匹配与84-91%执行准确率;确定性模式在全部100个测试案例中实现100%执行准确率且无解析错误。消融研究显示,模式感知提示是主要准确率提升因素,在两个基准上相较无模式基线提升18.4个百分点精确匹配率。text2ql已在PyPI以Apache 2.0许可开源。

原文摘要 · Abstract (English)

Natural language interfaces to databases have traditionally suffered from three structural limitations: exclusive targeting of relational SQL, unconditional dependence on large language model (LLM) inference at query time, and absence of any runtime signal when generated queries are semantically incorrect. This paper presents text2ql, an open-source Python framework that addresses all three limitations through a language-agnostic Intermediate Representation (QueryIR) and a pluggable renderer architecture. A single seven-stage detection pipeline serves both SQL and GraphQL targets; a zero-LLM deterministic mode delivers 100% execution accuracy at a median latency of 3.2 ms with no API cost; and every generated query carries a runtime confidence score in [0.15, 0.97] computed from an additive signal model. Evaluated on 50-query random samples from the Spider and BIRD benchmarks (indicative results; full-set evaluation is planned), the LLM-backed mode achieves 62-70% exact match and 84-91% execution accuracy; the deterministic mode achieves 100% execution accuracy with zero parse errors across all 100 test cases. An ablation study isolates schema-aware prompting as the dominant accuracy lever, contributing +18.4 percentage points of exact-match gain over the schema-free baseline on both benchmarks. text2ql is publicly available at https://pypi.org/project/text2ql/ under the Apache 2.0 license.

自然语言查询SQL生成零推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。