mxbai-rerank
mixedbread-ai's reranker family is built on DeBERTa-v3 — an architecture with disentangled attention that delivers strong cross-encoder precision. All three variants ship under Apache 2.0, so you can self-host freely. The xsmall model is compact enough to run in the browser, which is why it's one of the options in this site's live demo.
Model variants
| Model | Size | Context | Best for |
|---|---|---|---|
mxbai-rerank-xsmall-v1 | ~70 MB | 512 tokens | Browser / edge; lowest latency |
mxbai-rerank-base-v1 | ~278 MB | 512 tokens | Good balance of speed and quality |
mxbai-rerank-large-v1 | ~560 MB | 512 tokens | Highest precision; GPU recommended |
All three are DeBERTa-v3 cross-encoders trained on MS MARCO passage ranking. Start with mxbai-rerank-base-v1 for production use; switch to large if you have GPU headroom and need the extra precision. Use xsmall for browser or edge deployments where model size is the constraint.
Benchmarks
| Model | BEIR NDCG@10 (avg) | MS MARCO MRR@10 |
|---|---|---|
| mxbai-rerank-xsmall-v1 | ~55.5 | ~38.0 |
| mxbai-rerank-base-v1 | ~59.8 | ~40.6 |
| mxbai-rerank-large-v1 | ~62.1 | ~42.3 |
Scores are approximate averages across the 18 BEIR datasets. Check the mixedbread-ai HuggingFace model cards for per-dataset results.
Quick start
Self-hosted (sentence-transformers)
pip install sentence-transformers
from sentence_transformers import CrossEncoder
model = CrossEncoder("mixedbread-ai/mxbai-rerank-base-v1")
query = "How do I add reranking to my RAG pipeline?"
passages = [
"Rerankers score each query-passage pair with a cross-encoder.",
"BM25 is a classical keyword-based retrieval method.",
"London is the capital of the United Kingdom.",
"Two-stage retrieval: retrieve 50 candidates, rerank to top 5.",
]
scores = model.predict([(query, p) for p in passages])
ranked = sorted(zip(scores, passages), reverse=True)
for score, text in ranked:
print(f"{score:.4f} {text[:80]}")
In a RAG pipeline
from sentence_transformers import CrossEncoder
reranker = CrossEncoder("mixedbread-ai/mxbai-rerank-large-v1")
def rag_answer(query: str, vector_db, llm) -> str:
# Stage 1: retrieve wide
candidates = vector_db.search(query, top_k=50)
# Stage 2: rerank tight
scores = reranker.predict([(query, c) for c in candidates])
top5 = [c for _, c in sorted(zip(scores, candidates), reverse=True)[:5]]
# Stage 3: generate
return llm.complete(f"Context:\n" + "\n\n".join(top5) + f"\n\nQ: {query}")
Hosted API
mixedbread-ai offers a hosted rerank endpoint backed by the same model weights. Useful if you want to avoid running inference on your own infrastructure.
pip install mixedbread-ai
from mixedbread_ai import MixedbreadAI
mxbai = MixedbreadAI(api_key="YOUR_API_KEY")
result = mxbai.reranking(
model="mixedbread-ai/mxbai-rerank-large-v1",
query="How do I add reranking to my RAG pipeline?",
input=[
"Rerankers score each query-passage pair jointly.",
"BM25 is a keyword-based retrieval method.",
"London is the capital of the United Kingdom.",
"Two-stage retrieval: retrieve wide, rerank tight.",
],
top_k=3,
return_input=False,
)
for item in result.data:
print(f"{item.score:.4f} rank {item.index + 1}")
Browser use
The xsmall variant is compact enough to run in the browser via transformers.js — this is exactly what our demo uses:
// transformers.js (ES module)
import { AutoTokenizer, AutoModelForSequenceClassification }
from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3";
const tokenizer = await AutoTokenizer.from_pretrained(
"mixedbread-ai/mxbai-rerank-xsmall-v1", { dtype: "q8" }
);
const model = await AutoModelForSequenceClassification.from_pretrained(
"mixedbread-ai/mxbai-rerank-xsmall-v1", { dtype: "q8" }
);
const inputs = tokenizer(
[query, query],
{ text_pair: [doc1, doc2], padding: true, truncation: true }
);
const { logits } = await model(inputs);
const scores = logits.sigmoid().tolist();
With dtype: "q8" the quantized weights are roughly 35 MB — fast to download and cached in IndexedDB after the first run.
Pros and cons
Pros
- Apache 2.0 — fully open, commercial use allowed
- xsmall variant runs in-browser via transformers.js
- DeBERTa-v3 architecture: strong cross-encoder precision
- Large variant competitive with top commercial APIs
- Easy drop-in with sentence-transformers
- Hosted API option for managed inference
Cons
- Primarily English — limited multilingual support
- 512-token context is short for long documents
- Smaller community than bge or Cohere
- Large variant needs GPU for practical speed
mxbai-rerank-xsmall powers this demo
Select it in the model picker and see it score your passages live — no download required after first use.
Open the demo →