| # π§ MarianMT-Text-Translation-AI-Model-"en-de" | |
| A sequence-to-sequence translation model fine-tuned on EnglishβGerman sentence pairs. This model translates English text into German and is built using the Hugging Face MarianMTModel. Itβs suitable for general-purpose translation, language learning, and formal or semi-formal communication across English and German. | |
| --- | |
| ## β¨ Model Highlights | |
| - π Base Model: Helsinki-NLP/opus-mt-en-de | |
| - π Fine-tuned on a cleaned and tokenized parallel English-German dataset | |
| - π Direction: English β German | |
| - π§ Framework: Hugging Face Transformers + PyTorch | |
| --- | |
| ## π§ Intended Uses | |
| - β Translating English content (emails, documentation, support text) into German | |
| - β Use in educational platforms for learning German | |
| - β Supporting cross-lingual customer service, product documentation, or semi-formal communications | |
| --- | |
| ## π« Limitations | |
| - β Not optimized for informal, idiomatic, or slang expressions | |
| - β Not ideal for legal, medical, or sensitive content translation | |
| - π Sentences longer than 128 tokens are truncated | |
| - β οΈ Domain-specific accuracy may vary (e.g., legal, technical) | |
| --- | |
| ## ποΈββοΈ Training Details | |
| | Attribute | Value | | |
| |--------------------|----------------------------------| | |
| | Base Model | `Helsinki-NLP/opus-mt-en-de` | | |
| | Dataset | WMT14 English-German | | |
| | Task Type | Translation | | |
| | Max Token Length | 128 | | |
| | Epochs | 3 | | |
| | Batch Size | 16 | | |
| | Optimizer | AdamW | | |
| | Loss Function | CrossEntropyLoss | | |
| | Framework | PyTorch + Transformers | | |
| | Hardware | CUDA-enabled GPU | | |
| --- | |
| ## π Evaluation Metrics | |
| | Metric | Score | | |
| |------------|---------| | |
| | BLEU Score | 30.42 | | |
| --- | |
| ## π Output Details | |
| - Input: English text string | |
| - Output: Translated German text string | |
| --- | |
| ## π Usage | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
| import torch | |
| model_name = "AventIQ-AI/Ai-Translate-Model-Eng-German" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
| model.eval() | |
| def translate(text): | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| model.to(device) | |
| inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True).to(device) | |
| outputs = model.generate(**inputs) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Example | |
| print(translate("How are you doing today?")) | |
| ``` | |
| --- | |
| ## π Repository Structure | |
| ``` | |
| finetuned-model/ | |
| βββ config.json β Model architecture & config | |
| βββ pytorch_model.bin β Model weights | |
| βββ tokenizer_config.json β Tokenizer settings | |
| βββ tokenizer.json β Tokenizer vocabulary (JSON format) | |
| βββ source.spm β SentencePiece model for source language | |
| βββ target.spm β SentencePiece model for target language | |
| βββ special_tokens_map.json β Special tokens mapping | |
| βββ generation_config.json β (Optional) Generation defaults | |
| βββ README.md β Model card | |
| ``` | |
| ## π€ Contributing | |
| Contributions are welcome! Feel free to open an issue or pull request to improve the model, training scripts, or documentation. | |