Question answering model training method and device, question answering method and device

By constructing a semantic tree for formulas through training the model, the problem that end-to-end models cannot provide detailed solution steps is solved, thereby realizing the visualization of the problem-solving process and improving the interpretability of the answer.

CN115809318BActive Publication Date: 2026-04-28BEIJING 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
BEIJING YUANLI WEILAI SCI & TECH CO LTD
Filing Date
2021-09-14
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, end-to-end models can only output the final calculation formula for a problem, but cannot provide detailed solution steps, resulting in poor interpretability of the answer and affecting user experience.

Method used

The initial solution model is trained by acquiring a training sample set carrying semantic structure labels. The target training samples are selected by using the predicted semantic structure, and an arithmetic semantic tree is constructed to determine the detailed solution steps of the problem.

Benefits of technology

It improves the visualization and interpretability of the problem-solving process, enhances the user experience, and increases the efficiency and accuracy of semantic structure determination.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115809318B_ABST
    Figure CN115809318B_ABST
Patent Text Reader

Abstract

The present specification provides a question answering model training method and device, and a question answering method and device. The question answering model training method comprises: training an initial answer model according to a first training sample set and a semantic structure label to obtain a reference question answering model; inputting each second training sample included in a second training sample set into the reference question answering model to obtain a predicted semantic structure corresponding to each second training sample; selecting a target training sample from each second training sample according to the predicted semantic structure and adding the target training sample to the first training sample set to obtain an updated first training sample set, and returning to perform the operation step of training the initial answer model according to the first training sample set to obtain the reference question answering model until a first training stop condition is reached to obtain a trained question answering model. A question answering model with high accuracy can be obtained through a small amount of training samples carrying semantic structure labels.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a method for training a problem-solving model. This specification also relates to a training apparatus for a problem-solving model, a problem-solving method, a problem-solving device, a computing device, and a computer-readable storage medium. Background Technology

[0002] With the continuous development of computer and artificial intelligence technologies, more and more work and study tasks can be automated. Computer technology has been gradually applied to various daily education and learning activities. For example, computer technology can be used to automatically analyze the answers to certain questions, thereby greatly saving human resources.

[0003] In existing technologies, when a question needs to be answered, it can be input into an end-to-end model, which can then output the final calculation formula to automatically obtain the answer. However, the end-to-end model only provides the final calculation formula and does not provide detailed solution steps. This results in poor visualization of the problem-solving process, leading to poor interpretability of the answer and significantly impacting the user experience. Therefore, there is an urgent need for a problem-solving method that can improve the visualization of the problem-solving process. Summary of the Invention

[0004] In view of this, embodiments of this specification provide a method for training a question-solving model. This specification also relates to a training apparatus for a question-solving model, a question-solving method, a question-solving device, a computing device, and a computer-readable storage medium, to address the technical deficiencies existing in the prior art.

[0005] According to a first aspect of the embodiments of this specification, a method for training a question-answering model is provided, comprising:

[0006] Obtain a first training sample set and a second training sample set, wherein each first training sample in the first training sample set carries a semantic structure label;

[0007] Based on the first training sample set and the semantic structure labels, the initial answer model is trained to obtain the reference question answer model;

[0008] Each of the second training samples included in the second training sample set is input into the reference question answering model to obtain the predicted semantic structure corresponding to each of the second training samples;

[0009] Based on the predicted semantic structure, target training samples are selected from each of the second training samples and added to the first training sample set to obtain an updated first training sample set. Then, the operation steps of training the initial solution model based on the first training sample set to obtain a reference question-answering model are returned until the training stopping condition is met, and the trained question-answering model is obtained.

[0010] According to a second aspect of the embodiments of this specification, a problem-solving method is provided, including:

[0011] The obtained question to be solved is input into the formula recognition model to obtain the solution formula for the question to be solved;

[0012] The solution formula and the question to be solved are input into the problem-solving model to obtain the semantic structure of each formula factor in the solution formula. The problem-solving model is trained by the training method of the problem-solving model described in the first aspect above.

[0013] Based on the semantic structure of each formula factor, a formula semantic tree is generated, and based on the formula semantic tree, the solution steps for the problem to be solved are determined.

[0014] According to a third aspect of the embodiments of this specification, a training apparatus for a question-answering model is provided, comprising:

[0015] The acquisition module is configured to acquire a first training sample set and a second training sample set, wherein each first training sample in the first training sample set carries a semantic structure label.

[0016] The first training module is configured to train the initial answer model based on the first training sample set and the semantic structure label to obtain a reference question answer model.

[0017] The first obtaining module is configured to input each of the second training samples included in the second training sample set into the reference question answering model to obtain the predicted semantic structure corresponding to each of the second training samples.

[0018] The addition module is configured to select target training samples from each of the second training samples according to the predicted semantic structure and add them to the first training sample set to obtain an updated first training sample set, and then return to execute the first training module until the first training stopping condition is met to obtain a trained question answering model.

[0019] According to a fourth aspect of the embodiments of this specification, a problem-solving apparatus is provided, comprising:

[0020] The second obtaining module is configured to input the obtained question to be answered into the formula recognition model to obtain the answer formula for the question to be answered;

[0021] The third obtaining module is configured to input the solution formula and the question to be solved into the question solving model to obtain the semantic structure of each formula factor in the solution formula, wherein the question solving model is trained by the training method of the question solving model described in the first aspect above;

[0022] The determination module is configured to generate an arithmetic semantic tree based on the semantic structure of each arithmetic factor, and to determine the solution steps for the problem to be solved based on the arithmetic semantic tree.

[0023] According to a fifth aspect of the embodiments of this specification, a computing device is provided, comprising:

[0024] Memory and processor;

[0025] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the training method or the problem-solving method of the problem-solving model.

[0026] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of a training method for a problem-solving model or a problem-solving method.

[0027] The training method for the question-answering model provided in this specification involves obtaining a first training sample set and a second training sample set. Each first training sample in the first training sample set carries a semantic structure label. Then, based on the first training sample set and the semantic structure labels, the initial answering model is trained to obtain a reference question-answering model. Subsequently, each second training sample in the second training sample set is input into the reference question-answering model to obtain the predicted semantic structure corresponding to each second training sample. Based on the predicted semantic structure, target training samples are selected from each second training sample set and added to the first training sample set to obtain an updated first training sample set. The process then returns to execute the steps of training the initial answering model based on the first training sample set to obtain the reference question-answering model, until the training stopping condition is met, resulting in a completed question-answering model.

[0028] In this scenario, an initial solution model can be trained using a small number of training samples with semantic structure labels. Then, the reference question-answering model obtained from this initial training can predict the semantic structure of unlabeled training samples. From these predicted semantic structures, the most accurate ones can be selected as new training samples with semantic structure labels for further training. In this way, the initial solution model can be trained using only a small number of semantically labeled training samples. Then, based on the trained reference question-answering model, semantically labeled sample data can be added round by round, increasing the number of labeled training samples available for training the question-answering model. This results in a question-answering model with high accuracy, achieving this by using only a small number of semantically labeled training samples.

[0029] The problem-solving method provided in this manual involves inputting the acquired problem into a formula recognition model to obtain the solution formula. Then, the solution formula and the problem are input into a problem-solving model to obtain the semantic structure of each formula factor in the solution formula. The problem-solving model is trained using the aforementioned training method. Subsequently, a formula semantic tree is generated based on the semantic structure of each formula factor, and the solution steps for the problem are determined based on the formula semantic tree. In this case, the semantic structure of each formula factor in the solution formula of the problem can be determined through a pre-trained problem-solving model, constructing a formula semantic tree. This formula semantic tree can represent each solution step corresponding to the solution formula. Therefore, based on the constructed formula semantic tree, the detailed solution steps for the problem can be determined, making the device's problem-solving process more detailed and visual, improving the visualization of problem-solving through the device, thereby improving the interpretability of the automatically obtained answers to the problem, greatly enhancing the user experience. Furthermore, the pre-trained problem-solving model improves the efficiency and accuracy of determining the semantic structure. Attached Figure Description

[0030] Figure 1 This is a flowchart of a training method for a problem-solving model provided in one embodiment of this specification;

[0031] Figure 2 This is a schematic diagram of the structure of a first training sample provided in one embodiment of this specification;

[0032] Figure 3 This is a schematic diagram of the structure of a problem-solving model provided in one embodiment of this specification;

[0033] Figure 4 This is a schematic diagram of another problem-solving model provided in one embodiment of this specification;

[0034] Figure 5 This is a schematic diagram of the verification process of a verification model provided in one embodiment of this specification;

[0035] Figure 6 This is a schematic diagram illustrating the training process of a problem-solving model provided in one embodiment of this specification;

[0036] Figure 7 This is a flowchart of a problem-solving method provided in one embodiment of this specification;

[0037] Figure 8 This is a schematic diagram of an arithmetic semantic tree provided in one embodiment of this specification;

[0038] Figure 9 This is a schematic diagram of another formula semantic tree provided in one embodiment of this specification;

[0039] Figure 10 This is a schematic diagram of the structure of a training device for a problem-solving model provided in one embodiment of this specification;

[0040] Figure 11 This is a schematic diagram of the structure of a problem-solving device provided in one embodiment of this specification;

[0041] Figure 12 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation

[0042] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0043] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as 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.

[0044] 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, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0045] It should be noted that, in one possible approach to answering a question, the question can be input into an end-to-end model, which can then output the final calculation formula, thus automatically obtaining the answer. However, the end-to-end model only provides the final calculation formula and does not offer detailed solution steps. This results in poor visualization of the problem-solving process, leading to poor interpretability of the answer and significantly impacting the user experience.

[0046] Another possible implementation involves inputting the question to be solved into a sequence model, which then outputs the solution steps. However, since the solution steps are relatively long, training the sequence-to-sequence model requires massive amounts of high-quality training data, i.e., <question, solution steps> text pairs. Even with such a large amount of data, the solution steps may come from different people (e.g., teachers, students, or others), potentially resulting in different formats and writing styles. This makes it difficult for the sequence-to-sequence model to learn a fixed solution pattern, significantly increasing the training difficulty. Furthermore, the correctness of the solution steps in the massive amount of <question, solution steps> text pairs is not guaranteed. Incorrect solution steps may mislead the model's learning, further increasing the training difficulty. Additionally, the accuracy of the solution steps output by the sequence-to-sequence model is limited, greatly affecting the efficiency and accuracy of solving subsequent questions.

[0047] Therefore, this specification provides a training method for a question-answering model. First, an initial question-answering model is trained using a small number of training samples with semantic structure labels. These semantic structure labels can be the semantic structures of the various formula factors determined through semantic analysis. Then, the reference question-answering model obtained from the initial training predicts the semantic structures of unlabeled training samples. From these predicted semantic structures, the more accurate ones are selected as new training samples with semantic structure labels for further training. In this way, the initial question-answering model can be trained using only a small number of training samples with semantic structure labels. Then, based on the trained reference question-answering model, sample data with semantic structure labels is added round by round, increasing the number of labeled training samples available for training the question-answering model, thereby obtaining a question-answering model with high accuracy. A question-answering model with high accuracy can be obtained with only a small number of training samples with semantic structure labels.

[0048] This specification also provides a problem-solving method that can determine the semantic structure of each factor in the solution formula of the problem to be solved by using a pre-trained problem-solving model, and construct a formula semantic tree. This formula semantic tree can represent each solution step corresponding to the solution formula. Therefore, based on the constructed formula semantic tree, the detailed solution steps of the problem to be solved can be determined, making the problem-solving process of the device more detailed and visual, improving the visualization of problem-solving through the device, thereby improving the interpretability of the automatically obtained answers to the problem to be solved, greatly improving the user experience, and improving the efficiency and accuracy of determining the semantic structure by using the pre-trained problem-solving model.

[0049] This specification provides a method for training a question-solving model, and also relates to a training device for a question-solving model, a question-solving method, a question-solving apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.

[0050] Figure 1 A flowchart is shown illustrating a training method for a question-answering model according to an embodiment of this specification, specifically including the following steps:

[0051] Step 102: Obtain the first training sample set and the second training sample set. Each first training sample in the first training sample set carries a semantic structure label.

[0052] Specifically, the first training sample set can refer to the set of first training samples carrying semantic structure labels, and the second training sample set can refer to the set of second training samples without semantic structure labels. Furthermore, both the first and second training samples can be text data, which can be directly obtained or obtained by performing text recognition on image data.

[0053] It should be noted that the first training sample set may include at least one first training sample. Each first training sample may include a sample question and a sample formula. The sample formula may refer to the calculation formula for the answer to the sample question, that is, the calculation method to obtain the answer to the sample question. The semantic structure label may refer to the semantic structure corresponding to each formula factor included in the sample formula of the first training sample. Among them, the sample formula may be a binary tree structure, and the semantic structure may represent the physical meaning of the corresponding formula factor (node ​​in the binary tree).

[0054] In practical applications, a sample formula can refer to the calculation method of a sample problem. Therefore, a sample formula can include numerical values ​​and operators, and each numerical value and operator included in the sample formula is a formula factor. In actual implementation, semantic analysis can be performed on the sample problem, and combined with the corresponding sample formula, the physical meaning represented by each formula factor can be analyzed to obtain the corresponding semantic structure. That is, the semantic structure label carried by the first sample problem can be the semantic structure corresponding to each formula factor included in the sample formula, determined through semantic analysis of the sample problem and the sample formula.

[0055] In one optional implementation of this embodiment, taking a binary tree structure as an example, the formula factors included in the sample formula are nodes in the binary tree structure; in this case, semantic analysis is performed on the sample problem and the sample formula to determine the semantic structure corresponding to each formula factor included in the sample formula. The specific implementation process can be as follows:

[0056] For leaf nodes, the semantic structure of the leaf nodes is determined from the semantic analysis results of the sample questions and sample formulas according to the preset semantic extraction rules.

[0057] For intermediate nodes, determine the semantic structure of the intermediate nodes based on the child nodes they include;

[0058] For the root node, determine its semantic structure based on its child nodes; or, determine the semantic structure of the root node from the semantic analysis results of the sample questions and sample formulas based on preset semantic extraction rules.

[0059] Specifically, the preset semantic extraction rule can refer to the rule for obtaining the corresponding physical meaning of the leaf node (i.e., the formula factor) from the sample problem and sample formula. The preset semantic extraction rule can be defined in advance to determine the semantic structure of the leaf node.

[0060] It should be noted that leaf nodes are generally numbers included in the sample problem or sample formula. Therefore, the corresponding physical meaning of leaf nodes can be directly analyzed from the sample problem or sample formula. In other words, for leaf nodes, the semantic structure of leaf nodes can be determined from the semantic analysis results of the sample problem and sample formula according to the preset semantic extraction rules.

[0061] Furthermore, intermediate nodes are generally operators included in the sample formula, and therefore their physical meaning cannot be directly analyzed from the sample problem or formula. Since intermediate nodes include child nodes, their semantic structure can be deduced from these child nodes.

[0062] Furthermore, the root node also includes child nodes, so its semantic structure can be deduced based on its child nodes. Alternatively, since the root node is the top-level node in a binary tree structure, it often represents the final answer to the sample problem. Therefore, its corresponding physical meaning can be directly analyzed from the sample problem or sample formula. That is, the semantic structure of the root node can be determined from the semantic analysis results of the sample problem and sample formula according to the preset semantic extraction rules.

[0063] This specification allows for the determination of the corresponding semantic structure using different methods based on the characteristics of different types of nodes, ensuring the correctness of the determined semantic structure and thus guaranteeing the correctness of the semantic structure label of the final first training sample.

[0064] It should be noted that the semantic structure labels carried by the first training samples are obtained by performing semantic analysis on the sample questions and combining them with the corresponding sample formulas. This analysis reveals the physical meaning represented by each formula factor, avoiding the situation where the sample labels of the training samples obtained from the Internet come from different people. This ensures that the sample labels carried by each first training sample in the first training sample set are fixed and uniform, simplifying the learning difficulty of subsequent models and improving the training efficiency of the models.

[0065] In one optional implementation of this embodiment, the first training sample can be pre-constructed, that is, the first training sample set can be obtained. The specific implementation process is as follows:

[0066] Obtain at least one first-sample problem and its corresponding first-sample formula;

[0067] Convert the form of the first sample expression from an infix expression to a prefix expression;

[0068] The first sample formula of the prefix expression is concatenated after the corresponding first sample question and separated by a preset separator to obtain the first training sample;

[0069] Each of the first training samples constitutes the first training sample set.

[0070] Specifically, infix expressions are expressions where operators are embedded in the middle of the formula, and may include meaningless parentheses, etc.; prefix expressions are expressions where operators come before numbers. Preset separators can refer to pre-set special symbols used to separate the sample problem and sample formula of the first training sample, such as [SEP].

[0071] It should be noted that after obtaining the first training sample and the corresponding first sample formula, the first sample formula can be converted from an infix expression to a prefix expression, thereby removing meaningless parentheses and other symbols in the first sample formula, reducing the information that the model needs to learn, reducing the amount of processing, and improving the learning speed.

[0072] For example, suppose a first-sample problem is "The perimeter of a square is 8 centimeters, what is the area of ​​the square?", the corresponding first-sample expression is "(8 ÷ 4)". 2 The first sample equation is changed from "(8÷4)". 2 Convert the expression to ^÷842, then append the converted first sample expression to the first sample question, and separate them using the preset separator "[SEP]" to obtain the first training sample: "The perimeter of a square is 8 centimeters. What is the area of ​​the square? [SEP]^÷842".

[0073] Step 104: Train the initial solution model based on the first training sample set and semantic structure labels to obtain the reference question solution model.

[0074] It should be noted that, based on obtaining the first training sample set and the second training sample set, and since the first training sample set is a collection of training samples carrying semantic structure labels, the first training sample set can be used to perform supervised training on the initial solution model to obtain the reference problem solution model.

[0075] In one optional implementation of this embodiment, the initial answer model is trained based on the first training sample set and the semantic structure labels to obtain a reference question answer model. The specific implementation process can be as follows:

[0076] Obtain a first training sample from the first training sample set, input the first training sample into the initial solution model, and obtain the predicted semantic structure corresponding to the first training sample output by the initial solution model;

[0077] The loss value of the initial solution model is calculated based on the predicted semantic structure and semantic structure label corresponding to the first training sample.

[0078] Based on the loss value, the parameters of the initial solution model are adjusted, and the operation step of obtaining the first training sample in the first training sample set is returned until the second training stopping condition is met, thus obtaining the reference problem solution model.

[0079] Specifically, the cross-entropy loss function can be calculated based on the predicted semantic structure and semantic structure label of the first training sample to generate a loss value. Here, the semantic structure label refers to the actual result that the initial solution model wants to output, that is, the semantic structure label is the true result. When the first training sample is input into the initial solution model, the output predicted semantic structure is the predicted result. When the difference between the predicted result and the true result is small enough, it means that the predicted result is close enough to the true result. At this time, the initial solution model training is completed, and the reference problem solution model is obtained.

[0080] In practical applications, the second training stopping condition may include: all the first training samples included in the first training sample set have been acquired, that is, all the first training samples included in the first training sample set have completed the training of the initial solution model.

[0081] It should be noted that the first training sample set may initially include only a small number of first training samples carrying semantic structure labels. Therefore, when all the first training samples have been trained, the training process of training the initial solution model based on the first training sample set is completed, and the second training stopping condition is met.

[0082] This manual demonstrates the difference between the model's predictions and the actual results by calculating the loss value. Targeted training of the initial solution model and adjustment of parameters can effectively improve the training speed and effectiveness.

[0083] In an optional implementation of this embodiment, the initial solution model may include an encoder, at least one classifier, and a masking layer. In this case, the first training sample is input into the initial solution model to obtain the predicted semantic structure corresponding to the first training sample output by the initial solution model. The specific implementation process can be as follows:

[0084] The first training sample is input into the encoder of the initial solution model to obtain the hidden state vector of the first training sample;

[0085] The hidden state vector is input into at least one classifier of the initial solution model to obtain the predicted label and probability output by the at least one classifier;

[0086] The predicted labels and probabilities output by the at least one classifier are input into the masking layer of the initial solution model to obtain the predicted semantic structure of the first training sample.

[0087] Specifically, the encoder of the initial solution model can be a BERT model. By inputting the first training sample into the encoder (i.e., the BERT model) of the initial solution model, the hidden state vector of the first training sample can be obtained, which is the vector obtained by re-encoding through the BERT model.

[0088] In practical applications, since the BERT model has unique requirements for input, if the input information consists of two parts, then the two parts need to be clearly identified. Therefore, before inputting the first training sample into the encoder of the initial solution model, the corresponding position information and segmentation information can be filled in according to the first training sample and vectorized to obtain the first training sample that can be input into the encoder.

[0089] Example, Figure 2 This is a schematic diagram of the structure of a first training sample provided in one embodiment of this specification, as shown below. Figure 2 As shown, the first training sample consists of three parts: Token, Position, and Segment. Token is the sample problem and sample formula in the form of a prefix expression included in the first training sample: "The perimeter of a square is 8 centimeters. What is the area of ​​the square? [SEP]^÷842". Position represents the location information, and Segment represents the segmentation information.

[0090] In addition, by inputting the hidden state vector output by the encoder (i.e., the BERT model) into at least one classifier of the initial solution model, the predicted labels and probabilities output by each classifier can be obtained. The classifier is a fully connected layer, and the size of the parameter matrix of the fully connected layer is the dimension of the hidden state vector multiplied by the size of the label list pre-stored in the classifier.

[0091] It's important to note that the classifier predicts all positions within the first training sample. However, elements like sample problems, predefined separators, and constants in the first training sample do not need to be predicted, and any label predicted by the model will be incorrect, potentially leading to model non-convergence. Therefore, a masking layer is added after the classifier. In this layer, the masking mask for positions where labels do not need to be predicted is set to 0, while the masking mask for positions where labels need to be predicted is set to 1. The predicted labels and probabilities corresponding to each position output by the classifier are input into the masking layer and multiplied bitwise with the predefined masking mask to obtain the labels and probabilities corresponding to the positions in the first training sample that need to be predicted. In other words, only the information about the positions in the first sample formula that need to be predicted in the first training sample is retained, thus obtaining the predicted semantic structure of the first training sample.

[0092] In this specification, by using a masking layer, only the information of the location of the semantic structure that needs to be predicted is output. That is, only when the information of the location of the semantic structure that needs to be predicted is the loss value generated and gradient backpropagation performed, the model is prevented from not converging, the amount of data that needs to be processed is reduced, and the model training speed is improved.

[0093] In an optional implementation of this embodiment, the semantic structure labels may include subject, predicate, and unit. That is, the classifier in the initial decoding model needs to predict three labels—subject, predicate, and unit—and their corresponding probabilities. Therefore, the initial solution model may include three classifiers: a subject classifier, a predicate classifier, and a unit classifier. Different classifiers predict different labels and probabilities. The hidden state vector is then input into at least one classifier of the initial solution model to obtain the predicted labels and probabilities output by the at least one classifier. The specific implementation process can be as follows:

[0094] The hidden state vector is input into the subject classifier of the initial solution model. The predicted subject and probability of each element in the first training sample are obtained by using the subject list stored in the subject classifier.

[0095] The hidden state vector is input into the predicate classifier of the initial solution model. The predicted predicate and probability corresponding to each element of the first training sample are obtained through the predicate list stored in the predicate classifier.

[0096] The hidden state vector is input into the unit classifier of the initial solution model. The predicted unit and probability of each element in the first training sample are obtained through the unit list stored in the unit classifier.

[0097] It should be noted that each classifier pre-stores a corresponding list of labels. For example, the subject classifier pre-stores a list of subjects, the predicate classifier pre-stores a list of predicates, and the unit classifier pre-stores a list of units.

[0098] In practical applications, the subject list, predicate list, and unit list can all be pre-collected within the corresponding domain. However, for some domains, predicates and units form a closed set, so it's possible to exhaustively enumerate all predicates and units within that domain to obtain the predicate list and unit list, such as in the domain of simple geometry. For subjects, it's difficult to exhaustively enumerate all subjects included in the corresponding domain. Therefore, we can select the top preset number of subjects or those with a frequency exceeding a threshold from the obtained subjects to form the subject list.

[0099] Example, Figure 3 This is a schematic diagram of the structure of a problem-solving model provided in one embodiment of this specification, such as... Figure 3 As shown, taking a classifier as an example, the first training sample includes a sample problem and a sample formula. The first training sample is input into the BERT model to obtain the hidden state vector output by the BERT model. The hidden state vector is then input into the predicate classifier. The predicate classifier predicts the predicate label and probability of each position in the input hidden state vector through a pre-stored predicate vocabulary. Then, the predicted predicate label and probability of each position are input into the masking layer. The labels and probabilities predicted for meaningless positions are discarded, and the labels and probabilities predicted for meaningful positions in the sample formula are retained, thus obtaining the predicted semantic structure of the first training sample.

[0100] It should be noted that when the initial solution model includes at least two classifiers, each classifier can share the hidden state vector output by the encoder (BERT model) and the subsequent masking layer. The list of labels carried by different classifiers is different, thereby obtaining the predicted semantic structure of the first training sample. This predicted semantic structure includes the dimensions corresponding to each classifier.

[0101] Example, Figure 4 This is a schematic diagram of another problem-solving model provided in one embodiment of this specification, as shown below. Figure 4 As shown, the explanation uses subject classifiers, predicate classifiers, and unit classifiers as examples. Figure 4As shown, the first training sample includes a sample question and a sample formula. Inputting the first training sample into the BERT model yields the hidden state vector output by the BERT model. This hidden state vector is then input into the subject classifier, predicate classifier, and unit classifier, respectively. The subject classifier, using a pre-stored subject vocabulary, predicts the subject label and probability at each position in the input hidden state vector; the predicate classifier, using a pre-stored predicate vocabulary, predicts the predicate label and probability at each position in the input hidden state vector; and the unit classifier, using a pre-stored unit vocabulary, predicts the unit label and probability at each position in the input hidden state vector.

[0102] Then, the predicted subject labels and probabilities, predicate labels and probabilities, and unit labels and probabilities for each position can be input into the masking layer. The labels and probabilities predicted for meaningless positions are discarded, while the labels and probabilities predicted for meaningful positions in the sample formula are retained, thus obtaining the predicted semantic structure of the first training sample. This predicted semantic structure includes the subject, predicate, and unit predicted for meaningful positions.

[0103] Step 106: Input each of the second training samples included in the second training sample set into the reference question-answering model to obtain the predicted semantic structure corresponding to each second training sample.

[0104] It should be noted that the second training samples in the second training sample set do not carry semantic structure labels; that is, the semantic structure of each second training sample is unknown. Since the reference question-solving model is initially trained based on the first training samples carrying semantic structure labels, the reference question-solving model can be used to predict the semantic structure of each second training sample in the second training sample set.

[0105] Step 108: Based on the predicted semantic structure, select target training samples from each of the second training samples and add them to the first training sample set to obtain the updated first training sample set.

[0106] Return to step 104 until the first training stop condition is met, and obtain the trained problem-solving model.

[0107] It should be noted that the first training sample set only includes a small number of first training samples. That is, the reference question-answering model is only initially trained based on a small number of first training samples carrying semantic structure labels. Therefore, the predicted semantic structure of each second training sample predicted by the reference question-answering model may contain obvious errors. Thus, target training samples can be selected from each second training sample that predicts the corresponding predicted semantic structure and added to the first training sample set to obtain an updated first training sample set.

[0108] In practical applications, in each round of training, the first training sample set contains more training samples than the previous round. As a result, the reference question-answering model obtained from the training will be more accurate and can correctly predict the semantic structure of more second training samples. Therefore, with each round of training, the first training sample set will contain more and more training samples, and the reference question-answering model can correctly predict more and more second training samples.

[0109] In practice, when the number of second training samples that the reference question-answering model can correctly predict does not increase significantly, that is, when the increase in the number of training samples included in the first training sample set is less than the magnitude threshold in several rounds of training, it indicates that the model has converged, the training has been completed, and the first training stopping condition can be determined.

[0110] In one optional implementation of this embodiment, each predicted semantic structure can be verified based on a preset formula knowledge base and a verification model. That is, according to the predicted semantic structure, target training samples are selected from each of the second training samples and added to the first training sample set. The specific implementation process can be as follows:

[0111] Based on the predicted semantic structure of each second training sample, a predicted formula semantic tree corresponding to each second training sample is generated;

[0112] Based on the pre-set formula knowledge base and verification model, the semantic tree of the predicted formula corresponding to each second training sample is verified.

[0113] The second training sample corresponding to the verified prediction formula semantic tree is used as the target training sample, and the corresponding prediction semantic structure is used as the semantic structure label of the target training sample.

[0114] The target training samples carrying semantic structure labels are added to the first training sample set.

[0115] Specifically, the pre-set formula knowledge base can refer to a pre-established knowledge base that includes most of the calculation formulas within the domain to which the sample problem belongs. For example, for the simple geometry domain, since the simple geometry domain is a closed set, all the formulas included in the simple geometry domain can be exhaustively enumerated and combined to form the pre-set formula knowledge base. Furthermore, the validation model can refer to a pre-trained binary classification model that can identify whether the input is correct, such as a pre-trained binary classification BERT model.

[0116] It should be noted that each predicted semantic structure can be verified based on the preset formula knowledge base and the verification model. The predicted semantic structure that passes the verification is the semantic structure that the reference question-answering model can accurately predict. That is, the reference question-answering model can accurately analyze and identify the corresponding second training sample and predict the correct semantic structure.

[0117] At this point, the second training sample corresponding to the verified predicted semantic structure can be identified as the selected target training sample. This target training sample has a correct predicted semantic structure, which can be used as the semantic structure label of the target training sample. That is, the selected target training sample includes the corresponding semantic structure label, so the target training sample is a labeled training sample. It is added to the first training sample set to enrich the training data included in the first training sample set. Then, the reference question-answering model obtained in the previous round of training is trained again based on the first training sample set. Then, the predicted semantic structure of the second training sample in the second training sample set is predicted again until the first training stopping condition is met, and the trained question-answering model is obtained.

[0118] In one optional implementation of this embodiment, the semantic tree of the predicted formula corresponding to each second training sample is verified based on a preset formula knowledge base and a verification model. The specific implementation process can be as follows:

[0119] Based on the preset formula knowledge base, knowledge verification is performed on the semantic tree of the predicted formula corresponding to each second training sample.

[0120] Determine the reference prediction formula semantic tree that has passed knowledge verification, and determine the root node predicate in the reference prediction formula semantic tree;

[0121] The sample question of the second training sample corresponding to the reference prediction formula semantic tree and the root node predicate are input into the verification model to obtain the target verification result output by the verification model.

[0122] It should be noted that, due to the limited number of training samples in the first training sample set, the prediction accuracy of the reference question-answering model is not high, and two types of errors may exist. One is a conflict within the predicted formula semantic tree itself generated based on the predicted semantic structure, i.e., the predicted formula semantic tree does not match the known formula knowledge, for example, the predicted formula semantic tree is area = (area ÷ 4). 2 Therefore, using geometric knowledge, we can know that the prediction is incorrect. To address this problem, this invention can use pre-collected knowledge formulas, i.e., a preset formula knowledge base, to verify the semantic tree of the predicted formula.

[0123] Another scenario involves a predictive semantic tree generated from the predicted semantic structure. While the predictive semantic tree itself is self-consistent and correct, the final result of this tree does not correspond to the question asked in the second training sample. In other words, the predicted answer does not match the question. For example, the predicted semantic tree might state "Area = Length * Width," but the corresponding question in the second training sample is "A cuboid has a base area of ​​3 square centimeters and a height of 4 centimeters. Find its volume." Therefore, the correct predicted semantic tree should be "Volume = Base Area * Height." In this case, this invention proposes training a binary classifier, or verification model, to verify whether the answer matches the question.

[0124] In practical applications, the predicted formula semantic tree generated based on the predicted semantic structure is first passed through a preset formula knowledge base, and then verified by a verification model. The final verified predicted formula semantic tree is the one that makes the correct prediction and meets the requirements of the corresponding sample question. The second training sample corresponding to the final verified predicted formula semantic tree is the selected target training sample.

[0125] In addition, when validating the predictive formula semantic tree generated from the predictive semantic structure, validation can be performed based solely on the predicates in the semantic structure.

[0126] In an optional implementation of this embodiment, the predicted formula semantic tree includes at least one semantic subtree, and each semantic subtree consists of a child node and a parent node; in this case, knowledge verification is performed on the predicted formula semantic tree corresponding to each second training sample according to the preset formula knowledge base. The specific implementation process can be as follows:

[0127] For each semantic subtree in the predicted formula semantic tree, the semantic subtree is matched with each preset formula included in the preset formula knowledge base. If a corresponding preset formula is matched, the semantic subtree is determined to pass the formula verification. If no corresponding preset formula is matched, the semantic subtree is subjected to rule verification. If the rule verification fails, an empty flag is added to the parent node of the semantic subtree.

[0128] Determine whether the null flag exists in the root node of the prediction formula semantic tree. If it exists, determine that the prediction formula semantic tree has failed knowledge verification. If it does not exist, determine that the prediction formula semantic tree has passed knowledge verification.

[0129] In practical applications, when matching a semantic subtree with various preset formulas included in a preset formula knowledge base, the relationship between the child nodes and parent nodes of the semantic subtree can be determined based on the preset formula knowledge base. If a corresponding matching formula exists in the preset formula knowledge base, it means that the semantic subtree has passed the formula verification. If not, the semantic subtree can be further verified based on preset rules to further determine whether the semantic subtree can pass the knowledge verification.

[0130] The preset rules can refer to the rules set in advance to determine whether the relationship between the child nodes and the parent nodes of the semantic subtree conforms to the correct knowledge theory. For example, the operator of the semantic subtree is the addition or subtraction sign, the predicates of the child nodes and the parent nodes in the semantic subtree are the same (area = area - area), the operator of the semantic subtree is the division sign, the predicates of the two child nodes are the same, and the predicate of the parent node is a multiple.

[0131] It should be noted that the formula may contain some meaningless intermediate results (i.e., those without corresponding physical meaning). A semantic subtree with such an intermediate result as its parent node may fail knowledge verification. However, the parent node of a semantic subtree with that intermediate result as its child node may have corresponding physical meaning and pass knowledge verification. Therefore, if a semantic subtree still fails knowledge verification, it does not directly determine that the entire prediction formula semantic tree has failed knowledge verification. Instead, a null flag can be added to the parent node of that semantic subtree. After all semantic subtrees included in the entire prediction formula semantic tree have been verified, the presence or absence of a null flag in the root node of the prediction formula semantic tree determines whether the prediction formula semantic tree has passed knowledge verification.

[0132] In an optional implementation of this embodiment, the above verification model can be trained using the following method:

[0133] Obtain a third training sample set, which includes at least one positive training sample and at least one negative training sample;

[0134] The initial validation model is trained using the positive and negative training samples in the third training sample set to obtain the completed validation model.

[0135] In practical applications, the validation model can be a binary classification model. Therefore, when training the validation model, it can be trained using both positive and negative training samples. Positive training samples are those whose labels correspond to the root node predicates of the sample question, while negative training samples are those whose labels do not correspond to the root node predicates of the sample question.

[0136] In one possible implementation, positive training samples can be data pairs of <sample problem, corresponding root node predicate>, while negative training samples are randomly constructed <sample problem, non-corresponding root node predicate>. Positive and negative training samples are mixed in a 1:1 ratio to train the validation model.

[0137] It should be noted that the initial validation model is trained using positive and negative training samples to obtain a trained validation model. This trained validation model can analyze the input sample question and the root node predicate to determine whether the input root node predicate corresponds to the input sample question. If it does, the correct label can be output; otherwise, an incorrect label can be output. Thus, the trained validation model can determine whether the root node predicate is the true answer to the corresponding sample question and whether it passes the final validation.

[0138] Example, Figure 5 This is a schematic diagram illustrating the verification process of a verification model provided in one embodiment of this specification, as shown below. Figure 5 As shown, the question to be answered and the root node predicate (separated by a preset separator [SEP]) are input into the BERT model. The BERT model can output a binary classification result, namely the probability of validation passing and the probability of validation failing.

[0139] Next, the complete training process of the question-answering model will be illustrated. Figure 6 This is a schematic diagram illustrating the training process of a problem-solving model provided in one embodiment of this specification, as shown below. Figure 6 As shown, firstly, a set of first training samples carrying semantic structure labels is obtained as the first training sample set, and a set of second training samples without semantic structure labels is obtained as the second training sample set. The initial solution model is trained using the first training sample set. The second training sample set is then input into the trained initial solution model to obtain the predicted semantic structure of the second training sample set. Next, based on a pre-defined formula knowledge base, the predicted semantic structure of the second training sample set is verified. Then, the predicted semantic structure that passes the knowledge verification is used for model verification. The second training samples corresponding to the verified predicted semantic structures are added to the first training sample set. The initial solution model is then trained again using the first training sample set until the training termination condition is met.

[0140] The training method for the question-answering model provided in this manual allows for the initial training of the model using a small number of training samples with semantic structure labels. Then, the reference question-answering model obtained from this initial training predicts the semantic structure of unlabeled training samples. From these predicted semantic structures, the most accurate ones are selected and used as new training samples with semantic structure labels for further training. In this way, the initial question-answering model can be trained using only a small number of semantically labeled training samples. Then, based on the trained reference question-answering model, semantically labeled sample data is added round by round, increasing the number of labeled training samples available for training the question-answering model. This results in a question-answering model with high accuracy, achieving this by using only a small number of semantically labeled training samples.

[0141] Figure 7 A flowchart of a problem-solving method according to an embodiment of this specification is shown, which specifically includes the following steps:

[0142] Step 702: Input the obtained question into the formula recognition model to obtain the solution formula for the question.

[0143] It should be noted that the problem to be solved can be one that requires detailed solution steps, and this problem can be within the field of mathematics, such as a problem in simple geometry. Furthermore, the solution formula can refer to the calculation formula for the answer to the problem to be solved, that is, the method of calculating the answer to the problem. Moreover, the formula recognition model can be a pre-trained model capable of recognizing and analyzing the input problem and outputting the corresponding calculation formula.

[0144] In practical applications, the question to be answered is text data, which can be obtained directly as text data, or it can be obtained as image data. By performing text recognition on the image data, the text data of the question to be answered can be obtained.

[0145] For example, the problem to be solved could be "The perimeter of a square is 8 centimeters. What is the area of ​​the square?". Inputting this problem into the formula recognition model will output the corresponding formula as "(8÷4)". 2 ".

[0146] In this manual, after obtaining the question to be solved, the question can be input into a pre-trained formula recognition model to obtain the corresponding solution formula. Subsequently, the question and the solution formula can be analyzed through the question-solving model to obtain detailed solution steps, providing a data foundation for the subsequent analysis process.

[0147] Step 704: Input the solution formula and the question to be solved into the problem-solving model to obtain the semantic structure of each formula factor in the solution formula.

[0148] The problem-solving model is based on the above. Figure 1 The problem-solving model shown was trained using the training method described.

[0149] In one optional implementation of this embodiment, the solution formula and the question to be solved are input into the problem-solving model. The specific implementation process can be as follows:

[0150] The solution formula is appended to the question to be solved and separated by a preset separator to obtain the information to be encoded.

[0151] The spliced ​​information to be encoded is input into the problem-solving model.

[0152] It should be noted that the preset separator can refer to a special symbol set in advance to separate the sample question and sample formula of the first training sample, such as [SEP].

[0153] Step 706: Generate an equation semantic tree based on the semantic structure of each equation factor, and determine the solution steps for the problem to be solved based on the equation semantic tree.

[0154] Specifically, the semantic structure can represent the physical meaning of the corresponding formula factors. The formula semantic tree can be a binary tree, in which each node corresponds to each formula factor included in the solution formula, and each node has a corresponding semantic structure.

[0155] It should be noted that an arithmetic semantic tree can include multiple nodes of different types, thus forming at least one semantic subtree. Each semantic subtree consists of child nodes and a parent node. That is, according to the order of operations, an arithmetic semantic tree can be divided into at least one semantic subtree, and each semantic subtree can represent one step in solving the problem.

[0156] In an optional implementation of this embodiment, the formula semantic tree includes at least one semantic subtree, and each semantic subtree consists of child nodes and a parent node; in this case, the solution steps for the problem to be solved are determined based on the formula semantic tree, and the specific implementation process can be as follows:

[0157] For each semantic subtree included in the semantic tree of the formula, the semantic structure of the child nodes and parent nodes included in the semantic subtree is substituted into the preset step template to obtain the solution steps corresponding to the semantic subtree;

[0158] The solution steps of each semantic subtree are used as the solution steps of the question to be solved.

[0159] It should be noted that the preset step template can be a template pre-set based on the semantic structure. By inputting the semantic structure of the child nodes and parent nodes of a semantic subtree into the preset step template, one solution step corresponding to that semantic subtree can be obtained. In this way, the solution steps corresponding to each semantic subtree included in the formula semantic tree can be obtained, and these solution steps are the detailed solution steps for the problem to be solved.

[0160] For example, assuming the preset step template is to find the parent node predicate of the parent node subject, the parent node predicate = the left child node predicate, the operator corresponding to the parent node, and the right child node predicate, therefore the parent node predicate of the parent node subject = the formula for this step = the result and the parent node unit. Figure 8 This is a schematic diagram of an arithmetic semantic tree provided in one embodiment of this specification, such as... Figure 8 As shown, the semantic tree of the equation for the problem to be solved includes two semantic subtrees. Semantic subtree 1 includes nodes “÷”, “8”, and “4”, and semantic subtree 2 includes nodes “^”, “÷”, and “2”.

[0161] For semantic subtree 1, the parent node is node "÷", and the child nodes are nodes "8" and "4". Substituting the semantic structure of the parent and child nodes into the above preset step template, we can obtain the solution steps corresponding to semantic subtree 1 as follows: Find the side length of the square. The side length = perimeter ÷ constant 4 (since the predicate of the right child node is a constant, there is no predicate, so we directly substitute the constant value). Therefore, the side length of the square = 8 ÷ 4 = 2 cm.

[0162] For semantic subtree 2, the parent node is node "^", and the child nodes are nodes "÷" and node "2". Substituting the semantic structures of the parent and child nodes into the preset step template above, we can obtain the solution steps for semantic subtree 2 as follows: Calculate the area of ​​the square. Area = side length ^ constant 2 (since the predicate of the right child node is a constant, there is no predicate, so we directly substitute the constant value). Therefore, the area of ​​the square = 2^2 = 4 centimeters. 2 】

[0163] Therefore, the problem to be solved involves two steps: Step 1: Find the side length of the square. Side length = perimeter ÷ constant 4, so the side length of the square = 8 ÷ 4 = 2 centimeters; Step 2: Find the area of ​​the square. Area = side length^2, so the area of ​​the square = 2^2 = 4 centimeters. 2 .

[0164] In addition, when deriving the physical meaning of intermediate nodes based on leaf nodes to determine the semantic structure of intermediate nodes, the intermediate nodes may not have a corresponding physical meaning. That is, the intermediate nodes only represent intermediate results of the operation and have no practical meaning. Therefore, the semantic structure of the intermediate nodes may be a meaningless identifier and does not include subject, predicate, and unit.

[0165] Therefore, when taking the semantic structure of the child nodes and parent nodes of each semantic subtree included in the semantic tree of the formula and inputting it into the preset step template to obtain the solution steps corresponding to the semantic subtree, if the semantic structure of the parent node of a certain semantic subtree is a meaningless identifier, then instead of generating the corresponding solution steps separately based on that semantic subtree, the intermediate node is also taken as a child node, and the corresponding parent node (not a meaningless node) is found upwards to form a new semantic subtree, thereby obtaining the corresponding solution steps.

[0166] For example, suppose the problem to be solved is "The area of ​​the triangle is 6 centimeters". 2 Given a triangle with a base of 3, find the height of the triangle. Using the problem-solving model, the solution is: 6 × 2 ÷ 3. The semantic tree for this solution is as follows: Figure 9 As shown, Figure 9 This is a schematic diagram of another semantic tree for arithmetic expressions provided in one embodiment of this specification. The semantic structure of node "6" is: Subject: triangle, Predicate: area, Unit: centimeters. 2 The semantic structure of node “2” is “constant”, the semantic structure of node “3” is “subject: triangle, predicate: base, unit: centimeters”, the semantic structure of node “×” is “meaningless identifier”, and the semantic structure of node “÷” is “subject: triangle, predicate: height, unit is centimeters”.

[0167] like Figure 9 As shown, since the semantic structure of the intermediate node "×" is a "meaningless identifier", this intermediate node and its included child nodes "6" and "2" do not constitute a separate semantic subtree. Instead, nodes "6", "2", "×", and "3" are all treated as child nodes, and node "÷" is treated as the parent node, forming a semantic subtree. When generating the corresponding solution steps, this intermediate node can be inserted between its included child nodes.

[0168] Assuming the preset step template is to find the parent node predicate of the parent node subject, the parent node predicate = left child node predicate, parent node corresponding operator, and right child node predicate. Therefore, the parent node predicate of the parent node subject = the formula for this step = the result and the parent node unit. Substituting the semantic structure of the parent and child nodes of this semantic subtree into the above preset step template, we can find the height of the triangle. Height = area × constant 2 ÷ base (since the node "×" is meaningless, "×" is inserted between the included child nodes). Therefore, the height of the triangle = 6 × 2 ÷ 3 = 4 centimeters.

[0169] Therefore, the problem to be solved includes one solution step. Step 1: Find the height of the triangle. Height = area × constant 2 ÷ base. So the height of the triangle = 6 × 2 ÷ 3 = 4 centimeters.

[0170] The problem-solving method provided in this manual can determine the semantic structure of each factor in the solution formula of the problem to be solved by using a pre-trained problem-solving model, and construct a formula semantic tree. This formula semantic tree can represent each solution step corresponding to the solution formula. Therefore, based on the constructed formula semantic tree, the detailed solution steps of the problem to be solved can be determined, making the problem-solving process of the device more detailed and visual, improving the visualization of problem-solving through the device, thereby improving the interpretability of the automatically obtained answers to the problem to be solved, greatly improving the user experience, and improving the efficiency and accuracy of determining the semantic structure by using the pre-trained problem-solving model.

[0171] Corresponding to the above method embodiments, this specification also provides embodiments of a training device for a problem-solving model. Figure 10 A schematic diagram of a training device for a problem-solving model according to an embodiment of this specification is shown. Figure 10 As shown, the device includes:

[0172] The acquisition module 1002 is configured to acquire a first training sample set and a second training sample set, wherein each first training sample in the first training sample set carries a semantic structure label.

[0173] The first training module 1004 is configured to train the initial solution model based on the first training sample set and the semantic structure label to obtain a reference question solution model.

[0174] The first obtaining module 1006 is configured to input each of the second training samples included in the second training sample set into the reference question answering model to obtain the predicted semantic structure corresponding to each of the second training samples.

[0175] The addition module 1008 is configured to select target training samples from each of the second training samples according to the predicted semantic structure and add them to the first training sample set to obtain an updated first training sample set, and then return to execute the first training module 1004 until the first training stop condition is met to obtain the trained question answering model.

[0176] Optionally, the first training module 1004 is further configured as follows:

[0177] Obtain a first training sample from the first training sample set, input the first training sample into the initial solution model, and obtain the predicted semantic structure corresponding to the first training sample output by the initial solution model;

[0178] The loss value of the initial solution model is calculated based on the predicted semantic structure and semantic structure label corresponding to the first training sample.

[0179] Based on the loss value, the parameters of the initial solution model are adjusted, and the operation step of obtaining the first training sample in the first training sample set is returned until the second training stopping condition is met, thus obtaining the reference problem solution model.

[0180] Optionally, the initial solution model includes an encoder, at least one classifier, and a masking layer; the first training module 1004 is further configured to:

[0181] The first training sample is input into the encoder of the initial solution model to obtain the hidden state vector of the first training sample;

[0182] The hidden state vector is input into at least one classifier of the initial solution model to obtain the predicted label and probability output by the at least one classifier;

[0183] The predicted labels and probabilities output by the at least one classifier are input into the masking layer of the initial solution model to obtain the predicted semantic structure of the first training sample.

[0184] Optionally, the at least one classifier is a subject classifier, a predicate classifier, and a unit classifier; the first training module 1004 is further configured to:

[0185] The hidden state vector is input into the subject classifier of the initial solution model. The predicted subject and probability of each element in the first training sample are obtained by using the subject list stored in the subject classifier.

[0186] The hidden state vector is input into the predicate classifier of the initial solution model. The predicted predicate and probability corresponding to each element of the first training sample are obtained through the predicate list stored in the predicate classifier.

[0187] The hidden state vector is input into the unit classifier of the initial solution model. The predicted unit and probability of each element in the first training sample are obtained through the unit list stored in the unit classifier.

[0188] Optionally, the acquisition module 1002 is further configured as follows:

[0189] Obtain at least one first-sample problem and its corresponding first-sample formula;

[0190] Convert the form of the first sample expression from an infix expression to a prefix expression;

[0191] The first sample formula of the prefix expression is concatenated after the corresponding first sample question and separated by a preset separator to obtain the first training sample;

[0192] Each of the first training samples constitutes the first training sample set.

[0193] Optionally, module 1008 is further configured as follows:

[0194] Based on the predicted semantic structure of each second training sample, a predicted formula semantic tree corresponding to each second training sample is generated;

[0195] Based on the pre-set formula knowledge base and verification model, the semantic tree of the predicted formula corresponding to each second training sample is verified.

[0196] The second training sample corresponding to the verified prediction formula semantic tree is used as the target training sample, and the corresponding prediction semantic structure is used as the semantic structure label of the target training sample.

[0197] The target training samples carrying semantic structure labels are added to the first training sample set.

[0198] Optionally, module 1008 is further configured as follows:

[0199] Based on the preset formula knowledge base, knowledge verification is performed on the semantic tree of the predicted formula corresponding to each second training sample.

[0200] Determine the reference prediction formula semantic tree that has passed knowledge verification, and determine the root node predicate in the reference prediction formula semantic tree;

[0201] The sample question of the second training sample corresponding to the reference prediction formula semantic tree and the root node predicate are input into the verification model to obtain the target verification result output by the verification model.

[0202] Optionally, the prediction formula semantic tree includes at least one semantic subtree, and each semantic subtree consists of child nodes and a parent node; the adding module 1008 is further configured to:

[0203] For each semantic subtree in the predicted formula semantic tree, the semantic subtree is matched with each preset formula included in the preset formula knowledge base. If a corresponding preset formula is matched, the semantic subtree is determined to pass the formula verification. If no corresponding preset formula is matched, the semantic subtree is subjected to rule verification. If the rule verification fails, an empty flag is added to the parent node of the semantic subtree.

[0204] Determine whether the null flag exists in the root node of the prediction formula semantic tree. If it exists, determine that the prediction formula semantic tree has failed knowledge verification. If it does not exist, determine that the prediction formula semantic tree has passed knowledge verification.

[0205] Optionally, the training apparatus for the question-solving model further includes a second training module, configured as follows:

[0206] Obtain a third training sample set, which includes at least one positive training sample and at least one negative training sample;

[0207] The initial validation model is trained using the positive and negative training samples in the third training sample set to obtain the completed validation model.

[0208] The training device for the question-answering model provided in this manual can first train an initial answering model using a small number of training samples with semantic structure labels. Then, it uses the reference question-answering model obtained from the initial training to predict the semantic structure of unlabeled training samples. From the predicted semantic structures, the more accurate predicted semantic structures are selected as new training samples with semantic structure labels for further training. In this way, the initial answering model can be trained using only a small number of training samples with semantic structure labels. Then, based on the trained reference question-answering model, sample data with semantic structure labels is added round by round, increasing the number of labeled training samples that can be used to train the question-answering model, thereby obtaining a question-answering model with high accuracy. A question-answering model with high accuracy can be obtained with only a small number of training samples with semantic structure labels.

[0209] The above is a schematic scheme of a training device for a question-answering model according to this embodiment. It should be noted that the technical solution of this training device for a question-answering model and the technical solution of the above-described training method for a question-answering model belong to the same concept. For details not described in detail in the technical solution of the training device for a question-answering model, please refer to the description of the technical solution of the above-described training method for a question-answering model.

[0210] Corresponding to the above method embodiments, this specification also provides embodiments of a training device for a problem-solving model. Figure 11 A schematic diagram of a problem-solving device provided in one embodiment of this specification is shown.

[0211] like Figure 11 As shown, the device includes:

[0212] The second obtaining module 1102 is configured to input the obtained unsolved question into the formula recognition model to obtain the solution formula for the unsolved question;

[0213] The third obtaining module 1104 is configured to input the solution formula and the question to be solved into the question solving model to obtain the semantic structure of each formula factor in the solution formula, wherein the question solving model is trained by the above-mentioned question solving model training method;

[0214] The determination module 1106 is configured to generate an arithmetic semantic tree based on the semantic structure of each arithmetic factor, and to determine the solution steps for the problem to be solved based on the arithmetic semantic tree.

[0215] Optionally, the third acquisition module 1104 is further configured as follows:

[0216] The solution formula is appended to the question to be solved and separated by a preset separator to obtain the information to be encoded.

[0217] The spliced ​​information to be encoded is input into the problem-solving model.

[0218] Optionally, the formula semantic tree includes at least one semantic subtree, each semantic subtree consisting of child nodes and a parent node; the determining module 1106 is further configured to:

[0219] For each semantic subtree included in the formula semantic tree, the semantic structure of the child nodes and parent nodes included in the semantic subtree is substituted into a preset step template to obtain the solution steps corresponding to the semantic subtree;

[0220] The solution steps of each semantic subtree are used as the solution steps of the question to be solved.

[0221] The problem-solving device provided in this manual can determine the semantic structure of each factor in the solution formula of the problem to be solved by using a pre-trained problem-solving model, and construct a formula semantic tree. This formula semantic tree can represent each solution step corresponding to the solution formula. Therefore, based on the constructed formula semantic tree, the detailed solution steps of the problem to be solved can be determined, making the problem-solving process of the device more detailed and visual, improving the visualization of problem-solving through the device, thereby improving the interpretability of the automatically obtained answers to the problem to be solved, greatly improving the user experience, and improving the efficiency and accuracy of determining the semantic structure by using the pre-trained problem-solving model.

[0222] The above is a schematic scheme of a question-answering device according to this embodiment. It should be noted that the technical solution of this question-answering device and the technical solution of the question-answering method described above belong to the same concept. For details not described in detail in the technical solution of the question-answering device, please refer to the description of the technical solution of the question-answering method described above.

[0223] Figure 12 A structural block diagram of a computing device 1200 according to an embodiment of this specification is shown. The components of the computing device 1200 include, but are not limited to, a memory 1210 and a processor 1220. The processor 1220 is connected to the memory 1210 via a bus 1230, and a database 1250 is used to store data.

[0224] The computing device 1200 also includes an access device 1240, which enables the computing device 1200 to communicate via one or more networks 1260. 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 1240 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a 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 so on.

[0225] In one embodiment of this specification, the aforementioned components of the computing device 1200 and Figure 12 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 12 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0226] The computing device 1200 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 1200 can also be a mobile or stationary server.

[0227] The processor 1220 is used to execute the following computer-executable instructions to implement the steps of the training method or problem-solving method for the problem-solving model.

[0228] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the technical solution of the above-mentioned problem-solving model training method or problem-solving method. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned problem-solving model training method or problem-solving method.

[0229] An embodiment of this specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, are used to implement steps of a training method for a problem-solving model or a problem-solving method.

[0230] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the above-described question-answering model training method or question-answering method. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the above-described question-answering model training method or question-answering method.

[0231] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0232] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted 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 may not include electrical carrier signals and telecommunication signals.

[0233] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this specification is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this specification. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this specification.

[0234] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0235] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. These embodiments have been selected and specifically described in this specification to better explain the principles and practical applications of this specification, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A method for training a question-answering model, characterized in that, The method includes: Obtain a first training sample set and a second training sample set. Each first training sample in the first training sample set carries a semantic structure label. Each first training sample includes a sample question and a sample formula. The sample formula includes a calculation method to obtain the answer to the sample question. The semantic structure label includes the semantic structure corresponding to each formula factor in the sample formula. Each second training sample in the second training sample set does not carry a semantic structure label. Based on the first training sample set and the semantic structure labels, the initial answer model is trained to obtain the reference question answer model; Each of the second training samples included in the second training sample set is input into the reference question answering model to obtain the predicted semantic structure corresponding to each of the second training samples; Based on the predicted semantic structure, target training samples are selected from each of the second training samples and added to the first training sample set to obtain an updated first training sample set. Then, the operation steps of training the initial answer model based on the first training sample set and the semantic structure label to obtain a reference question answer model are returned until the first training stopping condition is met, and the trained question answer model is obtained.

2. The training method for the question-answering model according to claim 1, characterized in that, The step of training the initial answer model based on the first training sample set and the semantic structure labels to obtain a reference question answer model includes: Obtain a first training sample from the first training sample set, input the first training sample into the initial solution model, and obtain the predicted semantic structure corresponding to the first training sample output by the initial solution model; The loss value of the initial solution model is calculated based on the predicted semantic structure and semantic structure label corresponding to the first training sample. Based on the loss value, the parameters of the initial solution model are adjusted, and the operation step of obtaining the first training sample in the first training sample set is returned until the second training stopping condition is met, thus obtaining the reference problem solution model.

3. The training method for the question-answering model according to claim 2, characterized in that, The initial solution model includes an encoder, at least one classifier, and a masking layer; The step of inputting the first training sample into the initial solution model to obtain the predicted semantic structure corresponding to the first training sample output by the initial solution model includes: The first training sample is input into the encoder of the initial solution model to obtain the hidden state vector of the first training sample; The hidden state vector is input into at least one classifier of the initial solution model to obtain the predicted label and probability output by the at least one classifier; The predicted labels and probabilities output by the at least one classifier are input into the masking layer of the initial solution model to obtain the predicted semantic structure of the first training sample.

4. The training method for the question-answering model according to claim 3, characterized in that, The at least one classifier is a subject classifier, a predicate classifier, and a unit classifier; The step of inputting the hidden state vector into at least one classifier of the initial solution model to obtain the predicted label and probability output by the at least one classifier includes: The hidden state vector is input into the subject classifier of the initial solution model. The predicted subject and probability of each element in the first training sample are obtained by using the subject list stored in the subject classifier. The hidden state vector is input into the predicate classifier of the initial solution model. The predicted predicate and probability corresponding to each element of the first training sample are obtained through the predicate list stored in the predicate classifier. The hidden state vector is input into the unit classifier of the initial solution model. The predicted unit and probability of each element in the first training sample are obtained through the unit list stored in the unit classifier.

5. The training method for the problem-solving model according to any one of claims 1-4, characterized in that, The process of obtaining the first training sample set includes: Obtain at least one first-sample problem and its corresponding first-sample formula; Convert the form of the first sample expression from an infix expression to a prefix expression; The first sample formula of the prefix expression is concatenated after the corresponding first sample question and separated by a preset separator to obtain the first training sample; Each of the first training samples constitutes the first training sample set.

6. The training method for the question-answering model according to any one of claims 1-4, characterized in that, The step of selecting target training samples from each of the second training samples and adding them to the first training sample set based on the predicted semantic structure includes: Based on the predicted semantic structure of each second training sample, a predicted formula semantic tree corresponding to each second training sample is generated; Based on the pre-set formula knowledge base and verification model, the semantic tree of the predicted formula corresponding to each second training sample is verified. The second training sample corresponding to the verified prediction formula semantic tree is used as the target training sample, and the corresponding prediction semantic structure is used as the semantic structure label of the target training sample. The target training samples carrying semantic structure labels are added to the first training sample set.

7. The training method for the question-answering model according to claim 6, characterized in that, The step of validating the semantic tree of the predicted formula corresponding to each second training sample based on the preset formula knowledge base and the validation model includes: Based on the preset formula knowledge base, knowledge verification is performed on the semantic tree of the predicted formula corresponding to each second training sample. Determine the reference prediction formula semantic tree that has passed knowledge verification, and determine the root node predicate in the reference prediction formula semantic tree; The sample question of the second training sample corresponding to the reference prediction formula semantic tree and the root node predicate are input into the verification model to obtain the target verification result output by the verification model.

8. The training method for the question-answering model according to claim 7, characterized in that, The prediction formula semantic tree includes at least one semantic subtree, and each semantic subtree consists of a child node and a parent node; The step of performing knowledge verification on the semantic tree of the predicted formula corresponding to each second training sample based on the preset formula knowledge base includes: For each semantic subtree in the predicted formula semantic tree, the semantic subtree is matched with each preset formula included in the preset formula knowledge base. If a corresponding preset formula is matched, the semantic subtree is determined to pass the formula verification. If no corresponding preset formula is matched, the semantic subtree is subjected to rule verification. If the rule verification fails, an empty flag is added to the parent node of the semantic subtree. Determine whether the null flag exists in the root node of the prediction formula semantic tree. If it exists, determine that the prediction formula semantic tree has failed knowledge verification. If it does not exist, determine that the prediction formula semantic tree has passed knowledge verification.

9. The training method for the question-answering model according to claim 6, characterized in that, The verification model was trained using the following method: Obtain a third training sample set, which includes at least one positive training sample and at least one negative training sample; The initial validation model is trained using the positive and negative training samples in the third training sample set to obtain the completed validation model.

10. A method for answering a problem, characterized in that, The method includes: The obtained question to be solved is input into the formula recognition model to obtain the solution formula for the question to be solved; The solution formula and the question to be solved are input into the problem-solving model to obtain the semantic structure of each formula factor in the solution formula, wherein the problem-solving model is trained by the training method of the problem-solving model described in any one of claims 1-9 above; Based on the semantic structure of each formula factor, a formula semantic tree is generated, and based on the formula semantic tree, the solution steps for the problem to be solved are determined.

11. The problem-solving method according to claim 10, characterized in that, The step of inputting the solution formula and the question to be solved into the problem-solving model includes: The solution formula is appended to the question to be solved and separated by a preset separator to obtain the information to be encoded. The spliced ​​information to be encoded is input into the problem-solving model.

12. The problem-solving method according to claim 10 or 11, characterized in that, The formula semantic tree includes at least one semantic subtree, and each semantic subtree consists of a child node and a parent node; The steps for determining the solution to the problem based on the semantic tree of the formula include: For each semantic subtree included in the formula semantic tree, the semantic structure of the child nodes and parent nodes included in the semantic subtree is substituted into a preset step template to obtain the solution steps corresponding to the semantic subtree; The solution steps of each semantic subtree are used as the solution steps of the question to be solved.

13. A training device for a problem-solving model, characterized in that, The device includes: The acquisition module is configured to acquire a first training sample set and a second training sample set. Each first training sample in the first training sample set carries a semantic structure label. The first training sample includes a sample question and a sample formula. The sample formula includes a calculation method to obtain the answer to the sample question. The semantic structure label includes the semantic structure corresponding to each formula factor in the sample formula. Each second training sample in the second training sample set does not carry a semantic structure label. The first training module is configured to train the initial answer model based on the first training sample set and the semantic structure label to obtain a reference question answer model. The first obtaining module is configured to input each of the second training samples included in the second training sample set into the reference question answering model to obtain the predicted semantic structure corresponding to each of the second training samples. The addition module is configured to select target training samples from each of the second training samples according to the predicted semantic structure and add them to the first training sample set to obtain an updated first training sample set, and then return to execute the first training module until the first training stopping condition is met to obtain a trained question answering model.

14. A question-answering device, characterized in that, The device includes: The second obtaining module is configured to input the obtained question to be answered into the formula recognition model to obtain the answer formula for the question to be answered; The third obtaining module is configured to input the solution formula and the question to be solved into the question solving model to obtain the semantic structure of each formula factor in the solution formula, wherein the question solving model is trained by the training method of the question solving model described in any one of claims 1-9 above; The determination module is configured to generate an arithmetic semantic tree based on the semantic structure of each arithmetic factor, and to determine the solution steps for the problem to be solved based on the arithmetic semantic tree.

15. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the training method of the problem-solving model according to any one of claims 1-9, or the steps of the problem-solving method according to any one of claims 10-12.

16. A computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the training method for the problem-solving model according to any one of claims 1-9, or the steps of the problem-solving method according to any one of claims 10-12.

Citation Information

Patent Citations

  • Question-answer matching model updating method and device

    CN111008263A

  • Text generation model training method and device and electronic equipment

    CN111709248A