---
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
- en
tags:
- translation
- nllb-200
- formosan-languages
- low-resource
metrics:
- bleu
- chrf
- ter
model-index:
- name: nllb200-formosan-en-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: 14.790154
- type: chrf
name: chrF2
value: 33.158888
- type: ter
name: TER
value: 78.319765
---
# nllb200-formosan-en-spm8k
**Direction:** Formosan to English
**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 250,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 | 344,701 |
| 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 | `c84174ee46027e50d24aedc3cf4016412f7a4cbdeb14ceed2133ee76a4724be1` |
| Training profile SHA-256 | `4253b1b136fedebc589da942b80df71945212d1f4b92a8e98ec6fb160712f14b` |
## Usage
```python
import torch
from transformers import AutoModelForSeq2SeqLM, NllbTokenizer
from formosan_mt_inference import normalize_formosan
model_id = "FormosanBank/nllb200-formosan-en-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"):
text = normalize_formosan(text, lang_code)
tokenizer.src_lang = NLLB_LIDS[lang_code]
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('eng_Latn'),
max_new_tokens=256,
num_beams=4,
)
return tokenizer.batch_decode(output, skip_special_tokens=True)[0]
print(translate("Pa'araw cingra.", "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 | 344,701 |
| Test | 40,561 |
| Validate | 20,286 |
| Scope | BLEU | chrF2 | TER |
|---|---:|---:|---:|
| Hard test | 14.79 | 33.16 | 78.32 |
| Selection validation | 10.85 | 30.44 | 83.50 |
Test empty-output rate: 0.0000%.
| Language | Samples | BLEU | chrF2 | TER |
|---|---:|---:|---:|---:|
| `ami` | 6,761 | 11.96 | 30.94 | 86.53 |
| `bnn` | 4,815 | 17.90 | 36.54 | 73.67 |
| `ckv` | 1,915 | 11.40 | 30.97 | 77.08 |
| `dru` | 3,782 | 11.31 | 28.64 | 83.18 |
| `pwn` | 5,237 | 15.39 | 35.05 | 78.39 |
| `pyu` | 3,158 | 13.19 | 31.34 | 76.77 |
| `ssf` | 1,077 | 23.20 | 40.72 | 66.72 |
| `sxr` | 937 | 11.07 | 30.46 | 78.80 |
| `szy` | 857 | 18.00 | 37.14 | 75.11 |
| `tao` | 868 | 16.76 | 36.59 | 82.03 |
| `tay` | 4,763 | 17.08 | 34.95 | 74.90 |
| `trv` | 2,888 | 17.00 | 34.86 | 74.82 |
| `tsu` | 1,111 | 14.15 | 32.72 | 79.19 |
| `xnb` | 1,503 | 14.20 | 33.44 | 74.16 |
| `xsy` | 889 | 16.50 | 35.22 | 71.26 |
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:
924.
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.