Persian-t5-formality-transfer
This is a formality style transfer model for the Persian language to convert colloquial text into a formal one. It is based on the monolingual T5 model for Persian. and Persian T5 paraphraser
Note: This model is still in development and therefore its outputs might not be very good. However, you can experiment with different values for the decoder to get better results. For more info check this link.
Usage
>>> pip install transformers
>>> from transformers import (T5ForConditionalGeneration, AutoTokenizer, pipeline)
>>> import torch
model_path = 'erfan226/persian-t5-formality-transfer'
model = T5ForConditionalGeneration.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
pipe = pipeline(task='text2text-generation', model=model, tokenizer=tokenizer)
def paraphrase(text):
for j in range(3):
out = pipe(text, encoder_no_repeat_ngram_size=4, do_sample=True, num_beams=5, max_length=128)[0]['generated_text']
print("Paraphrase:", out)
text = "من با دوستام میرم بازی"
print("Original:", text)
paraphrase(text)
# Original: من با دوستام میرم بازی
# Paraphrase: دوست دارم با دوستانم بازی کنم.
# Paraphrase: من با دوستانم میرم...
# Paraphrase: من با دوستام بازی می کنم.
Training data
TBD
- Downloads last month
- 33
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.