language:
- ar
license: apache-2.0
tags:
- generated_from_trainer
base_model: google-bert/bert-base-multilingual-uncased
datasets:
- labr
widget:
- text: كتاب يستحق القراءة
example_title: مثال 1
- text: ما عجبني بنوب
example_title: مثال 2
- text: لم يعجبني أبدا
example_title: مثال 3
- text: أنصح وبشدة قراءة الكتاب خصوصا لمن لديه اهتمام في العلوم الاجتماعية
example_title: مثال 4
- text: ماشي حالو بعطيه 4 من 10
example_title: مثال 5
model-index:
- name: Arabic-Book-Review-Sentiment-Assessment
results: []
Arabic-Book-Review-Sentiment-Assessment
This model is a fine-tuned version of google-bert/bert-base-multilingual-uncased on labr dataset. It achieves the following results on the evaluation set:
- Loss: 1.5290
Model description
The purpose of this model is to analyze Arabic review texts and predict the appropriate rating for them, based on the sentiment and content of the review. This can be particularly useful in tasks such as sentiment analysis, customer feedback analysis, or any application where understanding the sentiment conveyed in an Arabic textual review is important.
Intended uses & limitations
While the model performs well with formal Arabic text (Examples 1, 3, and 4), it may struggle with slang or informal language, occasionally assigning higher ratings than expected (Example 2). Additionally, the model is not capable of interpreting verbally given ratings (Example 5). Users should be aware of these limitations and provide context-appropriate input for optimal performance.
Training and evaluation data
More information needed
Training procedure
import torch
from datasets import load_dataset
from transformers import (
AutoModelForSequenceClassification,
AutoTokenizer,
DataCollatorWithPadding,
TrainingArguments,
Trainer
)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
labr = load_dataset("labr")
labels = {0,1,2,3,4}
target_names = [
"Poor",
"Fair",
"Good",
"Very Good",
"Excellent"
]
id2label = {idx: label for idx, label in enumerate(target_names)}
label2id = {label: idx for idx, label in enumerate(target_names)}
BERT_MODEL = "google-bert/bert-base-multilingual-uncased"
model = AutoModelForSequenceClassification.from_pretrained(BERT_MODEL, num_labels = len(id2label))
tokenizer = AutoTokenizer.from_pretrained(BERT_MODEL)
model.to(device)
def preprocess_function(examples):
return tokenizer(examples["text"], truncation=True)
tokenized_labr = labr.map(preprocess_function, batched=True)
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)
training_args = TrainingArguments(
output_dir="Arabic-Book-Review-Sentiment-Assessment",
learning_rate=2e-5,
per_device_train_batch_size=8,
per_device_eval_batch_size=8,
num_train_epochs=1,
weight_decay=0.01,
push_to_hub=True
)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=tokenized_labr["train"],
eval_dataset=tokenized_labr["test"],
tokenizer=tokenizer,
data_collator=data_collator,
)
trainer.train()
trainer.evaluate(tokenized_labr["test"])
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 5
Training results
Training Loss | Epoch | Step | Validation Loss |
---|---|---|---|
1.0459 | 1.0 | 1470 | 1.5290 |
0.7622 | 2.0 | 2940 | 1.6278 |
0.8204 | 3.0 | 4410 | 1.5341 |
0.6592 | 4.0 | 5880 | 1.8030 |
0.4976 | 5.0 | 7350 | 1.9638 |
Framework versions
- Transformers 4.39.1
- Pytorch 2.2.1+cu121
- Datasets 2.18.0
- Tokenizers 0.15.2