
At this time, we’re excited to announce the launch of Keras Recommenders, a brand new library that places state-of-the-art suggestion strategies at your fingertips.
Energy digital experiences with suggestion programs
Advice programs energy lots of the interactions you’ve got with expertise at the moment. Open up any app in your telephone and also you’ll doubtless end up interacting with a suggestion mannequin instantly, from the homefeed in your go-to social media platform to video ideas on YouTube to even the adverts that pop up in your favourite recreation. Because the world of AI continues to evolve, delivering personalised experiences is extra vital than ever. Giant language fashions cannot do every part, and recommender programs are chargeable for creating many top-tier digital experiences at the moment.
To assist builders create performant and correct recommender programs, Keras Recommenders (KerasRS) accommodates 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 might be in your technique to crafting your individual 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 by which we determine a set of candidate suggestions. KerasRS offers every part it’s good to implement this structure, with specialised layers, losses, and metrics designed particularly for recommender duties. It’s also possible to observe 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 massive embedding lookups distributed throughout machines. Moreover, we are going to add common 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 need to spotlight all of the documentation we have now for Keras Recommenders on our 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, exhibiting an end-to-end instance of coaching a transformer mannequin.
Get began
Go to our web site at the moment for extra examples, documentation, and guides to construct your very personal suggestion system. It’s also possible to browse the code and contribute at https://github.com/keras-team/keras-rs (be happy to present it a star ⭐ too whilst you’re there!).
We look ahead to seeing all the wonderful suggestion programs that get constructed with Keras Recommenders.
Acknowledgements
Shout-out to Fabien Hertschuh and Abheesht Sharma for constructing Keras Recommenders. We additionally need to thank the Keras and ML Frameworks groups in addition to all our collaborators and management for serving to us pull this off.