Search papers, labs, and topics across Lattice.
This paper introduces text2ql, an open-source framework that overcomes the limitations of traditional natural language interfaces to databases by employing a language-agnostic Intermediate Representation (QueryIR) and a flexible renderer architecture. The framework achieves 100% execution accuracy in a zero-LLM deterministic mode with a median latency of 3.2 ms, while the LLM-backed mode demonstrates significant performance with 62-70% exact match and 84-91% execution accuracy on benchmark queries. An ablation study reveals that schema-aware prompting significantly enhances accuracy, providing an 18.4 percentage point improvement over schema-free approaches.
Achieving 100% execution accuracy without LLMs, text2ql redefines the efficiency of natural language querying for databases.
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.