Skip to main content
QUICK REVIEW

[Paper Review] CHESS: Contextual Harnessing for Efficient SQL Synthesis

Shayan Talaei, Mohammadreza Pourreza|arXiv (Cornell University)|May 27, 2024
Service-Oriented Architecture and Web ServicesComputer Science5 citations
TL;DR

CHESS presents an end-to-end LLM-based pipeline for text-to-SQL that retrieves context, prunes the schema, and generates SQL, achieving state-of-the-art results on the BIRD dataset and strong open-source performance on Spider.

ABSTRACT

Translating natural language questions into SQL queries, known as text-to-SQL, is a long-standing research problem. Effective text-to-SQL synthesis can become very challenging due to (i) the extensive size of database catalogs (descriptions of tables and their columns) and database values, (ii) reasoning over large database schemas, (iii) ensuring the functional validity of the generated queries, and (iv) navigating the ambiguities of natural language questions. We introduce CHESS, a Large Language Model (LLM) based multi-agent framework for efficient and scalable SQL synthesis, comprising four specialized agents, each targeting one of the aforementioned challenges: the Information Retriever (IR) extracts relevant data, the Schema Selector (SS) prunes large schemas, the Candidate Generator (CG) generates high-quality candidates and refines queries iteratively, and the Unit Tester (UT) validates queries through LLM-based natural language unit tests. Our framework offers configurable features that adapt to various deployment constraints, including 1) Supporting industrial-scale databases: leveraging the Schema Selector agent, CHESS efficiently narrows down very large database schemas into manageable sub-schemas, boosting system accuracy by approximately $2\%$ and reducing the number of LLM tokens by $ imes 5$. 2) State-of-the-Art privacy-preserving performance: Among the methods using open-source models, CHESS achieves state-of-the-art performance, resulting in a high-performing, privacy-preserving system suitable for industrial deployment. 3) Scalablity with additional compute budget: In settings with high computational budgets, CHESS achieves $71.10\%$ accuracy on the BIRD test set, within $2\%$ of the leading proprietary method, while requiring approximately $83\%$ fewer LLM calls.

Motivation & Objective

  • Address the challenge of translating natural language questions to SQL for real-world databases with large schemas and catalogs.
  • Develop a scalable retrieval mechanism to incorporate database values and catalogs into SQL generation.
  • Propose an efficient schema pruning method to reduce the input to the SQL generator.
  • Demonstrate end-to-end performance gains via ablation studies and comparisons with open-source and proprietary models.

Proposed method

  • Three-stage pipeline: entity/context retrieval, schema selection, and SQL generation.
  • Hierarchical retrieval using keyword extraction, locality-sensitive hashing (LSH), and vector databases to fetch relevant values and catalog descriptions.
  • Adaptive, multi-step schema pruning (column filtering, table selection, final column selection) to obtain a minimal sufficient schema.
  • Candidate SQL generation followed by revision using model feedback and self-consistency to pick the most frequent correct answer.
  • Preprocessing of values with LSH indexing and catalogs with vector databases to enable efficient retrieval within limited context windows.

Experimental results

Research questions

  • RQ1How can retrieval of values and catalog metadata improve text-to-SQL accuracy on real-world databases?
  • RQ2Can adaptive schema pruning reduce input size while preserving the necessary information for correct SQL generation?
  • RQ3What is the impact of combining retrieval, pruning, and generation modules on end-to-end SQL accuracy compared to prior approaches?
  • RQ4How does CHESS perform with open-source versus proprietary LLMs on challenging benchmarks like BIRD and Spider?

Key findings

  • CHESS achieves state-of-the-art execution accuracy on the BIRD development and test sets with proprietary models: 65.00% dev EX and 66.69% test EX.
  • CHESS with open LLMs attains the highest open-source performance on BIRD development, 61.5% EX, among open methods.
  • On the Spider test set, CHESS achieves 87.2% EX, ranking second among published methods in the reported comparison.
  • Ablation studies show the entity/context retrieval module contributes about 5% accuracy improvement, and table selection and revision steps significantly impact performance.
  • The end-to-end open-source CHESS pipeline with privacy-preserving deployment achieves strong results, narrowing the gap to closed-source approaches.

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.