At a glance
| Upstream model | intfloat/e5-large-v2 |
|---|---|
| Browser ONNX build |
Xenova/e5-large-v2
· onnx/model_quantized.onnx
|
| Task / pipeline |
sentence-similarity via pipeline("feature-extraction", …, { device: "wasm", dtype: "q8" })
with { pooling: "mean", normalize: true } → 1024-d unit vector
|
| Architecture |
BertModel · 24 layers · 16 heads · 1024 hidden · 4,096 FFN ·
~335M params · 30,522 uncased WordPiece vocab ([CLS]=101, [SEP]=102)
|
| Prefix protocol |
Mandatory prefixes: "query: " for retrieval queries & symmetric tasks;
"passage: " for corpus documents. InfoNCE temperature 0.01 puts typical cosines in 0.70–1.00.
|
| Sequence limit |
512 tokens (max_position_embeddings: 512; English-only)
|
| Quantisation & download |
q8 · 336.98 MB ONNX (336,983,104 B) + 0.71 MB tokenizer
(711,396 B) + configs (913 B) = 337.70 MB decimal total
|
| Backend & runtime | CPU WebAssembly (wasm) via shared Transformers.js 3.7.5 inside a dedicated Web Worker |
| License | MIT |
1. Live asymmetric retrieval & 1024-d cosine studio
Because
e5-large-v2 was trained contrastively with low temperature (0.01), unrelated passages still
score ~0.70–0.78 while true matches climb toward 0.85–0.94 — relative rank order and prefix roles
are what drive retrieval quality. Toggle between query:/passage:, symmetric query:, and
unprefixed raw text below.
Backend · dtype–
Latency–
Top match cos–
L2 norm range–
>512 tok items–
NaN count–
| Rank | Passage | Prefix role | Cosine | q · d | WordPiece tok |
|---|---|---|---|---|---|
| Initialise e5-large-v2 above to compute live 1024-d embeddings. | |||||
2. See inside: pairwise similarity matrix, 2-D PCA & WordPiece prefix tokens
Left: N×N pairwise cosine similarity across candidate passages (diagonal = 1.00). Right: deterministic 2-D principal component projection of 1024-d embeddings showing the query (★) and dashed rays to its Top-3 nearest neighbors.
Pairwise cosine matrix
2-D PCA semantic space
Prefixed query WordPiece tokenization (uncased 30,522-token vocab)
Run inference to inspect [CLS], E5 prefix tokens, WordPiece subwords (##), and [SEP].
Why 24-layer E5-large-v2 matters
- Higher retrieval ceiling in English RAG: 24 transformer layers and 1024-d embeddings encode finer topical and causal distinctions than compact 384-d MiniLM encoders, all locally in WASM.
- Explicit query/passage asymmetry: conditioning queries with
"query: "and documents with"passage: "aligns dense retrieval with real search workloads without shipping vectors to an API. - Composable two-stage retrieval: use E5-large-v2 for high-recall 1024-d shortlisting, then rerank the top candidates with a joint cross-encoder on Multi-model.
Use-case ladder
- Basics — E5 Prefix Protocol, Pooling & 512-Token Ceiling: measure how
query:/passage:, symmetricquery:, unprefixed, and swapped prefixes shift discrimination margins, plus pooling/norm verification and 128→512 token audit. - Practical — Private Knowledge-Base & FAQ Deduplicator: upload multiple
.txt/.csv/.jsonfiles, cluster near-duplicate docs calibrated for E5's 0.70–1.00 score band, cancel mid-batch cleanly, and export CSV/JSON/Markdown. - Wild — 6 Empirical E5-large-v2 Stress Probes: probe asymmetric prefix sensitivity, negation symmetry, the 512-token BERT tail drop, uncased WordPiece folding, numeric blindness, and zero-keyword synonyms.
- Multi-model — 24-Layer Bi-Encoder vs 12-Layer Cross-Encoder: chain
Xenova/e5-large-v2(1024-d) intoXenova/ms-marco-MiniLM-L-12-v2with live prefix ablation, Spearmanρ, and rank-shift bump chart.
How the API works
import { pipeline } from "@huggingface/transformers";
const extractor = await pipeline("feature-extraction", "Xenova/e5-large-v2", {
device: "wasm",
dtype: "q8",
});
// Asymmetric retrieval requires "query: " and "passage: " prefixes:
const inputs = [
"query: how much protein should an adult woman eat?",
"passage: CDC guidelines suggest roughly 46 grams per day for adult women.",
];
const out = await extractor(inputs, { pooling: "mean", normalize: true });
// out.dims = [2, 1024]; cosine similarity == dot product