Transformers
Safetensors
Arabic
t5
text2text-generation
saudi
nlp
error-correction
text-generation-inference
Instructions to use NAMAA-Space/SaudiSpell-AraT5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NAMAA-Space/SaudiSpell-AraT5 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("NAMAA-Space/SaudiSpell-AraT5") model = AutoModelForSeq2SeqLM.from_pretrained("NAMAA-Space/SaudiSpell-AraT5", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Create EADME.md
Browse files
EADME.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- FatimahEmadEldin/SaudiSpell-Error-Injection
|
| 5 |
+
language:
|
| 6 |
+
- ar
|
| 7 |
+
metrics:
|
| 8 |
+
- wer
|
| 9 |
+
base_model:
|
| 10 |
+
- UBC-NLP/AraT5-base
|
| 11 |
+
tags:
|
| 12 |
+
- auto-correction
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# SaudiSpell-AraT5: Balanced Saudi Dialect Spelling Correction
|
| 18 |
+
|
| 19 |
+
**SaudiSpell-AraT5** is a sequence-to-sequence spelling correction model fine-tuned on a massive, balanced corpus of Saudi Dialectal Arabic. Unlike generic Arabic correctors, this model is specifically engineered to handle the nuances of **Najdi**, **Hijazi**, and **Standard Saudi** dialects alongside Modern Standard Arabic (MSA).
|
| 20 |
+
|
| 21 |
+
## Model Description
|
| 22 |
+
|
| 23 |
+
- **Base Model:** [UBC-NLP/AraT5-base](https://huggingface.co/UBC-NLP/AraT5-base)
|
| 24 |
+
- **Task:** Grammatical Error Correction (GEC) / Spelling Correction
|
| 25 |
+
- **Dialect Coverage:**
|
| 26 |
+
- 🛡️ **Najdi** (33% of training data)
|
| 27 |
+
- 🕋 **Hijazi** (33% of training data)
|
| 28 |
+
- 🇸🇦 **Standard Saudi** (33% of training data)
|
| 29 |
+
|
| 30 |
+
## Training Methodology
|
| 31 |
+
|
| 32 |
+
The model was trained on **3 Million sentences** with a strict **Balanced Sampling Strategy** to prevent the majority dialect from dominating. Rare dialects were oversampled 50x to match the volume of web-crawled data.
|
| 33 |
+
|
| 34 |
+
### Synthetic Error Injection
|
| 35 |
+
To mimic real-world noisy text, we used a "Saudi-Calibrated" error injection framework. The training data consists of **20%** of each of the following error types:
|
| 36 |
+
1. **⌨️ Keyboard Typos:** Adjacency errors based on the Arabic keyboard layout.
|
| 37 |
+
2. **🗣️ Phonetic Substitutions:** Common dialectal sound-alike errors (e.g., Qaf variations).
|
| 38 |
+
3. **👁️ Visual Substitutions:** Look-alike character errors.
|
| 39 |
+
4. **❌ Deletions & Insertions:** Random character noise mimicking fast typing.
|
| 40 |
+
5. **✂️ Space Stripping:** Merged words mimicking ASR artifacts or missing spaces.
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
You can use this model with the Hugging Face `transformers` library.
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 48 |
+
|
| 49 |
+
model_name = "{FULL_REPO_ID}"
|
| 50 |
+
|
| 51 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 52 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 53 |
+
|
| 54 |
+
def correct_text(text):
|
| 55 |
+
# Note: The model was trained with the prefix "correct: "
|
| 56 |
+
input_text = "correct: " + text
|
| 57 |
+
|
| 58 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=128, truncation=True)
|
| 59 |
+
|
| 60 |
+
outputs = model.generate(
|
| 61 |
+
**inputs,
|
| 62 |
+
max_new_tokens=128,
|
| 63 |
+
num_beams=5, # Beam search for better quality
|
| 64 |
+
early_stopping=True
|
| 65 |
+
)
|
| 66 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 67 |
+
|
| 68 |
+
# Example (Hijazi/Najdi Mix)
|
| 69 |
+
noisy_text = "kif 7alak ya 9adi8i" # Arabizi/Typos support
|
| 70 |
+
print(correct_text(noisy_text))
|
| 71 |
+
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Limitations
|
| 75 |
+
|
| 76 |
+
* The model is optimized for short-to-medium length sentences (social media, chat).
|
| 77 |
+
* While robust to some Arabizi (Latin script Arabic), it performs best on Arabic script input.
|