DBCopilot: Natural Language Querying over Massive Databases via Schema Routing

Tianshu Wang, Xiaoyang Chen, Hongyu Lin, Xianpei Han, Le Sun +2 more
12/6/2023
cs.CLcs.DBcs.IR

No official code found. Best implementation: tshu-w/DBCopilot (137 stars, last commit 2025-08-25).

Abstract

The development of Natural Language Interfaces to Databases (NLIDBs) has been greatly advanced by the advent of large language models (LLMs), which provide an intuitive way to translate natural language (NL) questions into Structured Query Language (SQL) queries. While significant progress has been made in LLM-based NL2SQL, existing approaches face several challenges in real-world scenarios of natural language querying over massive databases. In this paper, we present DBCopilot, a framework that addresses these challenges by employing a compact and flexible copilot model for routing over massive databases. Specifically, DBCopilot decouples schema-agnostic NL2SQL into schema routing and SQL generation. This framework utilizes a single lightweight differentiable search index to construct semantic mappings for massive database schemata, and navigates natural language questions to their target databases and tables in a relation-aware joint retrieval manner. The routed schemata and questions are then fed into LLMs for effective SQL generation. Furthermore, DBCopilot introduces a reverse schema-to-question generation paradigm that can automatically learn and adapt the router over massive databases without manual intervention. Experimental results verify that DBCopilot is a scalable and effective solution for schema-agnostic NL2SQL, providing a significant advance in handling natural language querying over massive databases for NLIDBs.

View on arXivView PDF

Code Implementations(1)

tshu-w/DBCopilotCommunity100%

Code and data for the paper "DBCᴏᴘɪʟᴏᴛ: Natural Language Querying over Massive Database via Schema Routing" (EDBT 2025)

13725Shell, PythonJun 29, 20231 years ago
databasellmschema-routingtext-to-sql

Cite this paper

@article{wang2023dbcopilot,
  title  = {DBCopilot: Natural Language Querying over Massive Databases via Schema Routing},
  author = {Tianshu Wang and Xiaoyang Chen and Hongyu Lin and Xianpei Han and Le Sun and Hao Wang and Zhenyu Zeng},
  year   = {2023},
  eprint = {2312.03463},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2312.03463v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2312.03463.svg)](https://codeofpaper.com/paper/2312.03463)

Discussion