Method and device for assisting user in role playing chat
By training the large language model, it generates a coherent new plot outline, solving the problem of lack of fun and coherence in role-playing chats, and achieving richer and more personalized story development.
Patent Information
- Application Number
- CN202411738941.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-02-21
AI Technical Summary
When users engage in role-playing chat with chatbots, they are often limited to simple Q&A and it is difficult to continue chatting, resulting in lack of fun and coherence in the chat.
By obtaining the plot framework and chat content, sorting it into sample data, and training the large language model can enable it to generate a coherent and logical new plot. Enter the chat records between users and chatbots into the chat model, use the trained large language model to output a new plot outline, promote the development of the story during the chat process, and replace the existing plot.
It realizes a new plot outline that automatically generates a logically coherent in role-playing chat, which improves the fun of the chat and the user's sense of participation, making the story development richer and more personalized.
Smart Images

Figure CN119494407A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for assisting users in role-playing chat. Background Art
[0002] With the rapid development of artificial intelligence technology, especially the significant progress of large language models, chatbots have gradually been able to imitate human conversations more realistically. They can communicate smoothly with users and provide a personalized and natural interactive experience, as if users are really talking to a real person. When users chat or role-play with chatbots, they are often limited to simple questions and answers. Users sometimes don't know how to continue the chat, which makes them confused or lose interest, and role-playing lacks fun. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a method and device for assisting users in role-playing chat.
[0004] In a first aspect, the present application provides a method for assisting a user in role-playing chat, the method comprising:
[0005] Get the plot framework and chat content in each plot chapter;
[0006] Using preset guidance information to organize the plot framework and the chat content into sample data;
[0007] Using the sample data to train a large language model, so that the large language model can learn to generate a coherent and logical new plot;
[0008] Inputting chat records of a user and at least one chat robot role-playing into a chat model, and obtaining a new plot outline output by the chat model using a trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process;
[0009] The new plot outline is used to replace the existing plot in the chat model, so that users can have a conversation based on the latest plot.
[0010] Optionally, after the chat records of the user and at least one chat robot role-playing are input into the chat model, the method further includes:
[0011] Obtaining a current plot summary output by the chat model, wherein the current plot summary is generated based on the existing plot and the chat record, and the current plot summary is used to indicate events that have occurred and the current status of the characters;
[0012] The current plot summary and the new plot outline are used to replace the existing plot in the chat model, so that the user retains the memory of the previous plot and conducts a conversation based on the latest plot.
[0013] Optionally, obtaining the plot framework and chat content in each plot chapter includes:
[0014] Acquire a plot framework including a plurality of plot chapters, wherein the plot nodes in the plot chapters conform to the character settings and story background in the plot framework;
[0015] The plot nodes of the plot chapters are expanded to generate chat content between multiple characters, wherein the chat content of each plot chapter is associated with the plot nodes of the next plot chapter.
[0016] Optionally, using preset guidance information to organize the plot framework and the chat content into sample data includes:
[0017] Determine preset guidance information, wherein the guidance information includes task information, role settings, original plot, chat history, output requirements and output format;
[0018] The task information is used to instruct to generate an original plot summary and a new plot according to the role setting, the original plot and the chat history; the output format includes outputting the original plot summary and the title, content and opening remarks of the new plot; the output requirement is used to output the original plot summary and the new plot according to the output format;
[0019] The plot framework and the chat content are sorted to generate sample data that meets the guidance information.
[0020] Optionally, using the sample data to train a large language model so that the large language model can learn to generate a coherent and logical new plot includes:
[0021] Using the sample data to train a large language model to obtain a new plot output by the large language model;
[0022] Using a text coherence scoring tool to evaluate the coherence and logic between the output new plot and the original plot of the sample data, and determine a correlation score;
[0023] If the correlation score is less than a set threshold, the model parameters in the large language model are adjusted until the correlation score is greater than or equal to the set threshold.
[0024] Optionally, the chat records of the user and at least one chat robot role-playing are input into the chat model, and a new plot outline output by the chat model using the trained large language model is obtained, including:
[0025] When a user role-plays with at least one chatbot, the conversation content of each round of conversation is recorded;
[0026] When the number of dialogue turns is detected or the user triggers the next plot outline, the dialogue content is input into the chat model;
[0027] Obtain a new plot outline output by the chat model using the trained large language model, wherein the new plot outline includes a title and content of the new plot.
[0028] Optionally, each plot chapter in the original plot includes a plot conflict, and the plot conflict in the generated new plot outline is different from the plot conflict in the original plot.
[0029] In a second aspect, the present application provides a device for assisting a user in role-playing chat, the device comprising:
[0030] The acquisition module is used to obtain the plot framework and the chat content in each plot chapter;
[0031] A sorting module, used to sort the plot framework and the chat content into sample data using preset guidance information;
[0032] A training module, used to train the large language model using the sample data, so that the large language model can learn to generate a coherent and logical new plot;
[0033] An input-output module, used to input chat records of a user and at least one chat robot role-playing into a chat model, and obtain a new plot outline output by the chat model using a trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process;
[0034] The replacement module is used to replace the existing plot in the chat model with the new plot outline, so that users can have a conversation based on the latest plot.
[0035] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0036] Memory, used to store computer programs;
[0037] The processor is used to implement any of the steps of the method for assisting users in role-playing chat when executing the program stored in the memory.
[0038] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the steps of the method for assisting users in role-playing chat is implemented.
[0039] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: by constructing the initial plot framework and chat content, sample data is generated based on these data to train the large language model, so that the large language model learns to generate a logically coherent new plot, and then the trained large language model is applied in the chat model, so that when the user and the chat robot chat through the chat model, the chat model can predict the new plot outline, and the chat model displays the new plot outline, so that the user can interact based on the latest plot in the new plot outline. By automatically generating a new plot outline that is coherent with the aforementioned plot, the user can refer to the new plot outline to guide subsequent chat dialogues, thereby increasing the fun of chatting during role-playing. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A schematic diagram of the hardware environment of a method for assisting users in role-playing chat provided by an embodiment of the present application;
[0043] Figure 2 A flow chart of a method for assisting users in role-playing chat provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of guidance information provided for an embodiment of the present application;
[0045] Figure 4 An overall flow chart of assisting users in role-playing chat provided in an embodiment of the present application;
[0046] Figure 5 A schematic diagram of the structure of a device for assisting users in role-playing chat provided in an embodiment of the present application;
[0047] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0049] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0050] In order to solve the problems mentioned in the background technology, according to one aspect of the embodiments of the present application, an embodiment of a method for assisting users in role-playing chat is provided.
[0051] In the embodiment of the present application, the method for assisting users in role-playing chat can be applied to the following: Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1 As shown, the server 103 is connected to the terminal 101 through a network. The user plays a role and inputs the voice or text of the role through the terminal. The server integrates a chat tool person, a chat model and a large language model. The chat robot plays the role and chats with the user through the chat model. The chat model combines the ability of the large language model to provide a new plot outline based on the user's input and the chat robot's reply. A database 105 can be set on the server or independently of the server to store existing plots and chat records for the chat model. The above network includes but is not limited to: a wide area network, a metropolitan area network or a local area network. The terminal 101 includes but is not limited to a PC, a mobile phone, a tablet computer, etc.
[0052] Large language model: As a core technology, it provides powerful natural language processing capabilities and is responsible for generating coherent and logical new plots.
[0053] Chat model: It is a specific application form of the large language model. It combines the capabilities of the large language model and is specifically used to handle role-playing chat scenarios to generate current plot summaries and new plot outlines.
[0054] Chatbot: Interacts with users through a chat model, plays a specific role, and promotes the development of the story. Chatbots can not only generate dialogues, but also dynamically adjust the plot direction based on user choices.
[0055] The embodiment of the present application provides a method for assisting users in role-playing chat, which can be applied to a server. The following will be combined with a specific implementation method to provide a method for assisting users in role-playing chat provided by the embodiment of the present application in detail. Figure 2 As shown, the specific steps are as follows:
[0056] Step 201: Obtain the plot framework and chat content in each plot chapter;
[0057] Step 202: using preset guidance information to organize the plot framework and chat content into sample data;
[0058] Step 203: Using sample data to train the large language model so that the large language model can learn to generate a coherent and logical new plot;
[0059] Step 204: inputting chat records of the user and at least one chat robot role-playing into the chat model, and obtaining a new plot outline output by the chat model using the trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process;
[0060] Step 205: Use the new plot outline to replace the existing plot in the chat model, so that users can have a conversation based on the latest plot.
[0061] This application can be applied to a variety of scenarios, such as: 1. Online games: Chatbots act as NPCs (non-player characters) in games, advancing the plot through dialogue and increasing the immersion of the game. 2. Social platforms: Create virtual characters in social applications to have emotional conversations with users and enhance social interactivity. 3. Creative writing assistance: Writers play the roles in the script and have conversations, which can provide writers with creative inspiration and assist in building storylines and character development.
[0062] In this application, the server obtains a plot framework that is manually written or generated by a large language model. The plot framework includes character settings, background information, plot trends, and multiple plot chapters. In addition, the corresponding chat content is generated according to the plot of each plot chapter. Then, according to the preset guidance information (such as output requirements and output format, etc.), the plot framework and chat content are sorted to form structured sample data. The sorted sample data is used to fine-tune or fully supervise the large language model. The training goal is to enable the large language model to generate new, coherent and logical plot content based on the existing plot and dialogue history. After the large language model training is completed, the large language model is applied to the chat model, so that the chat model has the function of the large language model.
[0063] When a user has a conversation with a chatbot via voice or text, the latest conversation record will be input into the chat model. The chat model uses the trained large language model to process these conversation records and generate a new plot outline to promote the development of the story. The user and the chatbot can continue the subsequent chat based on the new plot outline. As the chat progresses, the chat model can replace the existing plot in the chat model with the new plot outline, so that when the user continues to interact with the chatbot, he can interact based on the latest plot in the new plot outline, ensuring the continuity of the story and the consistency of the user experience.
[0064] This application constructs an initial plot framework and chat content, generates sample data based on these data to train a large language model, so that the large language model learns to generate a logically coherent new plot, and then applies the trained large language model in the chat model, so that when the user and the chat robot chat through the chat model, the chat model can predict the new plot outline, and the chat model displays the new plot outline, so that the user can interact based on the latest plot in the new plot outline. By automatically generating a new plot outline that is coherent with the aforementioned plot, users can refer to the new plot outline to guide subsequent chat conversations, thereby increasing the fun of chatting during role-playing.
[0065] As an optional implementation, after the chat records of the user and at least one chat robot role-playing are input into the chat model, the method also includes: obtaining a current plot summary output by the chat model, wherein the current plot summary is generated based on the existing plot and chat records, and the current plot summary is used to indicate events that have occurred and the current status of the characters; using the current plot summary and the new plot outline to replace the existing plot in the chat model, so that the user retains the memory of the previous plot and conducts the conversation based on the latest plot.
[0066] In this application, after the chat model obtains the chat records of the user and other characters, it generates a current plot summary by summarizing the original existing plots and chat dialogue records. As the chat continues to advance, the chat model can replace the existing plots in the chat model with the current plot summary and the new plot outline. In this way, when the user continues to interact with the chat robot, he can retain his memory of the previous plot based on the current plot summary and interact based on the latest plot in the new plot outline, ensuring the continuity of the story and the consistency of the user experience.
[0067] Optionally, each plot chapter in the original plot includes a plot conflict, and the plot conflict in the generated new plot outline is different from the plot conflict in the original plot.
[0068] Each plot chapter in the original plot contains a specific plot conflict, which is a key factor in driving the development of the story and can also enhance the drama of the story. When generating a new plot outline, the system will design new plot conflicts to ensure that these new conflicts are different from the conflicts in the original plot. Although the new conflicts are different from the original conflicts, they still need to be logically consistent with the existing plots and chat records. Based on the user's interaction and choice, the system will dynamically adjust the conflict points in the new plot outline to make it more in line with the current story development. This application makes the story richer and more diverse by introducing new plot conflicts. The new conflict points can stimulate the interest of users and increase their participation and involvement.
[0069] As an optional implementation method, in step 201, obtaining the plot framework and the chat content in each plot chapter includes: obtaining a plot framework containing multiple plot chapters, wherein the plot nodes in the plot chapters conform to the character settings and story background in the plot framework; expanding the plot nodes of the plot chapters to generate chat content between multiple characters, wherein the chat content of each plot chapter is associated with the plot nodes of the next plot chapter.
[0070] Define core elements: determine the role setting and story background. You can collect the role's personality information based on querying the website and the film and television drama information on the site, including the role's name, gender, age, occupation, personality, hobbies, character relationships and background information;
[0071] Design plot nodes: Plan the main plot chapters, each of which includes at least one key event or turning point.
[0072] Plot chapter expansion: Generate a detailed description of each plot chapter as chat content, including environment description, character interaction and dialogue content, etc. At the same time, ensure that the detailed description is related to the next plot node, ensure that there is a logical connection between the plot nodes, and form a coherent story line.
[0073] This application expands the detailed plot nodes to generate richer and more diverse chat content, making the storyline fuller and more vivid; the chat content of each plot chapter can naturally transition to the next plot node, maintaining the overall coherence of the story, which can improve the accuracy of subsequent large language model training.
[0074] As an optional implementation method, in step 202, using preset guidance information to organize the plot framework and chat content into sample data includes: determining preset guidance information, wherein the guidance information includes task information, role settings, original plot, chat history, output requirements and output format; the task information is used to instruct the generation of an original plot summary and a new plot based on the role settings, the original plot and the chat history; the output format includes outputting the original plot summary and the title, content and opening remarks of the new plot; the output requirements are used to output the original plot summary and the new plot according to the output format; and the plot framework and chat content are organized to generate sample data that meets the guidance information.
[0075] The system can also generate an information summary based on each plot chapter and the corresponding chat content. The information summary serves as the memory information of the previous scene and can record the status of the current plot. The information summary can be a summary of a single plot chapter or a summary of all plot chapters, which is not limited in the embodiments of the present application.
[0076] The system organizes and cleans the plot framework, chat content, and information summary, removes content with a plot relevance less than the set relevance threshold, and retains high-quality plot-related data by removing irrelevant content. Then, the system organizes the high-quality plot-related data into the following format according to the guidance information: Figure 3 in the format.
[0077] Figure 3 This is a schematic diagram of the guidance information. It can be seen that the guidance information includes task information, role settings, original plot, chat history, output requirements and output format. The following is a detailed description of this information.
[0078] Task information: Instructs to generate the original plot summary and new plot based on the role settings, original plot and chat history.
[0079] Role setting: Provide detailed information about the role, such as name, gender, age, occupation, personality traits, hobbies, character relationships, etc.
[0080] Original Plot: Provides background information, major events, and the current status of the plot.
[0081] Chat history: Records the conversations between users and chatbots to ensure that the chat model can understand previous interactions.
[0082] Output requirements: The output should include a summary of the original plot and the title, content and opening remarks of the new plot.
[0083] Output format: Define the specific format of the output to ensure that the generated content is clearly structured and easy to process.
[0084] The server organizes the plot framework and chat content into structured sample data in accordance with the style of the above guidance information. These data should meet the requirements of the guidance information to facilitate subsequent large language model training.
[0085] Exemplarily, structured sample data generated based on the plot framework and chat content is as follows.
[0086] #Character
[0087] [Name]
[0088] Old Tang
[0089] [gender]
[0090] male
[0091] [age] 35
[0093] [Profession]
[0094] Team Leader
[0095] [World View]
[0096] AA City is a city where evil forces are rampant. The anti-fraud operation in AA City has begun. Many officials in the city have been investigated and dismissed. Criminal gangs use the Internet to commit crimes. The identity of the gang leader is mysterious and belongs to a high-IQ gang.
[0097] [Hobby]
[0098] Read detective novels
[0099] fitness
[0100] [Character Relationship]
[0101] Xiaolin, the victim girl, was the informant received by Lao Tang. Her report helped Lao Tang find a breakthrough in cracking down on the criminal gang.
[0102] A member of the brigade and Lao Tang's subordinate, he has been following Lao Tang to investigate and crack down on criminal gangs.
[0103] [Personality traits]
[0104] Upright and unyielding
[0105] [habit action]
[0106] Touch the badge
[0107] Adjust the hat
[0108] ##Original plot
[0109] From Xiaolin, you learned that this gang used the Internet to commit fraud, and she was one of the victims. Lao Tang comforted her and said that he would bring the suspect to justice as soon as possible, and told you to send Xiaolin home first, and he stayed to investigate the scene.
[0110] After sending Xiaolin home, you immediately rushed back to the warehouse, only to find Lao Tang lying in a pool of blood! You quickly went forward to check, fortunately only his arm was scratched. Lao Tang gritted his teeth and said: "Xiao Chen, those bastards actually installed a time bomb in the warehouse, fortunately I discovered it in time..."
[0111] You helped Lao Tang up, still feeling frightened. After returning to the brigade, Lao Tang immediately deployed operations, demanding an intensified search, vowing to catch the gang in one fell swoop.
[0112] ##Conversation content
[0113] Narrator: As night falls, the office of the brigade is brightly lit, and the atmosphere of tension and busyness permeates every corner. Old Tang's eyes are like sharp blades, scanning the information on the computer screen again and again.
[0114] Role: (Old Tang suddenly looked up, with an unyielding light in his eyes) Xiao Chen, are you okay with what happened just now?
[0115] Player: (shaking his head gently, with a firm look in his eyes) Captain, I'm fine. We must catch these people.
[0116] Character: (Old Tang nods, his tone firm) Yes, we can't let them continue to do evil. We already have some clues that need further confirmation.
[0117] Narrator: You noticed that the gauze bandage on Old Tang's arm was bleeding slightly, but he seemed to feel nothing and was still concentrating on his work.
[0118] Player: (with a concerned look) Captain, your wound is still bleeding and needs further treatment.
[0119] Character: (Waving his hand nonchalantly) No problem, what we need to do now is to analyze these clues. I suspect there is a mole in the gang.
[0120] Narrator: You feel the heaviness in Lao Tang's words. This battle is not only against crime, but also possible betrayal.
[0121] Player: (frown, firm tone) Captain, we must find the traitor and bring justice to Xiaolin and all the victims.
[0122] Role: (Old Tang stands up and walks out of the office) Come with me, I have a new task to assign.
[0123] Narrator: In the conference room, Old Tang stood in front of the whiteboard, his pen quickly moving across various photos and clues, connecting possible relationships.
[0124] Role: (Old Tang points to a blurry surveillance screenshot) Here, although this person’s face is not clear, I think he is the key.
[0125] Player: (staring at the screenshot, trying to make sense) Captain, how do we find him?
[0126] Role: (Serious expression, chin slightly raised) I plan to lead the team myself, Xiao Chen, I need your calmness and wit.
[0127] Narrator: You are fully aware of the importance of this operation, and you also understand the trust that Lao Tang has in you. You have been preparing for this moment for so long.
[0128] Player: (With his hands clenched, his expression firm) Captain, just give me the orders, I will never let you down.
[0129] Role: (Old Tang smiled slightly, his shoulders relaxed) Well, then use your courage and wisdom. Take action tomorrow and have a good rest tonight.
[0130] Narrator: The night deepened, and the lights in the office finally went out. Tomorrow's battle was approaching, and the power of justice gathered in the darkness.
[0131] Player: (Praying silently in his heart with a determined expression on his face) No matter what happens tomorrow, we will face it.
[0132] Role: (Old Tang adjusts his police hat, his eyes are sharp) Xiao Chen, tomorrow we are going to uncover the true face of this gang. Are you ready?
[0133] Player: (nods seriously) Captain, always be prepared.
[0134] Character: (with a determined look) Okay, we will not let the evil forces go unpunished. Tomorrow is the moment of the decisive battle.
[0135] ##Original plot summary
[0136] After discovering that the gang had set up a bomb, you and Lao Tang vowed to intensify the search, ready to uncover the mole and capture the criminal.
[0137] ##Generate a new plot
[0138] title:
[0139] Expose online fraud gangs.
[0140] content:
[0141] After days of investigation and tracking, the brigade finally determined the identity and hiding place of the gang leader. Lao Tang decided to lead the team to capture the suspect. On the day of the operation, you followed Lao Tang to a hidden villa. Lao Tang winked at you and signaled you to break in through the back door. You held your breath and sneaked into the house quietly. At this moment, a cold and hard voice sounded behind you: "Comrade police, welcome to my humble home!" You looked back and saw that the gang leader was pointing a gun at you with a creepy smile on his face. At the critical moment, Lao Tang broke in through the window and kicked the gun out of the gangster's hand! You took the opportunity to push the gangster to the ground and put handcuffs on him.
[0142] Opening remarks:
[0143] Narrator: As night falls, the moonlight shines on a hidden villa, making it seem particularly quiet. Old Tang stands outside the villa with a determined look. He winks at you, signaling you to enter through the back door. You have been preparing for a long time, and today you are finally going to uncover the true face of this criminal gang.
[0144] Character (Old Tang): (in a low but firm voice) Xiao Chen, get ready, we'll act according to the plan. I'll go in from the front, and you'll break in from the back door, so be careful.
[0145] Player: (Nods and takes a deep breath) Captain, don't worry, I will be careful.
[0146] Narrator: You hold your breath and quietly go to the back door of the villa. It's so quiet that you can only hear your own heartbeat. You gently push the door open and sneak into the house carefully. Suddenly, a cold and hard voice sounds behind you...
[0147] Character (Gang Leader): (Sneering) Police comrade, welcome to my humble abode!
[0148] Narrator: You turned around suddenly and saw the gang leader pointing a gun at you with a creepy smile on his face. At this moment, the window was suddenly smashed open and Lao Tang rushed in like a tiger descending from the mountain...
[0149] As an optional implementation, in step 203, the large language model is trained with sample data so that the large language model can learn to generate a coherent and logical new plot, including: training the large language model with sample data to obtain a new plot output by the large language model; using a text coherence scoring tool to evaluate the coherence and logic between the output new plot and the original plot of the sample data, and determining a correlation score; if the correlation score is less than a set threshold, adjusting the model parameters in the large language model until the correlation score is greater than or equal to the set threshold.
[0150] The server uses the sorted sample data to fine-tune or fully supervise the large language model. The training goal is to enable the large language model to generate new, coherent and logical plot content based on the existing plot and dialogue history, so the loss function is the cross-entropy loss function. After the training is completed, the large language model is used to generate new plot content. These new plots should include titles, detailed content, and opening remarks. Then, the text coherence scoring tool is used to evaluate the coherence and logic between the generated new plot and the original plot in the sample data. According to the evaluation results, the correlation score between the generated new plot and the original plot is determined. If the correlation score is lower than the set threshold, the hyperparameters of the large language model (such as learning rate, number of layers, number of hidden units, etc.) are adjusted, the model is retrained, and the above process is repeated until the correlation score of the generated new plot reaches or exceeds the set threshold, and a trained large language model is obtained.
[0151] The text coherence scoring tool may be BLEU (Bilingual Evaluation Understudy) or ROUGE (Recall-Oriented Understudy for Gisting Evaluation). The present application does not impose any specific restrictions on the type of scoring tool.
[0152] This application ensures that the generated new plots meet high standards in coherence and logic through continuous evaluation and adjustment, so that the large language model can better understand and generate new plots that conform to the character settings and story background. The new plot outline output by the subsequent chat model is also consistent with the existing plot to avoid logical contradictions or incoherence.
[0153] As an optional implementation, in step 204, the chat records of the user and at least one chat robot role-playing are input into the chat model, and the new plot outline output by the chat model using the trained large language model is obtained, including: when the user and at least one chat robot role-play, the conversation content of each round of conversation is recorded; when the number of conversation rounds is detected or it is detected that the user triggers the next plot outline, the conversation content is input into the chat model; and the new plot outline output by the chat model using the trained large language model is obtained, wherein the new plot outline includes the title and content of the new plot.
[0154] During the role-playing process between the user and the chatbot, the server will record the content of each round of dialogue in real time. These conversations include the user's input and the chatbot's response. The server stores the recorded conversation content in a structured database for subsequent processing and analysis. The server monitors the number of conversation rounds or the user's behavior. When the preset number of conversation rounds (such as 10 rounds) is reached or the user explicitly triggers the next plot outline (such as the user enters specific keywords or selects specific options), the system will input the accumulated conversation content into the chat model. The chat model uses the trained large language model to generate a new plot outline, including the title and content of the new plot, to promote the development of the story. At the same time, a summary of the current plot can also be generated based on the input conversation content, including events that have occurred and the current status of the characters.
[0155] In this application, the server dynamically adjusts the plot development according to the number of dialogue rounds or user behavior to make the story more flexible and personalized; generates personalized plots based on user interactions and choices, rather than traditional fixed plot outlines. The dynamically generated plot summaries and new plot outlines enable users to continue to immerse themselves in the story, increase the fun of role-playing chats, and enhance users' sense of participation and immersion.
[0156] As an optional implementation method, the method also includes: using a memory mechanism to track chat records and existing plots, wherein the memory mechanism is used to avoid conflicts between the new plot outline and the chat records and the existing plot, and adjust the new plot outline according to the chat records.
[0157] The chat model stores all chat records and existing plots in a structured database to ensure the integrity and accessibility of the data, and then uses context management techniques (such as attention mechanisms, memory networks, etc.) to track and manage these data to ensure that the system can understand the current conversation context. When generating a new plot outline, the system will check for potential conflicts between the new plot and the existing plots and chat records, and make corresponding adjustments. It can also dynamically adjust the content of the new plot outline based on the latest chat records to ensure that it is consistent with the user's interactions and choices.
[0158] This application uses a memory mechanism to ensure that the newly generated plot is consistent with the existing plot and chat records, avoiding logical contradictions and incoherence. Users can get a coherent and logically rigorous story experience, enhancing immersion and participation.
[0159] This application provides a method flow chart for assisting users in role-playing chat, such as Figure 4 As shown, the following steps are included:
[0160] 1. Construct the plot framework.
[0161] 1) Define the core elements.
[0162] Define the core elements. Determine the main characters in the story and their detailed information, including the character's name, gender, age, occupation, personality traits, hobbies, relationships, and background information. Character setting is the basis for building the plot. Ensure that each character has a distinct personality and motivation to make the story more vivid and real. Define the time, place, social environment, and related background information of the story.
[0163] 2) Design plot nodes.
[0164] According to the overall structure of the story, the main plot chapters are planned. Each chapter contains at least one key event or turning point, which is the driving force behind the development of the story. Whether it is manually written or generated using a large language model, it is necessary to ensure that each plot chapter conforms to the defined character settings and story background. This helps to maintain the consistency and coherence of the story.
[0165] 2. Plot chapter expansion.
[0166] Generate a detailed description of each plot chapter as chat content, including environment description, character interaction, dialogue content, etc. At the same time, ensure that the chat content of a plot chapter is related to the plot nodes of the next plot chapter, and ensure that there is a logical connection between the plot nodes to form a coherent story line.
[0167] 3. Information summary.
[0168] Summarize each plot chapter and the generated chat content as the memory information of the previous scene, ensure that the system can understand the current plot progress and provide contextual support for the development of subsequent plots.
[0169] 4. Data preprocessing.
[0170] 1) Data cleaning: remove irrelevant plots and dialogues, retain useful data, and ensure data quality and consistency.
[0171] 2) Format conversion: convert the above data into a format according to the style of the guidance information.
[0172] 3) Encoding: Use tokenizer to encode the text and generate sample data.
[0173] 5. Model training.
[0174] Based on the open source language model as the basic model, the preprocessed data is used for fine-tuning or full-scale supervised training. The training goal is to ensure that the new plot output is consistent and logical with the original plot of the sample data.
[0175] 6. Assisted chat.
[0176] 1) Recording conversation content: When a user has a role-playing chat with one or more characters in a specific plot, the system will record the content of each conversation in real time, including user input and character responses. When a certain number of rounds is reached or the user triggers the generation of the next plot outline, the system will input the above conversation content into the chat model.
[0177] 2) Model output content: The chat model outputs the current plot summary and the new plot outline. The new plot outline includes the title and content of the new plot. The new plot outline should be consistent with the existing plot and introduce new conflict points.
[0178] 3) Replace the original plot: Replace the existing plot in the chat model with the generated original plot summary and new plot outline, so that users can have conversations based on the latest plot during role-playing chats.
[0179] This application can achieve the following effects:
[0180] 1. Enhance the appeal of the story: Through detailed plot node expansion and diversified new plot conflicts, the story is made richer and more diverse, which enhances the appeal and fun of the story.
[0181] 2. Improved user experience: Through the memory mechanism and dynamically updated plot, users can get a coherent and logically rigorous story experience, enhancing immersion and satisfaction.
[0182] 3. Personalized experience: Dynamically adjust the plot based on user interactions and choices, provide a highly customized experience, and increase user participation and sense of involvement.
[0183] 4. Continuous appeal: By constantly introducing new points of conflict, stories can continue to attract users and prolong their engagement time.
[0184] The present application provides a device to assist users in role-playing chat, such as Figure 5 As shown, the device comprises:
[0185] The acquisition module 501 is used to acquire the plot framework and the chat content in each plot chapter;
[0186] Arrangement module 502, used to arrange the plot framework and chat content into sample data using preset guidance information;
[0187] A training module 503 is used to train the large language model using sample data so that the large language model can learn to generate a coherent and logical new plot;
[0188] An input-output module 504 is used to input the chat records of the user and at least one chat robot role-playing into the chat model, and obtain a new plot outline output by the chat model using the trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process;
[0189] The replacement module 505 is used to replace the existing plot in the chat model with a new plot outline, so that users can have a conversation based on the latest plot.
[0190] Optionally, the device is also used for:
[0191] Obtaining the current plot summary output by the chat model, wherein the current plot summary is generated based on the existing plot and chat records, and is used to indicate the events that have occurred and the current status of the characters;
[0192] The existing plot in the chat model is replaced with the current plot summary and the new plot outline, so that users can retain their memory of the previous plot and have a conversation based on the latest plot.
[0193] Optionally, the acquisition module 501 is used to:
[0194] Obtaining a plot framework including multiple plot chapters, wherein the plot nodes in the plot chapters conform to the character settings and story background in the plot framework;
[0195] The plot nodes of the plot chapters are expanded to generate chat contents between multiple characters, wherein the chat contents of each plot chapter are associated with the plot nodes of the next plot chapter.
[0196] Optionally, the sorting module 502 is used to:
[0197] Determine preset guidance information, wherein the guidance information includes task information, role settings, original plot, chat history, output requirements and output format;
[0198] The task information is used to instruct to generate the original plot summary and the new plot according to the role setting, the original plot and the chat history; the output format includes outputting the original plot summary and the title, content and opening remarks of the new plot; the output requirement is used to output the original plot summary and the new plot according to the output format;
[0199] Organize the plot framework and chat content to generate sample data that meets the guidance information.
[0200] Optionally, the training module 503 is used to:
[0201] Use sample data to train the large language model and obtain new plots output by the large language model;
[0202] Use the text coherence scoring tool to evaluate the coherence and logic between the output new plot and the original plot of the sample data, and determine the correlation score;
[0203] If the correlation score is less than the set threshold, the model parameters in the large language model are adjusted until the correlation score is greater than or equal to the set threshold.
[0204] Optionally, the input-output module 504 is used to:
[0205] When a user role-plays with at least one chatbot, the conversation content of each round of conversation is recorded;
[0206] When the number of conversation turns is detected or the user triggers the next plot outline, the conversation content is input into the chat model;
[0207] Obtain a new plot outline output by the chat model using the trained large language model, where the new plot outline includes the title and content of the new plot.
[0208] Optionally, the apparatus is further configured to: each plot chapter in the original plot includes a plot conflict, and the plot conflict in the generated new plot outline is different from the plot conflict in the original plot.
[0209] Based on the same technical concept, an embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0210] Memory 603, used for storing computer programs;
[0211] The processor 601 is used to implement the above steps when executing the program stored in the memory 603.
[0212] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0213] The communication interface is used for communication between the above electronic device and other devices.
[0214] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0215] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0216] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0217] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes any one of the methods in the above embodiments.
[0218] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0219] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0220] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for assisting users in role-playing chat, characterized in that: The method comprises: Get the plot framework and chat content in each plot chapter; Using preset guidance information to organize the plot framework and the chat content into sample data; Using the sample data to train a large language model, so that the large language model can learn to generate a coherent and logical new plot; Inputting chat records of a user and at least one chat robot role-playing into a chat model, and obtaining a new plot outline output by the chat model using a trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process; The new plot outline is used to replace the existing plot in the chat model, so that users can have a conversation based on the latest plot.
2. The method according to claim 1, characterized in that: After inputting the chat records of the user and at least one chat robot role-playing into the chat model, the method further includes: Obtaining a current plot summary output by the chat model, wherein the current plot summary is generated based on the existing plot and the chat record, and the current plot summary is used to indicate events that have occurred and the current status of the characters; The current plot summary and the new plot outline are used to replace the existing plot in the chat model, so that the user retains the memory of the previous plot and conducts a conversation based on the latest plot.
3. The method according to claim 1, characterized in that: Get the plot framework and chat content in each plot chapter including: Acquire a plot framework including a plurality of plot chapters, wherein the plot nodes in the plot chapters conform to the character settings and story background in the plot framework; The plot nodes of the plot chapters are expanded to generate chat content between multiple characters, wherein the chat content of each plot chapter is associated with the plot nodes of the next plot chapter.
4. The method according to claim 2, characterized in that: Using preset guidance information to organize the plot framework and the chat content into sample data includes: Determine preset guidance information, wherein the guidance information includes task information, role settings, original plot, chat history, output requirements and output format; The task information is used to instruct to generate an original plot summary and a new plot according to the role setting, the original plot and the chat history; the output format includes outputting the original plot summary and the title, content and opening remarks of the new plot; the output requirement is used to output the original plot summary and the new plot according to the output format; The plot framework and the chat content are sorted to generate sample data that meets the guidance information.
5. The method according to claim 1, characterized in that The sample data is used to train the large language model so that the large language model can learn to generate a coherent and logical new plot, including: Using the sample data to train a large language model to obtain a new plot output by the large language model; Using a text coherence scoring tool to evaluate the coherence and logic between the output new plot and the original plot of the sample data, and determine a correlation score; If the correlation score is less than a set threshold, the model parameters in the large language model are adjusted until the correlation score is greater than or equal to the set threshold.
6. The method according to claim 1, characterized in that Inputting chat records of a user and at least one chat robot role-playing into a chat model, and obtaining a new plot outline output by the chat model using the trained large language model includes: When a user role-plays with at least one chatbot, the conversation content of each round of conversation is recorded; When the number of dialogue turns is detected or the user triggers the next plot outline, the dialogue content is input into the chat model; Obtain a new plot outline output by the chat model using the trained large language model, wherein the new plot outline includes a title and content of the new plot.
7. The method according to claim 5, characterized in that Each plot chapter in the original plot includes a plot conflict, and the plot conflict in the generated new plot outline is different from the plot conflict in the original plot.
8. A device for assisting users in role-playing chat, characterized in that: The device comprises: The acquisition module is used to obtain the plot framework and the chat content in each plot chapter; A sorting module, used to sort the plot framework and the chat content into sample data using preset guidance information; A training module, used to train the large language model using the sample data, so that the large language model can learn to generate a coherent and logical new plot; An input-output module, used to input chat records of a user and at least one chat robot role-playing into a chat model, and obtain a new plot outline output by the chat model using a trained large language model, wherein the new plot outline is used to promote the development of the story during the chat process; The replacement module is used to replace the existing plot in the chat model with the new plot outline, so that users can have a conversation based on the latest plot.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Stroma generation method, device and equipment of small theater intelligent machine, medium and product
CN120181083A
Live broadcast interaction method and device of live broadcast room, live broadcast system, electronic equipment and medium
CN120856942A
Large language model role interaction system based on plot driving and tool calling
CN121598807A