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.
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)
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.
- Precision RAG rescue: Reorder top-10 retrieved chunks before handing context to an LLM.
- Cross-lingual EN↔ZH & multilingual matching: Score English queries against Chinese passages directly on XLM-RoBERTa-large.
- Policy & negation sensitivity: Catch "without", "prohibited", and threshold qualifiers that bag-of-words search misses.
Use-case ladder
Basics
128 → 512 SentencePiece truncation budget audit, logistic sigmoid curve, and cross-lingual paraphrase probe.
Practical
Cancellable 5-query bilingual RAG benchmark bench measuring live MRR@5, nDCG@5, and Top-1 Recall.
Wild
6-probe adversarial stress lab: BM25 stuffing, negation inversion, role swaps, EN→ZH zero-overlap, and tail-drop.
Multi-model
698.47 MB Retrieve-then-Rerank Studio: Stage 1 Multilingual E5-small → Stage 2 BGE-reranker-large waterfall.
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