A knowledge graph-based question and answer pair generation method

CN116822530BActive Publication Date: 2026-10-23HANGZHOU DIANZI UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310034743.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-10
Publication Date
2026-10-23
Estimated Expiration
2043-01-10

AI Technical Summary

Technical Problem

针对挑战(1) ,对Graph2Seq模型做出改进,引入句法依存树解决语法句法上不相似的问题;针对挑战(2) (3),提出了一种对知识图谱标注的策略,通过知识图谱标注获取同义词对,增强生成问句的多样性

Benefits of technology

[0035]本发明提出的一种基于知识图谱的问答对生成方法,首先抽取领域知识图谱中实体、关系、属性词,利用知识图谱标注策略,得到实体、关系、属性对应的同义词;抽取连通子图,通过基于的问句生成模型生成标准问句;将匹配到的同义词通过槽位填充替换到标准问句中,得到相似问句,最后与原答案组成问答对集合。本发明根据给定领域知识图谱生成领域问答对,使用知识图谱标注策略扩展问答对多样性,增强了知识图谱在问句理解中的领域性和专业性,提高了模板匹配的准确度,同时解决了在神经网络训练时领域问答对语料不足的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116822530B_ABST
    Figure CN116822530B_ABST
Patent Text Reader

Abstract

The application discloses a kind of question and answer pair generation methods based on knowledge graph.The application includes the following contents: first, extract entity, relationship, attribute word in domain knowledge graph, obtain the synonym of entity, relationship, attribute word using knowledge graph annotation strategy;Extract connected subgraph, generate standard question through the question generation model based on DPT-Loss;The matched synonym is replaced into the standard question by slot filling, to obtain similar question, finally with original answer constitutes question and answer pair set.The application generates domain question and answer pair according to given domain knowledge graph, uses knowledge graph annotation strategy to expand the diversity of question and answer pair, enhances the domain and professionalism of knowledge graph in question understanding, improves the accuracy of template matching, and at the same time solves the problem of insufficient domain question and answer pair corpus in neural network training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing, and more specifically to a question-answer pair generation method based on knowledge graphs. Background Technology

[0002] Knowledge graph-based question generation (KBQG) refers to the process of generating corresponding questions by fully utilizing the knowledge in a knowledge graph and providing specified answer information. Currently, there are three main methods for solving KBQG: template-based question generation, Seq2Seq-based question generation, and Graph2Seq-based question generation.

[0003] Template-based question generation generates questions by manually constructing question templates and filling slots; Seq2Seq-based question generation constructs a sequence from a triple and generates questions through a trained Encoder-Decoder model; Graph2Seq-based question generation preserves the structural information of the subgraph, encodes the entire subgraph, and can generate more complex questions.

[0004] Recent research has focused on question generation based on the Graph2Seq model. However, this approach faces several challenges when applying complex KBQG: (1) Existing learning models cannot guarantee that the generated questions match the answers in terms of syntax and grammar; (2) Existing methods cannot generate diverse questions, resulting in low accuracy when processing downstream tasks; (3) Current methods are based on general domains and have shortcomings when answering more specialized questions. Summary of the Invention

[0005] This invention proposes a question-answer pair generation method based on knowledge graphs. To address challenge (1), the Graph2Seq model is improved by introducing a syntactic dependency tree to solve the problem of syntactic dissimilarity. To address challenges (2) and (3), a strategy for knowledge graph annotation is proposed to obtain synonym pairs through knowledge graph annotation, thereby enhancing the diversity of generated questions.

[0006] A question-answer pair generation method based on knowledge graphs includes the following steps:

[0007] S1. Obtain the domain knowledge graph, and automatically and guidedly annotate entities, relations, and attribute words based on the domain knowledge graph to obtain synonym pairs;

[0008] S2, Training Based on A question generation model;

[0009] S21. Obtain an open-domain knowledge graph, which includes questions and standard answers. Encode the open-domain knowledge graph and the standard answers using Graph Transformer and BiLSTM respectively, and input them into an LSTM decoder to obtain the output of the LSTM decoder. Concatenate the outputs of the LSTM decoder to form an initial question sequence. ;

[0010] S22. Initial question sequence The question in the open-domain knowledge graph described in step S21 is segmented into words to obtain... ,in, This represents the n words obtained after word segmentation. The TF-IDF algorithm is used to calculate the value of each of the n words. The weights are used to obtain the weights of the n word segments. By using the BERT model for word embedding, semantic vectors corresponding to n word segments are obtained. ;

[0011] S23, Regarding the initial question sequence Dependency parsing is performed on the questions in the open-domain knowledge graph described in step S21 to form a corresponding syntactic dependency tree, wherein the leaf nodes of the syntactic dependency tree are { }, ;in, These represent the i-th word segment, the weight of the i-th word segment, and the semantic vector corresponding to the i-th word segment, respectively.

[0012] S24. Initial question sequence The syntactic dependency tree and the syntactic dependency tree of the problem in the open-domain knowledge graph described in step S21, any two nodes , To make a comparison, if , If all are leaf nodes, then

[0013] ;

[0014] in express and Cosine similarity between them Represents the similarity matrix. Represents a node With nodes The similarity between them;

[0015] if , If there is only one leaf node in the set, then let

[0016] ;

[0017] if , If neither is a leaf node, then it will be... , Repeat operation S24 for the subtree of the root node until all nodes have been compared.

[0018] S25. Perform Max Pooling on each row of K described in S24 to obtain... The matrix, and then the matrix... Perform Average Pooling on the matrix to obtain the similarity. ;

[0019] S26. Define the loss function:

[0020]

[0021] in This represents a hyperparameter that controls the weighting of the two loss functions. Represents the cross-entropy loss function;

[0022] S27, the loss function The value is fed back to the question generation model, and the question generation model is fine-tuned to obtain the fine-tuned question generation model.

[0023] S3. Extract connected subgraphs from the domain knowledge graph described in step S1, traverse the data of the connected subgraphs as answers, and use the fine-tuned question generation model obtained in step S27 to generate standard questions corresponding to the answers.

[0024] S4. Replace the entity, relation, and attribute words involved in the standard questions obtained in step S3 with the synonym pairs obtained in step S1 to obtain several different similar questions. Combine the standard questions, similar questions, and the answers described in S3 to obtain a question-answer pair set.

[0025] Preferably, in step S1, the method for automated and guided annotation of entities, relations, and attribute words is as follows:

[0026] For each triple in the domain knowledge graph, the entities, relations, and attribute words are tagged with part-of-speech tags. Entities, relations, and attributes tagged as function words, numerals, quantifiers, and pronouns are removed, while entities, relations, and attributes tagged as nouns, verbs, and adjectives are retained.

[0027] Preferably, in step S1, the method for obtaining synonym pairs is as follows:

[0028] Define a set of synonym matching patterns ,in This refers to a synonym matching pattern with target word slots and synonym slots, where m represents the number of synonym matching patterns.

[0029] Entities, relations, and attributes labeled as nouns, verbs, and adjectives will be used as target words. Iterate through the set of synonym matching patterns. all elements ,Will Replace to The target word slots are used to obtain matching patterns that only contain synonym slots. ;

[0030] In open source knowledge bases, according to Perform a match to obtain Synonyms To form a pair of synonyms .

[0031] Preferably, in step S3, the connected subgraph is ,in, These represent the subgraph number, node set, and edge set, respectively.

[0032] In step S3, the data is the connected subgraph. All entities, relations, and attribute terms in;

[0033] Part-of-speech tagging is performed on the answer in step S3 to obtain answer type information;

[0034] In step S3, generating a standard question corresponding to the answer using the fine-tuned question generation model obtained in step S27 includes: connecting the subgraph... The answer and answer type information are input into the fine-tuned question generation model obtained in step S27, and the question generation model outputs a standard question.

[0035] This invention proposes a question-answering pair generation method based on knowledge graphs. First, it extracts entity, relation, and attribute words from a domain knowledge graph. Then, using a knowledge graph annotation strategy, it obtains synonyms corresponding to the entities, relations, and attributes. Next, it extracts connected subgraphs and, based on... The invention generates standard questions using a question generation model; matched synonyms are then replaced into the standard questions through slot filling to obtain similar questions, which are finally combined with the original answers to form a question-answer pair set. This invention generates domain-specific question-answer pairs based on a given domain knowledge graph, uses knowledge graph annotation strategies to expand the diversity of question-answer pairs, enhances the domain-specificity and professionalism of the knowledge graph in question understanding, improves the accuracy of template matching, and simultaneously solves the problem of insufficient domain-specific question-answer pair corpora during neural network training. Attached Figure Description

[0036] Figure 1 This is a flowchart illustrating a knowledge graph-based question-answer pair generation method according to an embodiment of the present invention. Detailed Implementation

[0037] To make the technical solution and advantages of the present invention clearer, the present invention will be further described below with reference to the accompanying drawings. The specific contents are as follows:

[0038] S1. Obtain the domain knowledge graph, and automatically and guidedly annotate entities, relations, and attribute words based on the domain knowledge graph to obtain synonym pairs:

[0039] S11. Based on the given domain knowledge graph, use HanLP to perform part-of-speech tagging on the entities, relations, and attributes in each triple. Remove entities, relations, and attributes that are tagged as function words, numerals, quantifiers, and pronouns, and retain entities, relations, and attributes that are tagged as nouns, verbs, and adjectives.

[0040] S12. Define the set of synonym matching patterns. ,in This refers to a synonym matching pattern with target word slots and synonym slots, where m represents the number of synonym matching patterns. The synonym matching patterns are as follows: Indicates the target word slot. Synonym slots:

[0041] S13. In this embodiment, the synonym matching pattern set is defined. as follows:

[0042] I. Also known as ;

[0043] II.

[0044] III. Abbreviation

[0045] IV. Also known as

[0046] S14. Use the entities, relations, and attributes marked as nouns, verbs, and adjectives in S11 as target words. Iterate through the set of synonym matching patterns. all elements ,Will Replace to The target word slots are used to obtain matching patterns that only contain synonym slots. ;

[0047] S15. In this embodiment, taking Hangzhou Dianzi University, which was marked as a place name in S11, as an example, the standard word slot in the synonym matching pattern is replaced with Hangzhou Dianzi University. Get the matching pattern as follows:

[0048] I. Hangzhou Dianzi University, also known as ;

[0049] II. Hangzhou Dianzi University

[0050] III. Abbreviation of Hangzhou Dianzi University

[0051] IV. Hangzhou Dianzi University, also known as

[0052] S16. According to Wikipedia and Baidu Baike, Perform matching and extract entries from Wikipedia and Baidu Baike. Sentences;

[0053] S17. In this embodiment, the sentence is obtained as follows:

[0054] I. Hangzhou Dianzi University, also known as Hangdian;

[0055] II. Hangzhou Dianzi University (Hangdian)

[0056] III. Hangzhou Dianzi University (abbreviated as HDD)

[0057] IV. Hangzhou Dianzi University, also known as Hangdian University

[0058] S18, according to the above Chinese synonym slots The position is used to extract the corresponding words from the sentence obtained in step S16, resulting in... Synonyms To form a pair of synonyms ;

[0059] S19. In this embodiment, synonym pairs are obtained.

[0060] S2, Training Based on Question generation model:

[0061] S21. Obtain DBpedia data, which includes an open-domain knowledge graph, questions, and standard answers. Encode the open-domain knowledge graph and the standard answers using Graph Transformer and BiLSTM respectively, input them into an LSTM decoder, and concatenate the decoder's output to form an initial question sequence. ;

[0062] S22. Initial question sequence Regarding the issue in DBpedia mentioned in S21, HanLP was used for word segmentation to obtain... ,in, This represents the n words obtained after word segmentation. The TF-IDF algorithm is used to calculate the values ​​of each of the n words. The weights are used to obtain the weights of the n word segments. By using the BERT model for word embedding, semantic vectors corresponding to n word segments are obtained. ;

[0063] S23, Regarding the initial question sequence Regarding the problem in DBpedia described in S21, HanLP is used for dependency parsing to form a corresponding syntactic dependency tree. The leaf nodes of the syntactic dependency tree are { }, ;in, These represent the i-th word segment, the weight of the i-th word segment, and the semantic vector corresponding to the i-th word segment, respectively.

[0064] S24. Initial question sequence The syntactic dependency tree of the problem in DBpedia described in S21, and any two nodes , In comparison, if , If all are leaf nodes, then

[0065] ;

[0066] in express and Cosine similarity between them Represents the similarity matrix. Represents a node With nodes The similarity between them;

[0067] if , If there is only one leaf node in the set, then let

[0068] ;

[0069] if , If neither is a leaf node, then it will be... , Repeat operation S24 for the subtree of the root node until all nodes have been compared.

[0070] S25. Perform Max Pooling on each row of K described in S24 to obtain... The matrix, and then the matrix... Perform Average Pooling on the matrix to obtain the similarity. ;

[0071] S26. Define the loss function:

[0072]

[0073] in The hyperparameter represents the weighting of the two loss functions. In this embodiment... Take 0.5, Represents the cross-entropy loss function;

[0074] S27, the loss function The value is fed back to the model, and the model is fine-tuned to obtain the fine-tuned question generation model.

[0075] S3. Extract connected subgraphs from the domain knowledge graph described in step S1, traverse the data of the connected subgraphs as answers, and use the fine-tuned question generation model obtained in step S27 to generate standard questions corresponding to the answers:

[0076] S31. Extract connected subgraphs from the domain knowledge graph described in S1. traversal All entities, relations, and attributes in the code are used as answers. Part-of-speech tagging is performed on the answers to obtain answer type information. These represent the subgraph number, node set, and edge set, respectively.

[0077] S32. In this embodiment, a connected subgraph is extracted from the domain knowledge graph described in S1 and displayed in the form of a triple (Hangzhou Dianzi University, location, Hangzhou). All entities, relations, and attributes in the connected subgraph are traversed as the answer. Here, taking Hangzhou as an example, Hangzhou is tagged with parts of speech to obtain the answer type information, which belongs to the place name.

[0078] S33. Input the connected subgraph, answer, and answer type information described in S31 into the question generation model trained in step S2. The question generation model outputs a standard question.

[0079] S34. In this embodiment, (Hangzhou Dianzi University, location, Hangzhou), Hangzhou, and place name are input into the question generation model. The question generation model outputs the standard question: Where is Hangzhou Dianzi University located?

[0080] S4. For the entity, relation, and attribute words involved in the standard questions obtained in step S3, replace them with the synonym pairs obtained in step S1 to obtain several different similar questions. Combine the standard questions, similar questions, and the answers described in S3 to obtain a question-answer pair set:

[0081] S41. In this embodiment, the standard question obtained in step S34, "Where is Hangzhou Dianzi University located?", is replaced with the synonym pair (Hangzhou Dianzi University, HANDS) obtained in step S19 to obtain the similar question: "Where is HANDS located?". The standard question and the similar question are combined with the answer to obtain the question-answer pair (Where is Hangzhou Dianzi University located, Hangzhou) and (Where is HANDS located, Hangzhou).

Claims

1. A question-answer pair generation method based on knowledge graphs, characterized in that, Includes the following steps: S1. Obtain the domain knowledge graph, and automatically and guidedly annotate entities, relations, and attribute words based on the domain knowledge graph to obtain synonym pairs; S2, Training Based on A question generation model; S21. Obtain an open-domain knowledge graph, which includes questions and standard answers. Encode the open-domain knowledge graph and the standard answers using Graph Transformer and BiLSTM respectively, and input them into an LSTM decoder to obtain the output of the LSTM decoder. Concatenate the outputs of the LSTM decoder to form an initial question sequence. ; S22. Initial question sequence The question in the open-domain knowledge graph described in step S21 is segmented into words to obtain... ,in, This represents the n words obtained after word segmentation. The TF-IDF algorithm is used to calculate the value of each of the n words. The weights are used to obtain the weights of the n word segments. By using the BERT model for word embedding, semantic vectors corresponding to n word segments are obtained. ; S23, Regarding the initial question sequence Dependency parsing is performed on the questions in the open-domain knowledge graph described in step S21 to form a corresponding syntactic dependency tree, wherein the leaf nodes of the syntactic dependency tree are { }, ;in, These represent the i-th word segment, the weight of the i-th word segment, and the semantic vector corresponding to the i-th word segment, respectively. S24. Initial question sequence The syntactic dependency tree and the syntactic dependency tree of the problem in the open-domain knowledge graph described in step S21, any two nodes , To make a comparison, if , If all are leaf nodes, then ; in express and Cosine similarity between them Represents the similarity matrix. Represents a node With nodes The similarity between them; if , If there is only one leaf node in the set, then let ; if , If neither is a leaf node, then it will be... , Repeat operation S24 for the subtree of the root node until all nodes have been compared. S25. Perform Max Pooling on each row of K described in S24 to obtain... The matrix, and then the matrix... Perform Average Pooling on the matrix to obtain the similarity. ; S26. Define the loss function: in This represents a hyperparameter that controls the weighting of the two loss functions. Represents the cross-entropy loss function; S27, the loss function The value is fed back to the question generation model, and the question generation model is fine-tuned to obtain the fine-tuned question generation model. S3. Extract connected subgraphs from the domain knowledge graph described in step S1, traverse the data of the connected subgraphs as answers, and use the fine-tuned question generation model obtained in step S27 to generate standard questions corresponding to the answers. S4. Replace the entity, relation, and attribute words involved in the standard questions obtained in step S3 with the synonym pairs obtained in step S1 to obtain several different similar questions. Combine the standard questions, similar questions, and the answers described in S3 to obtain a question-answer pair set.

2. The question-answer pair generation method based on knowledge graph as described in claim 1, characterized in that, In step S1, the method for automated and guided annotation of entities, relations, and attribute words is as follows: For each triple in the domain knowledge graph, the entities, relations, and attribute words are tagged with part-of-speech tags. Entities, relations, and attributes tagged as function words, numerals, quantifiers, and pronouns are removed, while entities, relations, and attributes tagged as nouns, verbs, and adjectives are retained.

3. The question-answer pair generation method based on knowledge graph as described in claim 2, characterized in that, In step S1, the method for obtaining synonym pairs is as follows: Define a set of synonym matching patterns ,in This refers to a synonym matching pattern with target word slots and synonym slots, where m represents the number of synonym matching patterns. Entities, relations, and attributes labeled as nouns, verbs, and adjectives will be used as target words. Iterate through the set of synonym matching patterns. all elements ,Will Replace to The target word slots are used to obtain matching patterns that only contain synonym slots. ; In open source knowledge bases, according to Perform a match to obtain Synonyms To form a pair of synonyms .

4. The question-answer pair generation method based on knowledge graph as described in claim 3, characterized in that, In step S3, the connected subgraph is ,in, These represent the subgraph number, node set, and edge set, respectively. In step S3, the data is the connected subgraph. All entities, relationships, and attributes in; Part-of-speech tagging is performed on the answer in step S3 to obtain answer type information; In step S3, generating a standard question corresponding to the answer using the fine-tuned question generation model obtained in step S27 includes: connecting the subgraph... The answer and answer type information are input into the fine-tuned question generation model obtained in step S27, and the question generation model outputs a standard question.

Citation Information

Patent Citations

  • Intelligent question and answer method based on domain knowledge graph and Steiner tree

    CN114020885A

  • Citrus management and control question and answer module construction method based on knowledge graph and question and answer system

    CN114036281A