Abstract
Modern Deep Learning Recommendation Models (DLRMs) are characterized by their massive memory requirements, primarily driven by embedding tables for high-cardinality categorical features. Standard compression techniques like the hashing trick often result in significant accuracy degradation due to feature collisions. This paper introduces Compositional Embeddings, a novel approach that leverages complementary partitions to represent large vocabularies using multiple smaller embedding tables. By ensuring unique compositional representations for every category, this method achieves up to 60x model compression while maintaining competitive accuracy compared to full-sized models.
Introduction
Recommendation systems are the backbone of modern digital platforms, yet their deployment is increasingly hindered by the sheer scale of categorical features. Features such as User IDs or Page IDs often have cardinalities in the tens of millions. In a standard DLRM, each category is mapped to a unique dense vector in a lookup table. For large-scale models, these tables can exceed several gigabytes, making it impossible to fit models on single GPUs and complicating real-time inference.
The traditional solution, the "hashing trick," reduces memory by mapping multiple categories to the same embedding vector. However, this leads to information loss through collisions, where distinct entities become indistinguishable to the model. We propose a compositional framework that preserves uniqueness while drastically reducing parameter counts.
Methodology: Compositional Embeddings
The core idea of our approach is to decompose a single large embedding table of size $N$ into a set of smaller tables. These tables are indexed using "complementary partitions" of the original index space.
The Quotient-Remainder (Q-R) Trick
The simplest implementation uses the quotient and remainder of an index. For a vocabulary of size $N$, we can use two tables of size $\sqrt{N}$. An index $i$ is decomposed into $q = \lfloor i / \sqrt{N} \rfloor$ and $r = i \pmod{\sqrt{N}}$. The final embedding is then composed from the vectors at $W_1[q]$ and $W_2[r]$.
Complementary Partitions and Composition
This concept generalizes to $k$ partitions. As long as the partitions are complementary—meaning the combination of indices across all tables is unique for every category—the model retains the ability to distinguish between all inputs.
Once sub-embeddings are retrieved from their respective tables, they must be combined. We evaluated several operations:
- Concatenation: Appending vectors, which increases the final embedding dimension.
- Addition: Summing vectors element-wise.
- Multiplication: Element-wise multiplication, which we found to be particularly effective for preserving representational diversity and scalability.
Experimental Evaluation
We evaluated Compositional Embeddings on the Criteo Ad Kaggle dataset, a standard benchmark for click-through rate (CTR) prediction containing 45 million samples with 26 categorical features.
Key Results
Our experiments demonstrate that compositional embeddings provide a superior Pareto frontier for the memory-accuracy trade-off compared to standard hashing.
As shown in Figure 4, the element-wise multiplication method ("Mult") consistently outperforms hashing across various parameter budgets. Specifically, the Q-R trick with multiplication achieved accuracy comparable to a full-sized model while being 15x smaller than a hashing-based model of equivalent performance. In extreme cases, we observed up to 60x compression with minimal impact on test loss, staying within 0.3% to 0.7% of the baseline "Full Table" accuracy.
Discussion and Insights
The success of this method stems from its ability to maintain "natural diversity" in the embedding space. Unlike hashing, which forces hard collisions, compositional embeddings allow the model to learn unique representations for every category by combining shared components in unique ways.
Furthermore, the method is computationally efficient. The memory complexity is reduced from $O(|S|D)$ to $O(k|S|^{1/k}D)$, allowing millions of items to be represented by only a few thousand parameters. This efficiency makes it a "drop-in" replacement for standard embedding layers in production pipelines, and it has already been integrated into major open-source DLRM implementations.
Conclusion and Future Work
Compositional embeddings offer a robust solution to the memory bottleneck in recommendation systems. While our current implementation uses fixed mathematical partitions (like Q-R), future work could explore "semantic" partitions that leverage available metadata (e.g., grouping products by brand or category). Additionally, addressing the frequency imbalance in categorical data—where a few items appear much more frequently than others—could further optimize the allocation of model parameters by dedicating more resources to high-frequency categories.
Summary updated