Knowledge graph semantic enhancement generation method based on large language model
By combining PageRank and GAT to evaluate entity importance and designing differentiated Prompt templates, the problems of lack of context and high overhead when generating entity descriptions in large language models are solved, and efficient and accurate entity description generation is achieved.
Patent Information
- Application Number
- CN202511501977.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-01-23
AI Technical Summary
Large language models lack contextual information when generating entity descriptions, resulting in inaccurate descriptions and high system overhead, especially in the vertical field of hydraulic engineering operation and maintenance.
By combining the PageRank algorithm and the Graph Attention (GAT) mechanism, entity importance is evaluated and graded, differentiated prompt templates are designed to generate detailed or concise descriptions, and computational overhead is optimized.
It improves the accuracy and efficiency of entity description, reduces computational overhead, and enhances the generation quality and readability of knowledge graphs.
Smart Images

Figure CN121390261A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a knowledge graph semantic enhancement generation method based on a large language model, belonging to the technical field of natural language processing. BACKGROUND
[0002] The emergence of large language models has attracted widespread attention in recent years. However, large models can produce inaccurate or unrealistic outputs, a phenomenon commonly referred to as the "hallucination problem". The hallucination problem will limit the LLM's ability to answer questions in vertical fields such as water conservancy. Since the knowledge graph stores knowledge in a structured triple form, it has high reliability and good explainability. Combining knowledge graphs with large language models is considered a potential solution to effectively alleviate the hallucination problem in LLM reasoning. Therefore, in order to improve the question-answering ability of large language models in vertical fields, domain graphs are usually introduced to enhance the question-answering ability of large language models in vertical fields.
[0003] However, the quality of the knowledge graph has an important influence on improving the question-answering ability of the large language model. In order to enhance the quality of the knowledge graph, the traditional knowledge graph completion model considers completing from the aspect of the graph structure. The traditional knowledge graph completion method completes in the aspect of the graph structure, but the data of the knowledge graph is usually static, and lacks detailed entity description information, relying only on the text form of the entity name. This leads to limitations in the KGC model's understanding of entities, relationships, and triples. With the emergence of large language models, their inherent rich knowledge and powerful generation capabilities provide new possibilities for knowledge graph completion. However, when generating entity description information, the lack of entity context information can easily lead to the phenomenon of fictitious or inaccurate descriptions. For example, when generating entity descriptions for the water conservancy operation and maintenance vertical field knowledge graph, asking "Generate entity description information according to the entity name 'expansion joint'.", the LLM generates an incorrect answer that references the civil building standard and the inspection period does not conform to the water conservancy specification (should be before the flood season + after the earthquake, not fixed 5 years). This is due to the lack of context information provided only by the entity name, which prevents the model from accurately understanding the entity meaning, resulting in inaccurate information.
[0004] In addition, not all entities in the knowledge graph have the same importance, and large-scale generation of description information for all entities can cause significant system overhead problems. SUMMARY
[0005] Inventive purpose: In order to solve the problems of lack of context information and large system overhead in LLM generated entity description information, the application provides a knowledge graph semantic enhancement generation method based on large language model, which effectively fuses knowledge graph structure information and semantic information, reduces the computing overhead while ensuring the accuracy of description and context relevance, thereby improving the efficiency and quality of knowledge graph entity description generation.
[0006] Technical scheme: A knowledge graph semantic enhancement generation method based on large language model, comprising the following steps: (1) Entity importance evaluation: The importance of entities in the knowledge graph is calculated, and the structural importance of the entities is obtained based on the PageRank algorithm, while capturing entity features and complex semantic relationships; the PageRank value is taken as an additional feature and fused with the graph attention mechanism (GAT) to realize multi-dimensional entity importance evaluation; (2) Entity hierarchical processing: According to the results of entity importance evaluation, combined with the long-tail distribution characteristics of the knowledge graph, the important distribution level of the entity is determined to conform to the long-tail entity distribution characteristics, and the entity is divided into "important" entities and "generally important" entities in proportion; (3) Important entity subgraph extraction: For entities in the "important" level, multi-hop entity expansion is performed, with the head entity and the tail entity as the center, and multi-hop subgraph searching is performed; important entity K-neighbor relationship searching, focusing on extracting the context most closely related to the target triple in semantics according to semantic relevance; thus, the target entity associated subgraph information is retrieved in the knowledge graph to obtain the target triple subgraph containing the context semantics of the target triple; for the retrieved target triple subgraph, entity filtering is performed, and for nodes with the same entity type, they can be merged into one node, and the merged node is filtered according to the importance score to retain entities in the "important" level, thereby removing redundant information, simplifying the subgraph structure and optimizing the computing overhead; (4) Differentiated description generation: Different Prompt templates are designed for entities in different importance levels, and detailed description Prompts are designed for entities in the "important" level; for entities in the "generally important" level, a brief description Prompt is designed.
[0007] Further, the specific steps of the entity importance evaluation in step (1) are as follows: (1.1) Structural importance evaluation of each entity: The ranking of nodes is calculated by the PageRank algorithm, the importance is propagated by the connection relationship (edge) of the node, and the PageRank value converges to a stable state through iterative updating, the entity with high PageRank value has high influence in the graph, and the PageRank value calculation formula is as follows: in It is a node PageRank value; It is the damping factor (usually 0.85); It points to a node All nodes; It is a node The out-degree of the node. The number of edges it points to.
[0008] Let knowledge graph represent ,in Represents a set of entities ; Represents the set of edges, each edge Indicates from point to This is a relationship. Because this method focuses on generating entity description information, each edge is assigned a weight. Integrating knowledge graphs into the PageRank algorithm to calculate the importance of entities within the graph structure can be expressed by the following formula: in, Representing entities PageRank value. Damping coefficient (usually taken as 0.85) represents the probability of a random jump. Indicates all pointers A collection of entities. Representing entities The out-degree, that is, from The number of entities it points to. Indicates from arrive Relationship weights. It represents the total number of nodes.
[0009] First, for each node in the entity collection... of The value is initialized. During initialization... Setting it to the mean value indicates that each entity initially has equal importance. The formula is as follows: in, superscript This represents the number of iterations and is initialized to 0.
[0010] Update each entity gradually The value is used to iterate through each round until the PageRank value converges, which is... Less than a set threshold The specific formula is as follows: Wherein, The superscript in represents the kth round of iterative update.
[0011] (1.2) Extract the semantic importance of each entity: concatenate the entity and the relationship feature vector in the triple to obtain the embedding representation of the corresponding triple, as shown in the following formula: Wherein, represents a parameterized linear change matrix; || represents concatenation; , and represent the embedding of entity , relationship and entity .
[0012] The attention value of the triple is calculated by LeakyReLU nonlinear transformation, which represents the importance of the triple, as shown in the formula: Wherein, represents a parameterized linear change matrix; represents the entity domain entity set; represents the relationship set connecting entity and .
[0013] The new embedding vector of entity is the weighted sum of each triple representation according to its relative attention value: Where is the sigmod activation function.
[0014] In order to encapsulate more information of domain entity, the final entity embedding representation is calculated by multi-head attention, and the specific expression is as follows: Where M is the sum of independent attention mechanisms.
[0015] (1.3) Fuse the structure and semantic importance of the entity, and output the entity importance evaluation score: let the entity semantic importance embedding is . The PageRank value of entity is calculated by (1.1) as . Therefore, the initial feature of entity is shown in the formula as follows: where || represents the splicing operation.
[0016] In the updating process, GAT dynamically adjusts the importance of neighbor entities according to the entity features. The entity representation not only depends on the structure information (the features of neighbor nodes), but also needs to integrate the PageRank score and the semantic embedding. Specifically, the representation updating formula of entity is as follows: where represents the representation of entity at the k-th layer; is the weight matrix at the k-th layer, used to represent the representation of each entity; represents an entity in the set of entity neighbors; is the attention coefficient between node i and neighbor node j. This coefficient is dynamically calculated according to the features of the nodes and is learned through the representation of the nodes. The attention coefficient is calculated as shown in the following formula: where, is the learned attention vector used to calculate the similarity between two nodes. represents the representation of entity at the k-th layer; is the weight matrix at the k-th layer, used to represent the representation of each entity; represents an entity in the set of entity neighbors.
[0017] The final representation of entity is . On the basis of the entity representation, in order to comprehensively evaluate the importance of the entity and improve the accuracy of the evaluation result. The L2 norm of the entity representation and the structural feature value are combined to measure the importance of the entity , and the specific formula is as follows: where is a weight parameter determined through training.
[0018] Further, the specific steps in the entity grading process of step (2) are as follows, according to the obtained entity importance The entities are ranked, and research shows that the knowledge graph has a long-tail entity distribution feature. Therefore, the top 20% of entities are selected as the important entity set , and the last 80% of entities are selected as the general important entity set .
[0019] Further, the specific steps in step (3) important entity subgraph extraction are as follows: (3.1) Important entity multi-hop entity expansion: starting from the head entity , find all triples with as the head entity to get the entities directly connected to . For each head entity , its triples are , represent all tail entities connected to , is the set of all triples in the knowledge graph.
[0020] Starting from the tail entity , find all triples with as the tail entity to get the entities directly connected to . Similarly, the adjacency node set of the tail entity is .
[0021] The entities obtained from h and t are further expanded multiple times until the set number of jumps L is reached. Each jump further expands the node set , represents the node set of the th jump, as shown in the formula: (3.2) Important entity K-neighbor relationship search: according to the relationship in the target triple, retrieve all other triples containing the relationship from the knowledge graph. Traverse the knowledge graph to find all triples with relationship to get the set . Calculate the similarity between each triple and the target triple, and select the top K most relevant triples to construct the relationship subgraph, reduce redundant context information, and improve training efficiency. Calculate the similarity between the triples in and the target triple , and select the top K most relevant triples from the set so that the generated relationship subgraph can focus more on the context closest to the semantic of the target triple.
[0022] (3.3) Subgraph simplification: for the entity set in the subgraph , nodes with the same entity type are merged to obtain the subgraph after merging nodes . The merged nodes are further merged according to the entity importance as a screening condition, and important entities are selected to obtain the final subgraph entity set, as shown in the following formula: The final subgraph is obtained as .
[0023] Further, the specific steps in the step (4) of differential description generation are as follows: according to the obtained entity hierarchy, detailed descriptions are generated for the entities in the important entity layer to highlight their core position in the knowledge graph. These entities and relationships usually have high connectivity in the knowledge graph, directly affecting multiple other entities or relationships. Detailed descriptions are generated for these entities, including features, related relationships, etc. When generating description information, the subgraph content of the important entity is obtained; a brief description is generated for the entities in the general important entity layer. These entities do not appear as frequently as the entities in the first layer in the knowledge graph, but still have certain semantic relevance. Brief descriptions are generated for these entities, which may include entity names, entity types, etc., but omit other details.
[0024] A knowledge graph semantic enhancement generation system based on a large language model, comprising the following modules: (1) Entity importance evaluation module: the importance of entities in the knowledge graph is calculated, the structural importance of entities is obtained based on the PageRank algorithm, and the entity features and complex semantic relationships are captured; the PageRank value is taken as an additional feature, which is fused with the graph attention mechanism (GAT) to realize multi-dimensional entity importance evaluation; (2) Entity classification processing module: according to the results of entity importance evaluation, combined with the long-tail distribution characteristics of the knowledge graph, the important distribution level of the entity is determined to meet the long-tail entity distribution characteristics, and the entity is divided into "important" entities and "generally important" entities in proportion; (3) Important entity subgraph extraction module: for the "important" level entities, multi-hop entity expansion is performed, taking the head entity and the tail entity as the center, and multi-hop searching subgraph is performed; K-neighbor relationship searching is performed according to semantic relevance, focusing on extracting the context most closely related to the target triple in semantics; thus, the context semantics of the target entity is obtained by searching the subgraph information associated with the target entity in the knowledge graph; based on the important entity subgraph search result, the "important" entity subgraph content searched is filtered, and nodes with the same entity type They can be combined into one node, and the combined node is screened according to the importance score to retain entities of an 'important' level, so as to remove redundant information, simplify the subgraph structure and optimize the calculation overhead; (4) A differentiated description generation module: different Prompt templates are designed for entities of different importance levels, and a detailed description Prompt is designed for entities of an 'important' level; and a brief description Prompt is designed for entities of a general importance.
[0025] The implementation process and method of the system are the same, and will not be described again.
[0026] A computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the above-mentioned computer program to realize the knowledge graph semantic enhancement generation method based on a large language model as described above.
[0027] A computer readable storage medium has a computer program / instruction stored thereon, and the computer program / instruction is executed by a processor to realize the steps of the knowledge graph semantic enhancement generation method based on a large language model as described above.
[0028] Advantages: Compared with the prior art, the knowledge graph semantic enhancement generation method based on a large language model provided by the present application has the following advantages: The knowledge graph semantic enhancement generation method based on a large language model provided by the present application fully combines knowledge graph structure information and semantic information, effectively solves the problem of lack of context information and large calculation overhead when generating entity descriptions in existing methods. By introducing an entity importance evaluation module, the PageRank structural importance and the GAT semantic feature are fused to realize multi-dimensional entity importance determination, ensuring the target and accuracy of the description generation; in combination with the long-tail distribution characteristics of the knowledge graph, the entities are divided into two levels of 'important' and 'general important', and different Prompt templates are designed for different levels, realizing the strategy of generating detailed descriptions for target entities and generating concise descriptions for general entities, improving the readability and practicality of the generation results; through the important entity subgraph extraction module, multi-hop search and K-neighbor semantic focusing are used to extract the context information most closely related to the target entity semantics, and redundant nodes are combined and screened to simplify the subgraph structure and reduce the calculation burden; the method significantly optimizes the model calling efficiency while ensuring the generation quality, and has good scalability and engineering application value. BRIEF DESCRIPTION OF DRAWINGS
[0029] Figure 1 The method flowchart of the embodiment of the present application is shown in the figure; Figure 2 The knowledge graph semantic enhancement generation method framework based on a large language model of the embodiment of the present application is shown in the figure; Figure 3This is a schematic diagram illustrating the implementation effect of an embodiment of the present invention. Detailed Implementation
[0030] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading the present invention, any modifications of the present invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.
[0031] like Figure 1 , Figure 2 As shown, a semantic enhancement generation method for knowledge graphs based on large language models is applied to an emergency response knowledge graph in the hydraulic engineering field. The method involves inputting the entire knowledge graph and includes the following steps: Step (1) Entity importance assessment: The importance of entities in the knowledge graph is calculated, the structural importance of entities is obtained based on the PageRank algorithm, and the unit captures entity features and complex semantic relationships; the PageRank value is used as an additional feature and fused with the graph attention mechanism (GAT) to achieve multi-dimensional entity importance assessment.
[0032] The specific steps for entity importance assessment in step (1) are as follows: (1.1) Structural importance assessment for each entity: The ranking of nodes is calculated iteratively using the PageRank algorithm. The importance is propagated by the connection relationships (edges) of the nodes. Through iterative updates, the PageRank value will converge to a stable state. Entities with high PageRank values have higher influence in the graph. The PageRank calculation formula is as follows: in It is a node PageRank value; It is the damping factor (usually 0.85); It points to a node All nodes; It is a node The out-degree of the node. The number of edges it points to.
[0033] Let knowledge graph represent ,in Represents a set of entities ; Represents the set of edges, each edge Indicates from point to This is a relationship. Because this method focuses on generating entity description information, each edge is assigned a weight. The importance of an entity in the graph structure can be calculated by integrating the knowledge graph into the PageRank algorithm, which can be expressed as follows: wherein, represents the PageRank value of the entity . : damping factor (usually 0.85), representing the probability of random jumping. represents the set of all entities pointing to . represents the out-degree of the entity , i.e., the number of entities pointing from . represents the relationship weight from to . is the total number of nodes.
[0034] First, the value of of each node in the entity set is initialized. When initialized, is set to the average value, indicating that the initial importance of each entity is equal. The formula is as follows: wherein, the superscript in represents the number of rounds of iterative updates, which is set to 0 when initialized.
[0035] The value of each entity is updated step by step, and each round of iteration is performed until the PageRank value converges, that is, is less than the set threshold . The specific formula is as follows: wherein, the superscript in represents the kth round of iterative updates.
[0036] (1.2) Extract the semantic importance of each entity: concatenate the entity and relationship feature vectors in the triple wherein the entity is located to obtain the embedding representation of the corresponding triple, as shown in the following formula: wherein, represents a parameterized linear change matrix; || represents concatenation; , and represent the entity , the relationship and the entityEmbedding of .
[0037] Compute the attention value of triplets by LeakyReLU nonlinear transformation . , which represents the importance of triplets as shown in the formula: where denotes the parameterized linear transformation matrix; denotes the entity set of domain entities; denotes the set of relations connecting entities and .
[0038] The new embedding vector of entity is the weighted sum of each triplet representation according to its relative attention value: where is the sigmod activation function.
[0039] In order to encapsulate more information of domain entities, the final entity embedding representation is calculated by multi-head attention, and the specific expression is as follows: where M is the sum of independent attention mechanisms.
[0040] (1.3) Fuse the structure and semantic importance of entities and output the entity importance evaluation score: let the semantic importance embedding of entity be . The PageRank value of entity is calculated by (1.1) as . Therefore, the initial feature of entity is as shown in the formula: where || denotes the concatenation operation.
[0041] In the update process, GAT dynamically adjusts the importance of neighbor entities according to the entity features. Entity representation not only depends on structural information (features of neighbor nodes), but also needs to integrate PageRank scores and semantic embeddings. Specifically, the update formula of entity representation is: where denotes the representation of entity at the k-th layer; the weight matrix of the k-th layer, used to represent the representation of each entity; represent entities in the entity neighbor set; is the attention coefficient between node i and neighbor node j. This coefficient is dynamically calculated according to the characteristics of the node and is learned through the representation of the node. The attention coefficient The calculation formula is shown in the following formula: wherein, is the learned attention vector used to calculate the similarity between two nodes. represent entities in the k-th layer; the weight matrix of the k-th layer, used to represent the representation of each entity; represent entities in the entity neighbor set.
[0042] The representation of the entity is On the basis of the entity representation, in order to comprehensively evaluate the importance of the entity and improve the accuracy of the evaluation result. The L2 norm of the entity representation and the structural feature value are combined to measure the importance of the entity , and the specific formula is: wherein is a weight parameter determined by training.
[0043] Step (2) entity classification processing: according to the entity importance evaluation result, combined with the long tail distribution characteristics of the knowledge graph, the important distribution level of the entity is determined to be consistent with the long tail entity distribution characteristics. The entities are divided into "important" entities and "generally important" entities in proportion.
[0044] According to the obtained entity importance score , the entity is classified and processed. Research shows that the knowledge graph has a long tail entity distribution characteristic. Therefore, the top 20% of entities are selected as the important entity set , and the last 80% of entities are selected as the generally important entity set .
[0045] Step (3) important entity subgraph extraction: for the "important" level entity, through multi-hop entity expansion, the head entity and the tail entity are taken as the center, and the multi-hop search subgraph is carried out; K-neighbor relationship search, according to the semantic correlation, the context most closely related to the target triple in semantics is focused and extracted; thus the target entity associated subgraph information is retrieved in the knowledge graph to obtain its context semantics; based on the important entity subgraph retrieval result, the "important" entity subgraph content retrieved is filtered, and for the nodes with the same entity type , they can be merged into one node, and the merged node is screened according to the importance score to retain the "important" level entity, so as to remove redundant information, simplify the subgraph structure and optimize the calculation overhead; The specific steps of important entity subgraph extraction in step (3) are as follows: (3.1) important entity multi-hop entity expansion: starting from the head entity , find all triples with as the head entity to get the entities directly connected with . For each head entity , its triple is , , which represents all tail entities connected with , is the set of all triples in the knowledge graph.
[0046] Starting from the tail entity , find all triples with as the tail entity to get the entities directly connected with . Similarly, the adjacent node set of the tail entity is For the entities obtained from h and t, continue to expand for multiple times until the set number L is reached. Each jump further expands the node set , , which represents the node set of the th expansion, and the specific formula is as follows: (3.2) important entity K-neighbor relationship search: according to the relationship in the target triple, all other triples containing the relationship are retrieved from the knowledge graph. All triples with the relationship are searched in the knowledge graph to obtain the set . The similarity of each triple and the target triple is calculated, and the top K most relevant triples are selected to construct the relationship subgraph, so as to reduce the redundant context information and improve the training efficiency. The calculation is as follows: Middle Triple and Target Triple Similarity from sets Select the top K most relevant triplets This allows the generated relational subgraph to focus more on the context that is semantically closest to the target triplet.
[0047] (3.3) Subgraph simplification: For the set of entities in a subgraph Nodes with the same entity type Merge the nodes to obtain the subgraph after merging. The merged nodes will then be sorted according to entity importance. As a filtering criterion, important entities are selected to obtain the final set of subgraph entities, as shown in the formula below: The final subgraph is obtained as follows .
[0048] Step (4) Differentiated Description Generation: Design different Prompt templates for entities at different importance levels. For entities at the "important" level, design and generate a detailed description Prompt. The specific content is: "You are a knowledge graph entity description generation assistant, with the entity name as the core. Based on the entity name, entity type and the provided context triple information, generate a detailed description of the entity. Entity name: {entity name}; Entity type: {entity type); Context triple information: (1) Related entities: {list of related entities} (2) Relationships: {list of relationships between entities}; Description requirements: (1) Combine the context information to elaborate on the definition, key attributes and its relationship in the knowledge graph; (2) Ensure that the language is accurate and the logic is clear, and avoid redundancy. "; For entities at the "generally important" level, design a brief description prompt, the specific content of which is: "You are a knowledge graph entity description generation assistant. Please generate a concise and natural language description for this entity based on the following information. The description should be concise and semantically relevant, including its basic definition and its relationship with other related entities. Entity name: {entity name}, entity type: {entity type}; (head entity, relation, tail entity) = ({head entity}, {relation}, {tail entity}); Description requirements: (1) Briefly explain the definition and key attributes of the entity. (2) Describe its relationship with the target entity.
[0049] A knowledge graph semantic enhancement generation system based on a large language model includes the following modules: (1) Entity importance evaluation module: The importance of entities in the knowledge graph is calculated, the structural importance of entities is obtained based on the PageRank algorithm, and the entity features and complex semantic relationships are captured through the semantic importance extraction unit; the PageRank value is taken as an additional feature, which is fused with the graph attention mechanism (GAT) to realize multi-dimensional entity importance evaluation; (2) Entity classification processing module: According to the entity importance evaluation result, combined with the long-tail distribution characteristics of the knowledge graph, the important distribution level of the entity is determined to conform to the long-tail entity distribution characteristics, and the entity is divided into two levels of "important" entity and "generally important" entity in proportion; (3) Important entity subgraph extraction module: For the "important" level entity, the multi-hop entity expansion is performed to find the subgraph centered on the head entity and the tail entity; K-neighbor relationship search is performed to focus on extracting the context most closely related to the target triple in terms of semantics; thus, the target entity associated subgraph information is retrieved in the knowledge graph to obtain its context semantics; based on the important entity subgraph retrieval result, the important entity subgraph content retrieved is filtered, and for the nodes with the same entity type , they can be merged into one node, and the merged node is filtered according to the importance score to retain the "important" level entity, thereby removing redundant information, simplifying the subgraph structure and optimizing the calculation overhead; (4) Differentiated description generation module: Different Prompt templates are designed for entities of different importance levels, a detailed description Prompt is designed for the "important" level entity, and the specific content is: "You are a knowledge graph entity description generation assistant, taking the entity name as the core. According to the entity name, entity type and provided context triple information, generate a detailed description of the entity. Entity name: {entity name}; Entity type: {entity type}; Context triple information: (1) Related entities: {related entity list} (2) Associated relationship: {entity relationship list}; Description requirements: (1) Combine the context information to elaborate the definition, key attributes and associated relationships of the entity in the knowledge graph; (2) Ensure accurate language and clear logic, and avoid redundancy." For the "generally important" level entity, a brief description Prompt is designed, and the specific content is: "You are a knowledge graph entity description generation assistant. Please generate a concise and natural language description for the entity based on the following information. The description should be brief and semantically related, including its basic definition and relationship with other related entities. Entity name: {entity name}, entity type: {entity type}; (head entity, relationship, tail entity) = ({head entity}, {relationship}, {tail entity}); Description requirements: (1) Briefly explain the definition and key attributes of the entity. (2) Describe the associated relationship with the target entity.
[0050] Obviously, those skilled in the art should understand that each step of the knowledge graph semantic enhancement generation method based on the large language model of the above-mentioned embodiments of the present application or each module of the knowledge graph semantic enhancement generation system based on the large language model can be realized by a general computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices; alternatively, they can be realized by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, these steps can be executed in an order different from that shown or described herein, or they can be respectively made into individual integrated circuit modules, or a plurality of modules or steps can be made into a single integrated circuit module to realize. Thus, the embodiments of the present application are not limited to any specific combination of hardware and software.
Claims
1. A large language model-based knowledge graph semantic enhancement generation method, characterized in that, Comprising the following steps: (1) Entity importance evaluation: the importance of entities in the knowledge graph is calculated, and the PageRank value representing the structural importance of the entity is obtained based on the PageRank algorithm to capture entity features and semantic relationships; the PageRank value is used as an additional feature and is fused with the graph attention mechanism to realize multi-dimensional entity importance evaluation; (2) Entity classification processing: according to the results of entity importance evaluation, combining the long-tail distribution characteristics of the knowledge graph, the entities are divided into important entities and general important entities in proportion; (3) Important entity subgraph extraction: for important level entities, multi-hop entity expansion is performed, taking the head entity and the tail entity as the center, and multi-hop subgraph searching is performed; then important entity K-neighbor relationship searching is performed, and according to semantic correlation, the context most closely related to the target triple in semantics is focused and extracted; thus, the target entity associated subgraph information is retrieved in the knowledge graph; based on the retrieved target entity associated subgraph results, entity filtering is performed on the retrieved important entity subgraph content, and nodes with the same entity type are merged into one node, and the merged nodes are screened according to the importance score to retain important level entities; (4) Differentiated description generation: different Prompt templates are designed for entities of different importance levels, and detailed description Prompts are generated for important level entities; and brief description Prompts are generated for general important entities.
2. The method of claim 1, wherein the method further comprises: In step (1), the implementation process of structural importance evaluation for each entity is as follows: the ranking of nodes is calculated by iteration through the PageRank algorithm, the importance is propagated by using the connection relationship of nodes, and through iteration update, the PageRank value converges to a stable state; Set knowledge graph representation Wherein Represent a set of entities ; Represent a set of edges, each edge Represents a relationship from To ; Set the weight of each edge ; Integrate the knowledge graph into the PageRank algorithm to calculate the importance of entities in the graph structure, which is represented by the formula: wherein, denotes the PageRank value of an entity ; : damping factor, denotes the probability of a random jump; denotes the set of all entities pointing to ; denotes the out-degree of an entity , i.e. the number of entities pointing from ; denotes the relation weight from to ; is the total number of nodes; First, the value of each node in the set of entities is initialized ; at initialization , it is set to the mean value ; Update each entity gradually The value is used to iterate through each round until the PageRank value converges.
3. The method of claim 2, wherein the method further comprises: The step (1) extracts semantic importance of each entity: concatenates the entity and relation feature vectors in the triplets to obtain the embedding representation of the corresponding triplets , as shown in the following formula: wherein, denotes a parameterized linear variation matrix; || denotes concatenation; , and denote the embeddings of an entity , a relation and an entity , respectively. The triplets are computed by a LeakyReLU nonlinear transformation of the attention values representing the importance of the triplets; The new embedding vector of an entity is the weighted sum of the representations of each triple in which it appears by its relative attention value: To encapsulate more information of the field entity, the final entity embedding representation is calculated by using multi-head attention The specific expression is as follows: Where M is the sum of independent attention mechanisms.
4. The method of claim 3, wherein the method further comprises: In step (1), the structure and semantic importance of the entity are fused, and the entity importance evaluation score is output: let the semantic importance embedding of entity be ; and the initial feature of entity be as shown in the formula: Where || represents the concatenation operation; In the updating process, GAT dynamically adjusts the importance of neighbor entities according to entity features; entity representation updating formula: wherein representations of entities representations at k layers; weight matrices at k layers for representing the representation of each entity; representations of entities in a set of entity neighbors is an attention coefficient between node i and neighbor node j, which is dynamically calculated according to the features of the nodes and is learned through the representation of the nodes, and the attention coefficient The calculation formula is shown in the following formula: wherein, is the attention vector of learning, used to calculate the similarity between two nodes; represents the entity representation in k layer; weight matrix in k layer, used to represent the representation of each entity; represent the entity in the entity neighbor set; The final entity is represented as ; the L2 norm of the entity representation is combined with the structural feature value to measure the importance of the entity, specifically as follows: wherein weight parameters are determined by training.
5. The method of claim 1, wherein the method further comprises: The specific steps in the step (2) entity classification process are as follows, according to the obtained entity importance , the top 20% of entities are selected as the important entity set , and the last 80% of entities are selected as the general important entity set .
6. The method of claim 1, wherein the method further comprises: The specific steps in step (3) important entity subgraph extraction are as follows: (3.1) Important entity multi-hop entity expansion: from head entity Start, find all triples with as head entity, get entities directly connected to ; for each head entity , whose triples are , represent all tail entities connected to , is the set of all triples in the knowledge graph; Start from tail entity , find all triples with as tail entity, get entities directly connected with ; the set of adjacent nodes of tail entity ; and For the entities derived from h and t, continue to expand multiple times until a set jump number L is reached; each jump further expands the node set , denotes the node set of the th expansion, as shown in the formula: (3.2) Important entity K-nearest neighbor relation search: Based on the relations in the target triple, retrieve all contain relations from the knowledge graph. Other triples; traverse the knowledge graph to find all relations that are The triples yield the set ; The similarity of each triple to the target triple is calculated, and the top K most relevant triples are selected to construct a relation subgraph; the similarity of the middle triple to the target triple is calculated, and the top K most relevant triples are selected from the set (3.3) Subgraph simplification: for a set of entities in a subgraph nodes with the same entity type are merged to get a subgraph after merging nodes ; The merged nodes are further classified according to entity importance As a screening condition, the important entities are selected to obtain the final subgraph entity set, as shown in the following formula: The final subgraph is obtained as .
7. A large language model-based knowledge graph semantic enhancement generation system, characterized in that, Comprising the following modules: (1) Entity importance evaluation module: the importance of entities in the knowledge graph is calculated, and the PageRank value representing the structural importance of the entity is obtained based on the PageRank algorithm to capture entity features and semantic relationships; the PageRank value is used as an additional feature and is fused with the graph attention mechanism to realize multi-dimensional entity importance evaluation; (2) Entity classification processing module: according to the results of entity importance evaluation, combining the long-tail distribution characteristics of the knowledge graph, the important distribution level of the entity is determined to conform to the long-tail entity distribution characteristics, and the entities are divided into important entities and general important entities in proportion; (3) Important entity subgraph extraction module: For important level entities, multi-hop entity expansion is performed to find subgraphs centered on head entities and tail entities; important entity K-neighbor relationship search focuses on extracting the context most closely related to the target triple in terms of semantic relevance; thus, the target entity associated subgraph information is retrieved in the knowledge graph to obtain the target triple subgraph containing the context semantics of the target triple; for the retrieved target triple subgraph, entity filtering is performed, and for nodes with the same entity type, they are merged into one node, and the merged node is screened according to the importance score to retain important level entities, thereby removing redundant information, simplifying the subgraph structure and optimizing the computing overhead; (4) Differentiated description generation: different Prompt templates are designed for entities of different importance levels, and detailed description Prompts are generated for important level entities; for general important level entities, brief description Prompts are generated.
8. A computer device, comprising: The computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the above computer program to implement the steps of the knowledge graph semantic enhancement generation method based on a large language model according to any one of claims 1-6.
9. A computer readable storage medium having stored thereon computer programs / instructions, characterized in that: The computer program / instructions are executed by the processor to implement the steps of the knowledge graph semantic enhancement generation method based on a large language model according to any one of claims 1-6.