# gemini-embedding-2 reaches its 3,072-dimension BEIR SciFact plateau at 768d, and float16 cuts storage in half with zero loss

> Source: <https://dejan.ai/blog/gemini-embedding-2-matryoshka-halfvec-benchmark/>
> Published: 2026-11-30 10:02:13+00:00

**Recommendation:** Store L2-normalized embeddings as pgvector halfvec at 768 dimensions to match 3,072-dimension nDCG@10 (0.9030 vs 0.9033) while halving vector and HNSW index storage; drop to halfvec(256) only if 97.5% of peak recall is acceptable.
More in the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

# gemini-embedding-2 reaches its 3,072-dimension BEIR SciFact plateau at 768d, and float16 cuts storage in half with zero loss

BEIR SciFact retrieval benchmark (5,183 documents, 300 human-labeled queries) for gemini-embedding-2 from 64 to 3,072 dimensions in float32 and float16, paired with measured PostgreSQL pgvector HNSW storage costs.

On the official BEIR SciFact retrieval benchmark (5,183 scientific abstracts and 300 human-labeled test queries evaluated by pure cosine similarity), `gemini-embedding-2` hits its full 3,072-dimension retrieval ceiling at 768 dimensions (0.9030 nDCG@10 versus 0.9033 at 3,072d). Quantizing every vector from 32-bit float (`vector`) to 16-bit float (` halfvec`) changes nDCG@10 by 0.0000 across every tested dimension from 256 to 3,072 while cutting vector and HNSW index storage in half. Truncating further to `halfvec(256)` retains 97.5% of peak nDCG@10 (0.8808) and 97.1% Recall@10 at 512 bytes per vector, which is 24 times smaller than 32-bit 3,072-dimension vectors.

## Retrieval quality from 64 to 3,072 dimensions

Retrieval scores rise steeply between 64 and 256 dimensions, bend into a shallow shoulder between 256 and 768 dimensions, and flatten from 768 to 3,072 dimensions. Recall@100 reaches its ceiling of 0.9933 at 192 dimensions and stays flat through 3,072 dimensions. Recall@10 peaks at 768 and 1,024 dimensions (0.9833) before edging down slightly to 0.9767 at 3,072 dimensions.

| Dimensions | float32 bytes | float16 bytes | nDCG@10 (f32) | nDCG@10 (f16) | Recall@10 (f16) | MRR@10 (f16) | Recall@100 (f16) | Share of 3,072d nDCG@10 | 
|---|---|---|---|---|---|---|---|---|
| 64 | 256 B | 128 B | 0.7857 | 0.7855 | 0.9071 | 0.7524 | 0.9750 | 87.0% | 
| 128 | 512 B | 256 B | 0.8288 | 0.8289 | 0.9332 | 0.7984 | 0.9800 | 91.8% | 
| 192 | 768 B | 384 B | 0.8621 | 0.8624 | 0.9606 | 0.8326 | 0.9933 | 95.5% | 
| 256 | 1,024 B | 512 B | 0.8808 | 0.8808 | 0.9706 | 0.8547 | 0.9933 | 97.5% | 
| 384 | 1,536 B | 768 B | 0.8918 | 0.8918 | 0.9767 | 0.8662 | 0.9933 | 98.7% | 
| 512 | 2,048 B | 1,024 B | 0.8978 | 0.8978 | 0.9800 | 0.8720 | 0.9933 | 99.4% | 
| 768 | 3,072 B | 1,536 B | 0.9029 | 0.9030 | 0.9833 | 0.8783 | 0.9933 | 100.0% | 
| 1,024 | 4,096 B | 2,048 B | 0.9023 | 0.9023 | 0.9833 | 0.8769 | 0.9933 | 99.9% | 
| 1,536 | 6,144 B | 3,072 B | 0.9018 | 0.9018 | 0.9800 | 0.8785 | 0.9933 | 99.8% | 
| 3,072 | 12,288 B | 6,144 B | 0.9033 | 0.9033 | 0.9767 | 0.8809 | 0.9933 | 100.0% | 

## float32 versus float16 (pgvector halfvec)

Across the 256-to-3,072 dimension range, casting L2-normalized vectors from `float32` to `float16` produces identical nDCG@10, Recall@10, and Recall@100 scores to four decimal places, with one +0.0001 rounding shift at 768 dimensions. Plotting raw bytes per vector against nDCG@10 on a logarithmic scale shows the `float16` curve shifted strictly to the left of `float32` by a factor of two at every point.

At the same 1,024-byte raw vector budget, `halfvec(512)` scores 0.8978 nDCG@10 while `vector(256)` scores 0.8808. At 1,536 bytes per vector, `halfvec(768)` reaches the 0.9030 ceiling while `vector(384)` scores 0.8918.

## Measured PostgreSQL pgvector storage footprint

Raw vector bytes represent only part of the database footprint. In PostgreSQL with `pgvector` 0.8.6, we measured a production table holding 8,985 semantic chunks (534,068 words) indexed with `vector(768)`, an HNSW cosine index (` m = 16`, `ef_construction = 64`), and a generated `tsvector` GIN index. Total disk usage for those 8,985 chunks was 89.3 MB, split across vector TOAST storage (36 MB), the HNSW index (35 MB), the heap and `tsvector` column (10 MB), the GIN full-text index (5.8 MB), and parent document metadata (2.3 MB).

Because vector TOAST storage and the HNSW graph scale linearly with vector byte width (7.90 KB per chunk at 3,072 raw bytes, or 2.57x the raw vector payload) while chunk text, `tsvector`, and GIN index overhead remain fixed at roughly 2.0 KB per chunk (200 MB per 100,000 chunks), shrinking vectors produces large total savings down to 256 dimensions before fixed text overhead dominates.

| Column type | Raw vector | Vectors + HNSW (100k chunks) | Text + GIN (100k chunks) | Total (100k chunks) | BEIR SciFact nDCG@10 | 
|---|---|---|---|---|---|
| `vector(3072)` | 12,288 B | 3,012 MB | 200 MB | 3.14 GB | 0.9033 | 
| `halfvec(3072)` | 6,144 B | 1,506 MB | 200 MB | 1.67 GB | 0.9033 | 
| `vector(768)` | 3,072 B | 753 MB | 200 MB | 953 MB | 0.9029 | 
| `halfvec(768)` | 1,536 B | 376 MB | 200 MB | 576 MB | 0.9030 | 
| `halfvec(512)` | 1,024 B | 251 MB | 200 MB | 451 MB | 0.8978 | 
| `halfvec(384)` | 768 B | 188 MB | 200 MB | 388 MB | 0.8918 | 
| `halfvec(256)` | 512 B | 125 MB | 200 MB | 325 MB | 0.8808 | 

## Marginal return: HNSW memory and storage versus nDCG@10

Evaluating the step from `halfvec(256)` to `halfvec(768)` requires comparing marginal retrieval gain against marginal HNSW index memory and disk consumption. In our measured `pgvector` 0.8.6 table, the HNSW index (`m = 16`) occupies 1.315 times the raw vector width (35 MB across 8,985 3,072-byte vectors). For an HNSW graph to serve low-latency queries without disk reads, that index must stay resident in RAM (PostgreSQL `shared_buffers` plus OS page cache).

Marginal nDCG@10 per additional 100 bytes of `halfvec` storage drops by a factor of 3.3 immediately after 256 dimensions (from +0.0144 per 100 bytes on the 192-to-256 step down to +0.0043 on the 256-to-384 step) and falls to +0.0010 on the 512-to-768 step. Moving directly from `halfvec(256)` to `halfvec(768)` triples HNSW index RAM (0.63 GB to 1.88 GB per million chunks, or +200%) and increases total PostgreSQL disk usage by 78% (3.13 GB to 5.58 GB per million chunks) in exchange for +0.0222 nDCG@10 (+2.5%) and +0.0127 Recall@10 (+1.3%). Stepping halfway to `halfvec(384)` adds 0.31 GB of HNSW RAM per million chunks (+50%) and recovers 49.5% of the remaining nDCG@10 gap (+0.0110 out of +0.0222).

| halfvec step | Added bytes/chunk | Delta nDCG@10 | nDCG@10 per +100 B | Added HNSW RAM (1M chunks) | Added total disk (1M chunks) | 
|---|---|---|---|---|---|
| 64 to 128 | +128 B | +0.0434 | +0.0339 | +0.16 GB | +0.31 GB | 
| 128 to 192 | +128 B | +0.0335 | +0.0262 | +0.16 GB | +0.31 GB | 
| 192 to 256 | +128 B | +0.0184 | +0.0144 | +0.16 GB | +0.31 GB | 
| 256 to 384 | +256 B | +0.0110 | +0.0043 | +0.31 GB | +0.61 GB | 
| 384 to 512 | +256 B | +0.0060 | +0.0024 | +0.31 GB | +0.61 GB | 
| 512 to 768 | +512 B | +0.0052 | +0.0010 | +0.63 GB | +1.23 GB | 
| 768 to 3,072 | +4,608 B | +0.0002 | +0.0000 | +5.64 GB | +11.03 GB | 

## Methodology and scope

Every corpus document (title plus abstract, 5,183 items) and every test query (300 items) from the official BEIR SciFact distribution was embedded once at 3,072 dimensions using `gemini-embedding-2` on Vertex AI. For each tested dimension *d* in {64, 128, 192, 256, 384, 512, 768, 1024, 1536, 3072}, we sliced the first *d* coordinates, applied L2 normalization, and scored exact dot-product cosine similarity in `float32` and after `float16` quantization against the official `qrels/test.tsv` relevance judgments. Retrieval used pure dense cosine similarity with no BM25 fusion or reranker. Results cover one English scientific-abstract domain and do not measure out-of-domain web prose, multilingual queries, or approximate nearest-neighbor recall loss from HNSW parameters.
