Conversation optimization method and device, electronic equipment and readable storage medium
By filtering duplicate content in historical dialogue data in the dialogue system, the dialogue system can solve the problem of answering duplicate questions after multiple rounds of conversations, improving the dialogue quality and user experience.
Patent Information
- Application Number
- CN202510136472.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-02-07
AI Technical Summary
The existing dialogue system is prone to output repeated answers after multiple rounds of conversations, resulting in the conversation being monotonous and mechanical, affecting the user experience.
When the dialogue model completes a reply, it obtains the number of historical replies and all historical dialogue data. When the number of historical replies meets the preset optimization conditions, the repeated dialogue data is filtered, and the reconstructed dialogue record is obtained, and it is input into the dialogue model as prompt data to avoid repeated answers.
By deleting repeated answers from the dialogue system, the reply quality of the dialogue model is improved, the user experience is enhanced, and the conversation is more natural and diverse.
Smart Images

Figure CN120067257A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular, to a dialogue optimization method, device, electronic device, and readable storage medium. Background Art
[0002] With the continuous development of artificial intelligence technology, dialogue systems are increasingly widely used in various fields. There is usually a common problem in existing dialogue systems, that is, after a user has multiple rounds of conversations with the dialogue system, the dialogue system is prone to output answers that are the same as the historical reply content, making the dialogue appear monotonous and mechanical, seriously affecting the user's interaction experience. Summary of the Invention
[0003] The purpose of the present invention is to provide a dialogue optimization method, device, electronic device, and readable storage medium to improve the problems existing in the prior art.
[0004] Embodiments of the present invention may be implemented as follows:
[0005] In a first aspect, the present invention provides a dialogue optimization method applied to an electronic device that runs a dialogue model. The method includes:
[0006] When the dialogue model completes a reply in the current session each time, obtain the historical reply count and all historical dialogue data of the dialogue model in the current session;
[0007] When the historical reply count meets a preset optimization condition, filter out duplicate dialogue data from all the historical dialogue data to obtain a reconstructed dialogue record;
[0008] Input the reconstructed dialogue record as prompt data into the dialogue model, so that the dialogue model determines the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data.
[0009] In an alternative embodiment, a set of the historical dialogue data includes historical question data input by the user and historical reply content output by the dialogue model;
[0010] The step of filtering out duplicate dialogue data from all the historical dialogue data to obtain a reconstructed dialogue record when the historical reply count meets a preset optimization condition includes:
[0011] When the historical reply count is greater than a preset count threshold, calculate the difference between the historical reply count and the preset count threshold;
[0012] When the ratio of the difference to the preset interval count is an integer, obtain the historical reply vector corresponding to each historical reply content of the dialogue model in the current session;
[0013] Filter the duplicate dialogue data in all the historical dialogue data based on all the historical reply vectors to obtain the reconstructed dialogue record.
[0014] In an alternative embodiment, the electronic device includes a storage area. The step of obtaining the historical reply vector corresponding to each piece of historical reply content of the dialogue model in the current session includes:
[0015] Obtain the historical reply vector corresponding to each piece of historical reply content of the dialogue model in the current session from the storage area;
[0016] Alternatively, obtain the historical reply content in each group of historical dialogue data, and convert each obtained piece of historical reply content into a historical reply vector.
[0017] In an alternative embodiment, the step of filtering the duplicate dialogue data in all the historical dialogue data based on all the historical reply vectors to obtain the reconstructed dialogue record includes:
[0018] Perform clustering processing on all the historical reply vectors to obtain a plurality of clustering sets; at least one of the historical reply vectors is included in the clustering set;
[0019] Based on all the historical dialogue data, determine the dialogue set corresponding to each clustering set; the dialogue set includes at least one group of historical dialogue data;
[0020] Use the dialogue set corresponding to each clustering set with the number of historical reply vectors exceeding a preset value as the dialogue set to be screened, and use each group of historical dialogue data in the dialogue set corresponding to each clustering set with the number of historical reply vectors not exceeding the preset value as the key dialogue data;
[0021] For each of the dialogue sets to be screened, screen out a group of key dialogue data from the dialogue set to be screened;
[0022] Rearrange all the key dialogue data to obtain the reconstructed dialogue record.
[0023] In an alternative embodiment, the step of screening out a group of key dialogue data from the dialogue set to be screened includes:
[0024] For the historical reply content in each group of historical dialogue data in the dialogue set to be screened, perform word segmentation on the historical reply content to obtain multiple words in the historical reply content;
[0025] Calculate the importance coefficient of each word in the historical reply content in the dialogue set to be screened, and use the words with the importance coefficient exceeding the coefficient threshold as the key reply words;
[0026] Count the number of key reply words corresponding to each set of historical conversation data in the conversation set to be screened, and use the historical conversation data with the largest number of key reply words as the key conversation data.
[0027] In an alternative embodiment, the step of screening a set of key conversation data from the conversation set to be screened includes:
[0028] Randomly select a set of historical conversation data from the conversation set to be screened as the key conversation data.
[0029] In an alternative embodiment, the step of rearranging all the key conversation data to obtain the reconstructed conversation record includes:
[0030] Obtain the reply timestamps associated with the historical reply contents in each of the key conversation data; arrange all the key conversation data in ascending order of the reply timestamps to obtain the reconstructed conversation record;
[0031] Alternatively, obtain the question timestamps associated with the historical question data in each of the key conversation data; arrange all the key conversation data in ascending order of the question timestamps to obtain the reconstructed conversation record.
[0032] In a second aspect, the present invention provides a conversation optimization device, which is applied to an electronic device that runs a conversation model, and includes:
[0033] An acquisition module, configured to, when the conversation model completes a reply in the current session, acquire the historical reply times and all historical conversation data of the conversation model in the current session;
[0034] An optimization module, configured to, when the historical reply times meet a preset optimization condition, filter out duplicate conversation data from all the historical conversation data to obtain a reconstructed conversation record;
[0035] The optimization module is further configured to input the reconstructed conversation record as prompt data into the conversation model, so that the conversation model determines the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data.
[0036] In a third aspect, the present invention provides an electronic device, including: a memory and a processor, where the memory stores a software program, and when the electronic device runs, the processor executes the software program to implement the conversation optimization method as described in the first aspect above.
[0037] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the dialogue optimization method described in the foregoing first aspect.
[0038] Compared with the prior art, the embodiments of the present invention provide a dialogue optimization method, apparatus, electronic device and readable storage medium. The method is applied to an electronic device running a dialogue model, and the method is as follows: when the dialogue model completes a reply in the current session, obtain the historical reply times and all historical dialogue data of the dialogue model in the current session; when the historical reply times meet the preset optimization conditions, filter out the duplicate dialogue data in all historical dialogue data to obtain a reconstructed dialogue record; finally, input the reconstructed dialogue record as prompt data into the dialogue model, so that the dialogue model can determine the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data. Since the duplicate dialogue data has been deleted from the prompt data, the subsequent dialogue model can use the prompt content as a reference to understand the context before determining the reply content, thereby avoiding the subsequent reply content from repeating the previous historical reply content, optimizing the reply quality of the dialogue model, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0040] Figure 1 FIG. 1 is a schematic flowchart of a dialogue optimization method provided by an embodiment of the present invention.
[0041] Figure 2 FIG. 2 is a schematic flowchart of a dialogue optimization method provided by an embodiment of the present invention.
[0042] Figure 3 FIG. 3 is a schematic structural diagram of a dialogue optimization apparatus provided by an embodiment of the present invention.
[0043] Figure 4 FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0044] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are only a part rather than all of the embodiments of the present invention. Components of the embodiments of the present invention described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations.
[0045] Therefore, the detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0046] It should be noted that like reference numerals and letters denote like items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0047] In the description of the present invention, it should be noted that if terms such as "upper", "lower", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, or the orientations or positional relationships in which the products of the present invention are customarily placed during use, it is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the indicated devices or elements must have specific orientations, be constructed and operated in specific orientations, and thus should not be construed as limiting the present invention.
[0048] In addition, terms such as "first" and "second" are only used for descriptive distinction and should not be construed as indicating or implying relative importance.
[0049] It should be noted that the features in the embodiments of the present invention can be combined with each other without conflict.
[0050] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a dialogue optimization method provided for an embodiment of the present invention. This method can be applied to an electronic device running a dialogue model. The electronic device can be, but is not limited to, computing devices such as smart phones, smart tablets, personal notebooks, personal computers, servers, etc. The method includes the following steps:
[0051] S101. When the dialogue model completes one reply in the current session, obtain the historical reply count and all historical dialogue data of the dialogue model in the current session.
[0052] In this embodiment, the current session is a dialogue window or interface, and a set of historical dialogue data in the current session may include historical question data input by the user and historical reply content output by the dialogue model. The historical question data input by the user can be directly in text form or text obtained by speech recognition of the user's speech.
[0053] S102. When the number of historical replies meets the preset optimization condition, filter out duplicate dialogue data from all the historical dialogue data to obtain a reconstructed dialogue record.
[0054] In this embodiment, when the number of historical replies meets the preset optimization condition, all the historical dialogue data in the current session is optimized once, that is, filter out duplicate dialogue data from all the historical dialogue data to obtain a reconstructed dialogue record.
[0055] S103. Input the reconstructed dialogue record as prompt data into the dialogue model so that the dialogue model can determine the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data.
[0056] In this embodiment, in the reconstructed dialogue record, the historical reply content in any two sets of historical dialogue data is completely different. Therefore, after inputting the reconstructed dialogue record into the dialogue model, the dialogue model has "memory" and can remember the reconstructed dialogue record rather than those historical dialogue data with original duplicate dialogue data. If similar questions or situations appear in subsequent rounds of the dialogue, the dialogue model can refer to the reconstructed dialogue record to avoid giving the same answer.
[0057] In the dialogue optimization method provided by the embodiment of the present invention, when the dialogue model completes one reply in the current session, obtain the number of historical replies of the dialogue model in the current session and all the historical dialogue data; when the number of historical replies meets the preset optimization condition, filter out the duplicate dialogue data from all the historical dialogue data and input it into the dialogue model as prompt data, so that the dialogue model can determine the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data. Since the duplicate dialogue data has been deleted from the prompt data, the subsequent dialogue model can refer to this prompt content to understand the context before determining the reply content, thereby avoiding the subsequent reply content from repeating the previous answer, improving the reply quality of the dialogue model, and improving the user experience.
[0058] In an optional implementation manner, please refer to Figure 2 , for the process of "when the number of historical replies meets the preset optimization condition, filter out duplicate dialogue data from all the historical dialogue data to obtain a reconstructed dialogue record" in step S102 above, it may include the following sub-steps:
[0059] S1021. When the number of historical responses is greater than a preset number threshold, calculate the difference between the number of historical responses and the preset number threshold.
[0060] S1022. When the ratio of the difference to the preset interval number is an integer, obtain the historical response vectors corresponding to each historical response content in the current conversation of the dialogue model.
[0061] In this embodiment, assume that the number of historical responses is N, the preset number threshold is M, and the preset interval number is K. Then the preset optimization condition is: N≥M and (N - M) / K is an integer. For example, M = 10, K = 5. That is: after the dialogue model outputs the 10th answer, the first optimization is performed, and then the dialogue model is optimized every 5 replies, so as to ensure that the dialogue model can retain the memory of the historical response content at any time and prevent repeated answers.
[0062] Optionally, the electronic device may include a storage area, and the following two methods can be provided to obtain the historical response vectors corresponding to each historical response content in the current conversation of the dialogue model:
[0063] Method 1: Obtain the historical response vectors corresponding to each historical response content in the current conversation of the dialogue model from the storage area;
[0064] Method 2: Obtain the historical response content in each group of historical conversation data, and convert each obtained historical response content into a historical response vector.
[0065] Among them, the premise of Method 1 is that when the dialogue model replies each time, the output reply content is converted into a reply vector and stored in the memory, so that when the number of historical responses meets the preset optimization condition, the historical response vectors corresponding to each historical response content in the current conversation of the dialogue model can be directly read from the memory.
[0066] S1023. Based on all the historical response vectors, filter the duplicate dialogue data in all the historical conversation data to obtain a reconstructed dialogue record.
[0067] Optionally, the clustering method can be used to exemplify all the historical response vectors to determine which ones belong to the duplicate dialogue data. Therefore, the sub-steps of step S1023 may include:
[0068] S10231. Perform clustering processing on all the historical response vectors to obtain multiple clustering sets.
[0069] In this embodiment, the clustering set includes at least one historical reply vector. The clustering algorithm used for clustering can be, but is not limited to, the K-Means (K-Means Clustering) algorithm, the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm, the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm, etc.
[0070] S10232. Determine the conversation set corresponding to each clustering set based on all historical conversation data.
[0071] In this embodiment, for each clustering set, a set of historical conversation data corresponding to each historical reply vector in the clustering set is extracted from all historical conversation data, that is, the conversation set corresponding to the clustering set is obtained. Therefore, each conversation set includes at least one set of historical conversation data.
[0072] S10233. Use the conversation set corresponding to each clustering set with the number of historical reply vectors exceeding the preset value as the conversation set to be screened, and use each set of historical conversation data in the conversation set corresponding to each clustering set with the number of historical reply vectors not exceeding the preset value as the key conversation data.
[0073] In this embodiment, the number of historical reply vectors in a clustering set is the number of elements in the clustering set. For each clustering set with the number of elements exceeding the preset value (such as 2 or 3 or 5), it is considered that there are duplicate conversation data in the conversation set corresponding to the clustering set, and the duplicate conversation data needs to be further filtered out.
[0074] S10234. For each conversation set to be screened, screen out a set of key conversation data from the conversation set to be screened.
[0075] In an optional implementation, a set of historical conversation data can be randomly selected from the conversation set to be screened as the key conversation data, and the other unselected historical conversation data is directly used as duplicate conversation data and needs to be deleted.
[0076] In another optional implementation, the number of keywords in each historical reply content in the conversation set to be screened can be determined, and then only the historical conversation data with the most keywords is retained. That is, the process of "screening out a set of key conversation data from the conversation set to be screened" in step S10234 can include the following three sub-steps:
[0077] (1) For each historical reply content in each group of historical conversation data in the set of conversations to be screened, perform word segmentation on the historical reply content to obtain multiple words in the historical reply content;
[0078] (2) Calculate the importance coefficient of each word in the historical reply content in the set of conversations to be screened, and use the words whose importance coefficient exceeds the coefficient threshold as key reply words;
[0079] (3) Count the number of key reply words corresponding to each group of historical conversation data in the set of conversations to be screened, and use the historical conversation data with the largest number of key reply words as key conversation data.
[0080] Optionally, the importance coefficient can be the TF-IDF (Term Frequency-Inverse Document Frequency) coefficient. For a set of conversations to be screened K, the calculation methods of the term frequency TF(j, i) and the inverse document frequency IDF(i) of the j-th word in the i-th historical reply content are as follows:
[0081]
[0082] Therefore, for the set of conversations to be screened K, the TF-IDF coefficient of the j-th word in the i-th historical reply content is: TF-IDF(j, i) = TF(j, i) × IDF(j).
[0083] Or, after the above S10233, for each set of conversations to be screened, the following three steps can also be provided to obtain the key conversation data in the set of conversations to be screened:
[0084] (1) Calculate the average vector of all historical reply vectors in the set of clusters to be screened corresponding to the set of conversations to be screened;
[0085] (2) Calculate the similarity between each historical reply vector in the set of clusters to be screened and the average vector;
[0086] (3) Use the group of historical conversation data corresponding to the historical reply vector with the smallest similarity in the set of conversations to be screened as key conversation data.
[0087] S10235. Rearrange all the key conversation data to obtain a reconstructed conversation record.
[0088] In this embodiment, the time stamp of each group of key conversation data can be used for rearrangement. Therefore, the following two methods can be used to obtain the reconstructed conversation record:
[0089] (1) Obtain the reply timestamps associated with the historical reply contents in each key dialogue data; arrange all the key dialogue data in ascending order of the reply timestamps to obtain a reconstructed dialogue record;
[0090] (2) Obtain the question timestamps associated with the historical question data in each key dialogue data; arrange all the key dialogue data in ascending order of the question timestamps to obtain a reconstructed dialogue record.
[0091] It should be noted that the execution order of each step in the above method embodiments is not limited by the figures shown, and the execution order of each step is subject to the actual application situation.
[0092] To execute the corresponding steps in the above method embodiments and all possible implementation manners, an implementation manner of a dialogue optimization device is given below.
[0093] Please refer to Figure 3 , Figure 3 which shows a schematic structural diagram of a dialogue optimization device provided by an embodiment of the present invention. The dialogue optimization device 200 is applied to an electronic device that runs a dialogue model. The dialogue optimization device 200 includes:
[0094] An acquisition module 210, configured to obtain the historical reply count and all historical dialogue data of the dialogue model in the current session when the dialogue model completes a reply in the current session;
[0095] An optimization module 220, configured to filter duplicate dialogue data in all the historical dialogue data to obtain a reconstructed dialogue record when the historical reply count meets a preset optimization condition;
[0096] The optimization module 220 is further configured to input the reconstructed dialogue record as prompt data into the dialogue model, so that the dialogue model determines the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data.
[0097] Optionally, a set of the historical dialogue data includes historical question data input by the user and historical reply contents output by the dialogue model. In the process of the optimization module 220 filtering duplicate dialogue data in all the historical dialogue data to obtain a reconstructed dialogue record when the historical reply count meets a preset optimization condition, it may specifically be configured to: when the historical reply count is greater than a preset count threshold, calculate the difference between the historical reply count and the preset count threshold; when the ratio of the difference to the preset interval count is an integer, obtain the historical reply vectors corresponding to each historical reply content of the dialogue model in the current session; based on all the historical reply vectors, filter duplicate dialogue data in all the historical dialogue data to obtain the reconstructed dialogue record.
[0098] Optionally, the electronic device includes a storage area. The optimization module 220, in the process of obtaining the historical reply vectors corresponding to each historical reply content of the dialogue model in the current session, can specifically be used to: obtain the historical reply vectors corresponding to each historical reply content of the dialogue model in the current session from the storage area; or, obtain the historical reply content in each group of historical dialogue data, and convert each obtained historical reply content into a historical reply vector.
[0099] Optionally, the optimization module 220, in the process of filtering the duplicate dialogue data in all the historical dialogue data based on all the historical reply vectors to obtain the reconstructed dialogue record, can specifically be used to: perform clustering processing on all the historical reply vectors to obtain a plurality of clustering sets; each clustering set includes at least one of the historical reply vectors; based on all the historical dialogue data, determine the dialogue set corresponding to each clustering set; the dialogue set includes at least one group of historical dialogue data; use the dialogue set corresponding to each clustering set with the number of historical reply vectors exceeding a preset value as the dialogue set to be screened, and use each group of historical dialogue data in the dialogue set corresponding to each clustering set with the number of historical reply vectors not exceeding the preset value as the key dialogue data; for each dialogue set to be screened, screen out a group of key dialogue data from the dialogue set to be screened; rearrange all the key dialogue data to obtain the reconstructed dialogue record.
[0100] Optionally, the optimization module 220, in the process of screening out a group of key dialogue data from the dialogue set to be screened, can specifically be used to: for the historical reply content in each group of historical dialogue data in the dialogue set to be screened, perform word segmentation on the historical reply content to obtain a plurality of words in the historical reply content; calculate the importance coefficient of each word in the historical reply content in the dialogue set to be screened, and use the words with the importance coefficient exceeding the coefficient threshold as the key reply words; count the number of key reply words corresponding to each group of historical dialogue data in the dialogue set to be screened, and use the historical dialogue data with the largest number of key reply words as the key dialogue data.
[0101] Optionally, the optimization module 220, in the process of screening out a group of key dialogue data from the dialogue set to be screened, can specifically be used to: randomly select a group of historical dialogue data from the dialogue set to be screened as the key dialogue data.
[0102] Optionally, the optimization module 220, in the process of rearranging all the key conversation data to obtain the reconstructed conversation record, can specifically be used to: obtain the reply timestamp associated with the historical reply content in each key conversation data; arrange all the key conversation data in ascending order of the reply timestamp to obtain the reconstructed conversation record; or, obtain the question timestamp associated with the historical question data in each key conversation data; arrange all the key conversation data in ascending order of the question timestamp to obtain the reconstructed conversation record.
[0103] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described dialogue optimization device 200 can refer to the corresponding process in the foregoing method embodiment, and will not be elaborated herein.
[0104] Please refer to Figure 4 , Figure 4 FIG. 10 is a schematic structural diagram of an electronic device provided in an embodiment of the present invention. The electronic device 300 includes a processor 310, a memory 320, and a bus 330. The processor 310 is connected to the memory 320 through the bus 330.
[0105] The memory 320 can be used to store software programs. For example, the software program corresponding to the dialogue optimization device 200 provided in the embodiment of the present invention. The processor 310 executes various functional applications and data processing by running the software program stored in the memory 320 to implement the dialogue optimization method provided in the embodiment of the present invention.
[0106] Among them, the memory 320 can be, but is not limited to: RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0107] The processor 310 may be an integrated circuit chip with signal processing capabilities. The processor 310 may be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), SoC (System on Chip), etc.; it may also be: DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0108] It can be understood that Figure 4 The structure shown is only for illustration, and the electronic device 300 may also include more or fewer components than those shown Figure 4 in the figure, or have a different configuration from that shown Figure 4 in the figure. Figure 4 Each component shown in the figure may be implemented by hardware, software, or a combination thereof.
[0109] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it implements the dialogue optimization method disclosed in the above embodiment. The computer-readable storage medium may be, but is not limited to: various media such as USB flash drives, external hard drives, ROM, RAM, PROM, EPROM, EEPROM, FLASH disks, or optical discs that can store program codes.
[0110] In summary, an embodiment of the present invention provides a dialogue optimization method, apparatus, electronic device, and readable storage medium. The method is applied to an electronic device running a dialogue model. The method is as follows: When the dialogue model completes a reply in the current session, obtain the historical reply count and all historical dialogue data of the dialogue model in the current session; when the historical reply count meets the preset optimization condition, filter out the duplicate dialogue data in all historical dialogue data to obtain a reconstructed dialogue record; finally, input the reconstructed dialogue record as prompt data into the dialogue model, so that the dialogue model can determine the reply content corresponding to the question data input by the user in the subsequent current session based on the prompt data. Since the duplicate dialogue data has been deleted from the prompt data, the subsequent dialogue model can use the prompt content as a reference to understand the context before determining the reply content, thereby avoiding the subsequent reply content from repeating the previous historical reply content, optimizing the reply quality of the dialogue model, and improving the user experience.
[0111] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for optimizing a conversation, characterized in that: Applied to an electronic device, the electronic device runs a dialogue model, and the method includes: When the dialogue model completes a reply in the current session, the number of historical replies and all historical dialogue data of the dialogue model in the current session are obtained; When the number of historical replies meets a preset optimization condition, filtering duplicate conversation data in all the historical conversation data to obtain a reconstructed conversation record; The reconstructed conversation record is input into the conversation model as prompt data, so that the conversation model determines the reply content corresponding to the question data subsequently input by the user in the current conversation based on the prompt data.
2. The method according to claim 1, characterized in that A set of the historical dialogue data includes historical question data input by the user and historical reply content output by the dialogue model; When the number of historical replies meets a preset optimization condition, filtering duplicate conversation data in all the historical conversation data to obtain a step of reconstructing the conversation record includes: When the number of historical replies is greater than a preset number threshold, calculating the difference between the number of historical replies and the preset number threshold; When the ratio of the difference to the preset interval number is an integer, a historical reply vector corresponding to each historical reply content of the dialogue model in the current session is obtained; Based on all the historical reply vectors, duplicate conversation data in all the historical conversation data is filtered to obtain the reconstructed conversation record.
3. The method according to claim 2, characterized in that The electronic device includes a storage area, and the step of obtaining a historical reply vector corresponding to each historical reply content of the dialogue model in the current conversation includes: Acquire, from the storage area, a historical reply vector corresponding to each historical reply content of the dialogue model in the current session; Alternatively, historical reply content in each set of historical conversation data is obtained, and each obtained historical reply content is converted into a historical reply vector.
4. The method according to claim 2, characterized in that: The step of filtering repeated conversation data in the entire historical conversation data based on all the historical reply vectors to obtain the reconstructed conversation record comprises: Performing clustering processing on all the historical reply vectors to obtain a plurality of cluster sets; the cluster sets include at least one of the historical reply vectors; Based on the entire historical conversation data, determining a conversation set corresponding to each cluster set; the conversation set includes at least one set of historical conversation data; The conversation set corresponding to each cluster set whose number of historical reply vectors exceeds a preset value is used as a conversation set to be screened, and each group of historical conversation data in the conversation set corresponding to each cluster set whose number of historical reply vectors does not exceed a preset value is used as key conversation data; For each of the dialogue sets to be screened, a set of key dialogue data is screened out from the dialogue set to be screened; All key conversation data are rearranged to obtain the reconstructed conversation record.
5. The method according to claim 4, characterized in that The step of selecting a set of key conversation data from the conversation set to be screened includes: For each group of historical conversation data in the conversation set to be screened, performing word segmentation processing on the historical reply content to obtain a plurality of words in the historical reply content; Calculate the importance coefficient of each word in the historical reply content in the set of dialogues to be screened, and use the words whose importance coefficients exceed a coefficient threshold as key reply words; The number of key reply words corresponding to each group of historical conversation data in the conversation set to be screened is counted, and the historical conversation data with the largest number of key reply words is used as the key conversation data.
6. The method according to claim 4, characterized in that The step of selecting a set of key conversation data from the conversation set to be screened includes: A set of historical conversation data is randomly selected from the conversation set to be screened as the key conversation data.
7. The method according to claim 4, characterized in that The step of rearranging all key conversation data to obtain the reconstructed conversation record includes: Obtaining the reply timestamp associated with the historical reply content in each of the key conversation data; arranging all the key conversation data in ascending order of the reply timestamps to obtain the reconstructed conversation record; Alternatively, the question timestamp associated with the historical question data in each of the key conversation data is obtained; and all the key conversation data are arranged in ascending order of the question timestamps to obtain the reconstructed conversation record.
8. A conversation optimization device, characterized in that: Applied to an electronic device, the electronic device runs a dialogue model, including: An acquisition module, used for acquiring the number of historical replies and all historical conversation data of the conversation model in the current conversation each time the conversation model completes a reply in the current conversation; An optimization module, configured to filter duplicate conversation data from all the historical conversation data to obtain a reconstructed conversation record when the number of historical replies meets a preset optimization condition; The optimization module is further configured to input the reconstructed conversation record as prompt data into the conversation model, so that the conversation model determines, based on the prompt data, a reply content corresponding to the question data subsequently input by the user in the current conversation.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the dialogue optimization method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the dialogue optimization method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for conducting multi-round conversation based on topic keyword guidance
CN109086329A
A method and device for optimizing a dialogue model
CN109635095A
Role dialogue simulation method and device, equipment and storage medium
CN114822812A
Dialogue detection model training method and device
CN115730607A
Intelligent dialogue method and device, model training method and device, storage medium and equipment
CN116414951A