Skip to main content
QUICK REVIEW

[Paper Review] Enhancing Few-shot Text-to-SQL Capabilities of Large Language Models: A Study on Prompt Design Strategies

Linyong Nan, Yilun Zhao|arXiv (Cornell University)|May 21, 2023
Topic ModelingComputer Science7 citations
TL;DR

The paper investigates prompt design strategies for in-context learning to enhance few-shot Text-to-SQL with large language models, proposing syntax-based demonstration selection, schema augmentations, and voting to boost execution accuracy on Spider. The best prompts outperform state-of-the-art by 2.5 points and best fine-tuned systems by 5.1 points.

ABSTRACT

In-context learning (ICL) has emerged as a new approach to various natural language processing tasks, utilizing large language models (LLMs) to make predictions based on context that has been supplemented with a few examples or task-specific instructions. In this paper, we aim to extend this method to question answering tasks that utilize structured knowledge sources, and improve Text-to-SQL systems by exploring various prompt design strategies for employing LLMs. We conduct a systematic investigation into different demonstration selection methods and optimal instruction formats for prompting LLMs in the Text-to-SQL task. Our approach involves leveraging the syntactic structure of an example's SQL query to retrieve demonstrations, and we demonstrate that pursuing both diversity and similarity in demonstration selection leads to enhanced performance. Furthermore, we show that LLMs benefit from database-related knowledge augmentations. Our most effective strategy outperforms the state-of-the-art system by 2.5 points (Execution Accuracy) and the best fine-tuned system by 5.1 points on the Spider dataset. These results highlight the effectiveness of our approach in adapting LLMs to the Text-to-SQL task, and we present an analysis of the factors contributing to the success of our strategy.

Motivation & Objective

  • Improve Text-to-SQL performance with in-context learning using LLMs.
  • Investigate demonstration selection criteria that balance similarity and diversity.
  • Enhance prompts with database schema representations and knowledge augmentations.
  • Analyze factors contributing to successful prompt design in Text-to-SQL.

Proposed method

  • Use SQL syntax structure to select demonstrations rather than question-only similarity.
  • Represent databases as code (CREATE queries) instead of plain text for prompt construction.
  • Apply diversity through k-means clustering on discrete SQL syntax vectors to select demonstrations.
  • Augment prompts with semantic and structural schema information (ontology, column definitions, ER summaries).
  • Combine multiple prompts via voting across predictions from varied shot settings to reduce execution errors.
  • Evaluate prompts on Spider and related datasets with Codex (code-davinci-002) and gpt-3.5-turbo, reporting execution accuracy.
(a) Few-shot results
(a) Few-shot results

Experimental results

Research questions

  • RQ1How does demonstration selection based on SQL syntax affect few-shot Text-to-SQL performance?
  • RQ2Does balancing similarity and diversity in demonstrations improve execution accuracy across Text-to-SQL datasets?
  • RQ3What is the impact of schema-related knowledge augmentation on prompt effectiveness in zero-shot and few-shot settings?
  • RQ4Does an integrated voting strategy improve robustness across different prompt configurations?

Key findings

  • The similarity-diversity demonstration strategy yields higher execution accuracy than random, similarity-only, or diversity-only approaches.
  • Schema augmentation improves performance, with semantic augmentation (column descriptions) showing benefits in zero-shot settings and in some few-shot cases.
  • Using SQL CREATE queries to represent the database (code-seq) outperforms text-seq representations for prompt construction.
  • An integrated voting approach across multiple shot configurations consistently improves results and reduces execution errors.
  • On Spider, the proposed method achieves an Execution Accuracy of 84.4, outperforming the state-of-the-art by 2.5 points and the best fine-tuned system by 5.1 points.
(b) Zero-shot results
(b) Zero-shot results

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.