Query processing method and device and electronic equipment
By determining the similarity between the query request and the candidate intention and selecting the message, the target intention of the intention to be clarified is determined, which solves the problem of intention inconsistency caused by inaccurate user input and improves the accuracy of the response results of query processing.
Patent Information
- Application Number
- CN202410942656.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-18
AI Technical Summary
When the query request input by the user is inaccurate, the predicted user intention is inconsistent with the actual intention, resulting in the reply result being inconsistent with the user's needs. How to improve the accuracy of the reply result becomes a problem.
By determining the similarity between the query request and the candidate intent, the intent to be clarified is output, and the target intent is determined based on the selected message, and finally the corresponding reply result is generated.
When the clear intention cannot be determined, by outputting the intention to be clarified and obtaining the target intention, the answer result of the query request can be obtained more accurately, which improves the accuracy of the answer result.
Smart Images

Figure CN118797006A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to technical fields such as natural language processing and deep learning. Background Art
[0002] In the field of natural language processing, when the query request input by the user is not accurate, the user intention predicted based on the query request input by the user is often inconsistent with the user's actual intention, resulting in the query request response output based on the predicted user intention being inconsistent with the user's actual needs. How to improve the accuracy of the response results when the query request input by the user is not accurate becomes a problem to be solved. Summary of the invention
[0003] The present disclosure provides a query processing method, device, electronic device and storage medium.
[0004] According to one aspect of the present disclosure, a query processing method is provided, comprising:
[0005] In a case where it is determined based on the query request that there is at least one first candidate intent, obtaining a similarity between the at least one first candidate intent and the query request;
[0006] In a case where it is determined that there is at least one intent to be clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request, outputting the at least one intent to be clarified;
[0007] In response to obtaining a selection message, determining a target intent in the at least one intent to be clarified based on the selection message;
[0008] Based on the target intent, a response result corresponding to the query request is output.
[0009] According to another aspect of the present disclosure, a query processing device is provided, comprising:
[0010] A similarity acquisition module, configured to acquire a similarity between the at least one first candidate intent and the query request when it is determined that there is at least one first candidate intent based on the query request;
[0011] an intent-to-be-clarified output module, configured to output the at least one intent-to-be-clarified if it is determined that there is at least one intent-to-be-clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request;
[0012] a target intent determination module, configured to, in response to obtaining a selected message, determine a target intent in the at least one intent to be clarified based on the selected message;
[0013] The reply result output module is used to output the reply result corresponding to the query request based on the target intent.
[0014] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any embodiment of the present disclosure.
[0018] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to any embodiment of the present disclosure.
[0019] According to another aspect of the present disclosure, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method according to any one of the embodiments of the present disclosure is implemented.
[0020] By adopting the above implementation, when it is determined based on the query request that there is at least one intent to be clarified in at least one first candidate intent, the target intent in at least one intent to be clarified can be determined based on the selection message, and finally the reply result corresponding to the query request can be obtained according to the target intent. In this way, when a clear intent cannot be determined based on the query request, the target intent of the query request can be determined by outputting the intent to be clarified and obtaining the selection message for selecting the target intent, and then the reply result corresponding to the query request can be obtained more accurately according to the target intent.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0023] Figure 1 is a flowchart of a query processing method according to an embodiment of the present disclosure;
[0024] Figure 2 is a flowchart of a query processing method according to another embodiment of the present disclosure;
[0025] Figure 3 is a schematic block diagram of a query processing device according to an embodiment of the present disclosure;
[0026] Figure 4 is a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0028] Figure 1 is a schematic flow chart of a query processing method proposed in an embodiment of the present disclosure, comprising:
[0029] S110, when it is determined that there is at least one first candidate intent based on the query request, obtaining a similarity between the at least one first candidate intent and the query request;
[0030] S120, when it is determined that there is at least one intent to be clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request, output the at least one intent to be clarified;
[0031] S130, in response to obtaining a selected message, determining a target intent in the at least one intent to be clarified based on the selected message;
[0032] S140: Based on the target intent, output a response result corresponding to the query request.
[0033] The query processing method of the disclosed embodiment can be executed by an electronic device. The electronic device can be a terminal or a server. Exemplarily, the electronic device can be a terminal device with computing capabilities. Exemplarily, the first electronic device can be a server in the cloud; the server can be a single server, or can be at least one server in a server cluster, or can be a server in a distributed system (or can be called a computing node). It should be understood that the above is only an exemplary description of an electronic device, and the actual processing may not be limited to the devices mentioned in the above examples. As long as the electronic device can execute the query processing method provided in this embodiment, it is within the protection scope of this embodiment.
[0034] By adopting the above implementation, when it is determined based on the query request that there is at least one intent to be clarified in at least one first candidate intent, the target intent in at least one intent to be clarified can be determined based on the selection message, and finally the reply result corresponding to the query request can be obtained according to the target intent. In this way, when a clear intent cannot be determined based on the query request, the target intent of the query request can be determined by outputting the intent to be clarified and obtaining the selection message for selecting the target intent, and then the reply result corresponding to the query request can be obtained more accurately according to the target intent.
[0035] In some possible implementations, when it is determined based on the query request that there is at least one first candidate intention, obtaining the similarity between the at least one first candidate intention and the query request includes: when at least one matching intention is determined from the semantic library based on the query request, taking the at least one matching intention as the at least one first candidate intention; and obtaining the similarity between the at least one first candidate intention and the query request.
[0036] The query request may be input by a user. Specifically, the query request may be obtained by: displaying an interactive interface; in response to obtaining content input by a user in an input area of the interactive interface, obtaining the query request based on the content input by the user.
[0037] The interactive interface may be an interactive interface of a target application, and the target application may at least be capable of executing the query processing method provided in this embodiment. For example, the target application may be a target artificial intelligence application.
[0038] The content input by the user may include one of the following: a picture input by the user, a voice input by the user, text information input by the user, etc. Obtaining the query request based on the content input by the user may include one of the following: if the content input by the user is a picture input by the user, using the picture as the query request; if the content input by the user is a voice input by the user, using the voice as the query request; if the content input by the user is text information input by the user, using the text information as the query request.
[0039] After obtaining a query request and when at least one matching intent is determined from the semantic library based on the query request, before taking the at least one matching intent as the at least one first candidate intent, the processing that can be performed includes: determining whether there is a target keyword matching the query request in the keyword library; when there is a target keyword matching the query request in the keyword library, taking the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and outputting the reply result corresponding to the query request; when there is no target keyword matching the query request in the keyword library, searching from the semantic library based on the query request whether there is at least one matching intent.
[0040] Specifically, determining whether there is a target keyword matching the query request in the keyword library may include: obtaining text information included in the query request, and determining whether there is a target keyword matching the text information among all candidate keywords included in the keyword library.
[0041] Among them, obtaining the text information contained in the query request may include one of the following: when the query request is a picture, extracting the text information from the picture; when the query request is voice, extracting the text information from the voice; when the query request is text information, obtaining the text information contained in the query request.
[0042] Optionally, determining whether there is a target keyword matching the text information among all the candidate keywords included in the keyword library may include: based on each character in the text information and its order, and each character in each candidate keyword among all the candidate keywords included in the keyword library and its order, determining whether there is a target keyword matching the text information in the keyword library.
[0043] A method for determining whether there is a target keyword matching the query request in the keyword library may be: when each character and the order thereof in the text information are the same as each character and the order thereof in the first candidate keyword in the keyword library, determining that the first candidate keyword in the keyword library is the target keyword matching the query request.
[0044] Optionally, determining whether there is a target keyword matching the text information among all candidate keywords included in the keyword library may include: determining whether there is a target keyword matching the text information in the keyword library based on a vector corresponding to the text information and a distance between the vector corresponding to each candidate keyword in all candidate keywords included in the keyword library.
[0045] The calculation method of the vector corresponding to the text information may include: performing average pooling or maximum pooling calculation on the text information to obtain the vector corresponding to the text information. It should be understood that this is only an exemplary description of calculating the vector corresponding to the text information. In actual processing, the vector corresponding to the text information may also be calculated by other methods, which are not exhaustive or limited.
[0046] The distance may be one of the following: cosine distance, Euclidean distance, Manhattan distance, and the like.
[0047] The method for determining whether there is a target keyword matching the query request in the keyword library may be: when the distance between the vector corresponding to the text information and the vector corresponding to the second candidate keyword in the keyword library is less than or equal to a first distance threshold, determining the second candidate keyword in the keyword library as the target keyword matching the query request. In a preferred embodiment, the first distance threshold may be 0.
[0048] The preset answer information corresponding to the target keyword may be pre-configured, and the configuration method is not limited in this embodiment. Exemplarily, the preset answer information corresponding to the target keyword includes at least one of the following: business data trend, brand data trend, preset template information, etc. The preset template information may be the question answer information corresponding to the target keyword.
[0049] The using the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and outputting the reply result corresponding to the query request may include: using the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and displaying the reply result corresponding to the query request in a first area of an interactive interface, wherein the first area is the same as the above-mentioned input area.
[0050] The above implementation is explained with examples: for example, when the query request is "what can you do", and the query request input by the user matches the candidate keyword "what can you do" in the keyword library, "what can you do" is used as the target keyword, and the preset template information "I can help you gain insight into brand assets" corresponding to the target keyword "what can you do" is displayed in the first area of the interactive interface. For another example, when the query request is "business data trend", and the distance between the vector corresponding to the text information in the query request and the vector corresponding to the candidate keyword "business data trend" in the keyword library is less than or equal to the first distance threshold, "business data trend" is used as the target keyword, and the preset reply information corresponding to the target keyword "business data trend" is output.
[0051] Optionally, taking the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and outputting the reply result corresponding to the query request, may include: taking the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and displaying the reply result corresponding to the query request in a second area of the interactive interface, wherein the second area is different from the first area mentioned above. For example: For example, when the query request is "What can you do", and the query request input by the user matches the candidate keyword "What can you do" in the keyword library, "What can you do" is taken as the target keyword, and "View business data trends" and "View brand data trends" corresponding to the target keyword "What can you do" are respectively displayed in the first area of the interactive interface.
[0052] Searching from the semantic library whether there is at least one matching intent based on the query request may include: searching from the semantic library whether there is a vector corresponding to at least one candidate intent whose distance from the vector corresponding to the text information contained in the query request is greater than a second distance threshold based on the vector corresponding to the text information contained in the query request. The second distance threshold is greater than or equal to the first distance threshold.
[0053] The method of determining at least one matching intention from the semantic library based on the query request may include: when a distance between a vector corresponding to at least one candidate intention found in the semantic library and a vector corresponding to the text information contained in the query request is greater than a second distance threshold, taking the at least one candidate intention as at least one matching intention.
[0054] The obtaining of the similarity between the at least one first candidate intention and the query request may include: obtaining the distance between each first candidate intention in the at least one first candidate intention and the query request, and using the distance between each first candidate intention and the query request as the similarity between each first candidate intention and the query request.
[0055] By adopting the above-mentioned implementation mode, at least one matching intention can be determined from the semantic library based on the query request, and the matching intention can be used as the first candidate intention. In this way, at least one first candidate intention corresponding to the query request can be obtained more accurately; further, the similarity between the query request and the first candidate intention can be obtained, so that the intention to be clarified can be determined more accurately.
[0056] In a possible implementation, when it is determined that there is at least one intention to be clarified in the at least one first candidate intention based on the similarity between the at least one first candidate intention and the query request, the at least one intention to be clarified is output, including one of the following: when there is at least one second candidate intention in the at least one first candidate intention whose similarity with the query request is not greater than a first similarity threshold and greater than a second similarity threshold, the at least one second candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output, wherein the first similarity threshold is greater than the second similarity threshold; when there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, the multiple second candidate intentions are determined to be multiple intentions to be clarified, and the at least one intention to be clarified is output.
[0057] Specifically, when there is at least one second candidate intention in the at least one first candidate intention, whose similarity with the query request is not greater than the first similarity threshold and greater than the second similarity threshold, determining the at least one second candidate intention as the at least one intention to be clarified, and outputting the at least one intention to be clarified may include: judging whether the similarity between each first candidate intention in the at least one first candidate intention and the query request is greater than the first similarity threshold; if the similarity between the at least one first candidate intention and the query request is not greater than the first similarity threshold, judging whether there is at least one second candidate intention in the at least one first candidate intention, whose similarity with the query request is not greater than the first similarity threshold and greater than the second similarity threshold; if so, determining the at least one second candidate intention as the at least one intention to be clarified, and outputting the at least one intention to be clarified.
[0058] In the case that there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, determining the multiple second candidate intentions as multiple intentions to be clarified, and outputting the at least one intention to be clarified may include: judging whether there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold; if so, determining the multiple second candidate intentions as multiple intentions to be clarified, and outputting the at least one intention to be clarified.
[0059] In addition, it also includes: when there is only one target candidate intent among the at least one first candidate intent and the similarity between the target candidate intent and the query request is greater than a first similarity threshold, the target candidate intent is used as the target intent.
[0060] Outputting the at least one intention to be clarified may include: generating at least one message to be clarified containing the at least one intention to be clarified based on the at least one intention to be clarified; and outputting at least one message to be clarified, wherein the at least one message to be clarified includes a first message to be clarified and / or at least one second message to be clarified.
[0061] Optionally, at least one message to be clarified includes only one first message to be clarified. The generating of at least one message to be clarified including the at least one intention to be clarified based on the at least one intention to be clarified may include: generating a first message to be clarified including the at least one intention to be clarified based on a preset template to be clarified and the at least one intention to be clarified. For example: at least one intention to be clarified includes "business data trends" and "brand data trends", and the first message to be clarified is "Hello, this question is a bit vague to me. Do you want to ask about [business data trends] or [brand data trends]?", wherein "Hello, this question is a bit vague to me. Do you want to ask about [] or []?" is a preset template to be clarified.
[0062] The outputting at least one message to be clarified may include: displaying the first message to be clarified in a first area of the interactive interface.
[0063] Optionally, at least one message to be clarified includes only at least one second message to be clarified. The generating at least one message to be clarified including the at least one intention to be clarified based on the at least one intention to be clarified may include: inputting the at least one intention to be clarified and the query request into a clarification message rewriting model, and obtaining at least one second message to be clarified output by the clarification rewriting model, wherein different second messages to be clarified in the at least one second message to be clarified include different intentions to be clarified.
[0064] Further, when the query request includes a target sub-intent, each of the at least one second message to be clarified also includes a target sub-intent, where the target sub-intent is an undisputed sub-intent in the query request, and the target sub-intent is determined by the clarification message rewriting model.
[0065] Outputting at least one message to be clarified may include: displaying the at least one second message to be clarified in a second area of the interaction interface.
[0066] Among them, the clarification message rewriting model is obtained by training the LLM (Large Language Model l) model. For example: the query request is "last month's data", at least one intent to be clarified includes "business data trend" and "brand data trend", and the query request includes the target sub-intent of "last month", then the clarification rewriting model outputs two second messages to be clarified, and the two second messages to be clarified are "last month's business data trend" and "last month's brand data trend". For another example, the query request is "data", at least one intent to be clarified includes "business data trend" and "brand data trend", and the query request does not include the target sub-intent, then the clarification rewriting model outputs two second messages to be clarified, and the two second messages to be clarified are "business data trend" and "brand data trend".
[0067] By adopting the above implementation, based on the similarity between the at least one first candidate intent and the query request, the first similarity threshold and / or the second similarity threshold, at least one intent to be clarified is determined in the at least one first candidate intent, and the at least one intent to be clarified is output. In this way, at least one intent to be clarified can be accurately determined and output in the at least one first candidate intent, so that the optimal intent to be clarified can be given to the query request, ensuring the accuracy of the subsequent target intent.
[0068] After outputting at least one message to be clarified, the method includes: in response to obtaining a selected message, determining a target intent in the at least one intent to be clarified based on the selected message.
[0069] Optionally, in response to obtaining a selection message, determining the target intent in the at least one intent to be clarified based on the selection message may include: in response to obtaining a selection message input by the user in the first area of the interactive interface, determining the target intent in the at least one intent to be clarified based on the selection message. For example, when the output message to be clarified is the first message to be clarified, and the first clarification message is "Hello, this question is a bit vague to me. Do you want to ask about [business data trends] or [brand data trends]?", and the selection message input by the user is "first", the business data trend is used as the target intent.
[0070] Optionally, in response to obtaining a selection message, determining the target intent in the at least one intent to be clarified based on the selection message may include: in response to a selection operation obtained in the second area of the interactive interface, determining the target intent in the at least one intent to be clarified based on the selection operation. The output messages to be clarified are two second messages to be clarified, and the two second messages to be clarified are "business data trend" and "brand data trend" respectively. In response to the user's selection operation on "business data trend" obtained in the second area of the interactive interface, "business data trend" is used as the target intent.
[0071] In a possible implementation, when it is determined based on the query request that there is at least one first candidate intent, obtaining the similarity between the at least one first candidate intent and the query request includes: when it is determined based on the query request that there is no matching intent in the semantic library, inputting the query request into an intent analysis model, obtaining the at least one first candidate intent output by the intent analysis model, and obtaining the similarity between the at least one first candidate intent and the query request.
[0072] Optionally, determining that there is no matching intent in the semantic library based on the query request may include: based on the vector corresponding to the text information contained in the query request, searching from the semantic library whether there is at least one vector corresponding to a candidate intent and a distance between it and the vector corresponding to the text information contained in the query request is greater than a second distance threshold; if there is no vector corresponding to a candidate intent in the semantic library and the distance between it and the vector corresponding to the text information contained in the query request is greater than the second distance threshold, determining that there is no matching intent in the semantic library.
[0073] Optionally, determining that there is no matching intent in the semantic library based on the query request may include: determining that there is no matching intent in the semantic library when the similarity between each first candidate intent in the at least one first candidate intent and the query request is not greater than a second similarity threshold.
[0074] The step of inputting the query request into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model may include: inputting the query request into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model, and the similarity between the at least one first candidate intent and the query request. The intent analysis model may be obtained by training an LLM (Large Language Model l), and the specific training method is not limited here.
[0075] The obtaining of the similarity between the at least one first candidate intent and the query request may include: obtaining the similarity between the at least one first candidate intent output by the intent analysis model and the query request.
[0076] By adopting the above implementation, when it is determined based on the query request that there is no matching intent in the semantic library, the query request is input into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model. In this way, when there is no matching intent in the semantic library, at least one first candidate intent is obtained with the help of the intent analysis model, ensuring that all types of query requests can be reasonably processed, expanding the processing capacity and scope of application of the system, and reducing the number of query requests that cannot be processed.
[0077] In a possible implementation, when it is determined that there is at least one intention to be clarified in the at least one first candidate intention based on the similarity between the at least one first candidate intention and the query request, the at least one intention to be clarified is output, including one of the following: when there is at least one second candidate intention in the at least one first candidate intention whose similarity with the query request is not greater than a first similarity threshold and greater than a second similarity threshold, and at least one third candidate intention in the at least one second candidate intention is legal, the at least one third candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output, wherein the first similarity threshold is greater than the second similarity threshold; when there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, and at least one third candidate intention in the multiple second candidate intentions is legal, the at least one third candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output.
[0078] Specifically, when there is at least one second candidate intention in the at least one first candidate intention whose similarity with the query request is not greater than the first similarity threshold and greater than the second similarity threshold, and at least one third candidate intention in the at least one second candidate intention is legal, determining the at least one third candidate intention as the at least one intention to be clarified and outputting the at least one intention to be clarified may include: judging whether the similarity between each first candidate intention in the at least one first candidate intention and the query request is greater than the first similarity threshold; if the similarity between each first candidate intention in the at least one first candidate intention and the query request is not greater than the first similarity threshold, judging whether there is at least one second candidate intention in the at least one first candidate intention whose similarity with the query request is not greater than the first similarity threshold and greater than the second similarity threshold; if so, judging whether each second candidate intention in the at least one second candidate intention is legal; if there is at least one legal third candidate intention in the at least one second candidate intention, determining the at least one third candidate intention as the at least one intention to be clarified, and outputting the at least one intention to be clarified.
[0079] In the case where there are multiple second candidate intentions among the at least one first candidate intention and the similarity between them and the query request is greater than the first similarity threshold, and at least one third candidate intention among the multiple second candidate intentions is legal, determining the at least one third candidate intention as the at least one intention to be clarified, and outputting the at least one intention to be clarified may include: judging whether the similarity between each first candidate intention among the at least one first candidate intention and the query request is greater than the first similarity threshold; in the case where there are multiple second candidate intentions among the at least one first candidate intention and the similarity between them and the query request is greater than the first similarity threshold, judging whether each second candidate intention among the multiple second candidate intentions is legal, and in the case where there is at least one legal third candidate intention among the multiple second candidate intentions, determining the at least one third candidate intention as the at least one intention to be clarified, and outputting the at least one intention to be clarified.
[0080] In addition, the method may further include: if there is at least one fourth candidate intent that is illegal in at least one second candidate intent, outputting a rejection reply message of at least one fourth candidate intent. Among the rejection reply messages of at least one fourth candidate intent, any one of the rejection reply messages of the fourth candidate intent may be generated according to a preset rejection reply template, for example, a rejection reply message of a fourth candidate intent may be "Sorry, I cannot provide you with the data of [fourth candidate intent]", wherein "Sorry, I cannot provide you with the data of []" may be a preset rejection reply template.
[0081] In addition, it may also include: when there is only one target candidate intent among the at least one first candidate intent, and the similarity between the target candidate intent and the query request is greater than the first similarity threshold, judging whether the target candidate intent is legal; when the target candidate intent is legal, taking the target candidate intent as the target intent, and outputting the reply result corresponding to the query request based on the target intent; when the target candidate intent is illegal, outputting a rejection reply message of the target candidate intent. The rejection reply message of the target candidate intent may also be generated according to a preset rejection reply template, for example, the rejection reply message of the target candidate intent may be "Sorry, I cannot provide you with the data of [target candidate intent]", wherein "Sorry, I cannot provide you with the data of []" may be a preset rejection reply template.
[0082] Outputting a rejection reply message of the target candidate intention may include displaying the rejection reply message of the target candidate intention in the first area. Outputting a rejection reply message of at least one fourth candidate intention may include displaying the rejection reply message of the at least one fourth candidate intention in the first area.
[0083] Optionally, the at least one first candidate intention is matched from a semantic library.
[0084] In one case, each candidate intent in the semantic library is legal, in which case each second candidate intent is legal.
[0085] In one case, each candidate intent in the semantic library is pre-set with a corresponding label (or attribute) indicating whether it is legal. In this case, judging whether each second candidate intent is legal may include: judging whether each second candidate intent is legal based on the label (or attribute) indicating whether each second candidate intent in the semantic library corresponds to.
[0086] Optionally, the at least one first candidate intent is output by an intent analysis model.
[0087] In this case, the content output by the intent analysis model also includes the attributes or labels of whether each first candidate intent is legal. Correspondingly, judging whether each second candidate intent is legal may include: judging whether each second candidate intent is legal based on the attributes of each second candidate intent output by the intent analysis model.
[0088] The method of outputting the at least one intention to be clarified is the same as that in the aforementioned embodiment and will not be described in detail here.
[0089] In addition, it also includes: when there is no second candidate intent in the at least one first candidate intent whose similarity with the query request is greater than a second similarity threshold, displaying a rejection reply message of the query request in the first area. The specific output method of the rejection reply message is the same as the above implementation method, which will not be repeated here.
[0090] By adopting the above-mentioned implementation mode, after determining at least one second candidate intention based on the similarity between the at least one first candidate intention and the query request, the first similarity threshold and / or the second similarity threshold, at least one intention to be clarified is further determined based on whether the at least one second candidate intention is legal, thereby improving the accuracy of determining the intention to be clarified.
[0091] In a possible implementation, outputting a reply result corresponding to the query request based on the target intent includes: obtaining a reply result corresponding to the query request based on the target intent and the query request; and outputting the reply result corresponding to the query request.
[0092] The method of obtaining a reply result corresponding to the query request based on the target intent and the query request may include: inputting the target intent and the query request into a reply generation model, and obtaining a reply result corresponding to the query request output by the reply generation model, wherein the reply generation model is obtained by training the LLM model, and the specific training method is not limited.
[0093] Outputting the reply result corresponding to the query request may include: displaying the reply result corresponding to the query request in a first area.
[0094] By adopting the above implementation mode, the response result corresponding to the query request is determined by combining the target intention and the query request, thereby improving the accuracy of the response result.
[0095] Combination Figure 2 The above-mentioned embodiments are illustrated as an exemplary embodiment, including:
[0096] S201, determining whether there is a target keyword matching the query request in the keyword library, and if there is a target keyword matching the query request in the keyword library, taking the preset reply information corresponding to the target keyword as the reply result corresponding to the query request, and outputting the reply result corresponding to the query request. If there is no target keyword matching the query request in the keyword library, executing step S202.
[0097] S202, based on the query request, search from the semantic library whether there is at least one matching intent. If so, execute step S203; if not, execute step S208.
[0098] S203, obtaining the similarity between the at least one first candidate intention and the query request, that is, obtaining the similarity between the Top-k (first k) first candidate intentions and the query request.
[0099] S204, determine whether there is only one target candidate intent among the at least one first candidate intent whose similarity with the query request is greater than the first similarity threshold (that is, whether only Top-1 is greater than the first similarity threshold).
[0100] When there is only one target candidate intention among the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, a reply result corresponding to the query request is obtained based on the target intention and the query request; and the reply result corresponding to the query request is output.
[0101] In the case that there is not only one target candidate intent in the at least one first candidate intent whose similarity with the query request is greater than the first similarity threshold, executing step S205;
[0102] S205: If there is at least one second candidate intent in the at least one first candidate intent whose similarity with the query request is not greater than the first similarity threshold and greater than the second similarity threshold, determine that the at least one second candidate intent is the at least one intent to be clarified; if there are multiple second candidate intents in the at least one first candidate intent whose similarity with the query request is greater than the first similarity threshold, determine that the multiple second candidate intents are multiple intents to be clarified, and execute step S206. If there is no at least one second candidate intent in the at least one first candidate intent whose similarity with the query request is greater than the second similarity threshold, execute step S208.
[0103] S206: Generate at least one message to be clarified containing the at least one intention to be clarified.
[0104] Optionally, the at least one message to be clarified includes only one first message to be clarified. The generating at least one message to be clarified including the at least one intention to be clarified based on the at least one intention to be clarified may include: generating the first message to be clarified including the at least one intention to be clarified based on a preset template to be clarified and the at least one intention to be clarified.
[0105] Optionally, at least one message to be clarified includes only at least one second message to be clarified. The generating of at least one message to be clarified including the at least one intention to be clarified based on the at least one intention to be clarified may include: inputting the at least one intention to be clarified and the query request into a clarification message rewriting model, and obtaining at least one second message to be clarified output by the clarification rewriting model, wherein different second messages to be clarified in the at least one second message to be clarified contain different intentions to be clarified, and when the query request includes a target sub-intention, each second message to be clarified of the at least one second message to be clarified also includes a target sub-intention, and the target sub-intention is a sub-intention without objection in the query request, and the target sub-intention is determined by the clarification message rewriting model.
[0106] S207: Output at least one message to be clarified, and the process ends.
[0107] S208, input the query request into the intent analysis model, obtain the at least one first candidate intent output by the intent analysis model, and obtain the similarity between the at least one first candidate intent and the query request.
[0108] S209, obtain the similarity between the at least one first candidate intention (i.e., the Top-g first candidate intentions) and the query request, and return to execute step S204.
[0109] After completing S209, return to the process of executing S204. When executing S205, if there is no second candidate intention in the at least one first candidate intention whose similarity with the query request is greater than a second similarity threshold, step S208 is not executed, but a rejection reply message of the query request is output.
[0110] After executing step S207, it may also include: in response to obtaining a selected message, determining a target intent in the at least one intent to be clarified based on the selected message; obtaining a reply result corresponding to the query request based on the target intent and the query request; and outputting the reply result corresponding to the query request.
[0111] Figure 3 FIG. 1 is a schematic block diagram of a query processing device provided by an embodiment of the present disclosure. Figure 3 As shown, including:
[0112] A similarity acquisition module 301 is used to acquire the similarity between the at least one first candidate intent and the query request when it is determined that there is at least one first candidate intent based on the query request;
[0113] An intent-to-be-clarified output module 302 is configured to output the at least one intent-to-be-clarified when it is determined that there is at least one intent-to-be-clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request;
[0114] A target intent determination module 303, configured to, in response to obtaining a selected message, determine a target intent in the at least one intent to be clarified based on the selected message;
[0115] The reply result output module 304 is used to output the reply result corresponding to the query request based on the target intent.
[0116] The similarity acquisition module is used to determine at least one matching intention from the semantic library based on the query request, use the at least one matching intention as the at least one first candidate intention; and obtain the similarity between the at least one first candidate intention and the query request.
[0117] The to-be-clarified intention output module is used to perform one of the following:
[0118] In the case where there is at least one second candidate intent in the at least one first candidate intent, the similarity between which and the query request is not greater than a first similarity threshold and greater than a second similarity threshold, determining the at least one second candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold;
[0119] When there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, the multiple second candidate intentions are determined to be multiple intentions to be clarified, and the at least one intention to be clarified is output.
[0120] The similarity acquisition module is used to input the query request into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model, and obtain the similarity between the at least one first candidate intent and the query request when it is determined that there is no matching intent in the semantic library based on the query request.
[0121] The to-be-clarified intention output module is used to perform one of the following:
[0122] In the case where there is at least one second candidate intent in the at least one first candidate intent whose similarity with the query request is not greater than a first similarity threshold and greater than a second similarity threshold, and at least one third candidate intent in the at least one second candidate intent is legal, determining the at least one third candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold;
[0123] When there are multiple second candidate intentions among the at least one first candidate intentions whose similarity with the query request is greater than the first similarity threshold, and there is at least one third candidate intention among the multiple second candidate intentions that is legal, the at least one third candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output.
[0124] The reply result output module is used to obtain the reply result corresponding to the query request based on the target intention and the query request; and output the reply result corresponding to the query request.
[0125] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0126] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0127] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0128] Figure 4 A schematic block diagram of an example electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0129] like Figure 4As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0130] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0131] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the above method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, at least one step of the method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the above method in any other appropriate manner (e.g., by means of firmware).
[0132] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general programmable processor, which may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0133] The program code for implementing the method of the present disclosure may be written in any combination of at least one programming language. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0134] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on at least one line, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0135] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0136] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0137] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0138] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0139] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A query processing method, comprising: In a case where it is determined based on the query request that there is at least one first candidate intent, obtaining a similarity between the at least one first candidate intent and the query request; In a case where it is determined that there is at least one intent to be clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request, outputting the at least one intent to be clarified; In response to obtaining a selection message, determining a target intent in the at least one intent to be clarified based on the selection message; Based on the target intent, a response result corresponding to the query request is output.
2. The method according to claim 1, wherein: The step of obtaining the similarity between the at least one first candidate intent and the query request when it is determined based on the query request that there is at least one first candidate intent includes: In a case where at least one matching intent is determined from the semantic library based on the query request, taking the at least one matching intent as the at least one first candidate intent; Obtain the similarity between the at least one first candidate intent and the query request.
3. The method according to claim 2, wherein: The step of outputting the at least one intent to be clarified, when it is determined based on the similarity between the at least one first candidate intent and the query request that there is at least one intent to be clarified in the at least one first candidate intent, comprises one of the following: In the case where there is at least one second candidate intent in the at least one first candidate intent, the similarity between which and the query request is not greater than a first similarity threshold and greater than a second similarity threshold, determining the at least one second candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold; When there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, the multiple second candidate intentions are determined to be multiple intentions to be clarified, and the at least one intention to be clarified is output.
4. The method according to claim 1, wherein: The step of obtaining the similarity between the at least one first candidate intent and the query request when it is determined based on the query request that there is at least one first candidate intent includes: When it is determined that there is no matching intent in the semantic library based on the query request, the query request is input into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model, and the similarity between the at least one first candidate intent and the query request is obtained.
5. The method according to claim 2 or 4, wherein: The step of outputting the at least one intent to be clarified, when it is determined based on the similarity between the at least one first candidate intent and the query request that there is at least one intent to be clarified in the at least one first candidate intent, comprises one of the following: In the case where there is at least one second candidate intent in the at least one first candidate intent whose similarity with the query request is not greater than a first similarity threshold and greater than a second similarity threshold, and at least one third candidate intent in the at least one second candidate intent is legal, determining the at least one third candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold; When there are multiple second candidate intentions among the at least one first candidate intentions whose similarity with the query request is greater than the first similarity threshold, and there is at least one third candidate intention among the multiple second candidate intentions that is legal, the at least one third candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output.
6. The method according to claim 1, wherein: The outputting a response result corresponding to the query request based on the target intent includes: Based on the target intention and the query request, obtaining a response result corresponding to the query request; Output the response result corresponding to the query request.
7. A query processing device, comprising: A similarity acquisition module, configured to acquire a similarity between the at least one first candidate intent and the query request when it is determined that there is at least one first candidate intent based on the query request; an intent-to-be-clarified output module, configured to output the at least one intent-to-be-clarified if it is determined that there is at least one intent-to-be-clarified in the at least one first candidate intent based on the similarity between the at least one first candidate intent and the query request; a target intent determination module, configured to, in response to obtaining a selected message, determine a target intent in the at least one intent to be clarified based on the selected message; The reply result output module is used to output the reply result corresponding to the query request based on the target intent.
8. The device according to claim 7, wherein: The similarity acquisition module is used to determine at least one matching intent from the semantic library based on the query request and use the at least one matching intent as the at least one first candidate intent; Obtain the similarity between the at least one first candidate intent and the query request.
9. The device according to claim 8, wherein: The to-be-clarified intention output module is used to perform one of the following: In the case where there is at least one second candidate intent in the at least one first candidate intent, the similarity between which and the query request is not greater than a first similarity threshold and greater than a second similarity threshold, determining the at least one second candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold; When there are multiple second candidate intentions in the at least one first candidate intention whose similarity with the query request is greater than the first similarity threshold, the multiple second candidate intentions are determined to be multiple intentions to be clarified, and the at least one intention to be clarified is output.
10. The device according to claim 7, wherein: The similarity acquisition module is used to input the query request into the intent analysis model to obtain the at least one first candidate intent output by the intent analysis model, and obtain the similarity between the at least one first candidate intent and the query request when it is determined that there is no matching intent in the semantic library based on the query request.
11. The device according to claim 8 or 10, wherein: The to-be-clarified intention output module is used to perform one of the following: In the case where there is at least one second candidate intent in the at least one first candidate intent whose similarity with the query request is not greater than a first similarity threshold and greater than a second similarity threshold, and at least one third candidate intent in the at least one second candidate intent is legal, determining the at least one third candidate intent as the at least one intent to be clarified, and outputting the at least one intent to be clarified, wherein the first similarity threshold is greater than the second similarity threshold; When there are multiple second candidate intentions among the at least one first candidate intentions whose similarity with the query request is greater than the first similarity threshold, and there is at least one third candidate intention among the multiple second candidate intentions that is legal, the at least one third candidate intention is determined to be the at least one intention to be clarified, and the at least one intention to be clarified is output.
12. The device according to claim 7, wherein: The reply result output module is used to obtain the reply result corresponding to the query request based on the target intention and the query request; and output the reply result corresponding to the query request.
13. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.
15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.
