Question and answer generation method based on knowledge graph

By using technical means such as bidirectional semantic encoder, hierarchical knowledge fusion network and dynamic weight allocator in the knowledge graph question and answer system, problems such as low knowledge extraction accuracy and poor semantic alignment effect are solved, and high-quality question and answer pair generation is achieved, improving the practicality and scalability of the system.

CN119807349AActive Publication Date: 2025-04-11NANJING XINZHI ART TESTING TECH CO LTD

Patent Information

Application Number
CN202411790033.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-11
Estimated Expiration
2044-12-06

AI Technical Summary

Technical Problem

The existing knowledge graph Q&A technology has problems such as low knowledge extraction accuracy, poor semantic alignment effect, unreasonable Q&A path construction, and low quality of Q&A pair generation, resulting in the limitation of the practicality and scalability of the system.

Method used

The text processing is performed using a bidirectional semantic encoder, entity words and relational words are extracted, semantic vectors are formed, and converted into basic knowledge structures through a triple decomposition device. Then, aligning the basic knowledge structure with the preset knowledge graph is used to generate a multi-dimensional knowledge feature matrix. Based on this matrix, the dynamic weight allocator calculates the correlation strength between knowledge nodes, builds a hierarchical Q&A path, and generates high-quality Q&A pairs through the attention model and Q&A template library.

Benefits of technology

The accuracy of knowledge extraction is improved, the accurate alignment and reasonable organization of knowledge is achieved, the generated question-and-answer quality is significantly improved, and the practicality and scalability of the system are also improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807349A_ABST
    Figure CN119807349A_ABST
Patent Text Reader

Abstract

The invention discloses a question and answer generation method based on a knowledge graph, and relates to the technical field of artificial intelligence and natural language process.The method comprises the steps that a bidirectional semantic encoder is adopted to process input text corpus, entity words and relational words are extracted, a first semantic vector is formed, and the first semantic vector is converted into a basic knowledge structure through a triple decomposer; aligning the basic knowledge structure with deep semantic information in a preset knowledge graph by using a hierarchical knowledge fusion network to generate a multi-dimensional knowledge feature matrix, calculating association strength among knowledge nodes by using a dynamic weight distributor, and constructing a hierarchical question and answer path according to a sequence of the association strength from high to low; and inputting the hierarchical question and answer path into a constructed attention model, and generating a question and answer pair data set according to a question and answer template library. According to the method, the knowledge extraction accuracy and the knowledge fusion effect are improved, the question and answer path construction process is optimized, and a question and answer pair data set with a complete structure is formed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence and natural language processing, and in particular to a question-answering generation method based on a knowledge graph. Background Art

[0002] As a structured knowledge representation method, knowledge graph can effectively organize and manage large-scale knowledge information, providing important knowledge support for intelligent question-answering systems. Traditional knowledge graph question-answering systems mainly use methods based on template matching, semantic parsing, and deep learning to construct question-answer pairs. These methods perform well in simple question-answering scenarios, but there are still many challenges in dealing with complex multi-round dialogues and deep semantic understanding. In particular, in key links such as knowledge extraction, semantic alignment, and question-answering path construction, existing technologies often find it difficult to accurately capture entity relationships and deep semantic information in texts, resulting in suboptimal quality of generated question-answer pairs.

[0003] At present, the existing knowledge graph question-answering technology has the following problems in knowledge representation and question-answer generation: first, traditional knowledge extraction methods often use one-way encoding or simple feature extraction methods, which cannot fully utilize the contextual information and semantic features of the text; second, in the process of knowledge fusion, there is a lack of effective semantic alignment mechanism, which makes it difficult to accurately identify and match knowledge entities from different sources; third, the construction of question-answering paths usually adopts static rules or fixed templates, which is difficult to adapt to dynamically changing knowledge structures and user needs; finally, the hierarchy and relevance of knowledge are not fully considered in the generation process of question-answer pairs, resulting in a lack of systematicity and coherence in the generated question-answer content. These problems have seriously affected the practicality and scalability of the knowledge graph question-answering system.

[0004] These problems existing in the prior art urgently need a new knowledge graph question-answer generation method to solve. The present invention proposes a knowledge graph-based question-answer generation method, which aims to solve the problems of low knowledge extraction accuracy, poor semantic alignment effect, unreasonable question-answer path construction, and low quality of question-answer pair generation in the prior art; by introducing technical means such as bidirectional semantic encoding, hierarchical knowledge fusion, and dynamic weight allocation, efficient knowledge extraction, accurate alignment, and reasonable organization are achieved. Summary of the invention

[0005] In view of the problems existing in the existing knowledge graph question and answer generation methods in terms of knowledge extraction, semantic alignment, path construction and question and answer generation, the present invention is proposed.

[0006] Therefore, the problem to be solved by the present invention is how to improve the accuracy of knowledge extraction, achieve accurate alignment of knowledge, construct a reasonable hierarchical question-answering path, and generate a high-quality question-answer pair dataset.

[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0008] In the first aspect, an embodiment of the present invention provides a question and answer generation method based on a knowledge graph, which includes: using a bidirectional semantic encoder to process an input text corpus, extracting entity words and relationship words to form a first semantic vector, and converting the first semantic vector into a basic knowledge structure through a triple decomposer; using a hierarchical knowledge fusion network to align the basic knowledge structure with the deep semantic information in a preset knowledge graph to generate a multidimensional knowledge feature matrix; based on the multidimensional knowledge feature matrix, using a dynamic weight allocator to calculate the association strength between knowledge nodes, and constructing a hierarchical question and answer path in order of association strength from high to low; inputting the hierarchical question and answer path into the constructed attention model, and generating a question and answer pair data set according to the question and answer template library.

[0009] As a preferred solution of the question and answer generation method based on knowledge graph described in the present invention, wherein: the attention model includes an encoder and a decoder; the encoder performs multi-level feature extraction on the input hierarchical question and answer path, and calculates the attention weight score of each knowledge node in the path through the self-attention mechanism to identify the key knowledge nodes; the decoder matches the key knowledge nodes with the corresponding question and answer templates according to the question and answer templates pre-stored in the question and answer template library; the method for generating the question and answer pair data set is to dynamically integrate the semantic information of the key knowledge nodes into the structure of the question and answer pattern through the cross-attention mechanism to generate question and answer pairs, wherein the question and answer pairs include question text, answer text and corresponding knowledge path information; based on the question and answer pairs, rule filtering and semantic similarity calculation are used for screening; the screened question and answer pairs are organized according to the hierarchical relationship of the knowledge nodes to form a structured question and answer pair data set.

[0010] As a preferred solution of the question-answer generation method based on knowledge graph described in the present invention, wherein: the method for constructing the hierarchical question-answer path is that the dynamic weight allocator includes a feature aggregation unit and a weight calculation unit; the feature aggregation unit performs weighted summation on the attribute features of the nodes in the multidimensional knowledge feature matrix to generate a node representation vector; the weight calculation unit calculates the association strength of the node pairs based on the node representation vector and screens the node pairs; the node pairs that pass the screening are sorted from high to low according to the association strength value, and the node pairs are divided into different levels based on the sorting results; within each level, a directed connection path is constructed based on the semantic dependency relationship and relationship topological features of the node pairs; the directed connection paths of each level are connected in series in sequence to form a hierarchical question-answer path, in which the high-level nodes are used as core knowledge points and the low-level nodes are used as extended knowledge points.

[0011] As a preferred solution of the question-answer generation method based on knowledge graph described in the present invention, the specific formula of the association strength is as follows:

[0012]

[0013] Among them, R ij is the association strength value between node i and node j, v i and v j are the characterization vectors of nodes i and j respectively, and T is the characterization vector v i The transpose of M is the feature transformation matrix, β, ε and γ are adjustment coefficients, d is the feature dimension, and w k is the weight coefficient of the k-th dimension feature, x ik and x jk are the eigenvalues ​​of node i and node j in the kth dimension respectively.

[0014] As a preferred solution of the question-answer generation method based on the knowledge graph described in the present invention, wherein: based on the multidimensional knowledge feature matrix, a dynamic weight allocator is used to calculate the association strength between knowledge nodes, and a hierarchical question-answer path is constructed in order of association strength from high to low, including: the hierarchical knowledge fusion network includes an entity alignment unit and a relationship mapping unit; the semantic similarity of the entity in the basic knowledge structure and the entity in the preset knowledge graph is calculated by the entity alignment unit to determine whether the entity pair meets the matching conditions; the relationship mapping unit uses a multi-head attention mechanism to semantically map the relationship words of the basic knowledge structure and the relationship in the preset knowledge graph to extract the corresponding relationship between the relationships; based on the entity alignment result of the entity alignment unit and the mapping result of the relationship mapping unit, an alignment matrix is ​​constructed; entity attribute features related to the alignment matrix are extracted from the preset knowledge graph, and the relationship topological features between entities are extracted at the same time; the entity attribute features and the relationship topological features are combined to form a multidimensional knowledge feature matrix, wherein the rows of the multidimensional knowledge feature matrix represent different entity nodes, and the columns represent the corresponding attribute dimensions and topological features.

[0015] As a preferred solution of the question-answer generation method based on knowledge graph described in the present invention, the specific formula of the semantic similarity is as follows:

[0016]

[0017] Among them, Sim(e1,e2) is the semantic similarity value between the entity in the basic knowledge structure and the entity in the preset knowledge graph, α is the weight coefficient of the semantic similarity, v1 is the vectorized semantic representation of the entity in the basic knowledge structure, v2 is the vectorized semantic representation of the entity in the preset knowledge graph, n is the number of attributes of the entity, is the i-th attribute of the entity in the basic knowledge structure, is the i-th attribute of the entity in the preset knowledge graph, is the similarity score of the i-th attribute, e1 is the entity in the basic knowledge structure, and e2 is the entity in the preset knowledge graph.

[0018] When the semantic similarity is greater than or equal to a first preset threshold, the entity pair is matched; when the semantic similarity is less than the first preset threshold, the entity pair is temporarily stored in a cache to be processed, and the semantic representation of the entity is expanded, and the semantic similarity of the expanded entity is recalculated; if the semantic similarity of the expanded entity is still less than the first preset threshold, the entity pair is marked as unmatched, and the corresponding position in the alignment matrix is ​​filled with zero value; if the semantic similarity of the expanded entity is still greater than or equal to the first preset threshold, the entity pair is matched.

[0019] As a preferred solution of the question-answer generation method based on knowledge graph described in the present invention, wherein: a bidirectional semantic encoder is used to process the input text corpus, entity words and relation words are extracted to form a first semantic vector, and the first semantic vector is converted into a basic knowledge structure through a triple decomposer, including: the bidirectional semantic encoder includes a forward coding layer and a backward coding layer; the forward coding layer scans the word elements in the input text corpus from left to right in sequence; the backward coding layer scans the word elements in the input text corpus from right to left in sequence; the conversion method of the basic knowledge structure is to adaptively fuse the output results of the forward coding layer and the backward coding layer, determine the importance of the forward coding layer and the backward coding layer through a dynamic weight allocation mechanism, and introduce a multi-scale convolution operation at the same time. The method comprises the following steps: extracting local semantic features, and enhancing the sequence feature representation of the input text corpus in combination with the position coding information to generate a text semantic representation; processing the text semantic representation using a preset named entity recognition model to identify and annotate the type and boundary information of entity words; performing syntactic structure analysis on the text semantic representation using a dependency syntax analyzer to extract the relationship words between entity words; combining the identified entity words, the type and boundary information of entity words, relationship words and the semantic features corresponding to the relationship words in series in the vector space through a feature splicer to form a first semantic vector; processing the first semantic vector through a triple decomposer, and dividing the semantic vector into a number of sub-vector segments using a sliding window mechanism; performing semantic analysis and knowledge element extraction on the sub-vector segments to construct a basic knowledge structure.

[0020] In the second aspect, an embodiment of the present invention provides a question and answer generation method system based on a knowledge graph, comprising: an extraction and conversion module, which is used to use a bidirectional semantic encoder to process an input text corpus, extract entity words and relationship words, form a first semantic vector, and convert the first semantic vector into a basic knowledge structure through a triple decomposer; a generation module, which is used to use a hierarchical knowledge fusion network to align the basic knowledge structure with the deep semantic information in a preset knowledge graph to generate a multidimensional knowledge feature matrix; a construction module, based on the multidimensional knowledge feature matrix, uses a dynamic weight allocator to calculate the correlation strength between knowledge nodes, and constructs a hierarchical question and answer path in order of correlation strength from high to low; a generation module, which is used to input the hierarchical question and answer path into the constructed attention model, and generate a question and answer pair data set according to the question and answer template library.

[0021] In a third aspect, an embodiment of the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program instructions are executed by the processor, the steps of the question and answer generation method based on the knowledge graph as described in the first aspect of the present invention are implemented.

[0022] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program instructions are executed by a processor, the steps of the question and answer generation method based on the knowledge graph as described in the first aspect of the present invention are implemented.

[0023] The beneficial effects of the present invention are as follows: the present invention realizes high-precision entity and relationship extraction and effectively retains the contextual semantic information of the text by adopting a bidirectional semantic encoder and a multi-level named entity recognition model for text processing; through the semantic alignment mechanism of the hierarchical knowledge fusion network, the deep semantic fusion of the basic knowledge structure and the preset knowledge graph is realized, and the integrity of knowledge representation is improved; the hierarchical question-answer path constructed based on the dynamic weight allocator ensures the rationality of knowledge connection and the progressiveness of knowledge transfer; through the cooperation of the attention model and the question-answer template library, the intelligent generation of high-quality question-answer pairs is realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0025] Figure 1 This is a flowchart of the question and answer generation method based on the knowledge graph in Example 1.

[0026] Figure 2This is a semantic similarity distribution diagram of the question and answer generation method based on knowledge graph in Example 1. DETAILED DESCRIPTION

[0027] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0029] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0030] Example 1

[0031] Reference Figure 1-2 , which is the first embodiment of the present invention, and provides a question-answer generation method based on a knowledge graph, comprising:

[0032] S1: Use a bidirectional semantic encoder to process the input text corpus, extract entity words and relation words, form a first semantic vector, and convert the first semantic vector into a basic knowledge structure through a triple decomposer.

[0033] Specifically, the bidirectional semantic encoder includes a forward encoding layer and a backward encoding layer; the forward encoding layer scans the word units in the input text corpus from left to right; the specific formula of the forward encoding layer is as follows:

[0034] H f =σ(W f X+b f +η t-1 );

[0035] Among them, H f is the forward encoding output vector, W f is the forward encoding weight matrix, X is the input text sequence vector, b f is the input text sequence vector, σ is the activation function, η t-1 is the historical information impact factor;

[0036] Furthermore, the backward encoding layer scans the words in the input text corpus from right to left. The specific formula of the forward encoding layer is as follows:

[0037] H b =σ(W b X+b b +ξ t+1 );

[0038] Among them, H b is the backward encoding output vector, σ is the activation function, W b is the backward encoding weight matrix, X is the input text sequence vector, b b is the backward encoding bias term, ξ t+1 To predict the information impact factor;

[0039] It should be noted that when processing word units, the forward encoding layer and the backward encoding layer will consider the contextual information of the word unit, including the influence of historically processed information and future information to be processed, to capture semantic features.

[0040] Furthermore, the output results of the forward coding layer and the backward coding layer are adaptively fused, and the importance of the forward coding layer and the backward coding layer is determined through a dynamic weight allocation mechanism. At the same time, multi-scale convolution operations are introduced to extract local semantic features, and the sequence feature representation of the input text corpus is enhanced in combination with the position coding information to generate text semantic representation.

[0041] Specifically, the text semantic representation is processed using a preset named entity recognition model to identify and annotate the type and boundary information of entity words; the dependency syntax analyzer is used to parse the syntactic structure of the text semantic representation and extract the relationship words between entity words.

[0042] It should be noted that the preset named entity recognition model adopts a hierarchical structure design, including a word unit encoding layer, a feature enhancement layer, a context encoding layer, a label prediction layer, and a constraint optimization layer. Word unit encoding layer: the input text corpus is segmented, each word unit is mapped to a vector representation, and at the same time, character-level features are combined to extract the internal structure features of the word unit through the character embedding network to enhance the processing capabilities of unregistered words and rare words; Feature enhancement layer: Fusion of multi-dimensional feature information of word units, including part-of-speech tagging features, word form features (such as uppercase and lowercase and numbers), morpheme features (such as affixes and roots), and contextual semantic features provided by the pre-trained language model; Context encoding layer: A bidirectional long short-term memory network structure is used to capture long-range dependencies in the sequence, and a residual connection mechanism is introduced in the processing process to alleviate the gradient vanishing problem in deep network training. , and set up a multi-head attention module to extract the correlation information between words from different perspectives; annotation prediction layer: construct a conditional random field decoder, fully consider the transfer constraint relationship between annotations, find the optimal annotation sequence path through the Viterbi algorithm, introduce a label embedding mechanism, and represent the entity type label as a vector to enhance the model's semantic understanding of the entity type; constraint optimization layer: design a multi-task learning framework. In addition to the main sequence labeling task, it also introduces auxiliary boundary detection tasks and type classification tasks. Through mutual promotion between tasks, the robustness of the model is improved. At the same time, the entity boundary perception mechanism is adopted to improve the accuracy of entity boundary recognition.

[0043] Furthermore, the identified entity words, the types and boundary information of the entity words, the relation words and the semantic features corresponding to the relation words are serially combined in the vector space through a feature splicer to form a first semantic vector; the first semantic vector is processed by a triple decomposer, and the semantic vector is divided into several sub-vector fragments by a sliding window mechanism; semantic analysis and knowledge element extraction are performed on the several sub-vector fragments to construct a basic knowledge structure.

[0044] Furthermore, the sub-vector segment contains the head entity, the relation word, and the tail entity.

[0045] S2: Use a hierarchical knowledge fusion network to align the basic knowledge structure with the deep semantic information in the preset knowledge graph to generate a multi-dimensional knowledge feature matrix.

[0046] Specifically, the hierarchical knowledge fusion network includes an entity alignment unit and a relationship mapping unit; the method for generating a multidimensional knowledge feature matrix is ​​to calculate the semantic similarity between entities in the basic knowledge structure and entities in the preset knowledge graph through the entity alignment unit to determine whether this entity pair meets the matching conditions.

[0047] Furthermore, the specific formula of semantic similarity is as follows:

[0048]

[0049] Among them, Sim(e1,e2) is the semantic similarity value between the entity in the basic knowledge structure and the entity in the preset knowledge graph, α is the weight coefficient of the semantic similarity, v1 is the vectorized semantic representation of the entity in the basic knowledge structure, v2 is the vectorized semantic representation of the entity in the preset knowledge graph, n is the number of attributes of the entity, is the i-th attribute of the entity in the basic knowledge structure, is the i-th attribute of the entity in the preset knowledge graph, is the similarity score of the i-th attribute, e1 is the entity in the basic knowledge structure, and e2 is the entity in the preset knowledge graph.

[0050] Furthermore, when the semantic similarity is greater than or equal to a first preset threshold, the entity pair is matched; when the semantic similarity is less than the first preset threshold, the entity pair is temporarily stored in a cache area to be processed, and the semantic representation of the entity is expanded, and the semantic similarity of the expanded entity is recalculated; if the semantic similarity of the expanded entity is still less than the first preset threshold, the entity pair is marked as unmatched, and the corresponding position in the alignment matrix is ​​filled with zero value; if the semantic similarity of the expanded entity is still greater than or equal to the first preset threshold, the entity pair is matched.

[0051] It should be noted that the first preset threshold is a key parameter determined based on the distribution law of semantic similarity of entity pairs and empirical analysis; the clustering center of the similarity distribution is obtained by statistically analyzing the semantic similarity of entity pairs in large-scale annotated samples; secondly, comparative experiments are carried out under multiple candidate thresholds to evaluate the impact of different thresholds on entity alignment accuracy and recall rate; the preset knowledge graph contains a structured knowledge base of entities, relationships and attributes, and knowledge is represented and organized in the form of triples, where entity nodes carry attribute information and type labels, and entities are connected through semantic relationships, and each knowledge unit has deep semantic representation and vectorized encoding.

[0052] Specifically, a multi-head attention mechanism is used through the relationship mapping unit to perform semantic mapping on the relationship words of the basic knowledge structure and the relationships in the preset knowledge graph, and the correspondence between the relationships is extracted; an alignment matrix is ​​constructed based on the entity alignment results of the entity alignment unit and the mapping results of the relationship mapping unit; entity attribute features related to the alignment matrix are extracted from the preset knowledge graph, and the relationship topology features between entities are extracted at the same time.

[0053] Furthermore, entity attribute features include entity type labels, attribute values, and numerical features; relationship topology features include relationship directionality, relationship strength, and path distance.

[0054] Furthermore, the entity attribute features and the relationship topology features are combined to form a multidimensional knowledge feature matrix, where the rows of the multidimensional knowledge feature matrix represent different entity nodes and the columns represent the corresponding attribute dimensions and topology features.

[0055] S3: Based on the multi-dimensional knowledge feature matrix, a dynamic weight allocator is used to calculate the association strength between knowledge nodes, and a hierarchical question-answering path is constructed in descending order of association strength.

[0056] Specifically, the method for constructing a hierarchical question-answering path is that the dynamic weight allocator includes a feature aggregation unit and a weight calculation unit; the feature aggregation unit performs weighted summation on the attribute features of the nodes in the multidimensional knowledge feature matrix to generate a node representation vector; the weight calculation unit calculates the association strength of node pairs based on the node representation vector and screens the node pairs.

[0057] Furthermore, the specific formula of association strength is as follows:

[0058]

[0059] Among them, R ij is the association strength value between node i and node j, v i and v j are the characterization vectors of nodes i and j respectively, and T is the characterization vector v i The transpose of M is the feature transformation matrix, β, ε and γ are adjustment coefficients, d is the feature dimension, and w k is the weight coefficient of the k-th dimension feature, x ik and x jk are the eigenvalues ​​of node i and node j in the kth dimension respectively.

[0060] Furthermore, the screening includes, when the association strength value of the calculated node pair is greater than or equal to a second preset threshold, the node pair is retained and included in the subsequent hierarchical question-and-answer path construction process; when the association strength value of the calculated node pair is less than the second preset threshold, the node pair is eliminated.

[0061] It should be noted that the second preset threshold is a dynamic parameter determined based on the statistical distribution of the knowledge node association strength and experimental verification. By calculating the association strength of large-scale knowledge node pairs, the distribution characteristics of the association strength are obtained and their natural segmentation points are analyzed; at the same time, comparative experiments are conducted under multiple candidate thresholds to evaluate the impact of different thresholds on the construction of hierarchical question-answering paths.

[0062] Specifically, the node pairs that pass the screening are sorted from high to low according to the association strength value, and the node pairs are divided into different levels based on the sorting results; within each level, a directed connection path is constructed based on the semantic dependency relationship and relationship topological characteristics of the node pairs; the directed connection paths of each level are connected in series in sequence to form a hierarchical question-and-answer path, in which high-level nodes serve as core knowledge points and low-level nodes serve as extended knowledge points.

[0063] S4: Input the hierarchical question-answer path into the constructed attention model, and generate a question-answer pair dataset based on the question-answer template library.

[0064] Specifically, the attention model includes an encoder and a decoder; the encoder includes, performing multi-level feature extraction on the input hierarchical question and answer path; calculating the attention weight score of each knowledge node in the path through the self-attention mechanism, and identifying the key knowledge nodes based on the attention weight score; the decoder includes, matching the key knowledge nodes with the corresponding question and answer templates according to the question and answer templates pre-stored in the question and answer template library.

[0065] Furthermore, matching the key knowledge nodes with the corresponding question and answer templates includes extracting feature vectors of the input key knowledge nodes; the feature vector contains the node's type identification, attribute characteristics, relationship structure and contextual semantic information; a semantic similarity algorithm is used to calculate the matching degree between the secondary feature vector and the question and answer template, and a candidate question and answer template is selected based on a preset threshold; in the fine matching stage, an evaluation is performed from three dimensions: node type consistency, attribute completeness and relationship structure matching degree, and a weighted calculation is performed based on the historical frequency of use of the question and answer template, the question and answer quality and the contextual applicability to obtain a comprehensive matching score; the question and answer template with the highest score is instantiated, and the specific attribute values ​​of the knowledge node are mapped to the question and answer template variable position, and related information is supplemented from the knowledge graph when necessary; the quality verification mechanism is initiated, and an evaluation is performed based on indicators such as semantic integrity, logical consistency and expression accuracy.

[0066] It should be noted that the question and answer template library contains multiple types of question and answer modes, and each mode is provided with corresponding question templates and answer templates.

[0067] Furthermore, the method for generating a question-answer pair dataset is to dynamically integrate the semantic information of key knowledge nodes into the structure of the question-answer model through a cross-attention mechanism to generate question-answer pairs, where the question-answer pairs include question text, answer text and corresponding knowledge path information; based on the question-answer pairs, rule filtering and semantic similarity calculation are used for screening.

[0068] Specifically, the screening includes: when the semantic similarity value between the entity in the basic knowledge structure and the entity in the preset knowledge graph is greater than or equal to a third preset threshold, it is determined that there is semantic duplication in the question and answer pair and the question and answer pair is eliminated; when the semantic similarity value between the entity in the basic knowledge structure and the entity in the preset knowledge graph is less than the third preset threshold, the question and answer pair is retained.

[0069] It should be noted that the third preset threshold is a dynamic parameter value determined through semantic similarity distribution statistics and data verification experiments.

[0070] Furthermore, the screened question-answer pairs are organized according to the hierarchical relationship of knowledge nodes to form a structured question-answer pair dataset.

[0071] Furthermore, the present embodiment also provides a question and answer generation method system based on a knowledge graph, including: an extraction and conversion module, which is used to process the input text corpus using a bidirectional semantic encoder, extract entity words and relationship words, form a first semantic vector, and convert the first semantic vector into a basic knowledge structure through a triple decomposer; a generation module, which is used to align the basic knowledge structure with the deep semantic information in a preset knowledge graph using a hierarchical knowledge fusion network to generate a multi-dimensional knowledge feature matrix; a construction module, which uses a dynamic weight allocator to calculate the correlation strength between knowledge nodes based on the multi-dimensional knowledge feature matrix, and constructs a hierarchical question and answer path in order of correlation strength from high to low; a generation module, which is used to input the hierarchical question and answer path into the constructed attention model, and generate a question and answer pair data set according to the question and answer template library.

[0072] This embodiment also provides a computer device, which is suitable for the question and answer generation method based on the knowledge graph, including a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the question and answer generation method based on the knowledge graph proposed in the above embodiment.

[0073] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.

[0074] The present embodiment also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps: using a bidirectional semantic encoder to process an input text corpus, extracting entity words and relation words to form a first semantic vector, and converting the first semantic vector into a basic knowledge structure through a triple decomposer; using a hierarchical knowledge fusion network to align the basic knowledge structure with the deep semantic information in a preset knowledge graph to generate a multidimensional knowledge feature matrix; based on the multidimensional knowledge feature matrix, using a dynamic weight allocator to calculate the association strength between knowledge nodes, and constructing a hierarchical question-answer path in descending order of association strength; inputting the hierarchical question-answer path into the constructed attention model, and generating a question-answer pair dataset based on a question-answer template library.

[0075] In summary, the present invention uses a bidirectional semantic encoder and a multi-level named entity recognition model for text processing to achieve high-precision entity and relationship extraction and effectively retain the contextual semantic information of the text; through the semantic alignment mechanism of the hierarchical knowledge fusion network, the deep semantic fusion of the basic knowledge structure and the preset knowledge graph is realized to improve the integrity of knowledge representation; the hierarchical question and answer path constructed based on the dynamic weight allocator ensures the rationality of knowledge connection and the progressiveness of knowledge transfer; through the cooperation of the attention model and the question and answer template library, the intelligent generation of high-quality question and answer pairs is achieved.

[0076] Example 2

[0077] Referring to Table 1, which is the second embodiment of the present invention, this embodiment provides a question-answer generation method based on a knowledge graph. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.

[0078] Specifically, we selected medical text corpus as the test data set; 5,000 medical paper abstracts and 3,000 clinical diagnosis and treatment records were used to construct the test data set, and the public medical knowledge graph CMeKG was selected as the preset knowledge graph. The experiment was conducted on a server equipped with Intel(R) Xeon(R) Gold 6248R CPU@3.00GHz, NVIDIA Tesla A100 graphics card, 256GB memory, and the operating system was Ubuntu20.04.

[0079] Furthermore, in the text processing stage, an improved BERT-BiLSTM bidirectional semantic encoder architecture is adopted. The forward and backward layers of the encoder both adopt a 3-layer BiLSTM structure, the hidden layer dimension is set to 768, and the number of attention heads is 12. In order to enhance the feature extraction capability of the model, a multi-scale feature extraction module based on CNN is introduced, and three convolution kernels of sizes 3, 5, and 7 are designed, and the number of feature channels is uniformly configured to 256. Through a large number of experimental verifications, the optimal fusion weights of the forward encoding layer and the backward encoding layer are determined to be 0.6 and 0.4, respectively. In terms of sequence representation, a sinusoidal position encoding scheme matching the hidden layer dimension is adopted to effectively maintain the sequence position information. The entity recognition link uses a BiLSTM-CRF model optimized specifically for the medical field, which has achieved an F1 score of 92.3% on the medical entity recognition task.

[0080] Furthermore, a hierarchical processing strategy is adopted in the knowledge fusion stage. The core of the knowledge fusion network is a 4-layer Graph Transformer structure, with 8 attention heads configured in each layer to capture knowledge features from multiple angles. The entity alignment unit sets the similarity threshold to 0.85 to ensure the matching quality; the relationship mapping unit uses a 6-head attention mechanism for semantic mapping. When constructing the knowledge feature matrix, the 20 key attribute features and 15 topological features of the entity are comprehensively considered to form a multi-dimensional feature representation. In the process of constructing the hierarchical question-answer path, the dynamic weight allocator adopts a 3-layer GAT network structure, and the output dimension is set to 512, which realizes efficient feature aggregation. The weight calculation adopts a three-item weighting scheme, and the weight coefficients are λ1=0.4, λ2=0.3, and λ3=0.3 respectively. The entire knowledge network is divided into 5 levels, each level contains an average of 200 nodes, forming a clear hierarchical structure.

[0081] Specifically, in the question-answer generation phase, a symmetrical Transformer architecture is used, with a 6-layer structure for both the encoder and decoder, a 512-dimensional hidden layer, and 8 attention heads. To ensure the quality and diversity of the generated question-answer pairs, a question-answer template library containing 2,000 high-quality templates is pre-built. In the question-answer pair screening phase, the semantic similarity threshold is set to 0.8 to ensure the accuracy and practicality of the generated results.

[0082] Furthermore, as shown in Table 1, the method of the present invention is significantly better than the traditional BERT-QA method in all performance indicators; in terms of question-answering accuracy, the method of the present invention reaches 91.2%, which is significantly higher than the 82.5% of the traditional BERT-QA method, reflecting the advantage of the method in question-answering accuracy; the knowledge coverage rate is increased from 75.3% to 88.6%, indicating that the method can handle a wider range of question types. In terms of semantic relevance index, the method of the present invention reaches 0.893, while the traditional method is 0.756, indicating that the method has better performance in understanding question semantics and generating relevant answers. In terms of efficiency, the question generation speed is increased from 15.2 questions / second to 25.6 questions / second, and the processing efficiency is significantly improved.

[0083] Table 1 Comparison between the present invention and the traditional method

[0084] Test indicators Traditional BERT-QA Method Method of the present invention Question and answer accuracy (%) 82.5 91.2 Knowledge coverage (%) 75.3 88.6 Semantic relevance 0.756 0.893 Question generation rate (questions / second) 15.2 25.6 Knowledge reasoning depth (layer) 2.3 4.2 Answer completeness score 0.723 0.876 Question and answer pair quality score 7.5 8.8

[0085] Furthermore, the knowledge reasoning depth of the method of the present invention reaches 4.2 layers, far exceeding the 2.3 layers of the traditional method, indicating that the system has stronger multi-level reasoning capabilities; the answer completeness score is improved from 0.723 to 0.876, indicating that the answers generated by this method are more complete and comprehensive; the question and answer quality score is improved from 7.5 to 8.8, which comprehensively reflects the overall improvement of the question and answer quality of this method.

[0086] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A question-answer generation method based on knowledge graph, characterized in that: include, Using a bidirectional semantic encoder to process the input text corpus, extracting entity words and relation words to form a first semantic vector, and converting the first semantic vector into a basic knowledge structure through a triple decomposer; Using a hierarchical knowledge fusion network, the basic knowledge structure and deep semantic information in a preset knowledge graph are aligned to generate a multi-dimensional knowledge feature matrix; Based on the multi-dimensional knowledge feature matrix, a dynamic weight allocator is used to calculate the association strength between knowledge nodes, and a hierarchical question-answering path is constructed in descending order of association strength; The hierarchical question-answer path is input into the constructed attention model, and a question-answer pair dataset is generated according to the question-answer template library.

2. The question-answer generation method based on knowledge graph according to claim 1, characterized in that: The attention model includes an encoder and a decoder; the encoder performs multi-level feature extraction on the input hierarchical question-answer path, and calculates the attention weight score of each knowledge node in the path through the self-attention mechanism to identify the key knowledge nodes; the decoder matches the key knowledge nodes with the corresponding question-answer templates according to the question-answer templates pre-stored in the question-answer template library; the method for generating the question-answer pair data set is as follows: Dynamically integrating the semantic information of the key knowledge nodes into the structure of the question-answering model through a cross-attention mechanism to generate a question-answer pair, wherein the question-answer pair includes a question text, an answer text, and corresponding knowledge path information; Based on the question-answer pairs, screening is performed using rule filtering and semantic similarity calculation; The screened question-answer pairs are organized according to the hierarchical relationship of knowledge nodes to form a structured question-answer pair dataset.

3. The question-answer generation method based on knowledge graph according to claim 2, characterized in that: The method for constructing the hierarchical question-answering path is: The dynamic weight allocator includes a feature aggregation unit and a weight calculation unit; The feature aggregation unit performs weighted summation on the attribute features of the nodes in the multidimensional knowledge feature matrix to generate a node representation vector; the weight calculation unit calculates the association strength of the node pairs based on the node representation vector and screens the node pairs; Sort the node pairs that pass the screening from high to low according to the association strength value, and divide the node pairs into different levels based on the sorting results; In each level, a directed connection path is constructed based on the semantic dependency relationship and relationship topology characteristics of the node pairs; The directed connection paths of each level are connected in series to form a hierarchical question-answering path, in which high-level nodes serve as core knowledge points and low-level nodes serve as extended knowledge points.

4. The question-answer generation method based on knowledge graph according to claim 3, characterized in that: The specific formula of the association strength is as follows: Among them, R ij is the association strength value between node i and node j, v i and v j are the characterization vectors of nodes i and j respectively, and T is the characterization vector v i The transpose of M is the feature transformation matrix, β, ε and γ are adjustment coefficients, d is the feature dimension, and w k is the weight coefficient of the k-th dimension feature, x ik and x jk are the eigenvalues ​​of node i and node j in the kth dimension respectively.

5. The question-answer generation method based on knowledge graph according to claim 4, characterized in that: Based on the multi-dimensional knowledge feature matrix, A dynamic weight allocator is used to calculate the association strength between knowledge nodes, and a hierarchical question-answering path is constructed in descending order of association strength, including: The hierarchical knowledge fusion network includes an entity alignment unit and a relationship mapping unit; The entity alignment unit calculates the semantic similarity between the entity in the basic knowledge structure and the entity in the preset knowledge graph to determine whether the entity pair meets the matching conditions; The relationship mapping unit uses a multi-head attention mechanism to perform semantic mapping on the relationship words of the basic knowledge structure and the relationships in the preset knowledge graph to extract the corresponding relationship between the relationships; Constructing an alignment matrix based on the entity alignment result of the entity alignment unit and the mapping result of the relationship mapping unit; Extracting entity attribute features related to the alignment matrix from a preset knowledge graph, and extracting relationship topology features between entities; The entity attribute features and the relationship topology features are combined to form a multidimensional knowledge feature matrix, wherein the rows of the multidimensional knowledge feature matrix represent different entity nodes, and the columns represent corresponding attribute dimensions and topology features.

6. The question-answer generation method based on knowledge graph according to claim 5, characterized in that: The specific formula of the semantic similarity is as follows: Among them, Sim(e1,e2) is the semantic similarity value between the entity in the basic knowledge structure and the entity in the preset knowledge graph, α is the weight coefficient of the semantic similarity, v1 is the vectorized semantic representation of the entity in the basic knowledge structure, v2 is the vectorized semantic representation of the entity in the preset knowledge graph, n is the number of attributes of the entity, is the i-th attribute of the entity in the basic knowledge structure, is the i-th attribute of the entity in the preset knowledge graph, is the similarity score of the i-th attribute, e1 is the entity in the basic knowledge structure, and e2 is the entity in the preset knowledge graph; When the semantic similarity is greater than or equal to a first preset threshold, the entity pair is matched; When the semantic similarity is less than the first preset threshold, the entity pair is temporarily stored in the pending buffer area, the semantic representation of the entity is expanded, and the semantic similarity of the expanded entity is recalculated; if the semantic similarity of the expanded entity is still less than the first preset threshold, the entity pair is marked as unmatched, and the corresponding position in the alignment matrix is ​​filled with zero value; if the semantic similarity of the expanded entity is still greater than or equal to the first preset threshold, the entity pair is matched.

7. The question-answer generation method based on knowledge graph according to claim 6, characterized in that: The input text corpus is processed by a bidirectional semantic encoder to extract entity words and relation words to form a first semantic vector, and the first semantic vector is converted into a basic knowledge structure by a triple decomposer, including: The bidirectional semantic encoder comprises a forward encoding layer and a backward encoding layer; the forward encoding layer sequentially scans the word units in the input text corpus from left to right; the backward encoding layer sequentially scans the word units in the input text corpus from right to left; the conversion method of the basic knowledge structure is: The output results of the forward coding layer and the backward coding layer are adaptively fused, the importance of the forward coding layer and the backward coding layer is determined by a dynamic weight allocation mechanism, and a multi-scale convolution operation is introduced to extract local semantic features, and the sequence feature representation of the input text corpus is enhanced in combination with the position coding information to generate a text semantic representation; The text semantic representation is processed using a preset named entity recognition model to identify and annotate the type and boundary information of entity words; Utilizing a dependency parser to analyze the syntactic structure of the text semantic representation and extracting relationship words between entity words; The identified entity words, the type and boundary information of the entity words, the relation words, and the semantic features corresponding to the relation words are serially combined in the vector space by a feature concatenator to form a first semantic vector; Processing the first semantic vector by a triple decomposer, and dividing the semantic vector into a plurality of sub-vector segments by a sliding window mechanism; Semantic analysis and knowledge element extraction are performed on the plurality of sub-vector fragments to construct a basic knowledge structure.

8. A question-answer generation method system based on a knowledge graph, based on the question-answer generation method based on a knowledge graph according to any one of claims 1 to 7, characterized in that: include, An extraction and conversion module, used for processing the input text corpus using a bidirectional semantic encoder, extracting entity words and relation words to form a first semantic vector, and converting the first semantic vector into a basic knowledge structure through a triple decomposer; A generation module, used to align the basic knowledge structure with the deep semantic information in the preset knowledge graph by using a hierarchical knowledge fusion network to generate a multi-dimensional knowledge feature matrix; A construction module, based on the multi-dimensional knowledge feature matrix, uses a dynamic weight allocator to calculate the association strength between knowledge nodes, and constructs a hierarchical question-answering path in descending order of association strength; A generation module is used to input the hierarchical question-answer path into the constructed attention model and generate a question-answer pair dataset based on the question-answer template library.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the question and answer generation method based on the knowledge graph are implemented in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the question and answer generation method based on the knowledge graph are implemented in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Food safety question-answer reasoning method and system and electronic equipment

    CN113849613A

  • Knowledge reasoning method based on heterogeneous knowledge fusion

    CN117235216A

Cited By

  • Low-carbon community evaluation index library dynamic construction method and system

    CN120448595A

  • Data expansion and interaction method based on computer system

    CN120523326A

  • Method and system for correcting answer content based on image recognition

    CN120599636A

  • Product classification identification method and system based on AI technology

    CN120873855A

  • Product classification recognition method and system based on AI technology

    CN120873855B