This project focuses on fine-tuning DarijaBERT for Moroccan Darija text classification using LoRA (Low-Rank Adaptation). The workflow includes data preprocessing, tokenization, model training, evaluation, and performance analysis using Hugging Face Transformers and PyTorch.
# π Fine-Tuning DarijaBERT for Moroccan Darija Text Classification
### π§ Parameter-Efficient NLP Fine-Tuning using LoRA & Hugging Face Transformers
---
# π Overview
This project focuses on fine-tuning the **SI2M-Lab/DarijaBERT** model for **Moroccan Darija text classification** using **LoRA (Low-Rank Adaptation)**.
The workflow demonstrates a complete modern NLP pipeline including:
β
Data preprocessing
β
Tokenization
β
LoRA fine-tuning
β
Model evaluation
β
Metrics visualization
β
Confusion matrix analysis
The objective is to build an efficient NLP model capable of understanding and classifying Moroccan Darija text.
---
# π§° Tech Stack
| Category | Technologies |
|---|---|
| Programming | Python |
| Deep Learning | PyTorch |
| NLP | Hugging Face Transformers |
| Fine-Tuning | LoRA / PEFT |
| Data Processing | Pandas, NumPy |
| Evaluation | Scikit-learn |
| Visualization | Matplotlib |
| Environment | Jupyter Notebook |
---
# π Project Structure
```bash
darijabert-lora-finetuning/
β
βββ data/
β βββ dataset_darija2.csv
β
βββ notebooks/
β βββ darijabert_finetuning.ipynb
β
βββ results/
β βββ confusion_matrix.png
β βββ training_metrics.png
β
βββ README.md
βββ requirements.txt
βββ .gitignore
```
---
# βοΈ Workflow
```text
Dataset β Preprocessing β Tokenization β DarijaBERT β LoRA Fine-Tuning β Evaluation β Visualization
```
---
# π Training Results
| Metric | Score |
|---|---|
| π― Accuracy | 79.67% |
| π§ F1-Score | 78.91% |
| π Precision | 80.28% |
| π Recall | 79.67% |
---
# π Results Visualization
## π₯ Training Metrics
---
## π§© Confusion Matrix
---
# π Installation
Clone the repository:
```bash
git clone
github.com
cd darijabert-lora-finetuning
```
Install dependencies:
```bash
pip install -r requirements.txt
```
---
# βΆοΈ Run the Project
Launch Jupyter Notebook:
```bash
jupyter notebook
```
Open:
```bash
notebooks/darijabert_finetuning.ipynb
```
---
# β¦