Arabic passage-retrieval embedding model (query → relevant passage), fine-tuned from
Qwen/Qwen3-Embedding-4B with
Matryoshka Representation Learning.
Evaluated with
MTEB on Arabic retrieval tasks
(nDCG@10 / MRR@10). Baselines are run under identical conditions.
1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("mabdulaziz499/bahith-arabic-retrieval-4b")
4
5# Queries and documents — the correct prompts are stored in the model and applied
6# automatically by encode_query / encode_document (no manual prefixing needed).
7queries = [
8 "ما هي عاصمة مصر؟",
9 "من كتب رواية موسم الهجرة إلى الشمال؟",
10]
11documents = [
12 "القاهرة هي عاصمة جمهورية مصر العربية وأكبر مدنها وأكثرها سكانًا.",
13 "موسم الهجرة إلى الشمال رواية للكاتب السوداني الطيب صالح صدرت عام 1966.",
14 "برج إيفل معلم شهير يقع في مدينة باريس عاصمة فرنسا.",
15]
16
17query_embeddings = model.encode_query(queries)
18document_embeddings = model.encode_document(documents)
19
20# Cosine similarity: rows = queries, columns = documents
21similarities = model.similarity(query_embeddings, document_embeddings)
22print(similarities)
1# Matryoshka: truncate embeddings to a smaller dimension for cheaper storage / faster
2# search. The output is re-normalized automatically, so cosine similarity still works.
3from sentence_transformers import SentenceTransformer
4
5model = SentenceTransformer("mabdulaziz499/bahith-arabic-retrieval-4b", truncate_dim=256) # any supported dim
6embeddings = model.encode_document(["نص عربي للفهرسة والاسترجاع."])
7print(embeddings.shape) # (1, 256)
Matryoshka lets you trade a little accuracy for much cheaper storage and faster search.
Pick the smallest dimension that meets your quality bar (see the Results table above).
Full training, evaluation, and publishing code:
github.com/m0d9/arabic-retrieval-embeddings
Released under
apache-2.0, matching the base model
Qwen/Qwen3-Embedding-4B.