A question chain generation method and system based on knowledge graph relationship prediction
Through a method based on knowledge graph relationship prediction, the QCG-KGLP model is used to automatically generate question chains, which solves the inefficiency problem caused by relying on rule design in the existing technology, realizes efficient and automated question chain generation, and helps teachers carry out questioning teaching and Improve students' thinking ability.
Patent Information
- Application Number
- CN202210464241.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-04-29
AI Technical Summary
In the existing technology, question chain generation mainly relies on rule design, which requires teachers to invest a lot of manual resources, and artificial intelligence technology is not fully utilized, resulting in low efficiency.
A method based on knowledge graph relationship prediction is adopted. By constructing a question knowledge graph, the QCG-KGLP model is used for graph representation learning and link prediction to automatically generate question chains. Specific steps include building a question chain data set, feature initialization, graph representation learning and link prediction, and using GraphAttention and convKB modules to generate question chains.
It realizes the automatic generation of related and gradient question chains that adapt to teaching scenarios, reduces the workload of teachers, and improves the efficiency and quality of question chain generation.
Smart Images

Figure CN114860877B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of question chains and knowledge graphs, and in particular to a method and system for generating question chains based on knowledge graph relationship prediction. Background Art
[0002] "Question chain" breaks down the teaching content into small questions that build on each other and progress step by step. High-quality question chains are an important means to help teachers conduct question-based teaching and an important way to improve students' thinking ability. At present, the main way to generate question chains in the field of education is to use rule-based methods. Domain experts design question chain generation rules based on teaching requirements, and then match questions according to the rules to achieve the generation of question chains. Teachers need to read and understand the textbooks, dig deep into the textbooks during lesson preparation, be familiar with the teaching content, and scientifically summarize and deduce knowledge. This often requires educators to invest a lot of energy, and the labor cost is very huge. Nowadays, advanced technologies such as the Internet, big data and artificial intelligence are widely used in educational intelligence, but there are very few studies that apply artificial intelligence technology to the task of question chain generation. Therefore, using artificial intelligence technology to assist humans in automatically generating question chains is an important task in the field of teaching. Summary of the invention
[0003] The main purpose of the present invention is to overcome the above-mentioned defects in the prior art, and to propose a question chain generation method and system based on knowledge graph relationship prediction, so as to realize question chain generation based on question knowledge graph scenario.
[0004] The present invention adopts the following technical solution:
[0005] On the one hand, a question chain generation method based on knowledge graph relationship prediction includes the following steps:
[0006] Step 1: Construct a question chain dataset based on the question knowledge graph;
[0007] Step 2: Initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through the feature fusion method;
[0008] Step 3: Send the initial vectors of the fused head entity and the tail entity to be tested into the GraphAttention graph representation learning module of the QCG-KGLP model to obtain the representation vectors of the fused head entity and the tail entity to be tested;
[0009] Step 4: Input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation.
[0010] Preferably, the step 1 specifically includes:
[0011] Step 1.1: Given a question knowledge graph G, the question knowledge graph G contains a question entity set H = {e1, e2, …, e N}, where N is the number of entities in the question knowledge graph G; starting from any question entity e, we capture num question chains along the graph topology and obtain the question chain set D′={d1,d2,…,d num}, where each question chain d consists of a multi-hop triple, i.e., a question entity set E = {e1, e2, …, e l}, l represents the length of each question chain d; where N>l, the set corresponding to l belongs to a subset of N;
[0012] Step 1.2: Traverse all question entities in the question knowledge graph G, add the question chain set D′ obtained from each question entity e in the question entity set H to the question chain dataset D, and obtain the question chain dataset D corresponding to the question knowledge graph G = {d1, d2, …, d O}, where O is the total number of question chains.
[0013] Preferably, the step 2 specifically includes:
[0014] Step 2.1: Segment each question entity e and remove stop words to obtain the segmentation set C = {c1, c2, ..., c n}, where n represents the number of words contained in each question entity e after preprocessing;
[0015] Step 2.2: The word segmentation set C obtained in step 2.1 is represented by the initial vector through the GloVe pre-training model to obtain the word vector set W = {w1, w2, ..., w n}, where the word vector w is represented as:
[0016] w=GloVe(c) (1)
[0017] Among them, GloVe is the word vector expression function of the GloVe pre-training model;
[0018] Step 2.3: Based on the word vector set W obtained in step 2.2, the initial vector set Q of the question entity of each question chain d is obtained by weighted averaging the word vector set W of the word set C in the question entity e. l}, where the initial vector q of the question entity e is expressed as:
[0019]
[0020] Step 2.4: For each question chain d, use the information of the first l-1 question entities as the fusion head entity S of the question chain d, and its initial vector h S It is expressed as:
[0021]
[0022] Among them, i represents the question entity e i The position ranking in question chain d, calculated from the initial node;
[0023] Step 2.5: For each question chain d, take the lth question entity as the tail entity e to be tested j , whose vector h j It is expressed as:
[0024] h j =q l (4).
[0025] Preferably, the step 3 specifically includes:
[0026] Step 3.1: The initial vector h of the fusion head entity in step 2.4 S and the tail entity vector h to be measured in step 2.5 j Send it to the question knowledge graph representation learning module based on graph attention to calculate the fusion head entity S and the tail entity e to be tested in the question chain d j The attention coefficient α Sj , the formula is:
[0027]
[0028] b Sj =LeakyReLU(W2c Sj ) (6)
[0029] c Sj =W1[h S ||h j ||g r ] (7)
[0030] Among them, the relationship vector g r It is the fusion head entity S and the tail entity e to be tested j The embedding vector of the relationship r, W1, W2 represent linear transformation matrices, || represents the connection symbol, c Sj Indicates the fusion head entity S and the tail entity to be tested e j The weighted linear combination of the triples, b Sj Indicates the fusion head entity S and the tail entity to be tested e j The relative attention matrix, N Srepresents the set of entities adjacent to the fusion head entity S, e n Belongs to N S The entity b Sn Represents the fusion of head entity S and entity e n The relative attention matrix of
[0031] Step 3.2: Based on the fusion head entity S obtained in step 3.1 and the tail entity e to be tested j The weighted linear combination c Sj And the attention coefficient α Sj , calculate the representation vector h' of the fusion head entity S obtained after the question knowledge graph representation learning module based on graph attention S :
[0032]
[0033] Where σ represents an arbitrary nonlinear function and M represents the number of independent attention layers;
[0034] Step 3.3: The initial vector h of the fusion head node S based on step 2.4 S The representation vector h' from step 3.2 S , calculate the final representation vector h of the fused head entity S" S , which is calculated as:
[0035] h” S =W E h S +h' S (9)
[0036] Among them, W E is the linear transformation matrix that needs to be trained.
[0037] Preferably, the step 4 specifically includes:
[0038] Step 4.1: The final representation vector h of the fusion head entity S in step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r Send it to the question chain relationship discriminator based on convKB to calculate the fusion head entity S and the tail entity e to be tested j Is there a scoring function for whether there is a chain relationship The calculation method is as follows:
[0039]
[0040] in, Indicates the fusion of the head entity S and the tail entity e to be tested jThe chain of prediction questions, ω m represents the mth convolution filter, Ω represents the hyperparameter of the number of filters in the model, * is the convolution operator, W is the linear transformation matrix, level s Represents the last node e in the fusion head entity S s The difficulty level of the question j Indicates the tail entity to be tested e j The difficulty coefficient of the questions;
[0041] Step 4.2: Score function based on step 4.1 Calculate the loss L of the downstream task of the QCG-KGLP model main :
[0042]
[0043] in, Indicates the fusion of the head entity S and the tail entity e to be tested j The chain of prediction questions is composed of When Sj =-1; when When Sj =1; J represents a correct set of question chains, and J' represents an incorrect set of question chains;
[0044] Step 4.3: The final representation vector h of the fused head entity S based on step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r , calculate the loss L of the question knowledge graph representation learning module based on graph attention in the QCG-KGLP model reg :
[0045]
[0046]
[0047] in, Indicates the correct question chain data, represents the wrong question chain data, J is the correct question chain set, J' is the incorrect question chain set, Indicates h" s +g r With h j The L1 distance, Indicates error problem chain data "middle h" s +g r With h j The L1 distance, Indicates correct question chain data "middle h" s +g r With h j L1 distance, γ>0 is a marginal hyperparameter;
[0048] Step 4.4: Based on steps 4.2 and 4.3, calculate the total loss function L of the QCG-KGLP model:
[0049] L=L main +γ∑ n L reg (14)
[0050] Among them, the regularization coefficient γ is used to balance the loss L of the downstream task main The graph represents the learning loss L reg .
[0051] Step 4.5, minimize the total loss function L, update the network parameters until the maximum number of iterations T is reached, and obtain the trained QCG-KGLP model;
[0052] Step 4.6: Input a test problem chain data testd and a tail entity to be tested e j , merge the head entity S of testd with the tail entity e to be tested j Input into the trained QCG-KGLP model and output the prediction result like Represents the test problem chain data testd and the tail entity to be tested e j Construct a chain of questions. Indicates that the question chain is not established.
[0053] On the other hand, a question chain generation system based on knowledge graph relationship prediction includes:
[0054] The question chain dataset construction module is used to construct the question chain dataset based on the question knowledge graph;
[0055] The initial vector acquisition module is used to initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through a feature fusion method;
[0056] The representation vector acquisition module is used to send the initial vectors of the fused head entity and the tail entity to be tested into the Graph Attention graph representation learning module of the QCG-KGLP model, so as to obtain the representation vectors of the fused head entity and the tail entity to be tested;
[0057] The question chain generation module is used to input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation.
[0058] It can be seen from the above description of the present invention that, compared with the prior art, the present invention has the following beneficial effects:
[0059] The present invention can automatically generate question chains based on the question knowledge graph, and can effectively generate related and gradient question chains that adapt to teaching scenarios, thereby helping teachers to carry out question-based teaching and improve students' thinking ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a flowchart of the question chain generation method based on knowledge graph relationship prediction of the present invention;
[0061] Figure 2 This is a technical framework diagram for triple question chain prediction based on knowledge graph relationship prediction;
[0062] Figure 3 It is a technical diagram of question chain vector based on feature fusion;
[0063] Figure 4 This is a structural block diagram of the question chain generation system based on knowledge graph relationship prediction of the present invention. DETAILED DESCRIPTION
[0064] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.
[0065] See also Figure 1 As shown, the question chain generation method based on knowledge graph relationship prediction of the present invention includes the following steps:
[0066] Step 1: Construct a question chain dataset based on the question knowledge graph;
[0067] Step 2: Initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through the feature fusion method;
[0068] Step 3: Send the initial vectors of the fused head entity and the tail entity to be tested into the Graph Attention graph representation learning module of the QCG-KGLP (Question Chain Generator based on Knowledge Graph Link Prediction) model to obtain the representation vectors of the fused head entity and the tail entity to be tested;
[0069] Step 4: Input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation.
[0070] The step 1 is further specifically as follows:
[0071] Step 1.1: Given a question knowledge graph G, the question knowledge graph G contains a question entity set H = {e1, e2, …, e N}, where the number of entities in the question knowledge graph G is N = 2723. Taking any question entity e as the starting point, we can capture num question chains along the graph topology and obtain the question chain set D′ = {d1, d2, …, d num Each question chain d consists of a multi-hop triple, that is, a question entity set E = {e1, e2, …, e l}, the length of each question chain d is l=5;
[0072] Step 1.2: Traverse all question entities in the question knowledge graph G, add the question chain set D′ obtained for each question entity e to the question chain dataset D, and obtain the question chain dataset D corresponding to the question knowledge graph G = {d1, d2, …, d O}, where the total number of question chains O = 179482.
[0073] The step 2 is further specifically as follows:
[0074] Step 2.1: Segment each question entity e and remove stop words and other preprocessing to obtain the segmentation set C = {c1, c2, ..., c n}, where n represents the number of words contained in each question entity e after preprocessing.
[0075] Step 2.2: The word segmentation set C obtained in step 2.1 is represented by the initial vector through the GloVe pre-training model to obtain the word vector set W = {w1, w2, ..., w n}, where the word vector w is represented as:
[0076] w = GloVe(c) (1) where GloVe is the word vector expression function of the GloVe pre-trained model, and the word dimension of w is 200 dimensions.
[0077] Step 2.3: Based on the word vector set W obtained in step 2.2, the initial vector set Q of the question entity of each question chain d is obtained by weighted averaging the word vectors W of the word set C in the question entity e. l}, where the initial vector q of the question entity e is expressed as:
[0078]
[0079] Step 2.4: For each question chain d, use the information of the first l-1 question entities as the fusion head entity S of the question chain d, and its initial vector h S It is expressed as:
[0080]
[0081] Among them, i represents the question entity e i The position ranking is calculated from the initial node in the question chain d. The fusion process of the fusion head entity S is shown in the following figure. Figure 3 shown.
[0082] Step 2.5: For each question chain d, take the lth question entity as the tail entity e to be tested j , whose vector h j It is expressed as:
[0083] h j =q l (4)
[0084] The step 3 is further specifically as follows:
[0085] Step 3.1: transform the fusion head entity vector h of step 2.4 S and the tail entity vector h to be measured in step 2.5 j Send it to the question knowledge graph representation learning module based on graph attention to calculate the fusion head entity S and the tail entity e to be tested in the question chain d j The attention coefficient α Sj , the formula is:
[0086]
[0087] b Sj =LeakyReLU(W2c Sj ) (6)
[0088] c Sj =W1[h S||h j ||g r ] (7) Among them, g r It is the fusion head entity S and the tail entity e to be tested j The embedding vector of the relationship r, W1, W2 represent linear transformation matrices, || represents the connection symbol, c Sj Indicates the fusion head entity S and the tail entity to be tested e j The weighted linear combination of the triples, b Sj Indicates the fusion head entity S and the tail entity to be tested e j The relative attention matrix, N S represents the set of entities adjacent to the fusion head entity S, e n Belongs to N S The entity b Sn Represents the fusion of head entity S and entity e n The relative attention matrix of .
[0089] Step 3.2: Based on the weighted linear combination c obtained in step 3.1 Sj And the relative attention value α Sj , calculate the representation vector h' of the fusion head entity S obtained after the question knowledge graph representation learning module based on graph attention S :
[0090]
[0091] Here, σ represents an arbitrary nonlinear function and M represents the number of independent attention layers.
[0092] Step 3.3: The initial vector h of the fusion head node S based on step 2.4 S The representation vector h' from step 3.2 S calculate
[0093] The final representation vector h of the fused head entity S" S , the formula is:
[0094] h” S =W E h S +h' S (9)
[0095] Among them, W E is the linear transformation matrix that needs to be trained.
[0096] The technical framework diagram of step 2 and step 3 is attached Figure 2 shown.
[0097] The step 4 is further specifically as follows:
[0098] Step 4.1: The final representation vector h of the fusion head entity S in step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r Send it to the question chain relationship discriminator based on convKB to calculate the fusion head entity S and the tail entity e to be tested j Is there a scoring function for whether there is a chain relationship The calculation method is as follows:
[0099]
[0100] in, Indicates the fusion of the head entity S and the tail entity e to be tested j The chain of prediction questions, ω m represents the mth convolution filter, Ω represents the hyperparameter of the number of filters in the model, * is the convolution operator, and W is the linear transformation matrix. s Represents the last node e in the fusion head entity S s The difficulty level of the question j Indicates the tail entity to be tested e j The difficulty coefficient of the question.
[0101] Step 4.2: Score function based on step 4.1 Calculate the loss L of the downstream task of the QCG-KGLP model main :
[0102]
[0103] in, Indicates the fusion of the head entity S and the tail entity e to be tested j The chain of prediction questions is composed of When Sj =-1; when When Sj = 1. J represents a correct set of question chains, and J' represents an incorrect set of question chains.
[0104] Step 4.3: The final representation vector h of the fused head entity S based on step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r , calculate the loss L of the question knowledge graph representation learning module based on graph attention in the QCG-KGLP model reg :
[0105]
[0106]
[0107] in, Indicates the correct question chain data, represents the wrong question chain data, J is the correct question chain set, J' is the incorrect question chain set, Indicates h" S +g r With h j The L1 distance, Indicates error problem chain data "middle h" S +g r With h j The L1 distance, Indicates correct question chain data "middle h" S +g r With h j L1 distance, γ>0 is a marginal hyperparameter.
[0108] Step 4.4: Based on steps 4.2 and 4.3, calculate the total loss function L of the QCG-KGLP model:
[0109] L=L main +γ∑ n L reg (14) where the regularization coefficient γ is used to balance the loss L of the downstream task. main The graph represents the learning loss L reg .
[0110] Step 4.5, minimize the total loss function L (Formula 14), and update the network parameters until the maximum number of iterations T is reached. In the experiment, the question chain dataset is randomly divided into training set, validation set and test set in a ratio of 6:2:2. The initial parameter of L2 regularization setting in the graph attention mechanism model is 5e-6. The maximum number of iterations T of graph attention mechanism training is set to 3600, and the number of training epochs is 3000. The graph attention mechanism model uses Adam optimizer on the training set and the weight decay is set to 0.00001, and its training batch size is set to 86835. The initial parameter of L2 regularization setting in the convKB module is 1e-5. The maximum number of iterations T of the convKB module is set to 200, the number of epochs is 200, and the dropout probability of the convolutional layer is set to 0.3. Finally, the trained QCG-KGLP model is obtained.
[0111] Step 4.6: Input a test problem chain data testd and a tail entity to be tested e j. Combine the head entity S of testd with the tail entity e to be tested j Input into the trained QCG-KGLP model to output the prediction results like Represents the test problem chain data testd and the tail entity to be tested e j Construct a chain of questions, if Indicates that the question chain is not established.
[0112] The effectiveness of the QCG-KGLP model uses three types of baseline models: the first type is the translation model-based algorithm TransE, the second type is the knowledge graph completion algorithm DisMult and ComplEx based on semantic matching, and the third type is the knowledge graph completion algorithm ConvE, ConvKB, and R-GCN based on neural networks. The detailed description of all baseline models is shown in Table 1. The experimental comparison results of the QCG-KGLP model and the baseline model are shown in Table 2. MRR (Mean Reciprocal Rank), MR (Mean Rank) and Hits@k are used as evaluation indicators to evaluate the performance of the model.
[0113] Table 1 Baseline model settings
[0114]
[0115]
[0116] Table 2 Evaluation results of question chain dataset
[0117]
[0118]
[0119] At this point, the question chain generation method based on knowledge graph relationship prediction is complete. It is not difficult to find that the present invention uses Graph Attention to better integrate domain information into knowledge representation, and designs a question chain relationship discriminator based on convKB for question chain generation scenarios, which can better generate interrelated and gradient question chains, and at the same time construct a feature fusion function to comprehensively consider the semantic relationship and sequential relationship of the entire question chain, which can provide teachers with the question data support required for educational questions.
[0120] See also Figure 4 As shown, a question chain generation system based on knowledge graph relationship prediction includes:
[0121] A question chain dataset construction module 401 is used to construct a question chain dataset based on the question knowledge graph;
[0122] An initial vector acquisition module 402 is used to initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through a feature fusion method;
[0123] The representation vector acquisition module 403 is used to send the initial vectors of the fused head entity and the tail entity to be tested into the Graph Attention graph representation learning module of the QCG-KGLP model, so as to obtain the representation vectors of the fused head entity and the tail entity to be tested;
[0124] The question chain generation module 404 is used to input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation.
[0125] A specific implementation of a question chain generation system based on knowledge graph relationship prediction and a method for generating a question chain based on knowledge graph relationship prediction will not be repeated in this embodiment.
[0126] The above is only a specific implementation of the present invention, but the design concept of the present invention is not limited to this. Any non-substantial changes to the present invention using this concept shall be deemed as an infringement of the protection scope of the present invention.
Claims
1. A question chain generation method based on knowledge graph relationship prediction, characterized in that: The steps include: Step 1: Construct a question chain dataset based on the question knowledge graph; Step 2: Initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through the feature fusion method; Step 3: Send the initial vectors of the fused head entity and the tail entity to be tested into the Graph Attention graph representation learning module of the QCG-KGLP model to obtain the representation vectors of the fused head entity and the tail entity to be tested; Step 4: Input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation; The step 1 specifically includes: Step 1.1: Given a question knowledge graph G, the question knowledge graph G contains a question entity set H = [e1, e2, ..., e N }, where N is the number of entities in the question knowledge graph G; starting from any question entity e, we grab num question chains along the graph topology and obtain the question chain set D′=[d1, d2, ..., d num }, where each question chain d consists of a multi-hop triple, i.e., a question entity set E = [e1, e2, ..., e l }, l represents the length of each question chain d; where N>l, the set corresponding to l belongs to a subset of N; Step 1.2: Traverse all question entities in the question knowledge graph G, add the question chain set D′ obtained from each question entity e in the question entity set H to the question chain dataset D, and obtain the question chain dataset D corresponding to the question knowledge graph G = [d1, d2, ..., d O }, where O is the total number of question chains; The step 2 specifically includes: Step 2.1: Segment each question entity e and remove stop words to obtain the segmentation set C = [c1, c2, ..., c n }, where n represents the number of words contained in each question entity e after preprocessing; Step 2.2: The word segmentation set C obtained in step 2.1 is represented by the initial vector through the GloVe pre-training model to obtain the word vector set W = [w1, w2, ..., w n }, where the word vector w is represented as: w=GloVe(c) (1) Among them, GloVe is the word vector expression function of the GloVe pre-training model; Step 2.3: Based on the word vector set W obtained in step 2.2, the initial vector set Q of the question entity of each question chain d is obtained by weighted averaging the word vector set W of the word set C in the question entity e. l }, where the initial vector q of the question entity e is expressed as: Step 2.4: For each question chain d, use the information of the first l-1 question entities as the fusion head entity S of the question chain d, and its initial vector h S It is expressed as: Among them, i represents the question entity e i Position ranking in question chain d, calculated from the initial node; Step 2.5: For each question chain d, take the lth question entity as the tail entity e to be tested j , whose vector h j It is expressed as: h j =q l (4)。 2. The question chain generation method based on knowledge graph relationship prediction according to claim 1 is characterized in that: The step 3 specifically includes: Step 3.1: The initial vector h of the fusion head entity in step 2.4 S and the tail entity vector h to be measured in step 2.5 j Send it to the question knowledge graph representation learning module based on graph attention to calculate the fusion head entity S and the tail entity e to be tested in the question chain d j The attention coefficient α Sj , the formula is: b Sj =LeakyReLU(W2c Sj ) (6) c Sj =W1[h S ||h j ||g r ] (7) Among them, the relationship vector g r It is the fusion head entity S and the tail entity e to be tested j The embedding vector of the relationship r, W1, W2 represent linear transformation matrices, || represents the connection symbol, c Sj Indicates the fusion head entity S and the tail entity to be tested e j The weighted linear combination of the triples, b Sj Indicates the fusion head entity S and the tail entity to be tested e j The relative attention matrix, N S represents the set of entities adjacent to the fusion head entity S, e n Belongs to N S Entity, b Sn Represents the fusion of head entity S and entity e n The relative attention matrix of Step 3.2: Based on the fusion head entity S obtained in step 3.1 and the tail entity e to be tested j The weighted linear combination c Sj And the attention coefficient α Sj , calculate the representation vector h' of the fusion head entity S obtained after the question knowledge graph representation learning module based on graph attention S : Where σ represents an arbitrary nonlinear function and M represents the number of independent attention layers; Step 3.3: The initial vector h of the fusion head node S based on step 2.4 S The representation vector h' from step 3.2 S , calculate the final representation vector h of the fused head entity S" S , which is calculated as: h” S =W E h S +h’ S (9) Among them, W E is the linear transformation matrix that needs to be trained.
3. The question chain generation method based on knowledge graph relationship prediction according to claim 2 is characterized in that: The step 4 specifically includes: Step 4.1: The final representation vector h of the fusion head entity S in step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r Send it to the question chain relationship discriminator based on convKB to calculate the fusion head entity S and the tail entity e to be tested j Is there a scoring function for whether there is a chain relationship The calculation method is as follows: in, Indicates the fusion of the head entity S and the tail entity e to be tested j The chain of prediction questions, ω m represents the mth convolution filter, Ω represents the hyperparameter of the number of filters in the model, * is the convolution operator, W is the linear transformation matrix, level s Represents the last node e in the fusion head entity S s The difficulty level of the question j Indicates the tail entity to be tested e j The difficulty coefficient of the questions; Step 4.2: Score function based on step 4.1 Calculate the loss L of the downstream task of the QCG-KGLP model main : in, Indicates the fusion of the head entity S and the tail entity e to be tested j The chain of prediction questions is composed of When Sj =-1; when When Sj =1; J represents a correct set of question chains, and J' represents an incorrect set of question chains; Step 4.3: The final representation vector h of the fused head entity S based on step 3.3 S , the tail entity vector h to be measured in step 2.5 j And the relationship vector g r , calculate the loss L of the question knowledge graph representation learning module based on graph attention in the QCG-KGLP model reg : in, Indicates the correct question chain data, represents the wrong question chain data, J is the correct question chain set, and J' is the incorrect question chain set. Indicates h" S +g r With h j The L1 distance, Indicates error problem chain data "middle h" S +g r With h j The L1 distance, Indicates correct question chain data "middle h" S +g r With h j L1 distance, γ>0 is a marginal hyperparameter; Step 4.4: Based on steps 4.2 and 4.3, calculate the total loss function L of the QCG-KGLP model: L=L main +γ∑ n L reg (14) Among them, the regularization coefficient γ is used to balance the loss L of the downstream task main The graph represents the learning loss L reg ; Step 4.5, minimize the total loss function L, update the network parameters until the maximum number of iterations T is reached, and obtain the trained QCG-KGLP model; Step 4.6: Input a test problem chain data testd and a tail entity to be tested e j , merge the head entity S of testd with the tail entity e to be tested j Input into the trained QCG-KGLP model and output the prediction result like Represents the test problem chain data testd and the tail entity to be tested e j Construct a chain of questions. Indicates that the question chain is not established.
4. A question chain generation system based on knowledge graph relationship prediction, characterized in that: include: The question chain dataset construction module is used to construct the question chain dataset based on the question knowledge graph; The initial vector acquisition module is used to initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through a feature fusion method; The representation vector acquisition module is used to send the initial vectors of the fused head entity and the tail entity to be tested into the Graph Attention graph representation learning module of the QCG-KGLP model, so as to obtain the representation vectors of the fused head entity and the tail entity to be tested; The question chain generation module is used to input the representation vectors of the fused head entity and the tail entity to be tested into the convKB module of the QCG-KGLP model for link prediction, thereby realizing question chain generation; The question chain dataset is constructed based on the question knowledge graph, including: Given a question knowledge graph G, the question knowledge graph G contains a question entity set H = [e1, e2, ..., e N }, where N is the number of entities in the question knowledge graph G; starting from any question entity e, we grab num question chains along the graph topology and obtain the question chain set D′=[d1, d2, ..., d num }, where each question chain d consists of a multi-hop triple, i.e., a question entity set E = [e1, e2, ..., e l }, l represents the length of each question chain d; where N>l, the set corresponding to l belongs to a subset of N; Traverse all question entities in the question knowledge graph G, add the question chain set D′ obtained for each question entity e in the question entity set H to the question chain dataset D, and obtain the question chain dataset D corresponding to the question knowledge graph G = [d1, d2, ..., d O }, where O is the total number of question chains; Initialize the features of the question entity of the question chain, and obtain the initial vectors of the fused head entity and the tail entity to be tested of the question chain through the feature fusion method, specifically including: Each question entity e is segmented and preprocessed by removing stop words to obtain the segmentation set C = [c1, c2, ..., c n }, where n represents the number of words contained in each question entity e after preprocessing; The obtained word segmentation set C is represented by the initial vector through the GloVe pre-training model to obtain the word vector set W = [w1, w2, ..., w n }, where the word vector w is represented as: w=GloVe(c) (1) Among them, GloVe is the word vector expression function of the GloVe pre-training model; Based on the obtained word vector set W, the initial vector set Q = [q1, q2, ..., q l }, where the initial vector q of the question entity e is expressed as: For each question chain d, the information of the first l-1 question entities is used as the fusion head entity S of the question chain d, and its initial vector h S It is expressed as: Among them, i represents the question entity e i Position ranking in question chain d, calculated from the initial node; For each question chain d, the lth question entity is used as the tail entity e to be tested j , whose vector h j It is expressed as: h j =q l (4)。
Citation Information
Patent Citations
Model training method, dialogue generation method and device, equipment and medium
CN110188182A
Knowledge graph representation learning method for integrating text semantic features based on attention mechanism
CN110334219A
