Exercise analysis method, device, equipment and storage medium
By finding similar exercises and expressions in the exercise bank, and using the exercise analysis model for semantic analysis and analogy learning, the problem of wrong answers in automatic solution of application questions is solved, and the accuracy of the problem is improved and the solution ability of the model is improved.
Patent Information
- Application Number
- CN202111062194.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-09-10
AI Technical Summary
In the prior art, when matching the application question calculation expression template in the automatic problem-solving task of applying questions, problems that are wrong or cannot be calculated are prone to occur.
By finding similar exercises and corresponding expressions for the exercise to be solved in the exercise bank, using the exercise analysis model for semantic analysis and analogy learning, and generating the expression to be solved to get the answer.
It improves the problem-solving accuracy of the exercise analysis model, reduces the situation of wrong answers or inability to calculate, simulates human problem-solving modes and performs analogical learning, and enhances the model's solution ability.
Smart Images

Figure CN115809663B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of word processing technology, and in particular to an exercise analysis method, apparatus, device, and storage medium. Background Art
[0002] In the field of mathematics, the task of automatically solving word problems refers to directly obtaining the corresponding answer through a specific technical solution (i.e., the problem-solving process) based on a given word problem. Although this method can obtain the answer to the word problem, it ignores the reasoning process of the solution link. In order to clarify the reasoning process in the automatic problem-solving task, some related technologies use statistical machine learning and template matching methods to match the word problem information to the corresponding word problem calculation expression template, and calculate the answer to the word problem based on the word problem calculation expression template. This method only works well under limited word problem calculation expression templates. When the word problem calculation expression template cannot be matched, the answer to the word problem will be wrong or the answer to the word problem cannot be calculated, making the effect of the automatic problem-solving task poor. Summary of the Invention
[0003] An embodiment of the present application provides an exercise analysis method, apparatus, device and storage medium to solve the technical problem in related technologies that when matching expression templates for application problem calculations, incorrect answers to application problems may occur or the answers to application problems may not be calculated.
[0004] In a first aspect, an embodiment of the present application provides an exercise analysis method, comprising:
[0005] Get the exercises to be solved;
[0006] Searching for at least one first similar problem to the problem to be solved in the problem database, and obtaining a first expression of the first similar problem;
[0007] Inputting the problem to be solved, the first similar problem, and the corresponding first expression into a problem analysis model, and obtaining the expression to be solved of the problem to be solved by the problem analysis model;
[0008] The answers to the exercises to be solved are obtained according to the expressions to be solved.
[0009] In a second aspect, an embodiment of the present application further provides an exercise analysis device, comprising:
[0010] An acquisition module is used to obtain exercises to be solved;
[0011] a search module, configured to search the problem database for at least one first similar problem to the problem to be solved, and obtain a first expression of the first similar problem;
[0012] An analysis module, configured to input the problem to be solved, the first similar problem, and the corresponding first expression into a problem analysis model, and obtain a solution expression of the problem to be solved by the problem analysis model;
[0013] A solution module is used to obtain the answer to the exercise to be solved according to the expression to be solved.
[0014] In a third aspect, an embodiment of the present application further provides an exercise analysis device, comprising:
[0015] one or more processors;
[0016] a memory for storing one or more programs;
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the exercise analysis method as described in the first aspect.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the exercise analysis method as described in the first aspect.
[0019] In one embodiment of the present application, by obtaining a problem to be solved, searching a problem library for a first similar problem and a corresponding first expression that are similar to the problem to be solved, and then inputting the problem to be solved, the first similar problem, and the first expression into a problem analysis model, a technical means is provided to obtain the expression to be solved, and then the answer to the problem is obtained based on the expression to be solved. This technical means solves the technical problem that when matching a calculation expression template for a word problem, incorrect answers to word problems or inability to calculate the answer to a word problem are easily generated. When solving the problem to be solved, the problem analysis model refers to the retrieved first similar problem and the first expression, thereby improving the problem analysis model's problem-solving ability and making it less likely to give incorrect answers or be unable to calculate the answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A flowchart of a method for analyzing an exercise provided in one embodiment of the present application;
[0021] Figure 2 A flow chart of a training method for an exercise analysis model provided in one embodiment of the present application;
[0022] Figure 3 A schematic diagram of a mask matrix provided in one embodiment of the present application;
[0023] Figure 4 A schematic diagram of another mask matrix provided in one embodiment of the present application;
[0024] Figure 5A schematic diagram of the structure of an exercise analysis device provided in one embodiment of the present application;
[0025] Figure 6 A schematic structural diagram of an exercise analysis device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0026] The present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended to explain the present application, not to limit the present application. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present application, not all structures.
[0027] Among related technologies, since the large-scale word problem dataset, math23k, was made public, deep learning-based methods for automatically solving word problems have become widely used. Deep learning involves learning the inherent patterns and representational hierarchies of sample data, with the ultimate goal of enabling machines to acquire human-like analytical and learning capabilities. Sequence-to-sequence models based on recurrent neural networks are a commonly used deep learning method for automatically solving word problems. This approach requires first representing the numbers appearing in the word problem and calculation expressions in the word problem dataset using a unified character representation to generate an expression template. After the sequence-to-sequence model is trained, the current word problem to be solved is encoded to obtain an encoding vector. The sequence-to-sequence model is then used to generate the corresponding calculation expression. This approach significantly differs from the way humans solve word problems. Humans first analyze the semantics (i.e., clarify the problem description and the relationship between the problem and the numbers) and then solve based on the semantics. Furthermore, when solving word problems using expression templates, there is only one fixed expression template for each type of word problem, making analogical learning impossible.
[0028] In summary, an embodiment of the present application provides an exercise analysis method, device, equipment and storage medium, which can not only solve the technical problems in the related technology of incorrect answers to application questions or inability to calculate answers to application questions when matching application question calculation expression templates, but also can imitate the human answering mode when automatically answering application questions, and can perform analogical learning.
[0029] The exercise analysis method provided in one embodiment of the present application can be performed by an exercise analysis device. The exercise analysis device can be implemented through software and / or hardware. The exercise analysis device can be composed of two or more physical entities, or a single physical entity, without limitation. In one embodiment, the exercise analysis device can be an electronic device with data processing and analysis capabilities, such as a desktop computer, a laptop computer, a learning machine, an interactive smart tablet, or a server.
[0030] For example, Figure 1 This is a flowchart of a method for analyzing exercises provided in one embodiment of the present application. Figure 1 , the analysis method of this exercise specifically includes:
[0031] Step 110: Obtain the exercises to be solved.
[0032] The exercises to be solved refer to the exercises that currently need to be solved. In one embodiment, the exercises to be solved are mathematical word problems. The exercises to be solved can be one or more, and there is no current limitation on this. The method for obtaining the exercises to be solved is currently not limited. For example, the exercises to be solved are exercises input by the user. In another example, the exercises to be solved are exercises obtained by taking a photo and then using text recognition (such as optical character recognition). In another example, the exercises to be solved are exercises found in an Internet question bank. It can be understood that the exercises to be solved currently obtained mainly refer to the titles of the exercises.
[0033] Step 120: Search the problem database for at least one first similar problem to the problem to be solved, and obtain a first expression of the first similar problem.
[0034] The exercise database contains a large number of exercises and corresponding calculation expressions. The exercises are the titles of the exercises, and the corresponding calculation expressions are the mathematical formulas used to solve the exercises. Optionally, the exercise database also includes the answers to the exercises. In one embodiment, the exercise database contains at least mathematical word problems and may also include other types of exercises.
[0035] Exemplarily, in the question bank, at least one question that is similar to the question to be solved is searched, and the question found is recorded as the first similar question. In one embodiment, the similarity between the question to be solved and each question in the question bank is compared (specifically, the similarity of the questions), and then, at least one first similar question that is most similar is selected based on the similarity. Optionally, the number of first similar questions is pre-set (which can be set according to actual conditions), and then, based on the set number, the question with the highest similarity is selected from the question bank as the first similar question. Optionally, a similarity threshold is set, and the similarity between the selected first similar question and the question to be solved needs to be higher than the similarity threshold. If the number of first similar questions that are currently higher than the similarity threshold does not reach the set number, only the first similar questions that are higher than the similarity threshold are obtained. It can be understood that if the similarity is less than the similarity threshold, it means that the corresponding question in the question bank is not very similar to the question to be solved, and the problem-solving process of the question is not applicable to the question to be solved.
[0036] When comparing similarities, the first similar problem can be found by comparing keyword similarities between the problem to be solved and each problem in the problem bank. Alternatively, the first similar problem can be found by vectorizing the problem to be solved and each problem in the problem bank, and then calculating vector similarities. In one embodiment, vectorization is used as an example to describe how to find the first similar problem. In this case, searching the problem bank for at least one first similar problem to the problem to be solved includes steps 121 to 125:
[0037] Step 121: Segment the words of the problem to be solved to obtain all the first words that appear in the problem to be solved.
[0038] For example, the problem to be solved is segmented to separate the words in the problem. It is understood that the problem to be solved can be considered a text sequence. After segmentation, the problem to be solved can be broken down into individual words. In one embodiment, the words obtained after the problem to be solved is recorded as the first vocabulary. It should be noted that when segmenting the problem to be solved, existing segmentation methods are used, and this is not currently limited.
[0039] Step 122: Search the corpus for the word vector corresponding to the first word.
[0040] The corpus is a pre-built word vector library, which contains a large number of words and corresponding word vectors. Among them, word vector refers to the representation of words in the form of vectors. In one embodiment, the words contained in the corpus are the words of each exercise title in the exercise bank. For example, the words contained in each exercise title in the exercise bank are first determined. Afterwards, each word is vectorized to obtain a word vector representation of each word, wherein the word vector representation is recorded as a word vector. Optionally, the vectorization method is not currently limited. For example, a neural network that can be vectorized is pre-trained through neural network technology. Afterwards, each word in the exercise bank is input into the neural network to obtain the corresponding word vector. At this point, each word in the exercise bank has a corresponding word vector, and each word vector and word constitute the corpus.
[0041] Exemplarily, after obtaining the first vocabulary contained in the exercise to be solved, the first vocabulary is searched in the corpus, that is, the vocabulary identical to the first vocabulary is found, and the word vector of the vocabulary is obtained as the word vector of the first vocabulary. Among them, the vocabulary identical to the first vocabulary means that the text contained in the two vocabulary is the same. It is understandable that there is a case where the first vocabulary does not exist in the corpus. In this case, the word vector corresponding to the first vocabulary can be considered to be a zero vector, or another pre-set vector. After traversing each first vocabulary, the word vector corresponding to each first vocabulary is obtained.
[0042] Step 123: Obtain the first sentence vector of the problem to be solved based on the word vectors corresponding to each first vocabulary word.
[0043] Exemplarily, a sentence vector refers to a vector representing a sentence (in the embodiment, an exercise title). In one embodiment, the sentence vector representing the exercise to be solved is recorded as the first sentence vector. The first sentence vector is obtained by obtaining the word vector corresponding to each first word in the exercise to be solved. In one embodiment, the word vectors of each first word are averaged to obtain the first sentence vector. In this case, the first sentence vector is represented as:
[0044]
[0045] in, represents the first sentence vector of the problem to be solved, K represents the total number of first words contained in the problem to be solved, D represents the corpus, V nk Represents the word vector corresponding to the kth first word in the problem to be solved, V nk ∈D indicates that there is a word vector corresponding to the kth first word in the corpus, Z nj represents the zero vector corresponding to the jth first word in the problem to be solved, Indicates that the word vector corresponding to the jth first word does not exist in the corpus. From the above formula, we can see that we traverse the K first words in turn and find the word vector V corresponding to the first word that appears in the corpus nk , the first word that does not appear in the corpus is set to a zero vector. Then, the word vectors are added to the zero vector and the mean is calculated to obtain the first sentence vector. It can be understood that k and j in the above formula are only used to distinguish whether the first word appears in the corpus, rather than limiting the first word. It can be understood that n represents the current nth problem to be solved. When there is only one problem to be solved, n = 1.
[0046] Step 124: Calculate the similarity between the first sentence vector and the second sentence vector of each exercise in the exercise database, where the second sentence vector is determined based on the word vectors in the corpus.
[0047] Exemplarily, each exercise in the exercise bank has a corresponding sentence vector. In one embodiment, the sentence vector of the exercise in the exercise bank is recorded as the second sentence vector. In one embodiment, when constructing a corpus, a second sentence vector corresponding to each exercise in the exercise bank can be constructed based on each word vector and the corresponding vocabulary in the corpus. Optionally, the second sentence vector can also be determined based on the word vector corresponding to each vocabulary in the exercise. In one embodiment, the process of constructing a corpus and constructing a second sentence vector is as follows: each exercise in the exercise bank is segmented to obtain all the second vocabulary that appears in the exercise bank; a vectorization model is used to obtain the word vector corresponding to each second vocabulary, and each word vector constitutes a corpus; the word vector of each second vocabulary in the exercise is averaged to obtain the second sentence vector of the exercise.
[0048] Among them, the title of each exercise in the exercise bank is segmented, and this process is the same as the segmentation method used in step 121. In one embodiment, each vocabulary appearing in the exercise bank is recorded as a second vocabulary. Optionally, after the segmentation, the same second vocabulary can be deduplicated to avoid repeated processing of the same second vocabulary. Afterwards, the word vector of each second vocabulary is obtained using a vectorization model. The vectorization model is a pre-built neural network. In one embodiment, the vectorization model adopts a Word2Vec model, wherein Word2Vec is a natural language processing (NLP) tool, which is used to generate a related model for word vectors. Optionally, the Word2Vec model uses a shallow and double-layer neural network, and after the neural network training is completed, it can be used to map each word to a vector, and the word vector corresponding to the word can be obtained by the mapped vector. It should be noted that the training process of the Word2Vec model and the data set used in the training are not currently limited. It can be understood that after the word vector of each second vocabulary is obtained using the vectorization model, the corpus is composed of each second vocabulary and the word vector. For example, after obtaining the word vector, the word vector corresponding to each second word is determined based on the second word contained in each exercise in the exercise database, and the second sentence vector of each exercise is obtained based on the word vector. The second sentence vector is also determined by averaging, and the second sentence vector can be expressed as:
[0049]
[0050] Among them, Str n represents the second sentence vector of the nth exercise in the exercise database, K represents the total number of second words contained in the nth exercise, V nk Represents the word vector corresponding to the kth second word in the nth exercise. According to the above formula, we can get the word vector V corresponding to the K second words in the exercise nk After calculating the mean, we can get the second sentence vector of the nth exercise. It can be understood that after obtaining the second sentence vector of each exercise, each exercise is associated with the second sentence vector and saved.
[0051] In one embodiment, after obtaining the first sentence vector, the similarity between the first sentence vector and the second sentence vector of each exercise in the exercise library is calculated. The higher the similarity, the more similar the exercise to be solved is to the exercise corresponding to the second sentence vector, and the more likely the solution idea corresponding to the calculation expression of the exercise is to be applied to the exercise to be solved. Optionally, the length of the first sentence vector and the second sentence vector are the same. Exemplarily, the similarity between the first sentence vector and the second sentence vector can be calculated using the cosine similarity calculation method. In this case, the calculation formula can be:
[0052]
[0053] Among them, S i represents the i-th element of the first sentence vector in the problem to be solved, T i represents the i-th element of the second sentence vector of the first similar exercise, n is the total number of elements of the first sentence vector and the second sentence vector, S and T represent the first sentence vector and the second sentence vector respectively.
[0054] Currently, there is a similarity between the problem to be solved and each second sentence vector.
[0055] It should be noted that in actual applications, other methods can be used to calculate similarity, and there is no current limitation on this.
[0056] Step 125: Obtain at least one second sentence vector with the highest similarity, and use the exercise corresponding to the obtained second sentence vector as the first similar exercise found.
[0057] Exemplarily, based on the similarities corresponding to the second sentence vectors, at least one second sentence vector with the highest similarity is found, where the number of second sentence vectors with the highest similarity can be set based on actual conditions. Based on the association between the second sentence vector and the exercise, the exercise corresponding to the second sentence vector is found in the exercise database and used as the first similar exercise.
[0058] For example, after finding a first similar problem, a first expression corresponding to the first similar problem can be retrieved from the problem database. The first expression is the computational expression for the first similar problem. Optionally, each problem in the problem database is associated with its corresponding computational expression. When there are multiple problems to be solved, each problem corresponds to at least one first similar problem, and each first similar problem has a corresponding first expression.
[0059] It is understandable that in actual applications, other methods can also be used to find the first similar exercises. For example, the tfidf+jaccard similarity method is used to find the first similar exercises. Among them, tfidf is a commonly used weighted technology for information retrieval and data mining. The main idea of tfidf is: if a word or phrase (here equivalent to the second vocabulary) appears with a high frequency TF in an article (here equivalent to the exercises in the exercise bank) and rarely appears in other articles (here equivalent to other exercises in the exercise bank), then it is considered that this word or phrase has good category discrimination ability and is suitable for classification. Jaccard is also called the Jaccard similarity coefficient, which is used to compare the similarities and differences between finite sample sets. The larger the Jaccard coefficient value, the higher the similarity of the samples (i.e., the exercises to be solved and the exercises in the exercise bank).
[0060] Step 130: Input the problem to be solved, the first similar problem, and the corresponding first expression into the problem analysis model, and use the problem analysis model to analyze and obtain the expression to be solved of the problem to be solved.
[0061] Exemplarily, the problem analysis model is a pre-built neural network model, and the specific structure of the problem analysis model can be set according to actual conditions. The problem analysis model is used to obtain a computational expression for the problem to be solved. In one embodiment, the computational expression is recorded as the expression to be solved. It can be understood that the process of the problem analysis model obtaining the expression to be solved can be considered as the application process of the problem analysis model. Before application, the problem analysis model undergoes a training process and is deployed in the problem analysis device for application after the training is completed. The training process refers to the process of making the problem analysis model output stable and accurate results.
[0062] Exemplarily, the problem to be solved, all first similar problems similar to the problem to be solved, and the first expression of the first similar problem are input into the problem analysis model. Afterwards, the problem analysis model can perform semantic analysis on the problem to be solved to obtain the semantic features of the problem to be solved, and also perform semantic analysis on the first similar problem and the corresponding first expression to obtain the semantic features of the first similar problem and the first expression. The aforementioned semantic parsing process can be considered as a feature extraction process. Afterwards, the problem analysis module identifies the semantic features to obtain an expression to be solved that is suitable for the problem to be solved. Optionally, the problem analysis model also performs analogical learning on the problem to be solved, the first similar problem, and the corresponding first expression. The analogical learning can be considered as comparing the problem to be solved with the first similar problem and the first expression to find their similarity relationship, and based on this relationship, appropriately organize the relevant knowledge of the first similar problem and the first expression to correspond to the problem to be solved, thereby obtaining the relevant knowledge of the problem to be solved. In one embodiment, the problem analysis model extracts relevant features obtained during analogical learning. The semantic features obtained during feature extraction and the features obtained during analogical learning are then identified to output a final expression to be solved, which includes calculated values and operation symbols.
[0063] Exemplarily, the self-attention mechanism is used in both the feature extraction process and the analogy learning process of the problem analysis model. The attention mechanism refers to a mechanism that focuses attention on the main information. The self-attention mechanism can be considered to reduce dependence on external information and is better at capturing the correlation within data or features. In one embodiment, a mask matrix is used during the implementation of the self-attention mechanism. The mask matrix allows the problem analysis model to determine which content to focus on only when processing the content itself and which content to focus on other content (other content is related to the content being processed) during the processing process to avoid data leakage. For example, when the problem analysis model performs semantic analysis on the first similar problem and the first expression, the model sees the first expression when analyzing the first similar problem. However, when humans solve the problem and read the problem title, there is no corresponding calculation expression in the problem title. Therefore, it is necessary to use a mask matrix to mask the self-attention mechanism so that when processing the first similar problem, the problem analysis model only focuses on the content of the first similar problem itself, without referring to the content of the first expression, to avoid leaking the first expression, which in turn affects the accuracy of the semantic analysis. The content of the mask matrix can be set according to actual conditions and is not currently limited.
[0064] In one embodiment, the problem analysis model is composed of a feature representation model, an analogy learning model, and a reasoning model. Accordingly, step 130 includes steps 131 to 135:
[0065] Step 131: Concatenate the first similar exercises and the corresponding first expressions to obtain first concatenation information, where each first similar exercise corresponds to one piece of first concatenation information.
[0066] In one embodiment, after obtaining a first similar exercise and a first expression from an exercise library, the first expression is converted into a prefix expression. A prefix expression is one in which the operator is written in front and the operand is written in the back. The prefix expression can eliminate brackets in the first expression, reduce the length of the first expression, reduce the amount of data processed by the exercise analysis model, and reduce the difficulty of reasoning in the exercise analysis model. For example, the first expression is: 1-(2+3), and its prefix expression is: -1+23, in which brackets are eliminated.
[0067] In one embodiment, the first similar exercises and the first expression (here, the prefix expression) are concatenated, and the concatenated content is recorded as first concatenated information. In this case, each first similar exercise corresponds to one piece of first concatenated information.
[0068] Step 132: Utilize the feature representation model to extract the first semantic information of the problem to be solved and the second semantic information of the first concatenated information.
[0069] Exemplarily, the feature representation model is a sub-model in the exercise analysis model, which is used to perform semantic learning on the input content to extract the corresponding semantic features. The structure of the feature representation model can be set according to the actual situation. For example, the feature representation model is composed of multiple transformer modules. Transformer is a classic model of Neuro-Linguistic Programming (NLP) that adopts a self-attention mechanism. In one embodiment, the feature representation model includes six transformer modules. Optionally, the self-attention mechanism used by the transformer module may cause data leakage. For example, after the first splicing information is input into the exercise analysis model, the exercise analysis model will pay attention to the first expression when processing the first similar exercise. Therefore, a mask mechanism is applied in the feature representation model to set a mask matrix in the feature representation model. The mask matrix can make the feature representation model clearly know which part of the content to pay attention to during the processing. In one embodiment, the basis for setting the mask matrix is: when processing exercises, only focus on the exercises themselves; when processing expressions, focus on the exercises and the expressions processed before the current moment. It can be understood that when humans solve exercises and write expressions, when writing a number or symbol in the expression at the current moment, they can only read the content written before the current moment, and cannot read the content written after the current moment. Therefore, when processing expressions, the mask matrix only focuses on the expressions processed before the current moment.
[0070] In one embodiment, after the problem to be solved is input into the feature representation model, the feature representation model identifies the problem to be solved, that is, it performs feature learning on the problem to be solved to clarify the semantics of the problem to be solved, and then outputs semantic information. In one embodiment, the semantic information corresponding to the problem to be solved is recorded as the first semantic information. It can be understood that when the problem to be solved is input, the feature representation model can only process the problem to be solved, that is, the feature representation model will only pay attention to the problem to be solved. Therefore, when the feature representation model uses a mask matrix, it only pays attention to the problem itself (currently the problem to be solved). Similarly, after the first splicing information is input into the feature representation model, the feature representation model identifies the first splicing information, that is, it performs feature learning on the first similar problem and the first expression to clarify the semantics of the first similar problem and the first expression, and then outputs semantic information. In one embodiment, the semantic information corresponding to the first splicing information is recorded as the second semantic information. It can be understood that when the first concatenation information is input, the feature representation model uses a mask matrix to focus only on the first similar problem when processing it, and to focus on the problem and the first expression processed before the current moment when processing the first expression. It should be noted that after each first concatenation information is input into the feature representation model, the second semantic information of each first concatenation information can be obtained.
[0071] It can be understood that the same feature representation model is currently used to process the problem to be solved and the first splicing information. In actual applications, two feature representation models can be set, one for extracting the first semantic information and the other for extracting the second semantic information.
[0072] Step 133: Concatenate the first similar exercises, the corresponding first expressions, and the exercises to be solved to obtain second concatenated information, where each piece of first similar information corresponds to one piece of second concatenated information.
[0073] In one embodiment, the first similar exercise, the first expression (here, the prefix expression) and the exercise to be solved are spliced in sequence, and the content obtained after splicing is recorded as the second splicing information. At this time, the exercise to be solved is spliced once with each first similar exercise respectively. At this time, one first similar exercise corresponds to one second splicing information.
[0074] Step 134: Obtain third semantic information of the second concatenated information using an analogy learning model.
[0075] Exemplarily, the analogy learning model is a sub-model within the problem analysis model, which is used to compare the content in the second splicing information, find their similarity, and based on this relationship, appropriately organize the relevant knowledge of the first similar problem and the first expression to correspond to the problem to be solved, thereby obtaining relevant knowledge of the problem to be solved. In one embodiment, the structure of the analogy learning model can be set according to actual conditions. For example, the analogy learning model is composed of multiple transformer modules. In one embodiment, the analogy learning model includes six transformer modules. It is understandable that when the analogy learning model uses a transformer module and uses a self-attention mechanism, data leakage problems may also occur. For example, after the second splicing information is input into the problem analysis model, when the analogy learning model processes the first similar problem, it will pay attention to the first expression and the problem to be solved, causing data leakage problems. Therefore, a masking mechanism is applied to the analogy learning model. Through the corresponding mask matrix, the analogy learning model can clearly determine which part of the content to focus on during the processing process. In one embodiment, the mask matrix is configured such that when processing the first similar problem in the second concatenated information, only the first similar problem itself is considered; when processing the first expression, the first similar problem and the first expression processed before the current moment are considered; and when processing the problem to be solved, the problem to be solved, the first similar problem, and the first expression processed before the current moment are considered. Subsequently, features learned by analogy are output, and the features output by the analogy learning model are recorded as third semantic information. It is understood that each piece of second concatenated information input into the analogy learning model can generate corresponding third semantic information.
[0076] Step 135 : The reasoning model infers the expression to be solved of the problem to be solved based on the first semantic information, the second semantic information, and the third semantic information.
[0077] Exemplarily, the reasoning model is a sub-model in the exercise analysis model, which is used to infer the expression to be solved of the exercise to be solved based on the first semantic information, the second semantic information and the third semantic information. The specific structure of the reasoning model can be set according to the actual situation and is not currently limited. During the processing, the reasoning model gradually obtains the expression to be solved. Optionally, the expression to be solved output by the reasoning model can be a prefix expression. In this case, the prefix expression needs to be converted into an ordinary expression. Optionally, the expression to be solved output by the reasoning model is an ordinary expression.
[0078] It can be understood that the exercise analysis model can be considered as a memory-enhanced neural network, which can combine similar exercises in the exercise library to reason and obtain the expression to be solved.
[0079] It should be noted that the above-mentioned question bank can be updated according to actual conditions and there is currently no restriction on this.
[0080] Step 140: Obtain answers to the exercises to be solved according to the expressions to be solved.
[0081] Exemplarily, calculations are performed based on the numbers and operators contained in the expression to be solved to obtain the final answer to the exercise. Optionally, after obtaining the answer to the exercise, the answer to the exercise and the expression to be solved are displayed to facilitate the user to clearly understand the solution ideas and the answer to the exercise to be solved.
[0082] The following is an example of the problem analysis method. In this example, the problem to be solved is "Li Dong spent 5 yuan to buy stationery. He spent 1.5 yuan on pencils and had the remaining money to buy exercise books, each costing 0.35 yuan. How many exercise books can he buy?" First, similar problems are searched for the problem to be solved. Assume that the top 1 similar problem is retrieved (i.e., the number of similar problems is 1). The first similar problem currently detected is: "Xiao Lan spent 10 yuan to buy stationery. She bought two identical ballpoint pens, each costing 2.2 yuan. The remaining money is just enough to buy four exercise books. How much does each exercise book cost?" The corresponding first expression "x = (10 - 2.2 * 2) / 4" is obtained. Next, the first expression is converted into a prefix expression, that is, "x = (10 - 2.2 * 2) / 4" is converted to " / -10 * 2.2 2 4". Afterwards, the first similar problem and the prefix expression are fed into the feature representation module for feature learning to obtain the second semantic information. Similarly, the problem to be solved is fed into the feature representation module to obtain the first semantic information. The first similar problem, the corresponding prefix expression, and the problem to be solved are then concatenated and used as input to the analogy learning module. Analogy learning is performed using the self-attention mechanism to obtain the third semantic information. Finally, the reasoning module performs reasoning to obtain the expression to be solved for the problem to be solved. This expression to be solved is a prefix expression, specifically " / -5 1.5 0.35". The final answer can be obtained by calculating the prefix expression.
[0083] The above-mentioned technical approach, which involves obtaining a problem to be solved, searching a problem database for a first similar problem and a corresponding first expression that is similar to the problem to be solved, and then inputting the problem to be solved, the first similar problem, and the first expression into a problem analysis model, yields the expression to be solved, and then, based on the expression to be solved, obtains the answer to the problem. This resolves the technical issue of incorrect or inability to calculate the answer to a word problem when using a matching expression template. When solving the problem to be solved, the problem analysis model references the retrieved multiple first similar problems and first expressions, improving its problem-solving capabilities and making it less likely to provide incorrect answers or be unable to calculate. Moreover, the analogy learning model in the exercise analysis model can perform analogy learning on the first similar exercise and the exercise to be solved, can simulate the logic of humans in solving word problems, and draw inferences based on the learned knowledge. Moreover, applying different mask matrices in the feature representation model and the analogy learning model can avoid the problem of data leakage in the self-attention mechanism, so that the model can selectively learn different information at different stages, which not only makes the feature recognition model and the analogy learning model have stronger discrimination and learning capabilities, but also has a certain degree of explanatory power for the processing process of the feature recognition model and the analogy learning model.
[0084] In one embodiment of the present application, Figure 2A flow chart of a training method for an exercise analysis model provided in one embodiment of the present application. Figure 2 The steps shown are the process of training the above-mentioned exercise analysis model. It is understood that the training device for the exercise analysis model can be the exercise analysis device or other devices. When using other devices to train the exercise analysis model, it is necessary to deploy the exercise analysis model in the exercise analysis device. Figure 2 , the exercise analysis model is trained through the following steps:
[0085] Step 210: Obtain the solved exercises and the corresponding known expressions.
[0086] Exemplarily, a solved problem refers to a problem whose calculation expression has been determined. In one embodiment, the solved problem is of the same type as the problem to be solved, both being mathematical word problems. The solved problem can be one or more, and this is not currently limited.
[0087] In one embodiment, when obtaining a solved problem, the computational expression for the solved problem is also obtained. Currently, the computational expression for the solved problem is recorded as a known expression. A known expression is an accurate expression. The method for obtaining the solved problem and the known expression is not currently limited.
[0088] Step 220: Search the problem database for at least one second similar problem to the solved problem, and obtain a second expression for the second similar problem.
[0089] For example, during training, similar exercises found in the exercise database based on the solved exercises are recorded as second similar exercises, and the calculation expression for the second similar exercises is recorded as the second expression. It is understood that the method for searching for second similar exercises and second expressions is the same as that for searching for first similar exercises and first expressions, and will not be further described here.
[0090] Optionally, after searching the exercise database for at least one second similar exercise to the solved exercise and obtaining a second expression of the second similar exercise, the method further includes: converting the known expression and the second expression into prefix expressions respectively.
[0091] For example, to reduce the amount of data processing required by the subsequent exercise analysis model, the known expression is converted into a prefix expression, and each second expression is also converted into a prefix expression. This conversion process is the same as the conversion of the first expression into a prefix expression and will not be described in detail here. It should be noted that in actual applications, the known expression can also be converted into a prefix expression when it is obtained.
[0092] Step 230: Concatenate the solved problem and the known expression to obtain third concatenated information, and concatenate the second similar problem and the corresponding second expression to obtain fourth concatenated information. Each second similar problem corresponds to one piece of fourth concatenated information.
[0093] For example, the solved problem and the known expression (here, the prefix expression) are concatenated, and the resulting concatenation is recorded as the third concatenation information. The second similar problem and the second expression (here, the prefix expression) are concatenated, and the resulting concatenation is recorded as the fourth concatenation information. In this case, each second similar problem corresponds to a piece of fourth concatenation information.
[0094] Step 240: Use the feature representation model to extract the fourth semantic information of the third splicing information and the fifth semantic information of the fourth splicing information.
[0095] In one embodiment, the feature representation model processes the third and fourth splicing information in the same manner as it processes the first splicing information. It is understood that during training, the feature representation model processes the third splicing information, including known expressions, to facilitate learning. During application, the feature representation model only processes the problem to be solved, without known expressions. Currently, the feature representation model is composed of multiple transformer modules, which process the self-attention matrix based on a preset mask matrix.
[0096] Among them, the number of rows and columns of the mask matrix corresponding to the third splicing information are both equal to the length of the third splicing information; the rows and columns in the mask matrix correspond to the elements of the known expression to form a special lower triangular matrix, the elements above the main diagonal of the special lower triangular matrix are all numbers approaching negative infinity, the main diagonal and the elements below the special lower triangular matrix are all zero, the rows and columns in the mask matrix correspond to the elements of the solved exercises and are all zero, the rows in the mask matrix correspond to the solved exercises and the columns correspond to the elements of the known expressions and are all numbers approaching negative infinity, and the rows in the mask matrix correspond to the known expressions and the columns correspond to the solved exercises and are all zero.
[0097] For example, Figure 3 A schematic diagram of a mask matrix provided in one embodiment of the present application. Figure 3, the mask matrix is a mask matrix used by the feature representation model when processing the third splicing information. The elements in the mask matrix contain two values, one value is zero, and the other value is a number that tends to negative infinity. The number of rows and columns of the mask matrix is equal to the length of the third splicing information, that is, the row and column corresponding to a certain element in the mask matrix can both find corresponding content in the third splicing information. In one embodiment, in the mask matrix, the values of the elements corresponding to the solved problems in both rows and columns are zero, which indicates that when the feature representation model processes the solved problems, it focuses on the solved problems themselves. In the mask matrix, the elements whose rows correspond to the solved problems and whose columns correspond to the known expressions are numbers that tend to negative infinity, which indicates that when the feature representation model processes the solved problems, it does not focus on the known expressions. In the mask matrix, the values of the elements whose rows correspond to the known expressions and whose columns correspond to the solved problems are zero, which indicates that when the feature representation model processes the known expressions, it focuses on the solved problems. In the mask matrix, the rows and columns correspond to elements of known expressions, forming a special lower triangular matrix. The elements above the main diagonal of this special lower triangular matrix are all numbers approaching negative infinity, and the elements below the main diagonal are all zero. This indicates that when the feature representation model processes a known expression, it focuses on the known expression before the current moment. This focus on the known expression before the current moment can be understood as focusing on the expression information of the known expression before the current moment. For example, if the known expression is 1+2+3+4, and the expression information that the exercise analysis model should infer at the current moment is 2, then the expression information before the current moment is 1+. It can be understood that when the feature representation model processes a certain content, it uses the mask matrix to determine the row corresponding to the content in the mask matrix. Then, based on the values of each element in that row and the corresponding column in the mask matrix, the self-attention mechanism for processing the content is determined. It should be noted that each transformer module is configured to use a mask matrix for processing to prevent data leakage.
[0098] In one embodiment, when the transformer module uses the self-attention mechanism to process a preset mask matrix, the processing is implemented by the following formula:
[0099]
[0100] Q=K=V∈R n×d
[0101] Among them, Attention(Q, K, V) is the self-attention matrix, which indicates which part of the information the transformer module pays more attention to. Q, K, and V all represent the encoding corresponding to a single input variable (such as each character in the third splicing information); M represents the mask matrix, M∈R n×n , n represents the input length (such as the length of the third concatenation information), d represents the vector dimension of each character, d kCharacter vector dimension representing K. Superimpose the corresponding M onto QK T After passing through the softmax function, it is equivalent to converting the number approaching negative infinity into zero, so as not to pay attention to the content corresponding to this part, and converting zero into other values (non-zero positive numbers) to pay attention to the content corresponding to this part. T The calculated self-attention matrix can determine which part of the information to focus on.
[0102] In one embodiment, the semantic information obtained after the feature representation model recognizes the third splicing information is recorded as fourth semantic information, and the semantic information obtained after the feature representation model recognizes the fourth splicing information is recorded as fifth semantic information. It is understood that the fourth splicing information is processed in the same manner as the third splicing information and will not be further described herein.
[0103] Step 250: Concatenate the second similar problems, the corresponding second expressions, the solved problems, and the known expressions to obtain fifth concatenated information. Each second similar problem corresponds to one piece of fifth concatenated information.
[0104] In one embodiment, the second similar problem, the second expression (here, a prefix expression), the solved problem, and the known expression are spliced in sequence, and the content obtained after splicing is recorded as the fifth splicing information. At this time, the solved problem is spliced once with each second similar problem. At this time, one second similar problem corresponds to one fifth splicing information.
[0105] Step 260: Obtain sixth semantic information of the fifth concatenated information using an analogy learning model.
[0106] The analogy learning model processes the fifth concatenation information in the same manner as it processes the second concatenation information. It is understood that during training, the analogy learning model processes the fifth concatenation information to include known expressions, facilitating learning. During application, the analogy learning model only processes the problem to be solved, without known expressions. Currently, the analogy learning model consists of multiple transformer modules, which process the self-attention matrix based on a preset mask matrix.
[0107] Among them, the number of rows and columns of the mask matrix corresponding to the fifth splicing information are both equal to the length of the fifth splicing information, the elements of the mask matrix whose rows correspond to the second similar problems, the second expression, the solved problems or the known expressions and whose columns correspond to the second similar problems are all zero, the elements of the mask matrix whose rows correspond to the solved problems or the known expressions and whose columns correspond to the second expressions or the solved problems are all zero, the elements of the mask matrix whose rows correspond to the second similar problems and whose columns correspond to the second expressions, the solved problems or the known expressions are all numbers approaching negative infinity, and the mask The matrix whose rows correspond to the second expression or the solved problem and whose columns correspond to the known expression are all numbers approaching negative infinity. The mask matrix whose rows and columns correspond to the elements of the second expression and whose rows and columns correspond to the elements of the known expression form a special lower triangular matrix. The elements above the main diagonal of the special lower triangular matrix are all numbers approaching negative infinity. The elements on and below the main diagonal of the special lower triangular matrix are all zero. The mask matrix whose rows correspond to the second expression and whose columns correspond to the solved problem are all numbers approaching negative infinity.
[0108] For example, Figure 4 Another mask matrix diagram provided for an embodiment of the present application. Figure 4The mask matrix is used by the analogy learning model when processing the fourth splicing information. The elements in the mask matrix contain two values: one value is zero, and the other value is a number that tends to negative infinity. The number of rows and columns of the mask matrix is equal to the length of the fifth splicing information, that is, the row and column corresponding to a certain element in the mask matrix can both find corresponding content in the fifth splicing information. In one embodiment, in the mask matrix, the values of the elements whose rows and columns correspond to the second similar problem are zero, which indicates that when the analogy learning model processes the second similar problem, it focuses on the second similar problem itself. In the mask matrix, the elements whose rows correspond to the second similar problem and whose columns correspond to the second expression, solved problem, and known expression are values that tend to negative infinity, which indicates that when the analogy learning model processes the second similar problem, it does not focus on the second expression, solved problem, or known expression. In the mask matrix, the values of the elements whose rows correspond to the second expression and whose columns correspond to the second similar problems are zero, which indicates that when the analogy learning model processes the second expression, it pays attention to the second similar problems. In the mask matrix, the elements whose rows and columns correspond to the second expression form a special lower triangular matrix. The elements above the main diagonal of the special lower triangular matrix are all numbers approaching negative infinity, and the elements below the main diagonal of the special lower triangular matrix are all zero, which indicates that when the analogy learning model processes the second expression, it pays attention to the second expression before the current moment. In the mask matrix, the values of the elements whose rows correspond to the second similar problems and whose columns correspond to the solved problems and known expressions are values approaching negative infinity. The above indicates that when the analogy learning model processes the second expression, it does not pay attention to the solved problems and known expressions. In the mask matrix, the values of the elements corresponding to the solved problem in the rows and the second similar problem, the second expression, and the solved problem in the columns are zero, indicating that the analogy learning model focuses on the second similar problem, the second expression, and the solved problem when processing the solved problem. In the mask matrix, the values of the elements corresponding to the solved problem in the rows and the known expression in the columns are numbers approaching negative infinity, indicating that the analogy learning model does not focus on the known expression when processing the solved problem. In the mask matrix, the values of the elements corresponding to the known expression in the rows and the second similar problem, the second expression, and the solved problem in the columns are zero, indicating that the analogy learning model focuses on the second similar problem, the second expression, and the solved problem when processing the known expression. In the mask matrix, the values of the elements corresponding to the known expression in the rows and the known expression in the columns form a special lower triangular matrix, indicating that the analogy learning model focuses on the known expression before the current time when processing the known expression. As you can understand, when the analogy learning model processes a piece of content, it uses the mask matrix to identify the row that corresponds to that content. Then, based on the values of each element in that row and the corresponding column in the mask matrix, it determines the self-attention mechanism for processing that content. It should be noted that each transformer module is configured to use a mask matrix for processing to prevent data leakage.
[0109] In one embodiment, the semantic information obtained after the analogy learning model recognizes the fifth splicing information is recorded as the sixth semantic information.
[0110] It can be understood that in addition to using the transformer module, the feature representation model and the analogy learning model can also adopt other structures, such as recurrent neural networks, etc. In addition, in addition to the self-attention mechanism, other attention mechanisms can also be used.
[0111] Step 270: The inference model infers a known expression based on the fourth semantic information, the fifth semantic information, and the sixth semantic information.
[0112] The processing method during the inference model training process is the same as the processing method during the aforementioned application process. It can be understood that during the training process, the inference model refers to known expressions when processing the fourth semantic information and the sixth semantic information to facilitate the learning of the inference model. During the application process, the inference model only processes content without known expressions. In one embodiment, the calculation expression currently predicted and output by the inference model can be understood as the inferred known expression, and the optimal result of the exercise analysis model is that the inferred known expression is completely consistent with the original known expression.
[0113] Step 280: Construct a first loss function based on the inferred known expression.
[0114] Exemplarily, comparing the inferred known expression with the original known expression can clarify whether the problem analysis model accurately analyzes the solved problem. It can be understood that the higher the accuracy of the problem analysis model, the more similar the inferred known expression is to the original known expression. In one embodiment, a loss function of the problem analysis model is constructed based on the inferred known expression. The loss function is usually associated with the optimization problem (currently the inferred known expression is as close as possible to the original known expression) as a learning criterion, that is, the model (currently the problem analysis model) is solved and evaluated by minimizing the loss function. Currently, the loss function is recorded as the first loss function. The function type of the first loss function can be set according to the actual situation. In one embodiment, the first loss function is expressed as:
[0115] L1=-log(p θ (y|x))
[0116]
[0117] Where L1 represents the first loss function, x represents the solved problem, y represents the known expression of the solved problem, θ represents the model parameters of the problem analysis model, z represents the second similar problem and the corresponding second expression, y i Represents the expression information of the known expression inferred by the exercise analysis model at the i-th moment, y 1:i-1Indicates the expression information of the known expression before time i, 1≤i≤N, N is the total length of the known expression, p θ (y|x) represents the probability of the problem analysis model generating a known expression, and z∈top-K(p(z|x)) represents each second similar problem found. For example, the known expression is 1+2+3+4, and the expression information of the known expression inferred by the problem analysis model at the current moment (i.e., y i ) is 3, the expression information before the current moment (i.e. y 1:i-1 ) is 1+2+, that is, the problem analysis model is based on y 1:i-1 , x, z infer y i , then, after reasoning out all known expressions, we can get p θ (y|x). As can be seen from the above, by applying the model parameters of the problem analysis model to the solved problem, the known expression, the second similar problem, and the second expression, the known expression can be inferred. This leads to the probability that the problem analysis model inferred the original known expression, and the first loss function is constructed based on this probability.
[0118] Step 290: Update the model parameters of the exercise analysis model according to the first loss function until the first loss function converges.
[0119] Exemplarily, the model parameters of the exercise analysis model are updated according to the first loss function to improve the accuracy of the exercise analysis model. After that, new solved exercises and known expressions are obtained, and the above training process is repeated again to obtain the first loss function again, and the model parameters of the exercise analysis model are updated until the first loss function converges. In one embodiment, the convergence of the first loss function means that the first loss function obtained for multiple consecutive times is within a set numerical range, and within this range, the accuracy of the exercise analysis model meets the expected accuracy. Optionally, when training the exercise analysis model, a verification process is also included. The verification process can be understood as taking the solved exercises as the exercises to be solved, and obtaining the corresponding known expressions through the exercise analysis model. After that, the known expressions are compared with the original known expressions to verify the accuracy of the exercise analysis model.
[0120] In one embodiment of the present application, in order to enable the second expression to have expression learning capabilities, a loss function is also designed for the generation of the second expression. At this time, during the training process, the problem analysis model can also infer the calculation expression corresponding to the second similar problem based on the relevant semantic information of the second similar problem, that is, infer the second expression. The higher the accuracy of the problem analysis model, the more similar the inferred second expression is to the original second expression. At this time, when the inference model infers the second known expression of the solved problem based on the fourth semantic information, the fifth semantic information, and the sixth semantic information, it also includes: inferring the second expression by the inference model; and constructing a second loss function based on the inferred second expression.
[0121] In one embodiment, another loss function of the problem analysis model is constructed based on the inferred second expression. Currently, this loss function is recorded as the second loss function. The function type of the second loss function can be set according to actual conditions. In one embodiment, the second loss function is expressed as:
[0122] The second loss function is expressed as:
[0123]
[0124] Among them, L2 represents the second loss function, z q represents the second similar exercise, Represents the expression information of the second expression inferred by the exercise analysis model at time i, represents the expression information of the second expression before time i, θ represents the model parameters of the problem analysis model, 1≤i≤N, and N is the total length of the second expression corresponding to the second similar problem. As can be seen from the above formula, after the expression information of the second similar problem and the second expression before the current time is passed through the model parameters of the problem analysis model, the expression information of the second expression inferred at the current time can be obtained. Furthermore, the probability of the problem analysis model generating the second expression corresponding to the current time is obtained, and the second loss function is constructed based on this probability.
[0125] After constructing the second loss function, the first loss function and the second loss function can be used together as the loss function of the exercise analysis model to train the exercise analysis model. At this time, updating the model parameters of the exercise analysis model according to the first loss function until the first loss function converges includes: updating the model parameters of the exercise analysis model according to the first loss function and the second loss function until the first loss function and the second loss function converge.
[0126] In one embodiment, the problem analysis model can be jointly learned using a first loss function and a second loss function. In this case, the loss function ultimately used by the problem analysis model can be expressed as:
[0127] L=λL1+(1-λ)L2
[0128] Wherein, L1 represents the first loss function, L2 represents the second loss function, and λ is a hyperparameter whose specific value can be set according to actual conditions. In one embodiment, λ is 0.5 so that the exercise analysis model has the same learning ability for the two tasks (including reasoning about the known expression and the second expression).
[0129] It is understandable that the process of training the problem analysis model according to the first loss function and the second loss function is the same as the training process of step 290, and is not currently limited. When the problem analysis model obtained by training is used to solve the problem to be solved, it is not easy to make mistakes in answering or being unable to calculate. In addition, the analogy learning model in the problem analysis model can simulate the logic of humans solving word problems, and draw inferences based on the learned knowledge. The use of different mask matrices in the feature representation model and the analogy learning model can avoid the problem of data leakage in the self-attention mechanism, so that the model can selectively learn different information at different stages, which not only makes the feature recognition model and the analogy learning model have stronger discrimination and learning capabilities, but also has a certain degree of explanatory power for the processing of the feature recognition model and the analogy learning model.
[0130] In one embodiment of the present application, the problem analysis model is applied to the public data set math23k and compared with other advanced algorithms. math23k is a large-scale data set containing 23,162 questions. A higher accuracy rate is achieved on this data set, indicating that the model has better automatic problem-solving capabilities. Each model is evaluated using a five-fold cross-validation (denoted as "Math23k*") or a public test set (denoted as "Math23k"). Table 1 compares the effects of this method with existing methods:
[0131] Model Math23k Math23k* GROUP-ATT 69.5 66.9 GTS 75.6 74.3 TSN-MD 77.4 75.1 Graph2Tree 77.4 75.5 Exercise Analysis Model 79.7 78.2
[0132] Table 1
[0133] In Table 1, GROUP-ATT, GTS, TSN-MD, and Graph2Tree are all existing automatic learning models. As shown in Table 1, the accuracy of the exercise analysis model is at least 2% higher than that of the existing models.
[0134] Figure 5 This is a schematic diagram of a structure of an exercise analysis device provided in one embodiment of the present application, refer to Figure 5 The exercise analysis device includes an acquisition module 301, a search module 302, an analysis module 303, and a solution module 304.
[0135] Among them, the acquisition module 301 is used to obtain the exercise to be solved; the search module 302 is used to search for at least one first similar exercise of the exercise to be solved in the exercise library, and obtain the first expression of the first similar exercise; the analysis module 303 is used to input the exercise to be solved, the first similar exercise and the corresponding first expression into the exercise analysis model, and the exercise analysis model analyzes to obtain the expression to be solved of the exercise to be solved; the solution module 304 is used to obtain the answer to the exercise to be solved based on the expression to be solved.
[0136] In one embodiment of the present application, the exercise analysis model is composed of a feature representation model, an analogy learning model and a reasoning model, and the analysis module 303 includes: a first splicing unit, used to splice the first similar exercise and the corresponding first expression to obtain first splicing information, and each first similar exercise corresponds to a first splicing information; a first extraction unit, used to use the feature representation model to extract the first semantic information of the exercise to be solved and the second semantic information of the first splicing information respectively; a second splicing unit, used to splice the first similar exercise, the corresponding first expression and the exercise to be solved to obtain second splicing information, and each first similar exercise corresponds to a second splicing information; a first analogy unit, used to use the analogy learning model to obtain third semantic information of the second splicing information; a first reasoning unit, used to use the reasoning model to infer the expression to be solved of the exercise to be solved based on the first semantic information, the second semantic information and the third semantic information.
[0137] In one embodiment of the present application, the search module 302 includes: a first word segmentation unit, used to segment the exercises to be solved and obtain all the first words that appear in the exercises to be solved; a word vector search unit, used to search the word vectors corresponding to the first words in the corpus; a first sentence vector determination unit, used to obtain the first sentence vector of the exercises to be solved based on the word vectors corresponding to each first word; a similarity calculation unit, used to calculate the similarity between the first sentence vector and the second sentence vector of each exercise in the exercise library, the second sentence vector being determined based on the word vector in the corpus; an exercise search unit, used to obtain multiple second sentence vectors with the highest similarity, and use the exercises corresponding to the obtained second sentence vectors as the first similar exercises found, and obtain the first expression of the first similar exercises.
[0138] In one embodiment of the present application, it also includes: a second word segmentation module, which is used to segment each exercise in the exercise bank to obtain all second words appearing in the exercise bank; a word vector determination module, which is used to use a vectorization model to obtain the word vector corresponding to each second word, and each word vector constitutes a corpus; a second sentence vector determination module, which is used to average the word vectors of each second word in the exercise to obtain the second sentence vector of the exercise.
[0139] In one embodiment of the present application, the first sentence vector is represented as:
[0140] in, represents the first sentence vector of the problem to be solved, K represents the total number of first words contained in the problem to be solved, D represents the corpus, V nk Represents the word vector corresponding to the kth first word in the problem to be solved, V nk ∈D indicates that there is a word vector corresponding to the kth first word in the corpus, Z nj represents the zero vector corresponding to the jth first word in the problem to be solved, Indicates that the word vector corresponding to the j-th first word does not exist in the corpus.
[0141] In one embodiment of the present application, the present invention further includes: a known acquisition module for acquiring solved problems and corresponding known expressions; a known search module for searching for at least one second similar problem of the solved problem in the problem library and acquiring a second expression of the second similar problem; a third splicing module for splicing the solved problem and the known expression to obtain third splicing information, and splicing the second similar problem and the corresponding second expression to obtain fourth splicing information, wherein each second similar problem corresponds to one fourth splicing information; a second extraction module for extracting fourth semantic information of the third splicing information and fifth semantic information of the fourth splicing information respectively by using a feature representation model. ; A fifth splicing module is used to splice the second similar exercise, the corresponding second expression, the solved exercise and the known expression to obtain the fifth splicing information, and each second similar exercise corresponds to a fifth splicing information; a second analogy module is used to use the analogy learning model to obtain the sixth semantic information of the fifth splicing information; a second reasoning module is used to infer the known expression based on the fourth semantic information, the fifth semantic information and the sixth semantic information by the reasoning model; a function construction module is used to construct a first loss function based on the inferred known expression; a training module is used to update the model parameters of the exercise analysis model according to the first loss function until the first loss function converges.
[0142] In one embodiment of the present application, the function construction module is further configured to: infer a second expression from the inference model; and construct a second loss function based on the inferred second expression. Accordingly, the training module is specifically configured to: update model parameters of the exercise analysis model based on the first loss function and the second loss function until the first loss function and the second loss function converge.
[0143] In one embodiment of the present application, the feature representation model and the analogy learning model are both composed of multiple transformer modules, and the transformer module processes the self-attention matrix based on a preset mask matrix.
[0144] In one embodiment of the present application, the number of rows and columns of the mask matrix corresponding to the third splicing information are both equal to the length of the third splicing information; the rows and columns in the mask matrix correspond to the elements of the known expression to form a special lower triangular matrix, the elements above the main diagonal of the special lower triangular matrix are all numbers approaching negative infinity, the main diagonal and the elements below the special lower triangular matrix are all zero, the rows and columns in the mask matrix correspond to the elements of the solved problems and are all zero, the rows in the mask matrix correspond to the solved problems and the columns correspond to the elements of the known expressions and are all numbers approaching negative infinity, and the rows in the mask matrix correspond to the known expressions and the columns correspond to the solved problems and are all zero.
[0145] In one embodiment of the present application, the number of rows and columns of the mask matrix corresponding to the fifth splicing information are both equal to the length of the fifth splicing information; the elements of the mask matrix corresponding to the second similar problem, the second expression, the solved problem or the known expression and the columns corresponding to the second similar problem are all zero, the elements of the mask matrix corresponding to the solved problem or the known expression and the columns corresponding to the second expression or the solved problem are all zero, and the elements of the mask matrix corresponding to the second similar problem and the columns corresponding to the second expression, the solved problem or the known expression are all approaching negative infinity. Numbers, the elements of the mask matrix whose rows correspond to the second expression or the solved exercises and whose columns correspond to the known expressions are all numbers approaching negative infinity, the mask matrix whose rows and columns correspond to the elements of the second expression and whose rows and columns correspond to the elements of the known expression all form a special lower triangular matrix, the elements above the main diagonal of the special lower triangular matrix are all numbers approaching negative infinity, the main diagonal and the elements below the special lower triangular matrix are all zero, and the elements of the mask matrix whose rows correspond to the second expression and whose columns correspond to the solved exercises are all numbers approaching negative infinity.
[0146] In one embodiment of the present application, the first loss function is expressed as:
[0147] L1=-log(p θ (y|x))
[0148]
[0149] Where L1 represents the first loss function, x represents the solved problem, y represents the known expression of the solved problem, θ represents the model parameters of the problem analysis model, z represents the second similar problem and the corresponding second expression, y i Represents the expression information of the known expression inferred by the exercise analysis model at the i-th moment, y 1:i-1 Indicates the expression information of the known expression before time i, 1≤i≤N, N is the total length of the known expression, p θ(y|x) represents the probability of the exercise analysis model generating a known expression, and z∈top-K(p(z|x)) represents the second similar exercises found.
[0150] In one embodiment of the present application, the second loss function is expressed as:
[0151]
[0152] Among them, L2 represents the second loss function, z q represents the second similar exercise, Represents the expression information of the second expression inferred by the exercise analysis model at time i, represents the expression information of the second expression before time i, θ represents the model parameters of the exercise analysis model, 1≤i≤N, N is the total length of the second expression corresponding to the second similar exercise.
[0153] In one embodiment of the present application, a conversion module is further included, which is used to search for at least one second similar exercise of the solved exercise in the exercise library, obtain second expressions of the two similar exercises, and then convert the known expression and the second expression into prefix expressions respectively.
[0154] The exercise analysis device provided above can be used to execute the exercise analysis method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0155] It is worth noting that in the embodiment of the above-mentioned exercise analysis device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0156] Figure 6 This is a schematic diagram of the structure of an exercise analysis device provided in one embodiment of the present application. Figure 6 As shown, the exercise analysis device includes a processor 40, a memory 41, an input device 42, and an output device 43; the number of processors 40 in the exercise analysis device can be one or more. Figure 6 In the exercise analysis device, a processor 40, a memory 41, an input device 42, and an output device 43 can be connected by a bus or other means. Figure 6 The bus connection is taken as an example.
[0157] Memory 41, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the problem analysis method in the embodiments of the present application (e.g., the acquisition module, search module, analysis module, and solution module in the problem analysis device). Processor 40 executes the software programs, instructions, and modules stored in memory 41 to execute the various functional applications and data processing of the problem analysis device, thereby implementing the above-mentioned problem analysis method.
[0158] Memory 41 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the exercise analysis device. Furthermore, memory 41 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, memory 41 may further include memory remotely located relative to processor 40, and such remote memory may be connected to the exercise analysis device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0159] The input device 42 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the exercise analysis device. The output device 43 may include a display device such as a display screen.
[0160] The above-mentioned exercise analysis equipment includes an exercise analysis device, which can be used to execute any exercise analysis method and has corresponding functions and beneficial effects.
[0161] In addition, an embodiment of the present application also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform relevant operations in the exercise analysis method provided in any embodiment of the present application, and have corresponding functions and beneficial effects.
[0162] Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products.
[0163] Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including the instruction device, which implements the function specified in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0164] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-permanent storage in a computer-readable medium, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0165] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0166] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0167] Note that the above are only preferred embodiments of the present application and the technical principles employed. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present application. The scope of the present application is determined by the scope of the appended claims.
Claims
1. A method for analyzing exercises, characterized in that: include: Get the exercises to be solved; Searching for at least one first similar problem to the problem to be solved in the problem database, and obtaining a first expression of the first similar problem; Inputting the problem to be solved, the first similar problem, and the corresponding first expression into a problem analysis model, and obtaining the expression to be solved of the problem to be solved by the problem analysis model; Obtaining answers to the exercises to be solved according to the expressions to be solved; The exercise analysis model consists of a feature representation model, an analogy learning model and a reasoning model. Inputting the problem to be solved, the first similar problem, and the corresponding first expression into the problem analysis model, and obtaining the expression to be solved of the problem to be solved by the problem analysis model includes: splicing the first similar exercises and the corresponding first expressions to obtain first splicing information, wherein each of the first similar exercises corresponds to one piece of first splicing information; extracting first semantic information of the problem to be solved and second semantic information of the first concatenated information respectively by using a feature representation model; Splicing the first similar problem, the corresponding first expression, and the problem to be solved to obtain second splicing information, wherein each of the first similar problems corresponds to one piece of second splicing information; Obtaining third semantic information of the second splicing information using an analogy learning model; The inference model infers the expression to be solved of the problem to be solved based on the first semantic information, the second semantic information and the third semantic information.
2. The exercise analysis method according to claim 1, characterized in that: The step of searching the problem database for at least one first similar problem to the problem to be solved comprises: Perform word segmentation on the problem to be solved to obtain all first words that appear in the problem to be solved; Searching for a word vector corresponding to the first word in the corpus; Obtaining the first sentence vector of the problem to be solved based on the word vectors corresponding to each of the first words; Calculating the similarity between the first sentence vector and the second sentence vector of each exercise in the exercise database, where the second sentence vector is determined based on the word vectors in the corpus; At least one second sentence vector with the highest similarity is obtained, and the exercise corresponding to the obtained second sentence vector is used as the first similar exercise found.
3. The exercise analysis method according to claim 2, characterized in that: Also includes: Perform word segmentation on each exercise in the exercise database to obtain all second words that appear in the exercise database; Using a vectorization model to obtain a word vector corresponding to each of the second words, each of the word vectors forming the corpus; The word vectors of the second words in the exercise are averaged to obtain the second sentence vector of the exercise.
4. The exercise analysis method according to claim 2, characterized in that: The first sentence vector is represented as: in, represents the first sentence vector of the problem to be solved, K represents the total number of first words contained in the problem to be solved, D represents the corpus, V nk Represents the word vector corresponding to the kth first word in the problem to be solved, V nk ∈D indicates that there is a word vector corresponding to the kth first word in the corpus, Z nj represents the zero vector corresponding to the jth first word in the problem to be solved, Indicates that the word vector corresponding to the j-th first word does not exist in the corpus.
5. The exercise analysis method according to claim 1, characterized in that: The exercise analysis model is trained by the following steps: Get solved problems and corresponding known expressions; Searching for at least one second similar problem to the solved problem in the problem database, and obtaining a second expression of the second similar problem; splicing the solved problem and the known expression to obtain third splicing information, splicing the second similar problem and the corresponding second expression to obtain fourth splicing information, each second similar problem corresponding to one piece of fourth splicing information; respectively extracting fourth semantic information of the third splicing information and fifth semantic information of the fourth splicing information using the feature representation model; splicing the second similar problem, the corresponding second expression, the solved problem, and the known expression to obtain fifth splicing information, wherein each second similar problem corresponds to one piece of fifth splicing information; Obtaining sixth semantic information of the fifth splicing information using an analogy learning model; Inferring the known expression by an inference model based on the fourth semantic information, the fifth semantic information, and the sixth semantic information; Constructing a first loss function according to the inferred known expression; The model parameters of the exercise analysis model are updated according to the first loss function until the first loss function converges.
6. The exercise analysis method according to claim 5, characterized in that: When the inference model infers the known expression based on the fourth semantic information, the fifth semantic information, and the sixth semantic information, the method further includes: Inferring the second expression using the inference model; Constructing a second loss function according to the inferred second expression; The updating of the model parameters of the exercise analysis model according to the first loss function until the first loss function converges includes: The model parameters of the exercise analysis model are updated according to the first loss function and the second loss function until the first loss function and the second loss function converge.
7. The exercise analysis method according to claim 5, characterized in that: The feature representation model and the analogy learning model are both composed of multiple transformer modules, and the transformer modules process the self-attention matrix based on a preset mask matrix.
8. The exercise analysis method according to claim 7, characterized in that: The number of rows and the number of columns of the mask matrix corresponding to the third splicing information are both equal to the length of the third splicing information; The rows and columns in the mask matrix correspond to the elements of the known expression to form a special lower triangular matrix, the elements above the main diagonal in the special lower triangular matrix are all numbers approaching negative infinity, the main diagonal and the elements below the special lower triangular matrix are all zero, the rows and columns in the mask matrix correspond to the elements of the solved problems and are all zero, the rows in the mask matrix correspond to the solved problems and the columns correspond to the elements of the known expression are all numbers approaching negative infinity, the rows in the mask matrix correspond to the known expression and the columns correspond to the solved problems and are all zero.
9. The exercise analysis method according to claim 7, characterized in that: The number of rows and the number of columns of the mask matrix corresponding to the fifth splicing information are both equal to the length of the fifth splicing information; The mask matrix has rows corresponding to the second similar problem, the second expression, the solved problem or the known expression and columns corresponding to the elements of the second similar problem that are all zero, the mask matrix has rows corresponding to the solved problem or the known expression and columns corresponding to the elements of the second expression or the solved problem that are all zero, the mask matrix has rows corresponding to the second similar problem and columns corresponding to the elements of the second expression, the solved problem or the known expression that are all numbers approaching negative infinity, the mask matrix has rows corresponding to the second similar problem and columns corresponding to the elements of the second expression, the solved problem or the known expression that are all numbers approaching negative infinity, The two expressions or the solved problems and the elements of the columns corresponding to the known expressions are all numbers approaching negative infinity, the rows and columns in the mask matrix correspond to the elements of the second expression and the rows and columns correspond to the elements of the known expression, all forming a special lower triangular matrix, the elements above the main diagonal in the special lower triangular matrix are all numbers approaching negative infinity, the main diagonal and the elements below in the special lower triangular matrix are all zero, and the elements of the mask matrix whose rows correspond to the second expression and whose columns correspond to the solved problems are all numbers approaching negative infinity.
10. The exercise analysis method according to claim 5, characterized in that: The first loss function is expressed as: L1=-log(p θ (y|x)) Where L1 represents the first loss function, x represents the solved problem, y represents the known expression of the solved problem, θ represents the model parameters of the problem analysis model, z represents the second similar problem and the corresponding second expression, y i Represents the expression information of the known expression inferred by the exercise analysis model at the i-th moment, y 1:i-1 Indicates the expression information of the known expression before time i, 1≤i≤N, N is the total length of the known expression, p θ (y|x) represents the probability of the exercise analysis model generating a known expression, and z∈top-K(p(z|x)) represents the second similar exercises found.
11. The exercise analysis method according to claim 6, characterized in that: The second loss function is expressed as: Among them, L2 represents the second loss function, z q represents the second similar exercise, Represents the expression information of the second expression inferred by the exercise analysis model at time i, represents the expression information of the second expression before time i, θ represents the model parameters of the exercise analysis model, 1≤i≤N, N is the total length of the second expression corresponding to the second similar exercise.
12. The exercise analysis method according to claim 5, characterized in that: After searching the problem database for at least one second similar problem to the solved problem and obtaining a second expression for the second similar problem, the method further includes: Convert the given expression and the second expression into prefix expressions respectively.
13. A problem analysis device, characterized in that: include: An acquisition module is used to obtain exercises to be solved; a search module, configured to search the problem database for at least one first similar problem to the problem to be solved, and obtain a first expression of the first similar problem; An analysis module, configured to input the problem to be solved, the first similar problem, and the corresponding first expression into a problem analysis model, and obtain a solution expression of the problem to be solved by analyzing the problem analysis model; A solution module, configured to obtain an answer to the exercise to be solved according to the expression to be solved; The exercise analysis model is composed of a feature representation model, an analogy learning model and a reasoning model. The analysis module includes: a first splicing unit, used to splice the first similar exercise and the corresponding first expression to obtain first splicing information, and each first similar exercise corresponds to a first splicing information; a first extraction unit, used to use the feature representation model to extract the first semantic information of the exercise to be solved and the second semantic information of the first splicing information respectively; a second splicing unit, used to splice the first similar exercise, the corresponding first expression and the exercise to be solved to obtain second splicing information, and each first similar exercise corresponds to a second splicing information; a first analogy unit, used to use the analogy learning model to obtain third semantic information of the second splicing information; a first reasoning unit, used to use the reasoning model to infer the expression to be solved of the exercise to be solved based on the first semantic information, the second semantic information and the third semantic information.
14. A problem analysis device, characterized in that: include: one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the exercise analysis method according to any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the exercise analysis method as described in any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
A method and a device for correcting application questions in test paper
CN109583429A
Processing method and system of mathematical application question answering model and storage medium
CN112784536A