Table of Contents
Fetching ...

SLMRec: Distilling Large Language Models into Small for Sequential Recommendation

Wujiang Xu, Qitian Wu, Zujie Liang, Jiaojiao Han, Xuying Ning, Yunxiao Shi, Wenfang Lin, Yongfeng Zhang

TL;DR

This paper questions the necessity of large language models for sequential recommendation by showing that many intermediate LLM layers are redundant. It introduces SLMRec, a knowledge-distilled small language model that aligns a shallow student to a deeper teacher via layer-block feature regularizers and multiple supervision signals. On four large-scale Amazon-domain datasets, SLMRec with only about 13% of the teacher parameters matches or surpasses larger LLM-based baselines while delivering up to 6.6x training and 8x inference speedups, and remains compatible with quantization and pruning. Theoretical analysis explains why multi-layer attention can be compressed to a single-layer representation without losing denoising capability, supporting the distillation approach and suggesting a practical path for efficient LLM-based SR.

Abstract

Sequential Recommendation (SR) task involves predicting the next item a user is likely to interact with, given their past interactions. The SR models examine the sequence of a user's actions to discern more complex behavioral patterns and temporal dynamics. Recent research demonstrates the great impact of LLMs on sequential recommendation systems, either viewing sequential recommendation as language modeling or serving as the backbone for user representation. Although these methods deliver outstanding performance, there is scant evidence of the necessity of a large language model and how large the language model is needed, especially in the sequential recommendation scene. Meanwhile, due to the huge size of LLMs, it is inefficient and impractical to apply a LLM-based model in real-world platforms that often need to process billions of traffic logs daily. In this paper, we explore the influence of LLMs' depth by conducting extensive experiments on large-scale industry datasets. Surprisingly, our motivational experiments reveal that most intermediate layers of LLMs are redundant, indicating that pruning the remaining layers can still maintain strong performance. Motivated by this insight, we empower small language models for SR, namely SLMRec, which adopt a simple yet effective knowledge distillation method. Moreover, SLMRec is orthogonal to other post-training efficiency techniques, such as quantization and pruning, so that they can be leveraged in combination. Comprehensive experimental results illustrate that the proposed SLMRec model attains the best performance using only 13% of the parameters found in LLM-based recommendation models while simultaneously achieving up to 6.6x and 8.0x speedups in training and inference time costs, respectively. Besides, we provide a theoretical justification for why small language models can perform comparably to large language models in SR.

SLMRec: Distilling Large Language Models into Small for Sequential Recommendation

TL;DR

This paper questions the necessity of large language models for sequential recommendation by showing that many intermediate LLM layers are redundant. It introduces SLMRec, a knowledge-distilled small language model that aligns a shallow student to a deeper teacher via layer-block feature regularizers and multiple supervision signals. On four large-scale Amazon-domain datasets, SLMRec with only about 13% of the teacher parameters matches or surpasses larger LLM-based baselines while delivering up to 6.6x training and 8x inference speedups, and remains compatible with quantization and pruning. Theoretical analysis explains why multi-layer attention can be compressed to a single-layer representation without losing denoising capability, supporting the distillation approach and suggesting a practical path for efficient LLM-based SR.

Abstract

Sequential Recommendation (SR) task involves predicting the next item a user is likely to interact with, given their past interactions. The SR models examine the sequence of a user's actions to discern more complex behavioral patterns and temporal dynamics. Recent research demonstrates the great impact of LLMs on sequential recommendation systems, either viewing sequential recommendation as language modeling or serving as the backbone for user representation. Although these methods deliver outstanding performance, there is scant evidence of the necessity of a large language model and how large the language model is needed, especially in the sequential recommendation scene. Meanwhile, due to the huge size of LLMs, it is inefficient and impractical to apply a LLM-based model in real-world platforms that often need to process billions of traffic logs daily. In this paper, we explore the influence of LLMs' depth by conducting extensive experiments on large-scale industry datasets. Surprisingly, our motivational experiments reveal that most intermediate layers of LLMs are redundant, indicating that pruning the remaining layers can still maintain strong performance. Motivated by this insight, we empower small language models for SR, namely SLMRec, which adopt a simple yet effective knowledge distillation method. Moreover, SLMRec is orthogonal to other post-training efficiency techniques, such as quantization and pruning, so that they can be leveraged in combination. Comprehensive experimental results illustrate that the proposed SLMRec model attains the best performance using only 13% of the parameters found in LLM-based recommendation models while simultaneously achieving up to 6.6x and 8.0x speedups in training and inference time costs, respectively. Besides, we provide a theoretical justification for why small language models can perform comparably to large language models in SR.
Paper Structure (24 sections, 2 theorems, 19 equations, 5 figures, 9 tables)

This paper contains 24 sections, 2 theorems, 19 equations, 5 figures, 9 tables.

Key Result

Proposition 1

Given the updating matrix $\hat{\mathbf{A}}^{(k)} = \mathbf A^{(k)} + \mathbf I$, Eqn. eqn-attn-update is equivalent to a gradient descent step with respect to the following optimization problem:

Figures (5)

  • Figure 1: This overview compares traditional sequential recommendation (TSR) methods with LLM-based recommendation (LLMRec) methods. Here, $h_u$ and $h_i$ represent the user and item representations, respectively. In contrast to G-LLMRec methods, E-LLMRec approaches adhere to the TSR prediction framework. These methods leverage LLMs as feature extractors in the manner of BERT, diverging from the generative focus of G-LLMRec.
  • Figure 2: We present the relationship between the number of decoder layers and the final recommendation performance, with the performance of SASRec plotted as a baseline. Figures (a)-(c) show the results of directly using representations from the middle layers for inference without training, while (d)-(f) prune the later layers and train a model using only the specified number of layers. From the results, we observe that deeper decoder layers introduce redundancy in recommendation tasks, with models utilizing fewer layers (8-layer) achieving performance nearly equivalent to (24-layer) models.
  • Figure 3: The overview of $\textsc{SLMRec}\xspace$. A layer-wise knowledge distillation approach is applied to align the representation knowledge by grouping the layer into serveral blocks. The teacher and student model share a similar E-LLMRec model architecture. Multiple supervision signals are introduced to steer the student model toward acquiring fine-grained task-aware knowledge.
  • Figure 4: Experiment results (%) of online KD and block number $B$ in the Cloth dataset.
  • Figure 5: We present the relationship between the number of decoder layers and the final recommendation performance, with the performance of SASRec plotted as a baseline. Figures (a)-(c) show the results of directly using representations from the middle layers for inference without training, while (d)-(f) prune the later layers and train a model using only the specified number of layers. From the results, we observe that deeper decoder layers introduce redundancy in recommendation tasks, with models utilizing fewer layers (8-layer) achieving performance nearly equivalent to (24-layer) models.

Theorems & Definitions (4)

  • Proposition 1
  • Proposition 2
  • proof
  • proof