Human-computer dialogue generation method, device, electronic device and storage medium
By using user conversation data and historical conversation data to extract memory multi-tuples in the human-computer dialogue generation method, and combining it with the pre-trained language model and the dialogue generation model, the problems of high labeling cost and low memory data utilization in the existing technology are solved, and more efficient and flexible response sentence generation is achieved.
Patent Information
- Application Number
- CN202210513919.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-11
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-05-11
AI Technical Summary
The existing human-computer dialogue generation method relies on a large number of annotated data sets, resulting in high annotation costs, low utilization of memory data in historical dialogues, and stiff and inflexible response sentences.
By receiving user conversation data, traversing historical conversation data to find corresponding memory data, extracting memory tuples and generating reply sentences, using pre-trained language models and conversation generation models to adjust reply sentences, and combining the type and relevance of memory data to make the memory content controllable and flexible.
In the case of data scarcity, efficient use of memory data is achieved, the generated response sentences are more relevant to the user, the problem of awkwardness is avoided, and the utilization rate and flexibility of memory data in the dialogue generation process are improved.
Smart Images

Figure CN114969250B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device, and storage medium for generating human-computer dialogue. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the present disclosure that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] In related technologies, during human-machine conversations, robots analyze user input and summarize it to generate responses. Training these robots requires extensive, well-labeled datasets, including but not limited to conversation generation and summary datasets. Consequently, these techniques suffer from high labeling costs and low utilization of historical conversation memory, resulting in rigid and inflexible responses. Summary of the Invention
[0004] In view of this, the purpose of the present disclosure is to provide a method, device, electronic device and storage medium for generating human-computer dialogue.
[0005] Based on the above objectives, in a first aspect, the present disclosure provides a method for generating a human-computer dialogue, comprising:
[0006] Receive user conversation data;
[0007] Traversing pre-acquired historical conversation data according to the user conversation data, and determining whether there is memory data corresponding to the user conversation data in the historical conversation data;
[0008] In response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, performing word segmentation processing on the memory data to extract a memory tuple of the memory data;
[0009] A reply statement is generated according to the memory tuple.
[0010] In a possible implementation, performing word segmentation processing on the memory data to extract memory tuples of the memory data includes:
[0011] Analyze the dependency relationship between words in the memory data to obtain a number of data pairs consisting of two words with the dependency relationship, and merge two data pairs including the same word to obtain the memory tuple.
[0012] In a possible implementation, after receiving the user conversation data, the method further includes:
[0013] extracting a first conversation tuple for representing the user conversation data;
[0014] The first conversation tuple is labeled according to a preset type tag to determine a memory type of the first conversation tuple.
[0015] In a possible implementation, after labeling the first conversation tuple according to a preset type tag to determine the memory type of the first conversation tuple, the method further includes:
[0016] A storage duration of the first conversation tuple is determined according to a memory type of the first conversation tuple.
[0017] In a possible implementation, the memory types include: inherent attribute memory type, long-term memory type, short-term memory type and redundant memory type;
[0018] The determining, according to the memory type of the first conversation tuple, the storage duration of the first conversation tuple includes:
[0019] In response to determining that the memory type of the first conversation tuple is the inherent attribute memory type, determining the storage duration of the first conversation tuple as a first storage duration;
[0020] In response to determining that the memory type of the first conversation tuple is the long-term memory type, determining the storage duration of the first conversation tuple as a second storage duration;
[0021] In response to determining that the memory type of the first dialogue tuple is the short-term memory type, determining the storage duration of the first dialogue tuple to be a third storage duration;
[0022] In response to determining that the memory type of the first conversation tuple is the redundant memory type, determining the storage duration of the first conversation tuple as a fourth storage duration;
[0023] The first storage duration is greater than the second storage duration, the second storage duration is greater than the third storage duration, and the third storage duration is greater than the fourth storage duration.
[0024] In a possible implementation, before traversing the pre-acquired historical conversation data according to the user conversation data and determining whether there is memory data corresponding to the user conversation data in the historical conversation data, the method further includes:
[0025] Obtaining the historical conversation data;
[0026] Extracting a conversation ID based on the historical conversation data;
[0027] The historical conversation data is marked according to the conversation ID to bind the conversation ID and the historical conversation data.
[0028] In one possible implementation, traversing pre-acquired historical conversation data according to the user conversation data to determine whether memory data corresponding to the user conversation data exists in the historical conversation data includes:
[0029] Determining a user ID corresponding to the user conversation data according to the user conversation data;
[0030] determining, based on the user ID, whether the conversation ID corresponding to the user ID exists in the historical conversation data;
[0031] In response to the presence of the conversation ID corresponding to the user ID, acquiring the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID;
[0032] The user conversation data is compared with the candidate memory data to determine the candidate memory data whose relevance to the user conversation data reaches a preset relevance threshold, and the candidate memory data whose relevance to the user conversation data reaches the preset relevance threshold is used as the memory data.
[0033] In a possible implementation, generating a reply statement according to the memory tuple includes:
[0034] splicing the memory tuples according to a general dialogue template to determine candidate response sentences;
[0035] Inputting the candidate reply sentence into a pre-trained language model to determine the perplexity of the candidate reply sentence;
[0036] In response to the perplexity being less than a preset perplexity threshold, a reply statement is determined based on the candidate reply statements.
[0037] In a possible implementation, in response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes:
[0038] In response to the perplexity being less than a preset perplexity threshold, determining background information based on the memory data;
[0039] The candidate reply sentences are adjusted according to the context information to determine the reply sentence.
[0040] In a possible implementation, in response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes:
[0041] extracting a second conversation tuple of the historical conversation data;
[0042] Associating the second conversation tuple with the historical conversation data, and using the second conversation tuple and the historical conversation data as training set data;
[0043] Using the training set data to train a dialogue generation model;
[0044] The candidate reply sentences are adjusted using the dialogue generation model to determine the reply sentence.
[0045] In a possible implementation, the user conversation data includes: a first round of conversation;
[0046] After obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID in response to the conversation ID corresponding to the user ID, the method further includes:
[0047] Determining whether text exists in the first round of conversation;
[0048] In response to the absence of the text in the first round of dialogue, a reply sentence is generated according to any one of the candidate memory data.
[0049] In a possible implementation, the user conversation data includes: multiple rounds of conversations;
[0050] In response to the presence of the conversation ID corresponding to the user ID, the method further includes: obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID;
[0051] Determining whether there is text in the multiple rounds of conversations that does not exist in at least two adjacent rounds of conversations;
[0052] In response to the absence of text in at least two adjacent rounds of conversation, a reply sentence is generated based on any one of the candidate memory data.
[0053] In a second aspect, the present disclosure provides a human-computer dialogue generation device, comprising:
[0054] A receiving module configured to receive user conversation data;
[0055] A determination module is configured to traverse pre-acquired historical conversation data according to the user conversation data, and determine whether there is memory data corresponding to the user conversation data in the historical conversation data;
[0056] an extraction module configured to, in response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, perform word segmentation processing on the memory data and extract a memory tuple of the memory data;
[0057] A generation module is configured to generate a reply statement according to the memory tuple.
[0058] In a third aspect, the present disclosure provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the human-computer dialogue generation method as described in the first aspect is implemented.
[0059] In a fourth aspect, the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the human-computer dialogue generation method as described in the first aspect.
[0060] As can be seen from the above, the present disclosure provides a method, device, electronic device, and storage medium for generating human-computer dialogues. Based on received user dialogue data, the method searches for memory data corresponding to the user dialogue data from pre-acquired historical dialogue data of the user. When memory data corresponding to the user dialogue data exists, the method further extracts a memory tuple of the memory data, and then generates a reply statement related to the user's memory data based on the memory tuple. In the case of data scarcity, the memory capability required in the implementation scenario is achieved through a small amount of customization cost, and takes effect in real time during the dialogue process, thereby improving the utilization rate of the memory data in the historical dialogue data in the dialogue generation process, achieving the controllability and flexible scalability of the memory content, making the generated reply statement more relevant to the user, and avoiding the problem of the reply statement being too stiff. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0062] Figure 1 A schematic diagram illustrating an exemplary flow chart of a method for generating a human-computer dialogue provided by an embodiment of the present disclosure is shown;
[0063] Figure 2 A schematic diagram showing an exemplary flow chart of a method for generating a conversation combining online and offline according to an embodiment of the present disclosure is shown;
[0064] Figure 3A schematic diagram showing an exemplary structure of a human-computer dialogue generation device provided by an embodiment of the present disclosure is shown;
[0065] Figure 4 A schematic diagram of an exemplary structure of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0066] To make the objectives, technical solutions, and advantages of the present disclosure more clearly understood, the principles and spirit of the present disclosure will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided solely to enable those skilled in the art to better understand and implement the present disclosure, and are not intended to limit the scope of the present disclosure in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0067] According to an embodiment of the present disclosure, a method, device, electronic device and storage medium for generating human-computer dialogue are proposed.
[0068] It should be understood herein that any number of elements in the drawings is for illustration only and not for limitation, and any naming is only for distinction and does not have any limiting meaning.
[0069] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should have the usual meanings understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative position relationships. When the absolute position of the described object changes, the relative position relationship may also change accordingly.
[0070] The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure.
[0071] As mentioned in the background technology section, there has been some research on conversation memory in recent years. However, there is no mature technical solution in the industry. This is partly because there is currently no clear and unified definition standard for conversation memory, and partly because finding suitable application scenarios is also a major challenge.
[0072] Among some related technologies, existing open-domain chat robots, such as Microsoft XiaoIce, do not involve the ability to extract and use long-term memory in their public technologies; Baidu's PLATO-2 and Google's Meena also do not explicitly model and use conversational memory.
[0073] In other related technologies, historical conversation content is continuously summarized during the conversation process, and then these summaries and recent conversation history are used to generate replies. The conversation summary uses a conversation summary model trained on large-scale, manually annotated corpus. Conversation reply generation is also based on a large-scale pre-trained model trained on a large amount of collected conversation data. The summary results and conversation history are combined as the conversation context to generate replies.
[0074] Through research, the applicant found that in related technologies, during human-computer dialogue, the robot analyzes the dialogue content input by the user and summarizes the dialogue content input by the user in this dialogue to generate reply sentences. In the process of training the robot, it is necessary to rely on a large number of labeled data sets, including but not limited to dialogue generation data sets and dialogue summary data sets. In actual application, we usually need to quickly verify the impact of memory content on dialogue effect. If we rely on large-scale labeled data sets, and different scenarios may require different data sets, and need to label data in multiple fields, it will seriously affect the progress of product application. The content of memory is uncontrollable, because the memory time of different memories may be different, and we may need to abandon memories that are too old. In addition, there may be contradictions between previous and subsequent memories. Existing methods do not solve these problems.
[0075] For this reason, the present disclosure provides a method, device, electronic device, and storage medium for generating human-computer dialogues. Based on received user dialogue data, the method searches for memory data corresponding to the user dialogue data from pre-acquired historical dialogue data of the user. When memory data corresponding to the user dialogue data exists, the method further extracts memory tuples of the memory data, and then generates response statements related to the user's memory data based on the memory tuples. In the case of data scarcity, the memory capabilities required in the implementation scenario are achieved at a small customization cost, and the response takes effect in real time during the dialogue process. This improves the utilization rate of the memory data in the historical dialogue data during the dialogue generation process, realizes the controllability and flexible scalability of the memory content, and makes the generated response statements more relevant to the user, avoiding the problem of overly rigid response statements.
[0076] The human-computer dialogue generation method provided by the embodiment of the present disclosure is described in detail below through specific embodiments.
[0077] Figure 1A schematic diagram illustrating an exemplary flow chart of a method for generating a human-computer dialogue provided by an embodiment of the present disclosure is shown.
[0078] refer to Figure 1 The human-computer dialogue generation method provided by the embodiment of the present disclosure specifically includes the following steps:
[0079] S102: Receive user conversation data.
[0080] In a possible implementation, after receiving the user conversation data, the method further includes:
[0081] extracting a first conversation tuple for representing the user conversation data;
[0082] The first conversation tuple is labeled according to a preset type tag to determine a memory type of the first conversation tuple.
[0083] In a possible implementation, after labeling the first conversation tuple according to a preset type tag to determine the memory type of the first conversation tuple, the method further includes:
[0084] A storage duration of the first conversation tuple is determined according to a memory type of the first conversation tuple.
[0085] In a possible implementation, the memory types include: inherent attribute memory type, long-term memory type, short-term memory type and redundant memory type;
[0086] The determining, according to the memory type of the first conversation tuple, the storage duration of the first conversation tuple includes:
[0087] In response to determining that the memory type of the first conversation tuple is the inherent attribute memory type, determining the storage duration of the first conversation tuple as a first storage duration;
[0088] In response to determining that the memory type of the first conversation tuple is the long-term memory type, determining the storage duration of the first conversation tuple as a second storage duration;
[0089] In response to determining that the memory type of the first dialogue tuple is the short-term memory type, determining the storage duration of the first dialogue tuple to be a third storage duration;
[0090] In response to determining that the memory type of the first conversation tuple is the redundant memory type, determining the storage duration of the first conversation tuple as a fourth storage duration;
[0091] The first storage duration is greater than the second storage duration, the second storage duration is greater than the third storage duration, and the third storage duration is greater than the fourth storage duration.
[0092] S104: Traversing pre-acquired historical conversation data according to the user conversation data to determine whether there is memory data corresponding to the user conversation data in the historical conversation data.
[0093] In a possible implementation, before traversing the pre-acquired historical conversation data according to the user conversation data and determining whether there is memory data corresponding to the user conversation data in the historical conversation data, the method further includes:
[0094] Obtaining the historical conversation data;
[0095] Extracting a conversation ID based on the historical conversation data;
[0096] The historical conversation data is marked according to the conversation ID to bind the conversation ID and the historical conversation data.
[0097] In one possible implementation, traversing pre-acquired historical conversation data according to the user conversation data to determine whether memory data corresponding to the user conversation data exists in the historical conversation data includes:
[0098] Determining a user ID corresponding to the user conversation data according to the user conversation data;
[0099] determining, based on the user ID, whether the conversation ID corresponding to the user ID exists in the historical conversation data;
[0100] In response to the presence of the conversation ID corresponding to the user ID, acquiring the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID;
[0101] The user conversation data is compared with the candidate memory data to determine the candidate memory data whose relevance to the user conversation data reaches a preset relevance threshold, and the candidate memory data whose relevance to the user conversation data reaches the preset relevance threshold is used as the memory data.
[0102] S106: In response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, performing word segmentation processing on the memory data to extract a memory tuple of the memory data.
[0103] In a possible implementation, performing word segmentation processing on the memory data to extract memory tuples of the memory data includes:
[0104] Analyze the dependency relationship between words in the memory data to obtain a number of data pairs consisting of two words with the dependency relationship, and merge two data pairs including the same word to obtain the memory tuple.
[0105] S108: Generate a reply statement according to the memory tuple.
[0106] In a possible implementation, generating a reply statement according to the memory tuple includes:
[0107] splicing the memory tuples according to a general dialogue template to determine candidate response sentences;
[0108] Inputting the candidate reply sentence into a pre-trained language model to determine the perplexity of the candidate reply sentence;
[0109] In response to the perplexity being less than a preset perplexity threshold, a reply statement is determined based on the candidate reply statements.
[0110] In a possible implementation, in response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes:
[0111] In response to the perplexity being less than a preset perplexity threshold, determining background information based on the memory data;
[0112] The candidate reply sentences are adjusted according to the context information to determine the reply sentence.
[0113] In a possible implementation, in response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes:
[0114] extracting a second conversation tuple of the historical conversation data;
[0115] Associating the second conversation tuple with the historical conversation data, and using the second conversation tuple and the historical conversation data as training set data;
[0116] Using the training set data to train a dialogue generation model;
[0117] The candidate reply sentences are adjusted using the dialogue generation model to determine the reply sentence.
[0118] In a possible implementation, the user conversation data includes: a first round of conversation;
[0119] After obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID in response to the conversation ID corresponding to the user ID, the method further includes:
[0120] Determining whether text exists in the first round of conversation;
[0121] In response to the absence of the text in the first round of dialogue, a reply sentence is generated according to any one of the candidate memory data.
[0122] In a possible implementation, the user conversation data includes: multiple rounds of conversations;
[0123] In response to the presence of the conversation ID corresponding to the user ID, the method further includes: obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID;
[0124] Determining whether there is text in the multiple rounds of conversations that does not exist in at least two adjacent rounds of conversations;
[0125] In response to the absence of text in at least two adjacent rounds of conversation, a reply sentence is generated based on any one of the candidate memory data.
[0126] In some embodiments, in a human-machine dialogue scenario, a user and a robot communicate with each other. The robot can respond based on the dialogue data input by the user. After receiving the user dialogue data, the user dialogue data can be represented as a tuple to facilitate quick understanding of the main content of the user dialogue data. Specifically, a tuple can include a triple, such as a subject, a predicate, and an object. For example, if the user dialogue data is "I really like to eat scrambled eggs with tomatoes," the tuple extracted to represent the user dialogue data may be "I like to eat scrambled eggs with tomatoes," thereby quickly determining the main content of the user dialogue data.
[0127] Furthermore, each time a segment of user conversation data is received, the robot can store it. This storage can be done by extracting a tuple from the segment and then storing the tuple as a representation of the segment. The stored conversation data serves as the robot's memory, making the robot more human-like and the human-machine conversation scene more natural.
[0128] Each memory segment is assigned a corresponding memory type, making it clearer and faster to store or retrieve for generating responses. Different memories are categorized into different types. Memory types refer to different types of tuples, or subject-predicate relationships. Memory types can be manually defined in advance. For example, based on high-frequency subject-predicate relationships extracted from a conversation database in this field, the memory segment is manually labeled with terms such as name, age, friends, and food preferences. For example, in a conversation scenario between a game player and an in-game NPC, tuples of user conversation data are extracted over multiple rounds of dialogue. These tuples are then labeled for high-frequency subject-predicate relationships. This annotation process primarily involves merging synonymous relationships, removing overly general relationships (such as "yes"), and customizing the storage lifecycle of some tuples. This reduces the negative impact of uncertainty on user-entered conversation data during online use.
[0129] In some embodiments, after receiving a segment of user conversation data, its memory type can be determined, and different life cycles can be set for different types of memories. Memories that have exceeded the life cycle can be cleared, thereby reducing the pressure on system storage. Specifically, memory types can include: inherent attribute memory type, long-term memory type, short-term memory type, and redundant memory type. After determining the memory type of the first conversation tuple used to represent the user conversation data, the specific category of the memory type is further determined. When the memory type of the first conversation tuple is determined to be an inherent attribute memory type, the storage duration of the first conversation tuple can be determined as the first storage duration. For example, inherent attributes can include the user's name, nickname, age, hobbies, etc.
[0130] Furthermore, when the memory type of the first dialogue tuple is determined to be a long-term memory type, the storage duration of the first dialogue tuple can be determined as a second storage duration. Long-term memory types can include memories that are unlikely to change over a long period of time, such as marital status or a partner. When the memory type of the first dialogue tuple is determined to be a short-term memory type, the storage duration of the first dialogue tuple can be determined as a third storage duration. Short-term memory types can include memories that are unlikely to change over a short period of time, such as what I had for lunch yesterday or the glass of water I just drank. When the memory type of the first dialogue tuple is determined to be a redundant memory type, the storage duration of the first dialogue tuple can be determined as a fourth storage duration. Redundant memory types can include modal particles such as "oh," "okay," and "alright."
[0131] Since the memory content of the inherent attribute memory type hardly changes, the first storage duration can be defined as the longest, such as permanent memory or memory within ten years; the memory content of the long-term memory type will be maintained for a period of time, but may change, so the second storage duration can be shorter than the first storage duration, such as memory within a week; the memory content of the short-term memory type will only be maintained for a few days or will change within a day, so the third storage duration can be shorter than the second storage duration, such as memory within three days; and the memory content of the redundant memory type usually does not need to be memorized, or needs to be memorized within a round of conversation. For example, when the robot asks a question that requires confirmation, the user gives an affirmative response, such as "yes", then in this round of conversation it may reply according to the tone determined by the user, so the fourth storage duration can be shorter than the third storage duration, such as memory for the duration of a round of conversation.
[0132] Figure 2 The figure shows an exemplary flow chart of a method for generating a conversation combining online and offline according to an embodiment of the present disclosure.
[0133] refer to Figure 2 , the storage of memory data and the extraction of memory data for generating dialogues can be performed in offline mode. For the memory content that needs to be stored, it can be stored in a database (such as MongoDB) to prevent data loss. Since in the human-computer dialogue scenario, there may be complex scenarios where one user dialogues with multiple robots, or multiple users dialogue with one robot, or multiple users dialogue with multiple robots, the robot ID and the user ID are needed to distinguish the memory content, so that when the dialogue needs to be limited to the "robot-user" dialogue scenario, the memory content of other users and robots will not interfere with their dialogue scenario. By distinguishing different memory contents by robot ID and user ID, the memory data of different users and different robots can be isolated, and the dialogue generation between the current user and the robot can be avoided because of the memory data of other users or robots.
[0134] In some embodiments, historical conversation data between the user and the robot can be obtained. If the user has never had a conversation with the current robot, historical conversation data between the user and other robots can be obtained. A conversation ID is extracted from the historical conversation data. The conversation ID may include the user ID and / or robot ID corresponding to the historical conversation data. The historical conversation data is then bound to the conversation ID to determine the correspondence between the conversation ID and the historical conversation data.
[0135] To prevent the unlimited expansion of memory content, in addition to defining different storage durations, you can also set a storage limit for memory content, such as setting a maximum of 100 memory contents. In addition, if there is a conflict in memory content, the original memory content can be directly overwritten, and the latest memory content will prevail. Of course, you can also actively ask the user which memory content is correct, and then retain the confirmed memory content after receiving the user's affirmative response.
[0136] For step S104, after receiving the user conversation data, the historical conversation data can be traversed according to the user conversation data to find out whether there is memory data corresponding to the user conversation data, that is, whether the memory data corresponding to the current user conversation data can be found in the stored memory content.
[0137] In some embodiments, after receiving user conversation data, the user ID corresponding to the user conversation data can be determined based on the user conversation data, and whether a conversation ID corresponding to the user ID exists in the historical conversation data based on the user ID, for example, whether a conversation ID containing the user ID exists. Once it is determined that a conversation ID corresponding to the user ID exists, the historical conversation data bound to the conversation ID can be obtained, thereby determining the historical conversation data as candidate memory data corresponding to the user ID. Since multiple candidate memory data corresponding to the current user ID may be found, the candidate memory data needs to be further screened. The user conversation data and the candidate memory data can be compared, and the correlation between the two can be determined using a correlation model. Then, candidate memory data whose correlation with the user conversation data reaches a preset correlation threshold is determined, and the candidate memory data is used as the memory data for generating subsequent reply statements.
[0138] For step S106, when there is memory data corresponding to the user conversation data, the memory tuple of the memory data can be extracted. Since the conversation data and its corresponding tuple are associated with each other for the convenience of storage and quick understanding of the conversation content, and the conversation data is represented by the tuple, the memory tuple of the memory data can be extracted for the generation of subsequent reply statements.
[0139] Regarding step S108 , after the memory tuple of the memory data is extracted, a reply sentence related to the user conversation data may be further generated according to the memory tuple.
[0140] In some embodiments, the open source syntactic analysis tool HanLP can be used to extract memory tuples. Since HanLP extracts the dependency relationships between words, such as preposition-object relationship, verb-object relationship, attributive-predicate relationship, etc., and does not directly give tuples, the two pairs of relationships with the same "predicate" in the "subject-predicate relationship" and the same "verb" in the "verb-object relationship" are merged to obtain a complete set of tuples. For example, the subject is "Cao Cao" and the predicate is "attack", which constitutes a subject-predicate relationship. The predicate is "attack" and the object is "Jingzhou", which constitutes a verb-object relationship. Then, the two pairs of relationships with the same verb are merged to obtain a complete set of subject-predicate-object tuples, that is, "Cao Cao, attack, Jingzhou". In order to ensure that the reply sentence formed by the memory tuple is more reasonable, the memory tuples can be spliced according to the general dialogue template to determine multiple candidate reply sentences. Among them, the general template refers to a template that combines the extracted tuples into a sentence. For example, the tuple is (s, p, o), that is, (subject, predicate, object). The template can be: <s> <o>, or <o>quilt <s>< / s> < / o> < / o> <s>, for example, the candidate reply sentence obtained is "Cao Cao attacks Jingzhou".
[0141] Furthermore, the candidate reply sentence can be input into a pre-trained language model to determine the perplexity of the candidate reply sentence, wherein the language model can be used on the corpus in this field, such as dialogue data of game scenes, game copy data, game-related novel data, etc., and the GPT language model is pre-trained on these corpora. After the candidate reply sentence is input into the GPT language model, the perplexity (PPL) of the candidate reply sentence can be determined. The lower the perplexity score, the more reasonable the candidate reply sentence is. A perplexity threshold can be set. When the perplexity of the candidate reply sentence is less than the preset perplexity threshold, it proves that the candidate reply sentence is reasonable. The reply sentence can be determined based on the candidate reply sentence, thereby ensuring the rationality of the reply sentence.
[0142] It should be noted that a trained GPT language model can be used directly to generate this text. For example, if s = "Cao Cao attacks Jingzhou", the GPT language model is specified to generate this text. Each character position will have a generation probability p(wi), and the generation probability of this text is the cumulative product of the character probabilities p(s) = p(w1)...p(wn), PPL(s) = p(s)-1 / n.
[0143] Furthermore, when acquiring memory data, the perplexity of the memory data can be determined in the above manner to thereby determine more reasonable memory data.
[0144] In some embodiments, after obtaining reasonable candidate reply statements that can be used to determine the reply statement, the background information can be determined based on the memory data, such as the user background, the robot background, and the relationship between the user and the robot, and then the candidate reply statements can be adjusted based on the background information to determine the output reply statement.
[0145] Taking a specific implementation as an example, in a real-time game scenario, for example, a user says, "Remember, your nickname is Xiaohua." The memory type is "nickname," and the extracted tuple is (Peanut, nickname, Xiaohua). This memory content is described from the NPC's first-person perspective, so the pronoun "you" should be replaced with the NPC's real name, such as "Peanut." The extracted tuples are concatenated into candidate replies. After determining that their perplexity meets the required level, the active conversation content is obtained. The candidate replies are then adjusted based on the user's background, the NPC's background, and the relationship between the user and the NPC, resulting in a reply such as "Dad, my nickname is Xiaohua." The context refers to information such as the speaker's name, gender, and personality (not limited to these fields) and is used to describe the context of the conversation. In this case, the user and the NPC are involved. For example, the user's background might be "Zhanjian Tianya is a game player," and the NPC's background might be "Peanut is a 10-year-old girl." If a chat involves multiple people, the backgrounds of all three individuals can be listed.
[0146] Specifically, a language model with keyword control can be trained on a large-scale novel corpus. Since novel corpora typically consist of narration and dialogue, when constructing the training corpus, keywords (such as verbs and nouns) are extracted from the dialogue content (using the Jieba tool). Randomly select 0 to 5 keywords, shuffle them, and place them at the beginning of the dialogue. These keywords are then distinguished by identifiers. Training can then be performed using the normal GPT language model training method. For example, the original novel text might read: "A young man jumps to avoid a sudden attack from the evil Tongtian behind him while saying, 'I want to marry the Minister of War's daughter instead.'" The keywords extracted from the speech are "marry, Minister of War, daughter." The newly constructed training text then becomes: "A young man jumps to avoid a sudden attack from the evil Tongtian behind him while saying [marry, Minister of War, daughter]: 'I want to marry the Minister of War's daughter instead.'" After training the GPT language model, similar prefixes can be constructed for the currently extracted multi-tuples. For example, Zhanjian Tianya is a game player, Huashengmi is a 10-year-old girl, Huashengmi is Zhanjian Tianya's daughter, and Zhanjian Tianya is Huashengmi's father. Huashengmi said to her father [Huashengmi, nickname, Xiaohua]: ". The generated sentence in this case might be "Daddy, my nickname is Xiaohua."
[0147] In some embodiments, a method for determining a reply statement based on candidate reply statements can also be to extract a second dialogue tuple from historical dialogue data, associate the second dialogue tuple with the historical dialogue data, and then determine the training set data, and then use the training set data to train a dialogue generation model, and then use the dialogue generation model to splice the extracted memory tuple to determine the reply statement.
[0148] Specifically, a language model with keyword control, also known as a dialogue generation model, can be trained on the Chinese Wikipedia corpus. Keywords (such as verbs and nouns) are extracted from each sample sentence. These keywords are then placed before the sentence according to certain rules. A GPT language model is then trained to serve as the dialogue generation model. For example, the original sentence is: "Chinese Wikipedia positions itself as an encyclopedia encompassing all areas of human knowledge, rather than a dictionary, thesaurus, forum, or any other type of website." The extracted keywords are "Wikipedia, knowledge domain, encyclopedia, dictionary..." The resulting training sample is: [Wikipedia, knowledge domain, encyclopedia, dictionary] Chinese Wikipedia positions itself as an encyclopedia encompassing all areas of human knowledge, rather than a dictionary, thesaurus, forum, or any other type of website. After training the dialogue generation model, a prefix is constructed for the extracted memory tuple: [Peanut, nickname, Xiaohua] The model then generates: "Peanut's nickname is Xiaohua." Multiple responses can be generated simultaneously to guide users, increasing the diversity of the information provided.
[0149] It's important to note that keywords are placed at the beginning of a sentence according to a specific rule. Specifically, this concatenation rule can be [<keyword 1>, <keyword 2>, <keyword 3>, ...] <original sentence>. Following this rule, a large number of training samples can be generated, which are then divided into training, validation, and test sets. Specifically, the keyword shuffling rule can be: Multiple keywords may be extracted from the <original sentence>, but it's not necessary to place all of them at the beginning. One to five keywords are randomly selected in the [] field. If fewer than five keywords are extracted, the number of keywords is capped at the number of keywords extracted. If no keywords are present, the [] field is left empty. The order of the keywords is then shuffled and placed in the [] field to form the sample. The purpose of this shuffling is to help the model learn that the order of keywords does not affect the coherence of the generated sentences. Keywords can be identified by analyzing the original sentence's word segmentation and part of speech. Words marked as nouns and verbs are considered keywords, as these words represent specific meanings and are more valuable as references.
[0150] In some embodiments, when a user indicates they don't want to chat, the topic is actively switched, where the topic can be stored memory data. There may be multiple historical memories, so expired memories are filtered through the lifecycle, and then a random memory content is discarded. Alternatively, discarding a memory based on a specific strategy, such as discarding two consecutive memories of different types. Determining whether a user doesn't want to chat can be determined in the following ways.
[0151] Specifically, the user conversation data may include the first round of conversation, and determine whether there is text in the first round of conversation in the user's current conversation scenario, that is, whether a text containing Chinese is sent. If there is no text in the first round of conversation, it is determined that the user does not want to chat at the moment, and a reply statement can be generated based on any candidate memory data to switch the current user topic.
[0152] In some embodiments, user conversation data may also include multiple rounds of conversations, and determine whether there is text in the multiple rounds of conversations that does not exist in at least two adjacent rounds of conversations. When there is text that does not exist in at least two adjacent rounds of conversations, for example, during the user conversation process, numbers and / or irrelevant English symbols are sent in two consecutive rounds of conversations, a reply statement can be generated based on any candidate memory data to switch the current user topic.
[0153] It should be noted that by obtaining historical conversation data, it is possible to determine whether the user conversation data shows an intention not to chat, annotate the user conversation data input by the user, and then train a binary classification model. The binary classification model can be used to judge the user conversation data input by the current user to determine whether the user has an intention not to chat.
[0154] In some embodiments, during a conversation, relevant content can be retrieved from a pre-built topic library to generate a reply statement that can guide the user's topic. The content in the topic library includes multiple candidate reply statements generated based on different candidate memory data. Specific retrieval strategies can use methods such as es retrieval and vector retrieval. For example, when a user talks about apple-related topics, the relevant memory content "Huashengmi remembers that my father said before that he likes to eat apples" can be retrieved to assist in the generation of reply statements.
[0155] In some embodiments, based on the dialogue history, user dialogue data, and the results of topic guidance, in the process of generating reply sentences, a GPT-2 model trained on a large-scale Chinese corpus (mostly novel corpus) can be used to utilize the model's few-shot capability to generate reply sentences. All input information is spliced into a natural language text as a prefix to guide the GPT-2 model to generate a reply, such as the prefix: Dad said to Peanut: "I bought a few apples today." Peanut remembers that Dad had said before that he liked to eat apples. The GPT-2 model continues to generate replies, such as: "Dad, if you like apples, buy more."
[0156] In a specific conversation scenario, the user is the robot's father and the NPC is a 10-year-old boy. The conversation is as follows:
[0157] User: Hello.
[0158] At this time, if the corresponding memory data cannot be found based on the user conversation data, a reply statement can be generated based on the background information.
[0159] NPC: Hello, Daddy.
[0160] User: I like to eat braised pork.
[0161] At this time, the memory tuple corresponding to the memory data in the historical conversation data matched according to the user conversation data is [Dad, like to eat, braised pork], and the storage duration of the memory tuple is the first storage duration. For example, if it is set to permanent storage, a reply statement can be further generated based on the memory tuple.
[0162] NPC: The braised pork is fat and lean, and tastes great.
[0163] User: What do I like to eat?
[0164] At this point, the user conversation data entered by the user in this round of conversation has been stored in the historical conversation data and updated to the online mode through hot update, so a reply statement can be generated based on the memory data stored in this round of conversation.
[0165] NPC: If you like braised pork, eat more.
[0166] User: 123.
[0167] At this time, the user conversation data input by the user does not contain any text with substantial meaning, so the memory data stored in this round of conversation can be used to generate a reply statement to guide the topic or switch the topic, thereby guiding the current conversation back to a normal conversation.
[0168] bot: Dad, I remember you said you like to eat braised pork.
[0169] As can be seen from the above, the present disclosure provides a method, apparatus, electronic device, and storage medium for generating human-computer dialogues. Based on received user dialogue data, the method searches for memory data corresponding to the user dialogue data from previously acquired historical dialogue data. When memory data corresponding to the user dialogue data exists, the method further extracts a memory tuple of the memory data, and then generates a response statement related to the user's memory data based on the memory tuple. First, a set of data format specifications for dialogue memory content is defined to facilitate the management and storage of dialogue data. In the case of data scarcity, the memory capability required in practical scenarios can be achieved with minimal customization cost. Second, the storage of memory data and the generation of active response statements using memory data can be placed in an offline process without blocking the operation of the online dialogue process. Upon receiving new user dialogue data, the stored historical dialogue data is hot-updated, ensuring that all previously entered stored memory data can be promptly applied in subsequent dialogue processes. Finally, the method takes effect in real time during the dialogue process, improving the utilization rate of memory data in the historical dialogue data during the dialogue generation process, achieving controllability and flexible scalability of memory content, making the generated response statement more relevant to the user, and avoiding the problem of overly rigid response statements. By determining the perplexity level, the system screens reasonable candidate responses, reducing manual intervention costs. For each memorized item, it automatically expands the active conversation content and topic guidance, increasing text diversity and providing rich material for subsequent topic switching and guidance. It can also proactively bring up memorized topics to increase user engagement, thereby increasing the number of conversation turns and strengthening user engagement with the product. When relevant content in memory is mentioned, it can guide previously remembered content, resulting in responses consistent with previous conversations, adding a sense of surprise to the user, boosting their enthusiasm for conversation, and enhancing the user experience.
[0170] It should be noted that the method of the embodiments of the present disclosure can be performed by a single device, such as a computer or server. The method of the embodiments of the present disclosure can also be applied in a distributed scenario, where multiple devices cooperate to perform the method. In such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiments of the present disclosure, and the multiple devices will interact with each other to complete the method.
[0171] It should be noted that the above description is limited to some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in an order different from that described in the above embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0172] Figure 3 A schematic diagram of an exemplary structure of a human-computer dialogue generation device provided in an embodiment of the present application is shown.
[0173] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a human-computer dialogue generation device.
[0174] refer to Figure 3 The human-computer dialogue generation device includes: a receiving module, a determining module, an extracting module and a generating module; wherein,
[0175] A receiving module configured to receive user conversation data;
[0176] A determination module is configured to traverse pre-acquired historical conversation data according to the user conversation data, and determine whether there is memory data corresponding to the user conversation data in the historical conversation data;
[0177] an extraction module configured to, in response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, perform word segmentation processing on the memory data and extract a memory tuple of the memory data;
[0178] A generation module is configured to generate a reply statement according to the memory tuple.
[0179] In a possible implementation, the extraction module is specifically configured to:
[0180] Analyze the dependency relationship between words in the memory data to obtain a number of data pairs consisting of two words with the dependency relationship, and merge two data pairs including the same word to obtain the memory tuple.
[0181] In a possible implementation, the human-computer dialogue generating device is further configured to:
[0182] extracting a first conversation tuple for representing the user conversation data;
[0183] The first conversation tuple is labeled according to a preset type tag to determine a memory type of the first conversation tuple.
[0184] In a possible implementation, the human-computer dialogue generating device is further configured to:
[0185] A storage duration of the first conversation tuple is determined according to a memory type of the first conversation tuple.
[0186] In a possible implementation, the memory types include: inherent attribute memory type, long-term memory type, short-term memory type and redundant memory type;
[0187] The human-computer dialogue generating device is further configured to:
[0188] In response to determining that the memory type of the first conversation tuple is the inherent attribute memory type, determining the storage duration of the first conversation tuple as a first storage duration;
[0189] In response to determining that the memory type of the first conversation tuple is the long-term memory type, determining the storage duration of the first conversation tuple as a second storage duration;
[0190] In response to determining that the memory type of the first dialogue tuple is the short-term memory type, determining the storage duration of the first dialogue tuple to be a third storage duration;
[0191] In response to determining that the memory type of the first conversation tuple is the redundant memory type, determining the storage duration of the first conversation tuple as a fourth storage duration;
[0192] The first storage duration is greater than the second storage duration, the second storage duration is greater than the third storage duration, and the third storage duration is greater than the fourth storage duration.
[0193] In a possible implementation, the human-computer dialogue generating device is further configured to:
[0194] Obtaining the historical conversation data;
[0195] Extracting a conversation ID based on the historical conversation data;
[0196] The historical conversation data is marked according to the conversation ID to bind the conversation ID and the historical conversation data.
[0197] In a possible implementation, the determining module is specifically configured to:
[0198] Determining a user ID corresponding to the user conversation data according to the user conversation data;
[0199] determining, based on the user ID, whether the conversation ID corresponding to the user ID exists in the historical conversation data;
[0200] In response to the presence of the conversation ID corresponding to the user ID, acquiring the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID;
[0201] The user conversation data is compared with the candidate memory data to determine the candidate memory data whose relevance to the user conversation data reaches a preset relevance threshold, and the candidate memory data whose relevance to the user conversation data reaches the preset relevance threshold is used as the memory data.
[0202] In a possible implementation, the generating module is specifically configured to:
[0203] splicing the memory tuples according to a general dialogue template to determine candidate response sentences;
[0204] Inputting the candidate reply sentence into a pre-trained language model to determine the perplexity of the candidate reply sentence;
[0205] In response to the perplexity being less than a preset perplexity threshold, a reply statement is determined based on the candidate reply statements.
[0206] In a possible implementation, the generating module is specifically configured to:
[0207] In response to the perplexity being less than a preset perplexity threshold, determining background information based on the memory data;
[0208] The candidate reply sentences are adjusted according to the context information to determine the reply sentence.
[0209] In a possible implementation, the generating module is specifically configured to:
[0210] extracting a second conversation tuple of the historical conversation data;
[0211] Associating the second conversation tuple with the historical conversation data, and using the second conversation tuple and the historical conversation data as training set data;
[0212] Using the training set data to train a dialogue generation model;
[0213] The candidate reply sentences are adjusted using the dialogue generation model to determine the reply sentence.
[0214] In a possible implementation, the user conversation data includes: a first round of conversation;
[0215] The generation module is further configured to:
[0216] Determining whether text exists in the first round of conversation;
[0217] In response to the absence of the text in the first round of dialogue, a reply sentence is generated according to any one of the candidate memory data.
[0218] In a possible implementation, the user conversation data includes: multiple rounds of conversations;
[0219] The generation module is further configured to:
[0220] Determining whether there is text in the multiple rounds of conversations that does not exist in at least two adjacent rounds of conversations;
[0221] In response to the absence of text in at least two adjacent rounds of conversation, a reply sentence is generated based on any one of the candidate memory data.
[0222] For the convenience of description, the above devices are described as being functionally divided into various modules. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0223] The device of the above embodiment is used to implement the corresponding human-computer dialogue generation method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0224] Figure 4 A schematic diagram of an exemplary structure of an electronic device provided in an embodiment of the present application is shown.
[0225] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the human-computer dialogue generation method described in any of the above embodiments is implemented.
[0226] Figure 4 10 is a schematic diagram showing a more specific hardware structure of an electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other within the device via the bus 1050.
[0227] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0228] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0229] The input / output interface 1030 is used to connect an input / output module to implement information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.
[0230] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).
[0231] The bus 1050 comprises a path for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0232] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.
[0233] The electronic device of the above embodiment is used to implement the corresponding human-computer dialogue generation method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0234] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the human-computer dialogue generation method described in any of the above embodiments.
[0235] The above-mentioned non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid-state drives (SSDs)), etc.
[0236] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the human-computer dialogue generation method described in any embodiment in the above exemplary method part, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0237] Those skilled in the art will appreciate that embodiments of the present disclosure may be implemented as a system, method, or computer program product. Therefore, the present disclosure may be implemented in the following forms: entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or in a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the present disclosure may be implemented in the form of a computer program product embodied in one or more computer-readable media containing computer-readable program code.
[0238] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive examples) of computer-readable storage media can include, for example: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0239] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0240] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0241] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0242] It should be understood that each block in the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine. These computer program instructions are executed by the computer or other programmable data processing device to produce a device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0243] These computer program instructions can also be stored in a computer-readable medium that enables a computer or other programmable data processing device to operate in a specific manner. In this way, the instructions stored in the computer-readable medium produce a product that includes an instruction device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0244] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions executed on the computer or other programmable apparatus provide a process that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0245] Furthermore, although the operations of the disclosed method are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in that particular order, or that all of the operations shown must be performed to achieve the desired results. Rather, the steps depicted in the flowcharts may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into a single step, and / or a single step may be broken down into multiple steps.
[0246] The use of the verbs "comprise", "include" and their conjugations in the application documents does not exclude the presence of elements or steps other than those stated in the application documents. The article "a" or "an" preceding an element does not exclude the presence of a plurality of such elements.
[0247] Although the spirit and principles of the present disclosure have been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the specific embodiments disclosed, and the division into various aspects does not mean that the features of these aspects cannot be combined to benefit. Such division is merely for the convenience of expression. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.< / s> < / s>
Claims
1. A method for generating human-computer dialogue, characterized in that: include: Receive user conversation data; Acquire historical conversation data, extract a conversation ID based on the historical conversation data, mark the historical conversation data based on the conversation ID to bind the conversation ID and the historical conversation data, determine a user ID corresponding to the user conversation data based on the user conversation data, determine whether the conversation ID corresponding to the user ID exists in the historical conversation data based on the user ID, and in response to the presence of the conversation ID corresponding to the user ID, acquire the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID, compare the user conversation data with the candidate memory data to determine candidate memory data whose relevance to the user conversation data reaches a preset relevance threshold, and use the candidate memory data whose relevance to the user conversation data reaches the preset relevance threshold as the memory data; In response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, performing word segmentation processing on the memory data to extract a memory tuple of the memory data; A reply statement is generated according to the memory tuple.
2. The method according to claim 1, characterized in that The performing word segmentation processing on the memory data to extract the memory tuple of the memory data includes: Analyze the dependency relationship between words in the memory data to obtain a number of data pairs consisting of two words with the dependency relationship, and merge two data pairs including the same word to obtain the memory tuple.
3. The method according to claim 1, characterized in that After receiving the user conversation data, the method further includes: extracting a first conversation tuple for representing the user conversation data; The first conversation tuple is labeled according to a preset type tag to determine a memory type of the first conversation tuple.
4. The method according to claim 3, characterized in that After labeling the first conversation tuple according to the preset type tag to determine the memory type of the first conversation tuple, the method further includes: A storage duration of the first conversation tuple is determined according to a memory type of the first conversation tuple.
5. The method according to claim 4, characterized in that The memory types include: inherent attribute memory type, long-term memory type, short-term memory type and redundant memory type; The determining, according to the memory type of the first conversation tuple, the storage duration of the first conversation tuple includes: In response to determining that the memory type of the first conversation tuple is the inherent attribute memory type, determining the storage duration of the first conversation tuple as a first storage duration; In response to determining that the memory type of the first conversation tuple is the long-term memory type, determining the storage duration of the first conversation tuple as a second storage duration; In response to determining that the memory type of the first dialogue tuple is the short-term memory type, determining the storage duration of the first dialogue tuple to be a third storage duration; In response to determining that the memory type of the first conversation tuple is the redundant memory type, determining the storage duration of the first conversation tuple as a fourth storage duration; The first storage duration is greater than the second storage duration, the second storage duration is greater than the third storage duration, and the third storage duration is greater than the fourth storage duration.
6. The method according to claim 1, characterized in that Generating a reply statement according to the memory tuple includes: splicing the memory tuples according to a general dialogue template to determine candidate response sentences; Inputting the candidate reply sentence into a pre-trained language model to determine the perplexity of the candidate reply sentence; In response to the perplexity being less than a preset perplexity threshold, a reply statement is determined based on the candidate reply statements.
7. The method according to claim 6, characterized in that In response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes: In response to the perplexity being less than a preset perplexity threshold, determining background information based on the memory data; The candidate reply sentences are adjusted according to the context information to determine the reply sentence.
8. The method according to claim 6, characterized in that In response to the perplexity being less than a preset perplexity threshold, determining a reply statement based on the candidate reply statements includes: extracting a second conversation tuple of the historical conversation data; Associating the second conversation tuple with the historical conversation data, and using the second conversation tuple and the historical conversation data as training set data; Using the training set data to train a dialogue generation model; The candidate reply sentences are adjusted using the dialogue generation model to determine the reply sentence.
9. The method according to claim 1, characterized in that The user conversation data includes: the first round of conversation; After obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID in response to the conversation ID corresponding to the user ID, the method further includes: Determining whether text exists in the first round of conversation; In response to the absence of the text in the first round of dialogue, a reply sentence is generated according to any one of the candidate memory data.
10. The method according to claim 1, characterized in that The user conversation data includes: multiple rounds of conversations; In response to the presence of the conversation ID corresponding to the user ID, the method further includes: obtaining the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID; Determining whether there is text in the multiple rounds of conversations that does not exist in at least two adjacent rounds of conversations; In response to the absence of text in at least two adjacent rounds of conversation, a reply sentence is generated based on any one of the candidate memory data.
11. A human-computer dialogue generation device, characterized in that: include: A receiving module configured to receive user conversation data; a determination module configured to obtain historical conversation data, extract a conversation ID based on the historical conversation data, mark the historical conversation data based on the conversation ID to bind the conversation ID and the historical conversation data, determine a user ID corresponding to the user conversation data based on the user conversation data, determine based on the user ID whether the conversation ID corresponding to the user ID exists in the historical conversation data, and in response to the presence of the conversation ID corresponding to the user ID, obtain the historical conversation data bound to the conversation ID to determine candidate memory data corresponding to the user ID, compare the user conversation data with the candidate memory data to determine candidate memory data whose relevance to the user conversation data reaches a preset relevance threshold, and use the candidate memory data whose relevance to the user conversation data reaches the preset relevance threshold as the memory data; an extraction module configured to, in response to the presence of the memory data corresponding to the user conversation data in the historical conversation data, perform word segmentation processing on the memory data and extract a memory tuple of the memory data; A generation module is configured to generate a reply statement according to the memory tuple.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 10 is implemented.
13. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable a computer to implement the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Graph-based context association reply generation method, computer and medium
CN109918494A
Multi-round dialogue processing method, device and equipment
CN110032633A
Dialogue statement determination method and device, computer equipment and medium
CN111414462A
Conversation generation method and device, electronic equipment and storage medium
CN112559714A
Keyword extraction method and device, electronic equipment and computer storage medium
CN113392305A