Abstract
Tree-based models underpin many modern semantic search engines and recommender systems due to their sub-linear inference times. In industrial applications, these models operate at extreme scales, where every bit of performance is critical. Memory constraints at extreme scales also require that models be sparse, hence tree-based models are often back-ended by sparse matrix algebra routines. However, there are currently no sparse matrix techniques specifically designed for the sparsity structure one encounters in tree-based models for extreme multi-label ranking/classification (XMR/XMC) problems. To address this issue, we present the masked sparse chunk multiplication (MSCM) technique, a sparse matrix technique specifically tailored to XMR trees. MSCM is easy to implement, embarrassingly parallelizable, and offers a significant performance boost to any existing tree inference pipeline at no cost. We perform a comprehensive study of MSCM applied to several different sparse inference schemes and benchmark our methods on a general purpose extreme multi-label ranking framework. We observe that MSCM gives consistently dramatic speedups across both the online and batch inference settings, single- and multi-threaded settings, and on many different tree models and datasets. To demonstrate its utility in industrial applications, we apply MSCM to an enterprise-scale semantic product search problem with 100 million products and achieve sub-millisecond latency of 0.88 ms per query on a single thread -- an 8x reduction in latency over vanilla inference techniques. The MSCM technique requires absolutely no sacrifices to model accuracy as it gives exactly the same results as standard sparse matrix techniques. Therefore, we believe that MSCM will enable users of XMR trees to save a substantial amount of compute resources in their inference pipelines at very little cost.
Introduction
Extreme Multi-label Ranking (XMR) is a critical task in modern information retrieval, where a system must identify the most relevant items from a pool of millions or hundreds of millions. For instance, a product search engine must suggest a specific item from a massive global catalog based on a user's query. To maintain tractability at this scale, tree-based models combined with beam search are typically employed to explore only the most promising hierarchical branches.
However, at enterprise scales, the computational bottleneck often lies in the underlying sparse matrix operations. Specifically, multiplying a sparse query vector by sparse weight matrices (SpMSpV) becomes inefficient because standard routines treat every column independently. This "blindness" to the tree's inherent structure leads to redundant memory traversals and frequent CPU cache misses, limiting the throughput of real-time systems.
Methods: Masked Sparse Chunk Multiplication (MSCM)
To overcome these limitations, we introduce Masked Sparse Chunk Multiplication (MSCM). The core innovation involves transitioning from standard column-by-column matrix storage (e.g., Compressed Sparse Column or CSC) to a column-chunked format that aligns with the tree's topology.
Chunking by Siblings
In an XMR tree, nodes at the same level sharing a common parent are referred to as "siblings." MSCM groups the weight vectors of these siblings into contiguous memory blocks or "chunks." This grouping exploits the "sibling support" phenomenon, where sibling nodes often share similar sparsity patterns because they respond to similar features.
Exploiting Structured Sparsity
Beam search activates nodes in groups; if a parent node is selected, its children are evaluated. This creates a highly structured "mask" of weights to be multiplied. MSCM evaluates an entire chunk of siblings simultaneously, allowing the CPU to fetch query features once to update multiple sibling scores, significantly improving cache locality.
Optimized Iterators
We provide four iteration strategies for these chunks to suit different operational needs:
- Marching Pointers: Optimal when query and weights have similar sparsity.
- Binary Search: A robust, general-purpose approach.
- Hash-maps: Effective for small-to-medium batch sizes.
- Dense Lookups: The fastest for large batches, albeit with higher memory requirements.
Importantly, MSCM is a mathematical identity of the original operation, ensuring zero loss in model accuracy.
Datasets and Experimental Setup
We evaluated MSCM using six public datasets from the Extreme Classification Repository: eurlex-4k, amazoncat-13k, wiki10-31k, wiki-500k, amazon-670k, and amazon-3m. Additionally, we tested the method on a proprietary enterprise-scale dataset containing 100 million products and a 4-million-dimension feature space to demonstrate its real-world utility.
Key Results
MSCM consistently outperformed vanilla sparse matrix routines, providing speedups ranging from 2x to 20x across various tree topologies and datasets.
On the 100-million-product enterprise dataset, MSCM achieved a sub-millisecond average latency of 0.88 ms per query on a single thread—an 8x reduction compared to standard techniques. Furthermore, our implementation within the PECOS framework was nearly 10x faster than NapkinXC, a popular XMR framework, across all tested datasets. The method also proved to be "embarrassingly parallelizable," scaling efficiently with additional CPU threads.
Discussion and Future Work
While MSCM offers a "free lunch" for linear rankers by providing significant speedups without retraining or accuracy loss, it currently focuses on linear models where scores are dot products. Future work could explore adapting these structured sparsity techniques for non-linear models like deep neural networks. Additionally, while optimized for CPU cache hierarchies, GPU implementations could potentially yield further gains. Finally, exploring query reordering within batches could further enhance memory locality and throughput.
Summary updated