NLLB-200 600M fine-tuned for Cantonese โ†’ written Chinese

facebook/nllb-200-distilled-600M fine-tuned to translate colloquial Hong Kong Cantonese (yue_Hant) into standard written Chinese (zho_Hant), e.g. ใ€Œไฝขๅ–บๆ—บ่ง’ๅŒ้Š…้‘ผ็ฃไน‹้–“่ฟ”ๅทฅ๏ผŒๅ””ไฟ‚ๅฅฝๆ–นไพฟใ€ โ†’ ใ€Œไป–ๅœจๆ—บ่ง’ๅ’Œ้Š…้‘ผ็ฃไน‹้–“ไธŠ็ญ๏ผŒไธๆ˜ฏๅพˆๆ–นไพฟใ€. It is the translation stage of a Cantonese subtitle generator (speech recognition with Ming224/whisper-small-cantonese-ct2, then this model).

็ฒค่ฏญ โ†’ ไนฆ้ขไธญๆ–‡็ฟป่ฏ‘ๆจกๅž‹๏ผšๅœจ็ฒค่ฏญ-ไนฆ้ขไธญๆ–‡ๅนณ่กŒ่ฏญๆ–™ไธŠๅพฎ่ฐƒ็š„ NLLB-200 600M๏ผŒๅนถ็ป™่ฏ่กจ่กฅไธŠไบ† 2,629 ไธชๅŽŸๆจกๅž‹็ผบๅฐ‘็š„ๅธธ็”จๆฑ‰ๅญ— ๏ผˆ็‚’ใ€็ฒฅใ€่ƒใ€้‘ผใ€็ญฒใ€ไฝฌโ€ฆโ€ฆ๏ผ‰ใ€‚

Hugging Face transformers format (fp16). A CTranslate2 int8 conversion for fast CPU inference is at Ming224/nllb-600m-cantonese-ct2.

Built as a course project for IERG4320 / IEMS5726A Data Science in Practice (CUHK, 2026โ€“27 Term 1).

Usage

Use src_lang="yue_Hant" and force the target language token zho_Hant (traditional written Chinese; convert to simplified with OpenCC t2s if needed). The model can still translate into English with eng_Latn โ€” in our subtitle app this works better than the original NLLB, although English was not part of the fine-tuning data.

from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

repo = "Ming224/nllb-600m-cantonese"
tok = AutoTokenizer.from_pretrained(repo, src_lang="yue_Hant")   # must be THIS repo's tokenizer (extended vocabulary)
model = AutoModelForSeq2SeqLM.from_pretrained(repo)
enc = tok("ๆˆ‘ๅ“‹่ฝๆ—ฅๅŽป่ƒ็ฃ้ฃŸ็‚’็ฒฅๅ•ฆ", return_tensors="pt")
out = model.generate(**enc, forced_bos_token_id=tok.convert_tokens_to_ids("zho_Hant"), num_beams=4)
print(tok.decode(out[0], skip_special_tokens=True))   # ๆˆ‘ๅ€‘ๆ˜ŽๅคฉๅŽป่ƒ็ฃๅ–ซ็‚’็ฒฅๅง

Extended vocabulary

The original NLLB-200 vocabulary has no entry for many common Hong Kong characters, so they become <unk> (38% of our speech-recognition outputs contained at least one). We added 2,629 characters (vocabulary 256,204 โ†’ 258,833), written directly into the BPE vocabulary with consecutive ids so that segmentation of existing text is unchanged.

New embeddings (shared by the encoder, decoder and output layer):

  • 184 characters copied from a traditional/simplified variant already in the vocabulary
  • the rest initialised from data: for each new character, the mean final decoder state at the positions where it is the training target, minus the mean decoder state over all positions (otherwise the shared component makes new characters win everywhere), scaled to 0.4 ร— the typical spread of Han-character embeddings, added to the mean Han embedding
  • original embedding rows were frozen (gradients zeroed, no weight decay); the new rows used a 10ร— learning rate

A first version (v1) initialised new characters with the mean embedding. After training, these new embeddings were still short (median norm 1.56 vs 4.69 for existing single Han characters) and nearly identical to each other (mean pairwise cosine similarity 0.93 vs 0.14 among existing Han characters). With tied input/output embeddings the model could read the new characters but rarely wrote them (e.g. ็ญฒ็ฎ•็ฃ โ†’ ๅซ‚็ฃ). With the decoder-state initialisation (v2) the new embeddings are well separated (mean pairwise cosine 0.31, median norm 2.67) and are generated much more often.

Training data

  • raptorkwok/cantonese-traditional-chinese-parallel-corpus (CC0), train split only
  • The corpus' own validation/test splits were not used: 65% of the test pairs are near-copies (source โ‰ˆ reference)
  • Cleaning: removed over-long and length-mismatched pairs, pairs whose "written Chinese" side still contains Cantonese colloquial characters, duplicates, and two thirds of near-copy pairs
  • 100,751 training pairs; punctuation removed from half of the sources (speech-recognition output has none)
  • Validation and test sets (1,000 pairs each) held out from the training split: real translations only (character similarity < 0.85), and every pair sharing a source sentence with them removed from training

Training procedure

Setting Value
Base model facebook/nllb-200-distilled-600M (all layers trained except original embedding rows)
Steps 1 epoch, 3,149 steps; best checkpoint at step 3,000
Batch size 16 ร— 2 gradient accumulation = 32
Optimizer Adafactor, learning rate 1e-4 (new embedding rows 1e-3), 500 warm-up steps, linear decay
Precision fp16, one NVIDIA T4 (Google Colab), 62 min
Best validation chrF 32.7

Results

Held-out test set, 1,000 pairs; CTranslate2 int8, beam size 4. Before scoring, both sides are converted to half-width characters (NFKC) and simplified Chinese (OpenCC t2s); BLEU uses sacrebleu's zh tokenizer. "No punct." = punctuation removed from the source, as in speech-recognition output.

Model BLEU chrF BLEU (no punct.) chrF (no punct.)
facebook/nllb-200-distilled-600M (original) 14.6 14.5 13.7 13.6
fine-tuned v1 (new characters initialised with the mean embedding) 36.2 32.3 33.7 30.0
this model (v2, decoder-state initialisation) 37.2 33.1 34.8 30.9
  • Sentence-level chrF: v2 is better than the original model on 83.4% of sentences and worse on 13.2% (Wilcoxon signed-rank p โ‰ˆ 7e-111); better than v1 on 29.5%, worse on 20.3% (p = 3e-5)
  • Truncated translations (shorter than 60% of the reference): 24.2% โ†’ 5.0%
  • Recall of the newly added characters in the references: 22.7% (original) โ†’ 43.6% (v1) โ†’ 56.1% (v2)

Limitations

  • Fine-tuned only for Cantonese โ†’ written Chinese. English output is usable but place names are often wrong (e.g. ่‘ตๆถŒ โ†’ "Guangzhou"); in the app we block Chinese characters in English output and retry looping outputs.
  • The parallel corpus is mostly short conversational sentences; long or formal text is less covered.
  • New characters that are rare in the training targets are still not reliably generated.
  • Non-commercial license (inherited from NLLB-200).
Downloads last month
26
Safetensors
Model size
0.6B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Ming224/nllb-600m-cantonese

Finetuned
(489)
this model

Dataset used to train Ming224/nllb-600m-cantonese