DRAGOX7/JorSenti-LoRA

End-to-end MLOps pipeline and NLP engine analyzing Levantine/Jordanian Arabic sentiment using a custom PEFT/LoRA architecture (MARBERTv2).

Jupyter Notebook

0

14 commits

updated Apr 8, 2026

See the code

README

🍔 JorSenti-LoRA

Live Demo - HF Spaces Python PyTorch Streamlit Docker

Project Milestone: End-to-End MLOps & Research Phase
Developed by: The Debuggers (Jordan University of Science & Technology)


🚀 Live Web Application

The latest iteration of the model (JorSenti-LoRA) is containerized and currently hosted live on Hugging Face Spaces. 👉 Click here to test the live diagnostic engine


📋 Overview

This project is an end-to-end Machine Learning Operations (MLOps) pipeline and specialized sentiment diagnostic engine. Standard NLP models fundamentally fail when processing local slang, sarcasm, and "Neutral" sentiment bias.

We built this pipeline to handle the extreme linguistic complexities of the Levantine/Jordanian street dialect. It proves that targeted Domain Adaptation can drastically outperform baseline foundational models on hyper-local retail and food delivery (Talabat) data.

🧠 The Evolution & Engineering Pipeline

This project evolved from a baseline neural network into a highly optimized, context-aware engine.

Phase 1: Data Engineering & Baseline (v1)

  1. Data Collection: Built a custom Python scraper to extract 30,000+ live customer reviews and ratings directly from regional Talabat restaurant pages to capture real-world slang, misspellings, and emojis.
  2. Baseline Deep Learning: Initially fine-tuned aubmindlab/bert-base-arabertv02-twitter to establish a performance baseline.
  3. Experiment Tracking: Utilized MLflow to log training loops, hyperparameter tuning, and evaluation metrics.

Phase 2: JorSenti-LoRA Architecture (v2)

  1. The "Scalpel" Strategy (Weighted Loss): Standard datasets for food delivery are heavily skewed toward Positive reviews. To prevent the model from ignoring the Neutral class, we engineered a custom Weighted Cross-Entropy Loss function (Penalty Ratios: [Negative: 1.2, Neutral: 3.0, Positive: 0.8]). This forces gradient descent to prioritize the nuanced features of the minority Neutral class.
  2. PEFT / LoRA Efficiency: Instead of full fine-tuning, we utilized Low-Rank Adaptation (LoRA) on the UBC-NLP/MARBERTv2 foundational base. Only ~1% of the total parameters were trained, allowing for seamless local training on a consumer-grade NVIDIA RTX 4050 GPU.
  3. Context-Aware Augmentation: We identified an attention mechanism failure regarding temperature-sensitive items (the "Ice Cream vs. Pizza" bug). Baseline models flagged the word "بارد" (Cold) as universally Negative. We injected 500+ targeted synthetic rows to retrain the model's semantic routing.

🚀 Performance Metrics

MetricBaseline (v1)JorSenti-LoRA (v2)
Accuracy86.2%94.35%
F1-Score84.1%93.87%
Neutral Recall22.0%78.5%

📸 Live Demonstrations & Edge Case Analysis

To prove the efficacy of our engineering, we subjected the model to edge cases that traditionally break standard Arabic AI models.

Case Study 1: The "Reverse Meaning" Jordanian Slang

In Jordanian street slang, words that literally translate to violence, destruction, or negativity are actually used as high-tier compliments. Standard translation and base NLP models grade these as strictly Negative.

  • The Test: يا زلمة الشاورما سفاحة، يسعد دين المطعم (Literal: "The shawarma is a serial killer...")
  • The Test: البرجر قطاعة، اشي فاخر على الآخر (Literal: "The burger is a cutting machine...")
  • The Result: JorSenti-LoRA successfully maps the Ammani semantic context, scoring all of them with High Positive Confidence.

Reverse Meaning Slang 1

image

Reverse Meaning Slang 2

Screenshot 2026-04-08 174856

Case Study 2: The "Cold Context" Validation

Proof that our targeted data augmentation successfully rewired the model's understanding of temperature modifiers.

  • Negative Context: البطاطا باردة ومجلدة مش راضية تتاكل (Cold and frozen fries) ➡️ Negative 🔴
  • Positive Context: عصير برتقال بارد يسرح عالقلب (Cold orange juice) ➡️ Positive 🟢
  • Positive Context: البوظة وصلت باردة وبتجنن (Cold ice cream) ➡️ Positive 🟢

Cold Fries

image

Cold Juice

image

Cold Ice Cream

Screenshot 2026-04-08 173218

Case Study 3: Rescuing the "Jordanian Shrug" (Neutral Class)

Proving the success of our Scalpel Weighted Loss function. The model accurately identifies hard-to-impress, middle-ground, and purely factual reviews instead of artificially inflating its score by guessing Positive or Negative.

  • The Test: التوصيل نص نص بس الاكل زاكي (The delivery is fine but the food was delicious).
  • The Test: الاكل منيح بس السعر غالي شوي وما بشبع (Food is good but expensive and not filling).
  • The Result: Correctly identified as Neutral across the board, proving the gradient penalty worked.

Neutral Example 1

Screenshot 2026-04-08 174447

Neutral Example 2

Screenshot 2026-04-08 174344

💻 How to Run Locally

You can launch the live comparison dashboard on your local machine using either Docker or a standard Python environment. Ensure the talabat_augmented_scalpel weights folder is present in your active directory.

# 1. Clone the repository
git clone [https://github.com/YOUR-USERNAME/talabat-sentiment-analysis.git](https://github.com/YOUR-USERNAME/talabat-sentiment-analysis.git)
cd talabat-sentiment-analysis

# 2. Create and activate a fresh environment
conda create -n torch_env python=3.10
conda activate torch_env

# 3. Install dependencies & Launch
pip install -r requirements.txt
python -m streamlit run app.py

Author

Abdullah AlJafari — AI Student at JUST, Jordan AI & ML Engineer | Computer Vision | NLP | MLOps

GitHub LinkedIn


License

MIT License — see LICENSE for details.

DRAGOX7/JorSenti-LoRA

End-to-end MLOps pipeline and NLP engine analyzing Levantine/Jordanian Arabic sentiment using a custom PEFT/LoRA architecture (MARBERTv2).

Jupyter Notebook

0

14 commits

updated Apr 8, 2026

See the code

README

🍔 JorSenti-LoRA

Live Demo - HF Spaces Python PyTorch Streamlit Docker

Project Milestone: End-to-End MLOps & Research Phase
Developed by: The Debuggers (Jordan University of Science & Technology)


🚀 Live Web Application

The latest iteration of the model (JorSenti-LoRA) is containerized and currently hosted live on Hugging Face Spaces. 👉 Click here to test the live diagnostic engine


📋 Overview

This project is an end-to-end Machine Learning Operations (MLOps) pipeline and specialized sentiment diagnostic engine. Standard NLP models fundamentally fail when processing local slang, sarcasm, and "Neutral" sentiment bias.

We built this pipeline to handle the extreme linguistic complexities of the Levantine/Jordanian street dialect. It proves that targeted Domain Adaptation can drastically outperform baseline foundational models on hyper-local retail and food delivery (Talabat) data.

🧠 The Evolution & Engineering Pipeline

This project evolved from a baseline neural network into a highly optimized, context-aware engine.

Phase 1: Data Engineering & Baseline (v1)

  1. Data Collection: Built a custom Python scraper to extract 30,000+ live customer reviews and ratings directly from regional Talabat restaurant pages to capture real-world slang, misspellings, and emojis.
  2. Baseline Deep Learning: Initially fine-tuned aubmindlab/bert-base-arabertv02-twitter to establish a performance baseline.
  3. Experiment Tracking: Utilized MLflow to log training loops, hyperparameter tuning, and evaluation metrics.

Phase 2: JorSenti-LoRA Architecture (v2)

  1. The "Scalpel" Strategy (Weighted Loss): Standard datasets for food delivery are heavily skewed toward Positive reviews. To prevent the model from ignoring the Neutral class, we engineered a custom Weighted Cross-Entropy Loss function (Penalty Ratios: [Negative: 1.2, Neutral: 3.0, Positive: 0.8]). This forces gradient descent to prioritize the nuanced features of the minority Neutral class.
  2. PEFT / LoRA Efficiency: Instead of full fine-tuning, we utilized Low-Rank Adaptation (LoRA) on the UBC-NLP/MARBERTv2 foundational base. Only ~1% of the total parameters were trained, allowing for seamless local training on a consumer-grade NVIDIA RTX 4050 GPU.
  3. Context-Aware Augmentation: We identified an attention mechanism failure regarding temperature-sensitive items (the "Ice Cream vs. Pizza" bug). Baseline models flagged the word "بارد" (Cold) as universally Negative. We injected 500+ targeted synthetic rows to retrain the model's semantic routing.

🚀 Performance Metrics

MetricBaseline (v1)JorSenti-LoRA (v2)
Accuracy86.2%94.35%
F1-Score84.1%93.87%
Neutral Recall22.0%78.5%

📸 Live Demonstrations & Edge Case Analysis

To prove the efficacy of our engineering, we subjected the model to edge cases that traditionally break standard Arabic AI models.

Case Study 1: The "Reverse Meaning" Jordanian Slang

In Jordanian street slang, words that literally translate to violence, destruction, or negativity are actually used as high-tier compliments. Standard translation and base NLP models grade these as strictly Negative.

  • The Test: يا زلمة الشاورما سفاحة، يسعد دين المطعم (Literal: "The shawarma is a serial killer...")
  • The Test: البرجر قطاعة، اشي فاخر على الآخر (Literal: "The burger is a cutting machine...")
  • The Result: JorSenti-LoRA successfully maps the Ammani semantic context, scoring all of them with High Positive Confidence.

Reverse Meaning Slang 1

image

Reverse Meaning Slang 2

Screenshot 2026-04-08 174856

Case Study 2: The "Cold Context" Validation

Proof that our targeted data augmentation successfully rewired the model's understanding of temperature modifiers.

  • Negative Context: البطاطا باردة ومجلدة مش راضية تتاكل (Cold and frozen fries) ➡️ Negative 🔴
  • Positive Context: عصير برتقال بارد يسرح عالقلب (Cold orange juice) ➡️ Positive 🟢
  • Positive Context: البوظة وصلت باردة وبتجنن (Cold ice cream) ➡️ Positive 🟢

Cold Fries

image

Cold Juice

image

Cold Ice Cream

Screenshot 2026-04-08 173218

Case Study 3: Rescuing the "Jordanian Shrug" (Neutral Class)

Proving the success of our Scalpel Weighted Loss function. The model accurately identifies hard-to-impress, middle-ground, and purely factual reviews instead of artificially inflating its score by guessing Positive or Negative.

  • The Test: التوصيل نص نص بس الاكل زاكي (The delivery is fine but the food was delicious).
  • The Test: الاكل منيح بس السعر غالي شوي وما بشبع (Food is good but expensive and not filling).
  • The Result: Correctly identified as Neutral across the board, proving the gradient penalty worked.

Neutral Example 1

Screenshot 2026-04-08 174447

Neutral Example 2

Screenshot 2026-04-08 174344

💻 How to Run Locally

You can launch the live comparison dashboard on your local machine using either Docker or a standard Python environment. Ensure the talabat_augmented_scalpel weights folder is present in your active directory.

# 1. Clone the repository
git clone [https://github.com/YOUR-USERNAME/talabat-sentiment-analysis.git](https://github.com/YOUR-USERNAME/talabat-sentiment-analysis.git)
cd talabat-sentiment-analysis

# 2. Create and activate a fresh environment
conda create -n torch_env python=3.10
conda activate torch_env

# 3. Install dependencies & Launch
pip install -r requirements.txt
python -m streamlit run app.py

Author

Abdullah AlJafari — AI Student at JUST, Jordan AI & ML Engineer | Computer Vision | NLP | MLOps

GitHub LinkedIn


License

MIT License — see LICENSE for details.