feature-extraction · text · WASM · ~326 MB
This Sentence Transformers model fine-tunes DistilRoBERTa on more than one billion paired sentences. It turns each sentence or short paragraph into a 768-number point in “meaning space”. No query prefix is required: questions and documents use the same mean-pooling recipe. Build a live similarity matrix, search by meaning, and inspect the model’s real vector geometry. Nothing leaves your device.
| Canonical model | sentence-transformers/all-distilroberta-v1 |
|---|---|
| Task / pipeline | feature-extraction (the card’s public tag is sentence-similarity) |
| Architecture | DistilRoBERTa encoder → 768-dimensional sentence embedding; inputs over 128 word pieces are truncated |
| Pooling | attention-mask-aware mean pooling, then L2 normalization; no instruction prefix |
| Training | Contrastive learning over more than 1 billion paired sentences from retrieval, QA, paraphrase, and citation datasets |
| ONNX dtype | fp32 canonical export (not quantized) |
| Backend | WebAssembly (no WebGPU required) |
| Download | 326,244,228-byte ONNX (~326 MB decimal), cached after first load |
| License | Apache-2.0 |
| 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 768-d vectors — a flattened map where near = similar. Then type a query below to rank the lines by meaning.
The encoder emits one 768-number vector per token. To get a single vector per sentence, all-distilroberta-v1 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 768 dimensions (blue = positive, orange = negative, brighter = larger magnitude):
Embeddings are the quiet workhorse behind search, recommendations, deduplication, clustering, and retrieval-augmented generation. all-distilroberta-v1 trades a larger 326 MB fp32 download for a 768-dimensional representation trained across unusually broad paired-text sources. It is useful when that broad semantic geometry matters more than having the smallest possible browser download.
Do two lines mean the same thing? Read one real cosine-similarity number.
Semantic search, k-means clustering, and classify-by-nearest-label over your own text.
Embedding arithmetic: king − man + woman ≈ ? Analogies from vector math.
DistilRoBERTa v1 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",
"sentence-transformers/all-distilroberta-v1",
); // downloads + caches ~326 MB once
// DistilRoBERTa v1 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.