Introduction
Binary hashing is a cornerstone of large-scale data retrieval, compressing high-dimensional data into compact bitstrings to enable efficient storage and rapid distance calculations. However, standard Hamming distance suffers from an "ambiguity problem": its discrete nature often results in thousands of items sharing the same distance from a query, making it difficult to rank results accurately.
To address this, researchers use weighted binary codes, where different bits are assigned varying levels of importance. While this significantly improves retrieval accuracy, it breaks traditional indexing methods that assume all bits are equal. Consequently, searching weighted codes often defaults to an exhaustive linear scan—checking every item in the database one by one—which is prohibitively slow for billion-scale datasets. This paper introduces Multi-Index Weighted Querying (MIWQ), a novel search method that leverages multi-index hash tables to find exact $K$-nearest neighbors in weighted Hamming space up to 1000x faster than a linear scan.
The MIWQ Framework
The proposed MIWQ approach adapts the concept of Multi-Index Hashing (MIH) to work with weighted distances through two main components: a table bucket finding algorithm and a table merging algorithm.
Table Bucket Finding
Instead of checking buckets based on the number of bit flips (as in standard Hamming distance), MIWQ uses a priority queue to probe buckets in order of their weighted distance to the query. The algorithm intelligently generates bit-flip combinations, ensuring that the next bucket checked is always the one with the smallest possible increase in weighted distance. This approach pre-calculates the "cost" of flipping each bit to traverse the search space systematically.
Table Merging and Stopping Criterion
The full binary code is split into $m$ disjoint substrings, each with its own hash table. Results are merged using a $K$-size max-heap to track the best candidates. A key theoretical contribution is the stopping criterion: once the minimum possible weighted distance in un-probed buckets exceeds the maximum distance in the current top-$K$ heap, the algorithm can safely stop. This guarantees the same results as an exhaustive search while examining only a tiny fraction of the data.
Experimental Evaluation
The researchers evaluated MIWQ on three widely recognized benchmarks: Places205 (~1 million images), GIST1M (1 million descriptors), and SIFT1B (1 billion descriptors).
Performance and Accuracy
On the SIFT1B dataset, MIWQ was over 1000 times faster than a linear scan. Crucially, this speedup does not come at the cost of accuracy. As shown in the precision results, MIWQ provides significantly higher precision than standard MIH because it correctly identifies the true nearest neighbors in weighted space.
As seen in the table, MIWQ matches the precision of an exhaustive Linear Scan exactly, confirming its status as an exact search method. For example, at 64 bits for 1-NN retrieval, MIWQ achieves 34.46% precision, outperforming the standard MIH's 31.41%.
Conclusion
MIWQ demonstrates that it is possible to achieve high-accuracy retrieval in weighted binary spaces without the computational burden of exhaustive searches. By integrating weights directly into the search process and utilizing a rigorous stopping criterion, MIWQ offers a scalable solution for billion-scale datasets. Future work may focus on reducing the memory overhead associated with multi-index tables and exploring the integration of search indices with weight-learning processes.
Summary updated