LuthorSQL: A One-Pass Text-to-SQL Model as System 1 for a Slower LLM Agent
Problem Statement
Tool-using frontier LLM agents are among the most accurate text-to-SQL systems, but they are slow and expensive per query. The abstract estimates over $70K/year for 10K queries/day with a Claude Opus 5.5 agent at list price. They also send sensitive organizational queries to external APIs. The paper asks how much of this workload can run on hardware an organization already owns. It also asks whether public benchmark results for frontier models are inflated by contamination.
Key Novelty
- A non-autoregressive text-to-SQL architecture that runs one forward pass to predict slot scores over a bounded query-plan grammar, then compiles and executes up to 32 candidate plans and picks one with a trained validator.
- A pre-registered confidence cascade that pairs the local model (System 1) with a frontier LLM agent (System 2) and escalates only uncertain queries, tested on databases published after the frontier model's training cutoff.
- Contamination probing showing that Opus reproduces 48–92% of public benchmark gold SQL verbatim without seeing the schema, with robustness checks on renamed schemas and post-cutoff databases.
- Zero-shot dialect transfer from SQLite to Snowflake, BigQuery, MySQL, PostgreSQL and DuckDB, made possible by compiling a dialect-agnostic plan representation.
Evaluation Highlights
- 68.03% execution accuracy on BIRD's hidden test set at 0.84 s per question on a single GPU.
- Accuracy is maintained with 8-bit quantized weights in about 9 GB of memory.
- Zero-shot transfer to five other SQL dialects stays within 3.1 points of native SQLite accuracy.
- In a cascade with Claude Opus 5.5 over 227 post-cutoff questions, LuthorSQL answers nearly half locally and cuts API cost by 33.3% at the same accuracy.
- Opus agent accuracy holds on renamed schemas and reaches 95.6–97.4% on post-cutoff databases, despite verbatim reproduction of 48–92% of public gold queries.
Signal Assessment
Methodology
- Define a bounded grammar over SQL query plans so that generation becomes predicting slot scores rather than decoding tokens one at a time.
- Run the 7B model in a single non-autoregressive forward pass over the question and schema to score all grammar slots.
- Enumerate and compile up to 32 top candidate plans into concrete SQL for the target dialect, then execute them against the database.
- Use a trained validator to choose the final answer from the executed candidates and to produce a confidence estimate.
- In deployment, apply a pre-registered confidence threshold: answer locally when confident, otherwise escalate to the frontier LLM agent with database tools.
- Evaluate on BIRD's hidden test set, on cross-dialect transfer and on post-cutoff databases.
- Probe the frontier model for contamination using schema-free gold reproduction and renamed-schema tests.
System Components
A constrained, structured representation of SQL query plans with discrete slots. It makes one-pass prediction feasible and enables compilation into multiple dialects.
Predicts scores for all grammar slots in a single forward pass, giving sub-second latency on one GPU.
Converts the top-scoring slot combinations (up to 32) into executable SQL for the target dialect and runs them to get results.
Scores executed candidates to select the final answer and provides the confidence signal used for escalation.
A pre-registered routing policy that keeps confident queries local and escalates uncertain ones to a frontier LLM agent such as Claude Opus 5.5.
Tests whether the frontier model reproduces benchmark gold SQL without the schema, and checks robustness via renamed schemas and post-cutoff databases.
Results
| Metric/Benchmark | Baseline | This Paper | Delta |
|---|---|---|---|
| BIRD hidden test execution accuracy | Frontier LLM agents (described as among the most accurate; no number given) | 68.03% (LuthorSQL standalone) | Not reported in abstract |
| Latency per question | Hosted frontier agent (described as slow; no number given) | 0.84 s on a single GPU | Faster (magnitude not quantified) |
| Memory footprint | Full-precision 7B weights | ~9 GB at 8-bit, accuracy maintained | Fits commodity GPUs |
| Cross-dialect transfer (Snowflake, BigQuery, MySQL, PostgreSQL, DuckDB) | Native SQLite accuracy | Within 3.1 points of SQLite | ≤ -3.1 pts, zero-shot |
| Queries answered locally in cascade (227 post-cutoff questions) | 0% (Opus-only) | ~50% | Roughly half offloaded |
| API cost in cascade at equal accuracy | Opus 5.5 agent alone (>$70K/yr at 10K queries/day) | 33.3% lower | -33.3% cost |
| Opus verbatim gold-SQL reproduction without schema | N/A | 48–92% on public benchmarks | Evidence of contamination |
| Opus tool-assisted accuracy on post-cutoff DBs | Public-benchmark accuracy (potentially contaminated) | 95.6–97.4% | Holds on renamed and post-cutoff schemas |
Key Takeaways
- Fast-model-plus-escalation cascades are a practical way to cut frontier API spend for enterprise text-to-SQL. About half of queries can stay on-prem, which also reduces exposure of sensitive data.
- Structured, non-autoregressive prediction over a bounded plan grammar, combined with execution-guided candidate selection and a learned validator, gives competitive accuracy at sub-second latency. It also yields a natural confidence signal for routing.
- Compiling a dialect-agnostic plan representation enables near-lossless zero-shot transfer across warehouses such as Snowflake, BigQuery and Postgres, which matters for heterogeneous enterprise stacks.
- 8-bit quantization of the 7B model keeps accuracy in about 9 GB, so it can be deployed on modest existing hardware.
- Public text-to-SQL benchmarks such as BIRD are likely contaminated for frontier models. Evaluate on post-cutoff or renamed-schema databases and pre-register routing thresholds to get trustworthy accuracy estimates.
Abstract
Frontier LLM agents that query databases with tools are among the most accurate text-to-SQL systems, but per-query calls to a hosted model are slow, costly, and expose sensitive organizational queries to external APIs. For example, a Claude Opus 5.5 agent serving 10,000 queries a day costs over $70,000 a year at list price. To what extent can local hardware already owned by an organization offload this burden without compromising the agent's accuracy? We present LuthorSQL, a non-autoregressive 7B text-to-SQL model that serves as a rapid System 1 gate for a slower LLM agent (System 2), escalating queries only when uncertain. LuthorSQL makes a single forward pass to predict slot scores over a bounded grammar for query plans, compiles and runs up to 32 candidate plans, and chooses an answer using a trained validator. On its own, LuthorSQL reaches 68.03% execution accuracy on BIRD's hidden test set at 0.84 s per question on a single GPU, maintains its accuracy in 9 GB with 8-bit quantized weights, and transfers zero-shot to Snowflake, BigQuery, MySQL, PostgreSQL, and DuckDB within 3.1 points of its native SQLite accuracy. Combined with Claude Opus 5.5 in a pre-registered confidence cascade over 227 questions on databases published after Opus's training cutoff, LuthorSQL answers nearly half of all questions locally and cuts API cost by 33.3% at the same accuracy. Finally, contamination probing shows that Opus reproduces 48-92% of public benchmark gold queries verbatim without seeing the schema; however, its tool-assisted accuracy holds on renamed schemas and reaches 95.6-97.4% on post-cutoff databases. Code and data: https://github.com/IAMIbrahimmemon/luthorsql