Hard Negative Sampling via Large Language Models for Recommendation

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

Here is a concise, engaging summary of the research paper.

TL;DR

HNLMRec introduces a generative framework that leverages Large Language Models (LLMs) to create high-quality "hard negative" samples for recommender systems. By explicitly bridging the gap between semantic similarity and user behavior via contrastive supervised fine-tuning, it eliminates false negatives and significantly boosts recommendation accuracy, especially for sparse data and long-tail items.

What Problem Does This Paper Address?

To train effective recommender systems, models need to know not just what users like (positive samples), but also what they don't like (negative samples). "Hard negative sampling" focuses on finding unobserved items that are highly challenging for the model, which helps sharpen the decision boundary and accelerate training convergence.

However, traditional methods select these negatives from a fixed pool using purely ID-based, heuristic rules. Because they lack semantic awareness, they frequently misclassify items that align with a user's actual interests as negatives—a problem known as False Hard Negative Samples (FHNS).

While LLMs possess deep world knowledge that could theoretically solve this, simply plugging them in introduces a Semantic-Behavioral Gap. For example, an LLM might view an iPhone 13 and an iPhone 14 as a "hard negative" pair due to high text similarity, ignoring the fact that a user owning an iPhone 13 is highly likely to want an iPhone 14. Naive prompting causes the LLM to fall into the false negative trap, injecting noise that can degrade recommendation performance.

Methods

The authors propose HNLMRec (Hard Negative sampling via Language Model for Recommendation) to achieve Collaborative-Semantic Alignment. The framework operates in three main phases:

  1. Profile Generation: The LLM summarizes raw item attributes (titles, descriptions, reviews) and user histories into clean text profiles.
  2. Generative Hard Negative Sampling: The LLM is prompted to explore the semantic manifold and generate candidates that are semantically close to the user's preferences but behaviorally irrelevant.
  3. Semantic Manifold Alignment & Fine-Tuning: To stop the LLM from hallucinating and to bridge the gap between the LLM's high-dimensional semantic space and the recommender's collaborative space, the authors introduce a contrastive supervised fine-tuning (SFT) mechanism using LoRA. They use hard negatives mined from a traditional collaborative filtering (CF) model as "labels" to guide the LLM via an InfoNCE loss.

To avoid massive latency during live recommendations, HNLMRec synthesizes these negatives directly in the embedding space offline, caching them for efficient downstream training.

Figure 2: The overall pipeline of LLM-driven semantic negative sampling enhancing graph CF consists of three main components: user-item profile generation, semantic negative sampling, and semantic alignment & training

Datasets

The framework was evaluated on four real-world datasets:

  • Toys & Games (Amazon)
  • CDs & Vinyl (Amazon)
  • Yelp2018
  • Amazon Electronics (Used strictly as a held-out benchmark to test the model's zero-shot generalization capabilities).

Key Insights and Ideas

  • The Semantic-Behavioral Gap is Real: Items with high linguistic similarity often exhibit high behavioral correlation. Without grounding LLMs in collaborative signals, naive prompting hurts more than it helps.
  • Alignment Trumps Scale: In the ablation studies, simply scaling up the LLM (from Qwen 0.5B to 72B or ChatGPT-3.5) without alignment yielded unstable and limited performance gains. However, adding the contrastive alignment module allowed a medium-sized model (like Llama3-8B) to achieve superior, stable results.
  • Mitigating Popularity Bias: Traditional CF models over-recommend popular items because they lack semantic context. HNLMRec excels at mining high-quality negatives for unpopular, long-tail items, significantly improving fairness and diversity.
Figure 1: False negative reduction (a) and cross-dataset performance comparison (b).

Key Results

HNLMRec was paired with multiple backbone architectures (Matrix Factorization, LightGCN, and NGCF) and consistently outperformed state-of-the-art ID-based samplers (like MixGCF and AHNS) as well as other LLM-enhanced baselines:

  • Accuracy Boost: Under a LightGCN backbone, HNLMRec improved NDCG@10 by 7.89% on the Toys & Games dataset and 7.91% on CDs & Vinyl compared to the strongest baseline (AlphaRec).
  • Robustness to Sparsity: When training data was cut down to 40%, HNLMRec maintained a clear performance edge, proving that semantic priors can compensate for missing interaction data.
  • Zero-Shot Generalization: When the model fine-tuned on the other datasets was evaluated directly on the unseen Amazon Electronics dataset, it still significantly outperformed all baselines, demonstrating powerful cross-domain adaptability.

Limitations and Future Work

Despite its strong performance, the authors note a few limitations:

  • Training Overhead: The contrastive fine-tuning stage and the synthesis module introduce additional computational costs during the offline phase.
  • Dependence on Text Quality: The framework's efficacy relies heavily on the richness and quality of the item text and user review profiles.
  • Offline Evaluation: The current study focuses entirely on offline benchmarks. Validating HNLMRec in a fully online, real-time production environment remains an open direction for future research.

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