← All models · EmbeddingGemma 2

use case · practical

Practical: chunked semantic search with instant Matryoshka re-ranking

Chunking a document into semantic windows keeps each passage focused for retrieval. While EmbeddingGemma 2's model card documents an 8K context window (and its export config.json configures a 262,144 position range with a 512 sliding window), practical on-device search indexes bounded chunks to preserve fast retrieval and low latency. Once indexed, the Matryoshka dial truncates the vectors used for scoring from 768 down to 128 dimensions, re-ranking instantly from cached in-memory vectors without re-embedding. This page keeps the full-width 768-d vectors in its in-memory index and truncates only to score, so the dial changes retrieval quality, not this page's memory use— a 6× smaller store only for vectors you actually persist at that width (3,072 → 512 bytes per chunk).

768 → 512 → 256 → 128. Truncates and re-normalizes the full 768-d unit vectors to score each result, with zero re-embedding. The index still holds full 768-d vectors in memory; the size figure below is only what would be persisted at this width.

Everything runs on-device via WebGPU: the document text never leaves your browser, the embeddings live in memory as full 768-d Float32 arrays, and moving the slider slices the vector dimensions and re-normalizes Euclidean length via matryoshka() while scoring. This page does not shrink its stored index: it keeps the full 768-d vectors in memory, so choosing a smaller width here does not reduce this page's memory use. Persisting truncated vectors yourself would instead take only 512 bytes per vector at 128-d (versus 3,072 bytes at 768-d)—a 6× saving only in that persisted store. Limitation: although the model card describes cross-modal capability, image inference is unproven on this export and is not exercised here.

← Basics · EmbeddingGemma 2 · Next: Wild →