Knowledge Prompt-tuning for Sequential Recommendation

Jianyang Zhai, Xiawu Zheng, Chang-Dong Wang, Hui Li, Yonghong Tian

Introduction

Sequential Recommendation (SR) systems are fundamental to modern digital platforms, powering the "next-item" suggestions that drive user engagement in e-commerce, streaming, and social media. Traditionally, these systems rely on item IDs to model user behavior. However, ID-based models often fail to capture the nuanced semantic relationships between items—for instance, recognizing that a user who watched Inception might be interested in other films directed by Christopher Nolan, rather than just other "sci-fi" IDs.

While Pre-trained Language Models (PLMs) like T5 and GPT offer a potential solution by providing "common sense" reasoning, they often lack the specific domain knowledge required for niche recommendations. Conversely, integrating structured Knowledge Graphs (KGs) into these models frequently introduces "knowledge noise," where irrelevant facts distract the model from the user's core intent. This paper introduces KP4SR (Knowledge Prompt-tuning for Sequential Recommendation), a framework designed to bridge the semantic gap between structured knowledge and natural language processing while filtering out informational noise.

Methodology

KP4SR redefines the recommendation task as a natural language "cloze" (fill-in-the-blank) problem. The framework is built upon three primary pillars:

1. Masked Personalized Prompts (MPP)

To align the recommendation task with the original pre-training objectives of PLMs, KP4SR uses personalized prompts. Instead of processing a sequence of IDs, the model receives a prompt such as: "User u has watched A, B, and is going to watch [mask]." This approach allows the model to leverage its inherent linguistic capabilities to predict the next item in a way that feels "natural" to the underlying architecture.

2. Knowledge Prompts (KP)

To inject domain-specific expertise, the framework converts structured KG triplets into natural language sentences. For example, a triplet like (Inception, director, Christopher Nolan) is transformed into the sentence: "The director of Inception is Christopher Nolan." These prompts provide the model with the context necessary to understand the attributes and relationships of the items in a user's history.

3. Prompt Denoising (PD) via Knowledge Tree Mask

The core innovation of KP4SR is the Knowledge Tree Mask. Simply appending a list of facts to a prompt can lead to "knowledge noise," where the model struggles to distinguish which facts are relevant to the current prediction. To solve this, the authors organize prompts into a hierarchical Knowledge Tree. A custom attention mask is then applied, ensuring that any given token can only "see" logically related information—specifically its parents, children, or siblings within the tree. This preserves the structural integrity of the original Knowledge Graph within the transformer's self-attention mechanism, effectively denoising the input.

Experimental Setup

The framework was implemented using a T5 model as the backbone and evaluated on three diverse real-world datasets linked to the KB4Rec knowledge base:

  • Amazon Books: High-density data focused on literary interactions.
  • LFM-1b (Music): A large-scale dataset of music listening histories.
  • MovieLens-10M (Movies): A standard benchmark for movie recommendation performance.

Key Insights and Results

KP4SR demonstrated significant performance improvements over state-of-the-art (SOTA) baselines, including traditional ID-based models like SASRec and other PLM-based approaches like P5.

Performance Gains

The model achieved substantial improvements in recommendation accuracy across all benchmarks:

  • Books: Improved NDCG@5 by 40.65% and Hit Rate@5 by 36.42% compared to the P5 baseline.
  • Movies: Achieved a 22.17% improvement in NDCG@5.
  • Music: Showed an 11.17% improvement in NDCG@5.

Efficiency and Generalization

Beyond accuracy, the framework proved to be highly efficient. By framing recommendation as a cloze task, the model reached peak performance on the Amazon Books dataset with 70% fewer training epochs than previous PLM-based methods. Furthermore, the model showed a robust ability to generalize to unseen prompt templates, indicating that it learned the underlying logic of the recommendation task rather than merely memorizing specific sentence structures.

Discussion and Limitations

The research highlights that while PLMs are powerful, their effectiveness in specialized domains depends heavily on how knowledge is structured. The success of the Knowledge Tree Mask suggests that structure is more important than syntax; simply providing text is insufficient if the model cannot discern the logical relationships between entities.

However, some challenges remain. The current implementation is limited by the context window of transformers (512 tokens), which restricts the amount of multi-hop graph information that can be included in a single prompt. Additionally, the creation of relationship templates still requires some manual design. Future work will likely focus on scaling these methods to larger language models (LLMs) and developing automated ways to integrate high-order graph data without exceeding token limits.

Conclusion

KP4SR represents a significant step forward in merging the reasoning capabilities of Pre-trained Language Models with the factual depth of Knowledge Graphs. By treating recommendation as a denoised, knowledge-enhanced natural language task, the framework sets a new standard for accuracy and training efficiency in sequential recommendation systems.

Summary updated

BibTeX
@inproceedings{zhai2023knowledge,
  author = {Jianyang Zhai and Xiawu Zheng and Chang-Dong Wang and Hui Li and Yonghong Tian},
  title = {{Knowledge Prompt-tuning for Sequential Recommendation}},
  booktitle = {ACM Multimedia},
  year = {2023},
  doi = {10.1145/3581783.3612252},
}
Figure