Knowledge graph question and answer method and system
By introducing prototype information filtering and heterogeneous graph neural network processing in the knowledge graph question and answer system, the problems of incomplete candidate answer sets, limited accuracy of scoring mechanisms and insufficient expansion are solved, and higher accuracy and expansion of question and answers are achieved.
Patent Information
- Application Number
- CN202411616817.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-13
AI Technical Summary
The existing knowledge graph question and answer system faces the problems of incomplete candidate answer sets, limited accuracy of scoring mechanisms and insufficient expansion.
By introducing prototype information for filtering, heterogeneous information aggregation and feature transfer are used to perform heterogeneous information aggregation and feature transfer, and the scoring model is trained through reasonable loss functions to generate a more complete and accurate set of candidate answers.
It significantly improves the accuracy and expansion of knowledge graph questions and answers, and the generated set of candidate answers is more comprehensive and accurate, and can effectively handle complex question and answer tasks.
Smart Images

Figure CN119578524A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing based on knowledge graphs, and more specifically, to a knowledge graph question-answering method and system. Background Art
[0002] With the development of artificial intelligence and big data technology, knowledge graph question answering system has gradually become one of the important tools for understanding natural language and extracting knowledge from complex data. Knowledge graph question answering aims to generate accurate answers from natural language questions raised by users based on the structured information in the knowledge graph. As a structured representation, knowledge graph contains triple information of entity (head entity), relationship and attribute (tail entity). It can not only help computers better understand objects in the world and the relationships between them, but also improve the performance of question answering system. However, the current knowledge graph question answering technology still faces the following key problems:
[0003] (1) The candidate answer set is not complete
[0004] Knowledge graph question answering systems usually generate candidate answer sets. This process usually relies on entities, relations, and contextual information related to the question in the knowledge graph. However, existing methods often ignore some potentially relevant entities in the knowledge graph, resulting in the generated candidate answer sets being incomplete and incomplete.
[0005] (2) The accuracy of the scoring mechanism is limited
[0006] After generating a set of candidate answers, the system needs to score each candidate answer based on its relevance to the question, so as to select the most likely correct answer. Traditional scoring methods usually use path-based matching or simple models based on similarity, which are less effective when dealing with complex problems. Existing models do not fully utilize the neighbor relationships in the knowledge graph, resulting in insufficient entity expression capabilities; and when dealing with complex triple relationships, existing models also have deficiencies in feature extraction, making it difficult to capture the complex semantic structure in the question.
[0007] (3) Lack of scalability
[0008] The design of most current knowledge graph question answering systems is relatively dependent on the structure and content of specific knowledge graphs. Relying only on strict type information leads to insufficient filtering, lack of versatility and scalability. Some systems perform well in specific domains, but perform poorly in cross-domain or cross-knowledge graph question answering tasks. This problem stems from the fact that the system is overly dependent on the specific patterns and entity representations of the knowledge graph during design, and lacks effective use of the potential abstract structures (such as prototypes) in the knowledge graph. Summary of the invention
[0009] The purpose of the present invention is to overcome the defects of the prior art, such as incomplete candidate answer set, limited accuracy of scoring mechanism and insufficient scalability, and to provide a knowledge graph question answering method and system.
[0010] To achieve the above object, the technical solution of the present invention is as follows:
[0011] The present invention provides a knowledge graph question answering method, comprising the following steps:
[0012] Obtain input data, wherein the input data includes a triple set of a knowledge graph and a corresponding prototype set of an entity set in the triple set;
[0013] Based on the prototype set, a prototype vector set is obtained, and based on the entity set and the correlation between entities and prototypes in the prototype set, a clustering algorithm is used to calculate the membership of each entity to each prototype to obtain an entity-prototype membership matrix, and the prototype vector set is updated according to the entity-prototype membership matrix;
[0014] Obtaining a prototype relationship prototype tensor according to the expression pattern constraints of the knowledge graph, and obtaining an initial candidate answer set according to the prototype vector set, the entity-prototype membership matrix and the prototype relationship prototype tensor;
[0015] Using a heterogeneous graph neural network to perform heterogeneous information aggregation and feature transfer across types of nodes for the candidate triple answers in the initial candidate answer set;
[0016] Using a given knowledge graph question-answering sample as a training set and minimizing the loss function as a goal, the scoring model of the heterogeneous graph neural network is trained;
[0017] Connecting entity features and prototype representations of the candidate answer set after the heterogeneous information aggregation and feature transfer to obtain a final candidate answer set;
[0018] The trained heterogeneous graph neural network is used to score and sort the answers in the final candidate answer set, and the top K answers with the highest scores are output.
[0019] Furthermore, the clustering algorithm is a fuzzy C-means clustering algorithm, which is used to learn the relationship between entities and prototypes in the knowledge graph, rather than directly using the features of a single entity.
[0020] Furthermore, the calculation formula of the entity-prototype membership matrix is as follows:
[0021]
[0022] Where d represents entity e i With prototype p iThe semantic distance between them, k is the index of the traversal prototype, that is, for all prototypes p k Perform traversal and summation, α is the membership index, usually between [1.5, 2.5].
[0023] Further, the updating of the prototype vector set according to the entity-prototype membership matrix includes: using all entities e i For prototype p i Membership As a weight, for the entity vector e i Perform weighted summation and divide by the normalization factor of all memberships to obtain the prototype vector p j , the calculation expression is as follows:
[0024]
[0025] Furthermore, each candidate triple answer tensor C in the candidate answer set is obtained by the following calculation expression:
[0026] C=h p ×PRP×U
[0027] Among them, h p is the prototype vector of the head entity h, U is the entity-prototype membership matrix, and PRP is the prototype relation prototype tensor with dimension |P|×|R|×|P|.
[0028] Furthermore, the heterogeneous information aggregation includes: the heterogeneous graph neural network performs heterogeneous information aggregation on different types of neighbor nodes in the triple (h, r, t), and for the head entity h, its neighbor nodes may be other head entities h or tail entities t or relationship nodes r, and these neighbor nodes are of different types, so different aggregation functions are required;
[0029] The aggregation function of the head entity h is:
[0030]
[0031] Among them, N h is the neighbor set of head entity h, w hj is the weight coefficient between head entity h and neighbor j, is the weight matrix corresponding to the neighbor type, h j represents the j-th head entity node, σ is the activation function, usually the Leaky ReLU function;
[0032] The aggregation function of relation r is:
[0033]
[0034] Among them, N ris the neighbor set of relation r, w rm is the weight coefficient between relation r and neighbor m, is the weight matrix corresponding to the neighbor type, r m represents the mth relationship node;
[0035] The aggregation function of the tail entity t is:
[0036]
[0037] Among them, N t is the neighbor set of the tail entity t, w tk is the weight coefficient between the tail entity t and its neighbor k, is the weight matrix corresponding to the neighbor type, t k Represents the kth tail entity node.
[0038] Furthermore, the heterogeneous graph neural network uses a triple scoring function for scoring, and the expression of the scoring function is:
[0039]
[0040] Among them, σ is the Sigmoid function, v h 、v r 、v t They are the embedding vectors of the head entity, relation, and tail entity in the triple, respectively, and W,b are weight parameters.
[0041] Furthermore, the feature transfer between nodes of different types is performed using a type-related weighting mechanism, and the formula is as follows:
[0042]
[0043] Among them, z i is the feature representation, is the weight calculated according to the node type, W ij is a learnable parameter for aggregating neighbor information, C (h,r,t) Each candidate triple answer tensor C is converted into an embedding vector through a bilinear model to form a complete vectorized representation. The formula of the bilinear model is:
[0044] C (h,r,t) =s(h,r,t)=h T W r t.
[0045] Furthermore, the loss function adds a dynamic weight adjustment strategy for positive and negative samples. By introducing the problem complexity estimation, the weight distribution of positive and negative samples is dynamically adjusted. The loss function L uses a logarithmic-based loss that combines the scores of positive and negative samples to distinguish correct entity relationship triples from incorrect triples. The gradient descent algorithm is used to minimize the loss L during training and update the model parameters W,b. The expression of the loss function L is as follows:
[0046] L=log(1+exp(f(h,r + ,t + )))+log(1+exp(-f(h,r - ,t - )))
[0047] Among them, r + Represents the relationship vector of the positive sample, r - Represents the relationship vector of negative samples, t + represents the target entity of the positive sample, i.e., the tail entity, t - The target entity representing the negative sample is the tail entity.
[0048] To achieve the purpose of the invention, the present invention further provides a knowledge graph question answering system, which applies a knowledge graph question answering method such as described in the above technical solution, and the system includes:
[0049] A data input module, used to obtain input data, wherein the input data includes a triple set of the knowledge graph and a corresponding prototype set of the entity set in the triple set;
[0050] The prototype segmenter module is used to cluster entities in the knowledge graph using a clustering algorithm and learn the affiliation between entities and their prototypes to obtain an entity-prototype affiliation matrix and a set of prototype vectors;
[0051] A prototype-based filter module is used to construct a prototype relation prototype tensor according to the expression pattern constraints of the prototype relation, capturing the complex associations between prototypes to generate a more comprehensive and accurate initial candidate answer set;
[0052] The training module is used to construct the loss function and train the scoring model of the heterogeneous graph neural network;
[0053] The heterogeneous graph neural network module is used to perform heterogeneous information aggregation and feature transfer, connect the entity features and prototype representations in the initial candidate answer set, generate the final candidate answer set, score and sort the final candidate answer set, and output the top K highest-scoring answers.
[0054] Compared with the prior art, the present invention has the following beneficial effects:
[0055] The present invention generates a set of candidate answers by filtering using broader prototype information, thereby enhancing the filtering coverage, avoiding the problem of insufficient filtering caused by relying solely on strict type information, and enhancing scalability; introducing heterogeneous graph neural networks to solve the problem of heterogeneous information sources, extracting information from multi-type neighbors through different aggregation strategies, capturing complex entity relationships, and training the scoring model through a reasonable loss function to improve the matching degree of candidate answers, thereby significantly improving the accuracy of knowledge graph question and answering. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is a flow chart of a knowledge graph question-answering method of the present application. DETAILED DESCRIPTION
[0057] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0058] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0059] Example 1
[0060] See also Figure 1 Embodiment 1 of the present invention provides a knowledge graph question answering method, comprising the following steps:
[0061] S1: Obtain input data, including a set of triples in the knowledge graph and a set of prototypes corresponding to the set of entities in the set of triples.
[0062] Definition of prototype: The format of the type hierarchy is T = / t1 / t2 / … / tn, t1 is called the prototype, which is the broadest and abstract semantic type in the type hierarchy (for example, a type can be expressed as " / film / actor", and " / film" is called the prototype).
[0063] S2: Based on the prototype set, a prototype vector set is obtained. A clustering algorithm is used and based on the correlation between entities and prototypes in the entity set and the prototype set, the membership of each entity to each prototype is calculated to obtain an entity-prototype membership matrix, and the prototype vector set is updated according to the entity-prototype membership matrix. Step S2 is specifically as follows:
[0064] The fuzzy clustering algorithm is used to cluster entities in the knowledge graph and learn the affiliation between entities and their prototypes. In this way, an entity-prototype affiliation matrix is constructed, which is used to represent the strength of association between each entity and multiple prototypes. Compared with traditional entity representation methods, it can capture a wider range of potential associations, thus laying the foundation for the subsequent generation of candidate answer sets.
[0065] The relationship between entities and prototypes in the knowledge graph is learned through fuzzy C-means clustering, rather than directly using the features of a single entity. This can better express the potential relationship between entities. By introducing prototype representation, it is possible to handle complex knowledge graph question-answering tasks, especially those involving multi-hop reasoning.
[0066] The entity set E in the input data is {e1,e2,...,e m}, prototype set P = {p1,p2,...,p n}, randomly initialize each prototype p i The semantic vector of is obtained to obtain the prototype vector set. Iterative learning calculates the membership of the entity to each prototype:
[0067] (A) Computational entity e i For prototype p i The membership degree u ij :
[0068]
[0069] Where d represents entity e i With prototype p i The semantic distance between them, k is the index of the traversal prototype, that is, for all prototypes p k Perform traversal and summation, α is the membership index, usually between [1.5, 2.5].
[0070] (B) Update the prototype vector according to the membership degree:
[0071]
[0072] Utilize all entities i For prototype p i Membership As a weight, for the entity vector e i Perform weighted summation and divide by the normalization factor of all memberships to obtain the prototype vector p j .
[0073] S3: Obtain a prototype relationship prototype tensor according to the expression pattern constraints of the knowledge graph, and obtain an initial candidate answer set according to the prototype vector set, the entity-prototype membership matrix and the prototype relationship prototype tensor, as follows:
[0074] According to the expression pattern constraints of the prototype relationship, the correlation between prototypes is used to derive more likely candidate answers. This step builds a prototype tensor of prototype relationships to capture the complex associations between prototypes, ensuring that the generated candidate answer set is more complete and accurate. When generating the candidate answer set, the system not only relies on direct entity relationships, but also comprehensively considers the prototype information related to the question, which can effectively deal with situations where entity information is sparse or incomplete.
[0075] Using prototype relations instead of traditional direct entity relations for filtering can better ensure the completeness of the candidate answer set. The accuracy of candidate answer generation is enhanced by expressing pattern constraints, which is particularly suitable for multi-hop reasoning and complex question-answering tasks.
[0076] Input prototype vector h of head entity h p , entity-prototype membership matrix U, prototype relationship prototype tensor PRP, dimension |P|×|R|×|P|. The prototype triple is represented as a tensor, and the prototype vector of the entity is multiplied by the prototype relationship prototype tensor and the entity-prototype membership matrix to obtain the candidate triple answer tensor C:
[0077] C=h p ×PRP×U
[0078] The initial candidate answer set is obtained based on all candidate triple answer tensors C.
[0079] S4: Using a heterogeneous graph neural network to perform heterogeneous information aggregation and feature transfer across node types for the candidate triple answers in the initial candidate answer set, as follows:
[0080] Heterogeneous graph neural networks can effectively improve model performance under diverse data by processing different types of nodes and relationships.
[0081] Knowledge graphs contain multiple types of nodes and edges. In traditional graph neural networks, these nodes and edges are usually processed uniformly, while in heterogeneous graph neural networks, the differences in node and edge types are specially considered. For example, in a movie knowledge graph, nodes may include "actor", "movie", "director", etc., and relationships include "starring", "directing", etc. Heterogeneous graph neural networks use different strategies to process these heterogeneous data according to the types of nodes and edges.
[0082] Triple vectorization: First, each candidate triple answer tensor is converted into an embedding vector to form a complete vectorized representation. The bilinear model is used to transform C to obtain C (h,r,t) :
[0083] C (h,r,t) =s(h,r,t)=h T Wr t
[0084] The vectorized triples (h, r, t) will be used to generate feature representations as input to the heterogeneous graph neural network. The vectorized entity and relationship features can enable the heterogeneous graph neural network to better handle different types of nodes and edges.
[0085] Heterogeneous information aggregation: Heterogeneous graph neural networks aggregate information through different types of neighbors. Heterogeneous information aggregation focuses on how to process and integrate information from different types of nodes. In a heterogeneous graph, nodes may belong to different categories, and nodes of each category may have different characteristics and connection patterns. The goal of heterogeneous information aggregation is to capture the complex relationships between these different types of nodes and integrate their information to obtain a more comprehensive node representation. For the head entity h, its neighbor nodes can be other entity nodes (such as other movies, actors) or relationship nodes (such as "starring", "directed", etc.). These neighbor types are different, so different aggregation functions are required.
[0086] The aggregation function of the head entity h is:
[0087]
[0088] Among them, N h is the neighbor set of head entity h, w hj is the weight coefficient between head entity h and neighbor j, is the weight matrix corresponding to the neighbor type, h j represents the j-th head entity node, σ is the activation function, usually the Leaky ReLU function.
[0089] Similarly, the aggregation method of the tail entity t and the relationship r is also similar, except that different weight matrices are selected depending on the entity or relationship.
[0090] The aggregation function of relation r is:
[0091]
[0092] Among them, N r is the neighbor set of relation r, w rm is the weight coefficient between relation r and neighbor m, is the weight matrix corresponding to the neighbor type, r m Represents the mth relationship node.
[0093] The aggregation function of the tail entity t is:
[0094]
[0095] Among them, N tis the neighbor set of the tail entity t, w tk is the weight coefficient between the tail entity t and its neighbor k, is the weight matrix corresponding to the neighbor type, t k Represents the kth tail entity node.
[0096] Cross-type node feature transfer: Cross-type node feature transfer and heterogeneous information aggregation complement each other. For nodes in heterogeneous graphs, cross-type node feature information transfer is very important. Therefore, heterogeneous graph neural networks allow feature transfer between cross-type nodes. For example, the neighbors of node h can be other node types, such as other entities (head entity, tail entity) or relationships. This needs to be done through a type-dependent weighting mechanism, as follows:
[0097]
[0098] in, is the weight calculated according to the node type, W ij is a learnable parameter used to aggregate neighbor information.
[0099] S5: Using the given knowledge graph question-answering samples (including positive samples and negative samples) as the training set, and minimizing the loss function as the goal, the scoring model of the heterogeneous graph neural network is trained as follows:
[0100] The scoring model function for the triplet is as follows:
[0101]
[0102] Among them, σ is the Sigmoid function, v h 、v r 、v t They are the embedding vectors of the head entity, relation, and tail entity in the triple, respectively, and W,b are weight parameters.
[0103] Based on the traditional contrast loss function, a dynamic weight adjustment strategy for positive and negative samples is added. By introducing problem complexity estimation and dynamically adjusting the weight distribution of positive and negative samples, especially in complex scenarios of multi-hop reasoning, it can effectively distinguish error-prone samples from normal samples and improve the overall robustness of the model.
[0104] The loss function is defined as:
[0105] L=log(1+exp(f(h,r + ,t + )))+log(1+exp(-f(h,r - ,t - )))
[0106] where r +Represents the relationship vector of the positive sample, r - Represents the relationship vector of negative samples, t + represents the target entity of the positive sample, i.e., the tail entity, t - The target entity of the negative sample is the tail entity. The loss function L uses a logarithmic-based loss that combines the scores of positive and negative samples to distinguish between correct entity relationship triplets and incorrect triplets. The gradient descent algorithm is used to minimize the loss L and update the model weight parameter W,b.
[0107] S6: Connect the entity features and prototype representations of the initial candidate answer set after heterogeneous information aggregation and feature transfer to obtain the final candidate answer set.
[0108] Entity features refer to the specific information of a single entity, such as its type and attributes, which are converted into a vector representation obtained by embedding vectors; prototype representation refers to generating a typical vector representing a certain type of entity by clustering or summarizing the common features of the entity.
[0109] S7: Use the trained heterogeneous graph neural network to score and sort the answers in the final candidate answer set, and output the top K answers with the highest scores:
[0110] For each candidate answer t i , represented by its characteristics z i Calculate the score Can be simplified to:
[0111]
[0112] This rating is the relevance score of the candidate answer, reflecting how well the node matches the question.
[0113] The system scores each candidate answer based on its Sort in descending order and select the top K answers with the highest scores. The specific sorting formula is:
[0114]
[0115] Among them, Top-K means selecting the K answers with the highest scores.
[0116] Example 2
[0117] Based on Example 1, this Example 2 applies a knowledge graph question-answering method of Example 1 to provide a knowledge graph question-answering system, which includes:
[0118] A data input module is used to obtain input data, where the input data includes a triple set of the knowledge graph and a corresponding prototype set of the entity set in the triple set;
[0119] The prototype segmenter module is used to cluster entities in the knowledge graph using a clustering algorithm and learn the affiliation between entities and their prototypes to obtain an entity-prototype affiliation matrix and a set of prototype vectors;
[0120] A prototype-based filter module is used to construct a prototype relation prototype tensor according to the expression pattern constraints of the prototype relation, capturing the complex associations between prototypes to generate a more comprehensive and accurate initial candidate answer set;
[0121] The training module is used to construct the loss function and train the scoring model of the heterogeneous graph neural network;
[0122] The heterogeneous graph neural network module is used to aggregate heterogeneous information and transfer features, connect entity features and prototype representations in the initial candidate answer set, generate the final candidate answer set, score and sort the answers in the final candidate answer set, and output the top K highest-scoring answers.
[0123] The other technical details and steps of this embodiment 2 are the same as those of embodiment 1 and will not be repeated here.
[0124] Example 3
[0125] Based on Examples 1 and 2, Example 3 describes a knowledge graph question-answering process, where the knowledge graph contains entity information about "movies", such as movie names, directors, actors, ratings, genres, etc. The question raised by the user is: "Who is the director of Titanic?"
[0126] Step 1: Data Input Module and Prototype Segmenter Module Processing:
[0127] (1) Input data: relevant entities in the knowledge graph, including Titanic, James Cameron, other movies and their directors, etc.
[0128] (2) Fuzzy clustering: The prototype segmentation module performs fuzzy clustering on these entities to determine their membership in different prototype categories. For example:
[0129] 1. Prototype A: Director (including James Cameron, Spielberg, etc.)
[0130] 2. Prototype B: Movies (including Titanic, Jurassic Park, etc.)
[0131] 3. Archetype C: Actor (including Leonardo DiCaprio, Kate Winslet, etc.)
[0132] (3) Entity-prototype membership matrix: Generate an entity-prototype membership matrix to reflect the membership relationship between each entity and the prototype. For example, the membership probability between Titanic and the movie prototype is 0.9, and the membership probability between director James Cameron and the director prototype is 0.95.
[0133] Step 2: Prototype-based filter module processing:
[0134] (1) Prototype relationship tensor: Construct a prototype relationship tensor to express the relationship between different prototypes. For example:
[0135] The relationship between a director and a movie is "directing", and the relationship between an actor and a movie is "starring".
[0136] (2) Candidate answer generation: Using the prototype relation tensor, a candidate answer set is generated based on the entity "Titanic" in the user's question. For example, the generated candidate answers include: James Cameron, Spielberg, Martin Scorsese, etc. (possible movie directors).
[0137] (3) Filtering process: Based on the generated candidate answer set, expression pattern constraints are applied to filter, ensuring that the generated candidate answers meet the attributes of the director of the movie, thereby retaining valid candidate answers related to the question. For example, the candidate answer after filtering is: James Cameron.
[0138] Step 3: Heterogeneous graph neural network module processing:
[0139] (1) Neighbor relationship processing: Use the heterogeneous graph neural network scorer module to score candidate answers. Heterogeneous neural networks can handle multiple types of nodes and edges, thereby effectively improving model performance under diverse data. For "Titanic", neighbor nodes may include other movies and directors.
[0140] (2) Information aggregation: Heterogeneous neural networks aggregate information through different types of neighbors. For a head entity, its neighbor nodes can be other entity nodes (such as other movies, actors) or relationship nodes (such as "starring", "directed", etc.). Different types of neighbors need to be processed using different aggregation functions.
[0141] (3) Cross-type feature information transfer: Heterogeneous graph neural networks allow feature transfer between nodes of different types. For example, the neighbors of a node can be other node types, which is done through a type-dependent weighting mechanism.
[0142] Step 4: Output the final answer The final answer must conform to the entity features and prototype representation:
[0143] (1) Answer selection: Score the candidate answers, combining the characteristics and prototype representation of the candidate entities. For example, James Cameron scored 0.98 and Spielberg scored 0.75. Select the final answer based on the scoring results. Since James Cameron scored the highest, the answer returned by the system is "James Cameron".
[0144] (2) Output results: The final answer is displayed to the user. When asked “Who is the director of Titanic?”, the answer is “James Cameron”.
[0145] The other technical details and steps of this embodiment 3 are the same as those of embodiments 1 and 2 and will not be repeated here.
[0146] In summary of the above embodiments, the present invention uses a prototype segmenter to learn the affiliation of each entity with each prototype, and constructs an entity-prototype affiliation matrix; uses the prototype relationship prototype tensor to express pattern constraints, and introduces prototype information to generate a candidate answer set. The present invention uses heterogeneous graph neural network knowledge graph question and answer, which has many significant advantages, including the ability to effectively handle diversified data, enhanced information aggregation, flexible feature transfer, and adaptive learning capabilities. Heterogeneous graph neural networks extract information from multiple types of neighbors through different aggregation strategies, capture complex entity relationships, and improve question and answer accuracy. In addition, reasonable loss functions and optimization strategies enable it to effectively distinguish between correct and incorrect entity relationship triplets during training, thereby enhancing the robustness of the model.
[0147] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A knowledge graph question answering method, characterized in that: The following steps are involved: Obtain input data, the input data including a triple set of the knowledge graph and a prototype set corresponding to the entity set in the triple set; Based on the prototype set, a prototype vector set is obtained, and based on the entity set and the correlation between entities and prototypes in the prototype set, a clustering algorithm is used to calculate the membership of each entity to each prototype to obtain an entity-prototype membership matrix, and the prototype vector set is updated according to the entity-prototype membership matrix; Obtaining a prototype relationship prototype tensor according to the expression pattern constraints of the knowledge graph, and obtaining an initial candidate answer set according to the prototype vector set, the entity-prototype membership matrix and the prototype relationship prototype tensor; Using a heterogeneous graph neural network to perform heterogeneous information aggregation and feature transfer across types of nodes for the candidate triple answers in the initial candidate answer set; Using a given knowledge graph question-answering sample as a training set and minimizing the loss function as a goal, the scoring model of the heterogeneous graph neural network is trained; Connecting entity features and prototype representations of the initial candidate answer set after the heterogeneous information aggregation and feature transfer to obtain a final candidate answer set; The trained heterogeneous graph neural network is used to score and sort the answers in the final candidate answer set, and the top K answers with the highest scores are output.
2. A knowledge graph question answering method according to claim 1, characterized in that: The clustering algorithm is a fuzzy C-means clustering algorithm, which is used to learn the relationship between entities and prototypes in the knowledge graph, rather than directly using the features of a single entity.
3. A knowledge graph question answering method according to claim 1, characterized in that: The calculation formula of the entity-prototype membership matrix is as follows: Where d represents entity e i With prototype p i The semantic distance between them, k is the index of the traversal prototype, that is, for all prototypes p k Perform traversal and summation, α is the membership index, usually between [1.5, 2.5].
4. A knowledge graph question answering method according to claim 3, characterized in that: The updating of the prototype vector set according to the entity-prototype membership matrix comprises: using all entities e i For prototype p i Membership As a weight, for the entity vector e i Perform weighted summation and divide by the normalization factor of all memberships to obtain the prototype vector p j , the calculation expression is as follows:
5. A knowledge graph question answering method according to claim 4, characterized in that: Each candidate triple answer tensor C in the initial candidate answer set is obtained by the following calculation expression: C=h p ×PRP×U Among them, h p is the prototype vector of the head entity h, U is the entity-prototype membership matrix, and PRP is the prototype relation prototype tensor with dimension |P|×|R|×|P|.
6. A knowledge graph question answering method according to claim 5, characterized in that: The information aggregation includes: a heterogeneous graph neural network performs heterogeneous information aggregation on different types of neighbor nodes in the triple (h, r, t). For a head entity h, its neighbor nodes may be other head entities h or tail entities t or relationship nodes r. These neighbor nodes are of different types, and therefore require different aggregation functions. The aggregation function of the head entity h is: Among them, N h is the neighbor set of head entity h, w hj is the weight coefficient between head entity h and neighbor j, is the weight matrix corresponding to the neighbor type, h j represents the j-th head entity node, σ is the activation function, usually the Leaky ReLU function; The aggregation function of relation r is: Among them, N r is the neighbor set of relation r, w rm is the weight coefficient between relation r and neighbor m, is the weight matrix corresponding to the neighbor type, r m represents the mth relationship node; The aggregation function of the tail entity t is: Among them, N t is the neighbor set of the tail entity t, w tk is the weight coefficient between the tail entity t and its neighbor k, is the weight matrix corresponding to the neighbor type, t k Represents the kth tail entity node.
7. A knowledge graph question answering method according to claim 6, characterized in that: The feature transfer between nodes of different types is performed using a type-related weighting mechanism, and the formula is as follows: Among them, z i is the feature representation, h j represents the jth node, is the weight calculated according to the node type, W ij is a learnable parameter for aggregating neighbor information, C (h,r,t) The complete vectorized representation formed by converting each candidate triple answer tensor C into an embedded vector through a bilinear model, and the formula for the conversion of the bilinear model is: C (h,r,t) =s(h,r,t)=h T W r t。 8. A knowledge graph question answering method according to claim 7, characterized in that: The heterogeneous graph neural network uses a triple scoring function for scoring, and the expression of the scoring function is: Among them, σ is the Sigmoid function, v h 、v r 、v t They are the embedding vectors of the head entity, relation, and tail entity in the triple, respectively, and W,b are weight parameters.
9. A knowledge graph question answering method according to claim 8, characterized in that: The loss function adds a dynamic weight adjustment strategy for positive and negative samples. By introducing the problem complexity estimation, the weight distribution of positive and negative samples is dynamically adjusted. The loss function L uses a logarithmic-based loss that combines the scores of positive and negative samples to distinguish correct entity relationship triples from incorrect triples. The gradient descent algorithm is used to minimize the loss L during training and update the model parameters W,b. The expression of the loss function L is as follows: L=log(1+exp(f(h,r + ,t + )))+log(1+exp(-f(h,r - ,t - ))) Among them, r + Represents the relationship vector of the positive sample, r - Represents the relationship vector of negative samples, t + represents the target entity of the positive sample, i.e., the tail entity, t - The target entity representing the negative sample is the tail entity.
10. A knowledge graph question answering system, using a knowledge graph question answering method such as those described in claims 1-9, characterized in that: The system comprises: A data input module, used to obtain input data, wherein the input data includes a triple set of the knowledge graph and a corresponding prototype set of the entity set in the triple set; The prototype segmenter module is used to cluster entities in the knowledge graph using a clustering algorithm and learn the affiliation between entities and their prototypes to obtain an entity-prototype affiliation matrix and a set of prototype vectors; A prototype-based filter module is used to construct a prototype relation prototype tensor according to the expression pattern constraints of the prototype relation, capturing the complex associations between prototypes to generate a more comprehensive and accurate initial candidate answer set; The training module is used to construct the loss function and train the scoring model of the heterogeneous graph neural network; The heterogeneous graph neural network module is used to perform heterogeneous information aggregation and feature transfer, connect entity features and prototype representations in triples and candidate answer sets, generate a final candidate answer set, score and sort the final candidate answer set, and output the top K highest-scoring answers.
Citation Information
Patent Citations
Intelligent question-answering method based on knowledge graph embedded representation
CN112579795A
Contrast learning prediction method and system for heterogeneous knowledge graph
CN116401380A
Project evaluation and review method and system fused with natural language processing
CN118780767A
Distributed Entity Re-Resolution Based on Streaming Updates
US20240045896A1
Graph neural network-based disease diagnosis and prediction system
WO2023124190A1