transformers safetensors mistral text-generation conversational en nl license:apache-2.0 autotrain_compatible endpoints_compatible text-generation-inference region:us
---
license: apache-2.0
language:
- en
- nl
pipeline_tag: conversational
---

# mistral-en-nl-v2

## Description

`mistral-en-nl-v2` is a Mistral finetune specialized in translating English to Dutch.

## Usage

Import the required libraries and initialize the pipeline:

```python
from transformers import pipeline
import torch

pipe = pipeline(
    "conversational",
    model="yhavinga/mistral-en-nl-v1",
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
```

Define the translation function:

```python
def do_translate(text):
    messages = [
       {"role": "user", "content": f"Translate the following English text into Dutch: {text}"}
    ]
    outputs = pipe(
        messages, 
        max_new_tokens=2048, 
        do_sample=False, 
        num_beams=4, 
        early_stopping=True
    )
    return outputs[-1]['content']
```

Example:

```python
print(do_translate("Redistricting and West Virginia’s shrinking population forced the state’s Republican Legislature to pit Mr. McKinley, a six-term Republican with a pragmatic bent, against Mr. Mooney, who has served four terms marked more by conservative rhetoric than legislative achievements."))
```

This should yield 

Het herindelen van de kiesdistricten en de teruglopende bevolking van West-Virginia dwongen de republikeinse wetgevende macht van de staat om McKinley, een zesvoudig gekozen republikein met een pragmatische inslag, tegenover Mooney te zetten, die vier termijnen heeft gediend en meer bekendstaat om zijn conservatieve retoriek dan om zijn wetgevende prestaties.

## Limitations and Bias

The training data, sourced primarily from the internet, may contain biases. Users should be aware of potential biases in translations.

## Acknowledgements

This project would not have been possible without compute generously provided by Google through the
[TPU Research Cloud](https://sites.research.google/trc/).


Created by [Yeb Havinga](https://www.linkedin.com/in/yeb-havinga-86530825/)