NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Deep Recurrent Quantization for Generating Sequential Binary Codes

Jingkuan Song, Xiaosu Zhu, Lianli Gao, Xin-Shun Xu, Wu Liu, Heng Tao Shen

Abstract

Large-scale image retrieval relies on efficient Approximate Nearest Neighbor (ANN) search, typically achieved through quantization into compact binary codes. Traditional deep quantization methods require training separate models for different code lengths, leading to high computational costs and storage overhead. This paper introduces Deep Recurrent Quantization (DRQ), a novel architecture that generates sequential binary codes using a single trained model. By recurrently quantizing feature residuals with a shared codebook and a learnable scaling factor, DRQ allows for flexible code length control at inference time while significantly reducing parameter count compared to state-of-the-art methods.

Introduction

In modern computer vision, the ability to search through millions of images efficiently is a critical requirement. Quantization techniques address this by mapping high-dimensional image features into short binary strings. However, a significant limitation of existing deep hashing and quantization frameworks is their lack of flexibility; a model trained for 16-bit codes cannot be easily adapted for 32-bit or 64-bit retrieval without retraining. This "one model per length" paradigm is computationally expensive and results in massive model files for large-scale deployments.

The authors propose Deep Recurrent Quantization (DRQ) to solve this problem. The core idea is to treat quantization as a sequential process where each subsequent set of bits refines the approximation of the original feature. This approach enables "anytime" retrieval, where a single model can provide varying levels of precision depending on the available computational budget or accuracy requirements.

Methodology

Feature Extraction and Supervision

The DRQ framework begins with a standard convolutional neural network (CNN), such as AlexNet, to extract visual features. To ensure these features are discriminative and suitable for retrieval, the model is trained with intermediate supervision. Specifically, the authors employ triplet losses and adaptive margin losses. These loss functions encourage the network to cluster images of the same class together in the feature space while pushing dissimilar images apart, creating a robust foundation for the subsequent quantization stage.

Recurrent Quantization Block

The defining innovation of DRQ is the Recurrent Quantization (RQ) block. Instead of quantizing the entire feature vector in one pass, the RQ block operates iteratively. In each step $t$, the model approximates the current residual feature $r_{t-1}$ using a codeword from a shared codebook.

The DRQ architecture showing the feature extraction and the recurrent quantization loop.

Key components of the RQ block include:

  1. Shared Codebook: Unlike Product Quantization (PQ) which uses multiple distinct codebooks, DRQ reuses a single codebook across all iterations. This drastically reduces the number of parameters required for the model.
  2. Residual Quantization: At each step, the model calculates the error (residual) between the previous approximation and the actual feature. The next iteration then attempts to quantize this residual.
  3. Scalar Scaling Factor ($w$): Because residuals naturally shrink in magnitude as the approximation improves, a fixed codebook would eventually become ineffective. DRQ introduces a learnable scalar factor $w$ that adjusts the scale of the codebook at each step to match the decreasing magnitude of the residuals.
  4. Soft-to-Hard Quantization: To allow for end-to-end training via backpropagation, the model uses "soft quantization" (a differentiable weighted sum of codewords) during training. During inference, it switches to "hard quantization" (selecting the single closest codeword) to generate the final binary codes.

Experimental Results

Quantitative Performance

DRQ was evaluated on three benchmark datasets: CIFAR-10, NUS-WIDE, and ImageNet. The results demonstrate that DRQ achieves performance comparable to or better than specialized state-of-the-art methods like Deep Triplet Quantization (DTQ) and PQNet, despite the constraint of using a shared codebook for sequential output. For instance, on the NUS-WIDE dataset, DRQ achieved a mean Average Precision (mAP) of 0.843 for 48-bit codes, surpassing PQNet's 0.830.

Efficiency and Flexibility

A major advantage of DRQ is its parameter efficiency. For a 48-bit code, DRQ requires only 524k parameters for its codebook, whereas competing methods like DTQ require approximately 3.15M parameters. Furthermore, DRQ is the first method that allows a single model to be "sliced" at inference time. A user can extract the first 16 bits for a fast, coarse search or use the full 64 bits for high-precision retrieval without needing to load different models.

Qualitative Analysis

The effectiveness of the learned binary space is further evidenced by t-SNE visualizations. As shown in the comparison below, DRQ produces significantly cleaner and more distinct clusters for different image classes compared to previous methods like Deep Visual-Semantic Quantization (DVSQ).

t-SNE visualization comparing the clustering quality of different methods. DRQ (d) shows much clearer separation between classes.

Conclusion

Deep Recurrent Quantization represents a significant step forward in making deep quantization practical for real-world applications. By leveraging a recurrent architecture and a shared codebook, it provides a flexible, parameter-efficient solution for generating sequential binary codes. While there is a minor performance trade-off at extremely short code lengths due to the generalized nature of the shared codebook, the overall benefits in storage and flexibility make DRQ a compelling choice for large-scale image retrieval systems.

Summary updated

BibTeX
@inproceedings{song2019deep,
  author = {Jingkuan Song and Xiaosu Zhu and Lianli Gao and Xin-Shun Xu and Wu Liu and Heng Tao Shen},
  title = {{Deep Recurrent Quantization for Generating Sequential Binary Codes}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.24963/ijcai.2019/128},
}
Figure