Abdulrahman Al-Ghamdi
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
datasets:
|
@@ -9,95 +12,78 @@ metrics:
|
|
9 |
- precision
|
10 |
- recall
|
11 |
- f1
|
12 |
-
base_model:
|
|
|
13 |
pipeline_tag: text-classification
|
14 |
tags:
|
15 |
-
- text-classification
|
16 |
-
- sentiment-analysis
|
17 |
- arabic
|
18 |
-
-
|
19 |
-
|
20 |
-
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
name: hadyelsahar/ar_res_reviews
|
26 |
-
type: sentiment-analysis
|
27 |
-
metrics:
|
28 |
-
- name: Accuracy
|
29 |
-
type: accuracy
|
30 |
-
value: 86.41
|
31 |
-
- name: Precision
|
32 |
-
type: precision
|
33 |
-
value: 87.01
|
34 |
-
- name: Recall
|
35 |
-
type: recall
|
36 |
-
value: 86.49
|
37 |
-
- name: F1 Score
|
38 |
-
type: f1
|
39 |
-
value: 86.75
|
40 |
-
library_name: transformers
|
41 |
---
|
42 |
|
43 |
-
#
|
44 |
-
## π Overview
|
45 |
-
This project fine-tunes **AraBERT** to analyze sentiment in **Arabic restaurant reviews**.
|
46 |
-
We leveraged **Hugging Faceβs `transformers` library** for training and deployed the model as an **interactive pipeline**.
|
47 |
|
48 |
-
##
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
##
|
54 |
-
- **
|
55 |
-
|
56 |
-
- **
|
|
|
|
|
57 |
- **Tokenization**:
|
58 |
-
- Used **AraBERT tokenizer**
|
59 |
-
- **Data Balancing**:
|
60 |
-
- 2,418 **Positive** | 2,418 **Negative** (Balanced Dataset).
|
61 |
- **Train-Test Split**:
|
62 |
- **80% Training** | **20% Testing**.
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
66 |
|
67 |
-
### **π Model
|
68 |
| Metric | Score |
|
69 |
|-------------|--------|
|
70 |
-
| **Train Loss
|
71 |
-
| **Eval Loss**
|
72 |
-
| **Accuracy**
|
73 |
-
| **Precision**
|
74 |
-
| **Recall**
|
75 |
-
| **F1-score**
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
## βοΈ Training Parameters
|
80 |
```python
|
81 |
-
model_name = "aubmindlab/bert-base-arabertv2"
|
82 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2, classifier_dropout=0.5).to(device)
|
83 |
-
|
84 |
training_args = TrainingArguments(
|
85 |
output_dir="./results",
|
86 |
-
evaluation_strategy="epoch",
|
87 |
-
save_strategy="epoch",
|
88 |
-
per_device_train_batch_size=8,
|
89 |
-
per_device_eval_batch_size=8,
|
90 |
-
num_train_epochs=4,
|
91 |
-
weight_decay=1,
|
92 |
-
learning_rate=1e-5,
|
93 |
-
lr_scheduler_type="cosine",
|
94 |
-
warmup_ratio=0.1,
|
95 |
fp16=True,
|
96 |
-
report_to="none",
|
97 |
save_total_limit=2,
|
98 |
gradient_accumulation_steps=2,
|
99 |
load_best_model_at_end=True,
|
100 |
max_grad_norm=1.0,
|
101 |
metric_for_best_model="eval_loss",
|
102 |
greater_is_better=False,
|
103 |
-
)
|
|
|
1 |
+
# Create a Markdown file with the enhanced model card content
|
2 |
+
|
3 |
+
model_card_content = """\
|
4 |
---
|
5 |
license: apache-2.0
|
6 |
datasets:
|
|
|
12 |
- precision
|
13 |
- recall
|
14 |
- f1
|
15 |
+
base_model:
|
16 |
+
- aubmindlab/bert-base-arabertv02
|
17 |
pipeline_tag: text-classification
|
18 |
tags:
|
|
|
|
|
19 |
- arabic
|
20 |
+
- sentiment-analysis
|
21 |
+
- transformers
|
22 |
+
- huggingface
|
23 |
+
- bert
|
24 |
+
- restaurants
|
25 |
+
- fine-tuning
|
26 |
+
- nlp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
---
|
28 |
|
29 |
+
# **π½οΈ Arabic Restaurant Review Sentiment Analysis π**
|
|
|
|
|
|
|
30 |
|
31 |
+
## **π Overview**
|
32 |
+
This **fine-tuned AraBERT model** classifies **Arabic restaurant reviews** as **Positive** or **Negative**.
|
33 |
+
It is based on **aubmindlab/bert-base-arabertv2** and fine-tuned using **Hugging Face Transformers**.
|
34 |
+
|
35 |
+
### **π₯ Why This Model?**
|
36 |
+
β
**Trained on Real Restaurant Reviews** from the **Hugging Face Dataset**.
|
37 |
+
β
**Fine-tuned with Full Training** (not LoRA or Adapters).
|
38 |
+
β
**Balanced Dataset** (2418 Positive vs. 2418 Negative Reviews).
|
39 |
+
β
**High Accuracy & Performance** for Sentiment Analysis in Arabic.
|
40 |
+
|
41 |
+
---
|
42 |
|
43 |
+
## **π₯ Dataset & Preprocessing**
|
44 |
+
- **Dataset Source**: [`hadyelsahar/ar_res_reviews`](https://huggingface.co/datasets/hadyelsahar/ar_res_reviews)
|
45 |
+
- **Text Cleaning**:
|
46 |
+
- Removed **non-Arabic text**, special characters, and extra spaces.
|
47 |
+
- Normalized Arabic characters (`Ψ₯, Ψ£, Ψ’ β Ψ§`, `Ψ© β Ω`).
|
48 |
+
- Balanced **Positive & Negative** sentiment distribution.
|
49 |
- **Tokenization**:
|
50 |
+
- Used **AraBERT tokenizer** (`aubmindlab/bert-base-arabertv2`).
|
|
|
|
|
51 |
- **Train-Test Split**:
|
52 |
- **80% Training** | **20% Testing**.
|
53 |
|
54 |
+
---
|
55 |
+
|
56 |
+
## **ποΈ Training & Performance**
|
57 |
+
The model was fine-tuned using **Hugging Face Transformers** with the following hyperparameters:
|
58 |
|
59 |
+
### **π Final Model Results**
|
60 |
| Metric | Score |
|
61 |
|-------------|--------|
|
62 |
+
| **Train Loss** | `0.470` |
|
63 |
+
| **Eval Loss** | `0.373` |
|
64 |
+
| **Accuracy** | `86.41%` |
|
65 |
+
| **Precision** | `87.01%` |
|
66 |
+
| **Recall** | `86.49%` |
|
67 |
+
| **F1-score** | `86.75%` |
|
68 |
|
69 |
+
### **βοΈ Training Configuration**
|
|
|
|
|
70 |
```python
|
|
|
|
|
|
|
71 |
training_args = TrainingArguments(
|
72 |
output_dir="./results",
|
73 |
+
evaluation_strategy="epoch",
|
74 |
+
save_strategy="epoch",
|
75 |
+
per_device_train_batch_size=8,
|
76 |
+
per_device_eval_batch_size=8,
|
77 |
+
num_train_epochs=4,
|
78 |
+
weight_decay=1,
|
79 |
+
learning_rate=1e-5,
|
80 |
+
lr_scheduler_type="cosine",
|
81 |
+
warmup_ratio=0.1,
|
82 |
fp16=True,
|
|
|
83 |
save_total_limit=2,
|
84 |
gradient_accumulation_steps=2,
|
85 |
load_best_model_at_end=True,
|
86 |
max_grad_norm=1.0,
|
87 |
metric_for_best_model="eval_loss",
|
88 |
greater_is_better=False,
|
89 |
+
)
|