Knowledge graph complex question answering method and device based on unified query encoder
Through the method based on the unified query encoder, the problem of high time complexity and poor detection effect of incomplete knowledge graphs is solved, and efficient knowledge Q&A is achieved, which improves the accuracy of answer retrieval and model adaptation. sex.
Patent Information
- Application Number
- CN202311069119.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-23
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2043-08-23
AI Technical Summary
In the prior art, when sub-graph matching algorithms are used to obtain answers to logical query statements, the time complexity is high and the detection effect of incomplete knowledge graphs is poor, resulting in many answers being unable to be retrieved.
Using a method based on a unified query encoder, the global feature representation of the query graph is obtained and input into the neural link predictor, and the pre-trained knowledge graph embedding model is used for end-to-end query encoding, and the answers are directly retrieved from the neural knowledge base to avoid Gradually calculate the error accumulation of intermediate nodes.
It improves the success rate and accuracy of knowledge questions and answers, and is adapted to various types of neural link predictors and knowledge graph embedding models, which improves the training efficiency and scalability of the model.
Smart Images

Figure CN116992004B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a knowledge graph complex question-answering method and device based on a unified query encoder. Background Art
[0002] Complex logic question answering in knowledge bases is a basic research topic. Compared with general knowledge graph completion, this task is more difficult because it also involves first-order predicate logic, such as existential quantifiers. Conjunction (∧), disjunction (∨), and negation Therefore, complex queries on knowledge bases are closer to real application scenarios, such as being used in search engines to accurately answer multi-step and multi-constrained user queries. Answering knowledge base logical questions in large-scale and incomplete knowledge bases is a crucial basic task.
[0003] In the prior art, a subgraph matching algorithm is generally used to obtain answers to logical query statements.
[0004] However, the time complexity of this algorithm is relatively high and is at an exponential level. In addition, when this algorithm is used to detect incomplete knowledge graphs, many answers cannot be retrieved due to the missing of a large number of edges in the knowledge graph. Summary of the invention
[0005] The present invention provides a knowledge graph complex question answering method and device based on a unified query encoder, which is used to solve the problem that the time complexity of using a subgraph matching algorithm in the prior art to obtain answers to logical query statements is relatively high and at an exponential level. In addition, when this algorithm is used to detect incomplete knowledge graphs, many answers cannot be retrieved due to the missing of a large number of edges in the knowledge graph.
[0006] The present invention provides a knowledge graph complex question answering method based on a unified query encoder, comprising:
[0007] Acquire a global feature representation of a query graph; the global feature representation is used to reflect feature information of a head entity of the query graph and a relationship type between the head entities;
[0008] Inputting the global feature representation and the entity representation into a neural link predictor, and obtaining and outputting a predicted tail entity by the neural link predictor;
[0009] The neural link predictor is trained based on the knowledge graph completion task; and the entity representation is predetermined based on the neural link predictor.
[0010] According to a knowledge graph complex question answering method based on a unified query encoder provided by the present invention, the training step of the neural link predictor includes:
[0011] Obtain the knowledge graph embedding model, as well as the sample head entity, sample relationship type, and sample tail entity;
[0012] The knowledge graph embedding model is trained with the goal of maximizing the sum of the score of the predicted tail entity and the score of the predicted relationship type, and the trained knowledge graph embedding model is determined as the neural link predictor;
[0013] The score of the predicted tail entity is obtained by inputting the sample head entity and the sample relationship type into the knowledge graph embedding model; the score of the predicted relationship type is obtained by inputting the sample head entity and the sample tail entity into the knowledge graph embedding model.
[0014] According to a knowledge graph complex question answering method based on a unified query encoder provided by the present invention, the obtaining of a global feature representation of the query graph includes:
[0015] Acquire an original query graph, and convert the relationships between nodes in the original query graph into relationship nodes to obtain an augmented query graph;
[0016] Serializing the augmented query graph, and adding a virtual head entity node and a virtual relationship node to the serialized augmented query graph to obtain a target sequence;
[0017] Based on the target sequence, a global feature representation of the query graph is obtained.
[0018] According to a knowledge graph complex question answering method based on a unified query encoder provided by the present invention, obtaining a global feature representation of the query graph based on the target sequence includes:
[0019] Initializing the target sequence based on embeddings of entities and relationship types between the entities in the neural link predictor to obtain an initial target sequence;
[0020] The initial target sequence is subjected to dimensionality reduction processing to obtain a dimensionality reduction representation, and the dimensionality reduction representation is encoded to obtain a global feature representation of the query graph.
[0021] According to a knowledge graph complex question answering method based on a unified query encoder provided by the present invention, encoding the dimensionality reduction representation to obtain a global feature representation of the query graph includes:
[0022] Based on the directed shortest path in the original query graph, obtaining structural information of the original query graph;
[0023] The dimension reduction representation is encoded based on the structural information to obtain the global feature representation.
[0024] According to a knowledge graph complex question answering method based on a unified query encoder provided by the present invention, the structure information of the original query graph is obtained based on the directed shortest path in the original query graph, including:
[0025] Based on the following formula, the structural information of the original query graph is obtained:
[0026] φ(v i ,v j )=dir*spd(v i ,v j ),
[0027] dir=sgn(layer(v i )-layer(v j )),
[0028]
[0029] Among them, φ(v i ,v j ) represents the structural information of the original query graph, spd(v i ,v j ) represents the node v in the original query graph i and v j The directed shortest path between them, sgn(x) represents the symbol function, layer(v j ) represents node v j The number of layers, layer(v i ) represents node v i The number of layers.
[0030] The present invention also provides a knowledge graph complex question answering device based on a unified query encoder, comprising:
[0031] An acquisition unit, configured to acquire a global feature representation of a query graph; the global feature representation is used to reflect feature information of a head entity of the query graph and a relationship type between the head entities;
[0032] A prediction unit, used for inputting the global feature representation and the entity representation into a neural link predictor, and the neural link predictor obtains and outputs a predicted tail entity;
[0033] The neural link predictor is trained based on the knowledge graph completion task; and the entity representation is determined based on the neural link predictor.
[0034] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for complex question and answering of a knowledge graph based on a unified query encoder as described above is implemented.
[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described knowledge graph complex question-answering methods based on a unified query encoder.
[0036] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned knowledge graph complex question answering methods based on a unified query encoder.
[0037] The knowledge graph complex question-answering method and device based on the unified query encoder provided by the present invention encodes complex queries into the same form as simple queries through an end-to-end method, so that the pre-trained neural link predictor can be fully utilized. The query process can be regarded as directly retrieving answers from the neural knowledge base (neural link predictor) end-to-end, thereby avoiding the accumulation of errors caused by gradually calculating all intermediate nodes, improving the success rate and accuracy of knowledge questions and answers, and solving the technical problem of how to better detect the answer to the logical query statement from the knowledge graph in the prior art. In addition, the method completely decouples the neural link predictor and the encoder, so that it can adapt to various types of neural link predictors, solving the technical problem of how to adapt various types of knowledge graph embedding models in the prior art, and improving the training efficiency and scalability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 It is one of the flow charts of the knowledge graph complex question answering method based on the unified query encoder provided by the present invention;
[0040] Figure 2 This is the second flow chart of the knowledge graph complex question answering method based on the unified query encoder provided by the present invention;
[0041] Figure 3 This is the third flow chart of the knowledge graph complex question answering method based on the unified query encoder provided by the present invention;
[0042] Figure 4 It is a structural schematic diagram of a knowledge graph complex question-answering device based on a unified query encoder provided by the present invention;
[0043] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The present invention provides a knowledge graph complex question answering method based on a unified query encoder. Figure 1 This is one of the flow charts of the knowledge graph complex question answering method based on the unified query encoder provided by the present invention. Figure 2 This is the second flow chart of the knowledge graph complex question answering method based on the unified query encoder provided by the present invention. Figure 3 This is a flow chart of the third method for complex question answering of a knowledge graph based on a unified query encoder provided by the present invention. Figure 1 , Figure 2 , Figure 3 As shown, the method includes:
[0046] Step 110, obtaining a global feature representation of a query graph; the global feature representation is used to reflect feature information of a head entity of the query graph and a relationship type between the head entities;
[0047] Step 120, inputting the global feature representation and the entity representation into a neural link predictor, and the neural link predictor obtains and outputs a predicted tail entity;
[0048] The neural link predictor is trained based on the knowledge graph completion task; and the entity representation is predetermined based on the neural link predictor.
[0049] Specifically, a global feature representation of a query graph may be obtained, where the query graph reflects query structure information for a knowledge graph completion task, and the global feature representation is used to reflect feature information of the head entity of the query graph and the relationship type between the head entities.
[0050] The query graph here can be a complex query graph, and the complex query is encoded into the same form as the simple query through an end-to-end method, so as to make full use of the pre-trained neural link predictor.
[0051] After obtaining the global feature representation of the query graph, the global feature representation and the entity representation can be input into the neural link predictor, and the neural link predictor obtains and outputs the predicted tail entity.
[0052] The predicted tail entity here reflects the result information corresponding to the global feature representation and the entity representation. Specifically, it can be the tail entity with the highest score output by the neural link predictor. The entity representation here is predetermined based on the neural link predictor. Each entity and relationship in the neural link predictor has a corresponding embedding, and the entity representation is the embedding corresponding to the entity. For example, each entity corresponds to a number, such as 10. All entity representations are an N*d matrix, and each row corresponds to the representation of an entity (d-dimensional vector). Finding the corresponding entity representation is finding the vector of the corresponding row.
[0053] The neural link predictor here is trained based on the knowledge graph completion task. Here, the knowledge graph completion task refers to a simple query representation, that is, a logical query that only contains a single hop, that is, the task of predicting the tail entity given the head entity and relationship type.
[0054] The method provided by the embodiment of the present invention encodes complex queries into the same form as simple queries through an end-to-end method, so that the pre-trained neural link predictor can be fully utilized. The query process can be regarded as directly retrieving the answer from the neural knowledge base (neural link predictor) end-to-end, thereby avoiding the accumulation of errors caused by gradually calculating all intermediate nodes, improving the success rate and accuracy of knowledge questions and answers, and solving the technical problem of how to better detect the answer to the logical query statement from the knowledge graph in the prior art. In addition, the method completely decouples the neural link predictor and the encoder, so that it can adapt to various types of neural link predictors, solving the technical problem of how to adapt to various types of knowledge graph embedding models in the prior art, and improving the training efficiency and scalability of the model.
[0055] Based on the above embodiment, the training step of the neural link predictor includes:
[0056] Step 210, obtaining a knowledge graph embedding model, as well as a sample head entity, a sample relationship type, and a sample tail entity;
[0057] Step 220, training the knowledge graph embedding model with the goal of maximizing the sum of the scores of the predicted tail entity and the predicted relationship type, and determining the trained knowledge graph embedding model as the neural link predictor;
[0058] The score of the predicted tail entity is obtained by inputting the sample head entity and the sample relationship type into the knowledge graph embedding model; the score of the predicted relationship type is obtained by inputting the sample head entity and the sample tail entity into the knowledge graph embedding model.
[0059] Specifically, in order to better obtain the neural link predictor, the knowledge graph embedding model needs to be trained through the following steps:
[0060] First, we can obtain the Knowledge Graph Embedding (KGE) model, as well as the sample head entity, sample relationship type, and sample tail entity.
[0061] It can be understood that the general format of a triple is (sample header entity, sample relationship type, sample tail entity).
[0062] The knowledge graph embedding model can be trained with the goal of maximizing the sum of the scores of the predicted tail entity and the predicted relationship type, and the trained knowledge graph embedding model can be determined as a neural link predictor.
[0063] The score of the predicted tail entity here can be obtained by inputting the sample head entity and the sample relationship type into the knowledge graph embedding model. The score of the predicted relationship type here can be obtained by inputting the sample head entity and the sample tail entity into the knowledge graph embedding model.
[0064] For example, the formula for maximizing the sum of the scores of predicting the tail entity and predicting the relationship type is as follows:
[0065]
[0066]
[0067]
[0068] Among them, θ∈Θ is the knowledge graph embedding model parameter, including the embedding of entities and relations, h,r,t represents the sample head entity, sample relationship type and sample tail entity, h,t,t represents the embedding corresponding to the sample head entity, sample relationship type and sample tail entity under Θ, φ represents the scoring function of the knowledge graph embedding model, that is, by scoring the triplet, it indicates the probability that the triplet is true, and λ is the parameter that controls the weight of the additional training target.
[0069] Based on the above embodiment, the step of obtaining the global feature representation of the query graph in step 110 includes:
[0070] Step 111, obtaining an original query graph, and converting the relationships between nodes in the original query graph into relationship nodes to obtain an augmented query graph;
[0071] Step 112, serializing the augmented query graph, and adding a virtual head entity node and a virtual relationship node to the serialized augmented query graph to obtain a target sequence;
[0072] Step 113: obtaining a global feature representation of the query graph based on the target sequence.
[0073] Specifically, an original query graph may be obtained, where the original query graph refers to a query graph with directed and edge attributes, and then the relationships between nodes in the original query graph may be converted into relationship nodes (e.g., Figure 3 The relationship between Lieutenant General AI and V1field -1 Convert to field -1 Node, namely V2 node), to obtain the augmented query graph. The augmented query graph here refers to a query graph with undirected and edgeless properties.
[0074] After the augmented query graph is obtained, the augmented query graph may be serialized, and a virtual head entity node and a virtual relationship node may be added to the serialized augmented query graph to obtain a target sequence.
[0075] For example, a virtual head entity node g can be added to the serialized augmented query graph. h and virtual relationship node g r , and finally get the target sequence S = [g h ,g r ,v1,…,v n ], where n is the number of nodes in the augmented graph.
[0076] After obtaining the target sequence, a global feature representation of the query graph can be obtained based on the target sequence.
[0077] Based on the above embodiment, step 113 includes:
[0078] Step 1131, based on the embedding of entities and relationship types between the entities in the neural link predictor, initialize the target sequence to obtain an initial target sequence;
[0079] Step 1132, performing dimensionality reduction processing on the initial target sequence to obtain a dimensionality reduction representation, and encoding the dimensionality reduction representation to obtain a global feature representation of the query graph.
[0080] Specifically, the target sequence can be initialized based on the embedding of entities and relationship types between entities in the neural link predictor to obtain the initial target sequence. The initial target sequence here can be expressed as Where m = n + 2, d0 is the dimension of the embedding of the relationship between entities. For any node in S, if the node is an entity node or a relationship node, the representation of the node is the pre-trained embedding representation, otherwise the node representation is a learnable embedding.
[0081] After obtaining the initial target sequence, the initial target sequence can be processed by dimensionality reduction to obtain a dimensionality reduction representation. For example, a multi-layer perceptron (MLP) can be used to convert S 0 Dimension reduction is performed to reduce the number of parameters and calculation time of subsequent encoders. The specific formula is as follows:
[0082] S 1 =MLP proj (S 0 )
[0083] in, They respectively represent the initial representation of S (initial target sequence) and the representation after dimensionality reduction (reduced dimensionality representation), and d1<d0.
[0084] After obtaining the reduced-dimensional representation, the reduced-dimensional representation can be encoded to obtain the global feature representation of the query graph.
[0085] Based on the above embodiment, encoding the dimension reduction representation in step 1132 to obtain the global feature representation of the query graph includes:
[0086] Step 310, obtaining structural information of the original query graph based on the directed shortest path in the original query graph;
[0087] Step 320: Encode the dimension reduction representation based on the structural information to obtain the global feature representation.
[0088] Specifically, the structural information in the original query graph can be obtained based on the directed shortest path in the original query graph.
[0089] For example, a two-dimensional matrix can be used to record the directed shortest path between any two points in the original query graph, thereby recording the structural information of the original query graph. The specific formula is as follows:
[0090] φ(v i , v j )=dir*spd(v i , v j ),
[0091] dir=sgn(layer(v i )-layer(v j )),
[0092]
[0093] Among them, φ(v i , v j ) represents the structural information of the original query graph, spd(v i , v j ) represents node v i and v j The directed shortest path between layers (v i ) represents node v i The number of layers, layer(v j ) represents node v j The number of layers (obtained by topological sorting), sgn(x) represents the sign function.
[0094] Here, node v i and v j The directed shortest path between them can be calculated using the Floyd-Warshall algorithm (Floyd-Warshall algorithm), which is not specifically limited in the embodiment of the present invention.
[0095] After obtaining the structural information, the dimensionality reduction representation can be encoded based on the structural information to obtain the global feature representation.
[0096] For example, the dimensionality reduction representation can be encoded using an encoder based on the self-attention mechanism and structural information. The specific formula is as follows:
[0097]
[0098]
[0099] Among them, α ij Represents node v i and v j The attention coefficient between Q , Respectively represent the query (Query), key value (Key) matrix, Represents a i , v j )(structural information) determines the learnable bias term, h i Indicates S 1 The i-th element in .
[0100] Node v i The self-attention encoding results are as follows:
[0101]
[0102] in, Represents the value matrix.
[0103] The final output of the i-th layer is obtained by using the standard Transformer encoder. The specific formula is as follows:
[0104] h′(l)=LN(MHA(h (l-1) )+h (l-1) )
[0105] h (l) =LN(FFN(h′ (l) )+h′ (l) ),
[0106] FFN(x)=act(xW1+b1)W2+b2
[0107] Among them, MHA stands for Multi-Head Attention. act represents the activation function, FFN (Feedforward Neural Network), and LN (Layer Normalization).
[0108] After obtaining the global feature representation, the global feature representation can be input into the pre-trained neural link predictor to obtain the probability s(t i |g), the specific formula is as follows:
[0109] s(t i |g)=φ(g h ′,g r ′, t i )
[0110] g h ′=MLP rev (g h ), g r ′=MLP rev (g r )
[0111] Among them, g h ′,g r ′ are the representations of the virtual head entity node and the virtual relationship node in the last layer, MLP rev Project the final representation from the d1 dimension back to the d0 dimension, Represents entity t i is the pre-trained representation of , and φ is the score function of the knowledge graph embedding model.
[0112] Furthermore, the following formula is used as the loss function of the encoder to train the model so that it can generate appropriate g for any query. h , g r , that is, enter the g h , g r The correct answer can be obtained by passing it to the pre-trained neural link predictor.
[0113]
[0114] Where L represents the loss function of the encoder, s(t|g) represents the probability that entity t is the answer to the current query given the query graph g, and s(t i |g) represents a given query graph g, entity t i As the probability of the answer to the current query, t,t i Represent the correct entity and the wrong entity obtained by negative sampling respectively.
[0115] The following is a description of the knowledge graph complex question and answer device based on the unified query encoder provided by the present invention. The knowledge graph complex question and answer device based on the unified query encoder described below and the knowledge graph complex question and answer method based on the unified query encoder described above can be referenced to each other.
[0116] Based on any of the above embodiments, the present invention provides a knowledge graph complex question answering device based on a unified query encoder, Figure 4 is a schematic diagram of the structure of the knowledge graph complex question answering device based on the unified query encoder provided by the present invention, such as Figure 4 As shown, the device comprises:
[0117] An acquisition unit 410 is used to acquire a global feature representation of a query graph; the global feature representation is used to reflect feature information of a head entity of the query graph and a relationship type between the head entities;
[0118] A prediction unit 420, configured to input the global feature representation and the entity representation into the neural link predictor, and the neural link predictor obtains and outputs a predicted tail entity;
[0119] The neural link predictor is trained based on the knowledge graph completion task; and the entity representation is determined based on the neural link predictor.
[0120] The device provided by the embodiment of the present invention encodes complex queries into the same form as simple queries through an end-to-end method, so that the pre-trained neural link predictor can be fully utilized. The query process can be regarded as directly retrieving the answer from the neural knowledge base (neural link predictor) end-to-end, thereby avoiding the accumulation of errors caused by gradually calculating all intermediate nodes, improving the success rate and accuracy of knowledge questions and answers, and solving the technical problem of how to better detect the answer to the logical query statement from the knowledge graph in the prior art. In addition, the method completely decouples the neural link predictor and the encoder, so that it can adapt to various types of neural link predictors, solving the technical problem of how to adapt to various types of knowledge graph embedding models in the prior art, and improving the training efficiency and scalability of the model.
[0121] Based on any of the above embodiments, it further includes a training unit, wherein the training unit is specifically used for:
[0122] Obtain the knowledge graph embedding model, as well as the sample head entity, sample relationship type, and sample tail entity;
[0123] The knowledge graph embedding model is trained with the goal of maximizing the scores of the predicted tail entities and the predicted relationship types, and the trained knowledge graph embedding model is determined as the neural link predictor;
[0124] The score of the predicted tail entity is obtained by inputting the sample head entity and the sample relationship type into the knowledge graph embedding model; the score of the predicted relationship type is obtained by inputting the sample head entity and the sample tail entity into the knowledge graph embedding model.
[0125] Based on any of the above embodiments, the acquiring unit 410 is specifically used for:
[0126] An original query graph acquisition unit is used to acquire an original query graph and convert the relationships between nodes in the original query graph into relationship nodes to obtain an augmented query graph;
[0127] Determine a target sequence unit, which is used to serialize the augmented query graph, and add a virtual head entity node and a virtual relationship node to the serialized augmented query graph to obtain a target sequence;
[0128] A global feature representation unit is determined, which is used to obtain a global feature representation of the query graph based on the target sequence.
[0129] Based on any of the above embodiments, determining the global feature representation unit is specifically used for:
[0130] Determine an initial target sequence unit, which is used to initialize the target sequence based on the embedding of entities and the relationship types between the entities in the neural link predictor to obtain an initial target sequence;
[0131] A dimensionality reduction unit is used to perform dimensionality reduction processing on the initial target sequence to obtain a reduced dimensionality representation, and encode the reduced dimensionality representation to obtain a global feature representation of the query graph.
[0132] Based on any of the above embodiments, the dimension reduction unit is specifically used for:
[0133] Determine a structure information unit, which is used to obtain the structure information of the original query graph based on the directed shortest path in the original query graph;
[0134] An encoding unit is used to encode the reduced-dimensional representation based on the structural information to obtain the global feature representation.
[0135] Based on any of the above embodiments, determining that the structure information unit is specifically used for:
[0136] Based on the following formula, the structural information of the original query graph is obtained:
[0137] φ(v i , v j )=dir*spd(v i , v j ),
[0138] dir=sgn(layer(v i )-layer(v j )),
[0139]
[0140] Among them, φ(v i , v j ) represents the structural information of the original query graph, spd(v i , v j ) represents the node v in the original query graph i and v j The directed shortest path between them, sgn(x) represents the symbol function, layer(v j ) represents node v j The number of layers, layer(v i ) represents node v i The number of layers.
[0141] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the knowledge graph complex question answering method based on the unified query encoder, the method comprising: obtaining a global feature representation of the query graph; the global feature representation is used to reflect the feature information of the head entity of the query graph and the relationship type between the head entity; the global feature representation and the entity representation are input into the neural link predictor, and the neural link predictor obtains and outputs the predicted tail entity; the neural link predictor is trained based on the knowledge graph completion task; the entity representation is predetermined based on the neural link predictor.
[0142] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0143] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the knowledge graph complex question answering method based on a unified query encoder provided by the above methods, and the method includes: obtaining a global feature representation of the query graph; the global feature representation is used to reflect the feature information of the head entity of the query graph and the relationship type between the head entity; the global feature representation and the entity representation are input into a neural link predictor, and the neural link predictor obtains and outputs a predicted tail entity; the neural link predictor is trained based on the knowledge graph completion task; the entity representation is predetermined based on the neural link predictor.
[0144] On the other hand, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by the processor, it is implemented to execute the knowledge graph complex question answering method based on the unified query encoder provided by the above methods, the method comprising: obtaining a global feature representation of the query graph; the global feature representation is used to reflect the feature information of the head entity of the query graph and the relationship type between the head entity; the global feature representation and the entity representation are input into the neural link predictor, and the neural link predictor obtains and outputs the predicted tail entity; the neural link predictor is obtained based on the knowledge graph completion task training; the entity representation is predetermined based on the neural link predictor. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0145] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A knowledge graph complex question answering method based on a unified query encoder, characterized in that: include: Obtaining a global feature representation of the query graph; The global feature represents feature information used to reflect the head entity of the query graph and the type of relationship between the head entities; Inputting the global feature representation and the entity representation into a neural link predictor, and obtaining and outputting a predicted tail entity by the neural link predictor; The neural link predictor is trained based on the knowledge graph completion task; The entity representation is predetermined based on the neural link predictor; The obtaining of the global feature representation of the query graph includes: Obtaining an original query graph, and converting the relationships between nodes in the original query graph into relationship nodes to obtain an augmented query graph; the original query graph refers to a query graph with directed and edge attributes; The augmented query graph is serialized, and a virtual head entity node and a virtual relationship node are added to the serialized augmented query graph to obtain a target sequence; the augmented query graph refers to a query graph with undirected and edgeless properties; Based on the target sequence, a global feature representation of the query graph is obtained.
2. The knowledge graph complex question answering method based on a unified query encoder according to claim 1, characterized in that: The training steps of the neural link predictor include: Obtain the knowledge graph embedding model, as well as the sample head entity, sample relationship type, and sample tail entity; The knowledge graph embedding model is trained with the goal of maximizing the sum of the scores of the predicted tail entity and the predicted relationship type, and the trained knowledge graph embedding model is determined as the neural link predictor; The score of the predicted tail entity is obtained by inputting the sample head entity and the sample relationship type into the knowledge graph embedding model; the score of the predicted relationship type is obtained by inputting the sample head entity and the sample tail entity into the knowledge graph embedding model.
3. The knowledge graph complex question answering method based on a unified query encoder according to claim 1, characterized in that: The obtaining, based on the target sequence, a global feature representation of the query graph, comprises: Initializing the target sequence based on embeddings of entities and relationship types between the entities in the neural link predictor to obtain an initial target sequence; The initial target sequence is subjected to dimensionality reduction processing to obtain a dimensionality reduction representation, and the dimensionality reduction representation is encoded to obtain a global feature representation of the query graph.
4. The knowledge graph complex question answering method based on a unified query encoder according to claim 3 is characterized in that: The encoding of the dimension reduction representation to obtain a global feature representation of the query graph includes: Based on the directed shortest path in the original query graph, obtaining structural information of the original query graph; The dimension reduction representation is encoded based on the structural information to obtain the global feature representation.
5. The knowledge graph complex question answering method based on unified query encoder according to claim 4 is characterized in that: The obtaining structural information of the original query graph based on the directed shortest path in the original query graph includes: Based on the following formula, the structural information of the original query graph is obtained: φ(v i ,v j )=dir*spd(v i ,v j ), dir=sgn(layer(v i )-layer(v j )), Among them, φ(v i , v j ) represents the structural information of the original query graph, spd(v i , v j ) represents the node v in the original query graph i and v j The directed shortest path between them, sgn(x) represents the symbol function, layer(v j ) represents node v j The number of layers, layer(v i ) represents node v i The number of layers.
6. A knowledge graph complex question answering device based on a unified query encoder, characterized in that: include: An acquisition unit, used for acquiring a global feature representation of a query graph; The global feature represents feature information used to reflect the head entity of the query graph and the type of relationship between the head entities; A prediction unit, used for inputting the global feature representation and the entity representation into a neural link predictor, and the neural link predictor obtains and outputs a predicted tail entity; The neural link predictor is trained based on the knowledge graph completion task; the entity representation is determined based on the neural link predictor; The acquisition unit is specifically used for: Obtaining an original query graph, and converting the relationships between nodes in the original query graph into relationship nodes to obtain an augmented query graph; the original query graph refers to a query graph with directed and edge attributes; The augmented query graph is serialized, and a virtual head entity node and a virtual relationship node are added to the serialized augmented query graph to obtain a target sequence; the augmented query graph refers to a query graph with undirected and edgeless properties; Based on the target sequence, a global feature representation of the query graph is obtained.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the knowledge graph complex question answering method based on the unified query encoder is implemented as described in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the knowledge graph complex question answering method based on a unified query encoder as described in any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the knowledge graph complex question answering method based on a unified query encoder as described in any one of claims 1 to 5.
