
# Model Card for mt5-small en-nl translation

The mt5-small en-nl translation model is a finetuned version of [google/mt5-small](https://huggingface.co/google/mt5-small).

It was finetuned on 237k rows of the [iwslt2017](https://huggingface.co/datasets/iwslt2017/viewer/iwslt2017-en-nl) dataset and roughly 38k rows of the [opus_books](https://huggingface.co/datasets/opus_books/viewer/en-nl) dataset. The model was trained for 15 epochs with a batchsize of 16.


## How to use

**Install dependencies**
```bash
pip install transformers
```

You can use the following code for model inference. This model was finetuned to work with an identifier when prompted that needs to be present for the best results.

```Python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, GenerationConfig

tokenizer = AutoTokenizer.from_pretrained("Michielo/mt5-small_en-nl_translation")
model = AutoModelForSeq2SeqLM.from_pretrained("Michielo/mt5-small_en-nl_translation")

translation_generation_config = GenerationConfig(
    num_beams=4,
    early_stopping=True,
    decoder_start_token_id=0,
    eos_token_id=model.config.eos_token_id,
    pad_token=model.config.pad_token_id,
)

translation_generation_config.save_pretrained("/tmp", "translation_generation_config.json")
generation_config = GenerationConfig.from_pretrained("/tmp", "translation_generation_config.json")
inputs = tokenizer(">>nl<< Your text here", return_tensors="pt")
outputs = model.generate(**inputs, generation_config=generation_config)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
```


## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) file for details.
{"language": ["en", "nl"], "license": "apache-2.0", "tags": ["translation"], "datasets": ["opus_books", "iwslt2017"], "metrics": ["sacrebleu"], "base_model": "google/mt5-small", "pipeline_tag": "text2text-generation", "widget": [{"text": ">>nl<< Hello, what are you doing?"}]}
transformers safetensors mt5 text2text-generation translation en nl dataset:opus_books dataset:iwslt2017 base_model:google/mt5-small license:apache-2.0 autotrain_compatible endpoints_compatible text-generation-inference region:us