Text Ranking
sentence-transformers
Safetensors
Arabic
English
new
cross-encoder
reranker
arabic
long-context
custom_code
text-embeddings-inference
Instructions to use ALJIACHI/Mizan-Rerank-V2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use ALJIACHI/Mizan-Rerank-V2 with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("ALJIACHI/Mizan-Rerank-V2", trust_remote_code=True) query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -18,32 +18,52 @@ inference: true
|
|
| 18 |
|
| 19 |
# Mizan-Rerank-v2
|
| 20 |
|
| 21 |
-
A
|
| 22 |
|
| 23 |

|
| 24 |

|
| 25 |

|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
## Overview
|
| 40 |
|
| 41 |
-
Mizan-Rerank-v2 is a cross-encoder reranking model based on [Alibaba-NLP/gte-multilingual-reranker-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-reranker-base),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
## Key Features
|
| 44 |
|
| 45 |
- **Long Document Support**: Handles up to 8192 tokens using RoPE position embeddings with NTK scaling
|
| 46 |
-
- **
|
| 47 |
- **Arabic Language Optimization**: Fine-tuned on 1.2M+ Arabic query-document pairs from diverse sources
|
| 48 |
|
| 49 |
## Performance Benchmarks
|
|
@@ -52,6 +72,8 @@ Mizan-Rerank-v2 is a cross-encoder reranking model based on [Alibaba-NLP/gte-mul
|
|
| 52 |
|
| 53 |
### Reranking Evaluation (ndcg@10)
|
| 54 |
|
|
|
|
|
|
|
| 55 |
| Model | Parameters | Reranking | Triplet | MIRACL (Long Docs) | WikiQA | MedQA |
|
| 56 |
|-------|-----------|-----------|---------|---------------------|--------|-------|
|
| 57 |
| **Mizan-Rerank-v2** | **305M** | **1.0000** | 0.9993 | **0.8091** | 0.8258 | **0.6775** |
|
|
@@ -89,6 +111,8 @@ Mizan-Rerank-v2 is a cross-encoder reranking model based on [Alibaba-NLP/gte-mul
|
|
| 89 |
- **Number of Output Labels:** 1
|
| 90 |
- **Language:** Arabic (ar), English (en)
|
| 91 |
- **License:** Apache 2.0
|
|
|
|
|
|
|
| 92 |
|
| 93 |
## Usage
|
| 94 |
|
|
@@ -164,6 +188,22 @@ for passage, score in reranked:
|
|
| 164 |
print(f"Score: {score:.4f} | {passage[:80]}...")
|
| 165 |
```
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
## Training Details
|
| 168 |
|
| 169 |
### Training Data
|
|
@@ -196,6 +236,8 @@ Trained on **1,199,634 query-document pairs** from diverse Arabic sources
|
|
| 196 |
- Long-document Arabic content analysis
|
| 197 |
- E-learning platforms with Arabic content
|
| 198 |
|
|
|
|
|
|
|
| 199 |
### Framework Versions
|
| 200 |
|
| 201 |
- Python: 3.10.14
|
|
@@ -218,6 +260,18 @@ Trained on **1,199,634 query-document pairs** from diverse Arabic sources
|
|
| 218 |
}
|
| 219 |
```
|
| 220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
```bibtex
|
| 222 |
@inproceedings{reimers-2019-sentence-bert,
|
| 223 |
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
|
|
|
| 18 |
|
| 19 |
# Mizan-Rerank-v2
|
| 20 |
|
| 21 |
+
A cross-encoder model for reranking Arabic long texts, fine-tuned from Alibaba-NLP/gte-multilingual-reranker-base.
|
| 22 |
|
| 23 |

|
| 24 |

|
| 25 |

|
| 26 |
+

|
| 27 |
+
[](https://huggingface.co/ALJIACHI/Mizan-Rerank-v3/)
|
| 28 |
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## Deprecated: use Mizan-Rerank-v3
|
| 32 |
+
|
| 33 |
+
> **This model is deprecated and no longer maintained. Use [Mizan-Rerank-v3](https://huggingface.co/ALJIACHI/Mizan-Rerank-v3/) instead.**
|
| 34 |
+
>
|
| 35 |
+
> v3 is a 306M-parameter cross-encoder, fine-tuned from the same [Alibaba-NLP/gte-multilingual-reranker-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-reranker-base) base as v2 but on 71k Arabic listwise groups whose hard negatives are adversarial traps: negated rulings, swapped entities, shifted numbers and dates, exceptions applied to the wrong case. It scores higher than v2 on every held-out benchmark we measure, and it runs about twice as fast as bge-reranker-v2-m3.
|
| 36 |
+
>
|
| 37 |
+
> v3 is trained from the base model rather than from v2, so it is a replacement rather than a continuation. v3 covers the use cases v2 was built for, so there is no reason to start a new project on v2. This card is kept online for reproducibility of existing work.
|
| 38 |
+
|
| 39 |
+
### v2 vs. v3 at a glance
|
| 40 |
|
| 41 |
+
| | Mizan-Rerank-v2 | Mizan-Rerank-v3 |
|
| 42 |
+
|---|---|---|
|
| 43 |
+
| Status | **deprecated** | **recommended** |
|
| 44 |
+
| Parameters | 305M | 306M |
|
| 45 |
+
| Base model | Alibaba-NLP/gte-multilingual-reranker-base | Alibaba-NLP/gte-multilingual-reranker-base |
|
| 46 |
+
| Trained from | the gte base | the gte base (not from v2) |
|
| 47 |
+
| Training data | 1,199,634 Arabic query–document pairs | 71,044 Arabic listwise groups with adversarial hard negatives |
|
| 48 |
+
| Held-out Arabic benchmarks | baseline | **higher on every set** |
|
| 49 |
+
| Best for | — | RAG, long-document retrieval, domain-specific Arabic search |
|
| 50 |
|
| 51 |
+
Migrating is a one-line change — see [Migrating to v3](#migrating-to-v3) below.
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
|
| 55 |
## Overview
|
| 56 |
|
| 57 |
+
Mizan-Rerank-v2 is a cross-encoder reranking model based on [Alibaba-NLP/gte-multilingual-reranker-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-reranker-base), fine-tuned for Arabic text reranking. It handles long documents (up to 8192 tokens) and was the state of the art in the Mizan family when it was released. It is now superseded by v3.
|
| 58 |
+
|
| 59 |
+
### Legacy demo
|
| 60 |
+
|
| 61 |
+
The v2 demo space is still online at [ALJIACHI/Mizan-Rerank-V2-Demo](https://huggingface.co/spaces/ALJIACHI/Mizan-Rerank-V2-Demo). It serves v2; use v3 for new work.
|
| 62 |
|
| 63 |
## Key Features
|
| 64 |
|
| 65 |
- **Long Document Support**: Handles up to 8192 tokens using RoPE position embeddings with NTK scaling
|
| 66 |
+
- **Compact for its quality**: 305M parameters, roughly half the size of BAAI/bge-reranker-v2-m3 (568M)
|
| 67 |
- **Arabic Language Optimization**: Fine-tuned on 1.2M+ Arabic query-document pairs from diverse sources
|
| 68 |
|
| 69 |
## Performance Benchmarks
|
|
|
|
| 72 |
|
| 73 |
### Reranking Evaluation (ndcg@10)
|
| 74 |
|
| 75 |
+
The table below comes from the evaluation run used for the v2 release, so all models are measured under identical conditions and the numbers are directly comparable. It predates v3.
|
| 76 |
+
|
| 77 |
| Model | Parameters | Reranking | Triplet | MIRACL (Long Docs) | WikiQA | MedQA |
|
| 78 |
|-------|-----------|-----------|---------|---------------------|--------|-------|
|
| 79 |
| **Mizan-Rerank-v2** | **305M** | **1.0000** | 0.9993 | **0.8091** | 0.8258 | **0.6775** |
|
|
|
|
| 111 |
- **Number of Output Labels:** 1
|
| 112 |
- **Language:** Arabic (ar), English (en)
|
| 113 |
- **License:** Apache 2.0
|
| 114 |
+
- **Status:** deprecated
|
| 115 |
+
- **Replacement:** [ALJIACHI/Mizan-Rerank-v3](https://huggingface.co/ALJIACHI/Mizan-Rerank-v3/)
|
| 116 |
|
| 117 |
## Usage
|
| 118 |
|
|
|
|
| 188 |
print(f"Score: {score:.4f} | {passage[:80]}...")
|
| 189 |
```
|
| 190 |
|
| 191 |
+
## Migrating to v3
|
| 192 |
+
|
| 193 |
+
The interface is identical; only the model ID changes. Both models need `trust_remote_code=True`:
|
| 194 |
+
|
| 195 |
+
```python
|
| 196 |
+
from sentence_transformers import CrossEncoder
|
| 197 |
+
|
| 198 |
+
# Before
|
| 199 |
+
model = CrossEncoder("ALJIACHI/Mizan-Rerank-v2", max_length=8192, trust_remote_code=True)
|
| 200 |
+
|
| 201 |
+
# After
|
| 202 |
+
model = CrossEncoder("ALJIACHI/Mizan-Rerank-v3", max_length=3072, trust_remote_code=True)
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
Scores are not calibrated across versions, so if your pipeline uses an absolute score threshold to filter candidates, re-tune that threshold after switching. Full details, benchmarks and a usage guide are on the [v3 model card](https://huggingface.co/ALJIACHI/Mizan-Rerank-v3/).
|
| 206 |
+
|
| 207 |
## Training Details
|
| 208 |
|
| 209 |
### Training Data
|
|
|
|
| 236 |
- Long-document Arabic content analysis
|
| 237 |
- E-learning platforms with Arabic content
|
| 238 |
|
| 239 |
+
For all of the above, use v3. This model is deprecated and is documented here only for reproducibility of existing work.
|
| 240 |
+
|
| 241 |
### Framework Versions
|
| 242 |
|
| 243 |
- Python: 3.10.14
|
|
|
|
| 260 |
}
|
| 261 |
```
|
| 262 |
|
| 263 |
+
For the recommended model:
|
| 264 |
+
|
| 265 |
+
```bibtex
|
| 266 |
+
@software{Mizan_Rerank_v3_2026,
|
| 267 |
+
author = {Ali Aljiachi},
|
| 268 |
+
title = {Mizan-Rerank-v3: Adversarially Trained Arabic Long-Context Reranker},
|
| 269 |
+
year = {2026},
|
| 270 |
+
publisher = {Hugging Face},
|
| 271 |
+
url = {https://huggingface.co/ALJIACHI/Mizan-Rerank-v3}
|
| 272 |
+
}
|
| 273 |
+
```
|
| 274 |
+
|
| 275 |
```bibtex
|
| 276 |
@inproceedings{reimers-2019-sentence-bert,
|
| 277 |
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|