Persian to English Translation Model

This is a fine-tuned translation model based on facebook/nllb-200-distilled-600M specifically optimized for Persian (Farsi) to English translation with high accuracy.

Model Description

This model has been fine-tuned to provide high-quality translation from Persian (Farsi) to English. It achieves superior performance compared to the base model on Persian text translation tasks.

  • Developed by: Yasin keykha
  • Model type: Sequence-to-sequence translation model
  • Language(s): Persian (Farsi) → English
  • License: Apache-2.0
  • Base model: facebook/nllb-200-distilled-600M

Usage

Direct Usage with Transformers

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Load model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("Paulwalker4884/facebook-persian")
tokenizer = AutoTokenizer.from_pretrained("Paulwalker4884/facebook-persian")

# Translation function
def translate_persian_to_english(persian_text):
    # Set source language to Persian
    tokenizer.src_lang = "pes_Arab"
    
    # Encode input text
    inputs = tokenizer(persian_text, return_tensors="pt", padding=True, truncation=True)
    
    # Generate translation
    with torch.no_grad():
        generated_tokens = model.generate(
            **inputs,
            forced_bos_token_id=tokenizer.lang_code_to_id["eng_Latn"],
            max_length=256,
            num_beams=4,
            early_stopping=True
        )
    
    # Decode and return result
    translation = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
    return translation

# Example usage
persian_text = "سلام دنیا، چطور هستید؟"
english_translation = translate_persian_to_english(persian_text)
print(f"Persian: {persian_text}")
print(f"English: {english_translation}")

Using with Pipeline

from transformers import pipeline

translator = pipeline("translation", model="Paulwalker4884/facebook-persian")
result = translator("سلام دنیا", src_lang="pes_Arab", tgt_lang="eng_Latn")
print(result[0]['translation_text'])

Performance

This model shows significant improvements in Persian to English translation quality:

  • High accuracy on everyday Persian text
  • Better context understanding compared to base model
  • Improved handling of Persian idioms and expressions
  • Optimized for modern Persian language use

Training Details

  • Base Model: facebook/nllb-200-distilled-600M
  • Fine-tuning Method: Full model fine-tuning
  • Training Data: High-quality Persian-English parallel corpus
  • Optimization: Focused on Persian to English translation accuracy

Example Translations

Persian (فارسی) English
سلام دنیا Hello world
چطور هستید؟ How are you?
من دانشجوی دانشگاه هستم I am a university student
امروز هوا خیلی خوب است The weather is very nice today

Limitations

  • Optimized primarily for Persian to English translation
  • Performance may vary with highly technical or domain-specific texts
  • Best results with modern Persian text

Installation

pip install transformers torch

Citation

If you use this model, please cite:

@misc{persian-english-translator,
  title={Persian to English Translation Model},
  author={Yasin},
  year={2024},
  publisher={Hugging Face},
  url={https://huggingface.co/Paulwalker4884/facebook-persian}
}

Contact

For questions or issues, please contact through the model repository.


Note: This model is specifically fine-tuned for Persian to English translation and provides high-quality results for this language pair.

Downloads last month
87
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support