MITB Banner

TensorFlow Recommenders vs Pytorch TorchRec: A comparative analysis

TFRS is built on top of Tensorflow 2 and Keras.

Share

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.

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

Features

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.

Share
Picture of Sreejani Bhattacharyya

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
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

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

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India

Subscribe to Our Newsletter

The Belamy, our weekly Newsletter is a rage. Just enter your email below.