Views
No views yet
AfriNLLB-12enc-4dec-iterative-481m-ft is created using iterative layer pruning of AfriNLLB-12enc-12dec-full-ft-kd.
It is fine-tuned on both the AfriNLLB-train and AfriNLLB-train-distilled datasets. Please refer to the paper for more details.| Lang | Model | Enc | Dec | Params | V. | Quant | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| NLLB | 12 | 12 | 600M | n/a | 33.81 | 56.22 | 71.11 | 1469.96 | 21.02 | ||
| FP16 | 33.80 | 56.22 | 71.13 | 2834.69 | 10.92 | ||||||
| AfriNLLB | 12 | 12 | 600M | n/a | 35.15 | 57.61 | 71.87 | 1530.94 | 20.39 | ||
| FP16 | 35.10 | 57.61 | 71.87 | 2808.90 | 11.15 | ||||||
| AfriNLLB | 12 | 8 | 548M | n/a | 34.01 | 56.98 | 71.20 | 1807.61 | 17.38 | ||
| FP16 | 34.05 | 56.99 | 71.19 | 3513.32 | 8.96 | ||||||
| AfriNLLB | 12 | 6 | 514M | n/a | 33.35 | 56.48 | 70.79 | 2028.18 | 15.41 | ||
| FP16 | 33.32 | 56.45 | 70.79 | 4000.25 | 7.82 | ||||||
| AfriNLLB | 12 | 4 | 481M | 🟣 | n/a | 32.03 | 55.62 | 69.71 | 2257.03 | 13.77 | |
| 🟢 | FP16 | 32.01 | 55.60 | 69.71 | 4589.42 | 6.79 | |||||
| AfriNLLB | 8 | 8 | 498M | n/a | 30.89 | 54.32 | 68.08 | 1852.13 | 17.05 | ||
| FP16 | 30.86 | 54.30 | 68.08 | 3550.50 | 8.91 | ||||||
| NLLB | 12 | 12 | 600M | n/a | 22.70 | 47.89 | 69.36 | 1530.10 | 28.09 | ||
| FP16 | 22.68 | 47.88 | 69.38 | 2898.38 | 15.33 | ||||||
| AfriNLLB | 12 | 12 | 600M | n/a | 24.28 | 49.97 | 70.91 | 1610.23 | 26.98 | ||
| FP16 | 24.14 | 49.84 | 70.90 | 2811.34 | 18.82 | ||||||
| AfriNLLB | 12 | 8 | 548M | n/a | 24.17 | 50.05 | 70.37 | 1946.61 | 22.51 | ||
| FP16 | 24.15 | 50.06 | 70.41 | 3732.72 | 11.98 | ||||||
| AfriNLLB | 12 | 6 | 514M | n/a | 23.48 | 49.34 | 68.98 | 2265.87 | 18.50 | ||
| FP16 | 23.49 | 49.35 | 69.00 | 4428.68 | 9.65 | ||||||
| AfriNLLB | 12 | 4 | 481M | 🟣 | n/a | 21.77 | 47.80 | 65.68 | 2489.35 | 17.31 | |
| 🟢 | FP16 | 21.77 | 47.81 | 65.68 | 4954.62 | 9.09 | |||||
| AfriNLLB | 8 | 8 | 498M | n/a | 23.59 | 49.64 | 69.90 | 2015.53 | 21.34 | ||
| FP16 | 23.58 | 49.63 | 69.88 | 3851.13 | 11.34 | ||||||
| NLLB | 12 | 12 | 600M | n/a | 16.41 | 38.83 | 17.34 | 1475.48 | 26.46 | ||
| FP16 | 16.33 | 38.83 | 17.23 | 2850.66 | 13.71 | ||||||
| AfriNLLB | 12 | 12 | 600M | n/a | 17.91 | 40.45 | 18.47 | 1524.32 | 26.12 | ||
| FP16 | 17.83 | 40.42 | 18.37 | 2749.45 | 14.68 | ||||||
| AfriNLLB | 12 | 8 | 548M | n/a | 17.43 | 40.21 | 14.52 | 1845.09 | 21.61 | ||
| FP16 | 17.38 | 40.18 | 14.53 | 3569.23 | 11.17 | ||||||
| AfriNLLB | 12 | 6 | 514M | n/a | 16.52 | 39.44 | 11.78 | 2044.27 | 19.21 | ||
| FP16 | 16.54 | 39.42 | 11.68 | 3953.51 | 9.92 | ||||||
| AfriNLLB | 12 | 4 | 481M | 🟣 | n/a | 14.96 | 38.21 | 5.67 | 2340.99 | 16.77 | |
| 🟢 | FP16 | 14.90 | 38.17 | 5.71 | 4766.12 | 8.24 | |||||
| AfriNLLB | 8 | 8 | 498M | n/a | 14.42 | 37.05 | 3.14 | 1866.26 | 21.84 | ||
| FP16 | 14.34 | 36.97 | 3.14 | 3448.51 | 11.83 | ||||||
| NLLB | 12 | 12 | 600M | n/a | 9.44 | 33.42 | 19.25 | 1047.18 | 49.92 | ||
| FP16 | 9.52 | 33.40 | 19.38 | 1920.41 | 29.05 | ||||||
| AfriNLLB | 12 | 12 | 600M | n/a | 10.98 | 35.68 | 21.33 | 1081.84 | 51.56 | ||
| FP16 | 10.48 | 35.05 | 21.49 | 1700.25 | 51.31 | ||||||
| AfriNLLB | 12 | 8 | 548M | n/a | 10.20 | 35.21 | 20.04 | 1261.66 | 49.91 | ||
| FP16 | 10.11 | 35.13 | 20.03 | 2313.85 | 31.15 | ||||||
| AfriNLLB | 12 | 6 | 514M | n/a | 10.07 | 35.14 | 19.83 | 1416.33 | 30.89 | ||
| FP16 | 9.99 | 35.08 | 19.78 | 2465.60 | 18.68 | ||||||
| AfriNLLB | 12 | 4 | 481M | 🟣 | n/a | 7.57 | 32.42 | 14.16 | 1207.06 | 38.75 | |
| 🟢 | FP16 | 7.57 | 32.38 | 14.29 | 2069.52 | 23.25 | |||||
| AfriNLLB | 8 | 8 | 498M | n/a | 9.75 | 35.23 | 20.05 | 1222.83 | 45.33 | ||
| FP16 | 9.84 | 35.31 | 20.11 | 2186.73 | 25.97 |


pip3 install ctranslate2 sentencepiece transformers huggingface_hub1import os
2import ctranslate2
3import sentencepiece as spm
4from huggingface_hub import snapshot_download, hf_hub_download
5
6src_lang = "eng_Latn"
7tgt_lang = "amh_Ethi"
8
9source_sentences = [
10 "How are you doing today?",
11 "Africa has a diverse history and beautiful nature.",
12]
13
14# Download the CTranslate2 model
15model_name = "AfriNLP/AfriNLLB-12enc-4dec-iterative-481m-ft"
16
17# Use "ct2" for the non-quantized version
18# or "ct2-fp16" for the float16 quantized version
19ct2_dir = "ct2-fp16"
20
21model_dir = snapshot_download(
22 repo_id=model_name,
23 allow_patterns=[f"{ct2_dir}/*"]
24)
25ct2_model_path = os.path.join(model_dir, ct2_dir)
26
27# Download the SentencePiece BPE model
28spm_name = "sentencepiece.bpe.model"
29spm_path = os.path.join(ct2_model_path, "sentencepiece.bpe.model")
30if not os.path.exists(spm_path):
31 print("SP model cannot be found locally. Downloading from the baseline...")
32 hf_hub_download(
33 repo_id="facebook/nllb-200-distilled-600M",
34 filename=spm_name,
35 local_dir=ct2_model_path
36 )
37
38sp = spm.SentencePieceProcessor()
39sp.load(spm_path)
40translator = ctranslate2.Translator(ct2_model_path, device="cuda")
41
42print(f"Translating to {tgt_lang}..\n")
43
44# Tokenize the source texts
45encoded_source = sp.encode_as_pieces(source_sentences)
46encoded_source = [[src_lang] + s + ["</s>"] for s in encoded_source]
47
48# Translate
49results = translator.translate_batch(
50 encoded_source,
51 target_prefix = [[tgt_lang]] * len(encoded_source),
52 beam_size=5,
53 max_decoding_length=256,
54)
55
56# Decode the outputs and remove the language tag
57translations = []
58for res in results:
59 tokens = res.hypotheses[0]
60 if tokens and tokens[0] == tgt_lang:
61 tokens = tokens[1:]
62 text = sp.decode_pieces(tokens)
63 translations.append(text)
64
65for orig, trans in zip(source_sentences, translations):
66 print(f"Source ({src_lang}): {orig}\nTarget ({tgt_lang}): {trans}\n")1import torch
2from transformers import AutoModelForSeq2SeqLM, NllbTokenizerFast
3
4src_lang = "eng_Latn"
5tgt_lang = "amh_Ethi"
6
7source_sentences = [
8 "How are you doing today?",
9 "Africa has a diverse history and beautiful nature.",
10]
11
12# Load an AfriNLLB model
13model_name = "AfriNLP/AfriNLLB-12enc-4dec-iterative-481m-ft"
14model = AutoModelForSeq2SeqLM.from_pretrained(
15 model_name,
16 device_map="auto",
17 )
18
19# Load the NLLB tokenizer
20base_model_name = "facebook/nllb-200-distilled-600M"
21tokenizer = NllbTokenizerFast.from_pretrained(
22 base_model_name,
23 src_lang=src_lang,
24 )
25
26print(f"\nUsing device: {model.device}")
27print(f"Translating to {tgt_lang}..\n")
28
29# Tokenize the source sentences
30inputs = tokenizer(
31 source_sentences,
32 return_tensors="pt",
33 padding=True).to(model.device)
34
35forced_bos_token_id = tokenizer.convert_tokens_to_ids(tgt_lang)
36
37# Translate
38with torch.inference_mode():
39 translated_tokens = model.generate(
40 **inputs,
41 forced_bos_token_id=forced_bos_token_id,
42 max_length=256,
43 num_beams=5,
44 use_cache=True,
45 )
46
47# Decode the outputs and remove the language tag
48translations = tokenizer.batch_decode(
49 translated_tokens,
50 skip_special_tokens=True
51 )
52
53for orig, trans in zip(source_sentences, translations):
54 print(f"Source ({src_lang}): {orig}\nTarget ({tgt_lang}): {trans}\n")1@inproceedings{moslem-etal-2026-afrinllb,
2 title = "{A}fri{NLLB}: Efficient Translation Models for African Languages",
3 author = "Moslem, Yasmin and
4 Wassie, Aman Kassahun and
5 Gizachew, Amanuel",
6 booktitle = "Proceedings of the Seventh Workshop on African Natural Language Processing (AfricaNLP)",
7 month = mar,
8 year = "2026",
9 address = "Rabat, Morocco",
10 publisher = "Association for Computational Linguistics",
11 url = "https://openreview.net/forum?id=hVJZNUZBur",
12}