A multi-task knowledge graph question answering method
By employing a multi-task knowledge graph question answering method and utilizing named entity recognition and semantic similarity matching models, the problems of entity generalization and low retrieval efficiency in knowledge bases are solved, achieving efficient and accurate answer acquisition.
Patent Information
- Application Number
- CN202210660627.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-06-13
AI Technical Summary
In existing technologies, the entities in user questions have a certain degree of generalization, and the knowledge base data is large. Directly querying candidate relationships from the knowledge base based on question entities has problems such as entity retrieval failure and slow fuzzy search efficiency.
A multi-task knowledge graph question answering approach is adopted. The question entities are identified by the Bert-BILSTM-CRF named entity recognition model, an auxiliary Elasticsearch database is built to improve the entity generalization ability, and the Bert semantic similarity matching model is used to obtain the most similar entity relationships. Combined with the knowledge graph database, accurate retrieval is performed.
It improves the retrieval efficiency and accuracy of entity candidate relations, solves the problem of obtaining answers for single entity single relation, single entity multiple relation, and dual entity type questions, and improves the accuracy and efficiency of question answering.
Smart Images

Figure CN115292443B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and particularly relates to a multi-task knowledge graph question answering method. BACKGROUND
[0002] In natural language knowledge acquisition analysis, there are a large amount of structured and semi-structured text data, the structure of which has the characteristics of diversification, large data volume, loose structure and the like, and there are corresponding association relationships between the data structures. The knowledge graph is a structured semantic knowledge base, which makes the knowledge based on the relationship expressed in a form more convenient for human cognition through the formalized description of the structured knowledge in the physical world, and the essence is to associate based on the mutual relationship between entities and organize into a network-like knowledge structure. As the simplest and most effective way to acquire knowledge, the question answering is currently more and more widely applied in the field of knowledge graph, but with the increase of the data base number, the size of the knowledge graph also becomes larger and larger, and how to accurately understand the user's question and convert it into a corresponding query statement to obtain the answer becomes more and more difficult. Therefore, it has important research significance to establish an efficient and accurate intelligent question answering based on the knowledge graph data and realize the accurate acquisition of key information of large-scale data.
[0003] At present, the question answering based on the knowledge base mainly includes the method based on semantic parsing and the method based on information retrieval. The method based on semantic parsing usually uses machine learning plus dictionary, rules and the like to identify the problem entity and the relationship for answer retrieval, but it has great limitations in relationship generalization. The method based on information retrieval identifies the problem entity, obtains the candidate relationship associated with the entity according to the problem entity, and obtains the most similar relationship to the problem based on a semantic similarity matching model, and the semantic similarity matching model has good effect in relationship generalization. In actual application, the entity in the user's question usually has a certain generalization, the size of the knowledge base data is getting larger and larger, and there are problems such as entity retrieval failure and slow fuzzy query efficiency when directly querying the candidate relationship from the knowledge base according to the problem entity, and there are multi-entity, multi-relation and other types of problems in the user's question, so it is necessary to establish a complete process intelligent question answering model to solve the problems of entity and relationship generalization ability and the acquisition of answers to multi-type problems in the question answering based on the knowledge base. SUMMARY
[0004] The main purpose of the present application is to provide a multi-task knowledge graph question answering method, which aims to solve the technical problems that the entity in the user's question usually has a certain generalization, the size of the knowledge base data is getting larger and larger, and there are problems such as entity retrieval failure and slow fuzzy query efficiency when directly querying the candidate relationship from the knowledge base according to the problem entity.
[0005] To achieve the above purpose, the present application provides a multi-task knowledge graph question answering method, which comprises the following steps:
[0006] S1: preparing structured text data, and establishing a knowledge graph database in the form of a triple of entity-relation-entity;
[0007] S2: preparing training corpus required by a model based on the knowledge graph database;
[0008] S3: establishing an auxiliary Elasticsearch database of related entities according to the knowledge graph database;
[0009] S4: training a Bert-BILSTM-CRF named entity recognition model and a Bert semantic similarity matching model;
[0010] S5: performing entity recognition in a question based on the Bert-BILSTM-CRF named entity recognition model, and performing Es retrieval in the auxiliary Elasticsearch database according to the entity in the question to obtain a full name of the corresponding entity;
[0011] S6: performing accurate retrieval from the graph database according to the full name of the entity to obtain all candidate relations of the corresponding entity, and obtaining an entity relation most matched with the question by the Bert semantic similarity matching model;
[0012] S7: performing answer retrieval according to the defined path rules based on the obtained entity and relation.
[0013] Optionally, the step S1 specifically comprises: taking structured text data as basic data of knowledge graph question answering, storing the associated relations between the structured text data in a graph database in the form of a triple of entity-relation-entity, and connecting the relations to each other to form a network-shaped knowledge structure, so as to obtain the knowledge graph database.
[0014] Optionally, the step S3 specifically comprises: constructing an auxiliary Elasticsearch database according to the full name, the short name and the alias of the entity in the knowledge graph database.
[0015] Optionally, the step S5 specifically comprises:
[0016] S51: encoding the original data by using a Bert layer to obtain an encoding vector of the original data, training and learning the semantic information of text dependency and context by using a BILSTM layer, and adding constraints for the output of the BILSTM layer by using a CRF layer to recognize the entity in the question;
[0017] S52: performing Es retrieval by using the related entity Elasticsearch database, directly outputting the full name of the corresponding entity when the Es retrieval result threshold is greater than a preset threshold, or outputting the name of the related entity for user selection.
[0018] Optionally, the entity relationship most matched with the question is obtained by the Bert semantic similarity matching model, and specifically:
[0019] S61: splice the question and the candidate entity relationship as input in the following manner:
[0020]
[0021] S62: encode the input X by using the Bert encoding layer, and output the encoding vector corresponding to X:
[0022]
[0023] wherein m is the length of the input X, and xi is the representation vector of the ith character.
[0024] S63: connect the encoding vector output by the Bert and the information obtained by the Attention, input into the bidirectional BILSTM layer, and finally obtain a fixed-length vector through pooling and convert it into a probability value.
[0025] S64: set a threshold parameter score, and if the score is greater than the threshold, it is determined that the relationship and the question are matched, and the entity relationship most similar to the input question is obtained based on the model.
[0026] Optionally, the expression of the probability value is:
[0027]
[0028] wherein r is the text vector output after the pooling, P is the predicted similarity probability value, and w and r are weight parameters and bias term parameters, respectively.
[0029] Optionally, the step S6 specifically comprises: according to the number of entities and relationships, respectively completing the answer retrieval of single entity single relationship, single entity multiple relationship, and double entity question; wherein:
[0030] For the single entity single relationship question, the answer can be obtained according to the form of (entity, relation, answer).
[0031] For the single entity multiple relationship question, if it is single-hop multiple relationship, the answer can be obtained according to the form of (entity, relation, answer); if it is multi-hop multiple relationship, the entity and the candidate relationship are combined to verify whether it can satisfy the query path (entity, relation1, relation2, answer), and if it satisfies, the question answer is output.
[0032] For the double entity problem, the entity and the candidate relation are combined to verify whether it can satisfy the query path (entity1, relation1, answer, relation2, entity2), and if yes, the problem answer is output.
[0033] The multi-task knowledge graph question answering method provided in the embodiment of the application first pre-processes the input question into a standard format, extracts the entity in the question based on a named entity recognition model, and since the entity in the question generally has a certain generality, in order to accurately obtain the relation of the corresponding entity from the graph database, an Elasticserach database is constructed according to the corresponding entity information in the graph database, the full name of the corresponding entity in the graph database can be obtained from the Elasticserach database based on Es retrieval, and the accuracy and the retrieval efficiency of the candidate relation of the entity in the question in the graph database are improved, the most similar relation of the question is matched based on a Bert semantic similarity matching model, and finally the answers of the single entity single relation, the single entity multiple relation and the double entity problem are obtained according to the entity recognition result and the relation matching result. BRIEF DESCRIPTION OF DRAWINGS
[0034] Figure 1 FIG. 1 is a flowchart of the multi-task knowledge graph question answering method of the application.
[0035] Figure 2 FIG. 2 is a general flowchart of the multi-task knowledge graph question answering method of the application.
[0036] Figure 3 FIG. 3 is a schematic diagram of the Bert-BILSTM-CRF named entity recognition model of the application.
[0037] Figure 4 FIG. 4 is a schematic diagram of the Bert semantic similarity matching model of the application.
[0038] The implementation, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0039] It should be understood that the specific embodiments described herein are only used to explain the application, and are not used to limit the application.
[0040] At present, in the related technical field, the entity in the existing user question generally has a certain generality, the volume of the knowledge base data is getting larger and larger, and the direct query of the candidate relation from the knowledge base according to the question entity has the problems of entity retrieval failure and slow fuzzy query efficiency.
[0041] To solve this problem, various embodiments of the multi-task knowledge graph question answering method of the present application are proposed. The multi-task knowledge graph question answering method provided by the present application identifies problem entities based on a named entity recognition model, constructs an auxiliary Elasticsearch database to improve the generalization ability of problem entities, and improves the retrieval efficiency of entity candidate relationships through precise matching. A semantic similarity matching model is established to calculate the similarity of the problem and the candidate relationship, and the generalization ability in problem relationship recognition is good. By establishing a process-based knowledge graph question answering model, the problem entity and relationship are identified in modules, and the overall question answering accuracy is improved, solving the answer retrieval of single entity single relationship, single entity multiple relationship and double entity type problems.
[0042] The embodiment of the present application provides a multi-task knowledge graph question answering method, referring to Figure 1 , Figure 1 The flowchart of the multi-task knowledge graph question answering method embodiment of the present application is shown.
[0043] In this embodiment, the multi-task knowledge graph question answering method comprises the following steps:
[0044] S1: Prepare structured text data, and establish a knowledge graph database in the form of a triple of entity-relation-entity;
[0045] S2: Prepare training corpus required by the model based on the knowledge graph database;
[0046] S3: Establish an auxiliary Elasticsearch database of related entities based on the knowledge graph database;
[0047] S4: Train a Bert-BILSTM-CRF named entity recognition model and a Bert semantic similarity matching model;
[0048] S5: Perform entity recognition in the question based on the Bert-BILSTM-CRF named entity recognition model, and perform Es retrieval in the auxiliary Elasticsearch database according to the problem entity to obtain the full name of the corresponding entity;
[0049] S6: Perform accurate retrieval from the graph database according to the entity full name to obtain all candidate relationships of the corresponding entity, and then obtain the most matched entity relationship with the question by the Bert semantic similarity matching model;
[0050] S7: Perform answer retrieval according to the defined path rules based on the obtained entity and relationship.
[0051] Specifically, the embodiment provides the following detailed steps:
[0052] Step 1. Data preparation and processing.
[0053] The structured text data is taken as the basic data of the knowledge graph question and answer, the association relationship between the structured text data is stored in the graph database in the form of triple (entity-relation-entity), the knowledge structure is formed by the mutual connection of the relationship, and the training corpus required by the entity recognition model and the Bert semantic similarity matching model can be constructed according to the established knowledge graph database.
[0054] Step 2. Establishment of Elasticsearch database of related entities.
[0055] In the intelligent question and answer based on the knowledge graph, the entity in the question needs to be recognized first, and the entity candidate relationship is obtained from the knowledge graph database according to the entity, and the entity in the general question has a certain generality, so there are problems such as entity matching failure and slow query speed in the fuzzy query in the graph database according to the entity in the question.
[0056] Based on the above problems, the auxiliary Elasticsearch database of related entities is constructed, the Elasticsearch database is constructed based on the full name of the entity in the graph database, the abbreviation of the entity, the nickname of the entity and other related information of the entity, the Es retrieval database can be expressed as:
[0057] {“_index”:“xxx”,
[0058] “_type”:“xxx”,
[0059] “_source”::{
[0060] “node_name”:“xxx”,
[0061] “node_abbreviation”:“xxx”,
[0062] “node_nickname”:“xxx”,
[0063] }
[0064] }
[0065] Among them, “_index” and “_type” are the library name and table name corresponding to Es, “node_name” is the full name of the entity in the graph database, “node_abbreviation” is the abbreviation of the entity, “node_nickname” is the nickname of the entity, and related entity information can be created according to different scenes.
[0066] The Elasticsearch database constructed by corresponding entities in the knowledge graph library can obtain the entity full name corresponding to the current problem entity in the user question based on Es retrieval, and the candidate relationship of the corresponding entity can be more accurately and quickly obtained through the entity full name, which solves the problem of entity generalization in the question to a certain extent and improves the retrieval efficiency.
[0067] Step 3. Obtain the entity in the question based on the named entity recognition model.
[0068] In the question entity recognition of the intelligent question answering based on the knowledge graph, the Bert-BILSTM-CRF model is adopted. The Bert layer encodes the original data to obtain the encoding vector of the original data, the BILSTM layer can better learn the long-distance text dependency relationship and the semantic information of the context, the CRF layer adds constraint calculation to the output of the BILSTM layer to obtain the optimal result, reduces the probability of unreasonable sequence, and finally converts the sequence category label to output the prediction result.
[0069] Based on the trained named entity recognition model, the question entity is identified. Since the question entity has a certain generalization, the related entity Elasticsearch database is constructed for Es retrieval. If the Es retrieval result threshold is greater than the threshold set in advance, the corresponding entity full name is directly output, otherwise the related entity name is recommended for user selection.
[0070] Through the above steps, the entity name in the graph database corresponding to the entity in the question can be accurately obtained, and the candidate relationship can be accurately matched based on the entity name in the graph database. This method solves the problem of entity generalization on one hand, and on the other hand, based on the accurate entity name, the corresponding entity relationship can be quickly retrieved from the knowledge base, improving the retrieval efficiency.
[0071] Step 4. Obtain the relationship corresponding to the entity based on the Bert semantic similarity matching model.
[0072] The above process obtains the question entity and the candidate relationship. The Bert fine-tuning model based on the Attention-BILSTM network of the present application matches the most similar entity relationship of the question, the input of which is the question and the entity relationship, and the output of which is a probability value between 0 and 1. The closer the result is to 1, the more similar the entity relationship and the question are.
[0073] Input the question and the candidate entity relationship Splice as follows:
[0074]
[0075] The Bert encoding layer encodes the input X, and outputs the encoding vector corresponding to X:
[0076]
[0077] wherein m is the length of the input X, is the representation vector of the i-th character.
[0078] The encoding vector output by Bert and the information obtained by Attention are connected on the aggregation layer, and input into the bidirectional BILSTM layer. The BILSTM layer can better learn the long-distance text dependency relationship and the semantic information of the context, and finally obtain a fixed-length vector through pooling and convert it into a probability value, and the formula is as follows:
[0079]
[0080] wherein r is the text vector output after pooling, P is the predicted similarity probability value, w and r are weight parameters and bias term parameters respectively. By setting the threshold parameter score, if it is greater than the threshold value, it is determined that the relationship and the question are matched, and based on the model, the most similar entity relationship and the input question can be obtained.
[0081] Step 5. Obtain the question answer based on the question entity and the relationship.
[0082] Through the above steps, the question entity and the corresponding relationship obtained respectively, according to the number of entities and relationships, the corresponding logical rules can be defined, and the answer retrieval of single entity single relationship, single entity multiple relationship and double entity question is completed.
[0083] For single entity single relationship question, the answer can be obtained according to the form of (entity, relation, answer);
[0084] For single entity multiple relationship question, this paper divides it into single-hop and multi-hop multiple relationship. If it is single-hop multiple relationship, the answer can be obtained according to the form of (entity, relation, answer). If it is multi-hop multiple relationship, the entity and the candidate relationship are combined to verify whether it can satisfy the query path (entity, relation1, relation2, answer), and if it satisfies, the question answer is output;
[0085] For double entity question, the entity and the candidate relationship are combined to verify whether it can satisfy the query path (entity1, relation1, answer, relation2, entity2), and if it satisfies, the question answer is output.
[0086] The embodiment provides a multi-task knowledge graph question answering method, recognizes problem entities based on a named entity recognition model, constructs an auxiliary Elasticsearch database to improve the generalization capability of the problem entities, simultaneously improves the retrieval efficiency of entity candidate relations through accurate matching, establishes a semantic similarity matching model to calculate the similarity of the problem and the candidate relations, and has good generalization capability in problem relation recognition. By establishing a process-based knowledge graph question answering model, problem entities and relations are recognized in modules, the overall question answering accuracy is improved, and the answer retrieval of single-entity single-relation, single-entity multiple-relation, and double-entity type problems is solved.
[0087] In order to more clearly explain the present application, a specific example of a multi-task knowledge graph question answering method is provided.
[0088] Referring to Figure 2 , Figure 2 The overall process of the intelligent question answering based on the knowledge graph is as follows: first, a user inputs a question and answer problem, the problem is preprocessed and converted into a corresponding format, the entity in the problem is recognized based on a Bert-BILSTM-CRF named entity recognition model, the full name of the problem entity is obtained through Es retrieval based on the constructed graph entity Elasticsearch database, the associated relation of the entity is obtained through a graph logic query statement, the obtained entity candidate relation and the user question are input into a Bert semantic similarity matching model to obtain the most similar relation to the user question, and finally, the corresponding answer is obtained according to the number of obtained entities and relations. The following will be described one by one in combination with specific examples.
[0089] 1. Data preparation and processing.
[0090] Referring to Figure 3 The open source data is taken as an example to construct a question answering knowledge graph database, and the data in the example is stored in a graph database Neo4j database, and the full name, abbreviation and alias of the entity in the graph database are stored in an Elasticsearch database.
[0091] 2. Bert-BILSTM-CRF named entity recognition.
[0092] Based on the trained named entity recognition model, the entity in the question is recognized, and the input form is: [CLS user question SEP].
[0093] 3. Es retrieval to obtain the full name of the problem entity.
[0094] Based on the question entity identified by the named entity recognition model, the full name of the corresponding entity in the graph is obtained through the constructed entity Elasticsearch database. If the Es retrieval threshold is greater than the threshold set in advance, the corresponding entity full name is directly returned, otherwise the top k entities are recommended for user selection.
[0095] According to the question entity, the candidate relationship within two hops is accurately obtained based on the Cypher statement of Neo4j.
[0096] 4. The Bert semantic similarity matching model is used for relationship matching.
[0097] Referring to Figure 4 The structure diagram of the Bert semantic similarity matching model is shown. Based on the candidate relationship obtained above, the question and the candidate relationship are spliced and input into the semantic similarity matching model.
[0098] If the model output result probability is greater than the threshold set in advance, it is determined that the candidate relationship and the question are the most matched.
[0099] 5. Question answer acquisition.
[0100] According to the question entity and the relationship obtained above, the answers of different question types can be obtained in different cases:
[0101] For single entity and single relationship questions, the answer can be obtained according to the (entity, relation, answer) form;
[0102] For single entity and multiple relationship questions, here the multiple relationships within single hop and multiple hops are divided. If it is a single-hop multiple relationship, the answer can be obtained according to the (entity, relation, answer) form. If it is a multiple-hop multiple relationship, the entity and the candidate relationship are combined to verify whether it can satisfy the query path (entity, relation1, relation2, answer). If it satisfies, the question answer is output;
[0103] For double entity questions, the entity and the candidate relationship are combined to verify whether it can satisfy the query path (entity1, relation1, answer, relation2, entity2). If it satisfies, the question answer is output.
[0104] Based on the above rule logic, the corresponding question answer can be obtained.
[0105] The above is only a preferred embodiment of the application, and does not limit the patent scope of the application. Any equivalent structure or equivalent process transformation based on the content of the application specification and the drawings, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the application.
Claims
1. A multi-task knowledge graph question answering method, characterized in that, The method includes the following steps: S1: Prepare structured text data and build a knowledge graph database according to the triple form of entity-relation-entity; S2: Prepare the training corpus needed for the model based on the knowledge graph database; S3: Build an auxiliary Elasticsearch database for related entities based on the knowledge graph database; S4: Train the Bert-BILSTM-CRF named entity recognition model and the Bert semantic similarity matching model; S5: Based on the Bert-BILSTM-CRF named entity recognition model, entity recognition is performed in the question, and the full name of the corresponding entity is obtained by searching the auxiliary Elasticsearch database according to the question entity. S6: The full name of the entity is used to perform a precise search from the graph database to obtain all candidate relations of the corresponding entity, and then the BERT semantic similarity matching model is used to obtain the entity relation that best matches the question; S7: Retrieve the answer based on the obtained entities and relationships according to the defined path rules; Step S5 includes: S51: The original data is encoded using the Bert layer to obtain the encoded vector of the original data. The semantic information of text dependencies and context is learned by training the BILSTM layer. The CRF layer is used to add constraints to the output of the BILSTM layer in order to identify entities in the problem. S52: Use the relevant entity Elasticsearch database to perform Elasticsearch retrieval. When the threshold of the Elasticsearch retrieval result is greater than the preset threshold, the full name of the corresponding entity will be output directly. Otherwise, the relevant entity name will be output for the user to select. The entity relationships that best match the question, obtained by the BERT semantic similarity matching model, include: S61: The problem Relationship with candidate entities Concatenate the following as input: S62: Encode the input X using a BERT coding layer and output the encoded vector corresponding to X: in m is the length of the input X. Let be the representation vector of the i-th character; S63: The aggregation layer connects the encoded vector output by BERT with the information obtained by Attention, inputs it into the bidirectional BILSTM layer, and finally obtains a fixed-length vector through pooling, and converts it into probability values. S64: Set a threshold parameter score. If the score is greater than the threshold, the relationship is determined to match the question. Based on this model, obtain the entity relationship that is most similar to the input question.
2. The multi-task knowledge graph question answering method as described in claim 1, characterized in that, Step S1 includes: using structured text data as the basic data for knowledge graph question answering, storing the relationships between structured text data in the graph database in the form of entity-relationship-entity triples, and connecting them with each other through relationships to form a network-like knowledge structure to obtain the knowledge graph database.
3. The multi-task knowledge graph question answering method as described in claim 1, characterized in that, Step S3 includes: constructing an auxiliary Elasticsearch database based on the full name, abbreviation, and alias of entities in the knowledge graph database.
4. The multi-task knowledge graph question answering method as described in claim 1, characterized in that, The expression for the probability value is: Where r is the text vector output after pooling, P is the predicted similarity probability value, and w and r are the weight parameter and bias term parameter, respectively.
5. The multi-task knowledge graph question answering method as described in claim 4, characterized in that, Step S6 includes: retrieving answers for single-entity single-relationship, single-entity multiple-relationship, and two-entity questions based on the number of entities and relations; wherein: For single-entity, single-relation problems, the answer is obtained in the form {entity, relation, answer}. For single-entity, multi-relation problems, if it is a single-hop multi-relation problem, the answer is obtained in the form of {entity, relation, answer}; if it is a multi-hop multi-relation problem, the entity and candidate relations are combined and it is verified whether they can satisfy the query path {entity, relation1, relation2, answer}. If they can, the answer to the problem is output. For two-entity problems, the entity and candidate relation are combined and it is verified whether they can satisfy the query path {entity1, relation1, answer, relation2, entity2}. If they can, the answer to the problem is output.
Citation Information
Patent Citations
Intelligent construction full-life data processing, analyzing, managing and controlling system
CN111651447A
Domain knowledge graph recommendation method for global comprehensive observation results
CN113254630A