use case · basics · nomic-ai/nomic-embed-text-v1.5 · WASM q8 · 137.30 MB

Inside Matryoshka learning & task prefixes

A real query-corpus benchmark (8 queries, 12 documents, one known answer each) embedded once, then scored at all five Matryoshka sizes side by side — plus a controlled test of what happens when you omit or swap Nomic's task prefixes.

1 · 64-d vs 768-d retention curve

Each query is embedded with search_query: and each document with search_document: . For every dimension we apply layer_norm → slice → L2 and compare the ranking with the full 768-d ranking (Kendall τ, top-1 agreement, recall@3) and with the ground-truth answer (top-1 accuracy).

Retention metrics per Matryoshka dimension
Dims Bytes/vec Memory Kendall τ Top-1 = 768-d Recall@3 Top-1 accuracy
Run the benchmark to fill this table.

Per-query drill-down

Top-3 documents for the selected query at each dimension
Dims#1#2#3Answer rank
Run the benchmark first.

2 · Do the task prefixes matter?

Same benchmark, four prefix policies: the recommended search_query: → search_document:, no prefixes, swapped prefixes, and clustering: on both sides. Each policy re-embeds all 20 texts (80 forward passes total, cached per exact input string).

Retrieval quality by prefix policy
Prefix policy Top-1 accuracy Mean answer rank Mean margin Mean answer cos
Run the comparison to fill this table.

How the measurement works

Kendall τ-b counts concordant vs discordant document pairs between the d-dim and 768-d score lists — 1.0 means identical ordering. Margin = answer cosine minus the best distractor cosine (positive = answer ranked first).

Show the code — nomic-core.mjs retentionForQuery(): per-dim τ, top-1 and recall vs 768-d
Show the code — nomic-core.mjs kendallTau(): tie-aware τ-b rank correlation