Conversation reply determination method and device, equipment, storage medium and product
By adjusting the hidden state information of the dialogue model and increasing the probability value of sentiment words, the problem of high training cost when generating sentiment dialogues in the dialogue system is solved, and high-quality sentiment responses and improved user experience are achieved.
Patent Information
- Application Number
- CN202211420472.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-11-09
AI Technical Summary
Existing dialogue systems require a large number of emotional dialogue datasets of varying quality when generating emotional dialogues, resulting in high training costs and low efficiency, and making it difficult to optimize the empathy and dialogue quality of the model.
By adjusting the hidden state information of the preset dialogue model, the probability value of sentiment words in the target sentiment word bag is increased, thereby increasing the probability of sentiment words appearing in the response information. This avoids relying on a large amount of sentiment dialogue data for training and uses a sentiment classifier and preset decoding strategy to generate sentiment responses.
Without increasing training costs, improve the empathy and dialogue quality of the dialogue system, ensure that the response information matches the user's emotions, and enhance the user experience.
Smart Images

Figure CN115658873B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of artificial intelligence technology, and in particular to a dialogue reply determination method and device, equipment, a storage medium and a product. BACKGROUND
[0002] A dialogue system is a popular task in the field of natural language processing and has a very broad application prospect.
[0003] In a dialogue system, empathy refers to the dialogue system's ability to perceive the emotions of a chat participant. Whether a dialogue system has empathy can affect the quality of the dialogue to some extent, and thus affect the user experience. In order to generate a dialogue with emotions, a large amount of emotional dialogue data is usually required for model training. However, it is difficult to collect emotional dialogue data sets, and the quality of the data is uneven, which poses a challenge to the optimization of emotional dialogue models. SUMMARY
[0004] Embodiments of the present application provide a dialogue reply determination method, device, equipment, storage medium and product, which can optimize the existing dialogue reply determination scheme.
[0005] According to an aspect of the present application, a dialogue reply determination method is provided, which comprises:
[0006] inputting a current dialogue and a historical interactive dialogue of a user into a preset dialogue model to obtain hidden state information output by the preset dialogue model and probability values corresponding to each vocabulary in a preset vocabulary library, wherein the probability values are determined according to the hidden state information, and the probability values are used to represent the probability of the corresponding vocabulary appearing in the reply information to be determined;
[0007] determining a target emotional category corresponding to the current dialogue, and determining a target preset emotional bag corresponding to the target emotional category, wherein emotional words in the preset emotional bag are included in the preset vocabulary library;
[0008] taking the target emotional word probability value corresponding to the target emotional word in the target preset emotional bag as an adjustment target, adjusting the hidden state information to obtain adjusted target hidden state information;
[0009] determining target probability values corresponding to each vocabulary in the preset vocabulary library according to the target hidden state information;
[0010] determining target reply information corresponding to the current dialogue based on the target probability values.
[0011] According to another aspect of the present application, a dialogue reply determination device is provided, which comprises:
[0012] The dialogue input module is configured to input a current dialogue and a historical interaction dialogue of a user into a preset dialogue model to obtain hidden state information output by the preset dialogue model and probability values corresponding to respective words in a preset word library, wherein the probability values are determined according to the hidden state information, and the probability values are used to represent probabilities of the corresponding words appearing in to-be-determined reply information.
[0013] The sentiment bag determination module is configured to determine a target sentiment category corresponding to the current dialogue, and determine a target preset sentiment bag corresponding to the target sentiment category according to the target sentiment category, wherein sentiment words in the preset sentiment bag are included in the preset word library.
[0014] The hidden state adjustment module is configured to adjust the hidden state information to obtain adjusted target hidden state information, with the target sentiment words in the target preset sentiment bag having higher sentiment word probability values as an adjustment target.
[0015] The target probability determination module is configured to determine target probability values corresponding to respective words in the preset word library according to the target hidden state information.
[0016] The reply determination module is configured to determine target reply information corresponding to the current dialogue based on the target probability values.
[0017] According to another aspect of the present application, a dialogue reply determination device is provided, and the dialogue reply determination device comprises:
[0018] at least one processor; and
[0019] a memory connected in communication with the at least one processor; wherein
[0020] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the dialogue reply determination method described in any embodiment of the present application.
[0021] According to another aspect of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is used to enable a processor to implement the dialogue reply determination method described in any embodiment of the present application when executed by the processor.
[0022] According to another aspect of the present application, a computer program product is provided, and the computer program product comprises a computer program, and the computer program is used to implement the dialogue reply determination method described in any embodiment of the present application when executed by a processor.
[0023] The dialogue reply determination scheme provided in the embodiments of the present application inputs the current dialogue and the historical interaction dialogue of the user into a preset dialogue model, obtains hidden state information output by the preset dialogue model and probability values corresponding to each vocabulary in a preset vocabulary library, determines a target emotion category corresponding to the current dialogue, and determines a target preset emotion bag corresponding to the target emotion category, wherein the emotion words in the preset emotion bag are included in the preset vocabulary library. The target emotion word corresponding to the emotion word probability value in the target preset emotion bag is adjusted as an adjustment target, the hidden state information is adjusted to obtain adjusted target hidden state information, the target probability value corresponding to each vocabulary in the preset vocabulary library is determined according to the target hidden state information, and the target reply information corresponding to the current dialogue is determined based on the target probability value. By using the above technical scheme, when the dialogue reply is determined, the hidden state output by the preset dialogue model is adjusted to improve the probability that the emotion words corresponding to the current dialogue of the user are included in the reply, so that the emotion words are more likely to appear in the reply information, that is, the dialogue system has more empathy, improves the dialogue quality and user experience, and the scheme does not rely on training the preset dialogue model by using a large amount of emotion dialogue data, which can effectively reduce the training cost of the dialogue model.
[0024] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0026] Figure 1 A flowchart of a dialogue reply determination method provided by an embodiment of the present application is shown in the figure.
[0027] Figure 2 A flowchart of another dialogue reply determination method provided by an embodiment of the present application is shown in the figure.
[0028] Figure 3 A flowchart of another dialogue reply determination method provided by an embodiment of the present application is shown in the figure.
[0029] Figure 4 A dialogue reply determination process provided by an embodiment of the present application is shown in the figure.
[0030] Figure 5A structural block diagram of a dialogue reply determination apparatus provided by an embodiment of the present application is shown in FIG. 1.
[0031] Figure 6 A structural block diagram of a dialogue reply determination apparatus provided by an embodiment of the present application is shown in FIG. 1. DETAILED DESCRIPTION
[0032] In order to make the personnel in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person of ordinary skill in the art without creative labor should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily mean a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product or device.
[0034] In order to better understand the technical scheme of the present application, the related art is introduced below.
[0035] Currently, dialogue systems mainly include two types, task-oriented dialogue and open-domain dialogue. The former mainly solves dialogue in a specific domain, such as ticket booking or meal ordering, etc., while the latter is mainly used for chatting with users and is not limited to a single task or domain. The technical scheme provided by the embodiments of the present application can be applicable to both task-oriented dialogue systems and open-domain dialogue systems, and can achieve more significant technical effects for open-domain dialogue systems.
[0036] Common open-domain dialogue systems are mainly divided into three categories: generative systems, retrieval-based systems and integrated systems. The generative system can return a response sequence that may not exist in the training corpus with the help of a sequence-to-sequence model. The retrieval-based system can find a pre-defined response from a certain response set. The generative system can generate a reply related to the dialogue context, but sometimes lacks coherence and tends to make broad and meaningless replies. The retrieval-based system selects a reply from a pre-defined reply set, so it can achieve better coherence in surface language. However, the retrieval system is limited by the finiteness of the reply set, and sometimes the retrieved reply has weak relevance to the dialogue context. The integrated system combines the generative method and the retrieval-based method, can compare the retrieval result with the generation result, select the best one, and use the generation model to refine the retrieved response. The technical solutions in the embodiments of the present application can use the above-mentioned generative system, or the above-mentioned integrated system, and the specific implementation is not limited.
[0037] At present, in order to generate a dialogue with emotion, the common scheme includes two kinds. The first kind is to directly use an emotional dialogue data set to train a dialogue model; the second kind is to add an emotional dialogue module to a pre-trained dialogue model to guide the model to generate a reply with emotion. However, the above two kinds of schemes both need an emotional dialogue data set, but the emotional dialogue data set is difficult to collect, and the data quality is uneven, and the training cost is high, in addition, for the second kind of scheme, the introduction of the emotional dialogue module needs to retrain the dialogue model, which will consume more time cost and training resource cost.
[0038] In the embodiments of the present application, the existing dialogue model does not need to be adjusted in model structure and retrained, the probability of the emotional word corresponding to the current dialogue of the user in the reply is improved by adjusting the hidden state output by the model, so that the emotional word is more likely to appear in the reply information, which can effectively reduce the training cost of the dialogue model.
[0039] Figure 1 A flowchart of a dialogue reply determination method provided by the embodiments of the present application, the embodiments of the present application can be applicable to the case of determining the reply information of the device in the human-computer dialogue scene. The method can be executed by a dialogue reply determination apparatus, which can be realized in the form of hardware and / or software. The dialogue reply determination apparatus can be configured in a dialogue reply determination device, and the dialogue reply determination device can be a mobile phone, a smart watch, a smart speaker, a tablet computer, a smart television, a computer device or a server, etc. As shown in the figure, the method comprises: Figure 1
[0040] Step 101, input the current conversation and the historical interactive conversation of the user to a preset conversation model to obtain hidden state information output by the preset conversation model and probability values corresponding to each vocabulary in a preset vocabulary library, wherein the probability values are determined according to the hidden state information, and the probability values are used to represent probabilities of the corresponding vocabulary appearing in the to-be-determined reply information.
[0041] In the embodiment of the application, the current conversation of the user can be understood as the words spoken by the user to the reply-determining device (hereinafter referred to as a device) at present, which is generally natural language. The audio data of the user's speech can be collected through a microphone or other sound collection device, and the audio data can be processed through speech recognition to obtain the current conversation of the user. The historical interactive conversation can include the interactive conversation between the user and the device within a preset time period before the user speaks the current conversation, or the interactive conversation of a preset round, etc. That is, the historical interactive conversation contains the conversation of the user and the conversation (i.e. the reply) output by the device.
[0042] In the embodiment of the application, the preset conversation model can be a pre-trained language model, and can be a machine learning model, without limitation on the specific model structure. The training sample and training process of the preset conversation model are not limited, and can be trained by using ordinary conversation sample data (such as conversation data without emotion), or can be trained by using ordinary conversation sample data and a small amount of emotional conversation sample data.
[0043] For example, the preset vocabulary library can be understood as a set of words that can be included in the reply information output by the device. After the current conversation and the historical interactive conversation of the user are input to the preset conversation model, the preset conversation model can output the hidden state information and the probability values corresponding to each vocabulary in the preset vocabulary library. The hidden state information can contain the encoding information of the historical interactive conversation, and can be used as intermediate data output by the preset conversation model. The probability values corresponding to each vocabulary in the preset vocabulary library can be calculated according to the hidden state information, and the specific calculation method is not limited. For example, the hidden state information is passed through a full connection layer to obtain the probability values corresponding to each vocabulary in the preset vocabulary library. Optionally, the hidden state information can exist in the form of a vector, and correspondingly, the probability values corresponding to each vocabulary in the preset vocabulary library can also form a vector (which can also be referred to as probability distribution information), such as a vector formed according to the positions of each vocabulary in the preset vocabulary library.
[0044] Step 102, determine a target emotional category corresponding to the current conversation, and determine a target preset emotional bag corresponding to the target emotional category, wherein the emotional words in the preset emotional bag are included in the preset vocabulary library.
[0045] Optionally, step 102 can also be performed before step 101.
[0046] Exemplarily, the division manners of the emotion categories can be set according to actual needs, such as happy, sad, surprised, proud, excited, and frustrated, etc. Different emotion categories correspond to different preset emotion bags. Exemplarily, for each divided emotion category, the words with the attribute of the corresponding emotion category can be pre-selected from the preset word library, such as the selected words corresponding to the happy category can include happy and satisfied, etc. The corresponding preset emotion bag is determined according to the selected words.
[0047] Exemplarily, an emotion classifier can be used to identify the emotion category corresponding to the current dialogue, denoted as a target emotion category. The emotion classifier can be a pre-trained classification model for classifying the emotion contained in a sentence, and the specific model structure and training process are not limited. After determining the target emotion category corresponding to the current dialogue, the preset emotion bag matching the target emotion category is selected, denoted as a target preset emotion bag. For example, if the target emotion category is happy, the preset emotion bag corresponding to happy is determined as the target preset emotion bag.
[0048] Step 103: Adjusting the hidden state information to improve the emotion word probability value corresponding to the target emotion word in the target preset emotion bag as an adjustment target, to obtain adjusted target hidden state information.
[0049] In the embodiment of the present application, the words contained in the target preset emotion bag are denoted as target emotion words, and the target emotion words are contained in the preset word library. Therefore, the probability value corresponding to the target emotion word is contained in the probability value output by the preset dialogue model, and is denoted as an emotion word probability value for convenience. Improving the emotion word probability value can increase the probability of the corresponding target emotion word appearing in the to-be-determined reply information, and further improve the probability of the reply information having an emotional attribute. Therefore, the hidden state information is adjusted to improve the emotion word probability value as an adjustment target, to obtain adjusted target hidden state information.
[0050] Step 104: Determining the target probability value corresponding to each word in the preset word library according to the target hidden state information.
[0051] Exemplarily, after obtaining the target hidden state information, the target hidden state information can be input into the preset dialogue model as new intermediate data, so that the preset dialogue model can output new probability values corresponding to each word in the preset word library, denoted as target probability values.
[0052] Step 105: Determining the target reply information corresponding to the current dialogue based on the target probability value.
[0053] Exemplarily, a preset decoding strategy can be used to sample the target probability value corresponding to each vocabulary in the preset vocabulary library to obtain the reply information corresponding to the current dialogue, i.e., the target reply information. The preset decoding strategy is not limited in particular, for example, the vocabulary with the maximum target probability value can be selected to be added to the target reply information, and the like.
[0054] The dialogue reply determination method provided in the embodiments of the present application inputs the current dialogue and the historical interactive dialogue of the user into a preset dialogue model, obtains the hidden state information output by the preset dialogue model and the probability value corresponding to each vocabulary in the preset vocabulary library, determines the target emotion category corresponding to the current dialogue, and determines the target preset emotion bag corresponding to the target emotion category, wherein the emotion words in the preset emotion bag are included in the preset vocabulary library. The emotion word probability value corresponding to the target emotion word in the target preset emotion bag is taken as the adjustment target, the hidden state information is adjusted to obtain the adjusted target hidden state information, the target probability value corresponding to each vocabulary in the preset vocabulary library is determined according to the target hidden state information, and the target reply information corresponding to the current dialogue is determined based on the target probability value. By using the above technical solution, when determining the dialogue reply, the hidden state output by the preset dialogue model is adjusted to improve the probability that the emotion words corresponding to the current dialogue of the user are included in the reply, so that the emotion words are more likely to appear in the reply information, i.e., the dialogue system has more empathy, the dialogue quality and user experience are improved, and the training cost of the dialogue model can be effectively reduced without relying on training the preset dialogue model using a large amount of emotion dialogue data.
[0055] In some embodiments, the adjusting the hidden state information to obtain the adjusted target hidden state information, with the target emotion word probability value corresponding to the target emotion word in the target preset emotion bag as the adjustment target, comprises: determining the emotion word probability value corresponding to each target emotion word in the target preset emotion bag; determining a target function according to the emotion word probability value, wherein the value of the target function is negatively correlated with the sum of the emotion word probability values; and adjusting the hidden state information to obtain the adjusted target hidden state information, with the value of the target function as the adjustment target. This setting has the advantage that the adjustment direction of the hidden state information can be quickly and accurately determined, the generation efficiency of the reply information is improved, and the dialogue experience is further improved.
[0056] Figure 2 The flowchart of another dialogue reply determination method provided by the embodiments of the present application is optimized on the basis of the above-mentioned optional embodiments, and the method comprises:
[0057] Step 201, input the current conversation and historical interaction conversation of the user into a preset conversation model to obtain hidden state information output by the preset conversation model and probability values corresponding to each vocabulary in a preset vocabulary library.
[0058] The probability values are determined according to the hidden state information, and the probability values are used to represent probabilities of the corresponding vocabulary appearing in the to-be-determined reply information. Optionally, the probability values corresponding to each vocabulary in the preset vocabulary library constitute a first vector according to positions of the each vocabulary in the preset vocabulary library.
[0059] For example, in order to facilitate the description, it is assumed that the preset vocabulary library can be represented as [hello, goodbye, happy, sad, mobile phone, satisfied], and the preset conversation model can output probability values corresponding to each vocabulary. It is assumed that the first vector is [0.2, 0.4, 0.3, 0.6, 0.7, 0.1] in the form of a vector, that is, the probability value corresponding to hello is 0.2, the probability value corresponding to goodbye is 0.4, and so on.
[0060] Step 202, determine a target emotion category corresponding to the current conversation, and determine a target preset emotion bag corresponding to the target emotion category.
[0061] For example, it is assumed that the target emotion category is happy, and the target preset emotion bag corresponding thereto can be represented as [happy, satisfied].
[0062] Step 203, determine emotion word probability values corresponding to each target emotion word in the target preset emotion bag.
[0063] Optionally, positions of each target emotion word in the target preset emotion bag in the preset vocabulary library are encoded into a second vector, and specifically, a one-hot encoding mode can be used. For example, a vector with a length equal to the number of vocabularies in the preset vocabulary library can be first determined, and for each element in the vector, it is determined whether the position of the preset vocabulary library corresponding to the current element is the target emotion word. If yes, the current element takes a value of 0, otherwise, the current element takes a value of 1. For example, the positions of each target emotion word in the target preset emotion bag corresponding to happy in the preset vocabulary library are encoded into the second vector, which is [0, 0, 1, 0, 0, 1].
[0064] The determining of the sentiment word probability value corresponding to each target sentiment word in the target preset sentiment word bag can include: determining the sentiment word probability value corresponding to each target sentiment word in the target preset sentiment word bag according to the product of the first vector and the second vector. The advantage of this setting is that the sentiment word probability value corresponding to each target sentiment word in the target preset sentiment word bag can be quickly and accurately selected. For example, the sentiment word probability value corresponding to each target sentiment word in the target preset sentiment word bag can also be expressed as a vector, which can be denoted as a third vector.
[0065] As an example, the product of the first vector [0.2, 0.4, 0.3, 0.6, 0.7, 0.1] and the second vector [0, 0, 1, 0, 0, 1] can be calculated to obtain the third vector [0, 0, 0.3, 0, 0, 0.1], and the sentiment word probability values corresponding to happy and satisfied can be quickly confirmed as 0.3 and 0.1, respectively, according to the third vector.
[0066] Step 204, determining a target function according to the sentiment word probability value, wherein the value of the target function is negatively related to the sum of the sentiment word probability value.
[0067] Optionally, the target function can be the negative logarithm of the sum of the sentiment word probability value.
[0068] As an example, the target function can be expressed as -log(sum([0, 0, 0.3, 0, 0, 0.1])) = -log(0.4).
[0069] Step 205, adjusting the hidden state information to obtain adjusted target hidden state information, with the value of the target function as the adjustment target.
[0070] For example, when the value of the target function decreases, the sum of the sentiment word probability value increases, and accordingly, the sentiment word probability value corresponding to at least one of the target sentiment words increases, thereby increasing the probability of the target sentiment word appearing in the reply information.
[0071] Optionally, this step can include: iteratively adjusting the hidden state information to obtain adjusted target hidden state information, with the value of the target function as the adjustment target, and the preset number of iterations. The advantage of this setting is that the hidden state information is adjusted in an iterative manner, which can gradually improve the sentiment word probability value corresponding to the target sentiment word while ensuring the accuracy of the target vocabulary.
[0072] The preset number of iterations is greater than 1, and the specific number can be determined according to actual needs, such as the demand intensity of outputting reply information with sentiment words and the computing power of the device. Optionally, the preset number of iterations is 3.
[0073] Optionally, the single-iteration adjustment is performed in the following manner: performing back propagation aiming at reducing the current value of the target function to obtain gradient information of the current hidden state information; and adjusting the current hidden state information according to the gradient information to obtain adjusted hidden state information. This arrangement has the advantage that the hidden state information can be adjusted quickly and accurately. The adjustment of the current hidden state information according to the gradient information to obtain adjusted hidden state information can specifically include: calculating the sum of the gradient information and the current hidden state information to obtain the adjusted hidden state information.
[0074] Step 206: determining the target probability value corresponding to each word in the preset word library according to the target hidden state information.
[0075] Step 207: determining the target reply information corresponding to the current dialogue based on the target probability value.
[0076] The dialogue reply determination method provided by the embodiments of the present application determines the sentiment word probability value of the sentiment word corresponding to the sentiment category of the current dialogue according to the probability value output by the preset dialogue model when determining the dialogue reply, uses the sum of the sentiment word probability values to construct a target function, and iteratively adjusts the hidden state output by the preset dialogue model with the reduction of the target function as the adjustment target, so as to gradually increase the probability that the reply contains the sentiment word corresponding to the current dialogue of the user, make the sentiment word more likely to appear in the reply information, and further improve the dialogue quality and user experience while taking into account the accuracy of the reply word and the target word determination efficiency.
[0077] For example, after the adjustment of the hidden state information, the probability that the reply information contains the sentiment word is increased, but there is a certain possibility that the relevance of the context is reduced, such as destroying consistency. For example, the historical interactive dialogue includes: "Which character do you like to play?" and "I like to play XX". The current dialogue of the user is "Why do you like XX", if the device replies "I don't play XX", it does not conform to the consistency, and if the device replies "because she is very powerful", it can be considered to conform to the consistency.
[0078] In some embodiments, in order to overcome the above problems, the scheme can be further optimized. For example, the target reply information corresponding to the current dialogue is determined based on the target probability value, which includes: determining candidate reply information corresponding to the current dialogue based on the target probability value and a preset decoding strategy; determining the association degree of the candidate reply information with the historical interactive dialogue; and determining the target reply information corresponding to the current dialogue from the candidate reply information according to the association degree. The advantage of this setting is that the candidate reply information can be determined first, and then the target reply information is determined based on the association degree of the candidate reply information with the historical interactive dialogue, which can ensure the context coherence of human-computer interaction and further improve the dialogue experience in the human-computer interaction process.
[0079] For example, the determination manner of the candidate reply information is not limited. For example, a preset number of sentences can be generated as the candidate reply information based on the target probability value and the preset decoding strategy.
[0080] Optionally, the target reply information corresponding to the current dialogue is determined from the candidate reply information according to the association degree, which specifically can include: determining the candidate reply information with the highest association degree as the target reply information corresponding to the current dialogue.
[0081] Optionally, the association degree includes a consistency probability value. The determination of the association degree of the candidate reply information with the historical interactive dialogue includes: determining the consistency probability value of the candidate reply information with the historical interactive dialogue by using a preset consistency detector, wherein the preset consistency detector is determined based on a classification model. The advantage of this setting is that whether the candidate reply information meets the context association requirement can be quickly and accurately determined. The model structure and training process of the preset consistency detector are not limited.
[0082] In some embodiments, to further ensure contextual consistency, target words can be selected by combining response templates from a response template library. For example, determining candidate response information corresponding to the current dialogue based on the target probability value and a preset decoding strategy includes: determining first candidate response information corresponding to the current dialogue based on the target probability value and the preset decoding strategy. The method further includes: determining second candidate response information corresponding to the current dialogue from a preset response template library; and determining a set of candidate response information based on the first and second candidate response information. Determining the degree of association between the candidate response information and the historical interactive dialogue includes: determining the degree of association between each candidate response information in the candidate response information set and the historical interactive dialogue. Determining the target response information corresponding to the current dialogue from the candidate response information based on the degree of association includes: determining the target response information corresponding to the current dialogue from the set of candidate response information based on the degree of association.
[0083] Figure 3 This is a flowchart illustrating another dialogue response determination method provided in an embodiment of this application, which is an optimization based on the above-described optional embodiments. Figure 4 This is a schematic diagram of a dialogue response determination process provided in an embodiment of this application, which can be combined with... Figure 4 The embodiments of this application will be understood. Figure 3 As shown, the method may include:
[0084] Step 301: Determine the target sentiment category corresponding to the user's current conversation, and determine the corresponding target preset sentiment word bag based on the target sentiment category.
[0085] like Figure 4 As shown, the current dialogue input by the user is fed into the sentiment classifier to obtain the target sentiment category, and then the corresponding target preset sentiment word bag is determined. The sentiment classifier, control module, and consistency detector in the figure can be understood as peripheral plug-ins of the preset dialogue model.
[0086] Step 302: Input the current dialogue and historical interaction dialogue into the preset dialogue model to obtain the hidden state information output by the preset dialogue model and the probability value corresponding to each word in the preset word library.
[0087] like Figure 4 As shown, the user's current dialogue and historical interaction dialogue are input into the preset dialogue model to obtain the response words (that is, each word in the preset word library) and the corresponding probability values, as well as the hidden state.
[0088] Step 303: Determine the probability value of the sentiment word corresponding to each target sentiment word in the target preset sentiment word bag.
[0089] Exemplarily, as shown in Figure 4 Steps 303 to 305 can be executed by the control module to adjust the hidden state.
[0090] Step 304: determining a target function according to the probability values of the emotional words, wherein the value of the target function is negatively correlated with the sum of the probability values of the emotional words.
[0091] Step 305: iteratively adjusting the hidden state information for a preset number of iterations, with the value of the target function as the adjustment target, to obtain updated target hidden state information.
[0092] In one iteration, the gradient information of the current hidden state information is obtained by back propagation with the current value of the target function as the target, and the updated hidden state information is obtained by adjusting the current hidden state information according to the gradient information.
[0093] Exemplarily, the preset number of iterations is 3. In the first iteration, the current value a1 of the target function is determined according to the probability value output by the preset dialogue model for the first time, the gradient information t1 of the current hidden state information (the hidden state information h1 output by the preset dialogue model for the first time) is obtained by back propagation with a1 as the target, the sum of t1 and h1 is calculated to obtain the updated hidden state information h2. In the second iteration, the current value a2 of the target function is determined according to the probability value output by the preset dialogue model with h2 as the input, the gradient information t2 of the current hidden state information (h2) is obtained by back propagation with a2 as the target, the sum of t2 and h2 is calculated to obtain the updated hidden state information h3. In the third iteration, the current value a3 of the target function is determined according to the probability value output by the preset dialogue model with h3 as the input, the gradient information t3 of the current hidden state information (h3) is obtained by back propagation with a3 as the target, the sum of t3 and h3 is calculated to obtain the updated hidden state information h4 (target hidden state information).
[0094] Step 306: determining the target probability value corresponding to each word in the preset word library according to the target hidden state information.
[0095] Exemplarily, the control module outputs the final updated target hidden state information to the preset dialogue model after determining that the preset number of iterations is reached. For example, h4 is input to the preset dialogue model to obtain the target probability value.
[0096] Step 307: determining the first candidate reply information corresponding to the current dialogue based on the target probability value and the preset decoding strategy.
[0097] Exemplarily, the first preset number (denoted as A) of sentences can be generated as the first candidate reply information based on the target probability value and a preset decoding strategy, that is Figure 4 a model reply in the first candidate reply information.
[0098] Step 308, determining the second candidate reply information corresponding to the current dialogue from the preset reply template library, and determining the candidate reply information set according to the first candidate reply information and the second candidate reply information.
[0099] Exemplarily, the preset reply template library can include the corresponding relationship between the user dialogue and the reply sentence, the similarity between the current dialogue and each user dialogue in the preset reply template library is calculated, the similarities are sorted from high to low, and the first B (second preset number) similarities corresponding to the user dialogue are selected as the target dialogue, and the reply sentence corresponding to the target dialogue is determined as the second candidate reply information, that is Figure 4 a template reply in the second candidate reply information. The first candidate reply information and the second candidate reply information are summarized, and the candidate reply information set can be obtained, such as the candidate reply information set including A+B candidate reply information.
[0100] Step 309, determining the consistency probability value of each candidate reply information in the candidate reply information set and the historical interactive dialogue by using a preset consistency detector.
[0101] The preset consistency detector is determined based on a classification model.
[0102] Exemplarily, for each candidate reply information in the candidate reply information set, the historical interactive dialogue and the current candidate reply information are input into the preset consistency detector, and the consistency probability value output by the preset consistency detector is obtained, and A+B consistency probability values can be obtained.
[0103] Step 310, determining the target reply information corresponding to the current dialogue from the candidate reply information set according to the consistency probability value.
[0104] Exemplarily, the candidate reply information with the highest consistency probability value can be determined as the target vocabulary included in the reply information corresponding to the current dialogue, that is Figure 4 the final reply in the target vocabulary, and then the final reply can be output to the user and added to the historical interactive dialogue.
[0105] The dialog reply determination method provided by the embodiments of the present application determines the emotion word probability value of the emotion word corresponding to the emotion category of the current dialog according to the probability value output by the preset dialog model when determining the dialog reply, constructs a target function by using the sum of the emotion word probability values, and iteratively adjusts the hidden state output by the preset dialog model with the adjustment target of reducing the target function, so as to gradually increase the probability that the emotion word corresponding to the current dialog of the user is contained in the reply, so that the emotion word is more likely to appear in the reply information while the accuracy and determination efficiency of the reply information are taken into account, and the step of consistency detection is added, the consistency probability of the reply in the preset reply template library and the reply generated based on the preset dialog model with the historical interactive dialog is calculated respectively, so as to ensure that the finally output reply meets the coherence requirement of the dialog process, and the dialog quality and user experience can be further improved.
[0106] Figure 5 The structural block diagram of the dialog reply determination device provided by the embodiments of the present application is shown in the figure. The device can be implemented by software and / or hardware, and can be integrated in a dialog reply determination device. The dialog reply can be determined by executing the dialog reply determination method. Figure 5 As shown in the figure, the device comprises:
[0107] The dialog input module 501 is configured to input the current dialog of the user and the historical interactive dialog into the preset dialog model, and obtain the hidden state information output by the preset dialog model and the probability value corresponding to each word in the preset word library, wherein the probability value is determined according to the hidden state information, and the probability value is used to represent the probability that the corresponding word appears in the to-be-determined reply information.
[0108] The emotion word bag determination module 502 is configured to determine the target emotion category corresponding to the current dialog, and determine the target preset emotion word bag corresponding to the target emotion category according to the target emotion category, wherein the emotion words in the preset emotion word bag are contained in the preset word library.
[0109] The hidden state adjustment module 503 is configured to adjust the hidden state information with the adjustment target of improving the emotion word probability value corresponding to the target emotion word in the target preset emotion word bag, and obtain the adjusted target hidden state information.
[0110] The target probability determination module 504 is configured to determine the target probability value corresponding to each word in the preset word library according to the target hidden state information.
[0111] The reply determination module 505 is configured to determine the target reply information corresponding to the current dialog based on the target probability value.
[0112] The dialogue reply determination apparatus provided in the embodiments of the present application inputs the current dialogue and the historical interaction dialogue of a user into a preset dialogue model, obtains hidden state information output by the preset dialogue model and probability values corresponding to each vocabulary in a preset vocabulary library, determines a target emotion category corresponding to the current dialogue, and determines a target preset emotion bag corresponding to the target emotion category according to the target emotion category, wherein emotion words in the preset emotion bag are contained in the preset vocabulary library. The emotion word probability value corresponding to the target emotion word in the target preset emotion bag is taken as an adjustment target, the hidden state information is adjusted to obtain adjusted target hidden state information, the target probability value corresponding to each vocabulary in the preset vocabulary library is determined according to the target hidden state information, and the target reply information corresponding to the current dialogue is determined based on the target probability value. By using the above technical solution, when the dialogue reply is determined, the hidden state output by the preset dialogue model is adjusted to improve the probability that the emotion words corresponding to the current dialogue of the user are contained in the reply, so that the emotion words are more likely to appear in the reply information, that is, the dialogue system has more empathy, the dialogue quality and user experience are improved, and the training cost of the dialogue model can be effectively reduced without relying on training the preset dialogue model by using a large amount of emotion dialogue data.
[0113] Optionally, the hidden state adjustment module comprises:
[0114] The emotion word probability value determination unit is configured to determine emotion word probability values corresponding to each target emotion word in the target preset emotion bag.
[0115] The target function determination unit is configured to determine a target function according to the emotion word probability values, wherein the value of the target function is negatively correlated with the sum of the emotion word probability values.
[0116] The adjustment unit is configured to adjust the hidden state information to obtain adjusted target hidden state information, with the value of the target function being taken as an adjustment target.
[0117] Optionally, the probability values corresponding to each vocabulary in the preset vocabulary library constitute a first vector according to the positions of the each vocabulary in the preset vocabulary library, and the positions of each target emotion word in the target preset emotion bag in the preset vocabulary library are encoded as a second vector.
[0118] The emotion word probability value determination unit is specifically configured to:
[0119] According to the product of the first vector and the second vector, determine the emotion word probability values corresponding to each target emotion word in the target preset emotion bag.
[0120] Optionally, the adjustment unit is specifically configured to:
[0121] The preset number of iterations is adopted to iteratively adjust the hidden state information, so as to obtain adjusted target hidden state information, with the aim of reducing the value of the target function.
[0122] Optionally, the adjustment unit performs single iteration adjustment in the following manner:
[0123] The gradient information of the current hidden state information is obtained by back propagation with the aim of reducing the current value of the target function.
[0124] The current hidden state information is adjusted according to the gradient information, so as to obtain adjusted hidden state information.
[0125] Optionally, the reply determination module comprises:
[0126] The first candidate reply information determination unit is configured to determine the candidate reply information corresponding to the current dialogue based on the target probability value and a preset decoding strategy.
[0127] The correlation degree determination unit is configured to determine the correlation degree between the candidate reply information and the historical interactive dialogue.
[0128] The target vocabulary determination unit is configured to determine the target reply information corresponding to the current dialogue from the candidate reply information according to the correlation degree.
[0129] Optionally, the first candidate reply information determination unit is configured to determine the first candidate reply information corresponding to the current dialogue based on the target probability value and a preset decoding strategy.
[0130] The device further comprises:
[0131] The second candidate reply information determination unit is configured to determine the second candidate reply information corresponding to the current dialogue from a preset reply template library.
[0132] The candidate reply information combination determination unit is configured to determine a candidate reply information set according to the first candidate reply information and the second candidate reply information.
[0133] The correlation degree determination unit is specifically configured to:
[0134] determine the correlation degree between each candidate reply information in the candidate reply information set and the historical interactive dialogue.
[0135] The target vocabulary determination unit is specifically configured to:
[0136] determine the target reply information corresponding to the current dialogue from the candidate reply information set according to the correlation degree.
[0137] Optionally, the degree of association comprises a consistency probability value.
[0138] The degree of association determination unit is specifically configured to:
[0139] determine, by using a preset consistency detector, a consistency probability value of each candidate reply information in the candidate reply information set and the historical interaction dialogue, wherein the preset consistency detector is determined based on a classification model.
[0140] The embodiment of the present application provides a dialogue reply determination device. Figure 6 A structural block diagram of a dialogue reply determination device provided by the embodiment of the present application is provided. The dialogue reply determination device 600 comprises a processor 601 and a memory 602 connected with the processor 601, wherein the memory 602 stores a computer program executable by the processor 701, and the computer program is executed by the processor 601 to enable the processor 601 to execute the dialogue reply determination method provided by any embodiment of the present application. The number of processors can be one or more. Figure 6 The processor is taken as an example in the embodiment.
[0141] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is used to enable the processor to execute the dialogue reply determination method provided by any embodiment of the present application.
[0142] The embodiment of the present application further provides a computer program product, which comprises a computer program, and the computer program is used to enable the processor to execute the dialogue reply determination method provided by any embodiment of the present application.
[0143] The dialogue reply determination device, the dialogue reply determination device, the storage medium and the product provided in the above embodiments can execute the dialogue reply determination method provided by any embodiment of the present application, and have the corresponding function modules and beneficial effects of executing the method. Technical details not described in the above embodiments can be referred to the dialogue reply determination method provided by any embodiment of the present application.
Claims
1. A method for determining a dialogue response, characterized in that, include: The user's current dialogue and historical interaction dialogue are input into a preset dialogue model to obtain the hidden state information output by the preset dialogue model and the probability value corresponding to each word in the preset word library. The probability value is determined according to the hidden state information and is used to represent the probability that the corresponding word appears in the response information to be determined. Determine the target emotion category corresponding to the current dialogue, and determine the corresponding target preset emotion word bag based on the target emotion category, wherein the emotion words in the preset emotion word bag are included in the preset word library; The hidden state information is adjusted by increasing the probability value of the target emotional word corresponding to the target emotional word in the target preset emotional word bag, so as to obtain the adjusted target hidden state information. The target probability value corresponding to each word in the preset word library is determined based on the target hidden state information. The target response information corresponding to the current dialogue is determined based on the target probability value.
2. The method according to claim 1, characterized in that, The adjustment of the hidden state information by increasing the probability value of the target emotional word corresponding to the target emotional word in the target preset emotional word bag, to obtain the adjusted target hidden state information, includes: Determine the probability value of the sentiment word corresponding to each target sentiment word in the target preset sentiment word bag; A target function is determined based on the probability values of the sentiment words, wherein the value of the target function is negatively correlated with the sum of the probability values of the sentiment words; The hidden state information is adjusted by reducing the value of the objective function to obtain the adjusted target hidden state information.
3. The method according to claim 2, characterized in that, in, The probability values corresponding to each word in the preset word library are used to form a first vector based on the position of each word in the preset word library, and the position of each target emotion word in the target preset emotion word bag is encoded as a second vector in the preset word library; The step of determining the probability value of each target sentiment word in the target preset sentiment word bag includes: Based on the product of the first vector and the second vector, the probability value of the emotional word corresponding to each target emotional word in the target preset emotional word bag is determined.
4. The method according to claim 2, characterized in that, The adjustment of the hidden state information by reducing the value of the objective function to obtain the adjusted target hidden state information includes: The goal is to reduce the value of the objective function. The hidden state information is iteratively adjusted using a preset number of iterations to obtain the adjusted target hidden state information.
5. The method according to claim 4, characterized in that, Perform a single iteration adjustment in the following manner: Backpropagation is performed with the goal of reducing the current value of the objective function to obtain the gradient information of the current hidden state. The current hidden state information is adjusted based on the gradient information to obtain the adjusted hidden state information.
6. The method according to claim 1, characterized in that, Determining the target response information corresponding to the current dialogue based on the target probability value includes: Based on the target probability value and the preset decoding strategy, determine the candidate response information corresponding to the current dialogue; Determine the degree of correlation between the candidate response information and the historical interactive dialogue; Based on the degree of correlation, the target response information corresponding to the current dialogue is determined from the candidate response information.
7. The method according to claim 6, characterized in that, The step of determining the candidate response information corresponding to the current dialogue based on the target probability value and a preset decoding strategy includes: The first candidate response information corresponding to the current dialogue is determined based on the target probability value and the preset decoding strategy. The method further includes: Determine the second candidate response information corresponding to the current dialogue from the preset response template library; A set of candidate response information is determined based on the first candidate response information and the second candidate response information; The step of determining the correlation between the candidate response information and the historical interactive dialogue includes: Determine the degree of correlation between each candidate response in the candidate response information set and the historical interactive dialogue; The step of determining the target words contained in the target response information corresponding to the current dialogue from the candidate response information based on the degree of correlation includes: Based on the degree of correlation, the target response information corresponding to the current dialogue is determined from the candidate word set.
8. The method according to claim 7, characterized in that, The degree of correlation includes a consistency probability value; Determining the correlation between each candidate response in the candidate vocabulary set and the historical interactive dialogue includes: Using a preset consistency detector, the consistency probability value between each candidate response information in the candidate response information set and the historical interactive dialogue is determined, wherein the preset consistency detector is determined based on a classification model.
9. A dialogue response determining device, characterized in that, include: The dialogue input module is used to input the user's current dialogue and historical interaction dialogue into a preset dialogue model to obtain the hidden state information output by the preset dialogue model and the probability value corresponding to each word in the preset word library. The probability value is determined according to the hidden state information and is used to represent the probability that the corresponding word appears in the response information to be determined. The emotion bag-of-words determination module is used to determine the target emotion category corresponding to the current dialogue, and determine the corresponding target preset emotion bag-of-words based on the target emotion category, wherein the emotion words in the preset emotion bag-of-words are included in the preset word library; The hidden state adjustment module is used to adjust the hidden state information by increasing the probability value of the emotional word corresponding to the target emotional word in the target preset emotional word bag, so as to obtain the adjusted target hidden state information. The target probability determination module is used to determine the target probability value corresponding to each word in the preset word library based on the target hiding state information. The response determination module is used to determine the target response information corresponding to the current dialogue based on the target probability value.
10. A dialogue response confirmation device, characterized in that, The dialogue response determination device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, which enables the at least one processor to perform the dialogue response determination method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the dialogue response determination method according to any one of claims 1-8.
12. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the dialogue response determination method according to any one of claims 1-8.
Citation Information
Patent Citations
Emotion classification method based on transfer learning and ON-LSTM
CN110580287A
Method and device for generating emotion-containing intelligent customer service dialogue reply and electronic equipment
CN111522936A