Abstract
Large Language Models (LLMs) have shown promise in recommendation systems but suffer from hallucinations, knowledge cutoffs, and an inability to process structured relational data effectively. We present K-RagRec, a novel framework that integrates Knowledge Graphs (KGs) with LLMs through a retrieval-augmented generation approach. By employing "Hop-Field" semantic indexing and a popularity-selective retrieval strategy, K-RagRec aligns structured graph data with the LLM's semantic space. Experimental results across multiple benchmarks demonstrate that K-RagRec significantly reduces hallucinations by up to 93.1% and improves recommendation accuracy while maintaining low inference latency.
Introduction
While state-of-the-art LLMs like Llama-3 and GPT-4 possess vast general knowledge, their application in specialized recommendation tasks is hindered by three primary challenges:
- Hallucinations: Generating plausible but non-existent items (e.g., recommending "Godmother" instead of "The Godfather").
- Knowledge Cutoffs: Inability to recommend items released after the model's training data was frozen.
- Structural Blindness: Standard RAG methods often flatten relational data into text strings, losing the "structural magic" of Knowledge Graphs (e.g., the complex links between actors, genres, and directors).
Methodology
K-RagRec addresses these limitations through a five-step pipeline designed for efficiency and structural awareness:
- Hop-Field Semantic Indexing: Uses Graph Neural Networks (GNNs) to aggregate multi-hop neighborhood information, creating sub-graph representations that capture complex relational contexts rather than just single nodes.
- Popularity Selective Retrieval Policy: To optimize latency, the system only triggers retrieval for "long-tail" or less popular items, relying on the LLM's internal knowledge for well-known items. This balances performance with speed.
- Sub-graph Retrieval & Re-ranking: Relevant sub-graphs are retrieved from a vector database and re-ranked based on the user's specific query to ensure the most pertinent information is prioritized.
- Knowledge-Augmented Recommendation: Instead of text serialization, a GNN encoder and MLP projector translate graph data into "soft prompts"—mathematical vectors that the LLM processes directly as part of its input.
- Optimization: The framework keeps the LLM backbone frozen, training only the lightweight GNN and projector components, which significantly reduces computational costs.
Experimental Evaluation
The framework was evaluated on three major benchmarks: MovieLens-1M, MovieLens-20M, and Amazon Book, using Freebase as the external knowledge source.
Key Results
- Accuracy Boost: K-RagRec outperformed vanilla RAG and other graph-based baselines. On MovieLens-1M using Llama-2, it improved accuracy by 58.6% over the next best baseline.
- Hallucination Reduction: Qualitative analysis showed a 93.1% reduction in hallucinations compared to vanilla Llama-2.
- Efficiency: The popularity-selective policy ensures that inference is only ~0.1s slower than a standard LLM, making it 2x to 6x faster than existing KG-RAG methods.
- Generalization: The model demonstrated strong zero-shot performance, maintaining high accuracy when transferred from MovieLens-1M to the much larger MovieLens-20M or even the Amazon Book domain.
Conclusion
K-RagRec proves that direct vector alignment of structured knowledge is superior to text-based RAG for recommendations. By selectively retrieving information for unpopular items, it effectively balances the trade-off between accuracy and computational cost. Future work will explore scaling the framework to larger LLMs (70B+) and integrating diverse knowledge sources like Wikidata.
Summary updated