Introduction
Text-to-SQL systems aim to allow non-expert users to query databases using natural language. However, real-world queries are often ambiguous or "inexplicit." For instance, a user asking to "Find the aged students" might be referring to a column named Age, Birth_Year, or a specific filter. Existing interactive solutions often require SQL knowledge or are tightly coupled to specific parser architectures, limiting their utility for general users.
Presented at EMNLP 2020, PIIA (Parser-Independent Interactive Approach) introduces a "plug-and-play" interactive layer that bridges this gap. By treating the underlying SQL parser as a "black box," PIIA can be integrated with any existing system to boost performance through a few turns of natural language interaction.
The PIIA Framework
The PIIA framework operates as an intermediary between the user and a Text-to-SQL parser. It consists of three primary modules: the Error Locator, the Question Generator, and the NL Modifier.
1. Error Locator
To identify where a parser might have failed, PIIA employs a "restatement" technique. It converts the parser's predicted SQL back into a natural language sentence using predefined templates. For example, SELECT name WHERE age > 20 might be restated as "Find the name where the age is greater than 20." By aligning the original user question with this restatement using a BERT-based model, PIIA flags tokens with low alignment scores as Uncertain Tokens.
2. Question Generator
For each uncertain token, PIIA generates a multiple-choice question to clarify the user's intent. It identifies potential database matches (tables, columns, or values) by calculating lexical similarity (Jaccard distance) and semantic similarity (GloVe embeddings). To ensure robustness, every question includes a "Value" option (for potential data entries) and a "None" option (to avoid forcing incorrect corrections).
3. NL Modifier
Once the user selects an option, the NL Modifier rewrites the original question into a more explicit version. This might involve adding quotes around values or replacing vague terms with specific column names. This "corrected" natural language query is then resubmitted to the parser for a second, more accurate attempt.
Experimental Evaluation
The authors evaluated PIIA using two major benchmarks: WikiSQL (simple, single-table) and Spider (complex, multi-table). They tested the framework against five state-of-the-art parsers, including SQLova, SQLNet, and IRNet, demonstrating its parser-agnostic nature.
Key Results
- Accuracy Improvement: On the Spider dataset, PIIA increased the accuracy of the IRNet parser from 53.2% to 59.3% in simulations.
- Low Interaction Overhead: Performance gains were achieved with minimal user effort, requiring only 1.3 to 3.4 questions per query on average.
- Human Study Validation: A study with 30 non-expert volunteers confirmed that PIIA improved the absolute SQL accuracy of IRNet+BERT by 1.5% and the base IRNet by 3.7%.
Key Insights
- Alignment in Natural Language: Aligning two natural language sentences (original vs. restated) is more effective for error detection than directly mapping text to SQL logic, especially when leveraging pre-trained models like BERT.
- Input Rewriting vs. Output Fixing: Unlike systems that attempt to fix generated SQL, PIIA fixes the Natural Language input. This allows the system to leverage the parser's internal logic without needing access to its internal architecture.
- Safety Mechanisms: The "None" option acts as a critical safety net, allowing users to reject incorrect error flags and maintain the original query path.
Limitations and Future Work
While effective, PIIA relies on template-based restatements, which may struggle with extremely complex SQL queries. Additionally, as a "black-box" approach, it cannot utilize the internal confidence scores of neural parsers. Future research could focus on "distilling" user interactions to build domain-specific knowledge bases, reducing the need for repeated clarifications over time.
Summary updated