PURPLE: Making a Large Language Model a Better SQL Writer
Authors:
- 13 May 2024
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 15-28
Abstract
Large Language Model (LLM) techniques play an increasingly important role in Natural Language to SQL (NL2SQL) translation. LLMs trained by extensive corpora have strong natural language understanding and basic SQL generation abilities without additional tuning specific to NL2SQL tasks. Existing LLMs-based NL2SQL approaches try to improve the translation by enhancing the LLMs with an emphasis on user intention understanding. However, LLMs sometimes fail to generate appropriate SQL due to their lack of knowledge in organizing complex logical operator composition. A promising method is to input the LLMs with demonstrations, which include known NL2SQL translations from various databases. LLMs can learn to organize operator compositions from the input demonstrations for the given task. In this paper, we propose PURPLE (Pre-trained models Utilized to Retrieve Prompts for Logical Enhancement), which improves accuracy by retrieving demonstrations containing the requisite logical operator composition for the NL2SQL task on hand, thereby guiding LLMs to produce better SQL translation. PURPLE achieves a new state-of-the-art performance of 80.5% exact-set match accuracy and 87.8% execution match accuracy on the validation set of the popular NL2SQL benchmark Spider. PURPLE maintains high accuracy across diverse benchmarks, budgetary constraints, and various LLMs, showing robustness and cost-effectiveness.Keywords
All Related Versions
Funding Information
- NSFC (62272106)
This publication has 42 references indexed in Scilit:
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation2024
- Retrieval-Augmented GPT-3.5-Based Text-to-SQL Framework with Sample-Aware Prompting and Dynamic Revision Chain2023
- GenSql: A Generative Natural Language Interface to Database Systems2023
- Gar: A Generate-and-Rank Approach for Natural Language to SQL Translation2023
- Solving Steiner trees: Recent advances, challenges, and perspectivesNetworks, 2020
- Focal Loss for Dense Object Detection2017
- NaLIR2014
- Précis: from unstructured keywords as queries to structured databases as answersThe VLDB Journal, 2007
- Discover2002
- Steiner tree problemsNetworks, 1992