A Constraint-Aware Knowledge Graph RAG Framework for Personalized Food Recommendation
Abstract
To address the issues of knowledge hallucination, insufficient constraint satisfaction, and opaque recommendation rationale in Large Language Models (LLMs) during food recommendation tasks, this paper proposes a personalized food recommendation method based on Constraint-Aware Knowledge Graph Retrieval-Augmented Generation (RAG). First, the method performs intent recognition and constraint extraction on users' natural language requirements, transforming meal types, calorie limits, nutritional goals, allergy contraindications, and user preferences into structured query conditions. Subsequently, it retrieves relevant candidate dishes, ingredients, and nutritional subgraphs within the food knowledge graph. On this basis, a recommendation ranking function is designed, incorporating constraint matching, nutritional balance, user preferences, graph path relevance, and risk penalties. Finally, the ranked results and evidence subgraphs are input into the LLM as retrieval-augmented context to generate interpretable meal suggestions. Experimental results show that, compared with existing methods, the proposed method achieves superior performance in recommendation accuracy, constraint satisfaction rate, and response faithfulness. Furthermore, sensitivity analyses, performance evaluations and case studies provide further evidence that constraint-aware knowledge graph RAG can significantly enhance the reliability and explainability of food recommendation.