Knowledge graph question and answer method based on relational attention enhancement and cross coding
By using relational attention enhancement and feature cross-coding technology in the knowledge graph question answering system, the fuzziness and noise problems in query graph generation under complex problems are solved, and the accuracy and efficiency of the question answering system are improved.
Patent Information
- Application Number
- CN202310396580.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-14
- Publication Date
- 2024-10-18
AI Technical Summary
When existing knowledge graph question answering systems deal with complex problems, there are fuzziness and noise problems in the generation of query graphs, which results in increased accuracy and computational complexity, making it difficult to meet users' complex information retrieval needs.
Using methods based on relational attention enhancement and feature cross-encoding, through the two stages of problem structure classification and query graph sorting, the prior structural information of the problem is extracted and noise is filtered, and a multi-head attention mechanism and feature cross-encoder are used to generate more accurate Query graph and path sorting results.
It improves the accuracy of question and answer in complex problem scenarios, reduces the impact of noise, and improves the accuracy and computational efficiency of query graphs.
Smart Images

Figure SMS_1 
Figure SMS_2 
Figure SMS_3
Abstract
Description
Technical Field
[0001] The present invention designs a knowledge graph question answering method based on relational attention enhancement and cross-coding, which belongs to the field of natural language processing. Background Art
[0002] Intelligent question answering is an important research direction in the field of artificial intelligence and is gradually becoming a new trend for natural interaction between humans and machines. Knowledge graph is a structured database consisting of some interconnected entities and the relationships between entities. It is a semantic network with a mesh structure. In recent years, with the widespread application of knowledge graphs in various fields, the research on question answering systems based on knowledge graphs is gradually becoming a focus. Knowledge graph question answering is a form of question answering that uses knowledge graphs as the main data source. For given natural language questions, the machine performs semantic analysis and reasoning based on the knowledge graph to obtain answers. Early research on knowledge graph question answering mainly focused on simple questions in a single field (such as medical, finance, agriculture, film, etc.). However, with the explosive growth of information, simple question answering scenarios can no longer meet users' complex information retrieval needs. How to solve the problem of how question answering systems can handle complex questions has attracted widespread attention from researchers.
[0003] For more complex natural language questions raised by users, most question-answering methods use models to extract the subject entity of the question, then use the entity as the center to traverse entities and relationships within a certain range of hops in the knowledge graph as the query graph of the question, and finally use the query graph to retrieve the answer in the knowledge graph. This question-answering method often has the following problems: (1) The ambiguity of the hop count of complex questions may cause the query graph we generate to be inaccurate. A query graph that is too small will exclude the correct answer to the question, while a query graph that is too large will increase the search space and introduce unnecessary noise; (2) The generated query graph itself has noise. If it is not filtered, it will not only increase the amount of calculation, but also affect the subsequent query graph ranking module.
[0004] In order to meet the above challenges, a large number of researchers have conducted in-depth research and proposed corresponding solutions. In the early methods, researchers proposed a graph-based semantic parser, which uses combinatorial category grammar to convert questions into semantic query graphs. The relationships in natural language questions are represented as edges in the query graph, and entities are represented as graph nodes. The optimal semantic query graph is obtained by beam search. In recent years, some researchers have proposed a subgraph retrieval enhancement model for knowledge graph question answering. This model designs a trainable subgraph retriever that is decoupled from the subsequent reasoner. It can realize the automatic expansion and stopping of question subgraphs, thereby generating more accurate question subgraphs. Then, combined with any subgraph-oriented reasoner, it can achieve good question answering results.
[0005] Although researchers have done a lot of research on complex problems in knowledge graphs, query graph generation for multi-hop problems and restricted reasoning problems still faces many difficulties. For example, query graph generation for restricted problems still has the problem of inaccurate range. In previous studies, researchers mainly focused on how to better extract and represent features of problems, ignoring the prior structural information implied by the problems themselves. In the present invention, a knowledge graph question answering method based on relational attention enhancement and feature cross encoding is proposed. In this method, there are mainly two steps: question structure classification and query graph sorting. In question structure classification, the present invention designs a question structure classification module that integrates external relational features and performs attention enhancement to extract the prior structural information of the problem, and uses the extracted structural information to filter out obvious noise and reduce the size of the candidate path set. In the query graph sorting stage, the present invention uses a feature cross encoder to fuse the feature vectors of the candidate path and the question, and then screens out the optimal path in the candidate path, while streamlining the model structure to obtain more accurate path sorting results. Summary of the invention
[0006] The present invention proposes a knowledge graph question answering method based on relational attention enhancement and feature cross-coding for the knowledge graph question answering task of complex questions. The method mainly focuses on two tasks: question structure classification and query graph sorting. In the question structure classification stage, the present invention constructs a question structure classification model based on a multi-head attention mechanism that integrates external relations. The model first encodes the question, and uses the attention mechanism and the database relationship list to enhance the information representation of the question features, and then sends them to the classifier to obtain the question structure category. The classification result is used to filter the initial query graph of the question to obtain a more accurate query graph. In the query graph sorting stage, the present invention designs a query graph sorting model based on feature cross-coding, which encodes the spliced question and candidate path, and then obtains the encoded representation of the entire sequence after weighted summation of the output, and finally obtains the similarity score between the question and the candidate path through the fully connected layer. The knowledge graph question answering method proposed by the present invention helps to further improve the accuracy of question answering in complex problem scenarios.
[0007] The present invention achieves the above-mentioned purpose through the following technical solutions:
[0008] The knowledge graph question answering method claimed in the invention is as follows Figure 1As shown in the figure, we first determine the main entity of the question, use the main entity to retrieve a rough query graph in the knowledge graph, and input the question sentence into the AE-Classification structural classification model to classify the question structure. Then, we filter the noise of the query graph according to the classification result to obtain a more accurate query graph. Then, we use the FC-Ranking query graph ranking model to sort the query graph output in the previous step. Finally, we select the path with the highest score as the optimal path for the question, and convert it into the corresponding query statement to obtain the answer from the knowledge graph. It mainly includes two parts: question structure classification and query graph ranking.
[0009] In the problem structure classification stage, the following method is used:
[0010] (1) Define the structural categories of the question. There are three types of chain structures: SS1, SS2, and SS3; there are three types of constraint structures: SC1, SC2, and SC3. For example, chain structure SS2 = {H, r1, E1, r2, E0}, and constraint structure SC2 = {H, r1, E1, r2, E0, C}, where H represents the subject entity in the question, E0 represents the answer entity corresponding to the question, Ei represents the intermediate entity, ri represents the relationship, and C represents the restriction contained in the question;
[0011] (2) Embed the relations in the knowledge base to obtain a 1×768 relational feature representation e r , the relationship list composed of all relationships is represented as R.matrix r_nums×768 , used by subsequent modules, where r_nums represents the number of relations. For example, there are 18 relations in the MetaQA dataset and 2171 relations in the WebQuestionSP dataset;
[0012] (3) Input question q into the pre-trained Bert network for feature representation, and obtain the 1×768-dimensional question feature e q ;
[0013] (4) Use the attention mechanism to analyze the question feature e in step (3) q and the relation feature e in step (2) r Calculate the attention value and update the question feature representation:
[0014] weight(q,R)=e q ×R.matrix T (1)
[0015] weight(q,R)'=softmax(weight(q,R)) (2)
[0016] Att(q,r)=weight(q,R)'×R.matrix (3)
[0017] E q =Att(q,r)+e q (4)
[0018] The 1×768-dimensional e q and the transposed R.matrix T Perform vector multiplication to obtain a 1×r_nums-dimensional weight vector weight(q,R); then normalize the weight vector weight(q,R) through the softmax function to obtain weight(q,R)'; then multiply the weight corresponding to each relationship by the relationship feature to obtain the attention value Att(q,r) corresponding to the question and each relationship; finally, superimpose the attention value on the original question feature representation to obtain the updated question feature representation E q ;
[0019] (5) Update the question feature E q Send to the classifier for problem structure classification:
[0020] P=Classifier(E q ) (5)
[0021] Then use the cross entropy loss function to calculate the loss of model classification:
[0022]
[0023] Where N is the batch size for training, y represents the true structure category corresponding to the input question, and finally we will calculate the loss of all batches and the back propagation used for training the problem structure classification model.
[0024] In the query graph sorting phase, the following steps are performed:
[0025] (1) Use the feature cross encoder to perform feature fusion encoding on the candidate paths and questions in the query graph:
[0026] CLS,words_embedding=Bert(q,path) (7)
[0027] The question q is concatenated with the candidate path path in the query graph and then sent to the pre-trained Bert network for encoding to obtain the global feature information CLS of the sequence and the feature information words_embedding of each word;
[0028] (2) Multiply CLS and words_embedding to get a weight vector W(CLS,word) of 1×length_squence dimension:
[0029] W(CLS,word)=CLS×words_embedding T (8)
[0030] (3) Perform feature weighted fusion on each word in step (1) according to the weight in step (2) to obtain the final cross encoding result Cross_encoding(q,path):
[0031] Cross_encoding(q,path)=W(CLS,word)×words_embedding (9)
[0032] (4) Send the encoding result in step (3) to the fully connected layer and pass it through the softmax function to obtain the similarity score between the question and the candidate path;
[0033] (5) The cross entropy loss function is also used during training. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is the complete process of the question-and-answer method.
[0035] Figure 2 This is the detailed structure of the problem structure classification model proposed by the present invention.
[0036] Figure 3 This is the detailed structure of the query graph ranking model proposed in the present invention. DETAILED DESCRIPTION
[0037] The present invention will be further described below in conjunction with the accompanying drawings:
[0038] Figure 1 This is the complete process and training process of the entire question-answering method. The main work of this invention lies in two parts, namely, the question structure classification network based on external relationship attention enhancement and the query graph sorting network based on feature cross-coding. Figure 2 As shown in the figure, in the question structure classification network, the pre-trained knowledge representation model is first used to encode all the relations in the database to obtain the feature representation of each relation. Then the question is input into the pre-trained language model BERT for encoding to obtain a vector representation. At the same time, the attention mechanism and database relation features are used to enhance the information representation of the question features, and then sent to the classifier to obtain the question structure category. The classification result is used to filter the initial query graph of the question to obtain a more accurate query graph. As shown in the attached figure, the question is encoded into the pre-trained language model BERT to obtain the vector representation. Figure 3As shown, in the query graph sorting stage, the present invention uses feature cross-coding to encode the concatenated question and candidate paths, and then obtains the encoding representation of the entire sequence after weighted averaging of the output, and finally obtains the similarity score between the question and the candidate paths through a fully connected layer and a softmax function.
[0039] Table 1 and Table 2 are the experimental results of the present invention on the public datasets MetaQA and WebQuestionSP. The experiments show that the proposed question structure classification model and cross-coding ranking model achieve better results in terms of comprehensive evaluation indicators Accuracy and Hits@1 compared with the best existing models.
[0040] Table 1
[0041]
[0042] Table 2
[0043]
[0044] The above embodiments are only preferred embodiments of the present invention and are not limitations of the technical solutions of the present invention. Any technical solution that can be implemented on the basis of the above embodiments without creative work should be deemed to fall within the scope of protection of the patent of the present invention.
Claims
1. A knowledge graph question answering method based on relational attention enhancement and feature cross encoding, characterized by The following steps are involved: Step 1: Perform named entity recognition on the question and use this entity to search in the knowledge graph to obtain an initial query graph; Step 2: Use the pre-trained knowledge representation model Complex to encode the knowledge base relationship and obtain the feature representation R.matrix of all relationships; Step 3: Construct a question structure classification network, input the question into the question structure classification network, and output the question structure category corresponding to the question; Step 4: Use the classification results obtained in step 3 to filter the noise of the initial query graph in step 1 to obtain a more accurate query graph; Step 5: Use the query graph sorting model to sort the query graph obtained in step 4; Step 6: According to the query graph sorting results in step 5, select the first-ranked path as the optimal path for the question and obtain the final answer from the knowledge graph.
2. The method according to claim 1, characterized in that The construction of the problem structure classification network in step 3 is as follows: A question structure classification network is constructed based on the pre-trained language model BERT. In the process of question classification, the input question is encoded through the pre-trained language model BERT to obtain the question feature representation. q Then, the original question is enhanced with structural information through the multi-head attention mechanism and the relational features obtained in step 2, and sent to a fully connected layer for nonlinear transformation, and finally the structural category of the question is output. The calculation formula for question information enhancement is as follows: That(q,r)=softmax(e q ×R.matrix T )×R.matrix (1) E q =At(q,r)+e q (2) Where R.matrix is the relational feature obtained in step 2 of claim 1, T represents transposition, and e q is the question feature representation, and softmax is the normalized exponential function.
3. The method according to claim 1, characterized in that The construction of the query graph sorting network in step 5 is as follows: The question and candidate paths are concatenated through [SEP] and sent to the pre-trained language model BERT network. The features of each word in the concatenated sequence are obtained from the hidden layer output of the last layer of BERT, and the global information features of the sequence are obtained from the CLS output of the last hidden layer of BERT. The calculation process is shown in the following formula: CLS,words_embedding=Bert(q,path)(3) In the formula, Bert(q,path) means encoding the concatenated question and candidate path using the pre-trained BERT network, CLS is the feature vector corresponding to the last hidden layer CLS of BERT, and words_embedding is the output of the last hidden layer of BERT. The attention mechanism is used to calculate the similarity between the features of each word and the global feature CLS. The calculation formula is as follows: W(CLS,word)=CLS×words_embedding T (4) Where T represents transposition, and W(CLS, word) is the similarity vector between CLS and each word in the sequence. The features of all words are weighted and summed according to the similarity vector to obtain the cross-coding representation between the question and the candidate path. The calculation formula is as follows: Cross_encoding(q,path)=W(CLS,word)×words_embedding(5) In the formula, Cross_encoding(q,path) is the encoding representation between the final question and the candidate path; finally, it is sent to the fully connected layer for nonlinear transformation to obtain the similarity score between the question and the candidate path.
Citation Information
Patent Citations
Remote supervision relation extraction method based on entity features
CN113220844A
Knowledge base question and answer method under small-amount annotation scene
CN114077839A
Knowledge reasoning method based on graph attention network
CN115879551A
Logical expression determination method and system based on decomposition-combination knowledge graph
CN115905488A
Knowledge discovery using a neural network
US20220101113A1
