Query processing method, apparatus, device, and storage medium
By using a hierarchical knowledge attention model (HKBAM) to perform semantic analysis on user query requests, the problem of inaccurate semantic recognition in existing technologies is solved, thus improving the accuracy of intelligent question answering.
Patent Information
- Application Number
- CN202110213914.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-25
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2041-02-25
AI Technical Summary
Existing semantic recognition technologies cannot effectively solve the above-mentioned technical problems, resulting in low accuracy of intelligent question answering.
By using the Hierarchical Knowledge Attention Model (HKBAM) to perform semantic analysis on user query requests, the attributes of target entities and their types are determined. Combined with knowledge graphs and knowledge bases, the accuracy of semantic recognition is improved.
It improves the prediction accuracy of target entities and their type attributes when no obvious target entity appears, thereby improving the accuracy of intelligent question answering.
Smart Images

Figure CN114969276B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of information technology, and in particular, to a query processing method and device, equipment and a storage medium. BACKGROUND
[0002] With the continuous development of technology, intelligent question answering is applied in many fields, for example, intelligent customer service, intelligent question answering robots, intelligent sound boxes, question and answer systems in mobile phones, etc.
[0003] Intelligent question answering usually involves semantic recognition, for example, semantic recognition of a user's query request, such as a user's question sentence. Further, a query result, such as an answer to a user's question sentence, is obtained according to the semantic recognition result.
[0004] However, the inventors of the present disclosure found that general semantic recognition is not accurate, resulting in low accuracy of intelligent question answering. SUMMARY
[0005] To solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a query processing method, device, equipment and storage medium to effectively improve the accuracy of intelligent question answering.
[0006] In a first aspect, the embodiments of the present disclosure provide a query processing method, comprising:
[0007] obtaining a user's query request;
[0008] determining a target entity corresponding to the query request according to a first probability distribution of a plurality of preset entities;
[0009] determining an attribute of a type to which the target entity belongs according to a second probability distribution of a plurality of first preset attributes, the first preset attribute being an attribute of a type to which a preset entity belongs;
[0010] determining a query result corresponding to the query request according to at least the target entity and the attribute of the type to which the target entity belongs.
[0011] In a second aspect, the embodiments of the present disclosure provide a query processing device, comprising:
[0012] an obtaining module configured to obtain a user's query request;
[0013] a determining module configured to determine a target entity corresponding to the query request according to a first probability distribution of a plurality of preset entities; determine an attribute of a type to which the target entity belongs according to a second probability distribution of a plurality of first preset attributes, the first preset attribute being an attribute of a type to which a preset entity belongs; and determine a query result corresponding to the query request according to at least the target entity and the attribute of the type to which the target entity belongs.
[0014] In a third aspect, the embodiments of the present disclosure provide an electronic device, comprising:
[0015] a memory;
[0016] a processor; and
[0017] a computer program;
[0018] The computer program is stored in the memory and configured to be executed by the processor to implement the method according to the first aspect.
[0019] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, having a computer program stored thereon, the computer program being executed by a processor to implement the method according to the first aspect.
[0020] The query processing method, device, equipment and storage medium provided by the embodiments of the present disclosure can determine the target entity corresponding to the query request through the first probability distribution of a plurality of preset entities, and can determine the target entity corresponding to the query request even if the target entity does not appear obviously in the query request, thereby improving the prediction accuracy of the target entity. In addition, the attribute of the type to which the target entity belongs can be determined according to the second probability distribution of a plurality of first preset attributes, and the attribute of the type to which the target entity belongs in the query request can be normally predicted even if the target entity does not appear obviously in the query request, thereby improving the prediction accuracy of the attribute of the type to which the target entity corresponding to the query request belongs. Further, the accuracy of semantic recognition or semantic analysis of the query request can be improved through the target entity and the attribute of the type to which the target entity belongs, thereby effectively improving the accuracy of intelligent question answering. BRIEF DESCRIPTION OF DRAWINGS
[0021] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0023] Figure 1 A flowchart of the query processing method provided by the embodiments of the present disclosure;
[0024] Figure 2 A schematic diagram of an application scenario provided by the embodiments of the present disclosure;
[0025] Figure 3A schematic diagram of the HKBAM provided by an embodiment of the present disclosure is shown in FIG. 1.
[0026] Figure 4 A query processing method flowchart provided by another embodiment of the present disclosure is shown in FIG. 6.
[0027] Figure 5 A schematic diagram of the HKBAM provided by another embodiment of the present disclosure is shown in FIG. 7.
[0028] Figure 6 A query processing method flowchart provided by another embodiment of the present disclosure is shown in FIG. 8.
[0029] Figure 7 A query processing method flowchart provided by another embodiment of the present disclosure is shown in FIG. 9.
[0030] Figure 8 A schematic diagram of the effect comparison provided by an embodiment of the present disclosure is shown in FIG. 10.
[0031] Figure 9 A structural schematic diagram of the query processing apparatus provided by an embodiment of the present disclosure is shown in FIG. 11.
[0032] Figure 10 A structural schematic diagram of the electronic device embodiment provided by an embodiment of the present disclosure is shown in FIG. 12. DETAILED DESCRIPTION
[0033] In order to more clearly understand the above-mentioned purposes, features and advantages of the present disclosure, the schemes of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0034] In the following description, many specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure can also be implemented in other ways different from those described herein; obviously, the embodiments in the description are only some of the embodiments of the present disclosure, not all the embodiments.
[0035] Generally, intelligent question answering usually involves semantic recognition, for example, semantic recognition of a user query request such as a user question. Further, a query result such as an answer to the user question is obtained according to the semantic recognition result. However, the inventors of the present disclosure found that general semantic recognition is not accurate, resulting in low accuracy of intelligent question answering. In view of this problem, the present disclosure provides a query processing method, which will be introduced below in combination with specific embodiments.
[0036] Figure 1 A query processing method flowchart provided by an embodiment of the present disclosure is shown in FIG. 3. The method is applicable to an application scenario as shown in FIG. 4, which can include a server 20 and a terminal, and the terminal is not limited to Figure 2 Figure 2 The smartphone 21, desktop computer 22, and smart speaker 23 shown are examples. Additionally, terminals may include PDAs, tablets, wearable devices with displays, laptops, all-in-one computers, smart home devices, etc. The smartphone 21, desktop computer 22, and smart speaker 23 are used as illustrative examples here. Server 20 can be a cloud server or a server cluster. Specifically, server 20 and terminals can be used for intelligent question answering. For example, users can input user questions into the terminal through human-computer interaction. Furthermore, the terminal can send the user question to server 20, which can perform semantic analysis or semantic parsing on the user question and determine the answer corresponding to the user question based on the semantic analysis or semantic parsing results, returning the answer to the terminal. In some embodiments, intelligent question answering can also be applied to other application scenarios. For example, in a new retail scenario, there may be no cashiers in the store, but instead, there are intelligent customer service robots, companion robots, etc. Users can interact with these devices during the shopping or checkout process, enabling them to perform intelligent question answering. For example, in smart finance scenarios, platforms such as online customer service systems, intelligent customer service systems, customer service robots, and intelligent knowledge bases are used for intelligent question and answering to provide relevant services to users. Figure 2 Taking the illustrated application scenario as an example, it is understood that this embodiment does not limit the human-computer interaction method between the user and the terminal. For example, the user can input a text-based question in a browser installed on the smartphone 21 or desktop computer 22. Alternatively, the user can interact with the smartphone 21 or smart speaker 23 via voice interaction. The smartphone 21 or smart speaker 23 can collect the user's voice question and send it to the server 20, which then converts the voice question into a text-based question. Alternatively, if the smartphone 21 or smart speaker 23 collects a voice question, it can convert the voice question into a text-based question and send it to the server 20.
[0037] It is understood that, in some embodiments, the terminal may also perform semantic analysis or semantic parsing on the user's question, and determine the answer corresponding to the user's question based on the semantic analysis or semantic parsing results.
[0038] The following describes, with specific embodiments, the process by which server 20 performs semantic analysis or semantic parsing on text-based questions, and the process by which server 20 determines the answer to the question based on the semantic analysis or semantic parsing results. For example... Figure 1 As shown, the specific steps of this method are as follows:
[0039] S101. Obtain the user's query request.
[0040] For example, the server 20 obtains a query request of a user, which can be a user question as described above, such as a text type question.
[0041] S102, determining a target entity corresponding to the query request according to the first probability distribution of the plurality of preset entities.
[0042] In this embodiment, the server 20 can include a Knowledge Base Question Answering (KBQA) device or engine based on a knowledge graph or knowledge base. The KBQA device or engine can use a Hierarchical Knowledge Based Attention Model (HKBAM) to perform semantic analysis or semantic parsing on the query request of the user, such as the user question. The structure of the HKBAM is shown as 30. Figure 3
[0043] For example, the user question is “My daughter is 15 years old, what insurance can she buy”. The HKBAM can at least analyze or parse the target entity in the user question and the attribute of the type to which the target entity belongs. Specifically, the HKBAM can analyze or parse the target entity in the user question and the attribute of the type to which the target entity belongs in combination with a Knowledge Graph or Knowledge Base (KB). For example, the Knowledge Graph or Knowledge Base can include a plurality of preset types, and each preset type can include one or more preset entities. For example, “insurance type” is a preset type, and the preset type includes preset entities such as “health insurance”, “commercial insurance”, and “car insurance”. That is, the preset type can be the type to which the preset entity in the Knowledge Graph or Knowledge Base belongs. Each preset type can include one or more attributes, for example, the attributes of “insurance type” include “insurance introduction” and “insurance purchase method”. In addition, each preset type can also correspond to one or more preset constraint conditions, and the preset constraint condition includes an attribute and an attribute value. For example, the attribute of the preset constraint condition includes “age interval for insurance” and “gender for insurance”. The attribute value of the preset constraint condition includes “12-18 years old” and “male and female”. It can be understood that the Knowledge Graph or Knowledge Base can include a plurality of preset types, a plurality of preset entities, a plurality of attributes of the preset types, a plurality of attributes of the preset constraint conditions, and a plurality of attribute values of the preset constraint conditions. Each preset constraint condition in the Knowledge Graph or Knowledge Base can have one or more attributes, and correspondingly, each preset constraint condition in the Knowledge Graph or Knowledge Base can have one or more attribute values.
[0044] As Figure 3 As shown, the plurality of preset types, the plurality of preset entities, the plurality of preset types of attributes, the plurality of preset constraint conditions of attributes, and the plurality of preset constraint conditions of attribute values in the knowledge graph or the knowledge base can be used as inputs of an embedding layer in the HKBAM. The embedding layer can use random word vectors to encode the plurality of preset types, the plurality of preset entities, the plurality of preset types of attributes, the plurality of preset constraint conditions of attributes, and the plurality of preset constraint conditions of attribute values respectively, to obtain vector representations of the plurality of preset types, vector representations of the plurality of preset entities, vector representations of the plurality of preset types of attributes, vector representations of the plurality of preset constraint conditions of attributes, and vector representations of the plurality of preset constraint conditions of attribute values. Specifically, the vector representations of the plurality of preset types or the vector representations of the plurality of preset entities in the knowledge graph or the knowledge base can be denoted as Emb_e, the vector representations of the plurality of preset types of attributes in the knowledge graph or the knowledge base can be denoted as Emb_p, the vector representations of the plurality of preset constraint conditions of attributes in the knowledge graph or the knowledge base can be denoted as Emb_c, and the vector representations of the plurality of preset constraint conditions of attribute values in the knowledge graph or the knowledge base can be denoted as Emb_v.
[0045] In addition, as shown, a user question such as “My daughter is 15 years old. What insurance can she buy?” can be input into a structural bidirectional encoder representation from transformers (StructBERT). Figure 3 As shown, a user question such as “My daughter is 15 years old. What insurance can she buy?” can be input into a structural bidirectional encoder representation from transformers (StructBERT). The StructBERT can encode the user question to obtain a vector representation Q_ori of the user question. In addition, in some embodiments, the user question can also be delexicalized, which can be understood as a kind of normalization. For example, the user question is “How to open a traffic daily package”, where “traffic daily package” is an entity and “traffic package” is a type. Further, the “traffic daily package” can be replaced by “traffic package” to obtain the normalized user question “How to open a traffic package”. The StructBERT can also encode the normalized user question to obtain a vector representation Q_0 of the normalized user question. It can be understood that Q_ori and Q_0 are both mappings of the user question to a vector, so that the vector can represent the position of the user question in the semantic space. The difference between Q_ori and Q_0 is that Q_ori is the vector representation of the original question. Q_0 is the vector representation of the original question after lexical replacement.
[0046] Specifically, the HKBAM can obtain a first probability distribution of the plurality of preset entities according to the vector representation Q ori of the user question and the vector representation Emb e of the plurality of preset entities, and the first probability distribution can be denoted as Entity prob. Wherein, the first probability distribution of the plurality of preset entities can be understood as the probability that the target entity corresponding to the user question is each of the plurality of preset entities. Further, the HKBAM can determine the target entity corresponding to the user question according to the first probability distribution of the plurality of preset entities.
[0047] Alternatively, in some embodiments, Emb e can be a vector representation of a plurality of preset types, and the first probability distribution Entity prob can also represent a first probability distribution of a plurality of preset types, which can be a type to which the preset entity belongs. Wherein, the first probability distribution of the plurality of preset types can be the probability that the type to which the target entity corresponding to the user question belongs is each of the plurality of preset types. In this case, the HKBAM can also determine the type to which the target entity corresponding to the user question belongs according to the first probability distribution of the plurality of preset types.
[0048] Optionally, determining the target entity corresponding to the query request according to the first probability distribution of the plurality of preset entities comprises: obtaining the first probability distribution of the plurality of preset entities according to the query request and the plurality of preset entities; and determining the target entity corresponding to the query request according to the first probability distribution of the plurality of preset entities.
[0049] For example Figure 3 As shown, the vector representation Q ori of the user question and the vector representation Emb e of the plurality of preset entities in the knowledge graph can be used as the input of the knowledge graph or knowledge base attention (Knowledge Base Attention, KB-Attention) network. The output of the KB-Attention network can be used as the input of the multilayer perceptron (MLP), and the MLP can output the first probability distribution Entity prob of the plurality of preset entities. Further, the target entity corresponding to the user question is determined according to the first probability distribution Entity prob of the plurality of preset entities. Wherein, the KB-Attention network can use the vectorized user query request to perform self-attention on a type of elements in the knowledge graph or knowledge base (Knowledge Base, KB), while updating the vector representation of the user query request.
[0050] It can be understood that the MLP can not only use a classification model, but also use a matching model.
[0051] Optionally, the target entity is a preset entity corresponding to the maximum probability in the first probability distribution of the plurality of preset entities.
[0052] For example, the target entity corresponding to the user question can be a preset entity corresponding to the maximum probability in the first probability distribution Entity_prob of the plurality of preset entities.
[0053] In some other embodiments, the first probability distribution Entity_prob can also represent the probability distribution of a plurality of preset types in the knowledge graph or knowledge base. In this case, the vector representation Q_ori of the user question and the vector representation Emb_e of the plurality of preset types in the knowledge graph can be used as the input of the KB-Attention network. The output of the KB-Attention network can be used as the input of the MLP, and the MLP can calculate the first probability distribution Entity_prob of the plurality of preset types according to the output of the KB-Attention network. Further, the type to which the target entity corresponding to the user question belongs can be determined according to the first probability distribution Entity_prob of the plurality of preset types. For example, the type to which the target entity belongs can be a preset type corresponding to the maximum probability in the first probability distribution Entity_prob of the plurality of preset types.
[0054] S103, determining the attribute of the type to which the target entity belongs according to the second probability distribution of the plurality of first preset attributes, the first preset attribute being the attribute of the type to which the preset entity belongs.
[0055] For example, the knowledge graph or knowledge base includes a plurality of preset types of attributes, which can be denoted as first preset attributes. The HKBAM can predict the probability of the attribute of the type to which the target entity corresponding to the user question belongs being the attribute of each preset type in the knowledge graph or knowledge base, thereby obtaining the second probability distribution of the plurality of first preset attributes. Further, the HKBAM can determine the attribute of the type to which the target entity corresponding to the user question belongs according to the second probability distribution.
[0056] Optionally, determining the attribute of the type to which the target entity belongs according to the second probability distribution of the plurality of first preset attributes comprises: obtaining the second probability distribution of the plurality of first preset attributes according to the query request and the plurality of first preset attributes; and determining the attribute of the type to which the target entity belongs according to the second probability distribution of the plurality of first preset attributes.
[0057] For example Figure 3As shown, the vector representation Q_0 of the normalized user query and the first probability distribution Entity_prob can be input into a refuse gate, which can output Q_1 according to Q_0 and Entity_prob. In the case that Q_1 is not 0, Q_1 = Q_0. Further, the vector representation Q_0 of the normalized user query and the vector representation Emb_p of the plurality of first preset properties in the knowledge graph, i.e., the plurality of first preset properties, can be input into a KB-Attention network. The output of the KB-Attention network can be input into an MLP, which can calculate a second probability distribution of the plurality of first preset properties according to the output of the KB-Attention network, denoted as Property_prob. Further, the HKBAM can determine the type of the property to which the target entity corresponding to the user query belongs according to the second probability distribution Property_prob of the plurality of first preset properties.
[0058] Optionally, obtaining the second probability distribution of the plurality of first preset properties according to the query request and the plurality of first preset properties comprises: performing normalization processing on the query request to obtain a normalized query request; and in the case that the preset entity corresponding to the maximum probability in the first probability distribution is not empty, obtaining the second probability distribution of the plurality of first preset properties according to the normalized query request and the plurality of first preset properties.
[0059] For example, after normalization processing is performed on the user query, the vector representation of the normalized user query is Q_0. As shown in FIG. 2, the vector representation Q_0 of the normalized user query and the first probability distribution Entity_prob can be input into a refuse gate. Figure 3 As shown, the vector representation Q_0 of the normalized user query and the first probability distribution Entity_prob can be input into a refuse gate, which can output Q_1 according to Q_0 and Entity_prob. In the case that Q_1 is not 0, Q_1 = Q_0. Further, the vector representation Q_0 of the normalized user query and the vector representation Emb_p of the plurality of first preset properties in the knowledge graph, i.e., the plurality of first preset properties, can be input into a KB-Attention network. The output of the KB-Attention network can be input into an MLP, which can calculate a second probability distribution of the plurality of first preset properties according to the output of the KB-Attention network, denoted as Property_prob. Further, the HKBAM can determine the type of the property to which the target entity corresponding to the user query belongs according to the second probability distribution Property_prob of the plurality of first preset properties. Figure 3 As shown, the vector representation Q_0 of the normalized user query and the first probability distribution Entity_prob can be input into a refuse gate, which can output Q_1 according to Q_0 and Entity_prob. In the case that Q_1 is not 0, Q_1 = Q_0. Further, the vector representation Q_0 of the normalized user query and the vector representation Emb_p of the plurality of first preset properties in the knowledge graph, i.e., the plurality of first preset properties, can be input into a KB-Attention network. The output of the KB-Attention network can be input into an MLP, which can calculate a second probability distribution of the plurality of first preset properties according to the output of the KB-Attention network, denoted as Property_prob. Further, the HKBAM can determine the type of the property to which the target entity corresponding to the user query belongs according to the second probability distribution Property_prob of the plurality of first preset properties.
[0060] Specifically, if the preset entity or the preset type corresponding to the maximum probability in Entity_prob is none, Q_1 is set to all 0, so that Q_1 does not work in the subsequent propagation process, which is equivalent to that Q_1 cannot continue to propagate backward in the HKBAM.
[0061] If the preset entity or the preset type corresponding to the maximum probability in the Entity_prob is not empty, Q_1 = Q_0, that is, Q_1 is not 0, which means that Q_0 can continue to propagate backward in the HKBAM. In this case, Q_1 and the vector representation Emb_p of the multiple preset attributes of the multiple preset types in the knowledge graph, that is, the multiple first preset attributes, can be used as the input of the KB-Attention network. The output of the KB-Attention network can be used as the input of the MLP, and the MLP can calculate the second probability distribution Property_prob of the multiple first preset attributes according to the output of the KB-Attention network.
[0062] Optionally, the attribute of the type to which the target entity belongs is the first preset attribute corresponding to the maximum probability in the second probability distribution.
[0063] For example, the attribute of the type to which the target entity corresponding to the user query belongs can be the first preset attribute corresponding to the maximum probability in the second probability distribution Property_prob.
[0064] S104, determining the query result corresponding to the query request according to at least the target entity and the attribute of the type to which the target entity belongs.
[0065] For example, the HKBAM can determine the query result corresponding to the user query, that is, the answer to the user query, according to at least the target entity corresponding to the user query and the attribute of the type to which the target entity corresponding to the user query belongs.
[0066] The embodiments of the present disclosure can determine the target entity corresponding to the query request through the first probability distribution of the multiple preset entities, so that the target entity corresponding to the query request can be determined even if the target entity does not appear obviously in the query request, thereby improving the prediction accuracy of the target entity. In addition, the attribute of the type to which the target entity belongs can be determined according to the second probability distribution of the multiple first preset attributes, so that the attribute of the type to which the target entity belongs in the query request can be normally predicted even if the target entity does not appear obviously in the query request, thereby improving the prediction accuracy of the attribute of the type to which the target entity corresponding to the query request belongs. Further, the accuracy of semantic recognition or semantic parsing of the query request can be improved through the target entity and the attribute of the type to which the target entity belongs, thereby effectively improving the accuracy of intelligent question answering.
[0067] For example, the user question is "how to deduct for supporting the old", although the target entity "personal income tax" does not appear in the user question, the user question is also about "personal income tax". The traditional KBQA takes the entity appearing in the user question as a recognition mark. If the entity appearing in the user question is not recognized, the entity linking cannot be performed between the entity in the user question and the knowledge graph or the knowledge base, so the answer cannot be obtained, and then no answer is given. However, the disclosed embodiments can find the internal relationship between the preset entity in the knowledge graph or the knowledge base and the target entity corresponding to the user question, the internal relationship between the preset type in the knowledge graph or the knowledge base and the type to which the target entity corresponding to the user question belongs, and the internal relationship between the attribute of the preset type in the knowledge graph or the knowledge base and the attribute of the type to which the target entity corresponding to the user question belongs through the HKBAM. In addition, the disclosed embodiments can calculate the probability that the target entity corresponding to the user question is the preset entity in the knowledge graph or the knowledge base, the probability that the type to which the target entity corresponding to the user question belongs is the preset type in the knowledge graph or the knowledge base, and the probability that the attribute of the type to which the target entity corresponding to the user question belongs is the attribute of the preset type in the knowledge graph or the knowledge base through the HKBAM. Further, the target entity corresponding to the query request, the type to which the target entity belongs, and the attribute of the type to which the target entity belongs are determined according to the probabilities. Thus, the problem of poor user question recognition ability caused by the traditional KBQA not recognizing the entity appearing in the user question is solved to some extent.
[0068] On the basis of the above-mentioned embodiments, the query result corresponding to the query request is determined according to at least the target entity and the attribute of the type to which the target entity belongs, including the following steps as shown in Figure 4
[0069] S401, determining the attribute of the first type of constraint condition of the query request according to the third probability distribution of the plurality of second preset attributes, the second preset attribute being the attribute of the preset constraint condition.
[0070] In the disclosed embodiments, the HKBAM can also identify the text type of the constraint condition corresponding to the user question. The text type of the constraint condition can be denoted as the first type of constraint condition. Generally, the constraint condition can be understood as a certain limiting constraint on the user question. Adding the constraint condition and not adding the constraint condition can lead to different answers. Specifically, the constraint condition can correspond to an attribute and an attribute value. For example, the attribute of the constraint condition includes "insurance age interval" and "insurance gender". The attribute value of the constraint condition includes "12-18 years old" and "male and female".
[0071] For example, the attributes including the plurality of preset constraints in the knowledge graph or the knowledge base can be denoted as second preset attributes. The HKBAM can predict a probability that the attribute of the first type of constraint corresponding to the user question is each attribute of the preset constraint in the knowledge graph or the knowledge base, thereby obtaining a third probability distribution of the plurality of second preset attributes. Further, the HKBAM can determine the attribute of the first type of constraint corresponding to the user question according to the third probability distribution.
[0072] Optionally, determining the attribute of the first type of constraint of the query request according to the third probability distribution of the plurality of second preset attributes comprises: obtaining the third probability distribution of the plurality of second preset attributes according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of second preset attributes; and determining the attribute of the first type of constraint of the query request according to the third probability distribution of the plurality of second preset attributes.
[0073] For example, in the case that Q_1 is not 0, Q_1 = Q_0, the HKBAM can obtain a third probability distribution of the plurality of second preset attributes according to the vector representation Q_0 of the normalized user question, the second probability distribution Property_prob, the vector representation Emb_p of the plurality of first preset attributes in the knowledge graph or the knowledge base, and the vector representation Emb_c of the plurality of second preset attributes in the knowledge graph or the knowledge base, which can be denoted as ConsProp_prop. Further, the HKBAM can determine the attribute of the first type of constraint of the user question according to the third probability distribution ConsProp_prop.
[0074] Optionally, obtaining the third probability distribution of the plurality of second preset attributes according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of second preset attributes comprises: obtaining a first vector according to the plurality of first preset attributes and the second probability distribution; obtaining a second vector according to the normalized query request and the first vector; and obtaining the third probability distribution of the plurality of second preset attributes according to the second vector and the plurality of second preset attributes.
[0075] Optionally, obtaining the first vector according to the plurality of first preset attributes and the second probability distribution comprises: obtaining the first vector according to each first preset attribute in the plurality of first preset attributes and a probability corresponding to the each first preset attribute in the second probability distribution.
[0076] As Figure 3As shown, the HKBAM can perform a weighted sum of the plurality of first preset attributes, i.e., the vector representation Emb p of the plurality of preset types of attributes and the second probability distribution Property prob, to obtain a first vector, which can be denoted as Emb q. For example, Emb p i denotes the vector representation corresponding to the i-th first preset attribute in the plurality of first preset attributes. t denotes the number of iterations of the HKBAM in the training process. denotes the probability corresponding to the i-th first preset attribute in the second probability distribution Property prob after the t-th iteration. Among different iteration numbers, may change. The weighted sum of Emb p and Property prob can be represented as i.e., Emb q can be represented as
[0077] Further, in the case where Q 1 is not 0, Q 1 = Q 0, the vector representation Q 0 of the normalized user question and the first vector Emb q can be used as inputs of the attention model 1, and the attention model 1 can obtain a second vector from Q 0 and Emb q, denoted as Q 2.
[0078] Optionally, the second vector is obtained according to the normalized query request and the first vector, including: splicing the third vector corresponding to the normalized query request and the first vector to obtain a spliced vector; obtaining the second vector according to a preset weight matrix and the spliced vector.
[0079] For example, the vector representation Q 0 of the normalized user question can be denoted as a third vector. The attention model 1 can use a question update mechanism to calculate Q 0 and Emb q to obtain a second vector Q 2. Specifically, the attention model 1 can splice Q 0 and Emb q to obtain a spliced vector. Further, the spliced vector is subjected to matrix multiplication by a preset weight matrix to obtain a second vector Q 2. The second vector Q 2 can be a back-propagated sentence vector.
[0080] For example, the second vector Q 2 can be denoted as q t+1 , Q 0 is denoted as q t , the preset weight matrix is denoted as M t . q t+1 , q t , M t The relationship between them can be represented as the following formula (1):
[0081]
[0082] wherein, Emb_q denotes the vector after concatenation of Emb_q and Q_0. The weight matrix M t The key information that has been predicted in the user question can be masked or reduced in weight, so that the HKBAM can focus on other key information or other more useful information in the user question in the subsequent prediction process. Alternatively, the weight matrix M t The weight matrix M t The key information that has been predicted in the current iteration process can be masked or reduced in weight, so that the HKBAM can focus on other key information or other more useful information in the user question in the next iteration process.
[0083] Further, the second vector Q_2 and the vector representation Emb_c of the plurality of second preset attributes of the plurality of preset constraints in the knowledge graph or knowledge base can be input into the KB-Attention network, and the KB-Attention network can calculate Q_5 according to Q_2 and Emb_c, Q_5 being the output of the KB-Attention network. In addition, Q_5 can be input into the MLP, and the MLP can calculate a third probability distribution ConsProp_prop of the plurality of second preset attributes according to Q_5.
[0084] Optionally, the attribute of the first type of constraint condition of the query request is the second preset attribute corresponding to the maximum probability in the third probability distribution.
[0085] For example, in the process of determining the attribute of the first type of constraint condition of the user question according to the third probability distribution ConsProp_prop, the HKBAM can determine the second preset attribute corresponding to the maximum probability in the third probability distribution ConsProp_prop as the attribute of the first type of constraint condition of the user question.
[0086] S402, determining the attribute value of the first type of constraint condition according to a fourth probability distribution of a plurality of preset constraint values, the preset constraint value being a preset constraint condition attribute value.
[0087] For example, the knowledge graph or knowledge base includes a plurality of preset constraint condition attribute values, which can be denoted as preset constraint values. The HKBAM can predict the probability of the attribute value of the first type of constraint condition corresponding to the user question for each preset constraint value in the knowledge graph or knowledge base, thereby obtaining a fourth probability distribution of the plurality of preset constraint values. Further, the HKBAM can determine the attribute value of the first type of constraint condition corresponding to the user question according to the fourth probability distribution.
[0088] Optionally, the attribute value of the first type of constraint condition is determined according to a fourth probability distribution of the plurality of preset constraint values, including: obtaining the fourth probability distribution of the plurality of preset constraint values according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of preset constraint values; and determining the attribute value of the first type of constraint condition according to the fourth probability distribution of the plurality of preset constraint values.
[0089] For example, in the case that Q_1 is not 0, Q_1 = Q_0, the HKBAM can obtain a fourth probability distribution of the plurality of preset constraint values according to the vector representation Q_0 of the normalized user question, the second probability distribution Property_prob, the vector representation Emb_p of the plurality of first preset attributes, i.e. the plurality of preset types of attributes, in the knowledge graph or knowledge base, and the vector representation Emb_v of the attribute values of the plurality of preset constraint conditions, i.e. the plurality of preset constraint values, in the knowledge graph or knowledge base. The fourth probability distribution can be denoted as ConsValue_prob. Further, the HKBAM can determine the attribute value of the first type of constraint condition of the user question according to the fourth probability distribution ConsValue_prob.
[0090] Optionally, the fourth probability distribution of the plurality of preset constraint values is obtained according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of preset constraint values, including: obtaining a first vector according to the plurality of first preset attributes and the second probability distribution; obtaining a second vector according to the normalized query request and the first vector; and obtaining the fourth probability distribution of the plurality of preset constraint values according to the second vector and the plurality of preset constraint values.
[0091] For example, in the case that Q_1 is not 0, Q_1 = Q_0, the HKBAM can obtain a fourth probability distribution of the plurality of preset constraint values according to the vector representation Q_0 of the normalized user question, the second probability distribution Property_prob, the vector representation Emb_p of the plurality of first preset attributes, i.e. the plurality of preset types of attributes, in the knowledge graph or knowledge base, and the vector representation Emb_v of the plurality of preset constraint values, i.e. the plurality of preset constraint values, in the knowledge graph or knowledge base. The fourth probability distribution can be denoted as ConsValue_prob. Further, the HKBAM can determine the attribute value of the first type of constraint condition of the user question according to the fourth probability distribution ConsValue_prob. Figure 3As shown, the HKBAM can perform a weighted sum of the plurality of first preset properties, i.e., the vector representation Emb_p of the plurality of preset types of properties, and the second probability distribution Property_prob, to obtain a first vector Emb_q. Further, in the case of Q_1 = Q_0, the vector representation Q_0 of the normalized user question and the first vector Emb_q can be input into the attention model 1, and the attention model 1 can obtain a second vector Q_2 according to Q_0 and Emb_q. The specific calculation process of the first vector Emb_q and the second vector Q_2 can refer to the above content, and will not be described here. Further, the second vector Q_2 and the vector representation Emb_v of the plurality of preset constraint values of the plurality of preset constraint conditions in the knowledge graph or knowledge base can be input into the KB-Attention network, and the output of the KB-Attention network can be input into the MLP. The MLP can calculate a fourth probability distribution ConsValue_prob of the plurality of preset constraint values according to the output of the KB-Attention network.
[0092] Optionally, the attribute value of the first type of constraint condition is a preset constraint value corresponding to the maximum probability in the fourth probability distribution.
[0093] For example, in the process of determining the attribute value of the first type of constraint condition of the user question according to the fourth probability distribution ConsValue_prob, the HKBAM can determine the preset constraint value corresponding to the maximum probability in the fourth probability distribution ConsValue_prob as the attribute value of the first type of constraint condition of the user question.
[0094] S403, determining the query result corresponding to the query request according to at least the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition.
[0095] For example, the HKBAM can determine the query result corresponding to the user question, i.e., the answer to the user question, according to at least the target entity corresponding to the user question, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition.
[0096] The embodiment detects whether the target entity corresponding to the user question is empty through the rejection gate mechanism. In the case that the target entity is empty, the non-entity can be prevented from being propagated backward, thereby reducing the interference of the non-entity in the user question, so as to improve the prediction robustness of the HKBAM. In addition, the key information that has been predicted in the user question is shielded (Masked) or weighted by the question updating mechanism, so that the HKBAM can focus on other key information or other more useful information in the user question in the subsequent prediction process. Alternatively, the key information that has been predicted in the current iteration process is shielded (Masked) or weighted, so that the HKBAM can focus on other key information or other more useful information in the user question in the next iteration process, which can improve the prediction accuracy of the HKBAM. In addition, the question updating mechanism is applied to the attribute prediction and constraint condition prediction link, so that the prediction of the attribute can better guide the prediction of the constraint condition, thereby improving the prediction accuracy. In addition, compared with the prior art of identifying the text type of the constraint condition by using the template, the embodiment of the disclosure identifies the text type of the constraint condition of the user question predicted by the HKBAM model, which has stronger generalization, thereby improving the coverage of the text type of the constraint condition, and helping to more accurately identify the user's generalized question.
[0097] For example, the prior art uses a template to identify the text type of the constraint condition, which results in that the identification of the constraint condition does not have generalization. For example, the user question is "Can I declare individual income tax deduction if I live with my grandfather?", and the constraint condition of the user question is "supporting the elderly". However, since the user is not clear, the template cannot accurately identify the constraint condition of the user question. However, the rejection gate mechanism and the question updating mechanism in the HKBAM of the embodiment of the disclosure can improve the robustness and accuracy of the prediction of the HKBAM, so that the HKBAM has the generalization identification ability of the constraint condition, and has a higher coverage than the traditional pre-defined template.
[0098] It can be understood that the process of predicting the target entity, the type of the target entity, the attribute of the type of the target entity, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition corresponding to the user question by the HKBAM as described above can be a prediction process or a use process of the HKBAM. Before the prediction process or the use process of the HKBAM, the HKBAM also has a training process or a training stage. The following will be described in combination with Figure 3 The training process or training stage of the HKBAM is introduced. Specifically, the KBA, the MLP, the attention model 1, the attention model 2, the multi-layer perceptron, and the normalization layer (MLP&NormLayer) shown in the figure are trained. Figure 3 The training process or training stage of the HKBAM is introduced. Specifically, the KBA, the MLP, the attention model 1, the attention model 2, the multi-layer perceptron, and the normalization layer (MLP&NormLayer) shown in the figure are trained.
[0099] In the training stage, the input of the HKBAM can be a sample question, which can refer to the user question described above, and will not be described here. In addition, each sample question can correspond to a correct annotation result. For example, the annotation result of a certain sample question includes the entity corresponding to the sample question, the attribute of the type to which the entity belongs, the attribute of the constraint condition, and the attribute value of the constraint condition. Further, the HKBAM can obtain the first probability distribution Entity_prob, the second probability distribution Property_prob, the third probability distribution ConsProp_prop, and the fourth probability distribution ConsValue_prob according to the sample question. The HKBAM can predict the entity corresponding to the sample question, the attribute of the type to which the entity belongs, the attribute of the constraint condition, and the attribute value of the constraint condition according to the four probability distributions. Further, the HKBAM can calculate a loss function according to the entity corresponding to the sample question, the attribute of the type to which the entity belongs, the attribute of the constraint condition, and the attribute value of the constraint condition predicted by it, and the annotation result of the sample question. The parameters in the HKBAM are adjusted according to the loss function. The final parameters in the HKBAM are determined through continuous iteration, thereby completing the training of the HKBAM.
[0100] Specifically, the HKBAM can use a focal loss function (Focal loss) for multi-task training. As shown in Figure 3 , Ye represents the first probability distribution Entity_prob obtained when the input of the HKBAM is a sample question, Yp represents the second probability distribution Property_prob obtained when the input of the HKBAM is a sample question, Ycp represents the third probability distribution ConsProp_prop obtained when the input of the HKBAM is a sample question, and Ycv represents the fourth probability distribution ConsValue_prob obtained when the input of the HKBAM is a sample question.
[0101] The HKBAM can use the focal loss function 1 to calculate the function value of Ye, Yp, Ycp, Ycv, and the annotation result of the sample question, as shown in Figure 3 . The function value is denoted as Loss_focal value. The Loss_focal value can be the output of the focal loss function 1, as shown in Figure 3 .
[0102] As shown in Figure 3As shown, Q_2 and Q_5 can be used as inputs to attention recognition model 2. Attention recognition model 2 can use a query update mechanism, similar to attention model 1, to calculate vector Q_3 from Q_2 and Q_5. Vector Q_3 can be used as input to a multilayer perceptron and a normalization layer. The multilayer perceptron and normalization layer can map vector Q_3 to vector Q_4, where Q_4 is the sum of the dimensions of Ye, Yp, Ycp, and Ycv. For example, the multilayer perceptron and normalization layer can output Q_4. Furthermore, HKBAM can divide Q_4 into four segments based on the dimensions of Ye, Yp, Ycp, and Ycv, with the dimensions of these four segments being the same as the dimensions of Ye, Yp, Ycp, and Ycv, respectively. Furthermore, these four segments, along with Ye, Yp, Ycp, and Ycv, can be used as inputs to the KL divergence function (KL Div Loss). The KL divergence function can be used to calculate the KL divergence based on these four segments, Ye, Yp, Ycp, and Ycv. This KL divergence can be denoted as Loss_kl. In other words, Loss_kl can be... Figure 3 The output of the KL divergence function is shown. KL divergence (KL distance or relative entropy) is also known as KL divergence.
[0103] In addition, the four segments obtained after segmenting Q_4 as described above, and the annotation results of the sample questions, can be used as... Figure 3 The input to the focus loss function 2 is used. The focus loss function 2 calculates Loss_sp based on the annotation results of the four segments and the sample questions; that is, Loss_sp is the output of the focus loss function 2. Finally, for example... Figure 5 The outputs Loss_focal of the focal loss function 1, Loss_kl of the KL divergence function, and Loss_sp of the focal loss function 2 are summed together to perform multi-task training on HKBAM.
[0104] In other embodiments, the focus loss function can also be replaced by a weighted loss function, ordinary cross-entropy, least squares, etc.
[0105] Understandably, during the training phase of HKBAM, the focus loss function 1, KL divergence function, and focus loss function 2 are involved in the calculation.
[0106] In the prediction stage or use stage of the HKBAM, the focus loss function 1, the KL divergence function, and the focus loss function 2 do not participate in the calculation. In the prediction stage or use stage of the HKBAM, the input of the HKBAM is a user question, and the output is a target entity corresponding to the user question, a type to which the target entity belongs, an attribute of the type to which the target entity belongs, an attribute of a first type of constraint condition, and an attribute value of the first type of constraint condition.
[0107] For example, in the prediction stage or use stage of the HKBAM, the user question is “What insurance can my 15-year-old daughter be insured for?” as described above. The recognition result of the HKBAM is shown as 50. Figure 6 For example, the HKBAM can output that the target entity of the user question is “health insurance”. The attribute of the type to which the target entity belongs is “insurance introduction”. The attributes of the text type constraint condition are “insured age interval” and “insured gender”. The attribute values of the text type constraint condition are “15 years old” and “female”.
[0108] In addition, the target entity corresponding to the user question, the attribute of the type to which the target entity belongs, the attribute of the text type constraint condition, and the attribute value of the text type constraint condition output by the HKBAM can also be output to a KBQA question and answer process. The KBQA question and answer process is specifically shown as Figure 6 As shown in Figure 6 The process includes the following steps:
[0109] S601, input a user question.
[0110] S602, sentence recognition.
[0111] Specifically, the sentence recognition can recognize the sentence pattern of the user question. For example, the common sentence patterns include general sentences, comparison sentences, parallel sentences, judgment sentences, etc. For example, the TextCNN (Convolutional Neural Networks) model can be used for sentence recognition in this embodiment.
[0112] S603, entity recognition.
[0113] Specifically, the entity recognition can perform entity linking between the entity in the user question and the knowledge graph or knowledge base.
[0114] S604, entity prediction.
[0115] For example, Figure 7 The semantic analysis module shown in
[0116] For example, S603 and S604 can be executed in parallel. Alternatively, S603 is executed first and S604 is executed later. Specifically, if an entity in the user question can be identified through S603, the subsequent steps adopt the entity identified by S603. If an entity in the user question cannot be identified through S603, the entity in the user question is predicted by S604, for example, the preset entity corresponding to the maximum probability in Entity_prob is taken as the result of entity prediction.
[0117] S605, determining whether the entity corresponding to the user question exists. If yes, S607 is executed, otherwise S606 is executed.
[0118] S606, rejecting to identify the user question.
[0119] S607, attribute prediction of the type to which the entity belongs.
[0120] For example, the first preset attribute corresponding to the maximum probability in the second probability distribution Property_prob in HKBAM is taken as the attribute of the type to which the entity corresponding to the user question belongs.
[0121] S608, determining whether the attribute score is greater than a threshold. If yes, S610 is executed, otherwise S609 is executed.
[0122] S609, rejecting to identify the user question
[0123] S610, text type constraint condition identification.
[0124] For example, the second preset attribute corresponding to the maximum probability in the third probability distribution ConsProp_prop in HKBAM is taken as the attribute of the text type constraint condition corresponding to the user question. The preset constraint value corresponding to the maximum probability in the fourth probability distribution ConsValue_prob in HKBAM is taken as the attribute value of the text type constraint condition corresponding to the user question.
[0125] S611, numerical type constraint condition identification.
[0126] For example, the regular expression corresponding to each attribute is used to supplement the identification of the attribute and the attribute value of the numerical type constraint condition corresponding to the user question. That is, the text type constraint condition corresponding to the user question is predicted or identified by HKBAM. The numerical type constraint condition corresponding to the user question is identified by the preset template.
[0127] S612, sorting multiple combinations.
[0128] For example, according to the entity corresponding to the user question, the attribute of the type to which the entity belongs, the attribute of the text type constraint condition, the attribute value of the text type constraint condition, the attribute of the numerical value type constraint condition and the attribute value of the numerical value type constraint condition, a Lambda-MART sorting algorithm is used to sort multiple combinations.
[0129] S613, generating a query statement.
[0130] According to the sorting result, a query statement can be generated, which can be a SPARQL (SPARQL Protocol and RDF Query Language) query statement.
[0131] S614, judging whether the predicted entity is empty. If yes, S615 is performed, otherwise S616 is performed.
[0132] S615, asking the user for the target entity.
[0133] S616, judging whether the identified constraint condition is empty. If yes, S617 is performed, otherwise S618 is performed.
[0134] S617, asking the user for the target constraint condition.
[0135] S618, obtaining a query result according to the query statement.
[0136] For example, a knowledge query is performed according to the SPARQL query statement, so as to obtain a query result.
[0137] In this embodiment, by embedding the HKBAM into the KBQA question and answer process, the entity recognition ability of the KBQA question and answer process for the user question and the generalization recognition ability of the constraint condition can be improved, so as to improve the question and answer accuracy of the KBQA question and answer process.
[0138] Figure 6 A query processing method flowchart is provided for another embodiment of the present disclosure. In this embodiment, at least according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition and the attribute value of the first type of constraint condition, a query result corresponding to the query request is determined, including the following steps:
[0139] S701, according to a preset template, identifying the attribute of the second type of constraint condition in the query request and the attribute value of the second type of constraint condition.
[0140] For example, the query request is a user question. The second type of constraint condition can be a numerical value type constraint condition as described above, which includes an attribute and an attribute value.
[0141] S702, determine the query result corresponding to the query request according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition.
[0142] For example, the query result corresponding to the user question can be determined according to the target entity predicted by the HKBAM, the attribute of the type to which the target entity belongs, the attribute of the text type constraint condition, the attribute value of the text type constraint condition, and the attribute and attribute value of the numerical type constraint condition of the user question corresponding to the numerical type constraint condition identified according to the preset template.
[0143] Optionally, the determination of the query result corresponding to the query request according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition comprises: obtaining a first combination according to the target entity and the attribute of the type to which the target entity belongs; obtaining a second combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition; obtaining a third combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition; obtaining a fourth combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition; determining a target combination from the first combination, the second combination, the third combination, and the fourth combination; and determining the query result according to the target combination.
[0144] For example, the target entity corresponding to the user question and the attribute of the type to which the target entity belongs can be taken as the first combination; the target entity, the attribute of the type to which the target entity belongs, the attribute of the text type constraint condition, and the attribute value of the text type constraint condition can be taken as the second combination; the target entity, the attribute of the type to which the target entity belongs, the attribute of the numerical type constraint condition, and the attribute value of the numerical type constraint condition can be taken as the third combination; and the target entity, the attribute of the type to which the target entity belongs, the attribute of the text type constraint condition, the attribute value of the text type constraint condition, the attribute of the numerical type constraint condition, and the attribute value of the numerical type constraint condition can be taken as the fourth combination. Figure 6 As shown in S612, the first combination, the second combination, the third combination, and the fourth combination can be sorted, so as to determine the target combination in the first combination, the second combination, the third combination, and the fourth combination. Further, the query result of the user question can be determined according to the target combination.
[0145] Optionally, determining the target combination from the first combination, the second combination, the third combination, and the fourth combination includes: sorting the first combination, the second combination, the third combination, and the fourth combination to obtain a sorting result; and determining the target combination based on the sorting result.
[0146] For example, the first, second, third, and fourth combinations can be scored separately, and then ranked according to their respective scores. For instance, the combinations can be ranked from highest to lowest score, and the combination with the highest score in that ranking can be selected as the target combination.
[0147] Optionally, determining the query result based on the target combination includes: determining a query statement based on the target combination; and performing a query based on the query statement to obtain the query result.
[0148] For example, the target combination consists of the target entity, the attribute of the target entity's type, the attribute of the text constraint, and the attribute value of the text constraint. Further, the target entity, the attribute of the target entity's type, the attribute of the text constraint, and the attribute value of the text constraint are concatenated to obtain the SPARQL query statement. Finally, a knowledge query is performed based on the SPARQL query statement to obtain the query results.
[0149] Optionally, determining the query statement based on the target combination includes: if the target entity in the target combination is empty, querying the user for the target entity; and determining the query statement based on the target combination and the target entity provided by the user.
[0150] For example, in some embodiments, such as Figure 8 The entity prediction shown may fail to predict the target entity in the user's question, but instead predicts the type of the target entity corresponding to the user's question. In this case, the target entity in the target combination may be empty. To improve the accuracy of user question recognition, the KBQA question answering device or KBQA question answering engine can ask the user for the target entity. For example, if the user's question is "How to deduct taxes", the KBQA question answering device or KBQA question answering engine can further ask the user, "Do you want to ask about personal income tax or value-added tax?" Furthermore, the KBQA question answering device or KBQA question answering engine can determine the SPARQL query statement based on the target entity in the user's reply and the target combination.
[0151] Optionally, the query statement is determined according to the target combination, including: in a case where the target combination does not include at least one of the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition, asking the user for a target constraint condition; and determining the query statement according to the target combination and the target constraint condition.
[0152] For example, in a case where the target combination does not include a text type constraint condition and does not include a numerical value type constraint condition, the KBQA question answering device or the KBQA question answering engine can ask the user for a target constraint condition. Further, the KBQA question answering device or the KBQA question answering engine can determine a SPARQL query statement according to the target constraint condition replied by the user and the target combination.
[0153] The embodiment can effectively improve the recognition accuracy of the user question by asking the user for the target entity in a case where the target entity in the target combination is empty, and / or asking the user for a target constraint condition in a case where the target combination does not include a constraint condition, thereby improving the accuracy of intelligent question answering.
[0154] As shown in Figure 9 The test result comparison diagram of the intelligent question answering system using the HKBAM of the embodiment compared with the question answering system using other models, for example, a multi-constraint graph model (MultiCG). The accuracy of the question answering system using the multi-constraint graph model is only 46.31%, while the accuracy of the intelligent question answering system using the HKBAM alone can be as high as 84.60%. On the basis of the HKBAM, further increasing the StructBERT can make the accuracy of the intelligent question answering system as high as 86.15%. On the basis of the HKBAM, further increasing the StructBERT, the rejection gate mechanism, and the question updating mechanism can further improve the accuracy of the intelligent question answering system, for example, up to 88.70%. As can be seen, the accuracy (Accuracy, Acc) of the intelligent question answering system using the HKBAM is higher than that of the question answering system using other models. In addition, on the basis of the HKBAM, increasing the StructBERT, or increasing the StructBERT, the rejection gate mechanism, and the question updating mechanism can continuously improve the accuracy of the intelligent question answering system.
[0155] Figure 9 The structural schematic diagram of the query processing device provided by the embodiment of the present disclosure. The query processing device provided by the embodiment of the present disclosure can execute the processing flow provided by the query processing method embodiment, as shown in Figure 9 The query processing device 90 includes:
[0156] The acquisition module 91 is configured to acquire a query request of a user.
[0157] The determination module 92 is configured to determine a target entity corresponding to the query request according to a first probability distribution of a plurality of preset entities, determine an attribute of a type to which the target entity belongs according to a second probability distribution of a plurality of first preset attributes, the first preset attribute being an attribute of a type to which a preset entity belongs, and determine a query result corresponding to the query request according to at least the target entity and the attribute of the type to which the target entity belongs.
[0158] Optionally, the determination module 92 is specifically configured to:
[0159] determine an attribute of a first type of constraint condition of the query request according to a third probability distribution of a plurality of second preset attributes, the second preset attribute being an attribute of a preset constraint condition;
[0160] determine an attribute value of the first type of constraint condition according to a fourth probability distribution of a plurality of preset constraint values, the preset constraint value being an attribute value of a preset constraint condition;
[0161] determine the query result corresponding to the query request according to at least the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition.
[0162] Optionally, the determination module 92 is specifically configured to:
[0163] obtain the first probability distribution of the plurality of preset entities according to the query request and the plurality of preset entities;
[0164] determine the target entity corresponding to the query request according to the first probability distribution of the plurality of preset entities.
[0165] Optionally, the target entity is a preset entity corresponding to a maximum probability in the first probability distribution of the plurality of preset entities.
[0166] Optionally, the determination module 92 is specifically configured to:
[0167] obtain the second probability distribution of the plurality of first preset attributes according to the query request and the plurality of first preset attributes;
[0168] determine the attribute of the type to which the target entity belongs according to the second probability distribution of the plurality of first preset attributes.
[0169] Optionally, the determination module 92 is specifically configured to:
[0170] perform normalization processing on the query request to obtain a normalized query request;
[0171] In a case where the preset entity corresponding to the maximum probability in the first probability distribution is not empty, a second probability distribution of the plurality of first preset attributes is obtained according to the normalized query request and the plurality of first preset attributes.
[0172] Optionally, the attribute of the type to which the target entity belongs is a first preset attribute corresponding to the maximum probability in the second probability distribution.
[0173] Optionally, the determining module 92 is specifically configured to:
[0174] A third probability distribution of the plurality of second preset attributes is obtained according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of second preset attributes.
[0175] An attribute of the first type of constraint condition of the query request is determined according to the third probability distribution of the plurality of second preset attributes.
[0176] Optionally, the determining module 92 is specifically configured to:
[0177] A first vector is obtained according to the plurality of first preset attributes and the second probability distribution.
[0178] A second vector is obtained according to the normalized query request and the first vector.
[0179] The third probability distribution of the plurality of second preset attributes is obtained according to the second vector and the plurality of second preset attributes.
[0180] Optionally, the attribute of the first type of constraint condition of the query request is a second preset attribute corresponding to the maximum probability in the third probability distribution.
[0181] Optionally, the determining module 92 is specifically configured to:
[0182] A fourth probability distribution of the plurality of preset constraint values is obtained according to the query request, the second probability distribution, the plurality of first preset attributes and the plurality of preset constraint values.
[0183] An attribute value of the first type of constraint condition is determined according to the fourth probability distribution of the plurality of preset constraint values.
[0184] Optionally, the determining module 92 is specifically configured to:
[0185] A first vector is obtained according to the plurality of first preset attributes and the second probability distribution.
[0186] A second vector is obtained according to the normalized query request and the first vector.
[0187] According to the second vector and the plurality of preset constraint values, a fourth probability distribution of the plurality of preset constraint values is obtained.
[0188] Optionally, the attribute value of the first type of constraint condition is a preset constraint value corresponding to a maximum probability in the fourth probability distribution.
[0189] Optionally, the determining module 92 is specifically configured to: obtain the first vector according to each first preset attribute in the plurality of first preset attributes and a probability corresponding to each first preset attribute in the second probability distribution.
[0190] Optionally, the apparatus 90 further includes a splicing module 93 configured to splice the third vector corresponding to the query request after normalization processing and the first vector to obtain a spliced vector; and the determining module 92 is specifically configured to: obtain the second vector according to a preset weight matrix and the spliced vector.
[0191] Optionally, the apparatus 90 further includes an identifying module 94 configured to identify an attribute of a second type of constraint condition and an attribute value of the second type of constraint condition in the query request according to a preset template; and the determining module 92 is specifically configured to: determine the query result corresponding to the query request according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition.
[0192] Optionally, the determining module 92 is specifically configured to:
[0193] obtain a first combination according to the target entity and the attribute of the type to which the target entity belongs;
[0194] obtain a second combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, and the attribute value of the first type of constraint condition;
[0195] obtain a third combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition;
[0196] obtain a fourth combination according to the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint condition, the attribute value of the first type of constraint condition, the attribute of the second type of constraint condition, and the attribute value of the second type of constraint condition;
[0197] determine a target combination from the first combination, the second combination, the third combination, and the fourth combination;
[0198] determine the query result according to the target combination.
[0199] Optionally, the apparatus 90 further comprises a sorting module 95 configured to sort the first combination, the second combination, the third combination and the fourth combination to obtain a sorting result; and the determining module 92 is specifically configured to determine the target combination according to the sorting result.
[0200] Optionally, the determining module 92 is specifically configured to determine a query statement according to the target combination; and the apparatus 90 further comprises a querying module 96 configured to query according to the query statement to obtain the query result.
[0201] Optionally, the determining module 92 is specifically configured to:
[0202] inquire the target entity from the user in a case where the target entity in the target combination is empty;
[0203] determine the query statement according to the target combination and the target entity fed back by the user.
[0204] Optionally, the determining module 92 is specifically configured to:
[0205] inquire a target constraint condition from the user in a case where the target combination does not include at least one of an attribute of the first type of constraint condition, an attribute value of the first type of constraint condition, an attribute of the second type of constraint condition and an attribute value of the second type of constraint condition;
[0206] determine the query statement according to the target combination and the target constraint condition.
[0207] Figure 10 The query processing apparatus of the embodiments can be used to execute the technical solutions of the method embodiments, and the implementation principles and technical effects are similar, which will not be described here.
[0208] The internal functions and structures of the query processing apparatus are described above, and the apparatus can be implemented as an electronic device. Figure 10 As shown in the structural schematic diagram of the electronic device provided by the embodiments of the present disclosure, Figure 10 The electronic device comprises a memory 1001 and a processor 1002.
[0209] The memory 1001 is configured to store programs. In addition to the above programs, the memory 1001 can also be configured to store various data to support the operation on the electronic device. Examples of these data include instructions of any application program or method for operating on the electronic device, contact data, phonebook data, messages, pictures, videos, etc.
[0210] The memory 1001 can be implemented by any type of volatile or nonvolatile memory devices 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, magnetic disk or optical disk.
[0211] The processor 1002, coupled with the memory 1001, executes programs stored in the memory 1001, for:
[0212] obtaining a query request of a user;
[0213] determining a target entity corresponding to the query request according to a first probability distribution of a plurality of preset entities;
[0214] determining an attribute of a type to which the target entity belongs according to a second probability distribution of a plurality of first preset attributes, the first preset attribute being an attribute of a type to which a preset entity belongs;
[0215] determining a query result corresponding to the query request according to at least the target entity and the attribute of the type to which the target entity belongs.
[0216] Further, as shown in Figure 10 , the electronic device can further include a communication component 1003, a power supply component 1004, an audio component 1005, a display 1006, and other components. Figure 10 Some components are only schematically shown in the electronic device, and it does not mean that the electronic device only includes the components shown.
[0217] The communication component 1003 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an example embodiment, the communication component 1003 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an example embodiment, the communication component 1003 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0218] The power supply component 1004 provides power for various components of the electronic device. The power supply component 1004 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device.
[0219] The audio component 1005 is configured to output and / or input audio signals. For example, the audio component 1005 includes a microphone (MIC) configured to receive external audio signals when the electronic device is in an operation mode such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 1001 or transmitted via the communication component 1003. In some embodiments, the audio component 1005 also includes a speaker configured to output audio signals.
[0220] The display 1006 includes a screen, which can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes the touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and pressure related to the touching or sliding action.
[0221] In addition, the embodiments of the present disclosure further provide a computer readable storage medium, having stored thereon a computer program, the computer program being executed by a processor to implement the query processing method described in the above embodiments.
[0222] It should be noted that, in this document, relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. In addition, the terms "includes", "including", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus.
[0223] The above descriptions are only specific embodiments of the present disclosure to enable those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A query processing method, wherein, The method includes: Get the user's query request; The target entity corresponding to the query request is determined based on a first probability distribution of multiple preset entities; The attribute to which the target entity belongs is determined based on a second probability distribution of multiple first preset attributes, wherein the first preset attributes are attributes of the preset entity type; The query result corresponding to the query request is determined based at least on the attributes of the target entity and the type to which the target entity belongs; The method further includes: determining a first probability distribution of the plurality of preset entities based on the vector representation of the query request and the vector representation of the plurality of preset entities, wherein the first probability distribution is used to indicate the probability that the target entity corresponding to the query request is each of the plurality of preset entities.
2. The method according to claim 1, characterized in that, The query result corresponding to the query request is determined at least based on the attributes of the target entity and the type to which the target entity belongs, including: The attributes of the first type of constraint of the query request are determined based on the third probability distribution of multiple second preset attributes, wherein the second preset attributes are attributes of preset constraint conditions. The attribute values of the first type of constraint are determined based on a fourth probability distribution of multiple preset constraint values, wherein the preset constraint values are attribute values of the preset constraint conditions. The query result corresponding to the query request is determined based at least on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, and the attribute value of the first type of constraint.
3. The method according to claim 1, characterized in that, Determining the target entity corresponding to the query request based on a first probability distribution of multiple preset entities includes: Based on the query request and the multiple preset entities, a first probability distribution of the multiple preset entities is obtained; The target entity corresponding to the query request is determined based on the first probability distribution of the plurality of preset entities.
4. The method according to claim 1 or 3, characterized in that, The target entity is the preset entity with the highest probability in the first probability distribution of the plurality of preset entities.
5. The method according to claim 1, characterized in that, The attribute that determines the type of the target entity based on a second probability distribution of multiple first preset attributes includes: Based on the query request and multiple first preset attributes, a second probability distribution of the multiple first preset attributes is obtained; The attribute to which the target entity belongs is determined based on the second probability distribution of the plurality of first preset attributes.
6. The method according to claim 5, characterized in that, Based on the query request and multiple first preset attributes, a second probability distribution of the multiple first preset attributes is obtained, including: The query request is normalized to obtain a normalized query request; If the preset entity corresponding to the highest probability in the first probability distribution is not empty, a second probability distribution of the multiple first preset attributes is obtained based on the normalized query request and the multiple first preset attributes.
7. The method according to claim 1, 5, or 6, characterized in that, The attribute of the type to which the target entity belongs is the first preset attribute corresponding to the highest probability in the second probability distribution.
8. The method according to claim 2, characterized in that, The attributes of the first type of constraint of the query request are determined based on a third probability distribution of multiple second preset attributes, including: Based on the query request, the second probability distribution, the plurality of first preset attributes, and the plurality of second preset attributes, a third probability distribution of the plurality of second preset attributes is obtained; The attributes of the first type of constraint condition of the query request are determined based on the third probability distribution of the plurality of second preset attributes.
9. The method according to claim 8, characterized in that, The third probability distribution of the plurality of second preset attributes is obtained based on the query request, the second probability distribution, the plurality of first preset attributes, and the plurality of second preset attributes, including: Based on the plurality of first preset attributes and the second probability distribution, a first vector is obtained; Based on the normalized query request and the first vector, a second vector is obtained; The third probability distribution of the plurality of second preset attributes is obtained based on the second vector and the plurality of second preset attributes.
10. The method according to claim 2, 8 or 9, characterized in that, The attribute of the first type of constraint in the query request is the second preset attribute corresponding to the maximum probability in the third probability distribution.
11. The method according to claim 2, characterized in that, The attribute values of the first type of constraint are determined based on a fourth probability distribution of multiple preset constraint values, including: Based on the query request, the second probability distribution, the plurality of first preset attributes, and the plurality of preset constraint values, a fourth probability distribution of the plurality of preset constraint values is obtained; The attribute value of the first type of constraint is determined based on the fourth probability distribution of the multiple preset constraint values.
12. The method according to claim 11, characterized in that, Based on the query request, the second probability distribution, the plurality of first preset attributes, and the plurality of preset constraint values, a fourth probability distribution of the plurality of preset constraint values is obtained, including: Based on the plurality of first preset attributes and the second probability distribution, a first vector is obtained; Based on the normalized query request and the first vector, a second vector is obtained; The fourth probability distribution of the multiple preset constraint values is obtained based on the second vector and the multiple preset constraint values.
13. The method according to claim 2, 11, or 12, characterized in that, The attribute value of the first type of constraint is the preset constraint value corresponding to the maximum probability in the fourth probability distribution.
14. The method according to claim 9 or 12, characterized in that, Based on the plurality of first preset attributes and the second probability distribution, a first vector is obtained, including: The first vector is obtained based on each of the plurality of first preset attributes and the probability of each first preset attribute in the second probability distribution.
15. The method according to claim 9 or 12, characterized in that, Based on the normalized query request and the first vector, a second vector is obtained, including: The third vector corresponding to the normalized query request is concatenated with the first vector to obtain the concatenated vector; The second vector is obtained based on the preset weight matrix and the concatenated vector.
16. The method according to claim 2, characterized in that, The query result corresponding to the query request is determined based at least on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, and the attribute value of the first type of constraint, including: The attributes and attribute values of the second type of constraint in the query request are identified according to the preset template. The query result corresponding to the query request is determined based on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, the attribute value of the first type of constraint, the attribute of the second type of constraint, and the attribute value of the second type of constraint.
17. The method according to claim 16, characterized in that, Based on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, the attribute value of the first type of constraint, the attribute of the second type of constraint, and the attribute value of the second type of constraint, the query result corresponding to the query request is determined, including: A first combination is obtained based on the target entity and the type to which the target entity belongs; A second combination is obtained based on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, and the attribute value of the first type of constraint; A third combination is obtained based on the target entity, the attribute of the type to which the target entity belongs, the attribute of the second type of constraint, and the attribute value of the second type of constraint; A fourth combination is obtained based on the target entity, the attribute of the type to which the target entity belongs, the attribute of the first type of constraint, the attribute value of the first type of constraint, the attribute of the second type of constraint, and the attribute value of the second type of constraint. A target combination is determined from the first combination, the second combination, the third combination, and the fourth combination; The query results are determined based on the target combination.
18. The method according to claim 17, characterized in that, Determining the target combination from the first combination, the second combination, the third combination, and the fourth combination includes: The first combination, the second combination, the third combination, and the fourth combination are sorted to obtain the sorting result; The target combination is determined based on the sorting results.
19. The method according to claim 17, characterized in that, Determining the query results based on the target combination includes: The query statement is determined based on the target combination; The query results are obtained by performing the query based on the query statement.
20. The method according to claim 19, characterized in that, The query statement is determined based on the target combination, including: If the target entity in the target combination is empty, the user is asked to provide the target entity. The query statement is determined based on the target combination and the target entity provided by the user.
21. The method according to claim 19, characterized in that, The query statement is determined based on the target combination, including: If the target combination does not include at least one of the attributes of the first type of constraint, the attribute value of the first type of constraint, the attribute of the second type of constraint, and the attribute value of the second type of constraint, the user is queried for the target constraint. The query statement is determined based on the target combination and the target constraints.
22. A query processing device, characterized in that, include: The retrieval module is used to retrieve user query requests; The determination module is configured to determine the target entity corresponding to the query request based on a first probability distribution of multiple preset entities; determine the attribute of the type to which the target entity belongs based on a second probability distribution of multiple first preset attributes, wherein the first preset attributes are attributes of the type to which the preset entities belong; and determine the query result corresponding to the query request based at least on the target entity and the attribute of the type to which the target entity belongs. The device is further configured to: determine the first probability distribution of the plurality of preset entities based on the vector representation of the query request and the vector representation of the plurality of preset entities, wherein the first probability distribution is used to indicate the probability that the target entity corresponding to the query request is each of the plurality of preset entities.
23. An electronic device, wherein, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-21.
24. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-21.
Citation Information
Patent Citations
Automatic question and answer method, device and equipment and storage medium
CN112328759A