🧠 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 …