facebook/flores
Updated • 14.8k • 101
How to use dhtocks/nllb-200-distilled-350M_en-ko 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="dhtocks/nllb-200-distilled-350M_en-ko") # Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("dhtocks/nllb-200-distilled-350M_en-ko")
model = AutoModelForSeq2SeqLM.from_pretrained("dhtocks/nllb-200-distilled-350M_en-ko")The NLLB-200 model showed outstanding performance in translation task and contributed to solving problems with low-resource languages. Despite their efforts, it is still hard to run 600M or more than 1B model for those who have not enough computing environment. So I made much smaller model that expertized translaing English to Korean. you can also run it with cpu (No mixed-precision, No Quantization).
Model: model is based on NLLB-200 600M
Licnese: CC-BY-NC
| #Params | chrF(++) | GPU Inference time (s) | CPU Inference time (s) | |
|---|---|---|---|---|
| NLLB-200 3.3B | 3.3B | 34.3 | 0.98 s | 4.65 s |
| NLLB-200 1.3B | 1.3B | 32.1 | 0.89 s | 2.46 s |
| NLLB-200 600M | 600M | 32 | 0.43 s | 1.52 s |
| NLLB-200 350M (ours) | 350M | 24.6 | 0.24 s | 1.43 s |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained('dhtocks/nllb-200-distilled-350M_en-ko', forced_bos_token_id=256098)
tokenizer = AutoTokenizer.from_pretrained('dhtocks/nllb-200-distilled-350M_en-ko', src_lang='eng_Latn', tgt_lang='kor_Hang')
inputs = tokenizer('[YOUR_INPUT]', return_tensors="pt")
output = model.generate(**inputs)
print(tokenizer.decode(output[0]))
@misc{,
title={NLLB-200 distilled_350M_en-ko},
author={Saechan Oh},
year={2024}
}