Immediately, 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 methods
Suggestion methods energy lots of the interactions you might have with know-how immediately. Open up any app in your cellphone and also you’ll possible end up interacting with a suggestion mannequin immediately, from the homefeed in your go-to social media platform to video options on YouTube to even the adverts 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 pieces, and recommender methods are answerable for creating many top-tier digital experiences immediately.
To assist builders create performant and correct recommender methods, Keras Recommenders (KerasRS) comprises a set of APIs with constructing blocks designed for duties reminiscent of 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 package deal. Then set the backend to JAX (or TensorFlow or PyTorch). Now you’re in your strategy 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 well-liked retrieval structure wherein we determine a set of candidate suggestions. KerasRS offers all the pieces you want to implement this structure, with specialised layers, losses, and metrics designed particularly for recommender duties. You may also 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 giant embedding lookups distributed throughout machines. Moreover, we are going to add well-liked mannequin implementations to our library repeatedly, making it even simpler to construct state-of-the-art recommender methods.
Discover the KerasRS documentation and examples
We additionally wish to spotlight all of the documentation now we have for Keras Recommenders on our just lately redesigned keras.io web site. On keras.io/keras_rs, you could find 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, reminiscent of SASRec, exhibiting an end-to-end instance of coaching a transformer mannequin.
Get began
Go to our web site immediately for extra examples, documentation, and guides to construct your very personal suggestion system. You may also browse the code and contribute at https://github.com/keras-team/keras-rs (be at liberty to present it a star ⭐ too when you’re there!).
We stay up for seeing all the wonderful suggestion methods 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.