Skip to main content
QUICK REVIEW

[Paper Review] LlamaRec: Two-Stage Recommendation using Large Language Models for Ranking

Zhenrui Yue, Sara Rabhi|arXiv (Cornell University)|Oct 25, 2023
Topic ModelingComputer Science13 citations
TL;DR

LlamaRec combines a fast retrieval stage with an LLM-based ranking stage using a verbalizer to efficiently rank top-k candidates, achieving superior performance and faster inference than generation-based baselines.

ABSTRACT

Recently, large language models (LLMs) have exhibited significant progress in language understanding and generation. By leveraging textual features, customized LLMs are also applied for recommendation and demonstrate improvements across diverse recommendation scenarios. Yet the majority of existing methods perform training-free recommendation that heavily relies on pretrained knowledge (e.g., movie recommendation). In addition, inference on LLMs is slow due to autoregressive generation, rendering existing methods less effective for real-time recommendation. As such, we propose a two-stage framework using large language models for ranking-based recommendation (LlamaRec). In particular, we use small-scale sequential recommenders to retrieve candidates based on the user interaction history. Then, both history and retrieved items are fed to the LLM in text via a carefully designed prompt template. Instead of generating next-item titles, we adopt a verbalizer-based approach that transforms output logits into probability distributions over the candidate items. Therefore, the proposed LlamaRec can efficiently rank items without generating long text. To validate the effectiveness of the proposed framework, we compare against state-of-the-art baseline methods on benchmark datasets. Our experimental results demonstrate the performance of LlamaRec, which consistently achieves superior performance in both recommendation performance and efficiency.

Motivation & Objective

  • Motivate use of LLMs for recommendation while addressing real-time inference constraints.
  • Propose a two-stage framework combining retrieval and LLM-based ranking.
  • Show that a verbalizer enables fast, single-pass scoring without autoregressive generation.

Proposed method

  • Use LRURec as the retrieval module to produce top-k candidate items from user history.
  • Construct a text-based input for an Llama 2 ranker using an instruction template with history and candidate titles.
  • Apply a verbalizer to map LLM head logits over candidate index letters to ranking scores without generating long text.
  • Fine-tune the Llama 2 ranker with instruction tuning on the response part of the prompt using QLoRA quantization.
  • Train to maximize the ground-truth item score via next-token-like loss on label tokens (index letters and EOS).
  • Limit input length and candidates to top-20 each, with a max history of 20 items for efficiency.

Experimental results

Research questions

  • RQ1Can a two-stage framework improve both retrieval and ranking performance in LLM-based recommendations?
  • RQ2Does a verbalizer-based ranking approach offer efficiency gains over generation-based ranking in LLMs?
  • RQ3How does LlamaRec perform against state-of-the-art baselines on standard sequential recommendation benchmarks?

Key findings

  • LlamaRec outperforms baseline methods on multiple datasets across metrics such as MRR, NDCG, and Recall.
  • The biggest gains are on ML-100k, with notable improvements in MRR@5, NDCG@5, and Recall@5.
  • Within the valid retrieval subset, LlamaRec shows larger absolute gains than in full evaluation, indicating effective ranking of truly relevant items.
  • Compared to other LLM-based baselines on Beauty, LlamaRec achieves substantial performance gains (average around 14.31% across metrics).
  • The verbalizer approach dramatically improves inference efficiency, enabling a single forward pass to score all candidates, versus generation-based methods that require long decoding times.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.