Model Documentation: English to Simplified Chinese Translation with NLLB-200-distilled-600M
Model Overview
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.
Dependencies
The model requires the transformers
library by Hugging Face. Ensure that you have the library installed:
pip install transformers
Setup
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')
Usage
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
- Downloads last month
- 2,563
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.