A method, system and computer program product for generating role-playing dialogue data

Through the character generation and optimization model, the character library is constructed, and diverse character dialogue data is generated, which solves the problems of high cost of sample data acquisition and low diversity in the existing technology, and improves the training effect and user interaction of role-playing models quality.

CN118403367BActive Publication Date: 2024-11-15SHANGHAI XIYU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410651922.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-11-15
Estimated Expiration
2044-05-23

AI Technical Summary

Technical Problem

During the training process, the existing role-playing models have high cost of obtaining sample data and low diversity, resulting in poor training results, which affects the performance effect.

Method used

Through the character generation model and character optimization model, a character library is built using multiple character dialogue data, and different character generation dialogue data are selected to improve the diversity and acquisition efficiency of training samples.

Benefits of technology

This improves the diversity and acquisition efficiency of the training sample of the role-playing model, and enhances the authenticity and nature of the interaction between the model and the user.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118403367B_ABST
    Figure CN118403367B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, system and computer program product for generating role-playing dialogue data. The method for generating role-playing dialogue data in the present disclosure includes: inputting multiple segments of character dialogue data into a character generation model, and obtaining multiple character description data sets output by the character generation model, wherein each segment of the multiple segments of character dialogue data includes one or more rounds of dialogue data between different characters; each of the multiple character description data sets includes character description data of one of the characters participating in the dialogue; constructing a character library based on the multiple character description data sets; selecting different characters from the character library, and generating dialogue data between different characters based on the character description data sets corresponding to the different characters, to obtain role-playing dialogue data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present specification relates to the field of natural language processing, and in particular to a method, system and computer program product for generating role-playing dialogue data. Background Art

[0002] Role-playing models can imitate a character setting (or simply a character setting) and output language expressions that match the character setting's gender, character, personality, occupation, and other characteristics. Using role-playing models to play specific roles or characters for interaction has become a hot research direction. Training role-playing models usually requires a large amount of data. When the cost of obtaining sample data is high and the diversity of sample data is relatively low, the training effect of the role-playing model is often poor, which in turn affects the effect of role-playing.

[0003] To this end, some embodiments of the present specification aim to provide a method, device and related computer program product for generating role-playing dialogue data, so as to improve the efficiency of obtaining training samples and increase the diversity of training samples. Summary of the invention

[0004] One or more embodiments of the present specification provide a method for generating role-playing dialogue data, the method comprising: inputting multiple segments of character dialogue data into a character generation model, and obtaining multiple character description data sets output by the character generation model, wherein the character generation model is obtained by training an initial language model with character sample features and character sample dialogue data; each segment of character dialogue data in the multiple segments of character dialogue data respectively includes one or more rounds of dialogue data between different characters; each character description data set in the multiple character description data sets respectively includes character description data of one of the characters participating in the dialogue; constructing a character library based on the multiple character description data sets; selecting different characters from the character library, and generating dialogue data between the different characters based on the character description data sets corresponding to the different characters, thereby obtaining the role-playing dialogue data.

[0005] According to the role-playing dialogue data generation method described in some embodiments of the present specification, the character generation model is obtained in the following manner: obtaining character sample features and character sample dialogue data; inputting the character sample dialogue data into an initial language model to obtain a character description data set output by the initial language model; using EMD to calculate the loss value of the character description data set output by the initial language model and the character sample features, and iteratively updating the model parameters of the initial language model based on the loss value to obtain the character generation model.

[0006] According to the role-playing dialogue data generation method described in some embodiments of this specification, the character sample dialogue data includes dialogue data between more than three characters.

[0007] According to the role-playing dialogue data generation method described in some embodiments of the present specification, the method further includes: combining the character dialogue data and the character description data set output by the character generation model, and inputting them into the character optimization model to obtain the output of the character optimization model; the character optimization model is obtained by training an initial character optimization model with preset standard sample features and preset standard sample dialogue data; based on the output, determining an optimized character description data set corresponding to the character description data set output by the character generation model; constructing a character library based on multiple character description data sets, including: recording the optimized character description data set in the character library.

[0008] According to the role-playing dialogue data generation method described in some embodiments of the present specification, the multiple segments of character dialogue data include one or more rounds of dialogue data between a target character and multiple other characters; the multiple character description data sets output by the character generation model include multiple character description data sets corresponding to the target character; the method also includes: merging the multiple character description data sets corresponding to the target character to obtain the character description data set of the target character.

[0009] According to the role-playing dialogue data generation method described in some embodiments of the present specification, the selecting different characters from the character library and generating dialogue data between the different characters based on the character description data sets corresponding to the different characters respectively include: selecting a first character and a second character from the character library; inputting a first sentence of the first character and a character description data set of the first character and the second character into a second language model corresponding to the second character, and obtaining a first reply sentence of the second character output by the second language model; inputting the first reply data of the second character, the first sentence of the first character and the character description data set of the first character and the second character into the first language model corresponding to the first character, and obtaining a second sentence of the first character output by the first language model; inputting the second sentence of the first character, the first reply sentence of the second character, the first sentence of the first character and the character description data set of the first character and the second character into the second language model, and obtaining a second reply sentence of the second character; and so on, using the first language model and the second language model to alternately output sentences, and obtaining the dialogue data between the first character and the second character.

[0010] According to the role-playing dialogue data generation method described in some embodiments of this specification, the role-playing dialogue data is used to train an initial role-playing model to obtain a role-playing model.

[0011] According to the role-playing dialogue data generation method described in some embodiments of the present specification, the method further includes: calculating the similarity between different characters in the character library based on the character description data set of the character, and classifying the characters in the character library based on the similarity to obtain one or more character categories; selecting different characters from the character library, and generating dialogue data between the different characters based on the character description data sets corresponding to the different characters, including: selecting different characters from the same character category, generating dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then obtaining first specific role-playing dialogue data; selecting different characters from different character categories, generating dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then 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 a role-playing model.

[0012] One or more embodiments of the present specification also provide a role-playing dialogue data generation system, the system comprising: a character output module, used to input multiple character dialogue data into a character generation model, and obtain multiple character description data sets output by the character generation model, wherein the character generation model is obtained by training an initial language model with character sample features and character sample dialogue data; each of the multiple character dialogue data includes one or more rounds of dialogue data between different characters; each of the multiple character description data sets includes character description data of one of the characters participating in the dialogue; a character library construction module, used to construct a character library based on multiple character description data sets; and a dialogue data generation module, used to select different characters from the character library, and generate dialogue data between the different characters based on the character description data sets corresponding to the different characters, thereby obtaining the role-playing dialogue data.

[0013] One or more embodiments of the present specification also provide a role-playing dialogue data generation device, including a storage medium and a processor, wherein the storage medium stores computer instructions, and the processor is used to execute at least part of the computer instructions to implement the role-playing dialogue data generation method described in one or more embodiments of the present specification.

[0014] One or more embodiments of the present specification also provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for generating role-playing dialogue data described in one or more embodiments of the present specification can be implemented.

[0015] One or more embodiments of the present specification also provide a computer program product, including computer instructions or a computer program, which, when executed by a processor, can implement the role-playing dialogue data generation method described in one or more embodiments of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] This specification will be further explained by way of exemplary embodiments, which will be described in detail by way of the accompanying drawings. The same numbers in the drawings represent the same structures or steps.

[0017] Figure 1 This is a flowchart of a method for generating role-playing dialogue data according to some embodiments of this specification.

[0018] Figure 2 This is a flow chart of a method for training a persona generation model as shown in some embodiments of this specification.

[0019] Figure 3 This is a flow chart of a method for optimizing a person description data set shown in some embodiments of this specification.

[0020] Figure 4 This is a flow chart of a method for generating character dialogue data in some embodiments of this specification.

[0021] Figure 5 This is an exemplary block diagram of a system for generating role-playing dialogue data according to some embodiments of the present specification. DETAILED DESCRIPTION

[0022] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the embodiments will be described in detail below with reference to the accompanying drawings. Obviously, the contents described below are some examples or embodiments of this specification. For ordinary technicians in this field, without paying creative work, the technical solutions or means disclosed in this specification can also be applied to other scenarios based on these technical contents.

[0023] It should be understood that the "system", "device", "unit" and / or "module" used in this specification is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the words can be replaced by other expressions.

[0024] Unless otherwise specified, technical terms used in this specification to describe components, elements, etc. do not refer to the singular, but may also include the plural. Generally speaking, terms such as "include", "comprise", etc. only indicate that the steps, elements, or components that have been clearly identified are included, and these steps, elements, and components do not constitute an exclusive list, such as the method or device described may also include other steps or components.

[0025] Flowcharts are used in this specification to illustrate the operation steps performed by the device or system of the relevant embodiments, but unless otherwise specified, the order used to describe these steps should not be understood as a limitation on the order in which the steps are performed. A person of ordinary skill in the art can adjust the order in which these steps are performed based on the knowledge and information conveyed by the embodiments of this specification, and the adjustment includes but is not limited to swapping the order, merging multiple steps, and splitting a certain step.

[0026] The role-playing model can imitate a certain persona and output language expressions that conform to the characteristics of the persona, such as gender, character, personality, occupation, etc. The persona can be a real person, a virtual person or an anthropomorphic object, such as a character or anthropomorphic object in a film, TV series, or a game, or it can be a persona of practitioners in a certain industry, or it can be a persona created by the user himself. As an example, the role-playing model can imitate Sun Wukong to output language expressions that conform to the characteristics of the persona. For another example, the role-playing model can imitate the tour guide to interact with tourists in language and provide tourists with tour guide-related services. For another example, the role-playing model can imitate the two-dimensional persona personalized by the user to interact with the user through language interaction for entertainment. In actual application scenarios, the role-playing model can be used to play a specific role or character to interact with the user (natural person) or another role or character (such as another role-playing model) in dialogue. Exemplarily, the role-playing model can be used in a variety of specific scenarios such as intelligent customer service, navigation services, game entertainment, service hall robots, hotel room robots, etc., while providing users with consulting, guidance and other services, it can also increase the fun of the interaction process or make the model or robot dialogue more real and natural.

[0027] In order to make the role-playing model as close as possible to the person it simulates, a large number of training samples are needed for training. Specifically, a large amount of dialogue data of the corresponding persona is required, based on which the role-playing model is trained. In some training scenarios, the dialogue data for training can be obtained manually, specifically by professionals writing and collecting the dialogue data of the persona based on the personality, occupation and other characteristics of the persona. This method has high labor costs and low efficiency. In some other training scenarios, some existing dialogue data, such as open source dialogue databases, film and television scripts, etc., can be used to semi-automatically generate dialogue data of relevant personas by using data cleaning, extraction and other technologies. This method can improve the efficiency of training data acquisition to a certain extent, but the diversity of dialogue data is low, and it is difficult to fully and vividly reflect the characteristics of the persona.

[0028] To this end, some embodiments of the present specification provide a method, device and related computer program product for generating role-playing dialogue data, aiming to improve the efficiency of sample acquisition and enrich sample diversity.

[0029] Some embodiments of this specification obtain diverse characters by training the initial language, and use the diverse characters to build a character library, and further select different characters in the character library for dialogue, thereby efficiently obtaining rich and diverse character dialogue data with fine granularity. This further enriches the training samples of the role-playing model and improves the effect of the role-playing model interacting with the user.

[0030] Figure 1 A flowchart of a method for generating role-playing dialogue data provided in some embodiments of this specification, Figure 1 The process shown can be executed by a processing device, for example, it can be implemented by a role-playing dialogue data generation system deployed on the processing device. Figure 1 As shown, the role-playing dialogue data generation method specifically includes the following steps.

[0031] Step 101, input multiple segments of character dialogue data into a character generation model, and obtain multiple character description data sets output by the character generation model. In some embodiments, step 101 can be implemented by a character output module 501.

[0032] In some embodiments, a segment of character dialogue data may include one or more rounds of dialogue data between dialogue participants (or between different characters), wherein a round of character dialogue data may include statements output by at least two of the other participants for a topic or its sub-topic. Taking two dialogue participants as an example, a round of character dialogue data may include a statement initiated by a character among the dialogue participants, and a statement responded by another character among the dialogue participants. As an example, a segment of dialogue data may be A: "Wukong, how far is the next village?", B: "Master, you rest here, I, Old Sun, will go to find out." In some embodiments, a round of dialogue data may also be a dialogue between more characters. For example, the dialogue data may be dialogue data between more than three characters, specifically, it may be a group chat between 4, 5, 6 or even more characters. At this time, a round of dialogue data may be statements output by two or more of the three or more characters participating in the dialogue for a topic or its sub-topic. As an example, a piece of dialogue data may be: A: "Wukong, how far is the next village?", B: "Master, you take a rest here, I will go to check it out", C: "Big Brother, you go ahead, we will take good care of Master.". When the number of participants in the dialogue data is more than three people, it can more efficiently and multi-facetedly reflect the characteristics of the characters participating in the dialogue, which helps to obtain more fine-grained description information of the characters. In some embodiments, the dialogue data may be text data. In other embodiments, the dialogue data may also be in other forms such as audio data, and the dialogue data in audio form may be further subjected to speech recognition to obtain its corresponding text data. The dialogue data may also include a role identifier for each character, such as "A", "B", etc. in the above example, which is used to mark the sentences of each character in the dialogue data.

[0033] The multiple segments of character dialogue data are multiple aforementioned character dialogue data. It can be understood that each segment of character dialogue data in the multiple segments of character dialogue data includes one or more rounds of dialogue data between different characters. In some embodiments, the multiple segments of character dialogue data can be obtained from open source scripts, movie subtitles, web page information, encyclopedia entries, and other channels.

[0034] In some embodiments, multiple segments (for example, three segments) of character dialogue data can be input into the character generation model, and the character generation model can process each segment of character dialogue data in turn to obtain a corresponding character description data set, that is, multiple character description data sets can be obtained. Among them, the character description data set includes the character description data of a character participating in the conversation, which may specifically include the name, personality, social relations, hobbies, background and other information of the character. As an example, the character description data set of the character Sun Wukong may include "Sun Wukong, lively and active, benevolent and loyal, protecting Tang Monk from the West to obtain scriptures, and subduing demons all the way. Because of his high skills, he is relatively arrogant and unwilling to be constrained by the traditional etiquette and legal system." In some embodiments, one character corresponds to one character description data set. As an example, among the three segments of character dialogue data input to the character generation model, the first segment of dialogue data involves a dialogue between two characters; the second segment of dialogue data involves a dialogue between three characters; and the third segment of dialogue data involves a dialogue between five characters. The character generation model can generate character description datasets for the characters involved in each segment of dialogue data in turn, that is, the character generation model can output two character description datasets, three character description datasets, and five character description datasets corresponding to each segment of character dialogue data in turn; or, the character generation model can also output a character description dataset only for a specified character in each segment of character dialogue data. For example, for the aforementioned three segments of character dialogue data, the character generation model can output a character description dataset of a certain dialogue participant for each segment of character dialogue data. In some embodiments, a mark can be added to the character's role identifier in the character dialogue data to specify the character. The character generation model can be trained based on the initial language model. For details about the specific training process of the character generation model, see Figure 2 describe.

[0035] In some embodiments of the present specification, the multiple segments of character dialogue data may include one or more rounds of dialogue data between the same target character and multiple other characters. The multiple character description data sets output by the character generation model include multiple character description data sets corresponding to the target character.

[0036] For example, the target person is a tour guide, and the others are multiple tourists who follow the tour guide to visit the scenic spot. The multiple segments of the person-set dialogue data are the dialogue data between the tour guide and the multiple tourists. Specifically, the first segment of the person-set dialogue data may be the dialogue data between tour guide A and tourist B, and the second segment of the person-set dialogue data may be the group chat dialogue data between tour guide A and tourists C and D.

[0037] Furthermore, the multiple segments of character dialogue data formed between the tour guide and the tourists are input into the character generation model, and the character generation model can process the multiple segments of character dialogue data in sequence and output multiple character description data sets of tour guide A. That is, the character generation model generates a character description data set of tour guide A based on each segment of the multiple segments of character dialogue data. Furthermore, multiple character description data sets of the same target persona can be merged or combined to obtain a complete character description data set of the target persona. As an example, the aforementioned merger or combination can be to find the union of two or more character description data sets of the same target persona, thereby, the description of the target persona by the character description data set is more three-dimensional, the character description is more in line with the character prototype, and the granularity of the character description is also finer.

[0038] Step 102 , constructing a character library based on multiple character description data sets. In some embodiments, step 102 may be implemented by a character library construction module 502 .

[0039] In some embodiments of this specification, the multiple character description data sets obtained in step 101 can be further combined to form a character library, and the character library includes multiple character description data sets, including but not limited to: character description data sets of the same category and character description data sets of different categories. In some embodiments, the characters in the character library can correspond one-to-one to the character description data sets.

[0040] In some embodiments, the similarities between different personalities in a personality library may be calculated based on a personality description data set of the personalities, and the personalities in the personality library may be classified based on the similarities to obtain one or more personality categories.

[0041] Specifically, the character description data sets corresponding to each character in the character library can be processed into vector representations, and the cosine similarity, Euclidean distance, Pearson correlation coefficient, etc. between the vector representations of the character description data sets of each character can be calculated, thereby determining the similarity between different characters in the character library. In other embodiments, clustering can be performed based on the vector representations corresponding to each character description data set to obtain one or more character categories.

[0042] In some embodiments of this specification, the character description data set output by the character generation model can also be optimized, and a character library can be constructed based on the optimized character description data set. Specifically, the optimized character description data set can be recorded in the character library, and further, the optimized character description data set can be used to replace the original character description data set. The character description data sets in the character library thus constructed are more accurate and more in line with the character image. For the optimization steps of the character description data set, please refer to Figure 3 Related description.

[0043] Step 103 , select different characters from the character library, generate dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then obtain role-playing dialogue data. In some embodiments, step 103 can be implemented by the dialogue data generation module 503 .

[0044] The conversation data between different characters can be the conversation data between two characters, or the conversation data between more characters. Specifically, two or more language models can be used to generate conversation sentences based on the character description data sets of the selected characters, so as to obtain the conversation data between different characters. For more information about obtaining the conversation data between different characters, please refer to Figure 4 Related instructions.

[0045] 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, some sentences of the persona played by the role-playing model in the dialogue data can be masked, and the masked dialogue data can be input into the initial role-playing model to obtain the sentences of the persona played by the initial role-playing model output, and the model parameters can be adjusted to reduce the difference between the sentences output by the initial role-playing model and the masked sentences in the dialogue data. When the initial role-playing model training is completed, the role-playing model can be obtained. In some embodiments of the present specification, the dialogue data of step 103 can be directly used as role-playing dialogue data. In other embodiments of the present specification, the dialogue data can also be used as training data for the role-playing model after being subjected to optimization processing such as deduplication, cleaning, and correction.

[0046] Figure 2 This is a flow chart of a method for determining a personality generation model shown in some embodiments of this specification, which specifically includes the following steps.

[0047] Step 201, obtaining characteristics of a persona sample and conversation data of a persona sample.

[0048] In some embodiments, character sample features and character sample dialogue data can be obtained from open source data sets. Among them, the character sample features are feature labels preset for the character to be generated, which can specifically include specific descriptions of characteristics such as personality and hobbies. The character sample features and character sample dialogue data constitute the training sample data set of the character generation model. For example, the character sample features in the training sample data set are the feature descriptions of the well-known TV character Sun Wukong, and the character sample dialogue data are multiple dialogue lines between Sun Wukong and other characters in film and television dramas. For another example, the character sample features in the training sample data set are the feature descriptions of the historical figure Qu Yuan, and the corresponding character sample dialogue data are the dialogues between Qu Yuan and others recorded in ancient poems and essays, etc.

[0049] In some embodiments of the present specification, the character sample dialogue data may be dialogue data between two characters, or may include dialogue data between three or more characters, so that the initial language model can learn more three-dimensional and richer-level character description data during the training process.

[0050] Step 202: input the character sample dialogue data into an initial language model to obtain a character description data set output by the initial language model.

[0051] The initial language model may be an open source large language model, including but not limited to Mistral, OpenAI GPT, BERT, etc. The character sample dialogue data in step 201 may be input into the initial language model to obtain a character description data set output by the initial language model.

[0052] Step 203, using EMD to calculate the loss value of the persona description data set output by the initial language model and the persona sample features, iteratively updating the model parameters of the initial language model based on the loss value, and obtaining a persona generation model.

[0053] Based on the character description dataset output by the initial language model, the model parameters of the initial language model are adjusted. Each adjustment of the initial language model can be regarded as an iterative training of the initial language model.

[0054] In some embodiments, EMD (Earth Move's Distance) can be used to calculate the loss value between the character description data set obtained by the initial language model after each training by processing the character sample dialogue data and the character sample features in step 201. The model parameters are adjusted so that the EMD loss function value between the character description data set output by the model and the character sample features is reduced, so that the initial language model generates a character description data set similar to it by learning the distribution of the character sample features. Specifically, EMD is used to measure the difference between the character sample features and the character description data set output by the initial language model, and the similarity between the two is calculated by calculating the minimum cost required to convert the character description data set output by the initial language model into the character sample features. EMD considers the semantic relationship between the character sample features and the vocabulary of the character 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 character description data set into the vocabulary distribution of the character sample features, a more accurate similarity measure can be obtained.

[0055] On the one hand, the EMD loss function can provide accurate gradient information, helping the initial language model to better learn distribution information and improve the generation ability of the persona generation model. On the other hand, using EMD to optimize the training process of the persona generation model allows the model to generate targets with less data, save the amount of training data, and improve the model performance as much as possible under the condition of the same training data, generating diverse personas.

[0056] In some embodiments, when the loss value between the character description data set output by the initial language model and the character 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, the model training is determined to be completed and a trained character generation model is obtained. Alternatively, the trained character generation model can be tested, and when its performance meets the preset requirements, the model training can be terminated. The conditions for terminating the iterative training of the model can be flexibly set according to actual needs, and the embodiments of this specification do not limit this.

[0057] In some embodiments of this specification, after the character dialogue data is input into the character generation model, the character description data set output by the character generation model may not match the input character dialogue data. For example, the character generation model may input dialogue data of historical figures, but the character generation model may output a character description data set of modern figures. Figure 3 The method shown adjusts the character description dataset output by the character generation model so that the character generation model's description of the character is more accurate and more appropriate.

[0058] Figure 3 This is a flow chart of a method for optimizing a persona description data set as shown in some embodiments of this specification. In some embodiments, Figure 3 The method shown can be executed by a processing device, and can be specifically implemented by a character library construction module 502 in a role-playing dialogue data generation system deployed on the processing device. The method specifically includes the following steps.

[0059] Step 301, combining the character dialogue data and the character description data set output by the character generation model, and inputting them into the character optimization model to obtain the output of the character optimization model.

[0060] The persona optimization model can be obtained by training the initial persona optimization model with preset standard sample features and preset standard sample conversation data. In some embodiments, the preset standard sample features and preset standard sample conversation data can be understood as a specific sample data set, which can be a persona sample feature with higher description granularity and accuracy designed for multiple different personas and more representative sample conversation data, or it can be a combination of multiple preset standard sample features and preset standard sample conversation data, as well as labels corresponding to each set of data, and the specific labels can be "match" or "mismatch".

[0061] The initial person setting optimization model can be a large language model that has not been fine-tuned with a specific data set, such as Mistral, OpenAI GPT, etc. 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 person setting optimization model, and the model can be instructed to output its corresponding person setting description data set, and then ask the model Q1: Is the person setting description data set you output accurate? If the model reply is inaccurate, the model can be further asked Q2: Where is the inaccurate person setting description specifically reflected, and how should it be modified? Such multiple rounds of interaction make the initial person setting optimization model output a person setting description data set close to the aforementioned description granularity and more accurate person setting sample features. In another embodiment, the large language model can be adjusted in a supervised learning manner to obtain a person setting optimization model. Specifically, the combination of preset standard sample features and preset standard sample dialogue data can be input into the large language model to obtain its judgment result on whether the aforementioned combination matches, and the model parameters can be adjusted so that the judgment result of the model is consistent with the label of the combination. Using the preset standard sample features and preset standard dialogue data as specific training sample data, the initial person setting optimization model is fine-tuned to obtain a person setting optimization model.

[0062] Furthermore, the personality optimization model is used to Figure 1The character description data set output by the character generation model is optimized. Since the initial character optimization model itself has natural language conversation capabilities and has been trained to learn how to analyze the matching degree of the character conversation data and the character description data set, as well as how to determine the optimization method. Therefore, the character description data set output by the character generation model can be optimized using the character optimization model in an interactive conversation. For example, the character conversation data and the character description data set output by the character generation model can be input into the character optimization model, and the character optimization model is asked Q1: Is the character description output by the current character generation model accurate? The character optimization model replies A1: The character description output by the current character generation model is inaccurate / accurate. Ask the character optimization model Q2: Where is the inaccurate character description specifically reflected, and how should it be modified? The character optimization model replies A2: "He is a young man" in the current character description data set is inconsistent with the character conversation data input into the character generation model. Based on the beauty topic in the character conversation data, it can be determined that the character corresponding to the character conversation data is more likely to be a young woman. Furthermore, based on the output of the person setting optimization model, part of the content of the person setting description data set in the person setting generation model can be modified or replaced to obtain an optimized person setting description data set. For another example, the person setting dialogue data and the person setting description data set output by the person setting generation model can be input into the person setting optimization model, and the person setting optimization model can be asked whether the aforementioned combination matches. If the person setting optimization model outputs that it does not match, the person setting optimization model can be further instructed to generate a more accurate person setting description data set based on the person setting dialogue data than the person setting description data set output by the person setting generation model.

[0063] In some embodiments, the aforementioned query statements for the model can be pre-set and recorded in the question library. After obtaining the character description data set output by the character generation model, the character dialogue data and the character description data output by the character generation model can be automatically input into the character optimization model through program instructions, and the query statements can be automatically selected from the question library through program instructions, such as through a pre-written script file, and input into the character optimization model to obtain the corresponding output.

[0064] Step 302: Based on the output, determine an optimized character description data set corresponding to the character description data set output by the character generation model.

[0065] In some embodiments, an optimized character description dataset can be selected from the output results of the character optimization model to update the output of the character generation model, thereby improving the accuracy of the character description of the character generation model. Alternatively, based on the output of the character optimization model, part of the content of the character description dataset output by the character generation model is modified or replaced to obtain an optimized character description dataset.

[0066] The optimized character description data set can also be used to construct the character library described in step 102, thereby updating the character library.

[0067] Figure 4 A flowchart of a method for generating character dialogue data provided in some embodiments of this specification. In some embodiments, Figure 4 The method shown can be implemented by a dialogue data generation module 503 in a role-playing dialogue data generation system deployed on a processing device, which specifically includes the following steps.

[0068] Step 401, select a first character and a second character from a character library.

[0069] Two characters are randomly selected from the character library, namely the first character and the second character, thereby obtaining a character description data set of the first character and a character description data set of the second character. In some embodiments of this specification, the character description data set of the first character can be recorded as a, and the character description data set of the second character can be recorded as b.

[0070] In some embodiments, different personalities can be selected from the same personality category in the personality library, and dialogue data between personalities of different personality categories can be generated based on the personality description data sets corresponding to the different personalities, thereby obtaining the first specific role-playing dialogue data. For example, the personalities "Qu Yuan" and "Fan Zhongyan" can be selected from the personality category of historical figures to have a dialogue, and dialogue data can be obtained. In some other embodiments, different personalities can be selected from different personality categories, and dialogue data between personalities of different categories can be generated based on the personality description data sets corresponding to the personalities of different categories, thereby obtaining the second specific role-playing dialogue data. For example, the personality "Qu Yuan" can be selected from the personality category of historical figures, and "Xuanwu" can be selected from the personality category of animated characters, and dialogue data can be obtained based on "Qu Yuan" and "Xuanwu".

[0071] Step 402: Input the first sentence of the first person and the persona description data sets of the first person and the second person into a second language model corresponding to the second person, and obtain the first reply sentence of the second person output by the second language model.

[0072] In some embodiments, the first person setting and the second person setting may correspond to a language model, which may be referred to as a first language model and a second language model, respectively. The first and second language models may be large language models or other types of language models with dialogue capabilities. For example, the first language model and the second language model may be a Mistral chart model, the input of which may be a person setting description data set or a person setting description data set and a dialogue context, and the output is a sentence corresponding to the person setting.

[0073] The first sentence of the first person can be a preset sentence, or a sentence obtained by inputting the persona description dataset of the first person into the first language model. The first sentence generated by the first person (denoted as a1), the persona description dataset of the first person (denoted as a), and the persona description dataset of the second person (denoted as b) are input into the second language model, and the second language model outputs the first reply sentence of the second person, denoted as b1.

[0074] Step 403, input the first reply sentence b1 of the second person, the first sentence a1 of the first person, the person description data set a of the first person, and the person description data set b of the second person into the first language model corresponding to the first person, and obtain the second sentence of the first person output by the first language model. Among them, the first reply sentence b1 of the second person and the first sentence a1 of the first person can be understood as the conversation context between the first person and the second person, and the conversation context and the person description data sets of the first person and the second person (that is, a and b) are input into the first language model together, and the second sentence of the first person output by the first language model is obtained, and the second sentence is recorded as a2.

[0075] Step 404, the second sentence a2 of the first person, the first reply sentence b1 of the second person, the first sentence a1 of the first person, the person description data set a of the first person, and the person description data set b of the second person are input into the second language model to obtain the second reply sentence of the second person. Among them, the second sentence a2 of the first person, the first reply sentence b1 of the second person, and the first sentence a1 of the first person can be understood as the conversation context between the two persons. Further, the conversation context and the person description data sets of the first person and the second person (i.e., a and b) are input into the second language model to obtain the reply sentence b2 of the second person.

[0076] Step 405, and so on, use the first language model and the second language model to alternately output sentences to obtain the dialogue data between the first person setting and the second person setting.

[0077] In some embodiments, the first sentence a1 of the first person and the first reply sentence b1 of the second person can be regarded as the first round of dialogue data, and the second sentence a2 of the first person and the second reply sentence b2 of the second person can be regarded as the second round of dialogue data. The existing dialogue context and person description data set can be alternately input into the corresponding person language model to obtain the corresponding person's sentence, so as to obtain more rounds of dialogue data. Figure 4 The number of rounds of dialogue data obtained by the method shown can be set according to actual needs. For example, the obtained dialogue data can be two-round dialogue data, three-round dialogue data, etc.

[0078] Corresponding to step 401, based on whether the first character and the second character are from the same character category in the character library, the first specific role-playing dialogue data between characters of the same category and the second specific role-playing dialogue data between characters of different categories can be obtained respectively, 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 the role of a specified character to have a dialogue with various other characters, thereby obtaining an optimized role-playing model. The training process of the role-playing model can be described in detail in the following sections. Figure 1 can be found in the relevant instructions, which will not be repeated here.

[0079] Figure 4 The process of generating dialogue data is mainly explained using two human examples. Figure 4 The method flow shown can be used to generate conversation data between three or more characters. As an example, three characters can be selected from the character library, and three language models can be used to alternately process the existing conversation context and the corresponding character description dataset to obtain the corresponding character's utterances, thereby obtaining the conversation data between the three characters. Figure 4 The process of generating the dialogue data between the two characters shown is understood to be a limitation of the embodiments of this specification.

[0080] Figure 5 An exemplary block diagram of a role-playing dialogue data generation system provided in some embodiments of this specification, the system specifically includes the following modules.

[0081] The character output module 501 is used to input multiple character dialogue data into the character generation model, and obtain multiple character description data sets output by the character generation model, wherein the character generation model is obtained by training an initial language model based on character sample features and character sample dialogue data; each of the multiple character dialogue data includes one or more rounds of dialogue data between different characters; and each of the multiple character description data sets includes the character description data of one of the characters participating in the dialogue.

[0082] The character library construction module 502 is used to construct a character library based on multiple character description data sets.

[0083] The dialogue data generation module 503 is used to select different characters from the character library, generate dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then obtain the role-playing dialogue data.

[0084] For more information about each module, see Figure 1 as well as Figure 3~4The relevant description of will not be repeated here. It should be understood that Figure 5 The system and its modules shown 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. Among them, the hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. Those skilled in the art will understand that the above methods and systems can be implemented using computer executable instructions and / or control codes contained in a processor, such as a disk, CD or DVD-ROM, etc., and such codes are provided in a carrier medium or a memory of a programmable device. The system and its modules of this specification can not only be implemented by hardware circuits such as ultra-large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., but can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above hardware circuits and software (e.g., firmware).

[0085] It should be noted that the above description of the system and its modules is only for convenience of description and does not limit the present specification to the scope of the embodiments. It is understandable that for those skilled in the art, after understanding the principle of the system, it is possible to arbitrarily combine the modules without deviating from this principle to form a subsystem connected to other modules. Or split some modules to obtain more modules or multiple units under the module. As an example, in Figure 5 In the system shown, a character description optimization module (not shown in the figure) is added to replace the character library construction module 502 to implement the method flow for optimizing the character description data set. Such variations are all within the scope of the disclosure of this specification.

[0086] The beneficial effects that may be brought about by the embodiments of this specification include but are not limited to: (1) using the character generation model to generate diverse characters; (2) building a character library based on diverse characters, and using the characters in the character library to have conversations, thereby generating fine-grained dialogue data, which is conducive to improving the model performance of the role-playing model; (3) in the process of training the character generation model, using EMD to optimize the training process of the character generation model helps to save the amount of training sample data and improve the model training efficiency; (4) the method for generating role-playing dialogue data provided in some embodiments of this specification can be automatically executed by a computer or other processing equipment, which significantly improves the sample acquisition efficiency. It should be noted that different embodiments may produce different beneficial effects. In different embodiments, the beneficial effects that may be produced may be any one or a combination of the above, or any other possible beneficial effects.

[0087] The basic concepts have been described above. Obviously, for those skilled in the art, the above detailed disclosure is only for example and does not constitute a limitation of this specification. Although not explicitly stated here, those skilled in the art may make various modifications, improvements and corrections to this specification. Such modifications, improvements and corrections are taught in this specification, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of this specification.

Claims

1. A method for generating role-playing dialogue data, characterized in that: The method comprises: Input multiple segments of character dialogue data into a character generation model, and obtain multiple character description data sets output by the character generation model, wherein the character generation model is obtained by training an initial language model with character sample features and character sample dialogue data; each segment of character dialogue data in the multiple segments of character dialogue data includes one or more rounds of dialogue data between different characters; each of the multiple character description data sets includes character description data of one of the characters participating in the dialogue; Building a character library based on the multiple character description data sets; Selecting different characters from the character library, generating dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then obtaining the role-playing dialogue data, which includes: Calculating similarities between different personalities in the personality library based on the personality description data sets corresponding to the different personalities, and classifying the personalities in the personality library based on the similarities to obtain one or more personality categories; Selecting different characters from the same character category, generating dialogue data between the different characters based on character description data sets corresponding to the different characters, and thereby obtaining first specific role-playing dialogue data; Different characters are selected from different character categories, and dialogue data between the different characters are generated based on the character description data sets respectively corresponding to the different characters, so as to obtain second specific role-playing dialogue data.

2. The method for generating role-playing dialogue data according to claim 1, characterized in that: The character generation model is obtained in the following way: Obtaining character sample features and character sample conversation data; Inputting the character sample dialogue data into the initial language model to obtain a character description data set output by the initial language model; The loss value of the persona description data set output by the initial language model and the persona sample features is calculated using EMD, and the model parameters of the initial language model are iteratively updated based on the loss value to obtain the persona generation model.

3. The method for generating role-playing dialogue data according to claim 2, characterized in that: The character sample dialogue data includes dialogue data between more than three characters.

4. The method for generating role-playing dialogue data according to claim 1, characterized in that: The method further comprises: The character dialogue data and the character description data set output by the character generation model are combined and input into a character optimization model to obtain the output of the character optimization model; the character optimization model is obtained by training an initial character optimization model with preset standard sample features and preset standard sample dialogue data; Based on the output, determining an optimized person description data set corresponding to the person description data set output by the person generation model; The constructing of a character library based on multiple character description data sets includes: The optimized character description data set is recorded in the character library.

5. The method for generating role-playing dialogue data according to claim 1, characterized in that: The multiple segments of character dialogue data include one or more rounds of dialogue data between the target character and multiple other characters; The multiple personality description data sets output by the personality generation model include multiple personality description data sets corresponding to the target personality; The method further includes: merging a plurality of personality description data sets corresponding to the target personality to obtain a personality description data set for the target personality.

6. The method for generating role-playing dialogue data according to claim 1, characterized in that: The selecting different personalities from the personality library and generating conversation data between the different personalities based on the personality description data sets corresponding to the different personalities respectively include: Selecting a first persona and a second persona from the persona library; Inputting the first sentence of the first person setting and the person setting description data sets of the first person setting and the second person setting into a second language model corresponding to the second person setting, and obtaining a first reply sentence of the second person setting output by the second language model; Inputting the first reply data 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, and obtaining the second sentence of the first persona output by the first language model; Inputting the second sentence of the first person setting, the first reply sentence of the second person setting, the first sentence of the first person setting, and the person setting description data sets of the first person setting and the second person setting into the second language model to obtain a second reply sentence of the second person setting; The first language model and the second language model are used to alternately output sentences to obtain dialogue data between the first person setting and the second person setting.

7. The method for generating role-playing dialogue data according to claim 6, characterized in that: The role-playing dialogue data is used to train an initial role-playing model to obtain a role-playing model.

8. The method for generating role-playing dialogue data according to claim 7, characterized in that: The method further comprises: 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. A role-playing dialogue data generation system, characterized in that: The system comprises: A persona output module, used to input multiple segments of persona dialogue data into a persona generation model, and obtain multiple persona description data sets output by the persona generation model, wherein the persona generation model is obtained by training an initial language model with persona sample features and persona sample dialogue data; each segment of persona dialogue data in the multiple segments of persona dialogue data includes one or more rounds of dialogue data between different persons; each of the multiple persona description data sets includes persona description data of one of the persons participating in the dialogue; A character library construction module, used to construct a character library based on the multiple character description data sets; A dialogue data generation module is used to select different characters from the character library, generate dialogue data between the different characters based on the character description data sets corresponding to the different characters, and then obtain the role-playing dialogue data, which includes: Calculating similarities between different personalities in the personality library based on the personality description data sets corresponding to the different personalities, and classifying the personalities in the personality library based on the similarities to obtain one or more personality categories; Selecting different characters from the same character category, generating dialogue data between the different characters based on character description data sets corresponding to the different characters, and thereby obtaining first specific role-playing dialogue data; Different characters are selected from different character categories, and dialogue data between the different characters are generated based on the character description data sets respectively corresponding to the different characters, so as to obtain second specific role-playing dialogue data.

10. A computer program product, characterized in that The method comprises computer instructions or a computer program, which can implement the method according to any one of claims 1 to 8 when executed by a processor.