(Case study 10 / 11)
Schema-Aware Natural Language to SQL
English questions become PostgreSQL. Schema injection keeps the model from inventing tables, with about 85% accuracy on common reads and under 1.2 seconds typical latency.
~85%Accuracy on evaluated common reads
<1.2sTypical read latency, model and database included
6 weeksFrom kickoff to launch
(The challenge)
Non-technical operators need answers from a database without waiting for an engineer or a BI team. A naked language model will invent a table that doesn't exist, so the product has to constrain generation to the real schema.
- Operators depend on engineers to answer simple data questions
- Language models invent tables and columns
- A slow answer sends people back to asking an engineer
(What we built)
Natural language to SQL
- The real schema (tables, columns and relationships) loaded into the prompt so generation is constrained to what exists
- A query and a result returned from a plain-English question
- A latency budget that covers both model time and Postgres time
(The core insight)
(Results)
- About 85% accuracy on evaluated common reads, with most failures coming from ambiguous English rather than missing tables
- Common reads complete in under 1.2 seconds
(Technology)