HyMIR: A BI-Inspired Hybrid Intermediate Representation for Schema-Agnostic Text-to-SQL
BIRD is a recent enterprise-scale Text-to-SQL benchmark that exposes a regime not covered by earlier datasets such as Spider: it consists of 95 real-world databases, which on average contain seven tables each, with abbreviated column names, dense foreign key graphs, and noisy domain values. Generation-target intermediate representations (IRs) such as SemQL and NatSQL, which reduce the model’s output space to a structured plan and rely on a deterministic compiler to reconstruct full SQL, were developed before BIRD and evaluated mainly on Spider-like schemas. As a result, most subsequent BIRD-era work on Text-to-SQL has shifted toward prompt and pipeline engineering, while leaving the choice of generation target—raw SQL versus IR—largely unexamined for large, messy enterprise databases. In this work, we revisit generation-target IRs under the BIRD regime and propose HyMIR, a typed JSON IR designed for enterprise-scale schemas. HyMIR removes high-error structural clauses—JOIN, GROUP BY, and the SELECT projection—from the model’s output and delegates their reconstruction to a compiler that infers join paths from the foreign key graph, while a predicate passthrough channel carries the long tail of fragments that resist abstraction, including LIKE predicates, range bounds, nested IN subqueries, and dialect-specific date functions. To isolate the effect of the IR itself, we compare HyMIR against standard SQL as the generation target under strictly matched conditions: identical training data, backbone (Qwen-2.5-Coder-7B-Instruct), fine-tuning recipe (DoRA), and sampling protocol. On the BIRD development set, HyMIR improves execution accuracy from 52.50% to 55.48% under raw decoding and from 56.81% to 58.44% with $N{=}11$ result-set self-consistency. Across model scales (1.5B, 3B, 7B), the gains exhibit a mid-scale sweet spot—largest at 3B, with improvements of roughly + 11 points, and smaller but consistently positive at 7B—such that a 3B HyMIR model approaches the performance of a 7B SQL-tuned model while using fewer than half the parameters. Finally, a compiler-only oracle round-trip, which encodes gold SQL into HyMIR and compiles back, achieves 92.83% execution accuracy on BIRD and 91.0% on Spider, indicating comparable representational coverage across the two benchmarks and quantifying a hard upper bound on attainable model performance under this IR and compiler stack.