Weight optimization method for solving mathematical problems based on large language model
By using large language models and adaptive weight optimization algorithms on intelligent education platforms, combined with comprehensive evaluation functions and weight diffusion mechanisms, the problem of insufficient quality and efficiency of problem-solving solutions in the existing technology is solved, and efficient, flexible and accurate solutions are achieved. Solving mathematical problems.
Patent Information
- Application Number
- CN202411540429.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-10-31
AI Technical Summary
When generating and optimizing mathematical and physics problem-solving solutions, the existing technology failed to fully consider the diversity of the problem, and lacked comprehensive evaluation and selection of the solutions, which resulted in insufficient identification of key steps in the problem-solving process, which affected the quality of the solution and efficiency.
By obtaining the mathematical problem prompts input by users in the intelligent education platform, a large language model is used to generate a set of candidate solutions, and the weight of the problem-solving steps of each solution is initialized. Then, an evaluation function based on accuracy, efficiency, and stability is designed to evaluate each solution and select the best one. Identify key steps according to the best solution, perform weight diffusion and update, and iteratively optimize until the stopping conditions are met.
It improves the quality and efficiency of mathematical problem solving solutions, enhances the stability and diversity of the solutions, reduces reliance on professional knowledge, and improves the accuracy and innovation of problem solving.
Smart Images

Figure CN119046454B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a method for optimizing weights of mathematical problem solving steps based on a large language model. Background Art
[0002] Currently, in the field of intelligent education platforms, there is a growing demand for personalized learning experience. Large language models (LLMs) provide new possibilities for automated mathematical problem solving due to their excellent language understanding and generation capabilities. Nevertheless, traditional automated problem solving methods have many limitations, such as reliance on fixed strategies, lack of adaptability and flexibility, and high reliance on expertise in specific fields, which affect the widespread deployment and effectiveness of intelligent education platforms. With the rapid development of artificial intelligence technology, especially the breakthrough of deep learning technology, large language models can now be used to generate and optimize problem solutions. These models can accurately understand the description of the problem, generate logically feasible problem-solving steps, and provide multiple candidate solutions based on the specific type and structure of the problem. However, when generating and optimizing problem solutions, existing methods often fail to fully consider the diversity of problems, lack comprehensive evaluation and selection of solutions, and fail to effectively identify the key steps in the problem-solving process, which limits the quality and efficiency of the solutions. In addition, existing technologies may not be flexible or accurate enough when dealing with large-scale or complex mathematical problems, and require a lot of computing resources and time. The generated solutions may lack focus, be too complicated, and lack pertinence, resulting in unsatisfactory efficiency and quality when using large language models to solve mathematical problems. The existing technology also lacks an effective weight allocation and update mechanism and is unable to dynamically adjust the importance of problem-solving steps, thus affecting the dynamic adaptability of problem solving.
[0003] It can be seen that there is an urgent need for an efficient and accurate method for optimizing the weights of mathematical problem-solving steps based on a large language model. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method for optimizing the weights of mathematical problem solving steps based on a large language model, which at least partially solves the problems of poor optimization efficiency and accuracy in the prior art.
[0005] The embodiment of the present invention provides a method for optimizing weights of mathematical problem solving steps based on a large language model, comprising:
[0006] Step 1, obtaining a target prompt input by a target user in the intelligent education platform, wherein the target prompt includes a detailed description of a quantifiable mathematical problem and a classic step for solving the mathematical problem;
[0007] Step 2: Use the target prompt to guide the large language model to generate a set of candidate solutions;
[0008] Step 3: Initialize the weights of the problem-solving steps of each initial solution in the candidate solution set, and use this to guide the large model to generate m new weighted target solutions according to the weight vector, where m is the number of initial solutions;
[0009] Step 4, designing an evaluation function based on the weighted sum of accuracy, efficiency and stability;
[0010] Step 5: Use the evaluation function to evaluate each target solution and select the best solution;
[0011] Step 6, calculate the target performance according to the best solution and judge whether the iteration stop condition is met. If so, output the best solution and the weights corresponding to its problem-solving steps. If not, execute step 7;
[0012] Step 7, identify the key steps in the best solution;
[0013] Step 8, diffuse and update the weights corresponding to the key steps to obtain a weight scheme;
[0014] Step 9, guide the large model to generate a new target solution according to the weight scheme and iterate steps 6 to 9 until the iteration stop condition is met.
[0015] According to a specific implementation of the embodiment of the present invention, step 2 specifically includes:
[0016] Assume that there are n classic steps to solve the problem, and use this to guide the large language model to generate m candidate solutions. It consists of a process of n classic steps to form a set of candidate solutions , the process set of problem-solving steps in each candidate solution is expressed as .
[0017] According to a specific implementation of the embodiment of the present invention, step 3 specifically includes:
[0018] Step 3.1: Assign an initial weight to each problem-solving step and construct a weight vector , weights are randomly generated through normal distribution , the distribution range of weights is controlled by preset mean and standard deviation;
[0019] Step 3.2, after normalization So that the sum of the weights of all problem-solving steps is equal to 1, that is ;
[0020] Step 3.3: Update the weights corresponding to the problem-solving steps in the initial solution → , i={1,2,...,m}, take the current set of m solutions as the initial population;
[0021] Step 3.4, update the weight vector The heuristic information is input into the large model to guide the large model to generate m new weighted target solutions according to the weight vector.
[0022] According to a specific implementation of the embodiment of the present invention, the expression of the evaluation function is:
[0023]
[0024] Where t is the number of iterations, t={1,2,.. }, is the maximum number of iterations, , , are the weights of accuracy, efficiency and stability respectively, and + + =1, represents the accuracy score, represents the efficiency score, represents the stability score;
[0025]
[0026] Where n is the dimension of the solution, i.e. the length of the solution vector, It is a plan The solution value in the jth dimension is, is the value of the optimal solution or true solution vector in the jth dimension;
[0027]
[0028]
[0029] in, Representation scheme The execution time, is the execution time of the solution with the smallest execution time among all solutions, Represents the generation plan The time of ending, Represents the generation plan Start time;
[0030]
[0031] in, It is a plan The solution value in dimension j is, It is a plan The average of the solution values in dimension j over all k tests.
[0032] According to a specific implementation of the embodiment of the present invention, before step 4, the method further includes:
[0033] Calculate the entropy value of each indicator , where the entropy value The expression is
[0034]
[0035] Where m is the number of initial solutions, is the normalized score of the ith solution on the gth indicator, , and The entropy values of the accuracy, efficiency and stability indicators are used to determine the weights of the indicators and normalize them. The normalized expression is:
[0036]
[0037]
[0038] .
[0039] According to a specific implementation of the embodiment of the present invention, step 5 specifically includes:
[0040] Step 5.1: Use the evaluation function to evaluate each target solution. Conduct ratings;
[0041] Step 5.2: Score all solutions according to their performance E(t, ) to sort in descending order;
[0042] Step 5.3, select the solution with the highest performance score As the best solution for the current iteration, record its step sequence and corresponding weight vector, → ;
[0043] Step 5.4, record the best solution The steps, weights, performance scores, and all parameters and calculations used in the evaluation process.
[0044] According to a specific implementation of the embodiment of the present invention, step 6 specifically includes:
[0045] Step 6.1: Set the target performance threshold judgment formula
[0046]
[0047] Among them, E(t, ) is the expected performance level, is a positive error tolerance value, indicating the degree to which the acceptable performance is lower than the expected value. If E(t, ) is greater than or equal to , then Stop1 is true, otherwise it is false;
[0048] Step 6.2, set the minimum performance improvement threshold , used to judge the performance improvement between consecutive iterations;
[0049]
[0050] If the performance improvement of successive iterations is less than , then Stop2 is true, otherwise it is false;
[0051] Step 6.3, set the maximum number of iterations and judge accordingly
[0052]
[0053] If the current number of iterations Greater than or equal to the maximum number of iterations , then Stop3 is true, otherwise it is false;
[0054] Step 6.4, set the iteration stop condition to S=Stop1∨Stop2∨Stop3. If S is true, stop the iteration and output the final optimal solution and the weights corresponding to its steps. If S is false, continue the iteration and update the number of iterations t=t+1.
[0055] According to a specific implementation of the embodiment of the present invention, step 7 specifically includes:
[0056] Step 7.1: The best solution for the current situation Iterate over the weight vector All elements in to identify the weight of each step;
[0057] Step 7.2, during the traversal process, identify the step with the maximum weight value , record its index K, which represents the order of the step with the largest weight in the scheme;
[0058] Step 7.3, replace step and its corresponding weight Clearly identify the key steps in the current best practice.
[0059] According to a specific implementation of the embodiment of the present invention, step 8 specifically includes:
[0060] Step 8.1, first Weight Spread to Weight , i={1,2,...m} (i≠j), the expression of the diffusion process is:
[0061]
[0062] in, is the adjusted weight, E(t, ) and E(t, ) are respectively and Ratings;
[0063] Step 8.2, Weight Update, where i={1,2,...,m}(i≠j),z={1,2,...,n}(z≠k);
[0064] is the updated weight, which is expressed as:
[0065]
[0066] Thus, we get the updated weight scheme, → , i={1,2,...,m}.
[0067] The weight optimization scheme for solving mathematical problems based on a large language model in an embodiment of the present invention includes: step 1, obtaining a target prompt input by a target user in an intelligent education platform, wherein the target prompt includes a detailed description of a quantifiable mathematical problem and a classic step for solving the mathematical problem; step 2, using the target prompt to guide the large language model to generate a set of candidate solutions; step 3, initializing the weight of the problem-solving steps of each initial solution in the candidate solution set, and guiding the large model to generate m new weighted target solutions according to the weight vector, wherein the number m is the number of initial solutions; step 4, designing an evaluation function based on the weighted sum of accuracy, efficiency and stability; step 5, using the evaluation function to evaluate each target solution and select the best solution; step 6, calculating the target performance according to the best solution and judging whether the iteration stop condition is met, if so, outputting the best solution and the weights corresponding to the problem-solving steps, if not, executing step 7; step 7, identifying the key steps in the best solution; step 8, diffusing and updating the weights corresponding to the key steps to obtain a weight scheme; step 9, guiding the large model to generate a new target solution according to the weight scheme and iterating step 6 to step 9 until the iteration stop condition is met.
[0068] The beneficial effects of the embodiments of the present invention are as follows: through the scheme of the present invention, innovative points such as large language model, adaptive weight optimization algorithm, comprehensive evaluation function, key step identification and weight diffusion mechanism are introduced to provide an efficient, flexible and accurate automated mathematical problem solving technology. The method of the present invention first uses a prompt template to guide the large language model to analyze the problem type and structure, and generates multiple candidate problem-solving solutions, each of which contains an ordered sequence of problem-solving steps. Then, an adaptive weight optimization algorithm is applied to assign weights to each step, and the solution is optimized in combination with a comprehensive evaluation function and a weight update mechanism. This method not only improves the quality and efficiency of the problem-solving solution, but also enhances the stability and diversity of the solution through an iterative optimization process. The reliance on professional knowledge is reduced, and the identification of key steps and the introduction of a weight diffusion mechanism further improve the accuracy and innovation of problem solving, providing a significant advantage for the intelligent education platform to handle complex and quantifiable mathematical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0070] Figure 1 A flowchart of a method for optimizing weights of mathematical problem solving steps based on a large language model is provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0071] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0072] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0073] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present invention, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.
[0074] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention. The drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0075] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0076] An embodiment of the present invention provides a method for optimizing weights of steps in solving mathematical problems based on a large language model. The method can be applied to the process of solving mathematical problems in educational research scenarios.
[0077] See also Figure 1 , is a flow chart of a method for optimizing weights of mathematical problem solving steps based on a large language model provided by an embodiment of the present invention. Figure 1 As shown, the method mainly comprises the following steps:
[0078] Step 1, obtaining a target prompt input by a target user in the intelligent education platform, wherein the target prompt includes a detailed description of a quantifiable mathematical problem and a classic step for solving the mathematical problem;
[0079] In specific implementation, users with target needs, such as teachers or students, can enter a prompt in the intelligent education platform. The prompt includes two parts: one is a detailed description of a quantifiable mathematical problem, and the other is to determine the classic steps to solve the problem and generate multiple candidate solutions according to these steps.
[0080] Step 2: Use the target prompt to guide the large language model to generate a set of candidate solutions;
[0081] Based on the above embodiment, step 2 specifically includes:
[0082] Assume that there are n classic steps to solve the problem, and use this to guide the large language model to generate m candidate solutions. It consists of a process of n classic steps to form a set of candidate solutions , the process set of problem-solving steps in each candidate solution is expressed as .
[0083] In specific implementation, this prompt serves as an interface for interacting with the large language model, guiding the large language model to generate multiple candidate problem-solving solutions. Assuming there are n classic steps to solve a problem, and m candidate solutions are generated. It consists of n classical steps. Each step process Represents a logical unit of the problem-solving process. Ensure that each solution It is logically feasible and follows the standard procedure for problem solving, so the solution set is expressed as Then the process set of problem-solving steps in each solution is expressed as .
[0084] Step 3: Initialize the weights of the problem-solving steps of each initial solution in the candidate solution set, and use this to guide the large model to generate m new weighted target solutions according to the weight vector, where m is the number of initial solutions;
[0085] Furthermore, the step 3 specifically includes:
[0086] Step 3.1: Assign an initial weight to each problem-solving step and construct a weight vector , weights are randomly generated through normal distribution , the distribution range of weights is controlled by preset mean and standard deviation;
[0087] Step 3.2, after normalization So that the sum of the weights of all problem-solving steps is equal to 1, that is ;
[0088] Step 3.3: Update the weights corresponding to the problem-solving steps in the initial solution → , i={1,2,...,m}, take the current set of m solutions as the initial population;
[0089] Step 3.4, update the weight vector The heuristic information is input into the large model to guide the large model to generate m new weighted target solutions according to the weight vector.
[0090] In specific implementation, an initial weight can be assigned to each problem-solving step to construct a weight vector }. The weights are randomly generated using a normal distribution , select a suitable mean (for example, 0.5) and standard deviation to control the distribution range of weights, ensuring that the generated weights are concentrated in a reasonable range. And after normalization To ensure that the sum of weights of all steps is equal to 1, that is . Update the weights corresponding to the steps of the solution:
[0091] → ,i={1,2,...,m}. Take the current set of m solutions as the initial population. Then update the weight vector The information is input into the big model as heuristic information to guide the big model to generate m new weighted solutions according to the weight vector.
[0092] Step 4, designing an evaluation function based on the weighted sum of accuracy, efficiency and stability;
[0093] Furthermore, the expression of the evaluation function is
[0094]
[0095] Where t is the number of iterations, t={1,2,.. }, is the maximum number of iterations, , , are the weights of accuracy, efficiency and stability respectively, and + + =1, represents the accuracy score, represents the efficiency score, represents the stability score;
[0096]
[0097] Where n is the dimension of the solution, i.e. the length of the solution vector, It is a plan The solution value in the jth dimension is, is the value of the optimal solution or true solution vector in the jth dimension;
[0098]
[0099]
[0100] in, Representation scheme The execution time, is the execution time of the solution with the smallest execution time among all solutions, Represents the generation plan The time of ending, Represents the generation plan Start time;
[0101]
[0102] in, It is a plan The solution value in dimension j is, It is a plan The average of the solution values in dimension j over all k tests.
[0103] Furthermore, before step 4, the method further includes:
[0104] Calculate the entropy value of each indicator , where the entropy value The expression is
[0105]
[0106] Where m is the number of initial solutions, is the normalized score of the ith solution on the gth indicator, , and are the entropy values of the accuracy, efficiency and stability indicators respectively. The weights of the indicators are determined and normalized. The normalized expression is:
[0107]
[0108]
[0109] .
[0110] In specific implementation, the design process of the evaluation function can be as follows:
[0111] 4.1. Define a comprehensive evaluation function , used to quantify the solution performance at iteration t. This function is the accuracy ,efficiency ,stability The weighted sum of is expressed as formula (1):
[0112]
[0113] Where t is the number of iterations, t={1,2,.. }, is the maximum number of iterations, , , are the weights of accuracy, efficiency and stability respectively, and + =1.
[0114] 4.2 Accuracy Scoring By comparing The generated solution vector is calculated with the optimal solution or the true solution vector. The specific calculation method is as shown in formula (2):
[0115]
[0116] Where n is the dimension of the solution, i.e. the length of the solution vector, It is a plan The solution value in the jth dimension is, is the value of the optimal solution or true solution vector in the jth dimension.
[0117] 4.3 Efficiency Rating Solution-based Execution time , measured by a timer in the programming language. Formula (3) is:
[0118]
[0119] The efficiency score formula (4) can be defined as:
[0120]
[0121] Among them, Tmin is the execution time of the solution with the smallest execution time among all solutions.
[0122] 4.4 Stability score Evaluate by performing k perturbation tests, introducing random perturbations in each test Extract from the probability distribution. Formula (5) is as follows:
[0123] (5)
[0124] in, It is a plan The solution value in dimension j is, It is a plan The average of the solution values in dimension j over all k tests.
[0125] 4.5. Determine the weights of accuracy, efficiency, and stability in the evaluation function.
[0126] 4.5.1. Calculate the entropy value of each indicator , its formula (6) is:
[0127] (6)
[0128] Where m is the number of solutions, Aj(pi) is the normalized score of the ith solution on the jth indicator, , and are the entropy values of accuracy, efficiency and stability indicators respectively.
[0129] 4.5.2. Determine the weight of the indicator and normalize it, as shown in formula (7), (8), (9):
[0130]
[0131]
[0132]
[0133] Step 5: Use the evaluation function to evaluate each target solution and select the best solution;
[0134] Based on the above embodiment, step 5 specifically includes:
[0135] Step 5.1: Use the evaluation function to evaluate each target solution. Conduct ratings;
[0136] Step 5.2: Score all solutions according to their performance E(t, ) to sort in descending order;
[0137] Step 5.3, select the solution with the highest performance score As the best solution for the current iteration, record its step sequence and corresponding weight vector, → ;
[0138] Step 5.4, record the best solution The steps, weights, performance scores, and all parameters and calculations used in the evaluation process.
[0139] When it comes to specific implementation, the process of evaluating and selecting the best solution can be as follows:
[0140] 5.1. For each generated solution , using the comprehensive evaluation function E(t, ) for scoring.
[0141] 5.2. Score all solutions according to their performance E(t, ) are sorted in descending order to identify the best solution in the current iteration .
[0142] 5.3. Select the solution with the highest performance score As the best solution for the current iteration, record its step sequence and corresponding weight vector, → .
[0143] 5.4. Recording the best solution The steps, weights, performance scores, and all parameters and calculation results used in the evaluation process are displayed to facilitate subsequent weight updates and solution iterations.
[0144] Step 6, calculate the target performance according to the best solution and judge whether the iteration stop condition is met. If so, output the best solution and the weights corresponding to its problem-solving steps. If not, execute step 7;
[0145] Based on the above embodiment, step 6 specifically includes:
[0146] Step 6.1: Set the target performance threshold judgment formula
[0147]
[0148] Among them, E(t, ) is the expected performance level, is a positive error tolerance value, indicating the degree to which the acceptable performance is lower than the expected value. If E(t, ) is greater than or equal to , then Stop1 is true, otherwise it is false;
[0149] Step 6.2, set the minimum performance improvement threshold , used to judge the performance improvement between consecutive iterations;
[0150]
[0151] If the performance improvement of successive iterations is less than , then Stop2 is true, otherwise it is false;
[0152] Step 6.3, set the maximum number of iterations and judge accordingly
[0153]
[0154] If the current number of iterations Greater than or equal to the maximum number of iterations , then Stop3 is true, otherwise it is false;
[0155] Step 6.4, set the iteration stop condition to S=Stop1∨Stop2∨Stop3. If S is true, stop the iteration and output the final optimal solution and the weights corresponding to its steps. If S is false, continue the iteration and update the number of iterations t=t+1.
[0156] In specific implementation, the process of judging and outputting the iteration termination condition can be as follows:
[0157] 6.1. Target performance threshold judgment formula (10):
[0158]
[0159] in, is the desired performance level, is a positive error tolerance value, indicating the degree to which the acceptable performance is lower than the expected value. Greater than or equal to , then: Stop1 is true, otherwise it is false.
[0160] 6.2. Pre-set a minimum performance improvement threshold , which is used to judge the performance improvement effect between consecutive iterations. For example, formula (11):
[0161]
[0162] If the performance improvement of successive iterations is less than , then: Stop2 is true, otherwise it is false.
[0163] 6.3. Formula (12):
[0164]
[0165] If the current number of iterations Greater than or equal to the maximum number of iterations , then Stop3 is true, otherwise it is false.
[0166] 6.4. The final stopping condition S is the logical "or" of these individual conditions: S=Stop1∨Stop2∨Stop3; if S is true, the iteration is stopped and the final optimal solution and the weights corresponding to its steps are output.
[0167] If S is false, continue iterating and update the number of iterations t=t+1.
[0168] Step 7, identify the key steps in the best solution;
[0169] Furthermore, the step 7 specifically includes:
[0170] Step 7.1: The best solution for the current situation Iterate over the weight vector All elements in to identify the weight of each step;
[0171] Step 7.2, during the traversal process, identify the step with the maximum weight value , record its index K, which represents the order of the step with the largest weight in the scheme;
[0172] Step 7.3, replace step and its corresponding weight Clearly identify the key steps in the current best practice.
[0173] When it comes to specific implementation, the specific process of identifying the key steps in the best solution can be as follows:
[0174] 7.1. The best solution at present Iterate over the weight vector to identify the weights of each step.
[0175] 7.2. During the traversal process, identify the step with the maximum weight value , record its index K, which represents the order of the step with the largest weight in the solution.
[0176] 7.3、Step and its corresponding weight Clearly identify the key steps in the current best practice.
[0177] Step 8, diffuse and update the weights corresponding to the key steps to obtain a weight scheme;
[0178] Based on the above embodiment, step 8 specifically includes:
[0179] Step 8.1, first Weight Spread to Weight , i={1,2,...m} (i≠j), the expression of the diffusion process is:
[0180]
[0181] in, is the adjusted weight, E(t, ) and E(t, ) are respectively and Ratings;
[0182] Step 8.2, Weight Update, where i={1,2,...,m}(i≠j),z={1,2,...,n}(z≠k);
[0183] is the updated weight, which is expressed as:
[0184]
[0185] Thus, we get the updated weight scheme, → , i={1,2,...,m}.
[0186] In specific implementation, the process of diffusion and updating of weights in the scheme can be as follows:
[0187] 8.1, first Weight Spread to Weight , i={1,2,...m} (i≠j), formula (13) is:
[0188]
[0189] in, is the adjusted weight, E(t, ) and E(t, ) are respectively and When the two scores are close, the weights are slightly adjusted. When the score difference is large, the weight update is large. is the weight stability factor, which controls the smoothness of weight update. It is a nonlinear function used to smoothly transition from 0 to 1, making the weight update process smoother, avoiding local optimality and increasing the diversity of the population.
[0190] 8.2, Weight Update, where i={1,2,...,m} (i≠j), z={1,2,...,n} (z≠k).
[0191] is the updated weight, formula (14) is as follows:
[0192]
[0193] Thus, we get the updated weight scheme, → , i={1,2,...,m}.
[0194] It can be verified that the sum of the updated weights is still 1. That is:
[0195] .
[0196] Step 9, guide the large model to generate a new target solution according to the weight scheme and iterate steps 6 to 9 until the iteration stop condition is met.
[0197] In specific implementation, the updated weight scheme set in step 8 can be used as input to guide the large model to generate a new target scheme, and then steps 6 to 9 are iterated until the iteration stop condition is met.
[0198] The weight optimization method for solving mathematical problems based on a large language model provided in this embodiment provides an efficient, flexible and accurate automated mathematical problem solving technology by introducing innovative points such as a large language model, an adaptive weight optimization algorithm, a comprehensive evaluation function, key step identification and a weight diffusion mechanism. The method of the present invention first uses a prompt template to guide a large language model to analyze the type and structure of the problem, and generates multiple candidate problem-solving solutions, each of which contains an ordered sequence of problem-solving steps. Then, an adaptive weight optimization algorithm is applied to assign weights to each step, and the solution is optimized in combination with a comprehensive evaluation function and a weight update mechanism. This method not only improves the quality and efficiency of the problem-solving solution, but also enhances the stability and diversity of the solution through an iterative optimization process. The reliance on professional knowledge is reduced, and the identification of key steps and the introduction of a weight diffusion mechanism further enhance the accuracy and innovation of problem solving, providing a significant advantage for the intelligent education platform to handle complex and quantifiable mathematical problems.
[0199] The method of the present invention will be further described below in conjunction with a specific embodiment.
[0200] Step 1: Enter the prompt
[0201] 1.1 Describe the mathematical problem in detail: User input prompts, including a detailed description of the definite integral problem, i.e. "Calculate the definite integral ”.
[0202] 1.2 Determine the steps to solve the problem: The large language model also needs to determine the classic steps to solve this problem, which may include:
[0203] Step 1 is to determine the integration interval.
[0204] Step 2 is to select the integration method (direct integration, substitution integration, integration by parts, etc.).
[0205] Step 3 is to perform the integral calculation.
[0206] Step 2: Generate a solution
[0207] 2.1 Interaction with the large language model: The prompts entered by the user will serve as an interface for interacting with the large language model, guiding the model to generate multiple candidate solutions.
[0208] 2.2 Generate a set of candidate solutions: Assume that there are n classic steps to solve the problem, and generate m candidate solutions. For our example problem, we can assume n=3 (determine the integration interval, select the integration method, and perform the integration calculation), and generate m=3 different solutions.
[0209] Solution 1: Direct integration method
[0210] Step 1: Determine the integration interval as [0, 1].
[0211] Step 2: Choose direct integration because x squared is a simple polynomial function.
[0212] Step 3: Perform the integral calculation and apply the basic integral formula to get 1 / 3.
[0213] Solution 2: Substitution Integration Method
[0214] Step 1: Determine the integration interval as [0, 1].
[0215] Step 2: Select the substitution integration method.
[0216] Step 3: Simplify the integral expression by substitution, and then perform the integral calculation to obtain 1 / 3.
[0217] Solution 3: Integration by Parts
[0218] Step 1: Determine the integration interval as [0, 1].
[0219] Step 2: Select the method of integration by parts.
[0220] Step 3: Apply the integration by parts formula to perform the integral calculation and get 1.
[0221] Step 3: Initialize weights
[0222] 3.1 Assign initial weights to each problem-solving step and generate them randomly using a normal distribution. For example, At each step the weight vector may be = {0.1, 0.3, 0.6}, The step weight vector is = {0.2, 0.4, 0.4}, The step weight vector is = {0.3, 0.3, 0.4}.
[0223] 3.2 Steps to generate a new solution: Update the weight vector The heuristic information is input into the large model to guide the large model to generate m new weighted target solutions according to the weight vector.
[0224] Analyze the original plan: view the steps and corresponding weights of each plan.
[0225] Determine the direction of improvement: Based on the weights, determine the most important steps in each solution.
[0226] Generate new solutions: Use heuristic information (weights) to adjust the original solution and generate new solutions to the problem.
[0227] New scenario example
[0228] New solution 1: Improved direct integration method
[0229] Step 1 (weight 0.1): Determine the integration interval more accurately and consider whether the interval needs to be subdivided to improve the integration accuracy.
[0230] Step 2 (weight 0.3): Analyze whether a simpler direct integration method can be selected to reduce the computational complexity.
[0231] Step 3 (weight 0.6): Optimize the integral calculation process, possibly by using numerical integration methods to improve efficiency and accuracy.
[0232] New solution 2: Improved substitution integration method
[0233] Step 1 (weight 0.2): Re-evaluate the integration interval, consider the function characteristics, and determine the best substitution point.
[0234] Step 2 (weight 0.4): Explore whether there is a better substitution strategy, such as choosing a simpler u function.
[0235] Step 3 (weight 0.4): Improve the integral calculation, possibly by reducing the computation time through software tools or algorithm optimization.
[0236] New Solution 3: Improved Integration by Parts
[0237] Step 1 (weight 0.3): Carefully analyze the integration interval to determine whether it needs to be adjusted to accommodate the characteristics of partial integration.
[0238] Step 2 (weight 0.3): Investigate options for integration by parts, such as whether the calculation can be simplified by adjusting u and dv.
[0239] Step 3 (weight 0.4): Focus on optimizing the execution of the integration by parts, possibly through parallel computing or more efficient algorithms.
[0240] Step 4: Evaluate the function design
[0241] Define comprehensive evaluation function , including accuracy ,efficiency ,stability For example, It can be calculated by comparing how close the solution generated by the scheme is to the true solution.
[0242] Step 5: Evaluate and select the best solution
[0243] Each solution is scored using a comprehensive evaluation function and the solution with the best performance is selected. For example, if has the highest score, it will be selected as the best solution for the current iteration.
[0244] Step 6: Determine and output the iteration termination condition
[0245] Set the target performance threshold, minimum performance improvement threshold, and maximum number of iterations. If the current iteration meets these conditions, stop the iteration and output the best solution.
[0246] Step 7: Identification of key steps
[0247] Identify the step with the highest weight in the current best solution. For example, The step 3 (perform the integration and calculation) with the largest weight has a weight of 0.4, which will be the key step.
[0248] Step 8: Diffusion and update of weights in the scheme
[0249] Will The weight of step 3 of the solution is diffused to the corresponding step 3 in other solutions, and the weight is updated through a specific formula. For example, if the weight of the key step is 0.4, this weight is diffused to step 3 in other solutions according to the weight diffusion formula. The remaining steps are redistributed according to the original proportion.
[0250] Step 9: Repeat iteration and population evolution
[0251] The updated set of weighted solutions is used as input to guide the LLM to generate new weighted solutions and repeat the iterative process until the termination condition is met.
[0252] Assume that after the first round of iterations, the solution is selected as the best solution. In the second iteration, LLM uses the updated weight vector to generate a new solution, which may include more efficient steps. In this way, the system continues to iterate until it finds a solution to the definite integral problem that is both accurate and efficient.
[0253] The beneficial effects of the method of the present invention are:
[0254] 1. Application of Large Language Model: Use LLM to understand the problem description and generate logically feasible problem-solving steps.
[0255] 2. Adaptive weight optimization algorithm: Assign weights to problem-solving steps and improve the quality and efficiency of the solution through an iterative optimization process.
[0256] 3. Comprehensive evaluation function: A comprehensive evaluation function is designed to quantify the performance of the solution, taking into account the three dimensions of accuracy, efficiency and stability. Accuracy can measure the solution in multiple dimensions.
[0257] 4. Key step identification and weight diffusion mechanism: Identify the key steps in the current best solution and update the weights of other steps through the weight diffusion mechanism to enhance the accuracy and innovation of problem solving.
[0258] 5. Iterative optimization process: Through continuous iterations, combined with the weight update mechanism, the solution is gradually optimized until the predetermined performance threshold or number of iterations is reached.
[0259] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof.
[0260] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for optimizing weights of mathematical problem solving steps based on a large language model, characterized in that: include: Step 1, obtaining a target prompt input by a target user in the intelligent education platform, wherein the target prompt includes a detailed description of a quantifiable mathematical problem and a classic step for solving the mathematical problem; Step 2: Use the target prompt to guide the large language model to generate a set of candidate solutions; Step 3: Initialize the weights of the problem-solving steps of each initial solution in the candidate solution set, and use this to guide the large model to generate m new weighted target solutions according to the weight vector, where m is the number of initial solutions; Step 4, designing an evaluation function based on the weighted sum of accuracy, efficiency and stability; Step 5: Use the evaluation function to evaluate each target solution and select the best solution; Step 6, calculate the target performance according to the best solution and judge whether the iteration stop condition is met. If so, output the best solution and the weights corresponding to its problem-solving steps. If not, execute step 7; Step 7, identify the key steps in the best solution; The step 7 specifically includes: Step 7.1: The best solution for the current situation Iterate over the weight vector All elements in to identify the weight of each step; Step 7.2, during the traversal process, identify the step with the maximum weight value , record its index k, which represents the order of the step with the largest weight in the scheme; Step 7.3, replace step and its corresponding weight Clearly identify key steps in the current best practice; Step 8, diffuse and update the weights corresponding to the key steps to obtain a weight scheme; The step 8 specifically includes: Step 8.1, first Weight Spread to Weight , i={1,2,...m} (i≠j), the expression of the diffusion process is: ; in, is the adjusted weight, and The solutions are and Ratings; Step 8.2, Weight Update, where i={1,2,...,m} (i≠j), z={1,2,...,n} (z≠k); is the updated weight, which is expressed as: ; Thus, we get the updated weight scheme, , ; Step 9, guide the large model to generate a new target solution according to the weight scheme and iterate steps 6 to 9 until the iteration stop condition is met.
2. The method according to claim 1, characterized in that , the step 2 specifically includes: Assume that there are n classic steps to solve the problem, and use this to guide the large language model to generate m candidate solutions. It consists of a process of n classic steps to form a set of candidate solutions , the process set of problem-solving steps in each candidate solution is expressed as .
3. The method according to claim 2, characterized in that , the step 3 specifically includes: Step 3.1: Assign an initial weight to each problem-solving step and construct a weight vector , weights are randomly generated through normal distribution , the distribution range of weights is controlled by preset mean and standard deviation; Step 3.2, after normalization So that the sum of the weights of all problem-solving steps is equal to 1, that is ; Step 3.3: Update the weights corresponding to the problem-solving steps in the initial solution → , i={1,2,...,m}, take the current set of m solutions as the initial population; Step 3.4, update the weight vector The heuristic information is input into the large model to guide the large model to generate m new weighted target solutions according to the weight vector.
4. The method according to claim 3, characterized in that , the expression of the evaluation function is Where t is the number of iterations, t={1,2,.. }, is the maximum number of iterations, , , are the weights of accuracy, efficiency and stability respectively, and + + =1, represents the accuracy score, represents the efficiency score, represents the stability score; Where n is the dimension of the solution, i.e. the length of the solution vector, It is a plan The solution value in the jth dimension is, is the value of the optimal solution or true solution vector in the jth dimension; in, Representation scheme The execution time, is the execution time of the solution with the smallest execution time among all solutions, Represents the generation plan The time of ending, Represents the generation plan Start time; in, It is a plan The solution value in dimension j is, It is a plan The average of the solution values in dimension j over all k tests.
5. The method according to claim 4, characterized in that , before step 4, the method further includes: Calculate the entropy value of each indicator , where the entropy value The expression is Where m is the number of initial solutions, is the normalized score of the ith solution on the gth indicator, , and are the entropy values of the accuracy, efficiency and stability indicators respectively. The weights of the indicators are determined and normalized. The normalized expression is: 。 6. The method according to claim 5, characterized in that , the step 5 specifically includes: Step 5.1: Use the evaluation function to evaluate each target solution. Conduct ratings; Step 5.2: Score all solutions according to their performance E(t, ) to sort in descending order; Step 5.3, select the solution with the highest performance score As the best solution for the current iteration, record its step sequence and corresponding weight vector, → ; Step 5.4, record the best solution The steps, weights, performance scores, and all parameters and calculations used in the evaluation process.
7. The method according to claim 6, characterized in that , the step 6 specifically includes: Step 6.1: Set the target performance threshold judgment formula Among them, E(t, ) is the expected performance level, is a positive error tolerance value, indicating the degree to which the acceptable performance is lower than the expected value. If E(t, ) is greater than or equal to , then Stop1 is true, otherwise it is false; Step 6.2, set the minimum performance improvement threshold , used to judge the performance improvement between consecutive iterations; If the performance improvement of successive iterations is less than , then Stop2 is true, otherwise it is false; Step 6.3, set the maximum number of iterations and judge accordingly If the current number of iterations Greater than or equal to the maximum number of iterations , then Stop3 is true, otherwise it is false; Step 6.4, set the iteration stop condition to S=Stop1∨Stop2∨Stop3. If S is true, stop the iteration and output the final optimal solution and the weights corresponding to its steps. If S is false, continue the iteration and update the number of iterations t=t+1.
Citation Information
Patent Citations
Method and device for evaluating adsorption performance of metal organic framework on arsenic and related equipment
CN115049019A
Online question and answer cue word optimization generation method based on large language model
CN118093836A