Intelligent canteen personalized nutritious food recommendation system and method based on AIGC
Through the smart canteen personalized nutritional meal recommendation system based on AIGC, using reinforcement learning model and nutrition relationship diagram, the problem of lack of personalization of traditional nutritional meal recommendation methods is solved, personalized nutritional meal recommendation is realized, and nutritional value is enhanced.
Patent Information
- Application Number
- CN202510059350.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-02-18
AI Technical Summary
The traditional nutritional meal recommendation method lacks personalization, which leads to the overall nutritional value of recommended nutritional meals not optimal for every user.
Using the smart canteen personalized nutritional meal recommendation system based on AIGC, the nutritional relationship diagram of food is constructed by obtaining user feature vectors, dish interaction sequences and food nutritional content information, and training using reinforcement learning model, search output based on Monte Carlo tree Recommended recipes for users, and finally match the food in the recipe with the dishes in the canteen menu that day to generate a nutritious meal.
It realizes personalized nutritional meal recommendations, ensuring that the recommended dishes meet users' eating habits and nutritional needs, and enhances the nutritional value of the overall diet.
Smart Images

Figure CN119480010A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a smart canteen personalized nutritious meal recommendation system and method based on AIGC. Background Art
[0002] The public is paying more and more attention to dietary health and hopes that canteens can provide scientific nutritional combinations. This requires canteens to tailor nutritious meals for users based on their characteristics and knowledge of nutrition, culinary science and other disciplines. However, the traditional method of manually designing nutritious menus is difficult to meet the efficiency requirements of large-scale personalized production. Therefore, it is urgent to use artificial intelligence technology to achieve industrial-scale intelligent nutritious meal generation.
[0003] A Chinese patent with publication number CN111128342A discloses an artificial intelligence dish pairing recommendation platform and a dish pairing customization method, which includes a user collection unit for users to log in and input multiple user features, an image generation unit connected to the user collection unit to generate a virtual portrait of the user according to the multiple user features, a dish database for storing multiple dishes, and a dish analysis unit connected to the dish database to analyze the nutritional components of each dish; a dish recommendation unit for recommending dishes to users and an image analysis unit connected to the image generation unit to analyze the virtual portrait to obtain the daily nutritional requirements of the user; the dish recommendation unit is respectively connected to the image analysis unit and the dish analysis unit to recommend a dish combination containing multiple dishes according to the daily nutritional requirements of the user.
[0004] The traditional method of recommending nutritious meals is based on established rules and nutrient requirements, and lacks personalized nutritional recommendations for individuals, resulting in the overall nutritional value of the recommended nutritious meals not being optimal for each user. Summary of the invention
[0005] The present application aims to solve at least one of the technical problems in the related art to a certain extent. To this end, one purpose of the present application is to propose a personalized nutritious meal recommendation system and method for a smart canteen based on AIGC, so as to realize personalized recommendation of nutritious meals.
[0006] One aspect of the present application provides a method for recommending personalized nutritious meals in a smart canteen based on AIGC, including: Step S100: Obtain user feature vectors, food nutrient vectors and attribute vectors, collect all dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; Step S200: constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector; Step S300: define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and output the recommended recipes to the user using the trained reinforcement learning model based on Monte Carlo tree search; Step S400: Match the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal.
[0007] The specific method of obtaining the user feature vector, the food nutrient vector and the attribute vector, collecting all dishes consumed by the user in the last k days and their corresponding timestamps, and forming a dish interaction sequence is as follows: Step S110: Collect user information of user u to form a user feature vector ; Step S120: Obtain The food constitutes a food set, and the nutritional information of each food is collected to form a nutritional vector; Step S130: Collect food attribute information to form an attribute vector ; Step S140: Collect all dishes consumed by user u in the last k days and their corresponding timestamps to form a dish interaction sequence .
[0008] The specific method of constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector is: Step S210: concatenate the nutrient component vector and attribute vector of each food as the attribute of the vertex, wherein the vertex represents a food, and edges are established between the vertices to obtain the vertex set V and edge set E of the nutritional relationship graph, and construct the nutritional relationship graph G(V,E); Step S220: Establishing a first indicator function according to the nutrient component vector , when satisfied When the first indicator function =1, otherwise =0, calculate the nutritional complementarity weights between foods based on the first indicator function and the nutritional component vector , when the nutritional complementarity weight between foods is not 0, the edge connecting the foods is a complementary edge, and the combination of foods constituting the complementary edge constitutes a complementary edge set; wherein, and are the nth nutrient component vectors of food i and food j respectively; Step S230: Establish the harmfulness between the nutritional component vectors of different foods , establish a second indicator function based on the harmfulness , when satisfied When , the second indicator function is equal to 1, otherwise it is equal to 0, and the nutritional mutual exclusivity weights between foods are calculated based on the second indicator function and the hazard , when the nutritional mutual exclusivity weight between foods is not 0, the edge connecting the foods is a mutually exclusive edge, and the combination of foods constituting the mutually exclusive edge constitutes a mutually exclusive edge set; Step S240: Calculate the cosine similarity between foods based on the nutritional component vectors as the nutritional similarity weight between foods .
[0009] The specific method of defining the state, action, and state transfer function of the reinforcement learning model and defining the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight is: Step S310: define a state space, where the states s of the state space include: the total amount of food nutrients ingested , Recommended recipes And the cafeteria menu for the day ; Step S320: defining an action space, wherein an action a in the action space is selecting a food from the food set as the next food to be added to the recommended recipe; Step S330: define a state transition function T(s, a), which means taking action a in state s, selecting food m from the food set, updating the recommended recipe, and the updated recommended recipe Includes recommended recipes and the added food m, and at the same time update the total nutritional value of the food consumed. The updated total nutritional value of the food consumed Total nutritional value of food consumed The sum of the nutrient content vectors of the added food m, according to the updated recommended recipe , on the canteen menu of the day Match available dish combinations , get the next state ; Step S340: Calculate the cumulative intake deficiency of nutrient n at the current time t based on all the dishes consumed by the user in the last k days, calculate the compensation amount of nutrient n in the recommended recipe at the current time t based on the recommended recipe, and define the nutrient compensation reward ; The specific method of defining nutrition compensation rewards is: Step S341: Based on the user's recent k-day dish interaction sequence, for the set of dishes consumed on the k-th day , query the nutritional composition table of the dish and calculate the intake of nutrient n on day ki The nutritional information table provides the content of the nutritional components n per 100 grams of edible portion of each dish. ; Step S342: The intake of nutrient component n on day k Recommended daily intake Compare and calculate the insufficient intake of nutrient component n on day k, accumulate the insufficient intake of nutrient component n in k days, and calculate the cumulative insufficient intake at the current time t; Step S343: Calculate the total supplement amount of nutrient n for the recommended recipe based on the nutritional composition table of each food in the recommended recipe, calculate the compensation amount of nutrient n for the recommended recipe at the current moment t based on the cumulative intake shortfall and the total supplement amount, and calculate the nutritional compensation reward for nutrient n for the recommended recipe at the current moment t based on the compensation amount and the daily recommended intake.
[0010] Step S350: Calculate food based on the recommended recipes for the last k days The food diversity reward at the current time t ; Step S360: Obtain the cumulative intake of each nutrient in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient, and define the nutritional balance reward between different nutrients ; The cumulative intake of each nutrient component in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient component are obtained, and the nutritional balance reward between different nutrients is defined The specific method is: Step S361: Obtain all foods in the recommended recipe and their corresponding weights; Step S362: Query the food nutrition table to obtain the nutritional information of each food Nutritional content and nutritional content The contents of and ; Step S363: Calculate the nutritional components of the recommended recipes and nutritional content Cumulative intake and ; Step S364: According to the nutritional ingredients and nutritional content The recommended daily intake, combined with the nutritional content of the recommended diet and nutritional content Cumulative intake of nutrients, defining and nutritional content Nutritional balance between rewards .
[0011] Step S370: Obtain the complementary edge set and the mutually exclusive edge set in the nutritional relationship graph, and define the nutritional complementarity reward of the food combination for the food combination whose nutritional complementarity weight is not 0 in the nutritional relationship graph. For food combinations whose nutritional mutual exclusivity weight is not 0 in the nutritional relationship diagram, define the nutritional mutual exclusivity penalty of the food combination ; Step S380: The result of weighted summation of nutrition compensation reward, food diversity reward, nutrition balance reward, nutrition complementarity reward, and nutrition mutual exclusion penalty is defined as reward function R(s,a).
[0012] The specific method of constructing and training a reinforcement learning model, and outputting a recommended recipe to a user using the trained reinforcement learning model based on a Monte Carlo tree search is as follows: Step S390: Select DQN as the reinforcement learning algorithm, construct a Q network, input data is state s and action a, output data is state-action value function Q(s,a), for each action a, the Q network outputs the estimated Q value that can be obtained by selecting the action under state s, and the model parameters are updated by minimizing the mean square error between the actual Q(s,a) and the estimated Q value to obtain a trained reinforcement learning model; Step S391: Perform a tree search based on the estimated Q value of the trained Q network from the food set, where each node represents a state s, and each edge represents selecting a food m as the next action a in this state; Step S392: Start searching from the root node, calculate the UCT value at each node, select the node with the highest UCT value as the optimal child node, and repeat the search until the leaf node; Step S393: Calculate the cumulative reward function value at the leaf node, and back-propagate to the path from the leaf node to the root node. For each node and corresponding action on the path, add 1 to its visit count, and update the average estimated Q value of each node and corresponding action. Step S394: Repeat the Monte Carlo tree search until the maximum search rounds are reached, starting from the root node, recursively select the node with the most visits as the child node, until the leaf node is reached, and the food corresponding to the nodes in the path from the root node to the leaf node constitutes the recommended recipe and outputs it.
[0013] The specific method of matching the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal is: Step S410: The food contained in the recommended recipe Food from the cafeteria menu that day Matching, when finding a satisfying When recommending dishes containing the food, the dishes containing the food will be recommended; Step S420: When the dishes containing the same food as the recommended recipe are sold out, calculate the food contained in the recommended recipe The nutritional similarity weights between the food and other foods in the nutritional relationship diagram will be Other foods whose nutritional similarity weights are greater than the similarity weight threshold are used as substitute foods m*. The corresponding other foods m* are sorted in descending order according to the nutritional similarity weights, and are sequentially compared with the foods on the canteen menu of the day. Matching is performed until a dish containing the same food ingredients is found as a substitute to generate a recommended nutritious meal.
[0014] One aspect of the present application provides a personalized nutritious meal recommendation system for a smart canteen based on AIGC, including: The user data acquisition module is used to obtain the user feature vector, the nutritional component vector and attribute vector of the food, collect all the dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; A nutrition relationship building module is used to build a nutrition relationship diagram of food according to the nutrition component vector and the attribute vector, and calculate the nutrition complementarity weight, nutrition mutual exclusivity weight and nutrition similarity weight of the edges connecting the foods in the nutrition relationship diagram based on the nutrition component vector; The recommended recipe output module is used to define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and output the recommended recipes to the user based on the Monte Carlo tree search using the trained reinforcement learning model; The nutritious meal recommendation module is used to match the food in the recommended recipes with the dishes on the canteen menu of the day to generate nutritious meals.
[0015] One aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for recommending personalized nutritious meals for a smart canteen based on AIGC are implemented.
[0016] One aspect of the present application provides a readable storage medium storing a computer program, wherein the computer program is suitable for loading by a processor to execute the steps in a method for recommending personalized nutritious meals for a smart canteen based on AIGC.
[0017] Compared with the prior art, the AIGC-based smart canteen personalized nutritious meal recommendation system and method proposed in this application have the following advantages: By obtaining the user's feature vector, dish interaction sequence and food nutritional information, this application can provide personalized nutrition recommendations for each user to ensure that the recommended dishes are in line with the user's eating habits and nutritional needs.
[0018] By constructing a nutritional relationship diagram of food, this application can analyze the complementarity, mutual exclusivity and similarity between different foods, so as to recommend more reasonable food combinations to users and improve the nutritional value of the overall diet.
[0019] This application defines nutritional compensation rewards, food diversity rewards, nutritional balance rewards, nutritional complementarity rewards, and nutritional exclusion penalties to learn the characteristics of users' historical food intake and their personalized needs from multiple perspectives. It also comprehensively considers the nutritional balance of users' intake and the complementary and exclusive effects between foods to ensure that the recommended recipes meet users' personalized needs.
[0020] This application can use a reinforcement learning model to automatically generate nutritionally balanced, customized recipes based on the user's user characteristics, previous dietary intake, and the food supply in the cafeteria that day, providing users with highly personalized healthy dietary guidance services. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A method flow chart of the AIGC-based smart canteen personalized nutritious meal recommendation method provided for this application; Figure 2 A flowchart of the method for constructing a reinforcement learning environment provided for this application; Figure 3 A flow chart of the method for generating recommended recipes provided for this application; Figure 4 Functional module diagram of the AIGC-based smart canteen personalized nutritious meal recommendation system provided for this application. DETAILED DESCRIPTION
[0022] In order to better understand the present application, various aspects of the present application will be described in more detail with reference to the accompanying drawings. It should be understood that these detailed descriptions are only descriptions of exemplary embodiments of the present application and do not limit the scope of the present application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.
[0023] In the accompanying drawings, the size, dimensions and shapes of the elements have been slightly adjusted for ease of illustration. The drawings are for illustration only and are not strictly drawn to scale. As used herein, the terms "substantially", "approximately" and similar terms are used as terms of approximation, not as terms of degree, and are intended to illustrate the inherent deviations in measurements or calculations that will be recognized by those of ordinary skill in the art. In addition, in this application, the order in which the steps are described does not necessarily represent the order in which these processes occur in actual operation, unless otherwise specified or can be derived from the context.
[0024] It should also be understood that expressions such as "including", "comprising", "having", "containing" and / or "comprising" are open rather than closed expressions in this specification, which indicate the presence of the stated features, elements and / or components, but do not exclude the presence of one or more other features, elements, components and / or combinations thereof. In addition, when expressions such as "at least one of..." appear after a list of listed features, they modify the entire list of features rather than just the individual elements in the list. In addition, when describing embodiments of the present application, "may" is used to mean "one or more embodiments of the present application". And, the term "exemplary" is intended to refer to an example or illustration.
[0025] Unless otherwise defined, all words (including engineering terms and scientific and technological terms) used in this article have the same meaning as those commonly understood by ordinary technicians in the field to which this application belongs. It should also be understood that unless there is a clear explanation in this application, words defined in commonly used dictionaries should be interpreted as having the same meaning as their meaning in the context of the relevant technology, and should not be interpreted in an idealized or overly formal sense.
[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] Example 1
[0028] like Figure 1 As shown, the AIGC-based smart canteen personalized nutritious meal recommendation method provided in this application includes: Step S100: Obtain user feature vectors, food nutrient vectors and attribute vectors, collect all dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; The specific method of obtaining the user feature vector, the food nutrient vector and the attribute vector, collecting all dishes consumed by the user in the last k days and their corresponding timestamps, and forming a dish interaction sequence is as follows: Step S110: Collect user information of user u to form a user feature vector ; The user information also includes: the user's height, weight, age, gender, activity level, taste preferences and dietary taboos; Step S120: Obtain The food constitutes a food set, and the nutritional information of each food is collected to form a nutritional vector; The nutritional information includes: the content of energy, protein, fat, carbohydrates, vitamins and minerals of each food; Step S130: Collect food attribute information to form an attribute vector ; The food attribute information includes: the cooking method, taste and flavor of the food; Step S140: Collect all dishes consumed by user u in the last k days and their corresponding timestamps to form a dish interaction sequence ; Preferably, k is equal to 7.
[0029] Step S200: constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector; The nutritional similarity weight refers to the similarity of the nutritional components of food i and food j. If the nutritional similarity weight of the nutritional components of food i and food j is high, it means that food i and food j can be replaced with each other. When food i is lacking in the smart canteen, food j can be used to replace it, ignoring other factors.
[0030] The nutritional complementarity weight measures the degree of synergy between the nutritional components of food i and food j in complementary promotion of absorption. The larger the nutritional complementarity weight, the more types of nutrients contained in food i and food j, and the closer the ratio of the content of the ingredients, the better the complementary promotion effect.
[0031] The nutritional mutual exclusivity weight measures the risk level of consuming the nutrients of food i and food j at the same time. The larger the nutritional mutual exclusivity weight, the higher the potential risk of consuming the nutrients contained in food i and food j at the same time.
[0032] The specific method of constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector is: Step S210: concatenate the nutrient component vector and attribute vector of each food as the attribute of the vertex, wherein the vertex represents a food, and edges are established between the vertices to obtain the vertex set V and edge set E of the nutritional relationship graph, and construct the nutritional relationship graph G(V,E); Step S220: Establishing a first indicator function according to the nutrient component vector , when satisfied When the first indicator function =1, otherwise =0, calculate the nutritional complementarity weights between foods based on the first indicator function and the nutritional component vector , when the nutritional complementarity weight between foods is not 0, the edge connecting the foods is a complementary edge, and the combination of foods constituting the complementary edge constitutes a complementary edge set; The calculation formula of the nutritional complementarity weight is: ,in, and are the nth nutrient component vectors of food i and food j respectively; Step S230: Establish the harmfulness between the nutritional component vectors of different foods , establish a second indicator function based on the harmfulness , when satisfied When , the second indicator function is equal to 1, otherwise it is equal to 0, and the nutritional mutual exclusivity weights between foods are calculated based on the second indicator function and the hazard , when the nutritional mutual exclusivity weight between foods is not 0, the edge connecting the foods is a mutually exclusive edge, and the combination of foods constituting the mutually exclusive edge constitutes a mutually exclusive edge set; Whether the harmfulness is greater than 0 is determined by those skilled in the art based on common knowledge in the field; The calculation formula of the nutritional mutual exclusivity weight is: ; Step S240: Calculate the cosine similarity between foods based on the nutritional component vectors as the nutritional similarity weight between foods ; The calculation formula of the nutritional similarity weight is: ,in, The mold length.
[0033] Step S300: define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and output the recommended recipes to the user using the trained reinforcement learning model based on Monte Carlo tree search; The specific method of defining the state, action, and state transfer function of the reinforcement learning model and defining the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight is: Step S310: define a state space, where the states s of the state space include: the total amount of food nutrients ingested , Recommended recipes And the cafeteria menu for the day ;
[0034] The total nutritional amount of the ingested food is the total nutritional amount of the food in the recommended recipe, which is obtained by accumulating the nutritional vectors of the corresponding food.
[0035] The recommended recipe refers to the food composition that is gradually added by taking action a in state s.
[0036] The canteen menu of the day refers to the dishes included in the canteen of the day and the related information of the food included in the dishes, which is obtained by matching at the current time t.
[0037] Step S320: defining an action space, wherein an action a in the action space is selecting a food from the food set as the next food to be added to the recommended recipe;
[0038] Step S330: define a state transition function T(s, a), which means taking action a in state s, selecting food m from the food set, updating the recommended recipe, and the updated recommended recipe Includes recommended recipes and the added food m, and at the same time update the total nutritional value of the food consumed. The updated total nutritional value of the food consumed Total nutritional value of food consumed The sum of the nutrient content vectors of the added food m, according to the updated recommended recipe , on the canteen menu of the day Match available dish combinations , get the next state ; Step S340: Calculate the cumulative intake deficiency of nutrient n at the current time t based on all the dishes consumed by the user in the last k days, calculate the compensation amount of nutrient n in the recommended recipe at the current time t based on the recommended recipe, and define the nutrient compensation reward ; The specific method of defining nutrition compensation rewards is: Step S341: Based on the user's recent k-day dish interaction sequence, for the set of dishes consumed on the k-th day , query the nutritional composition table of the dish and calculate the intake of nutrient n on day ki The nutritional information table provides the content of the nutritional components n per 100 grams of edible portion of each dish. ; The intake of the nutrient component n on the first day The calculation formula is: ,in, is the weight of dish b consumed by the user on day ki, is the total number of dishes containing nutrient n in the dishes consumed on day ki, b is a variable, indicating the number of dishes containing nutrient n, b∈{1,2,..., }; Step S342: The intake of nutrient component n on day k Recommended daily intake Compare and calculate the insufficient intake of nutrient component n on day k, accumulate the insufficient intake of nutrient component n in k days, and calculate the cumulative insufficient intake at the current time t; The calculation formula for the insufficient intake of the nutrient component n is: ; The calculation formula for the cumulative intake deficiency at the current time t is: ; Step S343: Calculate the total supplement amount of nutrient n of the recommended recipe according to the nutritional composition table of each food in the recommended recipe, calculate the compensation amount of nutrient n of the recommended recipe at the current moment t according to the cumulative intake deficiency and the total supplement amount, and calculate the nutritional compensation reward of nutrient n of the recommended recipe at the current moment t according to the compensation amount and the daily recommended intake; The total supplement amount is calculated as follows: ,in, Recommend the qth food in the recipe The weight, For every 100g of food The content of nutrient n in the recommended recipe, Q represents the total number of foods included in the recommended recipe, q∈{1,2,...,Q}; The calculation formula for the compensation amount of the recommended recipe for nutrient component n at the current time t is: ; The calculation formula for the nutrition compensation reward is: ,in, Indicates the operation of taking the positive part.
[0039] Step S350: Calculate food based on the recommended recipes for the last k days The food diversity reward at the current time t ; The food The calculation formula for the food diversity reward at the current time t is: ,in, Indicates the recommended diet for day ki. is the third indicator function, when it satisfies hour, Equal to 1, otherwise is equal to 0; Step S360: Obtain the cumulative intake of each nutrient in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient, and define the nutritional balance reward between different nutrients ; The cumulative intake of each nutrient component in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient component are obtained, and the nutritional balance reward between different nutrients is defined The specific method is: Step S361: Obtain all foods in the recommended recipe and their corresponding weights; Step S362: Query the food nutrition table to obtain the nutritional information of each food Nutritional content and nutritional content The contents of and ; Step S363: Calculate the nutritional components of the recommended recipes and nutritional content Cumulative intake and ; The nutritional ingredients The calculation formula for the cumulative intake is: ; The nutritional ingredients The calculation formula for the cumulative intake is: ; Step S364: According to the nutritional ingredients and nutritional content The recommended daily intake, combined with the nutritional content of the recommended diet and nutritional content Cumulative intake of nutrients, defining and nutritional content Nutritional balance between rewards ; The calculation formula for the nutritional balance reward is: ,in, , Nutritional components and nutritional content The recommended daily intake of The recommended daily intake is directly obtained from the standard table of recommended nutrient intakes.
[0040] Step S370: Obtain the complementary edge set and the mutually exclusive edge set in the nutritional relationship graph, and define the nutritional complementarity reward of the food combination for the food combination whose nutritional complementarity weight is not 0 in the nutritional relationship graph. For food combinations whose nutritional mutual exclusivity weight is not 0 in the nutritional relationship diagram, define the nutritional mutual exclusivity penalty of the food combination ; The calculation formula for the nutritional complementary reward is: ,in, For foods not included in the recommended recipes, is the set of complementary edges in the nutritional relationship graph, is the fourth indicator function, when it satisfies hour is equal to 1, otherwise it is equal to 0; The calculation formula of the nutrient mutual exclusion penalty is: ,in, is the set of mutually exclusive edges in the nutritional relationship graph, For foods with mutually exclusive edges and food , is the fifth indicator function, when it satisfies hour is equal to 1, otherwise it is equal to 0; Step S380: defining the result of weighted summation of nutrition compensation reward, food diversity reward, nutrition balance reward, nutrition complementarity reward, and nutrition mutual exclusion penalty as reward function R(s,a); The calculation formula of the reward function is: ,in, They are the weight coefficients of nutrition compensation reward, food diversity reward, nutrition balance reward, nutrition complementarity reward, and nutrition mutual exclusion penalty; The values of the weight coefficients of the nutrition compensation reward, food diversity reward, nutrition balance reward, nutrition complementarity reward, and nutrition mutual exclusion penalty are determined by those skilled in the art based on experience.
[0041] Figure 2 Flowchart of the method for constructing the reinforcement learning environment provided in this application.
[0042] The specific method of constructing and training a reinforcement learning model, and outputting a recommended recipe to a user using the trained reinforcement learning model based on a Monte Carlo tree search is as follows: Step S390: Select DQN as the reinforcement learning algorithm, construct a Q network, input data is state s and action a, output data is state-action value function Q(s,a), for each action a, the Q network outputs the estimated Q value that can be obtained by selecting the action under state s, and the model parameters are updated by minimizing the mean square error between the actual Q(s,a) and the estimated Q value to obtain a trained reinforcement learning model; The input of the reinforcement learning model is state s and action a, and the output is a recommended recipe generated according to the current state and action; The Q network uses a multi-layer perceptron MLP or a convolutional neural network CNN; Step S391: Perform a tree search based on the estimated Q value of the trained Q network from the food set, where each node represents a state s, and each edge represents selecting a food m as the next action a in this state; Step S392: Start searching from the root node, calculate the UCT value at each node, select the node with the highest UCT value as the optimal child node, and repeat the search until the leaf node; The calculation formula of the UCT value is: ,in, are state s and state-action pairs respectively. The total number of visits, C is the exploration coefficient;
[0043] The exploration coefficient is used to control the exploration breadth and is set by those skilled in the art according to actual needs.
[0044] Step S393: Calculate the cumulative reward function value at the leaf node, and back-propagate to the path from the leaf node to the root node. For each node and corresponding action on the path, add 1 to its visit count, and update the average estimated Q value of each node and corresponding action. Step S394: Repeat the Monte Carlo tree search until the maximum search rounds are reached, starting from the root node, recursively select the node with the most visits as the child node, until the leaf node is reached, and the food corresponding to the nodes in the path from the root node to the leaf node constitutes the recommended recipe and outputs it.
[0045] Figure 3 Flowchart of the method for generating recommended recipes provided in this application.
[0046] Through the training of reinforcement learning models, this application can continuously optimize the recommendation strategy, improve the accuracy and effectiveness of recommendations, and enable the recommendation system to remain efficient in the ever-changing user needs and food supply environment.
[0047] Step S400: matching the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal; The specific method of matching the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal is: Step S410: The food contained in the recommended recipe Food from the cafeteria menu that day Matching, when finding a satisfying When recommending dishes containing the food, the dishes containing the food will be recommended; Step S420: When the dishes containing the same food as the recommended recipe are sold out, calculate the food contained in the recommended recipe The nutritional similarity weights between the food and other foods in the nutritional relationship diagram will be Other foods whose nutritional similarity weights are greater than the similarity weight threshold are used as substitute foods m*. The corresponding other foods m* are sorted in descending order according to the nutritional similarity weights, and are sequentially compared with the foods on the canteen menu of the day. Matching is performed until a dish containing the same food ingredients is found as a substitute to generate a recommended nutritious meal.
[0048] The similarity weight threshold is set by those skilled in the art according to actual needs.
[0049] When certain dishes in the recommended recipes are sold out, this application can dynamically adjust the recommendations based on nutritional similarities and provide alternative foods, ensuring that users can always choose nutritionally balanced meals and reduce user churn due to insufficient supply.
[0050] Example 2
[0051] like Figure 4 As shown, the AIGC-based smart canteen personalized nutritious meal recommendation system provided by this application includes: The user data acquisition module is used to obtain the user feature vector, the nutritional component vector and attribute vector of the food, collect all the dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; Furthermore, the user feature vector is obtained by the user logging into the smart canteen App, and the AIGC-based smart canteen personalized nutritious meal recommendation system reads the user's various feature information from the user information database; Furthermore, the system queries the user's dining record database for the past week to obtain information on all dishes the user has eaten. Then, the system matches the nutritional content of each dish from the dish nutritional ingredient table and calculates the total amount of each nutrient intake by the user.
[0052] A nutrition relationship building module is used to build a nutrition relationship diagram of food according to the nutrition component vector and the attribute vector, and calculate the nutrition complementarity weight, nutrition mutual exclusivity weight and nutrition similarity weight of the edges connecting the foods in the nutrition relationship diagram based on the nutrition component vector; The recommended recipe output module is used to define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and output the recommended recipes to the user based on the Monte Carlo tree search using the trained reinforcement learning model; Furthermore, the system will multiply the detailed nutritional data of each dish matched by the actual amount consumed by the user, and then combine the content of similar nutrients of all dishes to obtain the total nutritional value of the food consumed so far; The nutritious meal recommendation module is used to match the food in the recommended recipes with the dishes on the canteen menu of the day to generate nutritious meals; Furthermore, the system obtains information about all dishes served today from the cafeteria menu database based on the current date, i.e., the “canteen menu for the day”; Furthermore, when the reinforcement learning model generates a recommended recipe for a user, the system creates an empty "recommended recipe" object, ready to generate and fill in the recipe; The three pieces of information, “total nutrition intake”, “recommended recipes”, and “canteen menu for the day”, are packaged as the input state S of the reinforcement learning model; Based on the Monte Carlo tree search algorithm, the system samples several alternative actions from the Q value distribution given by the policy network, then selects the optimal node by the maximum UCT value, and recursively searches the next layer until it reaches the leaf node. During the search process, the state transfer function is used to simulate the addition of food and continuously update the state. After the search is completed, the path from the root node to the leaf node with the most visits constitutes the food sequence contained in this recommended recipe;
[0053] Match the food sequence recommended by the Monte Carlo tree search algorithm with the actual canteen menu of the day to select the most operational food combination.
[0054] Furthermore, the generated personalized recipes are pushed to the user's smart canteen App and displayed to the user in a friendly manner.
[0055] Example 3
[0056] According to another aspect of the present application, an electronic device is also provided. The electronic device may include one or more processors and one or more memories. The memory stores a computer-readable code, and when the computer-readable code is executed by one or more processors, the method for recommending personalized nutritious meals for a smart canteen based on AIGC as described above can be executed.
[0057] The method or system according to the implementation of the present application can also be implemented with the help of the architecture of an electronic device. The electronic device may include a bus, one or more CPUs, a read-only memory (ROM), a random access memory (RAM), a communication port connected to a network, an input / output component, a hard disk, etc. A storage device in an electronic device, such as a ROM or a hard disk, can store the AIGC-based smart canteen personalized nutritious meal recommendation method provided in this application. The AIGC-based smart canteen personalized nutritious meal recommendation method may include, for example: obtaining user feature vectors, food nutrient vectors and attribute vectors, collecting all dishes consumed by the user in the last k days and their corresponding timestamps, and forming a dish interaction sequence; constructing a food nutritional relationship diagram based on the nutrient vector and attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutrient vector; defining the state, action, and state transition function of the reinforcement learning model, defining the reward function based on the dish interaction sequence, nutritional complementarity weight and nutritional mutual exclusivity weight, constructing and training the reinforcement learning model, and outputting the recommended recipes to the user based on the Monte Carlo tree search using the trained reinforcement learning model; matching the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal. Further, the electronic device may also include a user interface. Of course, when implementing different devices, one or more components in the electronic device may be omitted according to actual needs.
[0058] Example 4
[0059] According to one embodiment of the present application, a computer-readable storage medium is provided. Computer-readable instructions are stored on the computer-readable storage medium. When the computer-readable instructions are executed by the processor, the method for recommending personalized nutritious meals for smart canteens based on AIGC according to the embodiment of the present application can be executed. The storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory (cache). Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.
[0060] In addition, according to the implementation of the present application, the process described in the above method flow chart can be implemented as a computer software program. For example, the present application provides a non-transitory machine-readable storage medium, the non-transitory machine-readable storage medium stores machine-readable instructions, and the machine-readable instructions can be executed by a processor to execute instructions corresponding to the method steps provided in the present application, for example: obtaining a user feature vector, a nutrient vector and an attribute vector of a food, collecting all dishes consumed by the user in the last k days and their corresponding timestamps, and forming a dish interaction sequence; constructing a nutritional relationship diagram of the food according to the nutrient vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutrient vector; defining the state, action, and state transition function of the reinforcement learning model, defining a reward function based on the dish interaction sequence, nutritional complementarity weight and nutritional mutual exclusivity weight, constructing a reinforcement learning model and training it, and outputting a recommended recipe to the user based on a Monte Carlo tree search using the trained reinforcement learning model; matching the food in the recommended recipe with the dishes in the canteen menu of the day to generate a nutritious meal. When the computer program is executed by a central processing unit (CPU), the above functions defined in the method of the present application are performed.
[0061] The methods, apparatuses, and devices of the present application may be implemented in many ways. For example, the methods, apparatuses, and devices of the present application may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present application are not limited to the order specifically described above unless otherwise specified. In addition, in some embodiments, the present application may also be implemented as programs recorded in a recording medium, which include machine-readable instructions for implementing the method according to the present application. Therefore, the present application also covers recording media storing programs for executing the method according to the present application.
[0062] In addition, the parts of the above-mentioned technical solutions provided in the embodiments of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive redundancy.
[0063] The specific implementation modes as described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation mode of the present invention and is not intended to limit the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. The AIGC-based smart canteen personalized nutritious meal recommendation method is characterized by: include: Obtain user feature vectors, food nutrient vectors and attribute vectors, collect all dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; Constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector; Define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and use the trained reinforcement learning model to output recommended recipes to users based on Monte Carlo tree search; Match the foods in the recommended recipes with the dishes on the cafeteria menu that day to create a nutritious meal.
2. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 1, characterized in that: The specific method of obtaining the user feature vector, the food nutrient vector and the attribute vector, collecting all dishes consumed by the user in the last k days and their corresponding timestamps, and forming a dish interaction sequence is as follows: Collect user information of user u and form a user feature vector ; Get The food constitutes a food set, and the nutritional information of each food is collected to form a nutritional vector; Collect food attribute information to form an attribute vector ; Collect all dishes consumed by user u in the last k days and their corresponding timestamps to form a dish interaction sequence .
3. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 2, characterized in that: The specific method of constructing a nutritional relationship diagram of food according to the nutritional component vector and the attribute vector, and calculating the nutritional complementarity weight, nutritional mutual exclusivity weight and nutritional similarity weight of the edges connecting the foods in the nutritional relationship diagram based on the nutritional component vector is: The nutritional component vector and attribute vector of each food are concatenated as the attribute of the vertex. The vertex represents a food. Edges are established between vertices to obtain the vertex set V and edge set E of the nutritional relationship graph, and construct the nutritional relationship graph G(V,E); Establish the first indicator function based on the nutrient vector , when satisfied When the first indicator function =1, otherwise =0, calculate the nutritional complementarity weights between foods based on the first indicator function and the nutritional component vector , when the nutritional complementarity weight between foods is not 0, the edge connecting the foods is a complementary edge, and the combination of foods constituting the complementary edge constitutes a complementary edge set; wherein, and are the nth nutrient component vectors of food i and food j respectively; Establish the harmfulness between the nutritional components of different foods , establish a second indicator function based on the harmfulness , when satisfied When , the second indicator function is equal to 1, otherwise it is equal to 0, and the nutritional mutual exclusivity weights between foods are calculated based on the second indicator function and the hazard , when the nutritional mutual exclusivity weight between foods is not 0, the edge connecting the foods is a mutually exclusive edge, and the combination of foods constituting the mutually exclusive edge constitutes a mutually exclusive edge set; Calculate the cosine similarity between foods based on the nutritional composition vector as the nutritional similarity weight between foods .
4. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 3, characterized in that: The specific method of defining the state, action, and state transfer function of the reinforcement learning model and defining the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight is: Define a state space, where the states s of the state space include: the total amount of food nutrition consumed , Recommended recipes And the cafeteria menu for the day ; An action space is defined, where an action a in the action space is to select a food from the food set as the next food to be added to the recommended recipe; Define a state transition function T(s, a), which means taking action a in state s, selecting food m from the food set, updating the recommended recipe, and the updated recommended recipe Includes recommended recipes and the added food m, and at the same time update the total nutritional value of the food consumed. The updated total nutritional value of the food consumed Total nutritional value of food consumed The sum of the nutrient content vectors of the added food m, according to the updated recommended recipe , on the canteen menu of the day Match available dish combinations , get the next state ; Based on all the dishes consumed by the user in the last k days, calculate the cumulative intake deficiency of nutrient n at the current time t, calculate the compensation amount of the food in the recommended recipe at the current time t for nutrient n, and define the nutritional compensation reward ; Calculate food based on recommended recipes from the last k days The food diversity reward at the current time t ; Get the cumulative intake of each nutrient in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient, and define the nutritional balance reward between different nutrients ; Get the complementary edge set and the mutually exclusive edge set in the nutritional relationship graph. For the food combination whose nutritional complementarity weight is not 0 in the nutritional relationship graph, define the nutritional complementarity reward of the food combination For food combinations whose nutritional mutual exclusivity weight is not 0 in the nutritional relationship diagram, define the nutritional mutual exclusivity penalty of the food combination ; The reward function R(s,a) is defined as the weighted sum of nutrition compensation reward, food diversity reward, nutrition balance reward, nutrition complementarity reward, and nutrition mutual exclusion penalty.
5. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 4, characterized in that: The specific method of defining nutrition compensation rewards is: Based on the user's dish interaction sequence in the last k days, for the set of dishes consumed on the kth day , query the nutritional composition table of the dish and calculate the intake of nutrient n on day ki The nutritional information table provides the content of the nutritional components n per 100 grams of edible portion of each dish. ; The intake of nutrients n on day k Recommended daily intake Compare and calculate the insufficient intake of nutrient component n on day k, accumulate the insufficient intake of nutrient component n in days k, and calculate the cumulative insufficient intake at the current time t; According to the nutritional composition table of each food in the recommended recipe, calculate the total supplement amount of nutrient n from the recommended recipe. According to the cumulative intake deficiency and the total supplement amount at the current time t, calculate the compensation amount for nutrient n from the recommended recipe at the current time t. Calculate the nutritional compensation reward for nutrient n from the recommended recipe at the current time t based on the compensation amount and the daily recommended intake.
6. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 5, characterized in that: The cumulative intake of each nutrient component in the recommended recipe at the current time t and the daily recommended intake of the corresponding nutrient component are obtained, and the nutritional balance reward between different nutrients is defined The specific method is: Get all the food in the recommended recipe and their corresponding weight; Query the food nutrition information table to get the nutrition information of each food Nutritional content and nutritional content The contents of and ; Calculate the nutritional content of recommended recipes and nutritional content Cumulative intake and ; According to nutritional content and nutritional content The recommended daily intake, combined with the nutritional content of the recommended diet and nutritional content Cumulative intake of nutrients, defining and nutritional content Nutritional balance between rewards .
7. The AIGC-based smart canteen personalized nutritious meal recommendation method according to claim 6, characterized in that: The specific method of constructing and training a reinforcement learning model, and outputting a recommended recipe to a user using the trained reinforcement learning model based on a Monte Carlo tree search is as follows: Select DQN as the reinforcement learning algorithm, build a Q network, input data is state s and action a, output data is state-action value function Q(s,a), for each action a, Q network outputs the estimated Q value that can be obtained by selecting this action under state s, and updates the model parameters by minimizing the mean square error between the actual Q(s,a) and the estimated Q value to obtain a trained reinforcement learning model; Perform a tree search based on the estimated Q value of the trained Q network from the food set, where each node represents a state s and each edge represents selecting a food m as the next action a in this state; Start the search from the root node, calculate the UCT value at each node, select the node with the highest UCT value as the optimal child node, and repeat the search until the leaf node; Calculate the cumulative reward function value at the leaf node and back-propagate it to the path from the leaf node to the root node. For each node and corresponding action on the path, add 1 to its visit count and update the average estimated Q value of each node and corresponding action. Repeat the Monte Carlo tree search until the maximum search rounds are reached. Starting from the root node, recursively select the node with the most visits as the child node until a leaf node is reached. The food corresponding to the nodes in the path from the root node to the leaf node constitutes the recommended recipe and is output.
8. A smart canteen personalized nutritious meal recommendation system based on AIGC, which is implemented based on the smart canteen personalized nutritious meal recommendation method based on AIGC according to any one of claims 1 to 7, characterized in that: include: The user data acquisition module is used to obtain the user feature vector, the nutritional component vector and attribute vector of the food, collect all the dishes consumed by the user in the last k days and their corresponding timestamps, and form a dish interaction sequence; A nutrition relationship building module is used to build a nutrition relationship diagram of food according to the nutrition component vector and the attribute vector, and calculate the nutrition complementarity weight, nutrition mutual exclusivity weight and nutrition similarity weight of the edges connecting the foods in the nutrition relationship diagram based on the nutrition component vector; The recommended recipe output module is used to define the state, action, and state transition function of the reinforcement learning model, define the reward function based on the dish interaction sequence, nutritional complementarity weight, and nutritional mutual exclusivity weight, build and train the reinforcement learning model, and output the recommended recipes to the user based on the Monte Carlo tree search using the trained reinforcement learning model; The nutritious meal recommendation module is used to match the food in the recommended recipes with the dishes on the canteen menu of the day to generate nutritious meals.
9. An electronic device, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the AIGC-based smart canteen personalized nutritious meal recommendation method are implemented as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which is suitable for being loaded by a processor to execute the steps in the AIGC-based smart canteen personalized nutritious meal recommendation method as described in any one of claims 1-7.
Citation Information
Patent Citations
Artificial intelligence recommended dish matching platform and dish matching customization method
CN111128342A
Nutrition balanced diet recommendation method and system based on user body health data
CN118430745A
Nutrition scheme recommendation method and system based on data fusion and knowledge graph
CN118645214A
Course recommendation method and device, equipment and storage medium
CN118861431A
Cited By
Food material nutrition database construction method and system and meal recommendation method and system
CN120690382A
Particle swarm algorithm-based nutrition catering recommendation system and method
CN122025018A