Dialogue optimization method, device, electronic device and readable storage medium
By filtering repeated conversation data in the conversation model and generating reconstructed conversation records, the problem of repeated answers in the conversation system is solved, and the user experience is improved.
Patent Information
- Application Number
- CN202510136472.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-02-07
AI Technical Summary
Existing dialogue systems tend to output repeated answers after multiple rounds of dialogue, resulting in a poor user experience.
Each time the dialogue model completes a response, it obtains the historical response count and data, filters out repeated dialogue data, and generates reconstructed dialogue records as prompt data input into the model to avoid repeated answers.
The response quality of the dialogue model is improved, which enhances the user experience.
Smart Images

Figure CN120067257B_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 being used in various fields. However, existing dialogue systems often suffer from a common problem: after multiple rounds of conversation between the user and the dialogue system, the system tends to output responses that are identical to previous responses, making the conversation appear monotonous and mechanical, seriously affecting the user's interactive experience. Summary of the Invention
[0003] The purpose of the present invention is to provide a conversation optimization method, device, electronic device and readable storage medium to improve the problems existing in the prior art.
[0004] The embodiments of the present invention can be implemented as follows:
[0005] In a first aspect, the present invention provides a conversation optimization method, applied to an electronic device running a conversation model, the method comprising:
[0006] 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;
[0007] When the number of historical replies meets a preset optimization condition, filtering duplicate conversation data from all the historical conversation data to obtain a reconstructed conversation record;
[0008] The reconstructed conversation record is input into the conversation model as prompt data, so that the conversation model determines, based on the prompt data, reply content corresponding to question data subsequently input by the user in the current conversation.
[0009] In an optional embodiment, a set of the historical conversation data includes historical question data input by the user and historical reply content output by the conversation model;
[0010] When the number of historical replies meets a preset optimization condition, the step of filtering duplicate conversation data in all the historical conversation data to obtain a reconstructed conversation record includes:
[0011] 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;
[0012] When the ratio of the difference to the preset number of intervals is an integer, obtaining a historical reply vector corresponding to each historical reply content of the dialogue model in the current session;
[0013] Based on all the historical reply vectors, repeated conversation data in all the historical conversation data is filtered to obtain the reconstructed conversation record.
[0014] In an optional embodiment, 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 session includes:
[0015] Acquire, from the storage area, a historical reply vector corresponding to each historical reply content of the dialogue model in the current session;
[0016] 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.
[0017] In an optional embodiment, the step of filtering duplicate conversation data in the entire historical conversation data based on all the historical reply vectors to obtain the reconstructed conversation record includes:
[0018] performing clustering processing on all the historical response vectors to obtain a plurality of cluster sets; each cluster set includes at least one of the historical response vectors;
[0019] Determining a conversation set corresponding to each cluster set based on all the historical conversation data; the conversation set includes at least one set of historical conversation data;
[0020] The conversation set corresponding to each cluster set whose number of historical reply vectors exceeds a preset value is used as the conversation set to be screened, and each set of historical conversation data in the conversation set corresponding to each cluster set whose number of historical reply vectors does not exceed the preset value is used as the key conversation data;
[0021] For each of the conversation sets to be screened, screening out a set of key conversation data from the conversation set to be screened;
[0022] All key conversation data are rearranged to obtain the reconstructed conversation record.
[0023] In an optional embodiment, the step of screening out a set of key conversation data from the set of conversations to be screened includes:
[0024] For each set 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;
[0025] Calculating the importance coefficient of each word in the historical reply content in the set of dialogues to be screened, and taking the words whose importance coefficients exceed a coefficient threshold as key reply words;
[0026] 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.
[0027] In an optional embodiment, the step of screening out a set of key conversation data from the set of conversations to be screened includes:
[0028] A set of historical conversation data is randomly selected from the conversation set to be screened as the key conversation data.
[0029] In an optional embodiment, the step of rearranging all key conversation data to obtain the reconstructed conversation record includes:
[0030] Obtaining a reply timestamp associated with a historical reply content in each of the key conversation data; arranging all of the key conversation data in ascending order of the reply timestamps to obtain the reconstructed conversation record;
[0031] 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.
[0032] In a second aspect, the present invention provides a conversation optimization device, applied to an electronic device, wherein the electronic device runs a conversation model, comprising:
[0033] an acquisition module, configured to acquire 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;
[0034] 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;
[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, based on the prompt data, a reply content corresponding to question data subsequently input by the user in the current conversation.
[0036] In a third aspect, the present invention provides an electronic device comprising: 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 conversation optimization method as described in the first aspect above.
[0037] In a fourth aspect, 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 first aspect.
[0038] Compared to the prior art, embodiments of the present invention provide a conversation optimization method, apparatus, electronic device, and readable storage medium. This method is applied to an electronic device running a conversation model. The method comprises the following steps: Each time the conversation model completes a reply in the current conversation, the number of historical replies and all historical conversation data for the conversation model in the current conversation are obtained. When the number of historical replies meets a preset optimization condition, duplicate conversation data is filtered from the entire historical conversation data to obtain a reconstructed conversation record. Finally, the reconstructed conversation record is input as prompt data into the conversation model, enabling the conversation model to determine, based on the prompt data, the response content corresponding to subsequent user-entered question data in the current conversation. Because duplicate conversation data has been deleted from the prompt data, the subsequent conversation model can use the prompt content as a reference to understand the context before determining the response content, thereby avoiding duplication of subsequent responses with previous historical responses. This optimizes the quality of the conversation model's responses and enhances 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 briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 One of the flow charts of a conversation optimization method provided in an embodiment of the present invention.
[0041] Figure 2 The second flowchart of a conversation optimization method provided by an embodiment of the present invention.
[0042] Figure 3 A structural diagram of a conversation optimization device provided by an embodiment of the present invention.
[0043] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0044] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0045] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0046] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0047] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the accompanying drawings, or is the orientation or position relationship in which the product of the invention is usually placed when in use. It is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be understood as a limitation on the present invention.
[0048] In addition, the terms "first", "second", etc., if used, are merely used to distinguish and describe, and should not be understood as indicating or implying relative importance.
[0049] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0050] Please refer to Figure 1 , Figure 1 This is a flow chart of a conversation optimization method provided by an embodiment of the present invention. This method can be applied to electronic devices running a conversation model, such as, but not limited to, smartphones, smart tablets, personal notebooks, personal computers, servers, and other computing devices. The method includes the following steps:
[0051] S101. Each time the dialogue model completes a reply in the current conversation, the number of historical replies and all historical dialogue data of the dialogue model in the current conversation are obtained.
[0052] In this embodiment, the current conversation is a dialog window or interface. The set of historical conversation data in the current session may include historical questions input by the user and historical replies output by the dialog model. The historical question data input by the user may be in text form or text obtained through speech recognition of the user's speech.
[0053] S102: When the number of historical replies meets a preset optimization condition, duplicate conversation data in all historical conversation data is filtered to obtain a reconstructed conversation record.
[0054] In this embodiment, when the number of historical replies meets the preset optimization condition, all historical conversation data in the current session is optimized once, that is, repeated conversation data in all historical conversation data is filtered to obtain a reconstructed conversation record.
[0055] S103: Input the reconstructed conversation record as prompt data into the conversation model, so that the conversation model determines, based on the prompt data, the reply content corresponding to the question data subsequently input by the user in the current conversation.
[0056] In this embodiment, in the reconstructed conversation record, the historical responses in any two sets of historical conversation data are completely different. Therefore, after inputting the reconstructed conversation record into the conversation model, the conversation model has a "memory" that can remember which historical conversation data contains duplicates rather than the reconstructed conversation record. If similar questions or situations arise in subsequent rounds of the conversation, the conversation model can refer to the reconstructed conversation record to avoid giving the same response.
[0057] In the conversation optimization method provided by an embodiment of the present invention, each time a conversation model completes a response in the current conversation, the conversation model obtains the number of historical responses and all historical conversation data in the current conversation. When the number of historical responses meets a preset optimization condition, duplicate conversation data from the entire historical conversation data is filtered out and input into the conversation model as prompt data. This allows the conversation model to determine, based on the prompt data, the corresponding response content for subsequent questions entered by the user in the current conversation. Because duplicate conversation data has been deleted from the prompt data, the subsequent conversation model can use the prompt content as a reference to understand the context before determining the response content, thereby avoiding duplication of subsequent responses with previous answers, improving the quality of the conversation model's responses and enhancing the user experience.
[0058] For optional implementations, see Figure 2 The process of "filtering duplicate conversation data from all historical conversation data to obtain reconstructed conversation records when the number of historical replies meets the preset optimization condition" in step S102 may include the following sub-steps:
[0059] S1021. When the number of historical replies is greater than a preset number threshold, calculate the difference between the number of historical replies and the preset number threshold.
[0060] S1022. When the ratio of the difference to the preset interval number is an integer, obtain a historical response vector corresponding to each historical response content of the dialogue model in the current session.
[0061] In this example, assuming the number of historical replies is N, the preset threshold is M, and the preset interval is K, then the preset optimization condition is: N ≥ M, and (NM) / K is an integer. For example, if M = 10 and K = 5, then the first optimization is performed after the dialogue model outputs a response for the tenth time. Thereafter, optimization is performed every five replies, ensuring that the dialogue model retains its memory of historical replies and avoids repetitive responses.
[0062] Optionally, the electronic device may include a storage area, and may provide the following two methods for obtaining a historical reply vector corresponding to each historical reply content of the dialogue model in the current session:
[0063] Method 1: Obtain the historical response vector corresponding to each historical response content of the dialogue model in the current session from the storage area;
[0064] Method 2: Obtain the historical reply content in each set of historical conversation data, and convert each obtained historical reply content into a historical reply vector.
[0065] Among them, the premise of method one is: each time the dialogue model replies, the output reply content is converted into a reply vector and stored in the memory, so that when the number of historical replies meets the preset optimization conditions, the historical reply vector corresponding to each historical reply content of the dialogue model in the current session can be directly read from the memory.
[0066] S1023. Based on all historical reply vectors, duplicate conversation data in all historical conversation data is filtered to obtain a reconstructed conversation record.
[0067] Optionally, all historical reply vectors may be sampled using a clustering approach to determine which ones are repeated conversation data. Therefore, the sub-steps of step S1023 may include:
[0068] S10231. Perform clustering processing on all historical response vectors to obtain multiple cluster sets.
[0069] In this embodiment, the cluster set includes at least one historical response vector. The clustering algorithm used in the clustering process may be, but is not limited to, a K-Means (K-Means Clustering) algorithm, a DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm, or a DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm.
[0070] S10232. Based on all historical conversation data, determine the conversation set corresponding to each cluster set.
[0071] In this embodiment, for each cluster set, a set of historical conversation data corresponding to each historical reply vector in the cluster set is extracted from all historical conversation data, thereby obtaining the conversation set corresponding to the cluster set. Therefore, each conversation set includes at least one set of historical conversation data.
[0072] S10233. The conversation set corresponding to each cluster set whose number of historical reply vectors exceeds a preset value is used as the 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 the preset value is used as the key conversation data.
[0073] In this embodiment, the number of historical reply vectors in a cluster set is the number of elements in the cluster set. For each cluster set whose number of elements exceeds a preset value (for example, 2, 3, or 5), it is considered that there is duplicate conversation data in the conversation set corresponding to the cluster set, and the duplicate conversation data needs to be further filtered out.
[0074] S10234. For each conversation set to be screened, a set of key conversation data is screened out 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 key conversation data, and other unselected historical conversation data can be directly treated as duplicate conversation data and need to be deleted.
[0076] In another optional implementation, the number of keywords in each historical reply in the set of conversations to be screened may be determined, and then only the historical conversation data with the most keywords may be retained. That is, the process of "screening a set of key conversation data from the set of conversations to be screened" in step S10234 may include the following three sub-steps:
[0077] (1) For each set of historical conversation data in the conversation set 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 dialogue set to be screened, and take the words whose importance coefficient exceeds the coefficient threshold as key reply words;
[0079] (3) Count the number of key response words corresponding to each group of historical dialogue data in the dialogue set to be screened, and take the historical dialogue data with the largest number of key response words as the key dialogue data.
[0080] Optionally, the important coefficient can be the TF-IDF (Term Frequency-Inverse Document Frequency) coefficient. For a set of dialogues to be screened K, the term frequency TF(j,i) and inverse document frequency IDF(i) of the jth word in the i-th historical reply are calculated as follows:
[0081]
[0082] Therefore, for the conversation set K to be screened, 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] Alternatively, after S10233, for each conversation set to be screened, the following three steps may be provided to obtain key conversation data in the conversation set to be screened:
[0084] (1) Calculate the average vector of all historical reply vectors in the cluster set to be screened corresponding to the dialogue set to be screened;
[0085] (2) Calculate the similarity between each historical response vector and the average vector in the cluster set to be screened;
[0086] (3) A set of historical conversation data corresponding to the historical reply vector with the smallest similarity in the conversation set to be screened is used as the key conversation data.
[0087] S10235. Rearrange all key conversation data to obtain reconstructed conversation records.
[0088] In this embodiment, the timestamp of each set 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 timestamp associated with the historical reply content in each key conversation data; sort all key conversation data in ascending order of reply timestamps to obtain the reconstructed conversation record;
[0090] (2) Obtain the question timestamp associated with the historical question data in each key conversation data; arrange all key conversation data in ascending order of question timestamps to obtain the reconstructed conversation record.
[0091] It should be noted that the execution order of the steps in the above method embodiment is not limited to that shown in the drawings, and the execution order of the steps shall be based on actual application conditions.
[0092] In order to execute the corresponding steps in the above method embodiment and various possible implementations, an implementation of a conversation optimization device is provided below.
[0093] See Figure 3 , Figure 3 The structure diagram of the dialogue optimization device provided by an embodiment of the present invention is shown. 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 is configured to acquire the number of historical responses and all historical conversation data of the conversation model in the current conversation each time the conversation model completes a response in the current conversation;
[0095] Optimization module 220, configured to filter duplicate conversation data from all historical conversation data to obtain reconstructed conversation records when the number of historical replies meets a preset optimization condition;
[0096] The optimization module 220 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, the reply content corresponding to the question data subsequently input by the user in the current conversation.
[0097] Optionally, a set of historical conversation data includes historical question data input by the user and historical reply content output by the conversation model. When the number of historical replies meets a preset optimization condition, the optimization module 220 is configured to filter duplicate conversation data from the entire historical conversation data to obtain a reconstructed conversation record. Specifically, the optimization module 220 may be configured to: when the number of historical replies exceeds a preset threshold, calculate the difference between the number of historical replies and the preset threshold; when the ratio of the difference to the preset interval is an integer, obtain a historical reply vector corresponding to each historical reply content of the conversation model in the current session; and based on all the historical reply vectors, filter duplicate conversation data from the entire historical conversation data to obtain the reconstructed conversation record.
[0098] Optionally, the electronic device includes a storage area. The optimization module 220, in the process of obtaining a historical reply vector corresponding to each historical reply content of the dialogue model in the current session, may be specifically configured to: obtain the historical reply vector 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 set 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 duplicate conversation data in all the historical conversation data based on all the historical reply vectors to obtain the reconstructed conversation record, can be specifically used to: cluster all the historical reply vectors to obtain multiple cluster sets; the cluster sets include at least one historical reply vector; based on all the historical conversation data, determine the conversation set corresponding to each cluster set; the conversation set includes at least one group of historical conversation data; use the conversation set corresponding to each cluster set whose number of historical reply vectors exceeds a preset value as the conversation set to be filtered, and use each group of historical conversation data in the conversation set corresponding to each cluster set whose number of historical reply vectors does not exceed the preset value as key conversation data; for each conversation set to be filtered, filter out a group of key conversation data from the conversation set to be filtered; and rearrange all the key conversation data to obtain the reconstructed conversation record.
[0100] Optionally, the optimization module 220, in the process of screening out a group of key conversation data from the conversation set to be screened, can be specifically used to: perform word segmentation processing on the historical reply content in each group of historical conversation data in the conversation set to be screened to obtain multiple words in the historical reply content; calculate the importance coefficient of each word of the historical reply content in the conversation set to be screened, and use the words whose importance coefficient exceeds the coefficient threshold as key reply words; count the number of key reply words corresponding to each group 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.
[0101] Optionally, the optimization module 220, in the process of screening out a set of key conversation data from the set of conversations to be screened, may be specifically configured to: randomly select a set of historical conversation data from the set of conversations to be screened as the key conversation data.
[0102] Optionally, the optimization module 220, in the process of rearranging all the key conversation data to obtain the reconstructed conversation record, can be specifically used to: obtain the reply timestamp associated with the historical reply content in each of the key conversation data; arrange all the key conversation data in order of the reply timestamps from small to large to obtain the reconstructed conversation record; or obtain the question timestamp associated with the historical question data in each of the key conversation data; arrange all the key conversation data in order of the question timestamps from small to large to obtain the reconstructed conversation record.
[0103] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working process of the dialogue optimization device 200 described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0104] See Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 , wherein the processor 310 is connected to the memory 320 via the bus 330 .
[0105] The memory 320 can be used to store software programs, such as the software program corresponding to the conversation optimization device 200 provided in the embodiment of the present invention. The processor 310 executes the software program stored in the memory 320 to perform various functional applications and data processing to implement the conversation 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] Processor 310 can be an integrated circuit chip with signal processing capabilities. Processor 310 can be a general-purpose processor, including a CPU (Central Processing Unit), a Network Processor (NP), or a System on Chip (SoC). It can also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0108] I understand. Figure 4 The structure shown is for illustration only. The electronic device 300 may also include Figure 4 More or fewer components than shown, or with Figure 4 Different configurations shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0109] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the conversation optimization method disclosed in the above embodiments. The computer-readable storage medium may be, but is not limited to, a USB flash drive, a mobile hard drive, ROM, RAM, PROM, EPROM, EEPROM, a FLASH disk, or an optical disk, among other media capable of storing program code.
[0110] In summary, embodiments of the present invention provide a conversation optimization method, apparatus, electronic device, and readable storage medium. This method is applied to an electronic device running a conversation model. The method comprises the following steps: Each time the conversation model completes a reply in a current conversation, the number of historical replies and all historical conversation data for the conversation model in the current conversation are obtained. When the number of historical replies meets a preset optimization condition, duplicate conversation data is filtered from the entire historical conversation data to obtain a reconstructed conversation record. Finally, the reconstructed conversation record is input into the conversation model as prompt data, enabling the conversation model to determine, based on the prompt data, the response content corresponding to subsequent question data entered by the user in the current conversation. Because duplicate conversation data has been deleted from the prompt data, the subsequent conversation model can use the prompt content as a reference to understand the context before determining the response content, thereby avoiding duplication of subsequent responses with previous historical responses. This optimizes the quality of the conversation model's responses and enhances the user experience.
[0111] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A method for dialogue optimization, characterized in that: Applied to an electronic device running a conversation model, 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; a set of 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 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 number of intervals is an integer, obtaining a historical reply vector corresponding to each historical reply content of the dialogue model in the current session; Based on all the historical reply vectors, filtering out 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, based on the prompt data, reply content corresponding to question data subsequently input by the user in the current conversation.
2. The method according to claim 1, 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 session 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.
3. The method according to claim 1, characterized in that The step of filtering duplicate conversation data in the entire historical conversation data based on all the historical reply vectors to obtain the reconstructed conversation record includes: performing clustering processing on all the historical response vectors to obtain a plurality of cluster sets; each cluster set includes at least one of the historical response vectors; Determining a conversation set corresponding to each cluster set based on all the historical conversation data; 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 the conversation set to be screened, and each set of historical conversation data in the conversation set corresponding to each cluster set whose number of historical reply vectors does not exceed the preset value is used as the key conversation data; For each of the conversation sets to be screened, screening out a set of key conversation data from the conversation set to be screened; All key conversation data are rearranged to obtain the reconstructed conversation record.
4. The method according to claim 3, characterized in that The step of screening out a set of key conversation data from the conversation set to be screened includes: For each set 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; Calculating the importance coefficient of each word in the historical reply content in the set of dialogues to be screened, and taking 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.
5. The method according to claim 3, characterized in that The step of screening out 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.
6. The method according to claim 3, characterized in that The step of rearranging all key conversation data to obtain the reconstructed conversation record includes: Obtaining a reply timestamp associated with a historical reply content in each of the key conversation data; arranging all of 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.
7. A conversation optimization device, characterized in that: Applied to an electronic device, the electronic device running a conversation model, including: an acquisition module configured to acquire the number of historical responses and all historical conversation data of the conversation model in the current conversation each time the conversation model completes a response in the current conversation; a set of historical conversation data includes historical question data input by the user and historical response content output by the conversation model; an optimization module, configured to calculate a difference between the number of historical replies and the preset number threshold when the number of historical replies is greater than a preset number threshold; The optimization module is further configured to obtain a historical response vector corresponding to each historical response content of the dialogue model in the current session when the ratio of the difference to the preset interval number is an integer; The optimization module is further configured to filter duplicate conversation data from all the historical conversation data based on all the historical reply vectors to obtain a reconstructed conversation record; 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 question data subsequently input by the user in the current conversation.
8. 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 according to any one of claims 1 to 6.
9. 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 6 is implemented.
Citation Information
Patent Citations
Role dialogue simulation method and device, equipment and storage medium
CN114822812A
Session processing method and device, electronic equipment and computer readable storage medium
CN117076623A