← All models

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

nomic-embed-text-v1 β€” embeddings with a task prefix

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.

At a glance

ModelXenova/nomic-embed-text-v1 (ONNX build of nomic-ai/nomic-embed-text-v1)
Task / pipelinefeature-extraction
Architecturenomic-bert (137M params, rotary embeddings) β†’ 768-dimensional sentence embedding
PoolingMean pooling over tokens (masked), then L2-normalize β€” not CLS pooling
Task prefixessearch_query: Β· search_document: Β· classification: Β· clustering: β€” prepended to the text
Context lengthup to 8192 tokens β€” far longer than most 512-token encoders
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~140 MB, cached after first load
LicenseApache-2.0 (fully open weights + training data)
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it β€” semantic search

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.

See inside β€” the vector, and the prefix effect

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.

The 768-d vector

Rank some passages to inspect a vector.

Prefix effect: which prefix, which winner

Rank passages to compare prefixes.

Why it matters

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.

Use cases

Basics

Pair similarity as one number, and a live look at how the task prefix changes the embedding.

Practical

Semantic search that beats keywords, plus near-duplicate clustering over a pasted corpus.

Wild

Word/phrase analogies in embedding space β€” king βˆ’ man + woman β€” done with vector maths.

Multi-model

Nomic retrieves a shortlist, then a MS-MARCO cross-encoder reranks it precisely.

How the API works

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.

References