A mathematical application problem solving method and system based on multi-path search

By constructing verification questions and a self-correction mechanism, the reasoning path of the large language model is optimized, solving the accuracy problem of solving mathematical word problems in existing technologies, and realizing efficient and accurate generation of answers to mathematical word problems.

CN121809704BActive Publication Date: 2026-05-19UNIV OF JINAN
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UNIV OF JINAN
Filing Date
2026-03-11
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing large language models struggle to accurately capture the dependencies between mathematical expressions in solving mathematical word problems, leading to missing or inconsistent intermediate derivation steps. Furthermore, the lack of a systematic verification mechanism makes it impossible to identify and correct erroneous paths, thus affecting the accuracy of the final result.

Method used

By constructing a verification problem, a mathematical solution model is used to self-verify and correct the initial answer, determine key numerical conditions, calculate consistency, and correct the reasoning path until an accurate answer is obtained. A large language model is used to construct and train the dataset, and a cross-attention mechanism and bundle search are introduced to optimize the reasoning path.

Benefits of technology

It improves the accuracy of solving mathematical word problems, ensures the correctness and logical consistency of the final answer, and enhances the model's ability to model mathematical semantic structures and numerical relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809704B_ABST
    Figure CN121809704B_ABST
Patent Text Reader

Abstract

The application discloses a kind of mathematical application question solving method and system based on multi-path search, belong to problem solving technical field, the method utilizes mathematical solving model to solve mathematical application question, after determining initial answer;Using initial answer replaces key numerical condition in mathematical application question, obtains verification problem;Using mathematical solving model solves verification problem, determines verification problem answer;The consistency between key numerical condition and verification problem answer is calculated, to determine whether initial answer is accurate;When determining that initial answer is not accurate, according to initial answer to construct negative prompt information;Utilize negative prompt information to revise erroneous reasoning path, until the initial answer that mathematical solving model solves is determined to be accurate;The initial answer that is determined to be accurate is used as the final answer of mathematical application question.Accurate solution to mathematical application question is realized, and the problem that current method is not accurate to solve mathematical application question is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of problem-solving technology, and in particular to a method and system for solving mathematical application problems based on multi-path search. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] Solving mathematical word problems is a typical application scenario in the fields of natural language processing and artificial intelligence reasoning. Its core goal is to analyze semantic information and numerical relationships from problems expressed in natural language, and derive the correct answer through logical reasoning and calculation steps.

[0004] Currently, there are methods that utilize large language models to solve mathematical word problems and obtain answers. Existing large language models typically employ Chain-of-Thought (CoT) hint technology to guide the model step-by-step in generating a solution process, thereby simulating human logical reasoning behavior. Multi-path search methods based on this approach generate multiple reasoning paths and perform self-consistency evaluation in the final stage to select an answer that combines consistency and confidence.

[0005] Existing methods still have the following shortcomings when generating inference chains: First, the model has difficulty accurately capturing the dependencies between mathematical expressions, resulting in missing or inconsistent intermediate derivation steps; Second, the inference chains generated by the model lack a systematic verification mechanism, making it impossible to identify and correct erroneous paths through external signals, thus affecting the correctness of the final result. Summary of the Invention

[0006] To address the aforementioned problems, this invention proposes a method and system for solving mathematical word problems based on multi-path search, which improves the accuracy of solving mathematical word problems.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] Firstly, a method for solving mathematical word problems based on multi-path search is proposed, including:

[0009] Get math word problems;

[0010] Using mathematical problem-solving models to solve mathematical word problems and determine the initial answer;

[0011] Identify the key numerical conditions in mathematical word problems;

[0012] Use the initial answer to replace the key numerical conditions in the math word problem to obtain the verification question;

[0013] The verification problem is solved using a mathematical solution model to determine the answer to the verification problem;

[0014] The accuracy of the initial answer is determined by calculating the consistency between the key numerical conditions and the answers to the verification questions.

[0015] When the initial answer is determined to be inaccurate, the reason for the error in the initial answer must be identified;

[0016] Based on the initial answer and the reason for its error, construct negative prompt information;

[0017] The reasoning path of the mathematical solution model is corrected based on negative prompts until the initial answer obtained by the mathematical solution model is determined to be accurate.

[0018] The accurate initial answer is taken as the final answer to the math word problem.

[0019] Furthermore, the process by which the mathematical solution model solves mathematical word problems includes:

[0020] Determine the initial reasoning chain, the structured information of the problem, and the solution instructions for a mathematical word problem;

[0021] Calculate the problem complexity based on the initial inference chain length and the number of intermediate inference nodes, and set the backfill ratio and consistency threshold based on the problem complexity.

[0022] By utilizing structured information, key semantic segments corresponding to the structured information in the initial inference chain are masked and backfilled in multiple steps to obtain the inference chain after each backfilling step.

[0023] Based on the set backfill ratio and consistency threshold, evaluate the logical consistency between the inference chain after each backfill step and the inference chain after the previous backfill step.

[0024] When the evaluation logic is insufficient or the backfill ratio reaches the set backfill ratio threshold, the optimal reasoning path is determined by beam search; based on the optimal reasoning path, the initial answer to the mathematical application problem is generated.

[0025] Furthermore, identify all numerical variables in the mathematical word problem;

[0026] Determine the degree of relevance between each numerical variable and the problem in the math word problem;

[0027] Select the numerical variables with the highest correlation as the key numerical conditions for mathematical word problems.

[0028] Furthermore, the process of determining the reason for the initial answer being incorrect includes:

[0029] While determining the initial answer using a mathematical solution model, a reasoning chain corresponding to the initial answer is generated.

[0030] Based on the reasoning chain corresponding to the initial answer, determine the earliest step in the initial answer where a deviation occurs and the reason for it, which serves as the cause of the initial answer's error.

[0031] Furthermore, the mathematical solution model takes mathematical word problems as input and the corresponding reasoning chain and initial answer as output. It is constructed using a large language model and trained using a training dataset. The training dataset contains multiple training mathematical word problems, each of which is labeled with an answer, solution instructions, and reasoning chain.

[0032] Furthermore, the loss functions used during the training of the mathematical solution model include inference process loss and answer prediction loss.

[0033] Secondly, a mathematical word problem-solving system based on multi-path search is proposed, including:

[0034] The math word problem acquisition unit is used to acquire math word problems;

[0035] The word problem solving unit is used to solve mathematical word problems using a mathematical solution model to determine the initial answer; identify the key numerical conditions in the word problem; replace the key numerical conditions in the word problem with the initial answer to obtain a verification question; solve the verification question using the mathematical solution model to determine the answer to the verification question; calculate the consistency between the key numerical conditions and the verification question answer to determine whether the initial answer is accurate; when the initial answer is determined to be inaccurate, determine the reason for the error; construct negative prompt information based on the initial answer and the reason for the error; correct the reasoning path of the mathematical solution model based on the negative prompt information until the initial answer obtained by the mathematical solution model is determined to be accurate; and use the initial answer determined to be accurate as the final answer to the word problem.

[0036] Thirdly, a computer device is proposed, the device comprising:

[0037] A processor, adapted to execute computer programs;

[0038] A computer-readable storage medium storing a computer program, which, when executed by the processor, implements a method for solving mathematical application problems based on multi-path search as proposed in the first aspect.

[0039] Fourthly, a computer-readable storage medium is proposed, which stores a computer program adapted for loading and execution by a processor of a method for solving mathematical application problems based on multi-path search proposed in the first aspect.

[0040] Fifthly, a computer program product is proposed, which includes a computer program that, when executed by a processor, implements a method for solving mathematical application problems based on multi-path search proposed in the first aspect.

[0041] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0042] This invention proposes a method and system for solving mathematical word problems based on multi-path search. The method uses a mathematical model to solve the mathematical word problem and determines an initial answer. Then, it replaces key numerical conditions in the problem with the initial answer to obtain a verification question. The verification question is then solved to obtain its answer. The accuracy of the initial answer is determined by calculating the consistency between the key numerical conditions and the verification question answer. If the initial answer is determined to be inaccurate, the mathematical solution model analyzes the location and cause of the error and corrects the erroneous reasoning path until the answer obtained by the mathematical solution model is determined to be accurate. The accurate answer is then used as the final answer to the mathematical word problem, thus ensuring the accuracy of the solution.

[0043] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0044] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.

[0045] Figure 1 This is a flowchart of a mathematical application problem-solving method based on multi-path search proposed in an embodiment of the present invention;

[0046] Figure 2 This is a schematic diagram of the data synthesis process proposed in an embodiment of the present invention;

[0047] Figure 3 This is a schematic diagram illustrating the fine-tuning process of the instruction-based large language model proposed in an embodiment of the present invention;

[0048] Figure 4 This is a schematic diagram of the self-correction process based on verification signals proposed in an embodiment of the present invention;

[0049] Figure 5 This is a flowchart of a mathematical application problem-solving method based on multi-path search proposed in an embodiment of the present invention. Detailed Implementation

[0050] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0051] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0052] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0053] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.

[0054] First, the terms used in the embodiments of this invention will be explained:

[0055] MWP problems are mathematical problems described in natural language that require solvers to reason and calculate based on the textual information provided in the problem to arrive at the answer.

[0056] Large language models are a type of large-scale natural language processing model based on deep learning, which uses a huge amount of corpus data and a large number of parameters during training.

[0057] Fine-tuning: Transferring the learning patterns and features of a pre-trained model to a new task, thereby improving performance and reducing the need for training data.

[0058] Next, the application scenarios of the mathematical word problem solving method based on multi-path search proposed in the embodiments of the present invention will be described.

[0059] The present invention proposes a method for solving mathematical word problems based on multi-path search, which is applied to the application scenario of solving mathematical word problems.

[0060] Solving mathematical word problems is a typical application scenario in the fields of natural language processing and artificial intelligence reasoning. Its core goal is to analyze semantic information and numerical relationships from problems expressed in natural language, and derive the correct answer through logical reasoning and calculation steps.

[0061] Existing large language models typically utilize Chain-of-Thought (CoT) prompting technology to guide the model through a step-by-step problem-solving process, thereby simulating human logical reasoning. Multi-path search methods based on this approach generate multiple reasoning paths and perform self-consistency evaluation in the final stage to select an answer that combines consistency and confidence. While this method improves the model's reasoning ability and robustness to some extent, it relies heavily on the large language model's own generation and comparison mechanisms, lacking external feedback and dynamic error correction capabilities. When dealing with complex mathematical application problems with diverse conditions, the model is prone to reasoning interruptions, logical confusion, or calculation errors, resulting in insufficient generalization ability.

[0062] To improve the mathematical reasoning ability of models, some studies have attempted to employ data synthesis techniques, constructing task-related training samples through algorithms or model generation, and using these samples to perform supervised fine-tuning (SFT) on large language models. This method can enhance the model's ability to model mathematical semantic structures and numerical relationships. However, the solution process for mathematical word problems usually involves multiple steps of formula derivation and logical connections. Existing methods still have the following shortcomings in generating reasoning chains: First, the model struggles to accurately capture the dependencies between mathematical expressions, leading to missing or inconsistent intermediate derivation steps; second, the reasoning chains generated by the model lack a systematic verification mechanism, making it impossible to identify and correct erroneous paths through external signals, thus affecting the correctness of the final result.

[0063] To accurately solve mathematical word problems and obtain their answers, this invention proposes a method for solving mathematical word problems based on multi-path search, such as... Figures 1-5 As shown, it includes:

[0064] Get math word problems;

[0065] Using mathematical problem-solving models to solve mathematical word problems and determine the initial answer;

[0066] Identify the key numerical conditions in mathematical word problems;

[0067] Use the initial answer to replace the key numerical conditions in the math word problem to obtain the verification question;

[0068] The verification problem is solved using a mathematical solution model to determine the answer to the verification problem;

[0069] The accuracy of the initial answer is determined by calculating the consistency between the key numerical conditions and the answers to the verification questions.

[0070] When the initial answer is determined to be inaccurate, the reason for the error in the initial answer must be identified;

[0071] Based on the initial answer and the reason for its error, construct negative prompt information;

[0072] The reasoning path of the mathematical solution model is corrected based on negative prompts until the initial answer obtained by the mathematical solution model is determined to be accurate.

[0073] The accurate initial answer is taken as the final answer to the math word problem.

[0074] The present invention proposes a method for solving mathematical application problems based on multi-path search. By constructing a verification problem, the method achieves self-verification and correction of the initial answer, thereby obtaining an accurate final answer.

[0075] The process of determining the key numerical conditions for a mathematical word problem includes:

[0076] Identify all numerical variables in a mathematical word problem;

[0077] Determine the degree of relevance between each numerical variable and the problem in the math word problem;

[0078] Select the numerical variables with the highest correlation as the key numerical conditions for mathematical word problems.

[0079] The process of solving mathematical word problems using a mathematical solution model includes:

[0080] Determine the initial reasoning chain, the structured information of the problem, and the solution instructions for a mathematical word problem;

[0081] Calculate the problem complexity based on the initial inference chain length and the number of intermediate inference nodes, and set the backfill ratio and consistency threshold based on the problem complexity.

[0082] By utilizing structured information, key semantic segments corresponding to the structured information in the initial inference chain are masked and backfilled in multiple steps to obtain the inference chain after each backfilling step.

[0083] Based on the set backfill ratio and consistency threshold, evaluate the logical consistency between the inference chain after each backfill step and the inference chain after the previous backfill step.

[0084] When the evaluation logic is insufficient or the backfill ratio reaches the set backfill ratio threshold, the optimal reasoning path is determined by bundle search; based on the optimal reasoning path, the answer to the mathematical word problem is generated.

[0085] The solution to a math word problem is generated into a solution that conforms to the format of the math word problem solution instruction, and this solution is used as the initial answer to the math word problem.

[0086] The mathematical solution model of this invention takes mathematical word problems as input and outputs the corresponding reasoning chain and initial answer. It is constructed using a large language model and trained using a training dataset. The training dataset contains multiple training mathematical word problems, each of which is labeled with an answer, solution instructions and reasoning chain.

[0087] This invention obtains a mathematical solution model through two stages: a data synthesis stage and a large language model fine-tuning stage. The data synthesis stage is used to determine the answers and reasoning chains of the training mathematical word problems, forming a training dataset. The large language model fine-tuning stage uses the training dataset to train and fine-tune the large language model. After training is completed, the trained large language model is used as the mathematical solution model.

[0088] like Figure 3 As shown, the training process of the mathematical solution model includes:

[0089] After obtaining the raw data of the training math word problems, the raw data is preprocessed to extract the questions and numerical answers of the training math word problems, and the numerical answers are cleaned.

[0090] Among them, cleaning numerical answers refers to automatically recognizing and converting decimal, fraction, percentage and other formats in numerical answers into standard floating-point number format using unified rules.

[0091] Next, the initial reasoning chain of the training math word problem is determined, and the problem complexity of the training math word problem is calculated based on the length of the initial reasoning chain and the number of intermediate reasoning nodes.

[0092] Determine the backfill ratio and consistency threshold based on the complexity of the problem;

[0093] Based on the backfill ratio and consistency threshold, determine whether the logical consistency between each completion result and the previous completion result is sufficient, and whether the backfill ratio reaches the threshold.

[0094] The length of the initial inference chain is determined by the number of explicit inference steps in the initial inference chain.

[0095] The number of intermediate reasoning nodes refers to the number of reasoning steps in the initial reasoning chain, excluding the initial conditions and the final answer, used to introduce intermediate conclusions, variables, or sub-problems.

[0096] Problem complexity increases with the length of the initial inference chain and the number of intermediate inference nodes, and the backfill ratio and logical consistency threshold of the inference chain are adaptively adjusted based on problem complexity.

[0097] (1);

[0098] in, Indicates the complexity of the problem. , All are weighted parameters. The length of the initial inference chain. This represents the number of intermediate inference nodes.

[0099] The training dataset was then obtained through inference chain backfilling and self-evaluation-guided bundle search.

[0100] In this embodiment of the invention, a program-assisted large language model is used to extract noun concepts and numerical relationships from the problem text of training mathematical word problems, and the extracted noun concepts and numerical relationships are used as the structured information of the problems of training mathematical word problems.

[0101] (2);

[0102] (3);

[0103] in, Problems for training in mathematical word problems, This represents the corresponding executable program. For the set of noun concepts in the problem, This is the set of numerical variables in the problem.

[0104] Among them, the program-assisted large language model is a hybrid reasoning model that integrates large language model generation and program execution verification. Specifically, the large language model is used to generate candidate results of noun concepts and numerical relationships from the question text. The program execution module then verifies these candidate results based on preset structural constraint rules, numerical consistency rules, or logical constraint conditions to obtain the structured information of the final training mathematical word problem.

[0105] This invention utilizes a large language model to mask key semantic segments in the initial inference chain corresponding to structured information, thereby obtaining the masked inference chain. .

[0106] Key semantic segments refer to word sequences or semantic units in the initial inference chain that directly correspond to noun concepts or numerical relationships in structured information.

[0107] (4);

[0108] (5);

[0109] Among them, in the initial inference chain and the problem Under these conditions, the Large Language Model (LLM) automatically identifies the locations of key semantic segments in the inference chain and generates a set of masking tags. The set of locations to be shielded as needed. From the initial inference chain, obtain the concealed inference chain. .

[0110] This invention introduces a cross-attention mechanism to jointly model the contextual representation and structured information of the obscured semantic fragments, thereby completing the inference chain. Based on the backfill ratio and consistency threshold, the logical consistency between the determined completion result and adjacent inference steps is evaluated.

[0111] Among them, the cross-attention mechanism refers to the mechanism of dynamically paying attention to and utilizing the key semantic judgments of another sequence during the generation of the current sequence by a large language model, thereby achieving semantic alignment between the two sequences.

[0112] (6);

[0113] (7);

[0114] In the formula, This represents the obscured chain of reasoning. This refers to math word problems used for training purposes. This indicates that the model is backfilled to the first... At position , the hidden state representation of the current inference chain. Indicate the problem The corresponding hidden state matrix is ​​used to provide external semantic information. and These represent the query mapping matrix and the key mapping matrix, respectively, used to represent the hidden state of the current backfill position. and Projected onto the same semantic subspace, This represents the dimension of the projected vector. This represents the conditional probability distribution of the word generated at the current position during the backfilling inference chain process. This indicates the number of pages that need to be filled in. Candidate words corresponding to each position To achieve the optimal backfilling result, deterministic backfilling of the currently obscured location is implemented.

[0115] After each backfilling step is completed, the logical consistency between the reasoning chain after the backfilling step and the reasoning steps after the previous backfilling step is evaluated to ensure the semantic coherence and logical consistency of the reasoning process:

[0116] (8);

[0117] in, Indicates the first The reasoning chain is completed after backfilling, and Indicates the first The logical consistency score corresponding to each step.

[0118] If the evaluation logic consistency is satisfied and the backfill ratio does not reach the set backfill ratio threshold, the next step of inference chain backfilling will continue.

[0119] If the evaluation logic is not consistent enough or the backfill ratio reaches the set backfill ratio threshold, the large language model performs a bundle search based on the backfilled part of the reasoning chain and the self-evaluation score to obtain the optimal reasoning path, and generates the reasoning chain and answer of the data application problem based on the optimal reasoning path.

[0120] Specifically, when the logical consistency is greater than or equal to the set consistency threshold, the logical consistency is deemed to be satisfied; when the logical consistency is less than the set consistency threshold, the logical consistency is deemed to be insufficient.

[0121] The self-evaluation score is obtained by weighted fusion of generation probability and correctness confidence. It is used to evaluate the logical consistency, correctness and credibility of multiple candidate reasoning paths generated by the large language model during the reasoning process. It serves as an evaluation label for candidate reasoning paths and is used to rank and filter candidate reasoning paths during the bundle search process.

[0122] (9);

[0123] in, Indicates the first t One reasoning step, This represents the confidence level of correctness at step t. Indicated by the evaluation model Parameterized conditional probability distribution This indicates the input to the evaluation model. Assessment prompt template, The evaluation label represents the generated result. For input questions, Indicates from step 1 to step 2. t The candidate inference paths generated step by step.

[0124] (10);

[0125] in, Indicates from step 1 to step 2. t Self-assessment scores of candidate reasoning paths. For input questions, This represents the generation probability of a large language model. Indicates the first t The confidence level of the correctness of the step. Weighting parameters to balance generation probability and correctness confidence.

[0126] During the beam search process, the large language model expands all current candidate reasoning paths, calculates all possible next outputs, and performs probabilistic sampling of candidate reasoning paths based on the sampling probability distribution constructed from self-evaluation scores. The top k candidate reasoning paths are retained for further expansion, thereby achieving a balance between the exploratory and optimal aspects of the generation process.

[0127] The model generates answers by searching the self-evaluation-guided bundle. It prioritizes retaining candidate reasoning paths with higher scores and reduces the retention of low-quality reasoning paths, thereby suppressing the accumulation and propagation of errors in the reasoning process. The reasoning path with the highest self-evaluation score is selected as the optimal reasoning path. The answer corresponding to the optimal reasoning path is used as the final generated answer. The generated answer is compared with the original answer to determine whether the generated answer is accurate.

[0128] This invention converts self-assessment scores into a sampling probability distribution for probabilistic selection during the path expansion phase of the beam search. While maintaining the priority of high-scoring candidate paths, controlled randomness is introduced to prevent the search process from prematurely converging to a single path. The definition is as follows:

[0129] (11);

[0130] in, Indicates the first During the step path expansion process, candidate inference paths The sampling probability selected for subsequent expansion. Indicates from step 1 to step 2. t The self-evaluation score of the step-by-step reasoning path is obtained by weighting the generation probability and the correctness confidence. This represents a temperature parameter used to adjust the smoothness of the sampling distribution.

[0131] In this embodiment of the invention, the numerical difference between the answer generated by the large language model and the answer labeled by the training mathematical application problem is calculated. If the numerical difference is less than a set error threshold, the generated answer is considered to be correct. The error threshold can be set to 1e-2.

[0132] If the generated answer is correct, the question, the reasoning chain generated by the large language model, and the answer are combined into training data according to a preset format and added to the training dataset.

[0133] In constructing the training dataset, this embodiment of the invention also adds a solution instruction with a task objective to each training sample, guiding the large language model to generate according to a unified problem-solving format;

[0134] The task objectives include: first, outputting a clear and explainable thought process; second, unfolding the reasoning steps in logical order; and finally, outputting the final numerical answer on a new line with "####" as a prefix.

[0135] Then, the large language model is fine-tuned using the solution instructions in the training dataset. According to the solution instructions and the preset task objectives, the large language model generates a logically rigorous and clearly structured reasoning chain, thereby obtaining the final answer to the training mathematical word problem.

[0136] Fine-tuning, or instruction fine-tuning, involves further training a large language model on a training dataset consisting of "instruction-response" pairs through supervised learning, and updating some parameters.

[0137] The response refers to the standardized solution output generated by the model after receiving the solution instructions, including a clear thought process, logical reasoning steps, and a formatted numerical answer.

[0138] The loss function used in training the mathematical solution model in this embodiment of the invention includes inference process loss and answer prediction loss. During the training process, by jointly optimizing the inference process loss and answer prediction loss, the model is guided to learn reliable inference patterns and accurate final answers at the same time.

[0139] The embodiments of the present invention employ a supervised learning approach, which fine-tunes a small-parameter language model based on a constructed training dataset. By simultaneously constraining the reasoning process and the answer output, the model is made capable of solving mathematical word problems.

[0140] The loss function consists of two parts, expressed as:

[0141] (12);

[0142] in, L For the total loss, This indicates the number of samples in the training batch. The cross-entropy, representing the loss during the inference process, is calculated over the text portion of the inference chain. The loss represents the prediction loss for the answer, calculated as the cross-entropy over the final answer portion. and These are the weighting coefficients. The first part of this loss function learns interpretive reasoning, and the second part learns the accuracy of the answers.

[0143] The loss during the inference process is specifically represented as follows:

[0144] (13);

[0145] in, This represents the set of tokens for the reasoning part. It is determined by parameters Parameterized language model Represents the parameters of the model. Indicates the first i The first sample t One output, This represents all output tokens preceding the current token. Represents the input sequence;

[0146] The answer prediction loss is expressed as:

[0147] (14);

[0148] in, This represents the set of tokens for the answer portion. This represents the t-th output of the i-th sample. This represents all output tokens preceding the current token. This represents the input sequence.

[0149] This invention also tests the mathematical solution model using a test problem. During the testing phase, the mathematical solution model is used to solve a test mathematical word problem; this problem is called the test problem. Generate a preliminary reasoning chain and the initial answer , represented as ;

[0150] By identifying key numerical conditions in the test problem through mathematical solution models, verification problems are constructed, including:

[0151] The mathematical solution model identifies all numerical variables in the test problem, and determines the relationship between each numerical variable and the test problem. Degree of correlation, find key numerical conditions .

[0152] In this embodiment of the invention, the cosine similarity between numerical variables and test questions is calculated to characterize the degree of correlation between the numerical variables and test questions, and the numerical variable with the highest degree of correlation is selected as the key numerical condition of the test question.

[0153] (15);

[0154] in, Indicates the first test question j Numerical variables, m To test the number of numerical variables in the problem, Calculate numerical variables and testing issues The cosine similarity between the vector representations of the two vectors. It is a selection and testing problem The most relevant numerical variables are the key numerical conditions of the test problem.

[0155] Use the initial answer to replace the key numerical conditions in the test problem to construct a validation problem.

[0156] (16);

[0157] (17);

[0158] in, The vector representation of the constructed verification problem, This represents the textual representation of the problem after removing key numerical conditions. This represents the initial answer.

[0159] The verification problem is solved using a mathematical solution model, and the answer to the verification problem is obtained. The system calculates the consistency between key numerical conditions and the answers to verification questions to determine whether the initial answer is accurate.

[0160] (18);

[0161] (19);

[0162] In the formula, Indicates key numerical conditions. This indicates that the answer to the question has been verified.

[0163] If the initial answer is incorrect, the mathematical solution model determines the reason for the error. The process of determining the reason for the error in the initial answer includes:

[0164] While determining the initial answer using a mathematical solution model, a reasoning chain corresponding to the initial answer is generated.

[0165] Based on the reasoning chain corresponding to the initial answer, determine the earliest step in the initial answer where a deviation occurs and the reason for it, which serves as the cause of the initial answer's error.

[0166] Specifically, when the initial answer is incorrect, the mathematical solution model further performs a consistency check on the reasoning chain it generates. By analyzing whether the intermediate variables satisfy the constraints between the preceding and following steps in the reasoning process, as well as the logical consistency between adjacent reasoning steps, it determines the earliest step that shows a deviation and the reason for the error.

[0167] The initial incorrect answer and the reason for the error are combined into an error dataset, which is used for subsequent model error correction and inference strategy optimization.

[0168] Based on the error reasons and their corresponding incorrect initial answers recorded in the error dataset, negative prompts are generated to explicitly indicate that the reasoning steps and answers previously identified as incorrect have been determined to be wrong. This guides the model to avoid repeating the same erroneous reasoning paths in subsequent reasoning processes, generating corrected initial answers, and re-evaluating their correctness.

[0169] Among them, the negative prompt message is a negative prompt message constructed from the error dataset. ,in, This indicates a negative message. Indicate the reason why the initial answer is incorrect. An incorrect initial answer is used to inform the mathematical solution model that some reasoning steps or answers may be wrong, thereby guiding the mathematical solution model to make corrections.

[0170] This embodiment of the invention also sets a maximum number of corrections. When the maximum number of corrections is reached, the mathematical solution model outputs the currently generated answer as the final answer to the test question.

[0171] This invention proposes a multi-path search-based method for solving mathematical application problems, comprising three stages: data synthesis, large language model fine-tuning, and self-correction. First, in the data synthesis stage, the problem complexity is calculated based on the length of the inference chain and the number of intermediate inference nodes, and a backfilling ratio and consistency threshold are set based on this complexity. A program-assisted language model is used to extract noun concepts and numerical relationships from the problem text, treating them as structured information. Key semantic segments corresponding to this structured information are masked within the inference chain. Subsequently, a cross-attention mechanism is introduced to jointly model the contextual representation of the masked semantic segments with the structured information, achieving inference chain completion and evaluating the logical consistency between the completed result and adjacent inference steps. When consistency is insufficient or the backfilling ratio reaches the set threshold, the model selects candidate inference paths through self-evaluation-guided beam search, synthesizing a training dataset. Second, in the large language model fine-tuning stage, based on the constructed training dataset, a parameter-efficient fine-tuning strategy is used to train the large language model, and the inference process loss and answer prediction loss are jointly optimized, guiding the model to simultaneously learn reliable inference patterns and accurate final answers. Finally, the fine-tuned large language model is used to solve mathematical word problems. The correctness of the generated results is verified by constructing verification problems, and the model is self-corrected based on the verification results to obtain the final answer.

[0172] This invention also proposes a mathematical word problem solving system based on multi-path search, comprising:

[0173] The math word problem acquisition unit is used to acquire math word problems;

[0174] The word problem solving unit is used to solve mathematical word problems using a mathematical solution model to determine the initial answer; identify the key numerical conditions in the word problem; replace the key numerical conditions in the word problem with the initial answer to obtain a verification question; solve the verification question using the mathematical solution model to determine the answer to the verification question; calculate the consistency between the key numerical conditions and the verification question answer to determine whether the initial answer is accurate; when the initial answer is determined to be inaccurate, determine the reason for the error; construct negative prompt information based on the initial answer and the reason for the error; correct the reasoning path of the mathematical solution model based on the negative prompt information until the initial answer obtained by the mathematical solution model is determined to be accurate; and use the initial answer determined to be accurate as the final answer to the word problem.

[0175] It should be noted that the above-described embodiment of a multi-path search-based mathematical word problem solving system is only illustrated by the division of the functional modules described above. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the multi-path search-based mathematical word problem solving system and the multi-path search-based mathematical word problem solving method embodiment belong to the same concept, and their specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0176] The present invention also discloses a computer device, the device comprising:

[0177] A processor, adapted to execute computer programs;

[0178] A computer-readable storage medium storing a computer program, which, when executed by the processor, implements a method for solving mathematical application problems based on multi-path search disclosed in an embodiment of the present invention.

[0179] The present invention also discloses a computer-readable storage medium storing a computer program adapted for loading and execution by a processor of a method for solving mathematical application problems based on multi-path search disclosed in the embodiments of the present invention.

[0180] The present invention also discloses a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements a method for solving mathematical application problems based on multi-path search disclosed in the embodiments of the present invention.

[0181] The method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.

[0182] Those skilled in the art will recognize that the units and algorithm steps described in conjunction with the embodiments herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0183] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. A method for solving mathematical word problems based on multi-path search, characterized in that, include: Get math word problems; Using mathematical problem-solving models to solve mathematical word problems and determine the initial answer; The mathematical solution model solves mathematical word problems by including the following process: Determine the initial reasoning chain, the structured information of the problem, and the solution instructions for a mathematical word problem; Calculate the problem complexity based on the initial inference chain length and the number of intermediate inference nodes, and set the backfill ratio and consistency threshold based on the problem complexity. By utilizing structured information, key semantic segments corresponding to the structured information in the initial inference chain are masked and backfilled in multiple steps to obtain the inference chain after each backfilling step. Based on the set backfill ratio and consistency threshold, evaluate the logical consistency between the inference chain after each backfill step and the inference chain after the previous backfill step. When the evaluation logic is insufficient or the backfill ratio reaches the set backfill ratio threshold, the optimal reasoning path is determined by beam search; based on the optimal reasoning path, the initial answer to the mathematical word problem is generated. Identify the key numerical conditions in mathematical word problems; Use the initial answer to replace the key numerical conditions in the math word problem to obtain the verification question; The verification problem is solved using a mathematical solution model to determine the answer to the verification problem; The accuracy of the initial answer is determined by calculating the consistency between the key numerical conditions and the answers to the verification questions. When the initial answer is determined to be inaccurate, the reason for the error in the initial answer must be identified; Based on the initial answer and the reason for its error, construct negative prompt information; The reasoning path of the mathematical solution model is corrected based on negative prompts until the initial answer obtained by the mathematical solution model is determined to be accurate. The accurate initial answer is taken as the final answer to the math word problem.

2. The method for solving mathematical word problems based on multi-path search as described in claim 1, characterized in that, Identify all numerical variables in a mathematical word problem; Determine the degree of relevance between each numerical variable and the problem in the math word problem; Select the numerical variables with the highest correlation as the key numerical conditions for mathematical word problems.

3. The method for solving mathematical application problems based on multi-path search as described in claim 1, characterized in that, The mathematical solution model takes mathematical word problems as input and outputs the corresponding reasoning chain and initial answer. It is constructed using a large language model and trained using a training dataset. The training dataset contains multiple training mathematical word problems, each labeled with an answer, solution instructions, and reasoning chain.

4. The method for solving mathematical application problems based on multi-path search as described in claim 3, characterized in that, The loss functions used in training mathematical solution models include inference process loss and answer prediction loss.

5. The method for solving mathematical word problems based on multi-path search as described in claim 1, characterized in that, The process of determining why the initial answer is wrong includes: While determining the initial answer using a mathematical solution model, a reasoning chain corresponding to the initial answer is generated. Based on the reasoning chain corresponding to the initial answer, determine the earliest step in the initial answer where a deviation occurs and the reason for it, which serves as the cause of the initial answer's error.

6. A mathematical word problem solving system based on multi-path search, characterized in that, include: The math word problem acquisition unit is used to acquire math word problems; The word problem solving unit is used to solve mathematical word problems using mathematical problem-solving models and determine the initial answer; The mathematical solution model solves mathematical word problems by including the following process: Determine the initial reasoning chain, the structured information of the problem, and the solution instructions for a mathematical word problem; Calculate the problem complexity based on the initial inference chain length and the number of intermediate inference nodes, and set the backfill ratio and consistency threshold based on the problem complexity. By utilizing structured information, key semantic segments corresponding to the structured information in the initial inference chain are masked and backfilled in multiple steps to obtain the inference chain after each backfilling step. Based on the set backfill ratio and consistency threshold, evaluate the logical consistency between the inference chain after each backfill step and the inference chain after the previous backfill step. When the evaluation logic is insufficient or the backfill ratio reaches the set backfill ratio threshold, the optimal reasoning path is determined by beam search; based on the optimal reasoning path, the initial answer to the mathematical word problem is generated. Identify the key numerical conditions in the math word problem; replace the key numerical conditions with the initial answer to obtain the verification question; solve the verification question using a mathematical solution model to determine the answer; calculate the consistency between the key numerical conditions and the verification question answer to determine the accuracy of the initial answer; if the initial answer is determined to be inaccurate, determine the reason for the error; construct negative prompts based on the initial answer and the reason for the error; correct the reasoning path of the mathematical solution model based on the negative prompts until the initial answer obtained by the mathematical solution model is determined to be accurate; use the accurate initial answer as the final answer to the math word problem.

7. An electronic device, characterized in that, The device includes: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, implements the method for solving mathematical application problems based on multi-path search as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading and execution by a processor of the method for solving mathematical application problems based on multi-path search as described in any one of claims 1-5.

9. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method for solving mathematical application problems based on multi-path search as described in any one of claims 1-5.