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.
gemini-embedding-2 across ten Matryoshka truncation sizes in float16 (5,183 corpus documents, 300 test queries).| 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.
float32 and float16.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.
pgvector 0.8.6 HNSW and GIN table sizes.| 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 vector width (left) and estimated HNSW index RAM at 1,000,000 chunks versus BEIR SciFact nDCG@10 (right).| 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 |
Cross-domain verification on BEIR NFCorpus
To check how the truncation curve behaves on a harder multi-document retrieval task with graded human relevance judgments (0, 1, 2), we repeated the exact same protocol on BEIR NFCorpus (3,633 medical and nutrition passages, 323 test queries). Quantization from float32 to float16 again preserved retrieval quality to four decimal places from 256 to 3,072 dimensions.
Truncation below 768 dimensions penalized NFCorpus more heavily than SciFact. At halfvec(256), NFCorpus retained 91.6% of its 3,072-dimension nDCG@10 (0.3969 versus 0.4331), compared with 97.5% on SciFact. Stepping to halfvec(384) lifted NFCorpus retention to 95.4% (0.4133), halfvec(512) reached 97.4% (0.4217), and halfvec(768) reached 99.0% (0.4289).
float16 dimensions on BEIR SciFact (5,183 docs, 300 queries) and BEIR NFCorpus (3,633 docs, 323 queries).| Dimensions (f16) | NFCorpus nDCG@10 (f32 / f16) | NFCorpus Recall@10 (f16) | NFCorpus MRR@10 (f16) | NFCorpus % of 3,072d | SciFact % of 3,072d |
|---|---|---|---|---|---|
| 64 | 0.2597 / 0.2596 | 0.1194 | 0.4502 | 59.9% | 87.0% |
| 128 | 0.3398 / 0.3408 | 0.1532 | 0.5575 | 78.7% | 91.8% |
| 192 | 0.3829 / 0.3840 | 0.1747 | 0.6113 | 88.7% | 95.5% |
| 256 | 0.3969 / 0.3969 | 0.1825 | 0.6160 | 91.6% | 97.5% |
| 384 | 0.4133 / 0.4133 | 0.1956 | 0.6313 | 95.4% | 98.7% |
| 512 | 0.4216 / 0.4217 | 0.2035 | 0.6290 | 97.4% | 99.4% |
| 768 | 0.4288 / 0.4289 | 0.2026 | 0.6322 | 99.0% | 100.0% |
| 1,024 | 0.4241 / 0.4242 | 0.2030 | 0.6224 | 97.9% | 99.9% |
| 1,536 | 0.4301 / 0.4310 | 0.2055 | 0.6337 | 99.5% | 99.8% |
| 3,072 | 0.4331 / 0.4331 | 0.2100 | 0.6337 | 100.0% | 100.0% |
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 two English BEIR benchmarks (SciFact scientific abstracts and NFCorpus medical-nutrition passages) and do not measure multilingual queries or approximate nearest-neighbor recall loss from HNSW parameters.

Comments
Sign in with Google to comment and annotate this content.