A method, device, equipment and storage medium for generating questions based on knowledge graph

Through the combination of knowledge graph and deep learning technology, questions with higher reasoning and clearer levels are generated, which solves the problem of insufficient question generation quality in the existing technology and improves the user's reading comprehension ability.

CN114925186BActive Publication Date: 2024-09-10WUHAN TUYAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210566962.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2024-09-10
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

The existing technology uses a large amount of model training data from chapters to questions and lacks knowledge guidance. As a result, the quality of generated questions cannot effectively perceive the inference relationships and hierarchical relationships between knowledge points.

Method used

The knowledge graph is used to obtain subgraph vectors through the graph transformation network model, and the BiLSTM neural network and pointer generation network model are combined to obtain external questions and question type parameters based on similarity, and generate questions with higher reasoning and clearer hierarchy.

Benefits of technology

It improves the reasoning and hierarchy of questions, strengthens the connection between knowledge points, improves the user's reading comprehension and analysis and comprehensive abilities, and generates questions that are more instructive and natural.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114925186B
    Figure CN114925186B
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device, equipment and storage medium for generating questions of a knowledge graph, and relates to the field of natural language processing technology. Among them, the question generation method comprises steps S1 to S7. S1. Obtain a knowledge graph. S2. According to the knowledge graph, obtain the subgraph vector of each subgraph through a graph transformation network model. S3. Obtain a question data set. S4. According to the knowledge graph and the question data set, obtain the external question of each subgraph based on similarity. S5. Obtain five question type parameters. S6. According to the five question type parameters and the external question, obtain the external enhancement vector through the Bi LSTM neural network model. S7. According to the subgraph vector and the external enhancement vector, obtain the question through a pointer generation network model. The present invention has a significant guiding and promoting role in generating questions with diverse types, rich semantic knowledge and natural language expression required in teaching scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, device, equipment and storage medium for generating questions based on a knowledge graph. Background Art

[0002] In the text generation task, artificial intelligence technology can extract knowledge by analyzing the text and then extract questions. However, most of the current research on text-to-question generation remains at the direct mapping from text to questions, and the amount of data required for model training is very large. At the same time, the essence of text-to-question generation is statistical learning and the use of large-scale data to train deep learning models. It lacks knowledge guidance, and the quality of the generated questions cannot well perceive the reasoning relationship and hierarchical relationship between knowledge points.

[0003] In view of this, the applicant filed this application after studying the existing technology. Summary of the invention

[0004] The present invention provides a method, device, equipment and storage medium for generating questions based on a knowledge graph to improve the above-mentioned technical problems.

[0005] First,

[0006] The embodiment of the present invention provides a method for generating questions based on a knowledge graph, which comprises steps S1 to S7:

[0007] S1. Obtain a knowledge graph. The knowledge graph includes a subgraph set, and each subgraph includes an entity set, a relationship set, and a triple set.

[0008] S2. According to the knowledge graph, the subgraph vector of each subgraph is obtained through the graph transformation network model.

[0009] S3. Obtain a question dataset.

[0010] S4. According to the knowledge graph and question dataset, external questions of each subgraph are obtained based on similarity.

[0011] S5. Obtain five geometric question type parameters.

[0012] S6. According to the five question type parameters and the external question, the external enhancement vector is obtained through the BiLSTM neural network model.

[0013] S7. Generate a network model through a pointer based on the subgraph vector and the external enhancement vector to obtain the question sentence.

[0014] Second,

[0015] An embodiment of the present invention provides a question generation device for a knowledge graph, which comprises:

[0016] The knowledge graph acquisition module is used to acquire the knowledge graph. The knowledge graph includes a subgraph set, and each subgraph includes an entity set, a relationship set, and a triple set.

[0017] The subgraph vector acquisition module is used to obtain the subgraph vector of each subgraph according to the knowledge graph through the graph transformation network model.

[0018] The question set acquisition module is used to obtain the question set data set.

[0019] The external question acquisition module is used to obtain the external questions of each subgraph based on similarity according to the knowledge graph and the question dataset.

[0020] The five-question acquisition module is used to obtain the five-question type parameters.

[0021] The external vector acquisition module is used to obtain the external enhanced vector through the BiLSTM neural network model according to the five question type parameters and the external question sentence.

[0022] The question generation module is used to generate a network model through a pointer according to the subgraph vector and the external enhancement vector to obtain the question.

[0023] Thirdly,

[0024] An embodiment of the present invention provides a question generation device for a knowledge graph, which includes a processor, a memory, and a computer program stored in the memory. The computer program can be executed by the processor to implement the question generation method for a knowledge graph as described in any paragraph of the first aspect.

[0025] Fourthly,

[0026] An embodiment of the present invention provides a computer-readable storage medium. The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the question generation method of the knowledge graph as described in any paragraph of the first aspect.

[0027] By adopting the above technical solution, the present invention can achieve the following technical effects:

[0028] Knowledge graphs can organize huge amounts of educational knowledge points very well. When combined with deep learning technology, knowledge graphs can generate knowledge question and answer data with higher reasoning and clearer hierarchy, thereby helping users to conduct reasoning learning for reading comprehension and better improve their reading comprehension ability.

[0029] Relatively speaking, in the case of the same data set, the effect of mapping from knowledge graph to question will be better. Knowledge graph can better strengthen the connection between knowledge points, and form a huge knowledge network with multi-dimensional information such as the meaning of important words and sentences in the text, the main points of the article, etc., which can help users improve their ability to understand the text and their ability to analyze and synthesize.

[0030] The present invention has a significant guiding and promoting effect on generating questions required in teaching scenarios that are diverse in type, rich in semantic knowledge, and have natural language expressions.

[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0033] Figure 1 It is a flowchart of the question generation method provided by the first embodiment of the present invention.

[0034] Figure 2 It is a logic block diagram of the question generation method provided by the first embodiment of the present invention.

[0035] Figure 3 is an example of a subgraph.

[0036] Figure 4 This is the annotation result format of the sentence text by the "Jieyu" pre-training model;

[0037] Figure 5 It is a structural schematic diagram of a question generating device provided by the second embodiment of the present invention. DETAILED DESCRIPTION

[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0039] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0040] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0041] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0042] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0043] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.

[0044] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments:

[0045] Embodiment 1:

[0046] See also Figures 1 to 4 As shown, the first embodiment of the present invention provides a method for generating questions of a knowledge graph, which can be performed by a question generating device of a knowledge graph. In particular, it is performed by one or more processors in the question generating device to implement steps S1 to S7:

[0047] S1. Obtain a knowledge graph. The knowledge graph includes a subgraph set, and each subgraph includes an entity set, a relationship set, and a triple set.

[0048] It is understandable that: it is understandable that the question generating device can be an electronic device with computing performance, such as a notebook computer, a desktop computer, a server, a smart phone or a tablet computer.

[0049] It should be noted that, given a knowledge graph G. The knowledge graph G contains an entity set E = {e1, e2, ..., e N} and the set of relation types R = {r1,r2,…,r M}. Wherein, N and M are the number of entities and the number of relationship types in the knowledge graph G, respectively. Preferably, N=14253, M=423.

[0050] The knowledge graph G contains at least one subgraph. Any subgraph is g, and subgraph g consists of lines <e i ,r,e j > is composed of triple data in the form of. i , e j Represents two different entities, r represents e i Point to e j The subgraph g contains the entity set E g ={e1,e2,…,e n}, the set of relation types is R g ={r1,r2,…,r m}, and the triple set Triad g ={triad1,triad2,…,triad tn}. n, m, and tn represent the number of entities, the number of relationship types, and the number of triples in the subgraph g, respectively.

[0051] The specific format of subgraph g is shown in the attached Figure 3 . The array e in the figure represents the entity set E g , array r represents the relationship type set R g , the array link represents the triple set Triad g , rId represents the id corresponding to the relationship r, source and target are the ids corresponding to the entity e.

[0052] S2. According to the knowledge graph, the subgraph vector of each subgraph is obtained through the graph transformation network model.

[0053] Specifically, a subgraph in the knowledge graph is first obtained, and then the subgraph is transformed into a vector form that can be recognized by the neural network model through the graph transformation network model, so as to make a prediction. Preferably, the graph transformation network model is a GraphTransformer neural network model. In other embodiments, other existing graph representation learning neural network models may also be used, and the present invention does not specifically limit this.

[0054] Based on the above embodiment, in an optional embodiment of the present invention, step S2 specifically includes steps S21 to S24.

[0055] S21. Input the entity set of the subgraph into the word vector model to obtain the entity vector set of the subgraph.

[0056] In this embodiment, the word vector model of step S21 is a GloVe pre-trained model. In other embodiments, other word vector models may be used, and the present invention does not make specific limitations on this.

[0057] Specifically, the entity e and relationship r of subgraph g are represented by initial vectors through the GloVe pre-trained model to obtain the entity vector set of subgraph g And the set of relationship vectors v e and v r They are the initial vector representations of any entity e and any relationship r of the subgraph g. Preferably, the word vector dimension is 200.

[0058] S22, the subgraph g entity vector set Input the graph attention network model to obtain the intermediate layer vectors of each entity e in the subgraph g Among them, the calculation model of the intermediate layer vector is:

[0059]

[0060]

[0061]

[0062] In the formula, is the intermediate layer vector of entity e, v e is the entity vector of entity e, V represents the concatenation of the information of N attention heads in the graph attention network model, Represents the attention parameter at the nth attention head is the entity e in the graph attention network model i With entity e j The attention parameters, is the feature matrix in the nth attention head, For entity e j The entity vector of For entity e i The entity vector, W Q and W K is the feature matrix for calculating the attention parameters, For entity e i The set of neighbor nodes in the knowledge graph.

[0063] In this embodiment, the graph attention network model of steps S22 and S23 is a Graph Attention neural network model.

[0064] S23, according to the intermediate layer vector of each entity e in subgraph g The output vector representation of each entity is obtained through the regularization layer and feedforward neural network layer of the graph attention network model. Among them, the calculation model represented by the output vector is:

[0065]

[0066]

[0067] FFN(x)=W1×(f(W2×x+b1)+b2)where: is the output vector representation of entity e, LayerNorm is the normalization function, v' e is the intermediate layer vector of entity e The hidden layer vector obtained through the LayerNorm function and the feedforward neural network layer FFN, W1 and W2 are the feature matrices in the feedforward neural network, x represents the input information of the feedforward neural network layer, and b1 and b2 are bias values.

[0068] S24. According to the output vector representation of each entity, the subgraph vector of subgraph g is obtained. Thus, the sub-graph vector of each sub-graph is obtained.

[0069] S3. Obtain a question dataset.

[0070] Specifically, the question dataset is an encyclopedia question dataset, which is a publicly available question dataset.

[0071] S4. According to the knowledge graph and question dataset, external questions of each subgraph are obtained based on similarity.

[0072] Based on the above embodiment, in an optional embodiment of the present invention, step S4 specifically includes steps S41 to S45.

[0073] S41. Input the subgraph’s relationship set into the PaddleNLP “language analysis” model to obtain the relationship part-of-speech annotation information set.

[0074] S42. Input the question dataset into the PaddleNLP "language analysis" model to obtain the question word class tagging information set.

[0075] Specifically, the relationship set R of the last hop of the graph topology in each subgraph g is g ′={r1,r2,…,r m ′} and the encyclopedia question dataset BQ = {bq1,bq2,bq3,…,bq IEach encyclopedia question bq in} is sent to the PaddleNLP "Jieyu" pre-trained model to get R g′ The set of relational word class annotation information corresponding to BQ and question part-of-speech tagging information collection The output format is attached. Figure 4 Among them, m′ is the number of relations in the last hop relation set, I=1502012 is the number of questions in the encyclopedia question dataset BQ, and Figure 4 The text in it is the input text, and items is the set of word class annotation information after the text is parsed.

[0076] S43, calculating the question part-of-speech tagging information set P BQ Each part of speech tagging information in p bq and relational part-of-speech tagging information set Similarity Among them, the similarity calculation model is:

[0077]

[0078] In the formula, Represents the relationship part of speech tagging information and question part-of-speech tagging information p bq The number of part-of-speech annotation information of the intersection of Represents the relationship part of speech tagging information and question part-of-speech tagging information p bq The number of part-of-speech tagging information in the union of .

[0079] S44. According to the similarity, obtain a similarity set between the subgraph g and the question dataset BQ.

[0080] Among them, the similarity set

[0081] S45. The question corresponding to the maximum similarity in the similarity set is used as the external question of the subgraph, thereby obtaining the external question of each subgraph.

[0082] Specifically, SIMILAR g The maximum value max(SIMILAR g ) is the external question ext of subgraph g. g .

[0083] S5. Obtain five geometric question type parameters.

[0084] Specifically, the five question type parameters include what, why, how, if, and by what. They belong to the prior art and are not further described in the present invention.

[0085] S6. According to the five question type parameters and the external question, the external enhancement vector is obtained through the BiLSTM neural network model.

[0086] Specifically, by introducing five question type parameters and external questions, knowledge can be guided to make the language expression of questions more natural, the semantic knowledge richer, and the types more diverse.

[0087] Based on the above embodiment, in an optional embodiment of the present invention, step S6 specifically includes steps S61 to S63.

[0088] S61. According to the five question type parameters and the external question, the five question type vectors and the first word segmentation vector set are obtained through the word vector model. Specifically, the five question type parameters and the external question can be converted into vectors that can be recognized by the neural network model through the word vector model, which has good practical significance.

[0089] Based on the above embodiment, in an optional embodiment of the present invention, step S61 specifically includes steps S611 to S613.

[0090] S611, input the five-question type parameters into the oneHot word vector model to obtain the five-question type vector. Preferably, the dimension of the five-question type vector is 5-dimensional.

[0091] S612: Input the external question into the PaddleNLP "interpretation" model to obtain the first word segmentation set of the external question, thereby obtaining the first word segmentation set of each subgraph. The first word segmentation set is represented by: extSplit g ={w1,w2,…,w eh}, where eh is extSplit g The number of words.

[0092] S613: Input the first word segmentation set into the GloVe word vector model to obtain a first word segmentation vector set. The first word segmentation vector set is represented as: Preferably, the word vector dimension of the first word segmentation vector is 200 dimensions.

[0093] Specifically, the format of the five question type parameters and the external question sentence is different, so different word vector models are used for targeted transformation to obtain vectors that can be recognized by the neural network model, which has good practical significance.

[0094] S62. Vertically concatenate each word vector in the first word segmentation vector set and the five question type vectors to obtain a concatenated word vector set.

[0095] S63. Input the concatenated word vector set into the BiLSTM neural network model to obtain an external enhanced vector set.

[0096] Specifically, the five geometric problem type vector The first word segmentation vector set with the external question Each word vector v in w Perform vector vertical splicing, where is a 200-dimensional word vector, It is a 5-dimensional vector. After vertical splicing, a 205-dimensional word vector is obtained. The spliced ​​word vector is sent to the BiLSTM network to obtain an external enhancement vector

[0097] S7. Generate a network model through a pointer based on the subgraph vector and the external enhancement vector to obtain the question sentence.

[0098] Specifically, first, the entity set and subgraph vector of the subgraph are input into the Attention mechanism model of N multi-head attention blocks to obtain the first context vector of the subgraph.

[0099] Then, the first word segmentation set of the external question and the external enhancement vector are input into the Attention mechanism model of N multi-head attention blocks to obtain the second context vector fused with the five question type parameters and the external question.

[0100] Then, the first context vector and the second context vector are concatenated to obtain a fused context vector.

[0101] Then, the context vector is fused, as well as the hidden state h at time t in the Attention mechanism. t Input the pointer generation network model and obtain the probability P(w) that the word generated at time t is w.

[0102] Finally, the word w corresponding to the maximum probability P(w) at time t is taken as the predicted output word at time t. When w is the end marker, the question generation task ends, and the generated question is obtained.

[0103] In this embodiment, the pointer generation network model is a Pointer-Generator Network.

[0104] Specifically, knowledge graphs can organize a large number of educational knowledge points very well. The combination of knowledge graphs and deep learning technology can generate knowledge question and answer data with higher reasoning and clearer hierarchy, thereby helping users to learn inferences for reading comprehension and better improve their reading comprehension ability. Relatively speaking, in the case of the same data set, the effect of mapping from knowledge graphs to questions will be better. Knowledge graphs can better strengthen the connection between knowledge points, and form a huge knowledge network with multiple dimensions of information such as the meaning of important words and sentences in the text, the main points of the article, etc., which can assist users in improving their ability to understand the passage and their ability to analyze and synthesize.

[0105] The question generation method of the present invention has a significant guiding and promoting effect on generating questions with diverse types, rich semantic knowledge, and natural language expression required in teaching scenarios.

[0106] Figure 2 The figure shows the framework model of the question generation method based on the knowledge graph, namely the T-KGQG (Transformer based Knowledge Graph Question Generator) model, which is mainly composed of five parts: BiLSTM network module, GraphTransformer module, Attention mechanism and Pointer-Generator Network.

[0107] In the above embodiment, T-KGQG is a trained model, and only the subgraph and the five question type parameters need to be input into the T-KGQG model to generate the question sentence corresponding to the subgraph. In other embodiments, T-KGQG may be a model that has not been trained. The training steps of T-KGQG are specifically steps S701 to S711.

[0108] S701, obtain the target question corresponding to each sub-graph g , and input the target question into the jieba word segmentation tool to obtain the second word segmentation set questionSplit g ={w1,w2,…,w u}. In the formula, u is questionSplit g The number of words.

[0109] Specifically, in this step, the subgraph is a training set, and each subgraph has a corresponding manually annotated target question.

[0110] S702: Input the second word segmentation set into the word vector model to obtain the second word segmentation vector set The word vector dimension of the second word vector is 200. In this embodiment, the word vector model of step S702 is a GloVe pre-trained model. In other embodiments, other existing word vector models may also be used, and the present invention does not specifically limit this.

[0111] S703: Extract the entity set and relationship set of the knowledge graph and all words in the second word segmentation set to obtain a dictionary.

[0112] Specifically, E = {e1, e2, ..., e N} and R = {r1, r2, ..., r M}, and the second word set questionSplit g All the words in the dictionary are extracted to form a dictionary Dict = {w1, w2, ..., w DN}. Among them, DN=21035 is the number of words in the dictionary Dict.

[0113] S704: Input the entity set and the subgraph vector of the subgraph into the Attention mechanism model of N multi-head attention blocks to obtain the first context vector of the subgraph. Preferably, N=5.

[0114] S705: Input the first word segmentation set of the external question and the external enhancement vector into the Attention mechanism model of N multi-head attention blocks to obtain the second context vector fused with the five question type parameters and the external question. Preferably, N=5.

[0115] S706: Concatenate the first context vector and the second context vector to obtain a fused context vector.

[0116] S707, the dictionary and the fused context vector, as well as the hidden state h at time t in the Attention mechanism t Input the pointer to generate the network model and obtain the probability P(w) that the word generated at time t is w. The probability calculation model is:

[0117] P(w)=p*α copy +(1-p)*α vocab

[0118] p=σ(W copy [h t ||c t ]+b copy )

[0119] α copy =a([h t ||c t ],w)

[0120] α vocab =softmax(W vocab [h t ||c t ]+b vocab )

[0121] Where p is a soft switch for selecting words from the subgraph or external question or from the dictionary, α copy Used to calculate the probability distribution of copying words from subgraphs or external questions, α vocab Used to calculate the probability distribution of words copied from the dictionary, σ represents the sigmoid function, W copy and W vocab Generate the feature matrix in the network model for the pointer, b copy and b vocab is the bias value.

[0122] In this embodiment, the pointer generation network model is a Pointer-Generator Network.

[0123] S708: The word w corresponding to the maximum probability P(w) at time t is used as the predicted output word at time t. When w is the end marker, the question generation task ends, thereby obtaining the predicted word set of the generated sentence and the predicted word vector set corresponding to the word set.

[0124] S709: Calculate the loss L of the graph transformation network model based on the second word segmentation vector set, all subgraphs of the knowledge graph, and the predicted word vector set. The loss calculation model is:

[0125]

[0126] In the formula, G is the knowledge graph, g is the subgraph of the knowledge graph, NLLLoss represents the negative log-likelihood loss function, V Pre is the second word vector set, is the first word vector set.

[0127] S710. With the goal of minimizing the loss, update the network parameters of the graph transformation network model until the maximum number of iterations T is reached, and obtain the question generation model of the trained knowledge graph.

[0128] Specifically, the loss function L is minimized. The present invention uses the Pytorch deep learning framework to build the algorithm model in the experiment. In order to prevent the neural network from encountering overfitting, the gradient clipping clip_gradient method is introduced during training. The threshold of gradient clipping is set to 4, and the gradient truncation operation is performed before the optimizer is updated during training. The optimizer uses SGD stochastic gradient descent, the initial learning rate is 1e-3, and the batch size is 32. The Dropout rate is set to 0.1, the LSTM hidden layer vector size involved in the present invention is set to 500, and the network parameters are updated until the maximum number of iterations T=20 is reached to obtain a trained T-KGQG model.

[0129] S711. Input the subgraph and the five question type parameters into the question generation model of the knowledge graph to obtain the question.

[0130] Embodiment 2

[0131] An embodiment of the present invention provides a question generation device for a knowledge graph, which comprises:

[0132] The knowledge graph acquisition module 1 is used to acquire the knowledge graph. The knowledge graph includes a subgraph set, and each subgraph includes an entity set, a relationship set, and a triple set.

[0133] The subgraph vector acquisition module 2 is used to obtain the subgraph vector of each subgraph according to the knowledge graph through the graph transformation network model.

[0134] The question set acquisition module 3 is used to acquire the question set data.

[0135] The external question acquisition module 4 is used to acquire the external questions of each subgraph based on similarity according to the knowledge graph and the question dataset.

[0136] The five-question acquisition module 5 is used to obtain the five-question type parameters.

[0137] The external vector acquisition module 6 is used to acquire the external enhanced vector through the BiLSTM neural network model according to the five question type parameters and the external question sentence.

[0138] The question generation module 7 is used to generate a network model through a pointer according to the subgraph vector and the external enhancement vector to obtain the question.

[0139] In an optional embodiment, the sub-image vector acquisition module 2 specifically includes:

[0140] The entity vector set acquisition unit is used to input the entity set of the subgraph into the word vector model to obtain the entity vector set of the subgraph.

[0141] The intermediate layer vector acquisition unit is used to input the entity vector set into the graph attention network model to obtain the intermediate layer vector of each entity Among them, the calculation model of the intermediate layer vector is:

[0142]

[0143]

[0144]

[0145] In the formula, is the intermediate layer vector of entity e, v e is the entity vector of entity e, ∨ represents the concatenation of the information of N attention heads in the graph attention network model, Represents the attention parameter at the nth attention head is the entity e in the graph attention network model i With entity e j The attention parameters, is the feature matrix in the nth attention head, For entity e j The entity vector of For entity e i The entity vector, W Q and W K is the feature matrix for calculating the attention parameters, For entity e i The set of neighbor nodes in the knowledge graph.

[0146] The output vector representation acquisition unit is used to obtain the output vector representation of each entity through the regularization layer and feedforward neural network layer of the graph attention network model according to the intermediate layer vector of each entity. Among them, the calculation model represented by the output vector is:

[0147]

[0148]

[0149] FFN(x)=W1×(f(W2×x+b1)+b2)where: is the output vector representation of entity e, LayerNorm is the normalization function, v' e is the intermediate layer vector of entity e The hidden layer vector obtained through the LayerNorm function and the feedforward neural network layer FFN, W1 and W2 are the feature matrices in the feedforward neural network, x represents the input information of the feedforward neural network layer, and b1 and b2 are bias values.

[0150] The sub-graph vector obtaining unit is used to obtain the sub-graph vector of the sub-graph according to the output vector representation of each entity, thereby obtaining the sub-graph vector of each sub-graph.

[0151] In an optional embodiment, the external question acquisition module 4 specifically includes:

[0152] The relationship word class annotation information set acquisition unit is used to input the relationship set of the subgraph into the PaddleNLP "language analysis" model to obtain the relationship word class annotation information set.

[0153] The question part-of-speech tagging information set acquisition unit is used to input the question data set into the PaddleNLP "language analysis" model to obtain the question part-of-speech tagging information set.

[0154] A similarity acquisition unit is used to calculate the similarity between each part of speech tagging information in the question part of speech tagging information set and the relationship part of speech tagging information set. Among them, the similarity calculation model is:

[0155]

[0156] In the formula, Represents the relationship part of speech tagging information and question part-of-speech tagging information p bq The number of part-of-speech annotation information of the intersection of Represents the relationship part of speech tagging information and question part-of-speech tagging information p bq The number of part-of-speech tagging information in the union of .

[0157] The similarity set acquisition unit is used to acquire a similarity set between the subgraph and the question dataset according to the similarity.

[0158] The external question acquisition unit is used to take the question corresponding to the maximum similarity in the similarity set as the external question of the subgraph, so as to acquire the external question of each subgraph.

[0159] In an optional embodiment, the external vector acquisition module 6 specifically includes:

[0160] The vector set acquisition unit is used to acquire the five question type vectors and the first word segmentation vector set according to the five question type parameters and the external question through the word vector model.

[0161] The first vector concatenation unit is used to vertically concatenate each word vector in the first word segmentation vector set and the five question type vector sets to obtain a concatenated word vector set.

[0162] The external enhanced vector set acquisition unit is used to input the concatenated word vector set into the BiLSTM neural network model to obtain the external enhanced vector set.

[0163] In an optional embodiment, the vector set acquisition unit specifically includes:

[0164] The five-question type vector acquisition subunit is used to input the five-question type parameters into the oneHot word vector model to obtain the five-question type vector.

[0165] The first word segmentation vector acquisition subunit is used to input the external question into the PaddleNLP "decoding" model to obtain the first word segmentation set of the external question, thereby obtaining the first word segmentation set of each subgraph.

[0166] The first word segmentation vector set acquisition subunit is used to input the first word segmentation vector set into the GloVe word vector model to obtain the first word segmentation vector set.

[0167] In an optional embodiment, the question generation module 7 specifically includes:

[0168] The second word segmentation set acquisition unit is used to acquire the target question corresponding to each subgraph, and input the target question into the jieba word segmentation tool to acquire the second word segmentation set.

[0169] The second word segmentation vector set acquisition unit is used to input the second word segmentation set into the word vector model to obtain the second word segmentation vector set.

[0170] The dictionary acquisition unit is used to extract the entity set and relationship set of the knowledge graph and all the words in the second word segmentation set to obtain a dictionary.

[0171] The first context vector acquisition unit is used to input the entity set and the sub-graph vector of the sub-graph into the Attention mechanism model of N multi-head attention blocks to obtain the first context vector of the sub-graph.

[0172] The second context vector acquisition unit is used to input the first word segmentation set of the external question and the external enhancement vector into the Attention mechanism model of N multi-head attention blocks to obtain the second context vector fused with the five question type parameters and the external question.

[0173] The fused context vector acquisition unit is used to concatenate the first context vector and the second context vector to acquire a fused context vector.

[0174] The probability acquisition unit is used to combine the dictionary and the fused context vector, as well as the hidden state h at time t in the Attention mechanism. tInput the pointer to generate the network model and obtain the probability P(w) that the word generated at time t is w. The probability calculation model is:

[0175] P(w)=p*α copy +(1-p)*α vocab

[0176] p=σ(W copy [h t ||c t ]+b copy )

[0177] α copy =a([h t ||c t ],w)

[0178] α vooab =softmax(W vocab [h t ||c t ]+b vocab )

[0179] Where p is a soft switch for selecting words from the subgraph or external question or from the dictionary, α copy Used to calculate the probability distribution of copying words from subgraphs or external questions, α vocab Used to calculate the probability distribution of words copied from the dictionary, σ represents the sigmoid function, W copy and W vocab Generate the feature matrix in the network model for the pointer, b copy and b vocab is the bias value.

[0180] The prediction word set acquisition unit is used to take the word w corresponding to the maximum probability P(w) at time t as the predicted output word at time t. When w is the end marker, the question generation task ends, thereby obtaining the prediction word set of the generated sentence and the prediction word vector set corresponding to the word set.

[0181] The loss calculation unit is used to calculate the loss L of the graph transformation network model according to the second word segmentation vector set, all subgraphs of the knowledge graph and the predicted word vector set. The loss calculation model is:

[0182]

[0183] In the formula, G is the knowledge graph, g is the subgraph of the knowledge graph, NLLLoss represents the negative log-likelihood loss function, V Pre is the second word vector set, is the first word vector set.

[0184] The model updating unit is used to update the network parameters of the graph transformation network model with the goal of minimizing the loss until the maximum number of iterations T is reached, thereby obtaining a question generation model of the trained knowledge graph.

[0185] The question generation unit is used to input the subgraph and five question type parameters into the question generation model of the knowledge graph to obtain the question.

[0186] Embodiment 3

[0187] The embodiment of the present invention provides a question generation device for a knowledge graph, which includes a processor, a memory, and a computer program stored in the memory. The computer program can be executed by the processor to implement the question generation method for a knowledge graph as described in any paragraph of the first embodiment.

[0188] Embodiment 4:

[0189] An embodiment of the present invention provides a computer-readable storage medium. The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the question generation method of the knowledge graph as described in any paragraph of the first embodiment.

[0190] In several embodiments provided in the embodiments of the present invention, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus and method embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, method and computer program product according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0191] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0192] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or partly contributed to the prior art or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, an electronic device, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk. It should be noted that, in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.

[0193] 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 question generation method based on a knowledge graph, characterized in that: Include: Obtain a knowledge graph; the knowledge graph includes a subgraph set, each subgraph includes an entity set, a relationship set and a triple set; According to the knowledge graph, a subgraph vector of each subgraph is obtained through a graph transformation network model; Get the question dataset; According to the knowledge graph and the question dataset, obtaining external questions of each subgraph based on similarity; Get the five-dimensional question type parameters; According to the five question type parameters and the external question sentence, an external enhancement vector is obtained through a BiLSTM neural network model; Generate a network model through a pointer according to the subgraph vector and the external enhancement vector to obtain a question sentence; According to the knowledge graph, a subgraph vector of each subgraph is obtained through a graph transformation network model, including: Input the entity set of the subgraph into the word vector model to obtain the entity vector set of the subgraph; The entity vector set is input into the graph attention network model to obtain the intermediate layer vector of each entity ; Wherein, the calculation model of the intermediate layer vector is: In the formula, For Entity The middle layer vector, For Entity The entity vector of Indicates that the graph attention network model The information of each attention head is concatenated. Represents the attention parameter at the nth attention head , It is an entity in the graph attention network model With entity The attention parameters, is the feature matrix in the nth attention head, For Entity The entity vector of For Entity The entity vector of and is the feature matrix for calculating the attention parameters, For Entity The set of neighbor nodes in the knowledge graph; According to the intermediate layer vectors of each entity, the output vector representation of each entity is obtained through the regularization layer and the feedforward neural network layer of the graph attention network model ; Wherein, the calculation model represented by the output vector is: In the formula, For Entity The output vector representation of is the normalization function, For Entity The middle layer vector go through Functions and feedforward neural network layers The hidden layer vector obtained, as well as is the feature matrix in the feedforward neural network, Represents the input information of the feedforward neural network layer, as well as is the bias value; According to the output vector representation of each entity, the subgraph vector of the subgraph is obtained, thereby obtaining the subgraph vector of each subgraph; According to the knowledge graph and the question dataset, external questions of each subgraph are obtained based on similarity, including: Input the subgraph's relation set into the PaddleNLP "decoding" model to obtain the relation part-of-speech labeling information set; Input the question dataset into the PaddleNLP "Language Interpretation" model to obtain the question part-of-speech tagging information set; Calculate the similarity between each part-of-speech tagging information in the question part-of-speech tagging information set and the relationship part-of-speech tagging information set ; Among them, the similarity calculation model is: In the formula, Represents the relationship part of speech tagging information and question part-of-speech tagging information The number of part-of-speech annotation information of the intersection of Represents the relationship part of speech tagging information and question part-of-speech tagging information The number of part-of-speech tagging information in the union of ; According to the similarity, obtaining a similarity set between the subgraph and the question dataset; The question corresponding to the maximum similarity in the similarity set is used as the external question of the subgraph, so as to obtain the external question of each subgraph.

2. The question generation method of the knowledge graph according to claim 1 is characterized in that: According to the five question type parameters and the external question sentence, an external enhancement vector is obtained through a BiLSTM neural network model, including: According to the five question type parameters and the external question, obtaining the five question type vectors and the first word segmentation vector set through the word vector model; Vertically concatenate each word vector in the first word segmentation vector set and the five question type vectors to obtain a concatenated word vector set; The concatenated word vector set is input into the BiLSTM neural network model to obtain an external enhanced vector set.

3. The question generation method of the knowledge graph according to claim 2 is characterized in that: According to the five question type parameters and the external question, the five question type vectors and the first word segmentation vector set are obtained through the word vector model, including: Input the five question type parameters into the oneHot word vector model to obtain the five question type vector; Input the external question into the PaddleNLP "decoding" model to obtain the first word segmentation set of the external question, thereby obtaining the first word segmentation set of each subgraph; The first word segmentation set is input into the GloVe word vector model to obtain a first word segmentation vector set.

4. The question generation method of the knowledge graph according to claim 3 is characterized in that: According to the subgraph vector and the external enhancement vector, a network model is generated through a pointer to obtain a question sentence, including: Obtain the target question corresponding to each subgraph, and input the target question into the jieba word segmentation tool to obtain a second word segmentation set; Inputting the second word segmentation set into a word vector model to obtain a second word segmentation vector set; Extracting the entity set and the relationship set of the knowledge graph and all the words in the second word segmentation set to obtain a dictionary; Input the entity set and subgraph vector of the subgraph into the Attention mechanism model of N multi-head attention blocks to obtain the first context vector of the subgraph; Input the first word segmentation set and the external enhancement vector of the external question into the Attention mechanism model of N multi-head attention blocks to obtain the second context vector fused with the five question type parameters and the external question; Concatenate the first context vector and the second context vector to obtain a fused context vector; The dictionary and the fused context vector, as well as the time series in the Attention mechanism Hidden state at the moment Input pointer to generate network model, get The word generated at this moment is Probability ; Wherein, the calculation model of the probability is: In the formula, A soft switch to select words from the subgraph or external question or from the dictionary. Used to calculate the probability distribution of copied words from subgraphs or external questions, used to calculate the probability distribution of words copied from the dictionary, represents the sigmoid function, and Generate feature matrix in network model for pointer, and is the bias value; Will Moment Probability The word corresponding to the maximum As the predicted output word at time t; when When it is the end marker, the question generation task is completed, thereby obtaining the predicted word set for the generated sentence and the predicted word vector set corresponding to the word set; Calculate the loss of the graph transformation network model based on the second word segmentation vector set, all subgraphs of the knowledge graph, and the predicted word vector set ; Wherein, the calculation model of the loss is: In the formula, For knowledge graph, is a subgraph of the knowledge graph, represents the negative log-likelihood loss function, is the second word vector set, is the first word vector set; With the goal of minimizing the loss, update the network parameters of the graph transformation network model until the maximum number of iterations is reached , get the question generation model of the trained knowledge graph; The subgraph and the five question type parameters are input into the question generation model of the knowledge graph to obtain the question.

5. A question generation device based on a knowledge graph, characterized in that: Include: A knowledge graph acquisition module, used to acquire a knowledge graph; the knowledge graph includes a subgraph set, each subgraph includes an entity set, a relationship set and a triple set; A subgraph vector acquisition module, used to acquire the subgraph vector of each subgraph through a graph transformation network model according to the knowledge graph; A question set acquisition module is used to acquire a question set; An external question acquisition module, used to acquire external questions of each subgraph based on similarity according to the knowledge graph and the question dataset; The five-question acquisition module is used to obtain the five-question type parameters; An external vector acquisition module, used to acquire an external enhancement vector through a BiLSTM neural network model according to the five question type parameters and the external question sentence; A question generation module, for generating a network model through a pointer according to the subgraph vector and the external enhancement vector to obtain a question; The sub-graph vector acquisition module specifically includes: An entity vector set acquisition unit, used for inputting the entity set of the subgraph into the word vector model to acquire the entity vector set of the subgraph; The intermediate layer vector acquisition unit is used to input the entity vector set into the graph attention network model to obtain the intermediate layer vector of each entity ; Among them, the calculation model of the intermediate layer vector is: In the formula, For Entity The middle layer vector, For Entity The entity vector of Indicates that the graph attention network model The information of each attention head is concatenated. Represents the attention parameter at the nth attention head , It is an entity in the graph attention network model With entity The attention parameters, is the feature matrix in the nth attention head, For Entity The entity vector of For Entity The entity vector of and is the feature matrix for calculating the attention parameters, For Entity The set of neighbor nodes in the knowledge graph; The output vector representation acquisition unit is used to obtain the output vector representation of each entity through the regularization layer and feedforward neural network layer of the graph attention network model according to the intermediate layer vector of each entity. ; Among them, the calculation model represented by the output vector is: In the formula, For Entity The output vector representation of is the normalization function, For Entity The middle layer vector go through Functions and feedforward neural network layers The hidden layer vector obtained, as well as is the feature matrix in the feedforward neural network, Represents the input information of the feedforward neural network layer, as well as is the bias value; A sub-graph vector acquisition unit, used to obtain a sub-graph vector of a sub-graph according to an output vector representation of each entity, thereby obtaining a sub-graph vector of each sub-graph; The external question acquisition module specifically includes: A relational word class annotation information set acquisition unit is used to input the subgraph's relation set into the PaddleNLP "decoding" model to acquire the relational word class annotation information set; A question part-of-speech tagging information set acquisition unit is used to input the question data set into the PaddleNLP "decoding" model to obtain the question part-of-speech tagging information set; A similarity acquisition unit is used to calculate the similarity between each part of speech tagging information in the question part of speech tagging information set and the relationship part of speech tagging information set. ; Among them, the similarity calculation model is: In the formula, Represents the relationship part of speech tagging information and question part-of-speech tagging information The number of part-of-speech annotation information of the intersection of Represents the relationship part of speech tagging information and question part-of-speech tagging information The number of part-of-speech tagging information in the union of ; A similarity set acquisition unit, used for acquiring a similarity set between the subgraph and the question dataset according to the similarity; The external question acquisition unit is used to take the question corresponding to the maximum similarity in the similarity set as the external question of the subgraph, so as to acquire the external question of each subgraph.

6. A question generation device for a knowledge graph, characterized in that: It includes a processor, a memory, and a computer program stored in the memory; the computer program can be executed by the processor to implement the question generation method of the knowledge graph as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the question generation method of the knowledge graph according to any one of claims 1 to 4.