An intelligent question-answering method and system based on a domain knowledge graph
Patent Information
- Application Number
- CN202311435968.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-10-31
AI Technical Summary
[0013]基于规则的模板匹配方法虽然可以很好的适用专业或者受限领域,无需大规模的数据训练,可以实现快速的结果返回,但其对非标准化输入和多变的自然语言表述难以胜任,随着知识库的扩大和更新,维护和更新模板也变得耗时且资源密集
[0057] Compared with existing knowledge graph question answering technologies, this invention has the following advantages:
Smart Images

Figure CN117648984B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an intelligent question-answering method and system based on domain knowledge graphs, belonging to the field of computer natural language processing technology. Background Technology
[0002] Since Google introduced large-scale knowledge graphs to its search engine in 2012, knowledge graphs have been widely used in various fields (such as healthcare and finance). Knowledge graphs can be categorized into general-domain and vertical-domain knowledge graphs based on the problem domain of their application. General-domain knowledge graphs cover a wide range of domains, are large in scale, and have a high degree of automation. In contrast, vertical-domain knowledge graphs are built based on data from a specific industry, are relatively smaller in scale, but contain high-quality and high-precision knowledge. Compared to other domains, building non-public domain knowledge graphs and datasets in vertical domains is a very challenging task. Information acquisition in this domain is characterized by fragmented information, high acquisition difficulty, and complex relationships between entities. Furthermore, the efficiency of building non-public domain knowledge graphs and datasets is relatively low. Therefore, building vertical domain knowledge graphs and datasets is highly challenging and requires in-depth research tailored to their specific characteristics.
[0003] In the construction of knowledge graphs for specific non-public domains, existing research results include: Li Huayu et al. trained an entity-relation joint extraction model based on the LEBERT model and relation extraction rules, ultimately realizing a multimodal computer science domain knowledge graph capable of automatically extracting relation triples. Deng Kai et al. proposed a domain knowledge graph construction method based on semi-structured data with rapid transferability, the main steps of which include: 1) dictionary construction; 2) data acquisition and cleaning; 3) entity maintenance and linking; 4) graph updating and visualization. Constructing a domain knowledge graph by acquiring entities and relations from multiple trusted data sources can effectively reduce manual labor and accelerate the construction of the knowledge graph. Meng Xiaofeng, based on the essential characteristics of semantic connections in knowledge graph construction, used triples as the modeling granularity to fully fit the interaction between head entities, relations, and tail entities, proposing the InterTris model. Due to the special nature of the data in this field, research results include: Chen et al., addressing the problems of data isolation, lack of related organization, and difficulty in effectively utilizing data in the informatization process, proposed a domain knowledge graph construction technology based on open-source and multi-data sources on the Internet. Liu Chenguang et al. proposed an entity relation extraction method based on Conditional Random Field (CRF) and syntactic parsing tree. Through massive data training, model comparison, and improvement, they optimized the construction of knowledge graphs. Faced with massive amounts of data, effective knowledge extraction methods can significantly improve the efficiency of knowledge graph construction. For example, Hou Zhenyu et al. used a BERT-CRF-PRF model for knowledge extraction, where BERT mainly consists of an embedding layer, a Transformer encoder, and a loss optimization layer. The CRF model can represent the joint probability of the entire feature sequence through the label relationship between adjacent positions, thus obtaining the optimal prediction result for the entire sequence.
[0004] Compared to general knowledge graph-based question answering, question answering based on non-public domain knowledge graphs typically requires specialized domain knowledge for question comprehension and necessitates the acquisition of more specialized information as supplementary tools. Therefore, the main challenge of knowledge graph-based question answering lies in the construction of the knowledge graph and how to transform user intent into structured statements that can be queried within the knowledge graph. Current research achievements in non-public domain knowledge graph-based question answering tasks include: Yilitai et al. applied deep learning and other intelligent recognition technologies to a medical question answering system, addressing the limitations of information redundancy and low efficiency in traditional medical question answering. They used a bidirectional Transformer-based joint learning model for knowledge extraction, an intent recognition and slot-filling algorithm based on the Stack-propagation framework for word segmentation and recognition of medical input questions, and constructed a medical knowledge graph using the Neo4j graph database to achieve question answering retrieval. Zhang Keliang et al.'s question answering system uses a domain ontology to classify questions and employs structured semantic information extraction methods to transform natural language questions into SPARQL queries, then searches for answers in the ontology knowledge base to resolve the questions. Based on this non-public domain knowledge graph, current research results on question answering include: Dou Xiaoqiang et al. proposed a question answering system consisting of three modules: question understanding, question solving, and answer generation. They used a Naive Bayes classifier to classify questions and then combined this with the knowledge graph to answer them. Sheng Jie et al. constructed a Support Vector Machine (SVM) multi-classifier for question classification, and used a Bidirectional Long Short-Term Memory (BiLSTM) network and Conditional Random Field (CRF) to complete the named entity recognition task, understanding the entities, attributes, and relationships in the questions. Then, they matched the user's question to the most similar question template. Finally, they used the generated graph database query statement Cypher to retrieve the answer from the constructed knowledge graph.
[0005] Knowledge graph-based question answering is an important subtask in dialogue generation. The combination of knowledge graphs and intelligent question answering can improve the accuracy and efficiency of question answering systems, providing users with better services and experiences. Early knowledge graph-based question answering mostly focused on simple questions containing only one relation, but most real-world questions are complex, containing multi-hop relations and constraints. Therefore, multi-hop question answering has recently received more attention. One of the most prominent challenges of knowledge graph-based question answering is the lexical gap—that is, the same question can be expressed in different ways in natural language. Since a knowledge graph is a standardized dictionary, how to learn a suitable model to map a natural language question to a structured knowledge base, thereby finding the correct answer, is the focus of knowledge graph multi-hop question answering research. Around the 1960s, the first question answering systems designed by Green et al. emerged. Their Baseball program could answer questions about baseball games in plain English. With the advent of machine learning and deep learning, the research direction of question answering systems has also moved away from templates and rules, developing towards large-scale datasets and intelligence. Research in this field has also expanded from fixed corpora to the entire internet.
[0006] Currently, the methods commonly used to solve knowledge graph-based question answering models mainly include:
[0007] 1. Query Graph Generation Model: In the question-answering domain of knowledge graphs, a common model strategy is to generate a corresponding query graph based on a specific question, then transform it into a structured statement for querying within the knowledge graph. However, as question complexity increases, the search space of the query graph expands dramatically. To effectively address this challenge, researchers Chen et al. and Lan et al. adopted a simplification strategy when generating query graphs. Specifically, they referenced the bundle search method, considering only the optimal relation when expanding the query graph path, rather than all possible relations.
[0008] 2. Graph Neural Network-Based Models: In recent years, graph neural network models such as GNN-QA and GraftNet have been widely used in knowledge graph question answering. These models efficiently represent knowledge graphs through graph neural networks, not only handling complex problems but also significantly optimizing the multi-hop question answering performance of knowledge graphs.
[0009] 3. In the field of natural language processing, pre-trained models such as BERT, RoBERTa, and GPT have achieved remarkable results. Recently, researchers have begun to explore the application of these models in knowledge graph-based question-answering systems, such as K-BERT. By learning from large amounts of knowledge graph data, these models can further improve the accuracy and efficiency of question answering.
[0010] 4. Cross-modal models: To more efficiently process and fuse multimodal information such as text and images, researchers have proposed cross-modal models, such as KVMN and MNLM. These models can not only fuse different forms of input information, but also achieve deeper semantic understanding and more accurate information extraction in a multimodal context. This approach opens up new possibilities for complex data processing and analysis tasks.
[0011] However, current knowledge graph-based question-answering models mainly rely on fixed sentence structures and lack in-depth learning and modeling of question sentences, thus affecting the model's generalization ability. Furthermore, the question-answering formats in specific non-public domains are complex and diverse, making it difficult for existing methods to meet the needs of varied and flexible questioning.
[0012] Classification-based knowledge graph question answering methods overemphasize model accuracy while neglecting model interpretability. This means that even if the answer is correct, users may still lack confidence because the model does not provide transparency regarding its decision-making process. Providing clear and interpretable justification for the decision is crucial; therefore, future research should emphasize the transparency and interpretability of model decisions while pursuing accuracy.
[0013] While rule-based template matching methods are well-suited for specialized or restricted fields, requiring no large-scale data training and enabling rapid result return, they struggle with non-standardized inputs and varied natural language expressions. Furthermore, as the knowledge base expands and updates, maintaining and updating templates becomes time-consuming and resource-intensive.
[0014] Although deep models can be trained to better handle complex, multi-layered open problems, training and running deep models often requires expensive computational resources and may sometimes provide inaccurate or irrelevant answers. Summary of the Invention
[0015] The purpose of this invention is to address the problems and shortcomings of existing technologies, and to creatively propose an intelligent question-answering method and system based on domain knowledge graphs to effectively solve technical problems such as the flexibility and interpretability of knowledge graph question answering.
[0016] This invention constructs datasets and knowledge graphs based on data from non-public data tables, including:
[0017] 1. Generate corresponding triples and generate a non-public domain dataset containing various random semantics using manual annotation;
[0018] 2. Combine the triples to form a knowledge graph and display it in a database (such as Neo4j).
[0019] On the one hand, this invention proposes an intelligent question-answering method based on domain knowledge graphs, comprising the following steps:
[0020] Step 1: Build a basic database, input user questions, and process the questions using a rule-based template matching method.
[0021] Specifically, step 1 includes the following steps:
[0022] Step 1.1: Extract entity database, event database, task database, relation database, and attribute database information from the database to build the basic database required for question answering (e.g., Jieba custom lexicon).
[0023] Based on the question database, a corresponding question template knowledge base is constructed for possible question types.
[0024] Based on the domain database, a corresponding knowledge graph is constructed, which includes entity nodes, entity attributes, neighbor nodes, and relationships with neighbor nodes.
[0025] Step 1.2: For the user's question input, process the question using a rule-based question template matching method.
[0026] For example, using Jieba's precise segmentation mode, the input question can be accurately segmented, and simple entity recognition and part-of-speech tagging can be performed.
[0027] Step 1.3: Remove stop words and irrelevant words after segmentation. Calculate the minimum edit distance between the segmented sentence and the entity list using a minimum edit distance algorithm (such as the Levenshtein algorithm). Sort the entity lists with obtained similarity to obtain the entity information of the question. Then, construct a thesaurus based on relation and attribute information to obtain the relation and attribute information in the question.
[0028] Step 1.4: Using the extracted question entity, attribute, and relation information, the questions are divided into various question query type templates, and the questions are matched to the predefined question templates mentioned above.
[0029] The query type template can specifically include 15 types, such as single entity single attribute query questions, single entity multi-attribute query questions, single entity single attribute yes / no class query questions, one-hop tail entity query questions, relationship query questions, two-hop attribute query questions, two-hop statistical query questions, two entity single attribute comparison query questions, single interval query questions, multi-interval query questions, multi-entity single attribute query questions, attribute maximum / minimum value query questions, tail entity confirmation query questions, maximum / minimum value query questions, and statistical query questions.
[0030] Step 2: Process the questions using BAMNet, TextCNN, and BERT.
[0031] In step 1, due to the strong constraints of rule-based question template matching methods on the questions and their poor generalization ability, it is difficult to capture all semantic information using fixed rules. For this type of question where template matching is not feasible, it is necessary to use BAMNet networks, TextCNN, or BERT to process the questions.
[0032] Specifically, step 2 includes the following sub-steps:
[0033] Step 2.1: Input the question into the TextCNN model and use a convolutional neural network to capture the semantic information of the sentence and obtain the type information of the question. The training process uses L2 regularization and dropout to prevent overfitting.
[0034] Step 2.2: For the remaining sentence after removing entities from the question, use the BERT model to calculate the similarity between the question and the relations in the relation database to obtain the relation information of the question.
[0035] Step 2.3: Input the question into the BAMNet network.
[0036] For a given question, use a bidirectional LSTM network to encode it as an intermediate hidden state vector representation;
[0037] For the three types of information of candidate answers in the knowledge graph, namely answer entity type, answer entity context representation, and answer entity path, a bidirectional LSTM network is used to encode them into vector representations respectively.
[0038] A key-value memory network is used to store candidate answer encoding information; a reasoning module consisting of a bidirectional attention mechanism network and a generalization module is used to realize bidirectional interaction between question vector identifiers and candidate answer encoding information.
[0039] For the question vector representation and the candidate answer representation, a similarity score is calculated, and the candidate answer entity with the highest score is selected as the question answer. Specifically, the generated question answer includes key information such as question type, question entity, question attributes, and question relationship.
[0040] Step 2.4: Based on the question type information obtained by the TextCNN model and the question type information obtained by the BAMNet network, the softmax function is used to obtain the final question type; based on the question relationship information obtained by the BERT model in Step 2.2 and the question information obtained by the BAMNet network, the softmax function is used to obtain the final question relationship, and the BAMNet network obtains the question attributes.
[0041] Step 3: Based on the question and answer information from Step 1 and Step 2, the question-answering system constructs the corresponding query statement (such as a Cypher statement), retrieves the answer from the database, further processes the answer, and returns the answer according to the question type.
[0042] Specifically, step 3 includes the following steps:
[0043] Step 3.1: In the rule-based question template matching method, if the question can perfectly match the template library, then Cypher statements are generated for the matched question query type, and the answer is retrieved in the graph database.
[0044] Step 3.2: For user questions that cannot be matched in the question template library, obtain the key information of the question representation (such as question type, question entity, question attribute, question relationship, etc.) in step 2, construct the corresponding Cypher query statement, and retrieve the answer in the graph database.
[0045] Step 3.3: Based on the user's question type (such as single entity question-and-answer, single entity single attribute question-and-answer), process and integrate the answers retrieved from the graph data, and transform them into user-friendly answers for return.
[0046] Through the above steps, the correct parsing and answering of natural language questions based on domain knowledge graphs were achieved.
[0047] On the other hand, this invention proposes an intelligent question-answering system based on domain knowledge graphs, including a template module and a deep module.
[0048] The template module is used for question preprocessing, question template matching, and query statement generation.
[0049] The template module's user query interface performs question segmentation and entity recognition after receiving user question input. The template module can generate query statements based on its own results or those returned by the deep learning module, perform a knowledge base search, conduct an initial search in the database, and return the corresponding answer based on the question type.
[0050] The deep module is used to learn complex features of problem questions that the template module cannot solve. The deep module includes a data module and a core task module.
[0051] The data module is used for knowledge graph generation. It preprocesses data from databases (such as MySQL and Neo4j databases), cleans the data to obtain accurate, complete, and timely data, constructs the corresponding knowledge graph, and further generates various question representations.
[0052] The core task module is responsible for reasoning the answers to questions, including a question encoding module, a candidate answer generation module, and an answer reasoning module.
[0053] The question encoding module uses a bidirectional LSTM encoder to encode the question input from the template module into a hidden layer vector and output it to the answer reasoning module.
[0054] The candidate answer generation module consists of three sub-modules: answer type encoding, answer path encoding, and answer context encoding. The embedding vectors input from the deep learning module (these embedding vectors are composed of information such as entity node name, entity node ID, entity attributes, entity type, entity node's neighbor node name, and neighbor node ID) are processed by the candidate answer generation module to generate candidate answers for the question, which are then input into the answer reasoning module.
[0055] The answer reasoning module consists of a knowledge base perception bidirectional attention module and a generation module. It is used to reason about the hidden layer vector of the question input by the question encoding module and the candidate answer representation input by the candidate answer generation module, generate key information answers such as question type, relation type, entity, attribute information, etc., and output them to the template module for constructing key information of the query statement.
[0056] Beneficial effects
[0057] Compared with existing knowledge graph question answering technologies, this invention has the following advantages:
[0058] 1. This invention constructs a complete and usable domain-specific dataset, enriching the types and specialization of questions, providing strong support for training knowledge graph-based question-answering models. A complete and usable knowledge graph is constructed, which is then used to provide supplementary information for the question-answering model, and a database is used to visualize it.
[0059] 2. To address the problem that the accumulation of error rates in upstream subtasks in current question-answering models based on domain-specific knowledge graphs leads to low accuracy in downstream question-answering models, this invention introduces an entity recognition method based on minimum edit distance. This method improves the accuracy of subtasks while saving subtask time and eliminates the influence of domain-specific knowledge on relationship recognition.
[0060] 3. Existing question-answering models based on knowledge graphs suffer from weak interaction between questions and the knowledge graph, and fail to fully utilize the vast amount of information within the knowledge graph. To address this issue, this invention introduces the BAMNet network to establish associations between questions and information such as entity types, relational paths, and context in the knowledge base, directly enhancing bidirectional communication and modeling between the knowledge base and questions.
[0061] 4. This invention overcomes the limitations of previous knowledge graph question-answering models that were restricted by manually labeled templates. It integrates rule-based template matching question answering with deep learning-based question answering, combining the advantages of both to improve the system's accuracy and response speed, reduce maintenance and update costs, and ensure the interpretability of the model while maintaining the accuracy of the question-answering model. Attached Figure Description
[0062] Figure 1 This is a flowchart of the present invention.
[0063] Figure 2 This is a system architecture diagram of the present invention.
[0064] Figure 3 This is an example diagram of the knowledge graph of the present invention.
[0065] Figure 4 This is a block diagram of the rule-based question template matching method for "What is the length of the SH-60B aircraft?" in step 1 and embodiment 1 of the present invention.
[0066] Figure 5 This is a dynamic cost matrix diagram showing the minimum edit distance between the remaining sentence after Jieba segmentation of the question "What is the length of the SH-60B aircraft?" in Step 1 and Example 1 of this invention and the entities in the entity list.
[0067] Figure 6 This is a diagram of the BAMNet network model involved in the answer reasoning process in step 2 of this invention.
[0068] Figure 7 This is a diagram of the TextCNN model architecture with two channels involved in step 2 of the present invention for question type classification. Detailed Implementation
[0069] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of the invention.
[0070] Example
[0071] Figure 2 This is a system framework diagram of the present invention, consisting of two task modules: a depth module and a template module. Users interact with the system through the user query interface and answer return interface of the template module. The template module performs preliminary parsing of the questions and then performs template matching. The depth module handles complex problems that the template module cannot process. The depth module consists of a data module and a core task module. The data module cleans the data and generates corresponding knowledge graphs, such as... Figure 3As shown, the core task module encodes the question, generates candidate answers, and performs answer reasoning. The specific process is as follows: Figure 1 As shown.
[0072] Figure 3 This is an example diagram of the knowledge graph in this invention. The following example illustrates the construction process of the military domain dataset and military domain knowledge graph in this invention.
[0073] This invention obtains information from non-public data sources. The original data is stored in a MySQL database and includes military information such as aircraft tables, ground facility tables, ship tables, and weapon tables. Among them, there are 4,581 records related to the aircraft table, 3,064 records related to the ground facility table, 3,026 records related to the ship table, and 3,337 records related to the weapon table.
[0074] Entities such as aircraft, ground facilities, ships, and weapons are retrieved from the corresponding data tables in the database, and their detailed information is mapped one-to-one with the entities. The detailed information for the aircraft entity "SH-60B Seahawk Helicopter" includes 34 attributes. This embodiment obtains relationship information from a non-public data source, mainly including data from attribute tables, relationship tables, and special keyword tables. The attribute table contains 33 records, the relationship table contains 19 records, and the special keyword table contains 6 records. Detailed information is shown in Table 1.
[0075] Table 1. Sources of Military Relationships
[0076]
[0077] After performing simple processing on the raw information in the MySQL database, detailed information, relational information, and answer information for entities such as aircraft, ground facilities, ships, and weapons are obtained. However, this data still contains noise, which can negatively impact the model's learning process and results. Therefore, further standardization processing of this data is required. The processing operations include the following three steps:
[0078] 1. Remove null and zero values from the data. For example, if the IsSelfDefined attribute value of the SH-60B "Seahawk" helicopter is 0, remove this attribute when selecting the data.
[0079] 2. Remove meaningless or unnecessary attributes from the data. For example, if the "Hypothetical" attribute value does not have a corresponding practical meaning, then remove this attribute from the relation table.
[0080] 3. Remove meaningless punctuation marks from entities to reduce the impact of noisy symbols. For example, the '-' and quotation marks in the SH-60B "Seahawk" helicopter are meaningless symbols; after removing them, the entity is the SH60B "Seahawk" helicopter.
[0081] The above operations can remove noise from the data and reduce the impact of data noise on tasks such as the learning process of question-answering models based on military knowledge graphs, entity recognition, and relation extraction.
[0082] The data obtained through the data cleaning process is used as the information source for the military knowledge graph triples. Aircraft entities, ground facility entities, and ship entities, along with their corresponding attribute values, relation values, and special terminology values, serve as candidate head and tail entities for the triples. Information from the attribute table, relation table, and special terminology table is selected as the relations within the triples. Triples are obtained through strategies such as attribute filtering and random matching. For example, for the entity SH-60B Seahawk helicopter, 33 triples related to its attributes can be created.
[0083] For some specialized information in the relation table and special keyword table, combined with information found in the web search, query the tail entity of the triple corresponding to each entity, and insert the meaningful triples into the triple set.
[0084] The generated triplet data pairs can be expanded. For example, the triplet (SH-60B Seahawk helicopter, length, 15.2 meters) can generate the corresponding questions "What is the length of the SH-60B aircraft?" or "How long is the SH-60B?".
[0085] An intelligent question answering method based on domain knowledge graphs, such as Figure 1 The steps shown are as follows:
[0086] For the example question "What is the length of the SH-60B aircraft?", if it can be answered using a rule-based template matching method, the following process is executed: Figure 4 As shown:
[0087] Step 1: Preprocess the user's questions, including text cleaning and stop word removal. This includes removing words that have practical meaning from the questions, such as spaces and quotation marks at the beginning and end of the questions.
[0088] Step 2: If the question can match a predefined template in rule-based template matching, then directly extract information such as question type, question entity, question attributes, and question relationship based on the question template.
[0089] Furthermore, step 2 includes the following steps:
[0090] Step 2.1: Using the Jieba tool, perform precise segmentation of the question "What is the length of the SH-60B aircraft?" using the exact mode and with a Hidden Markov Model (HMM). The segmented result is [('SH','eng'),('-','x'),('60B','eng'),('aircraft','n'),('of','uj'),('length','n_attr'),('is','v'),('how much','m'),('?','x')]. Remove words contained in the special keyword list to obtain the new sentence "The length of the SH-60B aircraft".
[0091] Step 2.2: Use the minimum edit distance algorithm, whose algorithm iteration matrix is as follows: Figure 5 As shown, the minimum edit distance between "length of SH-60B aircraft" and each entity in the entity list is calculated, and the similarity score is calculated based on the minimum edit distance. Entities with a similarity score greater than 0.5 are added to the similarity entity list.
[0092] Sort the entities in the similarity entity list to obtain the topic entity list 1 [SH-60B Seahawk Helicopter, SH-60J Seahawk Helicopter, SH-60F Seahawk Helicopter]. Take the first entity [SH-60B Seahawk Helicopter].
[0093] Step 2.3: Based on Step 2.2, calculate the length of the remaining sentence after removing entities from the question. Obtain the attribute length of the question by matching attributes in the attribute library and its thesaurus.
[0094] Step 2.4: Using the entity information [SH-60B Seahawk helicopter] and relation information [length] obtained in Steps 2.2 and 2.3, the question is identified as an attribute query type between two entities. The corresponding Cypher statement is "MATCH(node:military equipment)WHERE node.name = 'SH-60B Seahawk helicopter'RETURN DISTINCTnode.length". The answer to the question "What is the length of the SH-60B helicopter?" found in the Neo4j graph database is 15.2 meters.
[0095] To further illustrate, the steps for answering the question "What is the SH-60B aircraft carrying?" in the implementation example are as follows:
[0096] Step 1: For the question "What is the SH-60B aircraft carrying?", use a rule-based template matching algorithm for matching. Similar to steps 2.1 and 2.2 in Example 1, use a minimum edit distance algorithm to obtain the entity [SH-60B Seahawk helicopter] and the remaining sentence [What is it carrying?].
[0097] Step 2: Based on the matching results of Step 1, if the question cannot match the predefined template, the question is input into the BAMNet network, TextCNN network, and BERT for processing.
[0098] Step 2.1: In Step 2, the relation type of the question is obtained in the BERT model. Specifically, the question "What is attached?" is input into the BERT model to obtain the score of each relation category in its fully connected layer, as shown in the following formula:
[0099] logits = W·BERT output +b
[0100] Here, `logits` is the output of the fully connected layer, a vector of dimension C, where C is the total number of relation classes. `W` is the weight matrix, with dimensions C×D, where D is the dimension of the BERT output. `.` represents matrix multiplication, and `b` is the bias vector. BERT output It is the output of the BERT model, that is, the output of the [CLS] token, and its dimension is D.
[0101] Step 2.2: The question from Step 2 is input into the TextCNN model, such as... Figure 7 As shown, the type information of the input question is obtained.
[0102] Furthermore, step 2 includes the following steps:
[0103] Step 2.2.1: Input the question "What is the SH-60B aircraft carrying?" into the TextCNN model. The sentence is represented as:
[0104]
[0105] in, It is a concatenation symbol, and x1 is the k-dimensional word vector of the woed2vec model, which obtains the word vector representation of the sentence.
[0106] Step 2.2.2: Text Convolution. In the convolutional layer, multiple convolutional kernels are used to perform convolution operations on the input word embedding matrix. A convolutional kernel is represented as a weight matrix w and a bias term b. The convolution operation is represented as:
[0107] c i =f(w·X) i:i+h-1 +b)
[0108] Where · is the matrix multiplication representation, c i It is the i-th element of the convolution result; It is the convolution kernel weight matrix; x i:i+h-1is a window of the input matrix containing h consecutive word embedding vectors; f is a non-linear activation function, such as the ReLU activation function; b is a bias term.
[0109] Here, h words are used as a convolution window to generate a new feature vector c. i In this sentence, for each possible word window {x} 1:h x 2:h+1 , ..., x n-h+1:n Each of these will generate a feature map:
[0110] c = [c1, c2, ..., c n-h+1 ]
[0111] in, Further apply max pooling operation to the feature map To capture the highest value features of each feature map
[0112] Step 2.2.3: Regularization. Before the last softmax layer, dropout regularization and L2 regularization are used to prevent overfitting. Specifically, during forward propagation, dropout randomly discards some hidden units with probability 1-p, in the following manner:
[0113]
[0114] in, This is an element-wise multiplication operation; This represents a random occlusion vector with a probability of 1-p. Represents an m-dimensional vector; This is the feature map of the second to last layer. y represents the feature map representation after the greatest pooling; y is the output of the forward propagation of the fully connected layer, and its dimension is the number of sentence categories; w is the weight matrix of the fully connected layer.
[0115] Step 2.3: Further, the question from Step 2 in the BAMNet model, as follows: Figure 6 As shown, it includes the following sub-steps:
[0116] Step 2.3.1: Represent the question "What is the SH-60B aircraft carrying?" as Q, and encode it into an intermediate hidden state vector representation HQ using a bidirectional LSTM network.
[0117] Step 2.3.2: For the three pieces of information of the candidate answer in the knowledge graph—answer entity type, answer entity context representation, and answer entity path—a bidirectional LSTM network is used to encode them into H respectively. t H p H cA key-value memory network is used to store candidate entities for answers and knowledge graph information. The answer information is then linearly projected using the following formula:
[0118]
[0119]
[0120] in, and This is the answer information. The representation of d-dimensional keys and values, This represents the hidden layer of answer information. Let M be defined as a key-value memory, and its row representation is as follows: All dimensions are This represents a linear mapping function.
[0121] Step 2.3.3: Use the reasoning module, which consists of a bidirectional attention mechanism and a generalization module, to achieve bidirectional interaction between the question vector identifier and the candidate answer encoding information.
[0122] The knowledge graph attention-aware module uses a self-attention mechanism to generate a d-dimensional vector representation q for the HQ, as shown below:
[0123] q = BiLSTM([H Q A QQ T, H Q ])
[0124] A QQ =softmax((H Q ) T H Q )
[0125] Where BiLSTM represents a bidirectional LSTM network, A Q represents the attention weight, and T represents the matrix transpose.
[0126] Use a self-attention mechanism to obtain entity type m t Entity path m p and context representation m c Its calculation is shown in the following formula:
[0127]
[0128]
[0129] Where |A| represents the number of candidate answers, a x The attention weights represent the summary of the question q and a certain value in the knowledge base. The strength of the relationship. This leads to the knowledge base information vector representation m = [m t;m p m c ].pass Calculate the word q in the question i Attention between information in the knowledge graph. Maximum attention is achieved through a max-pooling layer.
[0130] Importance Module: The importance module focuses on the relevance between the problem and different aspects of information in the knowledge graph. Through A... QM Normalization is performed to obtain the attention matrix. The problem-aware memory representation is obtained using the following formula.
[0131]
[0132]
[0133]
[0134]
[0135]
[0136]
[0137] A QM =(M k H Q ) T
[0138] in, The question-aware representation of the knowledge base value, where A is the number of candidate answers. This represents the value of a specific answer in the knowledge base. This represents the problem's memory and perception representation. A key representation for a specific answer in a knowledge base. This is the normalized attention matrix, representing the importance of each aspect of the answer to each candidate answer. `softmax` is a normalization function, and `T` denotes the matrix transpose. A M Let A represent a two-dimensional attention matrix, where A represents the maximum relationship strength between each knowledge base and the most relevant word in the question. QM Let M represent a three-dimensional attention tensor, where M represents the strength of the relationship between each word in the question and a key in the knowledge base. k This represents the key of the knowledge base.
[0139] Enhancement Module: This module uses a second-level attention mechanism to further enhance the mutual representation between questions and the knowledge graph. A QM Let A represent a three-dimensional attention tensor.QM Max pooling and normalization are performed to obtain This was then merged into the problem statement. Finally passed We obtain a d-dimensional knowledge graph with enhanced question representation.
[0140] Similarly, the enhanced representation between the question and the knowledge graph is obtained through the following formula:
[0141]
[0142]
[0143]
[0144] in, The knowledge base representation of the question enhancement is shown. It is an attention vector, representing the relevance of each aspect of the knowledge base to the question. It is a knowledge base-aware attention vector, representing the importance of question qi in the knowledge base, and ⊙ is a matrix multiplication representation.
[0145] Generation Module: Add a one-hop attention mechanism module before the answer module. The knowledge graph-question reinforcement representation is computed using the attention mechanism. Key-value memory The degree of attention between them is finally determined by the Batch Normalization (BN) layer. As shown below:
[0146]
[0147]
[0148]
[0149]
[0150] Where BN is the batch normalization layer. Let q' represent the problem representation after a one-hop attention process, and q' be the problem representation updated using GRU (Recurrent Neural Network). For question-aware summary, 'a' represents the attention weight between the question and the knowledge base.
[0151] Step 2.3.4: Vector representation of questions and candidate answers The similarity score is calculated using the following formula to obtain a score vector representation of key question information such as question type, question relationship, and question attributes:
[0152]
[0153] Step 3: Aggregate the information from BAMNet, BERT, and TextCNN to obtain the final key information answer of the question, and construct a Cypher statement to retrieve the answer in the graph data.
[0154] Furthermore, step 3 includes the following steps:
[0155] Step 3.1: Based on the output vector of the fully connected layer for relations from the BERT model in Step 2.1, and the output vector of the fully connected layer for relations from BAMNet in Step 2.3, respectively, input them into the softmax layer, as shown in the following formula, to obtain their corresponding probability distributions, and sum them up to select the relation type with the highest probability as the relation of the question [mounted]:
[0156]
[0157] in, Let i and j represent the exponential representations of the i-th and j-th elements of the fully connected layer output vector x, respectively.
[0158] Based on the output vectors of the fully connected layer for question types from TextCNN in step 2.2 and the output vectors of the fully connected layer for question types from BAMNet in step 2.3, respectively, input them into the softmax layer to obtain their corresponding probability distributions. The probability distributions are then summed, and the question type with the highest probability is taken as the question type [one-hop tail entity query problem]. The question attributes based on BAMNet are used as the final attributes of the question.
[0159] Step 3.2: Using the key question information obtained in 3.1, such as the question type [one-hop tail entity query question], question relation [mounted], question entity [SH-60B Seahawk helicopter], and question attribute [none], construct the Cypher statement "MATCH(node{name: 'SH-60B Seahawk helicopter'})-[relation:mounted]-(relatedNode)RETURNDISTINCT relatedNode.name" to perform graph database retrieval and answer processing, and then return the answer.
[0160] Table 2. Results of the Intelligent Question Answering Method Based on Military Knowledge Graph
[0161]
[0162]
[0163] This invention is applied in the military field, using precision and response time metrics as standards to measure the quality of the model. The results are shown in Table 2. In this invention, 15,000 test cases were tested on 15 common question types in military question answering, with 1,000 test cases for each type of question. The accuracy rate obtained was 81.2%, and the average response time of the model was 0.41s.
[0164] like Figure 2 As shown, an intelligent question-answering system based on a domain knowledge graph includes a template module and a deep module.
[0165] The template module is used for question preprocessing, question template matching, and query statement generation.
[0166] The template module's user query interface performs question segmentation and entity recognition after receiving user question input. The template module can generate query statements based on its own results or those returned by the deep learning module, perform a knowledge base search, conduct an initial search in the database, and return the corresponding answer based on the question type.
[0167] The deep module is used to learn complex features of problem questions that the template module cannot solve. The deep module includes a data module and a core task module.
[0168] The data module is used to generate knowledge graphs. It preprocesses the data in the database, cleans the data to obtain accurate, complete and timely data, constructs the corresponding knowledge graph, and further generates various question representations.
[0169] The core task module is responsible for reasoning the answers to questions, including a question encoding module, a candidate answer generation module, and an answer reasoning module.
[0170] The question encoding module uses a bidirectional LSTM encoder to encode the question input from the template module into a hidden layer vector and output it to the answer reasoning module.
[0171] The candidate answer generation module consists of three sub-modules: answer type encoding, answer path encoding, and answer context encoding. The embedding vectors input from the deep learning module (these embedding vectors are composed of information such as entity node name, entity node ID, entity attributes, entity type, entity node's neighbor node name, and neighbor node ID) are processed by the candidate answer generation module to generate candidate answers for the question, which are then input into the answer reasoning module.
[0172] The answer reasoning module consists of a knowledge base perception bidirectional attention module and a generation module. It is used to reason about the hidden layer vector of the question input by the question encoding module and the candidate answer representation input by the candidate answer generation module, generate key information answers such as question type, relation type, entity, attribute information, etc., and output them to the template module for constructing key information of the query statement.
[0173] As illustrated by the embodiments of this invention, it solves the problem that existing knowledge graph question-answering models rely on manually predefined templates and can only answer fixed sentence patterns. When applied to the military field, this invention ensures that the model can answer various non-fixed military semantic sentence patterns while maintaining its interpretability, greatly improving the accuracy of decision-making by military commanders.
Claims
1. An intelligent question-answering method based on domain knowledge graphs, characterized in that, Includes the following steps: Step 1: Build a basic database, input user questions, and use a rule-based template matching method to preprocess the questions and perform template matching; Step 2: Match the question with a preset template library; If a match is successful, a Cypher query statement is generated directly based on the matched question query type, the answer is retrieved in the graph database, and then the process jumps to step 3. If a match fails, proceed with steps 2.1 through 2.5: Step 2.1: Input the question into the TextCNN model and use a convolutional neural network to capture the semantic information of the sentence and obtain the type information of the question. During the training process, L2 regularization and dropout are used to prevent overfitting. Step 2.2: For the remaining sentence after removing entities from the question, use the BERT model to calculate the similarity between the remaining sentence and the relations in the relation database to obtain the relation information of the question; Step 2.3: Input the question into the BAMNet network. For a given question, a bidirectional LSTM network is used to encode it into an intermediate hidden state vector representation, resulting in a question vector representation. For the three types of information of candidate answers in the knowledge graph, namely answer entity type, answer entity context representation, and answer entity path, a bidirectional LSTM network is used to encode them into vector representations to obtain the candidate answer encoding information. A key-value memory network is used to store candidate answer encoding information; a reasoning module consisting of a bidirectional attention mechanism network and a generalization module is used to realize bidirectional interaction between question vector representation and candidate answer encoding information; A similarity score is calculated between the question vector representation and the candidate answer encoding information to obtain key information of the candidate questions, including the candidate question type, the candidate question relationship, and the candidate question attributes. Step 2.4: Based on the question type information obtained by the TextCNN model in Step 2.1 and the candidate question type information obtained by the BAMNet network, the final question type is obtained using the softmax function; based on the question relationship information obtained by the BERT model in Step 2.2 and the candidate question relationship information obtained by the BAMNet network, the final question relationship is obtained using the softmax function, and the question attributes are obtained by the BAMNet network, thus obtaining the final key information of the question; Step 2.5: Construct the corresponding Cypher query based on the final key information of the question, and retrieve the answer in the graph database; Step 3: Based on the type of user question, process and integrate the answers retrieved from the graph database, and return them in user-friendly natural language.
2. The intelligent question-answering method based on domain knowledge graph as described in claim 1, characterized in that, Step 1 includes the following steps: Step 1.1: Extract entity database, event database, task database, relation database, and attribute database information from the database to construct the basic database required for question answering; Based on the question database, a corresponding question template knowledge base is constructed for question types; Based on the domain database, a corresponding knowledge graph is constructed, which includes entity nodes, entity attributes, neighbor nodes, and relationships with neighbor nodes. Step 1.2: For the user's question input, process the question using a rule-based question template matching method; Step 1.3: Remove stop words and irrelevant words after segmentation, use the minimum edit distance algorithm to calculate the minimum edit distance between the segmented sentence and the entity list, sort the entity list with obtained similarity to obtain the entity information of the question; then, construct a thesaurus based on relation and attribute information to obtain the relation and attribute information in the question. Step 1.4: Using the extracted question entity, attribute, and relation information, the questions are divided into various question query type templates, and the questions are matched to the predefined question templates.
3. The intelligent question-answering method based on domain knowledge graph as described in claim 2, characterized in that, The query type templates include: single entity single attribute query questions, single entity multi-attribute query questions, single entity single attribute yes / no class query questions, one-hop tail entity query questions, relationship query questions, two-hop attribute query questions, two-hop statistical query questions, two entity single attribute comparison query questions, single interval query questions, multi-interval query questions, multi-entity single attribute query questions, attribute maximum / minimum value query questions, tail entity confirmation query questions, maximum / minimum value query questions, and statistical query questions.
4. The intelligent question-answering method based on domain knowledge graph as described in claim 1, characterized in that, Steps 2.1, 2.2, and 2.3 specifically include: Step 2.1: Input the question into the TextCNN model to obtain the type information of the input question; Step 2.1.1: Input the question into the TextCNN model. The sentence is represented as: in, It is a serial symbol. For the woed2vec model 3D word vectors are used to obtain the word vector representation of a sentence; Step 2.1.2: Text Convolution; In the convolutional layer, multiple convolution kernels are used to perform convolution operations on the input word embedding matrix; a convolution kernel is represented as a weight matrix. and a bias term The convolution operation is represented as: in, It is a matrix multiplication representation. It is the first convolution result One element; It is the convolution kernel weight matrix; It is a window containing the input matrix. A series of word embedding vectors; It is a non-linear activation function, such as the ReLU activation function; It is a bias term; Will Each word is used as a convolution window to generate a new feature vector. In this sentence, for each possible word window... Each of these will generate a feature map: in, Furthermore, max pooling operation is applied to the feature map. To capture the highest value features of each feature map. Step 2.1.3: Regularization; Before the last softmax layer, use dropout regularization and Regularization; Dropout in forward propagation uses probability Randomly discard several hidden units in the following manner: in, This is an element-wise multiplication operation; Indicated by The random masking vector for probabilistic masking. Represents an m-dimensional vector; This is the feature map of the second to last layer. This represents the feature map representation after the greatest pooling. The output of the forward propagation of the fully connected layer has a dimension equal to the number of sentence categories. This is the weight matrix of the fully connected layer; Step 2.2: Input the question into the BERT model to obtain the score for each relation category in its fully connected layer, as shown in the following formula: in, It is the output of the fully connected layer, which is a dimensionless... The vector, where W is the total number of relation categories; W is the weight matrix, and its dimensions are... , where D is the dimension of the BERT output; It is matrix multiplication. It is the bias vector; BERT output It is the output of the BERT model, specifically the output of the [CLS] token, and its dimension is... ; Step 2.3: The question in the BAMNet model includes the following sub-steps: Step 2.3.1: Represent the question as It is encoded into an intermediate hidden state vector representation using a bidirectional LSTM network. ; Step 2.3.2: For the three pieces of information about the candidate answer in the knowledge graph—answer entity type, answer entity context representation, and answer entity path—a bidirectional LSTM network is used to encode them respectively. Key-value memory networks are used to store candidate entities and knowledge graph information for answers, and the answer information is linearly projected using the following formula: in, and This is the answer information. of Representation of key and value, This is a hidden layer representation of the answer information; Defined as key-value memory, its row representation is as follows Dimensions are all , Represents a linear mapping function; Step 2.3.3: Use a reasoning module consisting of a bidirectional attention mechanism and a generalization module to achieve bidirectional interaction between the question vector representation and the candidate answer encoding information; Among them, the knowledge graph attention perception module uses a self-attention mechanism to... generate 3D vector representation As shown below: in, Indicates a bidirectional LSTM network. The attention weights are represented by T, which represents the matrix transpose. Use self-attention mechanism to obtain entity types Entity path and context representation Its calculation is shown in the following formula: in, Indicates the number of candidate answers. Attention weights represent the problem summary. and a knowledge base The strength of the relationship; thus, the information vector representation of the knowledge base is obtained. ;pass Calculate the words in the question Attention between information in the knowledge graph; maximum attention is obtained through a max pooling layer. ; Importance Module: The importance module focuses on the relevance between the problem and different aspects of information in the knowledge graph; through... Normalization is performed to obtain the attention matrix. The problem-aware memory representation can be obtained using the following formula. : in, The question-aware representation of the knowledge base value, where A is the number of candidate answers. This represents the value of a specific answer in the knowledge base. A key representation for a specific answer in the knowledge base; It is the normalized attention matrix, representing the importance of each aspect of the answer to each candidate answer; It is a normalization function, and T represents the matrix transpose; This represents a two-dimensional attention matrix, indicating the maximum relationship strength between each knowledge base and the most relevant word in the question; This represents a three-dimensional attention tensor, indicating the strength of the relationship between each word in the question and a key in the knowledge base. This represents the key of the knowledge base; Enhancement Module: This module uses a second-level attention mechanism to further enhance the mutual representation between questions and the knowledge graph; Represent a three-dimensional attention tensor, for Max pooling and normalization are performed to obtain Then merge it into the problem statement. Finally passed get Knowledge Graph - Enhanced Representation of Questions; Similarly, the enhanced representation between the question and the knowledge graph is obtained through the following formula: in, The knowledge base representation of the question enhancement is shown. It is an attention vector, representing the relevance of each aspect of the knowledge base to the question; It is a knowledge base-aware attention vector representing the question. The importance of knowledge bases This is a matrix multiplication representation; Generation module: Add a one-hop attention mechanism module before the answer module; compute the knowledge graph-question reinforcement representation through the attention mechanism. Key-value memory The degree of attention between them is finally determined by the Batch Normalization (BN) layer. As shown below: Where BN is the batch normalization layer. This represents the problem representation after a single attentional step. The problem is represented by the updated GRU. To provide a problem-aware summary, This represents the attention weight between the question and the knowledge base; Step 2.3.4: Vector representation of questions and candidate answers The similarity score is calculated using the following formula to obtain the score vector representation of the key information in the question: Key information about a question includes its type, relationship, and attributes.
5. An intelligent question-answering system based on a domain knowledge graph, wherein the system is used to implement the intelligent question-answering method based on a domain knowledge graph as described in claim 1, characterized in that, Includes template modules and depth modules; The template module is used for question preprocessing, question template matching, and query statement generation; The template module's user query interface performs question segmentation and entity recognition after receiving user question input; the template module can generate query statements based on its own or the results returned by the deep module, perform knowledge base retrieval, conduct an initial retrieval in the database, and return the corresponding answer according to the question type; The deep module is used to learn complex features of question sentences that the template module cannot solve; the deep module includes a data module and a core task module. The data module is used to generate knowledge graphs. It preprocesses the data in the database, cleans the data to obtain accurate, complete and timely data, constructs the corresponding knowledge graph, and further generates various question representations. The core task module is responsible for reasoning the answers to questions, including a question encoding module, a candidate answer generation module, and an answer reasoning module; The question encoding module uses a bidirectional LSTM encoder to encode the question input from the template module into a hidden layer vector and output it to the answer reasoning module. The candidate answer generation module consists of three sub-modules: answer type encoding, answer path encoding, and answer context encoding. The embedding vector input from the deep learning module is used to generate candidate answers for the question, which are then input into the answer reasoning module. The answer reasoning module consists of a knowledge base perception bidirectional attention module and a generation module. It is used to reason about the hidden layer vector of the question input by the question encoding module and the candidate answer representation input by the candidate answer generation module, generate the answer with key information of the question, and output it to the template module to construct the key information of the query statement.
Citation Information
Patent Citations
Medical knowledge graph question-answering system construction method based on BERT and similarity algorithm
CN112131393A
Intelligent question and answer system based on knowledge graph subgraph retrieval
CN113297369A