You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Badr Embedding v0

Badr Embedding v0 is an Arabic sentence-transformer model specialized for answer-bearing retrieval in Islamic jurisprudence (fiqh). It is fine-tuned from mohamed2811/Muffakir_Embedding to retrieve passages that contain the ruling or information required by a fiqh question, rather than passages that are only topically similar.

The model was developed as part of the research presented in:

What Makes a Good Fiqh Retriever? Answer Retrieval for Arabic Islamic Jurisprudence
Somaya Eltanbouly, Heba Sbahi, Samer Rashwani, Abdessalam Bouchekif, Mutaz al-Khatib, Shahd Gaben, and Mohammed Ghaly.
arXiv:2608.20246

Model repository: somayaeltanbouly/Badr_embedding_v0

Model Details

Property Value
Architecture Sentence Transformer / bi-encoder
Base model mohamed2811/Muffakir_Embedding
Language Arabic
Domain Islamic jurisprudence (fiqh)
Embedding dimension 768
Maximum sequence length 512 tokens
Similarity function Cosine similarity
Training objective MatryoshkaLoss + MultipleNegativesRankingLoss
Matryoshka dimensions 768, 512, 256, 128, 64

Intended Use

The model is designed for Arabic semantic retrieval, particularly:

  • answer-bearing passage retrieval for fiqh questions;
  • dense retrieval in retrieval-augmented generation (RAG) systems;
  • semantic search over Arabic Islamic jurisprudence collections;
  • retrieval experiments involving domain-specific Arabic questions and passages.

This is a retrieval model, not a standalone system for generating or validating religious rulings. Retrieved passages should be interpreted in their source context.

Usage

Install Sentence Transformers:

pip install -U sentence-transformers

Load the model and retrieve the most relevant passage:

from sentence_transformers import SentenceTransformer
import torch

model = SentenceTransformer("somayaeltanbouly/Badr_embedding_v0")

query = "ما الحكم المعتبر في جواز قصر الصلاة عند الحنابلة؟"

passages = [
    "المعتبر نية المسافة لا حقيقتها، فلو رجع قبل استكمالها فلا إعادة عليه...",
    "يجوز للمصلي قطع الصلاة لإنقاذ غريق على الصحيح من المذهب...",
    "إذا نكر السلام في التشهد لم يجزه على الصحيح من المذهب..."
]

query_embedding = model.encode(
    [query],
    convert_to_tensor=True,
    normalize_embeddings=True
)

passage_embeddings = model.encode(
    passages,
    convert_to_tensor=True,
    normalize_embeddings=True
)

scores = torch.matmul(query_embedding, passage_embeddings.T)[0]
best_idx = int(torch.argmax(scores))

print("Best passage:", passages[best_idx])
print("Score:", float(scores[best_idx]))

Matryoshka Embeddings

The model was trained with Matryoshka Representation Learning at dimensions 768, 512, 256, 128, and 64. Embeddings can therefore be truncated when lower-dimensional representations are useful for storage or retrieval efficiency.

For example:

embedding = model.encode(
    ["ما حكم المسح على الخفين؟"],
    normalize_embeddings=True
)

embedding_256 = embedding[:, :256]

When comparing truncated embeddings, normalize them again after truncation before computing cosine similarity.

Training

The model was fine-tuned using triplets consisting of:

  • anchor: an Arabic fiqh question;
  • positive: a passage containing the answer;
  • negative: a non-answer-bearing passage.

Dataset

Split Samples
Training 18,354
Evaluation 965

Training Configuration

Parameter Value
Epochs 3
Batch size 128
Learning rate 1e-5
Warmup steps 42
Precision BF16
Optimizer AdamW
Loss MatryoshkaLoss over MultipleNegativesRankingLoss

Evaluation

The Sentence Transformers triplet evaluation included with this checkpoint reports:

Metric Score
Cosine Accuracy 0.9731

This score measures triplet discrimination on the model's fiqh-eval evaluation set. For retrieval evaluation and comparisons with lexical, dense, hybrid, fine-tuned, and madhhab-aware retrieval strategies, see the associated paper.

Limitations

The model is specialized for Arabic fiqh retrieval and may not generalize equally well to unrelated domains or other languages. Retrieval quality may also vary with question formulation, passage length, terminology, source style, and the availability of answer-bearing passages in the indexed corpus.

The model returns semantic similarity scores; these scores should not be treated as verification that a retrieved passage is jurisprudentially correct or sufficient on its own.

Associated Paper

What Makes a Good Fiqh Retriever? Answer Retrieval for Arabic Islamic Jurisprudence

The paper studies answer-bearing retrieval for Arabic fiqh and evaluates dense, lexical, hybrid, fine-tuned, and madhhab-aware retrieval strategies.

If you use this model in research, please cite the paper:

@misc{eltanbouly2026fiqhretriever,
  title        = {What Makes a Good Fiqh Retriever? Answer Retrieval for Arabic Islamic Jurisprudence},
  author       = {Somaya Eltanbouly and Heba Sbahi and Samer Rashwani and Abdessalam Bouchekif and Mutaz al-Khatib and Shahd Gaben and Mohammed Ghaly},
  year         = {2026},
  eprint       = {2608.20246},
  archivePrefix = {arXiv},
  primaryClass = {cs.IR},
  url          = {https://arxiv.org/abs/2608.20246}
}

Framework Versions

The released checkpoint was trained with:

  • Python 3.10.20
  • Sentence Transformers 5.3.0
  • Transformers 5.3.0
  • PyTorch 2.9.0+cu128
  • Accelerate 1.13.0
  • Datasets 5.0.0
  • Tokenizers 0.22.2
Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for somayaeltanbouly/Badr_embedding_v0

Collection including somayaeltanbouly/Badr_embedding_v0

Paper for somayaeltanbouly/Badr_embedding_v0

Evaluation results