PardisSzah commited on
Commit
f4b3e33
·
verified ·
1 Parent(s): 205140f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -0
README.md CHANGED
@@ -1,3 +1,80 @@
1
  ---
 
2
  license: mit
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: fa
3
  license: mit
4
+ pipeline_tag: text-classification
5
  ---
6
+
7
+
8
+ # PersianEase
9
+
10
+ This model is fine-tuned to classify informal text and formal text. It has been fine-tuned on [Mohavere Dataset] (Takalli vahideh, Kalantari, Fateme, Shamsfard, Mehrnoush, Developing an Informal-Formal Persian Corpus, 2022.) using the pretrained model [persian-t5-formality-transfer](https://huggingface.co/HooshvareLab/bert-base-parsbert-uncased).
11
+
12
+
13
+ ## Evaluation Metrics
14
+
15
+ **INFORMAL**:
16
+ Precision: 0.99
17
+ Recall: 0.99
18
+ F1-Score: 0.99
19
+ **FORMAL**:
20
+ Precision: 0.99
21
+ Recall: 1.0
22
+ F1-Score: 0.99
23
+
24
+ **Accuracy**: 0.99
25
+ **Macro Avg**:
26
+ Precision: 0.99
27
+ Recall: 0.99
28
+ F1-Score: 0.99
29
+ **Weighted Avg**:
30
+ Precision: 0.99
31
+ Recall: 0.99
32
+ F1-Score: 0.99
33
+
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+
39
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
40
+ import torch
41
+
42
+ labels = ["INFORMAL", "FORMAL"]
43
+
44
+ model = AutoModelForSequenceClassification.from_pretrained('parsi-ai-nlpclass/sentence_formality_classifier')
45
+ tokenizer = AutoTokenizer.from_pretrained('parsi-ai-nlpclass/sentence_formality_classifier')
46
+
47
+ def test_model(text):
48
+ inputs = tokenizer(text, return_tensors='pt')
49
+ outputs = model(**inputs)
50
+ predicted_label = labels[int(torch.argmax(outputs.logits))]
51
+ return predicted_label
52
+
53
+ # Test the model
54
+ text1 = "من فقط می‌خواستم بگویم که چقدر قدردان هستم."
55
+ print("Original:", text1)
56
+ print("Predicted Label:", test_model(text1))
57
+
58
+ # output: FORMAL
59
+
60
+ text2 = "آرزویش است او را یک رستوران ببرم."
61
+ print("\nOriginal:", text2)
62
+ print("Predicted Label:", test_model(text2))
63
+
64
+ # output: FORMAL
65
+
66
+ text3 = "گل منو اذیت نکنید"
67
+ print("\nOriginal:", text2)
68
+ print("Predicted Label:", test_model(text3))
69
+
70
+ # output: INFORMAL
71
+
72
+ text4 = "من این دوربین رو خالم برام کادو خرید"
73
+ print("\nOriginal:", text2)
74
+ print("Predicted Label:", test_model(text3))
75
+
76
+ # output: INFORMAL
77
+
78
+
79
+
80
+ ```