Ar-Spider: Text-to-SQL in Arabic

Saleh Almohaimeed, Saad Almohaimeed, Mansour Al Ghanim, Liqiang WangarXiv 2024 · DOI

TL;DR

Ar-Spider introduces the first cross-domain Text-to-SQL dataset for the Arabic language, bridging a significant gap in natural language interfaces for non-English speakers. To overcome the challenge of mapping Arabic questions to English database schemas, the authors propose a novel Context Similarity Relationship (CSR) approach using LASER embeddings, narrowing the performance gap between Arabic and English text-to-SQL parsing.

What Problem Does This Paper Address?

Text-to-SQL systems allow everyday users to query relational databases using natural language instead of writing complex code. While English-centric benchmarks (like the popular Spider dataset) have seen massive performance leaps, non-English languages are frequently left behind.

Developing an Arabic text-to-SQL system introduces two major hurdles:

  1. Schema Linguistic Challenge: Relational database schemas (tables and column names) are almost universally written in English. Traditional models rely on string matching to connect a user's question to a database column, which fails completely when the question is in Arabic script.
  2. SQL Structural Challenge: Mapping Arabic grammatical structures and vocabulary to rigid SQL clauses (SELECT, WHERE, GROUP BY) is inherently difficult due to the vast differences between the languages.

This paper tackles these challenges by creating a high-quality Arabic benchmark dataset and designing a cross-lingual alignment mechanism to map Arabic queries to English database structures.

Methods

The authors adapted two state-of-the-art English text-to-SQL baseline models, LGESQL and S²SQL, replacing their standard English text encoders with massive cross-lingual language models: mBERT and XLM-R.

To solve the cross-lingual schema linking problem, they introduced the Context Similarity Relationship (CSR) approach:

  • Instead of comparing characters, the system uses the Language-Agnostic Sentence Representations (LASER) model to project both the Arabic question tokens and the English database schema elements into a shared embedding space.
  • During preprocessing, the model calculates the cosine similarity between every Arabic question word and every English table/column name.
  • If the similarity score crosses a threshold of 78%, the system injects a new relationship edge into the model's question-schema interaction graph, explicitly telling the network that these two cross-lingual concepts are linked.
Figure 1: An illustration of the overall model architecture. There are three types of relations between nodes in the graph. Dot-line represents question-table-cosine-matches or question-column-cosine-matches. Bold-line represents question structure relationships between the nodes of the question tokens. Straight-line indicates schema structure relationships, such as primary and foreign keys. In the figure, the top right subgraph shows how question schema relations were created before CSR.

Datasets

The paper introduces Ar-Spider, a direct Arabic translation of the training and development sets of the English Spider dataset.

  • Dataset Statistics: It contains 9,691 questions and 5,277 distinct SQL queries spread across 166 databases spanning multiple domains.
  • Creation Process: To ensure high quality efficiently, the authors used a hybrid approach: they generated initial translations using GPT-3, had two native Arabic professional translators post-edit the text, and finally tasked three computer science graduate students with verifying that the Arabic questions perfectly matched the underlying SQL queries. This pipeline cut translation time down from an estimated 188 hours to just 80.1 hours while preserving rich word diversity.

Key Insights and Ideas

  • Semantic Alignment Over Syntax Matching: Standard English models rely heavily on exact or partial string matching (e.g., matching the word "customers" in a question to the table customers). For cross-lingual applications, semantic alignment via embedding spaces is mandatory.
  • LASER Outperforms mBERT/XLM for Alignment: In an ablation study comparing embedding spaces, the authors found that while mBERT and XLM-R often assign high similarity scores to completely unrelated words, LASER provides highly distinct, accurate cross-lingual mappings.
  • More Data Isn't Always Better: In similar studies for Russian and Portuguese, training models on a mix of English and the target language improved performance. Surprisingly, for Arabic, combining English and Arabic data degraded performance. The authors attribute this to Arabic's highly complex morphology (where nouns change form drastically based on case, number, and gender), suggesting that data augmentation for Arabic needs to happen alongside morphologically similar languages like Persian or Urdu instead of English.

Key Results

  • Baseline Performance: Without any special modifications, the best baseline combination (LGESQL + XLM-R) achieved an exact match accuracy of 65.57% on the Ar-Spider dataset.
  • The CSR Boost: Adding the Context Similarity Relationship (CSR) approach improved performance across all baseline variations. The top-performing configuration—LGESQL + XLM-R + CSR—achieved 66.63% accuracy, narrowing the performance gap between the Arabic and English versions of the dataset to just 7.73%.
  • For the S²SQL + XLM-R model, adding CSR yielded a notable 1.52% absolute accuracy improvement (rising from 62.48% to 64.00%).

Limitations and Future Work

While the CSR approach successfully mitigates the schema linguistic challenge, the negative results from mixing English and Arabic training data highlight a bottleneck in how cross-lingual models handle complex Arabic morphology.

The authors note that future work should explore leveraging Large Language Models (LLMs) more deeply or fine-tuning specialized encoder models explicitly dedicated to the Arabic-English schema linking task.

Summary updated

BibTeX
@misc{almohaimeed2024ar,
  author = {Saleh Almohaimeed and Saad Almohaimeed and Mansour Al Ghanim and Liqiang Wang},
  title = {{Ar-Spider: Text-to-SQL in Arabic}},
  year = {2024},
  eprint = {2402.15012},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.15012},
}
Figure