opus mt fr en
Helsinki-NLPIntroduction
The OPUS-MT-FR-EN model by the Helsinki-NLP group is a machine translation model designed to translate text from French (fr) to English (en). It is part of the OPUS-MT project which aims to provide open-source machine translation models for numerous language pairs.
Architecture
This model employs a transformer architecture, specifically tuned with alignment capabilities. The pre-processing steps for the model include normalization and the use of SentencePiece for tokenization. It is built using datasets from OPUS and has been trained with the transformer-align framework.
Training
The model was trained on datasets from the OPUS collection, a large-scale corpus designed for machine translation tasks. The original weights for the model can be downloaded from the provided link, with a specified date of 2020-02-26. Evaluation scores are available for various test sets, with performance measured using BLEU and chr-F scores.
Guide: Running Locally
To run the OPUS-MT-FR-EN model locally, follow these steps:
- Setup Environment: Ensure Python and PyTorch are installed. You may also use TensorFlow or JAX as this model is compatible with these libraries.
- Install Transformers Library: Use the Hugging Face
transformers
library, which can be installed via pip:pip install transformers
- Download Model: Load the model using the Transformers library:
from transformers import MarianMTModel, MarianTokenizer model_name = 'Helsinki-NLP/opus-mt-fr-en' tokenizer = MarianTokenizer.from_pretrained(model_name) model = MarianMTModel.from_pretrained(model_name)
- Translate Text: Use the model to translate French text into English:
text = "Votre texte en français ici." translated = model.generate(**tokenizer(text, return_tensors="pt", padding=True)) print([tokenizer.decode(t, skip_special_tokens=True) for t in translated])
- Recommended Hardware: For optimal performance, especially for large-scale translations, consider using cloud GPUs from providers like AWS, Google Cloud, or Azure.
License
The OPUS-MT-FR-EN model is licensed under the Apache 2.0 License, which permits use, distribution, and modification, provided that appropriate credit is given, and notices are preserved.