← All models

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

all-MiniLM-L6 β€” turn text into vectors you can see

This model reads a sentence and returns 384 numbers β€” a point in "meaning space" where sentences that mean similar things sit close together. Type a few lines and watch it build a live similarity matrix and a 2D map of where each sentence lands. Nothing leaves your device.

At a glance

ModelXenova/all-MiniLM-L6-v2
Task / pipelinefeature-extraction
Architecture6-layer MiniLM transformer β†’ 384-dimensional sentence embedding
Poolingmask-aware mean pooling over token vectors, then L2-normalize
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~25 MB, cached after first load
LicenseApache-2.0 (Sentence-Transformers)
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.

Cosine similarity matrix

2D map (PCA)

See inside

The transformer actually emits one 384-number vector per token. To get a single vector for the whole sentence we mean-pool β€” average those token vectors (ignoring padding) β€” and then L2-normalize so every sentence becomes a unit-length arrow. Once every vector has length 1, cosine similarity is just the dot product. Pick a sentence to see its real vector and its pre-normalization magnitude.

Embed some sentences to inspect a vector.

Why it matters

Embeddings are the quiet workhorse behind search, recommendations, deduplication, clustering, and retrieval-augmented generation. Once text is a vector, "does this mean the same thing?" becomes a distance you can compute β€” no keywords, no rules. And at 25 MB this runs in a tab, so you can do it without a vector database, an API bill, or sending user text anywhere.

Use cases

Basics

Do two sentences mean the same thing? One cosine number, felt directly.

Practical

Semantic search over a pasted corpus β€” ranked by meaning, not keywords.

Wild

Odd-one-out: drop in a list, watch the model spot the sentence that doesn't belong.

Multi-model

Semantic search that ranks with MiniLM, then reads each hit's tone with a sentiment model.

How the API works

Feature-extraction plus the pooling discipline is the whole recipe:

import { pipeline } from "@huggingface/transformers";

const extract = await pipeline(
  "feature-extraction",
  "Xenova/all-MiniLM-L6-v2",
); // downloads + caches ~25 MB once

// mask-aware MEAN pooling β†’ one 384-d vector per sentence, then L2-normalize:
const out = await extract(["a cat naps", "a kitten sleeps"], {
  pooling: "mean",
  normalize: true,
});
const [a, b] = out.tolist();

// vectors are unit-length, so cosine similarity is just the dot product:
const sim = a.reduce((s, x, i) => s + x * b[i], 0); // β‰ˆ 0.8 β€” very similar

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 and projection never jank the page.

References