mbart large 50 many to many mmt

facebook

Introduction

The mbart-large-50-many-to-many-mmt is a multilingual machine translation model fine-tuned from the mBART-large-50 architecture. It supports direct translation between 50 languages and was introduced in the paper "Multilingual Translation with Extensible Multilingual Pretraining and Finetuning."

Architecture

The model is based on the mBART (Multilingual Bidirectional and Auto-Regressive Transformers) architecture, designed for text-to-text generation tasks. It uses a pretraining and fine-tuning approach to enable multilingual capabilities, including translation between numerous language pairs without requiring separate models for each pair.

Training

The model was fine-tuned on a dataset covering 50 languages, enabling it to translate directly between any pair of these languages. During translation, the target language ID is forced as the first generated token using the forced_bos_token_id parameter in the generate method.

Guide: Running Locally

To run the model locally, follow these steps:

  1. Install the Transformers library:

    pip install transformers
    
  2. Load the model and tokenizer:

    from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
    
    model = MBartForConditionalGeneration.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")
    tokenizer = MBart50TokenizerFast.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")
    
  3. Translate text:

    tokenizer.src_lang = "hi_IN"
    encoded_hi = tokenizer("संयुक्त राष्ट्र के प्रमुख का कहना है कि सीरिया में कोई सैन्य समाधान नहीं है", return_tensors="pt")
    generated_tokens = model.generate(**encoded_hi, forced_bos_token_id=tokenizer.lang_code_to_id["fr_XX"])
    translation = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
    

For efficient training and inference, consider using cloud-based GPUs such as those provided by Google Cloud, AWS, or Azure.

License

The model is available for use under the terms specified by Facebook AI, the creators of the model. Please refer to the Hugging Face model card for specific licensing details.

More Related APIs in Translation