ColloQL: Robust Text-to-SQL Over Search Queries

Karthik Radhakrishnan, Arvind Srikantan, Xi Lin2020 · DOI

Abstract

Translating natural language utterances to executable queries is a helpful technique in making the vast amount of data stored in relational databases accessible to a wider range of nontech-savvy end users. Prior work in this area has largely focused on textual input that is linguistically correct and semantically unambiguous. However, real-world user queries are often succinct, colloquial, and noisy, resembling the input of a search engine. In this work, we introduce data augmentation techniques and a sampling-based content-aware BERT model (COLLOQL) to achieve robust text-to-SQL modeling over natural language search (NLS) questions. Due to the lack of evaluation data, we curate a new dataset of NLS questions and demonstrate the efficacy of our approach. COLLOQL's superior performance extends to well-formed text, achieving 84.9% (logical) and 90.7% (execution) accuracy on the WikiSQL dataset, making it, to the best of our knowledge, the highest performing model that does not use execution guided decoding.

Introduction

Traditional text-to-SQL research assumes users provide perfectly grammatical, unambiguous sentences. However, in real-world applications like CRM platforms, users often behave as if they are using a search engine—employing keywords, omitting column names, and using colloquialisms. This brevity introduces significant ambiguity. For instance, a query like "42" could refer to an Age, a Jersey Number, or a Player ID. Existing models trained on "clean" data often fail when faced with these telegraphic queries.

Comparison of full questions vs. search-style queries.

Furthermore, many top-performing models rely on "execution-guided decoding," a technique that filters candidate SQL queries based on execution results. This is often impractical for production systems where an empty result set might be the correct answer.

Methods

COLLOQL (pronounced "colloquial") addresses these challenges through two primary innovations: Content-Aware BERT Encoding and Natural Language Search (NLS) Data Augmentation.

Content-Aware BERT Encoding To help the model disambiguate columns, COLLOQL appends actual table values to column headers in the BERT input. Since scanning a million-row table at inference time is too slow, the authors propose two sampling strategies:

  • Random Sampling: Uses a fixed set of random values from each column to help the model learn the general data type and format of a column (e.g., names vs. dates).
  • Relevance Sampling: Employs a fast keyword search (using FlashText) to find cells matching tokens in the user's query, falling back to random samples if no match is found.

NLS Data Augmentation To bridge the gap between formal language and search-style queries, the authors synthesized an "NLS-WikiSQL" dataset. They used templates and a controllable sentence simplification model to compress verbose questions into keyword-heavy snippets.

COLLOQL model architecture overview.

The model architecture, shown above, builds on the SQLova framework, using BERT as a backbone and specialized LSTM/Attention layers to predict specific SQL components like the SELECT column, aggregation operators, and WHERE clauses.

Results

COLLOQL achieves state-of-the-art results on the WikiSQL benchmark, reaching 84.9% logical form accuracy and 90.7% execution accuracy without execution-guided decoding.

Crucially, COLLOQL demonstrates high robustness to query brevity. On a manually verified test set of 400 simplified queries, the base SQLova model's accuracy dropped to 68.7%, while COLLOQL maintained 87.0% accuracy. Efficiency tests on a 7-million-row database showed that relevance sampling is highly scalable, taking only 1.5 seconds for execution compared to intractable exact-match approaches.

Conclusion

COLLOQL demonstrates that content-aware sampling and targeted data augmentation can significantly improve the robustness of text-to-SQL models for real-world search-style queries. While limited by BERT's 512-token sequence length, which restricts the number of table samples, future work will explore personalized and diversity-based sampling to further enhance performance and scale to more complex multi-table queries.

Summary updated

Abstract

Translating natural language utterances to executable queries is a helpful technique in making the vast amount of data stored in relational databases accessible to a wider range of nontech-savvy end users. Prior work in this area has largely focused on textual input that is linguistically correct and semantically unambiguous. However, real-world user queries are often succinct, colloquial, and noisy, resembling the input of a search engine. In this work, we introduce data augmentation techniques and a sampling-based content-aware BERT model (COLLOQL) to achieve robust text-to-SQL modeling over natural language search (NLS) questions. Due to the lack of evaluation data, we curate a new dataset of NLS questions and demonstrate the efficacy of our approach. COLLOQL's superior performance extends to well-formed text, achieving 84.9% (logical) and 90.7% (execution) accuracy on the WikiSQL dataset, making it, to the best of our knowledge, the highest performing model that does not use execution guided decoding.
BibTeX
@misc{radhakrishnan2020colloql,
  author = {Karthik Radhakrishnan and Arvind Srikantan and Xi Lin},
  title = {{ColloQL: Robust Text-to-SQL Over Search Queries}},
  year = {2020},
  doi = {10.18653/v1/2020.intexsempar-1.5},
}
Figure