Abstract
Accurate click-through rate (CTR) prediction is vital for online advertising and recommendation systems. Recent deep learning advancements have improved the ability to capture feature interactions and understand user interests. However, optimizing the embedding layer often remains overlooked. Embedding tables, which represent categorical and sequential features, can become excessively large, surpassing GPU memory limits and necessitating storage in CPU memory. This results in high memory consumption and increased latency due to frequent GPU-CPU data transfers. To tackle these challenges, we introduce a Model-agnostic Embedding Compression (MEC) framework that compresses embedding tables by quantizing pre-trained embeddings, without sacrificing recommendation quality. Our approach consists of two stages: first, we apply popularity-weighted regularization to balance code distribution between high- and low-frequency features. Then, we integrate a contrastive learning mechanism to ensure a uniform distribution of quantized codes, enhancing the distinctiveness of embeddings. Experiments on three datasets reveal that our method reduces memory usage by over 50x while maintaining or improving recommendation performance compared to existing models. The implementation code is accessible in our project repository https://github.com/USTC-StarTeam/MEC.
Introduction
In modern recommendation systems and online advertising, Click-Through Rate (CTR) prediction is a cornerstone task. These models rely heavily on embedding tables to transform high-dimensional categorical features (e.g., User IDs, item tags) into dense numerical vectors. However, as vocabulary sizes grow into the millions, these tables can reach hundreds of gigabytes, far exceeding the memory capacity of modern GPUs. This forces systems to store embeddings in CPU memory, leading to significant latency during training and inference due to frequent data transfers.
While Product Quantization (PQ) is a common compression technique, it often struggles with the "long-tail" nature of CTR data. High-frequency features tend to dominate the quantization process, leading to "codebook collapse" where rare but potentially important features are poorly represented.
The MEC Framework
To address these limitations, we propose the Model-agnostic Embedding Compression (MEC) framework. MEC is a two-stage approach designed to be "pluggable" with virtually any existing CTR model architecture.
Stage 1: Intelligent Quantization
The first stage focuses on compressing pre-trained embeddings through two key innovations:
- Popularity-Weighted Regularization (PWR): Standard PQ treats all features equally. PWR introduces an entropy-based loss that ensures codes are distributed fairly across both high- and low-frequency features. This prevents popular features from monopolizing the representational capacity of the codebook.
- Contrastive Product Quantization: To enhance the distinctiveness of embeddings, we employ contrastive learning. We generate "semi-synthetic hard negatives" by mutating a single index of a quantized code. The model is then trained to distinguish the original embedding from these mutated versions, forcing it to learn more robust and unique representations.
Stage 2: Downstream Training
Once the codebook is optimized, it is used to train the final CTR prediction model. Because the embeddings are now significantly smaller, the entire model can typically fit within GPU memory, eliminating the CPU-GPU transfer bottleneck.
Experimental Evaluation
We evaluated MEC across three large-scale datasets: Criteo (45M samples), Avazu (~40M samples), and a massive Industrial Dataset from the Huawei ad platform (400M+ impressions).
Key Results
- Extreme Compression: On the Huawei dataset, MEC reduced embedding parameters from 3,142 MB to just 7 MB—a 448x reduction.
- Performance Maintenance and Improvement: MEC consistently maintained or even improved prediction accuracy (AUC). For instance, on Avazu, MEC-PNN outperformed the standard PNN, likely due to the regularization effect preventing overfitting on rare features.
- Efficiency Gains: Embedding lookup times were reduced by approximately 50%, significantly lowering real-time inference latency.
Conclusion
MEC provides a robust, model-agnostic solution for the memory bottleneck in CTR prediction. By decoupling compression from the final task and introducing popularity-aware regularization, it achieves massive compression ratios without sacrificing performance. Future work may explore end-to-end training to further streamline the deployment pipeline.
Summary updated