Achieve better text-to-SQL result for LLM

Adapt and Decompose: Efficient Generalization of Text-to-SQL via Domain Adapted Least-To-Most Prompting

Existing methods for text-to-SQL often struggle with generalization to new domains and database schemas. This is due to the limitations of large language models (LLMs) that are trained on extensive datasets, which may lack examples from various domains. The paper's key findings are as follows:
  • Domain adaptation is crucial for enhancing text-to-SQL model generalization.
  • Least-to-most prompting aids text-to-SQL models in avoiding early generation errors.
Text-to-SQL is a challenging task requiring a model to translate natural language queries into executable SQL queries. The proposed method addresses the generalization issue through two steps:
Domain Adaptation (Adaptation): The model is adapted to new domains by generating few-shot examples. The prompts start from a basic level and become domain-specific, guiding the model's understanding.
Example:
  • Initial Prompt: "Generate a SQL query based on the following natural language question."
  • Intermediate Prompt: "Generate a SQL query to find the names of restaurants that serve Italian cuisine."
  • Specific Prompt: "Generate a SQL query to list the average ratings of restaurants in New York that offer Mexican dishes."
Least-to-Most Prompting (Decomposition): Complex queries are broken down into sub-queries, helping the model generate SQL progressively to prevent early mistakes.
Example:
  • Complex Natural Language Query: "List the average ratings of Mexican restaurants in New York with more than 100 reviews."
  • Decomposition Step 1: Break the query into sub-queries:
    1. "Retrieve restaurant names in New York that serve Mexican cuisine."
    2. "Filter restaurants with more than 100 reviews."
    3. "Calculate the average ratings of these restaurants."
  • Decomposition Step 2: Focus on Sub-query 1 - Convert to Sequence-to-Sequence Problem:
    • Input: "Retrieve restaurant names in New York that serve Mexican cuisine."
    • Expected Output: SELECT restaurant_name FROM restaurants WHERE city='New York' AND cuisine='Mexican';

Fafa's avatar
Fafa
Entrepreneur, Engineer, Product, AI enthusiast

Explore
Chat
LeaderBoard
Me