Downloads · 30 days
44
6% of all-time downloads
Paulwalker4884/facebook-persian
facebook-persian is a translation model from Paulwalker4884. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as apache-2.0.
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.
Downloads · 30 days
44
6% of all-time downloads
All-time downloads
728
Public
Parameters
615M
2.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors2.5 GB · 99%
From the Hugging Face model README
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.
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.
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}")
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'])
This model shows significant improvements in Persian to English translation quality:
| Persian (فارسی) | English |
|---|---|
| سلام دنیا | Hello world |
| چطور هستید؟ | How are you? |
| من دانشجوی دانشگاه هستم | I am a university student |
| امروز هوا خیلی خوب است | The weather is very nice today |
pip install transformers torch
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}
}
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.