aref-j commited on
Commit
de01ca1
·
verified ·
1 Parent(s): 9a5f464

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +128 -1
README.md CHANGED
@@ -9,4 +9,131 @@ base_model:
9
  - HooshvareLab/bert-base-parsbert-uncased
10
  pipeline_tag: text-classification
11
  library_name: transformers
12
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  - HooshvareLab/bert-base-parsbert-uncased
10
  pipeline_tag: text-classification
11
  library_name: transformers
12
+ ---
13
+ # Model Card for aref-j/emotion-classifier-bert-fa-v1
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+ This is a fine-tuned BERT model for classifying emotions in Persian text, specifically detecting 6 emotion categories: ANGRY, FEAR, HAPPY, HATE, SAD, SURPRISE. It was developed using a merged dataset of Persian emotion corpora and is designed for applications like sentiment analysis on Persian tweets.
16
+
17
+ ## Model Details
18
+ ### Model Description
19
+ <!-- Provide a longer summary of what this model is. -->
20
+ This model is a fine-tuned version of ParsBERT (HooshvareLab/bert-base-parsbert-uncased) for emotion classification in Persian text. It uses a BERT base architecture with a sequence classification head to predict one of six emotion labels from input text. The model addresses class imbalance through weighted cross-entropy loss and was trained on a combined dataset of Persian tweets and short texts.
21
+ - **Developed by:** Aref Jafary
22
+ - **Model type:** Text classification (fine-tuned BERT)
23
+ - **Language(s) (NLP):** Persian (fa)
24
+ - **License:** MIT
25
+ - **Finetuned from model:** HooshvareLab/bert-base-parsbert-uncased
26
+ ### Model Sources [optional]
27
+ <!-- Provide the basic links for the model. -->
28
+ - **Repository:** https://github.com/ArefJafary/Persian-Emotion-Classification-BERT
29
+ - **Paper [optional]:** Not available
30
+ - **Demo [optional]:** Not available
31
+ ## Uses
32
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
33
+ ### Direct Use
34
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
35
+ The model can be used directly for inferring emotions from Persian text inputs, such as tweets or short messages, via the Hugging Face Transformers pipeline. It is suitable for applications in social media monitoring, customer feedback analysis, or psychological text analysis in Persian-speaking contexts.
36
+ ### Downstream Use [optional]
37
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
38
+ The model can be further fine-tuned for specific downstream tasks like multi-label emotion detection or integrated into larger NLP systems for Persian language processing.
39
+ ### Out-of-Scope Use
40
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
41
+ The model is not intended for use in non-Persian languages, multi-label classification, or real-time high-stakes applications without further validation. It may not perform well on formal Persian text, dialects, or noisy data beyond tweets. Misuse could include biased emotional profiling or surveillance without ethical considerations.
42
+ ## Bias, Risks, and Limitations
43
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
44
+ The model may inherit biases from the training datasets, which are primarily sourced from social media (tweets), potentially reflecting cultural, demographic, or topical biases in Persian online content. It handles 6 emotions but may struggle with nuanced or mixed emotions. Performance is evaluated on a held-out set, but real-world generalization could vary. Class imbalance in emotions like HATE or SURPRISE might affect minority class predictions.
45
+ ### Recommendations
46
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
47
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Evaluate the model on your specific dataset before deployment. Consider debiasing techniques or additional data for underrepresented emotions. Use ethically and transparently, especially in sensitive applications.
48
+ ## How to Get Started with the Model
49
+ Use the code below to get started with the model.
50
+ ```python
51
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
52
+
53
+ model_name = "aref-j/emotion-classifier-bert-fa-v1"
54
+
55
+ # Load tokenizer and model
56
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
57
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
58
+
59
+ # Create the classification pipeline
60
+ classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
61
+
62
+ # Example usage
63
+ result = classifier("چه هوای زیبایی امروز است")
64
+ print(result) # e.g. [{'label': 'HAPPY', 'score': 0.99}]
65
+ ```
66
+ ## Training Details
67
+ ### Training Data
68
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
69
+ The model was trained on a merged dataset from three Persian emotion corpora:
70
+ - **ArmanEmo**: Over 7,000 Persian sentences labeled for 7 emotions. [Paper](https://arxiv.org/abs/2207.11808), [GitHub](https://github.com/Arman-Rayan-Sharif/arman-text-emotion)
71
+ - **EmoPars**: 30,000 Persian tweets labeled with 6 basic emotions (Anger, Fear, Happiness, Sadness, Hatred, Wonder). [Paper](https://aclanthology.org/2021.ranlp-srw.23/), [GitHub](https://github.com/nazaninsbr/Persian-Emotion-Detection)
72
+ - **ShortPersianEmo**: 5,472 short Persian texts labeled for 5 emotions (angry, sad, fear, happy, neutral). [GitHub](https://github.com/vkiani/ShortPersianEmo), [Paper](https://jad.shahroodut.ac.ir/article_3030_8c27fa0d8cb5bfba01e6835a469d3072.pdf)
73
+
74
+ Datasets were standardized, cleaned (normalization with Parsivar, removal of URLs, mentions, emojis, etc.), deduplicated, and split into 90% train / 10% validation, with ArmanEmo held out for testing.
75
+ ### Training Procedure
76
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
77
+ #### Preprocessing [optional]
78
+ Text was normalized using Parsivar, with character mapping, diacritic removal, and stripping of URLs, mentions, hashtags, emojis, punctuation, digits, and extra spaces. Multi-label instances in EmoPars were converted to single-label via dominant label.
79
+ #### Training Hyperparameters
80
+ - **Training regime:** fp32 (assumed, not specified)
81
+ - Batch size: 32
82
+ - Epochs: 6
83
+ - Learning rate: 1e-5
84
+ - Optimizer: Not specified (default Hugging Face Trainer)
85
+ - Loss: Weighted cross-entropy to handle class imbalance
86
+ - Early stopping: After 2 epochs without validation loss improvement
87
+ #### Speeds, Sizes, Times [optional]
88
+ Not specified.
89
+ ## Evaluation
90
+ <!-- This section describes the evaluation protocols and provides the results. -->
91
+ ### Testing Data, Factors & Metrics
92
+ #### Testing Data
93
+ <!-- This should link to a Dataset Card if possible. -->
94
+ Held-out ArmanEmo test set.
95
+ #### Factors
96
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
97
+ Evaluation disaggregated by emotion classes (ANGRY, FEAR, HAPPY, HATE, SAD, SURPRISE).
98
+ #### Metrics
99
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
100
+ Accuracy (overall correct predictions), Macro F1-score (average F1 across classes, treating all equally), Precision, Recall, and Confusion Matrix.
101
+ ### Results
102
+ - Test Accuracy: 70.88%
103
+ - Macro F1-Score: 66.35%
104
+
105
+ Detailed per-class metrics and confusion matrix available in the repository.
106
+ #### Summary
107
+ The model shows robust performance on unseen Persian tweet data, with good generalization across emotions.
108
+
109
+
110
+ ## Technical Specifications [optional]
111
+ ### Model Architecture and Objective
112
+ BERT base model with a sequence classification head for multi-class emotion prediction.
113
+ #### Hardware
114
+ T4.
115
+ #### Software
116
+ Hugging Face Transformers library, Python.
117
+
118
+
119
+ **BibTeX:**
120
+ ```
121
+ @misc{jafary2023persianemotion,
122
+ author = {Aref Jafary},
123
+ title = {Persian Emotion Classification with BERT},
124
+ year = {2023},
125
+ publisher = {GitHub},
126
+ journal = {GitHub repository},
127
+ howpublished = {\url{https://github.com/ArefJafary/Persian-Emotion-Classification-BERT}}
128
+ }
129
+ ```
130
+
131
+ **APA:**
132
+ Jafary, A. (2023). Persian Emotion Classification with BERT [Repository]. GitHub. https://github.com/ArefJafary/Persian-Emotion-Classification-BERT
133
+ ## Glossary
134
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
135
+ - **ParsBERT**: A BERT model pre-trained on Persian text.
136
+ - **Weighted Cross-Entropy**: Loss function that assigns higher weights to underrepresented classes.
137
+
138
+ ## Model Card Contact
139
+ Contact via GitHub: https://github.com/ArefJafary