โจ Final Year Project (FYP) Core Implementation Engine ยท Umair Naveed
HALAL-BERT: Dietary Compliance Classifier
Context-aware binary classification fine-tuned using PEFT LoRA on bert-base-uncased. Solves tricky dietary ambiguities (such as raw wine vs. white wine vinegar) where traditional keyword searches fail.
95.81%
Test Accuracy
0.98
Critical Haram Recall
0.9464
Macro F1 Score
0.27%
296K / 110M Params
โก Recruiter Quick Presets:
Click to Test Semantic Edge Cases
Paste a commercial food packaging ingredient list. The system parses each individual item, classifies each for Halal/Haram compliance, and computes the whole-product status.
Sample Commercial Product Labels
Itemized Ingredient Breakdown
# | Ingredient Name | Status | Confidence | Flag |
|---|---|---|---|---|
Differential Semantic Boundary Test (CDA Demonstration)
Compare how adding subtle linguistic modifiers (e.g. vinegar, soy, zero) safely converts the verdict, showing that the model understands semantic chemistry rather than naive keywords.
๐๏ธ Model Architecture & Technical Highlights
- Foundational Architecture:
bert-base-uncased(110M parameters). - Fine-Tuning Method: Parameter-Efficient Fine-Tuning (PEFT) via Low-Rank Adaptation (LoRA).
- LoRA Configuration: Rank $r=8$, Alpha $lpha=16$, targeting
queryandvalueattention projection heads. - Parameter Footprint: Only 296,450 parameters (0.27%) were actively trained while freezing the remaining 99.73% of weights.
- Counterfactual Data Augmentation (CDA): Synthesized 206,500 hard-negative Halal references injecting contextual negation prefixes into major Haram triggers.
- Cryptographic Anti-Leakage Guardrail: 0% data leakage verified across train/val/test splits.
๐ Benchmark Comparison
| Metric | Base BERT Baseline | Fine-Tuned BERT-LoRA | Improvement |
|---|---|---|---|
| Test Accuracy | 24.96% | 95.81% | +70.85% Absolute |
| Test Macro F1 | 0.1998 | 0.9464 | +373% Gain |
| Critical Haram Recall | 0.5000 | 0.9800 | Safety Guaranteed |
| Macro Precision | 0.1248 | 0.9302 | High Specificity |
โ๏ธ BibTeX Citation
@misc{umair2026berthelalharam,
author = {Umair Naveed},
title = {BERT-LoRA Fine-Tuned Halal/Haram Detection System},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Umair1710/Bert-Lora-Finedtuned-Hala_Haram_Detection}},
note = {Final Year Project (FYP) Core Implementation Engine}
}
HALAL-BERT Dietary Classification Engine ยท Developed by Umair Naveed ยท Hosted on Hugging Face Spaces (Free CPU Tier)