MTAGEC is a unified framework for Arabic Grammatical Error Correction (AGEC) that performs:
Trained on ExplAGEC: the largest synthetic dataset for explainable AGEC, with 21.8M sentence pairs and 25 error types.
MTAGEC architecture: Arabic multi-task transformer for correction, error-type classification, and explanation
git clone https://github.com/Zainabobied/MTAGEC.git
cd MTAGEC
pip install -r requirements.txt
Step 1: Download the seed corpora
Step 2: Preprocess the corpora
Step 3: Generate the synthetic ExplAGEC dataset
python scripts/generate_dataset.py --input data/raw/seed_data.csv --output data/explagec/
Also, the dataset is available for download from Google Drive:
# Download AraBERT and AraT5v2 models
python scripts/setup_models.py
This script will download the following models:
The models will be saved to models/pretrained/ directory. You can specify a different directory using the --output-dir argument.
# Train MTAGEC model
python scripts/train_mtagec.py --config config/config.yaml
# Evaluate on ExplAGEC test set
python scripts/evaluate.py --config config/config.yaml --model_path models/checkpoints/mtagec_transformer/checkpoint-epoch-X --explagec
MTAGEC/
├── config/ # Configuration files
│ └── config.yaml
├── data/ # Data directory
│ ├── train.json/
│ ├── val.json/
│ └── test.json/
├── models/ # Model implementations
│ ├── checkpoints/
│ └── mtagec_transformer.py
├── scripts/ # Scripts for data processing and training
│ ├── evaluate.py # Evaluation script
│ ├── generate_dataset.py # Synthetic data generation
│ ├── train_mtagec.py # Model training
│ └── utils.py # Utility functions
├── README.md # This README
└── requirements.txt # Python dependencies
The ExplAGEC dataset is generated using the Arabic Explainable Error Generator (AEEG), which introduces 25 types of linguistic errors:
Example of synthetic data generated by AEEG:
{
"source": ["ذهب", "الولد", "الى", "المدرسة", "بسرعة", "."],
"target": ["ذهب", "الولد", "إلى", "المدرسة", "بسرعة", "."],
"evidence_index": [[2, 2]],
"correction_index": [[2, 2]],
"error_type": ["خطأ في التمييز بين الألف والياء"],
"error_classification": ["OA"],
"predicted_parsing_order": [
{
"0": 3,
"1": 3,
"2": 1,
"3": 3,
"4": 3,
"5": 3,
"6": 2,
"7": 3,
"8": 3
}
]
}
In this example:
Below are the required dependencies for running MTAGEC:
torch>=1.10.0
transformers>=4.18.0
datasets>=2.0.0
pyarabic>=0.6.15
arabert>=1.0.0
numpy>=1.20.0
scikit-learn>=1.0.0
tqdm>=4.62.0
pyyaml>=6.0
matplotlib>=3.5.0
seaborn>=0.11.2
pandas>=1.3.0
sacrebleu>=2.0.0
sentencepiece>=0.1.96
The Arabic Explainable Error Generator (AEEG) systematically introduces 25 types of linguistic errors based on the error taxonomy from Belkebir & Habash (2021) and Alfaifi (2014), covering morphological, syntactic, and orthographic errors. The AEEG algorithm follows these steps:
This process creates the ExplAGEC dataset with 21.8 million sentence pairs, featuring aligned error-type classifications and contextual evidence to address Arabic's linguistic complexities.
MTAGEC is based on Transformer encoder-decoder architecture with a unified softmax layer that combines:
The model supports different training configurations:
@article{mahmoud2023mtagec,
title={MTAGEC: Multi-Task Arabic Grammatical Error Correction as a sequence generation with Synthetic data},
author={Zeinab Mahmoud, Marco Zappatore, Natalia Kryvinska, Mohammed Abdalsalm, Ali Alfatemi, Aiman Solyman},
journal={Journal of King Saud University-Computer and Information Sciences},
year={2025}
}
MTAGEC is a unified framework for Arabic Grammatical Error Correction (AGEC) that performs:
Trained on ExplAGEC: the largest synthetic dataset for explainable AGEC, with 21.8M sentence pairs and 25 error types.
MTAGEC architecture: Arabic multi-task transformer for correction, error-type classification, and explanation
git clone https://github.com/Zainabobied/MTAGEC.git
cd MTAGEC
pip install -r requirements.txt
Step 1: Download the seed corpora
Step 2: Preprocess the corpora
Step 3: Generate the synthetic ExplAGEC dataset
python scripts/generate_dataset.py --input data/raw/seed_data.csv --output data/explagec/
Also, the dataset is available for download from Google Drive:
# Download AraBERT and AraT5v2 models
python scripts/setup_models.py
This script will download the following models:
The models will be saved to models/pretrained/ directory. You can specify a different directory using the --output-dir argument.
# Train MTAGEC model
python scripts/train_mtagec.py --config config/config.yaml
# Evaluate on ExplAGEC test set
python scripts/evaluate.py --config config/config.yaml --model_path models/checkpoints/mtagec_transformer/checkpoint-epoch-X --explagec
MTAGEC/
├── config/ # Configuration files
│ └── config.yaml
├── data/ # Data directory
│ ├── train.json/
│ ├── val.json/
│ └── test.json/
├── models/ # Model implementations
│ ├── checkpoints/
│ └── mtagec_transformer.py
├── scripts/ # Scripts for data processing and training
│ ├── evaluate.py # Evaluation script
│ ├── generate_dataset.py # Synthetic data generation
│ ├── train_mtagec.py # Model training
│ └── utils.py # Utility functions
├── README.md # This README
└── requirements.txt # Python dependencies
The ExplAGEC dataset is generated using the Arabic Explainable Error Generator (AEEG), which introduces 25 types of linguistic errors:
Example of synthetic data generated by AEEG:
{
"source": ["ذهب", "الولد", "الى", "المدرسة", "بسرعة", "."],
"target": ["ذهب", "الولد", "إلى", "المدرسة", "بسرعة", "."],
"evidence_index": [[2, 2]],
"correction_index": [[2, 2]],
"error_type": ["خطأ في التمييز بين الألف والياء"],
"error_classification": ["OA"],
"predicted_parsing_order": [
{
"0": 3,
"1": 3,
"2": 1,
"3": 3,
"4": 3,
"5": 3,
"6": 2,
"7": 3,
"8": 3
}
]
}
In this example:
Below are the required dependencies for running MTAGEC:
torch>=1.10.0
transformers>=4.18.0
datasets>=2.0.0
pyarabic>=0.6.15
arabert>=1.0.0
numpy>=1.20.0
scikit-learn>=1.0.0
tqdm>=4.62.0
pyyaml>=6.0
matplotlib>=3.5.0
seaborn>=0.11.2
pandas>=1.3.0
sacrebleu>=2.0.0
sentencepiece>=0.1.96
The Arabic Explainable Error Generator (AEEG) systematically introduces 25 types of linguistic errors based on the error taxonomy from Belkebir & Habash (2021) and Alfaifi (2014), covering morphological, syntactic, and orthographic errors. The AEEG algorithm follows these steps:
This process creates the ExplAGEC dataset with 21.8 million sentence pairs, featuring aligned error-type classifications and contextual evidence to address Arabic's linguistic complexities.
MTAGEC is based on Transformer encoder-decoder architecture with a unified softmax layer that combines:
The model supports different training configurations:
@article{mahmoud2023mtagec,
title={MTAGEC: Multi-Task Arabic Grammatical Error Correction as a sequence generation with Synthetic data},
author={Zeinab Mahmoud, Marco Zappatore, Natalia Kryvinska, Mohammed Abdalsalm, Ali Alfatemi, Aiman Solyman},
journal={Journal of King Saud University-Computer and Information Sciences},
year={2025}
}