Session response method and apparatus
Patent Information
- Application Number
- CN202210730224.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-06-24
AI Technical Summary
[0004]有鉴于此,本公开实施例提供了一种会话应答方法、装置、电子设备及计算机可读存储介质,以解决现有技术中应答系统回复的内容质量不高的问题
[0009]本公开实施例与现有技术相比存在的有益效果是:通过将用户输入数据输入知识库进行比对,并在第一相似度评分小于设定的第一阈值时对用户输入数据通过预设的编码模型进行编码处理,再将得到的编码数据输入到历史会话库中进行比对,得到会话应答数据,从而可以兼顾到历史会话库和知识库,提高了会话应答数据的质量。
Smart Images

Figure CN115269791B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a session response method and apparatus. Background Technology
[0002] In intelligent customer service scenarios, human agents need to respond to user input. The speed and quality of these responses often affect subsequent user actions, such as completing a transaction or filing a complaint. Related technologies include automated conversation response systems (ACRS) that can assist human agents in improving the speed and quality of their responses. When a user enters one or more sentences, the ACRS system recommends corresponding responses, which are then directly adopted or slightly adjusted by a human agent before being sent back to the user.
[0003] Automatic response systems can respond in two ways: generative and retrieval. Both of these methods suffer from low-quality responses that fail to meet user needs. Summary of the Invention
[0004] In view of this, embodiments of the present disclosure provide a session response method, apparatus, electronic device, and computer-readable storage medium to solve the problem of low content quality in response system replies in the prior art.
[0005] A first aspect of this disclosure provides a session response method, the method comprising: inputting user input data into a knowledge base for comparison to obtain a first comparison result, the first comparison result including first target comparison data and a first similarity score between the question of the first target comparison data and the user input data; responding to a first similarity score being less than a set first threshold, encoding the user input data of the current session using a preset encoding model to obtain encoded data; inputting the encoded data into a historical session database for comparison to obtain a second comparison result, the second comparison result including second target comparison data and a second similarity score between the second target comparison data and the encoded data; and responding to a second similarity score being greater than or equal to a set second threshold, obtaining session response data of the current session based on the second target comparison data.
[0006] A second aspect of this disclosure provides a session response apparatus, comprising: a first comparison module, configured to input user input data into a knowledge base for comparison to obtain a first comparison result, the first comparison result including first target comparison data and a first similarity score between the question of the first target comparison data and the user input data; an encoding module, configured to encode the user input data of the current session using a preset encoding model in response to the first similarity score being less than a set first threshold, to obtain encoded data; a second comparison module, configured to input the encoded data into a historical session database for comparison to obtain a second comparison result, the second comparison result including second target comparison data and a second similarity score between the second target comparison data and the encoded data; and a response acquisition module, configured to acquire session response data of the current session based on the second target comparison data in response to the second similarity score being greater than or equal to a set second threshold.
[0007] A third aspect of this disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0008] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0009] The beneficial effects of this disclosed embodiment compared with the prior art are as follows: by inputting user input data into a knowledge base for comparison, and encoding the user input data through a preset encoding model when the first similarity score is less than a set first threshold, and then inputting the obtained encoded data into a historical conversation database for comparison to obtain conversation response data, the historical conversation database and the knowledge base can be taken into account, thereby improving the quality of conversation response data.
[0010] Furthermore, by using user input in conjunction with a knowledge base and historical conversation database to generate automatic responses, the efficiency of agent responses can be improved, while ensuring stable and controllable quality. Since only user input data is used, and it is not necessary to obtain responses from agents in the current conversation, frequent data readings are avoided, thereby improving system response speed. Because both the knowledge base and historical conversation database can be utilized, the technical solution of this disclosure embodiment can improve response quality. In addition, the response system and encoding model designed in the technical solution of this disclosure embodiment are of low complexity and easy to implement. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic flowchart of a session response method provided in an embodiment of this disclosure;
[0013] Figure 2 This is a flowchart illustrating the training method of the encoding model provided in this embodiment of the disclosure;
[0014] Figure 3 This is a flowchart illustrating another session response method provided in an embodiment of this disclosure;
[0015] Figure 4 This is a schematic diagram of the structure of a session response device provided in an embodiment of this disclosure;
[0016] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0017] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, so as to provide a thorough understanding of the embodiments of this disclosure. However, those skilled in the art will understand that this disclosure may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this disclosure with unnecessary detail.
[0018] In related technologies, automated conversation response systems can respond in two ways: generative and retrieval. Generative responses are often uncontrollable, while controllable responses have high latency, making them difficult to meet deployment requirements. Retrieval-based responses, on the other hand, often limit the candidate set to historical responses, making it difficult to consider data in the existing knowledge base, resulting in low-quality responses that fail to meet user needs.
[0019] Furthermore, in real-world conversation scenarios, users often input multiple sentences consecutively, and agents often respond with multiple sentences consecutively. However, the input and output of automated response models are typically one-to-one, making it difficult to handle many-to-many scenarios. To handle many-to-many scenarios, it's often necessary to model multiple user inputs and multiple agent responses simultaneously, introducing role information. This increases model complexity, and the need to obtain agent responses in real-time during online service further increases system complexity, causing response delays and compromising response speed.
[0020] To address the above issues, this disclosure proposes a session response scheme to improve the response quality and speed of the session response system.
[0021] The session response method and apparatus according to embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings.
[0022] Figure 1 This is a schematic flowchart illustrating a session response method provided in an embodiment of this disclosure. The method provided in this embodiment can be executed by any electronic device with computer processing capabilities, such as a terminal or server. Figure 1 As shown, the session response method includes:
[0023] S101, Input the user input data into the knowledge base for comparison and obtain the first comparison result. The first comparison result includes the first target comparison data and the first similarity score between the question of the first target comparison data and the user input data.
[0024] Specifically, user input data needs to be preprocessed before being entered into the knowledge base. The comparison process of user input data in the knowledge base is a matching process that matches the user input data with the data in the knowledge base. The data in the knowledge base that is similar to the user input data is the first target comparison data. The data in the knowledge base includes the question part and the answer part, that is, the first target comparison data includes question data and answer data, and the similarity score between the question data of the first target comparison data and the user input data is the first similarity score.
[0025] S102, in response to the first similarity score being less than a set first threshold, the user input data of the current session is encoded using a preset encoding model to obtain encoded data.
[0026] Specifically, if the first similarity score is greater than or equal to a set first threshold, it indicates that a relatively similar match has been found in the knowledge base for the user's input data. In this case, the session response data for the current session can be obtained based on the first target comparison data. If the first similarity score is less than the set first threshold, it indicates that no relatively similar match has been found in the knowledge base for the user's input data. In this case, the corresponding existing data in the historical session database can be matched based on the user's input data. Before being input into the historical session database, the user's input data needs to be encoded using a preset encoding model.
[0027] S103, input the encoded data into the historical session database for comparison to obtain the second comparison result. The second comparison result includes the second target comparison data and the second similarity score between the second target comparison data and the encoded data.
[0028] Specifically, the historical session database, also known as the candidate set, is a dataset containing questions and responses from historical sessions. The process of comparing coded data with data in the historical session database is a matching process. The data in the historical session database that is similar to the coded data obtained from the matching is the second target comparison data. This data includes both question and response portions; that is, the second target comparison data includes both question and response data. The similarity score between the question data and the coded data in the second target comparison data is the second similarity score.
[0029] S104, in response to the second similarity score being greater than or equal to the set second threshold, obtain the session response data of the current session based on the second target comparison data.
[0030] Specifically, if the second similarity score is greater than or equal to the set second threshold, it means that a relatively similar matching data has been found for the encoded data in the historical session database. At this time, the session response data for the current session can be obtained based on the second target comparison data. If the second similarity score is less than the set second threshold, it means that no relatively similar matching data has been found for the encoded data in the historical session database. At this time, no result is returned, and the current session response service ends.
[0031] According to the technical solution of this disclosure, automatic responses are obtained by combining user input with a knowledge base and a historical conversation database, which can improve agent response efficiency and ensure stable and controllable quality. Since only user input data is used, it is not necessary to obtain responses from agents in the current conversation, avoiding frequent data reading and thus improving system response speed. Furthermore, by taking into account both the knowledge base and the historical conversation database, the technical solution of this disclosure can improve response quality. In addition, the response system and encoding model designed in the technical solution of this disclosure are of low complexity and easy to implement.
[0032] The technical solution of this disclosure includes an offline encoding model training phase and an online response phase.
[0033] In this embodiment, the encoding model is trained based on user input data and agent response data from historical sample session data. Since real-world session scenarios often involve users continuously inputting multiple sentences and agents continuously replying with multiple sentences, in this embodiment, each training data set may include at least one response and at least one question during the training process. For example, a training data set may include one response and a corresponding question, or it may include one response and two or more corresponding questions, or it may include two or more responses and two or more corresponding questions. In this embodiment, "question" refers to the user's input data, and "response" refers to the agent's reply data.
[0034] like Figure 2 As shown in this embodiment, the training process of the encoding model includes the following steps:
[0035] Step S201: Preprocess the sample session data to obtain training data. The training data may include one response and at least one question. The sample session data includes data of questions and responses generated during historical sessions. The preprocessing includes replacing the corresponding content in the sample session data with set characters and isolating the questions in the sample session data using concatenation characters.
[0036] Specifically, the settings in the sample session data may include personalized information that is useless for training the encoding model, such as names, times, and phone numbers. Replacing this personalized information with a setting character can improve the training efficiency of the encoding model. These characters can be restored to the original personalized information during the online response phase. For example, during model training, the setting of a phone number can be replaced with the setting character [PHONE]. During the online response phase, if the response data of the second match result in the historical session database contains the setting character [PHONE], since the setting corresponding to this setting character is a phone number, [PHONE] can be replaced with the current user's phone number to restore the personalized information. A sample session data may also include two responses, which also need to be concatenated using a concatenation character. The concatenation character can be [SEP]. Concatenating two or more questions and two or more responses, the concatenated data containing both questions and responses is used as a training data.
[0037] Step S202: Using the cross-entropy of positive and negative examples selected by the batch processing scheme in contrastive learning as the loss function, the question part and the response part of the training data are respectively input into the dual-tower deep learning model for training until the loss function converges, and the trained encoding model is obtained.
[0038] Specifically, contrastive learning can transform an instance into two different augmented instances, then train a neural network to obtain projected representations, use cosine similarity to calculate the similarity between pairwise projected representations, and maximize the consistency between projected representations of the same instance. The batch processing scheme is also known as the in-batch scheme.
[0039] In related technologies, customer service replies often contain a large amount of personalized information, such as "Can I contact you using a phone number ending in 1234?", "Is 123xxxx4331 your phone number?", and "Happy New Year! Sending you New Year's greetings!" Such personalized content can interfere with the training of the encoding model and is difficult to utilize even after retrieval. In this embodiment, personalization can be removed from the training data during the offline training phase and the user input data awaiting response during the online response phase, while personalization is restored in the response data during the online response phase. This personalization can include names, times, and phone numbers, but is not limited to these.
[0040] Specifically, in step S201, the set characters can be used to replace the set content data in the corresponding user input data to erase personalization. Similarly, when applying the encoding model to respond during the online response phase, the set content can be used to replace the set characters again based on the correspondence between the set content and the set characters, thereby restoring personalization.
[0041] For example, the NER (Named Entity Recognition) model can be used to identify sample session data, extract settings such as images, websites, mobile phone numbers, last four digits of mobile phone numbers, and names, and replace them with settings such as [PIC], [HTTP], [PHONE], [SUBPHONE], and [NAME], respectively, to achieve depersonalization of sample session data.
[0042] In the training phase, the technical solution of this disclosure replaces personalized information with standardized special symbols. This is because the system model does not consider the specific value of the personalized information during recognition, but only what type of information it represents. This replacement transforms the originally long string of personalized information into a standard word, effectively improving the model's recognition results. During the online response phase, the personalized information can be recovered, and special symbols can be used to indicate information that cannot be recovered, thus effectively maintaining the usability of the recommended responses.
[0043] Furthermore, when a user inputs an image, the system receives only the image's URL, making it difficult to capture the information it contains. Additionally, the long URL can interfere with model training. For example, real-world dialogues often use rich text formatting, containing a large number of meaningless HTML (Hypertext Markup Language) symbols, which severely interferes with model training. During the preprocessing of sample session data, such as before or after replacing the corresponding user input with specified characters, the rich text formatting in the sample session data can be removed. Specifically, regular expressions can be used to remove the rich text formatting, resulting in plain text. Simultaneously, the mapping relationship between the processed text and the original text is recorded to ensure the correct rich text formatting is output during the online response phase.
[0044] In step S201, the user's current input data and the user's historical input data obtained from the current session based on the session identifier can be concatenated using a concatenation character to form the user input data.
[0045] Specifically, the session identifier for the current session can be the current session ID stored in the cache. During the online response phase, user input data needs to be preprocessed. Specifically, each time the automatic response service is called, only the user's current input data and the current session ID are passed as parameters. Upon receiving the service request from the automatic response service, the historical input data of the current user in the current session corresponding to the current session ID stored in the cache is retrieved and concatenated with the encoded data processed by the encoding model using the concatenation operator [SEP] to obtain the new encoded data. The caching implementation can be a Redis database, but it is not limited to this.
[0046] In this embodiment of the disclosure, concatenating several consecutive sentences of text that are either user input or agent responses, and then separating them with concatenation characters, can yield a more accurate encoding model.
[0047] During the training of coding models, context awareness is required. A common practice is to concatenate the context and feed it into the model for recognition. When the length of the input text exceeds a specified value, it is often necessary to truncate or compress the text. The selection of truncation and compression strategies has a significant impact on the final result. In the model training phase, this embodiment adopts a processing method that truncates the question from the beginning and the response from the end, which can effectively retain useful information.
[0048] In this embodiment of the disclosure, preprocessing the sample session data further includes: if the text length of the question is greater than a set M characters, then the first character before the last M characters of the question is deleted; if the text length of the response is greater than a set M characters, then the last character after the first M characters of the response is deleted; if the number of questions in the training data is greater than a set N, then the questions before the last N questions are deleted, and the remaining N questions are concatenated using a concatenation operator. Here, M and N are both natural numbers. M can be 512, but is not limited to this value. If the text length of the question is 1000 characters, then the first 488 characters of the question can be deleted, retaining only the last 512 characters. If the text length of the response is 1000 characters, then the last 488 characters of the question can be deleted, retaining only the first 512 characters.
[0049] In addition, if the same training data contains two or more responses, the responses also need to be concatenated using a concatenation operator.
[0050] In this embodiment of the disclosure, the agent's reply can be regarded as the answer answer(a), and the user input can be regarded as the question query(q). The first part of q and the second part of a are deleted because the text in q and a that is closer to the current time contains more effective information. Deleting the part with more invalid information does not affect the training of the encoding model and can also reduce the interference to the training process of the encoding model.
[0051] In this embodiment of the disclosure, during the processing of a sample session data, when generating training data, N can be selected as 5, that is, at most the current user input and the previous 4 sentences, i.e., a total of 5 sentences, segmented by [SEP]. For example, let a and b represent the user input and agent response respectively, for the session history sequence [a1, b1, a2, b2, ..., a6, b6], the generated query-answer(qa) pairs are as follows:
[0052] "a1, b1", "a1[SEP]a2, b2", "a1[SEP]a2[SEP]a3, b3", "a1[SEP]a2[SEP]a3[SEP]a4, b4", "a1[SEP]a2[SEP]a3[SEP]a4[SEP]a5, b5" and "a1[SEP]a2[SEP]a3[SEP]a4[SEP]a5[SEP]a6, b6". In this embodiment of the disclosure, when the maximum selection is set to the current user input and the first 4 sentences, a query can contain a maximum of 4 [SEP], then the training data that can be obtained based on the conversation history sequence [a1, b1, a2, b2, ..., a6, b6] includes:
[0053] "a1, b1", "a1[SEP]a2, b2", "a1[SEP]a2[SEP]a3, b3", "a1[SEP]a2[SEP]a3[SEP]a4, b4", "a1[SEP]a2[SEP]a3[SEP]a4[SEP]a5, b5"
[0054] and "a2[SEP]a3[SEP]a4[SEP]a5[SEP]a6, b6".
[0055] In step S201, a series of qa pairs are generated as training data. In step S202, these qa pairs are used as training data to train a deep learning model, and the training process is as follows:
[0056] When training data is fed into the initial dual-tower model, the cosine similarity between each q and its corresponding a after model processing is maximized. The loss function adopts the in-batch approach from contrastive learning. For a batch (q1-a1, q2-a2, ..., qn-an), for any one question qm, its corresponding am is taken as a positive example, and the other a's in the batch are taken as negative examples. The cross-entropy is calculated as the loss function. Here, m and n are natural numbers, and a batch refers to a group of data after the entire training data is divided into fixed-size, evenly distributed groups.
[0057] After completing step S202, a trained encoding model is obtained. In this embodiment, the vector obtained by processing the sample session data using the encoding model and its corresponding original text are saved together to obtain a historical session database. Specifically, in this embodiment, sample session data can be input into the encoding model to obtain sample encoded data, and the sample encoded data and sample session data can be stored in the historical session database. Based on this historical session database, step S103 can be executed to match the encoded data in the historical session database and find data similar to the current encoded data. The historical session database obtained based on this encoding model has the technical advantages of a simple matching process and relatively accurate matching results.
[0058] The preprocessing of user input data includes removing rich text and de-personalizing images, websites, phone numbers, last four digits of phone numbers, and names. Specifically, de-personalization involves replacing images, websites, phone numbers, last four digits of phone numbers, and names with custom symbols [PIC], [HTTP], [PHONE], [SUBPHONE], and [NAME], respectively. These custom symbols are special characters. When these custom special characters [PIC], [HTTP], [PHONE], [SUBPHONE], [NAME], and [SEP] are input into the model's word segmenter, the model treats these special characters as complete words.
[0059] During the process of generating session response data based on user input data, two-way retrieval can be performed:
[0060] The first approach involves inputting the original user input data into the normal intent recognition model to obtain the first target comparison data with the highest similarity to the text in the knowledge base, along with its corresponding first similarity score s1. The normal intent recognition model is trained based on the knowledge base.
[0061] The second approach involves inputting the preprocessed user text data into the encoding model obtained during the offline encoding model training phase, resulting in a vector encoding of the text. This vector encoding is then used to search the historical conversation database to obtain the second target comparison data with the highest similarity to this vector encoding, along with its corresponding rich text and its corresponding second similarity score s2. This similarity can be cosine similarity, but is not limited to this.
[0062] In this embodiment of the disclosure, step S102 may be performed before step S101 or after step S101.
[0063] In this embodiment of the disclosure, the first threshold can be set to 0.8. If the first similarity score s1 is less than 0.8, then step S102 or step S103 is executed. If the first similarity score s1 is greater than or equal to 0.8, then session response data is obtained based on the first target comparison data. That is, in response to the first similarity score being greater than or equal to the first threshold, session response data is obtained based on the first target comparison data.
[0064] In this embodiment of the disclosure, the second threshold can be set to 0.7. If the second similarity score s2 is greater than or equal to 0.7, then step S104 is executed, that is, in response to the second similarity score being greater than or equal to the set second threshold, the session response data of the current session is obtained based on the second target comparison data. If the second similarity score s2 is less than or equal to 0.7, then an empty result is returned, and the automatic response process fails.
[0065] In step S104, in response to the presence of a set character in the second target comparison data, the set character is replaced with the corresponding set content to obtain session response data.
[0066] Specifically, if the second target comparison data contains special symbols such as [PIC], [HTTP], [PHONE], [SUBPHONE], and [NAME], then the symbols [PIC] and [HTTP] can be returned as is, while the symbols [PHONE], [SUBPHONE], and [NAME] can be replaced with the user identity information parameters attached when requesting the service in the current session. If no corresponding parameters are found, the symbols are returned as is. The purpose of returning the symbols as is is to remind the agent that they need to be replaced with the actual information, preventing the agent from forgetting and replying with incorrect results.
[0067] like Figure 3 As shown, a session response method according to an embodiment of this disclosure includes the following steps:
[0068] Step S301: Input the user input data into the knowledge base for comparison and obtain the first comparison result.
[0069] Step S302: Determine whether the first similarity score is less than the first threshold. If not, proceed to step S303. If yes, proceed to step S304.
[0070] Step S303: Obtain the session response data of the current session based on the first target comparison data.
[0071] Step S304: Input the encoded data into the historical session database for comparison to obtain the second comparison result.
[0072] Step S305: Determine whether the second similarity score is less than the second threshold. If yes, proceed to step S306; otherwise, proceed to step S307.
[0073] Step S306: Return an empty result.
[0074] Step S307: Obtain the session response data of the current session based on the second target comparison data.
[0075] In the technical solution of this disclosure embodiment, each service request for the automatic response service only requires the user's current input and does not require the agent's reply. This approach greatly shortens the system's response time. The reason is that each round of user input depends only on the agent's previous reply, and the candidate set for script recommendations comes from each round of agent replies. Therefore, the user's current input data and its context already contain sufficient information to make a relatively accurate reply, thus achieving context-based script recommendation while ensuring low system response latency.
[0076] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0077] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure.
[0078] According to the session response method of this disclosure, user input data is input into a knowledge base for comparison, and the user input data is encoded when the first similarity score is less than a set first threshold. The encoded data is then input into a historical session database for comparison to obtain session response data. This method can take into account both the historical session database and the knowledge base, thereby improving the quality of session response data.
[0079] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. The session response apparatus described below corresponds to the session response method described above. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the method embodiments of this disclosure.
[0080] Figure 4 This is a schematic diagram of a session response device provided in an embodiment of this disclosure. Figure 4 As shown, the session response device includes:
[0081] The first comparison module 401 is used to input user input data into a knowledge base for comparison and obtain a first comparison result. The first comparison result includes the first target comparison data and the first similarity score between the question of the first target comparison data and the user input data.
[0082] Specifically, user input data needs to be preprocessed before being entered into the knowledge base. The comparison process of user input data in the knowledge base is a matching process that matches the user input data with the data in the knowledge base. The data in the knowledge base that is similar to the user input data is the first target comparison data. The data in the knowledge base includes the question part and the answer part, that is, the first target comparison data includes question data and answer data, and the similarity score between the question data of the first target comparison data and the user input data is the first similarity score.
[0083] The encoding module 402 is used to encode the user input data of the current session using a preset encoding model in response to the first similarity score being less than a set first threshold, so as to obtain encoded data.
[0084] Specifically, if the first similarity score is greater than or equal to a set first threshold, it indicates that a relatively similar match has been found in the knowledge base for the user's input data. In this case, the session response data for the current session can be obtained based on the first target comparison data. If the first similarity score is less than the set first threshold, it indicates that no relatively similar match has been found in the knowledge base for the user's input data. In this case, the corresponding existing data in the historical session database can be matched based on the user's input data. Before being input into the historical session database, the user's input data needs to be encoded using a preset encoding model.
[0085] The second comparison module 403 is used to input the encoded data into the historical session database for comparison and obtain the second comparison result. The second comparison result includes the second target comparison data and the second similarity score between the second target comparison data and the encoded data.
[0086] Specifically, the historical session database, also known as the candidate set, is a dataset containing questions and responses from historical sessions. The process of comparing coded data with data in the historical session database is a matching process. The data in the historical session database that is similar to the coded data obtained from the matching is the second target comparison data. This data includes both question and response portions; that is, the second target comparison data includes both question and response data. The similarity score between the question data and the coded data in the second target comparison data is the second similarity score.
[0087] The response acquisition module 404 is used to acquire the session response data of the current session based on the second target comparison data in response to the second similarity score being greater than or equal to the set second threshold.
[0088] Specifically, if the second similarity score is greater than or equal to the set second threshold, it means that a relatively similar matching data has been found for the encoded data in the historical session database. At this time, the session response data for the current session can be obtained based on the second target comparison data. If the second similarity score is less than the set second threshold, it means that no relatively similar matching data has been found for the encoded data in the historical session database. At this time, no result is returned, and the current session response service ends.
[0089] According to the technical solution of this disclosure, automatic responses are obtained by combining user input with a knowledge base and a historical conversation database, which can improve agent response efficiency and ensure stable and controllable quality. Since only user input data is used, it is not necessary to obtain responses from agents in the current conversation, avoiding frequent data reading and thus improving system response speed. Furthermore, by taking into account both the knowledge base and the historical conversation database, the technical solution of this disclosure can improve response quality. In addition, the response system and encoding model designed in the technical solution of this disclosure are of low complexity and easy to implement.
[0090] In this embodiment of the disclosure, the response acquisition module can also be used to obtain session response data based on the first target comparison data in response to a first similarity score being greater than or equal to a first threshold.
[0091] In this embodiment of the disclosure, the session response device may further include a preprocessing module, used to concatenate the user's currently input data and the user's historical input data obtained according to the session identifier of the current session using a concatenation character to form the user input data. The preprocessing module may also replace the corresponding user input data with set content using set characters.
[0092] Specifically, the session identifier for the current session can be the current session ID stored in the cache. During the online response phase, user input data needs to be preprocessed. Specifically, each time the automatic response service is called, only the user's current input data and the current session ID are passed as parameters. Upon receiving the service request from the automatic response service, the historical input data of the current user in the current session corresponding to the current session ID stored in the cache is retrieved and concatenated with the encoded data processed by the encoding model using the concatenation operator [SEP] to obtain the new encoded data. The caching implementation can be a Redis database, but it is not limited to this.
[0093] In this embodiment of the disclosure, the response acquisition module can also be used to replace the set character with the corresponding set content in response to the second target comparison data containing a set character, thereby obtaining session response data.
[0094] For example, the NER (Named Entity Recognition) model can be used to identify sample session data, extract settings such as images, websites, mobile phone numbers, last four digits of mobile phone numbers, and names, and replace them with settings such as [PIC], [HTTP], [PHONE], [SUBPHONE], and [NAME], respectively, to achieve depersonalization of sample session data.
[0095] In the training phase, the technical solution of this disclosure replaces personalized information with standardized special symbols. This is because the system model does not consider the specific value of the personalized information during recognition, but only what type of information it represents. This replacement transforms the originally long string of personalized information into a standard word, effectively improving the model's recognition results. During the online response phase, the personalized information can be recovered, and special symbols can be used to indicate information that cannot be recovered, thus effectively maintaining the usability of the recommended responses.
[0096] In this embodiment of the disclosure, the session response device may further include a training module for preprocessing sample session data to obtain training data. The training data includes one response and at least one question. The sample session data includes questions and responses generated during historical sessions. The cross-entropy of positive and negative examples selected by the batch processing scheme in contrastive learning is used as the loss function. The question and response parts of the training data are respectively input into a dual-tower deep learning model for training until the loss function converges to obtain a trained encoding model. The preprocessing includes replacing the corresponding content in the sample session data with set characters and isolating the questions in the sample session data using concatenation characters.
[0097] Specifically, the sample session data includes personalized information that is useless for training the encoding model, such as names, times, and phone numbers. Replacing this personalized information with specified characters can improve the training efficiency of the encoding model. When feeding the training data into the initial model for training, the model aims to maximize the cosine similarity between each q and its corresponding a after processing. The loss function adopts the in-batch approach from contrastive learning. For a batch (q1-a1, q2-a2, ..., qn-an), for any one question qm, its corresponding am is taken as a positive example, and the other a's in the batch are taken as negative examples. The cross-entropy is calculated as the loss function. Here, m and n are natural numbers, and a batch refers to a group of data after the entire training data is divided into a fixed number of equal groups.
[0098] In this embodiment, the preprocessing module can further delete the first character before the last M characters of the question when the text length of the question is greater than a set M characters; delete the last character after the first M characters of the response when the text length of the response is greater than the set M characters; and delete the questions before the last N questions when the number of questions in the training data is greater than a set N. Here, M and N are both natural numbers. For example, M can be 512 and N can be 4, and are not limited to these values.
[0099] During the training of coding models, context awareness is required. A common practice is to concatenate the context and feed it into the model for recognition. When the length of the input text exceeds a specified value, it is often necessary to truncate or compress the text. The selection of truncation and compression strategies has a significant impact on the final result. In the model training phase, this embodiment adopts a processing method that truncates the question from the beginning and the response from the end, which can effectively retain useful information.
[0100] In this embodiment, the session response device can also be used to input sample session data into an encoding model to obtain sample encoded data, and store the sample encoded data and sample session data in a historical session database. In this embodiment, the vector obtained by processing the sample session data using the encoding model and its corresponding original text are saved together to obtain the historical session database. Based on this historical session database, step S103 can be executed to match the encoded data in the historical session database and find similar data in the database. The historical session database obtained based on this encoding model has the technical advantages of a simple matching process and relatively accurate matching results.
[0101] In this embodiment of the disclosure, each service request for the automatic response service only requires the user's current input and does not require a response from the agent. This approach greatly shortens the system's response time. The reason is that each round of user input depends only on the agent's previous response, and the candidate set for script recommendations comes from each round of agent responses. Therefore, the user's current input data and its context already contain sufficient information to make a relatively accurate response, thus achieving context-based script recommendation while ensuring low system response latency.
[0102] Since the functional modules of the session response device in the example embodiments of this disclosure correspond to the steps of the example embodiments of the session response method described above, for details not disclosed in the device embodiments of this disclosure, please refer to the embodiments of the session response method described above.
[0103] According to the session response device of this disclosure, user input data is input into a knowledge base for comparison, and the user input data is encoded when the first similarity score is less than a set first threshold. The encoded data is then input into a historical session database for comparison to obtain session response data. This approach can take into account both the historical session database and the knowledge base, thereby improving the quality of session response data.
[0104] Figure 5 This is a schematic diagram of the electronic device 5 provided in an embodiment of this disclosure. Figure 5 As shown, the electronic device 5 of this embodiment includes: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the computer program 503, it implements the steps in the various method embodiments described above. Alternatively, when the processor 501 executes the computer program 503, it implements the functions of each module in the various device embodiments described above.
[0105] Electronic device 5 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 5 may include, but is not limited to, processor 501 and memory 502. Those skilled in the art will understand that... Figure 5 This is merely an example of electronic device 5 and does not constitute a limitation on electronic device 5. It may include more or fewer components than shown, or different components.
[0106] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0107] The memory 502 can be an internal storage unit of the electronic device 5, such as a hard disk or RAM of the electronic device 5. The memory 502 can also be an external storage device of the electronic device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc., equipped on the electronic device 5. The memory 502 can also include both internal and external storage units of the electronic device 5. The memory 502 is used to store computer programs and other programs and data required by the electronic device.
[0108] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0109] If the integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0110] The above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit it. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be included within the protection scope of this disclosure.
Claims
1. A session response method, characterized in that, The method includes: User input data is input into a knowledge base for comparison to obtain a first comparison result. The first comparison result includes first target comparison data and a first similarity score between the question of the first target comparison data and the user input data. In response to a first similarity score being less than a set first threshold, the user input data for the current session is encoded using a preset encoding model to obtain encoded data; The encoded data is input into the historical session database for comparison to obtain a second comparison result. The second comparison result includes second target comparison data and a second similarity score between the second target comparison data and the encoded data. In response to the second similarity score being greater than or equal to a set second threshold, the session response data of the current session is obtained based on the second target comparison data; The training process of the encoding model includes: The sample session data is preprocessed to obtain training data, which includes one response and at least one question. The sample session data includes questions and responses generated during historical sessions. The preprocessing includes replacing the corresponding content in the sample session data with a set character and isolating the questions in the sample session data using a concatenation character. The cross-entropy of positive and negative examples selected using the batch processing scheme in contrastive learning is used as the loss function. The question part and the response part of the training data are respectively input into the dual-tower deep learning model for training until the loss function converges, and the trained encoding model is obtained.
2. The method according to claim 1, characterized in that, After obtaining the first comparison result, the method further includes: In response to a first similarity score being greater than or equal to the first threshold, the session response data is obtained based on the first target comparison data.
3. The method according to claim 1, characterized in that, Before encoding the user input data of the current session using a preset encoding model, the method further includes: The user input data is preprocessed, and the preprocessing includes replacing the corresponding user input data with set characters using set characters; The user input data is formed by concatenating the user's current input data with the user's historical input data obtained from the current session identifier using a concatenation operator.
4. The method according to claim 3, characterized in that, The step of obtaining the session response data of the current session based on the second target comparison data includes: In response to the inclusion of the set character in the second target comparison data, the set character is replaced with the corresponding set content to obtain the session response data.
5. The method according to claim 1, characterized in that, The sample session data is preprocessed to obtain training data, which includes one response and at least one question, including: If the text length of the question is greater than the set M characters, then the first character before the last M characters of the question will be deleted, where M is a natural number; If the length of the response text is greater than the set M characters, then delete the last character after the first M characters of the response; If the number of questions in the training data is greater than the set N, then the questions before the last N questions will be deleted, where N is a natural number.
6. The method according to claim 1, characterized in that, After obtaining the trained encoding model, the method further includes: The sample session data is input into the encoding model to obtain sample encoded data; The sample encoding data and sample session data are stored in the historical session database.
7. A conversation response device, characterized in that, The device includes: The first comparison module is used to input user input data into a knowledge base for comparison and obtain a first comparison result. The first comparison result includes first target comparison data and a first similarity score between the question of the first target comparison data and the user input data. The encoding module is used to encode the user input data of the current session using a preset encoding model in response to the first similarity score being less than a set first threshold, so as to obtain encoded data. The second comparison module is used to input the encoded data into the historical session database for comparison and obtain a second comparison result. The second comparison result includes second target comparison data and a second similarity score between the second target comparison data and the encoded data. The response acquisition module is used to acquire the session response data of the current session based on the second target comparison data in response to the second similarity score being greater than or equal to a set second threshold. The training process of the encoding model includes: The sample session data is preprocessed to obtain training data, which includes one response and at least one question. The sample session data includes questions and responses generated during historical sessions. The preprocessing includes replacing the corresponding content in the sample session data with a set character and isolating the questions in the sample session data using a concatenation character. The cross-entropy of positive and negative examples selected using the batch processing scheme in contrastive learning is used as the loss function. The question part and the response part of the training data are respectively input into the dual-tower deep learning model for training until the loss function converges, and the trained encoding model is obtained.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data query method and device
CN107741937A
Session recommendation method based on intelligent customer service and related device
CN111291170A