Fiqh-Classifier AR

Fiqh-Classifier reads a question as people actually write it — formal, dialectal, or mid-conversation — and tells you two things at once: which chapter of jurisprudence it belongs to, and whether it is too vague to answer without a follow-up. It is the routing layer in front of a fiqh assistant: pick the right index, the right prompt, the right specialist, before any retrieval happens.

Built by Sadiqoon Technologies on intfloat/multilingual-e5-base (278M parameters) with two lightweight heads over mean-pooled embeddings. A single forward pass, ~10 ms on GPU.

مصنّف يقرأ السؤال الفقهيّ كما يكتبه الناس — فصيحًا كان أو دارجًا أو مبتورًا — فيحدّد بابه من ثمانية عشر بابًا، وهل يحتاج إلى استيضاح قبل الجواب. طبقة توجيه تسبق الاسترجاع.

Labels

Chapter (18): طهارة · صلاة · صوم · خمس · زكاة · حج وعمرة · معاملات ومال · نكاح وأسرة · طلاق · نظر وحجاب ولباس · أطعمة وأشربة · نذر ويمين وكفارات · وقف ووصية وإرث · حدود وقصاص وديات · عقائد وأخلاق · جهاد وسياسة وحكومة · طب وحياة معاصرة · متفرقات

Needs clarification: boolean — the question is a fragment, a bare greeting, or lacks the detail a jurist would ask for.

Evaluation

900 held-out questions, labelled by chapter and clarification need:

Output Metric Score
Chapter (18-way) accuracy 0.743
Chapter (18-way) macro-F1 0.661
Needs clarification F1 (positive class, 1.2% prevalence) 0.267

The chapter head is the workhorse; the clarification head is a conservative signal best combined with your own length or context heuristics.

Training

~8,900 real questions in Arabic — formal and dialectal — each labelled with its chapter. Multi-task fine-tuning of the full encoder with class-balanced cross-entropy for the chapter head, four epochs.

Usage

# pip install transformers huggingface_hub torch
from huggingface_hub import hf_hub_download
import importlib.util
spec = importlib.util.spec_from_file_location("fc", hf_hub_download("sadiqoon/fiqh-classifier-ar", "fiqh_classifier.py"))
fc = importlib.util.module_from_spec(spec); spec.loader.exec_module(fc)

clf = fc.FiqhClassifier()
clf("هل يجب الخمس في الذهب الملبوس؟")
# {'topic': 'خمس', 'topic_confidence': 0.99, 'needs_clarification': False}

clf(["شو حكم الصلاة بالجراب اذا في ثقب صغير", "اجرت بيتي لواحد وما دفع الايجار شهرين شو بعمل", "السلام عليكم"])
# [{'topic': 'صلاة', 'topic_confidence': 0.88, 'needs_clarification': False},
#  {'topic': 'معاملات ومال', 'topic_confidence': 0.92, 'needs_clarification': False},
#  {'topic': 'متفرقات', 'topic_confidence': 0.80, 'needs_clarification': True}]

The repository ships the encoder in the standard Transformers layout plus heads.pt / heads_config.json; fiqh_classifier.py is a 30-line wrapper you can copy into your own code.

Citation

@misc{sadiqoon2026fiqhclassifier,
  title  = {Fiqh-Classifier AR: Chapter and Clarity Routing for Jurisprudential Questions},
  author = {Sadiqoon Technologies},
  year   = {2026},
  url    = {https://huggingface.co/sadiqoon/fiqh-classifier-ar}
}

License & Contact

MIT. Built and maintained by Sadiqoon Technologies Ltd, London. Questions and collaboration: info@sadiqoon.uk

Downloads last month
-
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for sadiqoon/fiqh-classifier-ar

Finetuned
(160)
this model