Introduction
Translating natural language (NL) questions into executable SQL queries is a cornerstone of accessible data management. However, this task faces two significant hurdles: the Mismatch Problem and the Lexical Problem. The Mismatch Problem arises because user intent often omits structural database requirements like JOIN or GROUP BY clauses. The Lexical Problem occurs in cross-domain settings where models encounter out-of-vocabulary (OOV) schema components.
To address these, we present IRNet, a neural approach that introduces an intermediate representation called SemQL. By abstracting away implementation details, IRNet bridges the gap between human intent and rigid SQL syntax, achieving a significant performance leap on complex benchmarks.
Methodology
IRNet decomposes the text-to-SQL task into three distinct phases to handle schema complexity and linguistic variation effectively.
Phase 1: Schema Linking
Before generation, IRNet identifies references to tables, columns, and cell values within the NL question. Using string matching and external knowledge bases like ConceptNet, the model links NL spans to the database schema. This allows the model to process "out-of-domain" words by recognizing their functional role (e.g., as a column name) even if the specific word was unseen during training.
Phase 2: SemQL Synthesis
Instead of direct SQL generation, IRNet synthesizes a SemQL tree. SemQL is a domain-specific language designed to capture the core logic of a query while hiding structural implementation details. It eliminates the need for the model to predict JOIN paths or HAVING clauses, which are instead inferred from the database schema.
Phase 3: SQL Inference
In the final stage, the SemQL tree is deterministically transformed into a valid SQL query. This process utilizes domain knowledge, such as foreign key relationships, to automatically construct the necessary joins and grouping logic required for execution.
Neural Architecture
The core of IRNet is a grammar-based neural model. It employs a Memory-Augmented Pointer Network for column selection. Unlike standard pointer networks that may redundantly select the same column, this architecture tracks previously used columns to minimize errors. The model is constrained by a formal grammar, ensuring that the generated SemQL is always syntactically valid.
Experimental Results
We evaluated IRNet on the Spider benchmark, a large-scale, cross-domain dataset featuring complex, multi-table queries. IRNet demonstrated a substantial improvement over existing baselines.
As shown in the results, IRNet achieved 46.7% accuracy on the Spider test set, representing a 19.5% absolute improvement over previous state-of-the-art models like SyntaxSQLNet. When integrated with BERT for enhanced language embeddings, performance further increased to 54.7%. Ablation studies confirmed that schema linking contributed an ~8% accuracy boost, while the memory-augmented pointer network reduced column selection errors by 70%.
Conclusion and Future Work
IRNet demonstrates that intermediate representations are highly effective for complex text-to-SQL tasks. By decoupling user intent from database implementation, the model achieves superior generalization across domains. Despite these gains, challenges remain in handling self-joins and accurately predicting columns based on specific cell values. Future research will focus on refining schema linking and expanding SemQL to cover more edge cases in SQL logic.
Summary updated