BERT2DNN: BERT Distillation with Massive Unlabeled Data for Online E-Commerce Search

Yunjiang Jiang, Yue Shang, Ziyang Liu, Hongwei Shen, Yun Xiao, Wei Xiong, Sulong Xu, Weipeng Yan, Di Jin

Abstract

BERT2DNN provides a practical framework for distilling the "intelligence" of massive Transformer models like BERT into simple, lightning-fast 4-layer feed-forward networks. By leveraging billions of unlabeled search logs as a "transfer set," the authors achieve near-BERT accuracy with a staggering 150x reduction in latency, making state-of-the-art relevance ranking feasible for high-traffic e-commerce platforms like JD.com.

Addressing the Accuracy vs. Latency Trade-off

In e-commerce, search relevance is paramount—if users cannot find what they want quickly, they leave. While models like BERT have revolutionized Natural Language Processing (NLP) and offer superior relevance scoring, they are notoriously computationally expensive. Their massive requirements make them too slow for real-time ranking in production environments that handle thousands of queries per second.

Furthermore, training these models typically requires high-quality human-labeled data, which is expensive and scarce. While researchers often use "clicks" as a proxy for relevance, this data is noisy and prone to behavioral biases. BERT2DNN addresses these challenges by finding a way to make simple models behave like complex ones through large-scale knowledge distillation.

The BERT2DNN Distillation Pipeline

The core of the paper is a multi-stage Knowledge Distillation pipeline designed to bridge the gap between model complexity and inference speed.

The BERT2DNN distillation pipeline, illustrating the flow from teacher ensembling to student network training using a massive transfer set.
  1. Teacher Training: A "Teacher" model (BERT-Base or an ensemble of BERT and ERNIE) is fine-tuned on a small set of high-quality human-labeled data.
  2. Massive Labeling: This teacher predicts relevance scores for a massive "transfer set" of hundreds of millions (up to 2.3 billion) of unlabeled query-item pairs from search logs.
  3. Student Learning: A "Student" model—a simple 4-layer Deep Neural Network (DNN)—is trained to mimic the teacher’s "soft" prediction scores rather than binary (0/1) labels.
  4. CWUB Tokenization: Unlike BERT’s WordPiece, the authors use a custom scheme called CWUB (Chinese Character and English Word Unigrams and Bigrams). This results in a massive vocabulary of 3 million tokens, allowing the simple DNN to capture complex semantic relationships by shifting the "intelligence" from computational layers to memory-based embeddings.

Datasets and Evaluation

The authors validated the framework using:

  • In-house (JD.com): 380k human-labeled query-item pairs for initial teacher fine-tuning and transfer sets scaling up to 2.3 billion pairs.
  • Public Benchmark: The SST-2 (Stanford Sentiment Treebank) dataset from the GLUE benchmark, using 64M unlabeled Amazon movie reviews as the transfer set to prove the method's generality.

Key Insights

  • Data Quantity > Model Complexity: A "dumb" model (a 4-layer MLP) can become remarkably "smart" if it is shown enough examples of how a "smart" model (BERT) thinks. The scale of the unlabeled data is the primary driver of performance.
  • The Power of Large Vocabularies: By using a 3M-entry vocabulary, the authors effectively shifted the computational burden to memory lookups. This is a classic engineering trade-off: memory is often cheaper and faster than CPU/GPU cycles in high-traffic production environments.
  • Soft Labels are Better Teachers: Training on the teacher's probability scores (e.g., 0.87 relevant) rather than hard labels provides the student with a richer signal about the teacher's uncertainty and the nuances of the data.

Performance and Business Impact

BERT2DNN demonstrates significant improvements in both technical efficiency and real-world business metrics.

Latency comparison (seconds per batch) showing BERT2DNN's performance relative to other models and the online deployment limit.
  • Latency: BERT2DNN is 150x faster than BERT-Base and 15x faster than TinyBERT. It can score 12,800 examples in 1.2 seconds, well within the "online limit" for search engines.
  • Accuracy: The student model recovered over 97% of the teacher's accuracy. On the SST-2 benchmark, it achieved 90.4% accuracy, rivaling much more complex distilled models like DistilBERT.
  • Online Impact: In A/B tests at JD.com, the model led to significant business gains, including a +2.17% increase in user view value (UV-value) and a +1.09% increase in conversion rate (UCVR).

Conclusion

While a small "distillation gap" remains between the student and teacher performance, BERT2DNN proves that massive-scale distillation is a viable path for deploying state-of-the-art NLP intelligence in latency-sensitive environments. Future work will explore AutoML to automatically optimize student architectures and investigate more sophisticated ensemble strategies for the teacher phase.

Summary updated

Abstract

Relevance has significant impact on user experience and business profit for e-commerce search platform. In this work, we propose a data-driven framework for search relevance prediction, by distilling knowledge from BERT and related multi-layer Transformer teacher models into simple feed-forward networks with large amount of unlabeled data. The distillation process produces a student model that recovers more than 97% test accuracy of teacher models on new queries, at a serving cost that's several magnitude lower (latency 150x lower than BERT-Base and 15x lower than the most efficient BERT variant, TinyBERT). The applications of temperature rescaling and teacher model stacking further boost model accuracy, without increasing the student model complexity. We present experimental results on both in-house e-commerce search relevance data as well as a public data set on sentiment analysis from the GLUE benchmark. The latter takes advantage of another related public data set of much larger scale, while disregarding its potentially noisy labels. Embedding analysis and case study on the in-house data further highlight the strength of the resulting model. By making the data processing and model training source code public, we hope the techniques presented here can help reduce energy consumption of the state of the art Transformer models and also level the playing field for small organizations lacking access to cutting edge machine learning hardwares.
BibTeX
@inproceedings{jiang2020bert,
  author = {Yunjiang Jiang and Yue Shang and Ziyang Liu and Hongwei Shen and Yun Xiao and Wei Xiong and Sulong Xu and Weipeng Yan and Di Jin},
  title = {{BERT2DNN: BERT Distillation with Massive Unlabeled Data for Online E-Commerce Search}},
  booktitle = {ICDM},
  year = {2020},
  url = {https://openreview.net/forum?id=br-691jAUH9},
}
Figure