feature-extraction Β· text Β· WASM Β· ~34 MB
GTE (General Text Embeddings, from Alibaba) turns a sentence into 384 numbers β a point in "meaning space" β and does it so well that this 33-million-parameter model outscores far larger ones on the MTEB retrieval benchmark. Unlike BGE or E5, it needs no query prefix: you embed a question and a document the exact same way. Type a few lines to build a live similarity matrix, search by meaning, and watch three different embedders disagree on the same pairs. Nothing leaves your device.
| Model | Xenova/gte-small (ONNX of thenlper/gte-small) |
|---|---|
| Task / pipeline | feature-extraction |
| Architecture | BERT-style encoder (~33M params) β 384-dimensional sentence embedding |
| Pooling | mask-aware mean pooling, then L2-normalize β and no instruction prefix (contrast BGE/E5) |
| Strength | Multi-stage contrastive training on a large diverse pair corpus β strong MTEB retrieval for its size |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~34 MB, cached after first load |
| License | MIT (thenlper GTE) |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Put one sentence per line, then embed. The matrix shows the cosine similarity between every pair (1.00 = identical direction). The scatter is a 2D PCA projection of the 384-d vectors β a flattened map where near = similar. Then type a query below to rank the lines by meaning.
The encoder emits one 384-number vector per token. To get a single vector per sentence GTE mean-pools those token vectors (mask-aware) and L2-normalizes, so every sentence becomes a unit-length arrow and cosine similarity is a plain dot product. Pick a sentence to see its real vector and its pre-normalization magnitude.
First 96 of 384 dimensions (blue = positive, orange = negative, brighter = larger magnitude):
Three embedders, three training recipes: MiniLM (mean pool), BGE (CLS pool, prefix-tuned for retrieval) and GTE (mean pool, no prefix). They do not agree on how similar two sentences are β that disagreement is exactly why the model you pick changes your search results. Loads MiniLM (~25 MB) and BGE (~34 MB) on demand, embeds each pair below with all three, and shows the real cosines.
Embeddings are the quiet workhorse behind search, recommendations, deduplication, clustering, and retrieval-augmented generation. GTE's pitch is efficiency: near-top MTEB retrieval quality from a 33M-param model with no prefix ritual β small enough to run in a tab, good enough to trust for real ranking, and private because the text never leaves the device.
Do two lines mean the same thing? One cosine number β and MiniLM/BGE/GTE side by side.
Semantic search, k-means clustering, and classify-by-nearest-label over your own text.
Embedding arithmetic: king β man + woman β ? Analogies from vector math.
GTE retrieves a shortlist by meaning, then a cross-encoder reranker re-scores the top hits.
Feature-extraction plus the pooling discipline is the whole recipe β and note there is no prefix:
import { pipeline } from "@huggingface/transformers";
const extract = await pipeline(
"feature-extraction",
"Xenova/gte-small",
); // downloads + caches ~34 MB once
// GTE uses MEAN pooling and needs NO instruction prefix β embed query and doc identically:
const out = await extract(["how do I sign in?", "the login page rejects my password"], {
pooling: "mean",
normalize: true,
});
const [q, d] = out.tolist();
// unit-length vectors β cosine similarity is just the dot product:
const sim = q.reduce((s, x, i) => s + x * d[i], 0); // high β same meaning
This page asks the worker for the un-normalized pooled vectors so "See inside" can show the real pre-normalization magnitude, then normalizes them in JS. Inference runs in a Web Worker, so the matrix, projection and comparison never jank the page.