{"slug": "gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot", "title": "Gemini Embedding 001 MRL Truncation: Why Unnormalized 768d Vectors Lose 0.54 Dot Product", "summary": "A benchmark from VoxellInc's rag-contradiction-benchmark v1.1.0 found that truncated Matryoshka prefixes of Google's gemini-embedding-001 are not unit-normalized, so 768d vectors carry an L2 norm of about 0.584 and raw dot products fall to roughly 0.288 versus 0.832 cosine similarity at full 3072d. The team reports that 768d MRL stays within 0.0028 to 0.0074 cosine points of the full vector while cutting index RAM 4x, provided vectors are L2 re-normalized before storage or search. The project recommends re-normalizing every ingested batch and query, and offers server-side fused normalization through its Voxell Forge embedding service.", "body_md": "Matryoshka Representation Learning (MRL) lets you slice high-dimensional embeddings (`3072d` or `2560d`) down to `768d`, `1024d`, or `1536d` to shrink HNSW memory footprints by `50%` to `75%`. Yet teams migrating to Google's `gemini-embedding-001` frequently hit silent ranking regressions when indexing truncated `output_dimensionality=768` vectors in `pgvector` (`vector_ip_ops`), Pinecone dot-product indexes, or FAISS `IndexFlatIP`.\n\nThe root cause is geometric: **only the full `3072d` output of `gemini-embedding-001` is guaranteed unit-normalized (`||v||_2 = 1.0`). Truncated MRL prefixes (` 768d`, `1536d`) are not unit-length unless you re-normalize them.**\n\nIn our 2026 open benchmark ([`VoxellInc/rag-contradiction-benchmark` v1.1.0](https://github.com/VoxellInc/rag-contradiction-benchmark)), we measured `3072d` full cosine similarity, L2-normalized `768d` MRL cosine similarity, unnormalized `768d` dot products, and `768d` prefix L2 norms on `gemini-embedding-001`:\n\n| Probe Query | `3072d` Cosine | `768d` MRL Cosine (L2 Normed) | `768d` Unnormed Dot Product | `768d` Prefix L2 Norm | \n|---|---|---|---|---|\n| `\"Cohere Rerank 3.5 pricing\"` | `0.8385` | `0.8318` | `0.2883` | `0.5845` | \n| `\"Vertex AI Search pricing per GB\"` | `0.8211` | `0.8183` | `0.2878` | `0.5862` | \n| `\"pgvector 2000 dimension limit hnsw fix\"` | `0.8386` | `0.8338` | `0.2899` | `0.5835` | \n| `\"Model Context Protocol server for private engineering documentation\"` | `0.8185` | `0.8111` | `0.2793` | `0.5841` | \n| `\"ERROR: column cannot have more than 2000 dimensions pgvector\"` | `0.8506` | `0.8459` | `0.2918` | `0.5823` | \n\nNotice two critical facts:\n\n`768d` MRL stays within `0.0028` to `0.0074` cosine points of the full `3072d` vector while cutting index RAM by `4x`.`||v||_2 = 0.584`, their raw dot product scales by roughly `0.584 * 0.584 = 0.341`, dropping `0.8318` down to `0.2883`. Worse, passage-to-passage variance in prefix energy (` 0.5823` vs `0.5862+`) skews top-` k` candidate ordering whenever an ANN engine assumes unit vectors or applies score thresholds (`score >= 0.75`) ahead of If you call `gemini-embedding-001` at `< 3072` dimensions, enforce L2 re-normalization on every ingested batch and every query before storage or search:\n\n```\npackage vecnorm\n\nimport \"math\"\n\nfunc NormalizeL2(v []float32) []float32 {\n    var sum float64\n    for _, x := range v {\n        sum += float64(x) * float64(x)\n    }\n    if sum == 0 {\n        return v\n    }\n    inv := float32(1.0 / math.Sqrt(sum))\n    for i := range v {\n        v[i] *= inv\n    }\n    return v\n}\n```\n\nOr eliminate client-side drift completely with [**Voxell Forge**](https://voxell.ai/forge/): both `turbo` (`1024d`, `$0/forever`, MRL `256..1024`) and `pro` (`2560d`, `$0.25/1M` tokens, MRL `256..2560`) execute fused GPU L2 re-normalization on the server whenever `dimensions` is passed, returning strict unit-norm vectors over HTTPS (`/v1/embeddings`) and mTLS gRPC.", "url": "https://wpnews.pro/news/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot", "canonical_source": "https://dev.to/jcorners68/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-054-dot-product-586", "published_at": "2026-12-03 20:43:36+00:00", "updated_at": "2026-12-03 20:46:55.536296+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "mlops", "ai-tools"], "entities": ["Google", "gemini-embedding-001", "Voxell", "Voxell Forge", "pgvector", "Pinecone", "FAISS"], "also_reported_by": [], "takeaway": "Only the full 3072d gemini-embedding-001 output is unit-normalized; truncated 768d MRL prefixes have an L2 norm near 0.584, so re-normalize them to recover cosine scores within 0.0028-0.0074 of full 3072d while cutting index RAM 4x.", "recommendation": {"advice": "L2-normalize every gemini-embedding-001 batch and query before storing or searching when output_dimensionality is below 3072, or dot-product scores will drop by roughly 0.54.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot", "markdown": "https://wpnews.pro/news/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot.md", "text": "https://wpnews.pro/news/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot.txt", "jsonld": "https://wpnews.pro/news/gemini-embedding-001-mrl-truncation-why-unnormalized-768d-vectors-lose-0-54-dot.jsonld"}}