Man-machine conversation method and device, electronic equipment and storage medium
By using the target model in the intelligent assistant to match and decode the dialogue text and historical summary, and generate a correlation representation, the problem of the intelligent assistant lacking memory ability in human-computer dialogue is solved, and the dialogue memory function and dialogue accuracy of the intelligent assistant are realized Sex improvement.
Patent Information
- Application Number
- CN202310628941.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2024-12-03
AI Technical Summary
Existing intelligent assistants lack memory capabilities in human-computer dialogues and are unable to effectively remember and utilize historical dialogue information, resulting in dialogue not having long-term memory functions.
By obtaining the user's currently input dialogue text and the summary of the historical dialogue text, the target model is used to decode the task to generate a correlation representation, retrieve the relevant summary and generate reply text, realize the robot dialogue memory function, and optimize through multi-task joint training Model.
The memory capability of the intelligent assistant is realized, allowing it to effectively utilize historical information in long-term dialogue scenarios, generate more context-based responses, reduce the number of models and improve the accuracy of conversations.
Smart Images

Figure CN119066157A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of natural language processing, and in particular to a human-computer dialogue method, device, electronic device and storage medium. Background Art
[0002] Human-computer dialogue technology has been applied to various types of products, such as smart assistants. With the continuous development of human-computer dialogue technology, people gradually pursue the anthropomorphic ability of smart assistants, which means that every time they chat with smart assistants, they can chat like friends, and hope that smart assistants can understand them. This poses a new challenge to the human-computer dialogue technology of smart assistants, that is, smart assistants need to have the ability to remember and use memory. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a human-computer dialogue method, device, electronic device and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a human-computer dialogue method is provided, comprising:
[0005] Acquire the dialogue text currently input by the user, and for each summary stored in the dialogue memory, input the dialogue text, the context of the dialogue text, and the summary into the target model to obtain a first correlation representation output by the target model after performing a first decoding task, wherein the first correlation representation is used to characterize the correlation between the dialogue text and the input summary, and the summary stored in the dialogue memory is generated based on the dialogue text in the historical dialogue between the user and the robot;
[0006] Determining at least one abstract related to the conversation text according to a first correlation representation between the conversation text and each of the abstracts;
[0007] Inputting the dialogue text, the context of the dialogue text and the at least one summary into the target model, and obtaining a reply text output by the target model after performing the second decoding task as the dialogue text of the robot;
[0008] Conduct a dialogue with the user according to the dialogue text of the robot.
[0009] Optionally, the target model performs a second decoding task, including:
[0010] The target model determines a second relevance representation according to the conversation text, the context of the conversation text and the at least one summary, wherein the second relevance representation is used to characterize the relevance between the conversation text and the at least one input summary;
[0011] The target model sequentially generates the words constituting the reply text according to the second relevance representation.
[0012] Optionally, the target model sequentially generates each word constituting the reply text according to the second relevance representation, including:
[0013] For the tth word constituting the reply text, the target model determines a target probability distribution according to a first probability distribution and a second probability distribution corresponding to the tth word, and determines a word with the largest generation probability from a preset word list according to the target probability distribution as the tth word, wherein the first probability distribution indicates the generation probability of the tth word corresponding to each word in the preset word list under the condition of the t-1 words before the tth word, and the second probability distribution indicates the generation probability of the tth word corresponding to each word in the preset word list under the condition represented by the second correlation.
[0014] Optionally, the method further comprises:
[0015] Inputting the dialogue text and the context of the dialogue text into the target model, and obtaining a summary text output by the target model after performing a third decoding task as a first summary;
[0016] The first summary is stored in the conversation memory.
[0017] Optionally, storing the first summary in the conversation memory includes:
[0018] Calculating the similarity between the first summary and each summary in the conversation memory;
[0019] If the similarity is greater than or equal to a preset threshold, the corresponding summary in the conversation memory is deleted, and the first summary is written into the conversation memory;
[0020] If the similarity is less than the preset threshold, the first summary is directly written into the conversation memory.
[0021] Optionally, the method further comprises:
[0022] Before inputting the dialogue text of the user or the robot into the target model, inserting a role marker at the beginning of the dialogue text to be input, wherein the role marker is used to indicate that the dialogue text to be input corresponds to a user role or a robot role;
[0023] Before inputting the abstract into the target model, a memory marker is inserted at the beginning of the abstract to be input.
[0024] Optionally, the target model includes an encoder and a decoder, and the method further includes:
[0025] Inserting a start marker at a start input position of the decoder, and the decoder starts decoding based on the start marker;
[0026] The first task marker or the second task marker is inserted into the second input position of the decoder, and the decoder performs the second decoding task based on the first task marker and performs the third decoding task based on the second task marker.
[0027] Optionally, the target model is trained by the following process:
[0028] Determine a training memory library and a training set, wherein the training set includes training texts representing multiple rounds of dialogue between a user character and a robot character;
[0029] For the third decoding task, the training text of the user role and the context of the training text are input into the target model, a third correlation representation and summary text output by the target model after the third decoding task is performed are obtained, and a third loss corresponding to the third decoding task is calculated according to the third correlation representation;
[0030] For a first decoding task, a summary is sampled from a training memory bank, a training text of the user role, a context of the training text, and the sampled summary are input into the target model, a first correlation representation output by the target model after the first decoding task is performed is obtained, and a first loss corresponding to the first decoding task is calculated according to the first correlation representation;
[0031] For the second decoding task, at least one summary is sampled from the training memory library, the training text of the user role, the context of the training text and the sampled at least one summary are input into the target model, a second correlation representation and a reply text outputted by the target model after the second decoding task is performed are obtained, and a second loss corresponding to the second decoding task is calculated according to the second correlation representation;
[0032] A total loss is obtained according to the first loss, the second loss and the third loss, and multi-task joint training is performed on the target model according to the total loss.
[0033] Optionally, calculating a third loss corresponding to the third decoding task according to the third correlation representation includes:
[0034] determining a third relevance classification probability according to the third relevance representation;
[0035] Determine the generation probability corresponding to each word constituting the summary text, and determine the generation probability corresponding to the summary text according to the generation probability corresponding to each word;
[0036] The third loss is determined according to the third relevance classification probability and the generation probability corresponding to the summary text.
[0037] Optionally, calculating a first loss corresponding to the first decoding task according to the first correlation representation includes:
[0038] determining a first relevance classification probability based on the first relevance representation;
[0039] The first loss is determined according to the first relevance classification probability.
[0040] Optionally, calculating a second loss corresponding to the second decoding task according to the second correlation representation includes:
[0041] determining a second relevance classification probability based on the second relevance representation;
[0042] Determine the generation probability corresponding to each word constituting the reply text, and determine the generation probability corresponding to the reply text according to the generation probability corresponding to each word;
[0043] The second loss is determined according to the second relevance classification probability and the generation probability corresponding to the reply text.
[0044] According to a second aspect of an embodiment of the present disclosure, there is provided a human-machine dialogue device, comprising:
[0045] a correlation determination module, configured to obtain a conversation text currently input by a user, and for each summary stored in a conversation memory, input the conversation text, the context of the conversation text, and the summary into a target model, and obtain a first correlation representation output by the target model after performing a first decoding task, wherein the first correlation representation is used to characterize the correlation between the conversation text and the input summary, and the summary stored in the conversation memory is generated based on the conversation text in the historical conversation between the user and the robot;
[0046] a summary determination module, configured to determine at least one summary related to the conversation text according to a first correlation representation between the conversation text and each of the summaries;
[0047] a reply generation module, used to input the dialogue text, the context of the dialogue text and the at least one summary into the target model, and obtain a reply text output by the target model after performing the second decoding task as the dialogue text of the robot;
[0048] The human-machine dialogue module is used to conduct a dialogue with the user according to the dialogue text of the robot.
[0049] Optionally, when the target model performs a second decoding task, it is used to determine a second relevance representation based on the conversation text, the context of the conversation text and the at least one summary, wherein the second relevance representation is used to characterize the relevance between the conversation text and the at least one input summary; and to sequentially generate individual words constituting the reply text according to the second relevance representation.
[0050] Optionally, in the process of the target model sequentially generating each word constituting the reply text according to the second correlation representation, for the tth word constituting the reply text, the target probability distribution is determined according to the first probability distribution and the second probability distribution corresponding to the tth word, and the word with the largest generation probability is determined from the preset vocabulary according to the target probability distribution as the tth word, wherein the first probability distribution represents the generation probability of the tth word corresponding to each word in the preset vocabulary under the condition of the t-1 words before the tth word, and the second probability distribution represents the generation probability of the tth word corresponding to each word in the preset vocabulary under the condition of the second correlation representation.
[0051] Optionally, the human-machine dialogue device further includes:
[0052] A summary extraction module, used for inputting the dialogue text and the context of the dialogue text into the target model, and obtaining a summary text output by the target model after performing a third decoding task as a first summary;
[0053] A summary storage module is used to store the first summary in the dialogue memory.
[0054] Optionally, the summary storage module is used to calculate the similarity between the first summary and each summary in the conversation memory; if the similarity is greater than or equal to a preset threshold, the corresponding summary in the conversation memory is deleted and the first summary is written into the conversation memory; if the similarity is less than the preset threshold, the first summary is directly written into the conversation memory.
[0055] Optionally, the human-computer dialogue device also includes an input processing module, which is used to insert a role marker at the starting position of the dialogue text to be input before the dialogue text of the user or the robot is input into the target model, and the role marker is used to indicate that the dialogue text to be input corresponds to a user role or a robot role; and is used to insert a memory marker at the starting position of the summary to be input before the summary is input into the target model.
[0056] Optionally, the target model includes an encoder and a decoder, and the human-computer dialogue device also includes an input processing module, which is used to insert a start marker at the starting input position of the decoder, and the decoder starts decoding based on the start marker; and is used to insert a first task marker or a second task marker at the second input position of the decoder, and the decoder performs a second decoding task based on the first task marker and performs a third decoding task based on the second task marker.
[0057] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0058] processor;
[0059] a memory for storing processor-executable instructions;
[0060] The processor is configured to execute instructions stored in the memory to implement the human-computer dialogue method provided in the first aspect of the present disclosure.
[0061] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the human-computer dialogue method provided by the first aspect of the present disclosure is implemented.
[0062] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0063] The present disclosure first memorizes the historical conversations between the user and the robot, compresses and simplifies the original conversation texts between the user and the robot in the historical conversations into multiple effective and brief summaries, and stores them in the conversation memory. When conducting the current conversation, according to the conversation text currently input by the user, a summary related to the conversation text is retrieved from the conversation memory through the first decoding task, and then according to the conversation text and the retrieved summary, the robot's conversation text is generated through the second decoding task, so that the robot can have the ability to remember and use memory, and can be applied to long-term memory conversation scenarios. In addition, the present disclosure uses the same target model for modeling for the first decoding task and the second decoding task, and reduces the number of models through parameter sharing.
[0064] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0066] Figure 1The figure is a flow chart of a human-computer dialogue method according to an exemplary embodiment.
[0067] Figure 2 is a schematic diagram of a scenario of a long-term memory dialogue between a user and a robot according to an exemplary embodiment.
[0068] Figure 3 is a schematic diagram showing a target model performing a third decoding task in a training phase according to an exemplary embodiment.
[0069] Figure 4 It is a schematic diagram showing a target model performing a first decoding task in a training phase according to an exemplary embodiment.
[0070] Figure 5 It is a schematic diagram showing that a target model performs a second decoding task in a training phase according to an exemplary embodiment.
[0071] Figure 6 The figure is a block diagram of a human-machine dialogue device according to an exemplary embodiment.
[0072] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0073] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0074] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0075] Figure 1 is a flowchart of a human-computer dialogue method according to an exemplary embodiment, through which a long-term memory dialogue between a user and a robot can be realized. Figure 1 , the human-computer dialogue method comprises the following steps:
[0076] Step S101, obtain the dialogue text currently input by the user, and for each summary stored in the dialogue memory, input the dialogue text, the context of the dialogue text and the summary into the target model to obtain a first correlation representation output by the target model after performing a first decoding task.
[0077] The first correlation represents the correlation between the conversation text and the input summary.
[0078] The dialogue memory is used to store summaries, each of which is generated based on the dialogue text between the user and the robot in the historical dialogue. For example, in the historical dialogue, the user and the robot had multiple rounds of dialogue, and the dialogue text of the user and the dialogue text of the robot in the multiple rounds of dialogue were compressed into multiple effective and short summaries, each of which can be understood as a memory of the content of the historical dialogue. The summary is then stored in the dialogue memory.
[0079] Step S102: determining at least one abstract related to the conversation text according to a first correlation representation between the conversation text and each abstract.
[0080] For example, assume that there are N summaries stored in the conversation memory. For each of the N summaries, the conversation text, the context of the conversation text, and the summary are input into the target model. The target model performs a first decoding task based on the above input and outputs a first correlation representation, which is used to characterize the correlation between the conversation text and the summary. Thus, N first correlation representations are obtained. Then, based on the N first correlation representations, p summaries related to the conversation text are determined, for example, p summaries with the highest correlation with the conversation text are determined, where p is a positive integer.
[0081] The context of the conversation text includes the conversation text between the user and the robot before the conversation text, and may also include the conversation text between the robot and the user before the conversation text.
[0082] In one example, the conversation text is recorded as u n , then the context of the dialogue text may include {u1,b1,……,u n-1 ,b n-1}, where u at the beginning represents a user and b at the beginning represents a robot.
[0083] Step S103, inputting the dialogue text, the context of the dialogue text and the at least one summary into the target model, obtaining a reply text output by the target model after performing the second decoding task as the dialogue text of the robot.
[0084] In some embodiments, the target model performing the second decoding task may include:
[0085] The target model first determines a second relevance representation based on the conversation text, the context of the conversation text, and the at least one summary. The second relevance representation is used to represent the relevance between the conversation text and the at least one summary input. For example, when multiple summaries are input, the second relevance representation can represent whether the conversation text is related to at least one of the multiple summaries. After determining the second relevance representation, the words constituting the reply text are sequentially generated based on the second relevance representation.
[0086] In some embodiments, a plurality of words are defined in a preset word list, and each word constituting the reply text is determined from the preset word list. Taking the t-th word constituting the reply text as an example, the target model determines the target probability distribution according to the first probability distribution and the second probability distribution corresponding to the t-th word, and determines the word with the largest generation probability from the preset word list according to the target probability distribution as the t-th word, wherein the first probability distribution indicates that the t-th word corresponds to the generation probability of each word in the preset word list under the condition of the t-1 words before the t-th word, and the second probability distribution indicates that the t-th word corresponds to the generation probability of each word in the preset word list under the condition of the second correlation representation.
[0087] In an example, the above process of generating the tth word can be constructed as the following formula:
[0088]
[0089] Among them, w t represents the tth word that makes up the reply text, represents the first probability distribution, that is, the generation probability of the t-th word corresponding to each word in the preset vocabulary under the condition of the t-1 words before the t-th word, represents the second probability distribution, that is, under the condition represented by the second correlation, the generation probability of the tth word corresponding to each word in the preset vocabulary, α is an adjustable hyperparameter, and V represents the preset vocabulary.
[0090] According to the first probability distribution Second probability distribution and hyperparameter α determines the target probability distribution Take the word with the highest generation probability in the target probability distribution as the tth word.
[0091] After generating the tth word, the target model continues to generate the t+1th word based on the tth word.
[0092] According to the above process, the target model uses the first probability distribution and the second probability distribution to generate the tth word, that is, not only the tth word is predicted based on the first t-1 words that have been generated, but also the tth word is predicted based on the second correlation representation between the current conversation text and the retrieved relevant p summaries. If the p summaries retrieved are truly relevant to the user's current conversation text, the words in the p summaries in the second probability distribution may have a higher probability, and it will be easier to obtain the words contained in the p summaries. For example, if one of the relevant summaries is "I like singing", it may be easier to obtain the word "singing" in it. On the contrary, if the p summaries retrieved are mixed with summaries that are actually irrelevant to the user's current conversation text, then under the condition of the second correlation representation, the words in the p summaries in the second probability distribution will not have a higher probability.
[0093] Therefore, the present disclosure generates each word constituting the reply text based on the second correlation representation between the user's current conversation text and the retrieved relevant abstracts. Even if the retrieved abstracts are mixed with actually irrelevant abstracts, the retrieved abstracts can be reasonably used to generate accurate robot reply texts. It can be seen that the present disclosure has good autonomous anti-interference capability when generating robot reply texts.
[0094] Step S104: having a conversation with the user according to the conversation text of the robot.
[0095] For example, a voice or text conversation may be conducted with the user based on the conversation text of the robot.
[0096] According to the above technical solution, the present disclosure first memorizes the historical conversations between the user and the robot, compresses and simplifies the original conversation texts between the user and the robot in the historical conversations into multiple effective and brief summaries, and stores them in the conversation memory. When conducting the current conversation, according to the conversation text currently input by the user, the summary related to the conversation text is retrieved from the conversation memory through the first decoding task, and then according to the conversation text and the retrieved summary, the robot's conversation text is generated through the second decoding task, so that the robot can have the ability to remember and use memory, and can be applied to long-term memory conversation scenarios. In addition, the present disclosure uses the same target model for modeling for the first decoding task and the second decoding task, and reduces the number of models through parameter sharing.
[0097] In some embodiments, the human-computer dialogue method further includes: inputting the dialogue text and the context of the dialogue text into the target model, obtaining a summary text output by the target model after performing the third decoding task as a first summary, and storing the first summary in the dialogue memory. Thus, the user's dialogue text is compressed into an effective and brief summary and stored in the dialogue memory.
[0098] Optionally, the present disclosure introduces a memory marker [M]. In the above process, the memory marker [M] can also be input into the target model. The memory marker can be used as a memory proxy to abstractly represent the conversation memory. At this time, the input of the target model includes {[M], u1, b1, ..., u n-1 ,b n-1 ,u n}, the target model determines a third correlation representation based on the above input, and the third correlation representation is used to characterize the correlation between the dialogue text and the memory marker [M], or in other words, the correlation between the dialogue text and the dialogue memory. If there is a correlation between the dialogue text and the dialogue memory, the dialogue text can be compressed into a summary.
[0099] In some embodiments, the target model performing the third decoding task may include:
[0100] The target model determines a third relevance representation based on the dialogue text, the context of the dialogue text and the memory marker, and the third relevance representation is used to characterize the relevance between the dialogue text and the dialogue memory base, and generates the individual words constituting the summary text in sequence according to the third relevance representation.
[0101] In a specific embodiment, for the tth word constituting the summary text, the target model determines the target probability distribution based on the first probability distribution and the second probability distribution corresponding to the tth word, and determines the word with the largest generation probability from the preset vocabulary according to the target probability distribution as the tth word, wherein the first probability distribution indicates that under the condition of the t-1 words before the tth word, the tth word corresponds to the generation probability of each word in the preset vocabulary, and the second probability distribution indicates that under the condition represented by the third correlation, the tth word corresponds to the generation probability of each word in the preset vocabulary.
[0102] It can be understood that the third decoding task needs to generate and output summary text, and the second decoding task needs to generate and output reply text. Both decoding tasks involve text generation. Therefore, the implementation method of generating summary text in the third decoding task can refer to the implementation method of generating reply text in the second decoding task in the previous text.
[0103] When storing the first summary in the conversation memory, the similarity between the first summary and each summary in the conversation memory can be calculated. If the similarity is greater than or equal to a preset threshold, the corresponding summary in the conversation memory is deleted and the first summary is written into the conversation memory. If the similarity is less than the preset threshold, the first summary is directly written into the conversation memory. In this way, the user-related summaries in the conversation memory can be updated. In an example, the user said in a previous conversation that he liked pop music, and then said that he did not like pop music. Based on this embodiment, the summary "I like pop music" can be updated to the summary "I do not like pop music".
[0104] In some embodiments, the human-computer dialogue method further includes: inputting the robot's dialogue text and the context of the dialogue text into the target model, obtaining the summary text output by the target model after performing the third decoding task as the second summary, and storing the second summary in the dialogue memory. Thus, the robot's dialogue text is compressed into an effective and brief summary and stored in the dialogue memory.
[0105] When storing the second summary in the dialogue memory, the similarity between the second summary and each summary in the dialogue memory can be calculated. If the similarity is greater than or equal to a preset threshold, the corresponding summary in the dialogue memory is deleted and the second summary is written into the dialogue memory. If the similarity is less than the preset threshold, the second summary is directly written into the dialogue memory. In this way, the robot-related summaries in the dialogue memory can be updated.
[0106] In some embodiments, the target model includes an encoder and a decoder, wherein the encoder is used to encode the input dialogue text and context, or to encode the input dialogue text, context and summary, and the output of the encoder flows into the decoder, and the decoder performs a corresponding decoding task according to the output of the encoder. In the present disclosure, the decoder is used to perform three different decoding tasks: a first decoding task, a second decoding task and a third decoding task, and the three decoding tasks share the same model parameters. In one example, the target model can adopt a Transformer model.
[0107] In some embodiments, the human-computer dialogue method further includes: before inputting the dialogue text of the user or robot into the target model, inserting a role marker at the starting position of the dialogue text to be input, and the role marker is used to indicate that the dialogue text to be input corresponds to the user role or the robot role. For example, inserting a first role marker at the starting position of the dialogue text to be input, and the first role marker is used to indicate that the dialogue text to be input corresponds to the user role. For another example, inserting a second role marker at the starting position of the dialogue text to be input, and the second role marker is used to indicate that the dialogue text to be input corresponds to the robot role. After completing the above operations, the dialogue text with the inserted role marker is input into the target model. Thus, the text is distinguished as coming from a user or a robot according to the role marker.
[0108] For example, when the context {u1,b1,...,u n-1 ,b n-1} and the dialogue text u n Before inputting into the target model, insert the first role marker at the beginning of u1, insert the second role marker at the beginning of b1, and so on. n-1 Insert the second character marker at the beginning of u n Insert the first role marker at the beginning of the .
[0109] In some embodiments, the human-computer dialogue method further includes: inserting a memory marker at the beginning of the summary to be input before inputting the summary into the target model, thereby distinguishing whether the text belongs to the actual dialogue or the memory according to the memory marker.
[0110] In some embodiments, the human-computer dialogue method also includes: inserting a start marker at the starting input position of the decoder, and the decoder starts decoding based on the start marker; inserting a first task marker or a second task marker at the second input position of the decoder, and the decoder performs a second decoding task based on the first task marker, and performs a third decoding task based on the second task marker.
[0111] Based on this embodiment, the decoder decodes the output result of the encoder based on the input start marker and task marker. For example, the decoder starts decoding based on the input start marker:
[0112] In the case where the task marker is not inserted, performing a first decoding task according to an output result of the encoder, and outputting a first correlation representation;
[0113] In the case of inserting the first task marker, performing a second decoding task according to the output result of the encoder, and outputting a second correlation representation and a reply text;
[0114] When the second task marker is inserted, a third decoding task is performed according to the output result of the encoder, and a third correlation representation and summary text are output.
[0115] It can be understood that this technical solution can be applied to human-computer dialogue scenarios, and specifically to multi-round dialogue scenarios related to long-term memory dialogues. Figure 2 A diagram showing a scenario of a long-term memory conversation between a user and a robot. Figure 2 , the user and the robot have had multiple rounds of dialogue before. According to this technical solution, the long-term memory dialogue between the user and the robot includes the following three processes:
[0116] ①Abstract extraction
[0117] For each dialogue text between the user and the robot in the historical dialogue, the dialogue text and the context of the dialogue text are input into the target model to obtain the user-related summary and the robot-related summary, and store the summary in the dialogue memory. For example, the user-related summary "I like pop music" and the robot-related summary "I can't sing" are obtained.
[0118] ②Abstract search
[0119] The user currently inputs "I feel so bored", and for each summary stored in the dialogue memory, the currently input dialogue text, the context of the dialogue text, and the summary are input into the target model, thereby obtaining a first correlation representation between the dialogue text and each summary, and at least one summary related to the dialogue text is retrieved according to the first correlation representation. For example, the retrieved related summary includes the user-related summary "I like pop music".
[0120] ③ Reply generation
[0121] The currently input dialogue text, the context of the dialogue text and the retrieved related summaries are input into the target model to obtain the robot's dialogue text "You can listen to your favorite pop music and relax." The user is replied according to the robot's dialogue text.
[0122] Furthermore, since the same target model is used in the present disclosure to perform three different decoding tasks, the target model is pre-trained for multi-task joint training. The training phase of the target model is described below, wherein the target model includes an encoder and a decoder.
[0123] In an exemplary embodiment, the target model is trained by the following process:
[0124] First, a training memory bank and a training set are determined, where the training set includes training texts representing multiple rounds of dialogue between a user character and a robot character.
[0125] Secondly, for the third decoding task, the training text of the user role and the context of the training text are input into the target model, and the third relevance representation and summary text output by the target model after performing the third decoding task are obtained. The third loss corresponding to the third decoding task is calculated based on the third relevance representation.
[0126] Secondly, for the first decoding task, a summary is sampled from the training memory library, the training text of the user role, the context of the training text and the sampled summary are input into the target model, and the first correlation representation output by the target model after performing the first decoding task is obtained. The first loss corresponding to the first decoding task is calculated according to the first correlation representation.
[0127] Secondly, for the second decoding task, at least one summary is sampled from the training memory library, the training text of the user role, the context of the training text and at least one sampled summary are input into the target model, the second relevance representation and reply text output by the target model after performing the second decoding task are obtained, and the second loss corresponding to the second decoding task is calculated according to the second relevance representation.
[0128] Finally, the total loss is obtained according to the first loss, the second loss and the third loss, and the target model is trained jointly for multiple tasks according to the total loss.
[0129] The following example and Figure 3-5 , the processes of the above three decoding tasks are explained in detail.
[0130] In one example, Figure 3 FIG. 4 is a schematic diagram showing a target model performing a third decoding task. Figure 3 For the third decoding task, the training text of the user role and the context of the training text are input to the encoder, and the start marker CLS is inserted at the start input position of the decoder and the second task marker CMP is inserted at the second input position, so as to obtain the third correlation representation h output by the decoder after performing the third decoding task. z3 and summary text. Figure 3 , the decoder outputs an end marker EOS at the end of the summary text, indicating the end of the summary text.
[0131] In one example, similar to the inference phase, the memory token [M], the training text u n ' and the context of the training text {u1',b1',...,u n-1 ',b n-1 '} is input to the encoder. At this time, the encoder input includes {[M],u1',b1',……,u n-1 ',b n-1 ',u n'}, the input of the decoder includes the start marker CLS and the second task marker CMP, and also includes the generated word (used to generate the next word).
[0132] In one example, the decoder determines the third correlation representation based on the output result of the encoder and its own input, generates a summary text based on the third correlation representation, and outputs the third correlation representation and the summary text. The process of the decoder generating the summary text based on the third correlation representation can be referred to in the previous text and will not be repeated here.
[0133] In one example, after obtaining a third correlation representation output by the decoder, a third loss corresponding to a third decoding task is calculated based on the third correlation representation.
[0134] In one example, calculating the third loss corresponding to the third decoding task according to the third correlation representation may include: determining a third correlation classification probability according to the third correlation representation; determining the generation probabilities corresponding to each word constituting the summary text, and determining the generation probability corresponding to the summary text according to the generation probabilities corresponding to each word; and determining the third loss according to the third correlation classification probability and the generation probability corresponding to the summary text.
[0135] Among them, the correlation can be regarded as a binary classification task, and the third correlation is represented as a vector. The vector represented by the third correlation is input into the multi-layer perceptron, and the result output by the multi-layer perceptron is processed by softmax to obtain the third correlation classification probability. For example, when the third correlation classification probability is greater than a certain probability threshold, the classification result is considered to be relevant, otherwise, the classification result is considered to be irrelevant.
[0136] Among them, according to the previous description, for the t-th word that constitutes the summary text, the decoder determines the word with the highest generation probability from the preset word list according to the target probability distribution corresponding to the t-th word, as the t-th word, thereby obtaining the generation probability corresponding to the t-th word.
[0137] In one example, the generation probability corresponding to each word constituting the summary text may be continuously multiplied, and the product result may be used as the generation probability corresponding to the summary text.
[0138] In one example, the process of calculating the third loss can be constructed as the following formula:
[0139]
[0140] P(m)=P(z3)P(m′)
[0141]
[0142] In the formula, represents the third loss, P(z3) represents the third relevance classification probability, P(m′) represents the generation probability corresponding to the summary text, P(m) represents the probability obtained according to P(z3) and P(m′), Π represents the continuous product, p(w t ) m It represents the generation probability corresponding to the t-th word that constitutes the summary text, the subscript m represents the summary text, and |m| represents the number of words in the summary text.
[0143] In one example, Figure 4 FIG. 4 is a schematic diagram showing a target model performing a first decoding task. Figure 4 For the first decoding task, a summary is sampled from the training memory, the training text of the user role, the context of the training text and the sampled summary are input to the encoder, and the start marker CLS is inserted at the start input position of the decoder, so as to obtain the first correlation representation h output by the decoder after the first decoding task z1 In one example, a summary may be randomly sampled from the training memory, so the sampled summary may or may not be related to the training text.
[0144] In one example, after obtaining a first correlation representation of a decoder output, a first loss corresponding to a first decoding task is calculated according to the first correlation representation.
[0145] In one example, calculating a first loss corresponding to a first decoding task according to a first correlation representation may include: determining a first correlation classification probability according to the first correlation representation, and determining a first loss according to the first correlation classification probability.
[0146] Among them, the correlation can be regarded as a binary classification task. The first correlation is represented as a vector. The vector represented by the first correlation is input into the multi-layer perceptron, and then the output of the multi-layer perceptron is processed by softmax to obtain the first correlation classification probability.
[0147] In one example, the process of calculating the first loss can be constructed as the following formula:
[0148]
[0149] In the formula, represents the first loss, and P(z1) represents the first correlation classification probability.
[0150] In one example, Figure 5 FIG. 4 is a schematic diagram showing a target model performing a second decoding task. Figure 5For the second decoding task, k summaries are sampled from the training memory library, where k can be a positive integer. The training text of the user role, the context of the training text, and the sampled k summaries are input to the encoder, and the start marker CLS is inserted at the start input position of the decoder, and the first task marker GNR is inserted at the second input position, so as to obtain the second correlation representation h output by the decoder after the second decoding task. z2 and reply text. Figure 5 , the decoder outputs an end marker EOS at the end of the reply text, indicating the end of the reply text.
[0151] Different from the first decoding task, which only needs to sample one digest, the second decoding task can sample multiple digests.
[0152] In some embodiments, due to the reasoning stage of the target model, that is, in the actual human-computer dialogue scenario, the relevant summaries retrieved from the dialogue memory may not all meet the requirements of the current dialogue round, that is, some of the retrieved relevant summaries may not actually be relevant to the dialogue text currently input by the user.
[0153] In order to simulate this actual scenario in the training stage, during the second decoding task, k1 summaries can be randomly sampled from the training memory bank as the retrieved summaries, and k2 noises can be added as the retrieved summaries, resulting in a total of k1+k2 summaries. These k1+k2 summaries are used to simulate multiple related summaries retrieved in actual human-computer dialogue scenarios, and then the training text, the context of the training text and these k1+k2 summaries are input into the encoder to improve the robustness of the target model.
[0154] In one example, the input of the encoder includes the training text, the context of the training text and the k1+k2 summaries, and the input of the decoder includes the start marker CLS and the first task marker GNR, as well as the generated word (used to generate the next word).
[0155] In one example, the decoder determines the second correlation representation based on the output result of the encoder and its own input, generates a reply text based on the second correlation representation, and outputs the second correlation representation and the reply text. The process of the decoder generating the reply text based on the second correlation representation can be referred to above and will not be repeated here.
[0156] In one example, after obtaining a second correlation representation output by the decoder, a second loss corresponding to a second decoding task is calculated based on the second correlation representation.
[0157] In one example, calculating the second loss corresponding to the second decoding task according to the second correlation representation may include: determining a second correlation classification probability according to the second correlation representation; determining the generation probability corresponding to each word constituting the reply text; determining the generation probability corresponding to the reply text according to the generation probability corresponding to each word; and determining the second loss according to the second correlation classification probability and the generation probability corresponding to the reply text.
[0158] Among them, the correlation can be regarded as a binary classification task, the second correlation is represented as a vector, the vector represented by the second correlation is input into the multi-layer perceptron, and then the result output by the multi-layer perceptron is processed by softmax to obtain the second correlation classification probability.
[0159] Among them, according to the previous description, for the tth word that constitutes the reply text, the decoder determines the word with the highest generation probability from the preset word list according to the target probability distribution corresponding to the tth word, as the tth word, thereby obtaining the generation probability corresponding to the tth word.
[0160] In one example, the generation probability corresponding to each word constituting the reply text may be continuously multiplied, and the product result may be used as the generation probability corresponding to the reply text.
[0161] In one example, the above process of calculating the second loss can be constructed as the following formula:
[0162]
[0163] P(b)=P(z2)P(b′)
[0164]
[0165] In the formula, represents the second loss, P(z2) represents the second correlation classification probability, P(b′) represents the generation probability corresponding to the reply text, P(b) represents the probability obtained according to P(z2) and P(b′), Π represents the continuous product, p(w t ) b represents the generation probability of the tth word that constitutes the reply text. The subscript b represents the reply text. t |Indicates the number of words in the reply text.
[0166] Finally, the total loss is obtained according to the first loss, the second loss and the third loss, and the target model is trained jointly for multiple tasks according to the total loss.
[0167] It can be understood that the above three decoding tasks all involve learning correlation representations. By learning correlation representations, the connection between the three decoding tasks is strengthened, which is conducive to better joint training of the target model. It should be noted that the specific implementation methods of the target model in the reasoning stage and the training stage in this disclosure can refer to each other.
[0168] In summary, the technical solution of the embodiment of the present disclosure has the following beneficial effects: by compressing the original conversation text with information into a summary, the storage pressure is greatly reduced and the conversation generation is made more convenient; by using the same model to model three different decoding tasks, and performing multi-task joint training on the model based on correlation representation, the internal connection between different tasks can be strengthened; by guiding the model to decode through correlation representation, the model can automatically distinguish the noise (irrelevant summary) in the retrieved summary, and reasonably use the retrieved summary.
[0169] Figure 6 is a block diagram of a human-machine dialogue device according to an exemplary embodiment. Figure 6 , the human-machine dialogue device 600 includes:
[0170] A correlation determination module 601 is used to obtain the dialogue text currently input by the user, and for each summary stored in the dialogue memory, input the dialogue text, the context of the dialogue text and the summary into the target model to obtain a first correlation representation output by the target model after performing the first decoding task, wherein the first correlation representation is used to characterize the correlation between the dialogue text and the input summary, and the summary stored in the dialogue memory is generated based on the dialogue text in the historical dialogue between the user and the robot;
[0171] A summary determination module 602, configured to determine at least one summary related to the conversation text according to a first correlation representation between the conversation text and each of the summaries;
[0172] A reply generation module 603 is used to input the dialogue text, the context of the dialogue text and the at least one summary into the target model, and obtain a reply text output by the target model after performing the second decoding task as the dialogue text of the robot;
[0173] The human-machine dialogue module 604 is used to conduct a dialogue with the user according to the dialogue text of the robot.
[0174] Optionally, when the target model performs a second decoding task, it is used to determine a second relevance representation based on the conversation text, the context of the conversation text and the at least one summary, wherein the second relevance representation is used to characterize the relevance between the conversation text and the at least one input summary; and to sequentially generate individual words constituting the reply text according to the second relevance representation.
[0175] Optionally, in the process of the target model sequentially generating each word constituting the reply text according to the second correlation representation, for the tth word constituting the reply text, the target probability distribution is determined according to the first probability distribution and the second probability distribution corresponding to the tth word, and the word with the largest generation probability is determined from the preset vocabulary according to the target probability distribution as the tth word, wherein the first probability distribution represents the generation probability of the tth word corresponding to each word in the preset vocabulary under the condition of the t-1 words before the tth word, and the second probability distribution represents the generation probability of the tth word corresponding to each word in the preset vocabulary under the condition of the second correlation representation.
[0176] Optionally, the human-machine dialogue device 600 further includes:
[0177] A summary extraction module, used for inputting the dialogue text and the context of the dialogue text into the target model, and obtaining a summary text output by the target model after performing a third decoding task as a first summary;
[0178] A summary storage module is used to store the first summary in the dialogue memory.
[0179] Optionally, the summary storage module is used to calculate the similarity between the first summary and each summary in the conversation memory; if the similarity is greater than or equal to a preset threshold, the corresponding summary in the conversation memory is deleted and the first summary is written into the conversation memory; if the similarity is less than the preset threshold, the first summary is directly written into the conversation memory.
[0180] Optionally, the human-machine dialogue device 600 further includes an input processing module.
[0181] Optionally, the input processing module is used to insert a role marker at the starting position of the dialogue text to be input before inputting the dialogue text of the user or the robot into the target model, wherein the role marker is used to indicate that the dialogue text to be input corresponds to a user role or a robot role; and to insert a memory marker at the starting position of the summary to be input before inputting the summary into the target model.
[0182] Optionally, the target model includes an encoder and a decoder.
[0183] Optionally, the input processing module is used to insert a start marker at the starting input position of the decoder, and the decoder starts decoding based on the start marker; and is used to insert a first task marker or a second task marker at the second input position of the decoder, and the decoder performs a second decoding task based on the first task marker and performs a third decoding task based on the second task marker.
[0184] Optionally, the target model is trained by the following process:
[0185] Determine a training memory library and a training set, wherein the training set includes training texts representing multiple rounds of dialogue between a user character and a robot character;
[0186] For the third decoding task, the training text of the user role and the context of the training text are input into the target model, a third correlation representation and summary text output by the target model after the third decoding task is performed are obtained, and a third loss corresponding to the third decoding task is calculated according to the third correlation representation;
[0187] For a first decoding task, a summary is sampled from a training memory bank, a training text of the user role, a context of the training text, and the sampled summary are input into the target model, a first correlation representation output by the target model after the first decoding task is performed is obtained, and a first loss corresponding to the first decoding task is calculated according to the first correlation representation;
[0188] For the second decoding task, at least one summary is sampled from the training memory library, the training text of the user role, the context of the training text and the sampled at least one summary are input into the target model, a second correlation representation and a reply text outputted by the target model after the second decoding task is performed are obtained, and a second loss corresponding to the second decoding task is calculated according to the second correlation representation;
[0189] A total loss is obtained according to the first loss, the second loss and the third loss, and multi-task joint training is performed on the target model according to the total loss.
[0190] Optionally, the third loss is calculated as follows:
[0191] determining a third relevance classification probability according to the third relevance representation;
[0192] Determine the generation probability corresponding to each word constituting the summary text, and determine the generation probability corresponding to the summary text according to the generation probability corresponding to each word;
[0193] The third loss is determined according to the third relevance classification probability and the generation probability corresponding to the summary text.
[0194] Optionally, the first loss is calculated as follows:
[0195] determining a first relevance classification probability based on the first relevance representation;
[0196] The first loss is determined according to the first relevance classification probability.
[0197] Optionally, the second loss is calculated as follows:
[0198] determining a second relevance classification probability based on the second relevance representation;
[0199] Determine the generation probability corresponding to each word constituting the reply text, and determine the generation probability corresponding to the reply text according to the generation probability corresponding to each word;
[0200] The second loss is determined according to the second relevance classification probability and the generation probability corresponding to the reply text.
[0201] Regarding the human-machine dialogue device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0202] The present disclosure also provides a computer-readable storage medium on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the human-computer dialogue method provided by the present disclosure are implemented.
[0203] Figure 7 800 is a block diagram of an electronic device 800 according to an exemplary embodiment. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a message transceiver device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc. The electronic device 800 implements a long-term memory dialogue with a user through the human-computer dialogue method provided by the embodiment of the present disclosure. In one example, an intelligent assistant may be implemented in the electronic device 800.
[0204] Reference Figure 7 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output interface 812 , a sensor component 814 , and a communication component 816 .
[0205] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned human-computer dialogue method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0206] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0207] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0208] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera.
[0209] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0210] The input / output interface 812 provides an interface between the processing component 802 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0211] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0212] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, 6G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0213] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned human-computer dialogue method.
[0214] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to complete the above-mentioned human-computer dialogue method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0215] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned human-computer dialogue method when executed by the programmable device.
[0216] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0217] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A human-computer dialogue method, characterized in that: include: Acquire the dialogue text currently input by the user, and for each summary stored in the dialogue memory, input the dialogue text, the context of the dialogue text, and the summary into the target model to obtain a first correlation representation output by the target model after performing a first decoding task, wherein the first correlation representation is used to characterize the correlation between the dialogue text and the input summary, and the summary stored in the dialogue memory is generated based on the dialogue text in the historical dialogue between the user and the robot; Determining at least one abstract related to the conversation text according to a first correlation representation between the conversation text and each of the abstracts; Inputting the dialogue text, the context of the dialogue text and the at least one summary into the target model, and obtaining a reply text output by the target model after performing the second decoding task as the dialogue text of the robot; Conduct a dialogue with the user according to the dialogue text of the robot.
2. The method according to claim 1, characterized in that The target model performs a second decoding task, including: The target model determines a second relevance representation according to the conversation text, the context of the conversation text and the at least one summary, wherein the second relevance representation is used to characterize the relevance between the conversation text and the at least one input summary; The target model sequentially generates the words constituting the reply text according to the second relevance representation.
3. The method according to claim 2, characterized in that The target model sequentially generates the words constituting the reply text according to the second relevance representation, including: For the tth word constituting the reply text, the target model determines a target probability distribution according to a first probability distribution and a second probability distribution corresponding to the tth word, and determines a word with the largest generation probability from a preset word list according to the target probability distribution as the tth word, wherein the first probability distribution indicates the generation probability of the tth word corresponding to each word in the preset word list under the condition of the t-1 words before the tth word, and the second probability distribution indicates the generation probability of the tth word corresponding to each word in the preset word list under the condition represented by the second correlation.
4. The method according to claim 1, characterized in that: The method further comprises: Inputting the dialogue text and the context of the dialogue text into the target model, and obtaining a summary text output by the target model after performing a third decoding task as a first summary; The first summary is stored in the conversation memory.
5. The method according to claim 4, characterized in that The storing the first summary in the conversation memory comprises: Calculating the similarity between the first summary and each summary in the conversation memory; If the similarity is greater than or equal to a preset threshold, the corresponding summary in the conversation memory is deleted, and the first summary is written into the conversation memory; If the similarity is less than the preset threshold, the first summary is directly written into the conversation memory.
6. The method according to claim 1, characterized in that The method further comprises: Before inputting the dialogue text of the user or the robot into the target model, inserting a role marker at the beginning of the dialogue text to be input, wherein the role marker is used to indicate that the dialogue text to be input corresponds to a user role or a robot role; Before inputting the abstract into the target model, a memory marker is inserted at the beginning of the abstract to be input.
7. The method according to claim 4, characterized in that The target model includes an encoder and a decoder, and the method further includes: Inserting a start marker at a start input position of the decoder, and the decoder starts decoding based on the start marker; The first task marker or the second task marker is inserted into the second input position of the decoder, and the decoder performs the second decoding task based on the first task marker and performs the third decoding task based on the second task marker.
8. The method according to claim 4, characterized in that The target model is trained through the following process: Determine a training memory library and a training set, wherein the training set includes training texts representing multiple rounds of dialogue between a user character and a robot character; For the third decoding task, the training text of the user role and the context of the training text are input into the target model, a third correlation representation and summary text output by the target model after the third decoding task is performed are obtained, and a third loss corresponding to the third decoding task is calculated according to the third correlation representation; For a first decoding task, a summary is sampled from a training memory bank, a training text of the user role, a context of the training text, and the sampled summary are input into the target model, a first correlation representation output by the target model after the first decoding task is performed is obtained, and a first loss corresponding to the first decoding task is calculated according to the first correlation representation; For the second decoding task, at least one summary is sampled from the training memory library, the training text of the user role, the context of the training text and the sampled at least one summary are input into the target model, a second correlation representation and a reply text outputted by the target model after the second decoding task is performed are obtained, and a second loss corresponding to the second decoding task is calculated according to the second correlation representation; A total loss is obtained according to the first loss, the second loss and the third loss, and multi-task joint training is performed on the target model according to the total loss.
9. The method according to claim 8, characterized in that The calculating, according to the third correlation representation, a third loss corresponding to the third decoding task comprises: determining a third relevance classification probability according to the third relevance representation; Determine the generation probability corresponding to each word constituting the summary text, and determine the generation probability corresponding to the summary text according to the generation probability corresponding to each word; The third loss is determined according to the third relevance classification probability and the generation probability corresponding to the summary text.
10. The method according to claim 8, characterized in that The calculating a first loss corresponding to the first decoding task according to the first correlation representation includes: determining a first relevance classification probability based on the first relevance representation; The first loss is determined according to the first relevance classification probability.
11. The method according to claim 8, characterized in that The calculating the second loss corresponding to the second decoding task according to the second correlation representation includes: determining a second relevance classification probability based on the second relevance representation; Determine the generation probability corresponding to each word constituting the reply text, and determine the generation probability corresponding to the reply text according to the generation probability corresponding to each word; The second loss is determined according to the second relevance classification probability and the generation probability corresponding to the reply text.
12. A human-computer dialogue device, characterized in that: include: a correlation determination module, configured to obtain a conversation text currently input by a user, and for each summary stored in a conversation memory, input the conversation text, the context of the conversation text, and the summary into a target model, and obtain a first correlation representation output by the target model after performing a first decoding task, wherein the first correlation representation is used to characterize the correlation between the conversation text and the input summary, and the summary stored in the conversation memory is generated based on the conversation text in the historical conversation between the user and the robot; a summary determination module, configured to determine at least one summary related to the conversation text according to a first correlation representation between the conversation text and each of the summaries; a reply generation module, used to input the dialogue text, the context of the dialogue text and the at least one summary into the target model, and obtain a reply text output by the target model after performing the second decoding task as the dialogue text of the robot; The human-machine dialogue module is used to conduct a dialogue with the user according to the dialogue text of the robot.
13. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute instructions stored in the memory to implement the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Multi-round dialogue reply selection method and system based on QA knowledge base reasoning
CN110096567A
Conversation processing method, device, equipment and storage medium
CN110399460A
Method and device for obtaining dialogue abstract and computer readable storage medium
CN111368066A
Man-machine conversation generation method and device, electronic equipment and storage medium
CN114969250A
Transform-based multi-round dialogue generation method
CN115186081A
Cited By
Conversation processing method, device and equipment
CN121597894A
