erfan226's picture
Update README.md
133eb72
|
raw
history blame
1.46 kB
metadata
language: fa
tags:
  - Style transfer
  - Formality style transfer
widget:
  - text: من با دوستام میرم بازی.
  - text: من به خونه دوستم رفتم.

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

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