Instructions to use DarjaCore/darjacore-mt-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DarjaCore/darjacore-mt-base with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="DarjaCore/darjacore-mt-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("DarjaCore/darjacore-mt-base") model = AutoModelForSeq2SeqLM.from_pretrained("DarjaCore/darjacore-mt-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
DarjaCore-MT-Base: Algerian Darja → English
DarjaCore-MT-Base is a neural machine translation model that translates Algerian Darja (Algerian Arabic dialect, written mainly in Arabic script) into English. Translation runs in one direction only: Darja → English. It is a fine-tune of Helsinki-NLP/opus-mt-tc-big-ar-en and is part of DarjaCore, an open research effort to build datasets, translation models and tools for Algerian Darja.
Standard Arabic translation models handle Modern Standard Arabic well but struggle with Darja's vocabulary, French loanwords, spelling variation and informal social-media style. This model was adapted to that register.
| Direction | Algerian Darja → English |
| Architecture | Marian encoder-decoder Transformer |
| Base model | Helsinki-NLP/opus-mt-tc-big-ar-en |
| Parameters | ~300M |
| Tokenizer | SentencePiece (source.spm, target.spm) |
| Languages | ar (Darja) → en |
| License | CC-BY-4.0 (see License) |
A quantized CTranslate2 version for fast CPU inference is available at DarjaCore/darjacore-mt-base-ct2-int8.
Quick start
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model_id = "DarjaCore/darjacore-mt-base"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
texts = [
"عندك حق",
"وين رحتي",
"ربي يسهلك اخويا و ربي يهدينا",
]
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
output_ids = model.generate(**inputs, num_beams=4, max_new_tokens=128)
for source, translation in zip(
texts, tokenizer.batch_decode(output_ids, skip_special_tokens=True)
):
print(f"{source} -> {translation}")
Requirements: pip install transformers torch sentencepiece. Installing sacremoses is optional and only silences a tokenizer warning.
The evaluation numbers below were produced with num_beams=4 and max_new_tokens=128. Different decoding settings will give slightly different outputs.
Faster CPU inference with CTranslate2
For CPU deployment, use the int8 CTranslate2 conversion. It uses much less memory and decodes considerably faster on CPU than fp32 PyTorch. All reported quality numbers were measured on this int8 version.
import ctranslate2
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
repo_id = "DarjaCore/darjacore-mt-base-ct2-int8"
model_dir = snapshot_download(repo_id)
tokenizer = AutoTokenizer.from_pretrained(model_dir, use_fast=False)
translator = ctranslate2.Translator(
model_dir, device="cpu", compute_type="int8", intra_threads=6
)
texts = ["عندك حق", "وين رحتي"]
source = [
tokenizer.convert_ids_to_tokens(tokenizer.encode(text, truncation=True, max_length=512))
for text in texts
]
results = translator.translate_batch(
source, beam_size=4, max_decoding_length=128, max_batch_size=16
)
for result in results:
ids = tokenizer.convert_tokens_to_ids(result.hypotheses[0])
print(tokenizer.decode(ids, skip_special_tokens=True))
Requirements: pip install ctranslate2 transformers sentencepiece huggingface_hub.
Intended use
- Translating informal Algerian Darja text (social media posts, forum comments, chat messages) into English for comprehension, search, data exploration and research.
- Building or bootstrapping downstream Darja NLP resources, with human review of the output.
- A baseline for further research on Algerian dialectal Arabic machine translation.
Out-of-scope use
- Legal, medical, financial, immigration or any other safety-critical translation.
- Translating text where a mistranslation could cause harm without human review.
- Translating Modern Standard Arabic or other Arabic dialects: other models are likely a better fit.
- English → Darja translation. This model translates in one direction only.
- Use as an authoritative source for religious texts. Religious formulas are often rendered loosely.
Training data
The model was fine-tuned on a parallel corpus of Algerian Darja sentences paired with English translations.
- Source side: Darja text collected from public Algerian online sources such as forums and comment threads, cleaned and filtered (deduplication, removal of non-Arabic and low-quality posts).
- Target side: English references that are at least partly machine-generated (LLM) and were not systematically reviewed by human translators.
- Size:
245,734parallel sentence pairs for training,12,934for validation, and2,808pairs in the held-out test set.
The training and test data are not redistributed in this repository. See Limitations for what this implies about quality.
Evaluation
Evaluated on the held-out test set (2,808 sentence pairs) with sacreBLEU default settings (BLEU with 13a tokenization, chrF and chrF++ with word_order=2).
| Version | BLEU | chrF | chrF++ |
|---|---|---|---|
| int8 (CTranslate2) | 16.56 | 36.75 | 35.40 |
Reading these numbers. The reference translations are partly machine-generated and noisy, and some contain explanatory notes or mistranslations, so absolute scores understate real translation quality and should not be compared directly with scores on clean benchmarks. They are most useful for comparing model versions and decoding settings on the same data.
Illustrative outputs
Selected outputs from internal testing (not cherry-picked for the best case; see failures under Limitations).
| Darja | Output |
|---|---|
| عندك حق | You are right |
| وين رحتي | Where did you go |
| تخافيش مراحش ناكلك | Don't be afraid, I won't eat you |
| ربي يسهلك اخويا و ربي يهدينا | May God make it easy for you my brother and may God guide us |
| لاتهتم | Don't worry |
Limitations
This is a research model with known weaknesses.
- Noisy training signal. Because English references are partly LLM-generated, the model can inherit their errors, omissions and stylistic quirks.
- Romanized Darja (Arabizi) is poorly supported. Inputs such as
Rani cv hmdlhorBdit ta3rag bred malkare usually copied or transliterated instead of translated. - Very short and ambiguous inputs are often mistranslated, since there is little context (for example, a single word can be rendered as a transliteration).
- Proper nouns and place names can be wrong. In internal tests the Arabic word for Bahrain was translated as a different country.
- Idioms and slang are frequently translated literally and lose their meaning.
- Religious formulas and long sentences can degrade, and long inputs may trigger repeated phrases. Truncating very long inputs or splitting them into sentences helps.
- Emoji, decorative Unicode and mixed scripts may be dropped or handled inconsistently.
- Dialectal variation. Darja differs by region and speaker. Coverage is uneven across regions and spellings.
- Bias. The model reflects the content and attitudes of the online sources it was trained on, including potentially offensive language, stereotypes and the loose translation of slurs.
Please have important translations reviewed by a fluent human speaker.
Training procedure
- Method: full fine-tuning of the base model on Darja → English sentence pairs.
- Tokenizer: the base model's SentencePiece vocabulary (
source.spm,target.spm,vocab.json). - Hyperparameters: learning rate
2e-5, batch size32, max sequence length128,20,000training steps with500warmup steps, AdamW optimizer (betas=(0.9, 0.98),weight_decay=0.01), cosine learning rate schedule, gradient clipping1.0, mixed precision (AMP). - Hardware: 2× NVIDIA T4 (training time: 4h 4m 5s).
Reproducing the evaluation
pip install transformers torch sentencepiece ctranslate2 sacrebleu
python scripts/test_helsinki.py --data data/processed/test.jsonl --count 2808 --seed 42 --backend ct2 --num-beams 4 --output runs/final_ct2_int8.jsonl
License
The base model Helsinki-NLP/opus-mt-tc-big-ar-en is released under CC-BY-4.0, and this fine-tuned model is released under the same license, with attribution to the OPUS-MT authors.
The fine-tuning data was collected from public online sources and its English side is machine-generated. The data is not included here, and no redistribution rights for it are granted or implied. If you build on this model, make sure your use also complies with the terms of any data you add.
Citation
If you use this model, please cite DarjaCore and the OPUS-MT work it builds on.
@misc{darjacore_darja_en_2026,
title = {DarjaCore-MT-Base: Algerian Darja to English machine translation},
author = {{DarjaCore}},
year = {2026},
howpublished = {\url{https://huggingface.co/DarjaCore/darjacore-mt-base}}
}
@inproceedings{tiedemann-thottingal-2020-opus,
title = {{OPUS}-{MT} {--} Building open translation services for the World},
author = {Tiedemann, J{\"o}rg and Thottingal, Santhosh},
booktitle = {Proceedings of the 22nd Annual Conference of the European Association for Machine Translation},
year = {2020},
address = {Lisboa, Portugal},
publisher = {European Association for Machine Translation},
url = {https://aclanthology.org/2020.eamt-1.61},
pages = {479--480}
}
Contact
Questions, bug reports and contributions: open a discussion on this model's page or visit the DarjaCore organization.
- Downloads last month
- 42
Model tree for DarjaCore/darjacore-mt-base
Base model
Helsinki-NLP/opus-mt-tc-big-ar-en