mRAT-SQL+GAP: A Portuguese Text-to-SQL Transformer

Marcelo Archanjo José, Fábio Gagliardi Cozman

TL;DR

This paper tackles the challenge of translating natural language questions into SQL queries for languages other than English, specifically Portuguese. They adapt a state-of-the-art English-centric model (RAT-SQL+GAP) by leveraging multilingual transformers and creating a Portuguese version of the popular Spider dataset, demonstrating that a combined English-Portuguese training approach yields the best results.

What Problem Does This Paper Address?

The field of Natural Language to SQL (NL2SQL) translation has seen significant advancements, primarily driven by transformer-based models. However, the vast majority of research and available datasets are focused on the English language. This leaves a gap for other languages, where the nuances of grammar, vocabulary, and cultural context can pose unique challenges for existing models. This paper aims to bridge this gap by developing and evaluating an NL2SQL system for Portuguese, investigating how to adapt existing English-centric models and datasets to a new linguistic domain.

Methods

The core of this work involves adapting the RAT-SQL+GAP system, a strong performer on English NL2SQL tasks. The authors made several key modifications:

  • Multilingual Model Adaptation: Instead of relying solely on English-specific language models, they experimented with multilingual models. Specifically, they fine-tuned a multilingual BART model (mBART-50) which is pre-trained on a wide range of languages, including Portuguese and English. They also explored BERTimbau, a Portuguese-specific BERT model.
  • Dataset Translation and Augmentation: They translated the widely-used Spider dataset's natural language questions into Portuguese. Crucially, they also experimented with combining the original English training data with the newly translated Portuguese data to create a larger, "double-size" training set.
  • Code Adaptation: Minor but necessary code modifications were made to handle UTF-8 encoding for Portuguese characters and to replace language-specific tools (like Stanford CoreNLP's lemmatizer) with multilingual alternatives (like Simplemma).

Datasets

  • Spider Dataset: This is the primary dataset used for both training and evaluation. The authors created a translated Portuguese version of the Spider dataset's questions.
  • Translated Spider Dataset: A new resource created by translating the natural language questions from the original Spider dataset into Portuguese. This dataset was used for training and testing the Portuguese NL2SQL capabilities.
  • Combined English and Portuguese Dataset: A larger training dataset created by merging the original English Spider training data with the translated Portuguese training data.

Key Insights and Ideas

  • Multilingual Training is Key: The most significant finding is that for non-English languages like Portuguese, a purely monolingual approach is suboptimal. Combining English and Portuguese data during training significantly improves performance, even when the target inference is solely in Portuguese. This suggests that leveraging the linguistic similarities and differences between languages can lead to more robust models.
  • Language Model Choice Matters: While BERTimbau (a Portuguese-specific BERT) showed low performance, the multilingual mBART-50 model, especially when fine-tuned on the combined dataset, demonstrated much stronger results. This highlights the advantage of using models pre-trained on a broader linguistic spectrum for cross-lingual transfer.
  • Direct Translation vs. Multilingual Approach: Simply translating questions and feeding them to an English-trained model might not be sufficient. The paper suggests that adapting the underlying model architecture and training strategy to be inherently multilingual is more effective.
  • SQL's Lingua Franca: Even when dealing with Portuguese questions, the generated SQL queries still use English keywords. This inherent linguistic mismatch between the input question and the output query structure can introduce challenges that multilingual models are better equipped to handle.

Key Results

The paper reports results using the Exact Set Match (ESM) metric without values.

  • Baseline (English): The original RAT-SQL+GAP model trained on English data achieved an ESM of 0.718 (All) on the English test set.
  • Portuguese-Only BERTimbau: Fine-tuning BERTimbau on Portuguese questions resulted in a low ESM of 0.417 (All).
  • Multilingual mBART-50:
    • Fine-tuned on English only, tested on English: 0.651 (All).
  • Fine-tuned on Portuguese only, tested on Portuguese: 0.588 (All).
  • Fine-tuned on English and Portuguese combined, tested on English: 0.664 (All). This is 92% of the English-only baseline.
  • Fine-tuned on English and Portuguese combined, tested on Portuguese: 0.595 (All). This is 83% of the English-only baseline.

The best result for Portuguese inference was achieved with the mBART-50 model fine-tuned on the combined English and Portuguese training dataset, yielding an ESM of 0.595.

Limitations and Future Work

  • Limitations:
    • The performance on Portuguese questions is still lower than on English questions, indicating room for improvement.
  • The paper notes that some questions require untranslated English words (e.g., proper nouns like "Boston Red Stockings") which can be challenging for models.
  • Real-world databases often use English table and column names even for Portuguese content, adding another layer of complexity.
  • Future Work:
    • Explore other multilingual transformers and seq-to-seq models.
  • Investigate the impact of larger language models, such as BERTimbau-large.
  • Extend the translation of the Spider dataset to other languages to enable simultaneous work with multiple languages.
  • Further research into handling mixed-language queries and database schemas.

Summary updated

BibTeX
@inproceedings{jose2021mrat,
  author = {Marcelo Archanjo José and Fábio Gagliardi Cozman},
  title = {{mRAT-SQL+GAP: A Portuguese Text-to-SQL Transformer}},
  booktitle = {BRACIS},
  year = {2021},
  url = {https://openreview.net/forum?id=2jEI6gQJErA},
}
Figure