CN119443267A - A method and system for solving mathematical problems by thinking chain reasoning based on feature classifier - Google Patents
A method and system for solving mathematical problems by thinking chain reasoning based on feature classifier Download PDFInfo
- Publication number
- CN119443267A CN119443267A CN202411479942.2A CN202411479942A CN119443267A CN 119443267 A CN119443267 A CN 119443267A CN 202411479942 A CN202411479942 A CN 202411479942A CN 119443267 A CN119443267 A CN 119443267A
- Authority
- CN
- China
- Prior art keywords
- reasoning
- node
- path
- training
- feature
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/04—Inference or reasoning models
- G06N5/041—Abduction
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2411—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Mathematical Analysis (AREA)
- Bioinformatics & Computational Biology (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Life Sciences & Earth Sciences (AREA)
- Computational Mathematics (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Databases & Information Systems (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Biology (AREA)
- Algebra (AREA)
- Computational Linguistics (AREA)
- Computing Systems (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a method and a system for solving a thinking chain reasoning mathematical problem based on a feature classifier, which comprise the steps of (1) obtaining a mathematical problem set and selecting forward and reverse thinking chain examples to splice to form a new set, (2) respectively inputting new set elements into a model to perform reasoning and constructing a word-level reasoning path spanning tree, selecting a attention weight matrix processed by pooling differences as node features to store, (3) traversing all generated reasoning path spanning trees, screening nodes meeting requirements to construct a feature classifier training set, (4) training the feature classifier by using a support vector machine algorithm, and (5) participating in path selection in a pre-training language model reasoning process through the trained feature classifier to obtain more accurate reasoning processes and answers. By utilizing the method, the adjustment and control of finer granularity of the pre-training language model reasoning path can be realized, the accurate reasoning and solving of the pre-training language model reasoning path on mathematical problems are facilitated, and the generalization level of the pre-training language model reasoning path is improved.
Description
Technical Field
The invention relates to the technical field of computer application, in particular to a thinking chain reasoning mathematical problem solving method and system based on a feature classifier.
Background
In recent years, the deep learning artificial intelligence technology mainly goes through the following research paradigm shift from an early task specific model of 'annotation data supervised learning', to a pre-training model of 'non-annotation data pre-training+annotation data fine tuning', to a large model of 'large-scale non-annotation data pre-training+instruction fine tuning+human alignment', and gradually enters the age of a large model. Meanwhile, as the model parameter scale and the pre-training data scale are continuously increased and reach the billion level, a large language model has developed a strong context learning capability, namely learning from examples of model input contexts, so that a series of complex tasks can be executed, and the model is a powerful tool for helping human beings to process a series of automated complex tasks. As a specific application of the context learning, the thinking chain technology can remarkably improve the performance of a large model under a complex reasoning task scene by gradually participating in the large language model to decompose a complex problem into sub-problems step by step and sequentially solving the sub-problems, and completing the mapping from input to the thinking chain and then to output.
Mathematical reasoning is crucial to artificial intelligence, and promotes continuous exploration for autonomously solving mathematical problems. This process requires enhanced model reasoning capabilities, intensive research into text understanding, image recognition, form analysis, symbolic operations, logical operations, and intensive knowledge of the world. The understanding capability of the large language model in various mathematical fields is comprehensively improved, not only can the technical strength be embodied, but also the method is an important step for general artificial intelligence. Existing studies can demonstrate that large language models are effective tools to help solve mathematical problems, whose language capabilities motivate us to explore how to use them for mathematical reasoning, revealing new insights into the synergy between language and logic.
As disclosed in chinese patent document CN116595159a, a training method and apparatus for a mathematical problem solution model are disclosed, in which a solution with an inference process for generating a correct answer to a mathematical problem is first generated as an example of learning a thought chain by using a pre-training language model with freezing parameters, then the mathematical problem solution model is used to generate multiple inference processes and answers corresponding to a target mathematical problem to be solved, and a self-consistent majority voting method is adopted to take the inference process and answer with the largest number of times as a final result corresponding to the target mathematical problem.
Chinese patent document publication No. CN118113444a discloses a task processing method, apparatus, electronic device, and storage medium. According to the method, the target task is subjected to step decomposition according to the input content and the output description of the target task through a pre-training language model, so that a corresponding thinking tree is generated. The nodes of the mental tree represent each step obtained by decomposing the steps, so that the model has the capability of searching among a plurality of inference chains. Searching an optimal step path for executing the target task in the thinking tree based on a preset searching algorithm, then executing the target task according to the input content based on the optimal step path, and outputting an execution result.
However, the follow-up work related to the prior pre-training language model thinking chain reasoning comprises self-consistency, thinking tree and other methods for promoting the reasoning of complex mathematical problems, all focused on a sequence-level reasoning path, and the method has limited effect on promoting the accuracy of a reasoning result and is constrained by the type of the mathematical problems. In addition, self-consistency may generate incorrect or nonsensical inference paths, and the search method of the inference chain of the thinking tree also needs more computing resources relative to sampling, and similar works are limited by the computing cost and performance.
Disclosure of Invention
The invention provides a thinking chain reasoning mathematical problem solving method and system based on a feature classifier, which can provide a problem solving process and a problem solving answer with higher quality and accuracy.
A thinking chain reasoning mathematical problem solving method based on a feature classifier comprises the following steps:
(1) Obtaining a mathematical problem set q= { Q 1,q2…qn }, for each element Q i, finding two corresponding examples using a mental chain hint generation method AndSo thatA correct answer is obtained and the user can obtain the correct answer,Obtaining wrong answers, forming a new set Q ′={q1 ′,q′ 2…q′ n }, wherein
(2) Based on the new set Q ′, inputting a pre-training language model by using a thinking chain prompting method, constructing a word-level reasoning path spanning tree, and storing an attention weight matrix A i after the average pooling and difference operation by each node n i;
(3) Traversing all the reasoning path spanning trees generated in the step (2), screening nodes meeting the requirements, and constructing a feature classifier training set, wherein the attention weight matrix A i of the nodes is used as a feature, the reasoning path result is used as a label, and a training data sample pair set D is constructed;
(4) Training a feature classifier C by using a support vector machine algorithm according to the training set generated in the step (3);
(5) And (3) in the pre-training language model reasoning stage, for the target mathematical problem q to be solved, randomly selecting two examples d a and d b in the data set, simultaneously carrying out reasoning, continuing to predict and generate until the end if the reasoning paths are the same, enabling the feature classifier C trained in the step (4) to select a word with higher correct probability to continue reasoning if the reasoning paths are different, finally obtaining a complete reasoning process, and extracting corresponding answers.
The invention firstly selects partial questions based on a mathematical question data set and constructs a word granularity level reasoning path spanning tree by using a thinking chain method, and then screens training sample data to train a feature selector. When the pre-training predictive model is used for reasoning, a thought chain prompting method is used for processing target mathematical questions to be solved, and during reasoning, a feature classifier intervenes in the selection generation of a reasoning path, so that a problem solving process and a problem solving answer with higher quality and accuracy are obtained.
In step (1), two examples are found corresponding using the mental chain hint generation methodAndThe specific process is as follows:
representing probability distribution fitted to a pre-trained large language model with parameter θ using p θ
Representing N d thought chain cues, where d i=(qi,ri,ai) is the ith example, q i,ri,ai represents the question, the reasoning step, and the answer, respectively, and if q represents the question to be reasoned, then the less sample thought chain FS-CoT is defined as:
Wherein y= { r, a } is the generated reasoning step r and the reasoning result a, only consider the situation that the value of N d is 1, and for each problem q i, the corresponding example is found by traversing the mathematical problem set AndSo thatAnswers obtained with maximum probabilityCorrect and at the same timeAnswers obtained with maximum probabilityError, eliminating the problem if no corresponding example is found, and finally, combining the problem and the corresponding two examples to obtain a new set Q ′={q1 ′,q′ 2…q′ m }, m.ltoreq.n, where
The specific process of the step (2) is as follows:
For all elements within new set Q ′, for Input text for obtaining pre-trained language model by stitchingFreezing all parameters of the model, and taking the parameters as input of a pre-training language model to perform forward reasoning;
In the reasoning process, q i ′ correspondingly generates a reasoning path tree G i, each node n j comprises three types of attributes (f (A j,l),xj,rj), wherein x j represents the text of the current node, r j represents the accuracy of all reasoning paths passing through the node n j, and A j represents the attention weight matrix of the model when x j is generated in a prediction mode;
The process of constructing the inference path tree includes constructing an empty node n root as the root node of the inference path tree, marking as non-leaf nodes, finding one of the non-leaf nodes in the end nodes of each path of the tree, setting the node as n i, and enabling the path from the root node n root to the node n i to represent an inference path Then determine the child node condition of node n i, specificallyAnd (3) withRespectively inputting a pre-training language model, and predicting the language model according to the following probability when the first i text sequences are input:
x i+1 there are two cases:
first, the text generated for the two campt runs is the same, i.e Then node n i adds a child node n i+1 with the text attribute set toIf it isIf the child node is a sentence terminator, marking the child node as a leaf node;
Second, the text generated for the two campt runs is different, i.e Then insert left and right child nodes for node n i, respectivelyText attributes are respectively set asAndIf it isIs a sentence terminator, then the child node is markedIs a leaf node ifIs a sentence terminator, then the child node is markedIs a leaf node;
And the like, until the end node of each path of the tree is a leaf node, finally, all elements in the new set Q ′ generate a corresponding reasoning path tree to obtain a set G=of the tree
{G1,G2,...Gm}。
In the step (3), nodes meeting the requirements are screened to construct a feature classifier training set, and the specific process is as follows:
Firstly, the set G of the tree generated in the step (2) comprises m trees, each of which corresponds to each problem in the mathematical problem set Q ′, each node in the tree comprises three parts of attributes, n i=(f(Ai,l),xi,ri) which are respectively a feature matrix, a text and the accuracy of all the inference paths passing through the node n i, before screening training set samples, the r i attributes of the nodes need to be calculated, an inference path is formed by assuming that for one inference path generating tree, the paths from the root node to the leaf nodes form, and a unique attribute a for one inference path represents the accuracy of the result of the inference path, wherein 1 represents the accuracy and 0 represents the error, thus the following calculation formula is obtained:
Wherein, beta (n u,Sj) represents whether the node n j belongs to the inference path S i, if so, the value is 1, and if not, the value is 0, the inference path correct rate of all nodes of all trees in the tree set G is calculated according to the formula, and then the nodes meeting the requirements are screened out based on the following conditions to be used as a training data set of the training feature classifier:
① . The nodes do not belong to root nodes and leaf nodes;
② . The r attribute value of the node is 0% or 100%, namely, the situation that the answers of the reasoning paths passing through the node are all wrong or are all correct is considered;
All eligible nodes are grouped into a node set n= { N 1,n2,...
The specific process of the step (4) is as follows:
Firstly, extracting the characteristics of each element of a training data set D as input, taking an inference path result as a label, carrying out standardized processing on the data, then, mapping the data to a high-dimensional characteristic space by using a radial basis function, training a support vector machine classification model by taking the maximum Lagrange dual problem as an objective function, evaluating the performance of the model by using cross verification, and adjusting super parameters as required, and finally, saving the trained support vector machine model for subsequent reasoning, wherein the obtained characteristic classifier C is as follows:
Wherein x is a new input sample, the similarity between the sample and all training samples x i is calculated through a kernel function K (x i, x), then the similarity is weighted and summed, wherein alpha iyi is derived from Lagrangian multipliers learned in the training process and labels of the training samples, and finally a bias term b is added, and a classification result is obtained through a sign function sign.
In the step (5), if the inference paths are different, the feature classifier C trained in the step (4) selects a word with higher accuracy probability to continue the inference, which specifically includes:
Respectively calculating attention weight matrixes used for generating the current text, carrying out average pooling of layer dimension and linear interpolation processing of sequence length dimension to obtain a feature matrix A a in an example d a and a feature matrix A b in an example d b, and obtaining a classification result of the feature matrix through a feature classifier C (x), wherein the classification result comprises the following 3 cases, and respectively carrying out the following processing according to the cases:
①、C(Aa)=C(Ab ) =1, i.e. in the current text, both play a positive role in the correctness of the inference path generation, in which case the larger numerical term in the sign function in the feature classifier C is selected as the current generated text prediction content;
②、C(Aa)=-1,C(Ab ) =1 or C (a a)=1,C(Ab) = -1, i.e. for the current text, both examples work positively and negatively, respectively, for the correctness of the correct inference path generation; in this case, a text of C (x) =1 is selected as the currently generated text prediction content;
③、C(Aa)=C(Ab ) = -1, i.e. in the current text, both play a negative role in the correctness of the inference path generation, in which case the smaller items of value within the sign function in the feature classifier C are selected as the current generated text prediction content.
Based on the same inventive principle, the invention also provides a thinking chain reasoning mathematical problem solving system based on the feature classifier, which comprises the following steps:
The thinking chain prompt generation module is used for acquiring mathematical reasoning problems to be processed, selecting examples and instructions meeting requirements according to the problems and forming complete input of a pre-training language model;
The inference path tree generation and feature screening module is used for generating a word-level inference path generation tree and screening out feature training data sets meeting the requirements;
the feature classifier training module is used for training the feature classifier, introducing a support vector machine algorithm based on a feature training data set, mapping data to a high-dimensional feature space by using a radial basis function as a kernel function, and improving the training efficiency of the support vector machine by using a sequence minimum optimization algorithm;
The feature classifier is used for guiding the pre-training language model to select a more accurate reasoning path through intervention of the feature classifier, so that a final mathematical problem reasoning process and a final mathematical problem reasoning answer are obtained.
Based on the same inventive principle, the invention also provides a thinking chain reasoning mathematical problem solving system based on the feature classifier, which comprises a memory and one or more processors, wherein the memory stores executable codes, and the one or more processors are used for realizing the thinking chain reasoning mathematical problem solving method when executing the executable codes.
Compared with the prior art, the invention has the following beneficial effects:
1. The present invention focuses on the predictive generation of text levels. The granularity of processing at the text level is significantly smaller than the currently prevailing sequence level technique. This results in improved accuracy of the predictions, while enabling more accurate and efficient control over the generation of the inference results. In practical application, the fine processing of the text level can be better adapted to complex and changeable demand scenes, and more targeted and reliable results are provided for users.
2. The invention innovatively utilizes a self-training feature classifier. The classifier exhibits excellent migration ability and broad generalization performance in the face of various different types of mathematical reasoning tasks. This means that it can adapt and function quickly in different tasks and scenarios without extensive retraining and adjustment, thus greatly improving the working efficiency and versatility of the model.
3. Compared with common methods such as self-consistency and search of a thinking tree inference chain, the method has obvious advantages in the aspect of the demand of computing resources. It has relatively less resource requirements and can significantly save the calculation cost. The method not only reduces the hardware threshold of system operation, but also provides greater possibility for large-scale application and deployment, so that efficient operation can be smoothly carried out in an environment with limited resources.
4. The invention also has a certain research significance for the interpretive work of the reasoning of the pre-training language model under the prompt of the thinking chain. The method provides a new thought and a new method for the research and the practice in the field, is helpful for further deepening the understanding of the language model reasoning process, and promotes the related technology to develop towards a more transparent, interpretable and reliable direction.
Drawings
FIG. 1 is a flow chart of a method for solving a mental chain reasoning mathematical problem based on a feature classifier;
FIG. 2 is a schematic diagram of a forward and reverse example build inference path spanning tree;
FIG. 3 is a schematic diagram of a filtering inference path tree node;
fig. 4 is a flowchart of support vector machine feature classifier training.
Detailed Description
The invention will be described in further detail with reference to the drawings and examples, it being noted that the examples described below are intended to facilitate the understanding of the invention and are not intended to limit the invention in any way.
As shown in fig. 1, a method for solving a thinking chain reasoning mathematical problem based on a feature classifier comprises the following steps:
(1) Obtain a mathematical problem dataset problem set q= { Q 1,q2…qn }, and find a corresponding example of a mental chain for each element Q i AndSo thatA correct answer is obtained and the user can obtain the correct answer,Obtaining wrong answers, forming a new set Q ′={q1 ′,q′ 2…q′ n }, wherein
(2) Based on the composed set Q ′, a pre-training predictive model is input by using a mental chain prompting method, a word-level reasoning path spanning tree is constructed, and each node n i stores an attention weight matrix a j after the average pooling and difference operation.
(3) Traversing all the reasoning path spanning trees generated in the step (2), and screening nodes meeting the requirements to construct a feature classifier training set, wherein the requirements are that all the reasoning path results passing through the nodes are the same, namely correct or incorrect. And (3) taking the attention weight matrix A i of the node as a characteristic, taking an inference path result as a label, and constructing a training data sample pair set D.
(4) And (3) training the feature classifier C by using a Support Vector Machine (SVM) algorithm according to the training set generated in the step (3). Firstly, extracting the characteristics of each element of the training data set D as input, taking an inference path result as a label, and carrying out standardization processing on the data. Then, the data is mapped to a high-dimensional feature space using the radial basis functions as kernel functions, the SVM model is trained, model performance is estimated using cross-validation, and the hyper-parameters are adjusted as needed. Finally, the trained model is saved for subsequent reasoning.
(5) And (3) in the pre-training language model reasoning stage, for the target mathematical problem q to be solved, randomly selecting two examples d a and d b in the data set, simultaneously carrying out reasoning, continuing to predict and generate until the end if the reasoning paths are the same, and if the reasoning paths are different, continuing to reason the word with higher correct probability selected by the feature classifier C trained in the step (4). And finally, obtaining a complete reasoning process and extracting corresponding answers.
In step (1), an original mathematical problem set to be solved is obtained, and a forward and reverse thinking chain example is selected to be spliced to form a new model input set, wherein the mathematical problem set to be solved is defined as q= { Q 1,q2…qn }, and each element Q i expresses a specific problem in the problem set. For each question q i, find the corresponding forward example using the minlink hint generation methodAnd reverse exampleThe thought chain prompting method comprises the following steps:
Using p θ to represent the probability distribution fitted to a pre-trained large language model with parameter θ, x= { X 1,x2,…,xN } represents a text sequence of input length N. When the first i text sequences are entered, the language model predicts according to probability p θ(xi+1)=pθ(xi+1|x1,…,xi).
By usingN d mental chain cues are represented, where d i={qi,ri,ai is the ith example and q i,ri,ai represents the question, reasoning step and answer, respectively. If q represents the question to be inferred, the less sample thought chain can be defined as follows:
Where y= { r, a } is the generated reasoning step r and reasoning result a. Considering only the case where N d is 1 in this step, for each problem q i, traversing the mathematical problem set finds the corresponding example AndSo thatAnswers obtained with maximum probabilityCorrect and at the same timeAnswers obtained with maximum probabilityErrors, if no corresponding example is found, the problem is eliminated. Finally, combining the problems in the original dataset and the corresponding forward and reverse examples can yield a new set Q ′={q1 ′,q′ 2…q′ m, where m.ltoreq.n
In the step (2), the new set elements are respectively input into a model to be inferred and constructed into a text-level inference path spanning tree, and the attention weight matrix after pooling difference processing is selected to be stored as node characteristics.
Traversing the new set Q ′ generated by the combination of step (1) forInput text for obtaining model by simple splicingAll parameters of the frozen model are processed, and forward reasoning is performed by taking the parameters as input of the pre-training language model. In the reasoning process, q i ′ corresponds to generating a reasoning path tree G i = { V, E }, where V represents a vertex set and E represents an edge set. Each node n j in the vertex set contains three classes of attributes (f (A j,l),xj,rj), where x j represents the text of the current node, r j represents the correct rate of all inference paths through node n j A j represents the attention weight matrix of the model when the prediction generates x j, and since the pre-training language model uses a multi-head mask self-attention mechanism, the sequence lengths of its input models are different, and the multi-head attention weight matrix is dimensionally transformed and processed using the f (-) function.
The f (a j, l) function performs mainly two steps on the multi-headed attention weight matrix, the first step using a linear difference method to compress or expand the matrix a ij from the dimension j x j to a fixed length l. In the implementation process, l=30 is set according to experimental experience. And secondly, carrying out average pooling processing on the layer dimension of the multi-head self-attention matrix to finally obtain a feature matrix with a fixed size, and storing the feature matrix as a feature matrix of the node.
After describing the tree and the attributes contained by the nodes, the process of building the inference path tree in detail is described below. First, an empty node n root is constructed as the root node of the inference path tree, labeled as a non-leaf node. In building the tree, one of the non-leaf nodes (randomly chosen if there are multiple nodes) is found among the end nodes of each path of the tree, which is set to n i. The path from root node n root to node n i may represent an inferred pathThe child node condition of node n i is then determined. In particular, we willAnd (3) withRespectively inputting a pre-trained language model, as shown in fig. 2, when the first i text sequences are input, the language model predicts according to the following probabilities:
then x i+1 has the following two cases:
first, the text generated for the two campt runs is the same, i.e Then node n i adds a child node n i+1 with the text attribute set toIf it isIs a sentence terminator, the child node is marked as a leaf node.
Second, the text generated for the two campt runs is different, i.eThen insert left and right child nodes for node n i, respectivelyText attributes are respectively set asAndIf it isIs a sentence terminator, then the child node is markedIs a leaf node ifIs a sentence terminator, then the child node is markedIs a leaf node.
And so on until the end nodes of each path of the tree are leaf nodes. Finally, all elements in the new set Q ′ can generate their corresponding inference path tree, and the set g= { G 1,G2,...Gm } of the tree can be obtained.
In step (3), traversing the inference path spanning tree from step (2), screening nodes meeting requirements, labeling and constructing a training data sample set together with characteristic attributes thereof. The specific implementation process is as follows.
First, the set G of trees generated in step (2) includes m trees, the inference path corresponding to each problem in the mathematical problem set Q ′ generates a tree, and each node in the tree includes three attributes, n i=(f(Ai,l),xi,ri), which are the feature matrix, the text, and the accuracy of all the inference paths passing through the node n i. It is defined that it is assumed that for an inference path spanning tree, paths from the root node to the leaf nodes constitute an inference path and that for an inference path there is a unique attribute a indicating the correctness of the result of this inference path, where 1 indicates correctness and 0 indicates error. The following formula can thus be derived:
Where β (n i,Sj) represents whether the node n j belongs to the inference path S j, if so, the value is 1, and if not, the value is 0, and the inference path correctness of all nodes of all trees in the tree set G is calculated according to the above formula.
And then screening out nodes meeting the requirements based on the following conditions as a training data set of the training feature classifier:
1) The nodes do not belong to root nodes and leaf nodes;
2) The r attribute value of the node is 0 or 100, namely, consider the situation that the answers of the reasoning paths passing through the node are all wrong or all correct.
Finally, all the nodes meeting the conditions are combined into a node set n= { N 1,n2. As shown in fig. 3, in the inference path spanning tree, there are a plurality of inference paths corresponding to correct or incorrect results, and according to the above-mentioned screening conditions, thickened nodes can be selected as training sample sets.
In step (4), a support vector machine feature classifier D (x) is trained. As shown in fig. 4, firstly, a training data set is prepared, a node set meeting the conditions is screened out based on the step (3), and a training set t= { (x 1,y1),(x2,y2),...,(xn,yn) } is constructed. Where x n represents the feature of the node attention weight matrix after the average pooling in the layer dimension and the linear difference processing in the sequence length dimension, y n e {1, -1} is a label, indicating the correctness and the error of the reasoning result. Next, a definition kernel function is selected. The method adopts a radial basis function as a kernel function, maps data to a high-dimensional feature space, and determines an optimal parameter value by using a cross-validation mode. The support vector machine takes the maximized Lagrangian dual problem as an objective function, and the quadratic programming problem is decomposed into a series of solvable sub-problems through a sequence minimum optimization algorithm to optimally solve the objective function. The method can reduce the computational complexity, improve the training efficiency of the support vector machine on a large-scale data set, and further obtain Lagrange multipliers.
The resulting final classification decision function is summarized as follows. Given a new input sample x, the similarity of this sample to all training samples x i is calculated by a kernel function K (x i, x) and then these similarities are weighted and summed, where α iyi is derived from the lagrangian multiplier learned during training and the labels of the training samples. And finally adding a bias term b, and obtaining a classification result through a sign function sign. If the result is positive, the sample is classified as a positive class (+1) corresponding to a node that acts positively on the inference result, and if the result is negative, the sample is classified as a negative class (-1) corresponding to a node that acts negatively on the inference result.
In the step (5), the solution stage is carried out on the test set of the data question set, and mainly comprises four parts of contents, namely, selection of examples, reasoning of a pre-training language model, intervention of the feature classifier trained in the step (4) in the reasoning process, and finally extraction of generated answers. The method comprises the following steps:
Firstly, selecting an example, namely randomly selecting two problem examples d a and d b as the context of a thought chain prompt for the problem q i of a mathematical problem set to be inferred
And (2) reasoning of the pre-training language model, wherein the reasoning generation logic of the step (2) is used, two examples are respectively combined with the problem to serve as input of the pre-training language model, and the two reasoning paths are compared. If the text generated at present is the same as the text generated at present under the prompt of examples d a and d b, continuing to reason, and if the text generated at present is different, introducing a feature classifier C to perform judgment and selection. The attention weight matrix used for generating the current text is calculated for the two, and the average pooling of the layer dimension and the linear interpolation of the sequence length dimension are performed, so that the feature matrix a a in the example d a and the feature matrix a b in the example d b can be obtained. The feature matrix obtains a classification result (+1: positive class, -1: negative class) by the feature classifier C (x), the classification result is contained in the following 3 cases, and the following processes are performed according to the cases, respectively:
1. C (a a)=C(Ab) =1, i.e. in the current text, both play a positive role in the correctness of the inference path generation, in which case the larger numerical term in the sign function in the feature classifier C is selected as the content of the currently generated text prediction.
2. C (a a)=-1,C(Ab) =1 or C (a a)=1,C(Ab) = -1, i.e. for the current text, both examples act positively and negatively, respectively, for the correctness of the correct inference path generation. In this case, a text of C (x) =1 is selected as the currently generated text prediction content.
3. C (a a)=C(Ab) = -1, i.e. in the current text, both play a negative role in the correctness of the inference path generation, in which case the smaller numerical terms in the sign function in the feature classifier C are selected as the current generated text prediction content.
And finally obtaining the reasoning process and the answer of the mathematical problem according to the rules.
The invention also comprises a thinking chain reasoning mathematical problem solving system based on the feature classifier, and the method comprises the steps of:
And the thinking chain prompt generation module is used for acquiring the mathematical reasoning problem to be processed, selecting examples and instructions meeting the requirements according to the problem, and forming complete input of the pre-training language model.
And the inference path tree generation and feature screening module is used for generating a word-level inference path generation tree and screening out a feature training data set meeting the requirements.
The feature classifier training module is used for training the feature classifier, introducing a support vector machine algorithm based on a feature training data set, mapping data to a high-dimensional feature space by using a radial basis function as a kernel function, and improving SVM training efficiency by using a sequence minimum optimization algorithm.
And the reasoning module is guided by the feature classifier and is used for solving the mathematical reasoning problem to be processed. The pre-training language model is guided to select a more accurate reasoning path through intervention of the feature classifier, so that a final mathematical problem reasoning process and a final mathematical problem answer are obtained.
The foregoing embodiments have described in detail the technical solution and the advantages of the present invention, it should be understood that the foregoing embodiments are merely illustrative of the present invention and are not intended to limit the invention, and any modifications, additions and equivalents made within the scope of the principles of the present invention should be included in the scope of the invention.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411479942.2A CN119443267B (en) | 2024-10-23 | 2024-10-23 | A method and system for solving mathematical problems based on feature classifier-based thought chain reasoning |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411479942.2A CN119443267B (en) | 2024-10-23 | 2024-10-23 | A method and system for solving mathematical problems based on feature classifier-based thought chain reasoning |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN119443267A true CN119443267A (en) | 2025-02-14 |
| CN119443267B CN119443267B (en) | 2025-11-14 |
Family
ID=94529754
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411479942.2A Active CN119443267B (en) | 2024-10-23 | 2024-10-23 | A method and system for solving mathematical problems based on feature classifier-based thought chain reasoning |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN119443267B (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119621974A (en) * | 2025-02-17 | 2025-03-14 | 科大讯飞股份有限公司 | A test question label prediction method, device, storage medium and equipment |
| CN119808966A (en) * | 2025-03-13 | 2025-04-11 | 浙江吉利控股集团有限公司 | Intelligent decision-making method, computer device and computer-readable storage medium |
| CN119808967A (en) * | 2025-03-14 | 2025-04-11 | 北京博大网信股份有限公司 | Visual thinking operating system and mathematical reasoning method for mathematical reasoning |
| CN120336491A (en) * | 2025-06-17 | 2025-07-18 | 南京信息工程大学 | An automatic thought chain prompt generation method based on black box optimization and vulnerability quantification |
Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20230244938A1 (en) * | 2022-02-02 | 2023-08-03 | Google Llc | Using Chains of Thought to Prompt Machine-Learned Models Pre-Trained on Diversified Objectives |
| CN116595159A (en) * | 2023-07-18 | 2023-08-15 | 深圳须弥云图空间科技有限公司 | Mathematical question answering model training method and device |
| CN117669536A (en) * | 2023-10-19 | 2024-03-08 | 西华大学 | A deep fine-tuning method for generating logical reasoning thinking chains in Chinese text |
| CN117892818A (en) * | 2024-03-18 | 2024-04-16 | 浙江大学 | Large language model rational content generation method based on implicit thinking chain |
| CN118333153A (en) * | 2024-04-23 | 2024-07-12 | 之江实验室 | A flexible thinking chain learning method, device and medium based on large language model |
| CN118467737A (en) * | 2024-06-05 | 2024-08-09 | 北京邮电大学 | Event extraction method based on large language model to generate thought chain explanation for training |
| CN118690877A (en) * | 2024-08-23 | 2024-09-24 | 阿里巴巴(中国)有限公司 | Natural language model generation method and data processing method |
| CN118709786A (en) * | 2024-08-06 | 2024-09-27 | 西安家育宝智能科技有限公司 | Reasoning method and device of large language model based on thinking tree |
| CN118747530A (en) * | 2024-06-07 | 2024-10-08 | 天津汲智科技有限公司 | A dual-model reflective learning method based on thinking chain correction and adaptive screening |
-
2024
- 2024-10-23 CN CN202411479942.2A patent/CN119443267B/en active Active
Patent Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20230244938A1 (en) * | 2022-02-02 | 2023-08-03 | Google Llc | Using Chains of Thought to Prompt Machine-Learned Models Pre-Trained on Diversified Objectives |
| CN116595159A (en) * | 2023-07-18 | 2023-08-15 | 深圳须弥云图空间科技有限公司 | Mathematical question answering model training method and device |
| CN117669536A (en) * | 2023-10-19 | 2024-03-08 | 西华大学 | A deep fine-tuning method for generating logical reasoning thinking chains in Chinese text |
| CN117892818A (en) * | 2024-03-18 | 2024-04-16 | 浙江大学 | Large language model rational content generation method based on implicit thinking chain |
| CN118333153A (en) * | 2024-04-23 | 2024-07-12 | 之江实验室 | A flexible thinking chain learning method, device and medium based on large language model |
| CN118467737A (en) * | 2024-06-05 | 2024-08-09 | 北京邮电大学 | Event extraction method based on large language model to generate thought chain explanation for training |
| CN118747530A (en) * | 2024-06-07 | 2024-10-08 | 天津汲智科技有限公司 | A dual-model reflective learning method based on thinking chain correction and adaptive screening |
| CN118709786A (en) * | 2024-08-06 | 2024-09-27 | 西安家育宝智能科技有限公司 | Reasoning method and device of large language model based on thinking tree |
| CN118690877A (en) * | 2024-08-23 | 2024-09-24 | 阿里巴巴(中国)有限公司 | Natural language model generation method and data processing method |
Non-Patent Citations (2)
| Title |
|---|
| THIEN-LOC HA,: "Auto Graph of Thoughts: A Hands-free and Cost Effective Method for using Graph of Thoughts", 《PROCEEDINGS OF THE 2024 10TH INTERNATIONAL CONFERENCE ON COMPUTER TECHNOLOGY APPLICATIONS》, 26 August 2024 (2024-08-26) * |
| 罗焕坤: "大语言模型在数学推理中的研究进展", 《计算机工程》, vol. 50, no. 9, 30 September 2024 (2024-09-30) * |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119621974A (en) * | 2025-02-17 | 2025-03-14 | 科大讯飞股份有限公司 | A test question label prediction method, device, storage medium and equipment |
| CN119621974B (en) * | 2025-02-17 | 2025-04-11 | 科大讯飞股份有限公司 | Test question label prediction method, device, storage medium and equipment |
| CN119808966A (en) * | 2025-03-13 | 2025-04-11 | 浙江吉利控股集团有限公司 | Intelligent decision-making method, computer device and computer-readable storage medium |
| CN119808967A (en) * | 2025-03-14 | 2025-04-11 | 北京博大网信股份有限公司 | Visual thinking operating system and mathematical reasoning method for mathematical reasoning |
| CN120336491A (en) * | 2025-06-17 | 2025-07-18 | 南京信息工程大学 | An automatic thought chain prompt generation method based on black box optimization and vulnerability quantification |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119443267B (en) | 2025-11-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Cheng et al. | A survey on deep neural network pruning: Taxonomy, comparison, analysis, and recommendations | |
| CN119443267B (en) | A method and system for solving mathematical problems based on feature classifier-based thought chain reasoning | |
| CN114969278B (en) | A text question answering model based on knowledge-enhanced graph neural network | |
| CN112132179A (en) | Incremental learning method and system based on a small number of labeled samples | |
| CN111985245A (en) | Relation extraction method and system based on attention loop-gated graph convolutional network | |
| CN112069310A (en) | Text classification method and system based on active learning strategy | |
| CN118132674A (en) | Text information extraction method based on large language model and high-efficiency parameter fine adjustment | |
| CN118041744A (en) | Fault diagnosis method for power backbone communication network based on knowledge graph reasoning | |
| Zhou et al. | On the opportunities of green computing: A survey | |
| CN117407532A (en) | Method for enhancing data by using large model and collaborative training | |
| Gong et al. | Margin based PU learning | |
| Zheng et al. | Named entity recognition: A comparative study of advanced pre-trained model | |
| Pereira et al. | Neural architecture search with interpretable meta-features and fast predictors | |
| Vento et al. | Traps, pitfalls and misconceptions of machine learning applied to scientific disciplines | |
| CN118195032B (en) | Large model automatic evolution system and method with active learning capability | |
| Lee et al. | Can we utilize pre-trained language models within causal discovery algorithms? | |
| CN118606469A (en) | Multi-classification prediction method for intangible cultural heritage text based on multi-head attention and semantic features | |
| CN119106118A (en) | A text question answering method and system in the field of urban scene safety | |
| Lekan et al. | Comparison of Neural Networks with Traditional Machine Learning Models (eg, XGBoost, Random Forest) | |
| Akinci et al. | Machine Learning Methods from Shallow Learning to Deep Learning | |
| Anireh et al. | HTM-MAT: An online prediction software toolbox based on cortical machine learning algorithm | |
| Katib et al. | Question Answering System Based on Bideirectional Long-Short-Term Memory (Bilstm) | |
| Zheng et al. | Thoughtful and cautious reasoning: A fine-tuned knowledge graph-based multi-hop question answering framework | |
| CN118210907B (en) | A method for constructing intelligent question answering model based on vectorized representation of knowledge graph | |
| Argyrou | Clustering hierarchical data using self-organizing map: a graph-theoretical approach |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |