GenRec: Generative Personalized Sequential Recommendation

Panfeng Cao, Pietro LioarXiv 2024 · DOI

Abstract

Sequential recommendation systems traditionally treat item prediction as a classification task over a fixed catalog. However, this approach faces challenges in scaling to large item spaces and capturing nuanced user-item relationships. We present GenRec, a generative framework that reformulates sequential recommendation as a sequence-to-sequence task. By utilizing a BART-based encoder-decoder architecture, GenRec introduces a "prompt-free" masked item prediction objective and cross-modal ID embeddings. Our experiments demonstrate that GenRec achieves state-of-the-art performance on multiple public benchmarks while remaining lightweight enough to train in just a few hours on a single consumer GPU, democratizing the use of Large Language Models (LLMs) for recommendation tasks.

Introduction

Sequential recommendation aims to predict a user’s next interaction by analyzing their historical behavior. For instance, if a user recently purchased a laptop, a recommendation system should ideally suggest related accessories like a mouse or a laptop bag. Traditionally, this has been framed as a classification problem, where the model learns to select one item from a predefined catalog.

Recent advancements have seen the application of Large Language Models (LLMs) to this domain. However, existing LLM-based approaches, such as the P5 model, often rely on complex "hard prompts"—manually designed templates like "What is the next item user 123 will buy?". These templates are brittle, sensitive to phrasing, and require extensive data preprocessing. Furthermore, representing users and items solely as text can lead to a "modality mismatch," where the unique identity information typically captured by ID-based embeddings is lost. GenRec addresses these issues by providing a prompt-free, generative alternative that integrates traditional ID embeddings with the reasoning capabilities of Transformer architectures.

Methodology

GenRec is built upon the BART (Bidirectional and Auto-Regressive Transformers) architecture, a standard encoder-decoder framework. The model's design is centered around three core pillars:

1. Cross-Modal Embeddings

To bridge the gap between textual representations and unique entity identities, GenRec incorporates three distinct types of embeddings for every token in a sequence:

  • Token Embeddings: Standard NLP textual representations that capture the semantic meaning of "user" or "item" tokens.
  • Positional Embeddings: These ensure the model maintains the chronological order of user interactions, which is critical for sequential tasks.
  • ID Embeddings: Unique, non-shared embeddings for specific User IDs and Item IDs. Unlike models that rely purely on text, these embeddings allow GenRec to capture personalized patterns and specific item characteristics that textual descriptions might omit.

2. Unified Masked Objective

Inspired by the "Cloze" task in natural language processing, GenRec uses a masked item prediction objective. Instead of relying on complex natural language prompts, the model simply receives a sequence of interactions where certain items are replaced by a [MASK] token. The goal is to reconstruct the original item based on the surrounding context.

The GenRec architecture, illustrating the flow from cross-modal embeddings through a bidirectional encoder to an auto-regressive decoder for item prediction.

3. Two-Stage Training Strategy

The training process is divided into two phases to maximize the model's understanding of sequential patterns:

  • Pretraining: The model randomly masks items anywhere within the historical sequence. This forces the model to learn bidirectional patterns—understanding how an item relates to both its preceding and succeeding interactions.
  • Finetuning: To align the model with the actual recommendation task, the [MASK] token is moved exclusively to the end of the sequence. This trains the model to predict the next item in a user's journey.

Experimental Setup

The authors evaluated GenRec on three widely recognized public benchmarks:

  • Amazon Sports: Comprising 35,598 users and 18,357 items.
  • Amazon Beauty: A smaller dataset with 22,363 users and 12,101 items.
  • Yelp: A large-scale business recommendation dataset featuring 30,431 users and 20,033 items.

The data was preprocessed using a standard "leave-one-out" strategy. In this setup, the final item in a user's history is reserved for testing, the second-to-last for validation, and all prior interactions are used for training.

Results and Key Insights

GenRec achieved State-of-the-Art (SOTA) results on the Sports and Yelp datasets, outperforming competitive baselines such as SASRec, BERT4Rec, and the significantly larger P5 model.

  • Performance Metrics: On the Amazon Sports dataset, GenRec achieved a Hit Ratio (HR@5) of 0.0397, surpassing the previous best (P5-B) of 0.0387. On Yelp, it achieved an NDCG@10 of 0.0507, demonstrating superior ranking capabilities.
  • The Importance of Pretraining: An ablation study on the Beauty dataset revealed that HR@5 scores dropped from 0.0515 to 0.0422 when pretraining was omitted. This underscores the necessity of the masked sequence modeling task for capturing deep user preferences.
  • Efficiency and Accessibility: One of GenRec's most significant contributions is its efficiency. While many LLM-based projects require massive compute clusters, GenRec (184M parameters) was trained on a single NVIDIA RTX 3090 in approximately one hour for pretraining and 25 epochs for finetuning.

Conclusion and Future Work

GenRec demonstrates that generative models can be both powerful and efficient for sequential recommendation without the need for complex prompt engineering. While it performed exceptionally well on larger datasets, it was slightly outperformed by P5 on the smaller Amazon Beauty dataset, suggesting that smaller data regimes may benefit from more extensive pretraining.

Future research directions include scaling the GenRec architecture to larger parameter counts (e.g., 7B+) to explore enhanced reasoning capabilities and adapting the framework for "direct recommendation" tasks based on user profiles rather than interaction history.

Summary updated

BibTeX
@misc{cao2024genrec,
  author = {Panfeng Cao and Pietro Lio},
  title = {{GenRec: Generative Personalized Sequential Recommendation}},
  year = {2024},
  eprint = {2407.21191},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.21191},
}
Figure