A method and apparatus for generating questions based on multi-source knowledge fusion
By using a multi-source knowledge fusion method, questions are generated using pre-trained language models and open-source datasets, which solves the problem of poor fluency in existing technologies and achieves higher quality question generation.
Patent Information
- Application Number
- CN202510250100.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-03-04
AI Technical Summary
Existing question generation methods suffer from poor fluency because they rely on a single source of knowledge and cannot cover a wide range of semantic information.
By acquiring the input subgraph and open-source dataset, initial entity type information and question words are generated using a pre-built large-scale pre-trained language model. Target entity type information is then filtered using multi-layer filters, and auxiliary knowledge is integrated using an information fusion module to generate a complete representation. Finally, the decoder generates the target question.
It improves the fluency and accuracy of questions, enhances the content of generated questions through multi-source knowledge fusion, and significantly improves the quality of generated questions.
Smart Images

Figure CN120106222B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and apparatus for generating questions based on multi-source knowledge fusion. Background Technology
[0002] In recent years, with the rapid development of knowledge graph (KG) and natural language processing technologies, knowledge-based question generation (KBQG) has gradually become an important research direction. KBQG aims to extract information from knowledge graphs and generate relevant questions to provide a more natural interactive experience in dialogue systems and information retrieval, and has wide applications in both academia and industry.
[0003] Research on Keyword Question Generation (KBQG) can be divided into two categories. The first category is structure-information-based KBQG. Initially, it heavily relied on manually created question templates for question generation. Subsequent improvements adopted a fully data-driven end-to-end approach, utilizing neural networks to generate labeled sequences of natural language questions, focusing on generating multi-hop complex questions by effectively modeling rich structures. The other category is external knowledge-enhanced KBQG. It enhances question generation by inputting external auxiliary knowledge (such as node attributes, interrogative words, and entity types) into the KG subgraph and designing fusion mechanisms to integrate the auxiliary knowledge with the KG subgraph.
[0004] Existing question generation methods mainly focus on a single type of knowledge base, which lacks sufficient reference knowledge. They cannot cover rich and diverse semantic information, contextual relationships, and various possible language expressions, which leads to logical incoherence, grammatical errors, or semantic ambiguity in the generated questions, resulting in poor fluency. Summary of the Invention
[0005] This invention provides a question generation method and apparatus based on multi-source knowledge fusion, which solves the technical problem that existing question generation methods result in poor fluency of the generated questions.
[0006] The first aspect of this invention provides a question generation method based on multi-source knowledge fusion, comprising:
[0007] Obtain the input subgraph and the open-source dataset;
[0008] A pre-built large-scale pre-trained language model is used to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open source dataset, and multiple pre-built manually constructed examples;
[0009] Multiple initial entity type information is filtered by a pre-set multi-layer filter to output multiple target entity type information;
[0010] Based on multiple target entity type information and the interrogative words of the input subgraph, auxiliary knowledge is generated, and a pre-set information fusion module outputs multiple complete representations based on the auxiliary knowledge and the input subgraph.
[0011] The complete representations are input into a preset decoder to generate the target question.
[0012] Optionally, the multiple initial entity type information includes multiple first initial entity type information and multiple second initial entity type information; the step of using a pre-set large-scale pre-trained language model to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open-source dataset, and multiple pre-set manually constructed examples includes:
[0013] Entity links are performed between the input subgraph and the open-source dataset to generate multiple first initial entity type information;
[0014] The input subgraph and multiple pre-built artificial examples are input into the pre-built large-scale pre-trained language model, which outputs multiple second initial entity type information and input subgraph interrogative words.
[0015] Optionally, the step of filtering multiple initial entity type information through a pre-set multi-layer filter to output multiple target entity type information includes:
[0016] Embedding is performed on each of the first initial entity type information and each of the second initial entity type information respectively, and the first word embedding corresponding to each of the first initial entity type information and the second word embedding corresponding to each of the second initial entity type information are output.
[0017] A pre-set multi-layer filter is used to calculate multi-layer similarity scores based on each first word embedding and each second word embedding to determine multiple similarity scores between each first word embedding and each second word embedding;
[0018] The similarity scores between each first word embedding and each second word embedding are summed, and the summed similarity score between each first word embedding and each second word embedding is output.
[0019] Each summed similarity score is compared with a preset similarity score threshold.
[0020] The first initial entity type information and the second initial entity type information corresponding to any summation similarity score greater than the preset similarity score threshold are used as the target entity type information.
[0021] Optionally, the pre-defined information fusion module includes a pooling layer, a global encoder, and a residual layer; the pre-defined information fusion module outputs multiple complete representations based on the auxiliary knowledge and the input subgraph, including:
[0022] The auxiliary knowledge and the input subgraph are formatted respectively to generate a linearized subgraph and a text sequence;
[0023] A global encoder is used to generate multiple hidden states based on the linearized subgraph and the text sequence;
[0024] The pooling layer generates multiple entity representations, multiple interrogative word representations, and multiple entity type representations based on the multiple hidden states.
[0025] Based on semantic and structural attention mechanisms, multiple entity representations, multiple interrogative word representations, and multiple entity type representations are integrated to generate multiple intermediate representations;
[0026] A residual layer is used to generate multiple complete representations based on multiple intermediate representations and multiple hidden states.
[0027] Optionally, the training process of the preset decoder is as follows:
[0028] Obtain the subgraph to be trained and the open-source dataset;
[0029] A pre-built large-scale pre-trained language model is used to generate multiple entity type information and interrogative words for the subgraph to be trained based on the subgraph to be trained, the open source dataset, and multiple pre-built manually constructed examples;
[0030] Multiple training entity type information is filtered by a pre-set multi-layer filter to output multiple training target entity type information.
[0031] Based on the multiple target entity type information to be trained and the interrogative words of the subgraph to be trained, auxiliary knowledge to be trained is generated, and a pre-set information fusion module is used to output multiple complete representations to be trained based on the auxiliary knowledge to be trained and the subgraph to be trained.
[0032] Based on a pre-set cross-entropy loss function, the initial decoder is trained using multiple complete representations to be trained, thereby determining the trained pre-set decoder.
[0033] Optionally, the step of training the initial decoder using multiple complete representations to be trained based on a preset cross-entropy loss function to determine the trained preset decoder includes:
[0034] The multiple complete representations to be trained are input into the initial decoder to generate the questions to be trained;
[0035] Substitute the question to be trained into the preset cross-entropy loss function and take the derivative to output the model gradient;
[0036] Based on the adaptive moment estimation optimization algorithm, the model parameters of the initial decoder are updated using the model gradient to determine the intermediate decoder;
[0037] The intermediate decoder is used to generate intermediate questions based on multiple training complete representations;
[0038] The preset cross-entropy loss function is used to calculate the loss value based on the intermediate question, the target loss value is determined, and it is determined whether the target loss value converges.
[0039] If so, the intermediate decoder is used as the trained preset decoder.
[0040] A second aspect of the present invention provides a question generation device based on multi-source knowledge fusion, comprising:
[0041] The acquisition module is used to acquire the input subgraph and open-source dataset;
[0042] A module is used to generate multiple initial entity type information and input subgraph interrogative words based on the input subgraph, the open source dataset, and multiple pre-built manually constructed examples using a pre-set large-scale pre-trained language model.
[0043] The filtering module is used to filter multiple initial entity type information through a preset multi-layer filter and output multiple target entity type information;
[0044] The fusion module is used to generate auxiliary knowledge based on multiple target entity type information and interrogative words of the input subgraph, and to output multiple complete representations based on the auxiliary knowledge and the input subgraph using a preset information fusion module;
[0045] The generation module is used to input multiple complete representations into a preset decoder to generate the target question.
[0046] A computer device provided in a third aspect of the present invention includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the question generation method based on multi-source knowledge fusion as described in any of the preceding claims.
[0047] The fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the steps of the question generation method based on multi-source knowledge fusion as described in any of the preceding claims.
[0048] The fifth aspect of the present invention provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein, when the program instructions are executed by a computer, the computer performs the steps of the question generation method based on multi-source knowledge fusion as described in any of the preceding claims.
[0049] As can be seen from the above technical solutions, the present invention has the following advantages:
[0050] The above-mentioned technical solution of the present invention provides a question generation method based on multi-source knowledge fusion. First, an input subgraph and an open-source dataset are obtained. Then, a pre-set large-scale pre-trained language model is used to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open-source dataset, and multiple pre-set manually constructed examples. Multiple initial entity type information is filtered through a pre-set multi-layer filter to output multiple target entity type information. Auxiliary knowledge is generated based on the multiple target entity type information and the input subgraph question words. Finally, a pre-set information fusion module is used to output multiple complete questions based on the auxiliary knowledge and the input subgraph. The complete representations are prepared; finally, the multiple complete representations are input to a pre-set decoder to generate the target question. Based on the above scheme, the input subgraph is processed using an open-source database and a pre-set large-scale pre-trained language model to obtain multiple initial entity type information and input subgraph question words. Combined with a pre-set multi-layer filter, a pre-set information fusion module, and a pre-set decoder, the target question is generated based on the target entity type information, input subgraph question words, and input subgraph. This invention obtains additional knowledge from different knowledge sources, including open-source databases and pre-set large-scale pre-trained language models, thereby enhancing the content of the input subgraph and improving the fluency of the generated question. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 The flowchart illustrates the steps of a question generation method based on multi-source knowledge fusion provided in Embodiment 1 of the present invention.
[0053] Figure 2 This is an overall framework diagram of the question generation method based on multi-source knowledge fusion provided in Embodiment 1 of the present invention;
[0054] Figure 3This is a flowchart illustrating the steps of training a preset decoder as provided in Embodiment 2 of the present invention.
[0055] Figure 4 This is a structural block diagram of a question generation device based on multi-source knowledge fusion provided in Embodiment 3 of the present invention. Detailed Implementation
[0056] This invention provides a question generation method and apparatus based on multi-source knowledge fusion to solve the technical problem that existing question generation methods result in poor fluency of the generated questions.
[0057] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0058] Please see Figure 1 , Figure 1 This is a flowchart illustrating the steps of a question generation method based on multi-source knowledge fusion, as provided in Embodiment 1 of the present invention.
[0059] This invention provides a question generation method based on multi-source knowledge fusion, comprising:
[0060] Step 101: Obtain the input subgraph and open-source dataset.
[0061] The open-source dataset is DBpedia.
[0062] Step 102: Using a pre-built large-scale pre-trained language model, multiple initial entity type information and input subgraph interrogative words are generated based on the input subgraph, open source dataset, and multiple pre-built manually constructed examples.
[0063] Multiple initial entity type information includes multiple first initial entity type information and multiple second initial entity type information.
[0064] Specifically, step 102 may include the following sub-steps S21-S22:
[0065] Step S21: Link entities between the input subgraph and the open source dataset to generate multiple first initial entity type information;
[0066] Step S22: Input the input subgraph and multiple pre-built manually constructed examples into a pre-built large-scale pre-trained language model, and output multiple second initial entity type information and input subgraph interrogative words.
[0067] The pre-built large pre-trained language model is LLaMA3 (Large Language Model Meta AI 3).
[0068] The multiple pre-built manually constructed examples are multiple examples built manually.
[0069] It should be noted that this invention requires knowledge augmentation of the entities in the input subgraph G. Specifically, the knowledge sources are the open-source dataset DBpedia and the large pre-trained language model LLaMA3. Entities in the input subgraph G are linked to DBpedia, and their entity types are queried to form entity type T1={t1,...,t...}. v ,...,t γ This yields multiple initial entity type information. Then, multiple examples are manually constructed. LLaMA3 analyzes these examples based on contextual learning and predicts the entity type, forming entity type T2={t1,...,t...}. u ,...,t μ}, that is, multiple second initial entity type information, and predict the interrogative word I (input subgraph interrogative word) of the input subgraph G.
[0070] Step 103: Filter multiple initial entity type information through a pre-set multi-layer filter to output multiple target entity type information.
[0071] Specifically, step 103 may include the following sub-steps S31-S35:
[0072] Step S31: Embed and generate each first initial entity type information and each second initial entity type information respectively, and output the first word embedding corresponding to each first initial entity type information and the second word embedding corresponding to each second initial entity type information;
[0073] Step S32: Using a pre-set multi-layer filter, multi-layer similarity scores are calculated based on each first word embedding and each second word embedding to determine multiple similarity scores between each first word embedding and each second word embedding;
[0074] Step S33: Sum the multiple similarity scores between each first word embedding and each second word embedding, and output the summed similarity score between each first word embedding and each second word embedding;
[0075] Step S34: Compare each summed similarity score with a preset similarity score threshold;
[0076] Step S35: Take the first initial entity type information and the second initial entity type information corresponding to any summed similarity score that is greater than the preset similarity score threshold as the target entity type information.
[0077] It should be noted that this invention utilizes a similarity-based multi-layer filter with N layers to select high-quality entity types from T1 and T2. Specifically, the GloVe model is first used to obtain t v With t u The word embedding involves embedding each first initial entity type information and each second initial entity type information to generate the corresponding first word embedding and second word embedding, which are then used as the input representation of the multi-layer filter.
[0078] Furthermore, the words are embedded into a similarity-based multi-layer filter (a pre-set multi-layer filter) to obtain the output vector of the k-th layer, denoted as... and Then, the similarity scores between them are calculated. :
[0079] ;
[0080] in, for and Similarity score between them; The first word embedded in the k-th layer is the output vector of the v-th initial entity type information; The output vector of the second word embedded in the k-th layer is the u-th second initial entity type information; For element-wise intersections, take the minimum value at the corresponding position; The union of elements is the set of elements, and the maximum value is taken at the corresponding position. For modular calculation.
[0081] Furthermore, by combining the similarity scores from all k layers, the final similarity score (summed similarity score) is obtained:
[0082] ;
[0083] in, for and The summation of similarity scores between them; Let be the weight parameters of the k-th layer, satisfying N represents the total number of pre-set multi-layer filters. for and Similarity score between them.
[0084] Furthermore, it is rare for entity types from different sources to be incorrect at the same time. Therefore, high similarity scores between them can corroborate each other's high quality, that is, higher similarity scores indicate more accurate type information.
[0085] For example, assuming the number of first initial entity type information is 3, the number of second initial entity type information is 3, and the number of layers of the preset multi-layer filter is 3, then there will be 3*3=9 combinations for calculating similarity scores. Each combination corresponds to three similarity scores. Then, the three similarity scores corresponding to the 9 combinations are summed, and the summed similarity scores corresponding to the 9 combinations are output.
[0086] Furthermore, entity types with summation similarity scores higher than a threshold are retained (i.e., the first initial entity type information and the second initial entity type information corresponding to the summation similarity scores). When no entity type meets the requirements, "None" is assigned as the entity type. The final entity type T (i.e., multiple target entity type information) and the subgraph interrogative word I together form the auxiliary knowledge K of the subgraph.
[0087] Step 104: Generate auxiliary knowledge based on multiple target entity type information and input subgraph interrogative words, and use a pre-set information fusion module to output multiple complete representations based on the auxiliary knowledge and input subgraph.
[0088] The pre-built information fusion module includes a pooling layer, a global encoder, and a residual layer.
[0089] Specifically, step 104 may include the following sub-steps S41-S45:
[0090] Step S41: Format the auxiliary knowledge and input subgraph respectively to generate a linearized subgraph and a text sequence;
[0091] Step S42: Use a global encoder to generate multiple hidden states based on the linearized subgraph and the text sequence;
[0092] Step S43: Generate multiple entity representations, multiple interrogative word representations, and multiple entity type representations based on multiple hidden states through the pooling layer;
[0093] Step S44: Integrate multiple entity representations, multiple interrogative word representations, and multiple entity type representations based on semantic and structural attention mechanisms to generate multiple intermediate representations;
[0094] Step S45: Use a residual layer to generate multiple complete representations based on multiple intermediate representations and multiple hidden states.
[0095] It should be noted that this invention utilizes a pre-built information fusion module in Transformer, and establishes semantic associations between subgraphs and auxiliary knowledge through a global encoder, pooling layer, and semantic and structural attention mechanism, thereby obtaining a complete representation of information; wherein, the global encoder captures the global semantic information of the input subgraph.
[0096] Specifically, the input subgraph is formatted with auxiliary knowledge to obtain a linearized subgraph. The linearized subgraph and the corresponding text sequence X are then input into the global encoder to obtain the hidden states of layer l.
[0097] ;
[0098] ;
[0099] ;
[0100] in, The attention scores of the i-th token and the j-th token at layer l; This represents the hidden state of the i-th token at level l-1. To query the trainable parameters corresponding to the matrix; These are the trainable parameters corresponding to the key matrix; The dimension of the query / key / value vector; m is the length of the linearized subgraph; n is the length of the text sequence; The normalized attention score is represented by j, which is the traversal index. These are the trainable parameters corresponding to the value matrix; Let i be the hidden state of the i-th token at level l.
[0101] Furthermore, the hidden state of layer l The corresponding entity representation is obtained through the pooling layer. Relational representation Entity type representation Interrogative words indicate The entity representation is obtained in the following ways:
[0102] ;
[0103] in, For entities The set of neighboring entities; For entities The hidden state at layer l; The number of entities in the subgraph; pooling refers to the pooling layer; For entities Entity representation at level l.
[0104] It is worth mentioning that the methods for obtaining other representations are the same as those for obtaining entity representations, and will not be elaborated further in this invention.
[0105] Furthermore, various representations are integrated using semantic and structural attention mechanisms, and then combined using a residual layer to generate a complete representation for subsequent computation:
[0106] ;
[0107] ;
[0108] ;
[0109] in, For entities Attention score for supplementary semantics at layer l; For entities Entity representation at level l; , , , , These are trainable parameters; For entities Interrogative words are represented at level l; For entities Entity type representation at level l; The dimension of the query / key / value vector; For entities Supplementary semantic representation at layer l; For entities The complete representation obtained at layer l.
[0110] Step 105: Input multiple complete representations into the preset decoder to generate the target question.
[0111] It should be noted that this invention uses a BART-based decoder (a pre-built decoder, a Bidirectional and Auto-Regressive Transformers base decoder) to generate questions (target questions) based on multiple complete representations.
[0112] For comparison of technical effects, existing technologies can be used as a reference. In recent years, with the rapid development of knowledge graphs (KG) and natural language processing technologies, knowledge base-based question answering (KBQG) has gradually become an important research direction. KBQG aims to extract information from knowledge graphs and generate relevant questions to provide a more natural interactive experience in dialogue systems and information retrieval, and has wide applications in both academia and industry.
[0113] Research on Keyword Question Generation (KBQG) can be divided into two categories. The first category is structure-information-based KBQG. Initially, it heavily relied on manually created question templates for question generation. Subsequent improvements adopted a fully data-driven end-to-end approach, utilizing neural networks to generate labeled sequences of natural language questions, focusing on generating multi-hop complex questions by effectively modeling rich structures. The other category is external knowledge-enhanced KBQG. It enhances question generation by inputting external auxiliary knowledge (such as node attributes, interrogative words, and entity types) into the KG subgraph and designing fusion mechanisms to integrate the auxiliary knowledge with the KG subgraph.
[0114] Despite the achievements of KBQG, existing methods still face two main challenges: First, the limited availability of knowledge sources. Existing work fails to utilize diverse information sources or appropriately filter information, resulting in limited knowledge and consequently, poor fluency in the generated questions. Second, insufficient integration of auxiliary knowledge. Existing work lacks sufficient fusion modules to integrate auxiliary knowledge with subgraphs, leading to semantic shifts between the generated results and the subgraphs. Therefore, effectively integrating auxiliary knowledge from different sources to improve the quality of question-answering generation has become an urgent problem to be solved.
[0115] For the above issues, please refer to Figure 2 This invention proposes a question generation method based on multi-source knowledge fusion. Its overall framework consists of three parts: knowledge enhancement, multi-layer filters, and an information fusion module. The knowledge enhancement method's core idea is to acquire additional knowledge from different sources, including open-source databases and large language models, to enhance the content of the input subgraph. The multi-layer filters evaluate and select auxiliary knowledge based on similarity to obtain high-quality information. The information fusion module aims to integrate auxiliary knowledge into the subgraph representation, providing the model with complete information input, thereby achieving accurate question generation. This invention, through multi-source knowledge enhancement, can provide more comprehensive and real-time additional knowledge to the subgraph; the proposed multi-layer filters compare similarity at multiple fine-grained levels to better filter out accurate supplementary information; and the proposed information fusion module fuses the subgraph and auxiliary knowledge from both semantic and structural perspectives to better analyze the subgraph's potential information, thus improving the fluency and accuracy of question generation.
[0116] In summary, this invention employs multi-layered filters to sift through knowledge from diverse sources, thereby acquiring highly relevant auxiliary knowledge at multiple fine-grained levels. Through a semantic and structural information fusion module, it effectively integrates the input subgraph with auxiliary knowledge to obtain a complete input representation, thus significantly improving the quality of question-answer generation. Experimental results on multiple datasets demonstrate that this invention outperforms several baseline models, validating its effectiveness and generalization ability, and providing a reference for future research.
[0117] In this embodiment of the invention, a question generation method based on multi-source knowledge fusion is provided. First, an input subgraph and an open-source dataset are acquired. Then, a pre-built large-scale pre-trained language model is used to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open-source dataset, and multiple pre-built manually constructed examples. Multiple initial entity type information is filtered through a pre-built multi-layer filter to output multiple target entity type information. Auxiliary knowledge is generated based on the multiple target entity type information and the input subgraph question words, and a pre-built information fusion module is used to output multiple complete representations based on the auxiliary knowledge and the input subgraph. Subsequently, multiple complete representations are input into a pre-set decoder to generate the target question. Based on the above scheme, the input subgraph is processed using an open-source database and a pre-set large-scale pre-trained language model to obtain multiple initial entity type information and input subgraph interrogative words. Combined with a pre-set multi-layer filter, a pre-set information fusion module, and a pre-set decoder, the target question is generated based on the target entity type information, input subgraph interrogative words, and input subgraph. This invention acquires additional knowledge from different knowledge sources, including open-source databases and pre-set large-scale pre-trained language models, thereby enhancing the content of the input subgraph and improving the fluency of the generated question.
[0118] For better explanation, refer to Figure 3 The diagram illustrates the steps of training a pre-set decoder according to Embodiment 2 of the present invention. This process may include the following steps:
[0119] Step 301: Obtain the subgraph to be trained and the open source dataset.
[0120] Step 302: Using a pre-built large-scale pre-trained language model, multiple entity type information and interrogative words for the subgraph to be trained are generated based on the subgraph to be trained, the open source dataset, and multiple pre-built manually constructed examples.
[0121] Step 303: Filter multiple entity type information to be trained by using a pre-set multi-layer filter, and output multiple target entity type information to be trained.
[0122] Step 304: Generate auxiliary knowledge to be trained based on multiple target entity type information and interrogative words of the subgraph to be trained, and use a pre-set information fusion module to output multiple complete representations to be trained based on the auxiliary knowledge to be trained and the subgraph to be trained.
[0123] Step 305: Based on the preset cross-entropy loss function, train the initial decoder using multiple complete representations to be trained, and determine the trained preset decoder.
[0124] Specifically, step 305 may include the following sub-step S351:
[0125] Step S351: Input multiple complete representations to be trained into the initial decoder to generate the question to be trained;
[0126] Step S352: Substitute the question to be trained into the preset cross-entropy loss function and take the derivative to output the model gradient;
[0127] Step S353: Based on the adaptive moment estimation optimization algorithm, the model parameters of the initial decoder are updated using the model gradient to determine the intermediate decoder;
[0128] Step S354: Use an intermediate decoder to generate intermediate questions based on multiple complete representations to be trained;
[0129] Step S355: Calculate the loss value based on the intermediate question using a preset cross-entropy loss function, determine the target loss value, and judge whether the target loss value has converged.
[0130] Step S356: If yes, then use the intermediate decoder as the trained preset decoder.
[0131] It should be noted that this invention uses an untrained BART-based decoder to generate the problem, and then substitutes it into a preset cross-entropy loss function and performs differentiation to obtain the model gradient. The preset cross-entropy loss function is specifically as follows:
[0132] ;
[0133] Where L is the target loss value; For conditional probability; The words generated at time step t; Words generated before time step t; For entities The complete representation obtained at layer L; X is the length of the generated question (the question to be trained).
[0134] Furthermore, the cross-entropy loss function is minimized using the Adam optimization algorithm (adaptive moment estimation optimization algorithm), while simultaneously updating the decoder's model parameters. Finally, the trained decoder is used to generate the problem X related to the subgraph. Specifically, based on the adaptive moment estimation optimization algorithm, the model parameters of the initial decoder are updated using the model gradient to determine the intermediate decoder. Then, combining the intermediate decoder and the preset cross-entropy loss function, the target loss value is calculated based on multiple complete representations to be trained, and it is determined whether it has converged. If the target loss value has not converged, the intermediate decoder is used as the new initial decoder, and step 305 is executed until the target loss value converges. The intermediate decoder determined when the target loss value converges is used as the trained preset decoder.
[0135] In this embodiment of the invention, a multi-layered filter is used to screen knowledge from different sources, thereby obtaining highly relevant auxiliary knowledge at multiple fine-grained levels. A semantic and structural information fusion module effectively integrates the input subgraph and auxiliary knowledge to obtain a complete input representation. Combined with a pre-set cross-entropy loss function, the model training of a pre-set decoder is completed, significantly improving the quality of question-answering generation. Experimental results on multiple datasets show that this invention outperforms several baseline models, validating its effectiveness and generalization ability, and providing a reference for future research.
[0136] Please see Figure 4 , Figure 4 This is a structural block diagram of a question generation device based on multi-source knowledge fusion provided in Embodiment 3 of the present invention.
[0137] This invention provides a question generation device based on multi-source knowledge fusion, comprising:
[0138] Module 401 is used to acquire the input subgraph and open-source dataset;
[0139] Module 402 is used to generate multiple initial entity type information and input subgraph interrogative words based on the input subgraph, open source dataset and multiple pre-built examples using a pre-built large pre-trained language model.
[0140] The filtering module 403 is used to filter multiple initial entity type information through a preset multi-layer filter and output multiple target entity type information;
[0141] The fusion module 404 is used to generate auxiliary knowledge based on multiple target entity type information and input subgraph interrogative words, and to output multiple complete representations based on the auxiliary knowledge and input subgraph using a pre-set information fusion module;
[0142] The generation module 405 is used to input multiple complete representations into a preset decoder to generate the target question.
[0143] Furthermore, the multiple initial entity type information includes multiple first initial entity type information and multiple second initial entity type information; module 402 is used specifically for:
[0144] Entity links are performed between the input subgraph and the open-source dataset to generate multiple initial entity type information.
[0145] The input subgraph and multiple pre-built manually constructed examples are fed into a pre-built large-scale pre-trained language model, which outputs multiple second initial entity type information and input subgraph interrogative words.
[0146] Furthermore, the filtering module 403 is specifically used for:
[0147] Embedding is performed on each first initial entity type information and each second initial entity type information respectively, and the first word embedding corresponding to each first initial entity type information and the second word embedding corresponding to each second initial entity type information are output.
[0148] A pre-set multi-layer filter is used to calculate multi-layer similarity scores based on each first word embedding and each second word embedding, thereby determining multiple similarity scores between each first word embedding and each second word embedding;
[0149] Sum the multiple similarity scores between each first word embedding and each second word embedding, and output the summed similarity score between each first word embedding and each second word embedding;
[0150] Each summed similarity score is compared with a preset similarity score threshold.
[0151] The first initial entity type information and the second initial entity type information corresponding to any summed similarity score greater than the preset similarity score threshold are used as the target entity type information.
[0152] Furthermore, the pre-built information fusion module includes a pooling layer, a global encoder, and a residual layer; the fusion module 404 is specifically used for:
[0153] The auxiliary knowledge and input subgraph are formatted separately to generate a linearized subgraph and a text sequence;
[0154] A global encoder is used to generate multiple hidden states based on the linearized subgraph and the text sequence;
[0155] The pooling layer generates multiple entity representations, multiple interrogative word representations, and multiple entity type representations based on multiple hidden states;
[0156] A semantic and structural attention mechanism is used to integrate multiple entity representations, multiple interrogative word representations, and multiple entity type representations to generate multiple intermediate representations;
[0157] A residual layer is used to generate multiple complete representations based on multiple intermediate representations and multiple hidden states.
[0158] In one optional device embodiment, it further includes:
[0159] The first module is used to obtain the subgraph to be trained and the open-source dataset;
[0160] The second module is used to generate multiple entity type information and question words for the subgraph to be trained based on the subgraph to be trained, the open source dataset, and multiple pre-built examples using a pre-set large pre-trained language model.
[0161] The third module is used to filter multiple entity type information to be trained through a pre-set multi-layer filter and output multiple target entity type information to be trained.
[0162] The fourth module is used to generate auxiliary knowledge to be trained based on multiple target entity type information and interrogative words of the subgraph to be trained, and to output multiple complete representations to be trained based on the auxiliary knowledge and the subgraph to be trained using a pre-set information fusion module.
[0163] The fifth module is used to train the initial decoder using multiple complete representations to be trained based on a pre-set cross-entropy loss function, and to determine the trained pre-set decoder.
[0164] Furthermore, the fifth module is specifically used for:
[0165] Multiple complete representations to be trained are input into the initial decoder to generate the questions to be trained;
[0166] Substitute the question to be trained into the preset cross-entropy loss function and take the derivative to output the model gradient;
[0167] Based on the adaptive moment estimation optimization algorithm, the model parameters of the initial decoder are updated using the model gradient to determine the intermediate decoder;
[0168] An intermediate decoder is used to generate intermediate questions based on multiple complete representations to be trained;
[0169] A pre-set cross-entropy loss function is used to calculate the loss value based on the middle question, determine the target loss value, and judge whether the target loss value converges.
[0170] If so, the intermediate decoder will be used as the pre-trained decoder.
[0171] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0172] This invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program; when the computer program is executed by the processor, the processor performs the steps of the question generation method based on multi-source knowledge fusion as described in Embodiment 1 above.
[0173] This invention also provides a computer-readable storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the steps of the question generation method based on multi-source knowledge fusion as described in Embodiment 1 above.
[0174] This invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the question generation method based on multi-source knowledge fusion as described in Embodiment 1 above.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0176] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0177] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A question generation method based on multi-source knowledge fusion, characterized in that, include: Obtain the input subgraph and the open-source dataset; A pre-built large-scale pre-trained language model is used to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open source dataset, and multiple pre-built manually constructed examples; Multiple initial entity type information is filtered by a pre-set multi-layer filter to output multiple target entity type information; Based on multiple target entity type information and the interrogative words of the input subgraph, auxiliary knowledge is generated, and a pre-set information fusion module outputs multiple complete representations based on the auxiliary knowledge and the input subgraph. The multiple complete representations are input into a preset decoder to generate the target question; The multiple initial entity type information includes multiple first initial entity type information and multiple second initial entity type information; the step of using a pre-set large-scale pre-trained language model to generate multiple initial entity type information and input subgraph question words based on the input subgraph, the open source dataset, and multiple pre-set manually constructed examples includes: Entity links are performed between the input subgraph and the open-source dataset to generate multiple first initial entity type information; The input subgraph and multiple pre-built manually constructed examples are input into the pre-built large-scale pre-trained language model, which outputs multiple second initial entity type information and input subgraph question words; The process of filtering multiple initial entity type information through a pre-set multi-layer filter to output multiple target entity type information includes: Embedding is performed on each of the first initial entity type information and each of the second initial entity type information respectively, and the first word embedding corresponding to each of the first initial entity type information and the second word embedding corresponding to each of the second initial entity type information are output. A pre-set multi-layer filter is used to calculate multi-layer similarity scores based on each first word embedding and each second word embedding to determine multiple similarity scores between each first word embedding and each second word embedding; The similarity scores between each first word embedding and each second word embedding are summed, and the summed similarity score between each first word embedding and each second word embedding is output. Each summed similarity score is compared with a preset similarity score threshold. The first initial entity type information and the second initial entity type information corresponding to any summation similarity score greater than the preset similarity score threshold are used as the target entity type information.
2. The question generation method based on multi-source knowledge fusion according to claim 1, characterized in that, The pre-defined information fusion module includes a pooling layer, a global encoder, and a residual layer; the pre-defined information fusion module outputs multiple complete representations based on the auxiliary knowledge and the input subgraph, including: The auxiliary knowledge and the input subgraph are formatted respectively to generate a linearized subgraph and a text sequence; A global encoder is used to generate multiple hidden states based on the linearized subgraph and the text sequence; The pooling layer generates multiple entity representations, multiple interrogative word representations, and multiple entity type representations based on the multiple hidden states. Based on semantic and structural attention mechanisms, multiple entity representations, multiple interrogative word representations, and multiple entity type representations are integrated to generate multiple intermediate representations; A residual layer is used to generate multiple complete representations based on multiple intermediate representations and multiple hidden states.
3. The question generation method based on multi-source knowledge fusion according to claim 1, characterized in that, The training process of the pre-built decoder is as follows: Obtain the subgraph to be trained and the open-source dataset; A pre-built large-scale pre-trained language model is used to generate multiple entity type information and interrogative words for the subgraph to be trained based on the subgraph to be trained, the open source dataset, and multiple pre-built manually constructed examples; Multiple training entity type information is filtered by a pre-set multi-layer filter to output multiple training target entity type information. Based on the multiple target entity type information to be trained and the interrogative words of the subgraph to be trained, auxiliary knowledge to be trained is generated, and a pre-set information fusion module is used to output multiple complete representations to be trained based on the auxiliary knowledge to be trained and the subgraph to be trained. Based on a pre-set cross-entropy loss function, the initial decoder is trained using multiple complete representations to be trained, thereby determining the trained pre-set decoder.
4. The question generation method based on multi-source knowledge fusion according to claim 3, characterized in that, The process of training an initial decoder using multiple complete representations to be trained, based on a pre-set cross-entropy loss function, to determine the trained pre-set decoder includes: The multiple complete representations to be trained are input into the initial decoder to generate the questions to be trained; Substitute the question to be trained into the preset cross-entropy loss function and take the derivative to output the model gradient; Based on the adaptive moment estimation optimization algorithm, the model parameters of the initial decoder are updated using the model gradient to determine the intermediate decoder; The intermediate decoder is used to generate intermediate questions based on multiple training complete representations; The preset cross-entropy loss function is used to calculate the loss value based on the intermediate question, the target loss value is determined, and it is determined whether the target loss value converges. If so, the intermediate decoder is used as the trained preset decoder.
5. A question generation device based on multi-source knowledge fusion, applied to the question generation method based on multi-source knowledge fusion as described in claim 1, characterized in that, include: The acquisition module is used to acquire the input subgraph and open-source dataset; A module is used to generate multiple initial entity type information and input subgraph interrogative words based on the input subgraph, the open source dataset, and multiple pre-built manually constructed examples using a pre-set large-scale pre-trained language model. The filtering module is used to filter multiple initial entity type information through a preset multi-layer filter and output multiple target entity type information; The fusion module is used to generate auxiliary knowledge based on multiple target entity type information and interrogative words of the input subgraph, and to output multiple complete representations based on the auxiliary knowledge and the input subgraph using a preset information fusion module; The generation module is used to input multiple complete representations into a preset decoder to generate the target question.
6. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the question generation method based on multi-source knowledge fusion as described in any one of claims 1-4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the question generation method based on multi-source knowledge fusion as described in any one of claims 1-4.
8. A computer program product, characterized in that, The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, wherein when the program instructions are executed by a computer, the computer performs the question generation method based on multi-source knowledge fusion as described in any one of claims 1-4.
Citation Information
Patent Citations
Knowledge graph question and answer method and system based on Sparql statement generation
CN115827844A
Drug repositioning method and system fusing multi-source knowledge graph
WO2024138803A1