TF-Ranking: Scalable TensorFlow Library for Learning-to-Rank

Rama Kumar Pasumarthi, Xuanhui Wang, Cheng Li, Sebastian Bruch, Michael Bendersky, Marc Najork, Jan Pfeifer, Nadav Golbandi, Rohan Anil, Stephan Wolf · DOI

Abstract

Learning-to-Rank (LTR) deals with maximizing the utility of a list of examples presented to the user, with items of higher relevance being prioritized. It has several practical applications such as large-scale search, recommender systems, document summarization and question answering. While there is widespread support for classification and regression based learning, support for learning-to-rank in deep learning has been limited. We propose TensorFlow Ranking, the first open source library for solving large-scale ranking problems in a deep learning framework. It is highly configurable and provides easy-to-use APIs to support different scoring mechanisms, loss functions and evaluation metrics in the learning-to-rank setting. Our library is developed on top of TensorFlow and can thus fully leverage the advantages of this platform. For example, it is highly scalable, both in training and in inference, and can be used to learn ranking models over massive amounts of user activity data, which can include heterogeneous dense and sparse features. We empirically demonstrate the effectiveness of our library in learning ranking functions for large-scale search and recommendation applications in Gmail and Google Drive. We also show that ranking models built using our model scale well for distributed training, without significant impact on metrics. The proposed library is available to the open source community, with the hope that it facilitates further academic research and industrial applications in the field of learning-to-rank.

Introduction

While deep learning has revolutionized classification and regression, ranking—the task of ordering a list of items to maximize utility—has seen less support in major open-source frameworks. Ranking is fundamentally different from standard classification: the objective is the relative order of items (e.g., ensuring the most relevant document is at the top) rather than absolute scores.

Existing LTR libraries often struggle with three main challenges: scalability to production-level datasets, native support for sparse high-cardinality features (like text n-grams) requiring embeddings, and accounting for position bias in real-world click data. TF-Ranking addresses these by providing a modular, scalable framework built on the TensorFlow ecosystem.

System Architecture

TF-Ranking is built on the TensorFlow Estimator API, offering a modular architecture for building ranking models. The library decomposes the ranking pipeline into several key components:

  • Scoring Function (score_fn): Supports both univariate scoring (one item at a time) and multivariate scoring (scoring a group of items jointly to capture interactions).
  • Ranking Head: A high-level abstraction that encapsulates various loss functions (pointwise, pairwise, and listwise) and ranking metrics (like NDCG and MRR).
  • Unbiased Learning: Integrates Inverse Propensity Weighting (IPW) directly into the losses and metrics to mitigate position bias in training data.
The TF-Ranking architecture showing the modular components for training and serving.

The architecture is designed to handle the "training-serving discrepancy," where models train on lists of items but must score individual items efficiently during real-time inference.

Experimental Evaluation

The library was evaluated using two massive, real-world datasets from Google services: Gmail Search (~250 million queries with dense and sparse features) and Google Drive "Quick Access" (~30 million instances, primarily dense features).

Key Insights

  • Loss Function Performance: Experiments confirm that listwise losses (which optimize the entire ordered list) consistently outperform pointwise and pairwise approaches as they align more closely with ranking metrics.
  • Sparse Feature Impact: In Gmail Search, incorporating sparse textual features via embeddings led to a significant performance boost (over 5% improvement in MRR) compared to dense features alone.
  • Scalability: The library demonstrates strong distributed training performance. Training speed increases linearly up to approximately 20 workers, after which communication overhead begins to diminish returns. Importantly, increasing the number of workers does not degrade model quality.

Results

Moving from a standard pointwise baseline to a listwise loss (Softmax Cross Entropy) provided substantial gains across all metrics in both Gmail and Drive contexts.

Relative improvements of different loss functions on Gmail Search and Google Drive Quick Access datasets.

In the Gmail Search context, the combination of listwise loss and sparse features proved particularly potent, with sparse features providing a larger performance jump than changing the loss function alone.

Conclusion

TF-Ranking provides a robust foundation for the community to build advanced ranking models. Future work includes expanding the library to support more sophisticated ranking methodologies and further research into countering selection and presentation biases in implicit feedback. The library is open-source to facilitate further academic and industrial research in the field.

Summary updated

BibTeX
@inproceedings{pasumarthi2018tf,
  author = {Rama Kumar Pasumarthi and Xuanhui Wang and Cheng Li and Sebastian Bruch and Michael Bendersky and Marc Najork and Jan Pfeifer and Nadav Golbandi and Rohan Anil and Stephan Wolf},
  title = {{TF-Ranking: Scalable TensorFlow Library for Learning-to-Rank}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2018},
  doi = {10.1145/3292500.3330677},
}
Figure