AGR ec: Adapting Autoregressive Decoders with Graph Reasoning for LLM -based Sequential Recommendation (2025)

Abstract: Autoregressive decoders in large language models (LLMs) excel at capturing users’ sequential behaviors for generative recommendations. However, they inherently struggle to leverage graph-structured user-item interactions, which are widely recognized as beneficial. This paper presents AGRec, adapting LLMs’ decoders with graph reasoning for recommendation. We reveal that LLMs and graph neural networks (GNNs) manifest complementary strengths in distinct user domains. Building on this, we augment the decoding logits of LLMs with an auxiliary GNN model to optimize token generation. Moreover, we introduce a rankable finite state machine to tackle two challenges: (1) adjusting autoregressive generation with discriminative decoders that directly predict user-item similarity, and (2) token homogeneity, where LLMs often generate items with similar prefix tokens, narrowing the scope of beam search. This approach offers a novel perspective to enhance LLMs with graph knowledge. Our AGRec outperforms state-of-the-art models in sequential recommendations. Our code is available online.

## introduction large language models (llms) have demonstrated powerful reasoning capabilities in converting recommendation tasks into language generation tasks @xcite @xcite @xcite . recent methods exploit enhanced item tokenization (e.g., <@xmath0. 1 ) @xcite @xcite , to substitute numerical ids (e.g., "item_1234") @xcite and textual ids (e.g., movie titles) @xcite . however, an inherent problem with llms is their difficulty in interpreting graph-constructed highorder interactions, which are widely acknowledged figure 1 : motivation illustration: llms and gnns both capture collaborative signals (leading to an overlap in terms of hit rate over user distribution), yet each also excels in distinct domains. llms excel at capturing user sequential behaviors autoregressively, while gnns better learn high-order relationships via message-passing. as valuable for recommendation tasks @xcite @xcite . the reason is that interaction signals and the pretrained textual semantics of llms are distributed in entirely different feature spaces @xcite . this fundamental mismatch explains why, despite numerous efforts to align graph-structured interactions with textual inference @xcite @xcite , llms still face challenges in accurately capturing these signals for recommendation. more recently, several attempts @xcite @xcite generate massive textual prompts based on user-item interaction edges to train their llms. this is less effective, as a node with 100 one-hop neighbors could have up to 10,000 two-hop neighbors, growing exponentially with more hops. another endeavor is to employ graph neural networks (gnns) @xcite @xcite that aggregate node features through interaction edges to assist llms in recommendations @xcite @xcite . nevertheless, the autoregressive decoder of llms involves token selection from a predefined vocabulary, centered around textual coherence, which inherently differs from gnns' decoding that relies on user-item representation similarity. unlike nlp tasks, training llms for recommendation with significantly large vocabularies (where a single token represents each item) is very challenging due to the extremely sparse user-item interactions (less than 0.09% as shown in in light of the aforementioned discussions, we propose the agrec model, which adapts llms' decoders with graph reasoning for recommendation. empirically, we found that llms and gnns make effective recommendations for the same user domain, while also demonstrating complementary strengths in specific user domains, as illustrated in fig. 1 . inspired by recent work @xcite that leverages text-free models to generate additional token scores at each decoding step, agrec employs an auxiliary gnn to directly enhance its decoding logits for token generation, harnessing their complementary strengths. different from the two common methods: (i) using a graph-based retriever and (ii) incorporating graph-based representations, this approach offers a novel perspective for improving llm-based recommenders with external graph-structured knowledge. to address the decoding misalignment and the homogeneity issues, we introduce a novel rankable finite state machine (fsm). the fsm has been widely studied to constructively reformulate text generation for llms (willard and louf, 2023; chen et al.; wang et al., 2024c), by strategically masking undesired tokens during decoding. specifically, we convert gnn logits into finite states with rating scores, in which only tokens from the top n items are selectable and rankable for llms. we reveal that llms can intelligently infer the next token, even when the newly generated last token is not the originally highest-ranked. the main contributions of our work can be summarized as follows: (1) we reveal the complementary strengths of llms and gnns in recommendation tasks and propose agrec, which augments the token generation of llms with an auxiliary gnn; (2) we introduce a novel rankable fsm to address the decoding misalignment between llms and gnns and the homogeneity issue. (3) extensive experiments demonstrate that agrec, with llama-1b as its backbone, outperforms state-ofthe-art (sota) baselines equipped with llama-7b in sequential recommendation tasks. ## related work llms have exhibited remarkable reasoning capabilities in recommendations @xcite @xcite @xcite @xcite . many attempts have leveraged knowledge of llms to improve performance @xcite @xcite , including reranking items using textual data @xcite , integrating multimodal data @xcite @xcite and augmenting textual representations @xcite @xcite @xcite . recently, numerous efforts have explored tokenization of items for recommendation @xcite @xcite ). an increasing number of research has integrated gnns with llms for recommendation, such as aligning interactions with textual inference @xcite @xcite , generating text prompts based on interaction edges @xcite @xcite , encoding node descriptions @xcite @xcite , and graph structure augmentation @xcite . several endeavors employ gnns @xcite to generate collaborative embeddings for llms. ## approach fig. 4 illustrates the overall framework of agrec, consisting of (a) decoding discriminative gnn logits and (b) recommendation with graph reasoning. ## conclusion this paper introduces agrec that manifests complementary strengths of llms and gnns in distinct user domains for sequential recommendations. we introduce a rankable finite state machine to adjust autoregressive generation with discriminative decoders, and mitigate token homogeneity to broaden the scope of beam search. the experimental results demonstrate the effectiveness and efficiency of agrec. our future work involves (i) incorporating multi-modal features, such as images @xcite and (ii) exploring more effective item tokenization @xcite @xcite for generative recommendations.