LLMEmb: Large Language Model Can Be a Good Embedding Generator for Sequential Recommendation

Qidong Liu, Xian Wu, Wanyu Wang, Yejing Wang, Yuanshao Zhu, Feng Tian, Yefeng Zheng

Introduction

Sequential Recommender Systems (SRS) are designed to predict a user’s future interactions based on their historical behavior. While effective for popular items, these systems frequently struggle with the "long-tail" problem, where the vast majority of items have sparse interaction data. Traditional models rely on item IDs to learn embeddings from scratch; consequently, niche or unpopular items often receive poorly defined representations, leading to suboptimal recommendations.

To address this, researchers have turned to Large Language Models (LLMs) to capture item semantics from textual metadata (e.g., titles and descriptions). However, a significant "semantic gap" exists between general-purpose language understanding and the collaborative signals required for recommendation. This paper introduces LLMEmb, a framework that bridges this gap by transforming LLMs into high-quality embedding generators for SRS without increasing inference latency.

The Long-Tail Challenge

The core issue in SRS is the disparity in item popularity. Traditional models like SASRec exhibit high performance on popular items but fail significantly on the long-tail. Furthermore, t-SNE visualizations reveal that traditional ID-based embeddings often lack discriminative power, clumping together in ways that obscure item-specific nuances. LLMEmb addresses this by generating more uniform and semantically rich embeddings.

Figure 1: (a) The long-tail problem in SASRec, where performance drops for less frequent items. (b-c) t-SNE visualization comparing SASRec ID embeddings with LLM-based semantic embeddings.

Methodology: The LLMEmb Framework

LLMEmb employs a two-stage process to align textual semantics with collaborative user behavior.

1. Supervised Contrastive Fine-Tuning (SCFT)

In the first stage, an open-source LLM (LLaMA-7B) is fine-tuned to become "recommendation-aware." The authors utilize attribute-level data augmentation, where an item's description is decomposed into multiple attributes (e.g., name, category, type). By randomly dropping attributes to create two augmented versions of the same item, the model is trained via contrastive loss to ensure their embeddings are similar to each other and distinct from other items. This process encourages the LLM to focus on fine-grained, discriminative features.

2. Recommendation Adaptation Training (RAT)

The second stage aligns the high-dimensional LLM outputs with the specific requirements of a recommendation backbone.

  • Dimensionality Reduction: PCA is used for initial compression, followed by a trainable two-layer MLP Adapter that shrinks the embedding to a standard size (e.g., 128 dimensions).
  • Collaborative Alignment: To preserve the LLM's semantic knowledge, the LLM remains frozen during this stage. The Adapter is trained using a contrastive alignment loss against a pre-trained traditional SRS model, effectively injecting "wisdom of the crowd" into the semantic embeddings.
Figure 2: The two-stage LLMEmb framework, featuring Supervised Contrastive Fine-Tuning (SCFT) and Recommendation Adaptation Training (RAT).

Crucially, during live inference, the LLM is not invoked. The embeddings are pre-computed and stored in the recommendation model’s embedding layer, ensuring that LLMEmb maintains the same speed as traditional ID-based models.

Key Insights and Results

Evaluations across three datasets (Yelp, Amazon Beauty, and Amazon Fashion) and three backbone models (SASRec, Bert4Rec, and GRU4Rec) demonstrate the effectiveness of LLMEmb:

  • Performance Gains: LLMEmb consistently outperforms state-of-the-art baselines. On the Yelp dataset, it improved the Hit Rate (H@10) for tail items from 0.1142 to 0.2951—a massive jump highlighting its ability to rescue unpopular items.
  • The "Seesaw" Effect: While long-tail performance sees massive improvements, there is a slight performance dip for extremely popular items, suggesting a trade-off between semantic diversity and popularity bias.
  • Frozen LLM Advantage: Experiments showed that updating LLM weights during the recommendation phase (RAT) actually degrades performance. Keeping the LLM frozen preserves the rich semantic relationships essential for high-quality embeddings.

Conclusion

LLMEmb demonstrates that LLMs can serve as powerful, zero-overhead embedding generators for sequential recommendation. By effectively bridging the gap between text semantics and collaborative signals, it provides a robust solution to the long-tail problem, making high-quality recommendations accessible even for the most niche products in a catalog.

Summary updated

BibTeX
@inproceedings{liu2025llmemb,
  author = {Qidong Liu and Xian Wu and Wanyu Wang and Yejing Wang and Yuanshao Zhu and Xiangyu Zhao and Feng Tian and Yefeng Zheng},
  title = {{LLMEmb: Large Language Model Can Be a Good Embedding Generator for Sequential Recommendation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i11.33327},
}
Figure