Views
No views yet
1import torch
2from src.inference import load_model_and_tokenizers, translate_sentence
3from src.config import get_config
4
5# Load model
6cfg = get_config()
7device = torch.device("cpu")
8model, tokenizer_src, tokenizer_trg = load_model_and_tokenizers(cfg, device)
9
10# Translate
11arabic_text = "مرحبا بالعالم"
12english_translation = translate_sentence(
13 model, tokenizer_src, tokenizer_trg, arabic_text, cfg, device
14)
15print(english_translation) # "Hello world"python main.pypython app.py| Metric | Greedy Decoding | Beam Search (k=3) |
|---|---|---|
| BLEU | 0.225 | 0.237 |
| WER | 0.694 | 0.701 |
| CER | 0.509 | 0.516 |
1@misc{arabic-english-transformer,
2 title={Arabic-English Translation Transformer},
3 author={Abdelrahman Mohamed},
4 year={2025},
5 url={https://github.com/Veto2922/transformer-arabic-english-translation}
6}