Method and device for determining length loss
By introducing a length loss determination method in machine reading comprehension model training, including the starting position, the end position and the length loss, the problem of inaccurate losses in the prior art is solved and the prediction accuracy of the model is improved.
Patent Information
- Application Number
- CN202111629548.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-01-29
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2039-01-29
AI Technical Summary
The losses considered during the training process of existing machine reading comprehension models are not accurate enough to fully reflect the loss of predicting the answer, resulting in a low accuracy rate of predicting the answer.
A length loss determination method is proposed. By obtaining training samples, generating predicted answers, and determining the accuracy loss of the predicted answer relative to the target answer, including the starting position loss, the end position loss and the length loss, based on these losses, the loss function is determined and the reading comprehension model is optimized.
The accuracy and efficiency of reading comprehension model training are improved, so that the trained model has a higher accuracy rate when predicting answers.
Smart Images

Figure CN114298310B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a method for determining length loss. The present application also relates to a device for determining length loss, a computing device, and a computer-readable storage medium. Background Art
[0002] Natural language processing is the study of various theories and methods to achieve effective communication between humans and computers using natural language. With the rapid development of natural language processing, machine reading comprehension, as a hot direction in the field of natural language processing, has also received widespread attention. Machine reading comprehension is a study dedicated to teaching machines to read human language and understand its connotation. The machine reading comprehension task focuses more on the understanding of the text of the passage. The machine must learn relevant information from the passage itself, rather than using preset world knowledge and common sense to answer questions, so it is more challenging.
[0003] At present, an important way to train machines to read and understand human language is to establish a machine reading comprehension model, and then train the established machine reading comprehension model to obtain the desired machine reading comprehension model, so as to find the answer to the question in the text fragment based on the trained machine reading comprehension model. However, the loss considered in the current machine reading comprehension model training process is not accurate enough to fully reflect the loss of predicting the answer, and the accuracy of the final predicted answer is low. Summary of the invention
[0004] In view of this, the embodiment of the present application provides a length loss determination method and a reading comprehension model training method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a length loss determination device, a reading comprehension model training device, a computing device, and a computer-readable storage medium.
[0005] This application provides a reading comprehension model training method, including:
[0006] Obtain training samples including sample questions and their corresponding target answers in sample articles;
[0007] Generate a predicted answer to the sample question by inputting the training sample into a reading comprehension model;
[0008] determining a loss in accuracy of the predicted answer relative to the target answer;
[0009] A loss function is determined based on the accuracy loss, and the reading comprehension model is optimized using the loss function.
[0010] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0011] Determine a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0012] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0013] Based on the start position loss, the end position loss, and the length loss, an accuracy loss of the predicted answer is determined.
[0014] Optionally, determining a starting position loss of a starting position predicted by the predicted answer in the sample article, and an ending position loss of a ending position predicted by the predicted answer in the sample article, comprises:
[0015] Calculating the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer;
[0016] Determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution;
[0017] The starting position loss of the predicted starting position is determined based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and the ending position loss of the predicted ending position is determined based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
[0018] Optionally, the predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article;
[0019] The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0020] Optionally, the starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer;
[0021] The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
[0022] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0023] Determine an article matrix corresponding to the sample article; the character units in the sample article correspond one to one with the elements in the article matrix;
[0024] Determine the predicted starting element and predicted ending element corresponding to the predicted starting position and predicted ending position of the predicted answer in the article matrix, and the target starting element and target ending element corresponding to the starting position and ending position of the target answer in the article matrix;
[0025] Determine a predicted answer vector from the predicted start element to the predicted end element, and a target answer vector from the target start element to the target end element;
[0026] The distance between the predicted answer vector and the target answer vector is calculated as the length loss of the predicted answer.
[0027] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0028] Determine the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0029] Calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0030] A byte length difference between the byte length of the predicted answer and the byte length of the target answer is determined as the length loss of the predicted answer.
[0031] Optionally, determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss, and the length loss includes:
[0032] A weighted sum of the starting position loss, the ending position loss and the length loss is calculated as the accuracy loss of the predicted answer.
[0033] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0034] Determine the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0035] Comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer;
[0036] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0037] An accuracy loss of the predicted answer is determined based on the position loss, the semantic loss, and the length loss.
[0038] Optionally, comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer includes:
[0039] Calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer;
[0040] The semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer is calculated based on the semantic similarity and summed up to obtain the semantic loss of the predicted answer.
[0041] The present application provides a method for determining length loss, comprising:
[0042] Determine the predicted starting position and predicted ending position of the predicted answer in the sample article;
[0043] Calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0044] A byte length difference between the byte length of the predicted answer and the byte length of the target answer is determined as the length loss of the predicted answer.
[0045] Optionally, the step of determining that the predicted answer is before the predicted starting position and the predicted ending position in the sample article further includes:
[0046] A starting position loss of the predicted answer in predicting a starting position in the sample article and an ending position loss of the predicted answer in predicting an ending position in the sample article are determined.
[0047] Optionally, after determining the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer, the method further includes:
[0048] Based on the start position loss, the end position loss, and the length loss, an accuracy loss of the predicted answer is determined.
[0049] Optionally, before determining the starting position loss of the predicted answer in the sample article and the ending position loss of the predicted answer in the sample article, the step further includes:
[0050] Obtain training samples including sample questions and their corresponding target answers in sample articles;
[0051] The predicted answer to the sample question is generated by inputting the training sample into the reading comprehension model.
[0052] Optionally, after determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss and the length loss, the method further includes:
[0053] A loss function is determined based on the accuracy loss, and the reading comprehension model is optimized using the loss function.
[0054] Optionally, the reading comprehension model is any one of Attentive Reader, Attention Sum Reader, Stanford Attentive Reader and Gated Attention Reader.
[0055] Optionally, determining a starting position loss of a starting position predicted by the predicted answer in the sample article, and an ending position loss of a ending position predicted by the predicted answer in the sample article, comprises:
[0056] Calculating the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer;
[0057] Determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution;
[0058] The starting position loss of the predicted starting position is determined based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and the ending position loss of the predicted ending position is determined based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
[0059] Optionally, the predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article;
[0060] The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0061] Optionally, the starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer;
[0062] The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
[0063] Optionally, the calculating of the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer, comprises:
[0064] Inputting the sample article and the sample question into a preconfigured classifier, and calculating in the classifier the starting probability distribution of the word unit contained in the sample article being the starting word of the predicted answer, and the ending probability distribution of the word unit being the ending word of the predicted answer;
[0065] After the calculation is completed, the classifier outputs the starting probability distribution and the ending probability distribution.
[0066] Optionally, determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss, and the length loss includes:
[0067] A weighted sum of the starting position loss, the ending position loss and the length loss is calculated as the accuracy loss of the predicted answer.
[0068] Optionally, after determining the predicted starting position and the predicted ending position of the predicted answer in the sample article, the step further includes:
[0069] Determine the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0070] The character units included in the predicted answer are compared with the character units included in the target answer to determine the semantic loss of the predicted answer.
[0071] Optionally, after determining the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer, the method further includes:
[0072] An accuracy loss of the predicted answer is determined based on the position loss, the semantic loss, and the length loss.
[0073] Optionally, comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer includes:
[0074] Calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer;
[0075] The semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer is calculated based on the semantic similarity and summed up to obtain the semantic loss of the predicted answer.
[0076] Optionally, the position loss is equal to the sum of the starting position loss of the predicted starting position and the ending position loss of the predicted ending position.
[0077] The present application provides a reading comprehension model training device, comprising:
[0078] A training sample acquisition module is configured to acquire training samples including sample questions and their corresponding target answers in sample articles;
[0079] A predicted answer generation module, configured to generate a predicted answer to the sample question by inputting the training sample into a reading comprehension model;
[0080] an accuracy loss determination module, configured to determine an accuracy loss of the predicted answer relative to the target answer;
[0081] The model optimization module is configured to determine a loss function based on the accuracy loss, and optimize the reading comprehension model using the loss function.
[0082] Optionally, the accuracy loss determination module includes:
[0083] A position loss determination submodule, configured to determine a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0084] A length loss determination submodule, configured to compare the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0085] The accuracy loss determination submodule is configured to determine the accuracy loss of the predicted answer based on the start position loss, the end position loss and the length loss.
[0086] The present application provides a length loss determination device, comprising:
[0087] A prediction position determination subunit, configured to determine a prediction start position and a prediction end position of the predicted answer in the sample article;
[0088] a byte length determination subunit, configured to calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0089] The second length loss determination subunit is configured to determine a byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer.
[0090] The present application provides a computing device, including:
[0091] Memory and processor;
[0092] The memory is used to store computer-executable instructions, and the processor implements the steps of the reading comprehension model training method when executing the computer-executable instructions.
[0093] The present application provides a computer-readable storage medium storing computer instructions, which implement the steps of the reading comprehension model training method when executed by a processor.
[0094] Compared with the prior art, this application has the following advantages:
[0095] The present application provides a reading comprehension model training method, comprising: obtaining a training sample comprising a sample question and its corresponding target answer in a sample article; generating a predicted answer to the sample question by inputting the training sample into a reading comprehension model; determining the accuracy loss of the predicted answer relative to the target answer; determining a loss function based on the accuracy loss, and optimizing the reading comprehension model using the loss function.
[0096] The reading comprehension model training method provided in the present application, during the reading comprehension model training process, generates the reading comprehension model's predicted answers to sample questions by inputting training samples into the reading comprehension model, and compares the predicted answers to the sample questions with the actual target answers to determine the loss of the predicted answers relative to the actual target answers, thereby guiding the training process of the reading comprehension model on the basis of the determined loss, improving the training efficiency of the reading comprehension model, and making the prediction accuracy of the trained reading comprehension model higher.
[0097] The present application provides a method for determining length loss, including: determining a predicted starting position and a predicted ending position of a predicted answer in a sample article; calculating the byte length from the predicted starting position to the predicted ending position as the byte length of the predicted answer; determining the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer.
[0098] The length loss determination method provided in the present application, in the process of determining the length loss, predicts the predicted starting position and the predicted ending position of the answer in the sample article, and calculates the byte length of the predicted ending position, and then obtains the length loss of the predicted answer according to the byte length of the predicted answer and the byte length of the target answer, which not only improves the accuracy of the length loss, but also fully reflects the loss of the predicted answer; in addition, the accuracy loss of the predicted answer can also be calculated based on the length loss, which can improve the accuracy of the accuracy loss, thereby guiding the training process of the reading comprehension model based on the accuracy loss, which is conducive to improving the training efficiency of the reading comprehension model, so that the prediction accuracy of the trained reading comprehension model is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0099] Figure 1 It is a processing flow chart of a reading comprehension model training method provided in an embodiment of the present application;
[0100] Figure 2 It is a structural schematic diagram of a reading comprehension model training device provided in an embodiment of the present application;
[0101] Figure 3 It is a structural block diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0102] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0103] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0104] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0105] The present application provides a reading comprehension model training method, and the present application also provides a reading comprehension model training device, a computing device, and a computer-readable storage medium. The following is a detailed description of each of the embodiments provided by the present application, and each step of the method is described.
[0106] An embodiment of a reading comprehension model training method provided in this application is as follows:
[0107] Refer to the attached Figure 1 , which shows a processing flow chart of a reading comprehension model training method provided in this embodiment.
[0108] Step S102, obtaining a training sample including a sample question and its corresponding target answer in a sample article.
[0109] The life cycle of a model mainly includes three main stages: construction stage, training stage and application stage; the reading comprehension model training method provided in this application is to train the already constructed reading comprehension model in the model construction stage, so that the trained reading comprehension model can predict more accurate answers when applied.
[0110] In addition, the reading comprehension model training method provided in the present application can also train the reading comprehension model during its application process. For example, each time a question and an article are input into the reading comprehension model to predict the answer to the question in the article, the predicted question, article and the predicted answer to the question in the article are used as training samples to optimize the reading comprehension model. This can not only make the prediction accuracy of the reading comprehension model higher during its application, but also make the optimization and adjustment of the reading comprehension model closer to the actual business of applying the reading comprehension model.
[0111] It should be noted that the reading comprehension model described in the embodiment of the present application refers to a machine reading comprehension model. There are many specific models in the field of machine reading comprehension research. For example, common machine reading comprehension models include: AttentiveReader, Attention Sum Reader (AS Reader), Stanford Attentive Reader (StanfordAR) and GatedAttention Reader (GAReader).
[0112] In the embodiment of the present application, a training sample consists of three parts: an article, a question, and the actual answer to the question in the article. For the sake of ease of description, the article is referred to as a sample article, the question is referred to as a sample question, the actual answer to the sample question in the sample article is referred to as a target answer, and the answer obtained by inputting the sample question and the sample article into the reading comprehension model for prediction is referred to as a predicted answer.
[0113] Step S104: generating a predicted answer to the sample question by inputting the training sample into a reading comprehension model.
[0114] In specific implementation, in order to evaluate the gap between the predicted answer obtained by the reading comprehension model and the target answer, the training sample needs to be input into the reading comprehension model to obtain the predicted answer predicted by the reading comprehension model. Specifically, the sample article and sample question contained in the training sample are input into the reading comprehension model, and the reading comprehension model performs predictive calculations in the sample article for the sample question, and finally outputs the predicted answer predicted by the sample question in the sample article.
[0115] Step S106, determining the accuracy loss of the predicted answer relative to the target answer.
[0116] In a preferred implementation manner provided in the embodiment of the present application, the accuracy loss of the predicted answer relative to the target answer is determined in the following manner:
[0117] 1) determining a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0118] In an embodiment of the present application, the predicted starting position of the predicted answer in the sample article is predicted, preferably by calculating the starting probability distribution of the character unit contained in the sample article as the starting character of the predicted answer, and determining the predicted starting position of the predicted answer in the sample article based on the starting probability distribution.
[0119] Preferably, the predicted starting position of the predicted answer in the sample article refers to the position of the word unit with the largest probability value contained in the starting probability distribution in the sample article.
[0120] It can be seen that the above method calculates the probability that each character unit in the sample article is the starting character of the predicted answer, thereby taking the character unit with the highest probability in the sample article as the starting character of the predicted answer, thereby improving the prediction accuracy of the starting character of the predicted answer.
[0121] Similar to the predicted starting position of the predicted answer in the sample article provided above, the predicted ending position of the predicted answer in the sample article is also predicted by calculating the ending probability distribution of the character unit contained in the sample article as the ending word of the predicted answer, and determining the predicted ending position of the predicted answer in the sample article based on the ending probability distribution.
[0122] Preferably, the predicted ending position of the predicted answer in the sample article refers to the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0123] It can be seen that by calculating the probability that each character unit in the sample article is the ending character of the predicted answer, and taking the character unit with the highest probability in the sample article as the ending character of the predicted answer, the prediction accuracy of the ending character of the predicted answer can also be improved.
[0124] During specific implementation, when the reading comprehension model predicts the answer corresponding to the predicted answer in the sample article, if the reading comprehension model needs to calculate the probability that each character unit in the sample article is the starting character of the predicted answer, and calculate the probability that each character unit in the sample article is the ending character of the predicted answer during the prediction process, the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer and the ending probability distribution of the character unit contained in the sample article being the ending character of the predicted answer can be read in the reading comprehension model.
[0125] In addition, the starting probability distribution of the starting word and the ending probability distribution can also be obtained by inputting the sample article and the sample question into a preconfigured classifier, and calculating the probability that the word unit contained in the sample article is the starting word or the ending word of the predicted answer in the classifier. After the calculation is completed, the classifier outputs the starting probability distribution and the ending probability distribution.
[0126] On the basis of the above-mentioned determination of the predicted starting position and the predicted ending position of the predicted answer in the sample article, the loss of the predicted starting position compared to the starting position of the target answer in the sample article is further calculated, and the loss refers to the starting position loss of the predicted starting position. Preferably, the starting position loss of the predicted starting position refers to the difference between the probability value corresponding to the predicted starting position and the probability value corresponding to the starting position of the target answer.
[0127] For example, the sample article consists of 100 character units. The probability of each character unit being the starting character of the predicted answer is calculated, and then the position of the character unit with the largest probability (probability value is 85%) in the sample article is determined as the predicted starting position of the predicted answer. If the predicted starting position is also the starting position of the target answer in the sample article, the probability value corresponding to the starting position of the target answer in the sample article is 1, and the loss of the predicted starting position is equal to the probability value 1 corresponding to the starting position in the sample article minus the corresponding probability value 85% of the predicted starting position. Finally, the starting position loss of the predicted starting position is 1-85%=0.15.
[0128] Similar to the process of determining the starting position loss of the predicted starting position, based on the above determination of the predicted ending position and the predicted ending position of the predicted answer in the sample article, the loss of the predicted ending position compared to the ending position of the target answer in the sample article is further calculated, and the loss refers to the ending position loss of the predicted ending position. The ending position loss of the predicted ending position refers to the difference between the probability value corresponding to the predicted ending position and the probability value corresponding to the ending position of the target answer.
[0129] For example, a sample article consists of 100 character units. The probability of each character unit being the ending character of the predicted answer is calculated, and then the position of the character unit with the largest probability (probability value is 70%) in the sample article is determined as the predicted ending position of the predicted answer. If the predicted ending position is also the ending position of the target answer in the sample article, then the probability value corresponding to the ending position of the target answer in the sample article is 1, and the loss of the predicted ending position is equal to the probability value 1 corresponding to the ending position in the sample article minus the corresponding probability value 70% of the predicted ending position. Finally, the ending position loss of the predicted ending position is 1-70%=0.3.
[0130] 2) comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0131] In a preferred implementation manner provided in the embodiments of the present application, the length loss of the predicted answer is specifically determined in the following manner:
[0132] (a) determining an article matrix corresponding to the sample article;
[0133] The word units in the sample article have a one-to-one correspondence with the elements in the article matrix, and each word unit corresponds to an element in the article matrix;
[0134] (b) determining the predicted starting element and predicted ending element corresponding to the predicted starting position and predicted ending position of the predicted answer in the article matrix, and the target starting element and target ending element corresponding to the starting position and ending position of the target answer in the article matrix;
[0135] (c) determining a predicted answer vector from the predicted start element to the predicted end element, and a target answer vector from the target start element to the target end element;
[0136] (d) Calculate the distance between the predicted answer vector and the target answer vector as the length loss of the predicted answer.
[0137] For example, the sample article consists of 100 character units, which are specifically displayed as 5 rows in the sample article, with 20 characters in each row. By establishing a mapping relationship between the rows in the sample article and the rows of the matrix, and establishing a mapping relationship between the columns in the sample article and the columns of the matrix, a corresponding matrix is constructed for the sample article, and each element in the matrix corresponds to a character unit in the sample article;
[0138] Then, the predicted starting element and the predicted ending element corresponding to the predicted starting position and the predicted ending position in the matrix are predicted, and the predicted answer vector from the predicted starting element to the predicted ending element is further determined; similarly, the target starting element and the target ending element corresponding to the starting position and the ending position of the target answer in the matrix are determined, and the target answer vector from the target starting element to the target ending element is further determined;
[0139] Finally, the Euclidean distance between the predicted answer vector and the target answer vector is calculated as the length loss of the predicted answer relative to the target answer.
[0140] In addition to the method for determining the length loss of the predicted answer provided above, the length loss of the predicted answer can also be determined in other ways, such as preferably determining the length loss of the predicted answer in the following way: first, determine the predicted starting position and predicted ending position of the predicted answer in the sample article; then, calculate the byte length from the predicted starting position to the predicted ending position as the byte length of the predicted answer; finally, determine the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer.
[0141] 3) Determine the accuracy loss of the predicted answer based on the starting position loss, the ending position loss and the length loss.
[0142] The accuracy loss of the predicted answer is preferably determined by calculating the weighted sum of the starting position loss, the ending position loss and the length loss.
[0143] For example, the accuracy loss Loss of predicting the answer is:
[0144] Loss=Loss_start+Loss_end+Loss_length
[0145] Among them, Loss_start is the starting position loss, Loss_end is the ending position loss, and Loss_length is the length loss.
[0146] Step S108, determining a loss function based on the accuracy loss, and optimizing the reading comprehension model using the loss function.
[0147] According to the determined accuracy loss of the predicted answer relative to the target answer, a loss function (evaluation function) for training the reading comprehension model is determined, and then the reading comprehension model is optimized using the loss function, such as by adjusting the parameters or weight coefficients of the reading comprehension model. Finally, after the reading comprehension model is trained, the obtained reading comprehension model has a higher prediction accuracy for the predicted answer.
[0148] In the process of determining the accuracy loss of the predicted answer relative to the target answer in this embodiment, the accuracy loss of the final predicted answer relative to the target answer is preferably determined based on the starting position loss, the ending position loss and the length loss. In addition, other accuracy-related losses may also be used in the accuracy loss determination process, such as the following method of determining the accuracy using position loss, semantic loss and length loss:
[0149] 1) determining the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0150] The position loss is equal to the sum of the starting position loss of the predicted starting position and the ending position loss of the predicted ending position;
[0151] 2) comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer;
[0152] Specifically, the semantic loss is preferably obtained by calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer, and calculating the semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer based on the semantic similarity and summing them up, so as to finally obtain the semantic loss of the predicted answer;
[0153] 3) comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0154] 4) Determining the accuracy loss of the predicted answer based on the position loss, the semantic loss and the length loss.
[0155] On the basis of determining the accuracy loss by using position loss, semantic loss and length loss, a loss function (evaluation function) for training the reading comprehension model is further determined, and then the reading comprehension model is optimized using the loss function to obtain a reading comprehension model with higher prediction accuracy.
[0156] To summarize, the reading comprehension model training method provided in the present application, during the reading comprehension model training process, generates the reading comprehension model's predicted answers to sample questions by inputting training samples into the reading comprehension model, and compares the predicted answers to the sample questions with the actual target answers to determine the loss of the predicted answers relative to the actual target answers, thereby guiding the training process of the reading comprehension model on the basis of the determined loss, improving the training efficiency of the reading comprehension model, and making the prediction accuracy of the trained reading comprehension model higher.
[0157] An embodiment of a reading comprehension model training device provided by the present application is as follows:
[0158] In the above-mentioned embodiment, a reading comprehension model training method is provided. Correspondingly, the present application also provides a reading comprehension model training device, which is described below in conjunction with the accompanying drawings.
[0159] Refer to the attached Figure 2 , which shows a structural schematic diagram of a reading comprehension model training device provided in an embodiment of the present application.
[0160] Since the device embodiment is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the corresponding description of the method embodiment provided above. The device embodiment described below is only illustrative.
[0161] The present application provides a reading comprehension model training device, comprising:
[0162] The training sample acquisition module 202 is configured to acquire a training sample including a sample question and its corresponding target answer in a sample article;
[0163] The predicted answer generation module 204 is configured to generate a predicted answer to the sample question by inputting the training sample into a reading comprehension model;
[0164] An accuracy loss determination module 206, configured to determine the accuracy loss of the predicted answer relative to the target answer;
[0165] The model optimization module 208 is configured to determine a loss function based on the accuracy loss, and optimize the reading comprehension model using the loss function.
[0166] Optionally, the accuracy loss determination module 206 includes:
[0167] A position loss determination submodule, configured to determine a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0168] A length loss determination submodule, configured to compare the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0169] The accuracy loss determination submodule is configured to determine the accuracy loss of the predicted answer based on the start position loss, the end position loss and the length loss.
[0170] Optionally, the position loss determination submodule includes:
[0171] A probability distribution calculation subunit is configured to calculate a starting probability distribution of a character unit contained in the sample article being a starting character of the predicted answer, and an ending probability distribution of a character unit being an ending character of the predicted answer;
[0172] A position determination subunit, configured to determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution;
[0173] The loss determination subunit is configured to determine the starting position loss of the predicted starting position based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and to determine the ending position loss of the predicted ending position based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
[0174] Optionally, the predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article;
[0175] The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0176] Optionally, the starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer;
[0177] The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
[0178] Optionally, the length loss determination submodule includes:
[0179] A matrix determination subunit is configured to determine an article matrix corresponding to the sample article; the character units in the sample article correspond one to one with the elements in the article matrix;
[0180] An element determination subunit is configured to determine the predicted starting element and predicted ending element corresponding to the predicted starting position and predicted ending position of the predicted answer in the article matrix, and the target starting element and target ending element corresponding to the starting position and ending position of the target answer in the article matrix;
[0181] a vector determination subunit configured to determine a predicted answer vector from the predicted start element to the predicted end element, and a target answer vector from the target start element to the target end element;
[0182] The first length loss determination subunit is configured to calculate the distance between the predicted answer vector and the target answer vector as the length loss of the predicted answer.
[0183] Optionally, the length loss determination submodule includes:
[0184] A prediction position determination subunit, configured to determine a predicted starting position and a predicted ending position of the predicted answer in the sample article;
[0185] a byte length determination subunit, configured to calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0186] The second length loss determination subunit is configured to determine a byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer.
[0187] Optionally, the accuracy loss determination submodule is specifically configured to calculate a weighted sum of the starting position loss, the ending position loss and the length loss as the accuracy loss of the predicted answer.
[0188] Optionally, the accuracy loss determination module 206 includes:
[0189] A second position loss determination submodule is configured to determine the position loss of the predicted start position and the predicted end position of the predicted answer in the sample article;
[0190] A semantic loss determination submodule, configured to compare the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer;
[0191] A second length loss determination submodule is configured to compare the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0192] The second accuracy loss determination submodule is configured to determine the accuracy loss of the predicted answer based on the position loss, the semantic loss and the length loss.
[0193] Optionally, the semantic loss determination submodule includes:
[0194] A semantic similarity calculation subunit, configured to calculate the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer;
[0195] The semantic loss determination subunit is configured to calculate the semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer based on the semantic similarity and sum them up to obtain the semantic loss of the predicted answer.
[0196] An embodiment of a computing device provided by the present application is as follows:
[0197] Figure 3 3 is a block diagram showing a computing device 300 according to an embodiment of the present specification. The components of the computing device 300 include but are not limited to a memory 310 and a processor 320. The processor 320 is connected to the memory 310 via a bus 330, and the database 350 is used to store data.
[0198] The computing device 300 also includes an access device 340 that enables the computing device 300 to communicate via one or more networks 360. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 340 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0199] In one embodiment of the present specification, the above components of the computing device 300 and Figure 3 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 3 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0200] The computing device 300 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 300 may also be a mobile or stationary server.
[0201] The present application provides a computing device, including a memory 310, a processor 320, and computer instructions stored in the memory and executable on the processor, wherein the processor 320 is configured to execute the following computer executable instructions:
[0202] Obtain training samples including sample questions and their corresponding target answers in sample articles;
[0203] Generate a predicted answer to the sample question by inputting the training sample into a reading comprehension model;
[0204] determining a loss in accuracy of the predicted answer relative to the target answer;
[0205] A loss function is determined based on the accuracy loss, and the reading comprehension model is optimized using the loss function.
[0206] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0207] Determine a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0208] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0209] Based on the start position loss, the end position loss, and the length loss, an accuracy loss of the predicted answer is determined.
[0210] Optionally, determining a starting position loss of a starting position predicted by the predicted answer in the sample article, and an ending position loss of a ending position predicted by the predicted answer in the sample article, comprises:
[0211] Calculating the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer;
[0212] Determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution;
[0213] The starting position loss of the predicted starting position is determined based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and the ending position loss of the predicted ending position is determined based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
[0214] Optionally, the predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article;
[0215] The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0216] Optionally, the starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer;
[0217] The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
[0218] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0219] Determine an article matrix corresponding to the sample article; the character units in the sample article correspond one to one with the elements in the article matrix;
[0220] Determine the predicted starting element and predicted ending element corresponding to the predicted starting position and predicted ending position of the predicted answer in the article matrix, and the target starting element and target ending element corresponding to the starting position and ending position of the target answer in the article matrix;
[0221] Determine a predicted answer vector from the predicted start element to the predicted end element, and a target answer vector from the target start element to the target end element;
[0222] The distance between the predicted answer vector and the target answer vector is calculated as the length loss of the predicted answer.
[0223] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0224] Determine the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0225] Calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0226] A byte length difference between the byte length of the predicted answer and the byte length of the target answer is determined as the length loss of the predicted answer.
[0227] Optionally, determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss, and the length loss includes:
[0228] A weighted sum of the starting position loss, the ending position loss and the length loss is calculated as the accuracy loss of the predicted answer.
[0229] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0230] Determine the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0231] Comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer;
[0232] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0233] An accuracy loss of the predicted answer is determined based on the position loss, the semantic loss, and the length loss.
[0234] Optionally, comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer includes:
[0235] Calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer;
[0236] The semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer is calculated based on the semantic similarity and summed up to obtain the semantic loss of the predicted answer.
[0237] An embodiment of a computer-readable storage medium provided by the present application is as follows:
[0238] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used when executed by a processor to:
[0239] Obtain training samples including sample questions and their corresponding target answers in sample articles;
[0240] Generate a predicted answer to the sample question by inputting the training sample into a reading comprehension model;
[0241] determining a loss in accuracy of the predicted answer relative to the target answer;
[0242] A loss function is determined based on the accuracy loss, and the reading comprehension model is optimized using the loss function.
[0243] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0244] Determine a starting position loss of the predicted answer in the sample article when predicting a starting position, and an ending position loss of the predicted answer in the sample article when predicting an ending position;
[0245] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0246] Based on the start position loss, the end position loss, and the length loss, an accuracy loss of the predicted answer is determined.
[0247] Optionally, determining a starting position loss of a starting position predicted by the predicted answer in the sample article, and an ending position loss of a ending position predicted by the predicted answer in the sample article, comprises:
[0248] Calculating the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer;
[0249] Determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution;
[0250] The starting position loss of the predicted starting position is determined based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and the ending position loss of the predicted ending position is determined based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
[0251] Optionally, the predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article;
[0252] The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
[0253] Optionally, the starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer;
[0254] The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
[0255] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0256] Determine an article matrix corresponding to the sample article; the character units in the sample article correspond one to one with the elements in the article matrix;
[0257] Determine the predicted starting element and predicted ending element corresponding to the predicted starting position and predicted ending position of the predicted answer in the article matrix, and the target starting element and target ending element corresponding to the starting position and ending position of the target answer in the article matrix;
[0258] Determine a predicted answer vector from the predicted start element to the predicted end element, and a target answer vector from the target start element to the target end element;
[0259] The distance between the predicted answer vector and the target answer vector is calculated as the length loss of the predicted answer.
[0260] Optionally, comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer includes:
[0261] Determine the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0262] Calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer;
[0263] A byte length difference between the byte length of the predicted answer and the byte length of the target answer is determined as the length loss of the predicted answer.
[0264] Optionally, determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss, and the length loss includes:
[0265] A weighted sum of the starting position loss, the ending position loss and the length loss is calculated as the accuracy loss of the predicted answer.
[0266] Optionally, determining the accuracy loss of the predicted answer relative to the target answer includes:
[0267] Determine the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article;
[0268] Comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer;
[0269] Comparing the predicted answer with the target answer in the sample article to determine the length loss of the predicted answer;
[0270] An accuracy loss of the predicted answer is determined based on the position loss, the semantic loss, and the length loss.
[0271] Optionally, comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer includes:
[0272] Calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer;
[0273] The semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer is calculated based on the semantic similarity and summed up to obtain the semantic loss of the predicted answer.
[0274] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned reading comprehension model training method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the above-mentioned reading comprehension model training method.
[0275] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0276] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0277] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0278] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for determining length loss, characterized in that: include: Determine the predicted starting position and predicted ending position of the predicted answer in the sample article; Calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer; The byte length difference between the byte length of the predicted answer and the byte length of the target answer is determined as the length loss of the predicted answer.
2. The method for determining length loss according to claim 1, characterized in that: The step of determining the predicted answer before the predicted starting position and the predicted ending position in the sample article further includes: A starting position loss of the predicted answer in predicting a starting position in the sample article and an ending position loss of the predicted answer in predicting an ending position in the sample article are determined.
3. The method for determining length loss according to claim 2, characterized in that: After determining the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer, the method further comprises: Based on the start position loss, the end position loss, and the length loss, an accuracy loss of the predicted answer is determined.
4. The method for determining length loss according to claim 2, characterized in that: Before determining the starting position loss of the predicted answer in the sample article and the ending position loss of the predicted answer in the sample article, the method further includes: Obtain training samples including sample questions and their corresponding target answers in sample articles; The predicted answer to the sample question is generated by inputting the training sample into the reading comprehension model.
5. The method for determining length loss according to claim 3, characterized in that: After determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss and the length loss, the method further includes: A loss function is determined based on the accuracy loss, and the reading comprehension model is optimized using the loss function.
6. The method for determining length loss according to claim 4 or 5, characterized in that: The reading comprehension model is any one of Attentive Reader, Attention Sum Reader, Stanford Attentive Reader and GatedAttention Reader.
7. The method for determining length loss according to claim 2, characterized in that: The determining of the starting position loss of the predicted answer in the sample article and the ending position loss of the predicted answer in the sample article comprises: Calculating the starting probability distribution of the character unit contained in the sample article being the starting character of the predicted answer, and the ending probability distribution of the character unit being the ending character of the predicted answer; Determine a predicted starting position and a predicted ending position of the predicted answer in the sample article based on the starting probability distribution and the ending probability distribution; The starting position loss of the predicted starting position is determined based on the probability value corresponding to the predicted starting position contained in the starting probability distribution, and the ending position loss of the predicted ending position is determined based on the probability value corresponding to the predicted ending position contained in the ending probability distribution.
8. The method for determining length loss according to claim 7, characterized in that: The predicted starting position includes: the position of the character unit with the largest probability value contained in the starting probability distribution in the sample article; The predicted ending position includes: the position of the character unit with the largest probability value contained in the ending probability distribution in the sample article.
9. The method for determining length loss according to claim 8, characterized in that: The starting position loss includes: a difference between a probability value corresponding to the predicted starting position and a probability value corresponding to the starting position of the target answer; The ending position loss includes: a difference between a probability value corresponding to the predicted ending position and a probability value corresponding to the ending position of the target answer.
10. The method for determining length loss according to claim 7, characterized in that: The calculating of the starting probability distribution of the word unit contained in the sample article being the starting word of the predicted answer and the ending probability distribution of the word unit being the ending word of the predicted answer comprises: Inputting the sample article and the sample question into a preconfigured classifier, and calculating in the classifier the starting probability distribution of the word unit contained in the sample article being the starting word of the predicted answer, and the ending probability distribution of the word unit being the ending word of the predicted answer; After the calculation is completed, the classifier outputs the starting probability distribution and the ending probability distribution.
11. The method for determining length loss according to claim 3, characterized in that: The step of determining the accuracy loss of the predicted answer based on the starting position loss, the ending position loss, and the length loss comprises: A weighted sum of the starting position loss, the ending position loss and the length loss is calculated as the accuracy loss of the predicted answer.
12. The method for determining length loss according to claim 1, characterized in that: After determining the predicted starting position and the predicted ending position of the predicted answer in the sample article, the method further includes: Determine the position loss of the predicted starting position and the predicted ending position of the predicted answer in the sample article; The character units included in the predicted answer are compared with the character units included in the target answer to determine the semantic loss of the predicted answer.
13. The method for determining length loss according to claim 12, characterized in that: After determining the byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer, the method further comprises: An accuracy loss of the predicted answer is determined based on the position loss, the semantic loss, and the length loss.
14. The method for determining length loss according to claim 12 or 13, characterized in that: The comparing the word units included in the predicted answer with the word units included in the target answer to determine the semantic loss of the predicted answer includes: Calculating the semantic similarity between each character unit included in the predicted answer and the corresponding character unit in the target answer; The semantic loss of each character unit included in the predicted answer and the corresponding character unit in the target answer is calculated based on the semantic similarity and summed up to obtain the semantic loss of the predicted answer.
15. The method for determining length loss according to claim 12 or 13, characterized in that: The position loss is equal to the sum of the starting position loss of the predicted starting position and the ending position loss of the predicted ending position.
16. A length loss determination device, characterized in that: include: A prediction position determination subunit, configured to determine a prediction start position and a prediction end position of the predicted answer in the sample article; a byte length determination subunit, configured to calculate the byte length from the prediction start position to the prediction end position as the byte length of the prediction answer; The second length loss determination subunit is configured to determine a byte length difference between the byte length of the predicted answer and the byte length of the target answer as the length loss of the predicted answer.
17. A computing device, characterized in that include: Memory and processor; The memory is used to store computer-executable instructions, and the processor implements the steps of the length loss determination method according to any one of claims 1 to 15 when executing the computer-executable instructions.
18. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by the processor, the steps of the length loss determination method described in any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Machine reading model training method and device, question and answer method and device
CN108959396A
Prediction of spectral coefficients in waveform coding and decoding
US20070016415A1