Papers
Topics
Authors
Recent
Search
2000 character limit reached

Centroid–Residual Quantization in ANN Search

Updated 30 December 2025
  • Centroid–Residual Quantization is a hierarchical vector quantization method that decomposes a data vector into a coarse centroid and a quantized residual.
  • An enhanced variant, Transformed Residual Quantization, applies per-cluster orthogonal transformations to align residuals and reduce quantization error by up to 50% in some cases.
  • This approach significantly improves approximate nearest neighbor search performance by reducing storage requirements and computational complexity compared to traditional methods.

Centroid–Residual Quantization, often referred to as Residual Quantization (RQ), is a hierarchical vector quantization strategy that approximates a data vector as the sum of a coarse centroid and a quantized residual. This two-stage quantizer has found substantial application in large-scale approximate nearest neighbor (ANN) search, where it achieves efficient representational compression and reduced computational complexity. An enhanced variant, Transformed Residual Quantization (TRQ), introduces per-cluster linear transformations—restricted to orthogonal matrices—to further align residuals, thereby minimizing quantization error and improving retrieval performance. Both models provide natural extensions and direct replacements for Product Quantization (PQ), yielding exponential complexity reductions in codebook size for both storage and computation (Yuan et al., 2015).

1. Formal Structure of Two-Stage Residual Quantization

Given a dataset X={xi}i=1NRDX = \{x_i\}_{i=1}^N \subset \mathbb{R}^D, RQ first partitions the data using a coarse codebook C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D. Each vector xix_i is assigned to its nearest centroid via

k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,

with the first-stage reproduction q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}. The residual vector is defined as ri=xick(i)(1)r_i = x_i - c^{(1)}_{k(i)}. The second-stage codebook C(2)={c1(2),,cK2(2)}C^{(2)} = \{c^{(2)}_1, \ldots, c^{(2)}_{K_2}\} is learned by applying k-means clustering to the collection of residuals {ri}\{r_i\}. Each residual rir_i is then assigned:

l(i)=argmin=1K2ric(2)22,q2(ri)=cl(i)(2).l(i) = \arg\min_{\ell=1\ldots K_2} \|r_i - c^{(2)}_\ell\|_2^2, \quad q_2(r_i) = c^{(2)}_{l(i)}.

The complete two-stage quantizer reconstructs

C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D0

minimizing the mean squared error (MSE)

C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D1

2. Transformed Residual Quantization: Objective and Model Enhancement

In ordinary RQ, the residuals from each first-stage cluster generally exhibit heterogeneous orientations and scales. TRQ addresses this by learning a cluster-specific orthogonal transformation C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D2 for each residual cluster. The representation becomes

C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D3

with each C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D4 constrained to be orthogonal: C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D5 for all C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D6.

The joint minimization objective for the first-stage codebook C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D7, the second-stage codebook C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D8, and the transforms C(1)={c1(1),,cK1(1)}RDC^{(1)} = \{c^{(1)}_1, \ldots, c^{(1)}_{K_1}\} \subset \mathbb{R}^D9 is

xix_i0

subject to xix_i1 for each xix_i2.

3. Alternating Optimization and Training Procedure

TRQ optimization employs block-coordinate descent with two alternating steps:

a. Codebook Update:

Fix the transformations xix_i3 and update xix_i4 and assignments xix_i5. For each residual cluster xix_i6, one computes the transformed residuals xix_i7, pools across clusters, and applies k-means (or a product quantizer) to obtain xix_i8. Residuals are assigned to their nearest second-stage centroids.

b. Transform Update:

Fix xix_i9 and the assignments, and update each k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,0 by solving an orthogonal Procrustes problem. Let k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,1 be the k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,2 matrix of cluster k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,3's residuals and k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,4 their corresponding second-stage reconstructions. The update is:

k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,5

This is solved via SVD of the cross-covariance k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,6, giving k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,7.

A few dozen iterations typically suffice for convergence in practice (Yuan et al., 2015).

4. Quantization Error and Empirical Results

Quantization error in TRQ and its predecessors is measured via MSE:

  • Ordinary RQ:

k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,8

  • TRQ:

k(i)=argmink=1K1xick(1)22,k(i) = \arg\min_{k=1\ldots K_1} \|x_i - c^{(1)}_k\|_2^2,9

where orthogonality of q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}0 ensures q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}1 but with markedly improved codebook alignment.

Empirical results indicate substantial error reductions for TRQ versus optimized product quantization (OPQ): on SIFT1M, MSE is reduced by approximately 25%, and on MNIST reductions reach up to 50%. GIST1M, whose features are already close to isotropic, sees a milder MSE improvement of around 10% (Yuan et al., 2015).

TRQ demonstrates significant performance enhancements in ANN search, particularly with inverted-index search frameworks. Because query-time cost is dominated by the number of first-stage cells visited, the additional cost of evaluating a small number of q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}2 orthogonal projections (one per active cluster) is minimal.

On the SIFT1B benchmark with 16-byte codes and recall@1 measured at shortlist sizes q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}3 and q1(xi)=ck(i)(1)q_1(x_i) = c^{(1)}_{k(i)}4, results included:

  • OPQ: R@1 = 0.359 (T = 10,000)
  • TRQ: R@1 = 0.426 (+8%)
  • OPQ: R@1 = 0.379 (T = 30,000)
  • TRQ: R@1 = 0.446 (+7%)

Similar gains appear for recall@10 and recall@50. On medium-scale datasets (SIFT1M, GIST1M, MNIST), TRQ increases Recall@1 by 5–10 percentage points over OPQ and by 7–12 points over vanilla PQ (Yuan et al., 2015).

6. Comparative Significance and Interpretations

The critical advance of TRQ is the explicit per-cluster alignment of residual distributions prior to the second-stage quantization, realized via orthogonal transformations that enable more effective codebook partitioning. This produces substantially lower quantization error and commensurate improvements in ANN search recall, especially where residuals are anisotropic across clusters.

The improvement magnitude is contingent on the structure of residual spaces: greater diversity in residual orientation or scale across clusters favors TRQ. On datasets where intrinsic isotropy is high, impact is less pronounced. A plausible implication is that further gains may be possible by hybridizing with or extending other vector quantization techniques, particularly in highly structured data environments (Yuan et al., 2015).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Centroid–Residual Quantization.