feature-extraction Β· text Β· WASM Β· ~139 MB
Most sentence embedders stop at 512 tokens β feed them a long document and they quietly ignore everything after the first few paragraphs. Jina embeddings v2 swaps learned positional embeddings for ALiBi, so a single 768-number vector can represent up to 8192 tokens β a whole article. Type passages to build a live similarity matrix, search long text by meaning, and watch Jina catch an answer buried in a tail that a 512-token model never even reads. Nothing leaves your device.
| Model | Xenova/jina-embeddings-v2-base-en (ONNX of jinaai/jina-embeddings-v2-base-en) |
|---|---|
| Task / pipeline | feature-extraction |
| Architecture | JinaBERT (BERT + ALiBi, ~137M params) β 768-dimensional embedding |
| Context length | 8192 tokens β vs the usual 512 (this is the whole point) |
| Pooling | mask-aware mean pooling, then L2-normalize; no instruction prefix |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~139 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Put one passage per line (they can be long β full paragraphs), then embed. The matrix is the cosine similarity between every pair; the scatter is a 2D PCA map where near = similar. Then type a query to rank the passages by meaning.
The encoder emits one 768-number vector per token; Jina mean-pools them (mask-aware) and L2-normalizes, so each passage becomes a unit-length arrow and cosine is a dot product. Embed above, then pick a passage to see its real vector and pre-normalization magnitude.
First 96 of 768 dimensions (blue = positive, orange = negative, brighter = larger magnitude):
Here is a long document whose answer to the query below sits in the final paragraph β past the 512-token cutoff of a standard encoder. We embed it with Jina (full document) and with MiniLM-L6 (which truncates at 512 tokens), then score each against the query. Jina saw the tail; MiniLM didn't. Watch the cosine gap.
Long context changes what you can embed. Instead of chopping a document into 512-token chunks and hoping the right chunk survives, you embed the whole thing once β fewer vectors, no lost tail, and a representation that actually reflects the full text. All private, because nothing leaves the tab.
Do two passages mean the same thing? One cosine number β even for long text.
Long-document semantic search and near-duplicate detection over full paragraphs.
Cluster a pile of passages into themes with k-means over the embeddings.
Jina retrieves a shortlist, then a cross-encoder reranker re-scores the top hits.
Feature-extraction with mean pooling β and no prefix, no 512-token ceiling:
import { pipeline } from "@huggingface/transformers";
const extract = await pipeline(
"feature-extraction",
"Xenova/jina-embeddings-v2-base-en",
); // downloads + caches ~139 MB once
// Jina uses MEAN pooling and needs NO prefix β and accepts up to 8192 tokens:
const out = await extract([longDocument, query], { pooling: "mean", normalize: true });
const [doc, q] = out.tolist();
// unit-length vectors β cosine similarity is just the dot product:
const sim = q.reduce((s, x, i) => s + x * doc[i], 0);
This page pools with normalize:false so "See inside" can show the real pre-normalization
magnitude, then normalizes in JS. Inference runs in a Web Worker, so the matrix, projection and
long-context test never jank the page.