aysangh commited on
Commit
92e4346
·
verified ·
1 Parent(s): 88d76fc

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -0
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - fa
5
+ metrics:
6
+ - f1
7
+ - accuracy
8
+ base_model:
9
+ - myrkur/Persian-ModernBert-base
10
+ library_name: transformers
11
+ ---
12
+
13
+ # ModernBERT-base-fa-taghche
14
+
15
+ Fine-tuned Persian sentiment analysis model based on [`myrkur/Persian-ModernBert-base`](https://huggingface.co/myrkur/Persian-ModernBert-base) for binary sentiment classification on the Taaghche Persian review dataset.
16
+
17
+ ## Dataset
18
+
19
+ The model was trained on the Taaghche Persian reviews dataset available on Kaggle:
20
+
21
+ * [Taaghche Dataset](https://www.kaggle.com/saeedtqp/taaghche)
22
+
23
+ ## Model Details
24
+
25
+ * **Base model:** `myrkur/Persian-ModernBert-base`
26
+ * **Task:** Sentiment Classification
27
+ * **Language:** Persian (Farsi)
28
+ * **Framework:** Transformers + PyTorch
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
34
+ import torch
35
+
36
+ model_name = "aysangh/ModernBERT-base-fa-taghche"
37
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
38
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
39
+
40
+ def predict_sentiment(text):
41
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256, padding=True)
42
+ with torch.no_grad():
43
+ outputs = model(**inputs)
44
+ probs = torch.softmax(outputs.logits, dim=-1)
45
+ pred = torch.argmax(probs, dim=-1).item()
46
+ confidence = probs[0][pred].item()
47
+ return {
48
+ "label": "positive" if pred == 0 else "negative",
49
+ "confidence": confidence
50
+ }
51
+
52
+ text = "خیلی بد بود، اصلاً پیشنهاد نمی‌کنم."
53
+
54
+ result = predict_sentiment(text)
55
+ print(result)
56
+
57
+ # Output:
58
+ # {'label': 'negative', 'confidence': 0.9999935626983643}
59
+ ```
60
+
61
+ ## Repository
62
+
63
+ Training and inference scripts are available on [GitHub](https://github.com/aysangh/persian-sentiment-analysis).