Multilingual AI customer-support chatbot (French, English, Arabic, Moroccan Darija) — NLP pipeline, RAG, human-in-the-loop dashboard, AI quotes & appointment booking. Deployed in production.
# Multilingual Chatbot 🇲🇦
**Multilingual AI customer-support chatbot with first-class Moroccan Darija support** — hybrid NLP pipeline, RAG, human-in-the-loop dashboard, AI-assisted quotes & appointment booking.
Built as a final-year engineering project (PFE) and deployed in production for a digital marketing agency in Marrakech (agency data anonymized in this repository).
---
## Why this project is interesting
Most chatbots handle French or English well. **Moroccan Darija** — written both in Arabic script (`فوقاش خدامين؟`) and in Latin "Arabizi" (`ch7al taman dyal site web?`) — is a low-resource language where off-the-shelf models fail. This project measures those failures honestly and engineers around them:
- Semantic embeddings scored only **37% Top-1** retrieval on Darija → a **lexical routing strategy** was designed for Darija queries, raising Top-1 by **+23 points** (measured on a 450-query benchmark).
- Every design decision (thresholds, score weights, hybrid strategies) was validated by **systematic sweeps** on independent test sets — and several "obvious improvements" (hybrid 0.5/0.5 scoring, Arabizi normalization) were **tested and rejected on evidence**.
## Pipeline
```mermaid
flowchart LR
A[User message] --> B[1. Language detection fastText + Darija rules]
B --> C[2. Intent classification SVM → XLM-R fallback]
C --> D[3. Confidence scoring & routing auto/review/escalate]
D --> E[4. RAG retrieval ChromaDB + lexical Darija routing]
E --> F[5. Response generation GPT-4o-mini, grounded on Top-5]
D -.->|low confidence| G[Human-in-the-loop dashboard]
```
## Measured results
| Stage | Metric | Score | Test set |
|---|---|---|---|
| Language detection (5 classes) | Accuracy | **92.3%** | 1,000 phrases |
| Intent classification (11 intents) | Accuracy | **90.5%** | 1,100 phrases |
| RAG retrieval | Top-5 accuracy | **90%** | 450 reformulations + 22 off-domain traps (0 leakage) |
| Darija lexical routing | Top-1 gain | **+23 pts** | same benchmark |
| Rou …