Question generation method, generation device, computer equipment and storage medium
Patent Information
- Application Number
- CN202211575166.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2042-12-08
AI Technical Summary
对于较为复杂的问题,例如知识图谱中子图生成多约束条件的前置问题,或者是知识图谱中的多跳问题构成的复杂问句,就显得无能为力了
[0028]本发明的附加方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本发明的实践了解到。
Smart Images

Figure CN115983249B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing application technology, and in particular to a question generation method, generation device, computer equipment, and storage medium based on knowledge graphs. Background Technology
[0002] Modern smart devices, under certain conditions, will broadcast short introductory texts related to the context, such as a smart speaker indicating that food is cooked or a smart car passing through Huangshan. To further enhance the user experience, these broadcast texts often involve interactive voice communication. This involves automatically generating questions from the text's semantic content, creating natural language questions based on the input, and ensuring that the generated questions can be answered using the input. Currently, knowledge graph-based question generation methods can only generate simple questions, such as asking about one element of a triple in the knowledge graph. They are inadequate for more complex questions, such as preconditions with multiple constraints generated from subgraphs in the knowledge graph, or complex questions composed of multi-hop problems within the knowledge graph. Summary of the Invention
[0003] This application provides a knowledge graph-based question generation method, generation apparatus, computer equipment, and storage medium.
[0004] The knowledge graph-based question generation method of this application includes: acquiring input content and identifying entities in the input content; acquiring multiple triples related to the entities in the knowledge graph and constructing a description of the multiple triples as a whole; encoding each triple using an encoder and obtaining the weight of each triple in each construction description and the relational distance in the construction description; and decoding the multiple triples using a decoder based on the weights and relational distances to generate a question.
[0005] In the knowledge graph-based question generation method of this application, multiple triples are decoded and complex questions are generated based on weights and relational distances using a decoder, thereby providing convenience for users.
[0006] In some implementations, when obtaining multiple triples related to entities in a knowledge graph and constructing a general description of these triples, the triples are described using the following formula: F =<s,p,o> Here, F represents the triple description, s represents the subject entity, p represents the predicate entity, and o represents the object entity. This allows for a comprehensive construction description of the triple, facilitating the calculation of weights.
[0007] In some implementations, each triple is encoded using an encoder to obtain the weight of each tuple in each construct description and the relational distance in the construct description, including: using the Attention layer in BiLSTM to jointly calculate the weights of the tuples in the triple and the construct description of the triple; and using the TransR model to determine the relational distance in the triple description.
[0008] Thus, by jointly calculating the weights of the tuples in the triples and their construction descriptions using the Attention layer in BiLSTM, and by determining the relational distances in the triple descriptions using the TransR model, complex problems can be generated.
[0009] In some implementations, the TransR model is used to determine the relation distance in the triple description, including: determining the head entity vector and the tail entity vector of the triple; mapping the head entity vector and the tail entity vector to the r relation space; and using the TransR model to determine the r relation distance between the head entity vector and the tail entity vector.
[0010] Thus, based on the head entity vector and tail entity vector of the triple, the head entity vector and tail entity vector can be mapped to the r-relation space. The TransR model can be used to determine the r-relation distance between the head entity vector and the tail entity vector, thereby solving the problems of reflexive, many-to-one and one-to-many types of relations in traditional displacement models.
[0011] In some implementations, a decoder is used to decode multiple triples and generate a question based on weights and relational distance, including: using an LSTM model to determine the current state of each triple in each constructed description based on relational distance; calculating the attention weight of each triple in the constructed description; and generating a question based on the current state and attention weight.
[0012] In this way, the LSTM model can be used to determine the current state of each tuple in each construct description based on the relational distance, and the attention weight of each tuple in the construct description can be calculated, so that the problem can be generated based on the current state and the attention weight.
[0013] In some implementations, the current state of the decoder is determined according to the following formula:
[0014] S t =LSTM(S t-1 Q t-1 )
[0015] Among them, S t t represents the current state of the decoder, t represents the current time step, LSTM represents the model, and Q represents the generated question.
[0016] Thus, the current state of the decoder can be determined according to the formula.
[0017] In some implementations, the attention weights are determined according to the following formula:
[0018]
[0019] Among them, a t To note the weights, e represents the entity, t represents the current time, k represents the triple, and s, p, and o are all tuples.
[0020] Thus, the attention weight of each element in the triple can be calculated according to the formula.
[0021] In some implementations, the problem is determined according to the following formula:
[0022]
[0023] Where P is the probability of generating the question, Q is the generated question, and Q' ...""""," where P is the probability of generating the question, Q'''''''''''''''''''''''''''''''''''''' <t For the previous problem of the current problem, F is the construction description, t is the current time, T is the overall time period, W is the weight, and the vectorization is v, s t c represents the current state of the decoder. t W is the set of complex numbers currently being reverse-analyzed. g It involves estimating the weights of each subgraph, W. g s t It involves estimating the subgraph of the current state, W. g c t It involves estimating the subgraph of the complex set obtained from the current reverse analysis.
[0024] Thus, the problem to be generated can be determined according to the formula.
[0025] This application provides a generation apparatus, comprising: an acquisition module for acquiring input content and identifying entities in the input content; and for acquiring multiple triples related to the entities in a knowledge graph and constructing an overall description of the multiple triples; a processing module for encoding each triple using an encoder and obtaining the weight of each triple in each construction description and the relational distance in the construction description; and a generation module for decoding the multiple triples using a decoder based on the weights and relational distances and generating a question.
[0026] This application provides a computer device, which includes a memory and a processor connected to the memory. The memory is used to store a computer program, and the processor is used to execute the computer program to implement the method of any of the above embodiments.
[0027] This application provides a non-volatile computer-readable storage medium with computer-executable instructions that, when executed by one or more processors, cause the processors to perform the methods of any of the above embodiments.
[0028] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0029] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0030] Figure 1 This is a flowchart illustrating the knowledge graph-based question generation method in the embodiments of this application;
[0031] Figure 2 This is a schematic diagram of the generation device in the embodiments of this application;
[0032] Figure 3 This is a schematic diagram of the computer device in the embodiments of this application;
[0033] Figure 4 This is a schematic diagram of a triple example in the knowledge graph-based question generation method of this application;
[0034] Figure 5 This is a flowchart illustrating the knowledge graph-based question generation method in the embodiments of this application;
[0035] Figure 6 This is a training diagram of the TransR method in the embodiments of this application;
[0036] Figure 7 This is a flowchart illustrating the knowledge graph-based question generation method in the embodiments of this application;
[0037] Figure 8 This is a flowchart illustrating the knowledge graph-based question generation method in the embodiments of this application;
[0038] Figure 9 This is a schematic diagram illustrating an example of a knowledge graph-based question generation method in the embodiments of this application;
[0039] Figure 10 This is a schematic diagram illustrating an example of a knowledge graph-based question generation method in the embodiments of this application;
[0040] Figure 11 This is a schematic diagram illustrating an example of a knowledge graph-based question generation method in the embodiments of this application.
[0041] Explanation of key component symbols: Computer device 100, memory 11, processor 12, generation device 200, acquisition module 21, processing module 22, generation module 23, subject entity 31, predicate entity 32, object entity 33. Detailed Implementation
[0042] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0043] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0044] The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the invention. Furthermore, reference numerals and / or letters may be repeated in different examples; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0045] Please see Figure 1 This application provides a knowledge graph-based question generation method, which includes:
[0046] S10, acquire the input content and identify entities in the input content;
[0047] S20: Obtain multiple triples related to entities in the knowledge graph and construct a description of the multiple triples as a whole.
[0048] S30, use the encoder to encode each triplet and obtain the weight of each triplet in each construction description and the relational distance in the construction description;
[0049] S40, based on weights and relational distance, uses a decoder to decode multiple triples and generate questions.
[0050] Please see Figure 2This application provides a generation device 200, which includes an acquisition module 21, a processing module 22, and a generation module 23. The control module is used to acquire input content and identify entities within the input content; and to acquire multiple triples related to the entities in a knowledge graph and construct an overall description of the multiple triples. The processing module 22 is used to encode each triple using an encoder and obtain the weight of each tuple in each constructed description and the relational distance in the constructed description. The generation module 23 is used to decode the multiple triples using a decoder based on the weights and relational distances and generate a question.
[0051] Please see Figure 3 This application provides a computer device 100, which includes a memory 11 and a processor 12 connected to the memory 11. The memory 11 is used to store computer programs, and the processor 12 is used to acquire input content and identify entities in the input content; to acquire multiple triples related to entities in a knowledge graph and to construct a description of the multiple triples as a whole; to encode each triple using an encoder and to obtain the weight of each triple in each construction description and the relational distance in the construction description; and to decode the multiple triples using a decoder based on the weights and relational distances and to generate a question.
[0052] In the knowledge graph-based question generation method of this application, the triples are first constructed and described as a whole, and then multiple triples are decoded by a decoder based on weights and relational distances, thereby generating complex questions and providing convenience for users.
[0053] Specifically, in the library and information science field, knowledge graphs are referred to as knowledge domain visualization or knowledge domain mapping maps. They are a series of various graphics that display the development process and structural relationships of knowledge. They use visualization techniques to describe knowledge resources and their carriers, and to mine, analyze, construct, draw, and display knowledge and the interrelationships between them. Knowledge graphs are a modern theory that combines theories and methods from applied mathematics, computer graphics, information visualization technology, and information science with methods such as bibliometric citation analysis and co-occurrence analysis. They utilize visualized graphs to vividly display the core structure, development history, cutting-edge fields, and overall knowledge architecture of a discipline, achieving the goal of multidisciplinary integration.
[0054] In step S10, the input content can be the content input by the user during application after the input content model has been trained. However, the corpus used during model training is the historical corpus input by the user. An entity refers to a distinguishable and independently existing thing, such as a person, a city, a plant, or a product. Entities are the most basic elements in a knowledge graph, and different entities have different relationships.
[0055] In step S20, multiple triples related to entities are obtained from the knowledge graph, and a comprehensive description of these triples is constructed. For example, when constructing a complex question generation system, it is necessary to first obtain <knowledge graph subgraph, triple question set> as training corpus. Here, a knowledge graph subgraph refers to triples in multiple knowledge graphs.
[0056] Taking multi-hop as an example, such as Figure 4 As shown: the third tuple in each triplet is virtually connected to the first tuple in the new triplet. That is, each independent triplet can be discrete, and this virtual connection may not have any direct logical relationship; it's only for convenience in subsequent calculations. The path in the graph may only be one path from the first tuple in the first triplet to the third tuple in the third triplet. This path may not be unique. Figure 1 The intermediate independent triples in the path may not be unique; there may be other independent triples forming the path links at both ends along the way.
[0057] In step 30, an encoder can be used to encode each triple and obtain the weight of each triple in each construct description and the relational distance in the construct description.
[0058] In one example, multiple triples can be constructed and described as a whole using KoPL (a knowledge-oriented reasoning and question-answering programming language). Each independent triple in the construction description is represented by F, where F =<s,p,o> , where s represents subject entity 31, p represents predicate entity 32, and o represents object entity 33. The goal of the natural language question generation task is to ensure that the answer to the natural language question is the third tuple o in the last triplet, which is o in the last F. The first tuple of the first triplet should be the initial entity involved first. The encoder converts the KoPL language description constructed by multiple Fs into a unified vector, that is, it performs joint calculation on the atoms (i.e. entities) in multiple independent triplets with the previous KoPL sequence. The encoder of each F is equivalent to the encoder of s + the encoder of p + the encoder of o. As shown in formula (1):
[0059] Enc(F) = [Enc(F)]s ;·Enc(F) p ;·Enc(F) o 】……(1), where, in Formula 1, Enc(F) represents encoding a specific independent triple, i.e., Enc(F), as shown in Formula (2), the weight of the entity in KoPL can be obtained. Thus, the weight of the independent triple in KoPL is obtained as a vector value.
[0060] Enc(F) atom =W Enc e atom ……(2),
[0061] This allows us to extract the relational distances within each F.
[0062] In step S40, based on the weights and relational distances, a decoder can be used to decode multiple triples and generate a question. The decoder can be implemented using TransferNet, which calculates the distance between the entity in the last triple of the multi-hop question and the located point, along with a threshold. The distance refers to the defined distance from the initial node to the given point. TransferNet is a transparent and efficient framework for multi-hop question answering in relational graphs.
[0063] In some implementations, when obtaining multiple triples related to entities in a knowledge graph and constructing a general description of these triples, the triples are described using the following formula:
[0064] F =<s,p,o> ,
[0065] Where F represents a triplet description, s represents the subject entity 31, p represents the predicate entity 32, and o represents the object entity 33.
[0066] Thus, based on this formula, the triplet can be constructed as a whole, which makes it easier to calculate the weights.
[0067] Specifically, multiple triples can be constructed and described as a whole using the KoPL language. Each independent triple in the construction description is represented by F, where F =<s,p,o> , where s represents the subject entity 31, p represents the predicate entity 32, and o represents the object entity 33. The goal of the natural language question generation task is to ensure that the answer to the natural language question is the third tuple o in the last triplet, that is, o in the last F. The first tuple of the first triplet should be the initial entity involved first.
[0068] For example, the answer to a natural language question can be set to consist of four triples: ABC, DEF, GHI, and JKL. During the calculation, these triples will be treated as a whole, i.e., ABCDEFGHIJKL. Setting the answer as the last triple can clearly define the fixed position and source of the answer within the whole.
[0069] Please see Figure 5 In some implementations, the encoder is used to encode each triplet, and the weight of each triplet in each construct description and the relational distance in the construct description are obtained (step S30), including:
[0070] S31, the Attention layer in BiLSTM is used to jointly calculate the weights of the tuples in the triplet and the construction description of the triplet.
[0071] S32, using the TransR model to determine the relational distance in the triplet description.
[0072] In some implementations, the processing module 22 is used to jointly calculate the weights of the tuples in the triples and the construction description of the triples using the Attention layer in BiLSTM; and to use the TransR model to determine the relational distance in the triple description.
[0073] In some implementations, processor 12 is used to jointly compute the weights of the tuples in the triples and the construction description of the triples using the Attention layer in BiLSTM; and to use the TransR model to determine the relational distance in the triple description.
[0074] Thus, by jointly calculating the weights of the tuples in the triples and their construction descriptions using the Attention layer in BiLSTM, and by determining the relational distances in the triple descriptions using the TransR model, complex problems can be generated.
[0075] Specifically, in step S31, the Attention layer in a BiLSTM (Bidirectional Long Short-Term Memory) network can be used to jointly calculate the weights of the tuples in the triples and the construction description of the triples. For example, ats, atp, and atto represent three attention weights, indicating the magnitude of the weight of attention in each different polynomial. This is consistent with the degree of influence of s, p, and o in F on the t-th position word in the generated natural language question.
[0076] In step S32, the relational distance in the triplet description can be determined using the TransR model. For example, as... Figure 6As shown, TransR is used to extract the relational distance from each F. The TransR method determines that the entity and relation are in the same dimension. For example, the entity "apple" could be a type of fruit or a mobile phone brand. To determine the semantic domain of this entity, we need to use the relations in the entity's context. The method is to map the entity to a relational space through matrix calculation, and determine which dimension the entity belongs to by the different relations of other entities in the sentence context. As shown in formula (3):
[0077]
[0078] Please see Figure 7 In some implementations, determining the relational distance in the triplet description using the TransR model (step S32) includes:
[0079] S321, determine the head entity vector and tail entity vector of the triple;
[0080] S322 maps the head entity vector and tail entity vector to the r relation space.
[0081] S323 uses the TransR model to determine the r-relationship distance between the head entity vector and the tail entity vector.
[0082] In some implementations, processing module 22 is used to determine the head entity vector and tail entity vector of the triple; and to map the head entity vector and tail entity vector to the r-relation space; and to use the TransR model to determine the r-relation distance between the head entity vector and the tail entity vector.
[0083] In some implementations, processor 12 is used to determine the head entity vector and tail entity vector of the triple; and to map the head entity vector and tail entity vector to the r-relation space; and to use the TransR model to determine the r-relation distance between the head entity vector and the tail entity vector.
[0084] Thus, based on the head entity vector and tail entity vector of the triple, the head entity vector and tail entity vector can be mapped to the r-relation space. The TransR model can be used to determine the r-relation distance between the head entity vector and the tail entity vector, thereby solving the problems of reflexive, many-to-one and one-to-many types of relations in traditional displacement models.
[0085] Specifically, in step S321, the first tuple and the third tuple in an independent triple can be represented by vectors head and tail to represent the head entity and the tail entity, respectively, thereby determining the head entity vector and the tail entity vector of the triple.
[0086] In step S322, the head entity vector and tail entity vector can be mapped to the r relation space using the Mr matrix, where Mr represents the matrix to be learned. The goal of TransR model training is to make the distance between the task target hr and entities with r relations as close as possible, and the distance between it and entities without r relations as far as possible, i.e., hr + r ≈ tr
[0087] In step S323, the TransR model is used. TransR projects entities onto the vector space to which the relation belongs, and can determine the r relation distance between the head entity vector and the tail entity vector. After training with TransR, a number of r should be learned in the unified sequence, and the number of r data is equal to the number of F.
[0088] Please see Figure 8 In some implementations, based on weights and relational distances, the decoder decodes multiple triples and generates a question (step S40) including:
[0089] S41, using the LSTM model, determine the current state of each tuple in each construct description based on relational distance;
[0090] S42, calculate the attention weight of each tuple in the constructed description;
[0091] S43 generates a question based on the current state and attention weights.
[0092] In some implementations, the generation module 23 is used to determine the current state of each tuple in each construct description based on relational distance using an LSTM model; to calculate the attention weight of each tuple in the construct description; and to generate a question based on the current state and the attention weight.
[0093] In some implementations, processor 12 is used to utilize an LSTM model to determine the current state of each tuple in each construct description based on relational distance; to compute the attention weight of each tuple in the construct description; and to generate a question based on the current state and the attention weight.
[0094] In this way, the LSTM model can be used to determine the current state of each tuple in each construct description based on the relational distance, and the attention weight of each tuple in the construct description can be calculated, so that the problem can be generated based on the current state and the attention weight.
[0095] Specifically, in step S41, an LSTM model can be used to determine the current state of each tuple in each constructed description based on relational distances. For example, using an LSTM model, this can be accomplished by calculating the distance and a threshold between the entity in the last triplet in a multi-hop problem and the located point t, where the distance to point t is the defined distance from the initial node to the given point t, denoted by t.
[0096] In step S42, the attention weight of each tuple in the construction description can be calculated. The attention weight is consistent with the degree of influence of s, p, and o in F on the word at position t in the generated natural language question.
[0097] In step S43, a question can be generated based on the current state and attention weights, where the current state refers to the current state of the encoder.
[0098] In some implementations, the current state of the decoder is determined according to the following formula (4):
[0099] S t =LSTM(S t-1 Q t-1 )……(4),
[0100] Among them, S t t represents the current state of the decoder, t represents the current time step, LSTM represents the model, and Q represents the generated question.
[0101] Thus, the current state of the decoder can be determined according to formula (4).
[0102] Specifically, using an LSTM model, the problem is solved by calculating the distance and a threshold between the entity in the last triplet of the multi-hop problem and the located point t. The distance to point t refers to the limited distance from the initial node to the given point t, denoted by t. The decoder determines the length of the subgraph, which in turn determines the complexity of problem generation.
[0103] In some implementations, the attention weights are determined according to the following formula (5):
[0104]
[0105] Among them, a t For attention weights, e represents the entity, t represents the current time step, k represents the triple, and s, p, and o are all tuples. Thus, the attention weight of each element in the triple can be calculated using the formula.
[0106] Specifically, a tThis represents the attention weights, where "attention" is short for attention, a term in deep learning. Attention is further divided into hard attention and soft attention; here, soft attention is used, representing the weight of attention in each distinct polynomial. This is consistent with the degree of influence of s, p, and o in F on the t-th position of the generated natural language word.
[0107] e tk The meaning is the weight of entities within the range from point t to point k, such as e. tk Evolutionary formula (6):
[0108]
[0109] Where F represents an independent triple.<s,p,o> Encoding is performed on specific independent triples, i.e., Enc(F), where k is an index representing a position. Many Enc(F)k sets should have different attention mechanisms, denoted by 'a'. All these sets are combined into a joint set, denoted by U, i.e., UaEnc(F)k.
[0110] W is the weight, Wa is the weight estimate for each attention, and St represents the current state. a s t-1 This represents the estimation of the previous state for the current state. An intercept is set to control the image of UaEnc(F)k. tanh is the hyperbolic tangent function, which applies the hyperbolic tangent to the content in parentheses. Finally, these are transformed and vectorized; the transformed value is t, and the vectorized value is v, i.e., v^t.
[0111] In some implementations, the problem is determined according to the following formula (7):
[0112]
[0113] Where P is the probability of generating the question, Q is the generated question, and Q' ...""""," where P is the probability of generating the question, Q'''''''''''''''''''''''''''''''''''''' <t For the previous problem of the current problem, F is the construction description, t is the current time, T is the overall time period, W is the weight, v is the vectorization, and s t c represents the current state of the decoder. t W is the set of complex numbers currently being reverse-analyzed. g It involves estimating the weights of each subgraph, W. g s t It involves estimating the subgraph of the current state, W. gc t This involves estimating the subgraph of the complex set from the current reverse analysis. Thus, the generated problem can be determined according to the formula.
[0114] Specifically, P is the probability of the problem being generated, F is the construction description, and t is the current time. Reverse analysis of F yields a set of complex numbers, as shown in formula (8):
[0115] C t =a ts Enc(F) s +a tp Enc(F) p +a to Enc(F) o ……(8),
[0116] Among them, a ts a tp and a to These represent three attention weights, which encode specific independent triples, i.e., Enc(F). This allows us to calculate the weight of each element in F, and then, based on the current state of the decoder and the set of complex numbers in the reverse parsing, we can derive the generation method for complex problems.
[0117] In one example, when constructing complex question generation, it is necessary to first obtain <knowledge graph subgraph, triple question set> as training corpus. Here, a knowledge graph subgraph refers to triples from multiple knowledge graphs. Starting from a certain entity (a node in the knowledge graph), a random walk is performed; the path length of the walk is linearly related to the number and complexity of the generated natural language questions. The KoPL language is used to construct and describe the multiple triples as a whole. Each independent triple in the construction description is represented by F, where F = ...<s,p,o> , where s represents the subject entity 31, p represents the predicate entity 32, and o represents the object entity 33. The goal of the natural language question generation task is to ensure that the answer to the natural language question is the third tuple o in the last triplet, which is o in the last F. The first tuple of the first triplet should be the initial entity 5 that is involved first.
[0118] Next, an encoder-decoder framework is used to complete the generation task of the above complex problem. The encoder converts the KoPL language description constructed by multiple Fs into a unified vector. The method is as follows: First, BiLSTM+Attention is used to jointly compute the atoms (i.e., entities e) in multiple independent triples with the previous KoPL sequence, that is, the encoder of each F is equivalent to the encoder of s + the encoder of p + the encoder of o. As shown in formula (1):
[0119] Enc(F) = [Enc(F)] s ;·Enc(F) p ;·Enc(F) o ]……(1),
[0120] The weights of entity e in KoPL are obtained, and thus the weights of independent triples in KoPL are obtained as vector values, as shown in formula (2):
[0121] Enc(F) atom =W Enc e atom ……(2),
[0122] Next, TransR is used to extract the relation distances within each F. The calculation method is as follows: the first and third tuples of an independent triple are represented by vectors head and tail, respectively, to represent the head and tail entities, and Mr represents the matrix to be learned. The head and tail entities are mapped to the relation space through the Mr matrix, making the distance between the task target hr and entities with the relationship r as close as possible, and the distance between it and entities without the relationship r as far as possible, i.e., hr + r ≈ tr. After training with TransR, a number of r values should be learned in the unified sequence, and the number of r values is equal to the number of F values.
[0123] Finally, the decoder is implemented using TransferNet. TransferNet's method involves using an LSTM model to calculate the distance and a threshold between the entity in the last triplet of the multi-hop problem and the located point t. The distance to point t refers to the limited distance from the initial node to the given point t, denoted by t. The current state of the decoder is determined by formula (4).
[0124] S t =LSTM(S t-1 Q t-1 )……(4),
[0125] Reverse analysis of F yields the set of complex numbers, which can be determined by formula (8).
[0126] C t =a ts Enc(F) s +a tp Enc(F) p +a to Enc(F) o ……(8),
[0127] Calculate the role weight (participation weight) of each element in F. Finally, derive the method for generating complex problems by reasoning from the current state of the decoder and the complex set obtained through reverse parsing.
[0128] In one example, suppose we want to generate the question "Of all the buttons in the front row, which ones are related to the sharing function?", the generated path would be as follows: Figure 9 As shown: In the subgraph of the knowledge graph, there are many kinds of objects in the front row of the vehicle, but only functional buttons (excluding switch buttons) are selected, and then the buttons with shared functions are associated with the functional buttons.
[0129] like Figure 10 As shown, with business requirements defined, the scope of the subgraph and the relevant set of triplet questions can be determined, and the encoder work can begin: each independent triplet is trained using TransR to determine the initial nodes and related questions, and then all KoPLs are generated, such as... Figure 11 As shown in the process diagram. Figure 5 The process first identifies entities related to the front row based on the semantic concept of "all in the front row," using a basis pre-defined during knowledge graph construction. Next, it identifies the "button" entity and generalizes to traverse all buttons in the sub-graph (a0), calculating the weight W1 for entities in the front row that are buttons. Then, it extracts functions with the "share" attribute based on semantics. This involves calculating the weight W1 from the front row to the button entity, multiplied by the generalized weight W2 from a1 = a0W1 to the "share" attribute, resulting in a2 = a1W2. Finally, the decoder tunes the parameter t, and through the attention mechanism and Enc(F) in the decoder, a specific question is obtained.
[0130] This application provides a non-volatile computer-readable storage medium with computer-executable instructions that, when executed by one or more processors 12, cause the processors 12 to perform the methods of any of the above embodiments.
[0131] Specifically, in one embodiment, the processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above types of chips.
[0132] Computer programs can be stored in memory. Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the methods in the above method embodiments. The processor executes various functional applications and data processing by running the non-transitory software programs, instructions, and modules stored in memory, thereby implementing the methods in the above method embodiments.
[0133] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The implemented program can be stored in a computer-readable storage medium. When executed, the program can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.
[0134] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with the described embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0135] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A question generation method based on knowledge graphs, characterized in that, include: Obtain the input content and identify the entities in the input content; Obtain multiple triples related to the entity from the knowledge graph and construct a description of the multiple triples as a whole; Each triplet is encoded using an encoder to obtain the weight of each triplet in each construct description and the relational distance in the construct description; Based on the weights and the relational distances, the decoder is used to decode the multiple triples and generate questions; The step of encoding each triplet using an encoder to obtain the weight of each triplet in each constructed description and the relational distance in the constructed description includes: The weights are determined by jointly calculating the tuples in the triplet and the construction description of the triplet using the Attention layer in BiLSTM. The TransR model is used to determine the relational distance in the triplet description.
2. The method according to claim 1, characterized in that, In the process of obtaining multiple triples related to the entity in the knowledge graph and constructing a comprehensive description of the multiple triples, the triples are described using the following formula: F=<s,p,o> , Where F represents a triple description, s represents the subject entity, p represents the predicate entity, and o represents the object entity.
3. The method according to claim 2, characterized in that, The determination of relational distances in the triplet description using the TransR model includes: Determine the head entity vector and tail entity vector of the triple; Map the head entity vector and the tail entity vector to the r relation space; The TransR model is used to determine the r-relationship distance between the head entity vector and the tail entity vector.
4. The method according to claim 2, characterized in that, The process of decoding the multiple triples and generating questions based on the weights and the relational distance using a decoder includes: Using an LSTM model, the current state of each tuple in each of the constructed descriptions is determined based on the relational distance; Calculate the attention weight for each tuple in the constructed description; A question is generated based on the current state and the attention weights.
5. The method according to claim 3, characterized in that, The current state of the decoder is determined according to the following formula: ( ) Among them, S t t represents the current state of the decoder, t represents the current time step, LSTM represents the model, and Q represents the generated question.
6. The method according to claim 3, characterized in that, Attention weights are determined according to the following formula: Among them, a t To note the weights, e represents the entity, t represents the current time, k represents the triple, and s, p, and o are all tuples. The weights of entities within the range from point t to point k.
7. The method according to claim 4, characterized in that, The problem is determined according to the following formula: Where P is the probability of generating the question, Q is the generated question, and Q' ...""""," where P is the probability of generating the question, Q'''''''''''''''''''''''''''''''''''''' <t For the previous problem of the current problem, F is the construction description, t is the current time, T is the overall time period, W is the weight, v is the vectorization, and s t c represents the current state of the decoder. t W is the set of complex numbers currently being reverse-analyzed. g It involves estimating the weights of each subgraph, W. g s t It involves estimating the subgraph of the current state, W. g c t It involves estimating the subgraph of the complex set obtained from the current reverse analysis.
8. A problem generation apparatus, said apparatus being used to implement the method according to any one of claims 1-7, characterized in that, include: The acquisition module is used to acquire input content and identify entities in the input content; And for obtaining multiple triples related to the entity in the knowledge graph and constructing a description of the multiple triples as a whole; The processing module is used to encode each triple using an encoder and obtain the weight of each triple in each construction description and the relational distance in the construction description. The generation module is used to decode the multiple triples and generate questions based on the weights and the relational distance using a decoder.
9. A computer device, characterized in that, The method includes a memory and a processor connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program to implement the method of any one of claims 1-7.
10. A non-volatile computer-readable storage medium with computer-executable instructions, characterized in that, When the computer-executable instructions are executed by one or more processors, the processors perform the method of any one of claims 1-7.
Citation Information
Patent Citations
Chinese question generation method based on two triples
CN111104517A
Question generation system based on knowledge graph and interrogative word driving
CN114168749A