Instructions to use sadiqoon/fiqh-embed-ar-fa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sadiqoon/fiqh-embed-ar-fa with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sadiqoon/fiqh-embed-ar-fa") sentences = [ "هذا شخص سعيد", "هذا كلب سعيد", "هذا شخص سعيد جدا", "اليوم هو يوم مشمس" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Fiqh-Embed AR/FA
Fiqh-Embed is a bilingual embedding model for semantic search over Islamic jurisprudence in the Ja'fari (Imami) tradition. It maps Arabic and Persian questions and passages into a shared 1024-dimensional space, so that a question asked in colloquial Arabic lands next to the ruling that answers it — whether that ruling is written in the Arabic of Taḥrīr al-Wasīla or the Persian of Tawḍīḥ al-Masāʾil.
The model was built by Sadiqoon Technologies from real retrieval traffic and a curated corpus of the standard reference works of the school. It continues BAAI/bge-m3 (568M parameters, 8,192-token context) and is a drop-in replacement for it: same dimensionality, same CLS pooling, no instruction prefixes.
نموذج تضمين ثنائيّ اللغة للبحث الدلاليّ في الفقه الإماميّ. يضع السؤال العربيّ — ولو بالعامّية — والنصّ الفقهيّ الذي يجيبه، عربيًّا كان أو فارسيًّا، في فضاءٍ واحد. مبنيّ على bge-m3 ويحلّ محلّه مباشرةً في أيّ منظومة استرجاع قائمة.
Highlights
- Domain-tuned retrieval. Trained on real questions people ask a fiqh assistant — short, dialectal, often imprecise — paired with the exact passages that answered them.
- Arabic ⇄ Persian. Persian source texts are retrievable from Arabic questions without translation; the two languages share the space by design.
- Drop-in for bge-m3. Identical interface and vector size; re-index and go. No query prefixes, no special pooling.
- Runs anywhere. Available as safetensors for Transformers / sentence-transformers and as GGUF for llama.cpp, Ollama and LM Studio.
Evaluation
Held-out set of 292 real questions across six categories, judged against pooled relevance labels (TREC-style, top-10 from five retrieval systems). nDCG@10:
| Category | n | bge-m3 | Fiqh-Embed |
|---|---|---|---|
| All | 292 | 0.446 | 0.502 |
| Colloquial / dialectal questions | 25 | 0.377 | 0.467 |
| Prohibition / negation rulings | 60 | 0.469 | 0.545 |
| Conceptual & applied questions | 110 | 0.450 | 0.520 |
| Terminology & definitions | 45 | 0.484 | 0.503 |
| Arabic question → Persian passage | 45 | 0.422 | 0.441 |
| Precise citation lookup | 7 | 0.336 | 0.339 |
Both models were evaluated in the same run, with the same tokenization and 384-token passage window.
Training
- Corpus: 40,183 passages from the reference works in Arabic and Persian — Ajwibat al-Istiftāʾāt, Taḥrīr al-Wasīla, al-Risāla al-Taʿlīmiyya, Risāla fī al-Ṣalāt wa-l-Ṣawm, al-Aḥkām al-Muntakhaba, Tawḍīḥ al-Masāʾil and others.
- Pairs: ~3,300 real user questions matched to their source passages by verbatim quotation and page reference, plus ~8,800 Arabic queries written for Persian passages to teach the cross-lingual mapping.
- Objective: contrastive (InfoNCE) with in-batch and mined hard negatives, Arabic and Persian mixed in every batch. Full fine-tuning of all weights.
Usage
sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("sadiqoon/fiqh-embed-ar-fa")
queries = ["هل يجب الخمس في الذهب الملبوس؟"]
passages = [
"لا يجب الخمس في ما لا يدخل في مسمّى التكسّب حتى لو مضى عليه سنة أو أكثر.",
"طلا و جواهراتی که زن برای زینت استفاده میکند، در صورتی که متناسب با شأن او باشد، خمس ندارد.",
"يستحب للمصلّي أن يأتي بالأذان والإقامة قبل الصلاة.",
]
q = model.encode(queries, normalize_embeddings=True)
p = model.encode(passages, normalize_embeddings=True)
print(q @ p.T)
Transformers
import torch
from transformers import AutoTokenizer, AutoModel
tok = AutoTokenizer.from_pretrained("sadiqoon/fiqh-embed-ar-fa")
model = AutoModel.from_pretrained("sadiqoon/fiqh-embed-ar-fa").eval()
def embed(texts):
t = tok(texts, padding=True, truncation=True, max_length=8192, return_tensors="pt")
with torch.no_grad():
h = model(**t).last_hidden_state[:, 0] # CLS pooling
return torch.nn.functional.normalize(h, dim=-1)
GGUF
Quantized builds for llama.cpp, Ollama and LM Studio are in sadiqoon/fiqh-embed-ar-fa-gguf.
Citation
@misc{sadiqoon2026fiqhembed,
title = {Fiqh-Embed AR/FA: Bilingual Embeddings for Imami Jurisprudence},
author = {Sadiqoon Technologies},
year = {2026},
url = {https://huggingface.co/sadiqoon/fiqh-embed-ar-fa}
}
License & Contact
MIT. Built and maintained by Sadiqoon Technologies Ltd, London. Questions and collaboration: info@sadiqoon.uk
- Downloads last month
- -