← All models

feature-extraction · text · WASM · ~326 MB

all-distilroberta-v1 — broad sentence meaning as a 768-number vector

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.

At a glance

Canonical modelsentence-transformers/all-distilroberta-v1
Task / pipelinefeature-extraction (the card’s public tag is sentence-similarity)
ArchitectureDistilRoBERTa encoder → 768-dimensional sentence embedding; inputs over 128 word pieces are truncated
Poolingattention-mask-aware mean pooling, then L2 normalization; no instruction prefix
TrainingContrastive learning over more than 1 billion paired sentences from retrieval, QA, paraphrase, and citation datasets
ONNX dtypefp32 canonical export (not quantized)
BackendWebAssembly (no WebGPU required)
Download326,244,228-byte ONNX (~326 MB decimal), cached after first load
LicenseApache-2.0
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 768-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 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.

Embed some sentences above to inspect a vector.

Why it matters

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.

Use cases

Basics

Do two lines mean the same thing? Read one real cosine-similarity number.

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

DistilRoBERTa v1 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",
  "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.

References