Guides to using TensorFlow Ranking, and functions for working with TFR in the wild.
Have you wanted to use TensorFlow Ranking for your ranking machine learning tasks? At Avatria, learning-to-rank is at the core of what we do, so the answer was an obvious "yes" for us. But nobody on the team had extensive TensorFlow experience, and we soon found that there was a lot of activation energy required to get off the ground and to the races with tensorflow-ranking
. After our data science team got TFR working the way we wanted it, we wanted to share our learnings with you so that others can have an easier go of it.
There are two main components of this repo: a set of tutorials and guides that explain how and why TFR works the way it does. These guides can help you do everything from convert your .csv's to Google protobufs to setting a learning rate decay schedule. Second, a python package with utility methods for data format conversion, feature scaling, and model exporting.
- Introduction to Tensorflow features, Protocol Buffers (protobufs), and Example Lists with Context (ELWCs).
- Getting your data to work with TensorFlow datasets for ranking.
- Groupwise Scoring Functions and standing up the key components of the Tensorflow Ranking Estimator.
- Exporting and importing
SavedModels
. - Performance hacks.
Here are some links to learning resources that we found helpful for getting TensorFlow Ranking up and running.
- TensorFlow Ranking Colab notebook tutorial
- Example LTR implementation using the deprecated
tfr.data.libsvm_generator
data processor method. - Airbnb paper on their experiences implementing deep nets for ranking.
- Master's thesis on learning to rank with TFR example
- SVMLight documentation, a popular LTR data format
- Crucial TFR GitHub issue on converting Python data structures to ELWCs.
- Strong Medium introduction to building TFrecords files.
- Groupwise Scoring Functions paper describes the core implementation TFR models.
The tfr_helpers
package provides utilities for converting your ranking datasets and pandas DataFrames into ELWCs, a rather complex data structure.
Other functionality:
- Exporting ranker estimators to SavedModel protobuf format.
- Extract model predictions on new
.tfrecords
files. - Load
.tfrecords
files containing ELWC protos into dataframes for inspection.