DuoRAT: Towards Simpler Text-to-SQL Models

Torsten Scholak, Raymond Li, Dzmitry Bahdanau, Harm de Vries, Chris Pal

Abstract

Torsten Scholak, Raymond Li, Dzmitry Bahdanau, Harm de Vries, Chris Pal. Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.

2021.

Introduction

The field of Text-to-SQL—building systems that allow non-experts to query databases using natural language—has recently seen a "complexity creep." Top-performing models often rely on a dizzying array of specialized techniques, including grammar-based constraints, intermediate representations, schema-linking heuristics, and hybrid LSTM-Transformer architectures. This high complexity creates a barrier to entry for researchers and slows experimentation cycles.

DuoRAT addresses this by providing a streamlined, transformer-only re-implementation of the state-of-the-art RAT-SQL model. By replacing complex LSTM-based decoders with relation-aware transformers, the authors achieved comparable performance while cutting training time by two-thirds (from 6 days to 2 days) and identifying which "sophisticated" features are actually redundant.

Methodology

DuoRAT is designed as an encoder-decoder model based entirely on the Transformer architecture. Its architecture consists of three primary stages:

  1. The Encoder: A two-stage process where a pre-trained BERT-large model jointly encodes the question and the database schema (table and column names). This is followed by a stack of Relation-Aware Transformer layers that process these representations using a graph-like structure to capture relational dependencies, such as foreign key relationships.
  2. The Decoder: Unlike the original RAT-SQL which utilized a custom LSTM, DuoRAT employs a Relation-Aware Transformer decoder. It uses a pointer-network mechanism to "copy" specific table or column names from the input into the final SQL query.
  3. Grammar Constraints: The model utilizes the TRANX framework to ensure generated outputs follow valid SQL syntax. Instead of predicting raw text, it predicts a sequence of actions to construct an Abstract Syntax Tree (AST).
The DuoRAT architecture featuring a BERT-large encoder and relation-aware transformer layers.

The authors also explored different "linking" strategies between the question and the database, including Name-Based Schema Linking (NBSL) and Content-Based Schema Linking (CBSL).

Results and Discussion

DuoRAT was primarily evaluated on the Spider benchmark, a large-scale, cross-domain dataset featuring over 10,000 questions and 200 complex databases.

Performance and Efficiency

DuoRAT achieved an Exact Match (EM) accuracy of 69.9% on the Spider development set, placing it on par with the original RAT-SQL (69.7%) and other state-of-the-art models like RYANSQL. Crucially, the move to a transformer-only architecture resulted in a 3x training speedup, reducing training time from 6 days to roughly 2 days on a single V100 GPU.

Exact Match (EM) performance comparison on the Spider development set.

Key Insights

  • Redundancy of Manual Linking: A significant finding was that Name-Based Schema Linking (NBSL) provides almost no benefit when using BERT. Because BERT jointly encodes the question and schema, it learns these alignments automatically, rendering hand-engineered character-matching features unnecessary.
  • Necessity of Grammar: While some features were redundant, grammar-constrained decoding proved essential. Removing these constraints led to a significant drop in accuracy (from ~70% to ~63%) and decreased training stability.
  • Relational Structure: Explicitly encoding the schema structure (e.g., which columns belong to which tables) via relational embeddings is significantly more effective than relying solely on the sequential order of the input text.

Generalization

To test robustness, DuoRAT was evaluated on single-database datasets (GeoQuery, Academic, IMDB, and Yelp). It consistently outperformed previous benchmarks, such as scoring 54.6% on GeoQuery compared to 41.6% in prior work, demonstrating that its simplifications did not compromise generalization.

Conclusion

DuoRAT demonstrates that state-of-the-art performance in Text-to-SQL can be achieved with a simpler, faster, transformer-only architecture. While the model still struggles with literal copying of long strings or unseen values, it provides a more accessible baseline for future research. Future work includes integrating even stronger pre-trained models like T5 or BART and improving the copy mechanism for complex literals.

Summary updated

BibTeX
@inproceedings{scholak2021duorat,
  author = {Torsten Scholak and Raymond Li and Dzmitry Bahdanau and Harm de Vries and Chris Pal},
  title = {{DuoRAT: Towards Simpler Text-to-SQL Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  url = {https://openreview.net/forum?id=Sf-n6H-yW5},
}
Figure