This project investigates the vulnerability of state-of-the-art Arabic transformer models to "script-switching"βthe practice of writing Arabic dialects (like Moroccan Darija) using Latin characters and numbers (Arabizi). By treating transliteration as a zero-effort adversarial attack, we demonstrate that models like AraBERT and DarijaBERT suffe
# Evaluating Script-Switching Robustness π‘οΈ
### Robustness Auditing of Arabic Transformer Models against Arabizi Adversarial Evasion
---
## π Overview
This repository contains the code and white paper for a controlled robustness audit of Arabic transformer models in the context of Moroccan misinformation detection.
We investigate a critical and largely unexplored vulnerability: **Script-Switching**.
Millions of Moroccan social media users write in **Arabizi** (Arabic phonemes using Latin characters/numbers). While AI systems are highly accurate on Arabic script, they are often "blind" to Arabizi. This study demonstrates that script-switching acts as a **zero-effort adversarial attack** that can bypass state-of-the-art detection systems with no technical expertise.
> **The Core Problem:** Most Arabic NLP models are trained and tested **exclusively on Arabic script**, creating a massive security gap on platforms where Arabizi is the dominant vernacular.
---
## π¬ Research Findings: The Robustness Paradox
Our study reveals a counterintuitive reality: **Higher benchmark accuracy does not predict greater operational reliability.**
| Model | Arabic F1 (Baseline) | Arabizi F1 (Adversarial) | Performance Drop |
|---|---|---|---|
| **DarijaBERT** | 0.7840 | 0.4979 | **β36.5%** |
| **AraBERT-Twitter** | 0.8725 | 0.3406 | **β60.9%** |
### π Visual Analysis
| Model | Baseline (Arabic) | Adversarial (Arabizi) |
|---|---|---|
| **DarijaBERT** | | |
| **AraBERT-Twitter** | | |
**Key Finding:** AraBERT-Twitter β the "stronger" model on standard Arabic β failed significantly harder on Arabizi, misclassifying **99%** of real news articles as fake.
---
## ποΈ Project Structure
```
code-switching/
βββ data/
β βββ train.csv # 16,000 training samples
β βββ val.csv # 2,000 validation samples
β βββ test.csv # 2,000 test samples (Arabic script)
β βββ test_arabizi.csv # 2,000 test samples (Arabizi β adversarial β¦