Hypergraph Enhanced Knowledge Tree Prompt Learning for Next-Basket Recommendation

Zi-Feng Mai, Chang-Dong Wang, Zhongjie Zeng, Ya Li, Jiaquan Chen, Philip S. Yu

TL;DR

HEKP4NBR is a novel recommendation framework that bridges the gap between Pretrained Language Models (PLMs) and real-world shopping data by transforming Knowledge Graphs into "Knowledge Tree Prompts." By combining these prompts with hypergraph convolutions, the model effectively captures high-order item dependencies and solves the "Out-Of-Vocabulary" problem that typically cripples PLM-based recommenders.

What Problem Does This Paper Address?

Next-Basket Recommendation (NBR) is the task of predicting a set of items a user will buy next, based on their purchase history. Unlike sequential recommendation, which assumes a strict one-by-one order, NBR acknowledges that users often buy multiple items simultaneously to satisfy a specific need.

Existing methods face three major hurdles:

  1. High-Order Dependencies: Most models only look at binary relations (Item A leads to Item B). In reality, dependencies are often complex—like a specific combination of medicines required for a therapy.
  2. Data Sparsity: Users only interact with a tiny fraction of available items, making it hard to learn robust representations.
  3. The OOV (Out-Of-Vocabulary) Problem: While PLMs like T5 or GPT are powerful, they struggle with specific item IDs (e.g., item_12345) or technical terms not found in their training corpus. As shown in Figure 1, standard tokenizers break these IDs into semantically meaningless fragments.
Figure 1: Example of OOV item IDs. These IDs become ir- relevant tokens after tokenization by tokenizers. We use T5-small [28] tokenizer in this example.

Methods

The authors propose HEKP4NBR, a framework consisting of three main components:

1. Knowledge Aware Prompt Learning

To make item IDs intelligible to a PLM, the authors use two types of prompts:

  • Masked User Prompt (MUP): Transforms the NBR task into a "mask prediction" task (e.g., "User bought A, B. Next basket consists of [MASK]").
  • Knowledge Tree Prompt (KTP): Instead of flattening a Knowledge Graph (KG) into a long, noisy string, they build a "Knowledge Tree" centered on the user's history. This tree is converted into natural language triplets (e.g., "The brand of $i_1$ is $A_{11}$") that provide the PLM with the context needed to "understand" OOV items.

2. Multi-item Relation Encoder

To capture complex relationships, the model uses:

  • Mixture-of-Experts (MoE): Measures item similarity from multiple aspects (e.g., price, category, complementarity).
  • Hypergraph Convolution: Items are connected via hyperedges (which can link more than two nodes). This allows the model to capture high-order correlations that simple graphs miss.

3. Frequency Based Gating

Finally, a gating mechanism dynamically weighs the PLM's sequence embeddings against the refined item embeddings based on how frequently a user interacts with specific items, acknowledging that past frequency is a strong predictor of future preference.

The overall framework of HEKP4NBR, showing the prompt learning and hypergraph modules.

Datasets

The model was evaluated on two real-world, non-public datasets provided by Chinese companies:

  • Poultry: A B2B dataset involving wholesale poultry sales. It features a small item set (238 items) but very dense interactions.
  • Pharmacy: A B2C dataset from a medicine store. It is much larger and sparser (6,262 items) and contains complex medical terminology.

The authors manually constructed Knowledge Graphs for both, linking items to attributes like "therapeutic function" or "poultry level."

Key Insights and Ideas

  • Task Alignment Matters: Transforming recommendation into a mask-prediction task (MUP) allows the model to leverage the PLM's native pre-training objectives, significantly speeding up convergence compared to standard fine-tuning.
  • Structured Context vs. Raw Data: The "Knowledge Tree" approach is a clever middle ground. It provides enough external knowledge to solve the OOV issue without overwhelming the PLM with the "noise" of a full, flattened KG.
  • Hypergraphs for Sparsity: In the sparser Pharmacy dataset, the hypergraph module was critical. Ablation studies showed that removing it caused a 25% drop in performance, proving that modeling multi-item combinations is essential when individual item data is thin.

Key Results

HEKP4NBR significantly outperformed state-of-the-art baselines (including P5, SASRec, and $M^2$) across all metrics.

  • Poultry Dataset: Achieved improvements of 22.9% in F1@5 and 35.8% in NDCG@5 over the best baseline.
  • Pharmacy Dataset: Showed even stronger gains in precision, with a 38.5% improvement in F1@5.
Table 2: Overall performance. Bold scores represent the highest results of all methods. Underlined scores stand for the second highest results of all methods.

Ablation studies (Figure 5) confirmed that every component—GCN, Hyper-GCN, the gating mechanism, and the KTP—contributes significantly to the final result.

Ablation study results showing the impact of removing specific components.

Limitations and Future Work

  • Context Window Constraints: PLMs have a maximum input length (e.g., 512 tokens). The authors noted a trade-off: longer user histories mean less room for Knowledge Tree Prompts. Finding the optimal balance is tricky.
  • Template Sensitivity: While the model generalizes well to unseen prompt templates, there is still a slight performance dip (up to 5%), suggesting the choice of natural language phrasing still matters.
  • Scalability: Future work aims to explore more parameter-efficient ways to utilize even larger PLMs for recommendation without the high computational overhead of full fine-tuning.

Summary updated

BibTeX
@inproceedings{mai2023hypergraph,
  author = {Zi-Feng Mai and Chang-Dong Wang and Zhongjie Zeng and Ya Li and Jiaquan Chen and Philip S. Yu},
  title = {{Hypergraph Enhanced Knowledge Tree Prompt Learning for Next-Basket Recommendation}},
  booktitle = {DASFAA},
  year = {2023},
}
Figure