Hard Negative Sampling via Large Language Models for Recommendation

Chu Zhao, Enneng Yang, Yuting Liu, Jianzhe Zhao, Guibing Guo · DOI

Abstract

Hard negative sampling improves recommendation performance by accelerating convergence and sharpening the decision boundary. However, most existing methods rely on heuristic strategies, selecting negatives from a fixed candidate pool. Lacking semantic awareness, these methods often misclassify items that align with users' semantic interests as negatives, resulting in False Hard Negative Samples (FHNS). Such FHNS inject noisy supervision and hinder the model's optimal performance. To address this challenge, we propose HNLMRec, a generative semantic negative sampling framework. Leveraging the semantic reasoning capabilities of Large Language Models (LLMs), HNLMRec directly generates negative samples that are behaviorally distinct yet semantically relevant with respect to user preferences. Furthermore, we integrate collaborative filtering signals into the LLM via supervised fine-tuning, guiding the model to synthesize more reliable and informative hard negatives. Extensive experiments on multiple real-world datasets demonstrate that HNLMRec significantly outperforms traditional methods and LLM-enhanced baselines, while effectively mitigating popularity bias and data sparsity, thereby improving generalization.

Introduction

Modern recommender systems utilize contrastive learning to distinguish between items a user likes (positives) and those they do not (negatives). To achieve high precision, models require "hard negatives"—items that are semantically similar to a user's interests but were not interacted with. However, traditional ID-based graph heuristics often fail to distinguish between a truly negative item and a "False Hard Negative Sample" (FHNS): an item the user would likely enjoy but has not yet encountered. Penalizing the model for these false negatives introduces noise, degrading overall performance.

While Large Language Models (LLMs) offer deep semantic understanding, a "Semantic-Behavioral Gap" exists. For instance, an LLM might view two successive phone models as highly similar (a hard pair), whereas in a recommendation context, a user purchasing one often makes the other a behavioral negative. Naive LLM prompting conflates these two spaces, leading to poor negative sampling.

Methodology: The HNLMRec Framework

To bridge this gap, we introduce HNLMRec (Hard Negative sampling via Language Model for Recommendation). This framework integrates LLM semantic knowledge with Collaborative Filtering (CF) signals through a multi-stage process.

The HNLMRec framework architecture, illustrating profile generation, semantic negative sampling, and joint training with alignment.
  1. Profile Generation: The LLM constructs detailed text profiles for users and items based on interaction histories and metadata.
  2. Contrastive Supervised Fine-Tuning (SFT): Using LoRA, the LLM is fine-tuned to generate negative representations. By using "Collaborative Labels" mined from traditional CF models, the LLM learns to distinguish semantic similarity from behavioral relevance.
  3. Semantic Manifold Alignment: A learnable neural network projects LLM-generated embeddings into the CF model's latent space. An InfoNCE loss ensures these generated negatives respect the structural boundaries of the recommendation graph.
  4. Offline Synthesis: To maintain efficiency, hard negative embeddings are synthesized offline. During training, the CF model performs a constant-time lookup, avoiding the latency of real-time LLM inference.

Experimental Results

We evaluated HNLMRec across four real-world datasets: Amazon Toys & Games, CDs & Vinyl, Electronics, and Yelp2018.

Comparison of (a) False Negative Ratio across training epochs and (b) NDCG@20 performance for HNLMRec against baselines.

Performance and Reliability

HNLMRec consistently achieves state-of-the-art results. When using LightGCN as a backbone, we observed NDCG@20 improvements of 7.89% on Toys & Games and 7.91% on CDs & Vinyl. Crucially, as shown in the experimental analysis, HNLMRec rapidly reduces the False Negative Ratio to near zero, significantly outperforming heuristic methods like AHNS and MixGCF. This confirms that our alignment strategy effectively filters out noisy supervision.

Robustness and Generalization

The framework demonstrates remarkable resilience to data sparsity. By leveraging the LLM's semantic priors, HNLMRec provides high-quality negative signals even when collaborative data is limited. Furthermore, the model effectively mitigates popularity bias, showing the most significant gains on long-tail items. In zero-shot tests on the Amazon Electronics dataset, HNLMRec maintained its lead over baselines, proving that the learned semantic-behavioral alignment generalizes across different domains.

Conclusion

HNLMRec addresses the fundamental challenge of False Hard Negative Samples by combining the generative power of LLMs with structural collaborative signals. By explicitly bridging the Semantic-Behavioral Gap, the framework provides a robust, scalable, and high-performance solution for modern recommendation tasks.

Summary updated

BibTeX
@misc{zhao2025hard,
  author = {Chu Zhao and Enneng Yang and Yuting Liu and Jianzhe Zhao and Guibing Guo},
  title = {{Hard Negative Sampling via Large Language Models for Recommendation}},
  year = {2025},
  eprint = {2504.04726},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.04726},
}
Figure