Sunflower Translate (NLLB-1.3B, salt-69)
Sunbird-experimental/nllb1.3b-67languages is
NLLB-200 1.3B fine-tuned by
Sunbird AI to translate between English and 74 other
languages. Most are spoken in Uganda; the rest are from elsewhere in Africa,
plus French. It translates in any direction between these languages, including
between two non-English languages.
It is a small, fast alternative to the Sunflower LLMs for translation only. On the salt-69 benchmark it averages 45.4 chrF, against 46.5 for Sunflower-Qwen3.5-27B -- about 1 chrF point behind a model 20x its size -- and 31.6 for the NLLB-200 1.3B checkpoint it was fine-tuned from. In the eng->xx directions the two are level (41.8 against 42.0), and this model is ahead in 38 of the 69. See Evaluation.
This release adds a GRPO post-training stage on top of supervised fine-tuning. Its clearest effect is on degenerate output rather than on average quality: the length ratio falls from 1.27 to 1.16, the number of eng->xx directions that generate more than twice the reference length falls from 12 to 4, and repetition loops in eng->xx output fall from 6.6% of sentences to 5.5%. Average chrF is 1.7 points above the previous release, of which 0.3 comes from GRPO and the rest from a revised SFT recipe. See Training details.
Additions to standard NLLB:
- 42 languages NLLB doesn't support, through repurposed language tokens (see Language codes). Almost all of the gain over base NLLB-200 sits here: 14.7 -> 36.5 chrF on those languages, against 51.1 -> 55.7 on the 32 that NLLB-200 already covered.
- The source language is optional. The model was trained to translate with or without being told the source language. This is useful for code-switched text, or when the source language is unknown. Leaving it out costs only about 0.3 chrF on average.
Status: experimental. Quality varies a lot by language: from strong (Afrikaans, Zulu, Swahili, Chichewa) to unusable (Ikposo, Lendu, and Berber eng->xx). Read Limitations before using it for a particular language.
Quick start
pip install torch transformers sentencepiece sacremoses huggingface_hub
import json
import re
import torch
from huggingface_hub import hf_hub_download
from sacremoses import MosesPunctNormalizer
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
MODEL_ID = 'Sunbird-experimental/nllb1.3b-67languages'
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSeq2SeqLM.from_pretrained(
MODEL_ID, dtype=torch.bfloat16).to(device).eval()
# SALT language code (e.g. 'lug') -> NLLB language token (e.g. 'lug_Latn').
with open(hf_hub_download(MODEL_ID, 'nllb_language_codes.json')) as f:
LANG_CODES = json.load(f)
UNKNOWN_SOURCE = 'und' # Source language not specified
_punct = MosesPunctNormalizer(
pre_replace_unicode_punct=True, post_remove_control_chars=True,
norm_quote_commas=False, norm_numbers=False)
def normalize(text):
'''Applies the same normalization as in training: typographic quotes and
dashes -> ASCII, whitespace collapsed, control characters removed.'''
text = re.sub(r'\s+', ' ', text)
text = text.replace('̇', '').replace('̦', '')
return _punct.normalize(text)
@torch.no_grad()
def translate(texts, tgt_lang, src_lang=None, num_beams=4):
'''Translates a list of texts into tgt_lang (a SALT code such as 'lug').
src_lang is optional; leave it as None if unknown or code-switched.'''
src_token = LANG_CODES[src_lang or UNKNOWN_SOURCE]
inputs = tokenizer([normalize(t) for t in texts], return_tensors='pt',
padding=True, truncation=True, max_length=512).to(device)
# NLLB puts the source-language token first: set it explicitly.
inputs['input_ids'][:, 0] = tokenizer.convert_tokens_to_ids(src_token)
# Cap the output length to stop runaway repetition on weaker languages.
max_new_tokens = min(512, 2 * inputs['input_ids'].shape[1] + 10)
outputs = model.generate(
**inputs,
forced_bos_token_id=tokenizer.convert_tokens_to_ids(LANG_CODES[tgt_lang]),
num_beams=num_beams, max_new_tokens=max_new_tokens, max_length=None)
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
print(translate(['How are you this morning?',
'Farmers should plant their crops before the rains begin.'],
tgt_lang='lug', src_lang='eng'))
# ['Oli otya enkya eno?',
# "Abalimi basaanidde okusimba ebirime byabwe ng'enkuba tennatandika."]
print(translate(['Abaana bagenda ku ssomero.'], tgt_lang='eng')) # no source language
# ['Children go to school.']
print(translate(['Abaana bagenda ku ssomero.'], tgt_lang='ach', src_lang='lug'))
# ['Lutino gicito i cukul.']
The model needs about 3 GB of GPU memory in bfloat16. It also runs on CPU, more slowly.
Why not tokenizer.src_lang / pipeline('translation')?
The standard NLLB recipe (tokenizer.src_lang = 'lug_Latn', or the
translation pipeline with src_lang/tgt_lang) works for languages with
a native NLLB code. The code above is more general:
- It uses the SALT codes from
nllb_language_codes.json. You don't need to know which NLLB token stands for each language. - It supports
src_lang=None(theundtoken), which the standard tokenizer doesn't know about. - It applies the input normalization the model was trained with.
Language codes
Use the SALT codes (mostly ISO 639-3) below for src_lang and tgt_lang.
nllb_language_codes.json in this repo maps each one to an NLLB language
token:
- Native codes: 33 languages (including English) use their own NLLB
token, e.g.
lug→lug_Latn,swa→swh_Latn,orm→gaz_Latn,mlg→plt_Latn. - Repurposed codes: 42 languages NLLB doesn't support reuse the token of
a European language that this model doesn't translate. For example, Acholi
ach→fur_Latn(Friulian), Runyankolenyn→lim_Latn, and Atesoteo→lmo_Latn. The NLLB language named in such a token is not a supported language. For example, asking forfur_Latngives Acholi, not Friulian. - Unknown source:
und→smo_Latn. Use it only on the source side, to translate without saying what the source language is. It is not a valid target.
The full mapping, with each language's scores, is in the
per-language results. The model has tokens for
five more languages that salt-69 doesn't cover: Thur (lth), Lulubo (lzm),
Kebu (ndp), Sebei (sbx) and So (soc). Their quality has not been
measured.
Inference tips
-
Normalize inputs. NLLB's vocabulary has no typographic quotes or dashes, so the model was trained on text normalized as in
normalize()above. Output uses ASCII punctuation ('"-); post-process it if you need typographic punctuation. -
Preserve line breaks. The tokenizer turns newlines into spaces. To keep the layout of multi-line text, split it into lines, translate the non-empty lines as one batch, and re-join:
def translate_multiline(text, tgt_lang, src_lang=None): lines = text.split('\n') nonempty = [l for l in lines if l.strip()] translated = iter(translate(nonempty, tgt_lang, src_lang)) if nonempty else iter([]) return '\n'.join(next(translated) if l.strip() else '' for l in lines)The model was also trained on whole multi-line dialogues, so translating a short paragraph in one go works too.
-
Input length. Training pairs were at most 512 tokens. Longer inputs are truncated, so split long documents into sentences or paragraphs first.
-
Source language: give it if you know it. It helps slightly (+0.3 chrF on average), mostly for xx→eng into English. Leave it out for code-switched or mixed-language text.
-
Mixed target languages in one batch.
forced_bos_token_idsets one target language pergeneratecall. To translate into several target languages in one batch, passdecoder_input_ids=[[2, tgt_token_id], ...](decoder start token, then each row's target-language token) instead. -
Decoding. The reported scores use beam search with 4 beams. Greedy decoding (
num_beams=1) is faster and only slightly worse. The length cap intranslate()matters for the weaker languages: without it, some outputs repeat a phrase until they reach the token limit.
Evaluation
All results are on the sunflower test split of salt-69: 100 sentences
per language, each translated eng->xx and xx->eng. Scores are chrF (x100),
averaged over sentences and then over directions. Before scoring, predictions
and references are normalized with Whisper's BasicTextNormalizer. Decoding
uses beam search (4 beams, up to 256 new tokens). None of the salt-69 texts
were used in training: training pairs containing any salt-69 sentence were
removed.
The two comparison models were evaluated with the same metric code and test set: Sunflower-Qwen3.5-27B, Sunbird's 27B translation LLM, and NLLB-200 1.3B, the stock checkpoint this model was fine-tuned from.
| Model | Params | Avg chrF | eng->xx chrF | xx->eng chrF | Avg BLEU | Length ratio |
|---|---|---|---|---|---|---|
| This model, source language given | 1.3B | 45.4 | 41.8 | 49.0 | 19.6 | 1.16 |
| This model, source language not given | 1.3B | 45.1 | 41.8 | 48.4 | 19.4 | 1.16 |
| its SFT checkpoint, before GRPO | 1.3B | 45.1 | 41.5 | 48.8 | 19.6 | 1.18 |
| previous release (SFT only) | 1.3B | 43.7 | 40.0 | 47.4 | 19.0 | 1.27 |
| Sunflower-Qwen3.5-27B | 27B | 46.5 | 42.0 | 50.9 | 20.9 | 1.02 |
| NLLB-200 1.3B (base, not fine-tuned) | 1.3B | 31.6 | 29.2 | 34.0 | 12.7 | 1.15 |
Notes:
- eng->xx is level with Qwen. 41.8 against 42.0, and this model scores higher in 38 of 69 eng->xx directions (the previous release won 22). These include Zulu, Swahili, Sotho, Igbo, Bambara, Kanuri, Dinka, Ateso, Lugbara and most of the larger Southern, Eastern and West African languages.
- xx->eng favours Qwen, which leads in 56 of 69 xx->eng directions. A 27B LLM writes more fluent English than a 1.3B translation model. Across both directions Qwen leads in 52 of 69 languages.
- Against base NLLB-200, this model is ahead in all 69 languages, by 13.8 chrF on average. The base figures above are with the source language given; stock NLLB-200 has no unknown-source token, so its "not given" column is not meaningful and is omitted.
- Translating without the source language costs 0.3 chrF overall. eng->xx is unchanged, because the model recognizes English. xx->eng loses 0.6, most for Kanuri, Kikuyu, Lumasaba, Lingala, Lugbara and Xhosa (-1.8 to -3.5).
- Length ratio 1.16, down from 1.27 before GRPO training. What remains is almost entirely eng->xx on the weakest languages (see Limitations). The length cap in the Quick start code limits it further.
Where the gain over base NLLB-200 sits, by whether the language has a native NLLB-200 token (avg chrF):
| Languages | NLLB-200 1.3B | Previous release | This model | Qwen 27B |
|---|---|---|---|---|
| 32 with a native NLLB token | 51.1 | 55.2 | 55.7 | 56.4 |
| 37 with a repurposed token | 14.7 | 33.7 | 36.5 | 37.9 |
How many of the 69 languages reach a given average chrF (mean of eng->xx and xx->eng):
| Avg chrF | >= 50 | >= 40 | >= 30 | < 30 |
|---|---|---|---|---|
| This model | 29 | 42 | 56 | 13 |
| Previous release | 26 | 38 | 52 | 17 |
| Qwen 27B | 31 | 44 | 55 | 14 |
| NLLB-200 1.3B | 20 | 26 | 30 | 39 |
Per-language results
chrF x100, source language given unless marked "no src". Bold marks the higher score of this model and Qwen in each direction. A dagger on the token marks a repurposed language code, for which base NLLB-200 was never trained. Sorted by this model's average.
| Code | Language | Token | eng->xx | xx->eng | eng->xx (no src) | xx->eng (no src) | Qwen eng->xx | Qwen xx->eng | NLLB eng->xx | NLLB xx->eng |
|---|---|---|---|---|---|---|---|---|---|---|
| afr | Afrikaans | afr_Latn | 80.0 | 83.1 | 79.9 | 83.1 | 82.2 | 85.1 | 80.0 | 80.4 |
| zul | Zulu | zul_Latn | 70.1 | 75.6 | 70.1 | 75.1 | 68.8 | 79.6 | 72.4 | 71.0 |
| nya | Chichewa | nya_Latn | 69.2 | 71.4 | 69.1 | 70.0 | 71.4 | 73.5 | 65.2 | 64.7 |
| xho | Xhosa | xho_Latn | 66.1 | 74.2 | 66.4 | 72.4 | 66.5 | 76.6 | 62.9 | 69.3 |
| swa | Swahili | swh_Latn | 67.2 | 70.5 | 67.2 | 69.4 | 66.2 | 72.6 | 62.6 | 67.3 |
| pcm | Nigerian Pidgin | deu_Latn † | 61.7 | 75.9 | 62.0 | 75.3 | 58.0 | 78.4 | 19.1 | 59.2 |
| fra | French | fra_Latn | 67.1 | 70.0 | 66.9 | 70.5 | 67.1 | 72.8 | 67.7 | 67.6 |
| som | Somali | som_Latn | 62.8 | 71.1 | 62.7 | 70.9 | 61.3 | 77.1 | 60.6 | 67.9 |
| sot | Sotho | sot_Latn | 64.8 | 68.8 | 64.6 | 68.5 | 59.7 | 71.0 | 56.3 | 64.5 |
| lin | Lingala | lin_Latn | 62.5 | 69.9 | 62.3 | 68.0 | 63.7 | 73.5 | 59.8 | 62.4 |
| ibo | Igbo | ibo_Latn | 64.2 | 67.3 | 64.3 | 66.2 | 58.6 | 70.3 | 56.5 | 61.7 |
| mlg | Malagasy | plt_Latn | 61.1 | 66.1 | 61.8 | 65.2 | 60.1 | 71.5 | 60.9 | 63.2 |
| amh | Amharic | amh_Ethi | 52.6 | 71.3 | 52.9 | 71.6 | 49.5 | 78.0 | 48.8 | 68.9 |
| tsn | Tswana | tsn_Latn | 56.5 | 64.2 | 56.0 | 63.8 | 55.8 | 64.9 | 55.5 | 58.6 |
| hau | Hausa | hau_Latn | 57.1 | 61.9 | 56.7 | 60.5 | 55.7 | 65.3 | 54.1 | 53.9 |
| kin | Kinyarwanda | kin_Latn | 60.4 | 58.0 | 61.2 | 57.8 | 59.1 | 62.1 | 62.2 | 53.2 |
| lug | Luganda | lug_Latn | 57.7 | 58.3 | 57.9 | 58.1 | 57.5 | 63.8 | 48.2 | 52.3 |
| yor | Yoruba | yor_Latn | 50.4 | 65.4 | 50.5 | 65.8 | 50.3 | 71.3 | 48.0 | 61.1 |
| sna | Shona | sna_Latn | 52.5 | 61.5 | 52.2 | 61.5 | 52.6 | 63.7 | 47.7 | 56.7 |
| nbl | Ndebele | ita_Latn † | 48.0 | 64.4 | 48.1 | 64.2 | 49.1 | 68.1 | 12.7 | 20.3 |
| ewe | Ewe | ewe_Latn | 52.5 | 57.9 | 52.0 | 58.6 | 51.0 | 59.0 | 47.7 | 52.7 |
| bam | Bambara | bam_Latn | 50.8 | 59.1 | 50.1 | 57.3 | 41.1 | 53.8 | 45.0 | 49.0 |
| nyo | Runyoro | dan_Latn † | 51.7 | 57.4 | 51.9 | 57.0 | 50.9 | 61.2 | 11.9 | 16.1 |
| luo | Luo | luo_Latn | 53.5 | 55.1 | 53.5 | 55.0 | 50.0 | 57.9 | 47.4 | 47.5 |
| run | Kirundi | run_Latn | 50.3 | 57.9 | 50.0 | 57.9 | 50.8 | 65.9 | 46.9 | 53.3 |
| nyn | Runyankole | lim_Latn † | 51.3 | 51.3 | 51.0 | 50.4 | 49.6 | 54.9 | 13.1 | 16.7 |
| orm | Oromo | gaz_Latn | 47.2 | 55.0 | 47.3 | 54.4 | 46.1 | 58.9 | 41.4 | 47.4 |
| xog | Lusoga | ltg_Latn † | 47.1 | 55.0 | 47.0 | 54.4 | 45.6 | 60.1 | 12.6 | 17.8 |
| ach | Acholi | fur_Latn † | 50.6 | 51.5 | 50.6 | 50.5 | 51.2 | 52.7 | 14.3 | 15.1 |
| cgg | Rukiga | fao_Latn † | 47.8 | 51.4 | 48.0 | 51.9 | 46.4 | 54.3 | 12.7 | 16.6 |
| bem | Bemba | bem_Latn | 45.1 | 53.5 | 45.0 | 51.7 | 45.4 | 52.6 | 38.7 | 47.9 |
| aka | Akan | aka_Latn | 42.0 | 56.4 | 41.8 | 56.3 | 42.7 | 58.6 | 39.8 | 48.1 |
| kik | Kikuyu | kik_Latn | 40.1 | 54.3 | 40.5 | 52.1 | 40.7 | 64.4 | 36.8 | 47.1 |
| ttj | Rutooro | scn_Latn † | 44.6 | 49.2 | 44.6 | 49.9 | 43.6 | 54.3 | 13.1 | 17.4 |
| ruc | Ruruuli | fin_Latn † | 40.3 | 50.0 | 40.1 | 50.6 | 38.6 | 56.8 | 13.8 | 15.8 |
| lgg | Lugbara | lij_Latn † | 41.9 | 48.0 | 41.8 | 46.1 | 41.2 | 44.8 | 13.2 | 15.3 |
| laj | Lango | mlt_Latn † | 39.6 | 49.5 | 39.7 | 50.2 | 39.8 | 50.1 | 13.6 | 16.1 |
| teo | Ateso | lmo_Latn † | 43.8 | 44.3 | 44.0 | 43.6 | 42.8 | 46.7 | 14.0 | 16.3 |
| kdi | Kumam | gle_Latn † | 38.9 | 47.6 | 39.1 | 46.9 | 38.4 | 45.9 | 13.4 | 15.4 |
| gwr | Lugwere | oci_Latn † | 37.9 | 46.7 | 37.8 | 47.0 | 38.3 | 51.2 | 13.5 | 17.7 |
| rub | Lugungu | est_Latn † | 37.9 | 46.7 | 37.7 | 46.2 | 39.9 | 51.1 | 12.3 | 15.6 |
| myx | Lumasaba | srd_Latn † | 40.1 | 43.8 | 40.2 | 41.8 | 39.6 | 44.0 | 13.1 | 15.3 |
| kab | Kabyle | kab_Latn | 33.8 | 44.5 | 33.9 | 42.8 | 34.1 | 49.4 | 32.6 | 39.6 |
| wol | Wolof | wol_Latn | 34.5 | 43.2 | 34.2 | 41.5 | 32.8 | 48.9 | 26.0 | 34.6 |
| nuj | Lunyole | nob_Latn † | 38.4 | 38.6 | 38.3 | 38.4 | 36.9 | 43.1 | 11.7 | 14.5 |
| din | Dinka | dik_Latn | 28.5 | 47.4 | 28.6 | 46.1 | 20.1 | 26.1 | 26.6 | 37.8 |
| adh | Jopadhola | szl_Latn † | 35.9 | 37.7 | 35.4 | 36.5 | 34.0 | 41.5 | 14.1 | 15.3 |
| bfa | Bari | ast_Latn † | 34.6 | 38.7 | 34.8 | 38.1 | 34.8 | 40.9 | 14.3 | 18.4 |
| koo | Rukonjo | epo_Latn † | 35.8 | 36.2 | 35.9 | 36.0 | 36.4 | 37.1 | 13.3 | 16.2 |
| tlj | Lubwisi | nno_Latn † | 32.8 | 38.9 | 33.0 | 39.3 | 35.0 | 41.8 | 12.1 | 15.6 |
| lsm | Samia | als_Latn † | 34.9 | 36.1 | 34.6 | 35.1 | 34.8 | 39.1 | 13.3 | 15.9 |
| keo | Kakwa | eus_Latn † | 36.4 | 32.6 | 37.0 | 32.3 | 35.5 | 31.0 | 15.6 | 15.1 |
| alz | Alur | vec_Latn † | 29.5 | 39.1 | 29.9 | 38.2 | 29.3 | 38.9 | 14.5 | 14.8 |
| dag | Dagbani | nld_Latn † | 32.8 | 32.0 | 32.6 | 31.0 | 33.4 | 36.1 | 11.3 | 12.4 |
| kau | Kanuri | knc_Latn | 25.3 | 39.2 | 25.1 | 35.7 | 14.5 | 24.3 | 19.4 | 32.4 |
| kdj | Karamojong | cym_Latn † | 29.9 | 31.4 | 29.7 | 30.3 | 32.7 | 32.9 | 12.7 | 14.9 |
| mhi | Ma'di | slk_Latn † | 27.4 | 29.8 | 27.7 | 28.3 | 29.4 | 28.5 | 12.5 | 13.5 |
| ful | Fulani | fuv_Latn | 22.9 | 33.1 | 22.8 | 31.6 | 22.6 | 32.6 | 19.4 | 25.7 |
| rwm | Kwamba | hun_Latn † | 23.2 | 27.2 | 23.0 | 27.7 | 27.1 | 27.1 | 11.7 | 14.4 |
| luy | Luhya | pol_Latn † | 19.1 | 27.3 | 18.6 | 26.8 | 18.2 | 28.1 | 11.6 | 14.9 |
| luc | Aringa | hrv_Latn † | 15.1 | 29.0 | 15.1 | 29.0 | 23.4 | 29.3 | 13.6 | 15.6 |
| dga | Dagaare | swe_Latn † | 16.8 | 24.5 | 16.6 | 24.6 | 16.1 | 26.4 | 11.1 | 11.8 |
| kpz | Kupsabiny | ltz_Latn † | 16.5 | 24.8 | 16.3 | 23.7 | 20.8 | 22.5 | 12.8 | 16.4 |
| ikx | Ik | gla_Latn † | 13.8 | 22.8 | 14.9 | 22.7 | 21.5 | 22.1 | 16.1 | 16.8 |
| kln | Kalenjin | cat_Latn † | 14.0 | 21.5 | 14.2 | 21.1 | 16.4 | 23.8 | 14.3 | 15.8 |
| pok | Pokot | lvs_Latn † | 14.6 | 20.8 | 14.8 | 21.1 | 19.5 | 21.2 | 11.5 | 14.6 |
| led | Lendu | isl_Latn † | 10.1 | 23.8 | 10.0 | 24.3 | 21.8 | 24.3 | 8.1 | 14.0 |
| ber | Berber | tzm_Tfng | 0.1 | 33.0 | 0.1 | 32.3 | 24.6 | 38.6 | 0.1 | 26.6 |
| kpo | Ikposo | glg_Latn † | 3.8 | 19.0 | 3.8 | 19.1 | 4.3 | 19.2 | 4.0 | 6.5 |
Limitations
Problems seen in salt-69 scores and in manual spot checks (eng->xx, beam search):
- Weak languages. The 13 languages with average chrF below 30 (Ma'di through Ikposo in the table above) should not be used for eng->xx without human review. xx->eng into English is usually more usable (chrF 19-33) than eng->xx.
- Output in the wrong language. For some repurposed codes, the model
sometimes falls back to the European language whose token was reused. In
spot checks, eng->Kalenjin (
cat_Latn) gave Catalan and eng->Ikposo (glg_Latn) gave Galician. Kalenjin is the worst case and was deliberately left out of the GRPO wrong-language reward (see Training details), so it is no better here than in the previous release. Some languages also drift into a related, better-resourced language: eng->Ik and eng->Pokot gave text resembling Ateso. - Repetition. For several low-resource targets the decoder sometimes
repeats a word or phrase until it reaches the length limit. GRPO reduced
this -- 6.6% to 5.5% of eng->xx outputs, and only Ik, Kupsabiny, Lendu and
Pokot still average more than twice the reference length, down from eight
for the SFT checkpoint and twelve for the previous release -- but did not
remove it. Lendu and Ik remain the worst (81 and
64 of 100 eng->xx sentences). The length cap in
translate()limits the damage. Addingno_repeat_ngram_size=4togeneratealso helps, but it doesn't recover a correct translation. - Berber script. The Berber (
ber) training data is in Tifinagh script, so eng->ber output is Tifinagh. The salt-69 references are presumably in Latin script, which would explain the near-zero eng->ber score (0.1). GRPO could not fix this and was never going to: the reward is chrF against those same references. Use the Kabyle (kab) code if you need Latin-script Berber output. - Domain. Training data is mostly general-domain and conversational sentences. Expect lower quality on specialised domains (legal, medical, technical) and on long documents.
- Punctuation. Output uses ASCII punctuation only (see Inference tips).
- Evaluation size. Each direction is scored on 100 sentences, so differences of 1-2 chrF points for a single language are within noise. The GRPO stage moved the overall average by 0.3, which is below that per-language threshold; it is reported as real because it is consistent in sign across 56 of 69 languages (sign test p = 8e-8), not because any one language moved a lot.
Training details
Three stages: supervised fine-tuning on all data, a second supervised epoch on the curated pairs alone, then GRPO.
Base and data
- Base model:
facebook/nllb-200-1.3B, fully fine-tuned (all parameters). - Data:
Sunbird/sunflower-pretrain-data(parallel_text): multi-way parallel text. Up to 15,000 pairs were sampled per eng->xx and per xx->eng direction. Non-English pairs were added, equal to 10% of the English-pivot pairs, with at most 2,000 per language pair.Sunbird/sunflower-posttrain-data(sft_translations): curated translation pairs, upsampled 2x. Multi-line dialogues were included both whole and split line by line.- Pairs were removed if they were empty, identical on both sides, duplicated, had a length ratio over 3:1, or contained any salt-69 test sentence.
- Source-language dropout: in 25% of training pairs, the source-language
token was replaced with the unknown-source token (
und/smo_Latn). This is what makes the source language optional at inference. - Source tagging. The two data sources differ in register: the curated posttrain pairs are clean and modern, the parallel_text rows are noisier and sometimes archaic. Every parallel_text pair was marked with a tag token inserted after its source-language token; the curated pairs were left untagged. Untagged input -- what evaluation and inference send -- therefore asks for the clean style, while the noisier rows still contribute. The tag reuses a spare embedding row of the base model (id 256204, which no string tokenizes to), so the tokenizer is unchanged and nothing at inference time has to know about it.
Supervised fine-tuning
- AdamW 8-bit (torchao) in pure bfloat16 with stochastic rounding, no weight decay, linear schedule with 100 warmup steps.
- Phase 1: 2 epochs on all data at learning rate 1e-4.
- Phase 2: 1 epoch on the curated pairs alone at 5e-5.
- Token-budgeted batches: <= 6,144 padded tokens per micro-batch, 6 micro-batches per optimizer step (~37k padded tokens per step). Max 512 tokens per side. Seed 42.
- Evaluated every 500 steps with greedy-decoded chrF on the
sft_translationsdev split; best checkpoint kept (dev chrF 0.5623).
GRPO
Group-relative policy optimization on the model's own samples, using
rl_translations from
Sunbird/sunflower-posttrain-data:
5,097 pairs with a reference translation and 3,093 with none.
- Reward = chrF against the reference, minus penalties for repetition, for output length outside 0.9-1.1x the expected length, for copying the source untranslated, and for replying in the wrong language. The summed repetition and length penalties are capped at 1.0, and the total is then clipped at 0: a repetition loop and a wrong-language reply are equally useless, so ordering them would only add gradient noise.
- Wrong-language penalty: a flat charge, applied only when the target
language falls outside the top 5 labels of
Sunbird/sunflower_language_classification. The classifier is neither reliable nor calibrated, and many of these languages are mutually confusable, so only the rank is read, and coarsely. - Rows with no reference are scored by round trip: the rollout is
translated back to English by a frozen copy of the SFT checkpoint and
chrF is measured against the original English. Freezing the
back-translator keeps the reward meaning the same at the last step as at
the first. Kalenjin was excluded from this branch: its NLLB token is
cat_Latnand the classifier has no Kalenjin label, so it is the one language that is both reward-inverted and unguarded. - Rollouts: 12 per prompt, 16 prompts per step (192 rollouts per step), temperature 1.1, up to 256 new tokens. Prompt blocks mix target languages, so each step averages over several languages rather than concentrating a long-tail language's few hundred rows into a handful of isolated updates. Advantages are group-mean-centred and scaled by the group's own standard deviation.
- Optimization: 512 steps (1 epoch over 8,190 prompts), learning rate 2e-6 with 20 warmup steps, gradient clipping at 1.0. Much lower than the supervised learning rate: this is a policy gradient on the model's own samples, on top of an already trained model.
- Model selection: greedy-decoded chrF on the same dev split every 50 steps. The best checkpoint was step 450 of 512, at dev chrF 0.5670, and it was still improving when the schedule ran out.
- Hardware: one NVIDIA RTX 5090 (32 GB). ~2.5 hours.
- Code:
notebooks/training/translation_nllb_grpo_69_languages.pyin the SunbirdAI/salt repository. The supervised stages aretranslation_nllb_training_69_languages.py(prepare/train/eval, run with--base_model facebook/nllb-200-1.3B).
License
This model is derived from NLLB-200, which is released under CC-BY-NC-4.0, and is therefore also for non-commercial use.
Citation
If you use this model, please cite Sunbird AI and the NLLB paper:
@article{nllb2022,
title = {No Language Left Behind: Scaling Human-Centered Machine Translation},
author = {{NLLB Team} and Costa-juss{\`a}, Marta R. and others},
journal = {arXiv preprint arXiv:2207.04672},
year = {2022}
}