Downloads · 30 days
17
25% of all-time downloads
mohres/Arabic-Book-Review-Sentiment-Assessment
Arabic-Book-Review-Sentiment-Assessment is a text classification model from mohres. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
17
25% of all-time downloads
All-time downloads
67
Public
Parameters
167M
2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors669 MB · 99%
From the Hugging Face model README
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:
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.
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.
More information needed
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"])
The following hyperparameters were used during training:
| 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 |