← All models

feature-extraction Β· text Β· WASM Β· ~34 MB

GTE-small β€” a tiny embedder that ranks with the big ones

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.

At a glance

ModelXenova/gte-small (ONNX of thenlper/gte-small)
Task / pipelinefeature-extraction
ArchitectureBERT-style encoder (~33M params) β†’ 384-dimensional sentence embedding
Poolingmask-aware mean pooling, then L2-normalize β€” and no instruction prefix (contrast BGE/E5)
StrengthMulti-stage contrastive training on a large diverse pair corpus β†’ strong MTEB retrieval for its size
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~34 MB, cached after first load
LicenseMIT (thenlper GTE)
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

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.

Cosine similarity matrix

2D map (PCA)

See inside β€” the vector, and why the model choice matters

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.

Embed some sentences above to inspect a vector.

MiniLM vs BGE vs GTE on the same pairs

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.

Why it matters

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.

Use cases

Basics

Do two lines mean the same thing? One cosine number β€” and MiniLM/BGE/GTE side by side.

Practical

Semantic search, k-means clustering, and classify-by-nearest-label over your own text.

Wild

Embedding arithmetic: king βˆ’ man + woman β‰ˆ ? Analogies from vector math.

Multi-model

GTE retrieves a shortlist by meaning, then a cross-encoder reranker re-scores the top hits.

How the API works

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.

References