---
language: ar
tags:
- sentiment-analysis
- darija
- arabic
license: apache-2.0
datasets:
- custom
metrics:
- accuracy
- precision
- recall
- f1
---
# Sentiment Analysis for Darija (Arabic Dialect)
This repository hosts a **Sentiment Analysis model for Darija** (Moroccan Arabic dialect), built using **BERT**. The model is fine-tuned to classify text into two categories: **positive** and **negative** sentiment. It is designed to facilitate sentiment analysis in applications involving Darija text data, such as social media analysis, customer feedback, or market research.
---
## Model Details
- **Base Model**: SI2M-Lab/DarijaBERT
- **Task**: Sentiment Classification (Binary)
- **Architecture**: BERT with a custom classification head and dropout regularization (0.3 dropout rate).
- **Fine-Tuning Data**: Dataset of labeled Darija text samples (positive and negative).
- **Max Sequence Length**: 128 tokens
---
## How to Use
### Load the Model and Tokenizer
To use this model for sentiment analysis, you can load it using the Transformers library:
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("BenhamdaneNawfal/sentiment-analysis-darija")
model = AutoModelForSequenceClassification.from_pretrained("BenhamdaneNawfal/sentiment-analysis-darija")
# Example text
test_text = "هذا المنتج رائع جدا"
# Tokenize the text
inputs = tokenizer(test_text, return_tensors="pt", truncation=True, padding=True, max_length=128)
# Get model predictions
outputs = model(**inputs)
logits = outputs.logits
predicted_class = logits.argmax().item()
print(f"Predicted class: {predicted_class}")
```
### Output Classes
- **0**: Negative
- **1**: Positive
---
## Fine-Tuning Process
The model was fine-tuned using the following:
- **Dataset**: A dataset of Darija text labeled for sentiment.
- **Loss Function**: …