Abstract
Industrial recommendation systems typically employ two-tower models for the matching stage to ensure efficient retrieval from massive item pools. However, these models are limited by "late interaction," which prevents them from capturing complex, fine-grained relationships between user and item features. We introduce SparCode, a novel matching framework that bridges the gap between efficient retrieval and complex "all-to-all" feature interactions. By combining learnable vector quantization with a sparse inverted index, SparCode allows for sophisticated cross-interactions during retrieval. Experimental results on major benchmarks demonstrate that SparCode significantly outperforms standard two-tower models—achieving up to a 71% relative improvement in precision—while maintaining the low latency required for industrial deployment.
Introduction: The Two-Tower Bottleneck
Industrial recommender systems generally follow a two-stage pipeline: Matching (retrieving a subset of candidates) and Ranking (fine-grained re-sorting). The matching stage is dominated by the Two-Tower Model, where separate networks encode queries (users) and items into a shared embedding space. While this allows for efficient Approximate Nearest Neighbor (ANN) search, the final score is restricted to a simple dot product.
This "late interaction" architecture cannot capture nuanced dependencies, such as a user’s preference for a specific actor within a specific genre. While "early interaction" models (like Transformers) can model these nuances, they are computationally prohibitive for real-time retrieval against millions of items. The central challenge is achieving the accuracy of complex cross-interactions with the retrieval speed of a two-tower system.
The SparCode Framework
SparCode addresses this challenge by transforming the continuous embedding problem into a discrete, sparse retrieval task. The architecture consists of three core modules:
- Tokenizer & Quantizer: The query is decomposed into $K_u$ tokens, which are then quantized into discrete codes using learned codebooks. This maps the continuous query into a set of discrete indices.
- All-to-all Interaction Scorer: Unlike the dot-product constraint of two-tower models, SparCode employs a parameterized scorer (e.g., an MLP or Self-Attention) that enables every query token to interact deeply with item features.
- Sparse Inverted Index: To ensure efficiency, the system pre-computes scores between every possible discrete code and every item. A "Sparsity Control" mechanism (utilizing a ReLU function with a learnable bias) ensures that only the most relevant (code, item) pairs are stored in a sparse index.
Efficient Online Serving
At inference time, SparCode bypasses complex neural network computations. The user's query is quantized into a few codes, and the system performs a simple hash-table lookup in the pre-computed sparse index. The final scores are obtained by summing these retrieved values. This approach reduces the inference complexity to $O(1)$ relative to the number of items, mirroring the efficiency of traditional search engines.
Key Insights
- Bridging Discrete and Continuous Spaces: By treating codes as "words," SparCode leverages mature sparse retrieval infrastructure (like Elasticsearch) while retaining the representational power of deep learning.
- End-to-End Optimization: Unlike traditional quantization methods (e.g., Product Quantization) that are applied post-hoc, SparCode trains the quantization codebooks and the interaction model simultaneously. This ensures that the discrete codes are specifically optimized for the retrieval task.
- Exploiting Natural Sparsity: The researchers observed that discarding 99% of pre-computed scores had minimal impact on performance. This confirms that the user-item interaction space is inherently sparse, allowing for massive index compression without sacrificing accuracy.
Experimental Results
The model was evaluated on the Deezer music dataset and Movielens-10M. Key findings include:
- Accuracy: On Deezer, SparCode achieved a 71.15% relative improvement in Precision@50 over the standard DSSM two-tower model.
- Comparison to Tree-Based Models: SparCode outperformed the Tree-based Deep Model (TDM) by approximately 35% in Recall, while offering lower inference complexity ($O(1)$ vs $O(\log N)$).
- Latency: Despite the increased model complexity, SparCode's query latency remains comparable to two-tower models using ANN indices.
Conclusion
SparCode represents a significant step beyond the two-tower paradigm. By rethinking retrieval as a sparse interaction problem, it enables the use of complex models in the matching stage without the typical latency penalties. Future work will focus on scaling the storage of the sparse index for billion-scale item catalogs and improving "cold start" performance for new items.
Summary updated