π§ Moroccan Arabic (Darija) text classifier β DarijaBERT fine-tuned with LoRA for 10-class classification. Built with FastAPI backend and React frontend.
# π§ DarijaBERT β Moroccan Arabic Text Classifier
A production-ready NLP pipeline that fine-tunes **DarijaBERT** with **LoRA adapters** to classify Moroccan Arabic (Darija) text into 10 categories, served through a **FastAPI** backend and a polished **React** frontend.
---
## π Table of Contents
- β¨ Overview
- π Project Structure
- ποΈ Architecture Overview
- π§ͺ Model Training
- π Results & Evaluation
- π Live Demo
- π οΈ Setup & Run
- π API Reference
- π Environment Variables
- π Possible Improvements
- π§° Tech Stack
- π License
---
## β¨ Overview
| | |
|---|---|
| **Task** | 10-class text classification |
| **Language** | Moroccan Arabic (Darija) |
| **Base model** | `SI2M-Lab/DarijaBERT` |
| **Fine-tuning** | LoRA (Low-Rank Adaptation) |
| **F1 Score** | **0.82** |
| **Avg. latency** | ~128ms |
| **Hosted model** | `HanaSoummar/DarijaBERT-finetuned_model_with_LORA` |
### π·οΈ Categories
| π° | π³ | ποΈ | π | π©Ί | β½ | π» | βοΈ | π° | π |
|---|---|---|---|---|---|---|---|---|---|
| ActualitΓ©s | Cuisine | Culture | Divertissement | SantΓ© | Sport | Technologie | Voyage | Γconomie | Γducation |
---
## π Project Structure
```
DarijaBert-Project/
βββ notebooks/
β βββ Finetuning.ipynb # LoRA fine-tuning notebook
βββ data/
β βββ dataset_darija2.csv
βββ backend/
β βββ main.py # FastAPI server
β βββ requirements.txt
β βββ .env.example
βββ frontend/
β βββ src/
β β βββ App.jsx
β β βββ index.css
β β βββ main.jsx
β βββ index.html
β βββ package.json
β βββ vite.config.js
β βββ .env.example
βββ docs/
β βββ screenshots/
βββ .gitignore
βββ README.md
```
---
## ποΈ Architecture Overview
| Layer | Stack |
|---|---|
| **Model** | DarijaBERT-base Β· LoRA adapters (`r=16`) Β· 10-class softmax head Β· π€Transformers |
| **Training** | Mixed precision (fp16) Β· Gradient accumulation Β· Early stopping Β· Weighted cross-entropy |
| **Backend** | FastAPI (async) Β· Torch JIT optimization Β· Batch inference Β· Healt β¦