AraSpider: Democratizing Arabic-to-SQL

Ahmed Heakl, Youssef Mohamed, Ahmed B. ZakyarXiv 2024

Abstract

This study presents AraSpider, the first Arabic version of the Spider dataset, aimed at improving natural language processing (NLP) in the Arabic-speaking community. Four multilingual translation models were tested for their effectiveness in translating English to Arabic. Additionally, two models were assessed for their ability to generate SQL queries from Arabic text. The results showed that using back translation significantly improved the performance of both ChatGPT 3.5 and SQLCoder models, which are considered top performers on the Spider dataset. Notably, ChatGPT 3.5 demonstrated high-quality translation, while SQLCoder excelled in text-to-SQL tasks. The study underscores the importance of incorporating contextual schema and employing back translation strategies to enhance model performance in Arabic NLP tasks. Moreover, the provision of detailed methodologies for reproducibility and translation of the dataset into other languages highlights the research's commitment to promoting transparency and collaborative knowledge sharing in the field. Overall, these contributions advance NLP research, empower Arabic-speaking researchers, and enrich the global discourse on language comprehension and database interrogation.

Introduction

While Natural Language Processing (NLP) has made massive strides in converting English questions into SQL queries (text-to-SQL), other languages—especially Arabic—have been left behind. Arabic is spoken by over 370 million people, yet most high-quality datasets for training database interfaces are English-only.

The "Spider" dataset is the gold standard for this field because it features complex queries across hundreds of different databases. However, translating it isn't just about swapping words; it requires maintaining the relationship between the natural language question and the underlying technical database schema (tables and columns). This paper introduces AraSpider, aiming to democratize database access for Arabic speakers by providing a high-quality benchmark and a proven pipeline for building these systems.

Methodology and Datasets

The authors employed a multi-step approach to create and validate AraSpider using the original Spider 1.0 dataset (10,181 questions across 200 databases) as a foundation.

Context-Aware Translation

Instead of literal translation, the researchers used ChatGPT 3.5 with prompt engineering. By providing the model with the database schema alongside the English question, they ensured the translation remained technically accurate. This "schema context" proved vital; as shown in the evaluation of translation models, providing context improved the quality score significantly compared to zero-context translations.

Comparison of translation model performance showing the benefit of schema context for ChatGPT 3.5.

Validation and Pipeline

Two native Arabic-speaking authors post-edited the translations to ensure cultural nuance. To evaluate text-to-SQL performance, the team compared a Direct strategy (Arabic Question → SQL) against a Back-Translation pipeline (Arabic Question → English Question → SQL). They tested several translation engines and two primary text-to-SQL models: ChatGPT 3.5 and SQLCoder 7b-2.

Key Insights

  • Schema Context is King: Translating technical questions is more effective when the AI knows the database structure (e.g., column names like Manager_ID).
  • Specialization Beats Generalization: While ChatGPT is a versatile large language model, SQLCoder—a smaller model specialized for code generation—consistently outperformed it in generating accurate SQL.
  • The "English Bridge" Advantage: Most databases use English schemas. Translating an Arabic question into English first (back-translation) allows the model to more accurately map the natural language to the database structure.

Results

The study measured Execution Accuracy to determine if the generated SQL returned the correct data. The results highlight a massive performance jump when moving from direct processing to a back-translation pipeline.

Execution accuracy results for ChatGPT and SQLCoder across direct and back-translation strategies.

As illustrated, SQLCoder using the back-translation strategy achieved the highest accuracy at 85.4%, compared to only 48.9% for direct Arabic processing. This confirms that a specialized pipeline is currently more effective than forcing models to process technical tasks directly in Arabic.

Limitations and Future Work

While AraSpider marks a significant step forward, the actual data within the databases (e.g., city names) remains in English, limiting the testing of localized data values. Future work will explore larger models like GPT-4 or SQLCoder 70b, which may possess emergent abilities to handle direct Arabic-to-SQL tasks more effectively. Additionally, the authors plan to expand this pipeline to other datasets like WikiSQL to further enrich the Arabic NLP ecosystem.

Summary updated

BibTeX
@misc{heakl2024araspider,
  author = {Ahmed Heakl and Youssef Mohamed and Ahmed B. Zaky},
  title = {{AraSpider: Democratizing Arabic-to-SQL}},
  year = {2024},
  eprint = {2402.07448},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.07448},
}
Figure