A method and apparatus for determining a customer service reply text
By using a twin structure model to calculate the encoding similarity between the customer service and user dialogue text and the knowledge base, the problems of long user waiting time and large amount of computation in customer service dialogue scenarios are solved, thus improving efficiency and speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING WODONG TIANJUN INFORMATION TECH CO LTD
- Filing Date
- 2022-03-28
- Publication Date
- 2026-05-22
AI Technical Summary
Existing technologies in customer service dialogue scenarios suffer from problems such as long user waiting times, low efficiency in resolving requests, and high computational demands, making it impossible to quickly determine the customer service response text.
A second pre-defined model is generated by training customer service and user dialogue text samples and knowledge point samples in the knowledge base using a twin structure pre-defined model. The dialogue text is then encoded using this model, and the similarity between the encoded vector and the encoding matrix in the knowledge base is calculated to determine the response text.
It enables rapid determination of customer service response text, shortens user waiting time, improves the efficiency of request resolution, and reduces computational load.
Smart Images

Figure CN116881393B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent customer service technology, and in particular to a method and apparatus for determining customer service response text. Background Technology
[0002] In some existing customer service dialogue scenarios, manual retrieval of knowledge points is still used. When a large number of users call simultaneously, the time required for manual retrieval leads to long user wait times and low efficiency in resolving requests. Some customer service dialogue scenarios use text matching algorithms. In traditional text matching algorithms, two sentences to be matched need to be input into the model simultaneously for calculation. In customer service dialogue knowledge point matching scenarios, the knowledge base typically contains multiple knowledge points, significantly increasing the computational load and matching time, thus reducing the efficiency of customer service personnel. Another solution uses knowledge distillation algorithms in customer service dialogue scenarios. While knowledge distillation compresses the original large model, it requires modeling a classification task. However, in knowledge point matching tasks, a text classification model cannot be directly constructed; the model inference time is long, and it is difficult to achieve satisfactory results in practical use.
[0003] In the process of realizing this invention, the inventors discovered at least the following problems in the prior art:
[0004] There are issues such as long user wait times, low efficiency in resolving requests, and large computational loads, making it impossible to quickly determine the customer service response text. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a method and apparatus for determining customer service response text, which can quickly determine customer service response text, shorten user waiting time, improve the efficiency of request resolution, and reduce the amount of computation.
[0006] To achieve the above objectives, according to one aspect of the present invention, a method for determining customer service response text is provided.
[0007] A method for determining customer service response text includes: training a first preset model of a twin structure using a dialogue text sample between customer service and user and a knowledge point sample in a knowledge base to obtain a second preset model; encoding a first dialogue text between customer service and user using the second preset model to obtain a dialogue text encoding vector; calculating the similarity between the dialogue text encoding vector and a knowledge base encoding matrix generated using knowledge points in the knowledge base; and determining the corresponding response text for the first dialogue text based on the calculated similarity.
[0008] Optionally, after obtaining the second preset model, the method further includes: encoding the knowledge points in the knowledge base using the second preset model to obtain the knowledge base encoding matrix, and saving the knowledge base encoding matrix.
[0009] Optionally, the first preset model of the twin structure includes a first input layer, a twin encoding layer, a first fully connected layer, and a matching layer; training the first preset model of the twin structure using dialogue text samples between customer service and users and knowledge point samples in the knowledge base to obtain a second preset model includes: receiving input samples through the first input layer, the input samples including dialogue text samples between customer service and users and knowledge point samples in the knowledge base, the knowledge point samples including positive samples and negative samples, the positive samples being knowledge point samples corresponding to the dialogue text samples and used by customer service, and the negative samples being knowledge point samples randomly selected from the knowledge base; semantically encoding the input samples by the twin encoding layer to obtain the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples respectively; after dimensionality transformation of the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples respectively through the first fully connected layer, calculating the similarity between the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples in the matching layer, and calculating the loss using the triplet loss function to train the second preset model.
[0010] Optionally, the second preset model includes a second input layer, an encoding layer, and a second fully connected layer; the step of encoding the first dialogue text between the customer service representative and the user through the second preset model to obtain a dialogue text encoding vector includes: receiving the first dialogue text between the customer service representative and the user through the second input layer; performing semantic encoding on the first dialogue text between the customer service representative and the user by the encoding layer to obtain a first encoding vector; and performing dimensional transformation on the first encoding vector through the second fully connected layer to obtain the dialogue text encoding vector.
[0011] Optionally, the twin coding layer includes two coding layers with a twin structure, and the semantic encoding is performed by a multi-layer converter.
[0012] Optionally, the step of calculating the similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and determining the corresponding response text for the first dialogue text based on the calculated similarity, includes: calculating the cosine similarity between the dialogue text encoding vector and each encoding vector in the knowledge base encoding matrix, and determining the knowledge points corresponding to a preset number of encoding vectors with the largest cosine similarity in the knowledge base encoding matrix as the response text.
[0013] Optionally, the first preset model and the second preset model are language representation models.
[0014] According to another aspect of the present invention, an apparatus for determining customer service response text is provided.
[0015] An apparatus for determining customer service response text includes: a model training module for training a first preset model of a twin structure using dialogue text samples between customer service and user and knowledge point samples in a knowledge base to obtain a second preset model; a dialogue text encoding module for encoding a first dialogue text between customer service and user using the second preset model to obtain a dialogue text encoding vector; and a response text determination module for calculating the similarity between the dialogue text encoding vector and a knowledge base encoding matrix generated using knowledge points in the knowledge base, and determining the corresponding response text for the first dialogue text based on the calculated similarity.
[0016] Optionally, it also includes a knowledge point encoding module, used to: encode the knowledge points in the knowledge base using the second preset model to obtain the knowledge base encoding matrix, and save the knowledge base encoding matrix.
[0017] Optionally, the first preset model of the twin structure includes a first input layer, a twin encoding layer, a first fully connected layer, and a matching layer; the model training module is further configured to: receive input samples through the first input layer, the input samples including dialogue text samples between customer service and users and knowledge point samples in a knowledge base, the knowledge point samples including positive samples and negative samples, the positive samples being knowledge point samples corresponding to the dialogue text samples and used by customer service, and the negative samples being knowledge point samples randomly selected from the knowledge base; perform semantic encoding on the input samples by the twin encoding layer to obtain the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples respectively; after dimensionality transformation of the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples respectively through the first fully connected layer, calculate the similarity between the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and the negative samples in the matching layer, and calculate the loss using the triplet loss function to train the second preset model.
[0018] Optionally, the second preset model includes a second input layer, an encoding layer, and a second fully connected layer; the dialogue text encoding module is further configured to: receive the first dialogue text between the customer service representative and the user through the second input layer; perform semantic encoding on the first dialogue text between the customer service representative and the user by the encoding layer to obtain a first encoding vector; and perform dimensional transformation on the first encoding vector through the second fully connected layer to obtain the dialogue text encoding vector.
[0019] Optionally, the twin coding layer includes two coding layers with a twin structure, and the semantic encoding is performed by a multi-layer converter.
[0020] Optionally, the response text determination module is further configured to: calculate the cosine similarity between the dialogue text encoding vector and each encoding vector in the knowledge base encoding matrix, and determine the knowledge points corresponding to the preset number of encoding vectors with the largest cosine similarity in the knowledge base encoding matrix as the response text.
[0021] Optionally, the first preset model and the second preset model are language representation models.
[0022] According to another aspect of the present invention, an electronic device is provided.
[0023] An electronic device includes: one or more processors; and a memory for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the method for determining customer service response text provided in embodiments of the present invention.
[0024] According to another aspect of the present invention, a computer-readable medium is provided.
[0025] A computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method for determining customer service response text provided in embodiments of the present invention.
[0026] One embodiment of the above invention has the following advantages or beneficial effects: A first preset model of the twin structure is trained using dialogue text samples between customer service and users and knowledge point samples in the knowledge base to obtain a second preset model; the first dialogue text between customer service and users is encoded using the second preset model to obtain a dialogue text encoding vector; similarity is calculated between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and the corresponding response text is determined based on the calculated similarity. This enables rapid determination of the customer service response text, shortens user waiting time, improves the efficiency of request resolution, and reduces computational load.
[0027] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0028] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0029] Figure 1 This is a schematic diagram illustrating the main steps of a method for determining customer service response text according to an embodiment of the present invention;
[0030] Figure 2 This is a schematic diagram of a preset model according to an embodiment of the present invention;
[0031] Figure 3 This is a flowchart illustrating the process of determining customer service response text according to an embodiment of the present invention;
[0032] Figure 4 This is a schematic diagram of the main modules of an apparatus for determining customer service response text according to an embodiment of the present invention;
[0033] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0034] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing the server of the present invention. Detailed Implementation
[0035] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0036] Figure 1 This is a schematic diagram illustrating the main steps of a method for determining customer service response text according to an embodiment of the present invention. Figure 1 As shown, a method for determining customer service response text according to an embodiment of the present invention mainly includes the following steps S101 to S103.
[0037] Step S101: Using the dialogue text samples between customer service and users and the knowledge point samples in the knowledge base, train the first preset model of the twin structure to obtain the second preset model.
[0038] Step S102: Encode the first dialogue text between the customer service representative and the user using the second preset model to obtain the dialogue text encoding vector.
[0039] Step S103: Calculate the similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and determine the corresponding response text for the first dialogue text based on the calculated similarity.
[0040] The customer service and user dialogue text samples include text samples of the customer service representative and the user.
[0041] The purpose of the method in this embodiment of the invention is to determine the customer service representative's response text from a dialogue text between a customer service representative and a user, which is referred to as the first dialogue text.
[0042] After obtaining the second preset model, the knowledge points in the knowledge base can be encoded using the second preset model to obtain the knowledge base encoding matrix, and the knowledge base encoding matrix can be saved.
[0043] The first pre-defined model of the twin structure specifically includes a first input layer, a twin coding layer, a first fully connected layer, and a matching layer.
[0044] Using customer service and user dialogue text samples and knowledge point samples from a knowledge base, a first pre-set model of the Siamese architecture is trained to obtain a second pre-set model. Specific steps include: receiving input samples through a first input layer, where the input samples include customer service and user dialogue text samples and knowledge point samples from the knowledge base. The knowledge point samples include positive and negative samples. Positive samples are knowledge point samples corresponding to the dialogue text samples and used by customer service, while negative samples are knowledge point samples randomly selected from the knowledge base. In other words, the input to the first input layer consists of three parts: customer service and user dialogue text samples, positive samples, and negative samples. The Siamese encoding layer performs semantic encoding on the input samples to obtain the encoding vector of the dialogue text samples. The system generates text encoding vectors corresponding to positive and negative samples, respectively. Specifically, the dialogue text samples between customer service and users are semantically encoded through one encoding layer in the Siamese encoding layer to obtain the encoding vector of the dialogue text samples. The positive and negative samples are semantically encoded through another encoding layer in the Siamese encoding layer to obtain the text encoding vectors corresponding to the positive and negative samples, respectively. After the encoding vectors of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples are dimensionally transformed through the first fully connected layer, the similarity between the encoding vector of the dialogue text samples and the text encoding vectors of the corresponding positive and negative samples is calculated in the matching layer. The loss is calculated using the triplet loss function to train the second preset model.
[0045] The second pre-defined model specifically includes a second input layer, an encoding layer, and a second fully connected layer. The first input layer corresponds to the second input layer, but the difference is that the input to the second input layer only includes one part, which can be the initial dialogue text between the customer service representative and the user or knowledge points from a knowledge base. The first fully connected layer corresponds to the second fully connected layer, and the second fully connected layer is used to perform dimensionality transformation on the output of the encoding layer. The twin encoding layer includes two encoding layers with a twin structure, and either of these two encoding layers is identical to the encoding layer in the second pre-defined model. The encoding layer performs semantic encoding through a multi-layer transformer.
[0046] The first dialogue text between customer service and user is encoded using a second preset model to obtain a dialogue text encoding vector. Specifically, this may include: receiving the first dialogue text between customer service and user through a second input layer; performing semantic encoding on the first dialogue text between customer service and user by an encoding layer to obtain a first encoding vector; and performing dimensional transformation on the first encoding vector through a second fully connected layer to obtain the dialogue text encoding vector.
[0047] The similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base is calculated. Based on the calculated similarity, the corresponding response text is determined for the first dialogue text. The specific steps include: calculating the cosine similarity between the dialogue text encoding vector and each encoding vector in the knowledge base encoding matrix, and determining the knowledge points corresponding to the preset number of encoding vectors with the largest cosine similarity in the knowledge base encoding matrix as the response text.
[0048] The first and second pre-set models are specifically language representation models, such as the BERT model. BERT stands for Bidirectional Encoder Representation from Transformers, and it is a pre-trained language representation model.
[0049] Figure 2 This is a schematic diagram of a preset model according to an embodiment of the present invention. The preset model in this embodiment is a BERT model, employing a Siamese network structure and using the Triplet Loss function to calculate the model loss and train the model. Therefore, the preset model in this embodiment can specifically be called the Siamese BERT-Triplet Loss model (Siamese BERT Triplet Loss model). The specific structure of the preset model in this embodiment is as follows: Figure 2 As shown, during the model training phase, the pre-defined model has four layers: an input layer (i.e., the first input layer), a Siamese encoding layer, a fully connected layer (i.e., the first fully connected layer), and a matching layer. After inputting customer service and user dialogue text samples and knowledge point text samples (i.e., knowledge point samples), they are semantically encoded using the Siamese encoding layer. A multi-layered Transformer is used to extract their semantic features. After mapping through the fully connected layer, the Triplet Loss function is used to calculate the model loss, thus training the encoding model. The formula for calculating the Triplet Loss function is:
[0050]
[0051] Where L represents the loss; i represents the sample number, i.e., the i-th sample group, 1≤i≤N; N represents the total number of samples, i.e., there are a total of N samples; a i p represents the i-th anchor sample, where the anchor is the dialogue text sample between the customer service representative and the user; i Let n represent the i-th positive sample. i This represents the i-th negative sample; both positive and negative samples are knowledge point samples; α represents a minimum margin, to prevent cos(α) from being used. i ,p i )<cos(a i ,n i )<cos(a i ,p i )+α, that is, a i and n i The distances are very close, and the α value is set, usually α is set to 0.5; cos(a i ,n i ) represents the cosine distance between the anchor and the negative sample, cos(a i ,p i ) represents the cosine distance between the anchor and the positive sample.
[0052] During the model training phase, the input layer consists of three parts: one dialogue text sample between customer service and user, and two knowledge point samples. The two knowledge point samples are the knowledge point text called in the dialogue text between customer service and user at that time, called the positive sample, and a knowledge point randomly selected from the knowledge base (to avoid selecting a positive sample), called the negative sample.
[0053] The input methods for the customer service and user dialogue text samples and the knowledge point samples are different. The customer service and user dialogue text samples are composed of conversations between customer service personnel and users. Their conversations are shown in Table 1.
[0054] Table 1: Customer Service Representative and User Dialogue Form
[0055]
[0056] The customer service representative text is Q = {q1, q3, q5, ..., q}. (2n-1)}, while the user text is represented as P = {p2, p4, p6, ..., p}. 2n After adding BERT input tags, it becomes:
[0057] Input={[CLS],q1,[SEP],p2,…,q (2n-1) [SEP],p 2n}
[0058] The input of knowledge point samples is represented as K = {k1, k2, ..., k n}, where k represents a character.
[0059] Negative sample selection employed the negative sampling method in Word2Vec (a tool for word vector calculation). The probability of a knowledge point being selected as a negative sample is related to its frequency of occurrence; knowledge points that are called more frequently are more likely to be selected as negative samples. The relationship between the probability of a knowledge point being selected as a negative sample and its frequency of occurrence is as follows:
[0060]
[0061] In the above formula, p(k) i ) represents knowledge point k i The probability of being selected as a negative sample, f(k) i ) is k i The frequency of being invoked. n represents the number of knowledge points. The method for selecting negative samples is shown in the algorithm in Table 2.
[0062] Table 2: Negative Sample Selection Algorithm
[0063]
[0064] During the model training phase, this embodiment of the invention combines BERT and Siamese structures, using a weight-shared BERT to simultaneously encode both the dialogue text samples between customer service and users, as well as knowledge point samples. This not only expands the text vector encoding space but also eliminates the semantic gap problem. The final text vector encoded by the BERT model is as follows:
[0065] H = {h1, h2, h3, ... h} l = Siamese-BERT(Input)
[0066] Where Siamese-BERT represents the Siamese BERT triplet loss model in this embodiment of the invention, and Input represents the input. l represents the sentence length of the input text, and d1 represents the dimension of the BERT output vector. To convert the output of the coding layer to a size of For the sentence vectors, this embodiment of the invention employs both average pooling and max pooling. In average pooling, the average value of the corresponding dimensions of the character vectors is calculated. In max pooling, the maximum value of the corresponding dimensions of the character vectors is calculated.
[0067] In the fully connected layer, the output of the Siamese-Bert encoding layer of the preset model in this embodiment of the invention undergoes a dimensionality transformation, projecting the vectors from the high-dimensional space to the low-dimensional space. The calculation method is as follows:
[0068] F out =W·H
[0069] Among them, F out H represents the output of the fully connected layer, and H represents the output of the Siamese coding layer. This is the weight matrix.
[0070] In the matching layer, the similarity between customer service and user dialogue text samples and positive and negative samples is calculated. In vector space, the distance between two vectors represents their similarity, which can be calculated using Euclidean distance or cosine similarity. Euclidean distance considers the spatial distance between points, analyzing differences in dimensionality, but it is not sensitive to direction. This embodiment of the invention uses cosine similarity. The formula for calculating cosine similarity is:
[0071]
[0072] γ and η represent vectors, and d(γ,η) represents the cosine similarity between the two vectors.
[0073] Cosine similarity represents the difference in direction. It is more suitable for calculating text similarity, as the vector directions of texts with the same meaning are often not very different.
[0074] In the matching layer, the similarity of vectors, or distance between vectors, is first calculated to facilitate integration with Triplet Loss. Existing techniques using the softmax loss function result in fixed categories, which, in text matching tasks, impairs the model's representational ability. The purpose of Triplet Loss in this invention is not to classify the results, but to learn a good vector representation.
[0075] In this embodiment of the invention, after inputting the dialogue text samples and knowledge point samples between customer service and users into the Siamese BERT-Triplet Loss model, semantic encoding is performed on them through the Siamese encoding layer (specifically the Siamese BERT encoding layer). Multi-layer Transformers are used to extract their semantic features. After mapping through fully connected layers, the Triplet Loss loss function is used to calculate the model loss and train the encoding model.
[0076] To efficiently and accurately match knowledge points, the model needs to quickly infer similar knowledge points. Existing text matching algorithms, which require encoding sentences simultaneously, are inefficient. This invention employs a Siamese network structure, specifically using the Siamese BERT-Triplet Loss model to simultaneously encode the dialogue text samples between customer service and users, as well as the knowledge point samples. Before the online inference stage, the knowledge point texts (referred to as knowledge points) in the knowledge base can be encoded to obtain a knowledge point encoding matrix. During inference, only the trained model (i.e., the second preset model) needs to be used to calculate the encoding vector of the first dialogue text between customer service and users, and then similarity calculation is performed with the knowledge point encoding matrix. This reduces the original thousands of model encoding calculations to a single operation, significantly improving matching efficiency.
[0077] Before the online reasoning stage, the knowledge points in the knowledge base are encoded to obtain a knowledge point encoding matrix. That is, the trained model is used as the encoding model to encode the knowledge points in the knowledge base. This step is performed after the model training is completed and before the first dialogue text between customer service and users is encoded online in real time. After obtaining the knowledge point encoding matrix, the knowledge point encoding matrix can be saved for subsequent use.
[0078] The use of a trained model to calculate the encoding vector of the first dialogue text between customer service and user during inference means that after receiving the first dialogue text between customer service and user online in real time, the trained model of this invention can be used to encode it in real time to obtain the dialogue text encoding vector.
[0079] Figure 3 This is a flowchart illustrating the process of determining customer service response text according to an embodiment of the present invention. Figure 3 As shown, Figure 3 The model in this embodiment is the trained model of the present invention, that is, the second preset model obtained after training the Siamese BERT-Triplet Loss model. The trained model is used as the encoding model to process the first dialogue text between the customer service representative and the user (i.e., Figure 3 Customer service dialogue text (in the database) or knowledge point text in the knowledge base (i.e.) Figure 3The model encodes text from a knowledge base. The encoding of the initial dialogue between customer service and the user is performed online in real-time, while the encoding of knowledge point texts from the knowledge base is performed offline beforehand. The trained model has only one input: the dialogue text or knowledge point text to be encoded. Furthermore, the trained model does not require a matching layer. Instead, it calculates the similarity (specifically, cosine similarity) between the dialogue text encoding vector and the knowledge base encoding matrix outside the trained model. The calculated similarities are ranked, and the corresponding response text is determined based on one or more knowledge points with the highest similarity (i.e., the matching knowledge point). If multiple knowledge points have the highest similarity, one can be randomly selected as the response text and recommended to customer service, or all of these knowledge points can be recommended to customer service so that they can choose one as the response text.
[0080] In order to obtain bidirectional text semantic representation information, this invention uses BERT as the text encoding model. By pre-training on customer service dialogue text, it can better understand colloquial text compared to other text encoding structures when performing knowledge point matching fine-tuning tasks. At the same time, the addition of the Triplet Loss function reduces the distance between the customer service dialogue and the corresponding knowledge point text in the vector space, thus increasing the value when calculating vector similarity. Through training with a large amount of data, the model can have better encoding capabilities.
[0081] Figure 4 This is a schematic diagram of the main modules of an apparatus for determining customer service response text according to an embodiment of the present invention. Figure 4 As shown, the apparatus 400 for determining customer service response text according to an embodiment of the present invention mainly includes: a model training module 401, a dialogue text encoding module 402, and a response text determination module 403.
[0082] The model training module 401 is used to train the first preset model of the twin structure using dialogue text samples between customer service and users and knowledge point samples in the knowledge base to obtain the second preset model.
[0083] The dialogue text encoding module 402 is used to encode the first dialogue text between the customer service representative and the user through a second preset model to obtain a dialogue text encoding vector.
[0084] The response text determination module 403 is used to calculate the similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and determine the corresponding response text for the first dialogue text based on the calculated similarity.
[0085] The device 400 for determining customer service response text may also include a knowledge point encoding module, used to: encode knowledge points in the knowledge base using a second preset model to obtain a knowledge base encoding matrix, and save the knowledge base encoding matrix.
[0086] The first pre-defined model of the twin structure includes a first input layer, a twin coding layer, a first fully connected layer, and a matching layer.
[0087] The model training module 401 can be specifically used to: receive input samples through the first input layer, the input samples include dialogue text samples between customer service and users and knowledge point samples in the knowledge base, the knowledge point samples include positive samples and negative samples, the positive samples are knowledge point samples corresponding to the dialogue text samples and used by customer service, and the negative samples are knowledge point samples randomly selected from the knowledge base; the input samples are semantically encoded by the Siamese encoding layer to obtain the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and negative samples respectively; after the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive samples and negative samples are dimensionally transformed through the first fully connected layer, the similarity between the encoding vector of the dialogue text samples and the text encoding vectors of the corresponding positive samples and negative samples is calculated in the matching layer, and the loss is calculated using the triplet loss function to train the second preset model.
[0088] The second preset model includes a second input layer, an encoding layer, and a second fully connected layer.
[0089] The dialogue text encoding module 402 can be specifically used to: receive the first dialogue text between the customer service representative and the user through the second input layer; perform semantic encoding on the first dialogue text between the customer service representative and the user by the encoding layer to obtain the first encoding vector; and perform dimensional transformation on the first encoding vector through the second fully connected layer to obtain the dialogue text encoding vector.
[0090] The twin coding layer consists of two coding layers with a twin structure, and the coding layers perform semantic encoding through a multi-layer converter.
[0091] The response text determination module 403 can be used to: calculate the cosine similarity between the dialogue text encoding vector and each encoding vector in the knowledge base encoding matrix, and determine the knowledge points corresponding to the preset number of encoding vectors with the largest cosine similarity in the knowledge base encoding matrix as the response text.
[0092] The first and second presupposed models are language representation models.
[0093] Furthermore, the specific implementation details of the device for determining customer service response text described in the embodiments of the present invention have been explained in detail in the method for determining customer service response text described above, so the details will not be repeated here.
[0094] Figure 5An exemplary system architecture 500 is shown, which can be applied to a method or apparatus for determining customer service response text according to embodiments of the present invention.
[0095] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0096] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0097] Terminal devices 501, 502, and 503 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0098] Server 505 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 501, 502, and 503 (for example only). The backend management server can analyze and process data such as received product information query requests, and feed back the processing results (such as target push information, product information - for example only) to the terminal device.
[0099] It should be noted that the method for determining customer service response text provided in this embodiment of the invention is generally executed by server 505, and correspondingly, the device for determining customer service response text is generally located in server 505.
[0100] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0101] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing terminal devices or servers in the embodiments of this application. Figure 6 The terminal device or server shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0102] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0103] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, 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, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.
[0104] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the main step schematic diagrams can be implemented as computer software programs. For example, embodiments of this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the main step schematic diagrams. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this application.
[0105] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0106] The schematic diagrams and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the schematic diagrams or block diagrams may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams or schematic diagrams, and combinations of blocks in the block diagrams or schematic diagrams, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0107] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor may be described as including a model training module, a dialogue text encoding module, and a response text determination module. The names of these modules do not necessarily limit the module itself; for example, the model training module may also be described as "a module used to train a first preset model of a twin structure using dialogue text samples between customer service and users and knowledge point samples in a knowledge base to obtain a second preset model."
[0108] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include: training a first preset model of a twin structure using dialogue text samples between customer service and users and knowledge point samples in a knowledge base to obtain a second preset model; encoding the first dialogue text between customer service and users using the second preset model to obtain a dialogue text encoding vector; calculating the similarity between the dialogue text encoding vector and a knowledge base encoding matrix generated using knowledge points in the knowledge base; and determining the corresponding response text for the first dialogue text based on the calculated similarity.
[0109] According to the technical solution of this invention, a first preset model of a twin structure is trained using dialogue text samples between customer service and users and knowledge point samples in a knowledge base to obtain a second preset model; the first dialogue text between customer service and users is encoded using the second preset model to obtain a dialogue text encoding vector; a similarity calculation is performed between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base; and the corresponding response text is determined for the first dialogue text based on the calculated similarity. This can shorten user waiting time, improve the efficiency of request resolution, reduce computational load, and quickly determine the customer service response text.
[0110] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for determining customer service response text, characterized in that, include: Using customer service and user dialogue text samples and knowledge point samples from the knowledge base, the first preset model of the twin structure is trained to obtain the second preset model; The first dialogue text between customer service and user is encoded using the second preset model to obtain the dialogue text encoding vector. The similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base is calculated, and the corresponding response text is determined for the first dialogue text based on the calculated similarity. The first preset model of the twin structure includes a first input layer, a twin encoding layer, a first fully connected layer, and a matching layer. Training the first preset model of the twin structure using dialogue text samples between customer service and users and knowledge point samples from a knowledge base to obtain a second preset model includes: receiving input samples through the first input layer, the input samples including dialogue text samples between customer service and users and knowledge point samples from a knowledge base, the knowledge point samples including positive samples and negative samples, the positive samples being knowledge point samples corresponding to the dialogue text samples and used by customer service, and the negative samples being knowledge point samples randomly selected from the knowledge base; semantically encoding the input samples by the twin encoding layer to obtain the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples respectively; performing dimensionality transformation on the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples respectively through the first fully connected layer, calculating the similarity between the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples in the matching layer, and calculating the loss using a triplet loss function to train the second preset model.
2. The method according to claim 1, characterized in that, After obtaining the second preset model, the method further includes: The knowledge points in the knowledge base are encoded using the second preset model to obtain the knowledge base encoding matrix, and the knowledge base encoding matrix is saved.
3. The method according to claim 1, characterized in that, The second preset model includes a second input layer, an encoding layer, and a second fully connected layer; The step of encoding the first dialogue text between the customer service representative and the user using the second preset model to obtain a dialogue text encoding vector includes: The second input layer receives the first dialogue text between the customer service representative and the user. The first dialogue text between the customer service representative and the user is semantically encoded by the encoding layer to obtain the first encoding vector; The first encoding vector is transformed by the second fully connected layer to obtain the dialogue text encoding vector.
4. The method according to claim 3, characterized in that, The twin coding layer comprises two coding layers with a twin structure, and the semantic encoding is performed by a multi-layer converter.
5. The method according to claim 1, characterized in that, The step of calculating the similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and determining the corresponding response text for the first dialogue text based on the calculated similarity, includes: Calculate the cosine similarity between the dialogue text encoding vector and each encoding vector in the knowledge base encoding matrix, and determine the knowledge points corresponding to the preset number of encoding vectors with the largest cosine similarity in the knowledge base encoding matrix as the response text.
6. The method according to claim 1, characterized in that, The first preset model and the second preset model are language representation models.
7. An apparatus for determining customer service response text, characterized in that, include: The model training module is used to train the first preset model of the twin structure using dialogue text samples between customer service and users and knowledge point samples in the knowledge base, so as to obtain the second preset model. The dialogue text encoding module is used to encode the first dialogue text between the customer service representative and the user through the second preset model to obtain the dialogue text encoding vector. The response text determination module is used to calculate the similarity between the dialogue text encoding vector and the knowledge base encoding matrix generated using knowledge points in the knowledge base, and determine the corresponding response text for the first dialogue text based on the calculated similarity. The first preset model of the twin structure includes a first input layer, a twin encoding layer, a first fully connected layer, and a matching layer. Training the first preset model of the twin structure using dialogue text samples between customer service and users and knowledge point samples from a knowledge base to obtain a second preset model includes: receiving input samples through the first input layer, the input samples including dialogue text samples between customer service and users and knowledge point samples from a knowledge base, the knowledge point samples including positive samples and negative samples, the positive samples being knowledge point samples corresponding to the dialogue text samples and used by customer service, and the negative samples being knowledge point samples randomly selected from the knowledge base; semantically encoding the input samples by the twin encoding layer to obtain the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples respectively; performing dimensionality transformation on the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples respectively through the first fully connected layer, calculating the similarity between the encoding vector of the dialogue text samples and the text encoding vectors corresponding to the positive and negative samples in the matching layer, and calculating the loss using a triplet loss function to train the second preset model.
8. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described in any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.