A newer version of this model is available: AfriNLP/AfriNLLB-12enc-12dec-full-ft-kd

AfriNLLB

AfriNLLB is a series of efficient multilingual open-source models for African languages.

Model Description

AfriNLP/AfriNLLB-12enc-12dec-full-ft is a fully fine-tuned version of NLLB-200 600M on the AfriNLP/AfriNLLB-train dataset, without any pruning.

Supported Languages

AfriNLLB supports 15 language pairs (30 translation directions), including Swahili, Hausa, Yoruba, Amharic, Somali, Zulu, Lingala, Afrikaans, Wolof, and Egyptian Arabic, as well as other African Union official languages such as Arabic (MSA), French, Portuguese, and Spanish. Our training data covers bidirectional translation between English and 13 languages, and between French and two languages (Lingala and Wolof).

Model Details

  • Model type: Translation
  • Base model: facebook/nllb-200-distilled-600M
  • Training data: AfriNLP/AfriNLLB-train
  • Test data: facebook/flores
  • Architecture: 12 encoder layers, 12 decoder layers
  • Pruning: No

Evaluation Results

How to Use

This model can be used for inference with either CTranslate2 or Transformers. The CTranslate2 models are faster and recommended for production. It has two versions, one with float16 quantization ("ct2-fp16") and one without quantization ("ct2"). You can also try the Transformers version, but it is better suited for fine-tuning For detailed code, please refer to the AfriNLLB repositories on GitHub.

pip3 install ctranslate2 sentencepiece transformers huggingface_hub

CTranslate2 version

import os
import ctranslate2
import sentencepiece as spm
from huggingface_hub import snapshot_download, hf_hub_download

src_lang = "eng_Latn"
tgt_lang = "amh_Ethi"

source_sentences = [
    "How are you doing today?",
    "Africa has a diverse history and beautiful nature.",
]

# Download the CTranslate2 model
model_name = "AfriNLP/AfriNLLB-12enc-12dec-full-ft"

# Use "ct2" for the non-quantized version 
# or "ct2-fp16" for the float16 quantized version
ct2_dir = "ct2-fp16"

model_dir = snapshot_download(
    repo_id=model_name,
    allow_patterns=[f"{ct2_dir}/*"]
)
ct2_model_path = os.path.join(model_dir, ct2_dir)

# Download the SentencePiece BPE model
spm_name = "sentencepiece.bpe.model"
spm_path = os.path.join(ct2_model_path, "sentencepiece.bpe.model")
if not os.path.exists(spm_path):
    print("SP model cannot be found locally. Downloading from the baseline...")
    hf_hub_download(
        repo_id="facebook/nllb-200-distilled-600M", 
        filename=spm_name, 
        local_dir=ct2_model_path
        )

sp = spm.SentencePieceProcessor()
sp.load(spm_path)
translator = ctranslate2.Translator(ct2_model_path, device="cuda")

print(f"Translating to {tgt_lang}..\n")

# Tokenize the source texts
encoded_source = sp.encode_as_pieces(source_sentences)
encoded_source = [[src_lang] + s + ["</s>"] for s in encoded_source]

# Translate
results = translator.translate_batch(
    encoded_source,
    target_prefix = [[tgt_lang]] * len(encoded_source),
    beam_size=5,
    max_decoding_length=256,
)

# Decode the outputs and remove the language tag
translations = []
for res in results:
    tokens = res.hypotheses[0]
    if tokens and tokens[0] == tgt_lang:
       tokens = tokens[1:]
    text = sp.decode_pieces(tokens)
    translations.append(text)

for orig, trans in zip(source_sentences, translations):
    print(f"Source ({src_lang}): {orig}\nTarget ({tgt_lang}): {trans}\n")

Transformers version

import torch
from transformers import AutoModelForSeq2SeqLM, NllbTokenizerFast

src_lang = "eng_Latn"
tgt_lang = "amh_Ethi"

source_sentences = [
    "How are you doing today?",
    "Africa has a diverse history and beautiful nature.",
]

# Load an AfriNLLB model
model_name = "AfriNLP/AfriNLLB-12enc-12dec-full-ft"
model = AutoModelForSeq2SeqLM.from_pretrained(
    model_name, 
    device_map="auto",
    )

# Load the NLLB tokenizer
base_model_name = "facebook/nllb-200-distilled-600M"
tokenizer = NllbTokenizerFast.from_pretrained(
    base_model_name,
    src_lang=src_lang,
    )

print(f"\nUsing device: {model.device}")
print(f"Translating to {tgt_lang}..\n")

# Tokenize the source sentences
inputs = tokenizer(
    source_sentences, 
    return_tensors="pt", 
    padding=True).to(model.device)

forced_bos_token_id = tokenizer.convert_tokens_to_ids(tgt_lang)

# Translate
with torch.inference_mode():
    translated_tokens = model.generate(
        **inputs,
        forced_bos_token_id=forced_bos_token_id,
        max_length=256,
        num_beams=5,
        use_cache=True,
    )

# Decode the outputs and remove the language tag
translations = tokenizer.batch_decode(
    translated_tokens, 
    skip_special_tokens=True
    )

for orig, trans in zip(source_sentences, translations):
    print(f"Source ({src_lang}): {orig}\nTarget ({tgt_lang}): {trans}\n")

Citation

If you use any of AfriNLLB models, datasets, or approaches, please cite the following paper:

@inproceedings{moslem-etal-2026-afrinllb,
    title = "{A}fri{NLLB}: Efficient Translation Models for African Languages",
    author = "Moslem, Yasmin  and
      Wassie, Aman Kassahun  and
      Gizachew, Amanuel",
    booktitle = "Proceedings of the Seventh Workshop on African Natural Language Processing (AfricaNLP)",
    month = jul,
    year = "2026",
    address = "Rabat, Morocco",
    publisher = "Association for Computational Linguistics",
}
Downloads last month
107
Safetensors
Model size
0.6B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for AfriNLP/AfriNLLB-12enc-12dec-full-ft

Finetuned
(259)
this model

Dataset used to train AfriNLP/AfriNLLB-12enc-12dec-full-ft

Collection including AfriNLP/AfriNLLB-12enc-12dec-full-ft