Skip to content

Conversation

@LakshmiKalaKadali
Copy link

This PR adds a tutorial demonstrating the implementation and core concepts of Generative Recommenders (GRs), leveraging the novel Hierarchical Sequential Transduction Unit (HSTU) architecture.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LakshmiKalaKadali, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive tutorial for Generative Recommenders (GRs), specifically showcasing the Hierarchical Sequential Transduction Unit (HSTU) architecture. The tutorial provides an end-to-end example, from data loading and preprocessing using the MovieLens 1M dataset to the implementation of the core HSTU model components, and finally, training, evaluation, and inference. It aims to demonstrate how GRs reformulate recommendation tasks as sequential transduction, offering a scalable alternative to traditional Deep Learning Recommendation Models (DLRMs).

Highlights

  • New Tutorial Introduction: A new tutorial has been added demonstrating Generative Recommenders (GRs) and the Hierarchical Sequential Transduction Unit (HSTU) architecture.
  • HSTU Model Implementation: The tutorial includes a full implementation of the HSTU model, comprising custom Keras layers for positional encoding and the core Sequential Transduction Unit (STU).
  • End-to-End Workflow: The PR provides a complete end-to-end workflow, from data loading and preprocessing using the MovieLens 1M dataset to model training, evaluation, and inference.
  • Keras 3 Compatibility: The implementation leverages Keras 3, allowing for flexible backend selection (e.g., TensorFlow, PyTorch, JAX).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a well-structured and comprehensive tutorial for Generative Recommenders using the HSTU architecture. The code is clear and follows the paper's implementation closely. I've provided a few suggestions to improve code efficiency and adhere more closely to Keras 3 best practices, such as optimizing the data loading pipeline and using backend-agnostic APIs.

"""
Creates a tf.data.Dataset for training the Keras model.
"""
processed_df = load_and_process_data(dataset_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function loads data on every call, which is inefficient. The data is loaded once before this function is called (to get VOCAB_SIZE), and then again for both training and validation dataset creation. To optimize this, you can refactor the function to accept a pre-loaded DataFrame.

This would involve:

  1. Changing the function signature at line 93 to def create_tf_dataset(processed_df, batch_size, max_seq_len, num_targets=1):.
  2. Removing this line (processed_df = load_and_process_data(dataset_name)).
  3. Updating the call sites at lines 482 and 533 to pass the processed_df DataFrame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants