Towards Robustness of Text-to-SQL Models Against Natural and Realistic Adversarial Table Perturbation

Xinyu Pi, Bing Wang, Yan Gao, Jiaqi Guo, Zhoujun Li, Jian-Guang Lou · DOI

Abstract

While Text-to-SQL models have achieved high accuracy on standard benchmarks, they remain surprisingly fragile when faced with minor, realistic changes to database schemas. This paper investigates this vulnerability by introducing Adversarial Table Perturbation (ATP) and the ADVETA benchmark, which simulate real-world schema evolutions like column renaming and the addition of distracting metadata. To address these weaknesses, we propose Contextualized Table Augmentation (CTA), a defense framework that leverages Natural Language Inference (NLI) to generate high-quality adversarial training examples. Our results demonstrate that CTA significantly enhances model resilience, narrowing the performance gap between clean and perturbed environments.

Introduction

Text-to-SQL models are designed to translate human questions into functional database queries. Most existing research has focused on making these models robust against "noisy" questions—such as those containing typos or synonyms. However, the database schema itself is often a source of instability. In production environments, database administrators frequently rename columns for clarity or add new columns as business requirements evolve.

This research identifies a critical flaw in state-of-the-art models: a heavy reliance on "lexical matching." When a column name like "Citizenship" is changed to "Nationality," models often fail to map the user's question to the correct schema element, even if the underlying logic remains identical. This paper seeks to quantify this fragility and provide a robust defense mechanism.

Methodology

Adversarial Table Perturbation (ATP)

The authors define two primary types of table-side modifications to test model robustness:

  1. REPLACE (RPL): Substituting a column name with a semantically equivalent synonym (e.g., changing "Score" to "Grade").
  2. ADD: Inserting new, distracting columns that are relevant to the domain but irrelevant to the specific query (e.g., adding an "Instructor Name" column to a table about student grades).

The ADVETA Benchmark

To evaluate these perturbations, the researchers developed ADVETA, a manually curated benchmark built by perturbing the development sets of major datasets, including Spider, WikiSQL, and WikiTableQuestions (WTQ).

Contextualized Table Augmentation (CTA)

To defend against these attacks, the authors propose CTA, a framework that generates "hard" training examples to force models to learn deeper semantic relationships rather than simple word-matching. The CTA pipeline involves:

  • Dense Table Retriever: Finding similar tables from a large-scale web database.
  • Reranker: Identifying associated columns within those tables.
  • NLI Decision Maker: Using a RoBERTa-MNLI model to ensure that generated synonyms are interchangeable in context. This prevents the training data from including nonsensical or semantically incorrect substitutions.

Experimental Results

Model Vulnerability

The study revealed that current models are highly susceptible to schema changes. On the ADVETA benchmark, state-of-the-art models experienced an average 53.1% relative performance drop when columns were renamed (RPL) and a 25.6% drop when distracting columns were added (ADD). This confirms that models rely heavily on surface-level lexical overlap between the question and the schema.

Effectiveness of CTA

The CTA defense proved highly effective in restoring performance. On the WikiSQL dataset, a standard model's accuracy plummeted from 81.6% to 27.2% under adversarial attack. When trained with CTA, the same model's accuracy under attack rose to 69.2%.

Cross-Side Generalization

An unexpected benefit of CTA is its impact on question-side robustness. Models trained with table-side augmentation showed a 9.8% improvement on the Spider-Syn dataset, which only modifies the natural language questions. This suggests that forcing the model to understand schema variations also improves its general linguistic understanding of the relationship between questions and data structures.

Conclusion

This research highlights a significant gap in the reliability of current Text-to-SQL systems. By introducing the ADVETA benchmark and the CTA defense framework, the authors provide a path toward more resilient models that can handle the dynamic nature of real-world databases. While CTA significantly reduces the performance drop caused by schema perturbations, future work is needed to address more complex changes, such as data type modifications and more sophisticated schema linking that moves entirely beyond lexical matching.

Summary updated

BibTeX
@inproceedings{pi2022towards,
  author = {Xinyu Pi and Bing Wang and Yan Gao and Jiaqi Guo and Zhoujun Li and Jian-Guang Lou},
  title = {{Towards Robustness of Text-to-SQL Models Against Natural and Realistic Adversarial Table Perturbation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.142},
}
Figure