|
--- |
|
license: apache-2.0 |
|
pipeline_tag: translation |
|
--- |
|
|
|
This is a base BART model fine-tuned for English to German translation. |
|
|
|
## Usage |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
|
|
|
# Load model and tokenizer |
|
tokenizer = AutoTokenizer.from_pretrained("MattBoraske/BART_De-En_Translation") |
|
model = AutoModelForSeq2SeqLM.from_pretrained("MattBoraske/BART_De-En_Translation") |
|
|
|
# Sample English sentence |
|
sentence = "Good morning! How are you?" |
|
|
|
# Translate English to Deutsch (German) |
|
inputs = tokenizer.encode(sentence, return_tensors="pt") |
|
outputs = model.generate(inputs, max_length=40, num_beams=4, early_stopping=True) |
|
translated_sentence = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
|
print(translated_sentence) |
|
``` |