# 🇲🇦 Darija Sentiment Analysis
A powerful and lightweight Moroccan Darija (Moroccan Arabic dialect) Sentiment Analysis model, built using **PEFT/LoRA** on top of the `SI2M-Lab/DarijaBERT` foundation model.
This project classifies text into three categories:
- 🔴 **Negative** (سلبية)
- ⚪ **Neutral** (Ů…Řايدة)
- 🟢 **Positive** (إيجابية)
## ✨ Features
- **High Accuracy**: Fine-tuned on over 56,000 Moroccan Darija examples (including Jumia reviews and curated datasets).
- **Efficient & Fast**: Utilizes Low-Rank Adaptation (LoRA), keeping the model footprint incredibly small (~6 MB adapter) while preserving the massive base model knowledge.
- **Interactive UI**: Comes with a clean, easy-to-use Web Interface built with Gradio.
- **Ready-to-use**: Fully configured for local inference on CPU or GPU.
## 🚀 Quick Start
### Prerequisites
Ensure you have Python 3.8+ installed, then install the required dependencies:
```bash
pip install -r requirements.txt
```
### Running the Web App
Launch the Gradio interface directly from your terminal:
```bash
python app.py
```
The app will open automatically in your browser at `
127.0.0.1`.
## đź§ Model Architecture
- **Base Model**: `SI2M-Lab/DarijaBERT`
- **Fine-Tuning Method**: PEFT / LoRA (Rank = 16, Alpha = 32)
- **Target Modules**: `query`, `key`, `value`, `classifier`, `pooler`
- **Dataset Size**: ~56,000 balanced sentences (Train: 44.8k, Val: 5.6k, Test: 5.6k)
- **Performance**: ~81% Accuracy across 3 classes
## đź“‚ Project Structure
```text
darija_sentiment_analysis/
├── app.py # Main Gradio application script
├── requirements.txt # Python dependencies
├── model_v5_final/ # Saved LoRA adapter and tokenizer weights
├── notebooks/ # Jupyter notebooks for data processing and training
└── README.md # Project documentation
```
## 🛠️ Usage Example
You can use the model directly via code without the UI:
```python
import torch
from transfo …