Enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval
By employing an enhanced generation method combining topology-aware graph encoding and adaptive subgraph retrieval, the problems of logical illusion and computational overhead in professional domains of large language models are solved, achieving efficient multi-hop reasoning and structured retrieval, and improving the reasoning accuracy and stability of large language models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAMEN UNIV
- Filing Date
- 2026-01-21
- Publication Date
- 2026-05-08
AI Technical Summary
Large language models are prone to factual omissions or logical illusions in specialized domains or tasks requiring traceable evidence. Existing technologies struggle to perform effective structured reasoning in multi-hop relationships, hierarchical inheritance, or causal chains, and computational overhead and oversmoothing are common when performing multi-layer message passing on large-scale graphs.
An enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval is adopted. By acquiring domain source data, semantic perception segmentation and entity relationship extraction are performed to construct a domain knowledge graph. Explicit topological position encoding and semantic embedding vector fusion are performed to locate seed nodes for constrained subgraph diffusion and dynamic pruning, generating a structured and sequential prompt word input large language model.
It improves the accuracy of multi-hop reasoning, reduces logical illusions, reduces computational overhead and oversmoothing, enhances the distinguishability and retrieval stability of node representations, and improves the structured reasoning ability of large language models.
Smart Images

Figure CN121562834B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence, information retrieval and knowledge engineering, and in particular to an enhanced generation method based on topology-aware graph coding and adaptive subgraph retrieval. Background Technology
[0002] In related technologies, large language models can generate coherent text and possess a certain degree of reasoning ability. However, in specialized fields or tasks requiring traceable evidence, relying solely on model parameter memorization can easily lead to factual omissions or logical illusions. Retrieval-enhanced generation techniques can improve answer coverage by retrieving relevant content from external knowledge bases and concatenating it with the input model. However, when knowledge involves multi-hop relationships, hierarchical inheritance, or causal chains, simple "retrieval text concatenation" often fails to express structured reasoning paths, resulting in potential reasoning gaps in the generated results.
[0003] To enhance structural reasoning, some solutions introduce knowledge graphs and provide evidence to the model through node or triple retrieval. However, node-level or triple-level retrieval tends to output fragmented knowledge, lacking connected context, making the model "see only local evidence and unable to form global inferences." Other solutions attempt to introduce message passing aggregation based on graph neural networks at the encoding layer to fuse neighborhood information. However, multi-layer message passing on large-scale graphs not only incurs high online computational costs but also easily leads to over-smoothing, causing the representations of different nodes to converge, reducing distinguishability and affecting retrieval stability. At the alignment layer, some solutions only perform semantic alignment in the vector space, such as using contrastive learning to shorten the distance between positive samples. These methods struggle to ensure that the large language model generation process truly "focuses" on key structural paths, resulting in attention allocation deviating from the needs of structured reasoning even when correct evidence is retrieved. Summary of the Invention
[0004] This invention aims to at least partially address one of the technical problems in the aforementioned technologies. To this end, this invention proposes an enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval, which enables structured guidance, thereby suppressing logical illusions and improving the accuracy of multi-hop reasoning.
[0005] To achieve the above objectives, this invention proposes an enhanced generation method based on topology-aware graph coding and adaptive subgraph retrieval. The method includes the following steps: acquiring domain source data and performing semantic-aware segmentation on the domain source data to obtain a multi-granularity text block set including parent and child text blocks; extracting entity relations based on the multi-granularity text block set to construct a domain knowledge graph, wherein the domain knowledge graph includes nodes and edges; performing text semantic coding on the nodes in the domain knowledge graph to obtain semantic embedding vectors; constructing a graph structure feature matrix and performing matrix feature decomposition or spectral analysis to obtain explicit topological position coding, wherein the graph structure feature matrix includes... The process includes: an adjacency matrix and / or a distance matrix; fusing the explicit topological location encoding with the semantic embedding vector in an overlay or concatenation manner to obtain a topology-aware node representation; acquiring a user query and vectorizing the user query to obtain a query vector; locating a seed node based on the query vector and the topology-aware node representation, performing constrained subgraph diffusion from the seed node to obtain a candidate subgraph, and performing semantic-topological joint scoring and dynamic pruning on the candidate subgraph to form an optimal connected subgraph; performing structured serialization on the optimal connected subgraph to construct prompt words including graph structure information, and inputting the prompt words and the query vector together into a large language model to generate output text.
[0006] Compared with the prior art, the present invention has at least the following beneficial effects: (1) By injecting structural information in the form of pre-computed coordinates through explicit topological position encoding, the computational overhead and excessive smoothing caused by multi-layer aggregation of online GNN are avoided, thereby improving the distinguishability of node representation and retrieval stability; (2) Connected subgraphs are used as retrieval enhancement context, and the diffusion and divergence of subgraphs are suppressed by semantic-topological joint scoring and dynamic pruning, thereby improving the connectivity and context density of multi-hop evidence chains; (3) Structural consistency constraints are imposed on the self-attention matrix and subgraph adjacency matrix of the large language model during the training or fine-tuning stage, and attention masks can be introduced during the inference stage to strengthen structural path consistency, thereby reducing logical illusions and improving the accuracy of multi-hop inference.
[0007] In addition, the enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval proposed in the above embodiments of the present invention may also have the following additional technical features:
[0008] Optionally, when training or fine-tuning the large language model, the self-attention weight matrix of the large language model for input words is obtained, and the adjacency matrix of the optimal connected subgraph is constructed. The graph-text structure consistency loss function is calculated to measure the difference between the self-attention weight matrix and the adjacency matrix, and the attention distribution of the large language model is structurally constrained by minimizing the difference.
[0009] Optionally, a graph structure feature matrix is constructed, and matrix eigenvalue decomposition or spectral analysis is performed to obtain an explicit topological position code, including constructing a normalized Laplace matrix; performing eigenvalue decomposition on the Laplace matrix, selecting the eigenvectors corresponding to multiple minimum nontrivial eigenvalues as the topological coordinate vectors of the nodes, and using the topological coordinate vectors as the explicit topological position code.
[0010] Optionally, the explicit topological location encoding is a pre-computed coordinate vector. The pre-computation includes offline computation of the entire graph or online computation of induced subgraphs of candidate subgraphs, and the pre-computed coordinate vector is directly called and fused with the semantic embedding vector during the inference stage.
[0011] Optionally, the fusion includes additive fusion, splicing fusion, or gated fusion, wherein gated fusion includes interactive calculation of gate coefficients based on query vectors and node topological feature values, used to dynamically adjust the explicit topological location encoding injection ratio.
[0012] Optionally, the constrained subgraph diffusion includes at least one of breadth-first search, random walk with restart, or neighborhood expansion with a limited number of hops, and the diffusion constraint includes at least one of maximum number of hops, edge type whitelist, maximum number of branches, or maximum number of candidate nodes.
[0013] Optionally, the semantic topology joint score satisfies the following formula:
[0014]
[0015] in, This represents the semantic cosine similarity between query vector q and node n. This represents the distance from node n to the nearest seed node. The shortest path distance, This represents the distance scaling parameter. This represents a smoothing term or a bias term adjusted based on the node centrality index; when If the value is less than a preset threshold, node n will be removed from the candidate subgraph.
[0016] Optionally, the structured serialization includes an output node list, an edge list, and a path list; wherein, the node list includes node identifiers, node text summaries, node topological feature values, and node topological coordinates; the edge list includes a start point, an end point, a relationship type, and an edge weight; and the path list includes the shortest path sequence from the seed node to the key evidence node.
[0017] Optionally, the image-text structure consistency loss function satisfies the following formula:
[0018]
[0019] in, This represents the self-attention weight matrix of the large language model for input lexical units. Represents the adjacency matrix of the optimal connected subgraph. Describing the Frobenius norm, This represents the normalization operator, and the model parameters are updated through gradient backpropagation to achieve matrix-level alignment between the self-attention weight matrix and the adjacency matrix.
[0020] Optionally, attention mask constraints are also included in the inference phase: an attention mask is constructed based on the adjacency relationship of the optimal connected subgraph, and suppression or upper limit constraints are imposed on the attention allocation between corresponding words of non-adjacent nodes to enhance the consistency of structural paths in the inference phase. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval according to an embodiment of the present invention.
[0022] Figure 2 This is a flowchart illustrating an enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval according to an embodiment of the present invention.
[0023] Figure 3 This is a schematic diagram illustrating the explicit topological location encoding generation and fusion principle according to an embodiment of the present invention;
[0024] Figure 4 This is a schematic diagram illustrating the adaptive subgraph diffusion and dynamic pruning principle according to an embodiment of the present invention;
[0025] Figure 5 This is a schematic diagram illustrating the principle of text-image structure consistency constraint according to an embodiment of the present invention. Detailed Implementation
[0026] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0027] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the invention to those skilled in the art.
[0028] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0029] refer to Figure 1 As shown, the enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval in this embodiment of the invention includes the following steps:
[0030] In one embodiment, the method includes a training phase and an inference phase, wherein the training phase is used to learn structured constraints on a large language model, and the inference phase is used to perform augmented generation based on pre-computed explicit topological position encoding and optimal connected subgraphs, with the following steps performed as needed at different phases.
[0031] S101, acquire domain source data and perform semantic-aware segmentation on the domain source data to obtain a multi-granularity text block set including parent text blocks and child text blocks.
[0032] As one example, the input domain source data may include policy specifications, technical documents, fault tickets, medical guidelines, equipment instructions, structured records, etc., and this application does not specifically limit it.
[0033] It should be noted that semantic-aware segmentation includes two levels of segmentation: parent and child. Parent text blocks are generated based on title level, chapter structure, or topic boundaries. Child text blocks are generated within the parent text blocks based on the changes in semantic similarity between adjacent paragraphs. The parent and child text blocks are then mapped to graph nodes of different granularities, and parent-child membership edges are established.
[0034] In other words, semantically aware segmentation of domain source data is preferably performed using a two-level parent-child strategy: the parent text block is used to maintain the integrity of the topic, and the child text block is used to provide fine-grained evidence.
[0035] S102, entity relations are extracted from a multi-granularity text block set to construct a domain knowledge graph, which includes nodes and edges.
[0036] As an example, the nodes of the domain knowledge graph include at least one or more of text block nodes, entity nodes, and relation nodes, and the edges include at least one or more of relation edges, co-occurrence relation edges, hierarchical relation edges, causal relation edges, or reference relation edges.
[0037] As an example, topological feature values are also calculated based on the nodes. The topological feature values include a combination of at least two of the following: degree centrality, betweenness centrality, eigenvector centrality, PageRank value, k-core level value, clustering coefficient, and random walk visit frequency.
[0038] Specifically, such as Figure 2As shown, entity relationships are extracted based on a multi-granularity text block set to obtain entity nodes, relationship edges, and text block nodes. Relationships such as "text block - entity", "entity - entity", and "parent block - child block" are written into the domain knowledge graph. Topological feature values are calculated for nodes, including at least centrality and importance indicators, which are used for subsequent gating fusion, seed priority setting, and pruning bias adjustment.
[0039] S103, perform text semantic encoding on the nodes in the domain knowledge graph to obtain semantic embedding vectors, and construct a graph structure feature matrix, and perform matrix feature decomposition or spectral analysis to obtain explicit topological location encoding, wherein the graph structure feature matrix includes an adjacency matrix and / or a distance matrix.
[0040] As an example, such as Figure 3 As shown, a graph structure feature matrix is constructed, and matrix eigenvalue decomposition or spectral analysis is performed to obtain explicit topological location encoding. This includes: constructing a normalized Laplacian matrix; performing eigenvalue decomposition on the Laplacian matrix, selecting the eigenvectors corresponding to multiple minimum nontrivial eigenvalues as the topological coordinate vectors of the nodes, and using the topological coordinate vectors as explicit topological location encoding.
[0041] As an example, explicit topological location encoding is a pre-computed coordinate vector. The pre-computation includes offline computation on the entire graph or online computation on induced subgraphs only for candidate subgraphs. The pre-computed coordinate vector is directly called and fused with the semantic embedding vector during the inference phase to reduce the computational overhead of online inference and avoid excessive smoothing caused by online multi-layer message passing.
[0042] Specifically, an adjacency matrix A is constructed by selecting a full or local induced subgraph from the domain knowledge graph; when multi-hop relationships need to be expressed, a distance matrix Dist is further constructed, where, This represents the shortest path distance between nodes i and j.
[0043] It should be noted that, unlike online message passing that relies on GNNs, this application converts structural information into a matrix and performs deterministic computation, thereby enabling the direct invocation of pre-computed coordinates during the inference stage, avoiding the overhead of online multi-layer aggregation and over-smoothing.
[0044] Construct the normalized Laplace matrix according to the following formula:
[0045] Where A represents the adjacency matrix, I represents the identity matrix, and D represents the degree matrix.
[0046] Perform eigenvalue decomposition based on the following formula:
[0047] Select the eigenvectors corresponding to the k smallest nontrivial eigenvalues to form Then the topological coordinate vector of each node is This coordinate system can reflect the global relative position of a node in the graph and the local community structure, and can capture long-range dependencies and distinguish different structural roles.
[0048] S104, during the inference phase, the explicit topological location encoding is fused with the semantic embedding vector in an overlay or concatenation manner to obtain the topologically aware node representation.
[0049] It should be noted that this is an online information transfer aggregation that does not rely on graph neural networks.
[0050] As an example, the fusion includes additive fusion, splicing fusion, or gated fusion. Among them, gated fusion includes interactive calculation of gate coefficients based on query vectors and node topological feature values, which are used to dynamically adjust the explicit topological location encoding injection ratio.
[0051] Specifically, such as Figure 2 As shown in the feature fusion layer, the semantic embedding vector is... With explicit topological location coding By merging or splicing, a topology-aware node representation is obtained. .
[0052] In one implementation, additive fusion is used:
[0053] in, This represents the projection matrix.
[0054] In another implementation, a splicing and blending method is used:
[0055] in, This represents the topological eigenvalue vector.
[0056] In a further optimized implementation, gated fusion is introduced to dynamically adjust the structure injection ratio:
[0057] The above gating mechanism enables the system to adaptively enhance structural information based on the query type: for example, when the query involves multi-hop reasoning and path constraints, the gating value is increased to enhance topology injection; when the query is more descriptive, the gating value is decreased to avoid introducing unnecessary structural noise.
[0058] As an alternative, explicit topological location coding can also employ random walk location coding (RWPE) or shortest path distance coding (SPD), but both are based on "explicitly pre-computed coordinates / distances and directly injected into embeddings" and do not rely on online GNN aggregation.
[0059] S105, obtain the user query and perform query vectorization on the user query to obtain the query vector.
[0060] S106. Based on the query vector and the topology-aware node representation, locate the seed node, perform constrained subgraph diffusion from the seed node to obtain candidate subgraphs, and perform semantic-topological joint scoring and dynamic pruning on the candidate subgraphs to form the optimal connected subgraph.
[0061] In other words, semantic and topological joint scoring and dynamic pruning are performed on candidate subgraphs to retain high-scoring nodes in order to form the optimal connected subgraph.
[0062] As an example, the constrained subgraph diffusion includes at least one of breadth-first search, random walk with restart, or neighborhood expansion with a limited number of hops, and the diffusion constraint includes at least one of maximum number of hops, edge type whitelist, maximum number of branches, or maximum number of candidate nodes.
[0063] Specifically, such as Figure 2 As shown, the user query is vectorized to obtain the query vector. The system is based on query vectors. With topology-aware node representation The similarity is used for initial screening to locate the Top-K seed nodes; the seed node location can be achieved using cosine similarity or a learned matching function; to improve robustness, node centrality can be used as a priori weighting to give priority to key structural hubs in the case of equal scores.
[0064] Constrained subgraph expansion includes: performing neighborhood expansion starting from the seed node, preferably limiting the maximum number of hops H (e.g., 1-hop, 2-hop, 3-hop) and using a whitelist of edge types; alternatively, a random walk with restart can be used to maintain focus around the seed node. Figure 4 As shown, during the diffusion process, long-tailed noise nodes that are "semantically similar but too far apart" will appear. If only semantic similarity is used for retention, it will cause the subgraph to diverge and introduce irrelevant context. Therefore, this application introduces a joint semantic-topological scoring and dynamic pruning. The retention score for candidate node n is defined as:
[0065] in, Represents semantic cosine similarity. This represents the shortest path distance to the nearest seed node. This represents the distance attenuation term, used to suppress long-tailed noise and prevent excessive diffusion. It can be used as a smoothing term to prevent the denominator from being zero; in the preferred implementation, Node centrality bias can also be introduced: smaller distance penalties are imposed on hub nodes with high centrality, making them easier to retain, thereby improving the connectivity of the evidence chain.
[0066] Dynamic pruning strategies include threshold pruning and budget pruning: when Remove nodes and related edges as needed; when the number of nodes in the subgraph or the token budget exceeds the limit, proceed as follows: Eliminate items gradually from low to high until the budget is met.
[0067] Only high-scoring nodes are retained to form a connected subgraph: such as Figure 4 As shown on the right, the system tends to retain high-scoring nodes and their necessary connecting edges to form an optimal connected subgraph for subsequent context generation, thereby achieving the retrieval goal of being "relevant, connected, and non-divergent".
[0068] In further optimization, the system adopts a two-stage retrieval approach from coarse to fine: first, candidate topics are located at the parent text block node level, and then child nodes are pruned within the candidate topics to improve evidence density and reduce cross-topic noise.
[0069] S107. The optimal connected subgraph is structured and serialized to construct prompt words that include graph structure information. The prompt words and query vector are then input into the large language model to generate the output text.
[0070] As an example, structured serialization includes outputting a node list, an edge list, and a path list; wherein, the node list includes node identifiers, node text summaries, node topological feature values, and node topological coordinates; the edge list includes start point, end point, relationship type, and edge weight; and the path list includes the shortest path sequence from the seed node to the key evidence node.
[0071] It should be noted that the above serialization method can explicitly present to the model "which nodes are related, which nodes are connected, and how to follow the path", avoiding the loss of structural constraints by simply splicing text.
[0072] As an example, when training or fine-tuning a large language model, the self-attention weight matrix of the large language model for input words is obtained, and the adjacency matrix of the optimal connected subgraph is constructed. The graph-text structure consistency loss function is calculated to measure the difference between the self-attention weight matrix and the adjacency matrix, and the attention distribution of the large language model is structurally constrained by minimizing the difference.
[0073] In other words, during the training or fine-tuning phase, the attention matrix is extracted from a specified layer of the Transformer (e.g., the last layer). And map the subgraph adjacency matrix according to the token alignment to .
[0074] As a specific example, the image-text structure consistency loss function satisfies the following formula:
[0075]
[0076] in, This represents the self-attention weight matrix of the large language model for input lexical units. Represents the adjacency matrix of the optimal connected subgraph. Describing the Frobenius norm, This represents a normalization operator used to normalize a matrix to a comparable probability distribution.
[0077] The training objective function can be:
[0078] in, Indicates the loss of generating the task. This represents the weight coefficients; the model parameters are updated through gradient backpropagation so that the attention distribution is structurally consistent with the adjacency relationship of the subgraph.
[0079] like Figure 5 As shown, the adjacency matrix of the subgraph is usually sparse, while the attention matrix is usually dense. By aligning the matrix, we can suppress the model from allocating attention to nodes that are not related to the structural path, thereby reducing illusions and improving the structural consistency of reasoning.
[0080] As a specific implementation, the inference phase also includes attention mask constraints: an attention mask is constructed based on the adjacency relationship of the optimal connected subgraph, and suppression or upper limit constraints are applied to the attention allocation between corresponding words of non-adjacent nodes to enhance the consistency of structural paths during the inference phase.
[0081] In other words, during the inference phase, the model trained with structural consistency constraints can be used directly; in further optimized implementations, attention masks can be constructed based on the adjacency relationships of the subgraph to impose penalties or upper limits on the attention between non-adjacent node tokens, making the structural constraints during the inference phase stronger.
[0082] In summary, the augmented generation method based on topology-aware graph encoding and adaptive subgraph retrieval according to embodiments of the present invention includes multi-granularity semantic-aware segmentation and knowledge graph construction, structural feature matrix construction and explicit topological position encoding generation, constrained subgraph diffusion and dynamic pruning based on semantic-topological joint scoring, and graph-text consistency loss constraint generation based on attention matrix structured alignment. Explicit topological position encoding is used at the encoding layer to avoid the overhead and over-smoothing caused by online GNN aggregation; connected subgraphs rather than fragmented nodes are used as augmented context at the retrieval layer; and the attention matrix and subgraph adjacency matrix within the large language model are directly constrained to be consistent at the alignment layer, achieving structured guidance from the reasoning mechanism level, thereby suppressing logical illusions and improving the accuracy of multi-hop reasoning.
[0083] In summary, when this application is used for medical pathway reasoning: the graph nodes include diseases, symptoms, tests, drugs, contraindications, and guideline clauses; when the query involves multi-hop reasoning such as "whether a certain drug is usable under a certain comorbidity," the system locates drug and comorbidity nodes through seed nodes, expands to obtain contraindication and alternative paths, prunes to retain only high-scoring connected subgraphs, and inputs the paths as prompt words into the model; structural alignment focuses attention on the contraindication chain and alternative paths, thereby outputting traceable conclusions; when used for industrial fault attribution: the graph nodes include equipment components, fault phenomena, alarm codes, operating parameters, and treatment measures; when the query is "the root cause and treatment sequence of alarm code X under operating condition Y," the system expands with alarm codes and operating conditions as seed nodes, retains the root cause chain and treatment path, and structural alignment constrains the model to focus on key nodes according to the chain, outputting treatment suggestions that include the order of steps and evidence citations.
[0084] Therefore, explicit topological location encoding captures the global relative position and community structure of nodes in the form of pre-computed coordinates, enabling the model to simultaneously perceive semantic relevance and topological potential; adaptive subgraph retrieval uses connected subgraphs as retrieval units, retaining both key evidence nodes and necessary intermediate paths, reducing inference breaks caused by fragmented evidence; semantic-topological joint scoring suppresses long-tail noise through logarithmic distance decay, avoids subgraph diffusion and divergence, and improves context density and usability; structured alignment of the attention matrix forces structural consistency at the inference mechanism level, effectively suppressing the model from focusing on irrelevant nodes, thereby reducing logical illusions; and it avoids multi-layer online message passing aggregation on large-scale graphs, reducing inference latency and computational costs, making it suitable for engineering deployment.
[0085] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0086] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0087] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0088] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0089] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0090] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0091] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0092] In the description of this invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0093] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0094] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0095] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms should not be construed as necessarily referring to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0096] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. An enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval, characterized in that, Includes the following steps: Acquire domain source data and perform semantic-aware segmentation on the domain source data to obtain a multi-granularity text block set including parent text blocks and child text blocks; Entity relations are extracted based on the multi-granularity text block set to construct a domain knowledge graph, wherein the domain knowledge graph includes nodes and edges; Text semantic encoding is performed on the nodes in the domain knowledge graph to obtain semantic embedding vectors, and a graph structure feature matrix is constructed. Matrix feature decomposition or spectral analysis is then performed to obtain explicit topological location encoding, wherein the graph structure feature matrix includes an adjacency matrix and / or a distance matrix. During the inference phase, the explicit topological location encoding is fused with the semantic embedding vector in an overlay or concatenation manner to obtain a topology-aware node representation; Obtain the user query and vectorize the user query to obtain the query vector; Based on the query vector and the topology-aware node representation, a seed node is located. Starting from the seed node, a constrained subgraph diffusion is performed to obtain a candidate subgraph. Then, a semantic-topological joint scoring and dynamic pruning are performed on the candidate subgraph to form an optimal connected subgraph. The optimal connected subgraph is structured and serialized to construct prompt words that include graph structure information. The prompt words and the query vector are then input into a large language model to generate output text. The semantic topology joint score satisfies the following formula: in, This represents the semantic cosine similarity between query vector q and node n. This represents the distance from node n to the nearest seed node. The shortest path distance, This represents the distance scaling parameter. This represents a smoothing term or a bias term adjusted based on the node centrality index. Dynamic pruning strategies include threshold pruning and budget pruning: when If the number of nodes is less than a preset threshold, remove node n from the candidate subgraph; if the number of nodes in the subgraph or the token budget exceeds the upper limit, proceed as follows: Eliminate items gradually from low to high until the budget is met.
2. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 1, characterized in that, When training or fine-tuning the large language model, the self-attention weight matrix of the large language model for input words is obtained, and the adjacency matrix of the optimal connected subgraph is constructed. The graph-text structure consistency loss function is calculated to measure the difference between the self-attention weight matrix and the adjacency matrix, and the attention distribution of the large language model is structurally constrained by minimizing the difference.
3. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 1, characterized in that, Construct a graph structure feature matrix and perform matrix eigenvalue decomposition or spectral analysis to obtain explicit topological location encoding, including: Construct a normalized Laplace matrix; The Laplacian matrix is subjected to eigenvalue decomposition, and the eigenvectors corresponding to multiple minimum nontrivial eigenvalues are selected as the topological coordinate vectors of the nodes. The topological coordinate vectors are then used as the explicit topological position codes.
4. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 3, characterized in that, The explicit topological location encoding is a pre-computed coordinate vector. The pre-computation includes offline computation of the entire graph or online computation of induced subgraphs of candidate subgraphs. The pre-computed coordinate vector is directly called and fused with the semantic embedding vector during the inference stage.
5. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 4, characterized in that, The fusion includes additive fusion, splicing fusion, or gated fusion. Among them, gated fusion includes the interactive calculation of gate coefficients based on query vectors and node topological feature values, which is used to dynamically adjust the explicit topological location encoding injection ratio.
6. The enhanced generation method based on topology-aware graph coding and adaptive subgraph retrieval as described in claim 1, characterized in that, The constrained subgraph diffusion includes at least one of breadth-first search, random walk with restart, or neighborhood expansion with a limited number of hops, and the diffusion constraint includes at least one of maximum number of hops, edge type whitelist, maximum number of branches, or maximum number of candidate nodes.
7. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 1, characterized in that, The structured serialization includes an output node list, an edge list, and a path list; wherein, the node list includes node identifiers, node text summaries, node topological feature values, and node topological coordinates; the edge list includes start point, end point, relationship type, and edge weight; and the path list includes the shortest path sequence from the seed node to the key evidence node.
8. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 2, characterized in that, The image-text structure consistency loss function satisfies the following formula: in, This represents the self-attention weight matrix of the large language model for input lexical units. Represents the adjacency matrix of the optimal connected subgraph. Describing the Frobenius norm, This represents the normalization operator, and the model parameters are updated through gradient backpropagation to achieve matrix-level alignment between the self-attention weight matrix and the adjacency matrix.
9. The enhanced generation method based on topology-aware graph encoding and adaptive subgraph retrieval as described in claim 2, characterized in that, The inference phase also includes attention mask constraints: an attention mask is constructed based on the adjacency relationship of the optimal connected subgraph, and suppression or upper limit constraints are applied to the attention allocation between corresponding words of non-adjacent nodes to enhance the consistency of structural paths during the inference phase.
Citation Information
Patent Citations
Large language model reasoning enhancement method based on structure perception knowledge graph representation
CN120633869A
Joint modeling method based on knowledge graph and large model retrieval enhancement
CN121117179A