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

SLMRec demonstrates that the massive depth of Large Language Models (LLMs) is largely redundant for sequential recommendation tasks. By distilling a 7B-parameter LLM into a compact "Small Language Model" (SLM) using layer-wise knowledge distillation, the authors achieved state-of-the-art performance with only 13% of the parameters and an 8x speedup in inference.

The Deployment Tax of LLMs in Recommendation

Sequential Recommendation (SR) aims to predict a user's next interaction based on their history. While Large Language Models (LLMs) like Llama have recently set new performance benchmarks in SR—either by treating recommendation as language modeling or using the LLM as a backbone for user representation—they come with a massive "deployment tax."

Traditional vs LLM-based Recommendation Architectures

Real-world recommendation platforms often process billions of traffic logs daily, making it computationally infeasible to run a 7-billion-parameter model for every request. Furthermore, there has been little research into whether the extreme depth of these models is actually necessary for recommendation, or if we are simply using a sledgehammer to crack a nut. The authors set out to find the "Goldilocks" size for language models in the recommendation domain.

Motivational Experiments and the SLMRec Method

The researchers first conducted motivational experiments by evaluating the performance of an LLM-based recommender across different layer depths. They discovered a surprising plateau: models with fewer layers (e.g., 8 layers) performed nearly as well as, or sometimes better than, deeper models (e.g., 24 or 32 layers), suggesting significant architectural redundancy in the later layers.

Performance vs. Layer Number in Motivational Experiments

Based on this insight, they proposed SLMRec, which employs a student-teacher knowledge distillation framework to empower small language models:

  • Teacher Model: A deep, well-performing LLM-based recommender (e.g., 8 or 32 layers).
  • Student Model: A shallow, highly efficient SLM (e.g., 4 layers).
  • Layer-wise Distillation: Instead of just matching the final output logits, SLMRec aligns intermediate representations using three specific loss functions:
  • Feature Similarity: Uses cosine similarity to ensure the student's hidden states point in the same "semantic direction" as the teacher's.
  • Feature Norm Regularization: Minimizes the L2 distance to align the magnitude of the representations.
  • Multiple Supervision: Introduces task-specific supervision signals at various intermediate blocks to ensure the student learns recommendation-aware features early on.

The paper also provides a theoretical justification, proving that a multi-layer attention stack can be mathematically simplified into a single-layer model that achieves the same "denoising" effect on user representations.

Datasets

The authors evaluated their model on four large-scale categories from the Amazon 18 industry dataset:

  • Cloth (Clothing, Shoes, and Jewelry)
  • Movie (Movies and TV)
  • Music (Digital Music)
  • Sport (Sports and Outdoors)

These datasets represent diverse user behaviors and varying levels of data density, providing a robust benchmark for real-world performance.

Key Insights and Ideas

  • The Redundancy Reveal: Most intermediate layers in LLMs contribute very little to the final recommendation accuracy. Pruning the later layers of a 7B model often results in negligible performance drops.
  • Representation > Generation: For recommendation, the "generative" capabilities of LLMs (predicting the next token) are less important than their ability to extract high-quality user embeddings.
  • Alignment Matters: Simple knowledge distillation isn't enough. Aligning the direction and magnitude of features across layers is critical for a small model to replicate the "expressive power" of a large one.
  • Efficiency Gains: The transition from LLM to SLM isn't just a marginal improvement; it represents a paradigm shift in making transformer-based recommenders production-ready.

Key Results

  • Superior Performance: SLMRec (with only 4 layers) consistently outperformed traditional models (like SASRec) and even beat its own 8-layer teacher model in several metrics.
  • Massive Compression: The model achieves its results using only 13% of the parameters found in standard LLM-based recommendation baselines.
  • Speedups:
    • Training: Up to 6.6x faster than LLM-based methods.
  • Inference: Up to 8.0x faster, making it significantly more viable for real-time industrial deployment.
  • Ranking: In comparative testing across all datasets, SLMRec achieved the #1 average rank across metrics like Hit Rate (HR@10) and NDCG@10.

Limitations and Future Work

  • Few-Shot Generalization: While SLMRec is excellent at supervised tasks, it may lose some of the zero-shot or few-shot "emergent" capabilities that full-sized LLMs possess.
  • Retraining Requirements: Currently, the model requires retraining when new data arrives. The authors suggest incremental learning as a promising future direction to handle streaming data.
  • Multi-modal Integration: The current version focuses on ID and text sequences. Future work could involve incorporating visual or auxiliary linguistic information to further bolster the model's adaptability to new scenarios.

Summary updated

BibTeX
@inproceedings{xu2025slmrec,
  author = {Wujiang Xu and Qitian Wu and Zujie Liang and Jiaojiao Han and Xuying Ning and Yunxiao Shi and Wenfang Lin and Yongfeng Zhang},
  title = {{SLMRec: Distilling Large Language Models into Small for Sequential Recommendation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=G4wARwjF8M},
}
Figure