Dense-retrieval services must switch among embedding-prefix dimensions and index bit rates as latency, quality, and memory budgets change. Tuning a quantizer separately for each rate gives the best quality, but the retrieval tier then holds several code streams and quantizer states at once. We introduce Matryoshka Residual Vector Quantization (MRVQ), a post-hoc residual quantizer for frozen embeddings. Its maximum-rate code can be truncated two ways: dropping residual stages lowers the rate, and dropping embedding coordinates lowers the dimension. One resident artifact therefore serves every (dimension, rate) pair we evaluate. Across FiQA and NFCorpus, four embedding families, and {4, 8, 16}-byte codes, MRVQ is the lowest-RAM design we evaluate. It uses 17.8-22.0x less memory than three separately trained QINCo2 indices, and 1.89-2.02x less than a lean shared-model steelman. The saving is not free: per-rate QINCo2 is 0.026-0.107 nDCG@10 better on FiQA. But MRVQ beats PQ, OPQ, and AdANNS-OPQ at matched code size. We also evaluate a low-build-cost PCA-scalar design that attains quality comparable to RaBitQ and its extension while fitting 420x faster at the median. Finally, we report two negative results: QINCo2 collapses when trained at high rates, and a ranking-bound hypothesis misses its pre-specified acceptance criteria. MRVQ is therefore a low-memory operating point for elastic retrieval, not a universal quality winner.
Figures & tables
Figure 1: Amortizing a rate-and-dimension menu. A rate-specialized deployment keeps one quantizer state and one code stream per rate; each stream may still expose every embedding-prefix dimension. MRVQ stores one maximum-rate residual code: stage prefixes select 4/8/16 B/vector, and coordinate prefixes select the embedding dimension. The document-code term falls from 28n to 16n bytes, and sharing the quantizer state produces the larger measured saving (Table 1 ). Quoted totals are FiQA at D=768 .
Dataset
Family
D
MRVQ
QINCo2 separate
QINCo2 shared
FiQA
MPNet/Nomic/BGE
768
12.88
228.9 ( 17.8× )
25.17 ( 1.95× )
FiQA
Mxbai
1024
16.88
354.6 ( 21.0× )
31.85 ( 1.89× )
NFCorpus
MPNet/Nomic/BGE
768
12.06
227.4 ( 18.9× )
24.34 ( 2.02× )
NFCorpus
Mxbai
1024
16.06
353.2 ( 22.0× )
31.03 ( 1.93× )
Table 1: Resident RAM (MiB) for the complete {4,8,16} B/vector menu; ratios are relative to MRVQ. “Separate” retains one QINCo2 model and code stream per rate; “shared” is the leanest single-model steelman evaluated. Families that share an embedding width share a row because the accounting depends on D , not on the family.
Figure 2: (a) FiQA menu-mean nDCG@10 versus resident RAM for the full menu. MRVQ ( ∘ ) occupies the low-memory corner and per-rate QINCo2 ( □ ) the high-quality corner; neither dominates on both axes. The dashed line marks the leanest shared-model QINCo2 RAM, whose quality we do not measure. (b) The same accounting as a function of corpus size at D=768 . The advantage over per-rate QINCo2 decays from ∼18× at the evaluated corpora to the 1.75× code-stream asymptote, and the shared-model advantage falls below 1.1× at n=7.3 M ( ▼ ).
Figure 3: FiQA ( n=57.6 k) resident RAM for the full rate menu, split into fixed model or codebook state and the document codes that grow with n . The code term is a thin sliver at this corpus size, which is why the measured ratios in Table 1 are far above the asymptotic 1.75× .
Figure 4: PCA-scalar − RaBitQ / Extended-RaBitQ nDCG@10 at matched nominal bits per dimension, with 95% paired-bootstrap intervals. Positive values favor PCA-scalar; the shaded region is the pre-specified ±0.005 practical-equivalence band.
Retrieval-augmented generation (RAG) depends on dense retrieval: each document is stored as a learned vector, and a query is answered by finding its nearest neighbors in that vector space. Keeping one full-precision vector per document is the dominant index cost at corpus scale, so retrieval systems replace each vector with a short code of a few bytes---a step called quantization. Standard quantizers such as product quantization (PQ) pick the code that reconstructs the original vector most closely. A single code is even more useful if it serves several byte budgets at once: when its short prefixes are each directly searchable, a deployment can set its efficiency--quality operating point without re-encoding the corpus. But training all prefixes under one objective makes the early bits a compromise across budgets---short codes improve while the full-width code degrades. Quantization to low-bit representation, such as binary codes, further sharpens the conflict. We introduce Matryoshka Hash Representations (MHR), a two-stage procedure that separates full-width training from prefix organization. MHR first learns a longer binary code, then freezes the model and trains additional zero-initialized residual code adaptors for directly searchable prefixes. Documents are stored at one bit per coordinate, while queries keep continuous logits like PQ to attain sufficient expressivity. We implement the search process with FAISS FastScan. Trained on MS MARCO and zero-shot transferred to seven BEIR datasets, MHR reaches .5561 NDCG@10 and .6535 Recall@100 at 32 bytes, surpassing the best baseline of the same budget. The advantage is more pronounced in lower budgets. The same code also strengthens two common pipelines: shortlisting candidates for full-precision reranking, and pruning a low-storage graph index such as LEANN.
By introducing RSLM (Rotated Scaled Lloyd-Max), a family of training-free vector quantization codecs compressing embeddings to 1--4 bits per dimension, we reduce memory cost and memory bandwidth of a typical large-scale Approximate Nearest Neighbor (ANN) search system, while reducing its complexity and keeping or improving recall across multiple benchmark datasets. State-of-the-art systems filter candidates using coarse partitions, approximately score them to narrow the set, and then rescore the best with higher precision representations (often >=8 bits per dimension). Our relativized codecs can bring this down to 2--4 bits per dimension. We use the properties of the ANN system to encode residual vectors instead of full vectors, both for the approximate scoring phase and the rescoring phase. Since Maximum Inner Product Search (MIPS) is very sensitive to vector norms, we correct the L2 norms of quantized vectors. Our major innovation is that we correct the L2 norm of the final reconstructed vector rather than just the residual. Our rescaling replaces more complicated schemes, such as Anisotropic loss. The residualization scheme gives us a more favorable quality vs size trade-off than generic quantization methods. Our high-performance implementation leverages a block-wise cascaded Fast Walsh-Hadamard Transform (FWHT) with linear-like complexity, AVX SIMD-optimized codebooks, and a steganographic encoding of scaling factors for perfect cache-line alignment.
Rastislav Lenhardt, Teodora Dobos, Thomas Vecchiato +2
Google Zurich, Switzerland · Technical University of Munich Munich, Germany · University of Copenhagen Copenhagen, Denmark +1
Vector quantization is a fundamental tool for compressing high-dimensional embeddings, yet existing multi-codebook methods rely on static codebooks that limit expressiveness under heterogeneous data geometry. While recent dynamic quantizers like QINCo adapt codebooks to individual inputs and improve expressiveness, their strict sequential dependencies create decoding bottlenecks. We propose Residual Quantization via Mixture of Experts (RQ-MoE), a framework combining a two-level MoE with dual-stream quantization to enable input-dependent codebook adaptation for efficient vector quantization. RQ-MoE enables dynamic codebook construction and decouples instruction from quantization, facilitating parallel decoding. Theoretically, we show that standard Residual Quantization and QINCo can be recovered as constrained special cases of RQ-MoE, and derive a guideline for setting expert dimensionality in RQ-MoE. Extensive experiments show that RQ-MoE achieves state-of-the-art or on-par performance in reconstruction and retrieval, while providing 6x-14x faster decoding than prior vector quantization methods. The implementation is available at https://github.com/KDEGroup/RQ-MoE.
Zhengjia Zhong, Shuyan Ke, Zaizhou Lin +3
Key Laboratory of Multimedia Trusted Perception and Efficient Computing, Ministry of Education of China, Xiamen University, Xiamen, China.