reranker (text-classification) · text · WASM · ~33 MB
A cross-encoder reads a query and a passage together and outputs one relevance score — far more accurate than comparing two separate embeddings. Most cross-encoders are big. This one is tiny: 4 Transformer layers, ~33 MB quantized, built by Jina AI specifically to be fast enough to rerank on a phone or in a tab. Give it a query and some candidates, watch it re-sort them, and look at the real per-pair latency — the whole point is that precision no longer means a slow, server-side model. Nothing leaves your device.
| Model | jinaai/jina-reranker-v1-tiny-en |
|---|---|
| Task / pipeline | text-classification used as a cross-encoder reranker (num_labels = 1) |
| Input | a (query, passage) pair encoded together → one relevance logit |
| Architecture | JinaBERT, 4 layers (~33M params) — distilled/pruned for speed; English |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~33 MB, cached after first load — one of the smallest rerankers here |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Type a query and one candidate passage per line. The model scores each passage against the query and re-sorts by relevance logit (higher = more relevant). Watch the latency readout — a tiny model reranks a handful of passages in a blink.
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). The before/after view puts the candidates in their original order on the left and the cross-encoder's reordering on the right — arrows mark what moved. Then a second contrast ranks the same passages by naive shared-word overlap; where the columns disagree, the cross-encoder is using meaning, not keywords.
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. The catch has always been cost — a cross-encoder runs the full model on every (query, passage) pair, so teams push it to a server. A tiny reranker changes the economics: at ~33 MB and a few milliseconds per pair on a CPU, the precise step can run on the device, inside a private RAG loop, with no inference bill and no data leaving the browser.
Rank a handful of passages against a query by cross-encoder relevance.
Fast on-device RAG rerank — time a whole shortlist and watch the per-pair latency.
Hard negatives: distractors stuffed with the query's words that answer the wrong thing.
MiniLM embeddings retrieve, the tiny Jina reranker reorders — the classic two-stage pipeline.
Contrast with the larger BGE-reranker (multilingual, ~270 MB) and the MS MARCO MiniLM reranker: same cross-encoder idea, but this one trades reach for size and speed.
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 = "jinaai/jina-reranker-v1-tiny-en";
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 passages by logits.data — that's your reranking, and at ~33 MB it's fast enough on a CPU
// to run right inside the browser
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.