Binary Embedding-based Retrieval at Tencent

Yukang Gan, Yixiao Ge, Chang Zhou, Shupeng Su, Zhouchuan Xu, Xuyuan Xu, Quanchao Hui, Xiang Chen, Yexin Wang, Ying Shan

Abstract

In industrial search engines, scaling Embedding-Based Retrieval (EBR) to handle hundreds of billions of documents presents significant challenges in storage, computation, and model maintenance. This paper introduces BEBR (Binary Embedding-based Retrieval), a system developed by Tencent’s ARC Lab and PCG teams. BEBR utilizes a novel recurrent binarization technique to compress high-dimensional float vectors into compact binary codes. The system reduces indexing costs by 30–50% and improves query throughput (QPS) by up to 90%, while supporting "hot-refresh" model upgrades that eliminate the need for full corpus re-indexing.

1. Introduction

Standard EBR represents queries and documents as dense float vectors, calculating similarity through metrics like cosine distance. At the scale of Tencent—which manages web search and copyright detection for billions of items—this approach encounters three primary bottlenecks:

  1. Storage & Memory Constraints: Storing billions of float vectors requires petabytes of expensive RAM or high-speed SSD storage.
  2. Computational Overhead: Calculating distances between high-precision float vectors is CPU-intensive, limiting the queries per second (QPS) a system can sustain.
  3. The "Refresh" Nightmare: Improving an embedding model (the "backbone") typically necessitates re-extracting and re-indexing the entire corpus. For billions of documents, this process can take weeks, delaying the deployment of improved AI models.

BEBR addresses these issues by integrating binary compression directly into the retrieval engine, optimizing for both hardware efficiency and operational flexibility.

2. Methodology

The BEBR engine incorporates several key innovations to ensure high fidelity and performance:

2.1 Recurrent Binarization

Rather than employing a simple one-shot hash, BEBR uses a lightweight model featuring residual Multi-Layer Perceptron (MLP) blocks. This architecture progressively refines the binary vector, allowing for "customizable bits per dimension." This flexibility enables engineers to trade off marginal storage increases for significantly higher retrieval accuracy.

2.2 Task-Agnostic Training

To streamline the pipeline, the authors utilize an "embedding-to-embedding" strategy. Instead of training the binarizer end-to-end with a heavy Transformer backbone, the binarizer is trained separately using only the output float vectors. This approach reduced training time from 125 GPU hours to just 11 GPU hours in production environments.

2.3 Backward Compatibility and Hot-Updates

A critical industrial requirement is the ability to update models without downtime. BEBR employs a training objective that ensures a new query model produces embeddings directly comparable to older document embeddings already stored in the index. This allows for "hot-updates," where the query model is upgraded instantly while the document index is updated lazily in the background.

2.4 Symmetric Distance Calculation (SDC)

To maximize speed on standard CPUs, BEBR utilizes Symmetric Distance Calculation (SDC). By leveraging SIMD (Single Instruction Multiple Data) instructions, the system performs lookups and distance calculations in parallel, significantly outperforming standard Hamming distance methods on commodity hardware.

3. Experimental Evaluation

The team evaluated BEBR across public benchmarks and massive internal production datasets:

  • Public (MS COCO): Evaluated for image-to-text retrieval.
  • Industrial Web Search: Tested on 400 million training samples and a 6-billion-document production index from the Sogou Search Engine.
  • Industrial Video: Tested on 8 million training images and a 10-billion-embedding index for video copyright detection.

4. Key Results and Insights

The deployment of BEBR at Tencent yielded substantial operational improvements:

  • Web Search Efficiency: The system achieved a 73.91% reduction in memory usage and a 90% increase in QPS, with a negligible 0.02% drop in click-through rate (CTR).
  • Video Copyright Detection: Memory usage was reduced by 89.65%, while QPS increased by 72%.
  • Cost Reduction: Overall retrieval costs were slashed by 55% for web search and 31% for video detection.
  • Accuracy Regularization: On the MS COCO benchmark, recurrent binary embeddings at 1024 bits occasionally outperformed the original float embeddings in Recall metrics, suggesting that the binarization process may act as a beneficial regularizer.

5. Conclusion

BEBR demonstrates that high-precision retrieval at scale does not require high-precision storage. By decoupling the binarization task from the backbone model and optimizing for CPU-based SIMD instructions, Tencent has created a system that is both cost-effective and operationally agile. While a slight drop in online metrics like CTR remains a challenge, the massive gains in throughput and storage efficiency make binary retrieval a necessity for modern web-scale applications. Future work will focus on extending these binary optimizations into the subsequent re-ranking stages of the search pipeline.

Reference: Gan, Y., et al. (2023). Binary Embedding-based Retrieval at Tencent. arXiv:2302.08714v1 [cs.IR].

Summary updated

BibTeX
@inproceedings{gan2023binary,
  author = {Yukang Gan and Yixiao Ge and Chang Zhou and Shupeng Su and Zhouchuan Xu and Xuyuan Xu and Quanchao Hui and Xiang Chen and Yexin Wang and Ying Shan},
  title = {{Binary Embedding-based Retrieval at Tencent}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2023},
}
Figure