A method and system for intelligently completing dish ingredients based on a large model
By building a local knowledge base and using big model technology, intelligent completion of dish ingredient information is achieved, the problems of low efficiency and high error rate of traditional dish management systems are solved, the efficiency and accuracy of dish information entry are improved, and the user experience is improved.
Patent Information
- Application Number
- CN202510012424.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-04-04
AI Technical Summary
Traditional dish management systems require manual entry of large amounts of dish information, resulting in inefficiency, high error rate, and lack of intelligent data processing methods, making it difficult to meet the needs of modern catering management systems.
Using the intelligent complementary method of dishes with large models, we automatically obtain the ingredients and proportions of dishes by building a local knowledge base and using semantic vector models and dialogue models, and improve the efficiency and automation level of dishes with food information completion.
It significantly improves the efficiency and accuracy of dish information entry, reduces user manual operation steps, improves user experience, and provides technical support for modern smart catering management systems.
Smart Images

Figure CN119761487A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of dish supervision, and in particular to a method and system for intelligently completing dish ingredients based on a large model. Background Art
[0002] In modern smart catering management systems, efficient operation of the backend system is an important link to ensure the quality and management level of catering services. Among them, dish management is one of the core functions of the backend system, which involves the entry, update, maintenance and query of dish information. Traditional dish management systems often require manual entry of a large amount of dish information, including dish names, ingredients and their proportions, cooking steps, nutritional ingredients, etc. Although this method can meet basic needs, it has many problems and limitations in practical applications. In the traditional smart canteen backend management, when users add basic information of dishes, they need to manually enter the ingredients and proportions used for each dish. Usually three methods are used to achieve this: manual input, users need to enter the ingredients and proportions of each dish one by one. This method is cumbersome, inefficient and prone to errors; template import, the system provides a unified and fixed template, users fill in the ingredients and relevant required proportions corresponding to the dishes in the template in advance, and realize batch addition by importing the template; basic automation, some systems try to introduce basic automation functions, such as entering dish information through simple rule matching, but due to technical limitations, these methods have limited effects in practical applications and cannot completely solve the problems of low efficiency and high error rate.
[0003] The existing technology has the following problems: low efficiency, manual input and template import methods both consume a lot of time and manpower, especially when a large amount of dish information needs to be entered, the operation is cumbersome and repetitive; poor accuracy, input errors or information omissions are prone to occur during manual input, resulting in inaccurate dish information, thus affecting the normal operation of the catering system and user experience. Traditional systems rely too much on manual operations and lack intelligent data processing methods, resulting in low operating efficiency and high error rates; although basic automation functions have emerged, the ability to automatically process data is still limited, lacking intelligent and flexible solutions, and it is difficult to meet the needs of modern catering management systems. Summary of the invention
[0004] The purpose of the present invention is to provide a method and system for intelligent completion of dish ingredients based on a large model, which can intelligently identify dishes through a large language model, automatically obtain the required ingredients and their proportions, improve the efficiency and automation level of dish ingredient information completion, reduce the user's tedious manual operations, improve the user experience, and provide technical support for modern smart catering management systems.
[0005] To achieve the above object, the present invention provides the following solutions: A method for intelligently completing dish ingredients based on a large model, the method comprising the following steps: S1, building a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; S2: Input the name of the dish to be tested, use the semantic vector model to extract the embedding features of the dish to be tested, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data sets closest to the dish to be tested from the local knowledge base; S3, the name of the dish to be tested and the K historical dish names in the topK dish data set are combined into K text pairs, and the relevance scores of the K text pairs are sorted in descending order using the relevance rearrangement model to obtain the text pair with the highest relevance score; S4, determining whether the score of the text pair with the highest correlation score is greater than a specified threshold thresh, and if so, using the ingredients and proportions corresponding to the historical dish names in the text pair as the ingredient completion information of the dish name to be tested; S5, if not, use the trained and fine-tuned dialogue model to predict the ingredients and proportions corresponding to the tested dish name.
[0006] Furthermore, in S1, building a local knowledge base specifically includes: Collect historical data based on the existing catering management system, the historical data includes historical dish names, ingredients required for the corresponding dishes and the proportion of ingredients used; Perform data cleaning on historical data to remove duplicate and invalid data. At the same time, mark the historical dish names, the ingredients required for the corresponding dishes, and the proportion of the ingredients used. The total proportion of ingredients corresponding to a historical dish name is 1. The names of various historical dishes and their corresponding ingredients and proportions are stored in the MYSQL database in tabular form as a local knowledge base.
[0007] Furthermore, in S1, building a local knowledge base also includes: Collect food recipe data based on the open source recipe database, and regularly update and improve the historical dish names and their corresponding ingredients and proportions in the local knowledge base.
[0008] Furthermore, in S2, a semantic vector model is used to extract the embedding features of the dish name to be tested, and a distance measurement is performed with the embedding features of the historical dish names, specifically including: The cosine similarity is used to measure the distance between the embedding features of the tested dish name and the embedding features of the historical dish name. The formula of the cosine similarity is as follows: ; In the formula, F i The embedding feature vector representing the historical dish name, F t The embedding feature vector representing the name of the dish to be tested, f iz and f tz Indicates F i and F t The zth component of , m represents the length of the embedding feature vector.
[0009] Furthermore, the training and fine-tuning process of the large dialogue model is as follows: The local knowledge base built by S1 uses a variety of historical dish names and their corresponding ingredients and proportions as training sets, and converts the training sets into dialogue format data that meets the requirements of SFT fine-tuning; Input the conversational data into the benchmark large language model in the form of question and answer for iterative training; During the training process, the loss function is calculated and the model parameters are optimized and adjusted until the loss function value reaches the set target. The trained and adjusted benchmark large language model is saved as the dialogue large model for predicting dish ingredients and ingredient proportions.
[0010] Furthermore, during the training process, the loss function is calculated, specifically including: Input the dialogue format data into the benchmark large language model in the form of question and answer. A set of dialogue format data is used as an input text, and the model output result logits is obtained. Logits is a three-dimensional vector of N×L×V, where N represents the number of sentences input for one training, L represents the maximum length of the input sentence, V represents the number of sentences in the vocabulary, and labels is an N×L label. When calculating the loss function, it is necessary to perform label alignment on the model output logits and transform the dimension of the aligned data to obtain s_logits and s_labels. The dimension of s_logits is a two-dimensional vector of N*(L-1)×V, and s_labels is a one-dimensional vector of N*(L-1). The loss function calculation formula is as follows: loss=\frac {1} {M}\sum ^{M-1}_{i=0} {log\left ( {{s_logits}_{i,j}} \right )},\left ( {i\in \left [ {0,M-1} \right ],j\in \left [ {0,V-1} \right ]} \right ) Where M=N*(L-1), V represents the length of a one-dimensional vector; i represents the i+1th sample of the model, i.e., i starts recording the subscript from 0, when i=0, it represents the first sample; j represents the j+1th position in V, j starts recording from 0, when j=0, it represents the j+1th position of the V-dimensional vector, It indicates that the model predicts the predicted probability of the word at the j+1th position of the i+1th data. Indicates the true label of the data at the predicted i+1 position.
[0011] Furthermore, the benchmark large language model adopts the Qwen-7b model.
[0012] Furthermore, the semantic vector model adopts the open source bge-base-zh model, and the relevance reranking model adopts bge-reranker-base.
[0013] The present invention also provides a system for intelligently completing dish ingredients based on a large model, which is used in the method for intelligently completing dish ingredients based on a large model, comprising: A local knowledge base construction module is used to construct a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; The feature recognition and comparison module is used to extract the embedding features of the input dish name to be tested using the semantic vector model, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data set closest to the dish name to be tested from the local knowledge base; The relevance calculation and sorting module is used to form K text pairs with the names of the dishes to be tested and the K historical dish names in the topK dish data set, and use the relevance rearrangement model to sort the relevance scores of the K text pairs in descending order to obtain the text pair with the highest relevance score; The relevance judgment module is used to judge whether the score of the text pair with the highest relevance score is greater than the specified threshold thresh. If so, the ingredients and proportions corresponding to the historical dish names in the text pair are used as the ingredient completion information of the dish name to be tested; if not, the ingredients and proportions corresponding to the dish name to be tested are predicted using the local knowledge base; The dialogue model training and fine-tuning module is used to train and fine-tune the dialogue model for predicting dish ingredients and ingredient proportions.
[0014] According to the specific embodiments provided by the present invention, the method and system for intelligently completing dish ingredients based on a large model provided by the present invention disclose the following technical effects: Automatic intelligent completion of dish ingredients is achieved based on the local knowledge base and the large language model. First, matching is performed with the local knowledge base. The local knowledge base is verified and contains a large amount of historical dish names and the ingredients required for their corresponding dishes and the proportion of the ingredients used. Then, the powerful text analysis, feature extraction and parsing capabilities of the semantic vector large model are used to obtain the high-dimensional feature representation of the dish name text, and the distance measurement is used to calculate the text similar to the local knowledge base. After that, the similarity rearrangement large model is used to calculate the relationship between the texts, which can automatically obtain the ingredients of the dish and the related proportions. If similar dishes cannot be found locally, the dialogue large model is finally used to automatically identify and complete the detailed information such as the ingredients corresponding to the dish name and the required proportions, significantly improving the efficiency of data entry.
[0015] The present invention can make the addition of dishes more intelligent through model analysis, and integrates a variety of different large models, effectively improving the analysis results of a single model and the accuracy of the analysis. The whole method not only improves the accuracy of the analysis, but also automatically generates and verifies the information of dishes through the model, reduces the errors caused by manual input and the omission of information, and improves the accuracy and consistency of the data; and the intelligent processing method reduces the user's operation steps, and the user can focus more on the core business part when using the background management system. Through this intelligent method, not only the system is easier to use, but also the user experience is increased, providing users with more accurate and personalized services. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0017] Figure 1 is a flow chart of a method for intelligently completing dish ingredients based on a large model in an embodiment of the present invention; Figure 2 It is a flow chart of the method for training and fine-tuning a large dialogue model in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] The purpose of the present invention is to provide a method and system for intelligently completing dish ingredients based on a large model. By using a semantic vector large model and a rearrangement model to obtain similar dishes from a large number of dish names through a local knowledge base, the ingredients and proportion of the dish can be directly obtained; if there is no relevant text in the local knowledge base, a fine-tuned large model is used for analysis. The large language model has powerful language analysis and parsing understanding capabilities, and can output the analysis results of the dishes in a specified format. Model analysis can make the addition of dishes more intelligent, and the integration of multiple different models effectively improves the analysis results of a single model and improves the accuracy of the analysis. The entire method not only improves the accuracy of the analysis, but also reduces the user's tedious manual operations and improves the user's experience of the system.
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] like Figure 1 As shown, the method for intelligently completing dish ingredients based on a large model provided by the present invention comprises the following steps: S1, building a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; S2: Input the name of the dish to be tested, use the semantic vector model to extract the embedding features of the dish to be tested, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data sets closest to the dish to be tested from the local knowledge base; S3, the name of the dish to be tested and the K historical dish names in the topK dish data set are combined into K text pairs, and the relevance scores of the K text pairs are sorted in descending order using the relevance rearrangement model to obtain the text pair with the highest relevance score; S4, determining whether the score of the text pair with the highest correlation score is greater than a specified threshold thresh, and if so, using the ingredients and proportions corresponding to the historical dish names in the text pair as the ingredient completion information of the dish name to be tested; S5, if not, use the trained and fine-tuned dialogue model to predict the ingredients and proportions corresponding to the tested dish name.
[0022] Specifically, in S1, building a local knowledge base specifically includes: Collect historical data based on the existing catering management system, the historical data includes historical dish names, ingredients required for the corresponding dishes and the proportion of the ingredients used; for example, the dish of tomato scrambled eggs requires the ingredients of tomato and egg, with a proportion of 70% and 30% respectively; Perform data cleaning on historical data to remove duplicate and invalid data. At the same time, mark the historical dish names, the ingredients required for the corresponding dishes, and the proportion of the ingredients used. The total proportion of ingredients corresponding to a historical dish name is 1. The names of various historical dishes and their corresponding ingredients and proportions are stored in a MYSQL database (not limited to MySQL database, but can be other structured databases) in tabular data as a local knowledge base.
[0023] Among them, based on the semantic vector model (such as the open source bge-base-zh model), the embedding of the historical dish names in the local knowledge base is obtained. The embedding is a one-dimensional feature vector and can be expressed as F i =(f i1 ,f i2 ,f i3 ,...,f im ), m is the length of the feature vector, and chroma is used for storage for fast retrieval.
[0024] Additionally, it includes: Collect food recipe data based on the open source recipe database, and regularly update and improve the historical dish names and their corresponding ingredients and proportions in the local knowledge base.
[0025] For the names of dishes to be tested, local retrieval is first performed, that is, embedding is extracted using a semantic vector model, and the top K dishes that are closest to the historical dish names stored in the local knowledge base are obtained.
[0026] Specifically, in S2, a semantic vector model is used to extract the embedding features of the dish name to be tested, and a distance measurement is performed with the embedding features of the historical dish names, specifically including: The cosine similarity is used to measure the distance between the embedding features of the tested dish name and the embedding features of the historical dish name. The formula of the cosine similarity is as follows: ; In the formula, F i The embedding feature vector representing the historical dish name, F t The embedding feature vector representing the name of the dish to be tested, f iz and f tz Indicates F i and F t The zth component of , m represents the length of the embedding feature vector.
[0027] Specifically, in S3, the name of the dish to be tested and the K historical dish names in the topK dish data set are combined to form K text pairs, which can be expressed as (name of the dish to be tested, historical dish name 1), (name of the dish to be tested, historical dish name 2), ..., (name of the dish to be tested, historical dish name K), and are respectively input into the relevance rearrangement model to calculate the relevance of the text pairs. The output result is a numerical value. The relevance rearrangement model used in the embodiment of the present invention is bge-reranker-base, and other rearrangement models can be selected to arrange the output results of the K dish pairs in descending order, and obtain the result of the text pair with the highest similarity and a score greater than the specified threshold thresh as the final retrieval result, where thresh is a decimal, generally set to 0. If the local search has a result with a threshold greater than thresh, then it is used as the final retrieval result, and the corresponding ingredients and ingredient proportions are retrieved from the MySQL database as the final output result.
[0028] If the local search fails to obtain results, the trained dialogue model is used to obtain the ingredients of the dish.
[0029] The training and fine-tuning process of the large dialogue model is as follows: The local knowledge base built by S1 uses a variety of historical dish names and their corresponding ingredients and proportions as training sets, and converts the training sets into dialogue format data that meets the requirements of SFT fine-tuning; The dialogue format data is input into the benchmark large language model in the form of questions and answers for iterative training; the dish names, ingredients, and ingredient ratios are sorted into tabular data. The input data for the training model is relatively simple, and the SFT (Suppervised fine-tuning) fine-tuning method is adopted, so the final input is in the form of questions and answers. The combined data is {"human":"What are the ingredients and corresponding ingredient ratios required for the preparation of xxx dish?","assistant":"Dish XXX (dish name) requires ingredients 1 and 2, of which ingredient 1 needs to be used in an amount of x1% and ingredient 2 needs to be used in an amount of x2%."}. For the public data sets collected on the Internet, the relevant recipes can be composed of the training set input format of {"human":"How to prepare xxx dish?","assistant":(description text related to dish preparation)}; During the training process, the loss function is calculated and the model parameters are optimized and adjusted until the loss function value reaches the set target. The trained and adjusted benchmark large language model is saved as the dialogue large model for predicting dish ingredients and ingredient proportions.
[0030] Specifically, the training process is as follows: Pre-training is performed based on the pytorch framework, and the benchmark large language model used is the Qwen-7b model. The model is fine-tuned and updated to obtain a parsing model related to dish parsing. The model training process is as follows: the organized dialogue data is input into the model, and a group of dialogues is used as an input text to obtain the model output logits. Logits is a three-dimensional vector of N×L×V, where N represents the number of sentences input for one training, and L represents the maximum length of the input sentence, which is generally a multiple of 512. The present invention sets L=1024, and V represents the number of words in the vocabulary. In the present invention, V=151936, and labels is an N×L label. Calculate the loss function and update the model weight parameters. When calculating the loss function, it is necessary to perform label alignment on the logits output result, and transform the aligned data into a dimension to obtain a s_logits and s_labels. The dimension of s_logits is a two-dimensional vector of N*(L-1)×V, and s_labels is a one-dimensional vector of N*(L-1).
[0031] The loss function calculation formula is as follows: loss=\frac {1} {M}\sum ^{M-1}_{i=0} {log\left ( {{s_logits}_{i,j}} \right )},\left ( {i\in \left [ {0,M-1} \right ],j\in \left [ {0,V-1} \right ]} \right ) Where M=N*(L-1), V represents the length of a one-dimensional vector; i represents the i+1th sample of the model, i.e., i starts recording the subscript from 0, when i=0, it represents the first sample; j represents the j+1th position in V, j starts recording from 0, when j=0, it represents the j+1th position of the V-dimensional vector, It indicates that the model predicts the predicted probability of the word at the j+1th position of the i+1th data. Indicates the true label of the data at the predicted i+1 position.
[0032] As the loss function gradually decreases, the weight parameters of the model are dynamically updated until the loss becomes stable or reaches the preset target (for example, the training iteration conditions are met). The fine-tuned model is saved as the large language model for predicting dish ingredients and ingredient proportions.
[0033] After fine-tuning the large dialogue model, it can be directly used for forward reasoning and prediction.
[0034] In order to facilitate the output of the large model, the prompt word engineering operation is performed before the model input, that is, the prompt is set to prompt this template, and the prompt of the large model is set to specify the format of the model output. The prompt is [{"role":"user","content":"""Please tell me what ingredients are in the dish and give the proportion of the ingredients. The total proportion is 100%, and the result is output in json format. The keyword key is the name of the ingredient, and the value value is the percentage of the ingredient. For example, if you enter tomato scrambled eggs, it will return {"tomato":70%,"egg":30%}"""} {"role":"assisstant","content":"OK"}], then directly enter the name of the dish to get the output result outputs, parse the output text, remove the redundant second text, intercept the part contained in {}, extract the corresponding ingredients and the proportion of ingredients, and the final output result is as follows: {"tomato":70%,"egg":30%}. If there is no {}, the relevant results cannot be returned in the end.
[0035] The present invention also provides a system for intelligently completing dish ingredients based on a large model, which is used in the method for intelligently completing dish ingredients based on a large model, comprising: A local knowledge base construction module is used to construct a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; The feature recognition and comparison module is used to extract the embedding features of the input dish name to be tested using the semantic vector model, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data set closest to the dish name to be tested from the local knowledge base; The relevance calculation and sorting module is used to form K text pairs with the names of the dishes to be tested and the K historical dish names in the topK dish data set, and use the relevance rearrangement model to sort the relevance scores of the K text pairs in descending order to obtain the text pair with the highest relevance score; The relevance judgment module is used to judge whether the score of the text pair with the highest relevance score is greater than the specified threshold thresh. If so, the ingredients and proportions corresponding to the historical dish names in the text pair are used as the ingredient completion information of the dish name to be tested; if not, the ingredients and proportions corresponding to the dish name to be tested are predicted using the local knowledge base; The dialogue model training and fine-tuning module is used to train and fine-tune the dialogue model for predicting dish ingredients and ingredient proportions.
[0036] In summary, the technical advantages of the method and system for intelligently completing dish ingredients based on a large model provided by the present invention are as follows: (1) The traditional method of completing dishes requires manual addition or filling in a template before importing. This process requires a lot of manpower and time, and the operation is cumbersome, highly repetitive and inefficient. Switching to an automatic completion method can improve data entry efficiency and reduce errors and information omissions caused by manual input.
[0037] (2) By using the semantic vector model and the rearrangement model to obtain similar dishes from a large number of dish names through the local knowledge base, the ingredients and proportion of the dishes can be directly obtained; if there is no relevant text in the local knowledge base, the fine-tuned large model is used for analysis. The large language model has powerful language analysis and parsing understanding capabilities and can output the analysis results of dishes in the specified format. Model analysis can make the addition of dishes more intelligent, and the integration of multiple different models effectively improves the analysis results of a single model and improves the accuracy of the analysis. The entire method not only improves the accuracy of the analysis, but also reduces the user's tedious manual operations and improves the user's experience of the system.
[0038] The present invention also provides an electronic device, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method for intelligent completion of dish ingredients based on a large model as described above.
[0039] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for intelligently completing dish ingredients based on a large model, characterized in that: The following steps are involved: S1, building a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; S2: Input the name of the dish to be tested, use the semantic vector model to extract the embedding features of the dish to be tested, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data sets closest to the dish to be tested from the local knowledge base; S3, the name of the dish to be tested and the K historical dish names in the topK dish data set are combined into K text pairs, and the relevance scores of the K text pairs are sorted in descending order using the relevance rearrangement model to obtain the text pair with the highest relevance score; S4, determining whether the score of the text pair with the highest correlation score is greater than a specified threshold thresh, and if so, using the ingredients and proportions corresponding to the historical dish names in the text pair as the ingredient completion information of the dish name to be tested; S5, if not, use the trained and fine-tuned dialogue model to predict the ingredients and proportions corresponding to the tested dish name.
2. The method for intelligently completing dish ingredients based on a large model according to claim 1 is characterized in that: In S1, building a local knowledge base specifically includes: Collect historical data based on the existing catering management system, the historical data includes historical dish names, ingredients required for the corresponding dishes and the proportion of ingredients used; Perform data cleaning on historical data to remove duplicate and invalid data. At the same time, mark the historical dish names, the ingredients required for the corresponding dishes, and the proportion of the ingredients used. The total proportion of ingredients corresponding to a historical dish name is 1. The names of various historical dishes and their corresponding ingredients and proportions are stored in the MYSQL database in tabular form as a local knowledge base.
3. The method for intelligently completing dish ingredients based on a large model according to claim 2 is characterized in that: In S1, building a local knowledge base also includes: Collect food recipe data based on the open source recipe database, and regularly update and improve the historical dish names and their corresponding ingredients and proportions in the local knowledge base.
4. The method for intelligently completing dish ingredients based on a large model according to claim 2 is characterized in that: In S2, a semantic vector model is used to extract the embedding features of the dish name to be tested, and a distance measurement is performed with the embedding features of the historical dish names, specifically including: The cosine similarity is used to measure the distance between the embedding features of the tested dish name and the embedding features of the historical dish name. The formula of the cosine similarity is as follows: ; In the formula, F i The embedding feature vector representing the historical dish name, F t The embedding feature vector representing the name of the dish to be tested, f iz and f tz Indicates F i and F t The zth component of , m represents the length of the embedding feature vector.
5. The method for intelligently completing dish ingredients based on a large model according to claim 1 is characterized in that: The training and fine-tuning process of the large dialogue model is as follows: The local knowledge base built by S1 uses a variety of historical dish names and their corresponding ingredients and proportions as training sets, and converts the training sets into dialogue format data that meets the requirements of SFT fine-tuning; Input the conversational data into the benchmark large language model in the form of question and answer for iterative training; During the training process, the loss function is calculated and the model parameters are optimized and adjusted until the loss function value reaches the set target. The trained and adjusted benchmark large language model is saved as the dialogue large model for predicting dish ingredients and ingredient proportions.
6. The method for intelligently completing dish ingredients based on a large model according to claim 5 is characterized in that: During the training process, the loss function is calculated, specifically including: The dialogue format data is input into the benchmark large language model in the form of question and answer. A set of dialogue format data is used as an input text to obtain the model output result logits. Logits is a three-dimensional vector of N×L×V, where N represents the number of sentences input for one training, L represents the maximum length of the input sentence, V represents the number of sentences in the vocabulary, and labels is an N×L label. When calculating the loss function, it is necessary to perform label alignment on the model output logits and transform the dimension of the aligned data to obtain s_logits and s_labels. The dimension of s_logits is a two-dimensional vector of N*(L-1)×V, and s_labels is a one-dimensional vector of N*(L-1). The loss function calculation formula is as follows: loss=\frac {1} {M}\sum ^{M-1}_{i=0} {log\left ( {{s_logits}_{i,j}} \right )},\left ( {i\in \left [ {0,M-1} \right ],j\in \left [ {0,V-1} \right ]} \right ) Where M=N*(L-1), V represents the length of a one-dimensional vector; i represents the i+1th sample of the model, i.e., i starts recording the subscript from 0, when i=0, it represents the first sample; j represents the j+1th position in V, j starts recording from 0, when j=0, it represents the j+1th position of the V-dimensional vector, It indicates that the model predicts the predicted probability of the word at the j+1th position of the i+1th data. Indicates the true label of the data at the predicted i+1 position.
7. The method for intelligently completing dish ingredients based on a large model according to claim 5 is characterized in that: The benchmark large language model adopts the Qwen-7b model.
8. The method for intelligently completing dish ingredients based on a large model according to claim 1, characterized in that: The semantic vector model adopts the open source bge-base-zh model, and the relevance reranking model adopts bge-reranker-base.
9. A system for intelligently completing dish ingredients based on a large model, used to execute the method for intelligently completing dish ingredients based on a large model according to any one of claims 1 to 8, characterized in that: include: A local knowledge base construction module is used to construct a local knowledge base, wherein the local knowledge base includes a plurality of historical dish names and their corresponding ingredients and proportions, and embedding features of the historical dish names extracted based on a semantic vector model; The feature recognition and comparison module is used to extract the embedding features of the input dish name to be tested using the semantic vector model, and measure the distance with the embedding features of the historical dish names, and obtain the topK dish data set closest to the dish name to be tested from the local knowledge base; The relevance calculation and sorting module is used to form K text pairs with the names of the dishes to be tested and the K historical dish names in the topK dish data set, and use the relevance rearrangement model to sort the relevance scores of the K text pairs in descending order to obtain the text pair with the highest relevance score; The relevance judgment module is used to judge whether the score of the text pair with the highest relevance score is greater than the specified threshold thresh. If so, the ingredients and proportions corresponding to the historical dish names in the text pair are used as the ingredient completion information of the dish name to be tested; if not, the ingredients and proportions corresponding to the dish name to be tested are predicted using the local knowledge base; The dialogue model training and fine-tuning module is used to train and fine-tune the dialogue model for predicting dish ingredients and ingredient proportions.