A custom Sequence-to-Sequence (Seq2Seq) Transformer model fine-tuned for translating Egyptian Arabic (Masri) into English.
It pairs a pre-trained AraBERT encoder with a custom Transformer decoder to handle dialectal idioms, conversational nuances, and mixed code-switching.
aubmindlab/bert-base-arabertv02The table below demonstrates representative test set outputs comparing model translations against human reference targets:
| Egyptian Arabic Source | Model Output | Reference (Ground Truth) | Assessment |
|---|---|---|---|
| هو ده المحل | is this the place? |
is this the place? | Exact Match (100%) |
| لا لسه. | not yet. |
not yet. | Exact Match (100%) |
| او يمكن بقول عكس اللي بفكر فيه. | or maybe i say the opposite of what i think. |
or maybe i do say the opposite of what i think. | Grammatically Accurate |
| وحسك عينك تقول انك سمعت حاجة | and don t you dare say you heard something! |
don t you dare say you heard something | Idiomatic / Natural |
| ايه اكتر TV show زينه بتحبه | what's zeina's favorite tv show? |
now what's zeina's favorite television show? | Handles Ar-En Code-Switching |
| لاني عمري ما كنت حاسس اني تايه كده | i ve never felt this lost before. |
i've never felt this lost | Fluent Expression |
| مع اني باعمل كل حاجة عشان ارضيها. كل حاجة. | i mean i do everything just to please her! |
everything i do is to please her. | Contextually Fluent |
| انا مش غبي يا علا . | i'm not dumb ola. |
i'm not stupid ola. | Accurate Synonym Usage |
| ماشي هكلمك | okay i'll call you. |
i'll call you. | Conversational Match |
| قالي اني عنقاء. | he told me he was a phoenix. |
he said i'm a phoenix. | Preserves Core Semantics |
import torch
from transformers import AutoTokenizer
# Load AraBERT Tokenizer
arabic_tokenizer = AutoTokenizer.from_pretrained("aubmindlab/bert-base-arabertv02")
# Load Model Weights
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.load_state_dict(torch.load("best_arabert_seq2seq.pt")).to(device)
model.eval()
Sentence Length: Optimized for conversational expressions and medium-length sentences. For long multi-sentence paragraphs, split input text by punctuation before passing to inference.
Domain: Best suited for everyday speech, media subtitles, and social media text rather than formal Modern Standard Arabic (MSA) legal/news documents.