Large language model reasoning enhancement method based on structure perception knowledge graph representation
Through adaptive multi-source structural information encoding and bidirectional contrastive learning mechanism, combined with robust fusion pruning strategy, the problems of lack of structural perception and insufficient semantic fusion of entity representation in knowledge graph enhanced large language models are solved, and the accuracy and stability of complex reasoning tasks are improved.
Patent Information
- Application Number
- CN202511110717.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-08
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-08-08
AI Technical Summary
In the existing technology, knowledge graph-enhanced large language models have problems such as lack of structural perception ability of entity representation, single and inefficient subgraph screening strategy, and insufficient fusion of semantic and structural features, which leads to unstable answer quality and insufficient accuracy in complex reasoning tasks.
By introducing an adaptive multi-source structural information encoding mechanism and graph neural network, combined with a bidirectional contrastive learning mechanism, the alignment of semantic and structural information is achieved, and an adaptive robust fusion pruning training strategy is designed to dynamically screen high-quality evidence subgraphs to improve generation accuracy and stability.
It significantly improves the accuracy, robustness, and resource efficiency of large language models in complex query tasks, ensuring the quality and consistency of generated results.
Smart Images

Figure CN120633869A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of combining knowledge graphs with large language models, and specifically relates to a large language model reasoning enhancement method based on structure-aware knowledge graph representation. Background Art
[0002] Large language models (LLMs) have achieved remarkable success in various natural language understanding and reasoning tasks. Despite their powerful capabilities, these models still struggle with complex reasoning, factual consistency, and understanding of domain-specific knowledge. In particular, LLMs often rely on implicit knowledge learned during pre-training, which can be outdated or insufficient for tasks requiring precise factual understanding.
[0003] Prior art has disclosed a novel method called RARoK (Retrieval-Augmented Reasoning on Knowledge). This method combines Chain of Thought (CoT) prompts with Retrieval-Augmented Generation (RAG) technology to iteratively optimize the model's reasoning process by leveraging external information from knowledge graphs (KGs). The RARoK method primarily relies on the simple topological structure of the knowledge graph during its iterative optimization process. It only selects paths relevant to the question using the PageRank algorithm, but ignores the rich semantic information of entities and relationships within the path. This approach may fail to fully utilize the detailed semantic knowledge contained in the knowledge graph to generate more accurate and explanatory answers when addressing complex medical questions, thus affecting the quality of the final answer.
[0004] The prior art also discloses a new prompting method called MindMap, which enhances the reasoning ability and transparency of large language models by combining knowledge graphs (KGs). Although the MindMap method has made significant progress in integrating knowledge graphs and large language models, it also has some disadvantages. First, the path exploration process is static and relies on predefined algorithms, which limits the flexibility and adaptability of the model when dealing with dynamic or real-time updated knowledge. At the same time, for the same data, there is uncertainty when exploring different starting points, resulting in unstable performance. In addition, this method only relies on simple semantic information such as simple relationship types for pruning, which reduces its accuracy. Its exploration scope of the knowledge graph may be limited and cannot include all possible entities and relationships, which may lead to insufficient supporting information for certain problems.
[0005] In summary, the current knowledge graph-enhanced large language models face multiple technical bottlenecks, primarily including a lack of structural awareness in entity representation, a single and inefficient subgraph screening strategy, and insufficient integration of semantic and structural features. Existing methods often rely solely on semantic information or simple heuristic rules for subgraph retrieval, which can easily introduce noisy paths or omit key evidence. The generated results are sensitive to changes in graph structure and lack robustness and generalization capabilities. Furthermore, the lack of unified alignment between semantic and structural information further restricts the acquisition of key and effective information from the knowledge graph, affecting the inference quality of large models. Summary of the Invention
[0006] In order to solve the problems in the existing technology of knowledge graph enhanced large language models, such as the lack of structural perception ability of entity representation, the single and inefficient subgraph screening strategy, and the insufficient fusion of semantic and structural features, the present application provides a structure-aware knowledge injection framework, which uses graph neural networks combined with multi-source structural information encoding to enhance entity representation, and realizes the alignment of semantic and structural space through a comparative learning mechanism. At the same time, an adaptive robust fusion pruning training strategy is designed to dynamically screen high-quality evidence subgraphs and guide the language model to perform structured reasoning, thereby improving the generation accuracy, stability and efficiency under complex problems.
[0007] In order to achieve the above objectives, this application is implemented through the following technical solutions:
[0008] This application is a large language model reasoning enhancement method based on structure-aware knowledge graph representation, including the following steps: Step 1: Encode the nodes in the original knowledge graph to generate a high-dimensional semantic embedding vector, introduce an adaptive multi-source structural information encoding mechanism to obtain the node structural information encoding, and splice the node structural information encoding with the high-dimensional semantic embedding vector to form the original structural perception feature;
[0009] Step 2: The original structure perception features obtained in step 1 are introduced into the multi-layer GPS graph convolutional neural network to form enhanced node embedding features. A two-way contrastive learning mechanism is introduced to align the enhanced node embedding features with the high-dimensional semantic embedding vector obtained in step 1 to obtain the final embedding vector.
[0010] Step 3: Obtain the embedding vector matrix of all nodes in the knowledge graph based on the embedding vector obtained in step 2 , using a large language model to answer questions The key entity set in After the key entity set is identified, Sentence-BERT is used to identify the key entity set. Encoded as dense vector , calculate the dense vector and the embedding vector matrix The cosine similarity matrix of Select the set of problem nodes that are most similar to the key entity set It is the anchor node of the subgraph;
[0011] Step 4: Starting from the anchor nodes obtained in step 3, a dual-channel strategy of path exploration and neighborhood expansion is used to generate a set of unpruned candidate subgraphs.
[0012] Step 5: Based on the embedding vector obtained in step 2, construct an adaptive robust fusion pruning training strategy, complete the subgraph screening from the unpruned candidate subgraph set in step 4, and select the subgraph from the unpruned candidate subgraph set. The optimal subgraph selected from the adaptive robust fusion pruning training strategy includes calculating the structural-semantic scoring component and counterfactual robustness score components ;
[0013] Step 6. For any new question, first generate a set of unpruned candidate subgraphs according to steps 1 to 4. Then, directly call the adaptive pruning scoring function trained by the adaptive robust fusion pruning training strategy in step 5 to screen the set of unpruned candidate subgraphs generated in step 4 and select the evidence subgraph that is most relevant to the question and has the most robust structure.
[0014] A further improvement of the present application is that step 1 specifically includes the following steps:
[0015] Step 1.1: Take any node in the original knowledge graph Starting from the center, a subgraph is sampled from the original knowledge graph through a breadth-first search sampling method. , the sampling process of the subgraph is defined as:
[0016]
[0017] in, For breadth-first search, Central Node The subgraph obtained by starting sampling, To include the central node and central nodes The set of nodes within a certain range of hops, For the relationship edge set, in order to control the subgraph scale and computational complexity, we introduce Limited game map The maximum number of nodes included in ;
[0018] Step 1.2: Use the Sentence-BERT (SBERT) model to sample the subgraph obtained in step 1.1 Each node in Encode and extract nodes Semantic features and generate high-dimensional semantic embedding vectors : ,in, ;
[0019] Step 1.3: Sample the subgraph obtained in step 1.1 Based on this, an adaptive multi-source structure information encoding mechanism is introduced to obtain node structure information encoding , and encode the node structure information The high-dimensional semantic embedding vector generated in step 1.2 Splicing to form original structural perception features .
[0020] A further improvement of the present application is that: in step 1.3, the adaptive multi-source structural information encoding mechanism includes random walk encoding , node type encoding and community structure type coding , random walk encoding The local path structure characteristics of the node are characterized in the form of a continuous real-valued vector, which can effectively reflect the topological position and connection pattern of the node in its neighborhood; node type encoding One-hot vectors are used to represent the category to which nodes belong, enhancing the ability to distinguish different types of nodes in heterogeneous graphs; community structure type encoding The community affiliation of the node in the global knowledge graph is identified by one-hot vector, capturing the functional role and community relationship of the node in the macro structure.
[0021] A further improvement of the present application is that step 1.3 specifically includes the following steps:
[0022] Step 1.3.1: Subgraph All nodes in , according to the node Centrality index Dynamically generate random walk codes , node type encoding and community structure type coding The fusion weight vector :
[0023]
[0024] in, Bias term, is the weight matrix;
[0025] Step 1.3.2, Compute Node Node structure information encoding :
[0026]
[0027] in, Is the node type code The embedding function is used to convert it from one-hot encoding into a dense vector, is the community structure type code The embedding function is used to convert it from one-hot encoding to a dense vector;
[0028] Step 1.3.3: Encode node structure information Perform batch normalization and linear mapping transformation:
[0029]
[0030] in, To encode node structure information Encoding of node structure information after batch normalization and linear mapping changes, is a linear change matrix, is batch normalization;
[0031] Step 1.3.4: The and high-dimensional semantic embedding vectors Splicing to form the original structural perception features:
[0032] .
[0033] A further improvement of the present application is that the step 2 specifically includes the following steps:
[0034] Step 2.1: Get the original structure perception features Input into the multi-layer GPS graph convolutional neural network for propagation and aggregation of original structure perception features. The calculation method of each layer of graph convolution is:
[0035]
[0036] in, is the number of GPS layers, , ;
[0037] Step 2.2, after completing After the feature propagation and aggregation of the GPS graph convolutional neural network, from each subgraph Extract the central node Enhanced embedded node features :
[0038] ;
[0039] Step 2.3: Use InfoNCE loss function to enhance the embedded node features With the central node High-dimensional semantic embedding vector For alignment, the InfoNCE loss function includes calculating the contrast loss from the image to the text direction and contrast loss in the text-to-image direction :
[0040]
[0041]
[0042] in, is the sample size, is the temperature coefficient, Is the central node The semantic features of is a node The semantic features of is a node Enhanced embedded node features, Is the central node Enhanced embedding node features, function To measure and Similarity between: , is transposed;
[0043] Step 2.4: Introduce the two-way contrastive learning mechanism. The contrastive learning loss function is:
[0044]
[0045] Step 2.5: After training, the final embedding vector :
[0046] .
[0047] A further improvement of this application is that the dual-channel strategy in step 4 is specifically:
[0048] Path exploration: For any entity pair in the anchor node obtained in step 3, the enumeration length does not exceed All paths, build a path collection , each path , retain the path All nodes and edges form a path-type subgraph; no pruning is performed at this stage to ensure that potential multi-hop semantic associations and complex reasoning chains are not missed.
[0049] Neighborhood expansion: For each anchor node, obtain the first-order neighbors and group them according to the relationship type of the edges corresponding to the anchor nodes. All neighbor nodes are retained in each group to form a neighborhood subgraph set. ; Similarly, no structure-based or semantic-based pruning is performed at this stage, maximizing the retention of local context information and potential evidence clues.
[0050] Constructing a set of unpruned candidate subgraphs based on path exploration and neighborhood expansion , as subsequent input.
[0051] A further improvement of the present application is that step 5 specifically includes the following steps:
[0052] Step 5.1: Define unpruned candidate subgraphs and problems The structural-semantic joint robustness scoring function is:
[0053]
[0054] in, is the fusion weight to be adaptively optimized, is the set of unpruned candidate subgraph nodes, is the set of unpruned candidate subgraph edges, , is the fusion weight to be learned, For the Structural-semantic scoring component for
[0055]
[0056] in, is the embedding of nodes in the unpruned candidate subgraph, is the semantic embedding of the question, Obtained through Sentence-BERT encoding;
[0057] Step 5.2: Calculate the counterfactual robustness score component :Compute unpruned candidate subgraphs using large oracle models and problems The correlation is the confidence score , and for the unpruned candidate subgraph conduct perturbations, generating a set of counterfactual subgraphs , the large prediction model calculates each counterfactual subgraph separately Score and get confidence score , get the counterfactual robustness score component :
[0058]
[0059] Step 5.3: Considering both the randomness and generalization ability of the generative reasoning process, Monte Carlo sampling is introduced to model the expectation of the generalization performance metric BERTScore:
[0060]
[0061] in, Generate noise for inference perturbations such as LLM, subgraph sampling perturbations, etc. is the generalization performance metric BERTScore, For the fusion weight and inference perturbations Down , through the structural-semantic joint robustness scoring function From the candidate subgraph set The best subgraph selected from is the answer generated by the large model given the current optimal subgraph and query, For the problem The standard answer to this question is:
[0062]
[0063] Step 5.4: During the training process, a Bayesian optimization strategy is used to randomly sample a number of Yes, repeatedly perform steps 5.1 to 5.4, and finally obtain adaptive pruning weights with good generalization ability :
[0064]
[0065] in, is the acquisition function, is the mean of the generalization performance metric BERTScore, is the variance estimate.
[0066] The beneficial effects of this application are:
[0067] This application is used to efficiently integrate reasoning evidence from knowledge graphs into the Large Language Model (LLM) generation process. This framework constructs an enhanced entity representation that fuses semantic and structural information. Through three stages, unified encoding, feature alignment, and robust pruning, it achieves deep integration and optimized utilization of structural and semantic information, significantly improving the model's accuracy, robustness, and resource efficiency for complex query tasks.
[0068] This application significantly improves the accuracy of entity recognition, matching, and subsequent sub-cluster pruning and reasoning, providing a stronger embedding foundation for generation quality.
[0069] This application introduces a bidirectional contrastive learning mechanism that aligns semantic embeddings with structurally enhanced embeddings, strengthening the consistency between the two representations and ensuring that the structurally enhanced embeddings retain the original semantic information. This mechanism also improves the fusion of semantics and structure, providing more robust and unified node embeddings for downstream tasks.
[0070] This application designs a dual-channel subgraph generation strategy of path exploration and neighborhood expansion, and proposes a multidimensional pruning scoring function that integrates structural similarity, semantic relevance and counterfactual robustness. It then combines Bayesian optimization and Monte Carlo sampling to dynamically adjust the weights of each scoring item, thereby maximizing the retention of potential semantic paths and structural evidence, and achieving more robust and effective evidence subgraph screening.
[0071] The adaptive robustness fusion pruning training strategy designed in this application integrates structural similarity scores, semantic consistency scores and counterfactual robustness indicators to construct a learnable multi-factor scoring function, and dynamically adjusts the scoring weights through Monte Carlo sampling and Bayesian optimization to improve the generalization performance and stability of the pruning strategy. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a flow chart of the enhanced method of the present application.
[0073] Figure 2 This is a schematic diagram of the adaptive robust fusion pruning training strategy of this application.
[0074] Figure 3 This is a model diagram of this application. DETAILED DESCRIPTION
[0075] The following diagrams illustrate embodiments of the present application. For clarity, many practical details will be included in the following description. However, it should be understood that these practical details are not intended to limit the present application. In other words, in some embodiments of the present application, these practical details are not essential. Furthermore, to simplify the drawings, some conventional structures and components are depicted in the drawings in a simplified schematic manner.
[0076] like Figure 1 and Figure 3 As shown, this application is a large language model reasoning enhancement method based on structure-aware knowledge graph representation, including the following steps:
[0077] Step 1: Take any node in the original knowledge graph Starting from the center, a subgraph is sampled from the original knowledge graph through a breadth-first search sampling method. , the sampling process of the subgraph is defined as:
[0078]
[0079] in, For breadth-first search, Central Node The subgraph obtained by starting sampling, To include the central node and central nodes The set of nodes within a certain range of hops, For the relationship edge set, in order to control the subgraph scale and computational complexity, we introduce Limited game map The maximum number of nodes included in Specifically, for the node "Panicdisorder," subgraphs centered around it include "Panic disorder," "Anxiety and nervousness," and others. Subgraph sampling based on breadth-first search (BFS) not only reduces subsequent training overhead but also maintains the relative integrity of the graph structure surrounding the node.
[0080] Step 2: Use the Sentence-BERT (SBERT) model to sample the subgraph obtained in step 1.1 Each node in Encode and extract nodes Semantic features and generate high-dimensional semantic embedding vectors : ,in, For the node "Panic disorder," its semantic embedding is tensor([-1.66086350e-02, -9.95494872e-02, -2.83739436e-02, -4.28055692e-03, 2.27553118e-03, …, -3.38866562e-02, 1.81445607e-03, -3.15738544e-02]). The resulting high-dimensional semantic embedding vector is used for subsequent graph structure enhancement and reasoning tasks. This embedding not only preserves the semantic context of the entity but also provides a semantic foundation for the structured processing of graph neural networks. This facilitates the integration of multi-source heterogeneous information, improving the expressiveness of node representations and their adaptability to downstream tasks.
[0081] Step 3: Sample the subgraph obtained in step 1 Based on this, an adaptive multi-source structure information encoding mechanism is introduced to obtain node structure information encoding , and encode the node structure information The high-dimensional semantic embedding vector generated in step 2 Splicing to form original structural perception features The adaptive multi-source structural information encoding mechanism includes random walk coding , node type encoding and community structure type coding , random walk encoding The local path structure characteristics of the node are characterized in the form of a continuous real-valued vector, which can effectively reflect the topological position and connection pattern of the node in its neighborhood; node type encoding One-hot vectors are used to represent the category to which nodes belong, enhancing the ability to distinguish different types of nodes in heterogeneous graphs; community structure type encoding The community affiliation of the node in the global knowledge graph is identified by one-hot vector, capturing the functional role and community relationship of the node in the macro structure.
[0082] The specific steps include:
[0083] Step 3.1: Subgraph All nodes in , according to the node Centrality index Dynamically generate random walk codes , node type encoding and community structure type coding The fusion weight vector :
[0084]
[0085] in, Bias term, is the weight matrix;
[0086] Step 3.2, Compute Node Node structure information encoding :
[0087]
[0088] in, Is the node type code The embedding function is used to convert it from one-hot encoding into a dense vector, is the community structure type code The embedding function is used to convert it from one-hot encoding to a dense vector;
[0089] Step 3.3: Encode node structure information Perform batch normalization and linear mapping transformation:
[0090]
[0091] in, To encode node structure information Encoding of node structure information after batch normalization and linear mapping changes, is a linear change matrix, is batch normalization;
[0092] Step 3.4: The and high-dimensional semantic embedding vectors Splicing to form the original structural perception features:
[0093] Step 4: Get the original structure perception features Input into the multi-layer GPS graph convolutional neural network for propagation and aggregation of original structure perception features. The calculation method of each layer of graph convolution is:
[0094]
[0095] in, is the number of GPS layers, , ;
[0096] Step 5: After completing After the feature propagation and aggregation of the GPS graph convolutional neural network, from each subgraph Extract the central node Enhanced embedded node features , which is used in the subsequent semantic-structural alignment module. The process is formalized as follows:
[0097] ;
[0098] This structure enhances embedding It is fed as input into the subsequent semantic-structural contrast learning module to prevent semantic drift.
[0099] Step 6: Use InfoNCE loss function to enhance the embedded node features With the central node High-dimensional semantic embedding vector For alignment, the InfoNCE loss function includes calculating the contrast loss from the image to the text direction and contrast loss in the text-to-image direction :
[0100]
[0101]
[0102] in, is the sample size, is the temperature coefficient, Is the central node The semantic features of is a node The semantic features of is a node Enhanced embedded node features, Is the central node Enhanced embedding node features, function To measure and Similarity between: , is transposed;
[0103] Step 7: Introduce the two-way contrastive learning mechanism. The contrastive learning loss function is:
[0104]
[0105] Step 8. After training, the final embedding vector :
[0106] .
[0107] Taking the node "Panic disorder" as an example, its final node embedding is tensor([-1.2250e-02, -1.0428e-01, -3.3630e-02, 7.8077e-04, 1.2489e-03, …, -4.8607e-02, 8.4550e-03, -2.4752e-02]).
[0108] Through normalized scaling and weighted fusion strategy, the final embedding vector is ensured to be While maintaining the original semantic consistency, it fully integrates the topological information of the graph structure. This fused embedding will serve as the input basis for subsequent key tasks such as entity recognition, entity linking, and subgraph pruning.
[0109] To improve the accuracy and stability of recognition, this application designs a structured prompt template (PromptTemplate), which includes: user questions to be analyzed, standardized guiding statements, and multiple manually verified example questions and entity labeling results to ensure the generalizability and consistency of the recognition process.
[0110] Step 9: Use the large language model to identify the extracted key entity set Then use Sentence-BERT to collect key entities Encoded as dense vector , calculate the dense vector and the embedding vector matrix The cosine similarity matrix of Select the set of problem nodes that are most similar to the key entity set , serving as the anchor node for subsequent evidence subgraphs.
[0111] Step 10: Starting from the obtained anchor nodes, a dual-channel strategy of path exploration and neighborhood expansion is used to generate a set of unpruned candidate subgraphs. The dual-channel strategy is as follows:
[0112] Path exploration: For any entity pair in the acquired anchor node, the enumeration length does not exceed All paths, build a path collection , each path , retain the path All nodes and edges form a path-type subgraph; no pruning is performed at this stage to ensure that potential multi-hop semantic associations and complex reasoning chains are not missed.
[0113] Neighborhood expansion: For each anchor node, obtain the first-order neighbors and group them according to the relationship type of the edges corresponding to the anchor nodes. All neighbor nodes are retained in each group to form a neighborhood subgraph set. ; Similarly, no structure-based or semantic-based pruning is performed at this stage, maximizing the retention of local context information and potential evidence clues.
[0114] Constructing a set of unpruned candidate subgraphs based on path exploration and neighborhood expansion , as subsequent input.
[0115] Step 11: To overcome the limitation of static pruning that traditional graphs rely only on structural or semantic features, an adaptive robust fusion pruning training strategy is constructed based on the obtained embedding vectors to complete the subgraph screening from the set of unpruned candidate subgraphs. The optimal subgraph selected from the adaptive robust fusion pruning training strategy includes calculating the structural-semantic scoring component and counterfactual robustness score components .
[0116] Step 11.1: Define unpruned candidate subgraphs and problems The structural-semantic joint robustness scoring function is:
[0117]
[0118] in, is the fusion weight to be adaptively optimized, is the set of unpruned candidate subgraph nodes, is the set of unpruned candidate subgraph edges, , is the fusion weight to be learned, For the Structural-semantic scoring component for
[0119]
[0120] in, is the embedding of nodes in the unpruned candidate subgraph, is the semantic embedding of the question, Obtained through Sentence-BERT encoding;
[0121] Step 11.2. Calculate the counterfactual robustness score component :Compute unpruned candidate subgraphs using large oracle models and problems The correlation is the confidence score , and for the unpruned candidate subgraph conduct perturbations (including random entity replacement and relation replacement) to generate a set of counterfactual subgraphs , the large prediction model calculates each counterfactual subgraph separately Score and get confidence score , get the counterfactual robustness score component :
[0122]
[0123] Step 11.3: Considering both the randomness and generalization capability of the generative reasoning process, Monte Carlo sampling is introduced to model the expectation of the generalization performance metric BERTScore:
[0124]
[0125] in, For inference perturbations (such as LLM noise generation, subgraph sampling perturbations, etc.), is the generalization performance metric BERTScore, For the fusion weight and inference perturbations Down , through the structural-semantic joint robustness scoring function From the candidate subgraph set The best subgraph selected from is the answer generated by the large model given the current optimal subgraph and query, For the problem The standard answer to this question is:
[0126]
[0127] Step 11.4, due to The calculation of depends on multiple sampling, which is costly and may have estimation bias. During the training process, the Bayesian optimization strategy is used to randomly sample several Yes, repeatedly perform steps 5.1 to 5.4, and finally obtain adaptive pruning weights with good generalization ability :
[0128]
[0129] in, is the acquisition function, is the mean of the generalization performance metric BERTScore, is the variance estimate.
[0130] Step 12: For any new question, first generate a set of unpruned candidate subgraphs according to steps 1 to 4, then directly call the adaptive pruning scoring function trained by the adaptive robust fusion pruning training strategy to screen the generated unpruned candidate subgraphs and select the evidence subgraphs that are most relevant to the question and have the most robust structure. is [0.9,0.1].
[0131] Step 14: In actual reasoning applications, for any new problem, we first generate a set of unpruned candidate subgraphs according to the above process. We then directly call the trained adaptive pruning scoring function to efficiently screen the candidate subgraphs, selecting the evidence subgraphs that are most relevant to the problem and have the most robust structure. The final results are shown in Table 1 below.
[0132] Table 1
[0133]
[0134] As can be seen from Table 1 above, the large language model reasoning enhancement method of this application significantly improves the accuracy, coherence and factual consistency of generated answers.
[0135] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for enhancing reasoning of large language models based on structure-aware knowledge graph representation, characterized by: The large language model reasoning enhancement method specifically includes the following steps: Step 1: Encode the nodes in the original knowledge graph to generate a high-dimensional semantic embedding vector, introduce an adaptive multi-source structural information encoding mechanism to obtain the node structural information encoding, and splice the node structural information encoding with the high-dimensional semantic embedding vector to form the original structural perception feature; Step 2: The original structure perception features obtained in step 1 are introduced into the multi-layer GPS graph convolutional neural network to form enhanced node embedding features. A two-way contrastive learning mechanism is introduced to align the enhanced node embedding features with the high-dimensional semantic embedding vector obtained in step 1 to obtain the final embedding vector. Step 3: Based on the embedding vector obtained in step 2, the embedding vector matrix of all nodes in the knowledge graph is obtained. The large language model is used to identify the key entity set in the question. After completing the identification of the key entity set, the key entity set is encoded into a dense vector using Sentence-BERT. The cosine similarity matrix between the dense vector and the embedding vector matrix is calculated. The question node set that is most similar to the key entity set is selected as the anchor node of the subgraph; Step 4: Starting from the anchor nodes obtained in step 3, a dual-channel strategy of path exploration and neighborhood expansion is used to generate a set of unpruned candidate subgraphs. Step 5: Based on the embedding vector obtained in step 2, an adaptive robust fusion pruning training strategy is constructed to complete the subgraph screening from the set of unpruned candidate subgraphs in step 4, and the optimal subgraph is selected from the set of unpruned candidate subgraphs. The adaptive robust fusion pruning training strategy includes calculating the structural-semantic scoring component and the counterfactual robustness scoring component. Step 6. For any new question, first generate a set of unpruned candidate subgraphs according to steps 1 to 4. Then, directly call the adaptive pruning scoring function trained by the adaptive robust fusion pruning training strategy in step 5 to screen the set of unpruned candidate subgraphs generated in step 4 and select the evidence subgraph that is most relevant to the question and has the most robust structure.
2. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 1 is characterized by: Step 1 specifically includes the following steps: Step 1.1: Take any node in the original knowledge graph Starting from the center, a subgraph is sampled from the original knowledge graph through a breadth-first search sampling method. , the sampling process of the subgraph is defined as: , in, For breadth-first search, Central Node The subgraph obtained by starting sampling, To include the central node and central nodes The set of nodes within a certain range of hops, is the set of relationship edges, Limited game map The maximum number of nodes included in ; Step 1.2: Use the Sentence-BERT model to sample the subgraph obtained in step 1.1 Each node in Encode and extract nodes Semantic features and generate high-dimensional semantic embedding vectors : ,in, ; Step 1.3: Sample the subgraph obtained in step 1.1 Based on this, an adaptive multi-source structure information encoding mechanism is introduced to obtain node structure information encoding , and encode the node structure information The high-dimensional semantic embedding vector generated in step 1.2 Splicing to form original structural perception features .
3. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 2 is characterized by: In step 1.3, the adaptive multi-source structural information encoding mechanism includes random walk encoding , node type encoding and community structure type coding , random walk encoding In the form of continuous real-valued vectors, the local path structure characteristics of the node are characterized, and the node type encoding One-hot vector is used to represent the category to which the node belongs and the community structure type encoding The community affiliation of a node in the global knowledge graph is identified by a one-hot vector.
4. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 3 is characterized by: The step 1.3 specifically includes the following steps: Step 1.3.1: Subgraph All nodes in , according to the node Centrality index Dynamically generate random walk codes , node type encoding and community structure type coding The fusion weight vector : , in, Bias term, is the weight matrix; Step 1.3.2, Compute Node Node structure information encoding : , in, Is the node type code The embedding function of is the community structure type code Embedding function of Step 1.3.3: Encode node structure information Perform batch normalization and linear mapping transformation: , in, To encode node structure information Encoding of node structure information after batch normalization and linear mapping changes, is a linear change matrix, is batch normalization; Step 1.3.4: The and high-dimensional semantic embedding vectors Splicing to form the original structural perception features: 。 5. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 4 is characterized by: The step 2 specifically includes the following steps: Step 2.1: Get the original structure perception features Input into the multi-layer GPS graph convolutional neural network for propagation and aggregation of original structure perception features. The calculation method of each layer of graph convolution is: , in, is the number of GPS layers, , ; Step 2.2, after completing After the feature propagation and aggregation of the GPS graph convolutional neural network, from each subgraph Extract the central node Enhanced embedded node features : ; Step 2.3: Use InfoNCE loss function to enhance the embedded node features With the central node High-dimensional semantic embedding vector For alignment, the InfoNCE loss function includes calculating the contrast loss from the image to the text direction and contrast loss in text-to-image direction : , , in, is the sample size, is the temperature coefficient, Is the central node The semantic features of is a node The semantic features of is a node Enhanced embedded node features, Is the central node Enhanced embedding node features, function To measure and Similarity between: , is transposed; Step 2.4: Introduce the two-way contrastive learning mechanism. The contrastive learning loss function is: ; Step 2.5: After training, the final embedding vector : 。 6. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 5 is characterized by: The dual-channel strategy of step 4 is specifically as follows: Path exploration: For any entity pair in the anchor node obtained in step 3, the enumeration length does not exceed All paths of , build a path collection , each path , retain the path All nodes and edges form a path-type subgraph; Neighborhood expansion: For each anchor node, obtain the first-order neighbors and group them according to the relationship type of the edges corresponding to the anchor nodes. All neighbor nodes are retained in each group to form a neighborhood subgraph set. ; Constructing a set of unpruned candidate subgraphs based on path exploration and neighborhood expansion .
7. The large language model reasoning enhancement method based on structure-aware knowledge graph representation according to claim 6 is characterized by: The step 5 specifically includes the following steps: Step 5.1: Define unpruned candidate subgraphs and problems The structural-semantic joint robustness scoring function is: , in, is the fusion weight, is the set of unpruned candidate subgraph nodes, is the set of unpruned candidate subgraph edges, , is the fusion weight to be learned, For the Structural-semantic scoring component for , in, is the embedding of nodes in the unpruned candidate subgraph, is the semantic embedding of the question, Obtained through Sentence-BERT encoding; Step 5.2: Calculate the counterfactual robustness score component :Compute unpruned candidate subgraphs using large oracle models and problems The correlation is the confidence score , and for the unpruned candidate subgraph conduct perturbations, generating a set of counterfactual subgraphs , the large prediction model calculates each counterfactual subgraph separately Score and get confidence score , get the counterfactual robustness score component : , Step 5.3: Introduce Monte Carlo sampling to model the expectation of the generalization performance metric BERTScore: , in, is the inference perturbation, is the generalization performance metric BERTScore, For the fusion weight and inference perturbations Down , through the structural-semantic joint robustness scoring function From the candidate subgraph set The best subgraph selected from is the answer generated by the large model given the current optimal subgraph and query, For the problem The standard answer to this question is: , Step 5.4: During the training process, a Bayesian optimization strategy is used to randomly sample a number of Yes, repeat steps 5.1 to 5.4, and finally get the adaptive pruning weight : , in, is the acquisition function, is the mean of the generalization performance metric BERTScore, is the variance estimate.
Citation Information
Patent Citations
Language model and knowledge representation learning combined common sense question and answer model and method
CN116719923A
Method for constructing knowledge graph based on large language model and vector library
CN119129722A
Medical text big data intelligent labeling and knowledge graph construction method and system
CN119851968A
Knowledge graph enhanced reasoning framework based on graph neural network and large language model
CN120106229A
Event information enhancement and deduction prediction method combined with knowledge graph
CN120197710A
Cited By
Knowledge base-based large model retrieval enhancement method and system
CN121009180A
A knowledge base-based large model retrieval enhancement method and system
CN121009180B
Domestic big language model retrieval enhancement generation method for customs
CN121350080A
Input disturbance robustness improvement method of power generation type large language model
CN121390055A
Enhanced generation method based on topology perception graph coding and self-adaptive sub-graph retrieval
CN121562834A