At the moment, we’re excited to announce the launch of Keras Recommenders, a brand new library that places state-of-the-art advice methods at your fingertips.
Energy digital experiences with advice programs
Suggestion programs energy lots of the interactions you’ve got with expertise right now. Open up any app in your cellphone and also you’ll doubtless end up interacting with a advice mannequin immediately, from the homefeed in your go-to social media platform to video ideas on YouTube to even the advertisements that pop up in your favourite recreation. Because the world of AI continues to evolve, delivering customized experiences is extra vital than ever. Giant language fashions cannot do all the things, and recommender programs are liable for creating many top-tier digital experiences right now.
To assist builders create performant and correct recommender programs, Keras Recommenders (KerasRS) incorporates a set of APIs with constructing blocks designed for duties equivalent to rating and retrieval. For instance, at Google, we use KerasRS to assist energy the feed in Google Play.
Set up KerasRS with JAX, TensorFlow, or PyTorch
To get began, pip set up the keras-rs bundle. Then set the backend to JAX (or TensorFlow or PyTorch). Now you’re in your approach to crafting your personal state-of-the-art recommender system.
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
import keras_rs
class SequentialRetrievalModel(keras.Mannequin):
def __init__(self):
self.query_model = keras.Sequential([
keras.layers.Embedding(query_count, embed_dim),
keras.layers.GRU(embed_dim),
])
self.candidate_model = keras.layers.Embedding(candidate_count, embed_dim)
self.retrieval = keras_rs.layers.BruteForceRetrieval(ok=10)
self.loss_fn = keras.losses.CategoricalCrossentropy(from_logits=True)
def name(self, inputs):
query_embeddings = self.query_model(inputs)
predictions = self.retrieval(query_embeddings)
return {"query_embeddings": query_embeddings, "predictions": predictions}
Python
On this instance, we present a preferred retrieval structure through which we determine a set of candidate suggestions. KerasRS supplies all the things you want to implement this structure, with specialised layers, losses, and metrics designed particularly for recommender duties. You may as well comply with alongside in this colab pocket book.
And naturally, all these constructing blocks work with the usual Keras APIs of mannequin.compile
to construct your mannequin and mannequin.match
to simply configure your coaching loop.
mannequin.compile(
loss=keras_rs.losses.PairwiseHingeLoss(),
metrics=[keras_rs.metrics.NDCG(k=8, name="ndcg")],
optimizer=keras.optimizers.Adagrad(learning_rate=3e-4),
)
mannequin.match(train_ds, validation_data=val_ds, epochs=5)
Python
Within the coming months, we plan to launch the keras_rs.layers.DistributedEmbedding
class for leveraging SparseCore chips on TPU for doing giant embedding lookups distributed throughout machines. Moreover, we are going to add standard mannequin implementations to our library constantly, making it even simpler to construct state-of-the-art recommender programs.
Discover the KerasRS documentation and examples
We additionally wish to spotlight all of the documentation we’ve for Keras Recommenders on our just lately redesigned keras.io web site. On keras.io/keras_rs, you will discover starter examples involving the basic Deep and Cross Community (DCN) and two-tower embedding mannequin that present the step-by-step processes for writing and coaching your first recommender. There are additionally extra superior tutorials, equivalent to SASRec, displaying an end-to-end instance of coaching a transformer mannequin.
Get began
Go to our web site right now for extra examples, documentation, and guides to construct your very personal advice system. You may as well browse the code and contribute at https://github.com/keras-team/keras-rs (be at liberty to offer it a star ⭐ too when you’re there!).
We stay up for seeing all the wonderful advice programs that get constructed with Keras Recommenders.
Acknowledgements
Shout-out to Fabien Hertschuh and Abheesht Sharma for constructing Keras Recommenders. We additionally wish to thank the Keras and ML Frameworks groups in addition to all our collaborators and management for serving to us pull this off.