Disclosure of Invention
Technical problem to be solved
Aiming at the technical problems in the prior art, the invention provides an intelligent question-answering method and device for a multi-source heterogeneous data source, which are used for at least partially solving the technical problems.
(II) technical scheme
The invention provides an intelligent question-answering method for a multi-source heterogeneous data source, which comprises the following steps: calculating a first similarity between the input question and a candidate relation, wherein the candidate relation is a relation related to the input question in a knowledge base; acquiring a first answer from a knowledge base according to the first similarity; searching a multi-hop text according to an input problem; calculating a second similarity between sentences in the multi-hop text and the input question and a third similarity between entities in the multi-hop text and the input question; acquiring a second answer from the multi-hop text according to the second similarity and the third similarity; and judging the relation between the first answer and the second answer, and outputting an answer text of the input question.
Optionally, querying the entity type of the entity in the input question in the knowledge base; acquiring the hierarchical information of a knowledge base and the literal information of input problems and candidate relations; and calculating a first similarity of the input question and the candidate relation according to the entity type, the hierarchy information and the literal information.
Optionally, calculating a first similarity between the input question and the candidate relationship according to the entity type information and the hierarchy information of the knowledge base and the literal information of the input question and the candidate relationship, including: removing entities contained in the input problems to obtain a problem template; integrating the characteristics of global information and local information of the entity type; calculating the similarity of the entity type and the candidate relationship after the feature integration to obtain a first similarity score; respectively carrying out semantic matching and literal matching on the problem template and the candidate relationship, calculating the similarity of the problem template and the candidate relationship, and obtaining a second similarity score and a third similarity score, wherein the semantic matching comprises the following steps: and dividing the candidate relation into two parts, namely mapping the relation in the entity and the problem template respectively, based on the hierarchical information of the knowledge base, and calculating to obtain a second similarity score.
Optionally, obtaining the first answer from the knowledge base according to the first similarity includes: and obtaining a candidate relation which is most matched with the input question according to the first similarity score, the second similarity score and the third similarity score, carrying out entity detection on the input question according to the candidate relation which is most matched with the input question to obtain a subject entity, and obtaining a first answer according to the subject entity.
Optionally, calculating a second similarity between a sentence in the multi-hop text and the input question and a third similarity between an entity in the multi-hop text and the input question comprises: screening sections associated with the input problem and splicing the sections into a long text; coding the long text and the input problem, and calculating the attention expression of the coded long text and the input problem; respectively taking sentences and entities in the long text as nodes, constructing a sentence graph neural network and an entity graph neural network, and reasoning to obtain coarse-grained graph neural network information and fine-grained graph neural network information; based on the attention representation, a global representation of the long text is computed using a self-attention mechanism.
Optionally, obtaining a second answer from the multi-hop text according to the second similarity and the third similarity, including: and fusing the global representation of the long text with the coarse-grained graph neural network information and the fine-grained graph neural network information, and predicting clue sentences, answer starting words and answer ending words of the fused long text to obtain a second answer.
Alternatively, a first similarity of the input problem to the candidate relationship may be calculated, using opponent training to introduce an input vector with interference capability.
Optionally, determining a relationship between the first answer and the second answer comprises: vector-coding the first answer and the second answer; and inputting the first answer and the second answer after vector coding into a classifier to obtain a relation, judging the relation to be inclusive or independent or contradictory, and combining the independent first answer and the independent second answer to obtain a combined answer text.
Optionally, outputting the answer text of the input question, including: outputting the implied first answer or the implied second answer; or outputting the merged answer text; or outputting a first answer and a second answer which are contradictory; and outputting the basis of obtaining the answer text.
Another aspect of the present invention provides an intelligent question answering apparatus for a multi-source heterogeneous data source, including: the question input module is used for inputting questions; the knowledge base question-answering module is used for calculating first similarity of the input questions and candidate relations, wherein the candidate relations are relations related to the input questions in the knowledge base; acquiring a first answer from a knowledge base according to the first similarity; the multi-hop text question-answering module is used for retrieving a multi-hop text according to an input question; calculating a second similarity between sentences in the multi-hop text and the input question and a third similarity between entities in the multi-hop text and the input question; acquiring a second answer from the multi-hop text according to the second similarity and the third similarity; the answer fusion module is used for judging the relationship between the first answer and the second answer to obtain an answer text of the input question; and the answer output module is used for outputting the answer text of the input question.
(III) advantageous effects
The invention provides an intelligent question-answering method and device facing a multi-source heterogeneous data source, which can fully understand and represent knowledge through multi-angle knowledge base information by simultaneously searching relevant answers of input questions from a structured knowledge base and an unstructured text, can greatly enrich answer contents through detection of a multi-hop text, can fully utilize multi-source heterogeneous information to return answers by combining the two, can better integrate more knowledge through integrating the knowledge base information and text semantic information compared with a single information source, provides more information sources and supports for answer reasoning, retains the advantages of accuracy and convenience of obtaining answers by the knowledge base question-answering, can well utilize the advantage of comprehensive answer coverage range of the text question-answering, and improves the accuracy and richness of output answers.
When the knowledge base is asked and answered, various information contained in the knowledge base is fully utilized to be matched with the questions, and a countermeasure training method is used, so that the performance of the knowledge base is improved, the accuracy of matching the knowledge base with the questions is improved, and the robustness of a question and answer model (device) is improved.
When the text question-answering is carried out, a multi-granularity graph neural network with the nodes being entities and the nodes being sentences is constructed and respectively used as coarse-granularity reasoning modules and fine-granularity reasoning modules, the graph neural network is used for carrying out information propagation on the sentence granularity and the entity granularity, different weights are given to the nodes according to the correlation degree with the question, noise text information is further filtered, and the performance of text answer clue extraction is improved.
The question-answer output and the text question-answer output of the knowledge base are unified, so that multi-source heterogeneous information can be effectively combined, and a simple and complete answer which is easier to understand by a user can be returned.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to specific embodiments and the accompanying drawings.
It should be noted that in the drawings or description, the same drawing reference numerals are used for similar or identical parts. Features of the embodiments illustrated in the description may be freely combined to form new embodiments without conflict, and each claim may be individually referred to as an embodiment or features of the claims may be combined to form a new embodiment, and in the drawings, the shape or thickness of the embodiment may be enlarged and simplified or conveniently indicated. Further, elements or implementations not shown or described in the drawings are of a form known to those of ordinary skill in the art. Additionally, while exemplifications of parameters including particular values may be provided herein, it is to be understood that the parameters need not be exactly equal to the respective values, but may be approximated to the respective values within acceptable error margins or design constraints.
Unless a technical obstacle or contradiction exists, the above-described various embodiments of the present invention may be freely combined to form further embodiments, which are within the scope of the present invention.
Although the present invention has been described in connection with the accompanying drawings, the embodiments disclosed in the drawings are intended to be illustrative of preferred embodiments of the present invention and should not be construed as limiting the invention. The dimensional proportions in the figures are merely schematic and are not to be understood as limiting the invention.
Although a few embodiments of the present general inventive concept have been shown and described, it would be appreciated by those skilled in the art that changes may be made in these embodiments without departing from the principles and spirit of the general inventive concept, the scope of which is defined in the claims and their equivalents.
The invention provides a specific embodiment to explain the technical scheme of the invention, for example, a natural language question is respectively input into a knowledge base question-answer module and a multi-hop text question-answer module, answer retrieval is carried out in a multi-source heterogeneous information source, after answer triples returned by the knowledge base question-answer module and answer texts returned by the text question-answer module are obtained, the answer triples and the answer texts are taken as candidate answers and sent to an answer fusion module, and the relation between the answer triples and the answer text is judged, so that uniform answer output is obtained. The multi-source data refers to a plurality of data sources, and the heterogeneous data refers to inconsistency of types, characteristics and the like of data, and comprises structured data, semi-structured data, unstructured data and the like.
Fig. 1 schematically shows a flowchart of an intelligent question-answering method for a multi-source heterogeneous data source according to an embodiment of the present invention, and as shown in fig. 1, the method includes:
s101, calculating a first similarity between the input question and a candidate relation, wherein the candidate relation is a relation related to the input question in a knowledge base.
According to the embodiment of the invention, before calculating the first similarity of the input problem and the candidate relation, the subject entity is detected according to the input problem, all the relations connected with the entity are inquired and obtained in the knowledge base to serve as the candidate relation, and then the entity type of the entity in the input problem in the knowledge base is inquired; acquiring the hierarchical information of a knowledge base and the literal information of input problems and candidate relations; and calculating a first similarity of the input question and the candidate relation according to the entity type, the hierarchy information and the literal information.
According to the embodiment of the invention, calculating the first similarity of the input question and the candidate relation according to the entity type information and the hierarchy information of the knowledge base and the literal information of the input question and the candidate relation comprises the following steps: removing entities contained in the input problems to obtain a problem template; integrating the characteristics of global information and local information of the entity type; calculating the similarity of the entity type and the candidate relationship after the feature integration to obtain a first similarity score; respectively carrying out semantic matching and literal matching on the problem template and the candidate relationship, calculating the similarity of the problem template and the candidate relationship, and obtaining a second similarity score and a third similarity score, wherein the semantic matching comprises the following steps: and dividing the candidate relation into two parts, namely mapping the relation in the entity and the problem template respectively to obtain a second similarity score by calculation based on the hierarchical information of the knowledge base, namely the multi-angle knowledge base information.
FIG. 2 schematically illustrates a knowledge base question answering module structure diagram according to an embodiment of the invention.
According to an embodiment of the present invention, as shown in fig. 2, in the method for question-answering by a knowledge base according to an embodiment of the present invention, the obtaining a first answer by a knowledge base may include: firstly, entity recognition is carried out on an input problem, a subject entity in the input problem is found, other parts of the input problem except the subject entity are used as a problem template, and data preprocessing is carried out for matching candidate relations. The subject entity may query the knowledge base for its entity type and query all the relationships to which it is connected (relationships refer to "subject", "couple", "parent", etc., a subset FB5M of Freebase includes seven thousand relationships) as candidates. Next, sending the entity type and the candidate relationship to an entity type-relationship matching module; on the other hand, the problem template and the candidate relation are input into a problem template-relation matching module, in the module, matching is divided into two paths, one path is matched with the semantic information of the problem template and the relation, and the other path is matched with the literal information of the problem template and the relation. The matching modules obtain three matching scores, which will be described below. And integrating the three scores to obtain a final score, wherein the candidate with the highest score is the knowledge base relationship which is most matched with the question, and then combining the subject entity obtained by the entity detection tool to obtain an answer knowledge triple of the question and answer of the knowledge base, namely the first answer obtained from the knowledge base.
According to the embodiment of the invention, when entity type-relation matching is carried out, in order to fully utilize entity type information, two levels of vector representation are used, one level is that the entity type is regarded as a whole, so that the global information of the entity type is fully expressed, the other level is that the entity type is divided into words, so that the local information of the entity type is fully utilized, after vector representation is respectively carried out, the features of different levels of the entity type are integrated by using the maximum pooling, the vector representation t of the entity type is obtained, then the vector representation r of the relation is obtained, the distance between the two vectors is measured by using cosine similarity, and a first similarity score S for measuring the similarity between the two vectors is obtainedtypeThe formula is as follows:
according to the embodiment of the invention, when semantic matching of the problem template-relation is carried out, considering that information contained in different parts of one relation is different, namely hierarchy information of a knowledge base, one relation is divided into two parts, the first part can be used for mapping information of a subject entity in the problem template, and the second part maps a relation reference in the problem template, for example, the relation of't v.t _ program.program _ creator' in the knowledge base Freebase, wherein the 't.t.v _ program' part represents the attribute of the subject entity, and the 'program _ creator' part contains a relation referenceAnd generating information. Then using a bidirectional long-short term memory network based on an attention mechanism to obtain a problem representation vector q with different emphasis points1And q is2And a relation representation vector r of different parts1And r2Respectively calculating the semantic similarity to obtain the score S of the semantic similaritysemanticThe formula is as follows:
Ssemantic=q1·r1+q2·r2 (2)
according to the embodiment of the invention, when the face matching of the problem template-relation is carried out, considering that some words in the problem template possibly correspond to some words in the relation, the relation is divided into a word sequence, so that the word sequence corresponding to the problem is realized, and the problem word sequence and the relation word sequence are respectively expressed into vectors q and rwThen, a similarity matrix containing the corresponding relation of the two word sequences is obtained by carrying out the operation of matrix multiplication, similar features are extracted by convolution, and thus, the similarity score S of the face is obtainedliteralThe formula is as follows:
Sliteral=conv(q·rw) (3)
according to the embodiment of the invention, when the first similarity of the input problem and the candidate relation is calculated, the input vector with the interference capability can be introduced by using the countertraining.
FIG. 3 schematically illustrates a diagram of an antagonistic training model according to an embodiment of the present invention.
According to the embodiment of the invention, during model training, a confrontation training method is used, namely, disturbance is added to an input sequence, the input with the disturbance is used for replacing the original input for subsequent training so as to enhance the robustness of the model, the network model of the part is shown in FIG. 3, the vector of the input obtained after the word embedding layer is assumed to be represented as w, and the added disturbance is radvThen the input vector after adding the perturbation becomes radvAnd + w. The calculation method of the disturbance is as follows:
radv=-∈g/||g||2 (4)
wherein | | xi | purple
2Representing a two-norm, F represents the loss function of the model,
are gradient operators.
S102, acquiring a first answer from the knowledge base according to the first similarity.
According to the embodiment of the present invention, according to the first similarity, the obtaining of the first answer triplet from the knowledge base includes: and obtaining a candidate relation which is most matched with the input question according to the first similarity score, the second similarity score and the third similarity score, carrying out entity detection on the input question according to the candidate relation which is most matched with the input question to obtain a subject entity, and obtaining a first answer according to the subject entity.
S103, searching the multi-hop text according to the input question.
According to an embodiment of the invention, for each question, for example, we retrieve ten articles related to the question from Wikipedia. The system returns answers and clue sentences after multi-hop understanding. For example, the question is "what is the party to whom 45 th american president belongs? ", corresponding to 10 text articles.
S104, calculating a second similarity between the sentences in the multi-hop text and the input question and a third similarity between the entity in the multi-hop text and the input question.
According to the embodiment of the invention, calculating a second similarity between a sentence in the multi-hop text and an input question and a third similarity between an entity in the multi-hop text and the input question comprises the following steps: screening sections associated with the input problem and splicing the sections into a long text; coding the long text and the input problem, and calculating the attention expression of the coded long text and the input problem; respectively taking sentences and entities in the long text as nodes, constructing a sentence graph neural network and an entity graph neural network, and reasoning to obtain coarse-grained graph neural network information and fine-grained graph neural network information; based on the attention representation, a global representation of the long text is computed using a self-attention mechanism.
Fig. 4 is a diagram schematically illustrating a multi-hop text question answering module structure according to an embodiment of the present invention.
According to the embodiment of the invention, as shown in fig. 4, first, a chapter screening module is used to remove chapters with low relevance to the problem, the chapter screening module is designed, and after being encoded by using a large-scale semantic model BERT, a sigmoid activation function is used to calculate two classifications, so as to determine whether each article is relevant to the problem. And splicing the screened remaining chapters into a long text. Then, long texts and questions are encoded using the pre-trained language model BERT, and a bi-directional attention model is used to compute the question-to-answer and the attention representation of the answer-to-question. And then respectively establishing a graph neural network with nodes being sentences and a graph neural network with nodes being entities, wherein the inference process of the graph network with the nodes being sentences is used as coarse-grained inference, and the graph network with the nodes being entities is used as fine-grained inference. And calculating the similarity score of the node and the problem, and masking the node. Information propagation between nodes relies on a graph attention mechanism, information of one node is propagated to adjacent nodes, and a self-attention mechanism is applied on a sentence graph neural network to obtain a global representation of the whole long text.
And S105, acquiring a second answer from the multi-hop text according to the second similarity and the third similarity.
According to an embodiment of the present invention, obtaining a second answer from the multi-hop text according to the second similarity and the third similarity includes: and fusing the global representation of the long text with coarse-grained graph neural network information and fine-grained graph neural network information, and predicting clue sentences, answer starting words and answer ending words of the fused long text to obtain a second answer, wherein the second answer can be a text, for example.
According to the embodiment of the invention, as shown in fig. 4, the graph neural network information with different granularities is spliced on the long text and used as the input of the cyclic neural network, so that the effect of multi-granularity fusion is achieved. And predicting the clue sentences, the answer starting words and the answer ending words on the long texts after the information is updated, so as to obtain corresponding answer texts.
According to the embodiment of the invention, clue sentences are extracted from long texts spliced by 10 text articles, and the first serves as the 45 th American president. "and" A "belong to the United states Congress Party. The answer is "American Council Party". When using model prediction, we predict the clue sentences and the answer start word index position and end word index position.
And S106, judging the relation between the first answer and the second answer, and outputting an answer text of the input question.
According to an embodiment of the present invention, determining the relationship between the first answer and the second answer includes: vector-coding the first answer and the second answer; and inputting the first answer and the second answer after vector coding into a classifier to obtain a relation, judging whether the relation is implied or independent or contradictory, and combining the independent first answer and the independent second answer to obtain a combined answer.
According to an embodiment of the present invention, outputting answer text of an input question includes: outputting the implied first answer or the implied second answer; or outputting the merged answer; or outputting a first answer and a second answer which are contradictory; and outputting the basis of obtaining the answer text.
Fig. 5 schematically shows a structure diagram of an answer fusion module according to an embodiment of the present invention.
According to the embodiment of the present invention, as shown in fig. 5, the input of the module is the output of the two modules, and firstly, the input answer to be processed is vector-coded; and then, a classifier is used for judging the answer relation of the multiple candidate answers, namely, judging whether the answers are in an inclusion, independent or contradictory relation. Specifically, the answer triples obtained by the knowledge base question-answering module and the answer texts output by the multi-hop text question-answering module are connected end to obtain a word sequence, the word sequence is embedded to obtain vector representation of the word sequence, a bidirectional long-time and short-time memory network is input, and finally a softmax layer is used for obtaining the relation between answers. And selecting the included answers for the answers containing the relations, outputting the answers containing the relations, combining the answers with the independent relations, reserving all the answers with the contradictory relations, and obtaining the basis of the answers for the user to select the answers.
In summary, the embodiment of the present invention provides an intelligent question answering method. The relevant answers of the input questions are retrieved from the structured knowledge base and the unstructured text at the same time, wherein knowledge can be fully understood and expressed through multi-angle knowledge base information, answer content can be greatly enriched by detecting the multi-hop text, the multi-source heterogeneous information can be fully utilized to return answers by combining the multi-angle knowledge base information and the unstructured text information, more knowledge can be better integrated by integrating the knowledge base information and the text semantic information compared with a single information source, more information sources and support are provided for answer reasoning, the advantage that the knowledge base question answering is accurate and convenient is kept, the advantage that the text question answering covers the advantage of the comprehensive answer range is well utilized, and the accuracy and the richness of the output answers are improved.
Fig. 6 schematically shows a block diagram of an intelligent question-answering device for a multi-source heterogeneous data source according to an embodiment of the present invention.
As shown in fig. 6, another aspect of the present invention provides an intelligent question answering device 600, including:
a question input module 610 for inputting a question.
A knowledge base question-answering module 620, configured to calculate a first similarity between the input question and a candidate relationship, where the candidate relationship is a relationship in the knowledge base related to the input question; and acquiring a first answer from the knowledge base according to the first similarity.
According to the embodiment of the invention, before calculating the first similarity between the input question and the candidate relationship, a subject entity is detected according to the input question, all the relationships connected with the entity are obtained as the candidate relationship by querying in a knowledge base, and the subject entity can be, for example, a structured triple.
A multi-hop text question-and-answer module 630, configured to retrieve a multi-hop text according to an input question; calculating a second similarity between sentences in the multi-hop text and the input question and a third similarity between entities in the multi-hop text and the input question; and acquiring a second answer from the multi-hop text according to the second similarity and the third similarity.
And the answer fusion module 640 is configured to determine a relationship between the first answer and the second answer to obtain an answer text of the input question.
And an answer output module 650 for outputting an answer text of the input question.
Fig. 7 schematically shows an overall structure diagram of an intelligent question answering device for a multi-source heterogeneous data source according to an embodiment of the present invention.
According to the embodiment of the present invention, as shown in fig. 7, a question is input in the question input module 610, answers to the input question are retrieved in the knowledge base question-answering module 620 and the multi-hop text question-answering module 630, respectively, and then the answers obtained from the knowledge base question-answering module 620 and the multi-hop text question-answering module 630 are determined and fused in the answer fusion module 640 to obtain the determined and fused answer, which may be, for example, an implied answer, a parallel independent answer, or all contradictory answers. Finally, the above answer text of the input question is output through the answer output module 650.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the present invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the protection scope of the present invention.