# π²π¦ 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 β¦