NLLB-600M Formosan (all dialects) finetune v3
A finetune of facebook/nllb-200-distilled-600M for translation between Mandarin (Traditional Chinese) and 42 Formosan dialects of Taiwan, in both directions. It succeeds ILRDF/nllb-600m-formosan-all-finetune-v2.
Changes from v2:
- New training data (10 datasets). Test sentences are held out across dialects and datasets: no training pair shares a test sentence's Mandarin (in any dialect), a near-identical Mandarin, or its Formosan within the language family.
- Glossary entries are dropped from every dataset, so the model is trained on sentence-level translation.
- Byte-fallback tokenizer: characters outside NLLB's vocabulary (蕉, 猴, 橘, ...) are no longer lost as
<unk>. - Sentence-initial casing normalized for Amis, Bunun, Truku and Seediq.
- Klokah lessons merged into paragraphs, so the model also sees multi-sentence input.
- Synthetic repeated-word pairs (
fafoy, fafoy, fafoy↔豬、豬、豬), which v2 collapses to one word. - Larger batches (256 sentences/step), higher learning rate and 15 epochs.
Files
| File | Description |
|---|---|
model.safetensors, config.json, generation_config.json | Model weights |
tokenizer.json, tokenizer_config.json | NLLB tokenizer + 256 byte-fallback tokens + 42 dialect tokens + 3 format tokens (vocabulary 256,512) |
dialects.json | lang_code → dialect token, dialect name |
formosan_translate.py | Inference (FormosanTranslator) |
Usage
pip install torch transformers tokenizers huggingface_hub
import sys
from huggingface_hub import snapshot_download
repo_dir = snapshot_download("ILRDF/nllb-600m-formosan-all-finetune-v3")
sys.path.insert(0, repo_dir)
from formosan_translate import FormosanTranslator
mt = FormosanTranslator(repo_dir, device="cuda")
print(mt.translate(["Maolah kako komaen to pawli."], "ami-x-pswl", "zh")) # 海岸阿美語 → 華語
print(mt.translate(["我喜歡吃香蕉。"], "zh", "ami-x-pswl")) # 華語 → 海岸阿美語
- Languages are formospeech
lang_codes (table below) or"zh"; the model tokens (ami_Coas,zho_Hant) also work. translate()takes a list and batches it (batch_size=32); decoding is greedy by default (num_beams=1), as in the evaluation.- Load the tokenizer as
formosan_translate.pydoes.AutoTokenizer.from_pretrained()on this repo silently drops byte fallback (transformers 5.x rebuilds the tokenizer without it), and every character outside NLLB's vocabulary becomes<unk>. - Amis, Bunun, Truku and Seediq sentence starts are lower-cased in training;
translate()lower-cases them in the input and capitalizes them in the output. Case is never changed in Kavalan and Saisiyat, where it marks different sounds.
| lang_code | Dialect | Token |
|---|---|---|
ami-x-frng | 馬蘭阿美語 | ami_Mala |
ami-x-iams | 南勢阿美語 | ami_Sout |
ami-x-pld | 恆春阿美語 | ami_Heng |
ami-x-pswl | 海岸阿美語 | ami_Coas |
ami-x-skl | 秀姑巒阿美語 | ami_Xiug |
bnn-x-bkh | 卡群布農語 | bnn_Kaqu |
bnn-x-bnz | 巒群布農語 | bnn_Luan |
bnn-x-isbk | 郡群布農語 | bnn_Junq |
bnn-x-td | 卓群布農語 | bnn_Zhuo |
bnn-x-vtn | 丹群布農語 | bnn_Tanq |
ckv | 噶瑪蘭語 | ckv_Kava |
dru-x-kgdv | 多納魯凱語 | dru_Dona |
dru-x-lbw | 大武魯凱語 | dru_Dawu |
dru-x-ngdr | 霧臺魯凱語 | dru_Wuta |
dru-x-opnh | 萬山魯凱語 | dru_Wans |
dru-x-tldr | 茂林魯凱語 | dru_Maol |
dru-x-trmk | 東魯凱語 | dru_East |
pwn-x-kcdsn | 東排灣語 | pwn_East |
pwn-x-pnvn | 中排灣語 | pwn_Cent |
pwn-x-vnrn | 北排灣語 | pwn_Nrth |
pwn-x-ynvl | 南排灣語 | pwn_Sout |
pyu-x-ksvk | 建和卑南語 | pyu_Jian |
pyu-x-ktrp | 知本卑南語 | pyu_Zhib |
pyu-x-mkzy | 西群卑南語 | pyu_Xiqu |
pyu-x-pym | 南王卑南語 | pyu_Nanw |
ssf | 邵語 | ssf_Thao |
sxr | 拉阿魯哇語 | sxr_Saar |
szy | 撒奇萊雅語 | szy_Saki |
tao | 雅美語 | tao_Yami |
tay-x-cql | 四季泰雅語 | tay_Four |
tay-x-kls | 宜蘭澤敖利泰雅語 | tay_Yzea |
tay-x-mtuw | 汶水泰雅語 | tay_Wens |
tay-x-plngw | 萬大泰雅語 | tay_Wand |
tay-x-sql | 賽考利克泰雅語 | tay_Seko |
tay-x-sul | 澤敖利泰雅語 | tay_Zeao |
trv-x-td | 都達賽德克語 | trv_Duda |
trv-x-tgdy | 德固達雅賽德克語 | trv_Tegu |
trv-x-trk | 德鹿谷賽德克語 | trv_Delu |
trv-x-truku | 太魯閣語 | trv_Truk |
tsu | 鄒語 | tsu_Tsou |
xnb | 卡那卡那富語 | xnb_Kana |
xsy | 賽夏語 | xsy_Sais |
Training
Data
train splits of ten datasets. Every pair is used in both directions (Formosan → Mandarin and Mandarin → Formosan). Records below are both directions, after the row filters (step 1) and before test-set exclusion and deduplication.
| Dataset | Revision | Records |
|---|---|---|
formospeech/klokah | 70ebc0bc | 593,426 |
formospeech/ilrdf_dicts | 55b7cf23 | 195,488 |
formospeech/formosan_bible | 65fac6b3 | 180,022 |
ILRDF/formosan_db | b0faf438 | 140,506 |
formospeech/ithuan_formosan_text | b4776d93 | 43,246 |
formospeech/nchu_pangcah | ad3893cb | 39,458 |
formospeech/ithuan_formosan | f9f9f764 | 32,168 |
formospeech/ntu_formosan_corpus | c3614160 | 27,846 |
formospeech/nchc_formosan | e9c856d0 | 21,286 |
formospeech/klokah_pcc | c71b1704 | 9,034 |
| Synthetic repeated-word pairs | — | 12,600 |
After removing 10,494 records that overlap the test sets and 112,794 duplicates: 1,171,792 records (585,896 pairs).
Processing:
- Dropped: rows whose Formosan or Mandarin side is empty or punctuation only; glossary entries (ids containing
word, and entries of at most two Formosan words whose Mandarin is a gloss rather than a sentence, e.g.ha= 哈); rows whose Mandarin side also carries the Formosan text; and dialects outside the 42. - Leading punctuation removed; a trailing
,/:becomes., a trailing,、:becomes。. - Sentence starts lower-cased for Amis, Bunun, Truku and Seediq, whose orthographies capitalize them but whose ASR-derived transcripts are mostly lower case.
- Klokah reading lessons (
cu_practice,rd_practice) are merged into paragraphs ending on a Chinese full stop and used only as paragraphs. 10% of the texts go to the paragraph test set, split by text across all its dialect versions. - Repeated-word pairs: 150 klokah glossary words per dialect, repeated 2–6 times, separated by
,or a space. - Test-set exclusion. A training pair is removed if it matches a test pair; if its Mandarin matches a test sentence's Mandarin in any dialect (punctuation and whitespace removed, 臺/台 and 甚麼/什麼 unified, personal names masked); if its Mandarin is near-identical to one (character 3–5-gram Jaccard ≥ 0.85); or if its Formosan matches a test sentence's Formosan in the same language family.
- Deduplication on (dialect, Formosan, Mandarin), across all datasets, keeping the first occurrence.
Tokenizer
The NLLB tokenizer with new tokens appended after its vocabulary, so every original token id is unchanged:
- 256 byte tokens
<0x00>–<0xFF>with byte fallback on. 0.32% of the characters in the training data, in 23% of the Mandarin sentences, are outside NLLB's vocabulary. - 42 dialect tokens (
ami_Coas,pwn_Cent, ...), one per dialect. - 3 format tokens (
<bt>,<seg>,<gloss>) reserved for experiments; this model is not trained with them.
Configuration
- 4× RTX A5000, 15 epochs (68,670 steps), 256 sentences per step (64 per GPU), lr 1.5e-3 (linear, 10% warmup), weight decay 0.01, AdamW, bf16, max input length 512 tokens.
- Batches group sentences of similar length and are balanced across the GPUs by estimated compute.
Evaluation
- Sentence test set: the
evalsplits offormospeech/klokah(revision70ebc0bc, where every dialect version of a sentence is on the same side) andformospeech/ithuan_formosan, without glossary entries and sentences under four Chinese characters once names are removed: 41,489 sentences in each direction. - Paragraph test set: 2,255 klokah paragraphs in each direction (see Processing, step 4).
- Metrics: sacrebleu corpus chrF, chrF++ (word n-gram order 2) and BLEU, case-insensitive except for Kavalan and Saisiyat targets. BLEU tokenizes Mandarin with
zh(one token per character) and Formosan with13a. For Mandarin targets, punctuation on both sides is converted to full width first, and chrF++ is not reported: its word n-grams split on whitespace, which unsegmented Mandarin does not have. - Greedy decoding; Amis, Bunun, Truku and Seediq sentence starts handled as in Usage.
- Baseline: ILRDF/nllb-600m-formosan-all-finetune-v2. Its training data contains the Mandarin of 91.7% of the test sentences, so the comparison that matters is the 2,545 sentences (1,622 paragraphs) whose Mandarin and Formosan it has not seen (v2-unseen).
| Test set | Direction | v2 chrF | v2 chrF++ | v2 BLEU | v3 chrF | v3 chrF++ | v3 BLEU |
|---|---|---|---|---|---|---|---|
| Sentences (41,489) | Formosan → Mandarin | 71.91 | — | 75.17 | 45.15 | — | 49.62 |
| Sentences (41,489) | Mandarin → Formosan | 66.32 | 64.91 | 44.83 | 61.98 | 60.28 | 39.04 |
| v2-unseen (2,545) | Formosan → Mandarin | 13.90 | — | 14.48 | 23.78 | — | 26.43 |
| v2-unseen (2,545) | Mandarin → Formosan | 40.08 | 38.15 | 12.51 | 45.18 | 42.98 | 16.58 |
| Paragraphs (2,255) | Formosan → Mandarin | 9.85 | — | 9.38 | 11.15 | — | 10.67 |
| Paragraphs (2,255) | Mandarin → Formosan | 32.24 | 30.11 | 5.32 | 36.22 | 33.71 | 8.38 |
| v2-unseen paragraphs (1,622) | Formosan → Mandarin | 7.77 | — | 6.33 | 11.07 | — | 10.67 |
| v2-unseen paragraphs (1,622) | Mandarin → Formosan | 30.44 | 28.37 | 4.26 | 36.12 | 33.66 | 8.52 |
- v2 is ahead over all sentences only because it was trained on most of them.
- v2-unseen sentences are newer and longer klokah text than the rest of the test set, so both models score low on them.
- Byte fallback matters: 18.2% of the v2-unseen Mandarin references contain a character v2 cannot produce. On those sentences v3 leads by 15.7 chrF, on the rest by 8.3.
→ zh: Formosan → Mandarin; zh →: Mandarin → Formosan; para: paragraph test set.
| lang_code | Dialect | n | → zh chrF | → zh BLEU | zh → chrF | zh → chrF++ | zh → BLEU | n (para) | para → zh chrF | para zh → chrF | para zh → chrF++ |
|---|---|---|---|---|---|---|---|---|---|---|---|
ami-x-frng | 馬蘭阿美語 | 713 | 55.65 | 60.92 | 67.72 | 66.24 | 46.94 | 47 | 17.57 | 40.80 | 39.27 |
ami-x-iams | 南勢阿美語 | 735 | 50.47 | 55.48 | 65.69 | 64.35 | 45.88 | 36 | 9.33 | 36.75 | 34.49 |
ami-x-pld | 恆春阿美語 | 706 | 54.34 | 59.22 | 65.27 | 63.43 | 41.22 | 60 | 14.24 | 33.30 | 31.40 |
ami-x-pswl | 海岸阿美語 | 1369 | 46.67 | 51.11 | 64.24 | 62.50 | 40.93 | 47 | 16.46 | 41.55 | 39.16 |
ami-x-skl | 秀姑巒阿美語 | 756 | 51.47 | 56.21 | 63.51 | 61.86 | 41.31 | 43 | 9.86 | 35.69 | 33.52 |
bnn-x-bkh | 卡群布農語 | 751 | 43.57 | 48.23 | 51.78 | 48.84 | 21.44 | 41 | 6.67 | 26.84 | 24.30 |
bnn-x-bnz | 巒群布農語 | 778 | 45.62 | 50.60 | 60.00 | 57.26 | 31.45 | 57 | 10.64 | 37.91 | 34.93 |
bnn-x-isbk | 郡群布農語 | 1370 | 42.68 | 47.40 | 60.72 | 57.80 | 31.54 | 41 | 10.05 | 36.35 | 33.25 |
bnn-x-td | 卓群布農語 | 733 | 48.24 | 52.09 | 60.23 | 57.53 | 33.64 | 53 | 11.70 | 31.54 | 28.22 |
bnn-x-vtn | 丹群布農語 | 760 | 47.25 | 52.35 | 59.74 | 57.41 | 32.41 | 27 | 9.20 | 36.02 | 33.42 |
ckv | 噶瑪蘭語 | 1395 | 45.11 | 49.71 | 66.98 | 66.04 | 46.52 | 53 | 12.76 | 43.39 | 40.89 |
dru-x-kgdv | 多納魯凱語 | 741 | 43.70 | 47.76 | 60.80 | 58.23 | 33.98 | 48 | 7.02 | 32.57 | 30.17 |
dru-x-lbw | 大武魯凱語 | 753 | 48.24 | 52.39 | 63.79 | 61.60 | 39.09 | 93 | 8.80 | 36.32 | 33.62 |
dru-x-ngdr | 霧臺魯凱語 | 1386 | 40.82 | 43.86 | 58.79 | 56.19 | 31.69 | 51 | 8.43 | 31.68 | 27.60 |
dru-x-opnh | 萬山魯凱語 | 764 | 43.92 | 48.59 | 59.84 | 56.55 | 30.39 | 53 | 13.11 | 34.49 | 29.88 |
dru-x-tldr | 茂林魯凱語 | 773 | 36.56 | 39.68 | 47.01 | 44.86 | 22.87 | 31 | 4.07 | 23.13 | 20.84 |
dru-x-trmk | 東魯凱語 | 749 | 45.73 | 49.58 | 56.78 | 53.98 | 30.50 | 58 | 8.69 | 34.06 | 30.25 |
pwn-x-kcdsn | 東排灣語 | 763 | 48.74 | 53.53 | 61.21 | 59.18 | 37.43 | 61 | 9.23 | 31.50 | 28.66 |
pwn-x-pnvn | 中排灣語 | 780 | 44.02 | 48.00 | 59.20 | 57.22 | 36.37 | 81 | 8.15 | 30.90 | 28.08 |
pwn-x-vnrn | 北排灣語 | 1393 | 41.49 | 44.56 | 58.28 | 56.49 | 33.75 | 156 | 7.47 | 32.56 | 29.51 |
pwn-x-ynvl | 南排灣語 | 739 | 48.03 | 53.04 | 60.88 | 58.57 | 34.92 | 51 | 6.50 | 29.53 | 27.17 |
pyu-x-ksvk | 建和卑南語 | 748 | 51.56 | 56.61 | 67.28 | 66.30 | 47.60 | 120 | 17.99 | 41.52 | 39.40 |
pyu-x-ktrp | 知本卑南語 | 741 | 54.60 | 58.80 | 65.50 | 64.27 | 44.02 | 83 | 13.12 | 40.58 | 38.37 |
pyu-x-mkzy | 西群卑南語 | 755 | 53.56 | 58.69 | 66.97 | 66.09 | 46.81 | 97 | 11.63 | 42.68 | 39.97 |
pyu-x-pym | 南王卑南語 | 1347 | 46.85 | 51.35 | 68.93 | 67.98 | 50.36 | 75 | 12.98 | 40.17 | 37.81 |
ssf | 邵語 | 1337 | 41.93 | 46.20 | 66.74 | 65.19 | 43.36 | 29 | 12.47 | 39.41 | 37.61 |
sxr | 拉阿魯哇語 | 1290 | 40.13 | 43.84 | 65.58 | 61.35 | 31.36 | 60 | 6.84 | 36.19 | 30.78 |
szy | 撒奇萊雅語 | 1394 | 43.69 | 47.84 | 64.71 | 63.40 | 42.17 | 34 | 13.27 | 35.88 | 34.43 |
tao | 雅美語 | 1407 | 36.35 | 39.48 | 53.50 | 52.39 | 31.59 | 69 | 7.88 | 31.96 | 30.42 |
tay-x-cql | 四季泰雅語 | 766 | 48.61 | 53.17 | 57.59 | 56.83 | 37.08 | 55 | 6.94 | 28.67 | 26.46 |
tay-x-kls | 宜蘭澤敖利泰雅語 | 749 | 53.26 | 58.05 | 63.65 | 63.10 | 45.14 | 15 | 17.51 | 31.39 | 29.43 |
tay-x-mtuw | 汶水泰雅語 | 732 | 48.09 | 52.64 | 60.82 | 59.17 | 39.56 | 23 | 6.14 | 34.89 | 32.46 |
tay-x-plngw | 萬大泰雅語 | 739 | 47.15 | 51.81 | 62.00 | 60.95 | 42.13 | 43 | 8.10 | 30.52 | 28.94 |
tay-x-sql | 賽考利克泰雅語 | 1406 | 42.45 | 46.65 | 53.84 | 52.25 | 29.75 | 19 | 7.02 | 25.39 | 23.24 |
tay-x-sul | 澤敖利泰雅語 | 702 | 50.98 | 55.67 | 58.34 | 57.45 | 38.47 | 40 | 13.29 | 36.80 | 34.84 |
trv-x-td | 都達賽德克語 | 729 | 51.47 | 56.64 | 59.15 | 58.60 | 38.14 | 17 | 19.70 | 41.34 | 39.48 |
trv-x-tgdy | 德固達雅賽德克語 | 1441 | 40.18 | 44.51 | 57.50 | 56.72 | 36.65 | 23 | 12.02 | 33.16 | 31.43 |
trv-x-trk | 德鹿谷賽德克語 | 720 | 52.04 | 57.29 | 64.23 | 63.58 | 45.90 | 9 | 10.07 | 34.56 | 31.80 |
trv-x-truku | 太魯閣語 | 1425 | 46.64 | 51.26 | 67.50 | 66.97 | 49.27 | 62 | 15.52 | 42.88 | 41.85 |
tsu | 鄒語 | 1373 | 41.18 | 44.51 | 56.56 | 54.77 | 33.22 | 37 | 10.92 | 33.63 | 31.04 |
xnb | 卡那卡那富語 | 1394 | 43.39 | 47.94 | 67.95 | 65.85 | 41.11 | 92 | 17.07 | 44.42 | 41.34 |
xsy | 賽夏語 | 1387 | 44.28 | 48.37 | 68.32 | 66.49 | 47.73 | 65 | 11.57 | 43.46 | 41.04 |
Limitations
- Paragraph translation is much weaker than sentence translation (Formosan → Mandarin chrF 11.15). Translate long text sentence by sentence.
- Quality varies widely by dialect; Yami (
tao) and Maolin Rukai (dru-x-tldr) are the weakest. See the per-dialect table. - The test sets come from the same sources as the training data (klokah lessons, ithuan_formosan), so scores on other kinds of text (news, conversation) are likely lower.
- Use the tokenizer loading in
formosan_translate.py; a plainAutoTokenizer.from_pretrained()loses byte fallback.