erfan226 commited on
Commit
0ddef3f
1 Parent(s): 7b77c80

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: fa
3
+ tags:
4
+ - Style transfer
5
+ - Formality style transfer
6
+ widget:
7
+ - text: "من دوستام میرم بازی."
8
+ - text: "من به خونه دوستم رفتم."
9
+
10
+ ---
11
+
12
+ # Persian-t5-formality-transfer
13
+
14
+ 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.](https://huggingface.co/Ahmad/parsT5-base) and [Persian T5 paraphraser](https://huggingface.co/erfan226/persian-t5-paraphraser)
15
+
16
+ ## Usage
17
+
18
+ ```python
19
+
20
+ >>> pip install transformers
21
+ >>> from transformers import (T5ForConditionalGeneration, AutoTokenizer, pipeline)
22
+ >>> import torch
23
+
24
+ model_path = 'erfan226/persian-t5-formality-transfer'
25
+ model = T5ForConditionalGeneration.from_pretrained(model_path)
26
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
27
+ pipe = pipeline(task='text2text-generation', model=model, tokenizer=tokenizer)
28
+
29
+ def paraphrase(text):
30
+ for j in range(3):
31
+ out = pipe(text, encoder_no_repeat_ngram_size=4, do_sample=True, num_beams=5, max_length=128)[0]['generated_text']
32
+ print("Paraphrase:", out)
33
+
34
+ text = "من با دوستام میرم بازی"
35
+ print("Original:", text)
36
+ paraphrase(text)
37
+
38
+ # Original: من با دوستام میرم بازی
39
+ # Paraphrase: دوست دارم با دوستانم بازی کنم.
40
+ # Paraphrase: من با دوستانم میرم...
41
+ # Paraphrase: من با دوستام بازی می کنم.
42
+
43
+ ```
44
+
45
+ ## Training data
46
+ TBD