TensorFlow Recommenders vs Pytorch TorchRec: A comparative analysis

TFRS is built on top of Tensorflow 2 and Keras.

As of last March, TikTok has over a billion monthly active users and is gaining eight new users every second. So, what explains TikTok’s explosive growth, despite  being banned in India? What makes its For You feed so addictive? One answer: Recommendation systems. The growth of a data driven-company, be it Netflix or Amazon, depends on the personalisation of customer experiences using insights from swathes of data. ‘Users also bought’ suggestions on Amazon website and ‘Up Next’ at the end of a Netflix show are recommendation systems at work.

According to Mordor Intelligence, the recommendation engine market was valued at USD 2.12 billion in 2020, and is expected to reach USD 15.13 billion by 2026, at a CAGR of 37.46% during the period of 2021-2026. 

TensorFlow Recommenders and PyTorch TorchRec are two popular libraries for building recommender system models. Let’s check how they stack up against each other.

Subscribe to our Newsletter

Join our editors every weekday evening as they steer you through the most significant news of the day, introduce you to fresh perspectives, and provide unexpected moments of joy
Your newsletter subscriptions are subject to AIM Privacy Policy and Terms and Conditions.

TensorFlow Recommenders

Google released TensorFlow Recommenders (TFRS), an open-source TensorFlow package designed for all stages of modern recommender systems, in 2020. TFRS, built on top of Tensorflow 2 and Keras, assists in building a recommender system right from data preparation, model formulation, training, evaluation, and deployment.

“Tensor Recommenders Library is grounded in years of experience of production recommender systems at Google. The  goal is to make TensorFlow Recommenders an evolving platform, flexible enough for conducting academic research and highly scalable for building web-scale recommendation systems. It aims at covering the entire stack from retrieval, through ranking, to post ranking and ties into the larger Tensorflow ecosystem for powering research and production use. Tensorflow Recommenders seamlessly integrate with Scan and TF-Ranking,” said Wei Wei, Developer Advocate, Google. The company is working on additional integration with other Google products such as TPU. 

Image: TensorFlow Recommenders


What makes TensorFlow Recommenders quite popular is its flexibility while building complex models and easy to use design. TFRS is good at:

 Scalable retrieval and feature interaction modelling

In November 2020, TensorFlow Recommenders (TFRS), v0.3.0 was released. It had two important features: 

  • Built-in support for fast, scalable approximate retrieva. By leveraging ScaNN, TFRS now makes it possible to build deep learning recommender models that can retrieve the best candidates out of millions in milliseconds – all while retaining the simplicity of deploying a single “query features in, recommendations out” SavedModel object.”
  • Modelling features interactions. The new version comes with the implementation of Deep & Cross Network (DCN). DCN was designed to learn explicit and bounded-degree cross features more effectively.” It starts with an input layer followed by a cross network ( models explicit feature interactions) ending with a deep network that models implicit feature interactions

PyTorch TorchRec

Meta introduced TorchRec, an open source library for building state-of-the-art recommendation systems under PyTorch, at Inside the Lab event held last month. TorchRec was used to train a model with 1.25 million parameters which went into production in January.

At the Inside Labs event, Jérôme Pesenti, who leads Facebook AI, said TorchRec provides common sparsity & parallelism primitives needed for large-scale recommender systems. He said it will “enable research teams to build the same state of the art personalisation that is used by Facebook Newsfeed and by Instagram Reels today.”

Image: PyTorch

The library includes optimised Recommendation Systems kernels that run on FBGEMM to create multinodal models using model parallelism. It also has a planner to generate optimised sharding plans for models automatically. Additionally, it provides GPU inference support.

“TorchRec is a library for  modern production recommendation with large embedding tables. However, unlike Pytorch’s DDP (Distributed Data Parallel) which replicates the model across devices, Torchrec shards the sparse parts of the model across devices and then uses DDP to replicate the dense parts across devices,” said Collin Taylor, software engineer working on Pytorch at Meta AI.

Sreejani Bhattacharyya
I am a technology journalist at AIM. What gets me excited is deep-diving into new-age technologies and analysing how they impact us for the greater good. Reach me at sreejani.bhattacharyya@analyticsindiamag.com

Download our Mobile App


AI Hackathons, Coding & Learning

Host Hackathons & Recruit Great Data Talent!

AIM Research

Pioneering advanced AI market research

Request Customised Insights & Surveys for the AI Industry


Strengthen Critical AI Skills with Trusted Corporate AI Training

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

AIM Leaders Council

World’s Biggest Community Exclusively For Senior Executives In Data Science And Analytics.

3 Ways to Join our Community

Telegram group

Discover special offers, top stories, upcoming events, and more.

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Subscribe to our Daily newsletter

Get our daily awesome stories & videos in your inbox