Abstract
In large-scale machine learning, calculating distances between high-dimensional vectors is a computationally intensive task. This paper proposes the Encoding Tree (E-Tree) and Encoding Forest, data structures that exploit prefix redundancy in quantized vector encodings to eliminate redundant calculations. By organizing compressed data into a specialized trie-like structure and utilizing a cache-friendly hierarchical memory layout, the authors achieve significant speedups and memory savings. Evaluation on the SIFT1M benchmark shows that this approach can improve distance computation speed by up to 111% while reducing memory consumption by 12.5% compared to standard Asymmetric Distance Computation (ADC).
Introduction
The explosion of high-dimensional data in fields like computer vision and information retrieval necessitates efficient search and retrieval methods. Vector Quantization (VQ), particularly Product Quantization (PQ), has become a standard for compressing millions of descriptors into short codes. While Asymmetric Distance Computation (ADC) allows for fast distance estimation using these codes, it suffers from a hidden inefficiency: in large datasets, many vectors share identical prefixes in their quantized representations. Standard ADC re-calculates distances for these shared prefixes for every vector, leading to massive computational redundancy.
The Encoding Tree (E-Tree)
To address this redundancy, the authors introduce the Encoding Tree (E-Tree). An E-Tree is a specialized prefix tree (trie) where each node represents a chunk of the vector encoding. Instead of storing encodings as a flat array, they are organized such that common prefixes are represented by shared internal nodes.
By calculating the partial distance for a prefix once at an internal node, the algorithm avoids repeating that work for all descendant leaf nodes. To optimize space, the E-Tree merges non-branching paths (nodes with only one child) into a single node, further reducing the tree's depth and memory footprint.
Hierarchical Memory and Distance Context
A key contribution of this work is the Hierarchical Memory Structure, which translates the logical tree into a hardware-efficient physical layout. The tree is stored linearly in memory to facilitate depth-first traversal, which is highly cache-friendly.
During traversal, the system maintains a "Distance Context"—a small table that stores the cumulative distance calculated from the root to the current node. As the algorithm moves deeper into the tree, it only needs to add the distance contribution of the current chunk to the value stored in the context. This "incremental update" mechanism is the primary driver of the observed speedups.
Scaling with Encoding Forests
While a single E-Tree is effective, its benefits can diminish as encodings become longer and more unique (the "postfix" problem). To counter this, the authors propose the Encoding Forest (E-Forest). By splitting an $M$-chunk encoding into smaller groups and building a separate E-Tree for each group, the probability of finding common prefixes increases significantly, maintaining high performance even for longer code lengths.
Experimental Results
The proposed methods were evaluated using the SIFT1M dataset (1 million 128-dimensional SIFT descriptors) across various quantization schemes, including PQ, Optimized PQ (OPQ), and Additive Quantization (AQ).
- Speed: The E-Forest achieved a 111.7% speedup over naive ADC for 8-byte PQ encodings. For more complex algorithms like IVFADC and Locally Optimized PQ, the E-Tree provided gains of 81% and 74%, respectively.
- Memory: Unlike most speed-up techniques that trade memory for performance, the E-Tree actually reduces memory usage by 12.5% due to its efficient prefix sharing.
Conclusion
The Encoding Tree offers a rare "win-win" in algorithm design, providing both increased speed and reduced memory consumption. By recognizing and exploiting the inherent redundancy in large-scale quantized datasets, it serves as a powerful drop-in replacement for standard distance computation methods in high-dimensional search applications. Future work may involve optimizing the ordering of encoding chunks to further maximize prefix sharing.
Summary updated