text-ranking (text-classification) · text · WASM · 580.04 MB q8 · MIT

BGE-reranker-large — 560M Cross-Encoder Precision Reranker

BAAI/bge-reranker-large is a 24-layer, 560M-parameter cross-encoder built on XLM-RoBERTa-large (hidden_size: 1024, 16 heads, 250,002 SentencePiece tokens). Unlike bi-encoders that compress query and passage separately, it reads every [<s> query </s></s> passage </s>] pair through shared self-attention to emit a single continuous relevance logit — delivering state-of-the-art English, Chinese, and cross-lingual reranking right inside your browser tab.

At a glance

Upstream → Loaded BAAI/bge-reranker-large → Xenova/bge-reranker-large
Task / pipeline text-classification cross-encoder reranker (id2label: {"0": "LABEL_0"}, continuous logit + sigmoid)
Architecture XLMRobertaForSequenceClassification · 24 layers · 16 heads · 1024 hidden · 514 max pos (512 tokens) · 250,002 vocab
Artifacts & size onnx/model_quantized.onnx (562.94 MB) + tokenizer.json (17.10 MB) + configs = 580.04 MB (q8)
Backend & runtime CPU WebAssembly (wasm) via shared ../../lib/webai.js (@huggingface/transformers@3.7.5)
License & Web APIs MIT · WebAssembly, dedicated module Web Worker, Cache Storage (Baseline widely available)

Run it — Live Cross-Encoder Reranking

Choose a bilingual EN/ZH or negation preset, paste/drop a .txt, .md, .csv, or .json corpus, or edit the query and candidate lines directly. Inference runs off the main thread in a strict-FIFO Web Worker.

Top Relevance Verdict: Initialise the model above to score query–passage pairs.
Top-1 Logit–
Margin vs #2–
Sigmoid σ(z₁)–
Latency / Pair–
Script / Head–
NaN Check–

Ranked passages with raw logits, sigmoid σ(z), softmax shares, and lexical overlap appear here.

See inside — Raw Logit Spectrum, Reordering & SentencePiece Tokens

Because bge-reranker-large outputs an unbounded scalar logit per pair (not normalized across candidates), positive vs negative margins around z = 0 reveal absolute confidence while before/after columns and 250k-vocab SentencePiece chips expose joint pair encoding and truncation.

Joint SentencePiece Tokens (Top-1 Pair)

Run reranking above to inspect the joint SentencePiece pair tokens.

Why it matters

Dense embeddings are fast for indexing millions of documents, but squeezing an entire paragraph into one vector loses fine-grained negation, numeric qualifiers, and cross-clause constraints. BGE-reranker-large brings a 24-layer cross-encoder to the browser so the precision stage of RAG, enterprise search, and bilingual EN/ZH helpdesks runs locally with zero data egress.

Use-case ladder

How the API works & Show the code

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

const modelId = "Xenova/bge-reranker-large";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId, { dtype: "q8" });

const inputs = tokenizer(
  passages.map(() => query),
  { text_pair: passages, padding: true, truncation: true, max_length: 512 },
);
const { logits } = await model(inputs); // shape [N, 1] continuous relevance logits
Show the code · worker.js — rerank()
Show the code · bge-reranker-large.js — BgeRerankerLargeClient
Show the code · bge-reranker-large-core.mjs — finalizeRankedRows()

References