--- license: cc-by-nc-4.0 library_name: transformers pipeline_tag: translation base_model: facebook/nllb-200-distilled-600M language: - ami - bnn - ckv - dru - pwn - pyu - ssf - sxr - szy - tao - tay - trv - tsu - xnb - xsy - zh tags: - translation - nllb-200 - formosan-languages - low-resource metrics: - bleu - chrf - ter model-index: - name: nllb200-zh-formosan-spm8k results: - task: type: translation name: Translation dataset: name: FormosanBank private no-Bible hard test type: private-no-bible-hard-test split: test metrics: - type: bleu name: sacreBLEU value: 10.520457 - type: chrf name: chrF2 value: 35.064121 - type: ter name: TER value: 80.016573 --- # nllb200-zh-formosan-spm8k **Direction:** Traditional Chinese to Formosan
**Base model:** [`facebook/nllb-200-distilled-600M`](https://huggingface.co/facebook/nllb-200-distilled-600M)
**Recipe:** `nllb200-spm8k-directional-v5`
**Release:** `20260816-193900`, validation-selected step 300,000 This is a directional model for 15 Formosan languages. It uses the `private_no_bible` leakage-controlled corpus, Formosan-aware 8k SentencePiece extension, balanced language/source sampling, direction/language controls, fixed coarse domain tags, and dialect tags. Domain and dialect metadata use independent training dropout so `unknown` and `default` are learned inference conditions. The model weights are public. The training corpus is distributed separately to authorized FormosanBank members through the access-controlled [`FormosanBank/formosan-mt-private`](https://huggingface.co/datasets/FormosanBank/formosan-mt-private) dataset and is not included with the weights. ## Model details | Item | Value | |---|---| | Base revision | `f8d333a098d19b4fd9a8b18f94170487ad3f821d` | | Training rows | 625,460 | | Effective batch size | 64 | | Maximum sequence length | 384 | | Learning rate | 2e-05 | | Precision | `bf16` | | Checkpoint selection | Validation `chrF2` | | Formosan text | `kindOf=standard`, `formosan-mt-standard-v3` | | Corpus SHA-256 | `0024e7fcd35958455a2a060b20999e94b5e8a4364e7f54ba97ef27810746d932` | | Training profile SHA-256 | `4253b1b136fedebc589da942b80df71945212d1f4b92a8e98ec6fb160712f14b` | ## Usage ```python import torch from transformers import AutoModelForSeq2SeqLM, NllbTokenizer model_id = "FormosanBank/nllb200-zh-formosan-spm8k" tokenizer = NllbTokenizer.from_pretrained(model_id, use_fast=False) model = AutoModelForSeq2SeqLM.from_pretrained(model_id) model.to("cuda" if torch.cuda.is_available() else "cpu") NLLB_LIDS = {'ami': 'ami_Latn', 'bnn': 'bnn_Latn', 'ckv': 'ckv_Latn', 'dru': 'dru_Latn', 'pwn': 'pwn_Latn', 'pyu': 'pyu_Latn', 'ssf': 'ssf_Latn', 'sxr': 'sxr_Latn', 'szy': 'szy_Latn', 'tao': 'tao_Latn', 'tay': 'tay_Latn', 'trv': 'trv_Latn', 'tsu': 'tsu_Latn', 'xnb': 'xnb_Latn', 'xsy': 'xsy_Latn'} def translate(text, lang_code, source_bucket="unknown", dialect="default"): tokenizer.src_lang = 'zho_Hant' source_bucket = source_bucket if source_bucket in ('dictionary', 'classroom', 'narrative', 'linguistic', 'education', 'media', 'culture', 'religious', 'unknown') else "unknown" domain_tag = f"" if tokenizer.convert_tokens_to_ids(domain_tag) == tokenizer.unk_token_id: domain_tag = "" dialect_tag = f"" if tokenizer.convert_tokens_to_ids(dialect_tag) == tokenizer.unk_token_id: dialect_tag = "" prompt = ( f" {domain_tag} {dialect_tag} {text}" ) inputs = tokenizer(prompt, return_tensors="pt").to(model.device) output = model.generate( **inputs, decoder_start_token_id=tokenizer.eos_token_id, forced_bos_token_id=tokenizer.convert_tokens_to_ids(NLLB_LIDS[lang_code]), max_new_tokens=256, num_beams=4, ) return tokenizer.batch_decode(output, skip_special_tokens=True)[0] print(translate('他回家了。', "ami")) ``` The control tags are part of the training contract. Use `unknown` and `default` when source bucket or dialect metadata is unavailable. ## Evaluation The best checkpoint was selected on validation chrF2. Test and validation contain only eligible, human-translated sentence pairs. Synthetic pivots and lexical entries are train-only. The headline result uses `default` metadata controls, so it does not assume access to test-set domain or dialect labels. | Split | Rows | |---|---:| | Train | 625,460 | | Test | 73,591 | | Validate | 36,797 | | Scope | BLEU | chrF2 | TER | |---|---:|---:|---:| | Hard test | 10.52 | 35.06 | 80.02 | | Selection validation | 9.46 | 35.82 | 83.08 | Test empty-output rate: 0.0000%. | Language | Samples | BLEU | chrF2 | TER | |---|---:|---:|---:|---:| | `ami` | 14,348 | 8.40 | 30.97 | 83.12 | | `bnn` | 6,048 | 7.78 | 36.24 | 84.72 | | `ckv` | 2,871 | 22.62 | 48.09 | 60.42 | | `dru` | 6,588 | 4.03 | 28.21 | 97.14 | | `pwn` | 5,945 | 6.09 | 33.16 | 90.98 | | `pyu` | 4,334 | 11.81 | 37.37 | 76.99 | | `ssf` | 2,150 | 21.53 | 50.02 | 56.10 | | `sxr` | 1,968 | 7.19 | 41.72 | 86.80 | | `szy` | 2,300 | 17.42 | 43.22 | 67.77 | | `tao` | 2,360 | 12.30 | 36.10 | 72.84 | | `tay` | 7,161 | 4.62 | 24.52 | 92.61 | | `trv` | 10,728 | 10.91 | 33.51 | 72.50 | | `tsu` | 2,048 | 12.91 | 38.60 | 73.06 | | `xnb` | 2,590 | 18.48 | 50.69 | 61.18 | | `xsy` | 2,152 | 21.81 | 47.25 | 63.76 | The corpus gate enforces standard-tier Formosan text, 5/10 validation/test proportions from all deduplicated pairs, capacity-aware source balance, sentence-only evaluation, and zero exact, skeleton, one-edit, or configured high character n-gram train/evaluation conflicts. Document overlap is diagnostic. This release passed all leakage gates: exact 0, skeleton 0, one-edit 0, character n-gram 0. Document overlap: 1439. See `eval/metrics.json` for sacreBLEU signatures, per-language, source, dialect, and length diagnostics. `publication.json` records the corpus, profile, run, and checkpoint hashes used for this release. ## Intended use This model supports research, corpus development, and assisted translation for the 15 included Formosan languages. It is designed for the exact prompt and generation contract shown above. ## Limitations Outputs require knowledgeable speaker review. Aggregate metrics hide large differences among languages and domains. This model is not suitable for authoritative, medical, legal, or safety-critical translation.