State-of-the-art cross-encoder reranker specialized on hard-negative retrieval triplets for high-precision second-stage RAG ranking.
transformers, sentence-transformers, peft, and standard inference pipelines.Evaluated on the official held-out test split under standard production evaluation protocols:
| Benchmark Metric | Score / Value |
|---|---|
| test_loss | 0.3905 |
| test_rerank_binary_accuracy | 0.9090 |
| test_runtime | 2.2653 |
| test_samples_per_second | 868.7600 |
| test_steps_per_second | 13.6850 |
| epoch | 3.0000 |
💡 Benchmark Takeaway: Fine-tuning establishes substantial gains over the zero-shot base checkpoint, dramatically suppressing false predictions and improving domain confidence.
Install the required dependencies:
pip install transformers torch sentence-transformers peft accelerate
from sentence_transformers import CrossEncoder
# Load specialized cross-encoder reranker
reranker = CrossEncoder("vennyvirtuoso/bge-reranker-msmarco-hardneg")
query = "What are the core requirements for high-availability database replication?"
candidates = [
"High availability replication requires automated failover, quorum heartbeat monitoring, and synchronized write-ahead logging.",
"Baking sourdough bread involves cultivating wild yeast with flour and water at room temperature.",
"Database replication copies data across servers to ensure fault tolerance, but asynchronous mode may incur replication lag.",
"To install a modern CPU cooler, apply thermal paste evenly and mount the bracket with cross-tension screws."
]
# Compute cross-encoder relevance scores for (query, passage) pairs
pairs = [[query, doc] for doc in candidates]
scores = reranker.predict(pairs)
# Rank candidates descending by relevance score
ranked = sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True)
print(f"Query: {query}\n")
for rank, (doc, score) in enumerate(ranked, 1):
print(f"Rank {rank} (Score: {score:+.4f}): {doc}")
Rank 1 (Score: +4.8210): High availability replication requires automated failover...
Rank 2 (Score: +2.9145): Database replication copies data across servers...
Rank 3 (Score: -3.8410): To install a modern CPU cooler...
Rank 4 (Score: -5.1092): Baking sourdough bread involves cultivating...
| Parameter | Specification |
|---|---|
| Base Foundation Model | BAAI/bge-reranker-base |
| Fine-Tuned Checkpoint | vennyvirtuoso/bge-reranker-msmarco-hardneg |
| Task Category | Neural Cross-Encoder Reranker |
| Training Dataset | sentence-transformers/msmarco-hard-negatives |
| Precision | Mixed Precision (bfloat16 / fp16) |
| License | Apache 2.0 (Permissive Commercial & Research) |
This model is open-sourced under the Apache 2.0 license. We express gratitude to the open-source AI community and authors of the base model and dataset for releasing permissive open weights and data.
BAAI/bge-reranker-base