← All models

reranker (text-classification) Β· text Β· WASM Β· ~90 MB

mxbai-rerank β€” rank passages with a DeBERTa-v2 cross-encoder

This is mixedbread's reranker. Like every cross-encoder it reads a query and a passage together and outputs one relevance score β€” but its backbone is DeBERTa-v2 with disentangled attention, a different architecture from the BERT-family and XLM-RoBERTa rerankers already in this showcase. It's English-focused and tiny (~90 MB at q8). Give it a query and some candidates, watch it re-sort them, then look inside at the raw logit per pair and how decisively the top answer wins. Nothing leaves your device.

At a glance

Modelmixedbread-ai/mxbai-rerank-xsmall-v1 (ships its own transformers.js ONNX)
Task / pipelinetext-classification used as a cross-encoder reranker (num_labels = 1)
Inputa (query, passage) pair encoded together β†’ one relevance logit
ArchitectureDeBERTa-v2 xsmall (12 layers, hidden 384, disentangled attention) fine-tuned by mixedbread for passage reranking
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~90 MB, cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

Type a query and one candidate passage per line. The model scores each passage against the query and re-sorts them by relevance logit (higher = more relevant). The default set is full of near-misses β€” passages that share words with the query but don't actually answer it.

See inside β€” the reordering and how decisively the top answer wins

The one number the model emits per pair is a relevance logit β€” unbounded, higher is more relevant (we also show its sigmoid as a 0–100% probability). First, the before/after view: the candidates in their original (retrieval) order on the left, and the cross-encoder's reordering on the right β€” arrows mark what moved. Then the decision margin: the logit gap between adjacent ranks. A big #1β†’#2 gap means the model chose confidently; a small gap means the top answers are close (feed several to your LLM). Finally a naive shared-word ranking, to show where the cross-encoder disagrees with keywords.

Rerank some passages above to look inside.

Decision margin β€” logit gap between adjacent ranks

Cross-encoder vs. lexical overlap

Why it matters

Rerankers are the precision stage of modern search. A fast retriever (a keyword index or embeddings) casts a wide net and returns, say, the top 50 candidates; a cross-encoder then reads each candidate against the query and reorders them with far higher accuracy. mxbai-rerank is a strong, compact English reranker with a DeBERTa-v2 backbone β€” a different bet from the BERT/RoBERTa rerankers, and small enough (~90 MB) to run in a tab. The precise, expensive step happens on-device with nothing sent anywhere.

Use cases

Basics

Rank a handful of passages against a query by cross-encoder relevance.

Practical

Two-stage RAG: retrieve a shortlist, then rerank it for precision.

Wild

Adversarial hard negatives: distractors built to fool keyword and embedding search.

Multi-model

GTE embeddings retrieve, mxbai-rerank reorders β€” the classic retrieve-then-rerank.

Compare with the other cross-encoders: the multilingual BGE-reranker (XLM-RoBERTa), the MS MARCO MiniLM (BERT), and the Jina reranker (JinaBERT) β€” same idea, four different backbones.

How the API works

A cross-encoder scores query–passage pairs; we read the raw logit off the model directly:

import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers";

const model_id = "mixedbread-ai/mxbai-rerank-xsmall-v1";
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const model = await AutoModelForSequenceClassification.from_pretrained(model_id, { dtype: "q8" });

// Encode the query with each passage AS A PAIR β€” [CLS] query [SEP] passage [SEP]:
const inputs = tokenizer(
  passages.map(() => query),
  { text_pair: passages, padding: true, truncation: true },
);
const { logits } = await model(inputs); // one relevance logit per pair β€” higher = more relevant
// sort the passages by logits.data β€” that's your reranking

This page loads the model through the shared loader as a text-classification pipeline, then reuses pipe.model + pipe.tokenizer to read the raw logits (the pipeline would squash them through a sigmoid). All inference runs in a Web Worker so ranking never janks the page.

References