Graph Enhanced Cross-Domain Text-to-SQL Generation

Siyu Huo, Tengfei Ma, Jie Chen, Maria Chang, Lingfei Wu, Michael Witbrock

Abstract

Cross-domain text-to-SQL generation remains a significant challenge in natural language processing, as models often struggle to generalize to unseen database schemas. This paper introduces GNN-SQL, a novel framework that leverages Graph Convolutional Networks (GCNs) to represent database schemas as interconnected graphs. By focusing on the column selection (COL) module—a known bottleneck in existing systems—GNN-SQL achieves substantial improvements in accuracy without the need for extensive data augmentation.

Introduction

The ability to query databases using natural language is a cornerstone of accessible data science. However, state-of-the-art models frequently fail when encountering "out-of-domain" databases—schemas not seen during training. The authors identify that the primary failure point is often the COL (Column) module, which struggles to identify relevant columns in complex, unfamiliar schemas. Standard models treat each database as an isolated island, missing the structural commonalities shared across different domains.

Methodology: Graph-Based Schema Encoding

Traditional approaches treat database schemas as sequences of strings, often using BiLSTMs for encoding. GNN-SQL moves beyond this by representing the schema as a massive, interconnected graph, which more naturally captures the relational structure of a database.

Database Graph Construction

The graph nodes represent words from column names, table names, and data types. A critical innovation is the use of Shared Nodes: if multiple databases use common terms like "ID" or "Name," these terms are represented by the same nodes in the graph. This creates a "vocabulary bridge" that facilitates knowledge transfer across different domains.

Graph Convolutional Networks (GCN)

A 2-layer GCN, initialized with GloVe embeddings, processes this graph. This allows the representation of a specific column (e.g., "customer_id" in a retail database) to be informed by similar columns in entirely different domains. The final column representation is a concatenation of the original GloVe vectors and the GCN-learned vectors, pooled across relevant nodes. This integrated representation replaces the standard BiLSTM encoding in the SyntaxSQLNet framework.

Experimental Evaluation

The model was evaluated on the Spider dataset, a benchmark specifically designed for cross-domain text-to-SQL tasks. Spider includes over 10,000 questions across 200 databases in 138 domains, ensuring that the test databases are entirely new to the model.

Key Results

GNN-SQL demonstrated a clear advantage over the baseline SyntaxSQLNet framework, particularly in column prediction accuracy.

As shown in the results, GNN-SQL achieved a 57.0% COL accuracy, a 3.5% absolute improvement over the baseline. This translated to an overall exact match accuracy of 22.0%. Notably, while data-augmented versions of SyntaxSQLNet reached higher scores, GNN-SQL achieves its gains through architectural efficiency rather than the costly manual labor required for manual data generation.

Discussion and Future Work

The success of GNN-SQL highlights that the relational structure of a database is better captured by a graph than a sequence. By targeting the specific bottleneck of column selection, the researchers provided a scalable way to improve cross-domain performance.

However, limitations remain. The model still trails behind systems using heavy data augmentation, and it relies on static GloVe embeddings. Future research could involve integrating contextual embeddings like BERT into the graph nodes or applying graph-based encoding to other complex SQL modules, such as JOIN condition prediction.

Summary updated

BibTeX
@inproceedings{huo2019graph,
  author = {Siyu Huo and Tengfei Ma and Jie Chen and Maria Chang and Lingfei Wu and Michael Witbrock},
  title = {{Graph Enhanced Cross-Domain Text-to-SQL Generation}},
  booktitle = {TextGraphs @ EMNLP},
  year = {2019},
  doi = {10.18653/v1/d19-5319},
}
Figure