Abstract
With the rapid development of Large Language Models (LLMs), various explorations have arisen to utilize LLMs' capability of context understanding in recommender systems. While pioneering strategies have primarily transformed traditional recommendation tasks into challenges of natural language generation, there has been a relative scarcity of exploration in the domain of session-based recommendation (SBR) due to its specificity. SBR has been primarily dominated by Graph Neural Networks (GNNs), which have achieved many successful outcomes due to their ability to capture both the implicit and explicit relationships between adjacent behaviors. The structural nature of graphs contrasts with the essence of natural language, posing a significant adaptation gap for LLMs. In this paper, we introduce large language models with graphical Session-Based recommendation, named LLMGR, an effective framework that bridges the aforementioned gap by harmoniously integrating LLMs with GNNs for SBR tasks. This integration seeks to leverage the complementary strengths of LLMs in natural language understanding and GNNs in relational data processing, leading to a more powerful session-based recommender system that can understand and recommend items within a session. Moreover, to endow the LLM with the capability to empower SBR tasks, we design a series of prompts for both auxiliary and major instruction tuning tasks. These prompts are crafted to assist the LLM in understanding graph-structured data and align textual information with nodes, effectively translating nuanced user interactions into a format that can be understood and utilized by LLM architectures. Extensive experiments on three real-world datasets demonstrate that LLMGR outperforms several competitive baselines, indicating its effectiveness in enhancing SBR tasks and its potential as a research direction for future exploration.
Introduction
Session-based recommendation (SBR) focuses on predicting a user's next action based on a short sequence of interactions, such as a single shopping session. Currently, the field is dominated by Graph Neural Networks (GNNs) because they excel at capturing transitions between items as nodes in a graph. However, GNNs typically rely on abstract item IDs and ignore rich textual information like product titles and descriptions. Conversely, Large Language Models (LLMs) are masters of semantic context but struggle with the non-linear, structural nature of graphs. The LLMGR framework addresses this "adaptation gap" by effectively injecting graph-structured behavioral data into a text-heavy LLM architecture.
Methodology
LLMGR (Large Language Models with Graphical Recommendation) consists of several innovative components designed to bridge the gap between structural and semantic data.
Hybrid Encoding Layer
Since item IDs from a pre-trained GNN have different dimensions than LLM word embeddings, LLMGR uses a linear transformation to project GNN embeddings into the LLM’s latent space. This allows the model to process "textual tokens" and "graph nodes" simultaneously. The GNN component is essential for capturing the implicit relationships between adjacent behaviors in a session.
Multi-Task Prompt Engineering and Instruction Tuning
To prevent the model from becoming confused by different tasks, the authors use a two-stage instruction tuning approach. First, the model is tuned on auxiliary tasks like Node-Context Aligning (teaching the LLM which text belongs to which node) and Contrastive Structure-Aware prompts (helping the LLM understand graph flow). Second, it focuses on the major Behavior Patterns Modeling task for the actual recommendation.
Ranking-based Output
Instead of asking the LLM to generate the name of the next item—which is prone to hallucination—LLMGR uses a Multilayer Perceptron (MLP) over the LLM's output to calculate a probability distribution across all possible items in the catalog.
Experiments and Results
The framework was evaluated on three real-world Amazon datasets: Music, Beauty, and Pantry.
- Superior Performance: LLMGR consistently outperformed several competitive baselines (including GCSAN and HCGR). On the "Pantry" dataset, it showed a massive 25.44% improvement in NDCG@5.
- Semantics Solve Sparsity: Traditional GNNs struggle with "cold-start" items. LLMGR leverages the LLM's semantic understanding to reason about new items based on their descriptions rather than just their interaction history.
- Portability: LLMGR is model-agnostic regarding the GNN; it can take embeddings from various existing GNN models and act as a semantic "booster."
Conclusion
LLMGR demonstrates that harmonizing the structural precision of GNNs with the semantic intelligence of LLMs significantly enhances session-based recommendation. While the computational overhead of 7B-parameter models remains a challenge, the framework's ability to handle data sparsity and complex session structures marks a significant step forward for the field. Future work will explore multi-domain scenarios and real-time inference optimization.
Summary updated