Training method and device of problem solving model

By replacing the same numbers with different substitutes during the training of the problem-solving model and modifying the correlation matrix, the accuracy problem caused by training data interference is solved, and the prediction accuracy of the model is improved.

CN115859008BActive Publication Date: 2026-03-27BEIJING YUANLI WEILAI SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-24
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing problem-solving models suffer from poor accuracy during training due to interference from training data containing identical characters.

Method used

By selecting different substitutes based on the frequency of digit occurrences in the training data, a second training data is generated. The association matrix is ​​then modified so that the prediction results of subsequent positions are associated with only one substitute. The model is then adjusted using an attention matrix and a preset loss function.

Benefits of technology

This improves the accuracy of the problem-solving model, avoids interference between the same characters when they are replaced by different substitutes, and ensures the accuracy of the prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115859008B_ABST
    Figure CN115859008B_ABST
Patent Text Reader

Abstract

The application discloses a problem-solving model training method and device, and relates to the technical field of artificial intelligence, and mainly aims to solve the problem of poor accuracy of an analysis model obtained through training in the training process of a problem-solving model. The method is as follows: when the same number exists in first training data, different replacement symbols corresponding to the number of times of occurrence of the number are selected according to the times of occurrence to replace the number, and second training data is obtained; a first relationship matrix is obtained through the second training data and a to-be-trained model; the correlation between the replacement symbols and the prediction results of subsequent positions in the first relationship matrix is modified to obtain a second relationship matrix, wherein the prediction results of the subsequent positions in the second relationship matrix only have a correlation with one of the multiple replacement symbols; and the to-be-trained model is trained based on the second relationship matrix.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a problem solving model training method and device. BACKGROUND

[0002] When a machine learning or deep learning model is used to analyze a test question, the stem is often parsed into a corresponding mathematical expression based on the "experience" learned by the machine model, thereby realizing the problem solving function of the test question. Since the problem solving process using the machine model is free from dependence on human labor, the accuracy of the problem solving model will directly affect the accuracy of the problem solving result.

[0003] Currently, in the problem solving process using the problem solving model, the problem solving model also needs to be pre-trained to obtain the "experience" required for subsequent problem solving. However, in actual application, some training data with the same characters in the training process will also interfere with the parsing model, for example, the stem of a certain training data is "a cylinder with a base diameter of 6 cm, its height is 6 cm, and the volume is requested", and the mathematical expression is Since there are the same number 6 in the test question, this will affect the problem solving model during training, thereby causing another test question "a cylinder with a base diameter of 6 cm, its height is 9 cm, and the volume is requested" to have the learned corresponding relationship confused due to the two numbers 6 in the previous training process, for example, if the problem solving model mistakenly believes that the first 6 and the second 6 in the mathematical expression both represent the base diameter of the cylinder, an incorrect prediction result If the problem solving model mistakenly believes that the first 6 in the mathematical expression represents the height of the cylinder and the second 6 represents the base diameter of the cylinder, an incorrect prediction result will be parsed, thereby causing the existing problem solving model training process to be often disturbed by the above-mentioned training data with the same characters, thereby affecting the accuracy of the problem solving model trained. SUMMARY

[0004] In view of the above problems, the present application provides a problem solving model training method and device, and the main purpose is to solve the problem that the accuracy of the parsing model obtained in the current problem solving model training process is poor.

[0005] To solve the above technical problems, in a first aspect, the present application provides a problem solving model training method, which comprises:

[0006] When there are the same numbers in the first training data, different replacement symbols corresponding to the number of times of occurrence of the numbers are selected according to the number of times of occurrence of the numbers to obtain second training data;

[0007] obtaining a first relation matrix by the second training data and a to-be-trained model;

[0008] modifying a correlation between the replacement symbol and the prediction result of the subsequent position in the first relation matrix to obtain a second relation matrix, wherein the prediction result of the subsequent position in the second relation matrix only has a correlation with one of the plurality of replacement symbols;

[0009] training the to-be-trained model based on the second relation matrix.

[0010] Optionally, the first relation matrix is a lower triangular matrix obtained based on a screening operation, and the attention matrix is used to represent the correlation between each prediction result with an attention parameter.

[0011] The modification of the correlation between the replacement symbol and the prediction result of the subsequent position in the first relation matrix to obtain a second relation matrix comprises:

[0012] modifying the correlation between each replacement symbol in the first relation matrix;

[0013] modifying the correlation between the prediction result of the subsequent position and the replacement symbol in the first relation matrix.

[0014] Optionally, the modification of the correlation between each replacement symbol in the first relation matrix comprises:

[0015] determining a first target region matrix from the first relation matrix, wherein the first target region matrix is a region in the first relation matrix for representing the correlation between the plurality of replacement symbols;

[0016] re-expressing the first target region matrix from a triangular matrix to a diagonal matrix, wherein the diagonal trend of the diagonal matrix is the same as that of the lower triangular matrix.

[0017] Optionally, the modification of the correlation between the prediction result of the subsequent position and the replacement symbol in the first relation matrix comprises:

[0018] determining a second target region matrix from the first relation matrix, wherein the second target region matrix is used to represent the correlation between the replacement symbol and the prediction result of the subsequent position;

[0019] in the second target region matrix, retaining one of a plurality of correlations corresponding to the prediction result of the subsequent position in each row.

[0020] Optionally, the retaining one of the plurality of association relationships between each row and the prediction result of the subsequent position in the second target region matrix comprises:

[0021] obtaining the attention matrix corresponding to the first relationship matrix, the attention matrix being obtained by the second training data based on the to-be-trained model;

[0022] obtaining a plurality of target attention parameters corresponding to the second target region matrix from the attention matrix, to obtain a parameter matrix, the target attention parameters being used to represent the association relationship between each of the replacement symbols and the prediction result of the subsequent position, and the distribution mode of the attention parameters in the parameter matrix corresponding to the association relationship in the second target region matrix;

[0023] retaining the association relationship corresponding to the maximum attention parameter in each row of the parameter matrix according to a preset selection formula, and clearing the association relationship corresponding to the remaining attention parameters in each row.

[0024] Optionally, the method further comprises:

[0025] adjusting the to-be-trained model by a preset loss function, the preset loss function comprising a first loss function and a second loss function, the first loss function being used to enable the to-be-trained model to select a combination of to-be-selected parameters based on the maximum value of the sum of prediction probabilities in a plurality of to-be-selected parameters when predicting, and the second loss function being used to select one of the to-be-selected parameters with the maximum prediction probability from the to-be-selected combination as the prediction result.

[0026] Optionally, the first loss function is a maximum likelihood loss function, and the second loss function is a hard expectation maximization loss function.

[0027] In a second aspect, an embodiment of the present application also provides a training device of a problem solving model, comprising:

[0028] a replacement unit configured to select different replacement symbols corresponding to the number of times of the same number in the first training data according to the times of the appearance of the number, to obtain second training data;

[0029] an obtaining unit configured to obtain a first relationship matrix by the second training data and a to-be-trained model;

[0030] a modifying unit configured to modify the association relationship between the replacement symbols and the prediction result of the subsequent position in the first relationship matrix, to obtain a second relationship matrix, wherein the prediction result of the subsequent position in the second relationship matrix only has an association relationship with one of a plurality of the replacement symbols;

[0031] a training unit configured to train the to-be-trained model based on the second relation matrix.

[0032] Optionally, the first relation matrix is a lower triangular matrix obtained after a screening operation based on an attention matrix, the attention matrix being used to represent the correlation between the prediction results with attention parameters.

[0033] The modification unit comprises:

[0034] a first modification module configured to modify the correlation between the replacement symbols in the first relation matrix;

[0035] a second modification module configured to modify the correlation between the prediction result of the subsequent position and the replacement symbol in the first relation matrix.

[0036] Optionally, the first modification module comprises:

[0037] a determination sub-module configured to determine a first target region matrix from the first relation matrix, wherein the first target region matrix is a region in the first relation matrix for representing the correlation between the replacement symbols;

[0038] a re-expression sub-module configured to re-express the first target region matrix from a triangular matrix to a diagonal matrix, wherein the diagonal trend of the diagonal matrix is the same as that of the lower triangular matrix.

[0039] Optionally, the second modification module comprises:

[0040] a determination sub-module configured to determine a second target region matrix from the first relation matrix, wherein the second target region matrix is used to represent the correlation between the replacement symbol and the prediction result of the subsequent position;

[0041] a reservation sub-module configured to reserve one of the multiple correlations corresponding to the prediction result of the subsequent position in each row in the second target region matrix.

[0042] Optionally, the reservation sub-module is further configured to:

[0043] obtain the attention matrix corresponding to the first relation matrix, the attention matrix being obtained based on the to-be-trained model by the second training data;

[0044] obtain multiple target attention parameters corresponding to the second target region matrix from the attention matrix, to obtain a parameter matrix, the target attention parameters being used to represent the correlation between each replacement symbol and the prediction result of the subsequent position, and the distribution mode of the attention parameters in the parameter matrix corresponding to the correlation in the second target region matrix.

[0045] According to a preset selection formula, an association corresponding to a largest attention parameter in a plurality of attention parameters corresponding to each row in the parameter matrix is reserved, and associations corresponding to the rest of the attention parameters in each row are cleared.

[0046] Optionally, the method further comprises:

[0047] The adjusting module is configured to adjust the to-be-trained model by using a preset loss function, the preset loss function comprising a first loss function and a second loss function, the first loss function being configured to enable the to-be-trained model to select a to-be-selected parameter combination based on a maximum value of a sum of prediction probabilities in a plurality of to-be-selected parameters when performing prediction, and the second loss function being configured to select a to-be-selected parameter with a maximum prediction probability from the to-be-selected combination as the prediction result.

[0048] Optionally, the first loss function is a maximum likelihood loss function, and the second loss function is a hard expectation maximization loss function.

[0049] In order to achieve the above-mentioned purpose, according to a third aspect of the present application, a storage medium is provided, the storage medium comprising a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the problem solving model training method of any one of the first aspect.

[0050] In order to achieve the above-mentioned purpose, according to a fourth aspect of the present application, a device is provided, the device comprising at least one processor and at least one memory connected with the processor; wherein the processor is configured to call the program instructions in the memory, and execute the problem solving model training method of any one of the first aspect.

[0051] By the technical scheme, the training method and device of the problem solving model provided by the application can solve the problem of poor accuracy of the analysis model obtained in the training process of the problem solving model. When the same number exists in the first training data, the number of times of appearance of the number is used to select different replacement symbols corresponding to the number of times to replace, to obtain second training data. Then, the first relationship matrix is obtained by using the second training data and the to-be-trained model, and the correlation between the replacement symbol and the prediction result of the subsequent position in the first relationship matrix is modified to obtain a second relationship matrix. In the second relationship matrix, the prediction result of the subsequent position is only correlated with one of the multiple replacement symbols, so that the to-be-trained model is trained based on the second relationship matrix. In the above scheme, the second training data capable of distinguishing the same numbers in different positions of the formula is obtained by selecting different replacement symbols corresponding to the number of times of appearance of the same number. In order to avoid the influence between the same characters when they are replaced by different replacement symbols during prediction, the first relationship matrix is obtained based on the second training data and the to-be-trained model, and the correlation between the prediction result of the subsequent position and the multiple replacement symbols in the second relationship matrix is only correlated with one of the multiple replacement symbols, so that the influence between the same characters when they are replaced by different replacement symbols during prediction can be avoided, and the problem that the multiple replacement symbols appear together to predict the subsequent prediction result can be solved, thereby improving the accuracy of the trained prediction model.

[0052] The above description is only a summary of the technical scheme of the application. In order to make the technical means of the application more clear, the application can be implemented according to the content of the specification, and in order to make the above and other purposes, features and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS

[0053] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not meant to limit the present application. Furthermore, the same reference numerals are used throughout the several views that follow. In the drawings:

[0054] Figure 1 A flow chart of a problem solving model training method provided by an embodiment of the application is shown;

[0055] Figures 2-A to 2-F Schematic diagrams of specific steps in the process of executing a problem solving model training method provided by an embodiment of the application are shown respectively;

[0056] Figure 3 A block diagram of a problem solving model training device provided by an embodiment of the application is shown;

[0057] Figure 4 A constituent block diagram of a device for training of a problem-solving model is shown. DETAILED DESCRIPTION

[0058] Exemplary embodiments of the present application will be described in greater detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it is understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thoroughly and completely understood, and will fully convey the scope of the application to those skilled in the art.

[0059] To solve the problem of poor accuracy of the analytical model obtained by training in the current training process of the problem-solving model, an embodiment of the present application provides a training method for a problem-solving model, as shown in Figure 1 The method comprises:

[0060] 101. When there are identical numbers in the first training data, different replacement symbols corresponding to the number of times of occurrence of the numbers are selected according to the times of occurrence of the numbers to obtain second training data.

[0061] Since the same numbers in the stem confuse the actual meaning of the positions corresponding to the same numbers in the training process of the problem-solving model, the prediction result of a position in the expression predicted in the subsequent problem solving using the problem-solving model is disturbed by the error "experience" in the training and is predicted incorrectly. Therefore, in this embodiment, when training the problem-solving model, when it is found that there is training data with identical numbers, i.e., the first training data, the identical numbers need to be replaced by different replacement symbols at this time, thereby obtaining the second training data after replacement. For example, when the first training data is "the base diameter of a cylinder is 6 cm, its height is 6 cm, and the volume is requested", according to the method of this embodiment, the identical number 6 in the first training data can be determined first, and the number of times of occurrence is twice, and two different replacement symbols are determined for replacement, wherein the second training data obtained after replacement can be "the base diameter of a cylinder is d1 cm, its height is d2 cm, and the volume is requested".

[0062] 102. A first relationship matrix is obtained by the second training data and the to-be-trained model.

[0063] For example, the correlation between the prediction results of each position in the formula in the second training data can be calculated based on the attention algorithm module in the to-be-trained model to obtain the first relationship matrix.

[0064] 103. modifying the association between the replacement symbol and the prediction result of the subsequent position in the first relationship matrix to obtain a second relationship matrix.

[0065] In the second relationship matrix, the prediction result of the subsequent position is only associated with one of the plurality of replacement symbols.

[0066] For example, in the prediction process of the transformer model, the prediction results of each position are associated with each other. Since the same number is replaced by different replacement symbols in the embodiment, and the same position is set between the replacement symbols, in order to avoid interference between the replacement symbols during the prediction process and affect the prediction result, and to avoid learning the association between the replacement symbols during the model training process. In the embodiment, the association between the replacement symbol and the prediction result of the subsequent position in the conventional relationship matrix corresponding to the model to be trained needs to be modified, that is, in actual application, the prediction result of the subsequent position is actually only associated with any one of the replacement symbols, that is, the prediction result of the subsequent position is only associated with one of the plurality of replacement symbols, and the rest of the association is removed.

[0067] In this way, after the second relationship matrix is obtained by modification, since the prediction result of the subsequent position adjacent to the replacement symbol is only associated with one of the plurality of replacement symbols, the prediction model obtained in this way can predict the subsequent other elements after any one of the plurality of replacement symbols, avoiding the problem that the solution model learns the association between the replacement symbols during the training process, and avoiding the problem that the model learns that all the replacement symbols need to be predicted before the subsequent prediction can be performed, thereby improving the accuracy of the solution model.

[0068] Based on the above scheme, for the problem that the accuracy of the analysis model obtained by training in the training process of the current problem solving model is poor, when the same number exists in the first training data, the number of times of appearance of the number is selected to replace the different substitute symbols corresponding to the number of times to obtain second training data; then the first relationship matrix is obtained through the second training data and the to-be-trained model, and the correlation between the substitute symbols and the prediction results of the subsequent positions in the first relationship matrix is modified to obtain a second relationship matrix, wherein the prediction results of the subsequent positions in the second relationship matrix only have a correlation with one of the plurality of substitute symbols, so as to train the to-be-trained model based on the second relationship matrix. In the above scheme, since the second training data capable of distinguishing the same numbers in different positions of the formula is obtained by selecting the different substitute symbols corresponding to the number of times of appearance of the same number to replace. And in order to avoid the influence between the same characters when they are replaced by different substitute symbols during prediction, the first relationship matrix is obtained based on the second training data and the to-be-trained model, and the correlation between the prediction results of the subsequent positions in the second relationship matrix and the plurality of substitute symbols is only with one of them, which can avoid the influence between the same characters when they are replaced by different substitute symbols during prediction, especially the problem that the subsequent prediction results can only be predicted when the same characters are replaced by different substitute symbols, thereby improving the accuracy of the trained prediction model.

[0069] In an optional embodiment, the first relationship matrix is a lower triangular matrix obtained after screening operation, and the attention matrix is used to represent the correlation between each prediction result with attention parameters;

[0070] The modification of the correlation between the substitute symbols and the prediction results of the subsequent positions in the first relationship matrix to obtain the second relationship matrix comprises:

[0071] The correlation between each of the substitute symbols in the first relationship matrix is modified;

[0072] The correlation between the prediction results of the subsequent positions and the substitute symbols in the first relationship matrix is modified.

[0073] In the embodiment, the second data specifically includes the stem "the base diameter of a cylinder is d1 cm, its height is d2 cm, and the volume is requested", the corresponding expression and the first relationship matrix obtained by the conventional transformer model can be as follows Figure 2-AAs shown in the first relationship matrix, the association between d1 and d2 representing the same number is 1, that is, d1 needs to be predicted in the prediction process, and the corresponding d2 will be predicted, but in fact, d1 and d2 both represent a number, so the prediction result is wrong. In addition, for ÷, since its association with d1 and d2 is 1, that is, d1 and d2 need to be predicted, and in fact, only one of d1 and d2 needs to be predicted, so from the above example, it can be concluded that if the prediction is performed according to the current relationship matrix, the prediction result of the problem solving model is wrong. Therefore, in this embodiment, the association between each of the replacement symbols in the first relationship matrix needs to be modified, and the association between the prediction result of the subsequent position of the first relationship matrix and the replacement symbol also needs to be modified, so as to update the relationship between each prediction result and the replacement symbol in the relationship matrix.

[0074] It should be noted that in this embodiment, the association between each element (i.e., the prediction result) is obtained by filtering the attention parameter calculated by the attention matrix through the selection function, which is used to clear the smaller attention parameter and directly assign 1 to the larger one.

[0075] Therefore, by modifying the association between each of the replacement symbols in the first relationship matrix and the association between the prediction result of the subsequent position of the first relationship matrix and the replacement symbol, the problem that the accuracy of the subsequent prediction result is affected when the model uses the original first relationship matrix to predict can be avoided, and the accuracy can be improved.

[0076] In an optional embodiment, the modification of the association between each of the replacement symbols in the first relationship matrix comprises:

[0077] A first target area matrix is determined from the first relationship matrix, wherein the first target area matrix is an area in the first relationship matrix for representing the association between the plurality of replacement symbols. As shown in the foregoing embodiment, the first target area matrix can be specifically as shown in the position marked by the block in Figure 2-B In this example, there are two d1 and d2 association relationships representing the same number, so there are two first target areas representing the same number.

[0078] The first target area matrix is re-expressed from a triangular matrix to a diagonal matrix, wherein the diagonal trend of the diagonal matrix is the same as that of the lower triangular matrix. For example, in the foregoing example, the first target area matrix is re-expressed from a triangular matrix to a diagonal matrix as shown in Figure 2-C ​

[0079] Since the first relationship matrix in the embodiment is a lower triangular matrix, when modifying the association relationship in the first target region matrix, the diagonal trend also needs to be considered. In addition, since the relationship between the two replacement symbols is not required to be learned by the model, in the embodiment, the relationship between the two should be adjusted, that is, when one of them exists, the other is not required to be predicted, so the lower triangular matrix of the region can be modified to a diagonal matrix, since the diagonal matrix can clearly indicate that the association relationship between d1 and d2 is 0, the model will not mislearn the case that the replacement symbols have an association relationship (the case that the value is 1), so that the problem solving model can be more accurate.

[0080] In an optional embodiment, the modifying the association relationship between the replacement symbol and the prediction result of the subsequent position of the first relationship matrix comprises:

[0081] determining a second target region matrix from the first relationship matrix, wherein the second target region matrix is used to represent the association relationship between the replacement symbol and the prediction result of the subsequent position. Specifically, based on the example of the foregoing embodiment, the process of determining the second target region matrix in this step can be as shown in Figure 2-D .

[0082] In the second target region matrix, one of the multiple association relationships corresponding to the prediction result of the subsequent position is retained in each row. In actual application, after any one of the replacement symbols is predicted, the prediction results of the remaining subsequent positions can be predicted without predicting the prediction results of the remaining positions after all the replacement symbols are predicted. That is, one of the multiple replacement symbols has an association relationship with the prediction results of the remaining subsequent positions (the value is 1 in the relationship matrix), so after the second target region matrix is determined, the association relationship in the matrix can be modified, and specifically can be as shown in Figure 2-E . In this way, it can be ensured that only one association relationship is retained in each row corresponding to the prediction result of the subsequent position.

[0083] In an optional embodiment, the retaining one of the multiple association relationships corresponding to the prediction result of the subsequent position in each row in the second target region matrix comprises:

[0084] obtaining the attention matrix corresponding to the first relationship matrix, wherein the attention matrix is obtained by the second training data based on the to-be-trained model;

[0085] Obtaining a plurality of target attention parameters corresponding to the second target region matrix from the attention matrix, to obtain a parameter matrix, the target attention parameters being used to represent the association relationship between each of the replacement symbols and the prediction result of the subsequent position, and the distribution of the attention parameters in the parameter matrix corresponding to the association relationship in the second target region matrix;

[0086] According to a preset selection formula, the association relationship corresponding to the largest attention parameter in each row of the parameter matrix is retained, and the association relationship corresponding to the remaining attention parameters in each row is cleared.

[0087] The specific implementation manner can be as shown in the following table. Figure 2-F It can be seen that, since the association relationship between each prediction result in the embodiment is obtained based on the attention parameters in the attention matrix according to the attention algorithm, that is, 0 and 1 both have actual values, that is, attention parameters, but only a smaller part is cleared and a larger part is assigned as 1 after filtering. That is, although each association relationship in the second target region matrix is 1, the attention parameters before filtering are actually different, but the attention parameter values of the association relationship of 1 are all higher than the threshold value at the time of filtering. In order to retain the association relationship between the specific one of the two replacement symbols d1 and d2 and the subsequent prediction result in each row in the embodiment, the parameter matrix corresponding to the second target region matrix, that is, the matrix representing the relationship with the attention parameters before filtering, can be obtained first. Then, a preset selection formula is used to select the two attention parameters in each row, the larger one is retained, and the smaller one is cleared. Then, the selected matrix is obtained, and in the selected matrix, each replacement symbol only has an association relationship with the remaining prediction results.

[0088] Specifically, in the embodiment, the preset selection function can be an argmax function, the main feature of the function being that the larger one is assigned as 1 and the smaller one is cleared when comparing two values. For example, when two attention parameters (0.25, 0.33) are selected by the argmax function, 0.25 is smaller and is cleared, 0.33 is larger and is assigned as 1, and the result is (0, 1).

[0089] In this way, according to the method in the embodiment, the adjustment of the association relationship is realized according to the size of the attention parameter, and the adjustment of the association relationship in the second target matrix is more in line with the law of the size of the attention parameter. In addition, it should be noted that in some cases, the attention parameters can be equal, and in this case, one of them can be selected as 0 and the other as 1 based on a random selection manner.

[0090] In some examples, the method further comprises adjusting the to-be-trained model by a preset loss function, the preset loss function comprising a first loss function and a second loss function, the first loss function being used to make the to-be-trained model select a to-be-selected parameter combination based on a maximum value of a sum of prediction probabilities in a plurality of to-be-selected parameters when predicting, and the second loss function being used to select a to-be-selected parameter with a maximum prediction probability from the to-be-selected combination as the prediction result.

[0091] It should be noted that the to-be-trained model can be a transformer model, which is a prediction model for predicting subsequent positions based on the correlation between the front and rear positions. That is, the model mainly predicts what the elements of each position are based on the coordinates corresponding to each prediction position and the relationship between the elements to be predicted between the positions, thereby obtaining an expression combined by a plurality of prediction results. For example, when the expression to be predicted is a-bx(l+x), when b is predicted, the sign x adjacent to the subsequent position can be predicted based on b, and then the sign * adjacent to the subsequent position can be predicted based on the sign *.

[0092] Based on the implementation of the preceding step, in this embodiment, the same number 6 needs to be replaced with different substitute symbols. Although the substitute symbols d1 and d2 are different in the stem, in fact, the numbers represented by the two substitute symbols are both 6, that is, it is acceptable to predict d1 or d2 in the prediction process, so the labels of d1 and d2 are both 1, and the labels of other characters are all 0. However, since the conventional trained model is a transformer model, the model mainly uses a cross-entropy loss function to control the prediction result in the prediction process. The function has the characteristic of tending to optimize only one target. Therefore, if there are multiple elements that can be the target at a certain position in the expression, the calculation method of the prediction probability of the target at the position is to calculate the product of the prediction probabilities of the elements with a label of 1 to determine the prediction result. This is acceptable when the multiple elements that can be the target are different. For example, a certain position has two elements c1 and c2 that can be the target, the labels of c1 and c2 are both 1, and the labels of other characters are all 0. The probability of the number 5 represented by c1 is 0.8, and the probability of the number 7 represented by c2 is 0.9. Therefore, the probability that the target at the position is both 5 and 7 is the product of 0.8 and 0.9, that is, 0.72. However, in the case of the present scheme, the two substitute symbols d1 and d2 represent the number 6. Therefore, a certain position has two elements d1 and d2 that can be the target, that is, when optimizing as one target, since the probabilities of d1 and d2 are both less than 1, the result of multiplying the probabilities, that is, the probability of the number 6 as the target, becomes smaller, thereby causing the prediction result to be inaccurate, and the model is inaccurate. Therefore, in this embodiment, a preset loss function can be used to replace the conventional cross-entropy loss function as the objective function for controlling the prediction process. In addition, in this embodiment, the characteristic of the loss function is that the sum of the probabilities of the elements can be analyzed to control the prediction result, that is, since different substitute symbols represent one number, the sum of the probabilities between multiple substitute symbols can greatly improve the probability of selecting the number as the prediction result in the prediction process, thereby making the prediction result of the adjusted model obtained by adjusting the trained model based on the preset loss function as the objective function more accurate.

[0093] Specifically, the first loss function is a maximum likelihood loss function, and the second loss function is a hard expectation maximization loss function.

[0094] Since the same number is replaced by different substitute symbols in the embodiment, that is, the same position coordinates need to be set for different substitute symbols, and the position coordinates are necessary for the transformer model to make a prediction, and the different substitute symbols set in the same position coordinates will have different probabilities when predicted. Therefore, in order to solve the prediction problem of superimposing one position "hidden state", the MML (Maximum Likelihood Loss) function and the HardEM (Hard Expectation Maximization) loss function are used to replace the conventional cross-entropy loss function as the objective function of the prediction process control in the embodiment.

[0095] wherein the maximum likelihood loss and the hard (HardEM) loss replace the cross-entropy loss to solve the same position multi-label problem, and the following two formulas are specific forms of the MML and HardEM loss functions respectively:

[0096]

[0097]

[0098] wherein V is a word table of the decoder, l i is the target label of the i-th word.

[0099] It can be seen from the formula of the MML function that the function can select the parameter combination from the maximum value of the sum of the prediction probabilities of the multiple candidate parameters in the word table when selecting the prediction result from the objective function. That is, the probability of the position being predicted as a substitute symbol can be determined based on the sum of the probabilities of the multiple substitute symbols in the same position. It is equivalent to superimposing the probabilities of multiple substitute symbols in one position. And it can be seen from the formula based on the HardEM function that the function selects the prediction probability of the candidate parameter as the prediction result. That is, when it is determined that a position is predicted to a substitute symbol combination, the specific substitute symbol occupying the position can be selected based on the prediction probability of the substitute symbol, so as to determine which substitute symbol occupies the position. For example, when the MML function can determine that the substitute symbol combination d1 and d2 in position 3 is the prediction result of the position, the HardEM function can determine the prediction result of the position based on the prediction probability of the two substitute symbols d1 and d2. Assuming that the prediction probability of d1 is 0.34 and the prediction probability of d2 is 0.57, the prediction result of position 3 is finally determined to be d2.

[0100] From the above scheme, it can be known that, in the process of determining the prediction result, the MML function and the HardEM function will not only optimize one prediction result as the conventional cross-entropy function, but also can determine whether the whole belongs to the prediction result of which position based on the probability of the combination of the replacement symbol first, and then screen, so as to ensure that the replacement symbol is normally predicted under the condition of the same position "hidden state" superposition, so that the model can learn the prediction mode of multiple replacement symbols in the superposition position, and the problem solving model is more accurate.

[0101] Further, as the implementation of the method described above Figure 1 As the implementation of the method described above Figure 1 The device embodiment corresponds to the foregoing method embodiment, and for the sake of reading, the details of the foregoing method embodiment will not be described one by one, but it should be clear that the device in the embodiment can correspondingly implement all the contents in the foregoing method embodiment. As shown in Figure 3 The device comprises a replacement unit 31, an acquisition unit 32, a modification unit 33, and a training unit 34, wherein

[0102] The replacement unit 31 is configured to, when there are the same numbers in the first training data, select different replacement symbols corresponding to the number of times of occurrence of the numbers according to the number of times of occurrence of the numbers to replace, to obtain second training data;

[0103] The acquisition unit 32 is configured to acquire a first relationship matrix through the second training data and a to-be-trained model;

[0104] The modification unit 33 is configured to modify the association relationship between the replacement symbol and the prediction result of the subsequent position in the first relationship matrix to obtain a second relationship matrix, wherein the prediction result of the subsequent position in the second relationship matrix only has an association relationship with one of the multiple replacement symbols;

[0105] The training unit 34 is configured to train the to-be-trained model based on the second relationship matrix.

[0106] Further, the first relationship matrix is a lower triangular matrix obtained after the attention matrix is screened, and the attention matrix is used to represent the association relationship between each prediction result with an attention parameter;

[0107] The modification unit comprises:

[0108] The first modification module is configured to modify the association relationship between each replacement symbol in the first relationship matrix;

[0109] ​The second modification module is configured to modify an association relationship between the prediction result of the subsequent position and the replacement symbol in the first relationship matrix.

[0110] Further, the first modification module comprises:

[0111] A determination sub-module is configured to determine a first target area matrix from the first relationship matrix, wherein the first target area matrix is an area in the first relationship matrix for representing an association relationship between a plurality of replacement symbols.

[0112] A representation sub-module is configured to represent the first target area matrix from a triangular matrix to a diagonal matrix, wherein a diagonal trend of the diagonal matrix is the same as that of the lower triangular matrix.

[0113] Further, the second modification module comprises:

[0114] A determination sub-module is configured to determine a second target area matrix from the first relationship matrix, wherein the second target area matrix is used to represent an association relationship between the replacement symbol and the prediction result of the subsequent position.

[0115] A reservation sub-module is configured to reserve one association relationship from a plurality of association relationships corresponding to the prediction result of the subsequent position in each row of the second target area matrix.

[0116] Further, the reservation sub-module is further configured to:

[0117] An attention matrix corresponding to the first relationship matrix is obtained, wherein the attention matrix is obtained based on the second training data and the to-be-trained model;

[0118] A plurality of target attention parameters corresponding to the second target area matrix are obtained from the attention matrix, to obtain a parameter matrix, wherein the target attention parameters are used to represent an association relationship between each replacement symbol and the prediction result of the subsequent position, and a distribution mode of the attention parameters in the parameter matrix corresponds to the association relationship in the second target area matrix.

[0119] According to a preset selection formula, an association relationship corresponding to a largest attention parameter is reserved from a plurality of attention parameters corresponding to each row in the parameter matrix, and association relationships corresponding to the remaining attention parameters in each row are cleared.

[0120] Further, the adjusting module is configured to adjust the to-be-trained model by using a preset loss function, the preset loss function comprising a first loss function and a second loss function, the first loss function being configured to cause the to-be-trained model to select a to-be-selected parameter combination based on a maximum value of a sum of prediction probabilities in a plurality of to-be-selected parameters when predicting, and the second loss function being configured to select a to-be-selected parameter with a maximum prediction probability from the to-be-selected parameter combination as the prediction result.

[0121] Further, the first loss function is a maximum likelihood loss function, and the second loss function is a hard expectation maximization loss function.

[0122] By means of the technical solution, the embodiment of the present application provides a problem solving model training method and device, and the accuracy of the analytical model obtained in the training process of the current problem solving model is poor. In the present application, when the same number exists in the first training data, different replacement symbols corresponding to the number of times of occurrence of the number are selected to replace the number, and the second training data is obtained. Then, the first relationship matrix is obtained by using the second training data and the to-be-trained model, and the correlation between the replacement symbol and the prediction result of the subsequent position in the first relationship matrix is modified to obtain the second relationship matrix. The prediction result of the subsequent position in the second relationship matrix is only correlated with one of the plurality of replacement symbols, so as to train the to-be-trained model based on the second relationship matrix. In the above solution, since the different replacement symbols corresponding to the number of times of occurrence of the same number are selected to replace the number, the second training data capable of distinguishing the same number at different positions in the formula is obtained. In order to avoid the influence between the same characters when they are replaced by different replacement symbols during prediction, the first relationship matrix is obtained based on the second training data and the to-be-trained model, and the correlation between the prediction result of the subsequent position in the second relationship matrix and the plurality of replacement symbols is only correlated with one of them. The influence between the same characters when they are replaced by different replacement symbols during prediction can be avoided, and the problem that the subsequent prediction result can only be predicted when the same characters are replaced by different replacement symbols is solved, thereby improving the accuracy of the trained prediction model.

[0123] The processor includes a core, and the core retrieves corresponding program units from the memory. The core can be one or more, and the accuracy of the analytical model obtained in the training process of the current problem solving model can be improved by adjusting the core parameters.

[0124] The embodiment of the present application provides a storage medium, and the storage medium comprises a stored program. When the program runs, the device where the storage medium is located is controlled to execute the problem solving model training method of any one of the technical solutions.

[0125] The embodiment of the present application provides a processor used for running a program, wherein the program performs the training method of the problem solving model when running.

[0126] The embodiment of the present application provides a device 40, as shown in the figure, the device comprises at least one processor 401 and at least one memory 402 connected with the processor, and a bus 403; wherein the processor 401, the memory 402 complete mutual communication through the bus 403; the processor 401 is used to call the program instruction in the memory, to execute the training method of the problem solving model described above. Figure 4

[0127] The device herein can be a server, a PC, a PAD, a mobile phone and the like.

[0128] The present application also provides a computer program product, when executed on a process management device, is suitable for executing the program initialized with the following method steps:

[0129] When there are same numbers in the first training data, different replacement symbols corresponding to the number of times of the numbers are selected according to the times of the numbers, and second training data is obtained; a first relationship matrix is obtained through the second training data and a to-be-trained model; an association relationship between the replacement symbols and the prediction results of subsequent positions in the first relationship matrix is modified, and a second relationship matrix is obtained, wherein the prediction results of the subsequent positions in the second relationship matrix only have an association relationship with one of the plurality of replacement symbols; and the to-be-trained model is trained based on the second relationship matrix.

[0130] Further, the first relationship matrix is a lower triangular matrix obtained after a screening operation based on an attention matrix, and the attention matrix is used to represent the association relationship between each prediction result with an attention parameter;

[0131] The modification of the association relationship between the replacement symbols and the prediction results of subsequent positions in the first relationship matrix to obtain the second relationship matrix comprises:

[0132] The association relationship between each of the replacement symbols in the first relationship matrix is modified;

[0133] The association relationship between the prediction results of the subsequent positions and the replacement symbols in the first relationship matrix is modified.

[0134] Further, the modification of the association relationship between each of the replacement symbols in the first relationship matrix comprises:

[0135] A first target area matrix is determined from the first relationship matrix, wherein the first target area matrix is an area in the first relationship matrix for representing the association relationship between the plurality of replacement symbols.​

[0136] re-express the first target region matrix from a lower triangular matrix to a diagonal matrix, wherein a diagonal trend of the diagonal matrix is same as the lower triangular matrix.

[0137] Further, the modifying the association between the replacement symbol and the prediction result of the subsequent position of the first relation matrix comprises:

[0138] determining a second target region matrix from the first relation matrix, wherein the second target region matrix is used to represent the association between the replacement symbol and the prediction result of the subsequent position;

[0139] in the second target region matrix, retaining one of the multiple associations corresponding to the prediction result of the subsequent position for each row.

[0140] Further, the retaining one of the multiple associations corresponding to the prediction result of the subsequent position for each row in the second target region matrix comprises:

[0141] obtaining the attention matrix corresponding to the first relation matrix, wherein the attention matrix is obtained by the second training data based on the to-be-trained model;

[0142] obtaining multiple target attention parameters corresponding to the second target region matrix from the attention matrix, to obtain a parameter matrix, wherein the target attention parameters are used to represent the association between each replacement symbol and the prediction result of the subsequent position, and a distribution mode of the attention parameters in the parameter matrix corresponds to the association in the second target region matrix;

[0143] according to a preset selection formula, retaining the association corresponding to the maximum attention parameter in the multiple attention parameters corresponding to each row in the parameter matrix, and clearing the associations corresponding to the remaining attention parameters in each row.

[0144] Further, the method further comprises: adjusting the to-be-trained model by a preset loss function, wherein the preset loss function comprises a first loss function and a second loss function, the first loss function is used to enable the to-be-trained model to select a to-be-selected parameter combination based on a maximum value of a sum of prediction probabilities in multiple to-be-selected parameters when predicting, and the second loss function is used to select one of the to-be-selected parameters with the maximum prediction probability from the to-be-selected combination as the prediction result.

[0145] Further, the first loss function is a MML maximum likelihood loss function, and the second loss function is a HardEM hard loss function.

[0146] The computer program instructions can also be loaded onto a computer, other programmable instruction execution devices to produce a series of instructions computer, special or other programmable instruction execution devices to produce a series of instructions such that the instructions that are executed on the computer or other programmable instruction execution devices implement the functions specified in the flowcharts and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0147] In one typical arrangement, the device includes one or more processors (CPUs), memory, and buses. The device can also include input / output interfaces, network interfaces, and the like.

[0148] The memory can include non-persistent memory in the form of random access memory (RAM) and / or non-volatile memory, such as read only memory (ROM) or flash memory (flash RAM), including at least one memory chip. The memory is an example of computer readable media.

[0149] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassette, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.

[0150] It is also to be noted that the terms "comprising", "including", and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises a... " does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0151] Those skilled in the art will appreciate that embodiments of the present application can be devised for a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer-readable program code.

[0152] The embodiments of the present application are only illustrative and are not intended to limit the present application. Various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method of training a problem-solving model, the method comprising: The method comprises the following steps: when there are same numbers in the first training data, selecting different replacement symbols corresponding to the number of times of occurrence of the numbers to replace the numbers, to obtain second training data; obtaining a first relationship matrix through the second training data and a to-be-trained model; modifying the correlation between the replacement symbols and the prediction results of the subsequent positions in the first relationship matrix to obtain a second relationship matrix, wherein the prediction results of the subsequent positions in the second relationship matrix only have a correlation with one of the plurality of replacement symbols; training the to-be-trained model based on the second relationship matrix.

2. The method of claim 1, wherein, The first relationship matrix is a lower triangular matrix obtained based on a screening operation, and the attention matrix is used to represent the correlation between each prediction result with an attention parameter; The modification of the correlation between the replacement symbols and the prediction results of the subsequent positions in the first relationship matrix to obtain a second relationship matrix comprises: modifying the correlation between each replacement symbol in the first relationship matrix; modifying the correlation between the prediction results of the subsequent positions and the replacement symbols in the first relationship matrix.

3. The method of claim 2, wherein, The modification of the correlation between each replacement symbol in the first relationship matrix comprises: determining a first target area matrix from the first relationship matrix, wherein the first target area matrix is an area in the first relationship matrix for representing the correlation between the plurality of replacement symbols; representing the first target area matrix from a triangular matrix to a diagonal matrix, wherein the diagonal trend of the diagonal matrix is the same as that of the lower triangular matrix.

4. The method of claim 2, wherein, The modification of the correlation between the prediction results of the subsequent positions and the replacement symbols in the first relationship matrix comprises: determining a second target area matrix from the first relationship matrix, wherein the second target area matrix is used to represent the correlation between the replacement symbols and the prediction results of the subsequent positions; in the second target area matrix, retaining one of the plurality of correlations corresponding to the prediction results of the subsequent positions in each row.

5. The method of claim 4, wherein, The retaining of one of the plurality of correlations corresponding to the prediction results of the subsequent positions in each row in the second target area matrix comprises: obtaining an attention matrix corresponding to the first relationship matrix, wherein the attention matrix is calculated based on the to-be-trained model and the second training data; obtaining a plurality of target attention parameters corresponding to the second target area matrix from the attention matrix to obtain a parameter matrix, wherein the target attention parameters are used to represent the correlation between each replacement symbol and the prediction result of the subsequent position, and the distribution mode of the attention parameters in the parameter matrix corresponds to the correlation in the second target area matrix; according to a preset selection formula, retaining the correlation corresponding to the largest attention parameter in the plurality of attention parameters corresponding to each row in the parameter matrix, and clearing the correlations corresponding to the remaining attention parameters in each row.

6. The method according to any one of claims 1-5, characterized in that, The method further comprises the following steps: The preset loss function comprises a first loss function and a second loss function, the first loss function is used for enabling the to-be-trained model to select a to-be-selected parameter combination based on a maximum value of prediction probabilities in a plurality of to-be-selected parameters when predicting, and the second loss function is used for selecting one to-be-selected parameter with a maximum prediction probability from the to-be-selected combination as the prediction result.

7. The method of claim 6, wherein, The first loss function is a maximum likelihood loss function, and the second loss function is a hard expectation maximization loss function.

8. A device for training a problem-solving model, characterized by, Comprise: The replacement unit is configured to, when there are same numbers in the first training data, select different replacement symbols corresponding to the number of times of occurrence of the numbers according to the times of occurrence to obtain second training data; The acquisition unit is configured to acquire a first relationship matrix through the second training data and the to-be-trained model; The modification unit is configured to modify a correlation relationship between the replacement symbol and a prediction result of a subsequent position in the first relationship matrix to obtain a second relationship matrix, wherein the prediction result of the subsequent position in the second relationship matrix only has a correlation relationship with one of a plurality of replacement symbols; The training unit is configured to train the to-be-trained model based on the second relationship matrix.

9. A storage medium, characterized by The storage medium comprises a stored program, wherein the program controls a device where the storage medium is located to execute the problem-solving model training method in any one of claims 1 to 7 when the program is running.

10. An electronic device, comprising: The device comprises at least one processor and at least one memory connected with the processor; wherein the processor is used to call program instructions in the memory to execute the problem-solving model training method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Question solving model training method and device and question solving formula generation method and device

    CN111767708A

  • Training method and device of problem solving model and problem solving method and device

    CN111783423A