[Paper Review] Interleaving Pre-Trained Language Models and Large Language Models for Zero-Shot NL2SQL Generation
This paper proposes ZeroNL2SQL, a framework that interleaves pre-trained language models (PLMs) and large language models (LLMs) for zero-shot NL2SQL generation. It first uses a PLM to generate an SQL sketch via schema alignment, then employs an LLM to complete the sketch using complex reasoning, with predicate calibration and execution-based selection improving accuracy. The method achieves state-of-the-art execution accuracy, outperforming SOTA PLM-based methods by 3.2–13% and LLM-based methods by 10–20% on real-world benchmarks.
Zero-shot NL2SQL is crucial in achieving natural language to SQL that is adaptive to new environments (e.g., new databases, new linguistic phenomena or SQL structures) with zero annotated NL2SQL samples from such environments. Existing approaches either fine-tune pre-trained language models (PLMs) based on annotated data or use prompts to guide fixed large language models (LLMs) such as ChatGPT. PLMs can perform well in schema alignment but struggle to achieve complex reasoning, while LLMs is superior in complex reasoning tasks but cannot achieve precise schema alignment. In this paper, we propose a ZeroNL2SQL framework that combines the complementary advantages of PLMs and LLMs for supporting zero-shot NL2SQL. ZeroNL2SQL first uses PLMs to generate an SQL sketch via schema alignment, then uses LLMs to fill the missing information via complex reasoning. Moreover, in order to better align the generated SQL queries with values in the given database instances, we design a predicate calibration method to guide the LLM in completing the SQL sketches based on the database instances and select the optimal SQL query via an execution-based strategy. Comprehensive experiments show that ZeroNL2SQL can achieve the best zero-shot NL2SQL performance on real-world benchmarks. Specifically, ZeroNL2SQL outperforms the state-of-the-art PLM-based methods by 3.2% to 13% and exceeds LLM-based methods by 10% to 20% on execution accuracy.
Motivation & Objective
- Address the challenge of zero-shot NL2SQL in new environments where no annotated training data is available.
- Overcome the limitations of existing PLM-based methods in complex reasoning and LLM-based methods in schema alignment.
- Enable robust NL2SQL generation across diverse databases, linguistic phenomena, and SQL structures without fine-tuning.
- Improve alignment between natural language questions and actual database values through instance-aware calibration.
- Achieve high execution accuracy in zero-shot settings by combining the strengths of PLMs and LLMs in a two-stage pipeline.
Proposed method
- Use a fine-tuned pre-trained language model (PLM) to generate an SQL sketch by performing schema alignment between the natural language question and database schema.
- Leverage a fixed, frozen large language model (LLM) to complete the SQL sketch by performing complex reasoning on the question and schema.
- Introduce a predicate calibration method that aligns generated SQL predicates with actual values in database instances using semantic matching (e.g., SBERT).
- Apply a multi-level matching strategy combining in-column, in-database, and multi-level value matching to improve predicate accuracy.
- Use an execution-based strategy to evaluate and select the optimal SQL query from multiple candidates generated by the LLM.
- Employ SBERT for semantic similarity calculation in predicate calibration, outperforming GloVe and fuzzy matching methods.
Experimental results
Research questions
- RQ1Can a hybrid framework combining PLMs and LLMs achieve superior zero-shot NL2SQL performance compared to purely PLM- or LLM-based approaches?
- RQ2How effectively can a PLM generate accurate SQL sketches for schema alignment in zero-shot settings?
- RQ3To what extent can an LLM complete SQL sketches with complex reasoning when guided by a PLM-generated sketch?
- RQ4How does predicate calibration based on database instances improve SQL accuracy in zero-shot NL2SQL?
- RQ5Can execution-based selection and semantic matching (e.g., SBERT) significantly enhance the robustness and accuracy of generated SQL queries?
Key findings
- ZeroNL2SQL achieves state-of-the-art execution accuracy on real-world NL2SQL benchmarks, outperforming SOTA PLM-based methods by 3.2% to 13%.
- The framework exceeds SOTA LLM-based methods by 10% to 20% in execution accuracy, demonstrating superior zero-shot generalization.
- Predicate calibration using SBERT improves average execution accuracy to 78.5%, significantly outperforming fuzzy matching (77.2%) and GloVe (76.3%).
- The multi-level matching strategy in predicate calibration achieves 78.5% average execution accuracy, showing robustness across diverse value types.
- The two-stage pipeline—PLM for sketch generation and LLM for completion—effectively balances schema alignment and complex reasoning.
- Execution-based selection effectively filters incorrect SQL queries, improving final accuracy by validating against actual database instances.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.