Data model refinement for LLM-based SQL code generation
Abstract
The current development of Text-to-SQL systems are mostly based on the improvement of the underlying Large Language Models (LLMs) or the surrounding harness. While this direction is proved to be highly effective for the frontier models, smaller locally deployable solutions usually lack the ability to write suitable complex SQL queries for realistic, complicated databases. This motivated our research to search an alternative direction, where we keep the model intact and optimize the database schema it has to read. The schema becomes the optimization variable, and we search for a data model which is optimal for a small local model to write SQL queries. An evolutionary loop proposes restructured schemas as code, every candidate must preserve the original data, and the fitness of a candidate is the measured execution accuracy of the fixed translator on a training split of the workload and the quality components of the data model such as integrity, implementability, simplicity. On 13 real databases and 101 questions from the Spider 2.0-Lite benchmark, 20 generations of schema evolution raise the mean execution accuracy of three small local translators from 27.1% to 50.6%, at a mutator cost of about $3.50 per database. The two stronger evolved translators were on par with Claude Opus 4.6 with thinking mode reading the original schemas (56.4% and 57.4% against 54.5%). The best schemas are purely additive: they drop nothing, grow a documented layer of derived tables that removes most joins from the translator's job, and differ per model. The whole loop can also run on local hardware: a 27B mutator with thinking mode recovers most of the gains of a frontier mutator at zero API cost.
est. 32% chance this paper gets accepted at ICLR 2027.
What do you think this paper will get?
All positions stay anonymous.