Downloads · 30 days
19
2% of all-time downloads
khaledsoudy/arabic-sentiment-bert-model
arabic-sentiment-bert-model is a text classification model from khaledsoudy. Use it when you need a label for a piece of text. The card lists the license as mit.
This repository contains a fine-tuned BERT model for sentiment analysis of Arabic reviews. The model is trained on the Arabic 100k Reviews dataset and can classify reviews into three sentiment categories: Positive, Ne…
Downloads · 30 days
19
2% of all-time downloads
All-time downloads
924
Public
Repo size
438 MB
Likes
2
Public
Click a slice to open those files.
.h5438 MB · 100%
From the Hugging Face model README
This repository contains a fine-tuned BERT model for sentiment analysis of Arabic reviews. The model is trained on the Arabic 100k Reviews dataset and can classify reviews into three sentiment categories: Positive, Negative, and Mixed.
Khaled Soudy
GitHub: khaledsoudy-1
You can find the source code and full implementation of this project on my GitHub repository.
The repository contains the Google Colab notebook, dataset, and scripts used to fine-tune the model for Arabic sentiment analysis.
Make sure you have the transformers and tensorflow libraries installed:
!pip install transformers
!pip install tensorflow
You can load the fine-tuned model and tokenizer directly from Hugging Face using the following code:
from transformers import TFBertForSequenceClassification, BertTokenizer
# Load model and tokenizer from Hugging Face
model_name = "khaledsoudy/arabic-sentiment-bert-model"
# Load model
model = TFBertForSequenceClassification.from_pretrained(model_name)
# Load tokenizer
tokenizer = BertTokenizer.from_pretrained(model_name)
To use the model for sentiment analysis on an Arabic text, follow these steps:
import tensorflow as tf
# Sample Arabic text for sentiment prediction
text = "الفندق رائع و الخدمة ممتازة"
# Tokenize the input text
inputs = tokenizer(text, return_tensors="tf")
# Get the model's prediction
outputs = model(**inputs)
# Get the predicted sentiment (assuming 3 classes: Positive, Negative, Mixed)
predicted_class = tf.argmax(outputs.logits, axis=-1).numpy()
# Map the predicted class index to sentiment labels
sentiment_labels = ['Mixed', 'Negative', 'Positive']
print(f"Predicted sentiment: {sentiment_labels[predicted_class[0]]}")
The model expects Arabic text input. The text should be preprocessed to remove unnecessary characters or diacritics for better results.
The model classifies the sentiment into three categories:
khaledsoudy/arabic-sentiment-bert-modelTFBertForSequenceClassificationYou can fine-tune this model further using your own dataset. Check out the source code and related notebooks on my GitHub for detailed steps and guidance.
This model is licensed under the MIT License.
This README is ready for use on your Hugging Face model page! It includes detailed usage instructions, links to your GitHub, and other relevant information.