A case recipe generation system and method based on a large language model

By using a recipe generation system based on a large language model, combined with nutrition and case data, the problem of existing systems being unable to generate recipes that meet the dietary health needs of patients with chronic diseases has been solved, and personalized recipes with nutritional basis have been generated.

CN119495402BActive Publication Date: 2026-03-20SICHUAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing recipe generation systems are unable to generate recipes that meet the dietary health needs of patients with chronic diseases, and the generation models lack sufficient understanding of specific domain terminology, which may lead to errors.

Method used

By employing a large language model combined with nutritional and case data, and through data preprocessing, named entity recognition, and semantic matching, recipes that meet the requirements of the cases are generated.

Benefits of technology

The generated recipes are nutritionally sound, meet patient needs, improve the reliability and feasibility of the recipes, and reduce misleading content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119495402B_ABST
    Figure CN119495402B_ABST
Patent Text Reader

Abstract

The application discloses a case recipe generation system and method based on a large language model, and comprises the following steps: step 1, obtaining nutrition data, recipe data and case data to form a data set; step 2, pre-processing the data in the data set obtained in step 1, the pre-processing process comprising unified expression of the case data; nutrition terminology recognition of the nutrition data to obtain a data set with a terminology label; filtering of the recipe data according to the nutrition data; step 3, obtaining nutrition text segments and recipe data meeting the requirements of the case; step 4, generation of the required case recipe by a large language model according to the text segments and data obtained in step 3; the method can significantly improve the reliability, feasibility and adaptability of recipe generation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a case recipe generation system and method based on a large language model. BACKGROUND

[0002] In recent years, the number of patients with chronic diseases is gradually increasing, and many risk factors of diseases are related to unreasonable dietary structure. Although the current dietary guidelines for chronic diseases are also specified, they only cover a small number of diseases and cannot meet the needs of a large number of patients who need to adjust their dietary structure. Although there are related websites on the network, the information is scattered, or they do not have knowledge of nutrition and cooking, and cannot obtain the required recipes.

[0003] The current recipe generation method is generally based on the text content of the given recipe to generate a recipe that meets the requirements. Using a generative language model, the materials required for the recipe and the steps required for cooking can be quickly obtained. Some current research results, such as a cooking recipe generation system using genetic algorithms and statistical language models, have studied the impact of preparation steps on the quality of generated recipes. Another part of the work focuses on generating cooking recipes under different restrictions. However, existing recipe generation systems often focus on the innovation of recipes and the requirements of partial taste customization, and do not involve dietary health. And limited by the training process of the generative language model, the existing method cannot generate a recipe that meets the requirements of the dietary health needs of the patient. The generative model has insufficient understanding of specific domain terminology and may generate errors. In a specific field, many concepts and terms have specific meanings and contexts. In summary, the existing processing method cannot obtain a recipe that meets the requirements. SUMMARY

[0004] The present application provides a case recipe generation system and method based on a large language model to solve the problems existing in the prior art.

[0005] The technical solution adopted by the present application is: a case recipe generation method based on a large language model, comprising the following steps:

[0006] Step 1: Obtain nutrition data, recipe data and case data to form a data set;

[0007] Step 2: Preprocess the data in the data set obtained in step 1, the preprocessing process including: uniformly expressing the case data; identifying the nutrition terminology of the nutrition data to obtain a data set with term labels; filtering the recipe data according to the nutrition data;

[0008] Step 3: Obtain nutrition text and recipe data that meet the requirements of the case;

[0009] Step 4: Use the large language model to generate the required case recipe based on the text and data obtained in step 3.

[0010] Further, the case data uniform expression process in step 2 is as follows:

[0011] According to the word frequency of the case data, perform coarse-grained filtering to obtain disease names with a word frequency greater than a threshold;

[0012] Calibrate the screened disease names to obtain standard names that meet disease coding; merge the standard names to obtain a uniform expression data set.

[0013] Further, the process of identifying nutrition terms in step 2 is as follows:

[0014] Use a large language model based on Transformer for named entity recognition.

[0015] Further, the screening and filtering process of recipe data in step 2 is as follows:

[0016] Expand the nutrition terms to obtain terms consistent with the ingredients in the recipe data set;

[0017] Screen and filter the recipes according to the nutrition value threshold.

[0018] Further, the process of obtaining nutrition text and recipe data that meet the case requirements in step 3 is as follows:

[0019] Segment and clean the recipe name list;

[0020] Use the bag-of-words model to screen the segmentation results to obtain a word table;

[0021] Retrieve the nutrition data and recipe data according to the keywords to obtain content consistent with the ingredient list, then perform semantic matching to obtain the similarity between the input query and the sentences in the data set; vectorize the recipe supplement description and perform similarity calculation with the vector after processing the nutrition data;

[0022] Sort the search results according to the similarity calculation results, and take the text and data with a relevance greater than a set threshold.

[0023] Further, the process of named entity recognition using a large language model based on Transformer is as follows:

[0024] Preprocess the input text;

[0025] Extract features from the text;

[0026] Split the text features to determine whether they are named entities;

[0027] Output the label of each word to perform named entity identification.

[0028] A case recipe generation system based on a large language model, comprising a data collection module, an information processing module, an information indexing module, and a recipe generation module;

[0029] The data collection module is used to obtain nutrition data, recipe data, and case data to form a data set.

[0030] The information processing module is used to preprocess the data in the data set.

[0031] The information indexing module is used to retrieve nutrition text segments and recipe data that meet the requirements of the case.

[0032] The recipe generation module is used to generate a case recipe based on a large language model according to the nutrition text segments and recipe data.

[0033] A computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps of the method when executing the computer program.

[0034] A computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the method.

[0035] The beneficial effects of the present application are:

[0036] (1) The present application integrates nutrition guidelines and a large language model, improving the reliability of the recipe generation system and the feasibility of the recipe.

[0037] (2) The present application can generate recipe data with nutritional basis and more realistic according to the information provided by the case, such as menu requirements and other text content. BRIEF DESCRIPTION OF DRAWINGS

[0038] Figure 1 The present application is a method flowchart.

[0039] Figure 2 The present application is a filtering process diagram for screening recipe data.

[0040] Figure 3 The present application is a process diagram for identifying nutrition terms.

[0041] Figure 4 The present application is a process diagram for uniform expression of case data.

[0042] Figure 5 The present application is a process diagram for named entity recognition based on a Transformer large language model.

[0043] Figure 6 The recipe obtained in the embodiment of the application. DETAILED DESCRIPTION

[0044] The application will be further described below in conjunction with the drawings and specific embodiments.

[0045] As Figure 1 shown, a case recipe generation method based on a large language model includes the following steps:

[0046] Step 1: Obtain nutrition data, recipe data and case data to form a data set;

[0047] Use a web crawler to filter out diet guidance text related to the disease from nutrition-related information to build a preliminary nutrition guide data; use the crawler to obtain recipe data on the website to obtain a selectable recipe data set; and provide the case data of the patient through an open source data set.

[0048] Step 2: Preprocess the data in the data set obtained in step 1, and the preprocessing process includes uniformly expressing the case data; identifying the nutrition terminology in the nutrition data to obtain a data set with term labels; and filtering the recipe data according to the nutrition data;

[0049] Uniformly express the case data as Figure 4 shown, the case data is filled out by different doctors, and there is a problem of inconsistent expression of the same disease. With the help of the International Classification of Diseases, 11th Edition, and other disease coding systems, rule-based processing is performed to obtain a uniformly expressed case data set. The specific process is as follows:

[0050] According to the word frequency of the case data, coarse-grained filtering is performed to obtain disease names with a word frequency greater than a threshold;

[0051] Calibrate the disease names obtained by filtering to obtain standard names that meet the disease coding; and merge the standard names to obtain a uniformly expressed data set.

[0052] The calibration process uses a web script to query the disease names obtained in the first step in the International Classification of Diseases, 11th Edition, browser webpage one by one, and the returned results of the query are taken as the standard names of the disease.

[0053] Due to the different structures of various website pages and the different structures of the content expression, a named entity recognition model is needed to identify the nutrition terminology, and the process of identifying the nutrition terminology is as follows:

[0054] A large language model based on Transformer is used for named entity recognition.

[0055] The specific process is as follows:

[0056] Named entity is a group of words or phrases with specific meaning, in the context of the present application, it is a nutrition term. For example, apple (food), vitamin C (nutritional ingredient). The task of named entity recognition is to identify these special groups or phrases related to nutrition in a given sentence. Due to the lack of specific models for the field of nutrition in the field of named entity recognition, there is a lack of corresponding training data set. In the present application, a large language model based on Transformer is used for named entity recognition. For a given sentence, first, the input text is preprocessed, including word segmentation, stop word removal, etc. Secondly, the features of the text are extracted, such as the form of the word, the context information, etc. These features help the model understand the meaning of the entity. The model analyzes the text and classifies each word to determine whether it is a named entity. The model outputs the label of each word, identifying those that are named entities and their categories. The model output of the present application is JSON formatted data, and the nutrition guide data set with nutrition term labels is obtained.

[0057] The screening and filtering process of recipe data is as shown in Figure 2

[0058] The recipe data obtained from the network is uploaded by network users themselves, and the quality is not the same. According to the labels in the nutrition guide, high-quality recipe data related to the labels is screened to obtain a recipe data set for subsequent use.

[0059] Nutrition term expansion is needed to expand each nutrition term based on the definition of food materials, that is, for each nutrition term, find the food material in the food material set corresponding to the recipe data set. For example, red meat: beef, pork, mutton, venison. The food material set obtained from the recipe data set does not contain venison, and finally the definition of red meat is: beef, pork, mutton. Get the term consistent with the food material in the food material set in the recipe data set;

[0060] Filtering and screening of recipes according to nutrition value threshold; assuming that the nutrition value screening of a recipe is determined by the food materials constituting the recipe. Since each recipe contains different types of food materials, given a nutrition guide, set the threshold proportion of recipes containing above as standard recipes. Thus, a part of the recipes containing food materials with low nutritional value are filtered out.

[0061] Step 3: Obtain nutrition text and recipe data that meet the requirements of the case;

[0062] ​The recipe name list is segmented and cleaned. The user provides case information, including the patient's ring class, dietary menu requirements, etc. Among them, the dietary menu can be divided into cooking methods and cooking materials. For example, braising, steaming, frying, etc. Cooking materials can be understood as the user specifying that a certain food material needs to be included in the recipe, such as fish and shrimp, chicken and duck, beans, etc. For this part, first get the high-quality recipe name list (the above-mentioned recipe data after screening and filtering), and then segment and clean it.

[0063] The segmented results are screened using the bag-of-words model to obtain a word table;

[0064] Using the bag-of-words model, all segmented results are treated as a set, and all unique words appearing in the text are collected to form a word table. The information in this word table can be obtained after manual screening, that is, the cooking method and cooking material requirement list.

[0065] In the nutrition data and recipe data, search according to the keywords to get the content consistent with the food material list, and then perform semantic matching to get the similarity between the input query and the sentence in the data set; the vectorization of the recipe supplement description and the vector after processing the nutrition data are used for similarity calculation;

[0066] To ensure that the nutrition guide data set and the recipe data set retrieve relevant content with high relevance. Use keyword search to search whether the keywords in the data set are completely consistent with the content in the data set. For example, whether the cooking materials specified by the user directly appear in the list of food materials used in the recipe.

[0067] For semantic matching, cosine similarity is used to compare the similarity between the input query and the sentence in the data set. Since some recipes also have description text as a supplement, this part of the text can be input into the BERT model for vectorization, and then the similarity with the same processed vector in the nutrition guide is calculated. According to the relevance, update degree and user demand, the retrieval results are sorted, and the text and recipes that do not meet the requirements are filtered out.

[0068] Step 4: Generate the required case recipe using a large language model based on the text and data obtained in step 3.

[0069] The retrieved text segments and data information are integrated by using a large language model to obtain a required recipe. Specifically, first, relevant nutrition guidelines, case information, and recipe data are retrieved from the nutrition guideline dataset, case dataset, and recipe dataset. These information includes the user's specific condition, dietary requirements, common ingredients, and cooking methods. The retrieved information is integrated. Based on these contents, a prompt is constructed to drive the large language model to intelligently generate. The language model has strong text generation capability and can automatically generate complete recipe content according to the prompt. The generated content includes the main points of the relevant nutrition guidelines, provides specific recipes suitable for the case, including ingredients, methods, and nutritional analysis. For example, Figure 6

[0070] A case recipe generation system based on a large language model includes a data collection module, an information processing module, an information indexing module, and a recipe generation module.

[0071] The data collection module is used to obtain nutrition data, recipe data, and case data to form a dataset.

[0072] The information processing module is used to preprocess the data in the dataset.

[0073] The information indexing module is used to retrieve nutrition text segments and recipe data that meet the requirements of the case.

[0074] The recipe generation module is used to generate a case recipe based on a large language model according to the nutrition text segments and recipe data.

[0075] The present application is based on the existing nutrition guidelines to generate recipes and nutrition recommendations that are not likely to contain misleading content that violates professional knowledge, reducing the risk of user health management. The recipe data is uploaded by actual users, ensuring its feasibility and practicality. The dataset based on the data uploaded by network users provides diversified choices to meet the taste needs of different patients. The present application method generates personalized recipes according to the user's condition and dietary preferences, ensuring the high relevance of the recommended content, and unlike existing recipe generation methods that focus on innovation and constraints, it is more suitable for real user needs.

[0076] Therefore, the present application method can significantly improve the reliability, feasibility, and adaptability of recipe generation.​

Claims

1. A method for generating case-based recipes based on a large language model, characterized in that, Includes the following steps: Step 1: Acquire nutritional data, recipe data, and case data to form a dataset; Step 2: Preprocess the data in the dataset obtained in Step 1. The preprocessing process includes standardizing the representation of the case data. Nutritional terminology is identified from nutritional data to obtain a dataset with terminology tags; recipe data is then filtered based on nutritional data; the process of identifying nutritional terms is as follows: Named entity recognition is performed using a large language model based on Transformer. Step 3: Obtain nutritional texts and diet data that meet the case requirements; the process for obtaining nutritional texts and diet data that meet the case requirements is as follows: Users provide case information, including the type of illness and dietary needs of the patients; to address this need, we first obtain a list of high-quality recipes, and then perform word segmentation and cleaning. The bag-of-words model is used to filter the word segmentation results to obtain a vocabulary list; The system retrieves content matching the ingredient list based on keywords from nutritional and recipe data, then performs semantic matching using cosine similarity to compare the similarity between the input query and sentences in the dataset; for supplementary recipe descriptions, the system vectorizes the data and calculates the similarity between the vectors and the processed nutritional data. The search results are sorted according to relevance, update frequency, and user needs, and text segments and data with relevance greater than a set threshold are selected. Step 4: Based on the text and data obtained in Step 3, use a large language model to generate the required case recipes.

2. The method for generating case-based recipes based on a large language model according to claim 1, characterized in that, The process of uniformly representing case data in step 2 is as follows: Coarse-grained filtering is performed based on the word frequency of the case data to obtain disease names whose word frequency is greater than a threshold; The selected disease names are calibrated to obtain standard names that conform to the disease codes; the standard names are then merged to obtain a dataset with a unified expression.

3. The method for generating case-based recipes based on a large language model according to claim 1, characterized in that, The process of filtering recipe data in step 2 is as follows: Expand the nutritional terminology to obtain terms that are consistent with the ingredients in the ingredient set of the recipe dataset; Recipes are filtered based on nutritional value thresholds.

4. The method for generating case-based recipes based on a large language model according to claim 1, characterized in that, The process of named entity recognition based on the Transformer-based large language model is as follows: Preprocess the input text; Extracting features from text; Split the text features to determine whether they are named entities; Output the label for each word and perform named entity identification.

5. A case study recipe generation system based on a large language model for performing the generation method as described in any one of claims 1 to 4, characterized in that, It includes a data collection module, an information processing module, an information indexing module, and a recipe generation module; The data collection module is used to acquire nutritional data, recipe data, and case data to form a dataset; The information processing module is used to preprocess the data in the dataset; The information index module is used to retrieve nutritional texts and recipe data that meet the requirements of the case. The recipe generation module is used to generate case recipes based on nutrition texts and recipe data using a large language model.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Food recipe recommendation system

    CN110298770A

  • Recipe recommendation system suitable for diabetics

    CN115440344A