Customer service conversation sentiment analysis system, method, and computer system
By constructing a sliding window-based customer service conversation sentiment analysis system, and utilizing Transformer and LSTM networks to fuse role and conversation semantic information, the system addresses the problem of insufficient accuracy in sentiment analysis during customer service conversations, achieving higher accuracy and recall in sentiment analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 南京云问网络技术有限公司
- Filing Date
- 2022-10-26
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies struggle to accurately capture customer emotional changes during customer service conversations, resulting in insufficient accuracy in sentiment analysis and loss of semantic information from the conversation context.
A customer service conversation sentiment analysis system is constructed using a sliding window approach. The conversation text is converted into word sequence vectors through encoding units, and role semantic information is incorporated. The conversation semantics are encoded using Transformer and LSTM networks, and sentiment classification is performed using a Softmax classifier. The analysis is then combined with multi-dimensional conversation semantic vectors.
It improves the accuracy of sentiment analysis in customer service conversations, enhances the semantic understanding of conversation context, and improves the precision and recall rate of sentiment analysis.
Smart Images

Figure CN115630652B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of NPL (Natural Language Processing) technology, and in particular to a customer service conversation sentiment analysis system, method, and computer system. Background Technology
[0002] In the field of natural language processing, conversational sentiment analysis is a crucial research area, and it has wide-ranging applications in intelligent dialogue. Currently, in customer service conversations, customers raise various requests and express different emotions depending on the customer service representative's feedback. Capturing these emotional changes during customer service conversations, performing sentiment analysis, and providing real-time feedback to relevant personnel can effectively reduce customer complaint rates and improve customer service quality.
[0003] In related technologies, conversational sentiment analysis methods include machine learning-based methods and deep learning-based methods.
[0004] Machine learning methods include support vector machines and logistic regression; deep learning methods include convolutional neural networks and recurrent neural networks. Performing sentiment classification on only a single sentence in a conversation would lose the semantic information of the conversation's context. Summary of the Invention
[0005] This invention addresses the problems existing in the prior art by proposing a customer service conversation sentiment analysis system that provides more accurate sentiment analysis results.
[0006] According to a first aspect of the present invention, a customer service conversation sentiment analysis system is proposed, comprising: an encoding unit, a role semantic encoding fusion unit, a conversation semantic vector encoding unit, a conversation vector fusion unit, and a conversation sentiment classification unit;
[0007] The encoding unit is configured to encode and output the input conversation text, converting the conversation text into a fixed-dimensional word sequence vector.
[0008] The role semantic encoding fusion unit is configured to integrate conversation role information into the semantic representation of a sentence;
[0009] The conversation semantic vector encoding unit is configured to input the set of sentence semantic role vectors output by the role semantic encoding fusion unit into the Transformer encoder and the LSTM network to perform conversation semantic vector encoding, thereby obtaining conversation semantic vectors based on the Transformer encoder and the LSTM network, respectively.
[0010] The session vector fusion unit is configured to concatenate and fuse the session semantic vector based on the Transformer encoder and LSTM network output by the session semantic vector encoding unit with the sentence vector encoded by the last sentence in the session window to obtain a multi-dimensional session semantic vector.
[0011] The conversation sentiment classification unit is configured to process the multi-dimensional conversation semantic vector S output by the conversation vector fusion unit. merge The input is fed into a fully connected layer, where a Softmax classifier is used to classify the conversation sentiment of the current sliding window, thus obtaining the conversation sentiment result.
[0012] Furthermore, the role semantic encoding fusion unit includes a conversation role encoding subunit and a role semantic fusion subunit;
[0013] The conversation role encoding subunit maps different roles in the conversation to different word vectors in the vocabulary; the word vectors are used as the conversation role representation of the corresponding role through word embedding matrix transformation;
[0014] The role semantic fusion subunit concatenates and fuses the sentence vector encoded by each sentence with the corresponding conversation role representation, thereby enabling simple and effective role identification.
[0015] This invention also provides a customer service conversation sentiment analysis method using the above-mentioned customer service conversation sentiment analysis system, comprising the following steps:
[0016] Step 1: Train the customer service conversation sentiment analysis system using the dataset;
[0017] Step 2: Set up a sliding window and move it sequentially according to the order of the conversation. Input all sentences in each sliding window into the customer service conversation sentiment analysis system to perform sentiment analysis on the last sentence in the sliding window.
[0018] Furthermore, the dataset includes a training set, a validation set, and a test set; the training method is as follows: cross-entropy is used as the loss function; the learning rate is set to 0.0005; the number of training rounds is set to 20 rounds; and the system parameters are saved based on the parameters with the highest F1 scores in the validation set. This effectively improves the accuracy of the analysis results.
[0019] Furthermore, in step 2, the sliding window size is 5. This increases the overall accuracy of the system's sentiment analysis.
[0020] Furthermore, when the number of conversation sentences within the sliding window is less than the set size, empty strings are padded. This setting is simple and effective; empty strings will be treated as NaN null values during preprocessing and then uniformly encoded.
[0021] Therefore, the above method ensures that the positions of these NaN null values are fixed within the model. The model can easily learn that this fixed information does not contain any semantic meaning.
[0022] The present invention also provides a computer system, comprising:
[0023] One or more processors;
[0024] The memory stores operable instructions that, when executed by the one or more processors, cause the one or more processors to perform operations, including the flow of the above-described customer service conversation sentiment analysis method.
[0025] The present invention also provides a computer-readable medium for storing software, the software including instructions executable by one or more computers, the instructions causing the one or more computers to perform operations including the flow of the above-described customer service conversation sentiment analysis method.
[0026] This invention constructs a customer service conversation sentiment analysis dataset based on a sliding window approach, and then builds a customer service conversation sentiment analysis model. The model takes the conversation text of a window as input, incorporates speaker character information encoding during the encoding process, and then uses Transformer and LSTM methods to encode and fuse the conversation sentence sequences. Finally, a classifier is used to classify the sentiment of the last sentence in the conversation.
[0027] Compared with existing technologies, this invention effectively improves the accuracy of sentiment analysis in customer service conversations; it is also applicable to a wide range of scenarios.
[0028] It should be understood that all combinations of the foregoing concepts and the additional concepts described in more detail below may be considered part of the inventive subject matter of this disclosure, provided that such concepts do not contradict each other. Furthermore, all combinations of the claimed subject matter are considered part of the inventive subject matter of this disclosure.
[0029] The foregoing and other aspects, embodiments, and features of the teachings of the present invention will be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the invention, such as features and / or beneficial effects of exemplary embodiments, will become apparent from the following description or may be learned through practice of specific embodiments according to the teachings of the present invention. Attached Figure Description
[0030] The accompanying drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in the various figures may be denoted by the same reference numeral. For clarity, not every component is labeled in each figure. Embodiments of various aspects of the invention will now be described by way of example and with reference to the accompanying drawings.
[0031] Figure 1 This is a schematic diagram of the customer service conversation sentiment analysis system provided by the present invention.
[0032] Figure 2 This is a schematic diagram of the sliding window movement in the customer service conversation sentiment analysis method provided by the present invention. Detailed Implementation
[0033] To better understand the technical content of the present invention, specific embodiments are described below in conjunction with the accompanying drawings.
[0034] Various aspects of the invention are described in this disclosure with reference to the accompanying drawings, which illustrate numerous illustrative embodiments. The embodiments of this disclosure are not necessarily intended to encompass all aspects of the invention. It should be understood that the various concepts and embodiments described above, as well as those described in more detail below, can be implemented in any of many ways, because the concepts and embodiments disclosed herein are not limited to any particular implementation. Furthermore, some aspects of the invention disclosed may be used alone or in any suitable combination with other aspects of the invention disclosed.
[0035] like Figure 1 As shown in the figure, this embodiment discloses a customer service conversation sentiment analysis system, including an encoding unit 1, a role semantic encoding fusion unit 2, a conversation semantic vector encoding unit 3, a conversation vector fusion unit 4, and a conversation sentiment classification unit 5.
[0036] The encoding unit 1 is configured to encode the input conversation text and convert it into a fixed-dimensional word sequence vector.
[0037] As an optional embodiment, encoding unit 1 converts and outputs the conversational text based on the vocabulary and word embedding matrix in the pre-trained language model.
[0038] First, for the acquired input conversation text, the text is segmented according to the vocabulary to obtain the segmented word sequence;
[0039] Then, the word sequence is transformed into a vector using a word embedding matrix, and each segmented word is converted into a fixed-dimensional word sequence vector and output.
[0040] In an embodiment of the present invention, the encoding unit converts all the conversational text in the sliding window into word sequence vectors.
[0041] For example, first according to formula x i =Embedding(token) i This yields the word sequence vector output by the i-th sentence in the conversation window, where tokens... i This represents the word sequence obtained after segmenting the i-th sentence in the conversation. Embedding() represents the word embedding matrix transformation. i This represents the word sequence vector output by the i-th sentence in the conversation window.
[0042] Then, the sentence encoder based on the pre-trained language model inputs the word sequence vectors into the sentence encoder to obtain the vector of each sentence in the conversation window and output it.
[0043] For example, according to formula h i =BERT(x i This obtains the sentence vector encoded from the i-th sentence in the conversation, where BERT() represents the sentence encoder of the BERT pre-trained language model, and h i This represents the sentence vector encoded from the i-th sentence in the conversation.
[0044] In this embodiment, the pre-trained language model uses the BERT pre-trained language model.
[0045] In another embodiment, the pre-trained language model may also employ other pre-trained language models such as RoBERT and SKEP.
[0046] Role semantic encoding fusion unit 2 is used to integrate conversation role information into the semantic representation of sentences.
[0047] As an optional embodiment, the role semantic encoding fusion unit 2 includes a conversation role encoding subunit and a role semantic fusion subunit.
[0048] It should be understood that a conversation, especially a customer service conversation, typically involves two conversational roles: customer service representative and customer. To better determine the emotional polarity of a conversation, it is necessary to distinguish whether the sentences in the conversation originate from the customer or the customer service representative.
[0049] The conversational role encoding subunit is configured to map the conversational roles of customer service representative and customer to the words [unused1] and [unused2] in the vocabulary, respectively. Then, the word vectors corresponding to [unused1] and [unused2] are transformed using a word embedding matrix to represent the conversational roles of customer service representative and customer, respectively.
[0050] x service =Embedding(token) [unused1] )
[0051] x customer =Embedding(token) [unused2] )
[0052] Where, x service This represents the customer service representative's conversational role, x customer A token representing the client's session role. [unused1] This refers to the word sequence obtained by segmenting the sentences spoken by customer service representatives during the conversation; token [unused2] This represents the word sequence obtained after segmenting the sentences expressed by the client during the conversation.
[0053] In this embodiment, word vectors from a pre-trained language model are used, and some unused character vectors in the word vectors are used as character information encoding vectors.
[0054] Using unused vectors from a pre-trained language model eliminates the need for manual parameter initialization and outperforms methods that train character vector parameter matrices separately, while also being simpler and more effective.
[0055] The role semantic fusion subunit is configured to concatenate and fuse the sentence vector encoded by each sentence with the corresponding conversation role representation.
[0056] As an optional implementation, the role semantic fusion subunit is set by the layer to obtain the role semantic vector t of the i-th sentence in the conversation according to the following formula. i :
[0057]
[0058]
[0059]
[0060] in, This represents the i-th sentence as a customer's question. This represents the i-th sentence as a customer service reply.
[0061] Conversation semantic vector encoding unit 3 is configured to integrate the sentence semantic role vector set T = {t1, t2, ..., t3} output by the role semantic encoding fusion unit. n The inputs are fed into the Transformer encoder and the LSTM network to encode the session semantic vectors, resulting in session semantic vectors based on the Transformer encoder and the LSTM (Long Short Term Memory) network, respectively.
[0062] In an optional embodiment, the Transformer encoder employs a typical Transformer-based encoder.
[0063] It should be understood that the aforementioned Transformer encoder and LSTM network are both pre-trained model structures, and the model parameters are determined through training with sample data.
[0064] As an optional implementation, the session semantic vector encoding unit 3 is configured to perform session semantic vector encoding in the following manner:
[0065] S transformer =Transformer(T);
[0066] S lstm =LSTM(T);
[0067] Among them, S transformer The session semantic vector S is obtained through the Transformer encoder. lstm It is a session semantic vector obtained through an LSTM network.
[0068] In this embodiment, to enhance the system's semantic encoding capabilities, multiple different encoders are incorporated. Both the Transformer encoder and the LSTM network can perform sequence encoding and model contextual semantic information, thereby effectively improving the overall system's accuracy in sentiment analysis.
[0069] The session vector fusion unit 4 is configured to concatenate and fuse the session semantic vector based on the Transformer encoder and LSTM network output by the session semantic vector encoding unit with the sentence vector encoded by the last sentence in the session window to obtain a multi-dimensional session semantic vector.
[0070] As an optional implementation, the session vector fusion unit 4 is configured to perform splicing and fusion in the following manner:
[0071] S merge =[S transformer S lstm h n ];
[0072] Among them, S merge h represents a multi-dimensional conversation semantic vector. n This represents the sentence vector encoded from the last sentence in the conversation window.
[0073] Conversation sentiment classification unit 5 is configured to integrate the multi-dimensional conversation semantic vector S output by the conversation vector fusion unit. mergeThe input is fed into a fully connected layer, and the Softmax classifier classifies the conversation sentiment of the current sliding window to obtain the conversation sentiment result.
[0074] Combination Figure 1 As shown in the example, this embodiment discloses a customer service conversation sentiment analysis method based on a customer service conversation sentiment analysis system, including the following steps:
[0075] Step 1: Train the customer service conversation sentiment analysis system using the dataset.
[0076] Step 2: Set up a sliding window and move it sequentially according to the development of the conversation; input the sentences in each sliding window into the customer service conversation sentiment analysis system for analysis.
[0077] In this embodiment, the dataset includes a training set, a validation set, and a test set; the training set is used to analyze the sentiment of customer service conversations.
[0078] The training process uses cross-entropy as the loss function. The learning rate is set to 0.0005; a certain number of training epochs are set, for example, 20-100 iterations; and the system parameters are saved based on the parameter with the highest F1 score in the validation set.
[0079] When the predetermined number of training rounds is reached, the final customer service conversation sentiment analysis system is obtained.
[0080] In the training process of this invention, the number of training rounds is set to 20 rounds.
[0081] By training with dataset samples, the network model parameters of the customer service conversation sentiment analysis system are determined, namely the parameters of the BERT language model, the Transformer encoder, and the LSTM network.
[0082] In this embodiment, the dataset sample can be anonymized data based on hotel customer service or bank customer service.
[0083] For example, taking hotel customer service as an example, the training set, validation set, and test set are split in an 8:1:1 ratio. The constructed training set has 8000 session samples, the validation set has 1000 session samples, and the test set has 1000 session samples.
[0084] In this embodiment, the sliding window size is set to 5. This increases the overall accuracy of the system's sentiment analysis.
[0085] When the number of conversation sentences within the sliding window is less than 5, conversations padded with empty strings are processed. This setup is simple and effective; empty strings are preprocessed to accept NaN null values and then uniformly encoded. This method ensures that the position of these NaN null values in the model is fixed. The model can easily learn that this fixed information does not contain any semantic meaning.
[0086] To verify the effectiveness of the customer service conversation sentiment analysis system, a set of comparative experiments was set up: a BERT-based single-sentence sentiment analysis system and a sliding window-based customer conversation sentiment analysis system analyzed the same conversation samples respectively. The precision, recall, and F1 score of each system model were calculated. As shown in Table 1, the customer service conversation sentiment analysis system disclosed in this embodiment outperforms the single-sentence sentiment analysis system in terms of precision, recall, and F1 score. This demonstrates that the sliding window-based customer conversation sentiment analysis improves the sentiment analysis effect of customer service conversations by incorporating semantic information from the conversation context.
[0087] Table 1:
[0088]
[0089] The present invention also provides a computer-readable medium for storing software, the software including instructions executable by one or more computers, the instructions causing the one or more computers to perform operations including the flow of the above-described customer service conversation sentiment analysis method.
[0090] The present invention also provides a computer system comprising: one or more processors; and a memory storing operable instructions that, when executed by the one or more processors, cause the one or more processors to perform operations, the operations including the flow of the aforementioned customer service conversation sentiment analysis method.
[0091] It should be understood that the aforementioned customer service conversation sentiment analysis method of the present invention can be applied to any computer system containing data storage and data processing capabilities. The aforementioned computer system can be at least one electronic processing system or electronic device including a processor and memory, such as a PC, whether it be a personal PC, a commercial PC, a graphics processing PC, or a server-class PC. These PCs enable wired and / or wireless data transmission, especially image data, through data interfaces and / or network interfaces.
[0092] In other embodiments, the computer system may also be a server, especially a cloud server, with data storage, processing, and network communication functions.
[0093] A typical computer system includes at least one processor, memory, and a network interface connected by a system bus. The network interface is used to communicate with other devices / systems.
[0094] The processor is used to provide computation and control for the system.
[0095] Memory includes non-volatile memory and cache.
[0096] Non-volatile memory typically has massive storage capacity and can store operating systems and computer programs. These computer programs may include operable instructions that, when executed by one or more processors, enable one or more processors to perform the customer service conversation sentiment analysis method of the foregoing embodiments of the present invention.
[0097] In a necessary or reasonable implementation, the aforementioned computer system, whether a PC device or a server, may include more or fewer components or combinations thereof than those shown in the diagram, or may employ different hardware, software, or other components or different deployment methods.
[0098] While the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the claims.
Claims
1. A customer service conversation sentiment analysis system, characterized in that, It includes an encoding unit, a role semantic encoding fusion unit, a conversation semantic vector encoding unit, a conversation vector fusion unit, and a conversation sentiment classification unit; The encoding unit is configured to encode and output the input conversation text, converting the conversation text into a fixed-dimensional word sequence vector. The role semantic encoding fusion unit is configured to integrate conversation role information into the semantic representation of a sentence; The conversation semantic vector encoding unit is configured to input the set of sentence semantic role vectors output by the role semantic encoding fusion unit into the Transformer encoder and the LSTM network to perform conversation semantic vector encoding, thereby obtaining conversation semantic vectors based on the Transformer encoder and the LSTM network, respectively. The session vector fusion unit is configured to concatenate and fuse the session semantic vector based on the Transformer encoder and LSTM network output by the session semantic vector encoding unit with the sentence vector encoded by the last sentence in the session window to obtain a multi-dimensional session semantic vector. The conversation sentiment classification unit is configured to integrate the multi-dimensional conversation semantic vector output by the conversation vector fusion unit. S merge The input is fed into a fully connected layer, where a Softmax classifier is used to classify the conversation sentiment of the current sliding window, thus obtaining the conversation sentiment result.
2. The customer service conversation sentiment analysis system according to claim 1, characterized in that: The encoding unit is configured to transform and output the conversational text based on the vocabulary and word embedding matrix in the pre-trained language model.
3. The customer service conversation sentiment analysis system according to claim 2, characterized in that: The encoding unit is configured to convert and output the conversation text according to the following process: First, based on the vocabulary and word embedding matrix in the pre-trained language model, all the conversation text in the sliding window is converted into word sequence vectors; Then, the sentence encoder based on the pre-trained language model inputs the word sequence vectors into the sentence encoder to obtain the vector of each sentence in the conversation window, and outputs it to the role semantic encoding fusion unit.
4. The customer service conversation sentiment analysis system according to claim 1, characterized in that: The role semantic encoding fusion unit includes a conversation role encoding subunit and a role semantic fusion subunit; The conversation role encoding subunit is configured to map different roles in a conversation to different word vectors in a vocabulary; The word vectors are used as the conversational role representation of the corresponding role by transforming the word embedding matrix; The role semantic fusion subunit is configured to concatenate and fuse the sentence vector encoded by each sentence with the corresponding conversation role representation.
5. A customer service conversation sentiment analysis method using the customer service conversation sentiment analysis system of claim 1, characterized in that: Step 1: Train the customer service conversation sentiment analysis system according to any one of claims 1-4 using the dataset, and determine the model parameters based on the Transformer encoder and LSTM network to obtain the trained customer service conversation sentiment analysis system. Step 2: Set up a sliding window and move it sequentially according to the dialogue development order; input all sentences in each sliding window into the previously trained customer service conversation sentiment analysis system to perform sentiment analysis on the last sentence in the sliding window.
6. The customer service conversation sentiment analysis method according to claim 5, characterized in that: The dataset includes a training set, a validation set, and a test set; The training method is as follows: cross-entropy is used as the loss function; the learning rate is set to 0.0005; the number of training rounds is set to 20-100 rounds; and the parameters with the highest F1 scores are obtained from the validation set and saved as system parameters.
7. The customer service conversation sentiment analysis method according to claim 5, characterized in that: In step 2, the size of the sliding window is 5.
8. The customer service conversation sentiment analysis method according to claim 5, characterized in that: When the number of conversation sentences in the sliding window is less than the set size, fill with an empty string.
9. A computer system, characterized in that, include: One or more processors; The memory stores operable instructions that, when executed by the one or more processors, cause the one or more processors to perform operations, including the flow of the customer service conversation sentiment analysis method as described in any one of claims 5-8.
10. A computer-readable medium for storing software, characterized in that, The software includes instructions executable by one or more computers, which, upon execution, cause the one or more computers to perform operations including the flow of the customer service conversation sentiment analysis method as described in any one of claims 5-8.
Citation Information
Patent Citations
Chinese sentiment analysis method based on BERT, LSTM and CNN fusion
CN110334210A
Emotion recognition method and device based on recurrent neural network and storage medium
CN111950275A