feature-extraction Β· text Β· WASM Β· ~140 MB
A fully-open, long-context embedder (8192 tokens) that matched OpenAI's text-embedding-ada-002
on release. Its defining quirk: you tell it the task by prepending a prefix to the text β
search_query: for what you're searching with, search_document: for what you're
searching over. Get the prefix right and retrieval sharpens; get it wrong and it dulls. Everything runs
locally; nothing leaves your device.
| Model | Xenova/nomic-embed-text-v1 (ONNX build of nomic-ai/nomic-embed-text-v1) |
|---|---|
| Task / pipeline | feature-extraction |
| Architecture | nomic-bert (137M params, rotary embeddings) β 768-dimensional sentence embedding |
| Pooling | Mean pooling over tokens (masked), then L2-normalize β not CLS pooling |
| Task prefixes | search_query: Β· search_document: Β· classification: Β· clustering: β prepended to the text |
| Context length | up to 8192 tokens β far longer than most 512-token encoders |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~140 MB, cached after first load |
| License | Apache-2.0 (fully open weights + training data) |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Type a query and one candidate passage per line. Nomic embeds the query as
search_query: and each passage as search_document:, then ranks the passages by
cosine similarity. Toggle the prefixes off to feel how much they matter.
Nomic emits a 768-number vector by averaging every token's vector (mean pooling), then
L2-normalizing to unit length. Below left: the real vector for a chosen passage. Below right: the same
query embedded under each task prefix, showing how much the top result and its score move β proof
that search_query: is the right choice for retrieval and the others pull the embedding elsewhere.
First 96 of 768 dimensions (blue = positive, orange = negative, brighter = larger):
| query prefix | top passage | cosine |
|---|
The passages stay embedded as
search_document:. Only the query's prefix changes. search_query: is the
matched pair and usually gives the cleanest top hit and the widest score gap.
Embeddings power search, recommendations, dedup, clustering, and RAG. Nomic is a fully open alternative to closed embedding APIs β open weights, open data, an 8192-token context that swallows whole documents β and it still fits in a browser tab at ~140 MB. So you can ship meaning-based search with no vector-DB service, no per-call API bill, and no user text leaving the device.
search_query: / search_document: split is built for short-query β long-passage search.clustering: prefix to collapse near-duplicate notes, tickets, or reviews with no labels.Pair similarity as one number, and a live look at how the task prefix changes the embedding.
Semantic search that beats keywords, plus near-duplicate clustering over a pasted corpus.
Word/phrase analogies in embedding space β king β man + woman β done with vector maths.
Nomic retrieves a shortlist, then a MS-MARCO cross-encoder reranks it precisely.
Feature-extraction with mean pooling β plus the all-important task prefixes:
import { pipeline } from "@huggingface/transformers";
const extract = await pipeline(
"feature-extraction",
"Xenova/nomic-embed-text-v1",
); // downloads + caches ~140 MB once
// Nomic uses MEAN pooling (not CLS), then L2-normalize:
const embed = (texts) => extract(texts, { pooling: "mean", normalize: true });
// Prepend the TASK PREFIX β this is the part people miss:
const q = await embed(["search_query: how to fix yellow leaves"]);
const ps = await embed([
"search_document: Yellow leaves often mean overwatering; let soil dry out.",
"search_document: The best time to visit Kyoto is autumn.",
]);
// unit vectors β cosine similarity is just the dot product:
const score = (a, b) => a.reduce((s, x, i) => s + x * b[i], 0);
const q0 = q.tolist()[0], docs = ps.tolist();
docs.map((d) => score(q0, d)); // β [0.62, 0.19] β the plant line wins
This page asks the worker for the un-normalized mean-pooled vectors so "See inside" can show the
real pre-normalization magnitude, then normalizes in JS. Inference runs in a Web Worker so ranking never
janks the page. Use search_query:/search_document: for retrieval;
classification: or clustering: for symmetric jobs.