PURPLE: Making a Large Language Model a Better SQL Writer

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Ren, Tonghui, Fan, Yuankai, He, Zhenying, Huang, Ren, Dai, Jiaqi, Huang, Can, Jing, Yinan, Zhang, Kai, Yang, Yifan, Wang, X. Sean
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866929295409020928
author Ren, Tonghui
Fan, Yuankai
He, Zhenying
Huang, Ren
Dai, Jiaqi
Huang, Can
Jing, Yinan
Zhang, Kai
Yang, Yifan
Wang, X. Sean
author_facet Ren, Tonghui
Fan, Yuankai
He, Zhenying
Huang, Ren
Dai, Jiaqi
Huang, Can
Jing, Yinan
Zhang, Kai
Yang, Yifan
Wang, X. Sean
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2403_20014
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle PURPLE: Making a Large Language Model a Better SQL Writer
Ren, Tonghui
Fan, Yuankai
He, Zhenying
Huang, Ren
Dai, Jiaqi
Huang, Can
Jing, Yinan
Zhang, Kai
Yang, Yifan
Wang, X. Sean
Databases
Artificial Intelligence
Computation and Language
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.
title PURPLE: Making a Large Language Model a Better SQL Writer
topic Databases
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2403.20014