[Paper Review] How to Prompt LLMs for Text-to-SQL: A Study in Zero-shot, Single-domain, and Cross-domain Settings
The paper systematically evaluates prompt constructions for text-to-SQL across zero-shot, single-domain, and cross-domain settings, showing that table relationships and content, prompt normalization, and in-domain demonstrations significantly affect LLM performance, with Codex typically outperforming ChatGPT in zero-shot scenarios and a sweet spot in prompt length for cross-domain prompts.
Large language models (LLMs) with in-context learning have demonstrated remarkable capability in the text-to-SQL task. Previous research has prompted LLMs with various demonstration-retrieval strategies and intermediate reasoning steps to enhance the performance of LLMs. However, those works often employ varied strategies when constructing the prompt text for text-to-SQL inputs, such as databases and demonstration examples. This leads to a lack of comparability in both the prompt constructions and their primary contributions. Furthermore, selecting an effective prompt construction has emerged as a persistent problem for future research. To address this limitation, we comprehensively investigate the impact of prompt constructions across various settings and provide insights into prompt constructions for future text-to-SQL studies.
Motivation & Objective
- Evaluate how database prompt representations (schema, relationships, and content) affect zero-shot, single-domain, and cross-domain text-to-SQL performance.
- Assess the impact of demonstrations (in-domain and out-of-domain) on LLM capabilities across settings.
- Identify effective prompt construction practices (normalization, content presentation) to improve LLM accuracy in text-to-SQL.
- Provide actionable recommendations for prompt design in future text-to-SQL work.
Proposed method
- Systematically compare multiple database prompt constructions (schema-only to enriched with relationships and content).
- Normalize prompt text to reduce token variability and case sensitivity.
- Use Spider as the cross-domain benchmark and evaluate with Codex and ChatGPT.
- Explore zero-shot, single-domain, and cross-domain in-context learning settings with varying demonstration strategies.
- Analyze the effect of demonstration quantity and prompt length on performance.
- Present results with execution accuracy (EX) as the evaluation metric.
Experimental results
Research questions
- RQ1How do different representations of the database schema and content in prompts affect zero-shot, single-domain, and cross-domain text-to-SQL performance?
- RQ2What is the role of in-domain versus out-of-domain demonstrations in prompting LLMs for text-to-SQL across settings?
- RQ3How does prompt length influence LLM performance in cross-domain prompting, and is there a sweet spot?
- RQ4Does the inclusion of table relationships (foreign keys) and content (sample rows) in prompts improve results, and how does this interact with demonstrations?
Key findings
- Table relationships and content in prompts are crucial for effective prompting, with normalization often improving results.
- In-domain demonstrations improve performance and can reduce sensitivity to prompt representations, but cannot fully replace table content knowledge.
- Prompt length has a significant impact in cross-domain settings, with a sweet spot observed for Codex and a token-length threshold beyond which performance declines.
- Codex generally outperforms ChatGPT in zero-shot text-to-SQL across prompt constructions.
- In single-domain settings, increasing in-domain demonstrations helps, and table content remains essential; however, the exact content presentation matters less as demonstrations grow.
- Out-of-domain demonstrations enhance capabilities in cross-domain prompting but do not provide database-specific knowledge; careful database prompt design remains crucial.
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.