Knowledge graph question-answering method and system based on cross attention and graph nerve prompt

By introducing a two-way cross-attention mechanism in the knowledge graph question and answer, multi-layer interaction between text and graph data is achieved, the problem of independent update of text and graph vectors in the existing technology is solved, and the accuracy and comprehensiveness of answer prediction are improved.

CN119396953APending Publication Date: 2025-02-07SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411503863.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the multi-hop question and answer process, the text vector and graph vector are updated independently during the inference process, failing to make full use of the other party's effective features, resulting in answer prediction relying on single text embedding and lacking comprehensive information.

Method used

After the inference of each layer of graph neural network, the graph node and text embedding representation are updated, and the prompt vector of the full graph information is generated through the additive attention mechanism, and text embedding is combined to enhance the answer reasoning ability.

Benefits of technology

Through multi-layer interaction of the two-way cross attention mechanism, ensuring the interaction between text and graph data, solving the problem of independent updates and improving the accuracy and comprehensiveness of answer prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396953A_ABST
    Figure CN119396953A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of knowledge graph multi-hop question answering, and particularly relates to a knowledge graph question answering method and system based on bidirectional cross attention and graph prompt. The method comprises the following steps: acquiring semantic representation and text representation of a question context text and a knowledge graph sub-graph corresponding to the question; performing multi-layer interaction on the text representation and the knowledge graph sub-graph by using a multi-layer interaction model, calculating a prompt vector representing full graph information by using the updated text representation and graph nodes, and enhancing semantic representation by using the prompt vector; and inputting the enhanced semantic representation and the graph node representation into a multi-layer perceptron to obtain scores of candidate options corresponding to the question. According to the method, the multi-layer interaction model is utilized to perform multi-layer interaction on the text representation and the graph node representation in the knowledge graph sub-graph, so that interaction of the text and the graph data is ensured; the problem of independent updating of the text vector and the graph vector in the knowledge graph question-answer reasoning process is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of knowledge graph multi-hop question answering, and in particular, relates to a knowledge graph question answering method and system based on bidirectional cross attention and graph neural prompts. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] The multi-hop knowledge graph question answering task is a complex question answering task that requires the model to obtain the answer to the question based on the question description and through multi-step reasoning in the knowledge graph. Compared with single-hop question answering, which can directly obtain the answer by querying the knowledge graph, multi-hop question answering needs to find a series of relationship links from the knowledge graph to answer the question. For example, to answer the question "Who is xxx's son-in-law?", you need to first find xxx's daughter and then find his daughter's spouse.

[0004] Knowledge graph multi-hop question answering can be applied to solve problems in various fields, such as finance, medicine, environment, etc., by analyzing and reasoning about large amounts of data to provide solutions. In this task, the knowledge graph, as a structured information repository, contains a large number of entity nodes and the relationships between them; the specific approach is to start with the natural language question text and perform reasoning in the knowledge graph to obtain the answer to the question.

[0005] A pre-trained language model is a model that is pre-trained based on a large amount of text data through unsupervised learning methods. This type of model can well capture the extensive grammatical rules and semantic information in the language text, so that it can have a certain foundation for language understanding before performing specific tasks. The key technical foundation is the Transformer architecture, especially the use of the self-attention mechanism to understand the context of the input text.

[0006] Prompt learning generally designs a series of prompt tags P and adds them to the text tag X, which is later used as the input of the pre-trained language model to generate predictions: y = f([P,X]); where the prompt tag P can be in the form of text input (hard prompt) or in the form of a learnable embedding vector (soft prompt). Graph neural prompt learning is mainly oriented to graph data, by obtaining specific graph structures or features as prompts.

[0007] The current knowledge graph question answering mainly focuses on the form of multiple-choice questions. Specifically, given a question Q, a set of answer options A = {a 1 …a n}; Design a machine learning model to select the correct answer from the answer candidate options based on the question.

[0008] At present, the knowledge graph question answering for multiple-choice selection is mainly solved by the "language model + knowledge graph" method. Specifically, the language model is used as a text encoder to convert questions into embedding vectors, and then the graph neural network is used to reason about the answers. In early studies, some researchers generated subgraphs on the knowledge graph based on questions and answers, and proposed the KagNet model, which used effective path reasoning and knowledge-aware semantic modeling to improve the accuracy and efficiency of question answering, but did not unify the representation of text and graphs. Some researchers also proposed the QA-GNN model, which can initially integrate text embedding updates into graph reasoning, but the fusion of graph and text is only in the last step of reasoning, and does not obtain sufficient feature fusion.

[0009] Therefore, the current multi-hop knowledge graph question answering method based on "language model + knowledge graph" still has the following problems:

[0010] (1) During the reasoning process, the text vector and the graph vector only update their own embedding representations, without utilizing each other’s effective features. (2) In the final answer prediction, only monotonous text embedding is used, without obtaining more comprehensive information. Summary of the invention

[0011] In order to solve the deficiencies of the prior art, the present invention provides a knowledge graph question-answering method, system, electronic device, computer-readable storage medium and computer program product based on bidirectional cross attention and graph prompts; after each layer of graph neural network inference, the updated graph node embedding representation and text embedding representation are used to perform bidirectional cross attention calculations, and the obtained graph nodes and text embeddings are then passed to the next layer of graph neural network. Through the additive attention mechanism, the output of the last layer of interaction generates a prompt vector containing full graph information, and the prompt vector and text embedding vector are combined to enhance the reasoning ability of the answer.

[0012] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:

[0013] In a first aspect, the present invention provides a knowledge graph question answering method based on bidirectional cross attention and graph prompts, comprising:

[0014] Obtain the question context text and encode it to obtain semantic representation and text representation;

[0015] Match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question;

[0016] After adding self-attention to the text representation, a multi-layer interaction model is used to perform multi-layer interactions between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation;

[0017] The updated text representation and graph nodes are used to calculate the hint vector representing the whole graph information, and the hint vector is used to enhance the semantic representation;

[0018] The enhanced semantic representation and graph node representation are input into a multi-layer perceptron to obtain the scores of the candidate options corresponding to the question.

[0019] In a second aspect, the present invention provides a knowledge graph question answering system based on bidirectional cross attention and graph prompts, comprising:

[0020] The question encoding module is configured to: obtain the question context text and encode it to obtain semantic representation and text representation;

[0021] The knowledge graph matching module is configured to: match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question;

[0022] The feature multi-layer interaction module is configured to: after adding self-attention to the text representation, use the multi-layer interaction model to perform multi-layer interaction between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation;

[0023] A graph neural network hint module is configured to: calculate a hint vector representing the whole graph information using the updated text representation and graph nodes, and enhance the semantic representation using the hint vector;

[0024] The question candidate answer scoring module is configured to: input the enhanced semantic representation and graph node representation into the multi-layer perceptron to obtain the score of the candidate option corresponding to the question.

[0025] In a third aspect, the present invention provides an electronic device;

[0026] An electronic device comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-mentioned knowledge graph question-answering method based on bidirectional cross-attention and graph prompts.

[0027] In a fourth aspect, the present invention provides a computer-readable storage medium;

[0028] A computer-readable storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements the steps of the above-mentioned knowledge graph question-answering method based on bidirectional cross-attention and graph prompts.

[0029] In a fifth aspect, the present invention provides a computer program product;

[0030] A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned knowledge graph question answering method based on bidirectional cross-attention and graph prompts.

[0031] One or more of the above technical solutions have the following beneficial effects:

[0032] (1) The present invention uses a multi-layer interaction model to perform multi-layer interaction between text representation and graph node representation in the knowledge graph subgraph. By introducing bidirectional cross-attention in the multi-layer interaction model, it ensures that text and graph data can interact with each other. It effectively solves the problem that text vectors and graph vectors are updated independently during the knowledge graph question-answering reasoning process and cannot fully utilize their complementary features.

[0033] (2) The present invention increases the multimodal information of the text by calculating a hint vector representing the entire image information, thereby improving the accuracy and comprehensiveness of answer prediction; and solves the problem that previous methods rely on a single text embedding representation when making final answer predictions.

[0034] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0036] Figure 1 This is a flow chart of a knowledge graph question answering method based on bidirectional cross-attention and graph prompts according to the first embodiment.

[0037] Figure 2 Flowchart of generating neural cue vectors for the first embodiment.

[0038] Figure 3 This is a diagram of the model test results of the first embodiment. DETAILED DESCRIPTION

[0039] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0040] It should be noted that the terms used herein are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0041] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0042] Embodiment 1

[0043] like Figure 1 As shown, this embodiment discloses a knowledge graph question answering method based on bidirectional cross attention and graph prompts, including:

[0044] Step 1: Obtain the question context text and encode it to obtain semantic representation and text representation;

[0045] Step 2: Match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question;

[0046] Step 3: After adding the self-attention mechanism to the text representation, a multi-layer interaction model is used to perform multi-layer interactions between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation;

[0047] Step 4: Use the graph neural network to fuse the updated text representation and graph node representation to obtain a hint vector representing the entire graph information, and use the hint vector to enhance the semantic representation;

[0048] Step 5: Input the updated graph node representation and the enhanced semantic representation into the multi-layer perceptron to obtain the score of the candidate options corresponding to the question.

[0049] Step 1 includes: Step 101: obtaining an original question q and a candidate option c corresponding to the question and concatenating them as a question context text [CLS];

[0050] Step 102: Encode the question context text using a pre-trained language model (RoBERTa model is used in this embodiment) to obtain a token representation (semantic representation) of the question text. and text representation

[0051] H cls,H q =Encoder(q;c);

[0052] Among them, the text represents H q That is, the hidden state of each word; n represents the length of the question, d LM Represents the dimension of the vector output of the last layer of the language model.

[0053] Step 2 includes: obtaining a knowledge graph of the knowledge field corresponding to the question text, matching the question text with the knowledge graph of the corresponding knowledge field, and obtaining a knowledge graph subgraph corresponding to the question; the present invention obtains a knowledge graph subgraph from the knowledge graph to improve the efficiency of answer reasoning.

[0054] Among them, the entity linking technology is used to retrieve subgraphs from the knowledge graph; first, relevant entities are identified from the question, and these entities are linked to the entity nodes in the knowledge graph to form a preliminary node set; then, based on the preliminary linked entities, the 2-hop paths between all these entities are checked; if the intermediate entities on the path connect two linked entities, these entities are added to the node set. Finally, these node names are merged with the question context, and the relevance of each node is evaluated by outputting scores from the pre-trained language model; the top 200 nodes with the highest scores are retained, and the edges of these nodes are connected to form a subgraph.

[0055] Step 3: After adding the self-attention mechanism to the text representation, a multi-layer interaction model is used to perform multi-layer interactions between the text representation and the graph node representation in the knowledge graph subgraph, and each interaction is to interact the text representation with all subgraph representations to update the text representation and graph node representation;

[0056] Each layer of the multi-layer interaction model includes a graph attention network and a bidirectional cross-attention module; the bidirectional cross-attention module uses a combination of multi-head cross-attention and feedforward neural networks, and adds residual connections and layer normalization in the module to prevent gradient disappearance and gradient explosion.

[0057] Residual connection is used to pass the input of the previous layer directly to the next layer. This method can alleviate the problems of gradient disappearance and gradient explosion. Layer normalization is used to normalize the mean and variance of neurons with respect to the sample to avoid model instability caused by batch size.

[0058] The calculation process of the bidirectional cross-attention module includes: taking the text representation as the query vector and the graph representation as the key vector and value vector for cross-attention calculation, and then adding residual connection and layer normalization to obtain the updated text representation and graph node representation.

[0059] In the process of interacting with the question text representation and the graph representation, multi-head cross attention is first used to calculate the attention between the question text representation and the graph node representation, and then the attention is added to the previous output (i.e., residual connection is performed). The result is input into the feedforward neural network (FFN) and added to the previous result (i.e., residual connection); finally, after layer normalization (LayerNorm layer), the final updated node representation is obtained.

[0060] The multi-layer interaction process between text representation and graph node representation includes: the text representation acts on the graph representation process and the graph representation reacts to the text representation process;

[0061] Text representation acts on graph representation: After updating the node representation by aggregating neighbor node information and relationship information in each layer of the graph attention network, the output graph representation interacts with the text representation through cross attention to obtain a graph representation with text features;

[0062] The graph representation reacts to the text representation: the text representation is used as the query vector, and the graph representation is used as the key vector and value vector to input symmetrical cross-attention calculations to improve the semantic representation of the text; with the stacking of graph neural network layers, there are multi-level interactions between text and graphs.

[0063] Step 301: Use X∈{x 1 ,x 2 …x n} is represented as a collection of knowledge graph subgraph nodes, H q ∈{q 1 …q n} represents the word vectors of text embedding.

[0064] First, let the graph nodes represent X and the text represent H q Unify the embedding dimension.

[0065] X,H q =σ(f(X,H q ))

[0066] In the formula, f represents the fully connected layer with adjusted dimension, σ represents the GELU activation function, at this time They all have the same dimension d, n represents the number of nodes, and l represents the length of the text.

[0067] Step 302: Map the graph node X∈{x 1 ,x 2 …x n} is sent to the graph attention network for reasoning, and the node representation is updated by aggregating the information of neighboring nodes; the update process of the node in the current layer of the graph neural network is as follows:

[0068]

[0069] Where W q ,W k ,W v ,W o represents the trainable matrix, represents the target node representation of the kth layer, is the neighbor node representation, represents the edge embedding representation between two nodes, and N(i) represents the neighbor set of node i.

[0070] Step 303: In order to capture the long-distance dependencies in the sequence, the question text representation matrix H in step 301 is q Apply a layer of self-attention to allow the model to dynamically decide which part of the sequence is more important; the question text is represented by H q After adding the self-attention mechanism,

[0071]

[0072] Step 304: Use multi-head cross attention to represent the question text in step 303 Interacting for the first time with the graph node X represented in step 302;

[0073]

[0074] In the formula, Attn represents the attention function, and the formula is [ ] i=1:h represents the concatenation operation of h attention heads, (W Q ,W K ,W V ) is the projection operation, W O It means converting the concatenated embedding dimension h×d to the original embedding dimension d.

[0075] Step 305: Use question text representation And the graph node representation after the first interaction The second interaction is performed, and the graph representation after the interaction is used as the input of the next layer of graph attention network. The output of the next layer of graph neural network is:

[0076]

[0077] Step 306: Use symmetric multi-head cross attention calculation To get a new text representation

[0078]

[0079] Step 306: The interaction process is repeated in this way until the set number of interactions is reached.

[0080] It should be noted that each time the model interacts, it is performed after the graph neural network layer, so the number of interactions is the same as the number of graph neural network layers, which is set to 5 layers in this embodiment.

[0081] In step 4, the graph neural network hint module uses the updated text representation and graph nodes to calculate the hint vector representing the entire graph information, and uses the hint vector to enhance the semantic representation; specifically, it includes:

[0082] Step 401: Output result after the last layer of interaction in the multi-layer interaction model First, the graph nodes are represented Use self-attention to more accurately capture the interdependencies between nodes and highlight the key nodes in the graph.

[0083]

[0084] Step 402: As a query vector, it is combined with text features and calculated using additive attention to highlight the important parts of the text;

[0085]

[0086] Step 403: Use an average pooling layer (AvgPooling) on ​​the text features processed by the attention layer to obtain a feature vector p with graph information;

[0087]

[0088] α=Softmax(B)

[0089] In the formula, MLP represents a multi-layer perceptron, and the multi-layer perceptron MLP is used to convert the dimension into H cls Consistent, to facilitate subsequent combination; V, W q ,W k is a learnable weight matrix and b is a bias term.

[0090] Step 404: Use the vector p representing the full image features as the semantic representation H of the prompt and question cls Fusion is performed to improve the semantic representation of the text; the fusion here adopts vector addition, that is, element-by-element addition;

[0091]

[0092] Step 5: Input the enhanced semantic representation and graph node representation into the multi-layer perceptron to obtain the scores of the candidate options corresponding to the question, including:

[0093] Step 501: Use multi-head attention pooling to calculate the graph representation X to obtain the final subgraph embedding g;

[0094]

[0095] Step 502: Embed the subgraph into g and the enhanced semantic representation The possibility score ρ of the candidate options corresponding to the question is obtained through a multi-layer perceptron;

[0096]

[0097] As a further technical solution, during the model training process, the rationality score of the correct answer option a is maximized by minimizing the cross entropy loss:

[0098]

[0099] During inference, through argmax a∈C ρ(q,a) is used to predict the most accurate answer; since the present invention is a question-answering method in the form of multiple options, the correct answer to the question is determined by calculating the probability score of each option being the correct option; among them, the option with the highest score is used as the predicted answer.

[0100] Figure 3 The performance of this model and the QA-GNN model on the CommonsenseQA question-answering dataset test set is demonstrated, and accuracy is used as the model performance evaluation indicator, where accuracy is the number of correctly predicted options / examples of prediction for given data; it can be seen that the final accuracy of the algorithm of the present invention is better than that of the QA-GNN algorithm.

[0101] Embodiment 2

[0102] This embodiment discloses a knowledge graph question answering system based on bidirectional cross attention and graph prompts, including:

[0103] The question encoding module is configured to: obtain the question context text and encode it to obtain semantic representation and text representation;

[0104] The knowledge graph matching module is configured to: match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question;

[0105] The feature multi-layer interaction module is configured to: after adding self-attention to the text representation, use the multi-layer interaction model to perform multi-layer interaction between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation;

[0106] A graph neural network hint module is configured to: calculate a hint vector representing the whole graph information using the updated text representation and graph nodes, and enhance the semantic representation using the hint vector;

[0107] The question candidate answer scoring module is configured to: input the enhanced semantic representation and graph node representation into the multi-layer perceptron to obtain the score of the candidate option corresponding to the question.

[0108] It should be noted that the above modules correspond to the steps in Embodiment 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above Embodiment 1. It should be noted that the above modules, as part of the system, can be executed in a computer system such as a set of computer executable instructions.

[0109] Embodiment 3

[0110] Embodiment 3 of the present invention provides an electronic device, including a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the steps of the above-mentioned knowledge graph question-answering method based on bidirectional cross-attention and graph prompts are completed.

[0111] Embodiment 4

[0112] Embodiment 4 of the present invention provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps of the above-mentioned knowledge graph question-answering method based on bidirectional cross-attention and graph prompts are completed.

[0113] Embodiment 5

[0114] Embodiment 5 of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned knowledge graph question-answering method based on bidirectional cross-attention and graph prompts.

[0115] 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 flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, 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 flowchart and / or block diagram. 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.

[0116] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate 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 A function specified in one or more boxes.

[0117] These computer program instructions can also be loaded onto a computer or other programmable data processing device, and a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide 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.

[0118] The description of each embodiment in the above embodiments has different emphases. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A knowledge graph question answering method based on bidirectional cross attention and graph prompts, characterized in that: include: Obtain the question context text and encode it to obtain semantic representation and text representation; Match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question; After adding self-attention to the text representation, a multi-layer interaction model is used to perform multi-layer interactions between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation; The updated text representation and graph nodes are used to calculate the hint vector representing the whole graph information, and the hint vector is used to enhance the semantic representation; The enhanced semantic representation and graph node representation are input into a multi-layer perceptron to obtain the scores of the candidate options corresponding to the question.

2. A knowledge graph question answering method based on bidirectional cross attention and graph prompting as claimed in claim 1, characterized in that: The question context text includes the original question and the candidate options corresponding to the question.

3. A knowledge graph question answering method based on bidirectional cross attention and graph prompting as claimed in claim 1, characterized in that: The question context text is encoded using a pre-trained language model, where the pre-trained language model is a RoBERTa model.

4. A knowledge graph question answering method based on bidirectional cross attention and graph prompting as claimed in claim 1, characterized in that: The method of using a multi-layer interaction model to perform multi-layer interaction between the text representation and the graph node representation in the knowledge graph subgraph includes: The graph node representation in the knowledge graph subgraph is input into the graph attention network for reasoning, and the node representation is updated by aggregating the information of neighboring nodes; The text representation and the graph representation output by the graph attention network are interacted through a bidirectional cross-attention module. The text representation is used as the query vector, and the graph representation is used as the key vector and value vector for cross-attention calculation. After a feedforward neural network, adding residual connections and layer normalization, the updated text representation and graph node representation are obtained.

5. A knowledge graph question answering method based on bidirectional cross attention and graph prompting as claimed in claim 1, characterized in that: The step of calculating a hint vector representing the entire graph information using the updated text representation and the graph nodes includes: After adding self-attention to the graph node representation, it is combined with the text representation as a query vector and calculated using additive attention and average pooling layers. The calculation result is dimensionally adjusted using a multi-layer perceptron to obtain a prompt vector.

6. A knowledge graph question answering method based on bidirectional cross attention and graph prompting as claimed in claim 1, characterized in that: During model training, the plausibility score of the correct answer option is maximized by minimizing the cross entropy loss.

7. A knowledge graph question answering system based on bidirectional cross attention and graph prompts, characterized in that: include: The question encoding module is configured to: obtain the question context text and encode it to obtain semantic representation and text representation; The knowledge graph matching module is configured to: match the question context text with the knowledge graph of its corresponding knowledge domain to obtain the knowledge graph subgraph corresponding to the question; The feature multi-layer interaction module is configured to: after adding self-attention to the text representation, use the multi-layer interaction model to perform multi-layer interaction between the text representation and the graph node representation in the knowledge graph subgraph to update the text representation and the graph node representation; A graph neural network hint module is configured to: calculate a hint vector representing the whole graph information using the updated text representation and graph nodes, and enhance the semantic representation using the hint vector; The question candidate answer scoring module is configured to: input the enhanced semantic representation and graph node representation into the multi-layer perceptron to obtain the score of the candidate option corresponding to the question.

8. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of a knowledge graph question answering method based on bidirectional cross attention and graph prompts as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by a processor, the steps of a knowledge graph question answering method based on bidirectional cross attention and graph prompts as described in any one of claims 1-6 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of a knowledge graph question answering method based on bidirectional cross attention and graph prompts as described in any one of claims 1-6 are implemented.

Citation Information

Cited By

  • Multi-modal agricultural technology question and answer method and system

    CN121210687A

  • A multi-modal agricultural technology question and answer method and system

    CN121210687B

  • Context self-adaptive knowledge graph question and answer method, equipment and medium

    CN122412559A