An Exploratory Study on Model Compression for Text-to-SQL

Shuo Sun, Yuze Gao, Yuchen Zhang, Jian Su, Bin Chen, Yingzhan Lin, Shuqi SunACL 2023

Abstract

State-of-the-art Text-to-SQL models, while accurate, often suffer from high computational costs that hinder real-world deployment. This study investigates the efficacy of model compression techniques—specifically layer pruning, knowledge distillation, and token pruning—across different model architectures. Our findings reveal that "sketch-based" models, which utilize slot-filling templates, are significantly more resilient to compression and offer better latency than traditional sequence-to-sequence (Seq2Seq) models.

Introduction

Text-to-SQL systems aim to bridge the gap between natural language and structured databases, enabling users to query data without SQL knowledge. However, the current state-of-the-art (SOTA) relies on massive transformer-based models like T5 and BERT. These models impose a "computational tax," requiring substantial memory and high-end GPUs, which results in unacceptable latency for many production environments. This research explores whether standard compression techniques can yield "production-ready" models without compromising accuracy.

Methodology

The study evaluates two primary architectural paradigms for Text-to-SQL:

  1. Sequence-to-Sequence (Seq2Seq): Models such as BRIDGE, RAT-SQL, and PICARD generate SQL statements token-by-token.
  2. Sketch-based (Slot-filling): Models like NL2SQL-RULE employ pre-defined SQL templates and use classifiers to fill in specific "slots" (e.g., table names, columns).

Three compression strategies were applied:

  • Layer Pruning: Removing the top $N$ layers of the transformer prior to fine-tuning.
  • Knowledge Distillation: Training compact "student" models (e.g., MiniLM, TinyBERT) to replicate the behavior of larger "teacher" models.
  • Token Pruning: Reducing the number of tokens processed by the encoder based on attention scores, specifically tested on the PICARD model.

The evaluation spanned three datasets: WikiSQL (simple English queries), Spider (complex English queries with joins), and TableQA (simple Chinese queries).

Key Insights and Ideas

The Decoding Bottleneck

A critical finding is that Seq2Seq models spend 76% to 87% of their inference time in the decoding phase. Sketch-based models circumvent this bottleneck by using fast classifiers instead of autoregressive generation, making them inherently more efficient for low-latency applications.

Sketch-based Models are "Compression-Friendly"

Sketch-based models demonstrate remarkable stability when compressed. Unlike Seq2Seq models, which often experience volatile performance drops as layers are removed, sketch-based architectures maintain high accuracy even with significant pruning.

Comparison of Seq2Seq (RAT-SQL) and Sketch-based (NL2SQL-RULE) models on the complex Spider dataset.

Simple Tasks, Simple Models

For datasets with lower complexity, such as WikiSQL, the study found that up to 50% of a model's layers can be pruned with less than a 1% decrease in accuracy. This suggests that for many practical business use cases, full-scale SOTA models are unnecessarily large.

Key Results

The experiments yielded several significant outcomes:

  • Significant Speedups: Layer pruning on simple datasets achieved 5-6x speedups with minimal performance impact.
  • Encoder Resilience: On the Spider benchmark, the RAT-SQL model maintained 92.6% of its original performance even when reduced to only six encoder layers.
  • Pruning vs. Distillation: For the BRIDGE model on WikiSQL, simple layer pruning surprisingly outperformed knowledge distillation (using MiniLM) when comparing models of equivalent depth.
Exact Set Match performance on WikiSQL for BRIDGE and NL2SQL-RULE as layers are pruned.

Limitations and Future Work

While compression is effective for moderately sized models, it remains challenging for extremely large models like PICARD (T5-3B). Token pruning on PICARD resulted in a negligible 5.2% speedup at the cost of a 26.3% performance drop. Future research should investigate Neural Architecture Search (NAS) and Quantization to further optimize these "heavyweight" models. Additionally, validating these compressed models on more diverse, real-world databases is essential for ensuring their practical utility.

Summary updated

BibTeX
@inproceedings{sun2023exploratory,
  author = {Shuo Sun and Yuze Gao and Yuchen Zhang and Jian Su and Bin Chen and Yingzhan Lin and Shuqi Sun},
  title = {{An Exploratory Study on Model Compression for Text-to-SQL}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=KqSXFk0PMu},
}
Figure