CN114942981A - Question-answer query method and device, electronic equipment and computer readable storage medium - Google Patents

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

Info

Publication number
CN114942981A
CN114942981A CN202210365261.8A CN202210365261A CN114942981A CN 114942981 A CN114942981 A CN 114942981A CN 202210365261 A CN202210365261 A CN 202210365261A CN 114942981 A CN114942981 A CN 114942981A
Authority
CN
China
Prior art keywords
question
sentence
target
classifier
classification
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210365261.8A
Other languages
Chinese (zh)
Inventor
韩红旗
丁楷
李琳娜
张运良
王力
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Institute Of Scientific And Technical Information Of China
Original Assignee
Institute Of Scientific And Technical Information Of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Institute Of Scientific And Technical Information Of China filed Critical Institute Of Scientific And Technical Information Of China
Priority to CN202210365261.8A priority Critical patent/CN114942981A/en
Publication of CN114942981A publication Critical patent/CN114942981A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • G06F40/35Discourse or dialogue representation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Databases & Information Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a question and answer query method and device, electronic equipment and a computer readable storage medium, and relates to the technical field of information processing. The method comprises the following steps: acquiring a question to be inquired; classifying the sentence patterns of the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of named entities and entity relations in the question sentence; analyzing the question based on the quantity information to generate a target query sentence corresponding to the question; and inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph. The question classification system is constructed according to the question patterns, the questions are effectively analyzed through the number information of the named entities and the entity relations, the field adaptability of question analysis is enhanced, and the answer accuracy and the query efficiency are effectively improved.

Description

Question and answer query method and device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of information processing technologies, and in particular, to a question and answer query method, device, electronic device, and computer-readable storage medium.
Background
At present, with the continuous development of intelligent information service application, Knowledge maps (Knowledge Graph) have been widely applied in the fields of intelligent search, intelligent question answering, personalized recommendation and the like. The knowledge graph provides a more effective mode for the expression, organization, management and utilization of massive, heterogeneous and dynamic big data on the Internet, so that the intelligent level of the network is higher and is closer to the cognitive thinking of human beings.
When inquiring and answering based on the knowledge map, natural language question sentences input by users need to be converted into inquiry sentences of the knowledge map, and then corresponding answer sentences are formed after inquiry according to the inquiry sentences. In the prior art, question classification is usually performed according to answer types, and question analysis is performed based on a keyword matching mode so as to generate query sentences; the generation process of the query sentence is limited by the identification and expansion mode of the key words of the question sentence, is suitable for a simple question sentence only containing one main predicate object, but cannot accurately analyze complex question sentences related to a plurality of limited relations, and has the problems that the accuracy of the generated query sentence is not high, and the accuracy of the queried answer sentence is not high.
Disclosure of Invention
The embodiment of the application provides a question and answer query method, a question and answer query device, electronic equipment and a computer readable storage medium, and can solve the problem that answer sentences queried by a question and answer query system in the prior art are low in accuracy. The technical scheme is as follows:
according to an aspect of an embodiment of the present application, there is provided a question and answer query method, including:
obtaining a question to be inquired;
classifying the sentence patterns of the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of named entities and entity relations in the question sentence;
analyzing the question based on the quantity information to generate a target query sentence corresponding to the question;
and inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph.
Optionally, the target classifier includes a first classifier and a second classifier;
classifying the sentence patterns of the question sentences by a pre-trained target classifier to obtain sentence pattern categories, wherein the sentence pattern categories comprise:
classifying the sentence patterns of the question sentences according to a first classifier to obtain a sentence pattern classification result;
and performing fusion processing on the sentence pattern classification result based on the second classifier to obtain the sentence pattern category.
Optionally, the first classifier includes at least two target classification units;
classifying the sentence patterns of the question sentences according to the first classifier to obtain a sentence pattern classification result, wherein the sentence pattern classification result comprises the following steps:
and classifying the sentence patterns of the question sentences based on each target classification unit respectively to obtain at least two classification information, and taking the classification information as a sentence pattern classification result.
Optionally, the first classifier includes three target classification units;
the target classifier is obtained by training based on the following modes:
dividing a preset first training set into three sub-training sets; each sub-training set corresponds to an initial classification unit;
respectively inputting the sub-training sets into corresponding initial classification units, and training the initial classification units to obtain target classification units;
obtaining a second training set based on the prediction data generated by the initial classification unit in the training process;
training the fusion classifier based on a second training set to obtain a target classifier; the fusion classifier comprises a target classification unit and a preset initial classifier.
Optionally, the analyzing the question based on the quantity information to generate a target query statement corresponding to the question includes:
identifying a named entity in the question;
extracting a target relation name in the question;
and converting the question sentence into a target query sentence based on the named entity, the target relation name and the quantity information.
Optionally, the extracting the target relationship name in the question sentence includes:
acquiring at least two candidate relationship names;
combining the question with each candidate relation name to generate fusion information;
and performing semantic analysis on the fusion information to determine a target relation name.
Optionally, the performing semantic analysis on the fusion information to determine the target relationship name includes:
determining semantic feature vectors of the fusion information;
determining target fusion information from the at least two fusion information based on the semantic feature vector;
and taking the candidate relation name corresponding to the target fusion information as a target relation name.
According to another aspect of the embodiments of the present application, there is provided a question and answer inquiring apparatus, including:
the first acquisition module is used for acquiring a question to be inquired;
the classification module is used for classifying the sentence patterns of the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of named entities and entity relations in the question sentence;
the analysis module is used for analyzing the question based on the quantity information to generate a target query sentence corresponding to the question;
and the second acquisition module is used for inquiring the answer sentence corresponding to the target inquiry sentence based on the preset knowledge graph.
Optionally, the target classifier includes a first classifier and a second classifier;
the classification module is configured to:
classifying the question sentence according to the sentence patterns of the first classifier to obtain a sentence pattern classification result;
and performing fusion processing on the sentence pattern classification result based on the second classifier to obtain the sentence pattern category.
Optionally, the first classifier includes at least two target classification units;
the classification module is further configured to:
and classifying the sentence patterns of the question sentences based on each target classification unit respectively to obtain at least two classification information, and taking the classification information as a sentence pattern classification result.
Optionally, the first classifier includes three target classification units;
the apparatus further comprises a training module configured to:
dividing a preset first training set into three sub-training sets; each sub-training set corresponds to an initial classification unit;
respectively inputting the sub-training sets into corresponding initial classification units, and training the initial classification units to obtain target classification units;
obtaining a second training set based on the prediction data generated by the initial classification unit in the training process;
training the fusion classifier based on a second training set to obtain a target classifier; the fusion classifier comprises a target classification unit and a preset initial classifier.
Optionally, the parsing module is configured to:
identifying a named entity in the question;
extracting a target relation name in the question;
and converting the question sentence into a target query sentence based on the named entity, the target relation name and the quantity information.
Optionally, the parsing module is further configured to:
acquiring at least two candidate relationship names;
combining the question with each candidate relation name to generate fusion information;
and performing semantic analysis on the fusion information to determine a target relation name.
Optionally, the parsing module is further configured to:
determining semantic feature vectors of the fusion information;
determining target fusion information from the at least two fusion information based on the semantic feature vector;
and taking the candidate relation name corresponding to the target fusion information as a target relation name.
According to another aspect of an embodiment of the present application, there is provided an electronic apparatus including: the apparatus comprises a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the steps of the method as shown in the first aspect of the embodiments of the present application.
According to a further aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method as set forth in the first aspect of embodiments of the present application.
According to an aspect of an embodiment of the present application, there is provided a computer program product comprising a computer program that, when executed by a processor, performs the steps of the method as set forth in the first aspect of the embodiment of the present application.
The technical scheme provided by the embodiment of the application has the following beneficial effects:
the method comprises the steps of carrying out sentence pattern classification on a question to be queried through a target classifier to obtain a sentence pattern type, analyzing the question based on quantity information of named entities and entity relations represented by the sentence pattern type to further generate a target query sentence corresponding to the question, wherein the target query sentence is matched with a preset knowledge map, and the target query sentence can be queried from the knowledge map to obtain a reply sentence through the target query sentence; the method comprises the steps of constructing a question classification system according to question patterns, and effectively analyzing the question according to quantity information of named entities and entity relations; compared with the prior art that the question is analyzed based on the keyword matching mode, the question analyzing mode based on the named entity and the entity relation is not limited by the field of question and answer query, and can be applied to complex question comprising multiple groups of entity names and entity relations, so that the adaptivity of a question and answer query system is improved, and the question accuracy and the query efficiency are effectively improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic view of an application scenario of a question and answer querying method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a question and answer querying method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart illustrating sentence classification in a question and answer query method according to an embodiment of the present application;
fig. 4 is a schematic flowchart illustrating a process of identifying a named entity in a question and answer querying method according to an embodiment of the present application;
fig. 5 is a schematic flow chart illustrating a process of extracting a target relationship name in a question and answer query method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of an exemplary question-answer query method provided in the embodiment of the present application;
fig. 7 is a schematic structural diagram of a question-answering query device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a question-answer querying electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the embodiments set forth below in connection with the drawings are exemplary descriptions for explaining technical solutions of the embodiments of the present application, and do not limit the technical solutions of the embodiments of the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should be further understood that the terms "comprises" and/or "comprising," when used in this specification in connection with embodiments of the present application, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, as embodied in the art. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
To make the objects, technical solutions and advantages of the present application more clear, the following detailed description of the embodiments of the present application will be made with reference to the accompanying drawings.
The knowledge graph is used as a semantic network for revealing the relation between entities, and provides a more effective mode for the expression, organization, management and utilization of massive, heterogeneous and dynamic large data on the Internet, so that the intelligent level of the network is higher, and the network is closer to the cognitive thinking of human beings. The knowledge graph is generally divided into a general domain knowledge graph and a vertical domain knowledge graph, and is stored in a Resource Description Framework (RDF) mode or a high-performance graph database (Neo 4 j) mode to form a graph database. In a question-answering system using a knowledge-graph database as a data source, it is necessary to convert a natural language question input by a user into a query sentence of a knowledge graph.
When a question is converted into a query statement of a knowledge graph, the method mainly comprises the following two steps: question classification and question parsing. The question classification is to classify the questions provided by the user into predefined categories so as to determine the types of the questions; the question analysis is to convert the question into a corresponding query language on the basis of question classification.
The inventor finds that in the prior art, a question classification system is generally established based on answer types, question semantic information or mixed semantic information of the answer types and the question semantics, then the question is classified in a classification mode based on rules, statistics or neural networks, and then the question is analyzed by methods such as keyword matching, template matching, semantic analysis or translation models, so as to generate query sentences. When the knowledge graph is queried, the prior art mainly has the following problems:
1. the construction mode of a question classification system has the problem that the classification granularity and the problem coverage rate are difficult to be considered;
2. when the question is classified, the problem of low accuracy or efficiency often exists;
3. when a question is analyzed, there is a problem that the analysis effect for a complicated question is not good.
The question and answer querying method, device, electronic equipment and computer readable storage medium provided by the application aim to solve the technical problems in the prior art.
The embodiment of the application provides a question and answer query method, which can be realized by a terminal or a server. The terminal or the server related to the embodiment of the application acquires a question to be queried, performs sentence pattern classification on the question through the target classifier to obtain a sentence pattern type, analyzes the question based on quantity information of a named entity and an entity relation represented by the sentence pattern type, and further generates a target query sentence corresponding to the question, wherein the target query sentence is matched with a preset knowledge map, and can be queried from a knowledge map through the target query sentence to obtain a reply sentence; the question sentence is effectively analyzed according to the sentence pattern type, and the accuracy rate of the answer sentence obtained by query is improved.
The technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application will be described below through descriptions of several exemplary embodiments. It should be noted that the following embodiments may be referred to, referred to or combined with each other, and the description of the same terms, similar features, similar implementation steps and the like in different embodiments is not repeated.
As shown in fig. 1, the question-answer query method of the present application may be applied to the scenario shown in fig. 1, specifically, the server 102 may obtain a question to be queried from the client 101, perform sentence pattern classification on the question based on a target classifier to obtain a sentence pattern type, analyze the question according to the number information of named entities and entity relationships represented by the sentence pattern type by the server 102 to generate a corresponding target query sentence, query an answer sentence corresponding to the target query sentence based on a knowledge graph, and send the answer sentence to the client 101.
In the scenario shown in fig. 1, the above-mentioned question and answer querying method may be performed in the server, or in another scenario, may be performed in the terminal.
Those skilled in the art will understand that the "terminal" used herein may be a Mobile phone, a tablet computer, a PDA (Personal Digital Assistant), an MID (Mobile Internet Device), etc.; a "server" may be implemented as a stand-alone server or as a server cluster comprised of multiple servers.
The embodiment of the present application provides a question and answer query method, as shown in fig. 2, which may be applied to a terminal or a server that performs question and answer query, and the method includes:
s201, a question to be inquired is obtained.
The question may be a natural language question.
Specifically, the terminal or the server for performing question and answer query may directly obtain the question from a preset memory address, or may obtain the question in a real-time acquisition manner.
In some embodiments, a terminal or a server for performing question and answer queries may generate a question sentence based on an input operation of a user on an input device such as a mouse, a keyboard, or a touch screen;
in other embodiments, the terminal or the server for performing question and answer query may collect voice information of the user in real time based on a voice device such as a microphone, and perform voice recognition on the voice information to generate a question.
S202, carrying out sentence pattern classification on the question sentences based on the pre-trained target classifier to obtain sentence pattern categories.
Wherein the target classifier may be an ensemble classifier comprising at least two machine learning models. The sentence pattern category represents the quantity information of named entities and entity relations in the question sentence.
Sentence categories may include simple question, single skip question, single double limited question, and multiple limited question. A simple question may be a question that includes only one query of a subject-predicate (i.e., a knowledge triplet), and its corresponding answer may belong to one of a subject, predicate, or object; for example, "what are the papers written by the three researchers? "is a simple question.
The single-hop question may include two associated knowledge triples, and when determining the corresponding answer, the intermediate answer needs to be found first, and the triple query is constructed again according to the intermediate answer; for example, "which research subjects all papers written by the three researchers? "is a single-hop question.
The single restrictive question may be a question including a restrictive relationship, and when determining the answer corresponding to the single restrictive question, two triples containing the same predicate need to be queried, and an intersection is taken on the basis of the query result to obtain a final answer. For example, "what are all papers written by researchers of zhang san and li xi? "is a single-weight restriction question.
The multiple restricted question may be a question including a plurality of restricted relationships, and when determining the answer corresponding to the multiple restricted question, it is necessary to query a plurality of triples containing the same predicate, and obtain the final answer based on the query result by taking the intersection. For example, "what are the papers on the topic of competitive intelligence written by researchers zhang san and li si? "is a multiple restricted question.
Wherein, the simple question sentence can comprise 1 named entity and 1 entity relation; a single-hop question may include 1 named entity and 2 entity relationships; a single qualified question may include 2 named entities and 1 entity relationship; a multiple qualified question may include 2 named entities and 2 entity relationships.
Specifically, the terminal or the server for performing question and answer queries may classify the sentence patterns by using a target classifier integrated by at least two machine learning models to obtain the sentence pattern categories.
Machine learning is a multi-field cross discipline, and relates to a plurality of disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. The special research on how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. It is the core of artificial intelligence and is the fundamental way to make computer have intelligence.
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.
And S203, analyzing the question based on the quantity information, and generating a target query sentence corresponding to the question.
Specifically, the terminal or the server for performing question and answer query may set a query sentence generation template corresponding to each sentence pattern category in advance for each sentence pattern category.
The terminal or the server for performing question and answer query can identify and extract the named entities and the entity relations in the question sentences, then generate templates based on the query sentences corresponding to the named entities, the entity relations and the sentence pattern types, and convert the question sentences into target query sentences.
And S204, inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph.
The storage mode of the knowledge graph comprises a relational table, a graph database and distributed storage.
The embodiment of the application specifically describes the case of a knowledge graph stored based on a graph database, wherein the graph database is a database which organizes and stores data in a graph form and is used for semantic retrieval, and a graph structure comprises nodes, edges and attributes to represent and store data. The key concept is a graph, which directly relates the stored data items. This association allows data to be directly associated and in many cases can be extracted in a single operation.
Correspondingly, the target query statement may be a query language that interacts with the graph database. The target Query statement may be a Cypher (a descriptive graphical Query Language) statement or a SparQL (SparQL Protocol and RDF Query Language, Query Language and data acquisition Protocol) statement, which is not limited in this application.
The method comprises the steps of carrying out sentence pattern classification on a question to be queried through a target classifier to obtain a sentence pattern type, analyzing the question based on quantity information of named entities and entity relations represented by the sentence pattern type to further generate a target query sentence corresponding to the question, wherein the target query sentence is matched with a preset knowledge map, and the target query sentence can be queried from the knowledge map to obtain a reply sentence through the target query sentence; the method comprises the steps of constructing a question classification system according to question patterns, and effectively analyzing the question according to quantity information of named entities and entity relations; compared with the prior art that the question is analyzed based on the keyword matching mode, the question analyzing mode based on the named entity and the entity relation is not limited by the field of question and answer query, and can be applied to complex question comprising multiple groups of entity names and entity relations, so that the adaptivity of a question and answer query system is improved, and the question accuracy and the query efficiency are effectively improved.
A possible implementation manner is provided in the embodiment of the present application, and as shown in fig. 3, the target classifier includes a first classifier and a second classifier.
Wherein the target classifier can be constructed based on a strategy of ensemble learning.
Ensemble learning (ensemble learning) accomplishes a learning task by building and combining multiple learners. The general structure is: a set of "individual learners" is created and then combined with some strategy. The combination strategy mainly comprises an averaging method, a voting method, a learning method and the like. Ensemble learning often achieves more significant generalization performance than a single learner by combining multiple learners.
Current ensemble learning methods can be divided into three categories: bagging, Boosting, and Stacking. Taking Stacking ensemble learning as an example, the implementation method is to train one target classifier to fit the prediction results of all predictors (including the first classifier and the second classifier), so that the classification accuracy of the target classifier can be improved. The following will specifically describe a Stacking-based object classifier as an example.
The classifying question sentence pattern by the pre-trained target classifier in step S202 to obtain sentence pattern categories, which include:
(1) and classifying the sentence patterns of the question sentences according to the first classifier to obtain a sentence pattern classification result.
Specifically, the terminal or the server for performing question and answer query may perform classification prediction on the question based on the first classifier to obtain a sentence pattern classification result.
In an embodiment of the present application, a possible implementation manner is provided, where the first classifier includes at least two target classification units; classifying the sentence patterns of the question sentences according to the first classifier to obtain a sentence pattern classification result, wherein the sentence pattern classification result comprises the following steps:
and classifying the sentence patterns of the question sentences based on each target classification unit respectively to obtain at least two classification information, and taking the classification information as a sentence pattern classification result.
The first classifier may be a base classifier based on a Decision Tree algorithm, and may include three target classification units, such as a LightGBM (Gradient Boosting Decision Tree) model, an XGBoost (eXtreme Gradient Boosting) model, and a random forest model.
Specifically, the terminal or the server for performing question and answer query may perform classification prediction on the question sentences by using each target classification unit, to obtain classification information corresponding to each target classification unit, and use at least two classification information as sentence pattern classification results.
Wherein, the classification information may be a predicted probability of the question for each candidate sentence pattern category; the candidate sentence pattern categories may include simple question, single skip question, single repeat question, and multiple repeat question.
(2) And performing fusion processing on the sentence pattern classification result based on the second classifier to obtain the sentence pattern category.
In some embodiments, the second classifier may be a meta classifier based on a logistic regression algorithm;
in other embodiments, the second classifier may also be a meta classifier based on a CNN (Convolutional neural network) or an SVM (Support Vector Machine) algorithm, which is not specifically limited in the embodiments of the present application.
In this embodiment, taking three target classification units as an example, a terminal or a server for performing question and answer query may input a question into each of the three target classification units, that is, the LightGBM model, the XGBoost model, and the random forest model, each target classification unit may output a predicted probability of the question for each candidate sentence pattern category, then input all the sentence pattern classification results into a meta classifier based on a logistic regression algorithm, output a target probability of the question for each candidate sentence pattern category, and may select a candidate sentence pattern category corresponding to a maximum value of the target probability as a final sentence pattern category.
The classification steps of the object classifier are introduced above, and the training process of the object classifier will be described in detail below.
In an embodiment of the present application, a possible implementation manner is provided, where the first classifier includes three target classification units;
the target classifier is obtained by training based on the following modes:
dividing a preset first training set into three sub-training sets; each sub-training set corresponds to an initial classification unit; inputting the sub-training sets into corresponding initial classification units respectively, and training the initial classification units to obtain target classification units;
obtaining a second training set based on the prediction data generated by the initial classification unit in the training process; training the fusion classifier based on a second training set to obtain a target classifier; the fusion classifier comprises a target classification unit and a preset initial classifier.
The first classifier may include three different classification models, which are a LightGBM model, an XGBoost model, and a random forest model, and the three initial classification units correspond to the three classification models, respectively. The preset initial classifier corresponds to the first classifier and is used for fusing the output data of all the initial classification units.
Specifically, the terminal or the server for performing the question and answer query may perform cross validation on each initial classification unit by equally dividing the training data of the first training set, where the training process of each initial classification unit includes: selecting two sub-training sets as training data, and taking the other sub-training set as test data; training the initial classification unit by adopting training data, and predicting the trained initial classification unit by adopting test data to generate prediction data. After the above-mentioned round of training is completed, the sub-training sets may be rotated, for example, there are A, B, C sub-training sets, the previous round of training uses a as test data, B, C as training data, and this time uses B as test data, A, C as training data. Each initial classification unit may be trained in three rounds, and then the prediction data generated during the three rounds of training may be used as a second training set.
The embodiment of the application trains the first classifier by using a cross validation mode, predicts the first training set by using the first classifier, takes the obtained prediction data as a new second training set, and trains the fusion classifier based on the second training set to generate the target classifier. Meanwhile, a question classification system is constructed based on sentence pattern categories, and the problem that classification granularity and problem coverage rate are difficult to consider in the prior art is solved.
A possible implementation manner is provided in the embodiment of the present application, where the analyzing the question based on the quantity information in step S203 to generate a target query statement corresponding to the question includes:
(1) named entities in the question are identified.
The named entities are the names of people, organizations, places and other entities identified by names. Named entities in this application include long string named entities and short string named entities.
Specifically, as shown in fig. 4, the terminal or the server for performing question and answer query may obtain the named entity of the long character string in the question sentence based on the first identifier, and obtain the named entity of the short character string in the question sentence based on the second identifier.
Wherein the first recognizer may be a recognition model based on an AC automaton. The AC Automaton (Aho-corona automation) is one of the well-known multi-mode matching algorithms proposed in bell laboratories in 1975, which is widely used for matching of multiple strings. The identification steps of the first identifier are as follows:
constructing a dictionary tree based on the question, wherein the dictionary tree is used for representing a search data structure of the question; then setting a prefix pointer, wherein the prefix pointer is used for matching and jumping aiming at each character node in the dictionary tree; and traversing the dictionary tree according to the prefix pointer to obtain the long character string named entity. The AC automaton can quickly identify the long character string named entity; and need not artifical a large amount of training data of label and carry out the model training, can deploy fast, promote recognition efficiency.
In another aspect of the embodiment of the present application, the second recognizer may be a recognition model based on an artificial neural network. The second recognizer is a Bi-directional Long Short-Term Memory (Bi-directional Long Short-Term neural network) model for specific description. The named entity recognizer based on the BilSTM mainly comprises 5 layers such as a data preprocessing layer, a word vector conversion layer, a BilSTM layer, a CRF (Conditional Random Field) layer and a model output layer;
the data processing layer is used for preprocessing a question sentence such as text word segmentation and stop word removal; the word vector conversion layer is used for converting the input text into a vector sequence; the BilSTM layer includes two bi-directional LSTMs: one is forward LSTM and is used for learning forward characteristic information of the vector, the other is backward LSTM and is used for learning backward characteristic information of the vector, the forward characteristic information and the backward characteristic information are spliced to obtain a target characteristic vector, the target characteristic vector can be used as the input of each time step of the BiLSTM, and a complete hidden state output sequence is calculated; the CRF layer promotes the accuracy of the predicted label by learning a constraint condition; and the model output layer takes the labeling sequence corresponding to the question as the result of the named entity recognition.
According to the method and the device, the long character string named entities and the short character string named entities in the question are recognized respectively in a cooperative mode of the first recognizer and the second recognizer, the recognition requirements of the two kinds of named entities are considered, the named entities in the question are extracted accurately, the question parsing effect is guaranteed, and a good foundation is laid for the follow-up conversion of the target query sentence.
(2) And extracting the target relation name in the question sentence.
The target relationship name may represent association information between named entities in the question.
Specifically, the terminal or the server for performing the question-answering query may extract the target relationship name in the question sentence based on a BERT (Bidirectional Encoder representation based on Transformers) model.
The Transformer is a natural language processing model based on an encoder and a decoder, the BERT model is based on a Transformer encoding module, the concurrent extraction of the relation characteristics of the target words in the sentences can be realized, the relation characteristics can be extracted at a plurality of different levels, and further the sentence semantics can be reflected more comprehensively; meanwhile, BERT can acquire word senses according to the context of sentences, so that ambiguity is avoided. The process of target relationship name extraction based on the BERT model will be described in detail below.
The embodiment of the present application provides a possible implementation manner, and the extracting a target relationship name in a question includes:
a. at least two candidate relationship names are obtained.
Specifically, the terminal or the server for performing the question and answer query may obtain the candidate relationship name from the preset relationship database.
Wherein the candidate relationship name may be set based on a selection operation of the user.
b. And combining the question with each candidate relation name to generate fusion information.
In the present application example, with the question "which institution the author of paper xx works with? "for example, candidate relationship names may include authors, institutions, and periodicals. The corresponding fusion information may include: "[ CLS ] paper xx authors [ SEP ]" in which institution [ SEP ] they are working, "[ CLS ] paper xx authors in which institution [ SEP ]" they are working, and "[ CLS ] paper xx authors in which institution [ SEP ] periodical [ SEP ]" they are working. Wherein [ CLS ] and [ SEP ] are special encoding symbols of the BERT model, the [ CLS ] symbol can be a classification flag bit, and the [ SEP ] can be a segmentation symbol for distinguishing text vectors.
c. And performing semantic analysis on the fusion information to determine a target relation name.
In the present application example, with the question "which institution the author of paper xx works with? "for example, candidate relationship names may include authors, institutions, and periodicals. The corresponding fusion information may include: "[ CLS ] paper xx authors [ SEP ]" in which institution [ SEP ] they are working, "[ CLS ] paper xx authors in which institution [ SEP ]" they are working, and "[ CLS ] paper xx authors in which institution [ SEP ] periodical [ SEP ]" they are working. The terminal or the server for performing question and answer inquiry can input the fusion information into the BERT model for semantic analysis to obtain classification data of each fusion information, and determine a target relationship name according to the classification data. Specifically, the process of extracting the target relationship name based on the BERT model will be described in detail below.
A possible implementation manner is provided in the embodiment of the present application, as shown in fig. 5, in the embodiment of the present application, a BERT model includes a preprocessing layer, a BERT layer, and a classification layer as an example; the semantic analysis of the fusion information to determine the target relationship name includes:
and c1, determining semantic feature vectors of the fusion information.
Specifically, the terminal or the server for performing question and answer query may perform Vector conversion on the fusion information based on a Word2Vector (Vector conversion algorithm) algorithm of the preprocessing layer to generate a preprocessing Vector; and then inputting the preprocessed vector into a BERT layer to obtain vector representation fused with full-text semantic information, namely a semantic feature vector.
The pre-processing vector may include a word vector, a text vector, and a position vector of the fused information, among others.
c2, determining target fusion information from at least two fusion information based on the semantic feature vector.
Specifically, the terminal or the server for performing the question and answer query may classify the semantic feature vectors based on a softmax (normalized exponential function) function in the classification layer to obtain a classification probability of each piece of fusion information, and determine the target fusion information based on the classification probability.
c3, using the candidate relation name corresponding to the target fusion information as the target relation name.
In the present application example, with the question "which institution the author of paper xx works with? "for example, candidate relationship names may include authors, institutions, and periodicals. The corresponding fusion information may include fusion information X: "[ CLS ] thesis xx is responsible for which institution [ SEP ] author [ SEP ]", fusion information Y: "[ CLS ] paper xx is the author of the work on which institution [ SEP ]" and fusion information Z: "[ CLS ] paper xx is the author of which institution [ SEP ] journal [ SEP ]" to work with. The terminal or server for performing question and answer query may input the fusion information into the BERT model for semantic analysis, and perform two classifications to obtain classification data of each fusion information, for example, if the classification probability of the fusion information X and the fusion information Y is 1, and the classification probability of the fusion information Z is 0, then the "author" and the "organization" are used as the target relationship name.
In the process of extracting the target relationship name, the question and the candidate relationship name are spliced and input to the BERT model for semantic analysis and classification processing, so that the relationship information included in the question is determined, and the semantic information is accurately grasped; and reliable guarantee is provided for the accuracy of the subsequent question switching.
(3) And converting the question sentence into a target query sentence based on the named entity, the target relation name and the quantity information.
Specifically, the terminal or the server for performing question and answer query may generate the query sentence generation rule corresponding to the sentence pattern category based on the combination information and the position information of the named entity and the relationship name in each sentence pattern category in advance; and then generating a target query sentence according to the query sentence generation rule corresponding to the sentence pattern type based on the sentence pattern type, the named entity and the target relation name.
Taking the target query statement as Cypher as an example, the conversion step of the target query statement is illustrated for each sentence pattern category:
when the question is "what are the papers written by three researchers? "the sentence pattern category corresponding to the sentence pattern is a simple question, and the named entity obtained by the question analysis is: class researcher-zhang iii; the target relationship name is: the authors of the paper; the corresponding query statement generation rule is as follows: the device comprises a Class document < thesis author > Class researchers, a first search module, a second search module and a third search module, wherein the Class document < thesis author > Class researchers are used for representing and determining position information of a named entity and a target relation name and searching answer sentences of the type of the Class document; the Cypher target query statement generated finally is as follows:
match (n: Paper) - [: Paper author' ] - > (p: People); matching paper author p and document n
Name ═ zhang-san; the authors of the paper are "Zhang III"
return n; return document n
When the question is "which research subjects all papers written by three researchers? "the sentence pattern category corresponding to the sentence pattern is a single-hop question, and the named entity obtained by the question analysis is: class researcher-zhang iii; the target relationship name is: paper author, keywords; the corresponding query statement generation rule is as follows: a Class researcher < thesis author > [ Class literature ] < keyword > Class research topic, which characterizes and determines the position information of the named entity and two target relation names and searches answer sentences with the type of 'Class research topic'; the Cypher target query statement generated finally is as follows:
match (n: peoples) < - [: article author '] - (p: Paper) - [: keyword' ] - > (q: key); matching paper author and keyword information
Name ═ zhang three; the authors of the paper are "Zhang III"
return q; returning a keyword q
When the question is "what are all papers written by three and four researchers? "the sentence pattern category corresponding to the sentence pattern is a single restriction question, and the named entity obtained by the question analysis is: class researchers-zhang san, Class researchers-liyi; the target relationship name is: the authors of the paper; the corresponding query statement generation rule is as follows: a Class researcher < paper author > [ Class document ] < paper author > Class researcher, which characterizes and determines the position information of two similar named entities and the target relation name, and searches a reply sentence with the type of 'Class document'; the Cypher target query statement generated finally is as follows:
match (n: Paper) - [: Paper author' ] - > (p: People); matching paper author p and document n
where p.name ═ zhang three AND p.name ═ lie four; the authors of the paper are "Zhang III" and "Li IV"
return n; return document n
What are the questions of "the papers on the topic of competitive intelligence written by three and four researchers? "the sentence pattern category corresponding to the question is multiple limited question sentences, and the named entity obtained by analyzing the question sentences is: class researchers-Zhang III, Class researchers-Lisi IV, Class research subject-competition information; the target relationship name is: paper author, keywords; the corresponding query statement generation rule is as follows: class researchers < paper author > [ Class literature ] < keyword > Class research topic, the representation of which determines the position information of two types of named entities and two target relation names and searches answer sentences of which the types are 'Class literature'; the Cypher target query statement generated finally is as follows:
match (n: peoples) < - [: article author '] - (p: Paper) - [: keyword' ] - > (q: key); matching paper author and keyword information
where p.name ═ zhangsan ═ lie ″, AND q.name ═ competition intelligence "; the authors of the paper are Zhang III and Li IV, and the keywords are Competition information "
return p; return document p
The embodiment of the application realizes question analysis and query statement conversion based on sentence pattern categories by extracting knowledge triple information such as named entities, target relation names and the like in the question; according to the method and the device, not only can simple questions be well analyzed, but also the complex questions can be accurately analyzed, so that the question-answering query system has good adaptivity, and the query efficiency and accuracy of the knowledge graph are improved.
In order to better understand the above question-answer query method, an example of the question-answer query method of the present application is described in detail below with reference to fig. 6, where the question-answer query method is applied in a terminal or a server, and the method includes the following steps:
s601, obtaining a question to be inquired.
The question may be a natural language question.
Specifically, the terminal or the server for performing question and answer query may directly obtain the question from a preset memory address, or may obtain the question in a real-time acquisition manner.
In some embodiments, a terminal or a server for performing question and answer query may generate a question sentence based on an input operation of a user for an input device such as a mouse, a keyboard, or a touch screen;
in other embodiments, the terminal or the server for performing question and answer query may collect voice information of the user in real time based on a voice device such as a microphone, and perform voice recognition on the voice information to generate a question.
S602, sentence pattern classification is carried out on the question sentences according to the first classifier, and sentence pattern classification results are obtained.
The first classifier may be a base classifier based on a decision tree algorithm, and may include three target classification units, such as a LightGBM model, an XGBoost model, and a random forest model.
Specifically, the terminal or the server for performing question and answer query may perform classification prediction on the question sentence by using each target classification unit, to obtain classification information corresponding to each target classification unit, and use at least two classification information as sentence pattern classification results.
Wherein, the classification information may be a predicted probability of the question for each candidate sentence pattern category; candidate sentence type categories may include simple question, single skip question, single delimited question, and multiple delimited question.
S603, fusing the sentence pattern classification result based on the second classifier to obtain a sentence pattern category; the sentence pattern category represents the quantity information of named entities and entity relations in the question sentence.
Wherein the second classifier may be a meta classifier based on a logistic regression algorithm. The first classifier and the second classifier construct a fusion classifier based on an ensemble learning mode.
In this embodiment, a terminal or a server for performing question and answer query may input a question into three target classification units, namely, a LightGBM model, an XGBoost model, and a random forest model, respectively, each target classification unit outputs a prediction probability of the question for each candidate sentence pattern category, then inputs all sentence pattern classification results into a meta classifier based on a logistic regression algorithm, outputs a target probability of the question for each candidate sentence pattern category, and may select a candidate sentence pattern category corresponding to a maximum value of the target probability as a final sentence pattern category.
S604, identifying the named entity in the question sentence.
The named entities are the names of people, organizations, places and other entities identified by names. Named entities in this application include long string named entities and short string named entities.
Specifically, the terminal or the server for performing question and answer query may obtain the named entity of the long character string in the question based on the first identifier, and obtain the named entity of the short character string in the question based on the second identifier.
S605, obtaining at least two candidate relation names; and combining the question with each candidate relation name to generate fusion information.
Specifically, the terminal or the server for performing the question and answer query may obtain the candidate relationship name from the preset relationship database.
Wherein the candidate relationship name may be set based on a selection operation by the user.
In the present application example, with the question "which institution the author of paper xx works with? "for example, candidate relationship names may include authors, institutions, and periodicals. The corresponding fusion information may include: "[ CLS ] paper xx authors [ SEP ]" in which institution [ SEP ] they are working, "[ CLS ] paper xx authors in which institution [ SEP ]" they are working, and "[ CLS ] paper xx authors in which institution [ SEP ] periodical [ SEP ]" they are working. Wherein [ CLS ] and [ SEP ] are special encoding symbols of the BERT model, the [ CLS ] symbol can be a classification flag bit, and the [ SEP ] can be a segmentation symbol for distinguishing text vectors.
S606, determining semantic feature vectors of the fusion information; target fusion information is determined from the at least two fusion information based on the semantic feature vector.
Specifically, the terminal or the server for performing question and answer query may perform Vector conversion on the fusion information based on the Word2Vector algorithm of the preprocessing layer to generate a preprocessing Vector; and then inputting the preprocessed vector into a BERT layer to obtain vector representation fused with full-text semantic information, namely a semantic feature vector.
The pre-processing vector may include a word vector, a text vector, and a position vector of the fused information, among others.
Meanwhile, the terminal or the server for performing the question and answer query can classify the semantic feature vectors based on the softmax function in the classification layer to obtain the classification probability of each piece of fusion information, and determine the target fusion information based on the classification probability.
S607, the candidate relationship name corresponding to the target fusion information is set as the target relationship name.
In the present application example, with the question "which institution the author of paper xx works with? "for example, candidate relationship names may include authors, institutions, and periodicals. The corresponding fusion information may include fusion information X: "[ CLS ] thesis xx is responsible for which institution [ SEP ] author [ SEP ]", fusion information Y: the author of "[ CLS ] paper xx is responsible for which institution [ SEP ]" and fusion information Z: "[ CLS ] paper xx is the author of which institution [ SEP ] journal [ SEP ]" to work with. The terminal or server for performing question and answer query may input the fusion information into the BERT model for semantic analysis, and perform two classifications to obtain classification data of each fusion information, for example, if the classification probability of the fusion information X and the fusion information Y is 1, and the classification probability of the fusion information Z is 0, then the "author" and the "organization" are used as the target relationship name.
S608, converting the question sentence into a target query sentence based on the named entity, the target relation name and the quantity information.
Specifically, the terminal or the server for performing question and answer query may generate the query sentence generation rule corresponding to the sentence pattern category based on the combination information and the position information of the named entity and the relationship name in each sentence pattern category in advance; and then generating a target query sentence through a query sentence generating rule corresponding to the sentence pattern type based on the sentence pattern type, the named entity and the target relation name.
And S609, inquiring the answer sentence corresponding to the target inquiry sentence based on the preset knowledge graph.
The storage mode of the knowledge graph comprises a relational table, a graph database and distributed storage. Taking the knowledge graph stored based on the graph database as an example, correspondingly, the target query statement may be a query language interacting with the graph database.
The method comprises the steps of classifying question sentences to be inquired through a target classifier in a sentence pattern mode to obtain sentence pattern types, analyzing the question sentences based on the quantity information of named entities and entity relations represented by the sentence pattern types to further generate target inquiry sentences corresponding to the question sentences, wherein the target inquiry sentences are matched with a preset knowledge graph spectrum, and the target inquiry sentences can be inquired from a knowledge graph through the target inquiry sentences to obtain answer sentences; the method comprises the steps of constructing a question classification system according to question patterns, and effectively analyzing the question according to quantity information of named entities and entity relations; compared with the prior art that the question is analyzed based on the keyword matching mode, the question analyzing mode based on the named entity and the entity relation is not limited by the field of question and answer query, and can be applied to complex question comprising multiple groups of entity names and entity relations, so that the adaptivity of a question and answer query system is improved, and the question accuracy and the query efficiency are effectively improved.
An embodiment of the present application provides a question-answer querying device, as shown in fig. 7, where the question-answer querying device 70 may include: a first obtaining module 701, a classifying module 702, an analyzing module 703 and a second obtaining module 704;
the first obtaining module 701 is configured to obtain a question to be queried;
a classification module 702, configured to perform sentence pattern classification on the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of named entities and entity relations in the question sentence;
the parsing module 703 is configured to parse the question based on the quantity information to generate a target query statement corresponding to the question;
and a second obtaining module 704, configured to query, based on a preset knowledge graph, an answer sentence corresponding to the target query sentence.
The embodiment of the present application provides a possible implementation manner, where the target classifier includes a first classifier and a second classifier;
the classification module 702 is configured to:
classifying the sentence patterns of the question sentences according to a first classifier to obtain a sentence pattern classification result;
and performing fusion processing on the sentence pattern classification result based on the second classifier to obtain the sentence pattern category.
In an embodiment of the present application, a possible implementation manner is provided, where the first classifier includes at least two target classification units;
the aforementioned classification module 702 is further configured to:
and classifying the sentence patterns of the question sentences based on each target classification unit respectively to obtain at least two classification information, and taking the classification information as a sentence pattern classification result.
In an embodiment of the present application, a possible implementation manner is provided, where the first classifier includes three target classification units;
the apparatus further comprises a training module configured to:
equally dividing a preset first training set into three sub-training sets; each sub-training set corresponds to an initial classification unit;
inputting the sub-training sets into corresponding initial classification units respectively, and training the initial classification units to obtain target classification units;
obtaining a second training set based on the prediction data generated by the initial classification unit in the training process;
training the fusion classifier based on a second training set to obtain a target classifier; the fusion classifier comprises a target classification unit and a preset initial classifier.
In the embodiment of the present application, a possible implementation manner is provided, and the parsing module 703 is configured to:
identifying a named entity in the question;
extracting a target relation name in the question;
and converting the question sentence into a target query sentence based on the named entity, the target relation name and the quantity information.
A possible implementation manner is provided in the embodiment of the present application, and the parsing module 703 is further configured to:
acquiring at least two candidate relationship names;
combining the question with each candidate relation name to generate fusion information;
and performing semantic analysis on the fusion information to determine a target relation name.
A possible implementation manner is provided in the embodiment of the present application, and the parsing module 703 is further configured to:
determining semantic feature vectors of the fusion information;
determining target fusion information from the at least two fusion information based on the semantic feature vector;
and taking the candidate relation name corresponding to the target fusion information as a target relation name.
The apparatus in the embodiment of the present application may execute the method provided in the embodiment of the present application, and the implementation principle is similar, the actions executed by the modules in the apparatus in the embodiments of the present application correspond to the steps in the method in the embodiments of the present application, and for the detailed functional description of the modules in the apparatus, reference may be made to the description in the corresponding method shown in the foregoing, and details are not repeated here.
The method comprises the steps of carrying out sentence pattern classification on a question to be queried through a target classifier to obtain a sentence pattern type, analyzing the question based on quantity information of named entities and entity relations represented by the sentence pattern type to further generate a target query sentence corresponding to the question, wherein the target query sentence is matched with a preset knowledge map, and the target query sentence can be queried from the knowledge map to obtain a reply sentence through the target query sentence; the method comprises the steps of constructing a question classification system according to question patterns, and effectively analyzing the question according to quantity information of named entities and entity relations; compared with the prior art that the question is analyzed based on the keyword matching mode, the question analyzing mode based on the named entity and the entity relation is not limited by the field of question and answer query, and can be applied to complex question comprising multiple groups of entity names and entity relations, so that the adaptivity of a question and answer query system is improved, and the question accuracy and the query efficiency are effectively improved.
The embodiment of the application provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to realize the steps of the question-answering query method, and compared with the related technology, the method can realize the following steps: the method comprises the steps of carrying out sentence pattern classification on a question to be queried through a target classifier to obtain a sentence pattern type, analyzing the question based on quantity information of named entities and entity relations represented by the sentence pattern type to further generate a target query sentence corresponding to the question, wherein the target query sentence is matched with a preset knowledge map, and the target query sentence can be queried from the knowledge map to obtain a reply sentence through the target query sentence; the method comprises the steps of constructing a question classification system according to question patterns, and effectively analyzing the question according to quantity information of named entities and entity relations; compared with the prior art that question sentences are analyzed based on keyword matching, the question sentence analyzing method based on named entities and entity relations in the embodiment of the application is not limited by the field of question-answer query, can be suitable for complex question sentences comprising multiple groups of entity names and entity relations, improves the adaptivity of a question-answer query system, and effectively improves the accuracy rate and query efficiency of the question-answer.
In an alternative embodiment, an electronic device is provided, as shown in fig. 8, the electronic device 800 shown in fig. 8 comprising: a processor 801 and a memory 803. Wherein the processor 801 is coupled to a memory 803, such as via a bus 802. Optionally, the electronic device 800 may further include a transceiver 804, and the transceiver 804 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data. It should be noted that the transceiver 804 is not limited to one in practical applications, and the structure of the electronic device 800 is not limited to the embodiment of the present application.
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 device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 801 may also be a combination of computing functions, e.g., comprising one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 802 may include a path that transfers information between the above components. The bus 802 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 802 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
The Memory 803 may be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer, without limitation.
The memory 803 is used for storing computer programs for executing the embodiments of the present application, and is controlled by the processor 801 to execute the computer programs. The processor 801 is adapted to execute computer programs stored in the memory 803 to implement the steps shown in the foregoing method embodiments.
Among them, 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.
Embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program may implement the steps and corresponding contents of the foregoing method embodiments.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device realizes the following when executed:
acquiring a question to be inquired;
classifying the sentence patterns of the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of named entities and entity relations in the question sentence;
analyzing the question based on the quantity information to generate a target query sentence corresponding to the question;
and inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims of the present application and in the above-described drawings (if any) are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in other sequences than illustrated or otherwise described herein.
It should be understood that, although each operation step is indicated by an arrow in the flowchart of the embodiment of the present application, the implementation order of the steps is not limited to the order indicated by the arrow. In some implementation scenarios of the embodiments of the present application, the implementation steps in the flowcharts may be performed in other sequences as desired, unless explicitly stated otherwise herein. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on an actual implementation scenario. Some or all of these sub-steps or stages may be performed at the same time, or each of these sub-steps or stages may be performed at different times. In a scenario where execution times are different, an execution sequence of the sub-steps or the phases may be flexibly configured according to requirements, which is not limited in the embodiment of the present application.
The foregoing is only an optional implementation manner of a part of implementation scenarios in this application, and it should be noted that, for those skilled in the art, other similar implementation means based on the technical idea of this application are also within the protection scope of the embodiments of this application without departing from the technical idea of this application.

Claims (10)

1. A question-answer query method is characterized by comprising the following steps:
acquiring a question to be inquired;
classifying the sentence patterns of the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; the sentence pattern type represents quantity information of named entities and entity relations in the question sentence;
analyzing the question based on the quantity information to generate a target query sentence corresponding to the question;
and inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph.
2. The method of claim 1, wherein the target classifier comprises a first classifier and a second classifier;
the pre-training-based target classifier performs sentence pattern classification on the question sentence to obtain a sentence pattern category, which includes:
classifying the sentence patterns of the question sentences according to the first classifier to obtain a sentence pattern classification result;
and carrying out fusion processing on the sentence pattern classification result based on the second classifier to obtain the sentence pattern classification.
3. The method of claim 2, wherein the first classifier comprises at least two target classification units;
and classifying the sentence patterns of the question sentences according to the first classifier to obtain a sentence pattern classification result, wherein the sentence pattern classification result comprises the following steps:
and classifying the sentence patterns of the question sentences based on each target classification unit respectively to obtain at least two classification information, and taking the classification information as the sentence pattern classification result.
4. The method of claim 3, wherein the first classifier comprises three target classification units;
the target classifier is obtained by training based on the following mode:
dividing a preset first training set into three sub-training sets; each sub-training set corresponds to an initial classification unit;
respectively inputting the sub-training sets into corresponding initial classification units, and training the initial classification units to obtain target classification units;
obtaining a second training set based on the prediction data generated by the initial classification unit in the training process;
training a fusion classifier based on the second training set to obtain the target classifier; the fusion classifier comprises the target classification unit and a preset initial classifier.
5. The method according to claim 1, wherein the parsing the question based on the quantity information to generate a target query sentence corresponding to the question comprises:
identifying a named entity in the question;
extracting a target relation name in the question sentence;
and converting the question sentence into a target query sentence based on the named entity, the target relationship name and the quantity information.
6. The method of claim 5, wherein the extracting the target relationship name from the question sentence comprises:
acquiring at least two candidate relationship names;
combining the question with each candidate relation name to generate fusion information;
and performing semantic analysis on the fusion information to determine the target relationship name.
7. The method according to claim 6, wherein the semantically analyzing the fusion information to determine the target relationship name comprises:
determining a semantic feature vector of the fusion information;
determining target fusion information from at least two fusion information based on the semantic feature vector;
and taking the candidate relation name corresponding to the target fusion information as the target relation name.
8. A question-answering query device, comprising:
the first acquisition module is used for acquiring a question to be inquired;
the classification module is used for carrying out sentence pattern classification on the question sentences based on a pre-trained target classifier to obtain sentence pattern categories; wherein, the sentence pattern type represents the quantity information of the named entity and the entity relation in the question sentence;
the analysis module is used for analyzing the question based on the quantity information to generate a target query sentence corresponding to the question;
and the second acquisition module is used for inquiring the answer sentence corresponding to the target inquiry sentence based on a preset knowledge graph.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202210365261.8A 2022-04-07 2022-04-07 Question-answer query method and device, electronic equipment and computer readable storage medium Pending CN114942981A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210365261.8A CN114942981A (en) 2022-04-07 2022-04-07 Question-answer query method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210365261.8A CN114942981A (en) 2022-04-07 2022-04-07 Question-answer query method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN114942981A true CN114942981A (en) 2022-08-26

Family

ID=82907410

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210365261.8A Pending CN114942981A (en) 2022-04-07 2022-04-07 Question-answer query method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN114942981A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116450867A (en) * 2023-06-15 2023-07-18 北京枫清科技有限公司 Graph data semantic search method based on contrast learning and large language model

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116450867A (en) * 2023-06-15 2023-07-18 北京枫清科技有限公司 Graph data semantic search method based on contrast learning and large language model
CN116450867B (en) * 2023-06-15 2023-08-18 北京枫清科技有限公司 Graph data semantic search method based on contrast learning and large language model

Similar Documents

Publication Publication Date Title
CN111026842B (en) Natural language processing method, natural language processing device and intelligent question-answering system
KR102288249B1 (en) Information processing method, terminal, and computer storage medium
KR102054514B1 (en) The System and the method of offering the Optimized answers to legal experts utilizing a Deep learning training module and a Prioritization framework module based on Artificial intelligence and providing an Online legal dictionary utilizing a character Strings Dictionary Module that converts legal information into significant vector
CN110727779A (en) Question-answering method and system based on multi-model fusion
CN111475623A (en) Case information semantic retrieval method and device based on knowledge graph
CN111753060A (en) Information retrieval method, device, equipment and computer readable storage medium
CN112507715A (en) Method, device, equipment and storage medium for determining incidence relation between entities
Santosh et al. Opinion mining of online product reviews from traditional LDA Topic Clusters using Feature Ontology Tree and Sentiwordnet
CN112328800A (en) System and method for automatically generating programming specification question answers
CN115204156A (en) Keyword extraction method and device
Najeeb A novel hadith processing approach based on genetic algorithms
Aghaei et al. Question answering over knowledge graphs: A case study in tourism
CN114117000A (en) Response method, device, equipment and storage medium
CN114942981A (en) Question-answer query method and device, electronic equipment and computer readable storage medium
CN113821588A (en) Text processing method and device, electronic equipment and storage medium
Suneera et al. A bert-based question representation for improved question retrieval in community question answering systems
Llopis et al. Matching user queries in natural language with Cyber-Physical Systems using deep learning through a Transformer approach
CN115129885A (en) Entity chain pointing method, device, equipment and storage medium
Bulfamante Generative enterprise search with extensible knowledge base using AI
Kaur et al. Conversational natural language processing for automated customer support services
Tian et al. Semantic similarity measure of natural language text through machine learning and a keyword‐aware cross‐encoder‐ranking summarizer—A case study using UCGIS GIS &T body of knowledge
Dubey Towards Complex Question Answering over Knowledge Graphs.
Zafartavanaelmi Semantic Question Answering Over Knowledge Graphs: Pitfalls and Pearls
US11934794B1 (en) Systems and methods for algorithmically orchestrating conversational dialogue transitions within an automated conversational system
CN117235237B (en) Text generation method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination