Knowledge graph-based knowledge question and answer method and device and storage medium
By introducing multi-hop reasoning technology and relational path embedding in the knowledge graph question and answer system, the problems of low accuracy and poor efficiency in handling complex questions and answers are solved, and more efficient and accurate complex question and answer processing are achieved.
Patent Information
- Application Number
- CN202411663537.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-14
AI Technical Summary
The prior art is inexpensive and poorly efficient when dealing with complex question-and-answer tasks, especially when multi-hop questions and answers, making it difficult to effectively understand and deal with problems involving multiple entities and complex relationships.
Using a knowledge question-and-answer method based on knowledge graph, combining multi-hop reasoning technology, users input question statements are obtained and entity recognition and vector embedding are performed, topic entities are mapped into the knowledge graph, candidate answer entities are generated, and answer inference is performed through relational path embedding.
It significantly improves the accuracy and efficiency of question-and-answer questions and answers in complex tasks, can better capture complex relationships and semantic features in the knowledge graph, provide a more comprehensive knowledge base, reduce invalid calculations, and improve the overall efficiency of the system.
Smart Images

Figure CN119621887A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a knowledge question answering method, device and storage medium based on a knowledge graph, and belongs to the technical field of natural language processing. Background Art
[0002] Knowledge graphs, a key underlying technology in artificial intelligence, are semantic networks that depict relationships between entities. They carry inherent semantics, logical meaning, and rules, describing relationships between entities through triples: a set of "entity x relationship x attribute." Knowledge graphs structure and visualize knowledge information in a nonlinear world, assisting humans in reasoning, prediction, and classification. The graphs in knowledge graphs are not images, but rather structures similar to chemical formulas. A knowledge graph often contains multiple types of entities and relationships. Accordingly, knowledge question answering, a question-answering system based on natural language processing, understands users' natural language questions and extracts relevant information from a known knowledge graph to answer them.
[0003] In the tobacco industry, knowledge graphs play a vital role in training and knowledge sharing. For example, tobacco farming technicians can use existing knowledge graphs and the closely connected knowledge question-answering systems to find specialized knowledge related to tobacco farming and enhance their skills. However, while knowledge graph technology has made significant progress in handling simple questions, the increasing complexity of question-answering tasks, especially when multi-hop question-answering is involved, makes it difficult to rely solely on traditional question-answering technologies. Multi-hop question-answering tasks often involve multiple entities and the complex relationships between them, requiring the system to integrate continuous information and perform deep reasoning. Traditional methods may be unable to cope with such problems because they often rely on fixed query patterns or rules and lack the flexibility to respond to diverse user needs. Therefore, given the low accuracy and poor efficiency of existing technologies when handling complex question-answering, how to combine corresponding multiple reasoning technologies to better understand and handle complex question-answering tasks has become a technical problem that needs to be urgently addressed. Summary of the Invention
[0004] The purpose of the present invention is to provide a knowledge question answering method, device and storage medium based on knowledge graph, aiming to deeply mine the semantic and relational features in the question by combining multi-hop reasoning technology, thereby significantly improving the accuracy and efficiency of complex task question answering.
[0005] In order to achieve the above objectives / solve the above technical problems, the present invention is implemented by adopting the following technical solutions.
[0006] In one aspect, the present invention provides a knowledge question answering method based on a knowledge graph, comprising: Obtain the user input question statement, as well as the target knowledge graph and its embedded representation; Performing entity recognition and question vector embedding processing on the user input question statement to obtain the subject entity and target question embedding vector respectively; Mapping the subject entity to the target knowledge graph and its embedded representation, and generating multiple candidate answer entities based on the subject entity and its proximity relationship; calculating a first similarity for the embedding vector corresponding to the subject entity, the embedding vector corresponding to each candidate answer entity, and the target question embedding vector, and then sorting them according to the corresponding generated first similarity values to obtain a target candidate answer entity set; Extracting a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set from the target knowledge graph, and obtaining a target relationship path embedding vector based on the relationship path set; A second similarity is calculated between the target question embedding vector and the target relationship path embedding vector, and then, based on the corresponding generated second similarity value, an answer to the user input question statement is inferred.
[0007] Optionally, multiple known knowledge graphs are fused and completed to obtain a completed target knowledge graph, including: Fusing the acquired first knowledge graph and the second knowledge graph to generate a fused knowledge graph; Performing random masking or removal processing on related triples of the fused knowledge graph to generate a masked knowledge graph; Input the fused knowledge graph and the masked knowledge graph into the ComplEx embedding model for a single embedding process, and obtain the first entity vector and the first relationship vector corresponding to the fused knowledge graph embedding, and the second entity vector and the second relationship vector corresponding to the masked knowledge graph embedding; Using a graph neural network to learn graph structure-enhanced embeddings, and combining the local graph structure information of the node, performing an embedding update on the first entity vector and the first relationship vector, as well as the second entity vector and the second relationship vector, to obtain a third entity vector and a third relationship vector corresponding to the enhanced fused knowledge graph embedding, and a fourth entity vector and a fourth relationship vector corresponding to the enhanced masked knowledge graph embedding; Calculating corresponding entity similarity values and relationship similarity values based on the third entity vector and the third relationship vector, and the fourth entity vector and the fourth relationship vector, respectively, and determining whether to generate a new alignment pair based on the similarity results, wherein if both the entity similarity value and the relationship similarity value are higher than a preset threshold, aligning the entities or relationships to generate a new alignment pair and adding it to the fused knowledge graph; otherwise, no alignment operation is performed; Repeat the above process until the preset number of iterations is reached, and then obtain the third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions; The third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions are input into the knowledge graph completion decoder to predict the head entity, tail entity and relationship, and generate new triples accordingly; The new triple is added to the knowledge graph corresponding to the third entity vector and the third relationship vector embedded in the enhanced fusion knowledge graph that meets the preset iteration conditions to obtain the target knowledge graph.
[0008] Optionally, the fused knowledge graph is randomly masked or removed by randomly masking or removing related triples to generate a masked knowledge graph, which is expressed as: ; Where, represents the masked knowledge graph, Represents a mask operation, Represents the fused knowledge graph.
[0009] Optionally, based on the third entity vector and the third relationship vector, and the fourth entity vector and the fourth relationship vector, corresponding entity similarity values and relationship similarity values are calculated, respectively, and expressed as: ; ; Where, Represents the entity similarity value, Represents the relationship similarity value, represents the third entity vector corresponding to the enhanced fusion knowledge graph embedding, represents the fourth entity vector corresponding to the enhanced masked knowledge graph embedding, represents the third relation vector corresponding to the enhanced fusion knowledge graph embedding, Represents the fourth relation vector corresponding to the enhanced masked knowledge graph embedding.
[0010] Optionally, entity recognition and question vector embedding are performed on the obtained user input question sentence to obtain the subject entity and target question embedding vectors, respectively, including: Input the text sequence corresponding to the user input question sentence into the Chinese pre-trained language model, and output a first vocabulary embedding vector sequence; Inputting the first vocabulary embedding vector sequence into a named entity recognition model, and outputting a subject entity corresponding to the user input question sentence; Inputting the first word embedding vector sequence into the first memory network layer, and outputting a second word embedding vector sequence; calculating a word-level attention score for each second word embedding vector in the second word embedding vector sequence based on a word-level attention mechanism, and weighting each second word embedding vector using the word-level attention score as a weight to generate a word-level weighted vector; Based on the sentence-level attention mechanism, a sentence-level attention score is calculated for the word-level weighted vector, and the word-level weighted vector is weighted using the sentence-level attention score as a weight to generate a target question embedding vector corresponding to the user input question sentence.
[0011] Optionally, based on a word-level attention mechanism, a word-level attention score is calculated for each second word embedding vector in the second word embedding vector sequence, and each second word embedding vector is weighted using the word-level attention score as a weight to generate a word-level weighted vector, which is expressed as: ; ; Where, Indicates the The attention weight of each word, represents the transpose of the word-level attention context vector, represents the activation function, represents the weight matrix in the word-level attention mechanism, represents the first word in the second word embedding vector sequence The embedding representation of words, Indicates the number of words, Represents word-level weighted vector.
[0012] Optionally, based on a sentence-level attention mechanism, a sentence-level attention score is calculated for the word-level weighted vector, and the sentence-level attention score is used as a weight to weight the word-level weighted vector to generate a question embedding vector corresponding to the question sentence input by the user, which is expressed as: ; ; Where, represents the sentence-level attention weight, represents the transpose of the sentence-level attention context vector, represents the weight matrix in the sentence-level attention mechanism, Indicates the The word embedding vector, Indicates the number of words in a sentence. Represents the question embedding vector corresponding to the user input question sentence.
[0013] Optionally, the subject entity is mapped to the target knowledge graph, and multiple candidate answer entities are generated based on the subject entity and its neighboring relationships, which are expressed as: ; Where, Represents a candidate answer set consisting of multiple candidate answer entities, Indicates the candidate answer entities.
[0014] Optionally, a first similarity is calculated for the embedding vector corresponding to the subject entity, the embedding vectors corresponding to each candidate answer entity, and the target question embedding vector, which is expressed as: ; ; Where, represents the first similarity calculation, The embedding vector of the candidate answer entity, Embedding vector representing the topic entity, Represents the similarity value.
[0015] Sort by the first similarity value generated, and get the target candidate answer entity set, which is expressed as: ; Where, Indicates that the first similarity value ranks first The target candidate answer entity collection consists of target candidate answer entities, Indicates the first similarity value ranking The target candidate answer entity.
[0016] Optionally, extracting a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set from the target knowledge graph, and obtaining a corresponding target relationship path embedding vector based on the relationship path set, including: Extracting a set of relationship paths from all subject entities to each target candidate answer entity in the target candidate answer set from the completed target knowledge graph; Performing a path serialization representation on each relationship path in the relationship path set, and converting each relationship in each relationship path into an embedding vector to obtain a relationship path embedding vector; Inputting the relationship embedding vector into a convolutional neural network and extracting local features to obtain a convolution feature vector; Based on the convolution feature vector, an attention score of each relationship is calculated, and the convolution feature vector is weighted using the attention score as a weight to generate a weighted relationship path embedding vector as the target relationship path embedding vector.
[0017] Optionally, based on the convolution feature vector, an attention score of each relationship is calculated, and the convolution feature vector is weighted using the attention score as a weight to generate a weighted relationship path embedding vector as the target relationship path embedding vector, which is expressed as: ; ; ; Where, represents the convolution feature vector, Indicates the operation of extracting local features through a one-dimensional convolutional layer. represents the relation path embedding vector, represents the attention score of each relation, represents the transpose of the attention weight vector, Indicates the The first relationship path convolutional features, Indicates the The first relationship path convolutional features, Indicates the The number of convolution features in the relationship path, Represents the weighted relation path embedding vector.
[0018] Optionally, a second similarity is calculated between the target question embedding vector and the target relationship path embedding vector, and then the answer to the user input question statement is inferred based on the corresponding second similarity value, which is expressed as: ; ; ; Where, represents the second similarity calculation, represents the transpose of the target problem embedding vector, represents the learnable weight matrix, Indicates the The total score is obtained by accumulating or weighted averaging the similarity values of all relationship paths corresponding to the target candidate answer entities. Indicates the relationship paths, Indicates the subject entity to All relationship paths of target candidate answer entities, Indicates the final answer corresponding to the question statement entered by the user. Indicates that the total score takes the maximum value.
[0019] In a second aspect, the present invention further provides a knowledge question-answering device based on a knowledge graph, comprising: A user question and target graph acquisition module is configured to obtain a user input question statement, a target knowledge graph and its embedded representation; A subject entity and question embedding vector determination module is configured to perform entity recognition and question vector embedding processing on the user input question sentence to obtain a subject entity and a target question embedding vector respectively; a candidate answer entity generation module configured to map the subject entity to the target knowledge graph and its embedded representation, and generate a plurality of candidate answer entities based on the subject entity and its proximity relationship; a target candidate answer entity determination module configured to calculate a first similarity for the embedding vector corresponding to the subject entity, the embedding vectors corresponding to each candidate answer entity, and the target question embedding vector, and then sort them according to the corresponding generated first similarity values to obtain a set of target candidate answer entities; a relationship path embedding vector determination module configured to extract, from the target knowledge graph, a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set, and obtain a corresponding target relationship path embedding vector based on the relationship path set; The answer reasoning module is configured to calculate a second similarity between the target question embedding vector and the target relationship path embedding vector, and then complete the answer reasoning of the user input question statement based on the corresponding generated second similarity value.
[0020] In a third aspect, the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the knowledge question-answering method based on the knowledge graph as described in the first aspect are implemented.
[0021] Compared with the prior art, the present invention has the following beneficial effects: By combining multi-hop reasoning technology, the present invention can better handle problems involving multiple entities and multiple reasoning paths, so as to effectively capture the complex relationships and semantic features in the knowledge graph, thereby enhancing the system's reasoning ability on complex problems; by fusing and embedding the relationship paths, it not only improves the representation ability of the knowledge graph, but also effectively overcomes the limitations of traditional knowledge graph embedding methods in dealing with multi-hop paths, thereby providing a more comprehensive knowledge base for the question-answering system; by optimizing the path selection and reasoning process, it reduces invalid calculations and improves the overall efficiency of the system to ensure that applications in actual scenarios can quickly respond to users' complex questions and are highly practical. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 FIG2 is a flow chart of an embodiment of a knowledge question answering method based on a knowledge graph according to the present invention; Figure 2 FIG2 is a flow chart of another embodiment of the knowledge question answering method based on knowledge graph of the present invention; Figure 3 Shown is a schematic diagram of knowledge graph embedding and completion processing in the knowledge graph-based knowledge question answering method of the present invention; Figure 4 It is a schematic diagram showing the subject entity recognition and question embedding processing in the knowledge graph-based knowledge question answering method of the present invention; Figure 5 Shown is a schematic diagram of the relational path extraction and embedding processing in the knowledge graph-based knowledge question answering method of the present invention. DETAILED DESCRIPTION
[0023] The technical solution of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations on the technical solution of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0024] The term "and / or" simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. Additionally, the character " / " generally indicates an "or" relationship between the related objects.
[0025] Example 1 refer to Figure 1 This embodiment introduces a knowledge question answering method based on a knowledge graph, which includes: Obtain the user input question statement, as well as the target knowledge graph and its embedded representation; Performing entity recognition and question vector embedding processing on the user input question statement to obtain the subject entity and target question embedding vector respectively; Mapping the subject entity to the target knowledge graph and its embedded representation, and generating multiple candidate answer entities based on the subject entity and its proximity relationship; calculating a first similarity for the embedding vector corresponding to the subject entity, the embedding vector corresponding to each candidate answer entity, and the target question embedding vector, and then sorting them according to the corresponding generated first similarity values to obtain a target candidate answer entity set; Extracting a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set from the target knowledge graph, and obtaining a target relationship path embedding vector based on the relationship path set; A second similarity is calculated between the target question embedding vector and the target relationship path embedding vector, and then, based on the corresponding generated second similarity value, an answer to the user input question statement is inferred.
[0026] In actual application, this embodiment first requires obtaining the user's input question and the completed target knowledge graph, which incorporates rich information about the tobacco industry. Furthermore, the relevant question-answering system identifies the key entities and relationships in the user's question to more accurately understand the user's query intent. Furthermore, because the knowledge graph provides a rich knowledge base, the question-answering system utilizes the entities, relationships, and attributes in the knowledge graph to construct a knowledge network related to the user's question and extracts useful information from it to generate more natural and accurate answers. This process utilizes knowledge graph technology, natural language processing technology, and vector space models, combined with a series of complex processing steps, to achieve intelligent understanding of user input questions and automatic reasoning of answers.
[0027] Example 2 refer to Figures 2 to 5 Based on Example 1, this example will introduce the specific implementation process of a related knowledge question and answer system through complete steps. For example, a tobacco planting technician discovers that the tobacco seedlings have yellowing leaves and slow growth during planting. Suspecting that they are attacked by a pest, they ask the related knowledge question and answer system a specific question: "What pest or disease is causing these yellowing leaves and slow growth?"
[0028] 1. Determination of the target knowledge graph and its embedded representation refer to Figure 3This section deals with the construction and training of the knowledge graph to ensure its integrity and the availability of embedding vectors. In practical applications, the system can use a pre-processed target knowledge graph to directly extract relevant entities, relationships, and embedding vectors to answer user questions. The specific process for determining the target knowledge graph is described below.
[0029] First, obtain the known first knowledge graph (KG1) and second knowledge graph (KG2). When determining core entities, these related knowledge graphs can specifically include tobacco varieties, growing environments, planting techniques, and tobacco pests and diseases (listing common tobacco diseases and pests such as tobacco anthrax, tobacco seedling damping-off, and tobacco aphids). When defining relationship types, one can specifically define the relationship between tobacco varieties and growing environments, such as the temperature and humidity conditions under which a particular tobacco variety grows best; and the relationship between planting techniques and tobacco pests and diseases, such as the effectiveness of certain field management measures in preventing or treating specific pests and diseases.
[0030] Fusing the first knowledge graph and the second knowledge graph to generate a new knowledge graph, namely, a fused knowledge graph; The fused knowledge graph is randomly masked or removed with respect to related triples to generate a masked knowledge graph, which is expressed as: ; Where, represents the masked knowledge graph, Represents a mask operation, Represents a fused knowledge graph; the above masking operation is intended to enable the model to learn to infer missing relevant knowledge through contextual relationships, thereby improving its ability to reason and complete unknown or incomplete data.
[0031] Furthermore, the fused knowledge graph and the masked knowledge graph are input into the ComplEx embedding model for an embedding process, thereby obtaining the first entity vector and the first relationship vector corresponding to the fused knowledge graph embedding, and the second entity vector and the second relationship vector corresponding to the masked knowledge graph embedding. The masked knowledge graph generates an incomplete graph after masking or removing some triples, while the fused knowledge graph may combine information from multiple knowledge graphs. The embedding operation on these processed knowledge graphs aims to convert them into representations in the vector space.
[0032] In the above process, the ComplEx embedding model measures the rationality of the related triples by calculating the dot product of the head entity and tail entity embedding vectors in the complex space defined by the relation embedding vector. The corresponding calculation formula is as follows: ; ; Where, represents the scoring function of the ComplEx embedding model, Represents a triple in a knowledge graph, Represents the head entity, Indicates relationship, Represents the tail entity, Represents the embedding vectors of the head entity, relation, and tail entity, respectively, embedded in the complex space middle, represents the dimension of the embedding vector, represents the real part of a complex number. represents the conjugate complex number of the tail entity embedding vector, represents the trilinear product of the conjugate complex numbers of the embedding vectors of the head entity, relation, and tail entity, Represents a complex vector No. Dimension, Represents a complex vector No. Dimension, Represents a complex vector No. It is worth noting that for the relevant scoring functions mentioned in this article, different expressions are usually presented in different application scenarios based on the same scoring function principle.
[0033] When a triple exists in the knowledge graph, the score should be greater than zero; otherwise, the score should be less than zero. In other words, the scoring function calculates the interaction between the embedding vectors of the head entity, the relationship, and the tail entity, and outputs a score that represents the authenticity of the triple. Generally, a higher score indicates a more likely triple is true knowledge; a lower score indicates a lower credibility of the triple.
[0034] Furthermore, during model training, the model uses not only real triplets (positive samples) but also generates negative samples (such as randomly replacing the head or tail entity). The scoring function optimizes the embedding vectors of entities and relations by distinguishing between positive and negative samples. In the masked knowledge graph, masked or removed triplets affect the model's ability to learn the underlying associations between entities and relations, making the model more capable of reasoning and handling incomplete data.
[0035] In summary, through the one-time embedding processing of the ComplEx embedding model, we can obtain: the first entity vector of the fused knowledge graph embedding and the first relationship vector , and the second entity vector embedded in the masked knowledge graph and the second relationship vector .
[0036] Furthermore, a graph neural network is used to learn graph structure-enhanced embeddings, and combined with the local graph structure information of the node, the first entity vector and the first relationship vector, as well as the second entity vector and the second relationship vector are embedded and updated once, respectively obtaining the third entity vector and the third relationship vector corresponding to the enhanced fused knowledge graph embedding, and the fourth entity vector and the fourth relationship vector corresponding to the enhanced masked knowledge graph embedding.
[0037] In a knowledge graph, entities (nodes) and relationships (edges) form a graph structure. A node's local neighborhood information refers to the nodes directly connected to it and the relationships between them. In other words, each entity's neighborhood consists of triplets of entities and relationships with it, reflecting the entity's context within the entire graph. In graph neural networks, a node's embedding vector not only relies on the node's own features but also collects and integrates information about its local neighborhood nodes and edges through a neighborhood aggregation mechanism.
[0038] Specifically, embedding updates include updating entity vectors and relationship vectors. The entity vector update process is as follows: ; ; Where, Indicates in The first entity vector of the knowledge graph embedded in the layer, represents a nonlinear activation function, represents the weight matrix of entity embedding, Indicates in The first entity vector of the knowledge graph embedded in the layer, Representing an entity The set of neighbor entities of represents the weight matrix of relation embedding, Indicates in The first relation embedding vector of the knowledge graph embedded in the layer, represents the Hadamard product, Indicates in The first layer that integrates knowledge graph embedding Entity vector, Indicates in The second entity vector embedded in the masked knowledge graph in the layer, Indicates in The second entity vector embedded in the masked knowledge graph in the layer, Indicates in The second relation embedding vector of the masked knowledge graph embedding in the layer; The process of updating the relationship vector is as follows: ; ; Where, Indicates in The first relation embedding vector of the knowledge graph embedded in the layer, Indicates in The second relation embedding vector of the masked knowledge graph embedding in the layer.
[0039] In summary, after continuous iteration of the graph neural network, the updated enhanced fusion knowledge graph embedding third entity vector is obtained , recorded as And the third relationship vector , recorded as , and the fourth entity vector of the enhanced masked knowledge graph embedding , recorded as and the fourth relation vector , recorded as .in, and To reach the maximum number of iterations The corresponding related representation.
[0040] Furthermore, based on the third entity vector and the third relationship vector, and the fourth entity vector and the fourth relationship vector, similarity calculations of the corresponding entity similarity values and relationship similarity values are performed respectively, and then whether to generate a new alignment pair is determined based on the similarity results, wherein if the entity similarity value and the relationship similarity value are both higher than the preset threshold, the third entity vector and the fourth entity vector are aligned, and the third relationship vector and the fourth relationship vector are aligned, and added to the fused knowledge graph as a new alignment pair; if the similarity value is lower than the preset threshold, it means that the similarity of the two vectors is not sufficient to confirm that they are the same entity or relationship, and therefore they will not be added to the fused knowledge graph as a new alignment pair. This operation can prevent irrelevant or erroneous alignment pairs from being introduced into the knowledge graph to maintain the consistency and accuracy of the graph.
[0041] The so-called similarity calculation refers to the similarity calculation between the third entity vector and the third relationship vector in the enhanced fusion knowledge graph embedding and the fourth entity vector and the fourth relationship vector in the enhanced mask knowledge graph embedding. It is necessary to compare the similarity between the third entity vector and the fourth entity vector, as well as the similarity between the third relationship vector and the fourth relationship vector. Based on these similarity calculations, new alignment pairs can be further generated, that is, the correspondence between entities and relationships in the two embedding methods is found. Specifically, the similarity measure is used to calculate the entity vector similarity and the relationship vector similarity respectively. The relevant calculation formulas are as follows: ; ; Where, Represents entity similarity, Represents the relationship similarity, represents the third entity vector corresponding to the enhanced fusion knowledge graph embedding, represents the fourth entity vector corresponding to the enhanced masked knowledge graph embedding, represents the third relation vector corresponding to the enhanced fusion knowledge graph embedding, Represents the fourth relation vector corresponding to the enhanced masked knowledge graph embedding.
[0042] Repeat the above process until the preset number of iterations is reached, and then obtain the third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions.
[0043] Furthermore, the third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions are taken as input and input into the designed decoder to predict new triples, and then the knowledge graph is completed based on the new triples. The specific process is described as follows.
[0044] The scoring function of the ComplEx model is used to evaluate the newly generated triples. The scoring function can measure the rationality of the triples, and the calculation formula is as follows: ; Where, represents the score of the triple, represents the real part of a complex number. Represents the header entity In complex space dimensional embedding, Representing relationships No. dimensional embedding, The conjugate complex number representing the tail entity embedding.
[0045] A knowledge graph completion decoder is designed to predict new triples based on the above scoring function. The third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions are input into the knowledge graph completion decoder to predict the head entity, tail entity and relationship, and generate new triples accordingly. The specific operations are as follows: Head entity prediction: For each relation and tail entity , find the head entity with the highest score , complete the prediction of the head entity in the new triplet, the corresponding calculation formula is as follows: ; Tail entity prediction: For each relation and head entity , find the tail entity with the highest score , complete the prediction of the tail entity in the new triple, the corresponding calculation formula is as follows: ; Relation prediction: given a head entity and tail entity , find the relationship with the highest score , complete the prediction of the relationship in the new triple, the corresponding calculation formula is as follows: ; The new triplet generated It is generated by scoring the missing head entity, relation or tail entity, and represents the completed triple.
[0046] Furthermore, the new triples generated in the above steps are added to the knowledge graph corresponding to the third entity vector and the third relationship vector embedded in the enhanced fusion knowledge graph that meets the preset iteration conditions, thereby obtaining the completed knowledge graph, that is, the target knowledge graph.
[0047] In addition, after the knowledge graph is completed, the embedding vectors of all entities and relationships in the graph need to be recalculated. Since the newly added triples may change the semantic associations between entities and relationships in the knowledge graph, through embedding updates, the system can integrate new knowledge into the graph embedding space, making the embedding representation more comprehensive and consistent. In addition, the completed knowledge graph has richer triples, which helps the model learn deeper patterns and relationships when updating embeddings, thereby improving the overall performance and generalization ability of the model and supporting more complex query and reasoning tasks. This process can be divided into the following two steps: Input the completed target knowledge graph into the ComplEx embedding model for secondary embedding processing to obtain the fifth entity vector and the fifth relationship vector corresponding to the embedded completed knowledge graph; At the same time, in order to further enhance the completed embedding representation, the graph neural network is used again to process the completed graph structure, that is, the fifth entity vector and the fifth relationship vector are embedded and updated twice, and finally the sixth entity vector and the sixth relationship vector corresponding to the target knowledge graph embedding are obtained.
[0048] 2. Topic Entity Recognition and Determination of Target Question Embedding Vector refer to Figure 4 , the relevant process of subject entity recognition is as follows: The text sequence corresponding to the user input question statement (What pests and diseases cause yellowing of tobacco seedling leaves and slow growth?) ,in Indicates the words, input into the Chinese pre-trained language model (ChineseBERT), and generate the first word embedding vector ,in It is The embedding representation of each word corresponds to the output of the first word embedding vector sequence ; Embed the first vocabulary into a vector sequence Input into the named entity recognition model (NER), and output the subject entity corresponding to the input question sentence (Company A) and its corresponding embedding vector .
[0049] The process of determining the target problem embedding vector is as follows: Embed the first vocabulary into a vector sequence Input to the first memory network layer to generate the second word embedding vector ,in, Indicates the The embedding representation of each word, the corresponding output is the second vocabulary embedding vector sequence ; Based on the word-level attention mechanism, the second word embedding vector sequence Each second word embedding vector in Calculate the word-level attention score and use it as a weight for each second word embedding vector Perform weighting to generate word-level weighted vectors , the calculation formula of word-level attention score is as follows: ; ; Where, Indicates the The attention weight of each word, represents the word-level attention context vector, which represents the global attention information, Represents the tangent hyperbolic function, which is a common activation function. Its function is to perform nonlinear transformation on the input so that the output value is between -1 and 1. represents the weight matrix in the word-level attention mechanism, represents the first word in the second word embedding vector sequence The embedding representation of words, Indicates the number of words, represents the word-level weighted vector. The transposition ensures that the dimensions of the matrix and vector match, allowing the calculation to proceed smoothly. In general, the transposition is only used to meet the dimensional requirements of matrix multiplication and does not directly change the nature of the calculation.
[0050] In addition, the letters As a commonly used index variable representing an integer sequence, especially when it comes to mathematical derivation, many symbols (such as n) are conventional and can adapt to a variety of different contexts without changing their basic meaning. These different meanings can be clearly distinguished through sufficient contextual explanation.
[0051] Based on the sentence-level attention mechanism, the word-level weighted vector Calculate the sentence-level attention score and use the sentence-level attention score as the weight to weight the word-level weighted vector to generate the target question embedding vector corresponding to the user input question sentence , the calculation formula of sentence-level attention score is as follows: ; ; Where, represents the sentence-level attention weight, represents the transpose of the sentence-level attention context vector, represents the weight matrix in the sentence-level attention mechanism, Indicates the The word embedding vector, Indicates the number of words in a sentence. Represents the target question embedding vector corresponding to the user input question sentence.
[0052] 3. Scoring and Ranking of Candidate Answers First, the subject entity is mapped to the target knowledge graph, and a plurality of candidate answer entities are generated based on the subject entity (tobacco seedlings and leaves) and its neighboring relationships.
[0053] The candidate answer entity can be obtained by connecting the edge or adjacent nodes with the subject entity, which is expressed as: ; Where, Indicated by The candidate answer set consists of candidate answer entities, Indicates the candidate answer entities.
[0054] Furthermore, for each candidate answer entity, the scoring function A first similarity is calculated for the embedding vector corresponding to the subject entity, the embedding vector corresponding to each candidate answer entity, and the target question embedding vector. The first similarity is calculated using cosine similarity, which is expressed as: ; Where, represents the first similarity calculation, The embedding vector of the candidate answer entity, Embedding vector representing the topic entity, Represents the target question embedding vector.
[0055] Among them, the higher the score, the higher the degree of semantic matching between the candidate answer entity and the question. The candidate answer entities are ranked according to the score, and the top The entities with the highest scores are taken as the final target candidate answer set, which is expressed as: ; ; Where, represents the first similarity value, Indicates that the first similarity value ranks first The target candidate answer entity collection consists of target candidate answer entities, Indicates the first similarity value ranking The target candidate answer entity.
[0056] 4. Extraction and Embedding of Relationship Paths refer to Figure 5 ,In this part, a convolutional neural network (CNN) combined with ,attention mechanism is used to model the relation path to ,generate the embedding vector of the relation path, as described below.
[0057] First, a set of relationship paths from all subject entities (tobacco seedlings and leaves) to each target candidate answer entity in the target candidate answer set (such as tobacco pests and diseases) is extracted from the completed target knowledge graph, where the lengths of these relationship paths are all less than a given number of hops.
[0058] Assume that from the subject entity To the entity in the target candidate answer set The relationship path set is: ; Where, Indicates the number of relationship paths, each relationship path Consists of multiple relationships.
[0059] Furthermore, each relationship path in the relationship path set is serialized. , and convert each relationship in each relationship path into an embedding vector to obtain the relationship path embedding vector, which is expressed as: ; Where, represents the relation path embedding vector, Represents each relationship in the path The embedding vector of .
[0060] Furthermore, the relational path embedding vector is used as input, and local features are extracted through a one-dimensional convolution layer to obtain a convolution feature vector: ; Where, represents the convolution feature vector, Represents the operation of extracting local features through a one-dimensional convolutional layer.
[0061] Furthermore, based on the convolution feature vector, the attention score of each relationship is calculated, and the convolution feature vector is weighted using the attention score as a weight to generate a weighted relationship path embedding vector as the target relationship path embedding vector, which is expressed as: ; ; Where, represents the attention score of each relation, represents the transpose of the attention weight vector, Indicates the The first relationship path convolutional features, Indicates the The first relationship path convolutional features, Indicates the The number of convolution features in the relationship path, Represents the weighted relation path embedding vector.
[0062] Furthermore, based on the output embedding vectors of all target relationship paths, the embedding vector set of all relationship paths can be obtained, which is expressed as: ; Where, represents the set of target relation path embedding vectors, Indicates the The embedding vector of the relationship path.
[0063] 5. Second Similarity Calculation and Answer Reasoning First, embed the target problem vector Embedding vector of the target relationship path The second similarity is calculated using the following formula: ; Where, represents the second similarity calculation, represents the transpose of the target problem embedding vector, Represents a learnable weight matrix. Among them, the corresponding second similarity score Reflects the target question embedding vector Embedding vector of each weighted relationship path The higher the score, the closer the relationship path is. It can better reflect the semantics of the problem. From the subject entity To the target candidate answer entity Therefore, the corresponding second similarity score can be understood as the degree of semantic matching between the input question and the target candidate answer.
[0064] It is worth noting that the final score of the candidate answer is obtained by accumulating or weighted averaging the similarity scores of all paths corresponding to each target candidate answer entity. , the corresponding total score can be calculated: ; Where, Indicates the total score, Represents the subject entity To the target candidate answer entity All relationship paths.
[0065] Furthermore, after all candidate answers are sorted according to their similarity scores, the system will select the candidate answer with the highest ranking as the final answer, thereby completing the answer reasoning for the question statement input by the user. The relevant formula is as follows: ; Where, Indicates the final answer corresponding to the question input, Indicates the maximum total score.
[0066] In actual application of this embodiment, after the above process is completed, the answer will be output: "The yellowing of tobacco seedling leaves and slow growth may be caused by tobacco seedling damping-off disease."
[0067] The binary cross-entropy loss function is used to optimize the relationship path model's path prediction accuracy, specifically optimizing the path embedding representation. This optimization process enables the model to accurately learn and predict these relationship paths. The path embedding representation is adjusted through the loss function to improve the ability to reason about complex paths. The relevant loss function is calculated as follows: ; Where, represents the binary cross entropy loss function, Indicates the number of samples, that is, how many training samples there are in total, Indicates a label, Represents the sigmoid function, which is used to map the score to the [0,1] interval. represents the label (1 represents a positive sample, 0 represents a negative sample), represents the score between the question embedding vector and the relation path embedding vector, Represents the weighted relation path embedding vector.
[0068] Example 3 Based on the same inventive concept as in Example 1 or 2, this embodiment introduces a knowledge question-answering device based on a knowledge graph, which includes: A user question and target graph acquisition module is configured to obtain a user input question statement, a target knowledge graph and its embedded representation; A subject entity and question embedding vector determination module is configured to perform entity recognition and question vector embedding processing on the user input question sentence to obtain a subject entity and a target question embedding vector respectively; a candidate answer entity generation module configured to map the subject entity to the target knowledge graph and its embedded representation, and generate a plurality of candidate answer entities based on the subject entity and its proximity relationship; a target candidate answer entity determination module configured to calculate a first similarity for the embedding vector corresponding to the subject entity, the embedding vectors corresponding to each candidate answer entity, and the target question embedding vector, and then sort them according to the corresponding generated first similarity values to obtain a set of target candidate answer entities; a relationship path embedding vector determination module configured to extract, from the target knowledge graph, a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set, and obtain a corresponding target relationship path embedding vector based on the relationship path set; The answer reasoning module is configured to calculate a second similarity between the target question embedding vector and the target relationship path embedding vector, and then complete the answer reasoning of the user input question statement based on the corresponding generated second similarity value.
[0069] Combine Figures 1 to 5 The knowledge question answering device based on knowledge graph can execute the knowledge question answering method based on knowledge graph introduced in the above embodiment 1 or 2, and the specific functional implementation of each functional module will not be repeated.
[0070] Example 4 This embodiment introduces a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the knowledge question answering method based on the knowledge graph as described in Example 1 or 2 are implemented.
[0071] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0072] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts 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, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0073] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0074] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0075] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A knowledge question answering method based on knowledge graph, characterized in that: include: Obtain the user input question sentence, as well as the target knowledge graph and its embedded representation; Performing entity recognition and question vector embedding processing on the user input question sentence to obtain the subject entity and target question embedding vector respectively; Mapping the subject entity to the target knowledge graph and its embedded representation, and generating multiple candidate answer entities based on the subject entity and its neighboring relationship; calculating the first similarity of the embedding vector corresponding to the subject entity, the embedding vector corresponding to each of the candidate answer entities, and the target question embedding vector, and then sorting them according to the corresponding first similarity values to obtain a target candidate answer entity set; Extracting a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set from the target knowledge graph, and obtaining a target relationship path embedding vector based on the relationship path set; A second similarity is calculated between the target question embedding vector and the target relationship path embedding vector, and then the answer reasoning for the user input question statement is completed according to the corresponding generated second similarity value.
2. The knowledge question answering method based on knowledge graph according to claim 1 is characterized in that: The process of determining the target knowledge graph includes: Fusing the acquired first knowledge graph and the second knowledge graph to generate a fused knowledge graph; Performing random masking or removal processing on the fused knowledge graph for related triples to generate a masked knowledge graph; Input the fused knowledge graph and the masked knowledge graph into the ComplEx embedding model for an embedding process, and obtain the first entity vector and the first relationship vector corresponding to the fused knowledge graph embedding, and the second entity vector and the second relationship vector corresponding to the masked knowledge graph embedding; Using a graph neural network to learn graph structure enhanced embedding, and combining the local graph structure information of the node, performing an embedding update on the first entity vector and the first relationship vector, and the second entity vector and the second relationship vector, respectively obtaining a third entity vector and a third relationship vector corresponding to the enhanced fusion knowledge graph embedding, and a fourth entity vector and a fourth relationship vector corresponding to the enhanced mask knowledge graph embedding; Based on the third entity vector and the third relationship vector, and the fourth entity vector and the fourth relationship vector, respectively, corresponding entity similarity values and relationship similarity values are calculated, and then whether to generate a new alignment pair is determined according to the similarity results, wherein if the entity similarity value and the relationship similarity value are both higher than a preset threshold, the entity or relationship is aligned to generate a new alignment pair and added to the fused knowledge graph; otherwise, no alignment operation is performed; Repeat the above process until the preset number of iterations is reached, and then obtain the third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions; The third entity vector and the third relationship vector corresponding to the enhanced fusion knowledge graph embedding that meet the preset iteration conditions are input into the knowledge graph completion decoder to predict the head entity, the tail entity and the relationship, and generate new triples accordingly; The new triple is added to the knowledge graph corresponding to the third entity vector and the third relationship vector embedded in the enhanced fusion knowledge graph that meets the preset iteration conditions to obtain the target knowledge graph.
3. The knowledge question answering method based on knowledge graph according to claim 2 is characterized in that: Performing entity recognition and question vector embedding processing on the user input question sentence to obtain the subject entity and target question embedding vector respectively, including: Inputting the text sequence corresponding to the question sentence input by the user into the Chinese pre-trained language model, and outputting a first vocabulary embedding vector sequence; Inputting the first vocabulary embedding vector sequence into a named entity recognition model, and outputting a subject entity corresponding to the question sentence input by the user; Inputting the first vocabulary embedding vector sequence into a first memory network layer, and outputting a second vocabulary embedding vector sequence; Based on the word-level attention mechanism, calculating a word-level attention score for each second word embedding vector in the second word embedding vector sequence, and weighting each second word embedding vector using the word-level attention score as a weight to generate a word-level weighted vector; Based on the sentence-level attention mechanism, a sentence-level attention score is calculated for the word-level weighted vector, and the word-level weighted vector is weighted using the sentence-level attention score as a weight to generate a target question embedding vector corresponding to the user input question sentence.
4. The knowledge question answering method based on knowledge graph according to claim 3 is characterized in that: Based on the word-level attention mechanism, a word-level attention score is calculated for each second word embedding vector in the second word embedding vector sequence, and each second word embedding vector is weighted using the word-level attention score as a weight to generate a word-level weighted vector, which is expressed as: ; ; In the formula, Indicates The attention weight of each word, represents the transpose of the word-level attention context vector, represents the activation function, represents the weight matrix in the word-level attention mechanism, represents the first word in the second word embedding vector sequence The embedding representation of words, Indicates the number of words, Represents word-level weighted vector; Based on the sentence-level attention mechanism, the sentence-level attention score is calculated for the word-level weighted vector, and the sentence-level attention score is used as the weight to weight the word-level weighted vector to generate a question embedding vector corresponding to the user input question sentence, which is expressed as: ; ; In the formula, represents the sentence-level attention weight, represents the transpose of the sentence-level attention context vector, represents the weight matrix in the sentence-level attention mechanism, Indicates the The embedding vector of each word, Indicates the number of words in a sentence. Represents the question embedding vector corresponding to the question sentence input by the user.
5. The knowledge question answering method based on knowledge graph according to claim 4 is characterized in that: The subject entity is mapped to the target knowledge graph, and multiple candidate answer entities are generated according to the subject entity and its neighboring relationship, which are expressed as: ; In the formula, Indicated by The candidate answer set consists of candidate answer entities. Indicates Candidate answer entities; The first similarity is calculated for the embedding vector corresponding to the subject entity, the embedding vector corresponding to each candidate answer entity, and the target question embedding vector, which is expressed as: ; ; In the formula, represents the first similarity calculation, The embedding vector of the candidate answer entity, The embedding vector representing the topic entity, Represents the similarity value; According to the first similarity value generated, the target candidate answer entity set is obtained by sorting, which is expressed as: ; In the formula, Indicates that the first similarity value ranks first The target candidate answer entity collection consists of target candidate answer entities, Indicates that the first similarity value is ranked The target candidate answer entity.
6. The knowledge question answering method based on knowledge graph according to claim 5, characterized in that: Extracting a set of relationship paths from the subject entity to each target candidate answer entity in the target candidate answer entity set from the target knowledge graph, and obtaining a corresponding target relationship path embedding vector based on the relationship path set, including: Extracting a set of relationship paths from all subject entities to each target candidate answer entity in the target candidate answer set from the completed target knowledge graph; Performing a path serialization representation on each relationship path in the relationship path set, and converting each relationship in each relationship path into an embedding vector to obtain a relationship path embedding vector; Inputting the relation embedding vector into a convolutional neural network, and extracting local features to obtain a convolutional feature vector; Based on the convolution feature vector, an attention score of each relationship is calculated, and the convolution feature vector is weighted using the attention score as a weight to generate a weighted relationship path embedding vector as the target relationship path embedding vector.
7. The knowledge question answering method based on knowledge graph according to claim 6 is characterized in that: Based on the convolution feature vector, the attention score of each relationship is calculated, and the convolution feature vector is weighted by using the attention score as a weight to generate a weighted relationship path embedding vector as the target relationship path embedding vector, which is expressed as: ; ; ; In the formula, represents the convolution feature vector, Indicates the operation of extracting local features through a one-dimensional convolutional layer. represents the relationship path embedding vector, represents the attention score of each relation, represents the transpose of the attention weight vector, Indicates The relationship path convolutional features, Indicates The relationship path convolutional features, Indicates The number of convolutional features in the relationship path, Represents the weighted relationship path embedding vector.
8. The knowledge question answering method based on knowledge graph according to claim 7, characterized in that: The second similarity is calculated for the target question embedding vector and the target relationship path embedding vector, and then the answer reasoning for the user input question statement is completed according to the corresponding generated second similarity value, which is expressed as: ; ; ; In the formula, represents the second similarity calculation, represents the transpose of the embedding vector representing the target problem, represents the learnable weight matrix, Indicates The total score is obtained by accumulating or weighted averaging the similarity values of all relationship paths corresponding to the target candidate answer entities. Indicates relationship paths, Indicates the subject entity to All relationship paths of target candidate answer entities, Indicates the final answer corresponding to the question statement entered by the user. Indicates that the total score takes the maximum value.
9. A knowledge question-answering device based on knowledge graph, characterized in that: include: A user question and target graph acquisition module is configured to acquire a user input question statement, a target knowledge graph and its embedded representation; A subject entity and question embedding vector determination module is configured to perform entity recognition and question vector embedding processing on the user input question sentence to obtain a subject entity and a target question embedding vector respectively; A candidate answer entity generation module is configured to map the subject entity to the target knowledge graph and its embedded representation, and generate a plurality of candidate answer entities according to the subject entity and its neighboring relationship; A target candidate answer entity determination module is configured to calculate a first similarity for the embedding vector corresponding to the subject entity, the embedding vector corresponding to each of the candidate answer entities, and the target question embedding vector, and then sort them according to the corresponding first similarity values to obtain a target candidate answer entity set; A relationship path embedding vector determination module is configured to extract a relationship path set from the target knowledge graph to each target candidate answer entity in the target candidate answer entity set, and obtain a corresponding target relationship path embedding vector based on the relationship path set; The answer reasoning module is configured to calculate the second similarity between the target question embedding vector and the target relationship path embedding vector, and then complete the answer reasoning for the user input question statement based on the corresponding generated second similarity value.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the knowledge question answering method based on the knowledge graph described in any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Attribute fusion-oriented knowledge graph multi-hop reasoning method and device
CN120012947A
Knowledge retrieval enhancement-based oral medical large model question and answer prediction method
CN120196725A
Multi-modal data fusion processing method and system based on artificial intelligence
CN120449101A
Tea intelligent inquiry method, device and system based on large language model and storage medium
CN120706554A
Event clue knowledge enhancement generation method and system based on deep learning
CN120893554A