Function call generation method and computer readable storage medium
By matching and adjusting function call prompts and semantic understanding prompts, and combining historical question-and-answer data and verification models, the problem of inconsistency between function call generation results and user intent is solved, and the accuracy of generation results is improved.
Patent Information
- Application Number
- CN202510851118.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-09-12
AI Technical Summary
In the prior art, the problem of low accuracy caused by the inconsistent results generated by function calls and user intentions has not been effectively solved.
By matching function call generation results and reconstruction results, adjusting function call prompts and semantic understanding prompts until the two match, and using historical question-answering data and verification models to improve accuracy.
Improved the accuracy of function call generation results, especially when facing complex problems, it can generate corresponding function calls more accurately.
Smart Images

Figure CN120631341A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a function call generation method and a computer-readable storage medium. Background Art
[0002] Function calls allow models to perform complex tasks by calling specific functions. By introducing this mechanism, large language models can more flexibly respond to diverse tasks and requirements, thereby improving the model's scalability and adaptability. Function calls can connect large language models with external tools, enabling richer functionality. For example, by calling the weather API (Application Programming Interface), large language models can provide real-time weather information. Therefore, function calls have become a key feature of large language models, significantly enhancing their application capabilities.
[0003] In related technologies, the intent features in user conversations are directly extracted through large language models, or the user's intent features are determined by extracting user conversation summaries, and then function call results are generated based on the user's intent features. However, there are often cases where the function call generation results are inconsistent with the user's intent.
[0004] With respect to the problem of low accuracy of function calls generated for user questions in related technologies, no effective solution has been proposed so far. Summary of the Invention
[0005] Based on this, it is necessary to provide a function call generation method and a computer-readable storage medium that can solve the problem of low accuracy of function calls generated for user questions in response to the above technical problems.
[0006] In a first aspect, a method for generating a function call is provided in this embodiment, the method comprising:
[0007] Generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstruction result;
[0008] Matching the function call generation result and the reconstruction result;
[0009] In the case that the function call generation result does not match the reconstruction result, the function call prompt or the semantic understanding prompt is adjusted until the function call generation result generated based on the user question and the adjusted function call prompt matches the reconstruction result obtained by reconstructing the user question based on the adjusted semantic understanding prompt.
[0010] In some embodiments, generating a corresponding function call generation result according to a user question and a function call prompt, and reconstructing the user question based on the semantic understanding prompt to obtain a reconstructed result includes:
[0011] Determine whether there is target question-and-answer data associated with the user question in the historical question-and-answer data;
[0012] If yes, input the user question, the first function call prompt and the target question and answer data into the function call generation model to obtain the function call generation result;
[0013] The user question, the first semantic understanding prompt and the target question and answer data are input into the semantic understanding model to obtain the reconstruction result.
[0014] In some embodiments, generating a corresponding function call generation result according to a user question and a function call prompt, and reconstructing the user question based on the semantic understanding prompt to obtain a reconstructed result includes:
[0015] Determine whether there is target question-and-answer data associated with the user question in the historical question-and-answer data;
[0016] If not, inputting the user question and the second function call prompt into the function call generation model to obtain the function call generation result;
[0017] The user question and the second semantic understanding prompt are input into the semantic understanding model to obtain the reconstruction result.
[0018] In some embodiments, determining whether there is target question-and-answer data associated with the user question in the historical question-and-answer data includes:
[0019] Dividing the historical question-and-answer data based on a preset step size;
[0020] Obtaining a summary of each of the divided historical question-and-answer data;
[0021] Target question-answer data associated with the user question is obtained based on the similarity between the summary and the user question.
[0022] In some embodiments, obtaining target question-answer data associated with the user question based on the similarity between the summary and the user question includes:
[0023] When the similarity between each summary and the user question is less than a similarity threshold, shorten the preset step size, divide the historical question and answer data based on the shortened preset step size, and obtain summaries of each divided historical question and answer data until a summary with a similarity to the user question greater than the similarity threshold is found;
[0024] The target question and answer data is obtained according to the summaries whose similarity is greater than the similarity threshold.
[0025] In some embodiments, when the function call generation result does not match the reconstruction result, adjusting the function call hint or the semantic understanding hint includes:
[0026] In the case where the function call generation result does not match the reconstruction result, if the function call generation result is more accurate than the reconstruction result, adjusting the semantic understanding prompt;
[0027] In the event that the function call generation result does not match the reconstruction result, if the reconstruction result is more accurate than the function call generation result, the function call hint is adjusted.
[0028] In some embodiments, matching the function call generation result and the reconstruction result includes:
[0029] Inputting the user question, the function call generation result, and the reconstruction result into a verification model, and outputting a first accuracy level of the function call generation result, a second accuracy level of the reconstruction result, and a matching level between the function call generation result and the reconstruction result based on the verification model;
[0030] If the matching degree is greater than or equal to a matching degree threshold, determining that the function call generation result matches the reconstruction result;
[0031] When the degree of matching is less than the matching threshold, if the first degree of accuracy is greater than the second degree of accuracy, it is judged that the function call generation result and the reconstruction result do not match and the function call generation result is more accurate than the reconstruction result; if the first degree of accuracy is less than the second degree of accuracy, it is judged that the function call generation result and the reconstruction result do not match and the reconstruction result is more accurate than the function call generation result; if the first degree of accuracy is equal to the second degree of accuracy, the verification model re-outputs the first degree of accuracy and the second degree of accuracy.
[0032] In some embodiments, the user question, the function call generation result, and the reconstruction result are input into a verification model, and based on the verification model, a first accuracy level of the function call generation result, a second accuracy level of the reconstruction result, and a matching level between the function call generation result and the reconstruction result are output, respectively, including:
[0033] When there is target question and answer data associated with the user question in the historical question and answer data, the user question, the function call generation result, the reconstruction result and the target question and answer data are input into the verification model, and based on the verification model, the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively.
[0034] In some embodiments, if the first accuracy is equal to the second accuracy, then re-outputting the first accuracy and the second accuracy by the verification model includes:
[0035] Determining the number of times the verification model outputs the first accuracy level and the second accuracy level;
[0036] When the number of times reaches a preset value, it is determined that the function call generation result matches the reconstruction result.
[0037] In a second aspect, a computer-readable storage medium is provided in this embodiment, on which a computer program is stored. When the computer program is executed by a processor, the function call generation method described in the first aspect is implemented.
[0038] The above-mentioned function call generation method and computer-readable storage medium adjust the function call prompt or semantic understanding prompt based on the matching results of the function call result and the reconstruction result, thereby improving the accuracy of the corresponding function call results generated when facing complex user problems based on the reflection verification method, and solving the problem of low accuracy of function calls generated for user problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 An application environment diagram of a function call generation method in one embodiment;
[0040] Figure 2 A schematic flow chart of a function call generation method in one embodiment;
[0041] Figure 3 A flowchart of a method for generating a function call based on multi-path learning and large-model reasoning and reflection in one embodiment;
[0042] Figure 4 Schematic diagram of an adaptive multi-round dialogue associated dialogue selection module in one embodiment;
[0043] Figure 5 Schematic diagram of a single-round reflection verification module in one embodiment;
[0044] Figure 61. A schematic diagram of a flow chart of a multi-round reflection verification module in one embodiment;
[0045] Figure 7 It is a structural block diagram of a function calling device in one embodiment;
[0046] Figure 8 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0048] In the related art, obtaining function calls based on big language includes: inputting a prompt and function description into a big language model; based on the function description, the big language model outputs the selected function and related request parameters; the application calls the corresponding API based on the selected function and related request parameters output by the big language model, and outputs the API execution results. In the field of artificial intelligence, a prompt refers to text or instructions that provide input to the model to guide it to generate specific outputs. It is a text paragraph provided by the user when interacting with the model, used to describe the information, answer, text, etc. that the user wants to obtain from the model. The purpose of the prompt is to guide the model to produce the desired response, so as to better control the generated output. However, related art often suffers from inaccurate recognition of complex user intentions, resulting in inaccurate function calls. Based on this, this embodiment provides a method for generating function calls.
[0049] The function call generation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. The data storage system can store data that server 104 needs to process. The data storage system can be integrated on server 104, or placed on the cloud or other network servers. Through the terminal, or the interaction between the terminal and the server, a function call is generated based on the user's question to generate a result. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, etc. Server 104 can be implemented as a standalone server or a server cluster consisting of multiple servers.
[0050] In one embodiment, Figure 2 As shown, a function call generation method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:
[0051] Step S202: Generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstructed result;
[0052] The user question can be obtained through user input. Function call prompts and semantic understanding prompts are prompt texts used to help the model understand the intent of the user question. Optionally, the user question and function call prompt are input into a large language model, which outputs the function call generation result. The user question and semantic understanding prompt are input into another large language model, which reconstructs the user question to obtain a reconstructed result. Two different large language models can be trained based on function call generation data and user reconstruction data, respectively; or pre-built models can be directly used.
[0053] Step S204, matching function call generation result and reconstruction result;
[0054] Matching the function call generation result and the reconstruction result includes matching the similarity between the function call generation result and the reconstruction result. Optionally, similarity matching is performed using a pre-trained large language model or BERT model to obtain a matching result. Furthermore, based on the user's question, the more accurate model output between the function call generation result and the reconstruction result can be determined. Based on the accuracy of the function call generation result and the reconstruction result, the function call prompt and semantic understanding prompt can be selectively adjusted.
[0055] Step S206: When the function call generation result does not match the reconstruction result, adjust the function call prompt or the semantic understanding prompt until the function call generation result generated based on the user question and the adjusted function call prompt matches the reconstruction result obtained by reconstructing the user question based on the adjusted semantic understanding prompt.
[0056] After adjusting the function call prompt, when generating the function call generation result again, you can use the adjusted function call prompt text to refer to the previous matching result, thereby improving the accuracy of the function call generation result. After adjusting the semantic understanding prompt, when generating the reconstruction result again, you can use the adjusted semantic understanding prompt text to refer to the previous matching result, thereby improving the accuracy of the reconstruction result.
[0057] Optionally, after adjusting the function call prompt, the user question and the adjusted function call prompt are input into a large language model, which then outputs a new function call generation result. The user question and the adjusted semantic understanding prompt are then input into another large language model, which then reconstructs the user question to produce a new reconstructed result.
[0058] Furthermore, in the case where the function call generation result matches the reconstruction result, the function call generation result is used as the final answer to the user's question.
[0059] In the above-mentioned function call generation method, the function call results and the reconstruction results are matched based on the reflection verification method, the function call prompts or semantic understanding prompts are adjusted based on the matching situation, and the function call generation results are output in multiple rounds based on user questions, thereby improving the accuracy of generating corresponding function calls when facing complex user questions, and solving the problem of low accuracy of function calls generated for user questions.
[0060] In one embodiment, a corresponding function call generation result is generated according to the user question and the function call prompt, and the user question is reconstructed based on the semantic understanding prompt to obtain a reconstruction result, including: determining whether there is target question and answer data associated with the user question in the historical question and answer data; if so, inputting the user question, the first function call prompt and the target question and answer data into the function call generation model to obtain a function call generation result; inputting the user question, the first semantic understanding prompt and the target question and answer data into the semantic understanding model to obtain a reconstruction result.
[0061] A round of Q&A is defined as the function call result corresponding to the user question. Historical Q&A data includes user questions and corresponding function call results from each round prior to the current round. The target Q&A data is the Q&A data in the historical Q&A data that is relevant to the user question in the current round. Optionally, the similarity between the historical Q&A data and the user question is determined, and the historical Q&A data with the highest similarity is used as the target Q&A data.
[0062] The function call generation model is a large language model used to understand user questions and generate corresponding function calls. To adapt the large language model to the function call generation method, it can be fine-tuned using a dataset related to function call generation to obtain the function call generation model. The first function call prompt guides the function call generation model to refer to both the user question and the target question and answer data when generating function call generation results. This target question and answer data helps users better understand the user question and improves the accuracy of the function call generation results.
[0063] The semantic understanding model is also a large language model used to understand and reconstruct user questions. The first semantic understanding prompt guides the semantic understanding model in generating reconstruction results, taking into account both the user question and the target question-and-answer data. This helps users better understand the user question and improves the accuracy of the reconstruction results. The first function call prompt and the first semantic understanding prompt can be set and modified according to user needs.
[0064] In this embodiment, when executing multiple rounds of question and answer, by selectively obtaining the target question and answer data associated with the user's questions, when generating the function call generation results and the reconstruction structure, the associated context information can be fully obtained, redundant information can be removed, and the number of examples required to generate the function call generation results and the reconstruction structure can be reduced, thereby improving the accuracy of the function call generation results and the reconstruction structure output.
[0065] In one embodiment, a corresponding function call generation result is generated based on the user question and the function call prompt, and the user question is reconstructed based on the semantic understanding prompt to obtain a reconstruction result, including: determining whether there is target question and answer data associated with the user question in the historical question and answer data; if not, inputting the user question and the second function call prompt into the function call generation model to obtain a function call generation result; inputting the user question and the second semantic understanding prompt into the semantic understanding model to obtain a reconstruction result.
[0066] The second function call prompt guides the function call generation model to generate a function call generation result corresponding to the user's question. The first semantic understanding prompt guides the semantic understanding model to generate a reconstruction result that is different from the user's question but has the same intent. The second function call prompt and the second semantic understanding prompt can be set and modified according to user needs.
[0067] Furthermore, if only one round of question-and-answering has been performed, no historical question-and-answer data exists. Therefore, the following steps can be directly executed: generating third input data based on the user question and the second function call prompt, and inputting the third input data into the function call generation model to obtain a function call generation result; generating fourth input data based on the user question and the second semantic understanding prompt, and inputting the fourth input data into the semantic understanding model to obtain a reconstruction result.
[0068] In this embodiment, when there is no target question and answer data associated with the user question, after generating the function call generation result and the reconstruction result, the third input data is adaptively generated based on the user question and the second function call prompt, and the fourth input data is generated based on the user question and the second semantic understanding prompt, thereby avoiding interference from irrelevant data in the historical question and answer data.
[0069] In one embodiment, determining whether there is target question and answer data associated with the user question in the historical question and answer data includes: dividing the historical question and answer data based on a preset step size; obtaining a summary of each divided historical question and answer data; and obtaining the target question and answer data associated with the user question based on the similarity between the summary and the user question.
[0070] The preset step size can be pre-set or randomly selected. Optionally, an open-source semantic similarity model is used to input the abstract and user question into the semantic similarity model, which then outputs the similarities between multiple abstracts and the user. Target question-and-answer data corresponding to abstracts with similarities greater than a similarity threshold can be obtained. Alternatively, one or more abstracts with the highest similarity can be selected to obtain target question-and-answer data corresponding to the abstracts.
[0071] Optionally, after determining a summary with a high similarity to the user's question, the question and answer records corresponding to the summary are obtained, i.e., the divided historical question and answer data. The divided historical question and answer data can be used as target question and answer data. To further reduce redundant information, the user's question and answer and the divided historical question and answer data can be input into a multi-turn dialogue semantic understanding model, and the target question and answer data associated with the user's question can be selected from the divided historical question and answer data, and the target question and answer data can be output. The multi-turn dialogue semantic understanding model is a pre-built large language model, and the user selects the target question and answer data with a high degree of relevance to the user's question from the divided historical question and answer data.
[0072] In this embodiment, the historical question and answer data is divided by step size to obtain a summary of the historical question and answer data, and the target question and answer data associated with the user question is determined through the summary, thereby reducing the difficulty of semantic understanding and improving the efficiency of obtaining the target question and answer data.
[0073] Furthermore, in one embodiment, target question and answer data associated with the user question is obtained based on the similarity between the summary and the user question, including: when the similarity between each summary and the user question is less than a similarity threshold, shortening the preset step size, and dividing the historical question and answer data based on the shortened preset step size, obtaining the summary of each divided historical question and answer data, until there is a summary with a similarity to the user question greater than the similarity threshold; and obtaining the target question and answer data based on the summary with a similarity greater than the similarity threshold.
[0074] If the similarity between each summary and the user question is less than the similarity threshold, the step size may be too large, resulting in missing details of the summary and the user question, and reduced recognition accuracy. By shortening the step size and repartitioning the historical question and answer data, the accuracy of the similarity comparison can be improved.
[0075] Optionally, when the step size is 1, the summaries and user questions cannot be further divided. It can be determined that there is no target question and answer data associated with the user question in the historical question and answer data, and the following steps are performed: the user question and the second function call prompt are input into the function call generation model to obtain the function call generation result; the user question and the second semantic understanding prompt are input into the semantic understanding model to obtain the reconstruction result.
[0076] In this embodiment, the step size is shortened to avoid the problem of inaccurate similarity due to the large step size. By improving the similarity between each summary and the user question, more accurate target question and answer data is obtained.
[0077] In one embodiment, when the function call generation result does not match the reconstruction result, the function call prompt or the semantic understanding prompt is adjusted, including: when the function call generation result does not match the reconstruction result, if the function call generation result is more accurate than the reconstruction result, the semantic understanding prompt is adjusted; when the function call generation result does not match the reconstruction result, if the reconstruction result is more accurate than the function call generation result, the function call prompt is adjusted.
[0078] Among them, the adjusted semantic understanding prompts can take into account both user questions and historical question and answer information in the previous round of questions and answers that "the function call generation results are more accurate than the reconstruction results" when generating function call results.
[0079] Optionally, two different function call prompts are preset. During the first match, the prompt that does not contain a reference to the previous match result in the text is selected as input. In the case where the function call generation result and the reconstruction result are not matched for the first time, the prompt that contains a reference to the previous match result in the text is selected as the subsequent input. Similarly, two different semantic understanding prompts can be preset. During the first match, the prompt that does not contain a reference to the previous match result in the text is selected as input. In the case where the function call generation result and the reconstruction result are not matched for the first time, the semantic understanding prompt that contains a reference to the previous match result in the text is selected as the subsequent input.
[0080] In this embodiment, according to the specific situation where the function call generation result and the reconstruction result do not match, the function call prompt or the semantic understanding prompt is adjusted respectively to achieve the effect of obtaining more accurate function call generation results and reconstruction results.
[0081] In one embodiment, matching the function call generation result and the reconstruction result includes inputting the user question, the function call generation result, and the reconstruction result into a verification model, and outputting, based on the verification model, a first accuracy level of the function call generation result, a second accuracy level of the reconstruction result, and a degree of match between the function call generation result and the reconstruction result. A large language model may be used as the verification model.
[0082] If the matching degree is greater than or equal to the matching degree threshold, the function call generation result is determined to match the reconstruction result. In this case, the function call generation result can be directly used as the output of the user question and answer.
[0083] If the degree of match is less than the matching threshold, and the first degree of accuracy is greater than the second degree of accuracy, then it is determined that the function call generation result and the reconstruction result do not match, and the function call generation result is more accurate than the reconstruction result. Furthermore, because the function call generation result is more accurate than the reconstruction result, when regenerating the function call result and the reconstruction result, the semantic understanding prompt can be adjusted, while the function call prompt is not adjusted.
[0084] When the degree of matching is less than the matching threshold, if the first degree of accuracy is less than the second degree of accuracy, it is determined that the function call generation result and the reconstruction result do not match and the reconstruction result is more accurate than the function call generation result; further, since the function call generation result is more accurate than the reconstruction result, when re-executing the generation of the function call result and the reconstruction result, the function call prompt can be adjusted without adjusting the semantic understanding prompt.
[0085] If the degree of match is less than the matching threshold, and the first degree of accuracy is equal to the second degree of accuracy, the verification model re-outputs the first degree of accuracy and the second degree of accuracy. Optionally, the function call generation result and the reconstruction result are re-input into the verification model, and based on the verification model, the first degree of accuracy of the function call generation result, the second degree of accuracy of the reconstruction result, and the degree of match between the function call generation result and the reconstruction result are respectively output, and a comparison is performed based on the degree of match, the first degree of accuracy, and the second degree of accuracy.
[0086] Furthermore, multiple verification models can be selected: a pre-built large language model can be directly used as a verification model; the large language model can also be fine-tuned based on function call data and semantic understanding data as training data, and / or the large language model can be trained based on function call data and semantic understanding data as training data. Thus, the first accuracy, second accuracy and matching degree are obtained through multiple large language models with different training degrees. Optionally, the first accuracy, second accuracy and matching degree output by multiple verification models are respectively integrated through mathematical methods such as averaging, weighted averaging, and addition. And the reconstruction result and the function call result are matched based on the integrated first accuracy, second accuracy and matching degree. Using multiple verification models to score the matching degree of the function call generation result and the semantic understanding result can verify the generated function call generation result and semantic understanding result multiple times, thereby improving the credibility of the score.
[0087] In this embodiment, based on the comparison of the matching degree and the matching degree threshold, the first accuracy degree and the second accuracy degree are compared, and the two comparison results are combined to achieve accurate matching of the function call generation result and the reconstruction result, thereby improving the accuracy of generating corresponding function calls for complex user problems.
[0088] Furthermore, in one embodiment, the user question, the function call generation result, and the reconstruction result are input into the verification model, and the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively based on the verification model, including: when there is target question and answer data associated with the user question in the historical question and answer data, the user question, the function call generation result, the reconstruction result, and the target question and answer data are input into the verification model, and the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively based on the verification model.
[0089] When target question-and-answer data associated with the user's question exists in the historical question-and-answer data, using the target question-and-answer data as input can help the verification model better match the function call result with the reconstruction result. In this embodiment, when target question-and-answer data associated with the user's question exists in the historical question-and-answer data, verification is performed in conjunction with the target question-and-answer data to improve the credibility of the scoring.
[0090] In the case of target question and answer data, the function call generation results, reconstruction results and target question and answer data can also be input into multiple verification models respectively, which will not be elaborated again.
[0091] Furthermore, in one embodiment, if the first degree of accuracy is equal to the second degree of accuracy, the verification model will re-output the first degree of accuracy and the second degree of accuracy, including: determining the number of times the verification model outputs the first degree of accuracy and the second degree of accuracy; when the number reaches a preset value, determining whether the function call generation result matches the reconstruction result.
[0092] Among them, if the number is equal to the preset value, the verification model repeats the output too many times. Since the first accuracy level and the second accuracy level are the same, it is directly judged that the function call generation result and the reconstruction result match, thereby reducing the number of verification repetitions.
[0093] In this embodiment, based on the number of times the verification model outputs the first accuracy level and the second accuracy level, a matching conclusion between the function call generation result and the reconstruction result is obtained, and the number of dialogue rounds is controlled, thereby improving the efficiency of the function call generation process.
[0094] In one embodiment, Figure 3 A flowchart of a function call generation method based on multi-path learning and large model reasoning reflection is provided, such as Figure 3 As shown, the steps include:
[0095] Step S301 determines whether the user question Q1 is the first round of user questions. If so, step S302 is executed; if not, step S303 is executed. The first round of user questions Q1 refers to the first question asked by the user when the user starts interacting with the dialogue system.
[0096] Step S302: The nth round user question Q n Input into the adaptive multi-round dialogue association dialogue selection module to obtain the user question Q in the first n-1 rounds of dialogue and the nth round n Related user questions and system answers S QA .
[0097] Step S303, determine the associated dialogue S QA Is it empty? If S QA If S is empty, execute step S304. QA If it is not empty, execute step S305.
[0098] Step S304: input the user question Q1 into the single-round reflection verification module to obtain the function call generation result F1 and the reconstructed user question R1.
[0099] Step S305: QA And the nth round user question Qn is input into the multi-round reflection verification module to obtain the function call generation result F n and reformulate the user question R n Among them, the first n-1 rounds of dialogue and the nth round of user questions Q n Related user questions and system answers S QA That is, the target question and answer data in the above embodiment.
[0100] Take the current user question as an example, which is the nth round question. Figure 4 A schematic diagram of an adaptive multi-turn dialogue association dialogue selection module is provided.
[0101] Get historical question and answer data and get the previous n rounds of user questions and answers {Q1A1...Q n-1 A n-1}. Record the first n-1 rounds of user questions and answers {Q1A1...Q n-1 A n-1 Input into the question and answer record partitioning module to obtain the question and answer record partitioning result:
[0102] K1={Q1A1...Q t A t};
[0103] …;
[0104] K a ={Q (a-1)t+1 A (a-1)t+1...Q at A at};
[0105] K a+1 ={Q at+1 A at+1 ...Q n-1 A n-1}.
[0106] Where Q is the user question, A is the answer record, and n is the number of rounds of user questions and answers. The question-answer record partitioning module is used to partition the user questions and answers for the first n-1 rounds according to a step size t, where a is the result of n-1 divided by t, rounded down. For n>1, t is greater than or equal to 1 and less than or equal to n-1. The initial step size t can be a random number.
[0107] Partition the question and answer records into K1…K a , K a+1 Input into the semantic understanding summary model to obtain the summary results S1...S of the question and answer record partition a+1 Among them, the semantic understanding summary model is a large language model used to extract key information from text data and generate summaries.
[0108] The summary results of partitioning the question and answer records S1...S a+1 and the nth round user problem Q n This is input into a semantic similarity model, which then outputs the similarity between each summary and the user question in round n. Optionally, the semantic similarity model analyzes the similarity between two input texts. Open-source semantic similarity models such as Sentence-BERT and Word2Vec can be used.
[0109] Determine whether the similarity between the question and answer record partition summary output by the semantic similarity model and the user question in the nth round is greater than the similarity threshold T. If the semantic similarity model does not output a similarity greater than the similarity threshold T, determine whether the current step size t is 1. When t is 1, determine whether the previous n-1 rounds of dialogue and the user question Q in the nth round are similar. n Related user questions and answers QA Empty. When t is not 1, adjust the step size to t-1 until the semantic similarity model outputs a similarity greater than the threshold T.
[0110] If the semantic similarity model outputs a similarity greater than the threshold T, the summary result S corresponding to the similarity is obtained. p… S q As the historical question-answering data associated with the nth round of user questions, determine the summary result S p S q Corresponding Q&A records:
[0111] K p ={Q (p-1)j+1 A (p-1)j+1 ...Q pj A pj};
[0112] …
[0113] K q ={Q (q-1)j+1 A (q-1)j+1 ...Q qj A qj};
[0114] Among them, the question and answer record K p… K q The partition result of question and answer record (that is, the historical question and answer data after partition). p… K q Input into the multi-round dialogue semantic understanding model to obtain the user question Q in the first n-1 rounds of dialogue and the nth round n Related user questions and system answers S QA Among them, the multi-round dialogue semantic understanding model CM is a large language model.
[0115] Figure 5 A flow chart of a single-round reflection verification module is provided.
[0116] The single-round user problem Q i Input into the single-round function call prompt, wherein the single-round function call prompt is the second function call prompt in the above embodiment. Optionally, the single-round function call prompt is: "Generate a suitable function call based on the user question. It is known that: User question: {Q i}”; Then, the single-round function call prompt is input into the function call generation model FM to obtain the function call generation result R Fi Among them, the function call generation model FM is a large language model.
[0117] The single-round user problem Q i Input into the single-round semantic understanding prompt, wherein the single-round semantic understanding prompt is the second semantic understanding prompt in the above embodiment. Optionally, the single-round semantic understanding prompt is: "Understand user semantics and reconstruct user questions. It is known that: User question: {Q i}”; Then, the single-round semantic understanding prompt is input into the semantic understanding model LM, and the user question is reconstructed by the semantic understanding model LM to obtain the reconstruction result R of the user question. Li Among them, the semantic understanding model LM is a large language model.
[0118] The single-round user problem Qi , function call generates result R Fi and the reconstruction result R Li The input is fed into the multi-path verification module to obtain the verification results. The multi-path verification module can output three verification results: Case 1: Match; Case 2: Mismatch, where the semantic understanding model (LM) is more accurate; Case 3: Mismatch, where the function call generation model (FM) is more accurate.
[0119] If the verification result is "Case 1: Match", the function call generation result R is directly output Fi As the final function call result F i , reconstruction result R Li As the final reformulated user question R i .
[0120] If the verification result is "Case 2: Mismatch, the semantic understanding model LM result is more accurate", the prompt will be adjusted from the single-round function call prompt to the single-round function call reflection prompt. i and reformulate the user question R Li Enter the single-round function call reflection prompt. Optionally, the single-round function call prompt is: "The function call generation result is inaccurate. Please reconstruct the user question based on the semantic understanding model, reflect and regenerate the function call. Known: User question: {Q i}Semantic understanding model reconstructs user questions: {R Li}". Then, the single-round function call reflection prompt is input into the function call generation model FM to obtain the function call generation result R' Fi . Call the function to generate the result R' Fi and the reconstruction result R Li Input into the multi-path verification module to obtain the verification result until the verification result is "Case 1: Match". It can be understood that if the function call generates the result R' Fi and the reconstruction result R Li Match, then call the function to generate the result R' Fi As the final function call result F i , the reconstruction result R Li As the final reformulated user question R i .
[0121] If the verification result is "Case 3: Mismatch, the function call generation model FM result is more accurate", the prompt will be adjusted from the single-round semantic understanding prompt to the single-round semantic understanding reflection prompt, and the single-round user question Q iInput into the single-round semantic understanding reflection prompt. Optionally, the single-round semantic understanding reflection prompt is: "The reconstruction of the user question is inaccurate. Please reflect and reconstruct the user question based on the result returned by the function call generation model. Known: User question: {Q i}The function call generates the model and returns the result: {R Fi}". Then, the single-round semantic understanding reflection prompt is input into the semantic understanding model LM to obtain the reconstruction result R' of the user question Li . Call the function to generate the result R Fi And the reconstruction result R' Li Input into the multi-path verification module to obtain the verification result until the verification result is "Case 1: Match". It can be understood that if the function call generates the result R Fi And the reconstruction result R' Li Match, then call the function to generate the result R Fi As the final function call result F i , will reconstruct the user problem R' Li As the final reformulated user question R i .
[0122] Figure 6 A flowchart of a multi-round reflection verification module is provided.
[0123] The nth round user question Q n Input into the multi-round function call prompt, wherein the multi-round function call prompt is the first function call prompt in the above embodiment. Optionally, the multi-round function call prompt is: "Generate a suitable function call based on the user question. It is known that: User question: {Q n}". Then, multiple rounds of function call prompts are input into the function call generation model FM to obtain the function call generation result R Fn Among them, the function call generation model FM is a model obtained by fine-tuning the large language model through a dataset. The dataset includes function call generation results and corresponding user questions.
[0124] The nth round user question Q n , the first n-1 rounds of dialogue output by the adaptive multi-round dialogue association dialogue selection module and the nth round user question Q n Related user questions and system answers S QA (target question-answering data) is input into the multi-round semantic understanding prompt, wherein the multi-round semantic understanding prompt is the first semantic understanding prompt in the above embodiment. Optionally, the multi-round semantic understanding prompt is: "Understand user semantics and reconstruct user questions. Given: in the first n-1 rounds of dialogue and the nth round user question Q nRelated user questions and system answers S QA :{Q m A m Q k A k ...}The user problem in round n is {Q n}". Then, multiple rounds of semantic understanding prompts are input into the semantic understanding model LM, and the user question is reconstructed by the semantic understanding model to obtain the reconstruction result R of the user question. Ln Among them, the semantic understanding model LM is a large language model.
[0125] The first n-1 rounds of dialogue obtained by the adaptive multi-round dialogue association dialogue selection module and the n-th round user question Q n Related user questions and system answers S QA (target question answering data), the nth round user question Q n , function call generates result R Fn and the reconstruction result R Ln , and input it into the multi-path verification module to obtain the verification result. The multi-path verification module can output three verification results: Case 1: Match; Case 2: Mismatch, the semantic understanding model LM result is more accurate; Case 3: Mismatch, the function call generation model FM result is more accurate.
[0126] If the verification result is "Case 1: Match", the function call generation result R is directly output Fn As the final function call result F n , reconstruction result R Ln As the final reformulated user question R n .
[0127] If the verification result is "Case 2: Mismatch, the semantic understanding model LM result is more accurate", the prompt will be adjusted from the multi-round function call prompt to the multi-round function call reflection prompt, and the nth round user question Q n and reformulate the user question R Ln Enter the multi-round function call reflection prompt. Optionally, the multi-round function call prompt is: "The function call generation result is inaccurate. Please reconstruct the user question based on the semantic understanding model, reflect and regenerate the function call. It is known that the user question is {Q n}; The semantic understanding model reconstructs the user question into {R Ln}". Then, multiple rounds of function call reflection prompts are input into the function call generation model FM to obtain the regenerated function call generation result R' Fn . The regenerated function call generates the result R' Fn and the reconstruction result R LnInput into the multi-path verification module to obtain the verification result until the verification result is "Case 1: Match". It can be understood that if the function call generates the result R' Fn and the reconstruction result R Ln Match, then call the function to generate the result R' Fn As the final function call result F n , the reconstruction result R Ln As the final reformulated user question R n .
[0128] If the verification result is "Case 3: Mismatch, the function call generation model FM result is more accurate", the prompt will be adjusted from the multi-round semantic understanding prompt to the multi-round semantic understanding reflection prompt. The first n-1 rounds of dialogue obtained by the adaptive multi-round dialogue association dialogue selection module and the nth round user question Q n Related user questions and system answers S QA (target question answering data), the nth round user question Q n and the function call generates the result R Fn , input into the multi-round semantic understanding reflection prompt. Optionally, the multi-round semantic understanding reflection prompt is: "The reconstruction of the user question is inaccurate. Please reflect and reconstruct the user question according to the function call generation model return result; known: in the first n-1 rounds of dialogue and the nth round user question Q n Related user questions and system answers S QA {Q m A m Q k A k ...}; The user problem in round n is {Q n}; The result returned by the generated model in the nth round of function call is {R Fn}". Then, the single-round semantic understanding reflection prompt is input into the semantic understanding model LM to obtain the reconstruction result R' of the user question Ln . The reconstructed result R' Ln and the function call generates the result R Fn Input the multi-path verification module to obtain the verification result until the verification result is "Case 1: Match". It can be understood that if the function call generates the result R Fn And the reconstruction result R' Ln Match, then call the function to generate the result R Fn As the final function call result F n , the reconstruction result R' Ln As the final reformulated user question R n .
[0129] The following explains the three verification results output by the multi-path verification module in the single-round reflection verification module and the multi-round reflection verification module:
[0130] When performing verification in the single-round reflection verification module, the user question {Q n} in the nth round, the function call generation result R Fn returned by the function call generation model, and the reconstruction result R Ln returned by the semantic understanding model are input into multiple verification models {V1, V2, V3}. When performing verification in the multi-round reflection verification model, the user question {Q n} in the nth round, the function call generation result R Fn returned by the function call generation model, the reconstruction result R Ln returned by the semantic understanding model, the user questions and system answers S n related to the user question Q in the nth round in the previous n - 1 rounds of conversations QA are input into multiple verification models {V1, V2, V3}. Among them, the verification models include the large language model V1, the large language model V2 obtained by fine-tuning the judgment data using function call data and semantic understanding results, and the Bert model V3 obtained by training the judgment data using function call data and semantic understanding results. It can be understood that other types of models can also be selected as verification models according to application requirements.
[0131] The matching degrees of the function call generation results and the reconstruction results are scored by multiple verification models {V1, V2, V3} to obtain {m1, m2, m3}, where 0 < m1 < 1, 0 < m2 < 1, 0 < m3 < 1. The final matching degree M = α × m1 + βm2 + γm3 is calculated according to the matching degree scores {m1, m2, m3}, where α, β, γ are preset weights, 1 / 3 < α < 1, 0 < β < 1 / 3, 0 < γ < 1 / 3.
[0132] The accuracies of the function call generation results and the reconstruction results are scored by multiple verification models {V1, V2, V3} to obtain the function call generation model return result scores {sf1, sf2, sf3}, and the semantic understanding model result scores {sl1, sl2, sl3}. Among them, 0 < sf1 < 1, 0 < sf2 < 1, 0 < sf3 < 1, 0 < sl1 < 1, 0 < sl2 < 1, 0 < sl3 < 1. The final function call generation model return result score SF = α × sf1 + βsf2 + γsf3 is calculated according to the function call generation model return result scores {sf1, sf2, sf3}. The final semantic understanding model result score SL = α × Sl1 + βsl2 + γsl3 is calculated according to the semantic understanding model result scores {sl1, sl2, sl3}.
[0133] When the final matching degree M of the function call generation result returned by the function call generation model and the reconstruction result output by the semantic understanding model is greater than or equal to the matching degree threshold T m , it is determined that the function call generation result matches the reconstruction result, and the matching result corresponds to the above-mentioned case 1.
[0134] When the final matching degree M of the function call generation result returned by the function call generation model and the reconstruction result output by the semantic understanding model is less than the matching degree threshold T m When: If the final function call generation model return result score SF> the final semantic understanding model result score SL, then it is judged that there is no match, and the function call generation result output by the function call generation model FM is more accurate. The matching result corresponds to the above situation 3; If the final function call generation model return result SF is less than the final semantic understanding model result score SL, then the output is no match, and the reconstruction result output by the semantic understanding model LM is more accurate. The matching result corresponds to the above situation 2; If the final function call generation model return result score SF is equal to the final semantic understanding model result score SL, then repeat the steps of letting the verification model {V1V2V3} score until the output is situation 1, situation 2 or situation 2, or until the number of scoring reaches Q. If after the first scoring, the final matching degree M is less than the matching degree threshold T after Q-1 consecutive cycles. m , and the final function call generation model return result score SF is still equal to the final semantic understanding model result score SL, then the output is matched, and the matching result corresponds to the above case 1.
[0135] In this embodiment, an adaptive multi-round dialogue association selection module is used to select user questions and system answers related to the nth round in the first n-1 rounds of dialogue using a multi-round semantic understanding model. This can adaptively control the number of rounds of multi-round dialogues and select dialogues related to the nth round of user questions. While ensuring the completeness of context information, redundant information is removed to reduce the difficulty of semantic understanding.
[0136] Based on the multi-path reinforcement learning approach, the matching degree between the function call generation results and the semantic understanding results is scored through multiple verification models. The accuracy of the results returned by the function call generation model and the results returned by the semantic understanding model are scored respectively to obtain the function call generation model return result score and the semantic understanding model return result score. The generated function call generation results and semantic understanding results can be verified multiple times to improve the credibility of the scoring.
[0137] Through reflection, the verification results obtained based on the multi-path reinforcement learning method will be reflected on. If there is a mismatch, the wrong model will refer to the results of the correct model for reflection, and the results will be regenerated to eliminate the differences between semantic understanding and function call, so as to ensure that both semantic understanding model understanding and function call model generation are more accurate.
[0138] It should be understood that, although the steps in the flowcharts of the above embodiments are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the flowcharts of the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0139] Based on the same inventive concept, the present application also provides a function call device 700 for implementing the aforementioned method for generating function calls. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the function call device 700 provided below can be found in the above-mentioned limitations of the method for generating function calls, and will not be repeated here.
[0140] In one embodiment, Figure 7 As shown, a structural block diagram of a function calling device 700 is provided, as shown in FIG. Figure 7 As shown, it includes: a generation module 701, a matching module 702 and a reflection module 703, wherein:
[0141] A generation module 701 is configured to generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstructed result;
[0142] Matching module 702, used for matching function call generation results and reconstruction results;
[0143] The reflection module 703 is used to adjust the function call prompt or the semantic understanding prompt when the function call generation result does not match the reconstruction result, until the function call generation result generated according to the user question and the adjusted function call prompt matches the reconstruction result obtained by reconstructing the user question based on the adjusted semantic understanding prompt.
[0144] In some of the embodiments, the generation module 701 generates a corresponding function call generation result based on the user question and the function call prompt, and reconstructs the user question based on the semantic understanding prompt to obtain a reconstruction result, including: determining whether there is target question and answer data associated with the user question in the historical question and answer data; if so, inputting the user question, the first function call prompt and the target question and answer data into the function call generation model to obtain a function call generation result; inputting the user question, the first semantic understanding prompt and the target question and answer data into the semantic understanding model to obtain a reconstruction result.
[0145] In some of the embodiments, the generation module 701 generates a corresponding function call generation result based on the user question and the function call prompt, and reconstructs the user question based on the semantic understanding prompt to obtain a reconstruction result, including: determining whether there is target question and answer data associated with the user question in the historical question and answer data; if not, inputting the user question and the second function call prompt into the function call generation model to obtain a function call generation result; inputting the user question and the second semantic understanding prompt into the semantic understanding model to obtain a reconstruction result.
[0146] In some embodiments, the generation module 701 determines whether there is target question-and-answer data associated with the user question in the historical question-and-answer data, including: dividing the historical question-and-answer data based on a preset step size; obtaining a summary of each divided historical question-and-answer data; and obtaining the target question-and-answer data associated with the user question based on the similarity between the summary and the user question. Optionally, obtaining the target question-and-answer data associated with the user question based on the similarity between the summary and the user question includes: shortening the preset step size when the similarity between each summary and the user question is less than a similarity threshold, and dividing the historical question-and-answer data based on the shortened preset step size, obtaining a summary of each divided historical question-and-answer data, until a summary exists whose similarity to the user question is greater than the similarity threshold; and obtaining the target question-and-answer data based on the summary whose similarity is greater than the similarity threshold.
[0147] In some of the embodiments, the reflection module 703 adjusts the function call prompt or the semantic understanding prompt when the function call generation result does not match the reconstruction result, including: when the function call generation result does not match the reconstruction result, if the function call generation result is more accurate than the reconstruction result, adjusting the semantic understanding prompt; when the function call generation result does not match the reconstruction result, if the reconstruction result is more accurate than the function call generation result, adjusting the function call prompt.
[0148] In some embodiments, the matching module 702 matches the function call generation result and the reconstruction result, including: inputting the user question, the function call generation result, and the reconstruction result into the verification model, and outputting the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the matching degree between the function call generation result and the reconstruction result based on the verification model; when the matching degree is greater than or equal to the matching degree threshold, it is judged that the function call generation result and the reconstruction result match; when the matching degree is less than the matching degree threshold, if the first accuracy is greater than the second accuracy, it is judged that the function call generation result and the reconstruction result do not match and the function call generation result is more accurate than the reconstruction result; if the first accuracy is less than the second accuracy, it is judged that the function call generation result and the reconstruction result do not match and the reconstruction result is more accurate than the function call generation result; if the first accuracy is equal to the second accuracy, the verification model re-outputs the first accuracy and the second accuracy.
[0149] Optionally, the user question, the function call generation result, and the reconstruction result are input into the verification model, and the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively based on the verification model, including: when there is target question and answer data associated with the user question in the historical question and answer data, the user question, the function call generation result, the reconstruction result and the target question and answer data are input into the verification model, and the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively based on the verification model.
[0150] Optionally, if the first degree of accuracy is equal to the second degree of accuracy, the verification model re-outputs the first degree of accuracy and the second degree of accuracy, including: determining the number of times the verification model outputs the first degree of accuracy and the second degree of accuracy; when the number reaches a preset value, determining whether the function call generation result matches the reconstruction result.
[0151] Each module in the above-mentioned function call device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0152] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store user question and answer data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a function call generation method is implemented.
[0153] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0154] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0155] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0156] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0157] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.
[0158] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0159] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A method for generating a function call, characterized in that: The method comprises: Generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstruction result; Matching the function call generation result and the reconstruction result; In the case that the function call generation result does not match the reconstruction result, the function call prompt or the semantic understanding prompt is adjusted until the function call generation result generated based on the user question and the adjusted function call prompt matches the reconstruction result obtained by reconstructing the user question based on the adjusted semantic understanding prompt.
2. The method according to claim 1, characterized in that Generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstruction result, including: Determine whether there is target question-and-answer data associated with the user question in the historical question-and-answer data; If yes, input the user question, the first function call prompt and the target question and answer data into the function call generation model to obtain the function call generation result; The user question, the first semantic understanding prompt and the target question and answer data are input into the semantic understanding model to obtain the reconstruction result.
3. The method according to claim 1, characterized in that Generate a corresponding function call generation result according to the user question and the function call prompt, and reconstruct the user question based on the semantic understanding prompt to obtain a reconstruction result, including: Determine whether there is target question-and-answer data associated with the user question in the historical question-and-answer data; If not, inputting the user question and the second function call prompt into the function call generation model to obtain the function call generation result; The user question and the second semantic understanding prompt are input into the semantic understanding model to obtain the reconstruction result.
4. The method according to claim 2 or 3, characterized in that Determining whether there is target question-and-answer data associated with the user question in the historical question-and-answer data includes: Dividing the historical question-and-answer data based on a preset step size; Obtaining a summary of each of the divided historical question-and-answer data; Target question-answer data associated with the user question is obtained based on the similarity between the summary and the user question.
5. The method according to claim 4, characterized in that Obtaining target question-answer data associated with the user question based on the similarity between the summary and the user question, including: When the similarity between each summary and the user question is less than a similarity threshold, shorten the preset step size, divide the historical question and answer data based on the shortened preset step size, and obtain summaries of each divided historical question and answer data until a summary with a similarity to the user question greater than the similarity threshold is found; The target question and answer data is obtained according to the summaries whose similarity is greater than the similarity threshold.
6. The method according to claim 1, wherein When the function call generation result does not match the reconstruction result, adjusting the function call prompt or the semantic understanding prompt includes: In the case where the function call generation result does not match the reconstruction result, if the function call generation result is more accurate than the reconstruction result, adjusting the semantic understanding prompt; In the event that the function call generation result does not match the reconstruction result, if the reconstruction result is more accurate than the function call generation result, the function call hint is adjusted.
7. The method according to claim 1 or 6, characterized in that Matching the function call generation result and the reconstruction result includes: Inputting the user question, the function call generation result, and the reconstruction result into a verification model, and outputting a first accuracy level of the function call generation result, a second accuracy level of the reconstruction result, and a matching level between the function call generation result and the reconstruction result based on the verification model; If the matching degree is greater than or equal to a matching degree threshold, determining that the function call generation result matches the reconstruction result; When the degree of matching is less than the matching threshold, if the first degree of accuracy is greater than the second degree of accuracy, it is judged that the function call generation result and the reconstruction result do not match and the function call generation result is more accurate than the reconstruction result; if the first degree of accuracy is less than the second degree of accuracy, it is judged that the function call generation result and the reconstruction result do not match and the reconstruction result is more accurate than the function call generation result; if the first degree of accuracy is equal to the second degree of accuracy, the verification model re-outputs the first degree of accuracy and the second degree of accuracy.
8. The method according to claim 7, characterized in that Inputting the user question, the function call generation result, and the reconstruction result into a verification model, and outputting a first accuracy level of the function call generation result, a second accuracy level of the reconstruction result, and a matching level between the function call generation result and the reconstruction result based on the verification model, including: When there is target question and answer data associated with the user question in the historical question and answer data, the user question, the function call generation result, the reconstruction result and the target question and answer data are input into the verification model, and based on the verification model, the first accuracy of the function call generation result, the second accuracy of the reconstruction result, and the degree of matching between the function call generation result and the reconstruction result are output respectively.
9. The method according to claim 7, characterized in that If the first accuracy is equal to the second accuracy, the verification model outputs the first accuracy and the second accuracy again, including: Determining the number of times the verification model outputs the first accuracy level and the second accuracy level; When the number of times reaches a preset value, it is determined that the function call generation result matches the reconstruction result.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.