CN-122021888-A - Mathematical problem solving method and related device based on progressive correction
Abstract
The invention belongs to the field of artificial intelligence, and discloses a mathematical problem solving method based on progressive correction and a related device. The verification step adopts an alternative verification method, namely, known numerical masks are substituted into the current answer to carry out reverse thrust, and the results are compared to verify the correctness of the answer. If the answer is correct, the answer is output as a final answer, and if the answer is wrong, the answer is added into a wrong set. The correction step uses the found wrong answer as constraint prompt to guide the large language model to avoid repeated errors and generate new answers until the answers pass verification or reach a preset iteration upper limit. The invention realizes early identification and correction of reasoning errors by constructing a closed loop iteration mechanism of error finding-error removing-re-reasoning, and effectively improves the accuracy and calculation efficiency of solving mathematical application problems.
Inventors
- SHEN CHAO
- WU ZHENYU
- LIN CHENHAO
- ZHANG LI
Assignees
- 西安交通大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260119
Claims (10)
- 1. A mathematical problem solving method based on progressive correction, comprising: Acquiring a mathematical application question to be solved, and generating an initial answer of the mathematical application question to be solved through a preset large language model; The method comprises the steps of carrying out iteration to obtain a final answer of a mathematic application question to be solved, wherein the step of verifying comprises the steps of adopting a replacement verification method to verify the correctness of the current answer according to the current answer of the mathematic application question to be solved, taking the current answer as the final answer when the correctness verification result of the current answer is correct, adding the current answer to an error answer set when the correctness verification result of the current answer is wrong, and the step of correcting comprises the steps of obtaining the current iteration times, taking the current answer as the final answer when the current iteration times are larger than a preset iteration times threshold value, and otherwise taking the error answer set as a constraint prompt, and generating the current answer of the mathematic application question to be solved through a preset large language model.
- 2. The progressive correction-based mathematical problem solving method as claimed in claim 1, wherein the generating an initial answer of the mathematical application problem to be solved by a preset large language model comprises: Replacing a problem placeholder in a preset reasoning generation prompt template with the to-be-solved mathematical application problem, generating a reasoning generation prompt of the to-be-solved mathematical application problem, and inputting the reasoning generation prompt of the to-be-solved mathematical application problem into a preset large language model to obtain a reasoning path of the to-be-solved mathematical application problem; replacing an inference path placeholder in a preset answer extraction prompt template by using an inference path of the to-be-solved mathematical application question, generating an answer extraction prompt of the to-be-solved mathematical application question, and inputting the answer extraction prompt of the to-be-solved mathematical application question into a preset large language model to obtain an initial answer of the to-be-solved mathematical application question.
- 3. The progressive correction-based mathematical problem solving method as claimed in claim 1, wherein said verifying the correctness of the current answer using an alternate verification method comprises: randomly selecting a known value in the to-be-solved mathematical application questions, masking the selected known value by adopting a preset mark, and generating a masking problem of the to-be-solved mathematical application questions; Replacing a mask problem placeholder in a preset verification problem template with a mask problem of the mathematical application problem to be solved, and replacing a current answer placeholder in the preset verification problem template with a current answer of the mathematical application problem to be solved to generate a verification problem, wherein the verification problem template comprises the mask problem placeholder, an answer prompt prefix, the current answer placeholder and a preset mark solution problem which are sequentially combined; replacing a problem placeholder in a preset reasoning generation prompt template by using the verification problem, generating a reasoning generation prompt of the verification problem, and inputting the reasoning generation prompt of the verification problem into a preset large language model to obtain a reasoning path of the verification problem; Replacing an inference path placeholder in a preset answer extraction prompt template by using an inference path of the verification question, generating an answer extraction prompt of the verification question, and inputting the answer extraction prompt of the verification question into a preset large language model to obtain a solving result of a preset mark; Comparing the solving result of the preset mark with the selected known value, and if the solving result and the selected known value are consistent, verifying the correctness of the current answer to be correct, otherwise, verifying the correctness of the current answer to be incorrect.
- 4. The mathematical problem solving method based on progressive correction according to claim 2 or 3, wherein the reasoning generation prompt template is a question prefix, a question placeholder, an answer prefix and a chain reasoning instruction which are sequentially combined, wherein the chain reasoning instruction is used for indicating a large language model to conduct chain reasoning and output a reasoning path, the answer extraction prompt template is a reasoning path placeholder and an answer extraction instruction which are sequentially combined, and the answer extraction instruction is used for indicating the large language model to extract an answer according to a preset format.
- 5. The progressive correction-based mathematical problem solving method as claimed in claim 1, wherein the generating the current answer of the mathematical application problem to be solved by using the wrong answer set as a constraint prompt through a preset large language model comprises: Replacing a problem placeholder in a preset answer correction reasoning prompt template by using the to-be-solved mathematical application questions, replacing the wrong answer placeholder in the preset answer correction reasoning prompt template by using a wrong answer set, generating a correction reasoning prompt of the to-be-solved mathematical application questions, and inputting the correction reasoning prompt of the to-be-solved mathematical application questions into a preset large language model to obtain a correction reasoning path of the to-be-solved mathematical application questions; Replacing an inference path placeholder in a preset answer extraction prompt template by adopting a correction inference path of the to-be-solved mathematical application question, generating a correction answer extraction prompt of the to-be-solved mathematical application question, and inputting the correction answer extraction prompt of the to-be-solved mathematical application question into a preset large language model to obtain a current answer of the to-be-solved mathematical application question.
- 6. The method for solving a mathematical problem based on progressive correction as claimed in claim 5, wherein the answer correction reasoning prompt template is a sequentially combined question prefix, a question placeholder, an exclusion prompt prefix, a wrong answer placeholder, an answer prefix and a chain reasoning instruction.
- 7. A mathematical problem solving system based on progressive correction, comprising: the initial solving module is used for acquiring the mathematic application questions to be solved and generating initial answers of the mathematic application questions to be solved through a preset large language model; the method comprises an iteration solving module, a correction step and a correction step, wherein the iteration solving module is used for carrying out iteration to obtain a final answer of a mathematic application question to be solved, the verification step comprises the steps of adopting an alternative verification method to verify the correctness of the current answer according to the current answer of the mathematic application question to be solved, taking the current answer as the final answer when the correctness verification result of the current answer is correct, adding the current answer to an error answer set when the correctness verification result of the current answer is incorrect, the correction step comprises the steps of obtaining the current iteration times, taking the current answer as the final answer when the current iteration times are greater than a preset iteration times threshold value, and otherwise taking the error answer set as a constraint prompt, and generating the current answer of the mathematic application question to be solved through a preset large language model.
- 8. The progressive correction-based mathematical problem solving system of claim 7, wherein said employing an alternative verification method to verify the correctness of the current answer comprises: randomly selecting a known value in the to-be-solved mathematical application questions, masking the selected known value by adopting a preset mark, and generating a masking problem of the to-be-solved mathematical application questions; Replacing a mask problem placeholder in a preset verification problem template with a mask problem of the mathematical application problem to be solved, and replacing a current answer placeholder in the preset verification problem template with a current answer of the mathematical application problem to be solved to generate a verification problem, wherein the verification problem template comprises the mask problem placeholder, an answer prompt prefix, the current answer placeholder and a preset mark solution problem which are sequentially combined; replacing a problem placeholder in a preset reasoning generation prompt template by using the verification problem, generating a reasoning generation prompt of the verification problem, and inputting the reasoning generation prompt of the verification problem into a preset large language model to obtain a reasoning path of the verification problem; Replacing an inference path placeholder in a preset answer extraction prompt template by using an inference path of the verification question, generating an answer extraction prompt of the verification question, and inputting the answer extraction prompt of the verification question into a preset large language model to obtain a solving result of a preset mark; Comparing the solving result of the preset mark with the selected known value, and if the solving result and the selected known value are consistent, verifying the correctness of the current answer to be correct, otherwise, verifying the correctness of the current answer to be incorrect.
- 9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the progressive correction based mathematical problem solving method according to any of claims 1 to 6 when the computer program is executed.
- 10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the mathematical problem solving method based on progressive correction as claimed in any one of claims 1 to 6.
Description
Mathematical problem solving method and related device based on progressive correction Technical Field The invention belongs to the field of artificial intelligence, and relates to a mathematical problem solving method based on progressive correction and a related device. Background Automatic solution of mathematical application questions (Math Word Problems, MWPs) requires that the system possess linguistic understanding, mathematical reasoning, and problem solving capabilities. The automatic solution of research mathematics application questions helps develop algorithms and models that can simulate human reasoning and problem solving capabilities. In recent years, a large language model is combined with a chained reasoning prompt method, and the complex problem solving capability of the model is remarkably improved through generating a reasoning process of thinking step by step, so that the method becomes a current mainstream technical path. The Chain-of-Thought, coT, hint method helps the large language model (Large Language Models, LLMs) to solve each sub-problem step by decomposing the complex problem into a number of simple sub-problems, thus completing the solution of the complex problem. However, the combined accuracy of the existing solution method on multiple standard data sets is only 77.3% on average, and the minimum 90% reliability standard required by practical application is far from being reached. This is mainly due to three fundamental drawbacks of the existing solving method, namely 1, lack of a mechanism for verifying the correctness of the answer, 2, lack of a mechanism for finding errors and correcting to find the correct answer, and 3, lack of an effective method for gradually optimizing the reasoning path. Specifically, regarding the lack of a mechanism for verifying the correctness of an answer, the existing solving method generally considers the most consistent answer as a correct answer by repeatedly solving the problem and adopting a crowding strategy, and this method is called self-consistency. However, since the same problem is solved independently a plurality of times, the process is easily repeated to generate the same error, so that frequently occurring answers may still be erroneous. Regarding the lack of a mechanism to find an error and correct to find a correct answer, the progressive hint method modifies the inference path by adding "(hint: answer near H)" after the question, where H is the placeholder for the previous answer, however when the previous answer is wrong, the large language model may still generate a wrong answer under the guidance of the hint. With respect to the lack of an efficient method of gradually optimizing the inference path, the chained inference method is extremely sensitive to errors in intermediate inference steps, and even a small error may affect the overall problem solving process, eventually leading to erroneous answers, so achieving multi-step accurate inference still faces a great challenge. Disclosure of Invention The invention aims to overcome the defects of the prior art and provide a mathematical problem solving method and a related device based on progressive correction. In order to achieve the purpose, the invention is realized by adopting the following technical scheme: The invention provides a mathematical problem solving method based on progressive correction, which comprises the steps of obtaining a mathematical application problem to be solved, generating an initial answer of the mathematical application problem to be solved through a preset large language model, carrying out an iterative verification step and a correction step to obtain a final answer of the mathematical application problem to be solved, wherein the verification step comprises the steps of verifying the correctness of the current answer by adopting a replacement verification method according to the current answer of the mathematical application problem to be solved, taking the current answer as the final answer when the correctness verification result of the current answer is correct, adding the current answer to an error answer set when the correctness verification result of the current answer is incorrect, obtaining the current iteration times, taking the current answer as the final answer when the current iteration times are greater than a preset iteration times threshold value, otherwise, taking the error answer set as a constraint prompt, and generating the current answer of the mathematical application problem to be solved through the preset large language model. Optionally, the generating the initial answer of the mathematic application question through the preset large language model comprises the steps of replacing a question placeholder in a preset reasoning generation prompt template with the mathematic application question to be solved, generating a reasoning generation prompt of the mathematic application question to be solved, inputting the reason