Semantic Retrieval Augmented Contrastive Learning for Sequential Recommendation

Ziqiang Cui, Yunpeng Weng, Xing Tang, Xiaokun Zhang, Shiwei Li, Peiyang Liu, Bowei He, Dugang Liu, Weihong Luo, xiuqiang He, Chen Ma

TL;DR

Semantic Retrieval Augmented Contrastive Learning (SRA-CL) leverages the reasoning power of Large Language Models (LLMs) to solve the "low-quality pair" problem in contrastive recommendation. By replacing random data perturbations with LLM-guided semantic retrieval and a learnable sample synthesizer, SRA-CL achieves state-of-the-art performance across multiple benchmarks without adding any latency to real-time inference.

What Problem Does This Paper Address?

Sequential recommendation models—which predict a user's next move based on their interaction history—often struggle with data sparsity. Because most users have very few interactions, it is difficult for models to learn robust and accurate representations.

To mitigate this, researchers frequently employ Contrastive Learning (CL). CL creates "augmented" versions of a user's history (e.g., by randomly masking or dropping an item) and teaches the model that these augmented versions should remain close in the embedding space. However, the authors identify two major flaws in current CL methods:

  1. Semantic Divergence: Randomly dropping an item might completely change the underlying "meaning" of a sequence. For example, removing the only running shoe from a sports-heavy history can lead the model to learn incorrect preference patterns.
  2. Unlearnability: Most existing methods use rigid, predefined rules to select similar users or items for contrastive pairs. These "hard rules" prevent the model from autonomously learning which samples are actually the most informative during training.

Methods

The authors introduce SRA-CL, a framework that uses LLMs to inject "common sense" and semantic depth into the contrastive learning process. The architecture consists of three main stages:

The overall architecture of SRA-CL, illustrating both inter-user and intra-user semantic retrieval augmented contrastive learning.

1. Semantic Understanding with LLMs

Instead of treating items as raw, meaningless IDs, the authors feed item attributes (name, brand, category) and user histories into an LLM.

  • For Users: The LLM summarizes the user's underlying preferences based on their interaction history.
  • For Items: The LLM summarizes the item's characteristics and its "typical audience" based on the context of users who interacted with it. These rich textual summaries are then converted into fixed vectors using a text embedding model (SimCSE-RoBERTa).

2. Semantic-Based Retrieval

Using these fixed semantic embeddings, the system builds "candidate pools" for contrastive learning:

  • Inter-user: Retrieves the top-$k$ users with the most similar semantic preference summaries.
  • Intra-user: Retrieves the top-$k$ items that are semantically similar to a given item in a user's sequence.

3. Learnable Sample Synthesis

This stage is the core innovation of SRA-CL. For inter-user CL, rather than simply picking the single most similar user, SRA-CL employs an attention-based Learnable Sample Synthesizer. It dynamically weights and combines the representations of users in the candidate pool to create an optimal, synthetic positive sample.

For intra-user CL, the model creates new views of a sequence by substituting items with their semantic neighbors from the pool. This ensures the core "meaning" of the sequence remains intact, avoiding the semantic divergence caused by random masking.

Crucially, SRA-CL is a "plug-and-play" module. It acts as an auxiliary loss during training but is completely discarded during inference, meaning the final recommender remains fast and lightweight.

Datasets

The authors evaluated SRA-CL on four widely used public datasets:

  • Yelp: Business and service reviews.
  • Amazon Sports: Sporting goods and apparel.
  • Amazon Beauty: Cosmetics and personal care.
  • Amazon Office: Office supplies and equipment.

All datasets were pre-processed to ensure users and items had at least five interactions, adhering to standard practices in the field.

Key Insights and Ideas

  • LLMs as Feature Extractors, Not Recommenders: Instead of asking an LLM to predict the next item (which is slow and computationally expensive), SRA-CL uses it to describe the data. This captures nuances that traditional ID-based collaborative filtering misses.
  • Contextual Item Similarity: By providing the LLM with "user sequences containing the item," the model learns that two items might be semantically similar not just because they share attributes, but because they serve the same type of audience.
  • Superiority in the "Long Tail": The paper notes that SRA-CL provides the most significant performance boosts for users with very short interaction histories (fewer than 7 items). This suggests that semantic information effectively "fills the gaps" where behavioral data is sparse.
  • Learnable vs. Fixed: Ablation studies show that the learnable synthesizer significantly outperforms methods that just pick the top-1 retrieved neighbor, proving that "soft" combinations of neighbors provide a more stable and informative training signal.

Key Results

SRA-CL was tested against 13 baselines, ranging from classical models (like SASRec) to recent LLM-enhanced methods (like RLMRec).

Performance improvements on the Yelp dataset when applying SRA-CL to various backbone models.
  • State-of-the-Art Performance: SRA-CL outperformed all baselines across all four datasets. For example, on the Sports dataset, it improved Hit Rate (HR@20) by 11.82% over the best baseline.
  • Model-Agnostic Gains: When added to existing backbones like GRU4Rec, SASRec, or DuoRec, SRA-CL consistently boosted their performance. As shown in the figure above, adding SRA-CL to DuoRec improved NDCG@20 by nearly 10% on the Yelp dataset.
  • Efficiency: Because the LLM summaries and embeddings are generated and cached offline, the training complexity remains comparable to standard ID-based contrastive models.

Limitations and Future Work

  • LLM Dependency: The quality of the retrieval heavily depends on the chosen LLM's reasoning capabilities. While the authors tested capable models, the impact of using smaller or highly specialized models remains an open question.
  • Fixed Sequence Length: The experiments were limited to a maximum sequence length of 20. Future work could explore how this semantic retrieval approach scales to much longer user histories.
  • Computational Cost of Pre-processing: While inference is fast, the initial step of calling LLM APIs to generate summaries for thousands of users and items can be time-consuming and potentially costly depending on the provider.

Summary updated

BibTeX
@inproceedings{cui2025semantic,
  author = {Ziqiang Cui and Yunpeng Weng and Xing Tang and Xiaokun Zhang and Shiwei Li and Peiyang Liu and Bowei He and Dugang Liu and Weihong Luo and xiuqiang He and Chen Ma},
  title = {{Semantic Retrieval Augmented Contrastive Learning for Sequential Recommendation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=9T6Pu6iWL6},
}
Figure