Downloads · 30 days
27
1% of all-time downloads
HackerMonica/nllb-200-distilled-600M-en-zh_CN
nllb-200-distilled-600M-en-zh_CN is a translation model from HackerMonica. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as cc-by-nc-4.0.
This document describes a machine translation model fine-tuned from Meta's NLLB-200-distilled-600M for translating from English to Simplified Chinese. The model, hosted at HackerMonica/nllb-200-distilled-600M-en-zhCN,…
Downloads · 30 days
27
1% of all-time downloads
All-time downloads
4.1K
Public
Repo size
5 GB
Likes
4
Public
Click a slice to open those files.
.bin2.5 GB · 99%
From the Hugging Face model README
This document describes a machine translation model fine-tuned from Meta's NLLB-200-distilled-600M for translating from English to Simplified Chinese. The model, hosted at HackerMonica/nllb-200-distilled-600M-en-zh_CN, utilizes a distilled version of the NLLB-200 model which has been specifically optimized for translation tasks between the English and Simplified Chinese languages.
The model requires the transformers library by Hugging Face. Ensure that you have the library installed:
pip install transformers
Import necessary classes from the transformers library:
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
Initialize the model and tokenizer:
model = AutoModelForSeq2SeqLM.from_pretrained('HackerMonica/nllb-200-distilled-600M-en-zh_CN')
tokenizer = AutoTokenizer.from_pretrained('HackerMonica/nllb-200-distilled-600M-en-zh_CN')
To use the model for translating text, use python code below to translate text from English to Simplified Chinese:
def translate(text):
inputs = tokenizer(text, return_tensors="pt").to("cuda")
translated_tokens = model.generate(
**inputs, forced_bos_token_id=tokenizer.lang_code_to_id["zho_Hans"], max_length=300
)
translation = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
return translation