Translation
Transformers
Safetensors
m2m_100
text2text-generation
nllb-200
formosan-languages
low-resource
Eval Results (legacy)
Instructions to use FormosanBank/nllb200-formosan-zh-spm8k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FormosanBank/nllb200-formosan-zh-spm8k with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="FormosanBank/nllb200-formosan-zh-spm8k")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("FormosanBank/nllb200-formosan-zh-spm8k") model = AutoModelForSeq2SeqLM.from_pretrained("FormosanBank/nllb200-formosan-zh-spm8k", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Standardize FormosanBank MT model card format
Browse files
README.md
CHANGED
|
@@ -70,16 +70,14 @@ model-index:
|
|
| 70 |
|
| 71 |
**Repo:** `FormosanBank/nllb200-formosan-zh-spm8k`
|
| 72 |
**Base model:** [`facebook/nllb-200-distilled-600M`](https://huggingface.co/facebook/nllb-200-distilled-600M)
|
| 73 |
-
**Direction:** **Formosan -> Traditional Chinese**
|
| 74 |
**Companion reverse-direction model:** [`FormosanBank/nllb200-zh-formosan-spm8k`](https://huggingface.co/FormosanBank/nllb200-zh-formosan-spm8k)
|
| 75 |
|
| 76 |
-
This
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
| Language | Code |
|
| 83 |
|---|---|
|
| 84 |
| Traditional Chinese | `zho_Hant` |
|
| 85 |
| Amis | `ami_Latn` |
|
|
@@ -100,11 +98,11 @@ This is a directional checkpoint. It is trained for this direction only; use the
|
|
| 100 |
|
| 101 |
## Input Format
|
| 102 |
|
| 103 |
-
This model was trained and evaluated with metadata control tags. Prefix the source text with:
|
| 104 |
|
| 105 |
`<to_zh> <src_LANG> <dom_BUCKET> <dialect_DIALECT>`
|
| 106 |
|
| 107 |
-
|
| 108 |
|
| 109 |
`<to_zh> <src_ami> <dom_unknown> <dialect_default> Pa'araw cingra to demak nira.`
|
| 110 |
|
|
@@ -112,9 +110,9 @@ If source bucket or dialect is unknown, use `<dom_unknown>` and `<dialect_defaul
|
|
| 112 |
|
| 113 |
## Usage
|
| 114 |
|
| 115 |
-
Tested with `transformers` 4.56.x.
|
| 116 |
|
| 117 |
-
|
| 118 |
|
| 119 |
```python
|
| 120 |
import torch
|
|
@@ -132,12 +130,7 @@ FORMOSAN_TO_LID = {
|
|
| 132 |
"tsu": "tsu_Latn", "xnb": "xnb_Latn", "xsy": "xsy_Latn",
|
| 133 |
}
|
| 134 |
|
| 135 |
-
def translate_formosan_to_chinese(
|
| 136 |
-
text: str,
|
| 137 |
-
lang_code: str,
|
| 138 |
-
source_bucket: str = "unknown",
|
| 139 |
-
dialect: str = "default",
|
| 140 |
-
) -> str:
|
| 141 |
tokenizer.src_lang = FORMOSAN_TO_LID[lang_code]
|
| 142 |
prompt = f"<to_zh> <src_{lang_code}> <dom_{source_bucket}> <dialect_{dialect}> {text}"
|
| 143 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=384).to(model.device)
|
|
@@ -161,7 +154,7 @@ print(translate_formosan_to_chinese("Pa'araw cingra to demak nira.", "ami"))
|
|
| 161 |
|
| 162 |
| Setting | Value |
|
| 163 |
|---|---|
|
| 164 |
-
| Corpus | FormosanBank Chinese Parallel Corpus, leakage-controlled
|
| 165 |
| Direction | `f2zh` |
|
| 166 |
| Base model | `facebook/nllb-200-distilled-600M` |
|
| 167 |
| Tokenizer | 8k Formosan SentencePiece extension |
|
|
@@ -178,13 +171,11 @@ print(translate_formosan_to_chinese("Pa'araw cingra to demak nira.", "ami"))
|
|
| 178 |
| Language sampling alpha | 0.5 |
|
| 179 |
| Metadata tags | enabled and validated as single tokenizer IDs |
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
## Evaluation
|
| 184 |
|
| 185 |
-
Evaluation
|
| 186 |
-
|
| 187 |
-
SacreBLEU used Chinese tokenization (`tokenize=zh`) for BLEU in this direction.
|
| 188 |
|
| 189 |
### Global Metrics
|
| 190 |
|
|
@@ -212,18 +203,19 @@ SacreBLEU used Chinese tokenization (`tokenize=zh`) for BLEU in this direction.
|
|
| 212 |
| Kanakanavu | `xnb_Latn` | 1,552 | 12.96 | 15.19 | 107.91 |
|
| 213 |
| Saisiyat | `xsy_Latn` | 1,212 | 14.45 | 16.32 | 106.80 |
|
| 214 |
|
| 215 |
-
|
| 216 |
|
| 217 |
## Intended Use
|
| 218 |
|
| 219 |
- Research, teaching, and prototyping for Formosan-language MT.
|
| 220 |
-
- Draft translation assistance where
|
| 221 |
- Comparative evaluation of low-resource MT methods on leakage-controlled FormosanBank splits.
|
| 222 |
|
| 223 |
## Limitations
|
| 224 |
|
| 225 |
- Outputs can be incorrect, ungrammatical, incomplete, or culturally inappropriate.
|
| 226 |
-
-
|
|
|
|
| 227 |
- Evaluation uses a hard split; BLEU should not be compared directly to older leaky or near-duplicate split results.
|
| 228 |
|
| 229 |
## License
|
|
@@ -233,10 +225,10 @@ Released under `cc-by-nc-4.0`. Some underlying corpus sources may carry addition
|
|
| 233 |
## Citation
|
| 234 |
|
| 235 |
```bibtex
|
| 236 |
-
@misc{
|
| 237 |
-
title = {nllb200-formosan-zh-spm8k: Directional NLLB-200 MT for FormosanBank Chinese Parallel Corpus},
|
| 238 |
author = {FormosanBank contributors},
|
| 239 |
year = {2026},
|
| 240 |
-
|
| 241 |
}
|
| 242 |
```
|
|
|
|
| 70 |
|
| 71 |
**Repo:** `FormosanBank/nllb200-formosan-zh-spm8k`
|
| 72 |
**Base model:** [`facebook/nllb-200-distilled-600M`](https://huggingface.co/facebook/nllb-200-distilled-600M)
|
| 73 |
+
**Direction:** **Formosan -> Traditional Chinese**
|
| 74 |
**Companion reverse-direction model:** [`FormosanBank/nllb200-zh-formosan-spm8k`](https://huggingface.co/FormosanBank/nllb200-zh-formosan-spm8k)
|
| 75 |
|
| 76 |
+
This is a directional NLLB-200 distilled 600M checkpoint for FormosanBank machine translation. It uses an 8k SentencePiece vocabulary extension plus FormosanBank metadata/control tags. Use the companion model for the reverse direction.
|
| 77 |
|
| 78 |
+
## Supported Languages
|
| 79 |
|
| 80 |
+
| Language | NLLB code |
|
|
|
|
|
|
|
| 81 |
|---|---|
|
| 82 |
| Traditional Chinese | `zho_Hant` |
|
| 83 |
| Amis | `ami_Latn` |
|
|
|
|
| 98 |
|
| 99 |
## Input Format
|
| 100 |
|
| 101 |
+
This model was trained and evaluated with metadata control tags. Prefix the source text in one of the supported Formosan languages with:
|
| 102 |
|
| 103 |
`<to_zh> <src_LANG> <dom_BUCKET> <dialect_DIALECT>`
|
| 104 |
|
| 105 |
+
Example with unknown metadata:
|
| 106 |
|
| 107 |
`<to_zh> <src_ami> <dom_unknown> <dialect_default> Pa'araw cingra to demak nira.`
|
| 108 |
|
|
|
|
| 110 |
|
| 111 |
## Usage
|
| 112 |
|
| 113 |
+
Tested with `transformers` 4.56.x. Use the slow `NllbTokenizer` or `AutoTokenizer.from_pretrained(model_id, use_fast=False)`. In `transformers` 4.56.x, fast-tokenizer added-token IDs can differ from the slow tokenizer IDs used during training.
|
| 114 |
|
| 115 |
+
For NLLB generation, keep `decoder_start_token_id=tokenizer.eos_token_id` and set `forced_bos_token_id` to the target language ID.
|
| 116 |
|
| 117 |
```python
|
| 118 |
import torch
|
|
|
|
| 130 |
"tsu": "tsu_Latn", "xnb": "xnb_Latn", "xsy": "xsy_Latn",
|
| 131 |
}
|
| 132 |
|
| 133 |
+
def translate_formosan_to_chinese(text: str, lang_code: str, source_bucket: str = "unknown", dialect: str = "default") -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
tokenizer.src_lang = FORMOSAN_TO_LID[lang_code]
|
| 135 |
prompt = f"<to_zh> <src_{lang_code}> <dom_{source_bucket}> <dialect_{dialect}> {text}"
|
| 136 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=384).to(model.device)
|
|
|
|
| 154 |
|
| 155 |
| Setting | Value |
|
| 156 |
|---|---|
|
| 157 |
+
| Corpus | FormosanBank Chinese Parallel Corpus, leakage-controlled in-domain hard split |
|
| 158 |
| Direction | `f2zh` |
|
| 159 |
| Base model | `facebook/nllb-200-distilled-600M` |
|
| 160 |
| Tokenizer | 8k Formosan SentencePiece extension |
|
|
|
|
| 171 |
| Language sampling alpha | 0.5 |
|
| 172 |
| Metadata tags | enabled and validated as single tokenizer IDs |
|
| 173 |
|
| 174 |
+
This repo publishes the final 300k-step checkpoint because it scored highest on the held-out hard test set among the evaluated final/best checkpoints.
|
| 175 |
|
| 176 |
## Evaluation
|
| 177 |
|
| 178 |
+
Evaluation used the held-out `in_domain_hard` test split with no normalized source, target, or pair overlap against train. These scores are intentionally lower than leaky or near-duplicate splits and are intended as a harder MT benchmark.
|
|
|
|
|
|
|
| 179 |
|
| 180 |
### Global Metrics
|
| 181 |
|
|
|
|
| 203 |
| Kanakanavu | `xnb_Latn` | 1,552 | 12.96 | 15.19 | 107.91 |
|
| 204 |
| Saisiyat | `xsy_Latn` | 1,212 | 14.45 | 16.32 | 106.80 |
|
| 205 |
|
| 206 |
+
Full source-bucket and length-bin breakdowns are available in [`eval/metrics.json`](eval/metrics.json).
|
| 207 |
|
| 208 |
## Intended Use
|
| 209 |
|
| 210 |
- Research, teaching, and prototyping for Formosan-language MT.
|
| 211 |
+
- Draft translation assistance where review by knowledgeable speakers is available.
|
| 212 |
- Comparative evaluation of low-resource MT methods on leakage-controlled FormosanBank splits.
|
| 213 |
|
| 214 |
## Limitations
|
| 215 |
|
| 216 |
- Outputs can be incorrect, ungrammatical, incomplete, or culturally inappropriate.
|
| 217 |
+
- Generation into Formosan languages is especially difficult and should be treated as draft-only.
|
| 218 |
+
- This model is not suitable for legal, medical, safety-critical, or authoritative community-facing use without expert review.
|
| 219 |
- Evaluation uses a hard split; BLEU should not be compared directly to older leaky or near-duplicate split results.
|
| 220 |
|
| 221 |
## License
|
|
|
|
| 225 |
## Citation
|
| 226 |
|
| 227 |
```bibtex
|
| 228 |
+
@misc{formosanbank_nllb200_formosan_zh_spm8k,
|
| 229 |
+
title = {nllb200-formosan-zh-spm8k: Directional NLLB-200 MT for the FormosanBank Chinese Parallel Corpus, leakage-controlled in-domain hard split},
|
| 230 |
author = {FormosanBank contributors},
|
| 231 |
year = {2026},
|
| 232 |
+
url = {https://huggingface.co/FormosanBank/nllb200-formosan-zh-spm8k}
|
| 233 |
}
|
| 234 |
```
|