Role-playing dialogue data generation method and system, and computer program product
By constructing a character generation and optimization model, a rich variety of role-playing dialogue data is generated, solving the problems of high cost and low diversity in obtaining training samples, and improving the training effect and interaction quality of the role-playing model.
Patent Information
- Application Number
- PCT/CN2024/131603
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-23
- Filing Date
- 2024-11-12
- Publication Date
- 2025-11-27
AI Technical Summary
In existing technologies, the cost of obtaining training samples for role-playing models is high and the diversity is low, which affects the training effect and the interaction effect.
By constructing a character generation model, multiple character description datasets are generated using multiple character dialogue data, a character library is constructed, and the description datasets are optimized through a character optimization model to generate rich and diverse role-playing dialogue data.
It improves the efficiency and diversity of training sample acquisition, and enhances the realism and fun of role-playing model interaction with users.
Smart Images

Figure CN2024131603_27112025_PF_FP_ABST
Abstract
Description
A role-playing dialogue data generation method, system and computer program product
[0001] Cross-reference to Related Applications
[0002] The present disclosure claims priority to the Chinese patent application No. 202410651922.2, entitled "A role-playing dialogue data generation method, system and computer program product", filed on May 23, 2024 with the China Patent Office, the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0003] Embodiments of the present disclosure relate to the field of natural language processing, and particularly to a role-playing dialogue data generation method, system and computer program product. BACKGROUND
[0004] A role-playing model can imitate a certain character setting (or simply referred to as a person setting) to output language expressions conforming to the characteristics of the gender, personality, character, occupation, etc. of the person setting. Using a role-playing model to play a specific role or character for interaction has become a popular research direction. Training a role-playing model usually requires a large amount of data. When the cost of obtaining sample data is high and the diversity of sample data is low, the training effect of the role-playing model is often poor, which in turn affects the effect of role-playing.
[0005] To this end, some embodiments of the present disclosure aim to provide a role-playing dialogue data generation method, device and related computer program product to improve the efficiency of obtaining training samples and increase the diversity of training samples.
[0006] SUMMARY
[0007] The purpose of the present disclosure includes providing a role-playing dialogue data generation method, device and related computer program product to improve the efficiency of obtaining training samples and increase the diversity of training samples.
[0008] Embodiments of the present disclosure provide a role-playing dialogue data generation method, which comprises: inputting multiple pieces of person setting dialogue data into a person setting generation model to obtain multiple person setting description data sets output by the person setting generation model, respectively, wherein the person setting generation model is obtained by training an initial language model based on person setting sample features and person setting sample dialogue data; each piece of the multiple pieces of person setting dialogue data comprises one or more rounds of dialogue data between different person settings; each person setting description data set in the multiple person setting description data sets comprises person setting description data of one person setting participating in the dialogue; constructing a person setting library based on the multiple person setting description data sets; selecting different person settings from the person setting library, generating dialogue data between the different person settings based on the person setting description data sets corresponding to the different person settings, respectively, and further obtaining the role-playing dialogue data.
[0009] Optionally, the persona generation model is obtained by: obtaining persona sample features and persona sample dialogue data; inputting the persona sample dialogue data into an initial language model to obtain an initial language model output persona description data set; calculating a loss value of the initial language model output persona description data set and the persona sample features by using EMD, and iteratively updating model parameters of the initial language model based on the loss value to obtain the persona generation model.
[0010] Optionally, the persona sample dialogue data includes dialogue data between more than three personas.
[0011] Optionally, the method further includes: inputting the persona dialogue data and the persona generation model output persona description data set into a persona optimization model to obtain an output of the persona optimization model; the persona optimization model is obtained by training an initial persona optimization model by using preset standard sample features and preset standard sample dialogue data; based on the output, an optimized persona description data set corresponding to the persona generation model output persona description data set is determined; and the constructing a persona library based on the multiple persona description data sets includes: recording the optimized persona description data set into the persona library.
[0012] Optionally, the multiple segments of persona dialogue data include one or more rounds of dialogue data between the target persona and multiple other personas; the multiple persona description data sets output by the persona generation model include multiple persona description data sets corresponding to the target persona; and the method further includes: merging the multiple persona description data sets corresponding to the target persona to obtain a persona description data set of the target persona.
[0013] Optionally, the generating dialogue data between different personas based on persona description data sets respectively corresponding to the different personas includes: selecting a first persona and a second persona from the persona library; inputting a first sentence of the first persona and the persona description data sets of the first persona and the second persona into a second language model corresponding to the second persona to obtain a first reply sentence of the second persona output by the second language model; inputting the first reply sentence of the second persona, the first sentence of the first persona, and the persona description data sets of the first persona and the second persona into a first language model corresponding to the first persona to obtain a second sentence of the first persona output by the first language model; inputting the second sentence of the first persona, the first reply sentence of the second persona, the first sentence of the first persona, and the persona description data sets of the first persona and the second persona into the second language model to obtain a second reply sentence of the second persona; and alternately outputting sentences by using the first language model and the second language model to obtain dialogue data between the first persona and the second persona.
[0014] Optionally, the role-playing dialogue data is used to train an initial role-playing model to obtain the role-playing model.
[0015] Optionally, the method further comprises: calculating the similarity between different personas in the persona library based on the persona description data sets of the personas, and classifying the personas in the persona library based on the similarity to obtain one or more persona categories; and the selecting of different personas from the persona library and the generation of dialogue data between the different personas based on the persona description data sets corresponding to the different personas respectively comprises: selecting different personas from the same persona category, and generating dialogue data between the different personas based on the persona description data sets corresponding to the different personas respectively, thereby obtaining first specific role-playing dialogue data; and selecting different personas from different persona categories, and generating dialogue data between the different personas based on the persona description data sets corresponding to the different personas respectively, thereby obtaining second specific role-playing dialogue data; and at least one of the first specific role-playing dialogue data and the second specific role-playing dialogue data is used to train the initial role-playing model to obtain the role-playing model.
[0016] Optionally, the calculating of the similarity between different personas in the persona library based on the persona description data sets of the personas comprises: determining the vector representation corresponding to the persona description data set of each persona in the persona library; calculating the similarity parameter between the vector representations corresponding to the persona description data sets of each persona, and determining the similarity between different personas according to the similarity parameter. The present disclosure also provides a role-playing dialogue data generation system, which comprises: a persona output module configured to input multiple segments of persona dialogue data into a persona generation model to obtain multiple persona description data sets output by the persona generation model respectively, wherein the persona generation model is obtained by training an initial language model based on persona sample features and persona sample dialogue data; each segment of the multiple segments of persona dialogue data comprises one or more rounds of dialogue data between different personas; each of the multiple persona description data sets comprises persona description data of one of the personas participating in the dialogue; a persona library construction module configured to construct a persona library based on the multiple persona description data sets; and a dialogue data generation module configured to select different personas from the persona library, generate dialogue data between the different personas based on the persona description data sets corresponding to the different personas respectively, and thereby obtain the role-playing dialogue data.
[0017] The embodiment of the present disclosure further provides a role-playing dialogue data generation apparatus, comprising a storage medium and a processor, the storage medium has computer instructions stored thereon, and the processor is used to execute at least part of the computer instructions to realize the role-playing dialogue data generation method provided by one or more embodiments of the present disclosure.
[0018] The embodiment of the present disclosure further provides a computer readable storage medium, which stores computer instructions, and the computer instructions can realize the role-playing dialogue data generation method provided by one or more embodiments of the present disclosure when executed by a processor.
[0019] The embodiment of the present disclosure further provides a computer program product, which comprises computer instructions or a computer program, and the computer instructions or the computer program can realize the role-playing dialogue data generation method provided by one or more embodiments of the present disclosure when executed by a processor. BRIEF DESCRIPTION OF DRAWINGS
[0020] The embodiment of the present disclosure will be further described in the manner of exemplary embodiments, which will be described in detail through the accompanying drawings. The same reference numerals in the drawings represent the same structure or step.
[0021] FIG. 1 is a flowchart of a role-playing dialogue data generation method according to an embodiment of the present disclosure.
[0022] FIG. 2 is a flowchart of a method for training a character generation model according to an embodiment of the present disclosure.
[0023] FIG. 3 is a flowchart of a method for optimizing a character description data set according to an embodiment of the present disclosure.
[0024] FIG. 4 is a flowchart of a method for generating character dialogue data according to an embodiment of the present disclosure.
[0025] FIG. 5 is an exemplary block diagram of a role-playing dialogue data generation system according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the embodiments will be described in detail below with reference to the accompanying drawings. Obviously, the following description is some examples or embodiments of the present disclosure, and for those skilled in the art, the technical solutions or means disclosed by the present disclosure can be applied to other scenarios without creative labor.
[0027] It should be understood that the terms “system,” “apparatus,” “unit,” and / or “module” used in the embodiments of the present disclosure are a method for distinguishing different components, elements, parts, sections, or assemblies of different levels. However, if other words can achieve the same purpose, the words can be replaced by other expressions.
[0028] Unless specifically stated otherwise, technical terms described in the embodiments of the present disclosure are not limited to a single implementation. Rather, these technical terms should be understood to encompass all technical equivalents that operate similarly to accomplish a similar purpose. Unless otherwise noted, the terms “including”, “containing”, “comprising” and the like are used in the sense of “including” and / or “comprising”, and not by way of “consisting only of” or “consisting of.” Thus, these terms should be interpreted as specifying the presence of stated steps, elements, and / or components but not precluding the presence of additional steps, elements, and / or components.
[0029] Flowcharts in the embodiments of the present disclosure are used to illustrate the operation steps performed by the apparatus or system of the related embodiments, but the order used to describe these steps should not be understood as a limitation on the execution order of the steps without specific description. A person of ordinary skill in the art can adjust the execution order of these steps according to the knowledge information conveyed by the embodiments of the present disclosure, which includes but is not limited to the reversal of the sequence, the merger of multiple steps, and the splitting of a step.
[0030] The role-playing model can imitate a certain character and output language expressions consistent with the gender, personality, character, occupation, and other characteristics of the character. The character can be a real person, a virtual character or a personified object, such as a character or personified object in a film, television drama, or game, or a character of a practitioner in a certain industry, or a character created by the user.
[0031] As an example, the role-playing model can imitate Sun Wukong to output language expressions consistent with the characteristics of the character. As another example, the role-playing model can imitate a tour guide to interact with tourists in language and provide tour guide-related services to tourists. As another example, the role-playing model can imitate a user's personalized two-dimensional character to entertain the user through language interaction. In actual application scenarios, the role-playing model can be used to play a specific role or character to interact with a user (a natural person) or another role or character (such as another role-playing model).
[0032] For example, the role-playing model can be used in intelligent customer service, navigation service, game entertainment, service hall robots, hotel room robots, and other specific scenarios. While providing consultation, guidance, and other services to users, the role-playing model can also increase the interest of the interaction process or make the model or robot conversation more realistic and natural.
[0033] Currently, in order to make the role-playing model approach the simulated character as much as possible, a large amount of training samples need to be used for training. Specifically, a large amount of dialogue data of the corresponding character is needed to train the role-playing model. In some training scenarios, the dialogue data used for training can be obtained manually, specifically, the dialogue data of the character can be written or collected by professional personnel based on the characteristics of the character, such as personality, occupation, and the like. This way has high labor cost and low efficiency. In some other training scenarios, some existing dialogue data, such as open source dialogue database, film and television scripts, and the like, can be used to semi-automatically generate dialogue data of the relevant character by means of data cleaning, extraction, and the like. Although this way can improve the efficiency of obtaining training data to some extent, the diversity of the dialogue data is low, and it is difficult to fully and vividly reflect the characteristics of the character.
[0034] Therefore, the embodiments of the present disclosure provide a role-playing dialogue data generation method, device and related computer program product, aiming to improve the efficiency of sample acquisition and enrich the diversity of samples.
[0035] The embodiments of the present disclosure can obtain diverse characters by training an initial language, and construct a character library by using the diverse characters, and further select different characters in the character library for dialogue, so that rich and diverse character dialogue data with fine granularity can be obtained efficiently. The training samples of the role-playing model are further enriched, and the effect of the role-playing model interacting with the user is improved.
[0036] FIG. 1 is a flowchart of a role-playing dialogue data generation method provided by the embodiments of the present disclosure. The flowchart shown in FIG. 1 can be executed by a processing device, for example, can be implemented by a role-playing dialogue data generation system deployed on the processing device. As shown in FIG. 1, the role-playing dialogue data generation method specifically includes the following steps.
[0037] Step 101: input a plurality of pieces of character dialogue data into a character generation model to obtain a plurality of character description data sets output by the character generation model, respectively. In some embodiments, step 101 can be implemented by a character output module 501.
[0038] In some embodiments, a piece of character dialogue data can include one or more rounds of dialogue data of dialogue participants (or different characters), wherein one round of character dialogue data can include statements output by at least two parties of the opposite participants on a topic or a subtopic thereof.
[0039] As an example, a round of role-play dialogue data can include a sentence initiated by one of the dialogue participants, and a sentence responded by another of the dialogue participants. As an example, a piece of dialogue data can be A: “Wukong, how far is the next village?” B: “Master, you rest here, I will go and investigate.” In some embodiments, a round of dialogue data can also be a dialogue among more than two roles. For example, the dialogue data can be a group chat among more than 3 roles, specifically, 4, 5, 6 or even more roles. At this time, a round of dialogue data can be the sentences output by two or more of the more than three dialogue participants on a topic or a sub-topic thereof.
[0040] As an example, a piece of dialogue data can be: A: “Wukong, how far is the next village?” B: “Master, you rest here, I will go and investigate.” C: “Elder brother, you go, we will take care of the master.” When the number of dialogue participants is more than three, the characteristics of the dialogue participants can be more efficiently and multi-dimensionally reflected, which helps to obtain more fine-grained role description information. In some embodiments, the dialogue data can be text data. In other embodiments, the dialogue data can also be in other forms such as audio data, and further, the audio form of dialogue data can be subjected to speech recognition to obtain corresponding text data. The dialogue data can also include the role identifier of each role, such as “A”, “B” in the above example, for marking the sentences of each role in the dialogue data.
[0041] Optionally, the multiple pieces of role-play dialogue data are multiple pieces of the aforementioned role-play dialogue data, which can be understood as each piece of role-play dialogue data in the multiple pieces of role-play dialogue data including one or more rounds of dialogue data between different roles. In some embodiments, the multiple pieces of role-play dialogue data can be obtained from open source scripts, movie subtitles, web information, encyclopedia entries, etc.
[0042] In some embodiments, the multiple pieces (e.g., three pieces) of role-play dialogue data can be input into a role generation model, and the role generation model can sequentially process each piece of role-play dialogue data to obtain a corresponding role description data set, i.e., multiple role description data sets of multiple roles can be obtained. The role description data set includes the role description data of a role participating in the dialogue, which can specifically include the name, personality, social relationship, hobby, background, etc. of the role. As an example, the role description data set of the role Wukong can include “Wukong, lively and active, righteous and loyal, protecting the Tang monk to get the scriptures from the Western Heaven, fighting demons and monsters along the way, because of his high skills, he is somewhat arrogant and unwilling to be bound by traditional rules and systems.” In some embodiments, a role corresponds to a role description data set.
[0043] As an example, the first piece of dialogue data in the three pieces of persona dialogue data input to the persona generation model involves a conversation between two personas; the second piece of dialogue data involves a conversation between three personas; and the third piece of dialogue data involves a conversation between five personas. The persona generation model can generate a persona description data set for each of the personas involved in each piece of dialogue data in turn, i.e., the persona generation model can output two, three, and five persona description data sets corresponding to the two, three, and five pieces of persona dialogue data, respectively; or, the persona generation model can output a persona description data set only for a specified persona in each piece of persona dialogue data, e.g., for the three pieces of persona dialogue data described above, the persona generation model can output a persona description data set for a certain conversation participant in each piece of persona dialogue data.
[0044] In some embodiments, a mark can be added to the role identifier of a persona in the persona dialogue data to specify the persona. The persona generation model can be trained based on an initial language model. For details of the specific training process of the persona generation model, refer to FIG. 2.
[0045] In some embodiments of the present disclosure, the multiple pieces of persona dialogue data can include one or more rounds of dialogue data between the same target persona and multiple other personas. The multiple persona description data sets output by the persona generation model include multiple persona description data sets corresponding to the target persona.
[0046] For example, the target persona is a tour guide, the other personas are multiple tourists following the tour guide to visit a scenic spot, and the multiple pieces of persona dialogue data are dialogue data between the tour guide and the multiple tourists. Specifically, the first piece of persona dialogue data can be dialogue data between tour guide A and tourist B, and the second piece of persona dialogue data can be group chat dialogue data between tour guide A and tourists C and D.
[0047] Further, the multiple pieces of persona dialogue data formed by the tour guide and the tourists are input to the persona generation model, and the persona generation model can process the multiple pieces of persona dialogue data in turn to output multiple persona description data sets of tour guide A. That is, the persona generation model generates a persona description data set for tour guide A based on each of the multiple pieces of persona dialogue data in turn. Further, the multiple persona description data sets of the same target persona can be merged or combined to obtain a complete persona description data set of the target persona. As an example, the aforementioned merging or combining can be to find the union of two or more persona description data sets of the same target persona, so that the persona description data set describes the target persona more stereoscopically, the persona description is more in line with the persona prototype, and the granularity of the persona description is more precise.
[0048] In step 102, a persona library is constructed based on the multiple persona description data sets.
[0049] In some embodiments, step 102 can be implemented by the persona library construction module 502.
[0050] In the embodiments of the present disclosure, the plurality of persona description data sets obtained in step 101 can be further combined to form a persona library, and the persona library includes a plurality of persona description data sets, including but not limited to: same category persona description data sets, different category persona description data sets. In some embodiments, the personas in the persona library can be one-to-one corresponding to the persona description data sets.
[0051] In some embodiments, the similarity between different personas in the persona library can be calculated based on the persona description data sets of the personas, and the personas in the persona library can be classified based on the similarity, to obtain one or more persona categories.
[0052] Specifically, the persona description data sets corresponding to each persona in the persona library can be processed into vector representations, and the similarity parameters between the vector representations of the persona description data sets of each persona, such as cosine similarity, Euclidean distance, Pearson correlation coefficient, etc., can be calculated, to determine the similarity between different personas in the persona library. In other embodiments, the vector representations corresponding to each persona description data set can be clustered to obtain one or more persona categories.
[0053] In the embodiments of the present disclosure, the persona description data sets output by the persona generation model can also be optimized, and the persona library can be constructed based on the optimized persona description data sets. Specifically, the optimized persona description data sets can be recorded in the persona library, and further, the original persona description data sets can be replaced by the optimized persona description data sets. Thus, the persona description data sets in the constructed persona library are more accurate and more consistent with the persona image. The optimization steps of the persona description data sets can be referred to the related description of FIG. 3.
[0054] Step 103: selecting different personas from the persona library, generating conversation data between the different personas based on the persona description data sets corresponding to the different personas respectively, and further obtaining role-playing conversation data.
[0055] In some embodiments, the conversation data between different personas can be the conversation data between two personas, or the conversation data between more personas. Specifically, two or more language models can be used to generate conversation sentences based on the persona description data sets of the selected personas, and thus the conversation data between different personas can be obtained. The related description of obtaining the conversation data between different personas can be further referred to the related description of FIG. 4.
[0056] Optionally, the role-playing dialogue data corresponding to various personas can be used as sample data for training the initial role-playing model. As an example, a part of the sentence of the persona played by the role-playing model in the dialogue data can be masked, the masked dialogue data can be input into the initial role-playing model, the sentence of the persona played by the initial role-playing model can be obtained, the model parameters can be adjusted to reduce the difference between the sentence output by the initial role-playing model and the masked sentence in the dialogue data, and the role-playing model can be obtained after the initial role-playing model is trained.
[0057] In the embodiments of the present disclosure, the dialogue data of step 103 can be directly used as role-playing dialogue data. In some other embodiments, the dialogue data can also be optimized by de-duplication, cleaning, correction, etc., and used as training data of the role-playing model.
[0058] FIG. 2 is a flowchart of a method for determining a persona generation model according to an embodiment of the present disclosure, which specifically includes the following steps.
[0059] In step 201, persona sample features and persona sample dialogue data are obtained.
[0060] In some embodiments, the persona sample features and the persona sample dialogue data can be obtained from an open source data set. The persona sample features are preset feature labels of the persona to be generated, which can specifically include specific descriptions of personality, hobbies, etc.
[0061] It can be understood that the persona sample features and the persona sample dialogue data constitute a training sample data set of the persona generation model. For example, the persona sample features in the training sample data set are the feature descriptions of a famous TV character named Sun Wukong, and the persona sample dialogue data are multiple dialogue lines of Sun Wukong with other characters in a TV series. For another example, the persona sample features in the training sample data set are the feature descriptions of a historical figure named Qu Yuan, and the corresponding persona sample dialogue data are the dialogues between Qu Yuan and others recorded in ancient poems and documents.
[0062] In some embodiments of the present disclosure, the persona sample dialogue data can be dialogue data between two personas, or can include dialogue data between more than three personas. In this way, the initial language model can learn more stereoscopic and hierarchical persona description data during the training process.
[0063] In step 202, the persona sample dialogue data is input into an initial language model to obtain a persona description data set output by the initial language model.
[0064] Optionally, the initial language model can be an open source large language model, including but not limited to: Mistral, OpenAI GPT, BERT, etc. The human setting sample dialogue data in step 201 can be input into the initial language model to obtain the human setting description data set output by the initial language model.
[0065] In step 203, the loss value of the human setting description data set output by the initial language model and the human setting sample feature is calculated by using EMD, and the model parameters of the initial language model are iteratively updated based on the loss value to obtain a human setting generation model.
[0066] Optionally, the model parameters of the initial language model are adjusted based on the human setting description data set output by the initial language model. After adjusting the initial language model each time, it can be regarded as one iteration training of the initial language model.
[0067] In some embodiments, the loss value between the human setting description data set obtained by processing the human setting sample dialogue data by the initial language model after each training and the human setting sample feature in step 201 can be calculated by using EMD (Earth Move’s Distance). By adjusting the model parameters, the EMD loss function value between the human setting description data set output by the model and the human setting sample feature is reduced, so that the initial language model generates a human setting description data set similar to the human setting sample feature by learning the distribution of the human setting sample feature.
[0068] Specifically, EMD is used to measure the difference between the human setting sample feature and the human setting description data set output by the initial language model, and the similarity between the two is calculated by calculating the minimum cost required for the initial language model to convert the human setting description data set into the human setting sample feature. EMD considers the semantic relationship between the vocabulary of the human setting sample feature and the human setting description data set, and can more accurately measure the similarity between two texts. By calculating the minimum cost required to convert the vocabulary distribution of the human setting description data set into the vocabulary distribution of the human setting sample feature, a more accurate similarity measure can be obtained.
[0069] On the one hand, the EMD loss function can provide accurate gradient information to help the initial language model better learn the distribution information and improve the generation ability of the human setting generation model. On the other hand, using EMD to optimize the human setting generation model training process makes the model can generate the target with less data, saves the amount of training data, and improves the model performance as much as possible under the condition of the same training data to generate diverse human settings.
[0070] In some embodiments, when the loss value of the personae description data set output by the initial language model and the personae sample features in step 201 is less than a preset threshold, or the number of iterations of the initial language model reaches a preset number, it is determined that the model training is completed, and a trained personae generation model is obtained. Alternatively, the trained personae generation model can be tested, and when its performance meets a preset requirement, the model training can be terminated. The condition for terminating the model iteration training can be flexibly set according to actual needs, and the embodiments of the present disclosure do not limit this.
[0071] In the embodiments of the present disclosure, after the personae dialogue data is input into the personae generation model, the personae description data set output by the personae generation model can not match the input personae dialogue data. For example, the input into the personae generation model is the dialogue data of a historical character, but the personae description data set output by the personae generation model is the description of a modern character. Therefore, some embodiments of the present disclosure can also adjust the personae description data set output by the personae generation model through the method shown in FIG. 3, so as to make the description of the personae generation model more accurate and more suitable.
[0072] FIG. 3 is a flowchart of a method for optimizing a personae description data set according to an embodiment of the present disclosure. In some embodiments, the method shown in FIG. 3 can be executed by a processing device, and specifically can be implemented by a personae library construction module 502 deployed in a role-playing dialogue data generation system on the processing device. The method specifically includes the following steps.
[0073] In step 301, the personae dialogue data and the personae description data set output by the personae generation model are combined and input into a personae optimization model to obtain the output of the personae optimization model.
[0074] Optionally, the initial personae optimization model can be trained by the preset standard sample features and the preset standard sample dialogue data.
[0075] In some embodiments, the preset standard sample features and the preset standard sample dialogue data can be understood as specific sample data sets, and specifically can be personae sample features and more representative sample dialogue data with higher description granularity and accuracy designed for multiple different personae, or a combination of multiple preset standard sample features and preset standard sample dialogue data, and labels corresponding to each group of data, which can be "match" or "not match".
[0076] Optionally, the initial personae optimization model can be a large language model that has not been fine-tuned by a specific data set, such as Mistral, OpenAI GPT, etc.
[0077] In some embodiments, the large language model can be fine-tuned by manual annotation. Specifically, more representative sample dialogue data can be input into the initial persona optimization model, and the model is instructed to output its corresponding persona description data set, and then the model is asked Q1: Is the persona description data set you output accurate? If the model replies that it is not accurate, the model can be further asked Q2: How is the inaccurate persona description embodied, and how should it be modified? Through such multiple rounds of interaction, the initial persona optimization model outputs a persona description data set that is close to the aforementioned description granularity and has higher accuracy.
[0078] In another embodiment, the large language model can be adjusted by supervised learning to obtain a persona optimization model. Specifically, the combination of the preset standard sample features and the preset standard sample dialogue data can be input into the large language model to obtain the judgment result of whether it matches the combination, and the model parameters are adjusted so that the judgment result of the model is consistent with the label of the combination. Using the preset standard sample features and the preset standard dialogue data as specific training sample data, the initial persona optimization model can be fine-tuned to obtain the persona optimization model.
[0079] Optionally, the persona optimization model is used to optimize the persona description data set output by the persona generation model described in FIG. 1. Since the initial persona optimization model itself has natural language dialogue capability and has learned how to analyze the matching degree of the persona dialogue data and the persona description data set, and how to determine the optimization method. Therefore, the persona optimization model can be used to optimize the persona description data set output by the persona generation model through interactive dialogue.
[0080] For example, the persona dialogue data and the persona description data set output by the persona generation model can be input into the persona optimization model, and the persona optimization model can be asked Q1: Is the persona description output by the current persona generation model accurate? The persona optimization model replies A1: The persona description output by the current persona generation model is not accurate / accurate. Ask the persona optimization model Q2: How is the inaccurate persona description embodied, and how should it be modified? The persona optimization model replies A2: The "he is a young man" in the current persona description data set does not conform to the persona dialogue data input into the persona generation model. Based on the beauty topic in the persona dialogue data, it can be determined that the persona corresponding to the persona dialogue data is more likely to be a young woman.
[0081] Optionally, based on the output of the persona optimization model, the content of the part of the persona description dataset in the persona generation model can be modified or replaced, thereby obtaining the optimized persona description dataset. For example, the persona dialogue data and the persona description dataset output by the persona generation model can be input into the persona optimization model, and the persona optimization model can be asked whether the foregoing combination matches. If the output of the persona optimization model is that the combination does not match, the persona optimization model can be further instructed to generate a more accurate persona description dataset based on the persona dialogue data than the persona description dataset output by the persona generation model.
[0082] In some embodiments, the foregoing sentence for querying the model can be pre-set and recorded in a question library. After obtaining the persona description dataset output by the persona generation model, the persona dialogue data and the persona description dataset output by the persona generation model can be automatically input into the persona optimization model through program instructions, and the querying sentence can be automatically selected from the question library and input into the persona optimization model through program instructions, such as through a pre-written script file, to obtain the corresponding output.
[0083] Step 302, based on the output, determining an optimized persona description dataset corresponding to the persona description dataset output by the persona generation model.
[0084] In some embodiments, the optimized persona description dataset can be selected from the output of the persona optimization model, and the output of the persona generation model can be updated, thereby improving the accuracy of the persona generation model in describing the persona. Alternatively, based on the output of the persona optimization model, the content of the part of the persona description dataset output by the persona generation model can be modified or replaced, thereby obtaining the optimized persona description dataset.
[0085] Optionally, the optimized persona description dataset can also be used to construct the persona library in step 102, thereby realizing the updating of the persona library.
[0086] FIG. 4 is a flowchart of a method for generating persona dialogue data according to some embodiments of the present disclosure. In some embodiments, the method shown in FIG. 4 can be implemented by the dialogue data generation module 503 in the role-playing dialogue data generation system deployed on a processing device, which specifically includes the following steps.
[0087] Step 401, selecting a first persona and a second persona from the persona library.
[0088] Optionally, two personas are randomly selected from the persona library, which are the first persona and the second persona, thereby obtaining the persona description dataset of the first persona and the persona description dataset of the second persona. In some embodiments of the present disclosure, the persona description dataset of the first persona can be recorded as a, and the persona description dataset of the second persona can be recorded as b.
[0089] In some embodiments, different personas can be selected from the same persona category in the persona library, and dialog data between the different personas in the different persona category can be generated based on the different persona description data sets corresponding to the different personas, and then the first specific role-playing dialog data can be obtained. For example, the personas "Qu Yuan" and "Fan Zhongyan" can be selected from the persona category of historical figures to have a dialog, and dialog data can be obtained. In yet other embodiments, different personas can be selected from different persona categories, and dialog data between the different personas in the different categories can be generated based on the different persona description data sets corresponding to the different personas, and then the second specific role-playing dialog data can be obtained. For example, the persona "Qu Yuan" can be selected from the persona category of historical figures, and the persona "Xuanwu" can be selected from the persona category of animation figures, and dialog data can be obtained based on the dialog between "Qu Yuan" and "Xuanwu".
[0090] In step 402, the first sentence of the first persona and the persona description data set of the first persona and the second persona are input into the second language model corresponding to the second persona, and a first reply sentence of the second persona output by the second language model is obtained.
[0091] In some embodiments, the first persona and the second persona can correspond to a first language model and a second language model, respectively. The first and second language models can be large language models or other types of language models with dialog capabilities. For example, the first and second language models can be Mistral chart models, the input of which can be a persona description data set or a persona description data set and a dialog context, and the output can be a sentence corresponding to a persona.
[0092] Optionally, the first sentence of the first persona can be a preset sentence, or a sentence obtained by inputting the persona description data set of the first persona into the first language model. The first sentence (denoted as a1) generated by the first persona, the persona description data set (denoted as a) of the first persona, and the persona description data set (denoted as b) of the second persona are input into the second language model, and the second language model outputs a first reply sentence of the second persona, denoted as b1.
[0093] In step 403, the first reply sentence b1 of the second persona, the first sentence a1 of the first persona, and the persona description data set a of the first persona and the persona description data set b of the second persona are input into the first language model corresponding to the first persona, and a second sentence of the first persona output by the first language model is obtained.
[0094] The first reply statement b1 of the second persona and the first statement a1 of the first persona can be understood as the dialogue context between the first persona and the second persona. The dialogue context and the persona description data set (i.e., a and b) of the first persona and the second persona are input into the first language model to obtain the second statement a2 of the first persona output by the first language model.
[0095] In step 404, the second statement a2 of the first persona, the first reply statement b1 of the second persona, the first statement a1 of the first persona, the persona description data set a of the first persona, and the persona description data set b of the second persona are input into the second language model to obtain the second reply statement b2 of the second persona.
[0096] The second statement a2 of the first persona, the first reply statement b1 of the second persona, and the first statement a1 of the first persona can be understood as the dialogue context between the two personas.
[0097] Alternatively, the dialogue context and the persona description data set (i.e., a and b) of the first persona and the second persona are input into the second language model to obtain the reply statement b2 of the second persona.
[0098] In step 405, the first language model and the second language model are used to alternately output statements to obtain dialogue data between the first persona and the second persona.
[0099] In some embodiments, the first statement a1 of the first persona and the first reply statement b1 of the second persona can be regarded as first round dialogue data, and the second statement a2 of the first persona and the second reply statement b2 of the second persona can be regarded as second round dialogue data. The existing dialogue context and the persona description data set can be alternately input into the corresponding persona language model to obtain the statement of the corresponding persona. In this way, more rounds of dialogue data can be obtained. The number of rounds of dialogue data obtained by the method shown in FIG. 4 can be set according to actual needs. For example, the obtained dialogue data can be two rounds of dialogue data, or three rounds of dialogue data, etc.
[0100] Corresponding to step 401, based on whether the first persona and the second persona come from the same persona category in the persona library, first specific role-playing dialogue data between personas of the same category and second specific role-playing dialogue data between personas of different categories can be obtained, further enriching the diversity of the dialogue data. The initial role-playing model can be trained based on at least one of the generated first and second specific role-playing dialogue data, so that the initial role-playing model can simulate or play dialogue with specified personas and various other personas, thereby obtaining an optimized role-playing model. The training process of the role-playing model can be found in the related description of FIG. 1, and will not be described here.
[0101] FIG. 4 illustrates a process of generating dialogue data between two personas as an example. According to the method shown in FIG. 4, it can be envisaged that a process of generating dialogue data between three personas or more personas. As an example, three personas can be selected from the persona library, and the existing dialogue context and the corresponding persona description data set are alternately processed using three language models to obtain the utterances of the corresponding personas, and then the dialogue data between the three personas is obtained. Therefore, the dialogue data generation process between two personas shown in FIG. 4 should not be understood as a limitation of the embodiments of the present disclosure.
[0102] FIG. 5 is an exemplary block diagram of a role-playing dialogue data generation system according to an embodiment of the present disclosure, which specifically includes:
[0103] The persona output module 501 is configured to input a plurality of segments of persona dialogue data into a persona generation model to obtain a plurality of sets of persona description data output by the persona generation model, wherein the persona generation model is obtained by training an initial language model based on persona sample features and persona sample dialogue data; each segment of the plurality of segments of persona dialogue data includes one or more rounds of dialogue data between different personas; and each set of the plurality of sets of persona description data includes persona description data of one of the personas participating in the dialogue.
[0104] The persona library construction module 502 is configured to construct a persona library based on the plurality of sets of persona description data.
[0105] The dialogue data generation module 503 is configured to select different personas from the persona library, generate dialogue data between the different personas based on the sets of persona description data corresponding to the different personas, and then obtain the role-playing dialogue data.
[0106] More details about the modules can be found in FIG. 1 and the related descriptions of FIGS. 3-4, which will not be repeated here. It should be understood that the system and its modules shown in FIG. 5 can be implemented in various ways. For example, in some embodiments, the system and its modules can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented by special logic; the software part can be stored in a memory and executed by a suitable instruction execution system, such as a microprocessor or a specially designed hardware. Those skilled in the art can understand that the above method and system can be implemented using computer executable instructions and / or control codes contained in a processor, such as a carrier medium, such as a disk, CD or DVD-ROM, or the memory of a programmable device. The system and its modules of the embodiments of the present disclosure can not only be implemented by hardware circuits such as very large scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc. It can also be implemented by software, such as executed by various types of processors, and can also be implemented by a combination of the above hardware circuit and software (for example, firmware).
[0107] It should be noted that the above description of the system and its modules is for convenience of description only and cannot limit the embodiments of the present disclosure to the scope of the embodiments. It can be understood by those skilled in the art that after understanding the principles of the system, the modules can be combined in any way to form a subsystem connected to other modules without deviating from the principles. Or some modules are split to get more modules or multiple units under the module. As an example, a person description optimization module (not shown in the figure) can be added to the system shown in FIG. 5 to replace the person library construction module 502 to implement the method flow of optimizing the person description data set. Variations such as this are within the scope disclosed by the embodiments of the present disclosure.
[0108] The beneficial effects that the embodiments of the present disclosure can bring include but are not limited to: (1) generating diverse personas using a persona generation model; (2) constructing a persona library based on diverse personas and conducting a dialogue using the personas in the persona library, thereby generating dialogue data with fine granularity, which is conducive to improving the performance of a role-playing model; (3) in the process of training the persona generation model, using EMD to optimize the training process of the persona generation model, which helps to save the number of training sample data and improve the efficiency of model training; (4) the method for generating role-playing dialogue data provided by some embodiments of the present disclosure can be automatically executed by a computer or other processing device, which significantly improves the sample acquisition efficiency. It should be noted that different embodiments can produce different beneficial effects, and in different embodiments, the beneficial effects that can be produced can be any one or a combination of several of the above, or any other beneficial effect that can be obtained.
[0109] Having described the basic concepts, it is obvious to those skilled in the art that the above detailed disclosure is only as an example, and does not constitute a limitation on the embodiments of the present disclosure. Although it is not explicitly stated here, those skilled in the art can make various modifications, improvements and corrections to the embodiments of the present disclosure. Such modifications, improvements and corrections are taught in the embodiments of the present disclosure, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of the present disclosure. Industrial applicability
[0110] The embodiments of the present disclosure provide a role-playing dialogue data generation method, system and computer program product, which improves the acquisition efficiency of training samples, increases the diversity of training samples, and can improve the model performance of the role-playing model.
Claims
1. A role-playing dialogue data generation method characterized by comprising: The method comprises: inputting multiple pieces of human setup dialogue data into a human setup generation model to obtain multiple human setup description data sets output by the human setup generation model respectively, wherein the human setup generation model is obtained by training an initial language model by human setup sample features and human setup sample dialogue data; each piece of human setup dialogue data in the multiple pieces of human setup dialogue data comprises one or more rounds of dialogue data between different human setups; and each human setup description data set in the multiple human setup description data sets comprises human setup description data of one human setup participating in the dialogue; constructing a human setup library based on the multiple human setup description data sets; selecting different human setups from the human setup library, generating dialogue data between the different human setups based on human setup description data sets corresponding to the different human setups respectively, and obtaining the role-playing dialogue data.
2. The role-playing dialogue data generation method according to claim 1, characterized by, The human setup generation model is obtained by: obtaining human setup sample features and human setup sample dialogue data; inputting the human setup sample dialogue data into the initial language model to obtain human setup description data sets output by the initial language model; calculating a loss value of the human setup description data sets output by the initial language model and the human setup sample features by using EMD, iteratively updating model parameters of the initial language model based on the loss value, and obtaining the human setup generation model.
3. The role-playing dialogue data generation method according to claim 2, characterized by, The human setup sample dialogue data comprises dialogue data between three or more human setups.
4. The role-playing dialogue data generation method according to any one of claims 1 to 3, characterized by, The method further comprises: combining the human setup dialogue data and the human setup description data sets output by the human setup generation model to input into a human setup optimization model to obtain an output of the human setup optimization model; the human setup optimization model is obtained by training an initial human setup optimization model by preset standard sample features and preset standard sample dialogue data; based on the output, determining optimized human setup description data sets corresponding to the human setup description data sets output by the human setup generation model; The human setup library is constructed based on the multiple human setup description data sets, comprising: recording the optimized human setup description data sets into the human setup library.
5. The role-playing dialogue data generation method according to any one of claims 1 to 4, characterized by, The multiple pieces of human setup dialogue data comprise one or more rounds of dialogue data between a target human setup and multiple other human setups; The multiple human setup description data sets output by the human setup generation model comprise multiple human setup description data sets corresponding to the target human setup; The method further comprises: merging the multiple human setup description data sets corresponding to the target human setup to obtain human setup description data of the target human setup.
6. The role-playing dialogue data generation method according to any one of claims 1 to 5, characterized by, The method further comprises: selecting a first human setup and a second human setup from the human setup library; inputting a first sentence of the first human setup and human setup description data sets of the first human setup and the second human setup into a second language model corresponding to the second human setup to obtain a first reply sentence of the second human setup output by the second language model; inputting the first reply sentence of the second role, the first sentence of the first role, and role description data sets of the first role and the second role into a first language model corresponding to the first role to obtain a second sentence of the first role output by the first language model; inputting the second sentence of the first role, the first reply sentence of the second role, the first sentence of the first role, the role description data set of the first role, and the role description data set of the second role into the second language model to obtain a second reply sentence of the second role; alternately outputting sentences by using the first language model and the second language model to obtain dialogue data between the first role and the second role.
7. The role-playing dialogue data generation method according to any one of claims 1 to 6, characterized by, The role-playing dialogue data is used to train an initial role-playing model to obtain a role-playing model.
8. The role-playing dialogue data generation method according to claim 7, characterized by, The method further comprises: calculating similarities between different roles in the role library based on role description data sets of the roles, and classifying the roles in the role library based on the similarities to obtain one or more role categories; The method further comprises: selecting different roles from the same role category, generating dialogue data between the different roles based on role description data sets respectively corresponding to the different roles, and obtaining first specific role-playing dialogue data; selecting different roles from different role categories, generating dialogue data between the different roles based on role description data sets respectively corresponding to the different roles, and obtaining second specific role-playing dialogue data; At least one of the first specific role-playing dialogue data and the second specific role-playing dialogue data is used to train the initial role-playing model to obtain the role-playing model.
9. The role-playing dialogue data generation method according to claim 8, characterized by, The method further comprises: determining vector representations corresponding to the role description data sets of the roles in the role library; calculating similarity parameters between the vector representations corresponding to the role description data sets of the roles, and determining similarities between different roles according to the similarity parameters.
10. A role-playing conversation data generation system characterized by comprising: The system comprises: a role output module configured to input multiple pieces of role dialogue data into a role generation model to obtain multiple role description data sets output by the role generation model, wherein the role generation model is obtained by training an initial language model based on role sample features and role sample dialogue data; each piece of the multiple pieces of role dialogue data comprises one or more rounds of dialogue data between different roles; and each of the multiple role description data sets comprises role description data of one of the roles participating in the dialogue; a role library construction module configured to construct a role library based on the multiple role description data sets. The dialogue data generation module is configured to select different personas from the persona library, generate dialogue data between the different personas based on different persona description data sets corresponding to the different personas, and obtain the role-playing dialogue data.
11. A role-playing dialogue data generation device characterized by comprising: A storage medium and a processor are included, and the storage medium stores computer instructions, and the processor is configured to execute the computer instructions to implement the method of any one of claims 1-8.
12. A computer-readable storage medium, characterized in that, A storage medium stores computer instructions, and the computer instructions are executed by a processor to implement the method of any one of claims 1-8.
13. A computer program product, characterised in that, A computer instruction or a computer program is included, and the computer instruction or the computer program is executed by a processor to implement the method of any one of claims 1-8.
Citation Information
Patent Citations
A method and device for optimizing a dialogue model
CN109635095A
Intelligent dialogue method, device, equipment and storage medium
CN110399474A
Sample data generation method and large language model training method
CN117113082A
Personalized dialogue generation method and system based on large language model
CN117787293A
Role playing dialogue data generation method and system and computer program product
CN118403367A