Text to SQL translation example with Huggingface transformers

Retraining T5 base model with WikiSQL dataset on Kaggle’s NVIDIA TESLA P100 GPU

Dmytro Iakubovskyi
Data And Beyond
Published in
3 min readApr 30, 2023

--

Photo by Caspar Camille Rubin on Unsplash

In this article, I closely follow up the detailed notebook from Manuel Romero with minor tweaks, such as replacing the T5 small model with the T5 base model (thus increasing the number of trainable parameters from 60M to about 223M). Full details of the analysis can be found in this public Kaggle notebook.

As a result of training during 5 epochs (taking about 2 hours of NVIDIA TESLA P100 GPU available for Kaggle users), the corresponding ROUGE2 Fscore is about 0.7904, or 2.86 percentage points higher than obtained in the initial notebook:

Source: author, text2sql_T5_retrain | Kaggle

Some of the predicted examples of text-to-SQL translation performed by the trained model, together with the expected SQL queries:

translate to SQL: What is terrence ross' nationality
Predicted: SELECT Nationality FROM table WHERE Player = Terrence Ross
Expected: SELECT Nationality FROM table WHERE Player = Terrence Ross

translate to SQL: how many schools or teams had jalen rose
Predicted: SELECT COUNT School/Club Team FROM table…

--

--

Dmytro Iakubovskyi
Data And Beyond

Top writer in AI, Movies | Senior data scientist | Editor in Data And Beyond | https://www.linkedin.com/in/dima806/