Question and Answer Method and Device

By determining the main entity in the question-and-answer system and constructing a semantic query diagram, the problem of inefficiency in the existing technology is solved, and efficient and accurate natural language question-and-answer is achieved.

CN114138929BActive Publication Date: 2025-07-18HISENSE VISUAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111146241.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2025-07-18
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

Existing Q&A systems rely on manually pre-setting of large number of Q&A templates, resulting in inefficiency and high workload.

Method used

By determining the main entity of the natural query statement, a semantic query diagram is constructed, indicating the relationship or attributes associated with the main entity, the semantic understanding of the natural query statement is realized and the natural answer statement is output.

Benefits of technology

There is no need to set up a question-and-answer template in advance, which improves the efficiency of the question-and-answer system, reduces workload, and has a more accurate semantic understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138929B_ABST
    Figure CN114138929B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a question-and-answer method and apparatus. The method includes: determining a main entity of a natural query statement; constructing a semantic query graph of the natural query statement according to the main entity, where the semantic query graph is used to indicate relationships or attributes associated with the main entity; and outputting a natural answer statement corresponding to the natural query statement according to the semantic query graph. The solution of the embodiment of the present application does not require pre-setting of question-and-answer templates. Instead, it first identifies the main entity, then constructs a semantic query graph based on the main entity to realize the understanding of the natural query statement, and further outputs a natural answer statement, with higher efficiency, less workload, and more accurate semantic understanding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of information interaction technologies, and particularly to a question-answering method and apparatus. Background Art

[0002] A question-answering system can receive questions expressed by a user in natural language, understand the user's intention, obtain relevant knowledge, and thus form and output an answer expressed in natural language.

[0003] Currently, the question-answering system is mainly implemented based on a template matching method. The method based on template matching mainly matches questions through prefabricated templates for semantic understanding. After obtaining the natural language question of the user, it is necessary to determine the template matching the natural language question in the prefabricated templates, so as to understand the semantics of the user, and based on the understood semantics of the user, determine the corresponding question-answering result for output.

[0004] The above solution requires a large amount of manual pre-setting of question-answering templates, with a large workload and low efficiency. Summary of the Invention

[0005] The embodiments of the present application provide a question-answering method and apparatus to improve the efficiency of the question-answering system.

[0006] In a first aspect, the embodiments of the present application provide a question-answering method, including:

[0007] Determine the main entity of the natural query statement;

[0008] Construct a semantic query graph of the natural query statement according to the main entity, where the semantic query graph is used to indicate the relationships or attributes associated with the main entity;

[0009] Output a natural answer statement corresponding to the natural query statement according to the semantic query graph.

[0010] In a possible implementation manner, the determining the main entity of the natural query statement includes:

[0011] Obtain the entity linking result of the natural query statement, where the entity linking result includes multiple entities associated with the natural query statement;

[0012] Identify the natural query statement to obtain an identification result, where the identification result is used to indicate whether there is a triple in the natural query statement;

[0013] Determine the main entity according to the entity linking result and the identification result.

[0014] In a possible implementation, the recognition result indicates that there is a triple in the natural query statement; determining the main entity according to the entity linking result and the recognition result includes:

[0015] Determine the entity corresponding to the tail element in the triple in the entity linking result as the main entity.

[0016] In a possible implementation, the recognition result indicates that there is no triple in the natural query statement; determining the main entity according to the entity linking result and the recognition result includes:

[0017] Obtain the popularity scores of the entities in the entity linking result;

[0018] Determine the main entity in the entity connection result according to the popularity scores of the entities.

[0019] In a possible implementation, constructing the semantic query graph of the natural query statement according to the main entity includes:

[0020] Obtain the relationships or attributes of the multiple entities associated with the natural query statement;

[0021] Determine the target relationship or target attribute among the relationships or attributes of the multiple entities according to the main entity;

[0022] Construct the semantic query graph according to the main entity and the target relationship or the target attribute.

[0023] In a possible implementation, constructing the semantic query graph according to the main entity and the target relationship or the target attribute includes:

[0024] Obtain at least one reference corresponding to the target relationship or the target attribute, and the score corresponding to each reference;

[0025] Construct the semantic query graph according to each reference and the corresponding score.

[0026] In a possible implementation, outputting the natural answer statement corresponding to the natural query statement according to the semantic query graph includes:

[0027] Obtain multiple candidate answers in the natural query statement according to the semantic query graph;

[0028] Determine the output answer of the natural query statement among the multiple candidate answers;

[0029] Output the natural answer statement according to the output answer.

[0030] In a possible implementation, obtaining multiple candidate answers in the natural query statement according to the semantic query graph includes:

[0031] Performing a matching process on the semantic query graph and a knowledge graph to obtain candidate answers corresponding to each reference, where any one reference indicates the relationship or attribute between the main entity and the corresponding candidate answer.

[0032] In a possible implementation, determining the output answer of the natural query statement among the multiple candidate answers includes:

[0033] Inputting the candidate answers into a preset model to obtain a confidence score output by the preset model;

[0034] Determining the output answer among the multiple candidate answers according to the confidence scores of the candidate answers;

[0035] Wherein, the preset model is trained by multiple groups of training samples, and each group of training samples includes a sample answer and a sample confidence score of the sample answer.

[0036] In a second aspect, an embodiment of the present application provides a question-answering device, including:

[0037] A determination module, configured to determine the main entity of a natural query statement;

[0038] A processing module, configured to construct a semantic query graph of the natural query statement according to the main entity, where the semantic query graph is used to indicate the relationship or attribute associated with the main entity;

[0039] An output module, configured to output a natural answer statement corresponding to the natural query statement according to the semantic query graph.

[0040] In a possible implementation, the determination module is specifically configured to:

[0041] Obtain an entity linking result of the natural query statement, where the entity linking result includes multiple entities associated with the natural query statement;

[0042] Identify the natural query statement to obtain an identification result, where the identification result is used to indicate whether there is a triple in the natural query statement;

[0043] Determine the main entity according to the entity linking result and the identification result.

[0044] In a possible implementation, the identification result indicates that there is a triple in the natural query statement; the determination module is specifically configured to:

[0045] Determine the entity corresponding to the tail element in the triple in the entity linking result as the main entity.

[0046] In a possible implementation manner, the recognition result indicates that there is no triple in the natural query statement; specifically, the determination module is configured to:

[0047] Obtain the popularity scores of the entities in the entity linking result;

[0048] Determine the main entity in the entity connection result according to the popularity scores of the entities.

[0049] In a possible implementation manner, the processing module is specifically configured to:

[0050] Obtain the relationships or attributes of the multiple entities associated with the natural query statement;

[0051] Determine the target relationship or target attribute according to the main entity in the relationships or attributes of the multiple entities;

[0052] Construct the semantic query graph according to the main entity and the target relationship or the target attribute.

[0053] In a possible implementation manner, the processing module is specifically configured to:

[0054] Obtain at least one reference corresponding to the target relationship or the target attribute, and the score corresponding to each reference;

[0055] Construct the semantic query graph according to each reference and the corresponding score.

[0056] In a possible implementation manner, the output module is specifically configured to:

[0057] Obtain multiple candidate answers in the natural query statement according to the semantic query graph;

[0058] Determine the output answer of the natural query statement among the multiple candidate answers;

[0059] Output the natural answer statement according to the output answer.

[0060] In a possible implementation manner, the output module is specifically configured to:

[0061] Perform matching processing on the semantic query graph and the knowledge graph to obtain candidate answers corresponding to each reference, where any one reference indicates the relationship or attribute between the main entity and the corresponding candidate answer.

[0062] In a possible implementation, the output module is specifically configured to:

[0063] Input the candidate answer into a preset model to obtain a confidence score output by the preset model;

[0064] Determine the output answer from the multiple candidate answers according to the confidence scores of the candidate answers;

[0065] Wherein, the preset model is trained by multiple groups of training samples, and each group of training samples includes a sample answer and a sample confidence score of the sample answer.

[0066] In a third aspect, an embodiment of the present application provides a question-and-answer device, including: at least one processor and a memory;

[0067] The memory stores computer-executable instructions;

[0068] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the question-and-answer method according to any one of the first aspects.

[0069] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the question-and-answer method according to any one of the first aspects is implemented.

[0070] In a fifth aspect, an embodiment of the present application provides a computer program product, the computer program product includes a computer program; when the computer program is executed, the question-and-answer method according to any one of the first aspects is implemented.

[0071] The question-and-answer method and device provided by the embodiments of the present application, after obtaining a natural query statement, first determine the main entity of the natural query statement, perform a preliminary identification of the natural query statement, and then construct a semantic query graph of the natural query statement according to the main entity. The semantic query graph indicates the relationships or attributes associated with the main entity, thereby realizing the semantic understanding of the natural query statement. Finally, according to the semantic query graph, determine the question-and-answer result and output the natural answer statement corresponding to the natural query statement. The solution of the embodiment of the present application does not require a pre-set question-and-answer template. Instead, it first identifies the main entity, then constructs a semantic query graph based on the main entity to realize the understanding of the natural query statement, and then outputs the natural answer statement, with high efficiency, small workload, and more accurate semantic understanding. Description of the Drawings

[0072] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.

[0073] Figure 1 Schematic diagram of the application scenario provided by the embodiment of the present application;

[0074] Figure 2 Schematic flowchart of the question-and-answer method provided by the embodiment of the present application;

[0075] Figure 3 Schematic diagram of the question-and-answer method provided by the embodiment of the present application;

[0076] Figure 4 Schematic diagram of natural query statement recognition provided by the embodiment of the present application;

[0077] Figure 5 Schematic diagram of determining the main entity provided by the embodiment of the present application;

[0078] Figure 6 Schematic flowchart of constructing a semantic query graph provided by the embodiment of the present application;

[0079] Figure 7 Schematic diagram of constructing a semantic query graph provided by the embodiment of the present application;

[0080] Figure 8 Schematic diagram of the structure of the question-and-answer device provided by the embodiment of the present application;

[0081] Figure 9 Schematic diagram of the hardware structure of the question-and-answer device provided by the embodiment of the present application. Detailed implementation manners

[0082] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.

[0083] First, the application scenario of the present application will be introduced.

[0084] Figure 1 Schematic diagram of the application scenario provided by the embodiment of the present application, as Figure 1As shown in the figure, it includes user 11 and smart speaker 12. User 11 can input a natural query statement to smart speaker 12, and the input method can be in the form of voice or text.

[0085] The knowledge Q&A system receives questions expressed in natural language, understands the user's intention, obtains relevant knowledge, and finally forms an answer expressed in natural language and feedbacks it to the user. A knowledge Q&A system should have four basic elements: questions, answers, agents, and knowledge bases.

[0086] Smart speaker 12 can perform semantic parsing on the natural query statement input by the user based on the knowledge Q&A system, obtain the intention of user 11, and obtain the corresponding answer according to the intention of user 11, and finally form a natural answer statement for output.

[0087] For example, in Figure 1 , user 11 inputs a natural query statement "Where was drama A of Jia filmed?", after obtaining this natural query statement, smart speaker 12 can understand this statement and finally output the answer "Drama A of Jia was filmed in Xiangshan Film and Television City".

[0088] Figure 1 Taking the smart speaker as the carrier of the knowledge Q&A system as an example for illustration, it can be understood that the carrier of the knowledge Q&A system can also be terminal devices such as smart TVs and smart phones.

[0089] The above Q&A form needs to be implemented based on the knowledge Q&A system. Currently, the knowledge Q&A system is mainly implemented based on the template matching method. Specifically, template matching questions and corresponding semantic understandings are preset in advance to form a prefabricated template. After obtaining the user's natural query statement, the natural query statement is matched in the prefabricated template to understand the user's intention, and the corresponding Q&A result is determined based on the user's intention.

[0090] The above method requires a large number of Q&A templates to be preset manually, with low efficiency and large workload. Based on this, the embodiments of the present application provide a Q&A method that can better understand the user's intention without manually setting Q&A templates, and then effectively output the user's natural query statement.

[0091] Figure 2 is a schematic flowchart of the Q&A method provided by the embodiments of the present application. As Figure 2 shown, the method may include:

[0092] S21, determining the main entity of the natural query statement.

[0093] The execution subject in the embodiments of the present application can be a terminal device, such as a smart TV, smart speaker, smart phone, computer, etc., or a server, or any other possible entity device.

[0094] The natural query statement is the question-and-answer statement input by the user, and the natural query statement exists in the form of human natural language. In the embodiments of the present application, the natural query statement can be speech, text, or other possible forms.

[0095] The natural query statement expresses human language, and the terminal device or machine cannot directly understand the natural query statement. Therefore, a series of processing needs to be performed on the natural query statement.

[0096] In the embodiments of the present application, after obtaining the natural query statement, the main entity of the natural query statement is first determined. In the natural query statement, there may be one or more associated entities, and the main entity is one of these one or more entities.

[0097] S22. According to the main entity, construct a semantic query graph of the natural query statement, and the semantic query graph is used to indicate the relationships or attributes associated with the main entity.

[0098] After determining the main entity, the relationships or attributes in the natural query statement will be recognized. Among them, the relationship refers to the association relationship between two entities, and the relationship corresponds to two entities. For example, A is an astronaut, and A and astronaut are two entities respectively. The relationship between these two entities is occupation, and A's occupation is an astronaut. The attribute corresponds to one entity, and the attribute refers to the characteristic description of the entity. For example, if B's date of birth is July 4, 2000, then B is an entity, and July 4, 2000 is B's attribute, and this attribute is the date of birth.

[0099] After recognizing the relationships or attributes in the natural query statement, a semantic query graph will be constructed based on the relationships or attributes, and the semantic query graph is used to indicate the relationships or attributes associated with the main entity. By constructing the semantic query graph, the understanding of the natural query statement is realized, and the user's intention is obtained.

[0100] S23. According to the semantic query graph, output the natural answer statement corresponding to the natural query statement.

[0101] After constructing the semantic query graph, the understanding of the natural query statement is realized. Thus, based on the semantic query graph, the corresponding answer can be searched in the preset knowledge base, and the answer is processed to input the natural answer statement corresponding to the natural query statement.

[0102] The Q&A method provided by the embodiments of the present application, after obtaining a natural query statement, first determines the main entity of the natural query statement, performs preliminary recognition on the natural query statement, and then constructs a semantic query graph of the natural query statement according to the main entity. The semantic query graph indicates the relationships or attributes associated with the main entity, thereby realizing the semantic understanding of the natural query statement. Finally, according to the semantic query graph, a Q&A result is determined, and a natural answer statement corresponding to the natural query statement is output. The solution of the embodiments of the present application does not require pre-setting Q&A templates. Instead, it first identifies the main entity, then constructs a semantic query graph based on the main entity to realize the understanding of the natural query statement, and then outputs a natural answer statement, with high efficiency, less workload, and more accurate semantic understanding.

[0103] The following introduces the solution of the present application in detail with reference to the accompanying drawings. In the following embodiments, the execution entity is taken as a server for description.

[0104] Figure 3 It is a schematic diagram of the Q&A method provided by the embodiments of the present application. As Figure 3 shown, after the server obtains a natural query statement, it first needs to perform main entity recognition to determine the main entity of the natural query statement. Then, a semantic query graph is constructed according to the main entity. After constructing the semantic query graph, sub-graph matching is performed to determine multiple candidate answers. Then, among the multiple candidate answers, the final output answer is determined.

[0105] First, an introduction is made to the recognition of the main entity of the natural query statement.

[0106] After obtaining the natural query statement, the server needs to determine the main entity of the natural query statement. Specifically, the server can obtain the entity linking result of the natural query statement, and the entity linking result includes multiple entities associated with the natural query statement.

[0107] Taking the following natural query statement as an example:

[0108] Where was the drama A starring A filmed?

[0109] In the above natural query statement, the entities related to "A" may include, for example, "A (film and television actor)", and the entities related to "drama A" may include, for example, "TV drama A (2017 ancient costume TV drama)", "Movie A (2017 ancient costume movie)", "Novel A (ancient style romance novel)", "Song A (the theme song of TV drama A)", etc. Therefore, the entity linking result of the above natural query statement is as follows:

[0110] TV drama A (2017 ancient costume TV drama);

[0111] Movie A (2017 ancient costume movie);

[0112] A (a film and television actor);

[0113] Novel A (an ancient style romantic novel);

[0114] Song A (the theme song of TV drama A).

[0115] After obtaining the entity linking results of the natural query statement, it is necessary to identify the natural query statement to determine whether there is a triple in the natural query statement. According to the identification result and the entity linking result, the main entity of the natural query statement is determined.

[0116] Figure 4 This is the schematic diagram of natural query statement identification provided by the embodiment of the present application. As Figure 4 shown, for the natural query statement, the dependency syntax tree of the natural query statement can be constructed. The dependency syntax tree describes the dependency relationships between various words, that is, the syntactic collocation relationships between words, and this collocation relationship is associated with semantics.

[0117] For example, in Figure 4 , "Where was the drama A starred by A filmed?" can be composed of two entities, "A" and "drama A", the category of "actor", three predicates "starred", "of", "filmed", and the constraint "where".

[0118] After constructing the syntactic dependency tree, the collocation relationships between words in the natural query statement can be obtained according to the syntactic dependency tree. For example, as shown in Figure 4 , there is a professional relationship between "actor" and "A", "A" is the star of "drama A", "drama A" is the representative work of "A", and the type of "drama A" is "TV drama", etc.

[0119] Then, the main entity can be determined based on the collocation relationships between words in the natural query statement.

[0120] Figure 5 This is the schematic diagram of determining the main entity provided by the embodiment of the present application. As Figure 5 shown, it includes:

[0121] S51, determine whether the natural query statement contains a triple. If so, execute S52; if not, execute S54.

[0122] The triples in the embodiments of the present application include complete triples and hidden relationship triples. Taking the sentence "What are the representative works of the well-known alumnus B of Ocean University of China?" as an example, "Ocean University of China", "well-known alumnus" and "B" constitute a triple, and it is a complete triple. In this triple, "Ocean University of China" is the head element (or head entity), "well-known alumnus" is the middle element (or middle entity), and "B" is the tail element (or tail entity).

[0123] Taking the sentence "What are the representative works of B from Ocean University of China" as an example, it includes a hidden relation triple, that is, "Ocean University of China", "well-known alumnus" and "B" form a hidden relation triple. In this triple, "Ocean University of China" is the head element (or head entity), "well-known alumnus" (which can also be "alumnus", "graduate", etc.) is the middle element (or middle entity), and "B" is the tail element (or tail entity).

[0124] S52, determine the tail element in the triple.

[0125] If the natural query sentence contains a triple, first determine the tail element (or tail entity) in the triple.

[0126] S53, determine the main entity according to the tail element.

[0127] After determining the tail element, the entity corresponding to the tail element in the entity linking result in the triple is determined as the main entity. For example, the main entity in "What are the representative works of Zang Kejia from Ocean University of China" is Zang Kejia.

[0128] In some cases, the tail entity in the natural query sentence can be directly used as the main entity. However, in some cases, due to the complexity of natural language, the description of the tail entity in the natural query sentence is not accurate. For example, if the tail entity in the natural query sentence is "Three Lives Three Worlds", it may be an abbreviation, which may correspond to "Three Lives Three Worlds: Ten Miles of Peach Blossoms", or it may also correspond to "Three Lives Three Worlds: The Pillow Book of the East Sea". Therefore, the entity corresponding to the tail element in the entity linking result needs to be determined as the main entity. Specifically, other words or features in the natural query sentence can be combined to determine the entity corresponding to the tail element in the entity linking result.

[0129] S54, obtain the popularity score in the entity linking result.

[0130] When obtaining the entity linking result, the popularity scores of the entities in the entity linking result can also be obtained. For example, for "Where was the drama A starring A filmed", the entity linking result is as follows:

[0131] Drama A (2017 ancient costume drama), 0.91;

[0132] Movie A (2017 ancient costume movie), 0.9;

[0133] A (film and television actor), 0.88;

[0134] Novel A (ancient style romance novel), 0.87;

[0135] Song A (theme song of drama A), 0.84.

[0136] Among them, the popularity scores of each entity can be jointly determined by multiple factors such as the popularity degree and association relationship of each entity.

[0137] S55. Determine the main entity according to the popularity score.

[0138] After obtaining the popularity scores of each entity, the main entity can be determined in the entity connection result according to the popularity scores of each entity. Specifically, the entity with the highest popularity score can be determined as the main entity. For example, in the above entity connection result, the popularity score of TV drama A (a 2017 ancient costume TV drama) is the highest, which is 0.91. Then TV drama A (a 2017 ancient costume TV drama) can be used as the main entity.

[0139] After determining the main entity of the natural query statement, it is necessary to construct a semantic query graph according to the main entity.

[0140] Figure 6 It is a schematic flowchart of the process for constructing a semantic query graph provided by an embodiment of the present application, as Figure 6 shown, including:

[0141] S61. Obtain the relationships or attributes of multiple entities associated with the natural query statement.

[0142] A possible implementation manner is to perform relationship or attribute modeling offline. Specifically, a relationship attribute recognition model can be pre-trained. When training the relationship attribute recognition model, input the natural query statement and the corresponding sample relationships or sample attributes into the model, and then obtain the relationships or attributes output by the model. According to the difference between the relationships output by the model and the sample relationships, or according to the attributes output by the model or the sample attributes, adjust the parameters of the relationship attribute recognition model to obtain the trained relationship attribute recognition model. When constructing the relationship attribute recognition model, for example, it can be modeled based on the ESIM architecture.

[0143] After training is completed, the natural query statement can be input into the relationship attribute recognition model, and the relationships or attributes of multiple entities associated with the natural query statement can be obtained.

[0144] Another possible implementation is to establish an entity-entity reference dictionary and a relation-relation reference dictionary offline. Among them, the entity-entity reference represents multiple different representations of an entity. For example, taking "Three Lives, Three Worlds" as A in the above example, the entity "Three Lives, Three Worlds" may refer to "Ten Miles of Peach Blossoms in Three Lives, Three Worlds", or it may refer to "Love and Redemption in Three Lives, Three Worlds". Due to the complexity of natural language, when making an inquiry, the user may say "Where was the drama filmed in which A starred", and here, according to the entity-entity reference dictionary, it can be determined whether "Three Lives, Three Worlds" in this natural query statement refers to "Ten Miles of Peach Blossoms in Three Lives, Three Worlds" or "Love and Redemption in Three Lives, Three Worlds".

[0145] Similarly, the relation-relation reference dictionary also indicates multiple different representations of a relation. For example, the relationship between "A" and "TV drama A" is the starring relationship, but in a natural query statement, it may be "TV drama A starred by A", "Representative work TV drama A of A", "TV drama A filmed by A", and through the relation-relation reference dictionary, it is determined that "starred by", "representative work", and "filmed by" express the same meaning and the same relationship.

[0146] The settings of the above entity-entity reference dictionary and relation-relation reference dictionary are only for example and do not constitute a limitation on the entity-entity reference dictionary and relation-relation reference dictionary.

[0147] After establishing the entity-entity reference dictionary and the relation-relation reference dictionary, the relationships or attributes of multiple entities associated with the natural query statement can be obtained through the entity-entity reference dictionary and the relation-relation reference dictionary.

[0148] S62, determine the target relationship or target attribute according to the main entity among the relationships or attributes of multiple entities.

[0149] A relationship associates two entities, and an attribute associates an entity and a character. In the embodiments of the present application, after obtaining the relationships or attributes of multiple entities associated with the natural query statement, it is necessary to determine the target relationship or target attribute. Among them, one of the two entities associated with the target attribute belongs to the natural query statement, and the other does not belong to the natural query statement; the entity associated with the target attribute belongs to the natural query statement, and the character does not belong to the natural query statement.

[0150] For example, in "Where was the drama A filmed in which A starred", "Where it was filmed" is a target relationship or target attribute, and one of the entities "drama A" associated with it belongs to the natural query statement.

[0151] S63, construct a semantic query graph according to the main entity and the target relationship or target attribute.

[0152] Specifically, first, at least one reference corresponding to the target relationship or target attribute, as well as the score corresponding to each reference, are obtained. Herein, a reference refers to different expressions of the same meaning. For example, "Who played it" and "Representative works" are a relationship-reference. Due to the complexity of natural language, the same question may have multiple different expression forms. Therefore, a reference dictionary can be preset in advance, and based on the reference dictionary, at least one reference corresponding to the target relationship or target attribute is obtained. For example, according to "Where was it filmed", references such as "Shooting location" and "Production area" can be determined.

[0153] After determining the references corresponding to the target relationship or target attribute, a semantic query graph can be constructed according to each reference and the corresponding score. Figure 7 A schematic diagram of constructing a semantic query graph provided by an embodiment of the present application is as Figure 7 shown

[0154] Adopting the node-first algorithm, nodes are found from the natural query statement, and then the edges between the nodes are filled. When filling the edges, if there is a problem that the same pair of nodes are connected by different paths, the result of the relationship attribute recognition model needs to be substituted. On the one hand, the out-of-vocabulary words in the relationship mapping dictionary are supplemented, and on the other hand, the score of the relationship mapping is used as a reference value for the answers recalled by this path.

[0155] Specifically, first, all entity references are identified by existing methods, and all wh-words and nouns that cannot be matched to any entity are used as wildcards. For example, for the example sentence "What is the budget of the film directed by X and starred by a Chinese actor?" (What is the budget of the film directed by X and starred by a Chinese actor?), "what" (what), "film" (film), "X", "Chinese" (China), and "actor" (actor) can be identified.

[0156] Secondly, the structure is established. Using the syntactic dependency tree, when there are no other nodes between two nodes, it is considered that there is an edge or path connection between these two nodes, that is, a relationship reference, and the combination of all edges on the path becomes this relationship reference. As Figure 7 shown, there are no other nodes between the point "film" and the points "X" and "actor" (actor). Therefore, there is a relationship between "film" (film) and "X", and the relationship reference is "directed by" (director); there is a relationship between "film" and "actor" (actor), and the relationship reference is "directed starred by", and thus the relationship references between the nodes are obtained. When there is no edge between the references of two nodes, as Figure 7For "Chinese" (China) and "actor", if both nodes are entities, then fill in the relationship between these two nodes in the knowledge graph; if one of the nodes is a wildcard, then locate the other node in the knowledge graph and take the predicates with the highest connection frequency as candidate relationships to fill in.

[0157] After relationship filling, Qu can be obtained, and Qu will contain all nodes, but the subgraph connecting all nodes with different edges is denoted as Si. When matching Si with the structured query graph, a top-down method based on dynamic programming is used to gradually expand. That is, first find the most likely matching partial subgraph Q, then add the edges connected to the nodes in Q one by one and evaluate whether it can match the subgraph in the knowledge graph G. If it can, then continue to add edges to Q until Q is a subgraph of Qu that contains all nodes of Qu, then it is considered that a semantic query graph is found; if no match can be generated after adding an edge, then backtracking is required, delete this edge from Q, add a new edge, and then iterate.

[0158] In the above way, a semantic query graph is constructed. As Figure 3 the example of the semantic query graph in, which includes the main entity "Drama A", and two mentions "shooting location" and "production area", and the two mentions include the corresponding scores. The scores corresponding to the mentions are used to indicate the mentions semantically corresponding to the target relationship or target attribute.

[0159] After constructing the semantic query graph, multiple candidate answers in the natural query statement can be obtained according to the semantic query graph. Specifically, the semantic query graph can be matched with the knowledge graph to obtain the candidate answers corresponding to each mention, where any mention indicates the relationship or attribute between the main entity and the corresponding candidate answer.

[0160] For example, in Figure 3 , through subgraph matching, two candidate answers are obtained, namely candidate answer 1 - the candidate answer "China" corresponding to the production area, and candidate answer 2 - the candidate answers "Xiangshan Film and Television City, Pu'erhei" corresponding to the shooting location.

[0161] After obtaining multiple candidate answers, the candidate answers can be input into a preset model to obtain the confidence scores output by the preset model; then, according to the confidence scores of each candidate answer, the output answer is determined among the multiple candidate answers; where the preset model is trained through multiple groups of training samples, and each group of training samples includes a sample answer and the sample confidence score of the sample answer.

[0162] For example, the confidence score of the candidate answer can be obtained based on the xgboost algorithm model. First, feature extraction is performed on the candidate answer based on xgboost. Among them, the extracted features can include, for example, entity link score, attribute score in the relationship recognition model, subsequent sorting score, similarity score between the concatenation of entity and attribute words and the natural query statement, and so on.

[0163] After feature extraction, xgboost modeling can be carried out. Among them, the positioning of the xgboost model is that, given a data set containing n samples and m features:

[0164] |D| = {(x1, y1), (x2, y2),..., (x n , y n )}, (1)

[0165] In formula (1), D is the data set, x n is the nth sample, and y n is the label of the nth sample (the label indicates correct or incorrect). The predicted output of the model is expressed as:

[0166]

[0167] Among them, Φ(x i ) is the sample prediction function, f(x) is the decision tree model, and f k (x i ) is the predicted value of the sample x i in the kth decision tree, and f k represents the regression tree, and K is the number of regression trees. Formula (2) means that given an input x i , the output value is the sum of the predicted values of K regression trees (that is, the weights of the leaf nodes divided according to the decision rules of the corresponding regression trees). The prediction result for each sample is the sum of the prediction scores of each regression tree.

[0168] Among them, any candidate answer can be used as a sample, and the attribute score, subsequent sorting score, similarity score between the concatenation of entity and attribute words and the natural query statement, etc. of the candidate answer can be used as the m features of the sample.

[0169] The objective function is:

[0170]

[0171] Among them,

[0172] is the error function, y i is the observed value of the sample label, is the predicted value of the sample label, and f kis a new function, added to f k The main purpose of k is to penalize complex models (prevent overfitting), by adding k in each round of training to minimize the objective function as much as possible.

[0173] Ω(f) is the regularization term, which describes the complexity of the regression tree. Here, T is the number of leaf nodes. When the tree is more complex, the number of its leaf nodes is larger. w ∈ R T is the vector of leaf nodes.

[0174] Through the above method, the confidence scores of each candidate answer can be obtained. Then, based on the confidence scores of each candidate answer, the output answer is determined among multiple candidate answers. For example, in Figure 3 , if the confidence score of candidate answer 1 is 0.91 and the confidence score of candidate answer 2 is 0.65, then the candidate answer with the highest confidence score is determined as the output answer.

[0175] After determining the output answer, methods such as template splicing, pronoun replacement, unit conversion, multiple answer splicing, and confidence strategy adjustment can be used to rewrite the output answer into a natural answer statement and output it. For example, in the example of Figure 3 , the final output answer is "Xiangshan Film and Television City, Puzhehei", and the finally output natural answer statement is "The drama A of Party A was filmed in Xiangshan Film and Television City".

[0176] The question-answering method provided by the embodiments of this application, after obtaining the natural query statement, first determines the main entity of the natural query statement, performs a preliminary identification of the natural query statement, then constructs a semantic query graph of the natural query statement according to the main entity. The semantic query graph indicates the relationships or attributes associated with the main entity, thus realizing the semantic understanding of the natural query statement. Finally, according to this semantic query graph, the question-answering result is determined, and the natural answer statement corresponding to the natural query statement is output. The solution of the embodiments of this application does not require pre-setting question-answering templates. Instead, it first identifies the main entity, then constructs a semantic query graph based on the main entity to realize the understanding of the natural query statement, and then outputs the natural answer statement, with high efficiency, less workload, and more accurate semantic understanding.

[0177] Figure 8 is the structural schematic diagram of the question-answering device provided by the embodiments of this application, as shown in Figure 8 shown, including:

[0178] A determination module 81, used to determine the main entity of the natural query statement;

[0179] A processing module 82, used to construct a semantic query graph of the natural query statement according to the main entity, and the semantic query graph is used to indicate the relationships or attributes associated with the main entity;

[0180] An output module 83, configured to output a natural answer statement corresponding to the natural query statement according to the semantic query graph.

[0181] In a possible implementation manner, the determining module 81 is specifically configured to:

[0182] Obtain an entity linking result of the natural query statement, where the entity linking result includes multiple entities associated with the natural query statement;

[0183] Identify the natural query statement to obtain an identification result, where the identification result is used to indicate whether there is a triple in the natural query statement;

[0184] Determine the main entity according to the entity linking result and the identification result.

[0185] In a possible implementation manner, the identification result indicates that there is a triple in the natural query statement; the determining module 81 is specifically configured to:

[0186] Determine the entity corresponding to the tail element in the triple in the entity linking result as the main entity.

[0187] In a possible implementation manner, the identification result indicates that there is no triple in the natural query statement; the determining module 81 is specifically configured to:

[0188] Obtain the popularity scores of the entities in the entity linking result;

[0189] Determine the main entity in the entity connection result according to the popularity scores of the entities.

[0190] In a possible implementation manner, the processing module 82 is specifically configured to:

[0191] Obtain the relationships or attributes of the multiple entities associated with the natural query statement;

[0192] Determine a target relationship or a target attribute according to the main entity in the relationships or attributes of the multiple entities;

[0193] Construct the semantic query graph according to the main entity and the target relationship or the target attribute.

[0194] In a possible implementation manner, the processing module 82 is specifically configured to:

[0195] Obtain at least one referent corresponding to the target relationship or the target attribute, and the score corresponding to each referent;

[0196] Construct the semantic query graph according to each referent and the corresponding score.

[0197] In a possible implementation, the output module 83 is specifically configured to:

[0198] Obtain multiple candidate answers in the natural query statement according to the semantic query graph;

[0199] Determine the output answer of the natural query statement among the multiple candidate answers;

[0200] Output the natural answer statement according to the output answer.

[0201] In a possible implementation, the output module 83 is specifically configured to:

[0202] Match the semantic query graph with the knowledge graph to obtain candidate answers corresponding to each reference, where any one reference indicates the relationship or attribute between the main entity and the corresponding candidate answer.

[0203] In a possible implementation, the output module 83 is specifically configured to:

[0204] Input the candidate answers into a preset model to obtain the confidence scores output by the preset model;

[0205] Determine the output answer among the multiple candidate answers according to the confidence scores of the candidate answers;

[0206] Wherein, the preset model is trained by multiple groups of training samples, and each group of training samples includes a sample answer and the sample confidence score of the sample answer.

[0207] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here in this embodiment.

[0208] Figure 9 It is a schematic hardware structure diagram of the question-and-answer device provided in the embodiments of the present application. As Figure 9 shown, the question-and-answer device in this embodiment includes: a processor 91 and a memory 92; wherein

[0209] The memory 92 is used to store computer execution instructions;

[0210] The processor 91 is used to execute the computer execution instructions stored in the memory to implement each step executed by the question-and-answer method in the above embodiments. For details, reference can be made to the relevant descriptions in the foregoing method embodiments.

[0211] Optionally, the memory 92 can be either independent or integrated with the processor 91.

[0212] When the memory 92 is independently provided, the Q&A device further includes a bus 93 for connecting the memory 92 and the processor 91.

[0213] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the processor executes the computer-executable instructions, the Q&A method executed by the above Q&A device is implemented.

[0214] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces, and the indirect coupling or communication connection of the device or module can be in an electrical, mechanical or other form.

[0215] The above-mentioned integrated modules implemented in the form of software function modules can be stored in a computer-readable storage medium. The above-mentioned software function modules are stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods described in various embodiments of the present application.

[0216] It should be understood that the above-mentioned processor may be a central processing unit (English: Central Processing Unit, abbreviated as: CPU), and may also be other general-purpose processors, digital signal processors (English: Digital Signal Processor, abbreviated as: DSP), application-specific integrated circuits (English: Application Specific Integrated Circuit, abbreviated as: ASIC), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed by the hardware processor, or executed by a combination of hardware and software modules in the processor.

[0217] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a disk, or an optical disc, etc.

[0218] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, the buses in the drawings of this application are not limited to only one bus or one type of bus.

[0219] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disc. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0220] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: various media such as ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0221] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A question-and-answer method, characterized in that, including: identifying a natural query statement to obtain an identification result, where the identification result is used to indicate whether there is a triple in the natural query statement; determining a main entity of the natural query statement according to the entity linking result of the natural query statement and the identification result, where the entity linking result includes multiple entities associated with the natural query statement; constructing a semantic query graph of the natural query statement according to the main entity, where the semantic query graph is used to indicate relationships or attributes associated with the main entity; outputting a natural answer statement corresponding to the natural query statement according to the semantic query graph; the identification result indicates that there is a triple in the natural query statement; the determining the main entity according to the entity linking result and the identification result includes: determining, as the main entity, the entity corresponding to the tail element in the triple in the entity linking result; the identification result indicates that there is no triple in the natural query statement; the determining the main entity according to the entity linking result and the identification result includes: determining the main entity in the entity linking result according to the popularity scores of the entities in the entity linking result, where the popularity scores of the entities are jointly determined by the popularity and association relationships of the entities; 2. The Q&A method according to claim 1, characterized in that, further including: obtaining the entity linking result of the natural query statement.

3. The Q&A method according to claim 2, characterized in that, further including: obtaining the popularity scores of the entities in the entity linking result.

4. The Q&A method according to claim 2 or 3, characterized in that the constructing the semantic query graph of the natural query statement according to the main entity includes: obtaining relationships or attributes of the multiple entities associated with the natural query statement; determining a target relationship or a target attribute from the relationships or attributes of the multiple entities according to the main entity; constructing the semantic query graph according to the main entity and the target relationship or the target attribute.

5. The Q&A method according to claim 4, characterized in that, the constructing the semantic query graph according to the main entity and the target relationship or the target attribute includes: obtaining at least one reference corresponding to the target relationship or the target attribute, and scores corresponding to the references; constructing the semantic query graph according to the references and the corresponding scores.

6. The Q&A method according to claim 5, characterized in that, the outputting the natural answer statement corresponding to the natural query statement according to the semantic query graph includes: obtaining multiple candidate answers in the natural query statement according to the semantic query graph; determining an output answer of the natural query statement from the multiple candidate answers; outputting the natural answer statement according to the output answer.

7. The Q&A method according to claim 6, wherein the obtaining the multiple candidate answers in the natural query statement according to the semantic query graph includes: performing a matching process on the semantic query graph and a knowledge graph to obtain candidate answers corresponding to the references, where any one reference indicates a relationship or an attribute between the main entity and the corresponding candidate answer.

8. The Q&A method according to claim 7, characterized in that the determining the output answer of the natural query statement from the multiple candidate answers includes: inputting the candidate answers into a preset model to obtain confidence scores output by the preset model; determining the output answer from the multiple candidate answers according to the confidence scores of the candidate answers; Among them, the preset model is obtained by training with multiple groups of training samples, and each group of training samples includes a sample answer and a sample confidence score of the sample answer.

9. A question-and-answer device, characterized in that, Including: A determination module, configured to identify a natural query statement and obtain an identification result, where the identification result is used to indicate whether there is a triple in the natural query statement; According to the entity linking result of the natural query statement and the identification result, determine the main entity of the natural query statement, where the entity linking result includes multiple entities associated with the natural query statement; A processing module, configured to construct a semantic query graph of the natural query statement according to the main entity, where the semantic query graph is used to indicate the relationships or attributes associated with the main entity; An output module, configured to output a natural answer statement corresponding to the natural query statement according to the semantic query graph; The identification result indicates that there is a triple in the natural query statement; The determination module is specifically configured to: determine the entity corresponding to the tail element in the triple in the entity linking result as the main entity; The identification result indicates that there is no triple in the natural query statement; The determination module is specifically configured to: determine the main entity in the entity linking result according to the popularity scores of the entities in the entity linking result, where the popularity scores of the entities are jointly determined by the popularity and association relationships of the entities.

10. A question-and-answer device, characterized in that, Including: At least one processor and a memory; The memory stores computer execution instructions; The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the question-answering method according to any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, Computer execution instructions are stored in the computer-readable storage medium, and when the processor executes the computer execution instructions, the question-answering method according to any one of claims 1-8 is implemented.

12. A computer program product, characterized in that, The computer program product includes a computer program; when the computer program is executed, the question-answering method according to any one of claims 1-8 is implemented.

Citation Information

Patent Citations

  • Semantic analysis method, device, computer equipment and storage medium

    CN111782781A

  • Construction method of medical knowledge question-answering system based on knowledge graph

    CN112148851A