Candy formula generation method and system based on retrieval enhancement generation and large language model, and medium

By constructing a multi-source heterogeneous data set and vector database, combining search enhancement generation and large language models, the candy formula standard is used to verify the database to correct unreasonable data, and a user feedback reinforcement learning mechanism is introduced, which solves the problem of inefficiency in candy formula design and achieves efficient candy formula generation that conforms to food scientific standards.

CN120430284APending Publication Date: 2025-08-05JIANGNAN UNIV +1

Patent Information

Application Number
CN202510564706.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

The prior art has problems in the design of candy formulas that are inefficient, difficult to meet market demand, low knowledge utilization rate and formula deviation from industry standards, especially the large language model lacks a closed-loop optimization mechanism when generating candy formulas.

Method used

By constructing a multi-source heterogeneous data set and vector database, combining search enhancement generation and large language models, the candy formula standard is used to verify the database to correct unreasonable data, and a user feedback reinforcement learning mechanism is introduced to optimize recipe generation.

Benefits of technology

It has achieved efficient and food-based scientific and food-based candy formula generation, shortened the R&D cycle, reduced the number of manual trial and error, and improved the market adaptability and rationality of the formula.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120430284A_ABST
    Figure CN120430284A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for generating a candy formula based on retrieval enhancement generation and a large language model, and a medium. According to the method, a multi-source heterogeneous data set is constructed, a vector database in the field of candy formulas is established, formula requirements input by a user are received, feature vectors are generated, similarity retrieval and correction are carried out in the candy formula vector database, and a retrieval result is obtained to serve as a context prompt. And the pre-trained formula large model quickly generates a candy formula according to context prompts. According to the candy formula generation method, context prompts of domain knowledge enhancement are formed through similarity retrieval, unreasonable data are corrected by utilizing a candy formula standard verification database, a large language model is effectively guided to output candidate schemes meeting food science specifications, and the problem that when a general large language model is directly applied to generate a formula, the candidate schemes are difficult to output is solved. The formula deviates from the industrial standard; and a reward function is further introduced through reinforcement learning to optimize the candy formula, so that the research and development cycle of the candy formula is remarkably shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of intersection of artificial intelligence and food formula, and specifically relates to a candy formula generation method, system and medium based on retrieval-enhanced generation and a large language model. Background Art

[0002] As a popular snack food, candy's taste, texture, and nutritional value have always been a focus of consumer attention. With intensified market competition and diversified consumer demands, the candy manufacturing industry faces unprecedented challenges. Traditional candy formulation design methods rely on empirical experience and trial-and-error experiments, which are not only inefficient but also fail to accurately meet market demands. Therefore, developing an efficient and intelligent candy formulation optimization method is particularly important.

[0003] In recent years, the rapid development of large language models has provided new ideas for recipe design. Some studies have attempted to introduce data analysis technology into recipe development, such as using machine learning models to analyze the raw material association patterns in historical recipe data. However, when applying existing large language models to candy recipes, they generally face the following problems: large language models involve a large number of candy data such as patent documents, process manuals, sensory evaluations, user preferences, etc. The multi-source heterogeneity of the data leads to low knowledge utilization. If large language models are directly applied to generate recipes, they are susceptible to model knowledge solidification and hallucination phenomena (such as fabricating non-standard raw material ratios or ignoring industry regulations), requiring repeated manual verification and correction. In addition, they focus more on static recipe recommendations and lack a closed-loop optimization mechanism based on production feedback and consumer evaluation, resulting in a disconnect between the recipe implementation effect and market demand.

[0004] Chinese invention patent publication number CN 119538986 A discloses a method for synthesizing feed raw material nutritional value data based on a large language model. This method generates corresponding raw material nutritional value data through a large language model, but relies on precise data for optimization and cannot avoid the large language model's verification of the rationality of the formula, reducing the efficiency of formula development. The existing technology does not have any research on candy formulas and processes in the direction of large model language. Therefore, it is necessary to develop a method for generating candy formulas using a large language model. Summary of the Invention

[0005] An object of the present invention is to provide a candy recipe generation method based on retrieval-enhanced generation and a large language model. This method can utilize a large language model to assist in the generation and effectiveness of candy recipes, promoting the efficient development of candy recipes using large language model tools. Another object of the present invention is to provide a candy recipe generation system based on retrieval-enhanced generation and a large language model, as well as a readable storage medium storing a computer program for executing the above method.

[0006] The technical solutions of the present invention are as follows:

[0007] A candy recipe generation method based on retrieval-enhanced generation and a large language model, comprising the following steps:

[0008] S1. Collect public and internal candy-related data and construct a multi-source heterogeneous dataset;

[0009] S2. Preprocess and vectorize multi-source heterogeneous datasets to construct a candy recipe vector database and a candy recipe standard verification database.

[0010] S3. Receive the recipe requirement parameters input by the user and perform vector representation to form a recipe requirement feature vector;

[0011] S4 based on the recipe requirements feature vector similarity search in the recipe vector database, to obtain candy recipes and processes sorted by similarity;

[0012] S5. Compare the candy recipes and processes sorted by similarity to the candy recipe standard verification database to verify the rationality of each recipe composition and content. Delete any unreasonable recipe ingredients and normalize the unreasonable recipes to adjust the unreasonable recipe content to reasonable limits, and output the candy recipe data.

[0013] S6. The recipe requirement parameters input by the user and the candy recipe data are concatenated and input into the large language model as enhanced contextual prompts to generate candidate recipes.

[0014] Furthermore, the candy formula generation method further includes establishing a user feedback reinforcement learning mechanism, in which the production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candy candidate formula are introduced into the reward function to optimize the formula and obtain the optimized candy formula;

[0015] The user feedback reinforcement learning mechanism is performed according to the following reward function:

[0016] R = w1 × production feasibility score + w2 × taste score + w3 × nutrition score + w4 × consumer satisfaction score - w5 × penalty item

[0017] Among them, R represents the reward function, w x Indicates the weight of each indicator; the penalty item is the compliance of the formula or process with regulations and practices.

[0018] Furthermore, the candy recipe generation method further includes concatenating the obtained optimized candy recipe with the recipe requirement parameters input by the user, and adding the result into the candy recipe vector database to optimize retrieval efficiency.

[0019] Furthermore, the consumer satisfaction assessment includes sensory evaluation of the taste, texture, color and smell of the candy, and the overall satisfaction score must be above 85 points on a 100-point scale.

[0020] Furthermore, the preprocessing in step S2 includes splitting the candy-related data into documents, identifying data, and performing data cleaning; the candy-related data in step S1 includes public and internal candy historical formula data, candy raw material characteristic data, candy patents, candy literature, user taste preference data, nutritional requirement parameters, sensory evaluation data, candy product manuals, candy industry specifications and national specifications, and process condition constraints. The candy product manuals, candy industry specifications, and national specifications are used to construct a candy formula standard verification database.

[0021] Furthermore, the recipe requirement parameters input by the user in step S3 include characteristics of the target candy product such as candy type, candy nutritional requirements, raw material constraints, taste index, physical and chemical properties, and cost constraints.

[0022] Furthermore, the similarity search in step S4 uses cosine similarity to evaluate the similarity, and the cosine similarity is expressed as:

[0023]

[0024] Where x1 and x2 represent two candy recipe vectors, x1·x2 represents the inner product of the candy recipe vectors, and ||x1|| and ||x2|| represent the lengths of the candy recipe vectors.

[0025] Preferably, the large language model in step S5 is one of a dedicated candy large language model and a general large language model established using the Cohere Command-R model as an architecture.

[0026] Furthermore, the candy recipe data in step S6 at least includes the type of candy, the composition and amount of raw materials used, and the production steps and process.

[0027] Preferably, the candy in step S1 is one of hard candy, soft candy, toffee, crisp candy, sandwich candy, and chocolate candy.

[0028] The present invention provides a candy recipe generation system based on retrieval-enhanced generation and a large language model for the candy recipe generation method, comprising a data collection module, a data processing module, a candy recipe database module, a candy recipe standard verification database module, a recipe requirement conversion module, an information indexing module, a verification and adjustment module, and a recipe generation module;

[0029] The data collection module is used to collect public and internal candy-related data and construct a multi-source heterogeneous dataset;

[0030] The data processing module is used to preprocess multi-source heterogeneous data sets, perform vector representation, and construct a candy recipe vector database and a candy recipe standard verification database respectively;

[0031] The candy recipe database module is used to store pre-processed and vectorized candy recipe data;

[0032] The candy formula standard verification database module is used to store pre-processed and vectorized candy formula standard data;

[0033] The recipe requirement conversion module is used to receive the recipe requirement parameters input by the user and perform vector representation to form a recipe requirement feature vector;

[0034] The information index module is used to perform similarity retrieval on the formula requirement feature vector in the candy formula database module to obtain candy formulas and processes sorted by similarity;

[0035] The inspection and adjustment module is used to compare the candy formulas and processes sorted by similarity to the candy formula standard verification database, verify the rationality of each formula composition and content, delete unreasonable formula composition ingredients, and normalize unreasonable formulas to adjust the unreasonable formula content to reasonable limits, and output candy formula data;

[0036] The recipe generation module is used to combine the recipe requirement parameters input by the user with the candy recipe data, and input them into the large language model as enhanced context prompts to generate candidate recipes;

[0037] Preferably, the generation system further comprises an optimization feedback module;

[0038] The optimization feedback module is used to optimize the production of candy candidate formulas and evaluate consumer satisfaction. The optimized candy formula data obtained is spliced with the formula requirement parameters entered by the user and added to the candy formula vector database to optimize retrieval efficiency.

[0039] The present invention provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the candy formula generation method.

[0040] The beneficial effects of the present invention are:

[0041] (1) This candy recipe generation method constructs a vector database of multi-source heterogeneous data to quickly mine potential associations between cross-domain data. Through retrieval enhancement generation technology, it dynamically combines user needs with highly correlated recipe data in the vector database to form contextual prompts that enhance domain knowledge. It also uses the candy recipe standard verification database to correct unreasonable data, effectively guiding the large language model to output candidate solutions that meet food science standards, avoiding the direct application of a general large language model to generate recipes, which often leads to recipes being unfeasible or deviating from industry standards due to model knowledge solidification or training data bias.

[0042] (2) This candy formula generation method avoids repeated design; further, by reinforcing the production, taste, nutrition, and consumer satisfaction information contained in the learning reward function, it adjusts the raw material ratio and process parameters, and optimizes the candy formula vector database, reducing the number of manual trial and error and shortening the candy formula R&D cycle. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is a flow chart of the candy recipe generation method based on retrieval-enhanced generation and a large language model of the present invention.

[0044] Figure 2 This is a system diagram of the candy recipe generation method based on retrieval-enhanced generation and a large language model of the present invention. DETAILED DESCRIPTION

[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.

[0046] Example 1

[0047] As attached Figure 1 This embodiment provides a candy recipe generation method based on retrieval-enhanced generation and a large language model, comprising the following steps:

[0048] S1. Collect public and internal candy-related data to construct a multi-source heterogeneous dataset. As an optional solution, the candy-related data in step S1 includes public and internal candy historical recipe data, candy raw material characteristic data, candy patents, candy literature, user taste preference data, nutritional requirement parameters, sensory evaluation data, candy product manuals, candy industry specifications and national specifications, and process condition constraints. The candy product manuals, candy industry specifications, and national specifications are used to construct a candy recipe standard verification database.

[0049] S2. Preprocessing and vectorizing the multi-source heterogeneous dataset to construct a candy recipe vector database and a candy recipe standard verification database. Optionally, the preprocessing includes document segmentation, data identification, and data cleaning of the candy-related data.

[0050] S3. Receive user-entered recipe requirement parameters and vectorize them to form a recipe requirement feature vector. As an optional solution, the recipe requirement parameters entered by the user in step S3 may include candy type, candy nutritional requirements, raw material constraints, taste indicators, physical and chemical properties, cost constraints, and other target characteristics for generating candy products.

[0051] S4. Based on the recipe requirement feature vector, a similarity search is performed in the recipe vector database to obtain candy recipes and processes sorted by similarity; as an optional solution, the similarity search in step S4 is performed using cosine similarity to evaluate the similarity, and the cosine similarity is expressed as:

[0052]

[0053] Where x1 and x2 represent two candy recipe vectors, x1·x2 represents the inner product of the candy recipe vectors, and ||x1|| and ||x2|| represent the lengths of the candy recipe vectors.

[0054] S5. Compare the candy recipes and processes sorted by similarity to the candy recipe standard verification database to verify the rationality of each recipe composition and content. Delete any unreasonable recipe ingredients and normalize the unreasonable recipes to adjust the unreasonable recipe content to reasonable limits, and output the candy recipe data.

[0055] S6. The user-entered recipe parameters and candy recipe data are concatenated and input into a large language model as enhanced contextual prompts to generate candidate recipes. Optionally, the large language model can be a dedicated candy large language model or a general large language model built using the Cohere Command-R model. Optionally, the candy recipe data in step S6 includes at least the candy type, raw material composition and amounts, and production steps and processes.

[0056] A user feedback reinforcement learning mechanism is established, and the production feasibility, taste, nutrition, and consumer satisfaction evaluation of candidate candy formulas are introduced into the reward function to optimize the formula and obtain the optimized formula; the obtained optimized candy formula data and the formula requirement parameters entered by the user are spliced and added to the candy formula vector database to optimize retrieval efficiency.

[0057] Among them, the user feedback reinforcement learning mechanism is based on the following reward function:

[0058] R = w1 × production feasibility score + w2 × taste score + w3 × nutrition score + w4 × consumer satisfaction score - w5 × penalty item

[0059] Among them, R represents the reward function, w x Indicates the weight of each indicator; the penalty item is the compliance of the formula or process with regulations and practices.

[0060] Preferably, consumer satisfaction includes sensory evaluation of the candy's taste, texture, color, and smell, and the overall satisfaction score must be above 85 points on a 100-point scale.

[0061] Example 2

[0062] This embodiment provides a candy recipe generation system based on retrieval-enhanced generation and a large language model of the candy recipe generation method described above, combined with the attached Figure 2 , including data collection module, data processing module, candy formula database module, candy formula standard verification database module, formula requirement conversion module, information index module, inspection and adjustment module and formula generation module. As an optional solution, it also includes an optimization feedback module;

[0063] The data collection module is used to collect public and internal candy-related data and construct a multi-source heterogeneous dataset;

[0064] The data processing module is used to preprocess multi-source heterogeneous data sets, perform vector representation, and construct a candy recipe vector database and a candy recipe standard verification database respectively;

[0065] The candy recipe database module is used to store pre-processed and vectorized candy recipe data;

[0066] The candy formula standard verification database module is used to store pre-processed and vectorized candy formula standard data;

[0067] The recipe requirement conversion module is used to receive the recipe requirement parameters input by the user and perform vector representation to form a recipe requirement feature vector;

[0068] The information indexing module is used to perform similarity retrieval on the formula requirement feature vector in the candy formula database model to obtain candy formulas and processes sorted by similarity;

[0069] The inspection and adjustment module is used to compare the candy formulas and processes sorted by similarity to the candy formula standard verification database, verify the rationality of each formula composition and content, delete unreasonable formula composition ingredients, and normalize unreasonable formulas to adjust the unreasonable formula content to reasonable limits, and output candy formula data;

[0070] The recipe generation module is used to combine the recipe requirement parameters input by the user with the candy recipe data, and input them into the large language model as enhanced context prompts to generate candidate recipes;

[0071] The optimization feedback module is used to perform feedback reinforcement learning optimization on candidate candy recipes. The production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candidate candy recipes are introduced into the reward function to optimize the recipes. The optimized candy recipes obtained are spliced with the recipe requirement parameters entered by the user and added to the candy recipe vector database to optimize retrieval efficiency.

[0072] The specific workflow of the system is as follows: the data collection module collects candy-related data and constructs a multi-source heterogeneous data set; the data processing module preprocesses the multi-source heterogeneous data set and performs vector representation, and constructs a candy recipe vector database and a candy recipe standard verification database respectively; the recipe requirement conversion module forms a recipe requirement feature vector, and performs similarity search in the candy recipe database module through the information index module to obtain candy recipes and processes sorted by similarity; then, the candy recipes and processes are compared to the candy recipe standard verification database through the inspection and adjustment module to verify the rationality of each recipe composition and content, and output the candy recipe data; then, the recipe generation module generates candidate recipes, and the candidate recipes are optimized through feedback reinforcement learning optimization by the optimization feedback module to obtain the optimized recipe; the optimized candy recipe and the recipe requirement parameters input by the user are spliced and added to the candy recipe vector database to optimize the retrieval efficiency.

[0073] Example 3

[0074] This embodiment provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the candy recipe generation method of embodiment 1.

[0075] Example 4

[0076] This example uses the method of Example 1 to generate a formula for a low-sugar hard candy product for diabetic patients, requiring a sugar content of less than 5g / 100g, using natural curcumin, and controlling the cost per piece to less than 0.15 yuan. The specific implementation steps are as follows:

[0077] (1) Data collection and preprocessing

[0078] Twelve low-sugar hard candy recipes were extracted from the patent library, and candy-related data such as raw material ratios, process parameters and costs were integrated. The candy-related data was split into documents, identified and cleaned to construct a candy recipe vector database. The maximum usage of curcumin in candies (0.7g / kg) in the "GB 2760-2024 National Food Safety Standard for the Use of Food Additives" was used to construct a candy recipe standard verification database. The data was cleaned to remove duplicates and recipes without marked process conditions, and finally a vector library containing 3,200 structured data was constructed.

[0079] (2) Demand input and vectorization

[0080] The user enters the following parameters: {"Candy Type": "Hard Candy", "Sugar Content": "≤5g / 100g", "Colour Source": "Natural Curcumin", "Cost per Candy": "≤0.15 RMB", "Hardness": "≥80 Shore A", "Taste Required": "Refreshing Mint Flavor"}. The system converts these parameters into a 768-dimensional feature vector, with the following weights assigned: sugar content (30%), cost (25%), hardness (20%), regulatory compliance (15%), and taste (10%).

[0081] (3) Similarity retrieval and correction

[0082] Use cosine similarity search to match hard candy-related formulas: invention patent with patent publication number CN116268162A and internal data; supplier data: erythritol procurement cost (0.11 yuan / g), maltitol (0.09 yuan / g); verification database comparison: the curcumin addition amount complies with GB 2760, but the initial formula hardness is only 75 Shore A, which needs to be optimized.

[0083] (4) Candidate recipe generation

[0084] The candy formulas and processes sorted by similarity are compared to the candy formula standard verification database to verify the rationality of the composition and content of each formula. If the result is reasonable, the candy formula data is output. After splicing with the user input parameters, the large language model is used to output the initial formula: maltitol 58%, erythritol 30%, turmeric concentrate (pigment carrier, containing 0.08% curcumin) 5%, citric acid 0.8%, natural mint flavor 0.2%, and crystallization inhibitor (lecithin) 0.5%.

[0085] Process parameters: cooking temperature: 143℃±1℃ (to prevent caramelization), holding time: 2.5min, adding acidulant before injection molding (pH controlled at 4.2-4.5).

[0086] (5) User feedback reinforcement learning mechanism

[0087] The production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candy candidate formula are introduced into the reward function to optimize the formula and obtain the optimized formula

[0088] Among them, the user feedback reinforcement learning mechanism is based on the following reward function:

[0089] R = w1 × production feasibility score + w2 × taste score + w3 × nutrition score + w4 × consumer satisfaction score - w5 × penalty item

[0090] Among them, R represents the reward function, w x Indicates the weight of each indicator; the penalty item is the compliance of the formula or process with regulations and practices.

[0091] The reward function for this example is defined as: R = 0.3 × production feasibility + 0.25 × taste + 0.2 × nutrition + 0.15 × satisfaction - 0.1 × penalty. Production feasibility: based on equipment compatibility (0-100 points); taste: blind taste test score (0-100 points); nutrition: sugar content compliance (≤5g / 100g = 100 points, 10 points deducted for every 0.1g overshoot); satisfaction: user comprehensive score (0-100 points); penalty: cost overrun (5 points deducted for every 0.01 yuan overshoot).

[0092] Iterative Optimization: First Round of Adjustments: Initial Formula Scores: Production Feasibility (85 points): Slightly higher viscosity due to lecithin addition; Taste (80 points): Overly strong mint flavor; Nutrition (95 points): Sugar content 4.8g / 100g; Satisfaction (82 points); Penalty (-10 points): Cost 0.16 yuan / piece. R = 0.3 × 85 + 0.25 × 80 + 0.2 × 95 + 0.15 × 82 - 0.1 × 10 = 69.3. Optimization Direction: Reduce mint flavor to 0.15% and switch to a lower-cost erythritol supplier. Second Round of Adjustments: Post-Adjustment Scores: Production Feasibility (90 points): Improved viscosity; Taste (88 points); Nutrition (100 points): Sugar content 4.5g / 100g; Satisfaction (88 points); Penalty (0 points): Cost 0.14 yuan / piece. R=0.3×90+0.25×88+0.2×100+0.15×88=89.2.

[0093] (6) Final formula and effect

[0094] Formula: 55% maltitol, 33% erythritol, 5% turmeric concentrate (0.08% curcumin), 0.7% citric acid, 0.15% natural mint flavor, 0.5% lecithin. Target achieved: 4.5g sugar content per 100g, 82 Shore A hardness, cost per pill: 0.14 yuan. Development cycle: 5 weeks (traditional methods require 4-6 months).

[0095] Example 5

[0096] This example provides a recipe for a vitamin C-rich soft candy that meets the needs of children aged 3-6 years. The recipe requires a vitamin C content of ≥2 mg / g, a soft texture to prevent choking (hardness ≤15N), and no artificial flavors. The specific implementation steps are as follows:

[0097] (1) Data collection and preprocessing

[0098] Eighteen patents for children's gummy candy formulas were extracted from public databases, and data on vitamin C fortification schemes, gelling agent ratios, and sensory evaluation were integrated. Candy-related data was split and identified, and data cleaning was performed to construct a candy formula vector database. The vitamin C usage range (1000mg / kg-6000mg / kg) in candies other than gum-based candies in "GB 14880-2012 National Food Safety Standard - Standard for the Use of Nutrient Fortifiers in Food" was used in the standard verification database. At the same time, the usage specifications for natural flavors in "GB 2760-2014" were integrated to construct a candy formula standard verification database. After data cleaning, formulas containing artificial flavors and those with excessive hardness were eliminated. Finally, a vector library containing 4,500 structured data was constructed, covering the ratios and process parameters of key raw materials such as gelatin, pectin, and vitamin C carriers (such as acerola cherry extract).

[0099] (2) Demand input and vectorization

[0100] The user enters the following parameters: {"Candy Type": "Soft Candy", "Vitamin C Content": "≥2mg / g", "Hardness": "≤15N", "Flavor Type": "Natural Fruit Flavor", "Target Audience": "Children Aged 3-6", "Taste Requirement": "Sweet and Sour Fruity", "Allergen Limitation": "Nut-Free"}. The system converts these parameters into a 768-dimensional feature vector.

[0101] (3) Similarity retrieval and correction

[0102] Using cosine similarity, we searched for a Chinese invention patent with publication number CN102550774A and matched it with an internal children's food database. A database comparison revealed that the initial formula contained 2.3 mg / g of vitamin C (which met the standard), but the hardness was 18N (which exceeded the standard). The gelling agent ratio needed to be optimized, reducing the gelatin content from 12% to 9%, and adding 0.5% glycerin as a plasticizer to reduce the hardness.

[0103] (4) Candidate recipe generation

[0104] Candy recipes and processes sorted by similarity were compared to a candy recipe standard verification database to verify the rationality of each recipe's composition and content. If the results were reasonable, the candy recipe data was output. After combining it with the user-input parameters, a large language model was used to output the initial recipe: Ingredients: 8% pectin, 9% gelatin, 8% acerola cherry concentrate (containing 25% vitamin C), 45% glucose syrup, 1.2% citric acid, 0.3% natural strawberry flavor, 0.5% glycerin, 27% purified water. Process parameters: mixing temperature 65°C ± 2°C, pH 3.8-4.2 (to enhance vitamin C stability), and 20 minutes of cooling time after injection molding (to ensure mold hardness).

[0105] (5) User feedback reinforcement learning mechanism

[0106] The production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candy candidate formula are introduced into the reward function to optimize the formula and obtain the optimized formula

[0107] Among them, the user feedback reinforcement learning mechanism is based on the following reward function:

[0108] R = w1 × production feasibility score + w2 × taste score + w3 × nutrition score + w4 × consumer satisfaction score - w5 × penalty item

[0109] Among them, R represents the reward function, w x Indicates the weight of each indicator; the penalty item is the compliance of the formula or process with regulations and practices.

[0110] The reward function for this example is defined as: R = 0.35 × Nutrition Score + 0.3 × Safety Score + 0.2 × Taste Score + 0.1 × Production Feasibility - 0.05 × Cost Exceedance Penalty. Nutrition Score: 100 points for a vitamin C content ≥ 2 mg / g, with a 15-point deduction for each 0.1 mg lower. Safety Score: 100 points for a hardness ≤ 15 N, with a 20-point deduction for each N higher. Taste Score: Children's blind taste test score (0-100 points). Production Feasibility: Based on the gel solubility and equipment compatibility score (0-100 points).

[0111] Iterative optimization: First round of adjustments: The initial formula hardness was 14N (reached the standard), but the taste score was 75 points (too high in acidity). Adjusted the citric acid to 0.9% and increased the glucose syrup to 47%. Second round of adjustments: After optimization, the vitamin C content was 2.1mg / g, the hardness was 13N, the taste score was 88 points, the production feasibility was 90 points, and the cost was 0.12 yuan / piece (within the limit). Reward value: R = 0.35×95+0.3×100+0.2×88+0.1×90 = 92.85

[0112] (6) Final formula and effect

[0113] Formula: 8% pectin, 8.5% gelatin, 8% acerola cherry concentrate, 47% glucose syrup, 0.9% citric acid, 0.3% natural strawberry flavor, 0.5% glycerin, 26.8% purified water. Processing: Mixing temperature 65°C, pH 4.0, cooling time 18 minutes. Achieved targets: Vitamin C content 2.1mg / g, hardness 13N, taste score 88 points, cost per candy 0.12 yuan. Development cycle: 3 weeks (traditional methods require 3-5 months). The optimized candy formula is combined with user-entered recipe parameters and added to the candy recipe vector database to optimize search efficiency.

[0114] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A candy recipe generation method based on retrieval-enhanced generation and large language model, characterized in that: The following steps are involved: S1. Collect public and internal candy-related data and construct a multi-source heterogeneous dataset; S2. Preprocess and vectorize multi-source heterogeneous datasets to construct a candy recipe vector database and a candy recipe standard verification database. S3. Receive the recipe requirement parameters input by the user and perform vector representation to form a recipe requirement feature vector; S4 based on the recipe requirements feature vector similarity search in the recipe vector database, to obtain candy recipes and processes sorted by similarity; S5. Compare the candy recipes and processes sorted by similarity to the candy recipe standard verification database to verify the rationality of each recipe composition and content. Delete any unreasonable recipe ingredients and normalize the unreasonable recipes to adjust the unreasonable recipe content to reasonable limits, and output the candy recipe data. S6. The recipe requirement parameters input by the user and the candy recipe data are concatenated and input into the large language model as enhanced contextual prompts to generate candidate recipes.

2. The candy recipe generation method according to claim 1, characterized in that: It also includes establishing a user feedback reinforcement learning mechanism to introduce the production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candy candidate formula into the reward function to optimize the formula and obtain the optimized formula; The user feedback reinforcement learning mechanism is performed according to the following reward function: R = w1 × production feasibility score + w2 × taste score + w3 × nutrition score + w4 × consumer satisfaction score - w5 × penalty item Among them, R represents the reward function, w x Indicates the weight of each indicator; the penalty item is the compliance of the formula or process with regulations and practices.

3. The candy recipe generation method according to claim 2, characterized in that: It also includes splicing the obtained optimized candy recipe data and the recipe requirement parameters input by the user, and adding them into the candy recipe vector database to optimize the retrieval efficiency.

4. The candy recipe generation method according to claim 2, characterized in that: The consumer satisfaction includes sensory evaluation of the candy's taste, texture, color, and smell, and the overall satisfaction score must be above 85 points on a 100-point scale.

5. The candy recipe generation method according to claim 1, characterized in that: The preprocessing described in step S2 includes document splitting, data identification, and data cleaning of the candy-related data; the candy-related data described in step S1 includes public and internal candy historical formula data, candy raw material characteristic data, candy patents, candy literature, user taste preference data, nutritional requirement parameters, sensory evaluation data, candy product manuals, candy industry specifications and national specifications, and process condition constraints. The candy product manuals, candy industry specifications, and national specifications are used to construct a candy formula standard verification database.

6. The candy recipe generation method according to claim 1, characterized in that: The recipe requirement parameters input by the user in step S3 include candy type, candy nutritional requirements, raw material constraints, taste indicators, physical and chemical properties, cost constraints and other target candy product characteristics.

7. The candy recipe generation method according to claim 1, characterized in that: The similarity search in step S4 uses cosine similarity to evaluate similarity. The cosine similarity is expressed as: Where x1 and x2 represent two candy recipe vectors, x1·x2 represents the inner product of the candy recipe vectors, and ‖x1‖ and ‖x2‖ represent the lengths of the candy recipe vectors.

8. The candy recipe generation method according to claim 1, characterized in that: The candy recipe data in step S6 at least includes the type of candy, the composition and amount of raw materials, and the production steps and process.

9. The candy recipe generation system based on retrieval-enhanced generation and large language model according to any one of claims 1 to 8, characterized in that: It includes a data collection module, a data processing module, a candy formula database module, a candy formula standard verification database module, a formula requirement conversion module, an information index module, an inspection and adjustment module, and a formula generation module; preferably, the generation system also includes an optimization feedback module; The data collection module is used to collect public and internal candy-related data and construct a multi-source heterogeneous dataset; The data processing module is used to preprocess multi-source heterogeneous data sets, perform vector representation, and construct a candy recipe vector database and a candy recipe standard verification database respectively; The candy recipe database module is used to store pre-processed and vectorized candy recipe data; The candy formula standard verification database module is used to store pre-processed and vectorized candy formula standard data; The recipe requirement conversion module is used to receive the recipe requirement parameters input by the user and perform vector representation to form a recipe requirement feature vector; The information index module is used to perform similarity retrieval on the formula requirement feature vector in the candy formula database module to obtain candy formulas and processes sorted by similarity; The inspection and adjustment module is used to compare the candy formulas and processes sorted by similarity to the candy formula standard verification database, verify the rationality of each formula composition and content, delete unreasonable formula composition ingredients, and normalize unreasonable formulas to adjust the unreasonable formula content to reasonable limits, and output candy formula data; The recipe generation module is used to combine the recipe requirement parameters input by the user with the candy recipe data, and input them into the large language model as enhanced context prompts to generate candidate recipes; The optimization feedback module is used to perform feedback reinforcement learning optimization on candidate candy recipes. The production feasibility, taste, nutrition, and consumer satisfaction evaluation of the candidate candy recipes are introduced into the reward function to optimize the recipes. The optimized candy recipes obtained are spliced with the recipe requirement parameters entered by the user and added to the candy recipe vector database to optimize retrieval efficiency.

10. A computer-readable storage medium storing a computer program, characterized in that: The computer program is executed by a processor to execute the candy recipe generating method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Sugar-free nutrient soft candy containing vitamin C and preparation method of same

    CN102550774A

  • Maltitol hard candy as well as preparation method and application thereof

    CN116268162A

  • Feed raw material nutritional value data synthesis method based on large language model

    CN119538986A

Cited By

  • Intelligent lean optimization method and system for food raw material formula and medium

    CN121144480A

  • A method, system, and medium for intelligent lean optimization of food ingredient formulations.

    CN121144480B