Question and answer query method, device, electronic device and computer-readable storage medium

The pre-trained target classifier classifies and analyzes the question pattern and generates target query statements, which solves the problem of poor analysis of complex question sentences in the existing technology, and improves the accuracy and efficiency of knowledge graph query.

CN114942981BActive Publication Date: 2024-12-17INST OF SCI & TECHN INFORMATION OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210365261.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2024-12-17
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

In the prior art question-and-answer query system based on knowledge graph, complex question-and-answer query system cannot accurately analyze, resulting in the inquired answers being less accurate.

Method used

The pre-trained target classifier classifies the question pattern, obtains the quantitative information of the named entity and entity relationship, generates the target query statement, and obtains the answer based on the knowledge graph query.

Benefits of technology

It improves the adaptability of the question-and-answer query system and the accuracy of answers, and is suitable for complex questions including multiple sets of entity names and entity relationships, improving query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114942981B_ABST
    Figure CN114942981B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a question-answer query method, device, electronic device, and computer-readable storage medium, and relate to the field of information processing technology. The method includes: obtaining a question to be queried; classifying the question into sentence patterns based on a pre-trained target classifier to obtain a sentence pattern category; wherein the sentence pattern category represents the quantity information of named entities and entity relationships in the question; parsing the question based on the quantity information to generate a target query sentence corresponding to the question; and querying the answer sentence corresponding to the target query sentence based on a preset knowledge graph. The embodiments of the present application construct a question classification system based on question sentence patterns, and effectively parses the question through the quantity information of named entities and entity relationships, thereby enhancing the domain adaptability of question parsing and effectively improving the accuracy of the answer sentence and the query efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing technology. Specifically, the present application relates to a question-and-answer query method, device, electronic device, and computer-readable storage medium. Background Art

[0002] At present, with the continuous development of intelligent information service applications, knowledge graphs have been widely used in the fields of intelligent search, intelligent question and answer, personalized recommendation, etc. Knowledge graphs provide a more effective way to express, organize, manage and utilize massive, heterogeneous and dynamic big data on the Internet, making the network more intelligent and closer to human cognitive thinking.

[0003] When performing question-answering queries based on the knowledge graph, it is necessary to convert the natural language question entered by the user into a query statement of the knowledge graph, and then generate the corresponding answer sentence based on the query statement. In the prior art, questions are usually classified according to the answer type, and the questions are parsed based on keyword matching to generate query sentences; the query sentence generation process provided above is limited by the identification and expansion method of the question keywords, and is suitable for simple questions containing only one subject, predicate and object, but cannot accurately parse complex questions involving multiple limiting relationships, and there is a problem that the accuracy of the generated query sentence is not high, resulting in the problem that the accuracy of the queried answer sentence is not high. Summary of the invention

[0004] The embodiments of the present application provide a question-answer query method, device, electronic device, and computer-readable storage medium, which can solve the problem that the accuracy of the answer sentences queried by the question-answer query system in the prior art is not high. The technical solution is as follows:

[0005] According to one aspect of an embodiment of the present application, a question-answer query method is provided, the method comprising:

[0006] Get the question to be queried;

[0007] The question is classified into sentence types based on the pre-trained target classifier to obtain sentence type categories, wherein the sentence type categories represent the quantity information of named entities and entity relationships in the question;

[0008] Parse the question sentence based on the quantity information and generate a target query sentence corresponding to the question sentence;

[0009] The answer sentence corresponding to the target query sentence is based on the preset knowledge graph query.

[0010] Optionally, the target classifier includes a first classifier and a second classifier;

[0011] Based on the pre-trained target classifier, the question is classified into sentence types, and the sentence types are obtained, including:

[0012] Classify the question sentence into sentence types according to the first classifier to obtain a sentence type classification result;

[0013] The sentence classification results are fused based on the second classifier to obtain the sentence category.

[0014] Optionally, the first classifier includes at least two target classification units;

[0015] The question is classified into sentence patterns according to the first classifier to obtain sentence pattern classification results, including:

[0016] The question is classified into sentence patterns based on each target classification unit to obtain at least two pieces of classification information, and the classification information is used as the sentence pattern classification result.

[0017] Optionally, the first classifier includes three target classification units;

[0018] The target classifier is trained in the following way:

[0019] The preset first training set is divided into three sub-training sets; each sub-training set corresponds to an initial classification unit;

[0020] Input the sub-training sets into the corresponding initial classification units respectively, train the initial classification units, and obtain the target classification units;

[0021] A second training set is obtained based on the prediction data generated by the initial classification unit during the training process;

[0022] The fusion classifier is trained based on the second training set to obtain a target classifier; wherein the fusion classifier includes a target classification unit and a preset initial classifier.

[0023] Optionally, the above-mentioned parsing of the question based on the quantity information to generate a target query sentence corresponding to the question includes:

[0024] Identify named entities in questions;

[0025] Extract the target relation name in the question;

[0026] Based on named entities, target relation names and quantity information, the question is converted into a target query statement.

[0027] Optionally, the target relation name in the above extraction question includes:

[0028] Get at least two candidate relationship names;

[0029] Combine the question sentence with each candidate relation name to generate fusion information;

[0030] Perform semantic analysis on the fused information to determine the target relationship name.

[0031] Optionally, the semantic analysis of the fusion information to determine the target relationship name includes:

[0032] Determine the semantic feature vector of the fused information;

[0033] determining target fusion information from at least two fusion information based on the semantic feature vector;

[0034] The candidate relation name corresponding to the target fusion information is used as the target relation name.

[0035] According to another aspect of an embodiment of the present application, a question-answer query device is provided, the device comprising:

[0036] A first acquisition module is used to acquire a question to be queried;

[0037] A classification module is used to classify the question sentences based on the pre-trained target classifier to obtain sentence categories; wherein the sentence categories represent the quantity information of named entities and entity relationships in the question sentences;

[0038] A parsing module, used to parse the question based on the quantity information and generate a target query sentence corresponding to the question;

[0039] The second acquisition module is used to query the answer sentence corresponding to the target query sentence based on the preset knowledge graph.

[0040] Optionally, the target classifier includes a first classifier and a second classifier;

[0041] The above classification module is used to:

[0042] Classify the question sentence into sentence types according to the first classifier to obtain a sentence type classification result;

[0043] The sentence classification results are fused based on the second classifier to obtain the sentence category.

[0044] Optionally, the first classifier includes at least two target classification units;

[0045] The above classification module is also used for:

[0046] The question is classified into sentence patterns based on each target classification unit to obtain at least two pieces of classification information, and the classification information is used as the sentence pattern classification result.

[0047] Optionally, the first classifier includes three target classification units;

[0048] The above device also includes a training module, which is used to:

[0049] The preset first training set is divided into three sub-training sets; each sub-training set corresponds to an initial classification unit;

[0050] Input the sub-training sets into the corresponding initial classification units respectively, train the initial classification units, and obtain the target classification units;

[0051] A second training set is obtained based on the prediction data generated by the initial classification unit during the training process;

[0052] The fusion classifier is trained based on the second training set to obtain a target classifier; wherein the fusion classifier includes a target classification unit and a preset initial classifier.

[0053] Optionally, the above parsing module is used to:

[0054] Identify named entities in questions;

[0055] Extract the target relation name in the question;

[0056] Based on named entities, target relation names and quantity information, the question is converted into a target query statement.

[0057] Optionally, the above parsing module is also used to:

[0058] Get at least two candidate relationship names;

[0059] Combine the question sentence with each candidate relation name to generate fusion information;

[0060] Perform semantic analysis on the fused information to determine the target relationship name.

[0061] Optionally, the above parsing module is also used to:

[0062] Determine the semantic feature vector of the fused information;

[0063] determining target fusion information from at least two fusion information based on the semantic feature vector;

[0064] The candidate relation name corresponding to the target fusion information is used as the target relation name.

[0065] According to another aspect of an embodiment of the present application, an electronic device is provided, which includes: a memory, a processor, and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the method shown in the first aspect of the embodiment of the present application.

[0066] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method shown in the first aspect of the embodiments of the present application are implemented.

[0067] According to one aspect of an embodiment of the present application, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, the steps of the method shown in the first aspect of the embodiment of the present application are implemented.

[0068] The beneficial effects of the technical solution provided by the embodiment of the present application are:

[0069] The embodiment of the present application uses a target classifier to classify the sentence patterns of the question to be queried to obtain a sentence pattern category, and then parses the question based on the quantity information of the named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches the preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the present application constructs a question classification system according to the question pattern, and effectively parses the question according to the quantity information of the named entities and entity relationships; compared with the question parsing method based on keyword matching in the prior art, the question parsing method based on named entities and entity relationships in the embodiment of the present application is not limited to the field of question and answer query, and can be applied to complex questions including multiple groups of entity names and entity relationships, thereby improving the adaptability of the question and answer query system and effectively improving the accuracy of the answer sentence and query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0071] Figure 1 A schematic diagram of an application scenario of a question-and-answer query method provided in an embodiment of the present application;

[0072] Figure 2 A flowchart of a question-and-answer query method provided in an embodiment of the present application;

[0073] Figure 3 A schematic diagram of a flow chart of sentence classification in a question-answering query method provided in an embodiment of the present application;

[0074] Figure 4 A schematic diagram of a process for named entity recognition in a question-answering query method provided in an embodiment of the present application;

[0075] Figure 5 A schematic diagram of a process for extracting a target relationship name in a question-answer query method provided in an embodiment of the present application;

[0076] Figure 6 A flowchart of an example question-answering query method provided in an embodiment of the present application;

[0077] Figure 7A schematic diagram of the structure of a question-and-answer query device provided in an embodiment of the present application;

[0078] Figure 8 A schematic diagram of the structure of a question-and-answer query electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0079] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0080] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" may be implemented as "A", or as "B", or as "A and B".

[0081] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0082] As a semantic network that reveals the relationship between entities, knowledge graph provides a more effective way to express, organize, manage and utilize the massive, heterogeneous and dynamic big data on the Internet, making the network more intelligent and closer to human cognitive thinking. Knowledge graphs are usually divided into general domain knowledge graphs and vertical domain knowledge graphs, which are stored in RDF (Resource Description Framework) or Neo4j (a high-performance graph database) to form a graph database. In a question-answering system that uses the graph database of the knowledge graph as a data source, it is necessary to convert the natural language questions entered by the user into query statements of the knowledge graph.

[0083] When converting a question into a query statement of the knowledge graph, there are two main steps: question classification and question parsing. Question classification is to classify the questions raised by the user into predefined categories to determine the type of question; question parsing is to convert the question into the corresponding query language based on question classification.

[0084] The inventors found that in the prior art, a question classification system is usually constructed based on answer type, question semantic information, or a mixture of answer type and question semantic information. Then, the questions are classified by rule-based, statistical, or neural network-based classification methods, and then keyword matching, template matching, semantic analysis, or translation model methods are used to parse the questions and generate query statements. When querying knowledge graphs, the prior art mainly has the following problems:

[0085] 1. The construction method of the question classification system has the problem of difficulty in balancing the classification granularity and question coverage;

[0086] 2. When classifying questions, there are often problems with accuracy or efficiency;

[0087] 3. When parsing questions, there is a problem that the parsing effect of complex questions is not good.

[0088] The question-and-answer query method, device, electronic device, and computer-readable storage medium provided in this application are intended to solve the above technical problems in the prior art.

[0089] The embodiment of the present application provides a question-answer query method, which can be implemented by a terminal or a server. The terminal or server involved in the embodiment of the present application obtains the question to be queried, and classifies the question into sentence patterns through a target classifier to obtain a sentence pattern category, and then parses the question based on the number information of the named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches a preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the embodiment of the present application effectively parses the question according to the sentence pattern category, thereby improving the accuracy of the answer sentence obtained by the query.

[0090] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.

[0091] like Figure 1 As shown, the question-answering query method of the present application can be applied to Figure 1In the scenario shown, specifically, the server 102 can obtain the question to be queried from the client 101, and classify the question into sentence patterns based on the target classifier to obtain a sentence pattern category. Then, the server 102 parses the question according to the quantity information of the named entities and entity relationships represented by the sentence pattern category, generates a corresponding target query statement, and then queries the answer sentence corresponding to the target query statement based on the knowledge graph, and sends the answer sentence to the client 101.

[0092] Figure 1 In the scenario shown, the above question-and-answer query method can be performed in a server, and in other scenarios, it can also be performed in a terminal.

[0093] Technicians in this technical field can understand that the "terminal" used here can be a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a MID (Mobile Internet Device), etc.; the "server" can be implemented by an independent server or a server cluster consisting of multiple servers.

[0094] The present application embodiment provides a question-answering query method, such as Figure 2 As shown, it can be applied to a terminal or server for performing question-answering query, and the method includes:

[0095] S201, obtaining a question to be searched.

[0096] The above question may be a natural language question.

[0097] Specifically, a terminal or server for question-answering query may directly obtain the question from a preset memory address, or may obtain the question in real-time acquisition.

[0098] In some implementations, a terminal or server for performing question-answering queries may generate a question based on a user's input operation on an input device such as a mouse, keyboard, or touch screen;

[0099] In other implementations, a terminal or server for question-and-answer queries may collect user voice information in real time based on a voice device such as a microphone, and perform voice recognition on the voice information to generate a question.

[0100] S202, classifying the question into sentence patterns based on the pre-trained target classifier to obtain sentence pattern categories.

[0101] The target classifier may be an integrated classifier including at least two machine learning models. The sentence type category represents the quantity information of named entities and entity relationships in the question.

[0102] Sentence types include simple questions, single-jump questions, single-qualified questions, and multiple-qualified questions. A simple question is a question that only includes a subject-predicate-object (i.e., knowledge triple) query, and its corresponding answer can belong to one of the subject, predicate, or object; for example, "What papers has researcher Zhang San written?" is a simple question.

[0103] A single-hop question may include two related knowledge triples. When determining its corresponding answer, it is necessary to first find the intermediate answer and then reconstruct the triple query based on the intermediate answer. For example, "What are the research topics of the papers written by researcher Zhang San?" is a single-hop question.

[0104] A single restrictive question can be a question that includes a restrictive relationship. When determining its corresponding answer, it is necessary to query two triples containing the same predicate and take the intersection based on the query results to get the final answer. For example, "What are the papers written by researchers Zhang San and Li Si?" is a single restrictive question.

[0105] A multi-qualified question can be a question that includes multiple qualification relationships. When determining its corresponding answer, it is necessary to query multiple triples containing the same predicate and take the intersection based on the query results to get the final answer. For example, "What papers on the topic of competitive intelligence have been written by researchers Zhang San and Li Si?" is a multi-qualified question.

[0106] Among them, a simple question can include 1 named entity and 1 entity relationship; a single-hop question can include 1 named entity and 2 entity relationships; a single-restricted question can include 2 named entities and 1 entity relationship; and a multiple-restricted question can include 2 named entities and 2 entity relationships.

[0107] Specifically, a terminal or server used for question-answering query can use a target classifier integrated by at least two machine learning models to classify sentences and obtain sentence categories.

[0108] Machine learning is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. It is the core of artificial intelligence and the fundamental way to make computers intelligent.

[0109] Common algorithms involved in machine learning include: decision tree algorithm, naive Bayes algorithm, support vector machine algorithm, random forest algorithm, artificial neural network algorithm, deep learning, etc.

[0110] S203, parsing the question based on the quantity information to generate a target query sentence corresponding to the question.

[0111] Specifically, a terminal or server for question-answering query may formulate a query sentence generation template corresponding to each sentence pattern category in advance.

[0112] The terminal or server used for question-answering query can identify and extract named entities and entity relationships in the question, and then generate a template based on the query statement corresponding to the named entities, entity relationships and sentence categories to convert the question into a target query statement.

[0113] S204, querying the answer sentence corresponding to the target query sentence based on the preset knowledge graph.

[0114] Among them, the storage methods of knowledge graphs include relational tables, graph databases and distributed storage.

[0115] The embodiment of the present application is specifically described by taking the knowledge graph stored in a graph database as an example. A graph database is a database that organizes and stores data in the form of a graph. A graph database is a database used for semantic retrieval that uses a graph structure including nodes, edges, and attributes to represent and store data. The key concept is the graph, which is directly associated with the stored data items. This association relationship allows data to be directly associated, and in many cases it can be extracted in just one step.

[0116] Correspondingly, the target query statement can be a query language for interacting with the graph database. The target query statement can be a Cypher (a descriptive graph query language) statement or a SparQL (SPARQL Protocol and RDFQuery Language, query language and data acquisition protocol) statement, which is not specifically limited in this application.

[0117] The embodiment of the present application uses a target classifier to classify the sentence patterns of the question to be queried to obtain a sentence pattern category, and then parses the question based on the quantity information of the named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches the preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the present application constructs a question classification system according to the question pattern, and effectively parses the question according to the quantity information of the named entities and entity relationships; compared with the question parsing method based on keyword matching in the prior art, the question parsing method based on named entities and entity relationships in the embodiment of the present application is not limited to the field of question and answer query, and can be applied to complex questions including multiple groups of entity names and entity relationships, thereby improving the adaptability of the question and answer query system and effectively improving the accuracy of the answer sentence and query efficiency.

[0118] A possible implementation method is provided in the embodiment of the present application, such as Figure 3As shown, the above-mentioned target classifier includes a first classifier and a second classifier.

[0119] Among them, the target classifier can be constructed based on the strategy of ensemble learning.

[0120] Ensemble learning completes learning tasks by building and combining multiple learners. The general structure is: first generate a group of "individual learners", and then combine them using a certain strategy. The main combination strategies include averaging, voting, and learning. Ensemble learning can often achieve more significant generalization performance than a single learner by combining multiple learners.

[0121] The current ensemble learning methods can be divided into three categories: Bagging (bagging algorithm), Boosting (boosting algorithm) and Stacking (Stacked Generalization). Taking Stacking ensemble learning as an example, its implementation method is to train a target classifier to fit the prediction results of all predictors (including the first classifier and the second classifier), which can improve the classification accuracy of the target classifier. The following will take the target classifier based on Stacking as an example for specific explanation.

[0122] In the above step S202, the pre-trained target classifier is used to classify the question into sentence patterns to obtain sentence pattern categories, including:

[0123] (1) The question is classified into sentence patterns according to the first classifier to obtain the sentence pattern classification result.

[0124] Specifically, a terminal or server used for question-answering query can classify and predict the question sentence based on the first classifier to obtain a sentence classification result.

[0125] In an embodiment of the present application, a possible implementation method is provided, wherein the first classifier includes at least two target classification units; the question is classified into sentence patterns according to the first classifier to obtain sentence pattern classification results, including:

[0126] The question is classified into sentence patterns based on each target classification unit to obtain at least two pieces of classification information, and the classification information is used as the sentence pattern classification result.

[0127] Among them, the first classifier can be a base classifier based on a decision tree algorithm, which can include three target classification units, namely, a LightGBM (Gradient Boosting Decision Tree) model, an XGBoost (eXtreme GradientBoosting) model and a random forest model.

[0128] Specifically, a terminal or server for question-answering query may use each target classification unit to perform classification prediction on the question sentence, obtain classification information corresponding to each target classification unit, and use at least two classification information as sentence classification results.

[0129] The classification information may be the predicted probability of a question for each candidate sentence type; the candidate sentence types may include simple questions, single-jump questions, single-restricted questions, and multiple-restricted questions.

[0130] (2) Based on the second classifier, the sentence classification results are fused to obtain the sentence category.

[0131] In some embodiments, the second classifier may be a meta-classifier based on a logistic regression algorithm;

[0132] In other embodiments, the second classifier may also be a meta-classifier based on a CNN (Convolutional neural network) or SVM (Support Vector Machine) algorithm, which is not specifically limited in the embodiments of the present application.

[0133] In an embodiment of the present application, taking three target classification units as an example, a terminal or server for question-and-answer queries can input questions into three target classification units, namely, the LightGBM model, the XGBoost model, and the random forest model, respectively. Each target classification unit outputs the predicted probability of the question for each candidate sentence category, and then all the above sentence classification results are input into a meta-classifier based on a logistic regression algorithm, and the target probability of the question for each candidate sentence category is output. The candidate sentence category corresponding to the maximum value of the target probability can be selected as the final sentence category.

[0134] The above introduces the classification steps of the target classifier, and the training process of the target classifier will be described in detail below.

[0135] A possible implementation method is provided in an embodiment of the present application, wherein the first classifier includes three target classification units;

[0136] The target classifier is trained in the following way:

[0137] The preset first training set is divided into three sub-training sets; each sub-training set corresponds to an initial classification unit; the sub-training sets are input into the corresponding initial classification units respectively, the initial classification units are trained, and the target classification units are obtained;

[0138] A second training set is obtained based on the prediction data generated by the initial classification unit during the training process; the fusion classifier is trained based on the second training set to obtain a target classifier; wherein the fusion classifier includes the target classification unit and a preset initial classifier.

[0139] The first classifier may include three different classification models, namely, LightGBM model, XGBoost model and random forest model, and the three initial classification units correspond to the above three classification models respectively. The above preset initial classifier corresponds to the first classifier, which is used to perform fusion processing on the output data of all initial classification units.

[0140] Specifically, a terminal or server used for question-and-answer queries can first cross-validate each initial classification unit by evenly dividing the training data of the first training set. The training process of each initial classification unit includes: selecting two sub-training sets as training data and another sub-training set as test data; using the training data to train the initial classification unit, and then using the test data to predict the trained initial classification unit to generate prediction data. After completing the above round of training, the sub-training sets can be rotated. For example, there are three sub-training sets A, B, and C. In the previous round of training, A was used as test data and B and C were used as training data. In this round, B is used as test data and A and C are used as training data. Each initial classification unit can undergo three rounds of training, and then the prediction data generated during the three rounds of training is used as the second training set.

[0141] The embodiment of the present application uses a cross-validation method to train the first classifier, and uses the first classifier to predict the first training set, and uses the obtained prediction data as the new second training set. Finally, the fusion classifier is trained based on the second training set to generate a target classifier. The above training process can improve the generalization ability of the classification model, so that the target classifier can adapt to a variety of training data and obtain more accurate sentence categories. At the same time, the present application constructs a classification system for questions based on sentence categories, avoiding the problem of difficulty in balancing classification granularity and question coverage in the prior art.

[0142] In an embodiment of the present application, a possible implementation method is provided, in which the question sentence is parsed based on the quantity information in the above step S203 to generate a target query sentence corresponding to the question sentence, including:

[0143] (1) Identify named entities in questions.

[0144] Among them, named entities are names of people, names of organizations, names of places, and all other entities identified by names. In this application, named entities include long string named entities and short string named entities.

[0145] Specifically, Figure 4As shown, a terminal or server for performing question-answering query can obtain long string named entities in the question based on a first identifier, and obtain short string named entities in the question based on a second identifier.

[0146] The first recognizer may be a recognition model based on AC automaton. AC automaton (Aho-Corasick Automaton) is one of the famous multi-mode matching algorithms proposed by Bell Labs in 1975. The algorithm is widely used in matching multiple strings. The recognition steps of the first recognizer are as follows:

[0147] Based on the question, a dictionary tree is constructed, which is used to represent the search data structure of the question; then a prefix pointer is set, which is used to match and jump to each character node in the dictionary tree; the dictionary tree is traversed according to the prefix pointer to obtain the long string named entity. The AC automaton can not only quickly identify the long string named entity; but also does not require manual annotation of a large amount of training data for model training, and can be quickly deployed to improve recognition efficiency.

[0148] On the other hand, in the embodiment of the present application, the second recognizer can be a recognition model based on an artificial neural network. Take the second recognizer as a BiLSTM (Bi-directional Long Short-Term Memory, bidirectional long short-term memory recurrent neural network) model as an example for specific description. The BiLSTM-based named entity recognizer mainly includes 5 layers: data preprocessing layer, word vector conversion layer, BiLSTM layer, CRF (Conditional Random Field, conditional random field) layer and model output;

[0149] Among them, the data processing layer is used to perform text segmentation, stop word removal and other preprocessing on the question; the word vector conversion layer is used to convert the input text into a vector sequence; the BiLSTM layer includes two bidirectional LSTMs: one is the forward LSTM, which is used to learn the forward feature information of the vector, and the other is the backward LSTM, which is used to learn the backward feature information of the vector, and the forward feature information and the backward feature information are concatenated to obtain the target feature vector. The target feature vector can be used as the input of each time step of BiLSTM, and the complete hidden state output sequence is calculated; the CRF layer improves the accuracy of predicted labels by learning constraints; the model output layer uses the annotation sequence corresponding to the question as the result of named entity recognition.

[0150] The embodiment of the present application recognizes long-string named entities and short-string named entities in a question sentence in a collaborative manner through the first recognizer and the second recognizer, respectively, taking into account the recognition requirements of both types of named entities, extracting accurate named entities in the question sentence, ensuring the effect of question parsing, and laying a good foundation for the subsequent conversion of the target query sentence.

[0151] (2) Extract the target relation name in the question.

[0152] Among them, the target relation name can represent the association information between the named entities in the question.

[0153] Specifically, a terminal or server for question-answering query may extract the target relation name in the question based on a BERT (Bidirectional Encoder Representations from Transformers) model.

[0154] Among them, Transformer is a natural language processing model based on encoder and decoder. The BERT model is based on the encoding module of Transformer, which can realize the concurrent extraction of relational features of target words in sentences, and can extract relational features at multiple different levels, thereby more comprehensively reflecting the semantics of sentences; at the same time, BERT can obtain word meanings based on the context of sentences, thereby avoiding ambiguity. The process of extracting target relation names based on the BERT model will be described in detail below.

[0155] In an embodiment of the present application, a possible implementation method is provided, wherein the target relation name in the above-mentioned extraction question sentence includes:

[0156] a. Get at least two candidate relationship names.

[0157] Specifically, a terminal or server for performing question-answer query may obtain candidate relationship names from a preset relationship database.

[0158] The candidate relationship name may be set based on a user's selection operation.

[0159] b. Combine the question with each candidate relation name to generate fusion information.

[0160] In the embodiment of the present application, taking the question "Which institution does the author of paper xx work for?" as an example, the candidate relationship names may include author, institution, and journal. The corresponding fusion information may include: "[CLS] Which institution does the author of paper xx work for [SEP] author [SEP]", "[CLS] Which institution does the author of paper xx work for [SEP] institution [SEP]", and "[CLS] Which institution does the author of paper xx work for [SEP] journal [SEP]". Among them, the above [CLS] and [SEP] are special encoders of the BERT model, the [CLS] symbol can be a classification flag, and [SEP] can be a segmentation symbol, which is used to distinguish text vectors.

[0161] c. Perform semantic analysis on the fused information to determine the target relationship name.

[0162] In an embodiment of the present application, taking the question "Which institution does the author of paper xx work for?" as an example, candidate relationship names may include author, institution, and journal. The corresponding fusion information may include: "[CLS] Which institution does the author of paper xx work for [SEP] author [SEP]", "[CLS] Which institution does the author of paper xx work for [SEP] institution [SEP]", and "[CLS] Which institution does the author of paper xx work for [SEP] journal [SEP]". A terminal or server used for question-and-answer queries may input the above fusion information into a BERT model for semantic analysis, obtain classification data for each fusion information, and determine the target relationship name based on the above classification data. Specifically, the process of extracting the target relationship name based on the BERT model will be described in detail below.

[0163] A possible implementation method is provided in the embodiment of the present application, such as Figure 5 As shown, in the embodiment of the present application, the BERT model includes a preprocessing layer, a BERT layer, and a classification layer as an example; the above-mentioned semantic analysis of the fusion information to determine the target relationship name includes:

[0164] c1. Determine the semantic feature vector of fused information.

[0165] Specifically, a terminal or server used for question-and-answer queries can perform vector conversion on the fused information based on the Word2Vector (vector conversion algorithm) algorithm of the preprocessing layer to generate a preprocessing vector; the preprocessing vector is then input into the BERT layer to obtain a vector representation that incorporates the semantic information of the entire text, namely, a semantic feature vector.

[0166] The preprocessing vector may include a word vector, a text vector, and a position vector of fused information.

[0167] c2. Determine target fusion information from at least two fusion information based on the semantic feature vector.

[0168] Specifically, a terminal or server used for question-answering queries can classify semantic feature vectors based on the softmax (normalized exponential function) function in the classification layer, obtain the classification probability of each fusion information, and determine the target fusion information based on the classification probability.

[0169] c3. Use the candidate relationship name corresponding to the target fusion information as the target relationship name.

[0170] In an embodiment of the present application, taking the question "Which institution does the author of paper xx work for?" as an example, candidate relationship names may include author, institution, and journal. The corresponding fusion information may include fusion information X: "[CLS] Which institution does the author of paper xx work for [SEP] author [SEP]", fusion information Y: "[CLS] Which institution does the author of paper xx work for [SEP] institution [SEP]", and fusion information Z: "[CLS] Which institution does the author of paper xx work for [SEP] journal [SEP]". A terminal or server used for question-and-answer queries may input the above fusion information into a BERT model for semantic analysis and perform binary classification to obtain classification data for each fusion information. For example, if the classification probability of fusion information X and fusion information Y is 1, and the classification probability of fusion information Z is 0, "author" and "institution" are used as target relationship names.

[0171] In the process of extracting the target relationship name, the embodiment of the present application concatenates the question sentence with the candidate relationship name and inputs it into the BERT model for semantic analysis and classification processing, thereby determining the relationship information included in the question sentence, achieving accurate grasp of the semantic information, and providing a reliable guarantee for the accuracy of subsequent question conversion.

[0172] (3) Based on the named entity, target relation name and quantity information, the question is converted into a target query statement.

[0173] Specifically, a terminal or server used for question-and-answer queries can generate query statement generation rules corresponding to the sentence pattern category in advance based on the combination information and position information of the named entities and relationship names in each sentence pattern category; and then generate a target query statement based on the sentence pattern category, named entities and target relationship names through the query statement generation rules corresponding to the sentence pattern category.

[0174] The following takes the target query statement as Cypher as an example, and illustrates the conversion steps of the target query statement for each sentence type category:

[0175] When the question is "What papers have been written by researcher Zhang San?", the corresponding sentence type is a simple question. The named entity obtained through question analysis is: Class researcher-Zhang San; the target relationship name is: paper author; the corresponding query statement generation rule is: Class document <paper author> Class researcher, which represents the position information of the named entity and the target relationship name, and searches for the answer sentence of type "Class document"; the final generated Cypher target query statement is:

[0176] match(n:Paper)-[:'Paper author']->(p:People); match paper author p and document n

[0177] where p.name = "Zhang San"; the author of the paper is "Zhang San"

[0178] return n; return document n

[0179] When the question is "What are the research topics of the papers written by researcher Zhang San?", the corresponding sentence type is a single-hop question. The named entity obtained through question analysis is: Class researcher-Zhang San; the target relationship name is: paper author, keyword; the corresponding query sentence generation rule is: Class researcher <paper author> [Class literature] <keyword> Class research topic, which represents the location information of the named entity and the two target relationship names, and searches for the answer sentence of type "Class research topic"; the final generated Cypher target query sentence is:

[0180] match(n:People)<-[:'paper author']-(p:Paper)-[:'keyword']->(q:key); match paper author and keyword information

[0181] where p.name = "Zhang San"; the author of the paper is "Zhang San"

[0182] return q; return keyword q

[0183] When the question is "What are the papers written by researchers Zhang San and Li Si?", the corresponding sentence type is a single-restricted question. The named entities obtained through question analysis are: Class researcher-Zhang San, Class researcher-Li Si; the target relationship name is: paper author; the corresponding query statement generation rule is: Class researcher <paper author> [Class document] <paper author> Class researcher, which represents the position information of two similar named entities and the target relationship name, and searches for the answer sentence of type "Class document"; the final generated Cypher target query statement is:

[0184] MATCH (n:Paper)-[:`Paper Author`]->(p:People); Match the paper author p and the literature n

[0185] WHERE p.name = "Zhang San" AND p.name = "Li Si"; The paper authors are "Zhang San" and "Li Si"

[0186] RETURN n; Return the literature n

[0187] When the question is "What are the papers on competitive intelligence written by researchers Zhang San and Li Si?", its corresponding sentence pattern category is a multiple-restriction question. Through question parsing, the named entities obtained are: Class researcher-Zhang San, Class researcher-Li Si, Class research topic-competitive intelligence; The target relationship names are: Paper author, Keyword; The corresponding query statement generation rule is: Class researcher<Paper author>[Class literature]<Keyword>Class research topic, which represents determining the position information of two types of named entities and two target relationship names, and the search type is the answer sentence of "Class literature"; The final generated Cypher target query statement is:

[0188] MATCH (n:People)<-[:`Paper Author`]-(p:Paper)-[:`Keyword`]->(q:key); Match the paper author and keyword information

[0189] WHERE p.name = "Zhang San" AND p.name = "Li Si" AND q.name = "competitive intelligence"; The paper authors are "Zhang San" and "Li Si", and the keyword is "competitive intelligence"

[0190] RETURN p; Return the literature p

[0191] In the embodiment of the present application, by extracting knowledge triple information such as named entities and target relationship names in the question sentence, the question parsing based on the sentence pattern category and the conversion of the query statement are realized; In the embodiment of the present application, not only can simple questions be well parsed, but also complex questions can be accurately parsed, making the question-and-answer query system have good adaptability and improving the query efficiency and accuracy of the knowledge graph.

[0192] To better understand the above question-and-answer query method, the following is combined with Figure 6 A detailed example of the question-and-answer query method of the present application is elaborated. This question-and-answer query method is applied to a terminal or a server, and the method includes the following steps:

[0193] S601, Obtain the question sentence to be queried.

[0194] The above question may be a natural language question.

[0195] Specifically, a terminal or server for question-answering query may directly obtain the question from a preset memory address, or may obtain the question in real-time acquisition.

[0196] In some implementations, a terminal or server for performing question-answering queries may generate a question based on a user's input operation on an input device such as a mouse, keyboard, or touch screen;

[0197] In other implementations, a terminal or server for question-and-answer queries may collect user voice information in real time based on a voice device such as a microphone, and perform voice recognition on the voice information to generate a question.

[0198] S602: classify the question into sentence patterns according to the first classifier to obtain a sentence pattern classification result.

[0199] Among them, the first classifier can be a base classifier based on a decision tree algorithm, which can include three target classification units such as a LightGBM model, an XGBoost model and a random forest model.

[0200] Specifically, a terminal or server for question-answering query may use each target classification unit to perform classification prediction on the question sentence, obtain classification information corresponding to each target classification unit, and use at least two classification information as sentence classification results.

[0201] The classification information may be the predicted probability of a question for each candidate sentence type; the candidate sentence types may include simple questions, single-jump questions, single-restricted questions, and multiple-restricted questions.

[0202] S603, performing fusion processing on the sentence pattern classification results based on the second classifier to obtain sentence pattern categories; the sentence pattern categories represent the quantity information of named entities and entity relationships in the question.

[0203] The second classifier may be a meta-classifier based on a logistic regression algorithm. The first classifier and the second classifier are used to construct a fusion classifier based on an integrated learning method.

[0204] In an embodiment of the present application, a terminal or server for question-and-answer queries can input questions into three target classification units, namely, the LightGBM model, the XGBoost model, and the random forest model, respectively. Each target classification unit outputs the predicted probability of the question for each candidate sentence category, and then all the above sentence classification results are input into a meta-classifier based on a logistic regression algorithm, and the target probability of the question for each candidate sentence category is output. The candidate sentence category corresponding to the maximum value of the target probability can be selected as the final sentence category.

[0205] S604: Identify named entities in the question.

[0206] Among them, named entities are names of people, names of organizations, names of places, and all other entities identified by names. In this application, named entities include long string named entities and short string named entities.

[0207] Specifically, a terminal or server for performing question-answer query may obtain long string named entities in the question based on a first identifier, and obtain short string named entities in the question based on a second identifier.

[0208] S605, obtaining at least two candidate relationship names; combining the question sentence with each candidate relationship name to generate fusion information.

[0209] Specifically, a terminal or server for performing question-answer query may obtain candidate relationship names from a preset relationship database.

[0210] The candidate relationship name may be set based on a user's selection operation.

[0211] In the embodiment of the present application, taking the question "Which institution does the author of paper xx work for?" as an example, the candidate relationship names may include author, institution, and journal. The corresponding fusion information may include: "[CLS] Which institution does the author of paper xx work for [SEP] author [SEP]", "[CLS] Which institution does the author of paper xx work for [SEP] institution [SEP]", and "[CLS] Which institution does the author of paper xx work for [SEP] journal [SEP]". Among them, the above [CLS] and [SEP] are special encoders of the BERT model, the [CLS] symbol can be a classification flag, and [SEP] can be a segmentation symbol, which is used to distinguish text vectors.

[0212] S606, determining a semantic feature vector of the fusion information; and determining target fusion information from at least two fusion information based on the semantic feature vector.

[0213] Specifically, a terminal or server used for question-and-answer queries can perform vector conversion on the fused information based on the Word2Vector algorithm of the preprocessing layer to generate a preprocessing vector; the preprocessing vector is then input into the BERT layer to obtain a vector representation that incorporates the semantic information of the entire text, namely, a semantic feature vector.

[0214] The preprocessing vector may include a word vector, a text vector, and a position vector of fused information.

[0215] At the same time, the terminal or server used for question-answering queries can classify the semantic feature vectors based on the softmax function in the classification layer, obtain the classification probability of each fusion information, and determine the target fusion information based on the classification probability.

[0216] S607: Use the candidate relationship name corresponding to the target fusion information as the target relationship name.

[0217] In an embodiment of the present application, taking the question "Which institution does the author of paper xx work for?" as an example, candidate relationship names may include author, institution, and journal. The corresponding fusion information may include fusion information X: "[CLS] Which institution does the author of paper xx work for [SEP] author [SEP]", fusion information Y: "[CLS] Which institution does the author of paper xx work for [SEP] institution [SEP]", and fusion information Z: "[CLS] Which institution does the author of paper xx work for [SEP] journal [SEP]". A terminal or server used for question-and-answer queries may input the above fusion information into a BERT model for semantic analysis and perform binary classification to obtain classification data for each fusion information. For example, if the classification probability of fusion information X and fusion information Y is 1, and the classification probability of fusion information Z is 0, "author" and "institution" are used as target relationship names.

[0218] S608: Convert the question sentence into a target query sentence based on the named entity, the target relationship name and the quantity information.

[0219] Specifically, a terminal or server used for question-and-answer queries can generate query statement generation rules corresponding to the sentence pattern category in advance based on the combination information and position information of the named entities and relationship names in each sentence pattern category; and then generate a target query statement based on the sentence pattern category, named entities and target relationship names through the query statement generation rules corresponding to the sentence pattern category.

[0220] S609, querying the answer sentence corresponding to the target query sentence based on the preset knowledge graph.

[0221] The storage methods of knowledge graphs include relational tables, graph databases, and distributed storage. Taking the knowledge graph stored in a graph database as an example, the corresponding target query statement can be a query language that interacts with the graph database.

[0222] The embodiment of the present application uses a target classifier to classify the sentence patterns of the question to be queried to obtain a sentence pattern category, and then parses the question based on the quantity information of the named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches the preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the present application constructs a question classification system according to the question pattern, and effectively parses the question according to the quantity information of the named entities and entity relationships; compared with the question parsing method based on keyword matching in the prior art, the question parsing method based on named entities and entity relationships in the embodiment of the present application is not limited to the field of question and answer query, and can be applied to complex questions including multiple groups of entity names and entity relationships, thereby improving the adaptability of the question and answer query system and effectively improving the accuracy of the answer sentence and query efficiency.

[0223] The present application embodiment provides a question-answer query device, such as Figure 7 As shown, the question-answer query device 70 may include: a first acquisition module 701, a classification module 702, a parsing module 703 and a second acquisition module 704;

[0224] The first acquisition module 701 is used to acquire the question to be queried;

[0225] A classification module 702 is used to classify the question sentence pattern based on the pre-trained target classifier to obtain a sentence pattern category; wherein the sentence pattern category represents the quantity information of the named entities and entity relationships in the question sentence;

[0226] A parsing module 703, used to parse the question sentence based on the quantity information and generate a target query sentence corresponding to the question sentence;

[0227] The second acquisition module 704 is used to query the answer sentence corresponding to the target query sentence based on the preset knowledge graph.

[0228] A possible implementation method is provided in an embodiment of the present application, wherein the target classifier includes a first classifier and a second classifier;

[0229] The classification module 702 is used to:

[0230] Classify the question sentence into sentence types according to the first classifier to obtain a sentence type classification result;

[0231] The sentence classification results are fused based on the second classifier to obtain the sentence category.

[0232] A possible implementation method is provided in an embodiment of the present application, wherein the first classifier includes at least two target classification units;

[0233] The classification module 702 is further used for:

[0234] The question is classified into sentence patterns based on each target classification unit to obtain at least two pieces of classification information, and the classification information is used as the sentence pattern classification result.

[0235] A possible implementation method is provided in an embodiment of the present application, wherein the first classifier includes three target classification units;

[0236] The above device also includes a training module, which is used to:

[0237] The preset first training set is divided into three sub-training sets; each sub-training set corresponds to an initial classification unit;

[0238] Input the sub-training sets into the corresponding initial classification units respectively, train the initial classification units, and obtain the target classification units;

[0239] A second training set is obtained based on the prediction data generated by the initial classification unit during the training process;

[0240] The fusion classifier is trained based on the second training set to obtain a target classifier; wherein the fusion classifier includes a target classification unit and a preset initial classifier.

[0241] The present application embodiment provides a possible implementation method, wherein the above-mentioned parsing module 703 is used to:

[0242] Identify named entities in questions;

[0243] Extract the target relation name in the question;

[0244] Based on named entities, target relation names and quantity information, the question is converted into a target query statement.

[0245] A possible implementation method is provided in an embodiment of the present application. The above-mentioned parsing module 703 is also used for:

[0246] Get at least two candidate relationship names;

[0247] Combine the question sentence with each candidate relation name to generate fusion information;

[0248] Perform semantic analysis on the fused information to determine the target relationship name.

[0249] A possible implementation method is provided in an embodiment of the present application. The above-mentioned parsing module 703 is also used for:

[0250] Determine the semantic feature vector of the fused information;

[0251] determining target fusion information from at least two fusion information based on the semantic feature vector;

[0252] The candidate relation name corresponding to the target fusion information is used as the target relation name.

[0253] The device of the embodiments of the present application can execute the method provided by the embodiments of the present application, and the implementation principles are similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.

[0254] The embodiment of the present application uses a target classifier to classify the sentence patterns of the question to be queried to obtain a sentence pattern category, and then parses the question based on the quantity information of the named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches the preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the present application constructs a question classification system according to the question pattern, and effectively parses the question according to the quantity information of the named entities and entity relationships; compared with the question parsing method based on keyword matching in the prior art, the question parsing method based on named entities and entity relationships in the embodiment of the present application is not limited to the field of question and answer query, and can be applied to complex questions including multiple groups of entity names and entity relationships, thereby improving the adaptability of the question and answer query system and effectively improving the accuracy of the answer sentence and query efficiency.

[0255] An electronic device is provided in an embodiment of the present application, including a memory, a processor and a computer program stored in the memory, the processor executes the above-mentioned computer program to implement the steps of the question-answering query method, which can be achieved compared with the related art: the embodiment of the present application uses a target classifier to classify the sentence patterns of the question to be queried to obtain a sentence pattern category, and then parses the question based on the number information of named entities and entity relationships represented by the sentence pattern category, and then generates a target query sentence corresponding to the question, wherein the target query sentence matches a preset knowledge graph, and the answer sentence can be queried from the knowledge graph through the target query sentence; the present application constructs a question classification system according to the question pattern, and effectively parses the question according to the number information of named entities and entity relationships; compared with the question parsing method based on keyword matching in the prior art, the question parsing method based on named entities and entity relationships in the embodiment of the present application is not limited to the field of question-answering query, and can be applied to complex questions including multiple groups of entity names and entity relationships, thereby improving the adaptability of the question-answering query system and effectively improving the accuracy of the answer sentence and the query efficiency.

[0256] In an alternative embodiment, an electronic device is provided, such as Figure 8 As shown, Figure 8The electronic device 800 shown includes: a processor 801 and a memory 803. The processor 801 and the memory 803 are connected, such as through a bus 802. Optionally, the electronic device 800 may also include a transceiver 804, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 804 is not limited to one, and the structure of the electronic device 800 does not constitute a limitation on the embodiments of the present application.

[0257] The processor 801 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 801 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0258] The bus 802 may include a path to transmit information between the above components. The bus 802 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 802 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0259] The memory 803 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage medium, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.

[0260] The memory 803 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 801. The processor 801 is used to execute the computer program stored in the memory 803 to implement the steps shown in the above method embodiment.

[0261] The electronic devices include, but are not limited to, mobile terminals such as mobile phones, notebook computers, PADs, etc. and fixed terminals such as digital TVs, desktop computers, etc.

[0262] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0263] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that when the computer device executes the computer instructions, the following conditions are achieved:

[0264] Get the question to be queried;

[0265] The question is classified into sentence types based on the pre-trained target classifier to obtain sentence type categories, wherein the sentence type categories represent the quantity information of named entities and entity relationships in the question;

[0266] Parse the question sentence based on the quantity information and generate a target query sentence corresponding to the question sentence;

[0267] The answer sentence corresponding to the target query sentence is based on the preset knowledge graph query.

[0268] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that shown or described in the drawings.

[0269] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0270] The above is only an optional implementation method for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.

Claims

1. A question-answering query method, It is characterized in that include: Get the question to be queried; Based on the pre-trained target classifier, the question is classified into sentence types to obtain sentence type categories; wherein the sentence type categories represent the quantity information of named entities and entity relationships in the question; Parsing the question sentence based on the quantity information to generate a target query sentence corresponding to the question sentence; Querying the answer sentence corresponding to the target query sentence based on the preset knowledge graph; The step of parsing the question sentence based on the quantity information to generate a target query sentence corresponding to the question sentence includes: Identifying named entities in the question; Extracting the target relation name in the question; Based on the named entity, the target relation name and the quantity information, the question sentence is converted into a target query sentence using a query sentence generation rule corresponding to the sentence pattern category generated in advance; The query statement generation rule is generated according to the combination information and position information of the named entity and relation name in the sentence pattern category.

2. The method according to claim 1, It is characterized in that The target classifier includes a first classifier and a second classifier; The pre-trained target classifier performs sentence classification on the question to obtain sentence categories, including: Performing sentence pattern classification on the question sentence according to the first classifier to obtain a sentence pattern classification result; The sentence pattern classification results are fused based on the second classifier to obtain a sentence pattern category.

3. The method according to claim 2, It is characterized in that The first classifier includes at least two target classification units; The step of performing sentence classification on the question sentence according to the first classifier to obtain a sentence classification result includes: The question is classified into sentence patterns based on each of the target classification units to obtain at least two pieces of classification information, and the classification information is used as the sentence pattern classification result.

4. The method according to claim 3, It is characterized in that The first classifier includes three target classification units; The target classifier is trained based on the following method: Divide the preset first training set into three sub-training sets; each of the sub-training sets corresponds to an initial classification unit; Inputting the sub-training sets into corresponding initial classification units respectively, training the initial classification units, and obtaining target classification units; Obtaining a second training set based on the prediction data generated by the initial classification unit during the training process; The fusion classifier is trained based on the second training set to obtain the target classifier; wherein the fusion classifier includes the target classification unit and a preset initial classifier.

5. The method according to claim 1, It is characterized in that The step of extracting the target relation name in the question sentence includes: Get at least two candidate relationship names; Combining the question sentence with each of the candidate relationship names to generate fusion information; The fusion information is semantically analyzed to determine the target relationship name.

6. The method according to claim 5, It is characterized in that The performing semantic analysis on the fusion information to determine the target relationship name includes: Determining a semantic feature vector of the fused information; Based on the semantic feature vector, determining target fusion information from at least two of the fusion information; The candidate relationship name corresponding to the target fusion information is used as the target relationship name.

7. A question-answering query device, It is characterized in that include: A first acquisition module is used to acquire a question to be queried; A classification module, used for performing sentence classification on the question based on a pre-trained target classifier to obtain a sentence category; wherein the sentence category represents the quantity information of named entities and entity relationships in the question; A parsing module, used to parse the question sentence based on the quantity information and generate a target query sentence corresponding to the question sentence; A second acquisition module is used to query the answer sentence corresponding to the target query sentence based on a preset knowledge graph; The parsing module is used to: Identifying named entities in the question; Extracting the target relation name in the question; Based on the named entity, the target relation name and the quantity information, the question sentence is converted into a target query sentence using a query sentence generation rule corresponding to the sentence pattern category generated in advance; The query statement generation rule is generated according to the combination information and position information of the named entity and relation name in the sentence pattern category.

8. An electronic device comprising a memory, a processor and a computer program stored in the memory, It is characterized in that The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Knowledge graph relational data classification method based on syntactic attention neural network

    CN111177394A

  • Intelligent question and answer method and system based on tourism knowledge graph

    CN113535917A