Stochastic Generative Hashing

Bo Dai, Ruiqi Guo, Sanjiv Kumar, Niao He, Le Song

Abstract

Learning-based binary hashing has become a powerful paradigm for fast search and retrieval in massive databases. However, due to the requirement of discrete outputs for the hash functions, learning such functions is known to be very challenging. In addition, the objective functions adopted by existing hashing techniques are mostly chosen heuristically. In this paper, we propose a novel generative approach to learn hash functions through Minimum Description Length principle such that the learned hash codes maximally compress the dataset and can also be used to regenerate the inputs. We also develop an efficient learning algorithm based on the stochastic distributional gradient, which avoids the notorious difficulty caused by binary output constraints, to jointly optimize the parameters of the hash function and the associated generative model. Extensive experiments on a variety of large-scale datasets show that the proposed method achieves better retrieval results than the existing state-of-the-art methods.

Introduction

Binary hashing is a critical technique for scaling similarity search in massive databases. By mapping high-dimensional data into short bitstrings, systems can leverage fast hardware instructions like POPCNT for rapid nearest-neighbor retrieval. However, traditional hashing methods often rely on heuristic objective functions and face significant optimization challenges due to the discrete nature of binary outputs. Stochastic Generative Hashing (SGH) addresses these issues by framing hashing as a generative modeling problem, ensuring that the learned codes are both principled and efficient.

Methodology

SGH utilizes the Minimum Description Length (MDL) principle to learn hash codes that maximally compress the dataset while enabling accurate reconstruction of the original inputs.

The Generative Framework

The model consists of an encoder $q(h|x)$, which serves as the hash function, and a decoder $p(x|h)$, which regenerates the input. The authors employ a multivariate Bernoulli distribution for the encoder and a Gaussian model for the decoder. By minimizing the Helmholtz free energy (a variational lower bound), the model learns to capture the essential geometric structure of the data in a compact binary form. A key insight of this approach is that minimizing reconstruction error serves as a mathematically sound surrogate for preserving Euclidean distances in the original space.

Distributional Stochastic Gradient Descent

To overcome the "optimality gap" caused by discrete binary constraints, the authors introduce a novel distributional stochastic gradient method. This approach allows for end-to-end optimization using standard gradient-based tools (like Adam or SGD) without the need for continuous relaxations that often degrade final performance. This "stochastic neuron" reparameterization allows gradients to flow directly through the discrete binary layer.

Experimental Results

The authors evaluated SGH against several state-of-the-art baselines, including Iterative Quantization (ITQ) and Binary Autoencoders (BA), across diverse datasets such as MNIST, CIFAR-10, and SIFT-1M.

SGH demonstrates significantly lower reconstruction error compared to ITQ and orders-of-magnitude faster training times than Binary Autoencoders on the SIFT dataset.

As shown in the figure above, SGH consistently achieves lower L2 reconstruction errors than ITQ across various bit lengths. This improvement is attributed to SGH's flexibility in avoiding rigid orthogonality constraints typically imposed by methods like ITQ. Furthermore, SGH exhibits remarkable training efficiency; while Binary Autoencoders (BA) require nearly 15,000 seconds to train on the SIFT-1M dataset, SGH completes the task in approximately 30-55 seconds. This efficiency makes SGH highly suitable for truly massive datasets, including the SIFT-1B benchmark.

Conclusion and Future Work

Stochastic Generative Hashing provides a principled, generative framework for binary hashing that bridges the gap between theoretical objectives and practical optimization. By achieving superior retrieval performance and significant gains in training speed, SGH represents a robust solution for large-scale similarity search. Future research directions include extending the framework to deep, non-linear generative models and adapting the distributional SGD approach to multi-valued quantization tasks.

Summary updated

BibTeX
@inproceedings{dai2017stochastic,
  author = {Bo Dai and Ruiqi Guo and Sanjiv Kumar and Niao He and Le Song},
  title = {{Stochastic Generative Hashing}},
  booktitle = {International Conference on Machine Learning},
  year = {2017},
  url = {https://openreview.net/forum?id=HkWwoj-uZB},
}
Figure