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.

The 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.

In our 2026 open benchmark (VoxellInc/rag-contradiction-benchmark v1.1.0), 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:

| Probe Query | 3072d Cosine | 768d MRL Cosine (L2 Normed) | 768d Unnormed Dot Product | 768d Prefix L2 Norm | |---|---|---|---|---| | "Cohere Rerank 3.5 pricing" | 0.8385 | 0.8318 | 0.2883 | 0.5845 | | "Vertex AI Search pricing per GB" | 0.8211 | 0.8183 | 0.2878 | 0.5862 | | "pgvector 2000 dimension limit hnsw fix" | 0.8386 | 0.8338 | 0.2899 | 0.5835 | | "Model Context Protocol server for private engineering documentation" | 0.8185 | 0.8111 | 0.2793 | 0.5841 | | "ERROR: column cannot have more than 2000 dimensions pgvector" | 0.8506 | 0.8459 | 0.2918 | 0.5823 |

Notice two critical facts:

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:

package vecnorm

import "math"

func NormalizeL2(v []float32) []float32 {
    var sum float64
    for _, x := range v {
        sum += float64(x) * float64(x)
    }
    if sum == 0 {
        return v
    }
    inv := float32(1.0 / math.Sqrt(sum))
    for i := range v {
        v[i] *= inv
    }
    return v
}

Or eliminate client-side drift completely with Voxell 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.

原文来源:dev.to