HackerMonica's picture
write README.md refering to cifope/nllb-200-wo-fr-distilled-600M
9ee9d47 verified
---
license: cc-by-nc-4.0
language:
- en
- zh
metrics:
- bleu
pipeline_tag: translation
---
# 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:
```bash
pip install transformers
```
## Setup
Import necessary classes from the `transformers` library:
```python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
```
Initialize the model and tokenizer:
```python
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:
```python
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
```