Description

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.

Model Details

  • Model Type: MarianMT (Transformer-based)
  • Source Language: German (de)
  • Target Language: English (en)
  • Architecture: 6-layer encoder-decoder with 8 attention heads
  • Vocabulary Size: 64,000 tokens

Intended Use

This model is intended for translating German text into English. Primary use cases include:

  • Document Translation: Translating German documents, articles, and texts into English
  • Content Localization: Helping to localize German content for English-speaking audiences
  • Research and Development: Serving as a baseline model for translation research
  • Educational Purposes: Learning about neural machine translation and the MarianMT architecture

The model works best with standard written German text. It may perform well on:

  • News articles
  • General prose
  • Technical documentation
  • Web content

Limitations

Users should be aware of the following limitations:

  • Domain Specificity: The model may not perform optimally on highly specialized domains (e.g., legal, medical, technical jargon) that were underrepresented in the training data
  • Context Length: The model has a maximum position embedding of 512 tokens, which may limit its ability to handle very long documents in a single pass
  • Idiomatic Expressions: Like most translation models, it may struggle with idiomatic expressions, cultural references, and nuanced language
  • Named Entities: Proper nouns and named entities may not always be translated correctly or preserved
  • Low-Resource Scenarios: Performance may degrade on text that differs significantly from the training distribution
  • No Fine-tuning: This is a base model and has not been fine-tuned for specific domains or use cases

How to Use

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?"

Batch Translation

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)}")

Using Pipeline API

from transformers import pipeline

translator = pipeline("translation", model="playground/opus-mt-de-en")
result = translator("Guten Morgen!")
print(result[0]['translation_text'])
Downloads last month
58
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support