Create README.md
Browse filesAdded Readme File ..
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hindi to English Translation Model
|
| 2 |
+
|
| 3 |
+
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.
|
| 4 |
+
|
| 5 |
+
## Model Details
|
| 6 |
+
|
| 7 |
+
- **Model Name:** Helsinki-NLP/opus-mt-hi-en
|
| 8 |
+
- **Language:** Hindi to English
|
| 9 |
+
- **Framework:** Transformers (Hugging Face)
|
| 10 |
+
- **License:** Apache 2.0
|
| 11 |
+
|
| 12 |
+
## Installation
|
| 13 |
+
|
| 14 |
+
To use this model, install the required dependencies:
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
pip install transformers torch
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
## Usage
|
| 21 |
+
|
| 22 |
+
You can use this model with the Hugging Face `transformers` library as follows:
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
from transformers import MarianMTModel, MarianTokenizer
|
| 26 |
+
|
| 27 |
+
def translate(text):
|
| 28 |
+
model_name = "Helsinki-NLP/opus-mt-hi-en"
|
| 29 |
+
tokenizer = MarianTokenizer.from_pretrained(model_name)
|
| 30 |
+
model = MarianMTModel.from_pretrained(model_name)
|
| 31 |
+
|
| 32 |
+
# Tokenize input text
|
| 33 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 34 |
+
|
| 35 |
+
# Generate translation
|
| 36 |
+
translated_tokens = model.generate(**inputs)
|
| 37 |
+
translation = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)
|
| 38 |
+
|
| 39 |
+
return translation[0]
|
| 40 |
+
|
| 41 |
+
# Example usage
|
| 42 |
+
hindi_text = "\u092e\u0947\u0930\u093e \u0928\u093e\u092e \u0930\u093e\u0939\u0941\u0932 \u0939\u0948"
|
| 43 |
+
english_translation = translate(hindi_text)
|
| 44 |
+
print("Translation:", english_translation)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## License
|
| 48 |
+
|
| 49 |
+
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.
|
| 50 |
+
|
| 51 |
+
## Acknowledgments
|
| 52 |
+
|
| 53 |
+
- **Helsinki-NLP** for providing the OPUS-MT model.
|
| 54 |
+
- **Hugging Face** for the `transformers` library.
|
| 55 |
+
|