A method and system for structuring a Chinese cooking process

By using the BERT model and Transformer architecture for entity recognition and relationship extraction, the problem of missing information and insufficient data correlation in Chinese cooking processes has been solved, realizing a deep digital reconstruction of Chinese cooking techniques and providing data support for scientific dietary assessment and intelligent transformation.

CN121030006BActive Publication Date: 2026-07-07JIANGNAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510945087.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-09
Publication Date
2026-07-07
Estimated Expiration
2045-07-09

AI Technical Summary

Technical Problem

Existing technologies suffer from a lack of information on the cooking process, insufficient data correlation, incomplete dietary assessment, and inadequate data support for downstream tasks. In particular, the changes in the nutrients in ingredients are unstable in Chinese cuisine, and there is a lack of systematic statistics and analysis.

Method used

This paper proposes a BERT model to construct a structured method for Chinese cooking processes. By performing entity recognition and relation extraction tasks, Chinese recipe texts are obtained, and a Chinese recipe process corpus dataset is constructed. The Transformer architecture model is used for feature extraction and model training to generate cooking process diagrams.

Benefits of technology

It has achieved a deep digital reconstruction of Chinese cooking techniques, accurately captured cooking process information and data correlation, provided data support for scientific dietary assessment, improved cooking success rate and efficiency, and supported the intelligent transformation of central kitchens and the digital inheritance of cooking skills.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121030006B_ABST
    Figure CN121030006B_ABST
Patent Text Reader

Abstract

The application relates to a Chinese cuisine cooking process structuring method and system, and belongs to the technical field of artificial intelligence. The method comprises the following steps: according to a Chinese recipe text in natural language, establishing an annotation strategy of entity recognition and relationship extraction tasks; according to the text and the annotation strategy, constructing a Chinese recipe process corpus dataset; based on a BERT model, extracting features of text data in a training set and a test set to obtain first global features and second global features; according to the first global features, constructing a first model of the entity recognition task; according to the second global features, constructing a second model of the relationship extraction task; training the first model and the second model respectively by using the training set, inputting the test set into the trained first model and second model, and extracting entity relationships; and obtaining a cooking process graph according to the entity relationships. The application can comprehensively obtain cooking process information, accurately capture data correlation, realize comprehensive dietary assessment, and provide data support for downstream tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and system for structuring Chinese cuisine cooking processes. Background Technology

[0002] Driven by global digitalization, the traditional food industry is facing unprecedented opportunities and challenges for transformation. With the rapid development of new-generation information technologies such as big data and artificial intelligence, how to utilize these new technologies to acquire structured data has become a crucial technical problem that the food industry urgently needs to solve.

[0003] In the culinary field, recipe datasets are mainly divided into plain text datasets and multimodal datasets containing recipe images. However, current research on recipe structuring largely focuses on knowledge graph construction. These studies only address surface-level information such as cuisine, ingredient quantities, and flavor, while paying insufficient attention to the specific process information during cooking. In particular, there is a lack of systematic statistical analysis of key data such as the characteristics of movements, temperature, and time during cooking, and research on the correlations between different data is also relatively scarce.

[0004] In recipe-based dietary assessment, existing technologies mostly focus only on ingredient selection, neglecting the issue of nutrient loss between different ingredients during cooking. This is especially true for Chinese cuisine, which involves complex cooking methods and fluctuating nutrient levels. Summary of the Invention

[0005] Therefore, the technical problem to be solved by the present invention is to overcome the lack of cooking process information, insufficient data correlation, incomplete dietary assessment and insufficient data support for downstream tasks in the prior art.

[0006] Firstly, to solve the above-mentioned technical problems, the present invention provides a method for structuring the Chinese cuisine cooking process, comprising:

[0007] Obtain Chinese recipe text; based on the Chinese recipe text, establish annotation strategies for entity recognition and relation extraction tasks; construct a Chinese recipe process corpus dataset based on the Chinese recipe text and the annotation strategies; wherein the Chinese recipe process corpus dataset includes a training set and a test set;

[0008] Based on the BERT model, feature extraction is performed on the text data in the training set and the test set to obtain the first global feature and the second global feature;

[0009] Based on the first global feature, a first model for the entity recognition task is constructed; based on the second global feature, a second model for the relationship extraction task is constructed.

[0010] The first model and the second model are trained using the training set, and the test set is input into the trained first model and the second model to extract entity relationships.

[0011] Based on the entity relationships, a cooking flowchart is obtained.

[0012] In one embodiment of the present invention, the step of extracting features from the text data in the training set and the test set based on the BERT model to obtain the first global feature is as follows:

[0013] Obtain the text sets of the training set and the test set, and determine the composition of each recipe in the text set; wherein each recipe composition includes a set of statements;

[0014] Based on the text set and each recipe, the target of named entity recognition is defined;

[0015] Based on the stated objective, the set of statements is input into the encoder of the BERT model; features are extracted in the encoder through a deformer to obtain the first feature;

[0016] The first feature is fused to obtain the first global feature.

[0017] In one embodiment of the present invention, the step of extracting features from the text data in the training set and the test set based on the BERT model to obtain the second global feature is as follows:

[0018] Based on the entity recognition task, an entity set is extracted from each recipe; two entities are randomly selected from the entity set to form an entity pair.

[0019] Obtain the original statement of the entity pair; mark the position of each entity in the original statement to obtain the labeled statement; input the labeled statement into the encoder of the BERT model to obtain the feature representation of each entity in the entity pair, and obtain the global semantic features of the labeled statement;

[0020] The feature representation is mapped and regularized to obtain a new feature representation;

[0021] The global semantic features and the new feature representation are concatenated to obtain the second global feature.

[0022] In one embodiment of the present invention, the step of constructing a first model for the entity recognition task based on the first global feature is as follows:

[0023] The first global feature is input into a bidirectional long short-term memory network to capture the relationship between each token and the previous token, thus obtaining the first hidden state vector generated at each time step; the relationship between each token and the subsequent token is captured to obtain the second hidden state vector generated at each time step.

[0024] The first hidden state vector and the second hidden state vector at each time step are concatenated to obtain the first feature representation;

[0025] The first feature representation is input into a linear classification layer to obtain the first prediction score of each feature based on the label.

[0026] Based on the first prediction score, the sequence labeling problem is modeled and a loss value is calculated; the model is then optimized based on the loss value to obtain the first model.

[0027] In one embodiment of the present invention, the step of constructing a second model for the relation extraction task based on the second global feature is as follows:

[0028] The second global feature is input into the linear classification layer, and a second prediction score based on the label is calculated for each feature.

[0029] The probability of the second predicted score is calculated using a probability distribution function;

[0030] Based on the stated probabilities, the total loss is calculated using the cross-entropy loss function; based on the total loss, a second model is constructed.

[0031] In one embodiment of the present invention, the annotation strategy for establishing entity recognition and relation extraction tasks includes:

[0032] In the entity recognition task, the annotation strategy is to label ingredients, actions, cooking time, ingredient quantity, tools, tool status, ingredient status, and actions with food as the primary factor.

[0033] In the relationship extraction task, the annotation strategy is as follows: direct object of action, indirect object of action, next action, food or tool equivalent, part of food or tool, food or tool as the dominant direct object, and next action node based on time or state.

[0034] In one embodiment of the present invention, before constructing the Chinese recipe process corpus dataset based on the Chinese recipe text and the annotation strategy, the data in the Chinese recipe text is cleaned. The cleaning step is as follows:

[0035] Regular expressions were used to remove illegal symbols from the data, a stop word list for the cooking field was constructed, and redundant text was removed based on syntactic rule matching.

[0036] The recipe data after cleaning was obtained by using TF-IDF weighted retention of cooking-related segments;

[0037] The recipe data is divided into training and testing sets according to a preset ratio using stratified random sampling.

[0038] In one embodiment of the present invention, the test set is input into the trained first model and second model, and when extracting entity relationships, the F1 index, accuracy and recall are used as evaluation indicators.

[0039] In one embodiment of the present invention, the BERT model includes a deformer module, a fine-tuning module, and an embedding module; the deformer module is used to capture complex relationships in the input text; the fine-tuning module is used to optimize the BERT model according to different tasks; and the embedding module is used to convert the text into a numerical form that conforms to the processing of the BERT model.

[0040] Secondly, to solve the above-mentioned technical problems, the present invention provides a structured system for Chinese cuisine cooking processes, comprising:

[0041] A dataset construction module is used to acquire Chinese recipe text; based on the Chinese recipe text, an annotation strategy is established for entity recognition and relation extraction tasks; based on the Chinese recipe text and the annotation strategy, a Chinese recipe process corpus dataset is constructed; wherein the Chinese recipe process corpus dataset includes a training set and a test set;

[0042] The feature acquisition module is used to extract features from the text data in the training set and the test set based on the BERT model to obtain the first global feature and the second global feature.

[0043] The model construction module is used to construct a first model for the entity recognition task based on the first global feature, and to construct a second model for the relationship extraction task based on the second global feature.

[0044] Extract the model, which is used to train the first model and the second model respectively using the training set, and input the test set into the trained first model and the second model to extract entity relationships;

[0045] The output module is used to output a cooking flowchart based on the entity relationships.

[0046] Compared with the prior art, the above-described technical solution of the present invention has the following advantages:

[0047] (1) The present invention provides a structured method and system for Chinese cooking processes, which achieves a deep digital reconstruction of Chinese cooking techniques by constructing a multi-dimensional cooking process analysis system. Through a fine-grained entity annotation strategy, it systematically analyzes the evolution of ingredient states, the timing of tool operations, and the dynamic correlation of heat, comprehensively depicting complex cooking chains such as stir-frying, oiling, and thickening. Combined with dynamic relationship modeling technology, this system can accurately capture the causal relationship between nutrient loss patterns and process parameters, opening up new paths for scientific dietary assessment. This technical system not only achieves a leap from static text to dynamic process deduction but also provides solid core technical support for the intelligent transformation of central kitchens, the digital inheritance of cooking skills, and precise nutrition management.

[0048] (2) The present invention uses two models of the Transformer architecture to implement the named entity recognition task and the relationship extraction task respectively, which can accurately identify entities such as ingredients, tools, actions and their complex relationships from cooking process text. Attached Figure Description

[0049] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:

[0050] Figure 1 This is a flowchart of a structured method for Chinese cuisine cooking in a preferred embodiment of the present invention;

[0051] Figure 2 This is a structural diagram of the deformer module in a preferred embodiment of the present invention;

[0052] Figure 3 This is a schematic diagram of the fine-tuning module in a preferred embodiment of the present invention;

[0053] Figure 4 This is a schematic diagram of the embedded module in a preferred embodiment of the present invention;

[0054] Figure 5 This is a schematic diagram illustrating the actual application results in a preferred embodiment of the present invention. Detailed Implementation

[0055] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.

[0056] Example 1

[0057] Reference Figure 1 As shown, this embodiment of the invention provides a method for structuring the Chinese cooking process, including but not limited to the following steps:

[0058] S1. Obtain Chinese recipe text in natural language; based on the Chinese recipe text, establish annotation strategies for entity recognition and relation extraction tasks; based on the Chinese recipe text and annotation strategies, construct a Chinese recipe process corpus dataset; the Chinese recipe process corpus dataset includes a training set and a test set;

[0059] S2. Based on the BERT model, feature extraction is performed on the text data in the training and test sets to obtain the first global feature and the second global feature;

[0060] S3. Based on the first global feature, construct the first model for the entity recognition task; based on the second global feature, construct the second model for the relationship extraction task.

[0061] S4. Train the first model and the second model using the training set respectively, and input the test set into the trained first model and the second model to extract entity relationships;

[0062] S5. Based on the entity relationships, obtain the cooking process diagram.

[0063] This invention provides a structured method for Chinese cuisine cooking processes. This method can comprehensively acquire cooking process information and accurately capture data correlations, achieving comprehensive dietary assessment and providing solid data support for downstream tasks. By collecting a large amount of Chinese recipe text and constructing a corpus covering various cuisines, cooking methods, ingredient pairings, and other rich scenarios, a sufficient and diverse data foundation is provided for model training. This helps the model learn a wider range of knowledge, improves its generalization ability, and enables it to better handle different types of recipe text. An entity recognition and relation extraction annotation strategies are formulated to ensure the standardization and consistency of corpus data annotation. This allows the model to accurately understand the meaning of the annotations during the learning process, reducing confusion and errors caused by inconsistent annotations, thereby improving the model's accuracy and reliability. Based on the powerful language representation capabilities of the BERT model, deep feature extraction can be performed on recipe text to obtain rich global features. These global features not only contain the semantic information of the text but also integrate contextual relationships, providing high-quality feature inputs for subsequent entity recognition and relation extraction tasks, which helps improve model performance. Models for entity recognition and relation extraction tasks are constructed based on the first and second global features, respectively, allowing each model to focus on its specific task and fully utilize the corresponding feature information for optimization. By accurately extracting entity relationships and generating cooking flowcharts, the relationships between cooking steps and ingredients in a recipe can be clearly displayed, providing users with intuitive and easy-to-understand cooking guidance. These flowcharts help users better understand recipes, improving cooking success rates and efficiency. Therefore, this method performs digital modeling of the cooking process in recipes, converting the cooking process text into a more structured directed graph form, a task of great practical value. This transformation not only provides stronger data support for downstream tasks such as recipe recommendation and dietary assessment optimization, but also effectively overcomes problems in existing technologies such as missing cooking process information, insufficient data correlation, incomplete dietary assessment, and insufficient data support for downstream tasks.

[0064] Specifically, in step S1, a Chinese recipe process corpus dataset is constructed. The specific steps for constructing the dataset are as follows:

[0065] S110. In this embodiment of the invention, Python web scraping technology is used to collect natural language Chinese recipe text from Chinese recipe websites. Specifically, based on the Scrapy framework, a dynamic anti-scraping strategy is employed to scrape the mainstream Chinese recipe website "Xiachufang" and collect a large number of highly diverse recipes (for example, 304 unique recipes were collected). To ensure the comprehensiveness and representativeness of the corpus, the following key aspects are particularly emphasized during the collection process: first, the coverage of cuisines, comprehensively covering the eight major cuisines and local specialties; second, the cooking techniques, including major cooking processes such as stir-frying, stewing, steaming, and roasting; and third, the target audience, collecting recipes tailored to different age groups and health needs.

[0066] S120. Establish a labeling strategy for entity recognition and relation extraction tasks. Specifically, for entity recognition tasks, the labeling strategy adopted is as follows: ingredients, actions, cooking time, ingredient quantity, tools, tool status, ingredient status, and actions with food as the primary element. For example, see Table 1.

[0067] Table 1 Named Entity Recognition Table

[0068]

[0069]

[0070] Furthermore, for the relation extraction task, the annotation strategy adopted based on entity type is as follows: direct object of action, indirect object of action, next action, food / tool ​​equivalence, part of food / tool, food / tool ​​as the dominant direct object, next action node based on time / state, and other relations (the effect of cooking time, cooking temperature on action / food / tool, etc.). For example, see Table 2.

[0071] Table 2 Relationship Extraction

[0072] Label Full English name Detailed description T Targ direct target object I Indirect targ Indirect target object N Next action Next move F-eq Food-equal Consistent with the meaning of food T-eq Tool-equal The meaning of "tool" is consistent. F-comp Food complement Food-oriented target T-comp Tool complement Tool-oriented target F-part-of Food part of Part of food T-part-of Tool part of Part of the tools V-tm Verb for timing Next action node based on time / state O Other relationships Other relation types

[0073] S130. To ensure the quality and validity of the dataset, appropriate data preprocessing operations are performed, including stratified sampling of the dataset, dividing it into training and test sets. The specific steps are as follows:

[0074] S131. For text-based recipe data, data cleaning is required. Unicode regular expressions are used to remove illegal symbols in the data. A stop word list for the cooking field is constructed and redundant text is removed based on syntactic rule matching.

[0075] S132. Use TF-IDF (Term Frequency-Inverse Document Frequency) weighting to retain cooking-related paragraphs, and then perform one more manual cleaning to ensure semantic integrity. Store the cleaned recipe data in JSONL format (including the original recipe text, entity annotations, and relationship annotations).

[0076] S133. Use stratified random sampling to divide the above recipe data into a training set and a test set according to a preset ratio. In this embodiment, the preset ratio is set to 9:1.

[0077] S134. Perform 10-fold cross-validation on the training set, strictly following the principle of stratified sampling to ensure that the proportion distribution of each category in the original dataset is accurately maintained in each fold of the data.

[0078] In the above steps, during data collection, use Python crawler technology to collect 304 diverse recipes from websites such as "Xiachufang", covering eight major cuisines, various cooking techniques, and recipes for different target groups, ensuring the comprehensiveness and representativeness of the corpus, and providing a rich data foundation for model training. In terms of annotation strategies, clarify the annotation rules for entity recognition and relationship extraction, covering entities such as ingredients and actions, and relationships such as the direct object of an action, providing clear guidance for model training, improving the model's understanding and analysis ability of recipe texts, and enhancing accuracy and reliability. In the data preprocessing link, eliminate redundant text through data cleaning and stopword lists, use TF-IDF weighting to retain highly relevant paragraphs, and then perform manual cleaning to ensure semantic integrity, and store the data in JSONL format for easy model reading and processing. Stratified random sampling is used to divide the dataset and perform 10-fold cross-validation to ensure data quality and the effectiveness of model training, and improve the stability and generalization ability of the model.

[0079] Specifically, in step S2, use the BERT model based on Transformer to extract features from the text data in the training set and the test set. The specific steps are as follows:

[0080] S210. Extract the first global feature of each entity in the text. The specific steps are as follows:

[0081] S211. Obtain the text collections of the training set and the test set, and determine the composition of each recipe in the text collections; where the composition of each recipe includes a set of sentences.

[0082] S212. Based on the text collections and the composition of each recipe, clarify the goals of named entity recognition.

[0083] S213. Based on the goals, input the set of sentences into the encoder of the BERT model; extract features through the Transformer in the encoder to obtain the first feature.

[0084] S214. Fuse the first features and obtain the first global feature.

[0085] For example, given a collection of texts of the original recipe Among them, R i Let X represent the i-th recipe, and n represent the total number of recipes. For a single recipe, it consists of m statements, each statement X = {x1, x2, ..., x...}. N}, where N represents the number of characters. The purpose of named entity recognition is to identify each x. i Assign corresponding labels τ∪{O}, where τ is the entity type label and O is the non-entity label. For the set of statements X, input it into the encoder of the BERT model. In this embodiment, BERT consists of 12 Transformers, each of which can extract x. i Feature information from different layers, including syntactic features, positional encoding features, and semantic features, is extracted and fused, and the first global feature is obtained in the last layer.

[0086] S220. Extract the second global feature of the specified entity pair. The specific steps are as follows:

[0087] S221. Based on the entity recognition task, extract an entity set from each recipe; randomly select any two entities in the entity set to form an entity pair.

[0088] S222. Obtain the original statements of the entity pairs; mark the position of each entity in the original statements to obtain the labeled statements; input the labeled statements into the encoder of the BERT model to obtain the feature representation of each entity in the entity pair and obtain the global semantic features of the labeled statements.

[0089] S223. Map and regularize the feature representation to obtain a new feature representation.

[0090] S224. Concatenate the global semantic features and feature representations to obtain the second global feature.

[0091] For example, based on the entity recognition task requirements described above, given the set of entities contained in each recipe... Where k represents the total number of entities, e i It includes entity name, entity type, and span features (such as the start and end positions in recipe text). The goal of relation extraction is to predict the potential relationship (Relation(e)) between two entity pairs. i e j For entity pair P, retrieve the original statement from the recipe corresponding to each entity. And re-annotate the entity location in the statement. (i.e., the labeled statement), and then feeds it as input into the encoder of the BERT model to obtain the feature representations E1 and E2 of the two entities, which are then input into the entity FC layer (Fully Connected Layer, or FC layer for short) to perform feature mapping and regularization processing, E′ i =tanh(dropout(E i In this context, tanh(·) represents the activation function, and dropout(·) represents the regularization function. Additionally, the input is obtained... global semantic features E x By concatenating the two entity features mentioned above, we obtain the second global feature H = concat(E). x (E′1, E′2). Here, concat(·) represents the concatenation function, E x Represents global semantic features.

[0092] Steps S221 to S224 enhance the model's understanding of entity relationships in recipe text by combining local and global semantic features of entity pairs, thereby improving the accuracy of relationship prediction. Mapping and regularization improve the model's generalization and robustness, enabling it to maintain stable performance across different recipe texts. Furthermore, the optimized feature processing streamlines the model training process and improves efficiency.

[0093] In this embodiment of the invention, the BERT model includes a Transformer module, a fine-tuning module, and an embedding module. These modules work together to achieve efficient language understanding and feature extraction. The Transformer module is responsible for capturing the complex relationships in the input text; the fine-tuning module optimizes the model according to the specific task; and the embedding module is used to convert the text into a numerical form that the BERT model can process.

[0094] Furthermore, referring to Figure 2 As shown, Figure 2This diagram illustrates the structure of the deformer module in the BERT model. In the input layer, the input data consists of a sequence of words, including a special classification label [CLS] and subsequent word representations 1 through n. These words are first processed through an embedding layer, where each word (including the [CLS] label) is transformed into a corresponding embedding vector, labeled embedding 1, embedding 2, and so on, up to embedding n. Next, these embedding vectors enter the deformer layer for further processing. The diagram shows a two-layer deformer structure, each layer consisting of multiple deformer modules. In this structure, the output of the first deformer layer is passed to the second deformer layer as its input, forming a multi-layered deformer processing flow. Finally, in the output layer, the vectors processed by the multiple deformers are output, labeled vector 1, vector 2, and so on, up to vector n. The entire structure diagram demonstrates how the BERT model effectively processes the input word sequence and generates a corresponding vector representation for each word, which can be used for subsequent natural language processing tasks.

[0095] Furthermore, referring to Figure 3 As shown, Figure 3 This demonstrates how the fine-tuning module in the BERT model adjusts the output format according to different tasks. Specifically, in the sentence classification task, the output is a single result. The input consists of multiple vectors, including vector1, vector2, up to vectorn. In the named entity recognition task, the output corresponds to multiple results, each corresponding to a vector. The input also consists of multiple vectors, covering vector1, vector2, up to vectorn. Both tasks involve vector input and output, reflecting the structural characteristics of the fine-tuning module when handling different types of natural language processing tasks.

[0096] Furthermore, referring to Figure 4 As shown, Figure 4 This section illustrates the structure of the embedding module in the BERT model. This module includes positional encoding embeddings, which provide positional information for each element in the input sequence; sentence segmentation embeddings, which distinguish different sentences or paragraphs in the input sequence; and word embeddings, which convert the input words into vector representations. These three embedding parts are connected by a plus sign (+), indicating that they are additive in processing the input and together constitute the final embedding representation.

[0097] Specifically, in step S3, different models for the entity recognition task and the relation extraction task are constructed, and the specific steps are as follows:

[0098] S310. For entity recognition tasks, a bidirectional long short-term memory network and a stochastic conditional field module are added to the BERT model. Based on the first global feature... The specific steps for constructing the first model for the entity recognition task are as follows:

[0099] S311. Input the first global feature into the bidirectional long short-term memory network, capture the relationship between each token and the previous token, and obtain the first hidden state vector generated at each time step; capture the relationship between each token and the subsequent token, and obtain the second hidden state vector generated at each time step.

[0100] S312. Concatenate the first hidden state vector and the second hidden state vector at each time step to obtain the first feature representation.

[0101] S313. Input the first feature representation into the linear classification layer to obtain the first prediction score of each feature based on the label.

[0102] S314. Input the first prediction score into the conditional random field model, use the conditional random field model to model the sequence labeling problem, calculate the loss value; optimize the model based on the loss value to obtain the first model.

[0103] For example, the feature E extracted based on the BERT model i The data is input into a Bidirectional Long Short-Term Memory (Bi-LSTM) network. First, a forward LSTM is used to capture the relationship between the current token and the preceding text from left to right. Then, a backward LSTM is used to capture the relationship between the current token and the following text from right to left. The hidden states at each time step are concatenated to obtain the first feature representation. The first feature representation is input into the linear classification layer to obtain the first predicted score (logits represent the predicted score) of each feature based on the label. This score is then input into the conditional random field model to calculate the loss value. The specific calculation formula is as follows:

[0104]

[0105] Where x represents the predicted label, y represents the true label, S(x,y) represents the path score of x and y, and exp(·) represents the expectation function.

[0106] S320. For the relation extraction task, add an entity boundary linear network layer to the BERT model. Based on the second global feature H = concat(E... x The second model for the relation extraction task is constructed using the following steps: (E′1, E′2).

[0107] S321. Input the second global feature into the linear classification layer and calculate the second prediction score for each feature based on the label.

[0108] S322. Calculate the probability of the second predicted score using a probability distribution function. The probability distribution function can be a softmax function. This function takes the second predicted score as input and transforms it into a probability distribution by applying the softmax function, thus obtaining the predicted probability for each category. This process ensures that the probability values ​​output by the model not only reflect the relative likelihood of each category but also sum to 1, conforming to the basic properties of probability distributions.

[0109] S323. Calculate the total loss using the cross-entropy loss function based on the probability; construct the second model based on the total loss.

[0110] For example, the concatenated second global feature H is input into a linear classification layer to obtain the label-based logits for each feature. Then, the total loss is calculated using the cross-entropy function, with the specific formula as follows:

[0111]

[0112] Where C represents the total number of label categories, y i For the one-hot encoding of the real label, p i Let logits be the probability.

[0113] Steps S321 to S323 input the second global feature into the linear classification layer, accurately calculate logits, and optimize the model using the cross-entropy loss function, thereby improving classification accuracy and generalization ability. The clear loss calculation process enhances the model's interpretability while improving training efficiency. Furthermore, this step offers good flexibility and scalability, adapting to different model architectures and task requirements.

[0114] Specifically, in step S4, the trained model is used on the test set, and the F1 score, accuracy, and recall are used as evaluation metrics.

[0115] For example, accuracy is used to evaluate the proportion of true positives (correctly identified positives) among samples predicted as positive by the model. It reflects the proportion of relevant instances in the search results. The formula for calculating accuracy Ac is:

[0116]

[0117] Where T1 is a true example and T2 is a true negative example.

[0118] For example, recall measures the proportion of all actual positive instances that are correctly identified as positive by the model. It reflects the completeness of the relevant instances that the model can retrieve. The formula for recall (Re) is:

[0119]

[0120] T3 is a false negative.

[0121] For example, the F1-score is the harmonic mean of precision (Ac) and recall (Re). It combines these two metrics, providing a balanced measure, particularly useful in situations where class imbalance or penalties for both false positives and false negatives are important. The formula for calculating the F1-score is:

[0122]

[0123] These evaluation metrics allow for a comprehensive assessment of the model's performance on the test set, ensuring that the model not only has high accuracy but also good recall and F1 score, thus better meeting the needs in practical applications.

[0124] Specifically, in step S5, the entity relationships extracted above are used to create a flowchart using a Python script. The following are exemplary steps:

[0125] Step 1: Organize the extracted entity relationship data into a format suitable for generating a flowchart. For example, create a list of nodes and a list of edges, where nodes represent entities and edges represent relationships between entities.

[0126] Step 2: Choose a suitable Python library, such as matplotlib, networkx, or graphviz. These libraries provide rich APIs for creating and customizing flowcharts.

[0127] Step 3: Based on the organized data, create nodes and edges in the flowchart using the selected library. Set attributes for each node and edge, such as label, color, and shape.

[0128] Step 4: Choose a suitable layout algorithm, such as spring_layout or circular_layout, to determine the position of the nodes in the diagram, making the flowchart both aesthetically pleasing and easy to understand.

[0129] Steps 1 through 4 can efficiently visualize entity relationship data as a flowchart.

[0130] This invention, through steps S1 to S5, systematically constructs a multi-dimensional cooking process analysis system, achieving a deep digital reconstruction of Chinese cuisine cooking techniques. Utilizing a fine-grained entity annotation strategy, this system can comprehensively and accurately analyze the evolution of ingredient states, the timing of tool operations, and the dynamic correlation of heat, fully depicting complex cooking chains such as "stir-frying—oil application—thickening." Simultaneously, combined with dynamic relationship modeling technology, this system can accurately capture the causal relationship between nutrient loss patterns and process parameters, opening up a new path for scientific dietary assessment. This technical system not only achieves a leap from static text to dynamic process deduction but also provides solid core technical support for the intelligent transformation of central kitchens, the digital inheritance of cooking skills, and precision nutrition management.

[0131] To further illustrate the method described in the embodiments of the present invention, the following specific application steps are given:

[0132] Given a recipe and cooking process text, including: Step 1: Heat an iron wok over low heat and add 15ml of peanut oil; Step 2: Pour in the egg mixture and let it sit for 3 seconds, then quickly stir with chopsticks in a circular motion until the egg mixture is 70% solidified, then remove it from the wok immediately; Step 3: Add 5ml of oil to the wok, add the white parts of the scallions and sauté until fragrant, then add the tomatoes and stir-fry over medium heat for 30 seconds, then cover and simmer for 1 minute; Step 4: Add salt and sugar, and stir-fry until the tomatoes are semi-pure; Step 5: Return the eggs to the wok, gently stir-fry for 5 seconds to coat the egg pieces with the tomato sauce.

[0133] Step 1: Refer to Figure 5 As shown, the trained named entity recognition model is used to analyze the above process text and extract various entities. Specifically: iron pot, chopsticks, and original pot are tools; heating, adding, and pouring are actions; peanut oil, egg liquid, and scallion whites are food; 15ml and 5ml are ingredient amounts; low heat and medium heat are tool states; muddy and 70% are food states; 30 seconds, 1 minute, and 5 seconds are cooking times; and coating and solidifying are actions primarily related to the ingredients. Figure 5 In this context, T represents the direct target object (the object directly affected by the action), O represents other relationships (such as tool usage time, temperature setting, food status), N represents the connection to the next action, and I represents the indirect target object. See Table 2 above for details.

[0134] Step 2: Based on the entities extracted in Step 1, construct entity pairs and use the trained relation extraction model to predict the potential relationships between entity pairs. For example: wok -> heat: direct target object; turn -> add: next action; chopsticks -> draw circles: tool-driven direct target object; original pot -> replenish: indirect target object.

[0135] Through steps 1 and 2 above, this embodiment of the invention can convert complex cooking process text into structured data, providing more accurate and richer data support for subsequent downstream tasks such as recipe recommendation and dietary assessment optimization.

[0136] The method described in this invention encompasses a fine-grained annotation specification for 8 types of entities and 11 types of relationships, ranging from ingredient states to tool operations and cooking temperature variations. This design of a dynamically annotated cooking process dataset breaks through the limitations of static descriptions in traditional knowledge graphs, enabling the integration of more complex cooking techniques and methods. Based on semantic extraction of Chinese cooking processes, this invention employs two models with a Transformer architecture to implement named entity recognition and relationship extraction tasks, respectively, accurately identifying entities such as ingredients, tools, and actions, as well as the complex relationships between them, from cooking process text.

[0137] Example 2

[0138] Based on the same inventive concept, this embodiment provides a structured system for Chinese cooking processes. The principle of solving the problem is similar to that of the structured method for Chinese cooking processes provided in Embodiment 1, and the repetitions will not be repeated.

[0139] This embodiment provides a structured system for Chinese cuisine cooking processes, including:

[0140] The dataset construction module is used to acquire Chinese recipe text; based on the Chinese recipe text, it establishes annotation strategies for entity recognition and relation extraction tasks; based on the Chinese recipe text and annotation strategies, it constructs a Chinese recipe process corpus dataset, which includes a training set and a test set.

[0141] The feature extraction module is used to extract features from text data in the training and test sets based on the BERT model, and obtain the first global feature and the second global feature.

[0142] The model construction module is used to construct a first model for entity recognition task based on the first global features, and to construct a second model for relation extraction task based on the second global features.

[0143] Extract the model, which is used to train the first model and the second model respectively using the training set, and input the test set into the trained first model and the second model to extract entity relationships;

[0144] The output module is used to output a cooking flowchart based on entity relationships.

[0145] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0146] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0147] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0148] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0149] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.

Claims

1. A method for structuring the Chinese cooking process, characterized in that, include: Obtain Chinese recipe text, and based on the Chinese recipe text, establish annotation strategies for entity recognition and relationship extraction tasks; Based on the Chinese recipe text and the annotation strategy, a Chinese recipe flow corpus dataset is constructed. The Chinese recipe flow corpus dataset includes a training set and a test set; the annotation strategies for entity recognition and relation extraction tasks include: In the entity recognition task, the annotation strategy is to label ingredients, actions, cooking time, ingredient quantity, tools, tool status, ingredient status, and actions with food as the primary factor. In the relation extraction task, the annotation strategy is as follows: direct object of action, indirect object of action, next action, food or tool equivalent, part of food or tool, food or tool as the dominant direct object, and next action node based on time or state. Based on the BERT model, feature extraction is performed on the text data in the training set and the test set to obtain the first global feature and the second global feature; Based on the first global feature, a first model for the entity recognition task is constructed, specifically as follows: The first global feature is input into a bidirectional long short-term memory network to capture the relationship between each token and the previous token, thus obtaining the first hidden state vector generated at each time step; the relationship between each token and the subsequent token is captured to obtain the second hidden state vector generated at each time step. The first hidden state vector and the second hidden state vector at each time step are concatenated to obtain the first feature representation; The first feature representation is input into a linear classification layer to obtain the first prediction score of each feature based on the label. Based on the first prediction score, the sequence labeling problem is modeled, and the loss value is calculated; the model is optimized based on the loss value to obtain the first model; Based on the second global feature, a second model for the relation extraction task is constructed, specifically as follows: The second global feature is input into the linear classification layer, and a second prediction score based on the label is calculated for each feature. The probability of the second predicted score is calculated using a probability distribution function; Based on the stated probabilities, calculate the total loss using the cross-entropy loss function; based on the total loss, construct a second model; The first model and the second model are trained using the training set, and the test set is input into the trained first model and the second model to extract entity relationships. Based on the entity relationships, a cooking flowchart is obtained.

2. The method for structuring Chinese cuisine cooking processes according to claim 1, characterized in that, The step of extracting features from the text data in the training set and the test set based on the BERT model to obtain the first global feature is as follows: Obtain the text sets of the training set and the test set, and determine the composition of each recipe in the text set; wherein each recipe composition includes a set of statements; Based on the text set and each recipe, the target of named entity recognition is defined; Based on the stated objective, the set of statements is input into the encoder of the BERT model; features are extracted in the encoder through a deformer to obtain the first feature; The first feature is fused to obtain the first global feature.

3. The method for structuring Chinese cuisine cooking processes according to claim 1, characterized in that, The step of extracting features from the text data in the training set and the test set based on the BERT model to obtain the second global feature is as follows: Based on the entity recognition task, an entity set is extracted from each recipe; two entities are randomly selected from the entity set to form an entity pair. Obtain the original statement of the entity pair; mark the position of each entity in the original statement to obtain the labeled statement; input the labeled statement into the encoder of the BERT model to obtain the feature representation of each entity in the entity pair, and obtain the global semantic features of the labeled statement; The feature representation is mapped and regularized to obtain a new feature representation; The global semantic features and the new feature representation are concatenated to obtain the second global feature.

4. The method for structuring Chinese cooking processes according to claim 1, characterized in that, Before constructing the Chinese recipe process corpus dataset based on the Chinese recipe text and the annotation strategy, the data in the Chinese recipe text also needs to be cleaned. The cleaning steps are as follows: Regular expressions were used to remove illegal symbols from the data, a stop word list for the cooking field was constructed, and redundant text was removed based on syntactic rule matching. The recipe data after cleaning was obtained by using TF-IDF weighted retention of cooking-related segments; The recipe data is divided into training and testing sets according to a preset ratio using stratified random sampling.

5. The method for structuring the Chinese cooking process according to claim 1, characterized in that... The test set is input into the first and second models after training. When extracting entity relationships, the F1 score, accuracy, and recall are used as evaluation metrics.

6. The method for structuring Chinese cooking processes according to claim 1, characterized in that... The BERT model includes a deformer module, a fine-tuning module, and an embedding module. The deformer module is used to capture complex relationships in the input text; the fine-tuning module is used to optimize the BERT model according to different tasks; and the embedding module is used to convert the text into a numerical form that conforms to the processing of the BERT model.

7. A structured system for Chinese cooking processes, used to implement the structured method for Chinese cooking processes as described in any one of claims 1 to 6, characterized in that, include: The dataset building module is used to obtain Chinese recipe text; Based on the Chinese recipe text, establish annotation strategies for entity recognition and relationship extraction tasks; Based on the Chinese recipe text and the annotation strategy, a Chinese recipe process corpus dataset is constructed; wherein the Chinese recipe process corpus dataset includes a training set and a test set; The feature acquisition module is used to extract features from the text data in the training set and the test set based on the BERT model to obtain the first global feature and the second global feature. The model construction module is used to construct a first model for the entity recognition task based on the first global feature, and to construct a second model for the relationship extraction task based on the second global feature. Extract the model, which is used to train the first model and the second model respectively using the training set, and input the test set into the trained first model and the second model to extract entity relationships; The output module is used to output a cooking flowchart based on the entity relationships.

Citation Information

Patent Citations

  • Power grid business data entity relationship extraction method based on full word shielding

    CN116562293A

  • Menu recommendation method, device and system based on knowledge graph path

    CN119848336A