Question situation understanding-based mathematical application question intelligent solving method and system
By constructing interactive graphs and edge elimination methods, deep learning models can more accurately understand mathematical application problems, solve the problem of insufficient reasoning capabilities of existing models, and achieve more efficient problem-solving effects.
Patent Information
- Application Number
- CN202411213854.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-31
- Publication Date
- 2024-12-20
AI Technical Summary
In the automatic calculation task of complex mathematical application problems, the existing deep learning models lack reasoning ability and are difficult to effectively process novel arithmetic application problems data sets, and there is room for improvement in structure.
Using an intelligent problem-solving method based on problem situation understanding, by constructing interactive graphs to simulate dynamic relationships between entities and gradually update the entity state using edge elimination method. Deep learning models can more accurately understand and analyze the situations in mathematical application problems. information, generate accurate answers and equation expressions.
The model's understanding and answering mathematical application problems has been improved, the reasoning ability has been enhanced, and a more accurate and transparent problem-solving process has been provided, which has improved the model's problem-solving efficiency and effectiveness.
Smart Images

Figure CN119167927A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing, and specifically relates to an intelligent problem-solving method and system for mathematical word problems based on problem context understanding. Background Art
[0002] With the continuous attempts and applications of deep learning in the field of natural language processing, some end-to-end models have shown very good results in the automatic calculation of some machine mathematical word problems. These models do not need to rely on the complex manually designed features used by traditional methods, and their performance is much better than traditional methods.
[0003] Wang et al. proposed a deep neural solver (NDS) which is a seq2seq model that directly converts the input question into an output expression. Wang et al. proposed the T-RNN model, which applies a recurrent neural network to predict unknown operators in the prediction template. Li et al. proposed the GROUP-ATT model, which applies a group attention mechanism to extract four features from the input question. Xie et al. proposed a goal-driven tree-structured MWP solver (GTS), which generates expressions through a tree-structured neural network and generates trees in a goal-driven manner. Lin et al. proposed the HMS model, which imitates human reading habits by utilizing hierarchical word-break question relationships. Zhang et al. proposed the Grap2Tree model, which applies a graph-based encoder to capture the relationship and order information between quantities. Wu et al. proposed the edge-enhanced hierarchical Group2Tree model (EEH-G2T) to construct an edge-labeled graph for question representation and capture common sense information based on an external knowledge base. Shen
[28] et al. proposed the MEMD model, proposed a model with multiple encoders and multiple decoders, and designed a new graph form of mathematical word problems. Zhao et al. proposed the FECA model, which enhanced the seq2seq model through external features and replication mechanisms. Wu et al. proposed the NUMS2T model, which processes all numbers with explicit numerical values and adds external knowledge to the encoder model. Wu
[31] et al. proposed the KA-S2T model, which is a drawing tree model with commonsense knowledge from an external knowledge base, which uses a state aggregation mechanism to recursively aggregate the neighbors of each node in the expression tree. Inspired by the theory of two-level understanding process, Wu et al. proposed a new clause-level relation-aware mathematical solver (CLRSolver) to simulate the human understanding process from lower to higher levels. In the lower-level process, the problem is divided into clauses according to the natural division of the problem, and their semantics are learned. In the higher-level process, according to the human multi-view understanding of clause-level relations, a CNN-based module is first applied to learn the dependencies between clauses from the word correlations of the local view. Then, two new relation-aware mechanisms are proposed to learn the dependencies from the clause semantics from the global perspective. Next, the representation of the clause is enhanced based on the learned clause-level dependencies. In the expression generation process, a tree-based decoder is developed to generate mathematical expressions.
[0004] The introduction of deep learning has changed the research ideas of many natural language processing tasks, and deep learning has achieved good results in the automatic calculation of arithmetic word problems by machines, which also indirectly illustrates the importance of deep learning for the automatic calculation of arithmetic word problems. Since the automatic calculation data of arithmetic word problems in life are more complex, the current automatic calculation of arithmetic word problems by machines has put forward higher requirements on the reasoning ability of machines. More and more novel automatic calculation data sets for arithmetic word problems have been proposed. Answering the questions in these data sets requires high discrete reasoning ability. How to process these data sets has become the key to improving the reasoning ability of the model. However, the existing deep learning models may not be mature enough, and there is still room for improvement in their structure. Summary of the invention
[0005] The purpose of the present invention is to provide a method and system for intelligently solving mathematical word problems based on problem context understanding, which can understand the known condition text and problem description of the input mathematical word problems and give corresponding answers and equation expressions.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is: an intelligent problem-solving method for mathematical word problems based on problem context understanding, comprising the following steps:
[0007] Step A: pre-process the collected math word problem data to establish a training set TS containing known conditions, questions and answers of the math word problems;
[0008] Step B: constructing a deep learning model for intelligent problem solving of mathematical word problems, determining a loss function Loss, and training the deep learning model by minimizing the loss function on a training set; the deep learning model simulates the dynamic relationship between entities in the problem by constructing an interaction graph, and gradually updates the entity state by using an edge elimination method, so as to improve the ability to understand problems and solve word problems;
[0009] Step C: Input the known conditions and problems of the mathematical word problem into the trained deep learning model and output the answer to the problem.
[0010] Furthermore, the step A specifically includes the following steps:
[0011] Step A1: collecting math word problem data for training, each piece of math word problem data includes a problem, an equation and an answer of the math word problem;
[0012] Step A2: Preprocess each piece of math word problem data, segment the text of the math word problem and remove stop words, replace the known numbers in the problem, and obtain a four-tuple (P, N P ,E P ,a), where P represents the problem text of the math word problem, N P represents the set of numbers appearing in the text, E P represents a mathematical expression, and a represents the answer to the question;
[0013] Where P = {p1, p2, ..., pL (p)}, p i is the i-th word in the text after the math word problem is segmented and replaced with numbers, i=1,2,...,L(p), L(P) is the number of words remaining in the text after the math word problem is segmented and stop words are removed; e i ∈V op ∪N P , V op Indicates the operation operator used in mathematical expressions, i=1,2,...,L(E P ), L(E p ) is the length of the mathematical equation;
[0014] Step A3: Use the 4-tuple (P, N) of the math problem data processed in step A2 P ,E P ,a) constitute the training set.
[0015] Furthermore, the step B specifically includes the following steps:
[0016] Step B1: Traverse the training set and for each quadruple (P, NP ,E P ,a), Input the problem text P of the mathematical word problem into the semantic encoder to obtain the semantic initial representation vector H of the problem r ;
[0017] Step B2: Input the question text P into the fine-tuned language model, identify the entity information ent in the text, organize the identified entity information structure into a json representation, each entity ent has four fields: entity name E, container C, quantity N, attribute A; organize all the entity information identified in the question text P into an entity set ENT, ENT = {ent1, ent2, ... entL (ENT)};
[0018] Step B3: Extract the who-doing-what triple information from the question text P, and combine it with the entity set ENT constructed in step B2 to construct an interaction diagram for describing the specific situation content.
[0019] Step B4: The interaction diagram obtained in step B3 Use the graph attention network for encoding and calculate the interaction graph representation vector H g ;
[0020] Step B5: The semantic initial representation vector H obtained in steps B1 and B4 is r , interaction graph representation vector H g , through the dynamic vector fusion method, the intermediate state fusion vectors are calculated respectively, and then the final coding fusion vector H is obtained by stacking the coding modules. final ;
[0021] Step B6: Convert the interaction diagram obtained in step B3 According to the action edge A The order of occurrence, retrieve the two entities involved in the action from the entity set ENT i ,ent j , according to the attribute category of the action, update the quantity field N of the entity and Eliminate action edge e A ; Repeat the update operation until there are no edges in the interaction graph, Group all updated entities into a final state entity set
[0022] Step B7: The final state entity set ENT obtained in step B6 f Each entity in Input the entity encoder to obtain the final state representation H of the entity set e ; Fusion code final vector H final and the final state of the entity set H e Send it to the sequence generation decoder to generate the predicted mathematical expression E' P , calculate the target loss function Loss;
[0023] Step B8: According to the loss function Loss obtained in B7, the gradient of each parameter in the deep learning network model is calculated by the back propagation method, and the parameters are updated by the stochastic gradient descent method; when the iterative change of the loss value generated by the deep learning model is less than the set threshold and no longer decreases or reaches the maximum number of iterations, the training of the deep learning model is terminated.
[0024] Furthermore, the step B1 specifically includes the following steps:
[0025] Step B11: Replace the digital tokens appearing in the question text P with predefined tokens <num i >, i = 1, 2, ...; where i represents the i-th number in the text; embed the processed question text input word into the encoding layer Embed s , get the word token embedding for each word
[0026] Let L w ∈R d×|V| is the pre-trained word vector matrix, where d is the dimension of the word vector and |V| is L w The number of words in the problem text of a mathematical word problem P = {p1, p2, ..., p L(p)}, whose word token embedding is represented as in is the i-th word p in the question text P i In the pre-trained word vector matrix L w The word vector obtained by searching in
[0027] Step B12: embed the word tokens obtained in step B11 into the representation The problem description P is encoded through a bidirectional gated recurrent unit (Bi-GRU); the output of the bidirectional gated recurrent unit is the hidden state vector H of all word tags r ={h1,h2,…h L(P)}, where L(P) is the length of the question text, and the calculation process is as follows:
[0028]
[0029] Furthermore, the step B2 specifically includes the following steps:
[0030] Step B21: Use the labeled entity data to fine-tune the Bert model to adapt to the specific entity recognition task. The fine-tuned model can better understand the context information of the entity. Use the fine-tuned Bert model to recognize the entities in the question text P, output the entity's starting position loc, entity type type and entity name E, and preliminarily construct the entity set ENT.
[0031] Step B22: For each entity ent in the entity set ENT in step B21 i , using the Bert model to encode the context of the entity, combined with dependency analysis rules and semantic role labeling technology, predict the three fields of the entity's attributes, quantity, and container, and extract the key information of the entity; for entities that do not have an obvious quantity relationship, the quantity field is uniformly labeled as: x i , represents the unknown quantity of the i-th entity;
[0032] Step B23: Based on the complete entity information obtained in step B22, each entity i Encapsulated in json format, it is expressed as follows:
[0033]
[0034] Among them, p i represents the word token in the question text P, NUM represents the set of all numbers in the question text P, NUM={n1,n2,…n l}, l is the total number of numbers; finally, all entity information identified in the question text P is combined into an entity set ENT, ENT = {ent1, ent2, ... ent L(ENT)};
[0035] The step B3 specifically comprises the following steps:
[0036] Step B31: Use Stanford CoreNLP to change the third-person pronouns appearing in the question text P into specific entity names E according to the coreference cluster replacement rule; then use the open information extraction system to extract who-doing-what triples from the converted text;
[0037] Step B32: Initialize the point set V using the entity set ENT obtained in step B2 A , point set V A Each point in Both represent an entity ent i ; Initialize edge set E according to the triples extracted in step B31 A , each directed edge It has three attributes: (action, sequence number, number); the value of action is the value of the doing part in the who-doing-what triple; the value of the sequence number is k, indicating the kth action in the question text; the number num is the numeric word tag with the closest dependency relationship with the triple; the interaction graph is constructed from the extracted triples If two entities ent i ,ent j are the subject and object in the triple respectively, then With directed edge E A [j][j]=1 is connected.
[0038] Furthermore, the step B4 specifically includes the following steps:
[0039] Step B41: Use the network based on the graph attention mechanism to take advantage of the relationship between nodes. Each node in Encoding, the calculation process is as follows:
[0040]
[0041]
[0042] in, W e and a are trainable parameters, [·||·] represents the concatenation of two vectors, σ is the activation function, yes Middle and Node The set of adjacent nodes;
[0043] Step B42: For a given interaction graph adjacency matrix A k and the feature matrix X of each node. At the beginning, X is set to X = H = {h i}, define the GCN network as follows:
[0044] GCN(A k ,X)=GConv2(A k ,GConv1(A k ,X))
[0045] GCN consists of two different graph convolution operations:
[0046] GConv(A k ,X)=relu(A k X T W gk )
[0047] For each graph Execute GCN in parallel to generate d k dimensional output values, which are concatenated and projected to produce the final value:
[0048]
[0049] Among them, || indicates that there are K GCN heads in series, and then the graph convolution network uses a feedforward network layer, a normalization layer, and a residual difference connection to enhance the output, which is calculated as follows:
[0050]
[0051]
[0052] It is a two-layer feed-forward network with a relu function between the layers:
[0053] FFN(x)=max(0,xW f1 +b f1 )W f2 +b f2
[0054] Step B43: Generated graph node representation It contains quantity, entities and relationships, and applies element-by-element minimum pooling operation to the learned node representation; finally, the global feature information is input into the fully connected neural network (FFN) to generate the interaction graph representation vector H g :
[0055]
[0056] Furthermore, the step B5 specifically includes the following steps:
[0057] Step B51: The semantic representation vector H obtained through steps B1 and B4 r , interaction graph representation vector H g , respectively from H r and H g The average pooling operation obtains vector s and vector q, and then in H r Between q and H g Apply cross-modal attention between and :
[0058]
[0059]
[0060] The attention score a i ,b i It is calculated as follows:
[0061]
[0062]
[0063] in and is a learnable weight matrix; by applying different weights to different modalities, the output of the intermediate fusion vector is obtained:
[0064]
[0065]
[0066] Step B52: A refined understanding of the question p is achieved by stacking multiple encoders. For the dynamic fusion output of the k-1th layer semantic encoder and the interaction graph encoder, the result of feature stacking is:
[0067]
[0068] The attention weight c r and c g And the calculation method is:
[0069]
[0070]
[0071] in, and is a learnable weight matrix, is the input of the K-th encoder combination block, and the output of the K-th encoder combination block is and After completing the K-th step of reasoning, we will get and Connect them together to get the final output representation H final .
[0072] Furthermore, the step B6 specifically includes the following steps:
[0073] Step B61: Obtain the interaction diagram from step B3 The edge set E A , from E A Select an edge e with the smallest sequence number ij ; According to the edge e ij Select the relevant entity ent from the entity set ENT i ,ent j ; According to the edge eij The action attribute action is input into the pre-trained action classifier network to obtain the mathematical operation operator op corresponding to the behavior action and the corresponding inverse operation operator
[0074] Step B62: Assume that entity ent i The value of the quantity field N is n i Entity j The value of the quantity field N is n j ;Entity i The quantity field N is updated to "n i op num"; the entity ent j The quantity field N is updated to At the same time in the interactive diagram Eliminate edge ij , get the updated new entity ent' i andent' j :
[0075]
[0076] Step B63: Interaction diagram Repeat steps B61 and B62 until Get the final image Let the final graph The entity ent' corresponding to each point in i for All new entities after update are combined into a final state entity set
[0077] Furthermore, the step B7 specifically includes the following steps:
[0078] Step B71: The final state complete state entity set ENT obtained in step B6 f Each entity in Input the entity embedder EM to obtain the final state representation of each entity The final state representation of all entities is encoded through the aggregation network to synthesize the final state representation of the entity set H e ; The final encoding fusion vector and the final state representation of the entity set are sent to the sequence generation decoder GM. In the process of generating each word tag, the decoder GM accepts the output of the entity embedder EM and the word embedding of the previous word tag, and decodes the word tag e at the tth time step after performing attention calculation on the two. t ; After connecting all word tags, the final generated mathematical expression E' is obtained p ={e1,e2,...e t};
[0079] Step B72: For a given training data set TS = {(P0, E p0 ),(P1,E p1 ),…,(P N ,E pN )}, the entire encoder-decoder model is trained by minimizing the value of the loss function Loss, where the loss function Loss is calculated as follows:
[0080]
[0081] The present invention also provides an intelligent problem-solving system for mathematical word problems based on problem context understanding, comprising a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0082] Compared with the prior art, the present invention has the following beneficial effects: the present invention provides a method and system for intelligently solving mathematical word problems based on problem context understanding. The deep learning model of the method can transform the text information in mathematical word problems into a graphical entity relationship representation by constructing an interaction graph; this structural representation not only captures the direct information in the question, but also reveals the implicit logical and semantic connections through the connection relationship between entities; this in-depth semantic understanding enables the model to more accurately parse the context in the question, providing a solid foundation for problem solving. In addition, the "edge elimination method" proposed by the method is a novel dynamic entity state update mechanism; in the constructed interaction graph, each edge represents an action or event, and the edge elimination method updates the state of the relevant entities by gradually processing these actions until the problem is solved; the edge elimination method not only simulates the step-by-step reasoning process of humans when solving problems, but also intuitively shows the progress of problem solving through the elimination of edges, improving the transparency and efficiency of the problem solving process. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 is a flow chart of a method implementation of an embodiment of the present invention;
[0084] Figure 2 It is an architectural diagram of the deep learning model in an embodiment of the present invention. DETAILED DESCRIPTION
[0085] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0086] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0087] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0088] like Figure 1 As shown, this embodiment provides a method for intelligently solving mathematical word problems based on problem context understanding, comprising the following steps:
[0089] Step A: pre-process the collected math word problem data to establish a training set TS containing known conditions, questions and answers of the math word problems;
[0090] Step B: construct a deep learning model for intelligent problem solving of mathematical word problems, determine the loss function Loss, and train the deep learning model by minimizing the loss function on the training set; the deep learning model simulates the dynamic relationship between entities in the problem by constructing an interaction graph, and gradually updates the entity state by using the "edge elimination method". This method combining graph theory and deep learning not only improves the accuracy of problem understanding, but also enhances the model's ability to solve word problems;
[0091] Step C: Input the known conditions and problems of the mathematical word problem into the trained deep learning model and output the answer to the problem.
[0092] In this embodiment, the step A specifically includes the following steps:
[0093] Step A1: collecting math word problem data for training, each piece of math word problem data includes a problem, an equation and an answer of the math word problem;
[0094] Step A2: Preprocess each piece of math word problem data, segment the text of the math word problem and remove stop words, replace the known numbers in the problem, and obtain a four-tuple (P, N P ,E P ,a), where P represents the problem text of the math word problem, N P represents the set of numbers appearing in the text, E P represents a mathematical expression, and a represents the answer to the question;
[0095] Where P = {p1, p2, ..., p L(p)}, p iis the i-th word in the text after the math word problem is segmented and replaced with numbers, i=1,2,...,L(p), L(P) is the number of words remaining in the text after the math word problem is segmented and stop words are removed; e i ∈V op ∪N P , V op Indicates the operation operator used in mathematical expressions, i=1,2,...,L(E P ), L(E p ) is the length of the mathematical equation;
[0096] Step A3: Use the 4-tuple (P, N) of the math problem data processed in step A2 P ,E P ,a) constitute the training set.
[0097] Figure 2 It is the architecture diagram of the deep learning model in this embodiment. In this embodiment, the specific implementation steps of step B are as follows.
[0098] Step B1: Traverse the training set and for each quadruple (P, N P ,E P ,a), Input the problem text P of the mathematical word problem into the semantic encoder to obtain the semantic initial representation vector H of the problem r .
[0099] The step B1 specifically comprises the following steps:
[0100] Step B11: Replace the digital tokens appearing in the question text P with predefined tokens <num i >, i = 1, 2, ...; where i represents the i-th number in the text; embed the processed question text input word into the encoding layer Embed s , get the word token embedding for each word
[0101] Let L w ∈R d×|V| is the pre-trained word vector matrix, where d is the dimension of the word vector and |V| is L w The number of words in the problem text of a mathematical word problem P = {P1, P2, ..., p L(p)}, whose word token embedding is represented as in is the i-th word p in the question text P i In the pre-trained word vector matrix L w The word vector obtained by looking up in .
[0102] Step B12: embed the word tokens obtained in step B11 into the representation The problem description P is encoded through a bidirectional gated recurrent unit (Bi-GRU); the output of the bidirectional gated recurrent unit is the hidden state vector H of all word tags r ={h1,h2,…h L(P)}, where L(P) is the length of the question text, and the calculation process is as follows:
[0103]
[0104] Step B2: Input the question text P into the fine-tuned language model, identify the entity information ent in the text, organize the identified entity information structure into a json representation, each entity ent has four fields: entity name E, container C, quantity N, attribute A; organize all the entity information identified in the question text P into an entity set ENT, ENT = {ent1, ent2, ... ent L(ENT)}.
[0105] The step B2 specifically comprises the following steps:
[0106] Step B21: Use the labeled entity data to fine-tune the Bert model to adapt to the specific entity recognition task. The fine-tuned model can better understand the contextual information of the entity; use the fine-tuned Bert model to identify the entities in the question text P, output the entity's starting position loc, entity type type and entity name E, and preliminarily construct the entity set ENT.
[0107] Step B22: For each entity ent in the entity set ENT in step B21 i , the Bert model is used to encode the context of the entity, and the dependency analysis rules and semantic role labeling technology are combined to predict the three fields of the entity's attributes, quantity, and container, and extract the key information of the entity; for entities without obvious container relationships, the container field is uniformly labeled as: "world", and for entities without obvious quantity relationships, the quantity field is uniformly labeled as: x i , represents the unknown quantity of the i-th entity.
[0108] Step B23: Based on the complete entity information obtained in step B22, each entity i Encapsulated in json format, it is expressed as follows:
[0109]
[0110] Among them, p irepresents the word token in the question text P, NUM represents the set of all numbers in the question text P, NUM={n1,n2,…n l}, l is the total number of numbers; finally, all entity information identified in the question text P is combined into an entity set ENT, ENT = {ent1, ent2, ... ent L(ENT)}.
[0111] Step B3: Extract the who-doing-what triple information from the question text P, and combine it with the entity set ENT constructed in step B2 to construct an interaction diagram for describing the specific situation content.
[0112] The step B3 specifically comprises the following steps:
[0113] Step B31: Use Stanford CoreNLP to change the third-person pronouns appearing in the question text P into specific entity names E according to the coreference cluster replacement rule; then use the Open Information Extraction system (OpenIE) to extract who-doing-what triples from the converted text.
[0114] Step B32: Initialize the point set V using the entity set ENT obtained in step B2 A , point set V A Each point in Both represent an entity ent i ; Initialize edge set E according to the triples extracted in step B31 A , each directed edge It has three attributes: (action, sequence number, number); the value of action is the value of the doing part in the who-doing-what triple; the value of the sequence number is k, indicating the kth action in the question text; the number num is the numeric word tag with the closest dependency relationship with the triple; the interaction graph is constructed from the extracted triples If two entities ent i ,ent j are the subject and object in the triple respectively, then With directed edge E A [i][j]=1 are connected.
[0115] Step B4: The interaction diagram obtained in step B3 Use the graph attention network for encoding and calculate the interaction graph representation vector H g .
[0116] The step B4 specifically comprises the following steps:
[0117] Step B41: Use the network based on the graph attention mechanism to take advantage of the relationship between nodes. Each node in Encoding, the calculation process is as follows:
[0118]
[0119]
[0120] in, W e and a are trainable parameters, [·||·] represents the concatenation of two vectors, σ is the activation function, yes Middle and Node A collection of adjacent nodes.
[0121] Step B42: For a given interaction graph adjacency matrix A k and the feature matrix X of each node. At the beginning, X is set to X = H = {h i}, define the GCN network as follows:
[0122] GCN(A k ,X)=GConv2(A k ,GConv1(A k ,X))
[0123] GCN consists of two different graph convolution operations:
[0124] GConv(A k ,X)=relu(A k X T W gk )
[0125] For each graph Execute GCN in parallel to generate d k dimensional output values, which are concatenated and projected to produce the final value:
[0126]
[0127] Among them, || indicates that there are K GCN heads in series, and then the graph convolution network uses a feedforward network layer, a normalization layer, and a residual difference connection to enhance the output, which is calculated as follows:
[0128]
[0129]
[0130] It is a two-layer feed-forward network with a relu function between the layers:
[0131] FFN(x)=max(0,xW f1 +b f1 )W f2 +b f2
[0132] Step B43: Generated graph node representation In order to further learn the global context graph representation, the learned node representation is subjected to element-by-element minimum pooling operation. Finally, the global feature information is input into the fully connected neural network (FFN) to generate the interaction graph representation vector H. g :
[0133]
[0134] Step B5: The semantic initial representation vector H obtained in steps B1 and B4 is r , interaction graph representation vector H g , through the dynamic vector fusion method, the intermediate state fusion vectors are calculated respectively, and then the final coding fusion vector H is obtained by stacking the coding modules. final .
[0135] The step B5 specifically comprises the following steps:
[0136] Step B51: The semantic representation vector H obtained through steps B1 and B4 r , interaction graph representation vector H g , respectively from H r and H g The vector s and vector q are obtained in the average pooling operation of H r Between q and H g Apply cross-modal attention between and :
[0137]
[0138]
[0139] The attention score a i ,b i It is calculated as follows:
[0140]
[0141]
[0142] in and is a learnable weight matrix; by applying different weights to different modalities, the output of the intermediate fusion vector is obtained:
[0143]
[0144]
[0145] Step B52: A refined understanding of the question p is achieved by stacking multiple encoders. For the dynamic fusion output of the k-1th layer semantic encoder and the interaction graph encoder, the result of feature stacking is:
[0146]
[0147] The attention weight c r and c g And the calculation method is:
[0148]
[0149]
[0150] in, and is a learnable weight matrix, is the input of the K-th encoder combination block, and the K-th encoder combination block will output and After completing the K-th step of reasoning, we will get and Connect them together to get the final output representation H final .
[0151] Step B6: Convert the interaction diagram obtained in step B3 According to the action edge A The order of occurrence, retrieve the two entities involved in the action from the entity set ENT i ,ent j , according to the attribute category of the action, update the quantity field N of the entity and Eliminate action edge e A ; Repeat the update operation until there are no edges in the interaction graph, Group all updated entities into a final state entity set
[0152] The step B6 specifically comprises the following steps:
[0153] Step B61: Obtain the interaction diagram from step B3 The edge set E A , from E A Select an edge e with the smallest sequence number ij ; According to the edge e ij Select the relevant entity ent from the entity set ENT i ,ent j ; According to the edge e ij The action attribute action is input into the pre-trained action classifier network to obtain the mathematical operation operator op corresponding to the behavior action and the corresponding inverse operation operator
[0154] Step B62: Assume that entity ent i The value of the quantity field N is n i Entity j The value of the quantity field N is n j ;Entity i The quantity field N is updated to "n i op num"; the entity ent j The quantity field N is updated to At the same time in the interactive diagram Eliminate edge ij , get the updated new entity ent' i andent' j :
[0155]
[0156] Step B63: Interaction diagram Repeat steps B61 and B62 until Get the final image Let the final graph The entity ent' corresponding to each point in i for All new entities after update are combined into a final state entity set
[0157] Step B7: The final state entity set ENT obtained in step B6 f Each entity in Input the entity encoder to obtain the final state representation H of the entity set e ; Fusion code final vector H final and the final state of the entity set H e Send it to the sequence generation decoder to generate the predicted mathematical expression E' P , calculate the target loss function Loss.
[0158] The step B7 specifically includes the following steps:
[0159] Step B71: The final state complete state entity set ENT obtained in step B6 f Each entity in Input the entity embedder EM to obtain the final state representation of each entity The final state representation of all entities is encoded through the aggregation network to synthesize the final state representation of the entity set H e ; The final vector of the encoding fusion and the final state representation of the entity set are sent to the sequence generation decoder GM. In the process of generating each word tag, the decoder GM will accept the output of the entity embedder EM and the word embedding of the previous word tag, and decode the word tag e at the tth time step after performing attention calculation on the two. t ; After connecting all word tags, the final generated mathematical expression E' is obtained p ={e1,e2,...e t}.
[0160] Step B72: For a given training data set TS = {(P0, E p0 ),(P1,E p1 ),…,(P N ,E pN )}, the entire encoder-decoder model is trained by minimizing the value of the loss function Loss, where the loss function Loss is calculated as follows:
[0161]
[0162] Step B8: According to the loss function Loss obtained in B7, the gradient of each parameter in the deep learning network model is calculated by the back propagation method, and the parameters are updated by the stochastic gradient descent method; when the iterative change of the loss value generated by the deep learning model is less than the set threshold and no longer decreases or reaches the maximum number of iterations, the training of the deep learning model is terminated.
[0163] This embodiment also provides an intelligent problem-solving system for mathematical word problems based on problem context understanding, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0165] 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 generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
Claims
1. An intelligent method for solving mathematical word problems based on problem context understanding, characterized in that: The following steps are involved: Step A: pre-process the collected math word problem data to establish a training set TS containing known conditions, questions and answers of the math word problems; Step B: constructing a deep learning model for intelligent problem solving of mathematical word problems, determining a loss function Loss, and training the deep learning model on a training set by minimizing the loss function; The deep learning model simulates the dynamic relationship between entities in the problem by constructing an interaction graph and gradually updates the entity status using the edge elimination method to improve the ability to understand the problem and solve the application problem; Step C: Input the known conditions and problems of the mathematical word problem into the trained deep learning model and output the answer to the problem.
2. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 1 is characterized in that: The step A specifically comprises the following steps: Step A1: collecting math word problem data for training, each piece of math word problem data includes a problem, an equation and an answer of the math word problem; Step A2: Preprocess each piece of math word problem data, segment the text of the math word problem and remove stop words, replace the known numbers in the problem, and obtain a 4-tuple (P, N P ,E P ,a), where P represents the problem text of the math word problem, N P represents the set of numbers appearing in the text, E P represents a mathematical expression, and a represents the answer to the question; Where P = {p1, p2, ..., p L(p) }, p i is the i-th word in the text after the math word problem is segmented and replaced with numbers, i=1,2,...,L(p), L(P) is the number of words remaining in the text after the math word problem is segmented and stop words are removed; V op Indicates the operation operator used in mathematical expressions, i=1,2,...,L(E P ), L(E p ) is the length of the mathematical equation; Step A3: Use the 4-tuple (P, N) of the math problem data processed in step A2 P ,E P ,a) constitute the training set.
3. The intelligent method for solving arithmetic word problems according to claim 2, characterized in that: The step B specifically comprises the following steps: Step B1: Traverse the training set and for each quadruple (P, N P ,E P ,a), Input the problem text P of the mathematical word problem into the semantic encoder to obtain the semantic initial representation vector H of the problem r ; Step B2: Input the question text P into the fine-tuned language model, identify the entity information ent in the text, organize the identified entity information structure into a json representation, each entity ent has four fields: entity name E, container C, quantity N, attribute A; organize all the entity information identified in the question text P into an entity set ENT, ENT = {ent1, ent2, ... ent L(ENT) }; Step B3: Extract the who-doing-what triple information from the question text P, and combine it with the entity set ENT constructed in step B2 to construct an interaction diagram for describing the specific situation content. Step B4: The interaction diagram obtained in step B3 Use the graph attention network for encoding and calculate the interaction graph representation vector H g ; Step B5: The semantic initial representation vector H obtained in steps B1 and B4 is r , interaction graph representation vector H g , through the dynamic vector fusion method, the intermediate state fusion vectors are calculated respectively, and then the final coding fusion vector H is obtained by stacking the coding modules. final ; Step B6: Convert the interaction diagram obtained in step B3 According to the action edge A The order of occurrence, retrieve the two entities involved in the action from the entity set ENT i ,ent j , according to the attribute category of the action, update the quantity field N of the entity and Eliminate action edge e A ; Repeat the update operation until there are no edges in the interaction graph, Group all updated entities into a final state entity set Step B7: The final state entity set ENT obtained in step B6 f Each entity in Input the entity encoder to obtain the final state representation h of the entity set e ; Fusion code final vector H final and the final state of the entity set H e Send it to the sequence generation decoder to generate the predicted mathematical expression E' P , calculate the target loss function Loss; Step B8: According to the loss function Loss obtained in B7, the gradient of each parameter in the deep learning network model is calculated by the back propagation method, and the parameters are updated by the stochastic gradient descent method; when the iterative change of the loss value generated by the deep learning model is less than the set threshold and no longer decreases or reaches the maximum number of iterations, the training of the deep learning model is terminated.
4. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 3 is characterized in that: The step B1 specifically comprises the following steps: Step B11: Replace the digital tokens appearing in the question text P with predefined tokens <num i >, i = 1, 2, ...; where i represents the i-th number in the text; embed the processed question text input word into the encoding layer Embed s , get the word token embedding for each word Let L w ∈R d×|V| is the pre-trained word vector matrix, where d is the dimension of the word vector and |V| is L w The number of words in the problem text of a mathematical word problem P = {p1, p2, ..., p L(p) }, whose word tag embedding is represented as in is the i-th word p in the question text P i In the pre-trained word vector matrix L w The word vector obtained by searching in Step B12: embed the word tokens obtained in step B11 into the representation The problem description P is encoded through a bidirectional gated recurrent unit (Bi-GRU); the output of the bidirectional gated recurrent unit is the hidden state vector H of all word tags r ={h1,h2,…h L(P) }, where L(P) is the length of the question text, and the calculation process is as follows:
5. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 4 is characterized in that: The step B2 specifically comprises the following steps: Step B21: Use the labeled entity data to fine-tune the Bert model to adapt to the specific entity recognition task. The fine-tuned model can better understand the context information of the entity. Use the fine-tuned Bert model to recognize the entities in the question text P, output the entity's starting position loc, entity type type and entity name E, and preliminarily construct the entity set ENT. Step B22: For each entity ent in the entity set ENT in step B21 i , using the Bert model to encode the context of the entity, combined with dependency analysis rules and semantic role labeling technology, predict the three fields of the entity's attributes, quantity, and container, and extract the key information of the entity; for entities that do not have an obvious quantity relationship, the quantity field is uniformly labeled as: x i , represents the unknown quantity of the i-th entity; Step B23: Based on the complete entity information obtained in step B22, each entity i Encapsulated in json format, it is expressed as follows: Among them, p i represents the word token in the question text P, NUM represents the set of all numbers in the question text P, NUM={n1,n2,…n l }, l is the total number of numbers; finally, all entity information identified in the question text P is combined into an entity set ENT, ENT = {ent1, ent2, ... ent L(ENT) }; The step B3 specifically comprises the following steps: Step B31: Use StanfordCoreNLP to change the third-person pronouns appearing in the question text P into specific entity names E according to the coreference cluster replacement rule; then use the open information extraction system to extract who-doing-what triples from the converted text; Step B32: Initialize the point set V using the entity set ENT obtained in step B2 A , point set V A Each point in Both represent an entity ent i ; Initialize edge set E according to the triples extracted in step B31 A , each directed edge It has three attributes: (action, sequence number, number); the value of action is the value of the doing part in the who-doing-what triple; the value of the sequence number is k, indicating the kth action in the question text; the number num is the numeric word tag with the closest dependency relationship with the triple; the interaction graph is constructed from the extracted triples If two entities ent i ,ent j are the subject and object in the triple respectively, then With directed edge E A [j][j]=1 is connected.
6. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 5 is characterized in that: The step B4 specifically comprises the following steps: Step B41: Use the network based on the graph attention mechanism to take advantage of the relationship between nodes. Each node in Encoding, the calculation process is as follows: in, W e and a are trainable parameters, [·||·] represents the concatenation of two vectors, σ is the activation function, yes Middle and Node The set of adjacent nodes; Step B42: For a given interaction graph adjacency matrix A k and the feature matrix X of each node. At the beginning, X is set to X = H = {h i }, define the GCN network as follows: GCN(A k ,X)=GConv2(A k ,GConv1(A k ,X)) GCN consists of two different graph convolution operations: GConv(A k ,X)=relu(A k X T W gk ) For each graph Execute GCN in parallel to generate d k dimensional output values, which are concatenated and projected to produce the final value: Among them, || indicates that there are K GCN heads in series, and then the graph convolution network uses a feedforward network layer, a normalization layer, and a residual difference connection to enhance the output, which is calculated as follows: It is a two-layer feed-forward network with a relu function between the layers: FFN(x)=max(0,xW f1 +b f1 )W f2 +b f2 Step B43: Generated graph node representation It contains quantity, entities and relationships, and applies element-by-element minimum pooling operation to the learned node representation; finally, the global feature information is input into the fully connected neural network (FFN) to generate the interaction graph representation vector H g :
7. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 6 is characterized in that: The step B5 specifically comprises the following steps: Step B51: The semantic representation vector H obtained through steps B1 and B4 r , interaction graph representation vector H g , respectively from H r and H g The vector s and vector q are obtained in the average pooling operation of H r Between q and H g Apply cross-modal attention between and : The attention score a i ,b i It is calculated as follows: in and is a learnable weight matrix; by applying different weights to different modalities, the output of the intermediate fusion vector is obtained: Step B52: A refined understanding of the question p is achieved by stacking multiple encoders. For the dynamic fusion output of the k-1th layer semantic encoder and the interaction graph encoder, the result of feature stacking is: The attention weight c r and c g And the calculation method is: in, and is a learnable weight matrix, is the input of the K-th encoder combination block, and the output of the K-th encoder combination block is and After completing the K-th step of reasoning, we will get and Connect them together to get the final output representation H final .
8. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 7 is characterized in that: The step B6 specifically comprises the following steps: Step B61: Obtain the interaction diagram from step B3 The edge set E A , from E A Select an edge e with the smallest sequence number ij ; According to the edge e ij Select the relevant entity ent from the entity set ENT i ,ent j ; According to the edge e ij The action attribute action is input into the pre-trained action classifier network to obtain the mathematical operation operator op corresponding to the behavior action and the corresponding inverse operation operator Step B62: Assume that entity ent i The value of the quantity field N is n i Entity j The value of the quantity field N is n j ;Entity i The quantity field N is updated to "n i op num"; the entity ent j The quantity field N is updated to At the same time in the interactive diagram Eliminate edge ij , get the updated new entity ent' i andent' j : Step B63: Interaction diagram Repeat steps B61 and B62 until Get the final image Let the final graph The entity ent' corresponding to each point in i for All new entities after update are combined into a final state entity set 9. The intelligent method for solving mathematical word problems based on problem context understanding according to claim 8, characterized in that: The step B7 specifically includes the following steps: Step B71: The final state complete state entity set ENT obtained in step B6 f Each entity in Input the entity embedder EM to obtain the final state representation of each entity The final state representation of all entities is encoded through the aggregation network to synthesize the final state representation of the entity set H e ; The final encoding fusion vector and the final state representation of the entity set are sent to the sequence generation decoder GM. In the process of generating each word tag, the decoder GM accepts the output of the entity embedder EM and the word embedding of the previous word tag, and decodes the word tag e at the tth time step after performing attention calculation on the two. t ; After connecting all word tags, the final generated mathematical expression E' is obtained p ={e1,e2,...e t }; Step B72: For a given training data set TS = {(P0, E p0 ),(P1,E p1 ),…,(P N ,E pN )}, the entire encoder-decoder model is trained by minimizing the value of the loss function Loss, where the loss function Loss is calculated as follows:
10. An intelligent mathematical word problem solving system based on problem context understanding, characterized in that: The method comprises a memory, a processor, and computer program instructions stored in the memory and executable by the processor. When the processor executes the computer program instructions, the method steps as described in any one of claims 1 to 9 can be implemented.
