← All models

feature-extraction · text · WASM · ~34 MB

Arctic-Embed-S — a retriever that reads the question differently

Snowflake's Arctic-Embed family was tuned for one job: retrieval — finding the passage that answers a query. Its trick is an asymmetric recipe. A document is embedded plainly, but a query is first wrapped in a short instruction, "Represent this sentence for searching relevant passages: …", and the sentence vector is read from the [CLS] token, not a mean of all tokens. Type a few lines to build a live similarity matrix, search with the real query prefix, and watch — in A/B — how the prefix reshapes a query's vector. Nothing leaves your device.

At a glance

ModelSnowflake/snowflake-arctic-embed-s (official ONNX)
Task / pipelinefeature-extraction
ArchitectureBERT-style encoder (~33M params) → 384-dimensional sentence embedding
Pooling[CLS] token pooling, then L2-normalize (contrast GTE/MiniLM mean pooling)
Query prefixRepresent this sentence for searching relevant passages: on queries only — documents stay raw
StrengthRetrieval-tuned with hard-negative mining → strong MTEB retrieval / nDCG for its size
Quantizationq8 (8-bit) ONNX (model_quantized.onnx)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~34 MB, 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 384-d vectors — a flattened map where near = similar. Then type a query below; it is embedded with Arctic's retrieval prefix and ranks the lines by meaning.

Cosine similarity matrix

2D map (PCA)

See inside — the vector, and what the query prefix does

The encoder emits one 384-number vector per token; Arctic reads the [CLS] token's vector as the whole-sentence representation and L2-normalizes it, so every sentence becomes a unit-length arrow and cosine similarity is a plain dot product. Pick a passage to see its real vector and its pre-normalization magnitude.

Embed some passages above to inspect a vector.

A/B — what the query prefix does to the vector

We take a query and the passage that answers it, and embed the query two ways: with the retrieval prefix (as Arctic intends) and without it. The document is embedded raw both times. Note what happens: on a single pair the absolute cosine often drops with the prefix — the instruction words dilute the sentence — yet the prefix is exactly what Arctic was trained to expect. Its real payoff is ranking quality across a whole corpus (the MTEB nDCG the model is tuned for), not the score on one pair. This A/B shows you the measured shift, honestly; it is not a claim that the prefix raises every number.


Arctic vs GTE vs MiniLM on the same pairs

Three embedders, three recipes: Arctic-Embed-S (CLS pool, query prefix), GTE (mean pool, no prefix) and MiniLM (mean pool, no prefix). For a fair fight each query below is embedded the way each model wants it (Arctic gets its prefix; the others don't), then scored against the same passages. Loads GTE (~34 MB) and MiniLM (~25 MB) on demand and shows the real cosines.

Why it matters

Retrieval is the first stage of almost every serious search and RAG system: you have thousands of passages and one question, and you need the few that actually answer it. Arctic-Embed is tuned precisely for that, and the asymmetric query prefix is a cheap, deliberate lever — you spend a few tokens to tell the model "this is a search query", and ranking quality goes up. Small enough to run in a tab, private because the text never leaves the device.

Use cases

Basics

Does the query prefix change the score? One query, one passage, the number with and without it.

Practical

Prefixed retrieval over your own corpus, plus near-duplicate detection at a threshold.

Wild

Cluster a mixed pile of text into unlabeled groups by embedding proximity (k-means).

Multi-model

Arctic retrieves a shortlist, then a cross-encoder reranker re-scores the top hits.

How the API works

Feature-extraction with CLS pooling, plus the query prefix — that asymmetry is the whole point:

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

const extract = await pipeline(
  "feature-extraction",
  "Snowflake/snowflake-arctic-embed-s",
); // downloads + caches ~34 MB once

const PREFIX = "Represent this sentence for searching relevant passages: ";

// A DOCUMENT is embedded raw; a QUERY is wrapped in the retrieval instruction:
const out = await extract(
  [PREFIX + "how do I sign in?", "the login page rejects my password"],
  { pooling: "cls", 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); // higher with the prefix than without

This page asks the worker for the un-normalized CLS 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