# Hindi to English Translation Model This repository contains a pre-trained machine translation model for translating text from Hindi to English. The model is based on the **Helsinki-NLP/opus-mt-hi-en** model, utilizing the **Transformers** framework. ## Model Details - **Model Name:** Helsinki-NLP/opus-mt-hi-en - **Language:** Hindi to English - **Framework:** Transformers (Hugging Face) - **License:** Apache 2.0 ## Installation To use this model, install the required dependencies: ```bash pip install transformers torch ``` ## Usage You can use this model with the Hugging Face `transformers` library as follows: ```python from transformers import MarianMTModel, MarianTokenizer def translate(text): model_name = "Helsinki-NLP/opus-mt-hi-en" tokenizer = MarianTokenizer.from_pretrained(model_name) model = MarianMTModel.from_pretrained(model_name) # Tokenize input text inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True) # Generate translation translated_tokens = model.generate(**inputs) translation = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True) return translation[0] # Example usage hindi_text = "\u092e\u0947\u0930\u093e \u0928\u093e\u092e \u0930\u093e\u0939\u0941\u0932 \u0939\u0948" english_translation = translate(hindi_text) print("Translation:", english_translation) ``` ## License This project is licensed under the **Apache 2.0** License. See the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) file for more details. ## Acknowledgments - **Helsinki-NLP** for providing the OPUS-MT model. - **Hugging Face** for the `transformers` library.