safetensors marian region:us
---
{}
---
# English to Tamazight (zgh) Translator Model

This model is a fine-tuned MarianMT model for translating text from **English** (`en`) to **Tamazight** (`zgh`). It is based on the [Helsinki-NLP/opus-mt-en-ROMANCE](https://huggingface.co/Helsinki-NLP/opus-mt-en-ROMANCE) architecture and fine-tuned using a custom dataset of English-Tamazight sentence pairs.

---

## Model Details

- **Base Model**: `Helsinki-NLP/opus-mt-en-ROMANCE`
- **Fine-Tuned Language Pair**: English (`en`) → Tamazight (`zgh`)
- **Framework**: Hugging Face Transformers
- **Architecture**: MarianMT

---

## Features

- **Input Language**: English
- **Output Language**: Tamazight (Standard Amazigh, ISO 639-3: `zgh`)
- **Use Case**: Translation of text from English to Tamazight, suitable for low-resource machine translation tasks.

---

## How to Use

### Installation

Install the required libraries:
```bash 
pip install transformers torch sentencepiece
```

### Loading the Model

Use the following code to load and use the model for translation:

```py
from transformers import MarianMTModel, MarianTokenizer

# Load the fine-tuned model and tokenizer
model_name = "ilyasaqit/MarianMTModel-EN-ZGH-PreTrained"
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)

# Translate text
def translate_to_tamazight(text: str) -> str:
    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
    translated = model.generate(**inputs)
    return tokenizer.decode(translated[0], skip_special_tokens=True)

# Example usage
text = "Hello, how are you?"
tamazight_translation = translate_to_tamazight(text)
print(f"Tamazight Translation: {tamazight_translation}")
```

