作者
Sheng-Han Yueh,Karin Bergling,Len A. Usvyat,Peter Kotanko,Hanjie Zhang
摘要
Abstract Background and Aims Dietary planning for dialysis patients often relies on time-consuming manual processes. We explore the use of Retrieval-Augmented Generation (RAG) combined with models from OpenAI to enhance recipe recommendations. RAG is an efficient approach to enhance background knowledge of a base language model without retraining, thereby saving time and cost. By integrating a curated database of kidney-friendly recipes into a RAG pipeline, the system retrieves relevant recipes and provides personalized recommendations tailored to user queries. This approach harnesses RAG and OpenAI’s generative AI capabilities to deliver accurate, scalable, and user-friendly dietary management tools. Method We collected 322 kidney-friendly recipes sourced from the website of a large dialysis organization (https://www.freseniuskidneycare.com/recipes-and-nutrition/recipes). Each recipe was formatted into a structured text representation, including fields such as recipe name, description, ingredients, directions, nutrition information, serving size, time for preparation, and reference URL. These structured texts were embedded using a pre-trained model from OpenAI and stored in a vector database (Fig 1). For each query, the Facebook AI Similarity Search (FAISS) method retrieves the 10 most relevant recipes by identifying those with the smallest Euclidean distance to the query vector. These retrieved recipes are then incorporated into the prompt, enabling the response generation to be highly specific and evidence based. Results We tested multiple queries, such as: “Provide three chicken-based dinner recipes under 500 calories, with less than 250 mg of sodium per serving, and high in protein. As you know, I am allergic to paprika”. All 10 retrieved documents align with the requirement of chicken-based recipes (Table 1). The retrieved documents were integrated into the prompt for the GPT-4o model, which then generated a response tailored to the query. The response (Fig. 2) provided key details such as nutrients, ingredients, and serving sizes, while highlighting deviations and suggesting ingredient adjustments for better alignment with the criteria. However, during retrieval phase, several recipes, including “Braised Paprika Chicken” (similarity score: 0.7317) and “Paprika Chicken Thighs with Brussels Sprouts” (0.7166), include paprika, directly contradicting the specified exclusion due to an allergy. This highlights the challenges of accurately interpreting and applying negative constraints. During the generation phase, the GPT-4o model re-evaluate the “Query + Retrieval recipes”, strictly enforcing the exclusion of paprika, ensuring adherence to the hard constraint specified in the query, the final output recipes did not contain paprika. Conclusion The results demonstrate the combined strengths of RAG and GPT-4o in providing a more flexible and adaptive solution for recipe recommendations. RAG efficiently retrieves relevant recipes, while GPT-4o enhances the process by addressing nutrient restrictions and allergy constraints. Despite some challenges in enforcing negative constraints during retrieval, such as excluding paprika-containing recipes, GPT-4o successfully refines the output by highlighting discrepancies, suggesting modifications, and adhering to strict requirements. This integration showcases a versatile approach to personalized recipe design, accommodating dietary needs and preferences effectively.