← All models

reranker (text-classification) · text · WASM · ~280 MB · non-commercial licence

Jina-reranker-v2 — rank passages by relevance, across 100+ languages and code

Jina AI's second-generation reranker. Where the v1 tiny reranker was a 4-layer English-only cross-encoder built for speed, v2-base-multilingual is a full XLM-RoBERTa cross-encoder trained across 100+ languages and, distinctively, on code and function-calling relevance. Instead of turning a query and a passage into separate vectors and comparing them, it reads both together and outputs one relevance score, so it ranks a Chinese, Spanish or code passage against an English query as easily as an English one. Give it a query and candidates and watch it re-sort them; then look inside at the raw logit per pair. Nothing leaves your device.

At a glance

Modeljinaai/jina-reranker-v2-base-multilingual (official ONNX)
Task / pipelinetext-classification used as a cross-encoder reranker (num_labels = 1)
Inputa (query, passage) pair encoded together → one relevance logit
ArchitectureXLM-RoBERTa cross-encoder (12-layer base) fine-tuned for reranking — v2 of the Jina reranker family
vs. v1 tinyv1 = 4-layer English-only (~33 MB), speed-first; v2 = full multilingual (100+ langs) + code / function-calling relevance (~280 MB q8)
Loading notethe ONNX config omits model_type, so a plain pipeline() errors; we inject model_type: "xlm-roberta" (the real backbone) and load AutoModelForSequenceClassification — no remote code, canonical weights only
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~280 MB, cached after first load
LicenseCC-BY-NC-4.0 — free for research / non-commercial use (this educational showcase); a commercial deployment needs a licence from Jina AI
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 mixes English, Chinese and Spanish so you can see cross-language ranking.

See inside — before vs after, and why it isn't word-matching

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 a second contrast ranks the same passages by naive shared-word overlap; where the columns disagree, the cross-encoder is using meaning, and it does so across languages — a word-overlap score can't match an English query to a Chinese or Spanish answer at all, but a multilingual cross-encoder can. Jina v2 extends the same trick to code, matching a natural-language query to the snippet that implements it.

Rerank some passages above to compare.

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. Jina-reranker-v2 pairs that precision with both the widest language reach and a genuinely unusual skill in the family — it was trained on code and function-calling too, so one model reranks a mixed-language corpus and a set of code snippets or tool signatures. At ~280 MB it runs in a tab, so 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 multilingual shortlist, then rerank with v2.

Wild

Rank code snippets against a plain-English request — the function-calling skill v2 was trained for.

Multi-model

Multilingual E5 embeddings retrieve, jina-reranker-v2 reorders — the classic retrieve-then-rerank.

Contrast with the first-generation jina-reranker-v1-tiny: same cross-encoder idea, but v2 adds 100+ languages and code/function-calling relevance at a larger size, and with the newer BGE-reranker-v2-m3 it rounds out the multilingual reranker options.

How the API works

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

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

const model_id = "jinaai/jina-reranker-v2-base-multilingual";
const tokenizer = await AutoTokenizer.from_pretrained(model_id);

// the ONNX config omits `model_type`, so inject the real backbone before loading:
const config = await AutoConfig.from_pretrained(model_id);
config.model_type = "xlm-roberta";
const model = await AutoModelForSequenceClassification.from_pretrained(model_id, { dtype: "q8", config });

// 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 (works even when query and passage are in
// different languages, or when the passage is code, because v2 was trained multilingual + on code)

All inference runs in a Web Worker so ranking never janks the page. The pipeline helper would squash the logits through a sigmoid, so this page reads model() directly to keep the raw logit.

References