# PET-SQL: A Prompt-enhanced Two-stage Text-to-SQL Framework with Cross-consistency

**Authors:** Zhishuai Li, Xiang Wang, Jingjing Zhao, Sun Yang, Guoqing Du, Xiaoru Hu, Bin Zhang, Yuxiao Ye, Ziyue Li, Rui Zhao, Hangyu Mao  
**arXiv:** [2403.09732](https://arxiv.org/abs/2403.09732)  
**Date:** 2024-03-13  
**Summary page:** https://www.summarizepaper.com/en/paper/2403.09732v1/

## Key points

- The paper introduces a two-stage Text-to-SQL framework called PET-SQL
- The first stage utilizes reference-enhanced prompt representation and schema information to guide large language models in generating SQL queries
- The second stage involves cross-consistency refinement using linked schema information to instruct the model in producing the final SQL query
- PET-SQL achieves state-of-the-art results on the Spider benchmark with an execution accuracy of 87.6%

## Summary

, , , , 

The paper "PET-SQL: A Prompt-enhanced Two-stage Text-to-SQL Framework with Cross-consistency" introduces a novel approach to enhancing the performance of Text-to-SQL systems. Recent advancements in this field have focused on leveraging large language models for in-context learning, but they often struggle with verbose database information and complex user intentions. To address these challenges, the authors propose a two-stage framework that utilizes a reference-enhanced prompt representation in the first stage and cross-consistency refinement in the second stage. The first stage includes schema information and randomly sampled cell values from tables to guide large language models in generating SQL queries, using question-SQL pairs as few-shot demonstrations. The entities mentioned in the preliminary SQL query (PreSQL) are then parsed for schema linking, which helps condense useful information. In the second stage, with the linked schema, the prompt's schema information is simplified to instruct the model in producing the final SQL query. This innovative approach not only addresses existing challenges but also achieves state-of-the-art results on the Spider benchmark with an execution accuracy of 87.6%. Overall, PET-SQL demonstrates significant improvements in performance through its two-stage approach and cross-consistency refinement technique.
