Response method and device
By combining intent recognition and emotion recognition models with dialogue models, the limitations of point-and-click intelligent dialogue systems are overcome, achieving accurate, personalized, and empathetic responses, thereby improving user experience and response efficiency.
Patent Information
- Application Number
- CN202410868050.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-11-22
AI Technical Summary
Existing point-and-click intelligent dialogue systems suffer from difficulties in understanding complex semantics and handling polysemous words, resulting in a poor user experience, an inability to flexibly understand questions, and limitations in predefined options that prevent the system from providing accurate answers or solutions.
By combining intent recognition and emotion recognition models with dialogue models to generate targeted responses, we can achieve accurate, personalized, and empathetic responses, thereby enhancing the user experience.
This improved the accuracy of responses and user satisfaction, making the generated target responses more likely to be adopted and accepted by users, thus increasing response efficiency.
Smart Images

Figure CN119003710A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a response method and device. Background Art
[0002] With the development of artificial intelligence technology, artificial intelligence is gradually becoming an important force affecting the future development of the industry. From smart phones, smart homes to autonomous driving, artificial intelligence has been involved in all aspects of people's lives. Similarly, for common dialogue systems, intelligent dialogue systems can not only effectively save human resources, but also have the advantages of fast response and continuous service. At present, the common intelligent dialogue system in web pages or applications is a point-and-click dialogue system, in which users dialogue and communicate with the system by selecting the options provided by the system.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:
[0004] Although this point-and-click intelligent dialogue system is relatively simple to implement, it has many limitations. For example, the limitation of semantic understanding: the point-and-click intelligent dialogue system has difficulties in complex semantic understanding and polysemous word processing, and cannot understand the problem flexibly; the limitation of user experience: users can only interact with the system by selecting predefined options, which gives a poor experience; the limitation of predefined options: if the user's question is not within the range of options, the system may not be able to provide an accurate answer or solution. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a method and device for answering, which achieves accuracy, personalization and empathy in answering, which not only overcomes the limitations of point-and-click answering, effectively improves the user experience, enhances user satisfaction, and improves service quality, but also the generated target answers are more easily adopted and accepted by users, thereby truly improving answering efficiency.
[0006] To achieve the objective, according to one aspect of an embodiment of the present invention, a method for responding is provided, including:
[0007] In response to receiving a response request sent by the requester, parsing the response request to obtain question information;
[0008] Performing intention recognition and emotion recognition on the question information respectively to obtain an intention recognition result and an emotion recognition result;
[0009] Using a pre-built dialogue model to generate a native response corresponding to the question information;
[0010] A target response is generated based on the intention recognition result, the emotion recognition result, and the native response, and the target response is returned to the requesting party.
[0011] Optionally, the question information is subjected to separate intention recognition and emotion recognition to obtain intention recognition results and emotion recognition results, including: inputting the question information into a pre-built intention recognition model to obtain the intention recognition result output by the intention recognition model, wherein the intention recognition model includes a context encoding layer, a priori network and a recognition network; inputting the question information into a pre-built emotion recognition model to obtain the emotion recognition result output by the emotion recognition model, wherein the emotion recognition model includes a context information encoding layer and a historical dialogue encoding layer.
[0012] Optionally, the intention recognition model is constructed in the following manner: obtaining the historical conversation record corresponding to the response request, and using the context encoding layer in a pre-constructed intention recognition initial model to encode the historical conversation record to obtain a context hidden state; based on the context hidden state, predicting the intention category of the question information through the prior initial network in the intention recognition initial model, and obtaining a first distribution result of intention; based on the historical conversation record, identifying the intention category of the question information through the recognition network in the pre-constructed intention recognition initial model, and obtaining a second distribution result of intention; determining the divergence loss function value of the intention recognition initial model based on the first distribution result and the second distribution result, using the divergence loss function value to adjust the parameters of the intention recognition initial model to construct an intention recognition model.
[0013] Optionally, after obtaining the second distribution result of intention, the method also includes: selecting the target intention category with the highest probability in the second distribution result of intention; determining the response reconstruction loss function value based on the target intention category and the historical conversation record; and using the divergence loss function value to adjust the parameters of the initial model of intention recognition, including: using the response reconstruction loss function value and the divergence loss function value to adjust the parameters of the initial model of intention recognition.
[0014] Optionally, the emotion recognition model is constructed in the following manner: extracting context words from the question information, encoding the context words through a context information encoding layer in a pre-constructed emotion recognition initial model to generate a context vector; obtaining a historical conversation record corresponding to the response request, encoding the historical conversation record through a historical conversation encoding layer in the emotion recognition initial model to generate a historical vector; fusing the context vector and the historical vector to obtain a fused feature vector; applying an activation function to the fused feature vector to obtain the probability of the emotion category corresponding to the question information, and then determining a cross-entropy loss function value; and using the cross-entropy loss function value to adjust the parameters of the emotion recognition initial model to construct an emotion recognition model.
[0015] Optionally, a target response is generated based on the intention recognition result, the emotion recognition result, and the native response, including: weighted summing the intention recognition result, the emotion recognition result, and the native response according to preset intention weights, emotion weights, and native weights to obtain a target response vector; and using a vector-to-text conversion function to convert the target response vector into text form to generate a target response.
[0016] Optionally, the method further includes: splicing the question information, the native response, the intention recognition result, and the emotion recognition result to generate training samples for the dialogue model to iteratively train the dialogue model.
[0017] According to a second aspect of an embodiment of the present invention, a response device is provided, including:
[0018] A question acquisition module, configured to, in response to receiving a response request sent by a requester, parse the response request to acquire question information;
[0019] The intention and emotion recognition module performs intention recognition and emotion recognition on the question information to obtain intention recognition results and emotion recognition results;
[0020] A native response generation module, used to generate a native response corresponding to the question information using a pre-built dialogue model;
[0021] A target response generation module is used to generate a target response based on the intention recognition result, the emotion recognition result, and the native response, and return the target response to the requester.
[0022] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for responding, including:
[0023] one or more processors;
[0024] a storage device for storing one or more programs,
[0025] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0026] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0027] An embodiment of the invention has the following advantages or beneficial effects: by responding to a response request sent by a requesting party, parsing the response request to obtain question information; performing intent recognition and emotion recognition on the question information respectively to obtain intent recognition results and emotion recognition results; using a pre-built dialogue model to generate a native response corresponding to the question information; generating a target response based on the intent recognition results, emotion recognition results, and native responses, and returning the target response to the requesting party. The technical solution achieves accuracy, personalization, and empathy in the response, which not only overcomes the limitations of point-and-click responses, effectively improves user experience, enhances user satisfaction, and improves service quality, but also makes the generated target responses more easily adopted and accepted by users, thereby truly improving the efficiency of responses. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0029] Figure 1 is a schematic diagram of the main flow of the response method according to an embodiment of the present invention;
[0030] Figure 2 It is an overall principle diagram of the response method of an embodiment of the present invention;
[0031] Figure 3 is a flow chart of generating a target response according to an embodiment of the present invention;
[0032] Figure 4 is a schematic diagram of main modules of a response device according to an embodiment of the present invention;
[0033] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0034] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0035] It should be noted that in the technical solution of the present invention, the collection / collection, updating, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, disclosed or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken for user personal information to selectively block the use or access to personal information data to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. In addition, once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.
[0036] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention 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 and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0037] Although the existing point-and-click intelligent dialogue system is relatively simple to implement, it has many limitations. For example, the limitation of semantic understanding: the point-and-click intelligent dialogue system has difficulties in complex semantic understanding and polysemous word processing, and cannot understand the problem flexibly; the limitation of user experience: users can only interact with the system by selecting predefined options, which gives a poor experience; the limitation of predefined options: if the user's question is not within the range of options, the system may not be able to provide an accurate answer or solution.
[0038] In order to solve the above problems existing in the prior art, the present invention proposes a method of answering, which generates a target answer with emotion based on the native answer of the question information generated by the dialogue model, combined with the intention recognition and emotion recognition of the question information, and the obtained intention recognition results and emotion recognition results. The accuracy, personalization and empathy of the answer are achieved, which not only overcomes the limitations of point-and-click answering, effectively improves the user experience, enhances user satisfaction, and improves service quality, but also the generated target answer is easier to be adopted and accepted by users, thereby truly improving the efficiency of answering.
[0039] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:
[0040] GRU: GRU (Gated Recurrent Unit) is a variant of Recurrent Neural Network (RNN) used to process sequence data and time series modeling. GRU solves the gradient vanishing and gradient exploding problems in traditional RNN by introducing a gating mechanism, and provides better long-term dependency modeling capabilities;
[0041] Attention: The Attention mechanism is a technique used in deep learning to strengthen the model's attention to and selective processing of input information. It dynamically gives different weights to different input parts, allowing the model to focus more on information related to the current task;
[0042] FFN: Feed-Forward Network (FFN) is a basic neural network structure, also known as Fully Connected Neural Network or Multilayer Perceptron (MLP).
[0043] BERT: BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained deep bidirectional Transformer model;
[0044] KL divergence: KL divergence (Kullback-Leibler Divergence), also known as relative entropy, is a measure of the difference between two probability distributions. KL divergence is used to compare the degree of difference between two probability distributions P and Q, indicating the information loss from probability distribution Q to probability distribution P.
[0045] Figure 1 is a schematic diagram of the main flow of the response method according to an embodiment of the present invention, such as Figure 1 As shown, the response method of the embodiment of the present invention includes the following steps S101 to S103.
[0046] Step S101: In response to receiving a response request sent by a requester, the response request is parsed to obtain question information.
[0047] Specifically, the intelligent dialogue system is a human-computer interaction technology that aims to enable computers to have natural and smooth dialogues with humans. It is widely used in real life. In the field of education, it can serve as a learning companion to provide personalized learning support and feedback; in the medical field, it can be used for health consultation, disease diagnosis and other aspects; in the financial field, the intelligent dialogue system can provide customer service, investment consultation and other services; in the field of e-commerce, it can provide personalized transaction product recommendations, shopping guidance and other services. The embodiment of the present invention supports intelligent dialogue in various business application scenarios. The requester uses voice or text to input dialogue questions on the client, and sends a response request with the dialogue question to the intelligent dialogue system through the language termination mark or the send button of the text box. The intelligent dialogue system parses the received response request and obtains the question information with the question content.
[0048] Step S102: perform intention recognition and emotion recognition on the question information respectively to obtain intention recognition results and emotion recognition results.
[0049] Specifically, the obtained question information is matched with the preset intention markers and emotion markers, and the intention recognition and emotion recognition are performed by matching the intention markers and emotion markers, thereby obtaining the intention recognition results and emotion recognition results. For example, for the intelligent customer service dialogue business scenario in the e-commerce field, the intention markers for pre-sales consultation are set as "which size", "can I get a discount", etc., and the emotion markers for positive emotions are set as "thank you", "please ask", etc., and the question information is matched with the intention markers and emotion markers. When the matching similarity reaches the preset threshold, the match is considered successful, and the intention type and emotion type to which the successfully matched marker belongs are the intention recognition results and emotion recognition results.
[0050] According to one embodiment of the present invention, the question information is respectively subjected to intention recognition and emotion recognition to obtain intention recognition results and emotion recognition results, including: inputting the question information into a pre-built intention recognition model to obtain the intention recognition result output by the intention recognition model, the intention recognition model including a context encoding layer, a priori network and a recognition network; inputting the question information into a pre-built emotion recognition model to obtain the emotion recognition result output by the emotion recognition model, the emotion recognition model including a context information encoding layer and a history dialogue encoding layer.
[0051] Specifically, when the question information includes intention markers and emotion markers, the above method can obtain the intention recognition result and emotion recognition result of the question information. However, in most cases, there may not be a complete expression in the question, and it is more scientific to use the conversation history to recognize the intention and emotion. The embodiment of the present invention uses a more scientific model with high accuracy to perform intention recognition and emotion recognition on the question information. The intention recognition model and the emotion recognition model are constructed in advance. For intention recognition: the question information is input into the intention recognition model, and the historical conversation record corresponding to the received answer request is encoded into the hidden state of the context through the context encoding layer in the intention recognition model; according to the hidden state and the current question information, the distribution of possible various intentions of the question information is predicted through the prior network, and finally the final intention category is determined by the recognition network according to the distribution of various intentions output by the prior network, and the intention recognition result is output. For emotion recognition: the question information is input into the emotion recognition model, the context information encoding layer in the emotion recognition model encodes the context of the question information, and the historical conversation record corresponding to the answer request is historically encoded through the historical conversation encoding layer; then the context information and the historical encoding are combined to output the emotion recognition result.
[0052] It is understandable that the execution order of the intention recognition and emotion recognition in the embodiment of the present invention is not limited. It can be that the intention recognition of the question information is performed first, and then the emotion recognition of the question information is performed; it can also be that the emotion recognition of the question information is performed first, and then the intention recognition of the question information is performed; it can also be that the intention recognition and emotion recognition of the question information are performed at the same time. The specific execution order is selected according to needs.
[0053] According to another embodiment of the present invention, the intention recognition model is constructed in the following manner: obtaining the historical conversation record corresponding to the response request, and using the context encoding layer in the pre-constructed intention recognition initial model to encode the historical conversation record to obtain the context hidden state; based on the context hidden state, predicting the intention category of the question information through the prior initial network in the intention recognition initial model, and obtaining the first distribution result of intention; based on the historical conversation record, identifying the intention category of the question information through the recognition network in the pre-constructed intention recognition initial model, and obtaining the second distribution result of intention; determining the divergence loss function value of the intention recognition initial model based on the first distribution result and the second distribution result, using the divergence loss function value to adjust the parameters of the intention recognition initial model to construct an intention recognition model.
[0054] Specifically, the accuracy of the intent recognition result obtained by the intent recognition model mainly depends on the performance of the intent recognition model, and the performance of the intent recognition model depends on the training of the model. Before the question information is input into the pre-built intent recognition model, the historical conversation record C corresponding to the answer request is obtained, and the context encoding layer uses a gated recurrent unit to encode the context of each time step. Specifically, for each time step t, the context encoder receives the hidden state h of the previous time step t-I and the word embedding E(c t ), where c t represents the tth word in the context; then, the hidden state h of the current time step is calculated through the update gate, reset gate and new state of the gated recurrent unit t . This process can be expressed by the following formula:
[0055] h t =GRU(h t-I ,E(c t )),
[0056] Among them, h t represents the hidden state of the current time step, h t-I represents the hidden state of the previous time step, E(c t ) represents the word embedding of the current time step, GRU represents the use of gated recurrent unit encoding. Through this process, the context encoding layer encodes the conversation history C into a series of hidden states h1, h2, ..., hm, where m represents the length of the conversation history. The formula is as follows:
[0057] h m =GRU(h m-I ,h t ).
[0058] The context coding layer of the embodiment of the present invention uses a gated recurrent unit (GRU) to encode the input to obtain a hidden state. Of course, the calculation formula of the context coding layer can be adjusted according to the specific GRU implementation, for example, more gating mechanisms can be added or other recurrent neural network structures such as long short-term memory networks can be used to improve the performance of the context coding layer.
[0059] Furthermore, the a priori initial network selects to use a feedforward neural network with two hidden layers to map the hidden state of the above context encoding layer to obtain the distribution of each intention of the predicted question information, that is, the first distribution result of the intention p i (z|C), this mapping process can be expressed by the following formula:
[0060] p i (z|C)=Softmax(FFNz (h m )),
[0061] Where FFN represents a feedforward neural network with two hidden layers, z represents the index of intent, and i represents the index of intent distribution, which is used to represent different intent categories, such as “asking for product information”, “complaining about service quality”, etc. If there are three possible intent categories, then i can be 1, 2, or 3, representing different intent types respectively.
[0062] For the recognition network in the initial model of intent recognition, the intent classifier of the pre-trained language model is selected for encoding, and the historical conversation record C is used as input to embed each word into E(c t ) is encoded by the intent classifier of the pre-trained language model, and then the encoded representation is mapped to the probability distribution of each emotion category through the activation function, which is the second distribution result of the intent. This process can be expressed by the following formula:
[0063] q r (z|X)=Softmax(Bert(E(c t ))),
[0064] Among them, q r (z|X) represents the probability distribution of each sentiment category z given the context C, Bert represents the pre-trained language model for intent classification, and E(c t ) represents word embedding.
[0065] Finally, considering that the priori initial network in the intent recognition initial model needs to be trained, while the recognition network does not need additional training, the training of the intent recognition initial model is achieved by training the priori initial network. The embodiment of the present invention uses KL divergence to measure the difference between the first distribution result of intent and the second distribution result of intent, and determines the divergence loss function value according to the divergence loss function of the intent recognition initial model:
[0066]
[0067] where q r (z|X) represents the second distribution result of the recognition network output, p i (z|C) represents the first distribution result of intent predicted by the prior network. The goal of this loss function is to make the predicted first distribution result of intent as close as possible to the second distribution result of recognized intent. Then, according to the divergence loss function, the parameters of the prior initial network in the intent recognition initial model are adjusted to obtain the trained prior network, and finally an intent recognition model with good performance is established.
[0068] According to another embodiment of the present invention, after obtaining the second distribution result of intention, the method also includes: selecting the target intention category with the highest probability in the second distribution result of intention; determining the response reconstruction loss function value based on the target intention category and the historical conversation record; and using the divergence loss function value to adjust the parameters of the initial model of intention recognition, including: using the response reconstruction loss function value and the divergence loss function value to adjust the parameters of the initial model of intention recognition.
[0069] Specifically, considering that the prior network may sample the wrong intent, and thus introduce uncertainty and noise into the sample, in order to further ensure the performance of the intent recognition model, after obtaining the second distribution result of the intent, the embodiment of the present invention uses the arg max function to select the target intent category with the highest probability in the second distribution result of the intent:
[0070]
[0071] Then, given the historical dialogue record C and the target intent category z k The probability p(X|C, z) of generating a reply X when k ), according to the response reconstruction loss function used to measure the difference between the response generated by the initial model of intent recognition and the true response, determine the response reconstruction loss function value:
[0072]
[0073] Finally, combining the above divergence loss function values, the overall loss function of the initial model of intent recognition is obtained as follows:
[0074]
[0075] By minimizing the divergence loss function and minimizing the response reconstruction loss function, the parameters of the initial intent recognition model are adjusted to obtain an intent recognition model that can accurately identify intent categories.
[0076] According to another embodiment of the present invention, the emotion recognition model is constructed in the following manner: extracting context words from the question information, encoding the context words through the context information encoding layer in the pre-constructed emotion recognition initial model to generate a context vector; obtaining the historical conversation record corresponding to the response request, encoding the historical conversation record through the historical conversation encoding layer in the emotion recognition initial model to generate a history vector; fusing the context vector and the history vector to obtain a fused feature vector; using an activation function on the fused feature vector to obtain the probability of the emotion category corresponding to the question information, and then determining the cross entropy loss function value; using the cross entropy loss function value to adjust the parameters of the emotion recognition initial model to construct an emotion recognition model.
[0077] Specifically, in order to improve the emotion recognition capability of the intelligent dialogue system, it is necessary to obtain rich emotion information in the encoding stage. The accuracy of the emotion recognition results obtained by the emotion recognition model mainly depends on the performance of the emotion recognition model, and the performance of the emotion recognition model depends on the training of the model. Before the question information is input into the pre-built emotion recognition model, context words are extracted from the question information, and the context words are encoded using the context information encoding layer to obtain a hidden vector with context features: the context vector h s ; Then input the historical conversation record C corresponding to the answer request into the historical conversation encoding layer, and output the hidden vector with historical conversation features: historical vector h D The two vectors are then fused using the feature fusion layer, which is designed based on the idea of the attention mechanism and calculates the history vector h D and the context vector h S The fused feature vector after fusion:
[0078]
[0079] in, It is mainly used to scale the attention weights to ensure that the size of the attention weights is reasonable in higher dimensions. k is the dimension of the vector used to calculate the attention weights in the attention mechanism.
[0080] Furthermore, the fused feature vector is linearly transformed, and the activation function is used to calculate the probabilities of different emotion categories corresponding to the question information. This process can be expressed by the following formula:
[0081] p(h)=softmax(Liner(h)),
[0082] Then, according to the cross entropy loss function of the initial model of emotion recognition, the cross entropy loss function value is determined:
[0083]
[0084] in, It means to sum all categories. is the probability of the i-th emotion in the true emotion distribution, p i is the probability of the i-th emotion in the probability distribution of the model output. Finally, we use optimization algorithms such as gradient descent to minimize the cross entropy loss function, adjust the parameters of the initial emotion recognition model, and obtain an emotion recognition model that can accurately identify the emotion category of the question information.
[0085] Step S103: Use the pre-built dialogue model to generate a native response corresponding to the question information.
[0086] Specifically, the embodiment of the present invention uses the open source Chinese-English bilingual dialogue model ChatGLM2-6B as the dialogue generation model base, but it is not limited to this. The advantage of ChatGLM is that the number and length of the blank parts in the text can be adjusted according to the requirements of the task, adapting to different types of tasks, and having good generalization ability and efficiency, and can support more rounds of dialogue. Input the question information into the pre-built ChatGLM2-6B dialogue model, and the dialogue model combines the local knowledge base, such as common questions, user feedback, common replies and other data, to output the native response corresponding to the question information.
[0087] Step S104: Generate a target response based on the intention recognition result, the emotion recognition result, and the native response, and return the target response to the requesting party.
[0088] Specifically, the above method can be used to obtain the intention recognition result of the question information. The intention recognition result is usually the category of intent, such as "query", "order", "feedback", "refund", etc. The emotion recognition result of the question information can also be obtained. The emotion recognition result is usually an emotion category or an emotion score. The emotion category can be predefined as "positive", "negative", "neutral", etc. The emotion score indicates the intensity of emotion carried by the question information. The intention recognition result and the emotion recognition result are combined into the intention emotion result corresponding to the question information, and then the intention emotion result is added to the dialogue model as a conditional input. The dialogue model processes the intention emotion result and the native response to generate an emotion response that matches the intention of the question information. Figure 1 The target response is consistent and empathetic, and finally the target response is returned to the requesting user as the response result of the response request.
[0089] Figure 2 It is an overall schematic diagram of the response method of an embodiment of the present invention. It is divided into four parts as a whole: a front-end interaction part, a data support part, an empathy analysis and identification part, and a target response generation part. The front-end interaction part is mainly responsible for displaying data, receiving question input from the requester or user, and sending the response request from the requester or user to the back-end for processing. Specifically, web-related technologies (such as HTML, CSS, JavaScript) are used to build the user interface, and the user's response request is transmitted and the response result of the response request is received through communication with the back-end. The data support part mainly includes data preprocessing such as cleaning and filtering of basic data, as well as local knowledge bases of customer service dialogue scenarios such as local dialogue knowledge bases, rule bases and databases, which are used to support the processing of problem information and the generation of responses.
[0090] The empathy analysis and recognition part in the figure mainly includes intent recognition and emotion recognition. It is responsible for processing the question data transmitted from the front end and analyzing the intent category of the question information through the intent recognition model, such as "after-sales" and "consultation". It can be seen that the intent recognition model mainly includes the context encoding layer, the prior network, and the recognition network. Before performing intent recognition, it is necessary to train the model to obtain an intent recognition network with accurate intent recognition capabilities, and then perform intent recognition on the question information to obtain the intent recognition result of the question information, that is, the intent category. After intent recognition, the emotion recognition model is used to perform emotion recognition on the question information. The emotion recognition model mainly includes the text preprocessing layer for word segmentation, the context encoding layer, and the historical dialogue encoding layer. Similarly, before performing emotion recognition on the question information, the model is trained to obtain an emotion recognition network with accurate emotion recognition capabilities, and then perform emotion recognition on the question information to obtain the emotion recognition result of the question information, that is, the emotion category. The target response generation part first generates the native response to the question information through the dialogue model, and then combines the intent recognition results and the emotion recognition results to generate a target response with empathy and consistent with the intent of the question information, providing users with a more comprehensive, effective, and emotionally valuable target response.
[0091] According to one embodiment of the present invention, a target response is generated based on the intention recognition result, the emotion recognition result, and the native response, including: according to preset intention weights, emotion weights, and native weights, weighted summation of the intention recognition result, the emotion recognition result, and the native response is performed to obtain a target response vector; and using a vector-to-text conversion function to convert the target response vector into a target response in text form.
[0092] Specifically, in order to more flexibly control the correlation between the generated target response and the intent recognition result and the emotion recognition result, the embodiment of the present invention sets specific intent weights, emotion weights, and native weights according to different business scenarios, and inputs the intent recognition result and the emotion recognition result into the dialogue model respectively. The dialogue model performs weighted summation of the intent recognition result, the emotion recognition result, and the native response according to various corresponding weights to determine the proportion of various components in the target response to be generated. The calculation formula is as follows:
[0093] H1=α·p i (glm)+β·p i (z)+γ·p x (h),
[0094] where p i (glm) is the raw response output by the ChatGLM2-6B model, p i (z) is the result of intention recognition, p x(h) is the emotion recognition result. α, β, and γ are the native weight, intention weight, and emotion weight, respectively. The weight value can be adjusted as needed to generate the intention weight. Figure 1 The target response vector with empathy is generated. The pre-packaged vector-to-text conversion function vector_to_sentence is then used to convert the target response vector into a textual target response in combination with the contextual scene. If the emotional weight accounts for a large proportion, it means that a strong empathy expression needs to be added, such as "I'm really sorry that I gave you a bad experience" or "Thank you for your recognition", etc., to meet the needs of the dialogue and enhance the user's experience of dialogue and communication.
[0095] According to another embodiment of the present invention, the method further includes: splicing the question information, the native response, the intention recognition result, and the emotion recognition result to generate training samples for the dialogue model to iteratively train the dialogue model.
[0096] Specifically, the embodiments of the present invention can also make full use of the learning ability of the dialogue model to splice the native responses, intent recognition results and emotion recognition results corresponding to the question information obtained above, and construct question information and corresponding response training samples containing intent, emotion and native responses, so as to facilitate iterative training of the dialogue model, help the dialogue model better understand the user's intentions and emotions, and generate diversified target responses.
[0097] Figure 3 This is a flow chart for generating a target response according to an embodiment of the present invention. According to the received response request, the question information and the conversation history context corresponding to the response request are obtained, and the context hidden state is obtained through the context encoding layer in the intent recognition model. Based on the context hidden state, the intent recognition result is obtained through the prior network and the recognition network in the intent recognition model, and the emotion recognition result of the question information is obtained through the emotion recognition model. The ChatGLM2-6B dialogue model is then used in combination with the local knowledge base to generate a native response to the question information, and the intent recognition result and the emotion recognition result are input as conditions into the ChatGLM2-6B dialogue model. The ChatGLM2-6B dialogue model generates a response that empathizes with the user and is consistent with the intent based on the intent recognition result, the emotion recognition result and the native response. Figure 1 The target answer with the valid solution is returned to the requesting user.
[0098] The embodiment of the present invention solves the problems of intention recognition, emotion recognition, and historical conversation context understanding through the intention recognition model, emotion recognition model, and dialogue model, so as to achieve the purpose of generating accurate, personalized, and emotional target responses. Such an intelligent dialogue system can effectively improve the user experience and enhance user satisfaction. In addition, in the customer service dialogue scenario, the embodiment of the present invention makes full use of the local knowledge base, so that the intention recognition model, emotion recognition model, and dialogue model can accurately understand the problem information and provide effective and professional solutions as target responses.
[0099] Figure 4 FIG. 1 is a schematic diagram of the main modules of a response device according to an embodiment of the present invention. Figure 4 As shown, the response device 400 mainly includes a question acquisition module 401, an intention emotion recognition module 402, a native response generation module 403 and a target response generation module 404.
[0100] The question acquisition module 401 is used to parse the response request sent by the requester in response to receiving the response request and obtain question information;
[0101] The intention and emotion recognition module 402 performs intention recognition and emotion recognition on the question information to obtain intention recognition results and emotion recognition results;
[0102] A native response generation module 403 is used to generate a native response corresponding to the question information using a pre-built dialogue model;
[0103] The target response generation module 404 is used to generate a target response according to the intention recognition result, the emotion recognition result, and the native response, and return the target response to the requesting party.
[0104] According to one embodiment of the present invention, the intention emotion recognition module 402 is also used to: input the question information into a pre-built intention recognition model to obtain the intention recognition result output by the intention recognition model, and the intention recognition model includes a context encoding layer, a priori network and a recognition network; input the question information into a pre-built emotion recognition model to obtain the emotion recognition result output by the emotion recognition model, and the emotion recognition model includes a context information encoding layer and a historical dialogue encoding layer.
[0105] According to another embodiment of the present invention, the response device 400 also includes an intention recognition model construction module (not shown in the figure), which is used to: obtain the historical conversation record corresponding to the response request, and use the context encoding layer in the pre-built intention recognition initial model to encode the historical conversation record to obtain a context hidden state; based on the context hidden state, predict the intention category of the question information through the prior initial network in the intention recognition initial model to obtain a first distribution result of intention; based on the historical conversation record, identify the intention category of the question information through the recognition network in the pre-built intention recognition initial model to obtain a second distribution result of intention; determine the divergence loss function value of the intention recognition initial model based on the first distribution result and the second distribution result, use the divergence loss function value to adjust the parameters of the intention recognition initial model to construct an intention recognition model.
[0106] According to another embodiment of the present invention, the response device 400 also includes a loss function construction module (not shown in the figure), which is used to: after obtaining the second distribution result of the intention, select the target intention category with the highest probability in the second distribution result of the intention; determine the response reconstruction loss function value according to the target intention category and the historical conversation record; the intention recognition model construction module (not shown in the figure) is also used to: use the response reconstruction loss function value and the divergence loss function value to adjust the parameters of the initial model of intention recognition.
[0107] According to another embodiment of the present invention, the response device 400 also includes an emotion recognition model construction module (not shown in the figure), which is used to: extract context words from the question information, encode the context words through the context information encoding layer in the pre-constructed emotion recognition initial model, and generate a context vector; obtain the historical conversation record corresponding to the response request, encode the historical conversation record through the historical conversation encoding layer in the emotion recognition initial model, and generate a history vector; fuse the context vector and the history vector to obtain a fused feature vector; use an activation function on the fused feature vector to obtain the emotion category probability corresponding to the question information, and then determine the cross entropy loss function value; use the cross entropy loss function value to adjust the parameters of the emotion recognition initial model to construct an emotion recognition model.
[0108] According to another embodiment of the present invention, the target response generation module 404 is further used to: perform weighted summation of the intention recognition result, the emotion recognition result, and the native response according to preset intention weights, emotion weights, and native weights to obtain a target response vector; and use a vector-to-text conversion function to convert the target response vector into a target response in text form.
[0109] According to another embodiment of the present invention, the response device 400 also includes an iterative training module (not shown in the figure), which is used to: splice the question information, the native response, the intention recognition result, and the emotion recognition result to generate training samples of the dialogue model to iteratively train the dialogue model.
[0110] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
[0111] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0112] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications, such as answering applications, etc., can be installed on terminal devices 501, 502, 503 (only as an example).
[0113] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0114] Server 505 may be a server that provides various services, such as a background management server that provides support for responses made by users using terminal devices 501, 502, and 503 (for example only). In response to receiving a response request sent by the requesting party, the background management server may parse the response request to obtain question information; perform intent recognition and emotion recognition on the question information to obtain intent recognition results and emotion recognition results; use a pre-built dialogue model to generate a native response corresponding to the question information; generate a target response based on the intent recognition result, the emotion recognition result, and the native response, and return the target response to the requesting party for processing, and feed back the processing result (such as the target response, etc. - for example only) to the terminal device.
[0115] It should be noted that the response method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the response device is generally set in the server 505 .
[0116] It should be understood that Figure 5The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0117] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0118] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0119] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0120] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0121] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.
[0122] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0123] The units involved in the embodiments of the present invention may be implemented in software or hardware. The units described may also be provided in a processor, for example, may be described as follows: a processor includes: a question acquisition module, an intention emotion recognition module, a native response generation module, and a target response generation module.
[0124] Among them, the names of these modules do not constitute a limitation of the modules themselves in some cases. For example, the native response generation module can also be described as "a module for generating a native response corresponding to the question information using a pre-built dialogue model."
[0125] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or it may exist independently without being assembled into the device. The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device includes: in response to receiving a response request sent by the requester, parsing the response request to obtain question information; performing intent recognition and emotion recognition on the question information respectively to obtain intent recognition results and emotion recognition results; using a pre-built dialogue model to generate a native response corresponding to the question information; generating a target response based on the intent recognition result, the emotion recognition result, and the native response, and returning the target response to the requester.
[0126] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to the answer request sent by the requesting party, the answer request is parsed to obtain the question information; the intention recognition and emotion recognition are respectively performed on the question information to obtain the intention recognition result and the emotion recognition result; a pre-built dialogue model is used to generate a native response corresponding to the question information; a target response is generated according to the intention recognition result, the emotion recognition result, and the native response, and the target response is returned to the technical solution of the requesting party, which realizes the accuracy, personalization and empathy of the response, and not only overcomes the limitations of the point-to-point response, effectively improves the user experience, enhances the user satisfaction, and improves the service quality, but also the generated target response is more easily adopted and accepted by the user, thereby truly improving the response efficiency.
[0127] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method of responding, characterized in that: include: In response to receiving a response request sent by the requester, parsing the response request to obtain question information; Performing intention recognition and emotion recognition on the question information respectively to obtain an intention recognition result and an emotion recognition result; Using a pre-built dialogue model to generate a native response corresponding to the question information; A target response is generated based on the intention recognition result, the emotion recognition result, and the native response, and the target response is returned to the requesting party.
2. The method according to claim 1, characterized in that Performing intention recognition and emotion recognition on the question information respectively, obtaining intention recognition results and emotion recognition results, including: Inputting the question information into a pre-built intention recognition model to obtain an intention recognition result output by the intention recognition model, wherein the intention recognition model includes a context encoding layer, a priori network, and a recognition network; The question information is input into a pre-built emotion recognition model to obtain an emotion recognition result output by the emotion recognition model, wherein the emotion recognition model includes a context information encoding layer and a history dialogue encoding layer.
3. The method according to claim 2, characterized in that The intent recognition model is constructed in the following way: Obtaining a historical conversation record corresponding to the response request, and encoding the historical conversation record using a context encoding layer in a pre-built intent recognition initial model to obtain a context hidden state; According to the context hidden state, the intent category of the question information is predicted through the prior initial network in the intent recognition initial model to obtain a first distribution result of the intent; According to the historical conversation records, the intent category of the question information is identified through a recognition network in a pre-built intent recognition initial model, and a second intent distribution result is obtained; According to the first distribution result and the second distribution result, the divergence loss function value of the initial model of intent recognition is determined, and the divergence loss function value is used to adjust the parameters of the initial model of intent recognition to construct an intent recognition model.
4. The method according to claim 3, characterized in that: After obtaining the second distribution result of the intention, the method further includes: Selecting the target intent category with the highest probability in the second distribution result of the intent; determining the response reconstruction loss function value according to the target intent category and the historical conversation record; Utilizing the divergence loss function value to adjust parameters of the initial model for intention recognition includes: The response reconstruction loss function value and the divergence loss function value are used to adjust the parameters of the initial model of intent recognition.
5. The method according to claim 2, characterized in that: The emotion recognition model is constructed in the following way: Extracting context words from the question information, encoding the context words through a context information encoding layer in a pre-built sentiment recognition initial model, and generating a context vector; Obtaining a historical conversation record corresponding to the response request, encoding the historical conversation record through a historical conversation encoding layer in the emotion recognition initial model, and generating a historical vector; Fusing the context vector and the history vector to obtain a fused feature vector; Using an activation function on the fused feature vector, obtaining the probability of the sentiment category corresponding to the question information, and then determining the value of the cross entropy loss function; The cross entropy loss function value is used to adjust the parameters of the initial emotion recognition model to construct an emotion recognition model.
6. The method according to claim 1, characterized in that Generating a target response according to the intention recognition result, the emotion recognition result, and the native response, including: According to the preset intention weight, emotion weight, and native weight, the intention recognition result, the emotion recognition result, and the native response are weighted and summed to obtain a target response vector; The target response vector is converted into a target response in text form using a vector-to-text conversion function.
7. The method according to claim 1, characterized in that The method further comprises: The question information, the native response, the intent recognition result, and the emotion recognition result are concatenated to generate training samples for the dialogue model to iteratively train the dialogue model.
8. A response device, characterized in that: include: A question acquisition module, configured to, in response to receiving a response request sent by a requester, parse the response request to acquire question information; The intention and emotion recognition module performs intention recognition and emotion recognition on the question information to obtain intention recognition results and emotion recognition results; A native response generation module, used to generate a native response corresponding to the question information using a pre-built dialogue model; A target response generation module is used to generate a target response based on the intention recognition result, the emotion recognition result, and the native response, and return the target response to the requester.
9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Dialogue response and response strategy matching model training method and device
CN113326359A
Intelligent response method and device
CN114970559A
Conversation generation method and system for enhancing text features
CN115495566A
Conversation emotion detection method in combination with scene message
CN117151113A
Consultation reply method and device and computer readable storage medium
CN117312514A
Cited By
Conversation processing method and device based on artificial intelligence
CN120316248A
Artificial intelligence-based dialogue processing method and device
CN120316248B
User answering method, device and equipment based on intelligent interaction tool and storage medium
CN121543736A
