Downloads · 30 days
3
4% of all-time downloads
Jiaao/opus-mt-de-en
opus-mt-de-en is a translation model from Jiaao. Use it when you need text moved from one language to another. The card lists the license as apache-2.0.
This is a German to English translation model based on the MarianMT architecture. The model is trained to translate text from German (de) to English (en) and is part of the OPUS-MT series of translation models.
Downloads · 30 days
3
4% of all-time downloads
All-time downloads
84
Public
Repo size
26 B
Likes
0
Public
Click a slice to open those files.
.md3.6 KB · 82%
From the Hugging Face model README
This is a German to English translation model based on the MarianMT architecture. The model is trained to translate text from German (de) to English (en) and is part of the OPUS-MT series of translation models.
The model uses a transformer-based encoder-decoder architecture with 6 layers in both the encoder and decoder. It has been trained on parallel corpora from the OPUS dataset, which includes various sources of German-English parallel text.
This model is intended for translating German text into English. Primary use cases include:
The model works best with standard written German text. It may perform well on:
Users should be aware of the following limitations:
You can use this model with the Hugging Face Transformers library:
from transformers import MarianMTModel, MarianTokenizer
# Load model and tokenizer
model_name = "playground/opus-mt-de-en"
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)
# Translate German to English
german_text = "Guten Tag, wie geht es Ihnen?"
inputs = tokenizer(german_text, return_tensors="pt", padding=True)
# Generate translation
translated = model.generate(**inputs)
english_text = tokenizer.decode(translated[0], skip_special_tokens=True)
print(english_text)
# Output: "Good day, how are you?"
For translating multiple sentences:
texts = [
"Hallo Welt",
"Ich liebe maschinelles Lernen",
"Das Wetter ist schön heute"
]
inputs = tokenizer(texts, return_tensors="pt", padding=True)
translated = model.generate(**inputs)
for i, translation in enumerate(translated):
print(f"{texts[i]} -> {tokenizer.decode(translation, skip_special_tokens=True)}")
from transformers import pipeline
translator = pipeline("translation", model="playground/opus-mt-de-en")
result = translator("Guten Morgen!")
print(result[0]['translation_text'])