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

Learning to Rank Binary Codes

Jie Feng, Wei Liu, Yan WangarXiv 2014

Abstract

Binary codes have been widely used in vision problems as a compact feature representation to achieve both space and time advantages. Various methods have been proposed to learn data-dependent hash functions which map a feature vector to a binary code. However, considerable data information is inevitably lost during the binarization step which also causes ambiguity in measuring sample similarity using Hamming distance. Besides, the learned hash functions cannot be changed after training, which makes them incapable of adapting to new data outside the training data set. To address both issues, in this paper we propose a flexible bitwise weight learning framework based on the binary codes obtained by state-of-the-art hashing methods, and incorporate the learned weights into the weighted Hamming distance computation. We then formulate the proposed framework as a ranking problem and leverage the Ranking SVM model to offline tackle the weight learning. The framework is further extended to an online mode which updates the weights at each time new data comes, thereby making it scalable to large and dynamic data sets. Extensive experimental results demonstrate significant performance gains of using binary codes with bitwise weighting in image retrieval tasks. It is appealing that the online weight learning leads to comparable accuracy with its offline counterpart, which thus makes our approach practical for realistic applications.

Introduction

Large-scale image retrieval systems increasingly rely on binary hashing to compress high-dimensional features into compact bitstrings. This approach enables rapid similarity searches using hardware-accelerated Hamming distance calculations. However, traditional hashing methods face two critical limitations: distance ambiguity and static rigidity. The lossy nature of binarization often results in many distinct images sharing the same Hamming distance from a query, hindering fine-grained ranking. Furthermore, once hash functions are trained, they are typically static; adapting to new data distributions usually requires a computationally expensive re-indexing of the entire database.

This paper introduces a framework to learn bitwise weights for these binary codes, transforming the standard Hamming distance into a more discriminative weighted version. By decoupling the weighting process from the initial hashing, the system can adapt to new data through an efficient online update mode without recomputing existing binary codes.

Proposed Framework

The proposed framework treats weight learning as a "post-hashing" optimization problem. Rather than treating all bits equally, the system learns to assign higher weights to bits that are more discriminative for a given task.

Overview of the bitwise weight learning framework, illustrating the transition from offline Ranking SVM training to an online updater for dynamic data.

Weighted Hamming Distance and Ranking SVM

The core of the method is the weighted Hamming distance, defined as the weighted sum of bitwise differences (XOR) between two codes. To learn these weights, the authors utilize the Absolute Code Difference Vector (ACDV) as a feature representation. The weight learning is then formulated as a learning-to-rank problem using a Ranking SVM. The objective is to optimize a weight vector $w$ such that image pairs from the same class maintain a smaller weighted distance than pairs from different classes.

Optimization and Online Learning

To ensure the weights remain valid for a distance metric (i.e., non-negative), the authors employ Exponentiated Gradient Descent (EGD). This optimization naturally encourages sparsity, effectively filtering out bits that do not contribute to retrieval accuracy. For dynamic environments, the framework incorporates a Passive-Aggressive algorithm for online learning, allowing bit weights to be updated incrementally as new labeled data arrives.

Experimental Evaluation

The framework was rigorously tested on three benchmarks: MNIST (handwritten digits), CIFAR10 (object categories), and the YouTube Faces Database (large-scale video data).

Key results include:

  • Performance Gains: The weighted approach consistently outperformed standard Hamming distance, yielding Mean Average Precision (MAP) improvements of 5% to 20% across various hashing algorithms like LSH, SH, and ITQ.
  • Method Agnosticism: Weighting allowed simpler methods like Locality Sensitive Hashing (LSH) to achieve performance levels comparable to more complex, computationally intensive hashing techniques.
  • Online Efficiency: Crucially, the online learning mode achieved accuracy nearly identical to the offline batch mode, validating its utility for real-world, evolving datasets.

Discussion and Insights

The fundamental insight of this work is that not all bits in a binary code are created equal. Even optimized hashing methods produce bits with varying levels of discriminative power.

Visualization of bit patterns for same-class vs. different-class pairs. Red boxes highlight specific bits that remain consistent within a class but differ across classes, justifying bitwise weighting.

By identifying and weighting these "high-quality" bits, the system recovers much of the information lost during the initial binarization. While weighted Hamming distance introduces a slight computational overhead compared to raw POPCNT operations, it serves as an excellent "fine-grained" re-ranking step after an initial coarse filter. Future work may explore unsupervised weight learning or deeper integration of the weighting layer into the initial hash function training process.

Summary updated

BibTeX
@misc{feng2014learning,
  author = {Jie Feng and Wei Liu and Yan Wang},
  title = {{Learning to Rank Binary Codes}},
  year = {2014},
  eprint = {1410.5524},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1410.5524},
}
Figure