Knowledge graph and dynamic pruning optimization-based big language model mathematical inference method

By constructing a structured knowledge graph and a large language model mathematical inference method with dynamic pruning optimization, the hallucination problem of large language models in mathematical reasoning is solved, higher accuracy and reliability are achieved, and mathematical understanding and deductive ability are improved.

CN120671854AActive Publication Date: 2025-09-19JIANGXI NORMAL UNIV

Patent Information

Application Number
CN202511163691.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-20
Publication Date
2025-09-19
Estimated Expiration
2045-08-20

AI Technical Summary

Technical Problem

Large language models frequently experience hallucinations in mathematical reasoning tasks and lack explicit modeling of structural relationships such as knowledge points, theorems, and formulas, resulting in a lack of logical support and controllability in the problem-solving process. Existing technologies rely on external tools or high-cost fine-tuning, making it difficult to meet actual needs.

Method used

Construct a large language model mathematical inference method based on knowledge graph and dynamic pruning optimization. By building a structured knowledge graph to integrate mathematical concepts and semantic edge relationships, combined with the discrimination-difficulty parameter mechanism, dynamically control the reasoning path, select high-quality starting nodes, perform path expansion and pruning, and optimize the problem-solving process.

Benefits of technology

It significantly improves the accuracy and reliability of large language models in mathematical reasoning, provides a controllable reasoning support environment, reduces the risk of path divergence, and enhances mathematical understanding and deductive ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120671854A_ABST
    Figure CN120671854A_ABST
Patent Text Reader

Abstract

The invention discloses a big language model mathematical inference method based on a knowledge graph and dynamic pruning optimization, and the method comprises the steps: constructing a mathematical data set containing multi-level knowledge points and complexity scores, and building a structured knowledge graph fusing mathematical concepts, theorems and the like; and extracting knowledge points of the to-be-solved question and expanding the triple to obtain a comprehensive difficulty score. When the score is smaller than or equal to a threshold value, directly calling a large language model for reasoning; if the result is larger than the threshold value, an initial search tree is built through search tree starting point modeling, and an optimal path and an answer are obtained through path expansion and pruning and path scoring and optimization. According to the method, reasoning support is provided through the knowledge graph, and the mathematical understanding and deduction ability and reasoning stability and effectiveness of the model are improved in combination with difficulty parameters and dynamic pruning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of large language model reasoning technology, and specifically to a large language model mathematical inference method based on knowledge graph and dynamic pruning optimization. Background Art

[0002] In recent years, large language models (LLMs) have made significant progress in natural language processing, demonstrating exceptional capabilities in tasks such as text generation, question answering, and translation. However, in knowledge-intensive tasks such as mathematical reasoning, LLMs often exhibit so-called "hallucination" problems, where the generated reasoning or answers deviate from the facts or even contain fabricated information. This phenomenon is particularly evident in solving mathematical word problems, as mathematical problems require rigorous logic and clear steps. If a deviation occurs in the reasoning at any intermediate step, the final answer will be incorrect, thus affecting the reliability of the system. For example, when comparing the size of numbers, some large models may draw incorrect conclusions based on sentence patterns (e.g., misinterpreting "9.11" as greater than "9.8"), exposing the limitations of the model's reliance on language patterns rather than true mathematical semantics.

[0003] To address this issue, industry and academia have proposed a series of improvements, but some approaches remain inadequate. For example, instruction fine-tuning methods use supervised, fine-grained fine-tuning of models on large-scale, high-quality mathematical problems and detailed explanations, enabling the model to master formulas, theorems, and problem-solving steps, thereby significantly improving the accuracy of multi-step mathematical reasoning. However, these methods rely on massive amounts of high-quality data, making fine-tuning expensive and time-consuming. Furthermore, the models are easily limited by the distribution of the training data, requiring re-fine-tuning whenever the reasoning scenario changes.

[0004] Another approach is tool enhancement, which dynamically calls external calculators or symbolic solvers (such as Mathematica and Sympy) during inference to ensure the accuracy of numerical calculations and symbolic derivations. Tool enhancement improves inference accuracy and the model's ability to handle complex calculations, but it relies heavily on the stability of external tools, increasing the complexity of system deployment and maintenance.

[0005] Overall, existing technologies mainly rely on prompt engineering, instruction fine-tuning or external tools, but lack the introduction and utilization of structured knowledge in the field of mathematics. The model lacks explicit modeling and calling of structural relationships such as knowledge points, theorems, and formulas, resulting in a lack of logical support in the problem-solving process, which is prone to misuse of concepts or skipped reasoning. In addition, the reasoning process lacks controllability, and most adopts a "one-step generation to the end" approach, lacking effective monitoring and intervention of intermediate steps. The reasoning chain is prone to jumps or breaks and lacks explainability. At the same time, existing technologies lack a mechanism for dynamically eliminating unreasonable content, and are unable to adjust or eliminate illogical hallucination paths in a timely manner. These deficiencies lead to frequent hallucinations in large models in complex mathematical problems, and the accuracy and reliability are difficult to meet actual needs. Therefore, there is an urgent need for a new method to combine structured domain knowledge and dynamically control the reasoning process to fundamentally alleviate the hallucination problem of large language models in mathematical reasoning. Summary of the Invention

[0006] In response to the shortcomings of the existing technology, the present invention provides a large language model mathematical inference method based on knowledge graph and dynamic pruning optimization, which aims to solve the problems in the background technology.

[0007] To achieve the above objectives, the present invention provides the following technical solution: a large language model mathematical inference method based on knowledge graph and dynamic pruning optimization, comprising the following steps: Step S1: Construct a data set containing several primary and secondary school mathematics problems containing multi-level knowledge points; assign knowledge attribute labels representing complexity scoring parameters to the knowledge points corresponding to the primary and secondary school mathematics problems; Step S2: Given a math problem to be solved, extract the initial knowledge point entity set in the math problem through the large language model, perform semantic expansion on the initial knowledge point entity set, and construct the corresponding expanded triple set; Step S3: Construct a structured knowledge graph based on primary and secondary school mathematics problems, use extended triples to search the structured knowledge graph, obtain relevant knowledge point subgraphs, and read the complexity scores of relevant knowledge points from the relevant knowledge point subgraphs as the comprehensive difficulty scores of the corresponding mathematics problems to be solved; Step S4: When the comprehensive difficulty score ≤ preset threshold When the large language model is directly called for reasoning, the corresponding mathematical problem to be solved is generated. Problem solving process and answers ; Step S5: When the comprehensive difficulty score >Preset threshold When the corresponding math problem to be solved, the relevant knowledge point subgraph and the corresponding complexity scoring parameters are input into the search tree starting point modeling module. In the search tree starting point modeling module, the semantic matching between the math problem to be solved and the knowledge point is analyzed, and the complexity scoring parameters of the knowledge point are combined to select the most relevant knowledge point as the starting point of the search tree. Based on this information, the initial search tree is constructed and the frontier queue is generated. Step S6: The initial search tree and the frontier queue are input into the path expansion and pruning module. In the path expansion and pruning module, the inference path is expanded based on the initial search tree and the frontier queue, and the path scores are calculated to perform pruning, with high-scoring paths being retained first. Finally, a set of paths to be evaluated and a priority queue are obtained. Step S7: Input the set of paths to be evaluated and the priority queue into the path scoring and optimization module. In the path scoring and optimization module, the reward model is used to score each path to be evaluated. The logical structure, semantic matching and target orientation of the path to be evaluated are comprehensively considered. Through multi-dimensional evaluation, the path with the highest score is selected, and the node status is updated based on the feedback mechanism to obtain the optimal path and answer.

[0008] Furthermore, the specific process of step S1 is: Step S1.1: Collect a number of primary and secondary school mathematics problems containing multi-level knowledge points; Step S1.2: Preprocessing the collected primary and secondary school mathematics problems, including cleaning and deduplication of the primary and secondary school mathematics problems and labeling knowledge points; Step S1.3: Assign knowledge attribute labels representing complexity scores to the preprocessed knowledge points of primary and secondary school mathematics problems and construct a dataset; The specific process of step S1.3 is: Step S1.31: Collecting answer data for a number of primary and secondary school mathematics problems; constructing a question-respondent response matrix based on the answer data for the primary and secondary school mathematics problems; each cell in the question-respondent response matrix indicates whether the respondent's answer to the question is correct; Step S1.32: Based on the question-respondent response matrix, use a two-parameter logistic model to estimate the discrimination parameter of each knowledge point for the primary and secondary school mathematics questions. and difficulty parameters ; Step S1.33: Establish the mapping relationship between primary and secondary school mathematics problems and knowledge points, according to the discrimination parameters of primary and secondary school mathematics problems and difficulty parameters Perform weighted aggregation on the associated knowledge points and generate the complexity score of each knowledge point as the knowledge attribute label; Step S1.34: Manually check and correct the primary and secondary school mathematics problems corresponding to the knowledge points assigned knowledge attribute labels, and construct a data set.

[0009] Furthermore, in step S2, the mathematical problem to be solved is expressed as , Indicates the first A token of a character or word, Indicates the number of characters or words.

[0010] Furthermore, the specific process of constructing a structured knowledge graph based on primary and secondary school mathematics problems is as follows: Step S3.11: Extract entities and semantic relationships from primary and secondary school mathematics problems to form a preliminary set of triples; the entities include head entities and tail entities; Step S3.12: Import the preliminary triple set into the graph database to build a structured knowledge graph; the structured knowledge graph adopts a directed graph structure based on triples, represented as , Indicates the The head entity of the preliminary triple, Indicates the The semantic relationship of the initial triples, express The tail entity of the preliminary triple; Indicates the number of preliminary triples.

[0011] Furthermore, the related knowledge point subgraph is represented as , Represents the node set in the related knowledge point subgraph, Represents the semantic edge set in the related knowledge point subgraph; From the related knowledge point subgraph Read the complexity score of the relevant knowledge points as the corresponding math problem to be solved The specific process of comprehensive difficulty scoring is as follows: From the relevant knowledge point subgraph through the large language model Identify math problems to be solved A collection of semantically related knowledge points ,in, Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related knowledge points; Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related Knowledge points, ; Identified mathematical problems to be solved Semantically related knowledge points are related knowledge point subgraphs Nodes in Calculate the math problems to be solved through a large language model With the Knowledge points The attention score between , to solve math problems Normalize the attention scores between all knowledge points to get the knowledge points Approaching math problems The importance of semantic relations ; Based on the importance of semantic relations , knowledge points Corresponding complexity scoring parameters To calculate the math problem to be solved Overall difficulty rating : ; in, Representing knowledge points The corresponding discrimination parameter; Representing knowledge points The corresponding difficulty parameter.

[0012] Furthermore, the specific process of step S5 is as follows: Step S5.1: Based on the mathematical problem to be solved and related knowledge point subgraphs To construct a large language model input prompt string ; Step S5.2: Input the large language model into the prompt string Input into the large language model and output a set of candidate knowledge points as the starting point of reasoning , Indicates the candidate knowledge points in natural language form; Step S5.3: Collect candidate knowledge points The candidate knowledge points in natural language Match to relevant knowledge point subgraph The nodes in , get the mapping node set , Representing related knowledge point subgraphs Corresponding Mapping node; Step S5.4: Calculate the mapping node and math problems to be solved Semantic relevance score : ; Where, Represents a mathematical problem to be solved Semantic feature vector of express The structure embedding vector of Step S5.5: According to the mapping node Corresponding complexity scoring parameters To calculate the structural score of the mapping node ; Represents a mapping node The corresponding discrimination parameter, Represents a mapping node The corresponding difficulty parameter; Step S5.6: Score based on semantic relevance and the structural score of the mapping node To calculate the comprehensive score of the mapping node : ; Where, 、 All represent adjustable hyperparameters. ; Step S5.7: Comprehensive score of the mapping node As a basis, set the threshold , filter out the comprehensive score not lower than the threshold Mapping nodes to build a search starting point candidate pool ; Step S5.8: Search the starting point candidate pool In the example, based on the comprehensive score of the node Sort and select the mapping node with the highest score as the root node of the search tree ; Step S5.9: Search the root node of the tree As the root of the tree, from the relevant knowledge point subgraph Filter the semantic relationships that meet the settings to build the initial search tree ; Step S5.10: Search the candidate pool for the starting point All mapping nodes in the table are ranked according to their corresponding comprehensive scores. Sort in descending order and build a frontier queue , Represents the candidate node in the frontier queue; express depth.

[0013] Furthermore, the specific process of step S6 is as follows: Step S6.1: Depth With the maximum depth threshold For comparison, when , then based on the initial search tree The specific process of the expansion operation is as follows: definition The set of legal adjacent points : ; Where, represents a candidate expansion node; Will Append to Corresponding path On the basis of the above, a set of paths to be evaluated is formed. ; Step S6.2: Budget pruning strategy: based on comprehensive difficulty score ,dynamically control the expansion operation; Let the total number of path nodes generated by the current search tree be , then the maximum number of nodes allowed to be expanded in this round is for: ; Where, represents the scaling factor; represents the expansion adjustment coefficient; For all candidate expansion nodes Perform semantic structure scoring, scoring function Defined as: ; Where, Represents a candidate expansion node The structure embedding vector of Represents a candidate expansion node Structural scoring parameters of Keep the highest rated candidate expansion nodes, forming a preliminary pruning set ; Step S6.3: Logical consistency pruning strategy: define consistency judgment function : ; Where, express arrive The semantic relationship type of Represents the set of allowed semantic relations; express Attribute conditions; According to the consistency judgment function Initial pruning set Screening to obtain a valid candidate set ; For each , update its cumulative number of visits: ; Where, express The cumulative number of visits during the search process; Step S6.4: Frontier Queue Update to get the priority queue : ; Where, express Comprehensive rating of express depth.

[0014] Furthermore, the specific process of step S7 is as follows: Step S7.1: Set the set of paths to be evaluated as , Indicates the first path in the set of paths to be evaluated. Paths to be evaluated; Indicates the number of paths to be evaluated in the set of paths to be evaluated; based on the priority queue , record the access status of nodes in the path to be evaluated; Step S7.2: Introducing a multi-dimensional reward model , for multi-dimensional reward models Conduct training, Input to the trained multi-dimensional reward model In the equation, we get a three-dimensional rating vector, which is expressed as: ; Where, express Logical consistency score; express Semantic matching score of express Target fit score; Step S7.3: Perform weighted fusion on the obtained three-dimensional score vector to obtain Bonus score , expressed as: ; Where, All are adjustable parameters. ; Step S7.4: Based on the reward score , select the set of paths to be evaluated The optimal path in : ; Step S7.5: The optimal path The nodes in the path are connected in sequence to construct the mathematical problem to be solved. Complete structured problem-solving process and summarize to get answer A.

[0015] Furthermore, for the multi-dimensional reward model The specific process of training is as follows: Based on the standard answer database PIB Annotation Label , combined with and the corresponding Form labeled path sample pairs ,based on Multi-dimensional reward model The goal of the training process is to minimize the mean square error loss function.

[0016] Furthermore, a back propagation mechanism is designed to convert the optimal path Bonus score Feedback to its own intermediate node; for the optimal path The intermediate node , update its visit count and accumulated reward points , and calculate its average historical score .

[0017] Compared with the existing technology, the present invention has the following beneficial effects:

[0018] (1) This invention constructs a structured knowledge graph for mathematical reasoning tasks, integrates mathematical concepts, theorems, formulas and semantic edge relationships, and introduces a discrimination-difficulty parameter mechanism to improve the discriminability and organization of knowledge points in structural reasoning, providing a controllable and searchable reasoning support environment for large language models, and significantly enhancing the mathematical understanding and deductive ability of the model.

[0019] (2) The present invention combines the comprehensive difficulty of the questions with the predefined semantic relationship to achieve precise control and complexity compression in the path expansion process; to address the problem of high uncertainty in the generation of reasoning paths for large language models, the present invention proposes a starting point modeling mechanism that integrates semantic relevance and difficulty scoring, accurately selects high-quality starting nodes, effectively guides the direction of reasoning tree construction, reduces the risk of path divergence, and improves reasoning stability and generation effectiveness. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flow chart of the steps of the present invention. DETAILED DESCRIPTION

[0021] like Figure 1 As shown, the present invention provides a technical solution: a large language model mathematical inference method based on knowledge graph and dynamic pruning optimization, comprising the following steps: Step S1: Construct a data set, which includes a number of primary and secondary school mathematics problems containing multi-level knowledge points; assign knowledge attribute labels representing complexity scoring parameters to the knowledge points corresponding to the primary and secondary school mathematics problems.

[0022] Since existing public datasets are mainly composed of questions, solution steps and answers, they generally lack structured association information between questions and knowledge points, especially lack of annotation of knowledge point hierarchical classification, theorem attribution and difficulty estimation, which makes it difficult to meet the needs of knowledge graph construction and reasoning path control in this invention. This invention constructs a dataset of mathematical knowledge point relationships and reasoning tasks for elementary to junior high school students. The specific process is as follows: Step S1.1: Approximately 24,000 primary and secondary school mathematics problems containing multiple levels of knowledge points (12 first-level knowledge points, 75 second-level knowledge points, and 395 third-level knowledge points) were collected from multiple public mathematics test paper repositories and online learning platforms, covering a variety of types such as arithmetic, algebra, geometry, and word problems. Knowledge point definitions:

[0023] Level 1 knowledge points: broad areas of mathematics, usually divided by grade; Level 2 knowledge points: refinement of level 1 knowledge points, usually corresponding to specific chapters, involving specific mathematical concepts and skills; Level 3 knowledge points: the most detailed classification, focusing on specific formulas, theorems, etc., usually corresponding to the contents of subsections in chapters.

[0024] Step S1.2: Preprocess the collected primary and secondary school mathematics problems. The preprocessing includes cleaning and deduplication of the primary and secondary school mathematics problems and labeling of knowledge points. Specifically: Step S1.21: Clean and deduplicate primary and secondary school mathematics questions, removing redundant, ambiguous, and content that does not conform to the curriculum standards.

[0025] Step S1.22: Based on the graded dictionary of mathematics knowledge points compiled from the People's Education Press textbooks, automatically identify and preliminarily annotate the knowledge points in primary and secondary school mathematics problems. The annotation system covers multiple levels of knowledge points and prioritizes refining them to the third level to improve the semantic granularity and reasoning accuracy of the graph construction.

[0026] Step S1.23: To ensure the quality of annotation, a label consistency evaluation mechanism is introduced to perform similarity matching on the annotated knowledge points, and the result with the highest consistency is selected as the final annotation.

[0027] Step S1.3: Assign knowledge attribute labels representing complexity scoring parameters to the preprocessed knowledge points of primary and secondary school mathematics questions and construct a dataset; specifically: Step S1.31: Collect a large amount of answer data for primary and secondary school mathematics problems (real students' answer records and simulated answer results of artificial intelligence agents (AI agents) of different ability levels); construct a question-answering matrix based on the answer data for primary and secondary school mathematics problems; each cell in the question-answering matrix indicates whether the answerer's answer to the question is correct.

[0028] Step S1.32: Based on the question-respondent response matrix, use the two-parameter logistic model (2PL) in item response theory (IRT) to estimate the discrimination parameter of each elementary and middle school mathematics question corresponding to each knowledge point. and difficulty parameters .

[0029] Step S1.33: Establish a one-to-one or many-to-many mapping relationship between primary and secondary school mathematics problems and knowledge points, according to the discrimination parameters of primary and secondary school mathematics problems. and difficulty parameters The associated knowledge points are weighted and summarized to generate the complexity scoring parameters of each knowledge point as the knowledge attribute label, which is used in the subsequent reasoning path scheduling and pruning control mechanism.

[0030] Step S1.34: Manually check and correct the primary and secondary school mathematics problems corresponding to the knowledge points assigned with knowledge attribute labels, retain 8962 primary and secondary school mathematics problems, and construct a data set based on the retained primary and secondary school mathematics problems.

[0031] Step S2: Given a math problem to be solved , extracting the math problems to be solved through the Large Language Model (LLM) The initial knowledge point entity set in Perform semantic expansion and construct the corresponding extended triple set .

[0032] Among them, the mathematical problem to be solved is expressed as , Indicates the first A token of a character or word, Indicates the number of characters or words.

[0033] Step S3: Construct a structured knowledge graph based on primary and secondary school mathematics questions, using extended triples Retrieve the structured knowledge graph, obtain the relevant knowledge point subgraph, and read the complexity scoring parameters of the relevant knowledge points from the relevant knowledge point subgraph as the corresponding mathematical problems to be solved The overall difficulty rating.

[0034] Among them, the relevant knowledge point subgraph is represented as , Represents a variety of node sets in the related knowledge point subgraph, Represents the set of semantic edges in the related knowledge point subgraph.

[0035] The specific process of constructing a structured knowledge graph based on primary and secondary school mathematics questions is as follows: Step S3.11: Use entity dictionaries, rule templates, and dependency parsing methods to extract entities (including head entities and tail entities) and semantic relationships in primary and secondary school mathematics problems to form a preliminary set of triples.

[0036] Among them, entity types include knowledge points (Knowledge), theorems (Theorem), common formulas (Formula), variable constraints (Constraint), etc.; semantic relationship types include prerequisite relationships (Precedes), inclusion relationships (Contains), applicable conditions (ApplicableTo), reference relationships (References), etc.; each entity node also contains structural attributes, such as the textbook version, grade level, knowledge point level label, etc.

[0037] Among them, a manual review mechanism is introduced to proofread and resolve conflicts in the extracted entities and semantic relationships to ensure accuracy and consistency.

[0038] Step S3.12: Import the preliminary triple set into a graph database (such as Neo4j) to build a structured knowledge graph; the structured knowledge graph uses a directed graph structure based on triples and can be represented as , Indicates the The head entity of the preliminary triple, Indicates the The semantic relationship of the initial triples, express The tail entity of the preliminary triple; Indicates the number of preliminary triples.

[0039] Among them, in order to further enhance the representation ability of knowledge points in the atlas, the relevant knowledge point subgraphs can be Input graph convolutional neural network (GCN) to perform structure-aware embedding update on its nodes to obtain node embedding representation Specific: Set up relevant knowledge point subgraph Contains nodes, each node is initially represented as a The nodes of the relevant knowledge point subgraph are updated through the graph convolutional neural network (GCN), and the node embedding representation is finally obtained. .

[0040] Among them, from the relevant knowledge point subgraph Read the complexity scoring parameters of relevant knowledge points as the corresponding mathematical problems to be solved The specific process of comprehensive difficulty scoring is as follows: 1. Use the large language model to extract relevant knowledge points from the subgraph Identify math problems to be solved A collection of semantically related knowledge points ,in, Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related knowledge points; Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related Knowledge points, ; Identified mathematical problems to be solved Semantically related knowledge points are related knowledge point subgraphs Nodes in .

[0041] 2. Calculate the math problems to be solved through a large language model With the Knowledge points The attention score between , solve math problems through the softmax function Normalize the attention scores between all knowledge points to get the knowledge points Approaching math problems The importance of semantic relations .

[0042] 3. Based on the importance of semantic relationships , knowledge points Corresponding complexity scoring parameters To calculate the math problem to be solved Overall difficulty rating : . in, Representing knowledge points The corresponding discrimination parameter; Representing knowledge points The corresponding difficulty parameter.

[0043] Step S4: When the comprehensive difficulty score ≤ preset threshold When the large language model is directly called for reasoning, the corresponding mathematical problem to be solved is generated. Problem solving process and answers .

[0044] Step S5: When the comprehensive difficulty score >Preset threshold When the corresponding mathematical problem to be solved , related knowledge point sub-graph And the corresponding complexity scoring parameters Input to the search tree starting point modeling module, in the search tree starting point modeling module by analyzing the mathematical problem to be solved Based on the semantic matching of knowledge points and the complexity scoring parameters of knowledge points, the most relevant knowledge points are selected as the starting point of the search tree. Based on this information, the initial search tree is constructed and the frontier queue is generated.

[0045] Step S5.1: Based on the mathematical problem to be solved and related knowledge point subgraphs To construct a large language model input prompt string , in order to determine the optimal starting point of the search tree.

[0046] Step S5.2: Input the large language model into the prompt string Input into the large language model and output a set of candidate knowledge points that may serve as the starting point of reasoning , Indicates the candidate knowledge points in natural language form.

[0047] Step S5.3: Collect candidate knowledge points The candidate knowledge points in natural language Match to relevant knowledge point subgraph The nodes in , get the set of mapping nodes that are successfully matched , Representing related knowledge point subgraphs Corresponding The mapping node.

[0048] Step S5.4: Calculate the mapping node and math problems to be solved Semantic relevance score : ; Where, Represents a mathematical problem to be solved Semantic feature vector of express The structure embedding vector of .

[0049] get The process is: put the first word tokens Input a large language model and output a set of semantic feature vectors , Represents the first The dimensions are Context-aware vector of .

[0050] Step S5.5: According to the mapping node Corresponding complexity scoring parameters To calculate the structural score of the mapping node ; Represents a mapping node The corresponding discrimination parameter, Represents a mapping node The corresponding difficulty parameter.

[0051] Step S5.6: Score based on semantic relevance and the structural score of the mapping node To calculate the comprehensive score of the mapping node : ; Where, 、 All represent adjustable hyperparameters. .

[0052] Step S5.7: Comprehensive score of the mapping node As a basis, set the threshold , filter out the comprehensive score not lower than the threshold Mapping nodes to build a search starting point candidate pool : .

[0053] Step S5.8: Search the starting point candidate pool In the example, based on the comprehensive score of the node Sort and select the mapping node with the highest score as the root node of the search tree : .

[0054] Step S5.9: Search the root node of the tree As the root of the tree, from the relevant knowledge point subgraph Filter the semantic relationships that satisfy the "precedes" and "applicable to" relationships to build the initial search tree .

[0055] Step S5.10: Search the candidate pool for the starting point All mapping nodes in the table are ranked according to their corresponding comprehensive scores. Sort in descending order and build a frontier queue , Represents the candidate node in the frontier queue; express depth.

[0056] Step S6: Initial search tree and the frontier queue The input is sent to the path extension and pruning module. In the path extension and pruning module, the inference path is expanded based on the initial search tree and the frontier queue, and pruned by calculating the path score, giving priority to retaining high-scoring paths, and finally obtaining a set of paths to be evaluated and a priority queue.

[0057] Step S6.1: Depth With the maximum depth threshold For comparison, if , then based on the initial search tree The semantic relationship in the expansion operation is performed to prevent the reasoning process from falling into redundant or non-convergent search space; the specific process of the expansion operation is: definition The set of legal adjacent points : ; Where, represents a candidate expansion node, Must be in the knowledge graph and in the current search tree There are legal connections that ensure the expanded path remains attached to the initial search tree effective structure.

[0058] Will Append to Corresponding path On the basis of the above, a set of paths to be evaluated is formed. : ; Where, Represents a path concatenation operation.

[0059] Step S6.2: Budget pruning strategy: based on comprehensive difficulty score ,dynamically control the expansion operation; Let the total number of path nodes generated by the current search tree be , then the maximum number of nodes allowed to be expanded in this round is for: ; Where, represents the empirically set scaling factor; Indicates the expansion adjustment coefficient.

[0060] For all candidate expansion nodes Perform semantic structure scoring, scoring function Defined as: ; Where, Represents a candidate expansion node The structure embedding vector of Represents a candidate expansion node Structural scoring parameters.

[0061] Keep the highest rated candidate expansion nodes, forming a preliminary pruning set : ; Where, Express According to the scoring function Sort in descending order, select the top Candidate expansion node operation.

[0062] Step S6.3: Logical consistency pruning strategy: define consistency judgment function : ; Where, express arrive The semantic relationship type of Represents the set of allowed semantic relations; express Attribute conditions.

[0063] According to the consistency judgment function Initial pruning set Screening to obtain a valid candidate set : .

[0064] In order to support the path evaluation and reverse optimization mechanism, a node visit count recording mechanism is introduced; for each , update its cumulative number of visits: ; Where, express The cumulative number of visits during the search process.

[0065] Step S6.4: Frontier Queue Update to get the priority queue : ; Where, express Comprehensive rating of express depth.

[0066] Step S7: Input the set of paths to be evaluated and the priority queue into the path scoring and optimization module. In the path scoring and optimization module, the reward model is used to score each path to be evaluated. The logical structure, semantic matching and target orientation of the path to be evaluated are comprehensively considered. Through multi-dimensional evaluation, the path with the highest score is selected, and the node status is updated based on the feedback mechanism to obtain the optimal path and answer.

[0067] Step S7.1: Set the set of paths to be evaluated as , Indicates the first path in the set of paths to be evaluated. The nodes in the path to be evaluated represent the key information in the process of solving the math problem to be solved. Represents the multi-step problem-solving process of the mathematical problem to be solved; Indicates the number of paths to be evaluated in the set of paths to be evaluated; based on the priority queue , records the access status of nodes in the path to be evaluated, which is used to support the subsequent feedback update process.

[0068] Step S7.2: Introducing a learnable multi-dimensional reward model , for multi-dimensional reward models Conduct training, Input to the trained multi-dimensional reward model In the equation, we get a three-dimensional rating vector, which is expressed as: ; Where, express Logical consistency score, used to measure Whether it complies with the graph reasoning rules; express The semantic matching score of semantic rationality; express The target fit score is used to measure Whether it is close to the reasoning target.

[0069] Step S7.3: Perform weighted fusion on the obtained three-dimensional score vector to obtain Bonus score , expressed as: ; Where, are all adjustable parameters used to reflect the importance of the three-dimensional rating vector in the reward score. .

[0070] Among them, for the multi-dimensional reward model The specific process of training is: According to the standard answer database PIB (including question answers and standard solution paths) Annotation Label , combined with and the corresponding Form labeled path sample pairs ,based on Multi-dimensional reward model The goal of the training process is to minimize the mean square error loss function.

[0071] ; Where, represents the mean square error loss function; Represents the parameters of the multidimensional reward model.

[0072] Step S7.4: Based on the reward score , select the set of paths to be evaluated The optimal path in : ; In order to guide the search tree to converge towards a better path, a back propagation mechanism is designed to convert the optimal path Bonus score Feedback to its own intermediate node; for the optimal path The intermediate node , update its visit count and accumulated reward points , and calculate its average historical score , expressed as: .

[0073] Step S7.5: The optimal path The nodes are connected in the order of the path to build a complete structured problem-solving process, and the final answer A is obtained through summary.

[0074] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A large language model mathematical inference method based on knowledge graph and dynamic pruning optimization, characterized by: The steps include: Step S1: Construct a data set containing several primary and secondary school mathematics problems containing multi-level knowledge points; assign knowledge attribute labels representing complexity scoring parameters to the knowledge points corresponding to the primary and secondary school mathematics problems; Step S2: Given a math problem to be solved, extract the initial knowledge point entity set in the math problem through the large language model, perform semantic expansion on the initial knowledge point entity set, and construct the corresponding expanded triple set; Step S3: Construct a structured knowledge graph based on primary and secondary school mathematics problems, use extended triples to search the structured knowledge graph, obtain relevant knowledge point subgraphs, and read the complexity scores of relevant knowledge points from the relevant knowledge point subgraphs as the comprehensive difficulty scores of the corresponding mathematics problems to be solved; Step S4: When the comprehensive difficulty score ≤ preset threshold When the large language model is directly called for reasoning, the corresponding mathematical problem to be solved is generated. Problem solving process and answers ; Step S5: When the comprehensive difficulty score >Preset threshold When the corresponding math problem to be solved, the relevant knowledge point subgraph and the corresponding complexity scoring parameters are input into the search tree starting point modeling module. In the search tree starting point modeling module, the semantic matching between the math problem to be solved and the knowledge point is analyzed, and the complexity scoring parameters of the knowledge point are combined to select the most relevant knowledge point as the starting point of the search tree. Based on this information, the initial search tree is constructed and the frontier queue is generated. Step S6: The initial search tree and the frontier queue are input into the path expansion and pruning module. In the path expansion and pruning module, the inference path is expanded based on the initial search tree and the frontier queue, and the path scores are calculated to perform pruning, with high-scoring paths being retained first. Finally, a set of paths to be evaluated and a priority queue are obtained. Step S7: Input the set of paths to be evaluated and the priority queue into the path scoring and optimization module. In the path scoring and optimization module, the reward model is used to score each path to be evaluated. The logical structure, semantic matching and target orientation of the path to be evaluated are comprehensively considered. Through multi-dimensional evaluation, the path with the highest score is selected, and the node status is updated based on the feedback mechanism to obtain the optimal path and answer.

2. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 1 is characterized by: The specific process of step S1 is: Step S1.1: Collect a number of primary and secondary school mathematics problems containing multi-level knowledge points; Step S1.2: Preprocessing the collected primary and secondary school mathematics problems, including cleaning and deduplication of the primary and secondary school mathematics problems and labeling knowledge points; Step S1.3: Assign knowledge attribute labels representing complexity scores to the preprocessed knowledge points of primary and secondary school mathematics problems and construct a dataset; The specific process of step S1.3 is: Step S1.31: Collecting answer data for a number of primary and secondary school mathematics problems; constructing a question-respondent response matrix based on the answer data for the primary and secondary school mathematics problems; each cell in the question-respondent response matrix indicates whether the respondent's answer to the question is correct; Step S1.32: Based on the question-respondent response matrix, use a two-parameter logistic model to estimate the discrimination parameter of each knowledge point for the primary and secondary school mathematics questions. and difficulty parameters ; Step S1.33: Establish the mapping relationship between primary and secondary school mathematics problems and knowledge points, according to the discrimination parameters of primary and secondary school mathematics problems and difficulty parameters Perform weighted aggregation on the associated knowledge points and generate the complexity score of each knowledge point as the knowledge attribute label; Step S1.34: Manually check and correct the primary and secondary school mathematics problems corresponding to the knowledge points assigned knowledge attribute labels, and construct a data set.

3. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 2 is characterized by: In step S2, the mathematical problem to be solved is expressed as , Indicates the first A token of a character or word, Indicates the number of characters or words.

4. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 3 is characterized by: The specific process of constructing a structured knowledge graph based on primary and secondary school mathematics problems is as follows: Step S3.11: Extract entities and semantic relationships from primary and secondary school mathematics problems to form a preliminary set of triples; the entities include head entities and tail entities; Step S3.12: Import the preliminary triple set into the graph database to build a structured knowledge graph; The structured knowledge graph adopts a directed graph structure based on triples, which is represented as , Indicates the The head entity of the preliminary triple, Indicates the The semantic relationship of the initial triples, express The tail entity of the preliminary triple; Indicates the number of preliminary triples.

5. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 4 is characterized by: The relevant knowledge point subgraph is represented as , Represents the node set in the related knowledge point subgraph, Represents the semantic edge set in the related knowledge point subgraph; From the related knowledge point subgraph Read the complexity score of the relevant knowledge points as the corresponding math problem to be solved The specific process of comprehensive difficulty scoring is as follows: From the relevant knowledge point subgraph through the large language model Identify math problems to be solved A collection of semantically related knowledge points ,in, Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related knowledge points; Represents a subgraph from related knowledge points Identify math problems to be solved Semantically related Knowledge points, ; Identified mathematical problems to be solved Semantically related knowledge points are related knowledge point subgraphs Nodes in Calculate the math problems to be solved through a large language model With the Knowledge points The attention score between , to solve math problems Normalize the attention scores between all knowledge points to get the knowledge points Approaching math problems The importance of semantic relations ; Based on semantic relationship importance , knowledge points Corresponding complexity scoring parameters To calculate the math problem to be solved Overall difficulty rating : ; in, Representing knowledge points The corresponding discrimination parameter; Representing knowledge points The corresponding difficulty parameter.

6. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 5 is characterized by: The specific process of step S5 is: Step S5.1: Based on the mathematical problem to be solved and related knowledge point subgraphs To construct a large language model input prompt string ; Step S5.2: Input the large language model into the prompt string Input into the large language model and output a set of candidate knowledge points as the starting point of reasoning , Indicates the candidate knowledge points in natural language form; Step S5.3: Collect candidate knowledge points The candidate knowledge points in natural language Match to relevant knowledge point subgraph The nodes in , get the mapping node set , Representing related knowledge point subgraphs Corresponding Mapping node; Step S5.4: Calculate the mapping node and math problems to be solved Semantic relevance score : ; Where, Represents a mathematical problem to be solved Semantic feature vector of express The structure embedding vector of Step S5.5: According to the mapping node Corresponding complexity scoring parameters To calculate the structural score of the mapping node ; Represents a mapping node The corresponding discrimination parameter, Represents a mapping node The corresponding difficulty parameter; Step S5.6: Score based on semantic relevance and the structural score of the mapping node To calculate the comprehensive score of the mapping node : ; Where, 、 All represent adjustable hyperparameters. ; Step S5.7: Comprehensive score of the mapping node As a basis, set the threshold , filter out the comprehensive score not lower than the threshold Mapping nodes to build a search starting point candidate pool ; Step S5.8: Search the starting point candidate pool In the example, based on the comprehensive score of the node Sort and select the mapping node with the highest score as the root node of the search tree ; Step S5.9: Search the root node of the tree As the tree root, from the relevant knowledge point subgraph Filter the semantic relationships that meet the settings to build the initial search tree ; Step S5.10: Search the candidate pool for the starting point All mapping nodes in the table are ranked according to their corresponding comprehensive scores. Sort in descending order and build a frontier queue , Represents the candidate node in the frontier queue; express depth.

7. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 6 is characterized by: The specific process of step S6 is: Step S6.1: Depth With the maximum depth threshold For comparison, when , then based on the initial search tree The specific process of the expansion operation is as follows: definition The set of legal adjacent points : ; Where, represents a candidate expansion node; Will Append to Corresponding path On the basis of the above, a set of paths to be evaluated is formed. ; Step S6.2: Budget pruning strategy: based on comprehensive difficulty score ,dynamically control the expansion operation; Let the total number of path nodes generated by the current search tree be , then the maximum number of nodes allowed to be expanded in this round is for: ; Where, represents the scaling factor; represents the expansion adjustment coefficient; For all candidate expansion nodes Perform semantic structure scoring, scoring function Defined as: ; Where, Represents a candidate expansion node The structure embedding vector of Represents a candidate expansion node Structural scoring parameters of Keep the highest rated candidate expansion nodes, forming a preliminary pruning set ; Step S6.3: Logical consistency pruning strategy: define consistency judgment function : ; Where, express arrive The semantic relationship type of Represents the set of allowed semantic relations; express Attribute conditions; According to the consistency judgment function Initial pruning set Screening to obtain a valid candidate set ; For each , update its cumulative number of visits: ; Where, express The cumulative number of visits during the search process; Step S6.4: Frontier Queue Update to get the priority queue : ; Where, express Comprehensive rating of express depth.

8. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 7 is characterized by: The specific process of step S7 is: Step S7.1: Set the set of paths to be evaluated as , Indicates the first path in the set of paths to be evaluated. Paths to be evaluated; Indicates the number of paths to be evaluated in the set of paths to be evaluated; based on the priority queue , record the access status of nodes in the path to be evaluated; Step S7.2: Introducing a multi-dimensional reward model , for multi-dimensional reward models Conduct training, Input to the trained multi-dimensional reward model In the equation, we get a three-dimensional rating vector, which is expressed as: ; Where, express Logical consistency score; express Semantic matching score of express Target fit score; Step S7.3: Perform weighted fusion on the obtained three-dimensional score vector to obtain Bonus score , expressed as: ; Where, All are adjustable parameters. ; Step S7.4: Based on the reward score , select the set of paths to be evaluated The optimal path in : ; Step S7.5: The optimal path The nodes in the path are connected in sequence to construct the mathematical problem to be solved. Complete structured problem-solving process and summarize to get answer A.

9. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 8, characterized in that: Multi-dimensional reward model The specific process of training is as follows: Based on the standard answer database PIB Annotation Label , combined with and the corresponding Form labeled path sample pairs ,based on Multi-dimensional reward model The goal of the training process is to minimize the mean square error loss function.

10. The large language model mathematical inference method based on knowledge graph and dynamic pruning optimization according to claim 9 is characterized by: Design a back-propagation mechanism to convert the optimal path Bonus score Feedback to its own intermediate node; for the optimal path The intermediate node , update its visit count and accumulated reward points , and calculate its average historical score .

Citation Information

Patent Citations

  • Cross-domain data heterogeneous large model online pruning method and related equipment

    CN115423088A

  • Knowledge graph question and answer retrieval method based on large language model and MCTS algorithm

    CN118296114A

  • Mathematical reasoning training set generation method for large language model

    CN118821942A

  • Chemical reaction path reasoning method and device, related equipment and program product

    CN120340650A

  • Mathematical problem generation method and system based on adaptive multilevel retrieval enhancement

    CN120450035A

Cited By

  • Intelligent application interaction method and system driven by multi-mode end side model

    CN121188100A

  • Multimodal end-to-side model-driven intelligent application interaction method and system

    CN121188100B

  • Method for intelligently solving plane geometry by simulating human thinking and program product

    CN121212373A

  • A method and program product for solving plane geometry problems by human-like thinking intelligence

    CN121212373B