Conversation generation method and device, computer equipment, storage medium and program product

By deconstructing the role description information of digital humans into target persona feature phrases, and combining dialogue scene matching and historical dialogue content, the problem of persona drift and forgetting in long-range dialogues of large language models is solved, and the consistency of role features in dialogue is achieved.

CN121503454APending Publication Date: 2026-02-10GUANGZHOU QUWAN NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511656282.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Large language models are prone to character setting deviation (character drift) and forgetting of early content (character collapse) in long-range dialogues, leading to dialogue inconsistency.

Method used

By deconstructing the character description information of digital humans into multiple target persona feature words, combining them into feature word groups according to the degree of semantic association, and matching them with a preset dialogue scenario library, feature word groups are selected based on the current scenario and historical dialogue content when generating dialogues to ensure the consistency of character features.

Benefits of technology

Maintain micro and macro consistency of character traits in long conversations, avoid character drift and forgetting, and ensure the coherence and authenticity of the dialogue.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121503454A_ABST
    Figure CN121503454A_ABST
Patent Text Reader

Abstract

The invention relates to a dialogue generation method and device, computer equipment, a storage medium and a program product, and the method comprises the steps: obtaining a plurality of target person feature words corresponding to the role description information of a digital person according to a preset person feature word library; combining the feature words set by each target person to obtain a plurality of feature word groups; matching the plurality of feature phrases with a preset dialogue scene library to determine a feature phrase set; under the condition that the current output dialogue is the first section dialogue, determining a first feature phrase; generating a current output dialogue based on the first feature phrase through a dialogue generation model; under the condition that the current output dialogue is any non-first-section dialogue, determining a second feature word group; and through the dialogue generation model, based on the second feature phrase and the output dialogue before the current output dialogue, the consistency of long-range dialogue role features is maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of artificial intelligence technology and data science technology, and in particular to a dialogue generation method, apparatus, computer device, computer-readable storage medium and computer program product. Background Technology

[0002] With the rapid development of Large Language Models (LLM) capabilities, their applications in the field of natural language processing are becoming increasingly widespread, especially in building interactive, anthropomorphic intelligent agents, such as chatbots, virtual companions, and game NPCs (non-player characters). In these applications, to provide an immersive and believable experience, Large Language Models not only need to understand and generate fluent language, but more importantly, they need to maintain a stable and consistent role identity throughout a long, multi-turn dialogue.

[0003] Current dialogue generation methods based on large language models typically involve providing a set of prompts for a character and then instructing the large language model to generate dialogue that conforms to those prompts.

[0004] However, as the number of dialogue rounds increases, the large language model can easily deviate from its initial character setting, exhibiting phenomena such as "character drift" and "character collapse." For example, a character initially portrayed as a "concise and succinct ancient general" might start using modern internet slang or become overly talkative after several rounds of dialogue. Furthermore, the large language model can "forget" earlier dialogue content and key character information when processing long dialogues, leading to factual contradictions in responses. For instance, a character might initially claim to be "from the north," but dozens of rounds later say they "have never seen snow." Summary of the Invention

[0005] Therefore, it is necessary to provide a dialogue generation method, apparatus, computer device, computer-readable storage medium, and computer program product that can maintain the consistency of role characteristics in long-range dialogues, in order to address the aforementioned technical problems.

[0006] Firstly, this application provides a dialogue generation method, the method comprising:

[0007] Based on a pre-defined character feature word library, multiple target character feature words corresponding to the role description information of the digital human are obtained; the target character feature words are used to characterize the role features of the digital human; the digital human is a virtual robot used to communicate with users;

[0008] Based on the semantic relevance of each target persona feature word, the feature words of each target persona are combined to obtain multiple feature word groups;

[0009] Multiple feature word groups are matched with multiple dialogue scenarios in a pre-set dialogue scenario library to determine the corresponding set of feature word groups for each dialogue scenario.

[0010] In a case where the current output dialogue is a first dialogue, a first feature word group is determined according to the current dialogue scenario and a feature word group set corresponding to the current dialogue scenario; the current output dialogue is generated by the dialogue generation model based on the first feature word group; the current dialogue scenario is one of a plurality of dialogue scenarios; and the first feature word group is one of the feature word group set corresponding to the current dialogue scenario.

[0011] In a case where the current output dialogue is any dialogue other than the first dialogue, a second feature word group is determined according to the current dialogue scenario, a feature word group set corresponding to the current dialogue scenario, an output dialogue before the current output dialogue output by the dialogue generation model, and a feature word group of the output dialogue before the current output dialogue; the current output dialogue is generated by the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is one of the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue.

[0012] In an embodiment, a plurality of feature word groups are matched with a plurality of dialogue scenarios in a preset dialogue scenario library, and a corresponding feature word group set is determined for each dialogue scenario, including:

[0013] Character-level intersection processing is performed on the character features of each feature word group and each dialogue scenario to obtain an intersection score corresponding to each character feature;

[0014] For each dialogue scenario, a preset number of character features with a high intersection score are determined.

[0015] According to the feature word groups to which the preset number of character features belong, a feature word group set corresponding to the dialogue scenario is determined.

[0016] In an embodiment, the method further includes:

[0017] For each feature word, in a case where the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is less than a preset number threshold, the current feature word is added to a target dialogue scenario until the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is greater than or equal to the preset number threshold.

[0018] The target dialogue scenario is a dialogue scenario in the plurality of dialogue scenarios other than the dialogue scenario corresponding to the feature word group to which the current feature word belongs.

[0019] In an embodiment, the current output dialogue is generated by the dialogue generation model based on the first feature word group, including:

[0020] Obtain user role information and dialogue generation constraint information;

[0021] Generate a first prompt word according to the user role information, the first feature word group, and the dialogue generation constraint information;

[0022] Input the first prompt word into the dialogue generation model to generate the current output dialogue.

[0023] In one of the embodiments, the dialogue generation model generates the current output dialogue based on the second feature word group and the output dialogue before the current output dialogue, including:

[0024] Obtain user role information and dialogue generation constraint information;

[0025] Generate a second prompt word according to the user role information, the second feature word group, the output dialogue before the current output dialogue, and the dialogue generation constraint information;

[0026] Input the second prompt word into the dialogue generation model to generate the current output dialogue.

[0027] In one of the embodiments, according to a preset character feature word library, a plurality of target character feature words corresponding to the role description information of the digital person are obtained, including:

[0028] Text preprocessing is performed on the role description information to obtain preprocessed role description information;

[0029] Feature extraction is performed on the preprocessed role description information to obtain role feature information;

[0030] The role feature information is matched with each character feature word in the preset character feature word library to obtain a plurality of target character feature words corresponding to the role description information.

[0031] In a second aspect, the present application further provides a dialogue generation device, the device comprising:

[0032] A target character feature word obtaining module is configured to obtain a plurality of target character feature words corresponding to the role description information of the digital person according to a preset character feature word library; the target character feature word is used to represent the role characteristics of the digital person; the digital person is a virtual robot used to dialogue with the user;

[0033] A feature word group obtaining module is configured to combine each target character feature word according to the semantic association degree of the target character feature word to obtain a plurality of feature word groups;

[0034] A feature word group set determining module is configured to match the plurality of feature word groups with a plurality of dialogue scenes in a preset dialogue scene library, and determine a corresponding feature word group set for each dialogue scene;

[0035] The first dialogue generation module is configured to, in a case where the current output dialogue is a first dialogue, determine a first feature word group according to a current dialogue scenario and a feature word group set corresponding to the current dialogue scenario, and generate the current output dialogue based on the first feature word group by using a dialogue generation model; the current dialogue scenario is one of a plurality of dialogue scenarios; and the first feature word group is one of the feature word group set corresponding to the current dialogue scenario.

[0036] The second dialogue generation module is configured to, in a case where the current output dialogue is any dialogue other than the first dialogue, determine a second feature word group according to the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, an output dialogue before the current output dialogue output by the dialogue generation model, and a feature word group of the output dialogue before the current output dialogue, and generate the current output dialogue based on the second feature word group and the output dialogue before the current output dialogue by using the dialogue generation model; the second feature word group is one of the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue.

[0037] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, the memory stores a computer program, and the processor implements the method steps of the first aspect when executing the computer program.

[0038] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method steps of the first aspect.

[0039] In a fifth aspect, the present application further provides a computer program product, which comprises instructions, and the instructions are executed by a processor of an electronic device to enable the electronic device to perform the method steps of the first aspect.

[0040] The dialogue generation method, device, computer equipment, computer readable storage medium and computer program product described above, by obtaining a plurality of target character feature words corresponding to the role description information of the digital person according to a preset character feature word library; the target character feature word is used to represent the role characteristics of the digital person; the digital person is a virtual robot used to have a dialogue with the user; combining each target character feature word according to the semantic association degree of each target character feature word to obtain a plurality of feature word groups; matching the plurality of feature word groups with a plurality of dialogue scenes in a preset dialogue scene library to determine a corresponding feature word group set for each dialogue scene; in the case that the current output dialogue is the first dialogue, determining a first feature word group according to the current dialogue scene and the feature word group set corresponding to the current dialogue scene; generating the current output dialogue based on the first feature word group through the dialogue generation model; the current dialogue scene is one of the plurality of dialogue scenes; the first feature word group is one of the feature word groups in the feature word group set corresponding to the current dialogue scene; in the case that the current output dialogue is any non-first dialogue, determining a second feature word group according to the current dialogue scene, the feature word group set corresponding to the current dialogue scene, the output dialogue before the current output dialogue output by the dialogue generation model and the feature word group of the output dialogue before the current output dialogue; generating the current output dialogue based on the second feature word group and the output dialogue before the current output dialogue through the dialogue generation model; the second feature word group is one of the feature word groups in the feature word group set corresponding to the current dialogue scene, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue. According to the above content, the role description information of the digital person is deconstructed into a group of standardized and combinable target character feature words; the target character features are combined to obtain a feature word group; the feature word group is arranged and combined with a large number of dialogue scenes in a controlled and systematic manner, so as to guide the dialogue generation model to generate a dialogue focusing on a specific personality aspect under a specific dialogue scene, thereby ensuring that the dialogue data can maintain high role characteristic consistency at both micro (single answer) and macro (long-term dialogue) levels. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other related drawings can be obtained by those skilled in the art without creating any creative labor.

[0042] Figure 1 An application environment diagram of the dialogue generation method in an embodiment;

[0043] Figure 2A flowchart of a dialogue generation method in an embodiment;

[0044] Figure 3 A flowchart of a dialogue generation method in an embodiment;

[0045] Figure 4 A block diagram of a dialogue generation device in an embodiment;

[0046] Figure 5 An internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.

[0048] It should be noted that the terms "first", "second" and the like used in the present application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "include" and "have" and any variations thereof used in the present application are intended to cover non-exclusive inclusion. The term "multiple" used in the present application refers to two or more. The term "and / or" used in the present application refers to one of the options or any combination of multiple options.

[0049] The dialogue generation method provided by the embodiments of the present application can be applied to, for example, Figure 1The application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data required by the server 104 to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. The terminal 102 obtains a plurality of target character feature words corresponding to the role description information of the digital person according to the preset character feature word library; the target character feature word is used to represent the role characteristics of the digital person; the digital person is a virtual robot used for dialogue with the user; according to the semantic association degree of each target character feature word, each target character feature word is combined to obtain a plurality of feature word groups; the plurality of feature word groups are matched with a plurality of dialogue scenes in the preset dialogue scene library, and a corresponding feature word group set is determined for each dialogue scene; in the case that the current output dialogue is the first dialogue, according to the current dialogue scene and the feature word group set corresponding to the current dialogue scene, a first feature word group is determined; the current dialogue scene is one of the plurality of dialogue scenes; the first feature word group is one of the feature word groups in the feature word group set corresponding to the current dialogue scene; in the case that the current output dialogue is any non-first dialogue, according to the current dialogue scene, the feature word group set corresponding to the current dialogue scene, the output dialogue before the current output dialogue output by the dialogue generation model and the feature word group of the output dialogue before the current output dialogue, a second feature word group is determined; the dialogue generation model generates the current output dialogue based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is one of the feature word groups in the feature word group set corresponding to the current dialogue scene, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue. Among them, the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, unmanned aerial vehicles, low-altitude aircraft, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart vehicle device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0050] In one embodiment, as shown in Figure 2 , a dialogue generation method is provided. The embodiment takes the terminal 102 in the method applied to Figure 1 as an example to illustrate the method, which includes the following steps:

[0051] In step S210, a plurality of target character trait words corresponding to the role description information of the digital human are obtained according to a preset character trait word library. The target character trait words are used to represent the role characteristics of the digital human. The digital human is a virtual robot used to have a dialogue with the user.

[0052] The digital human can be a virtual simulated dialogue robot. In different scenarios, the form of the digital human can be different. For example, in a role-playing scenario, the digital human can be a virtual companion of the user. In a customer service scenario, the digital human can be a chat robot that has a chat with the user. In a game scenario, the digital human can be a game NPC that interacts with the user.

[0053] The role description information includes but is not limited to the role name, the role gender, and the role characteristics of the digital human. The role characteristics include but are not limited to the voice characteristics, the personality characteristics, and the behavior characteristics. For example, the role characteristics include “superior endurance”, “you” is more important than friends, regular work and rest but stay up late for “you”, consistent aesthetic with “you”, and like small animals.

[0054] The preset character trait word library is a standardized and controlled word library that is constructed in advance. The word library includes a plurality of filtered, conflict-free, and unambiguous character trait words. The form of the preset character trait word library includes but is not limited to a character trait word table and a character trait knowledge graph.

[0055] Specifically, the character trait words can be organized into a character trait knowledge graph, in which the nodes represent the character trait words, and the edges represent the relationships between the character trait words (for example, “introverted” is a superordinate concept of “not good at socializing”). The generation of the subsequent feature word group can be subgraph sampling or path walking with specific rules on the character trait knowledge graph.

[0056] The character trait word table does not have to be fixed in advance. A large auxiliary language model can dynamically generate a set of standardized and atomic character trait words according to the input original role description, and then perform subsequent combination.

[0057] In the embodiments of the present application, for a given digital human role description information, the information is deconstructed or mapped to one or more character trait words in the preset character trait word library, so as to convert the complex and fuzzy role description information into accurate target character trait words, and complete the conversion from unstructured description to structured features.

[0058] In step S220, the target character trait words are combined according to the semantic association degree of each target character trait word, and a plurality of feature word groups are obtained.

[0059] The semantic association degree includes but is not limited to the similarity of categories, functions, and attributes.

[0060] In the embodiments of the present application, semantic recognition is performed on each target character trait word, and the semantic correlation degree between each target character trait word is analyzed, and the target character trait words are combined according to a preset combination rule to obtain a plurality of trait word groups. The preset combination rule includes but is not limited to category combination, function combination and attribute combination. Specifically, each trait word group usually contains 2-3 target character trait words, which represents the combination of personality aspects that the character may exhibit in a certain specific situation.

[0061] In step S230, the plurality of trait word groups are matched with a plurality of dialogue scenes in a preset dialogue scene library, and a corresponding trait word group set is determined for each dialogue scene.

[0062] The preset dialogue scene library is a large-scale and diversified dialogue scene list constructed in advance. Each dialogue scene can be accompanied by a stage label (such as “icebreaking period”, “intimate period”, “ambiguous period”), an emotion label or a communication channel identifier (such as “text chat”, “voice chat”), providing rich scene information for dialogue generation.

[0063] The trait word group set includes one or more trait word groups.

[0064] In the embodiments of the present application, all trait word groups are matched with all dialogue scenes in the dialogue scene library. Specifically, a preset matching method can be used to filter and assign several (for example, 8-10) most suitable trait word groups to each dialogue scene. The preset matching method includes but is not limited to setting keyword weight rules, score thresholds, Jaccard similarity de-duplication thresholds and semantic-based similarity matching.

[0065] In step S240, in the case that the current output dialogue is the first dialogue, a first trait word group is determined according to the current dialogue scene and the trait word group set corresponding to the current dialogue scene, and the current output dialogue is generated based on the first trait word group by a dialogue generation model. The current dialogue scene is one of the plurality of dialogue scenes, and the first trait word group is one of the trait word group set corresponding to the current dialogue scene.

[0066] Each dialogue includes a plurality of rounds of dialogue, and each round of dialogue includes a question and an answer. For example, each dialogue includes 5-10 rounds of dialogue.

[0067] The dialogue generation model is a large language model trained after training.

[0068] In this embodiment, for the first dialogue segment, a feature word group (first feature word group) can be selected from the feature word group set corresponding to the current dialogue scenario. This first feature word group guides the digital human to generate dialogue data in the current dialogue scenario according to the role characteristics represented by the feature word group, thus completing the dialogue interaction with the user. Specifically, the current dialogue scenario and the feature word group set corresponding to the current dialogue scenario can be used as prompt words and input into an auxiliary large language model. The large language model outputs the first feature word group. The first feature word group is then input into the dialogue generation model to generate the first dialogue segment.

[0069] Step S250: If the current output dialogue is any non-first segment dialogue, determine the second feature word group based on the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, the output dialogue before the current output dialogue output by the dialogue generation model, and the feature word group of the output dialogue before the current output dialogue; generate the current output dialogue through the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue.

[0070] Among them, any dialogue that is not the first dialogue includes, but is not limited to, the second dialogue, the third dialogue, and so on.

[0071] In this embodiment of the application, the current output dialogue is taken as the second dialogue as an example. The output dialogue before the current output dialogue is the first dialogue. The feature word group that generated the output dialogue before the current output dialogue is the first feature word group. Based on the current dialogue scenario, the first feature word group and the dialogue content of the first dialogue, a feature word group (second feature word group) is selected from the feature word group set corresponding to the current dialogue scenario to guide the digital human to generate dialogue data in the current dialogue scenario according to the role characteristics represented by the feature word group, and complete the dialogue interaction with the user.

[0072] Specifically, the current dialogue scenario, the set of feature words corresponding to the current dialogue scenario, the output of the dialogue generation model, the output dialogue before the current output dialogue, and the feature words of the output dialogue before the current output dialogue can be used as prompt words. These are then input into a large language model with an auxiliary language model, which outputs a second set of feature words. The second set of feature words is then input into the dialogue generation model to generate a second dialogue.

[0073] The process of generating feature phrases for each dialogue segment is as follows: Based on the current dialogue scenario, the feature phrase set corresponding to the current dialogue, the selected feature phrases, and the existing dialogue context (if any, both the selected and previously selected feature phrases are initially empty and added iteratively), a new feature phrase is selected from the feature phrase set of this dialogue scenario.

[0074] For example, using an auxiliary large language model, the prompt words for the feature word groups of each dialogue are output as follows:

[0075] You are a master of virtual simulation dialogue, adept at capturing human interests and emotions, making people genuinely feel that you are a particularly relatable and engaging person. You possess a rich set of character traits, representing the various human-like characteristics of the role you play in conversations. Based on the meaning and relevance of the words, these character traits are combined into multiple **characteristic phrases**, each containing 2-3 of your character traits.

[0076] You (assistant) and the user are now having a conversation around the scenario "{scene}". You expect your performance to continue to impress the user and make them want to continue a fun and engaging chat with you.

[0077] You will select from the set of characteristic phrases listed below based on the existing dialogue context between you (assistant) and the user (user) surrounding the dialogue scene "{scene}" (if empty, it means you are about to start your first dialogue), in order to make your character perform rich and vivid actions that contribute to the plot within the theme of the current dialogue scene.

[0078]

Set of Featured Phrases

[0079] {allbsk}

[0080] ---

[0081] Please refer to the **existing dialogue context** between you (assistant) and the user (user) to generate new feature phrases:

[0082] {chat history}

[0083] ---

[0084] Each dialogue segment generated is based on the current dialogue scenario, historical dialogue content, and feature phrases from the generated historical dialogue content to select the feature phrases for the current output dialogue. Since a feature phrase is selected from the set of feature phrases corresponding to the current dialogue scenario, the phenomena of "character drift" and "character collapse" can be effectively avoided. Because each dialogue segment corresponds to a single feature phrase, the long-range forgetting limitation of large language models is effectively overcome, ensuring the consistency of character features throughout long dialogues.

[0085] To facilitate understanding of the above steps S210~S250, as follows Figure 3 As shown, the overall solution architecture is mainly divided into two stages. The first stage generates different dialogue scenarios and corresponding character feature baskets (feature word groups) data under a specific role description. The second stage generates dialogue based on the current dialogue scenario and the corresponding character feature basket data. In the first stage, the complex role description is broken down into multiple target character feature words and bound to multiple dialogue scenarios to obtain a balanced set of dialogue scenarios and corresponding feature baskets. In the second stage, based on the current dialogue scenario, the corresponding character feature basket is determined, and it is checked whether the character feature basket has been used. If so, the character feature basket is updated; otherwise, prompt words are generated based on the character feature basket. Dialogue is generated based on the prompt words. It is then determined whether the dialogue meets the required number of rounds. If not, dialogue generation continues iteratively; if so, the final dialogue is output.

[0086] The aforementioned dialogue generation method obtains multiple target persona feature words corresponding to the role description information of the digital human based on a pre-set persona feature word library. These target persona feature words characterize the role features of the digital human, which is a virtual robot used to converse with the user. Based on the semantic relevance of each target persona feature word, the feature words are combined to obtain multiple feature word groups. These feature word groups are then matched with multiple dialogue scenarios in a pre-set dialogue scenario library to determine a corresponding set of feature word groups for each dialogue scenario. If the current output dialogue is the first segment of the dialogue, a first feature word group is determined based on the current dialogue scenario and the corresponding set of feature word groups. Finally, the dialogue generation model generates the current output dialogue based on the first feature word group. The current dialogue scenario is one of multiple dialogue scenarios; the first feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario; when the current output dialogue is any non-first dialogue, the second feature word group is determined based on the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, the output dialogue before the current output dialogue output by the dialogue generation model, and the feature word group of the output dialogue before the current output dialogue; the current output dialogue is generated by the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue. As can be seen from the above, this application deconstructs the role description information of digital humans into a set of standardized and combinable target persona feature words; combines these target persona features to obtain feature word groups; and arranges and combines the feature word groups with a large number of dialogue scenarios in a controlled and systematic manner, thereby guiding the dialogue generation model to generate dialogues that focus on specific personality aspects in specific dialogue scenarios, thus ensuring that the dialogue data can maintain a high degree of consistency in role characteristics at both the micro (single response) and macro (long-distance dialogue) levels.

[0087] In one embodiment, based on a pre-defined character feature word library, multiple target character feature words corresponding to the role description information of the digital human are obtained, including:

[0088] Step S212: Perform text preprocessing on the character description information to obtain preprocessed character description information.

[0089] Text preprocessing includes, but is not limited to, word segmentation, stop word removal, punctuation removal, and special character removal.

[0090] Step S214: Extract features from the preprocessed character description information to obtain character feature information.

[0091] Feature extraction includes, but is not limited to, keyword extraction, part-of-speech tagging, and named entity recognition.

[0092] Step S216: Match the character feature information with each character feature word in the preset character feature word library to obtain multiple target character feature words corresponding to the character description information.

[0093] In this embodiment of the application, the similarity between the character feature information and each character feature word in the preset character feature word library can be calculated, the similarity can be sorted from high to low, and a preset number of character feature words with the highest ranking can be selected as target character feature words.

[0094] In one embodiment, multiple feature word groups are matched with multiple dialogue scenarios in a pre-defined dialogue scenario library, and a corresponding set of feature word groups is determined for each dialogue scenario, including:

[0095] Step S232: Perform character-level intersection processing on the persona feature words of each feature word group and each dialogue scene to obtain the intersection score corresponding to each persona feature word.

[0096] Character-level intersection processing is a text processing technique used to analyze the common parts of two or more text fragments at the character level.

[0097] In this embodiment of the application, for each dialogue scenario, the current dialogue scenario and each person's feature word are intersected at the character level. The larger the intersection, the higher the score.

[0098] Step S234: For each dialogue scenario, determine the preset number of persona feature words that rank highest based on the intersection score.

[0099] The preset quantity can be set according to actual needs.

[0100] In this embodiment of the application, the top 20 personality feature words with the highest scores are retained for each dialogue scenario.

[0101] Step S236: Determine the set of feature words corresponding to the dialogue scene based on the preset number of character feature words to which the feature word groups belong.

[0102] In this embodiment of the application, a feature word group to which each of the preset number of persona feature words belongs is determined, and a feature word group set is constructed based on these feature word groups.

[0103] Optionally, after obtaining the set of feature words corresponding to the dialogue scenario, deduplication and format normalization can be performed on each feature word in the set to improve the quality of the feature word set.

[0104] This application's embodiments, by matching feature phrases with dialogue scenarios, ensure that the generation of each subsequent dialogue segment is traceable and possesses strong interpretability.

[0105] In one embodiment, the method further includes:

[0106] Step S238: For each feature word, if the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is less than a preset number threshold, add the current feature word to the target dialogue scenario until the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is greater than or equal to the preset number threshold.

[0107] Among them, the target dialogue scenario is the dialogue scenario other than the dialogue scenario corresponding to the feature word group to which the current feature word belongs, among multiple dialogue scenarios.

[0108] The preset quantity threshold can be set according to actual needs. For example, the preset quantity threshold is 10.

[0109] In this embodiment, a checking procedure is run to ensure that each persona feature word is covered in a sufficient number of dialogue scenarios, avoiding insufficient representativeness of some persona feature words. When the number of dialogue scenarios covered by a persona feature word is insufficient, a dialogue scenario completion operation is performed for the under-covered persona feature words.

[0110] In one embodiment, a dialogue generation model generates the current output dialogue based on a first feature word group, including:

[0111] Step S242: Obtain user role information and dialogue generation constraint information.

[0112] User role information includes, but is not limited to, the user's name, personality, and role characteristics.

[0113] The dialogue generation constraints include, but are not limited to, the number of dialogue rounds, the dialogue language, and the dialogue format.

[0114] Step S244: Generate the first prompt word based on the user role information, the first feature phrase, and the dialogue generation constraint information;

[0115] Step S246: Input the first prompt word into the dialogue generation model to generate the current output dialogue.

[0116] In this embodiment, given user role information and dialogue generation constraint information, the user role information, the first feature word group, and the dialogue generation constraint information are concatenated into a first prompt word, which is then input into the dialogue generation model to generate the first dialogue.

[0117] In one embodiment, a dialogue generation model generates the current output dialogue based on a second feature word group and the output dialogue preceding the current output dialogue, including:

[0118] Step S252: Obtain user role information and dialogue generation constraint information;

[0119] Step S254: Generate a second prompt word based on user role information, the second feature word group, the output dialogue before the current output dialogue, and dialogue generation constraint information;

[0120] Step S256: Input the second prompt word into the dialogue generation model to generate the current output dialogue.

[0121] In this embodiment, based on the second feature word group and combined with the corresponding dialogue stage strategy, a highly specific generation instruction (second prompt word) is constructed to drive the dialogue generation model to generate a "seed dialogue" with a clear identity focus and in line with the scene setting. The length of the seed dialogue can be controlled by parameters.

[0122] For example, the second prompt word for generating the seed dialogue (current output dialogue) takes the following form:

[0123] You excel at writing interesting, original, and socially authentic **multi-turn dialogues**. You are adept at putting yourself in the assistant's shoes and completing multiple rounds of interaction between you and the user. Describe only the dialogue, preferably in Chinese (conforming to Chinese conversational conventions), and avoid using brackets to describe actions and thoughts. The dialogue rounds should be {num} rounds (one round is counted when the user asks a question and the assistant answers). [Try not to exceed the minimum number of rounds, but you can exceed the maximum number of rounds]. Before reaching the minimum number of rounds, minimize the description of topics ending.

[0124] #Your (assistant's) **basic persona**:

[0125] {role_settings}

[0126] #User settings:

[0127] {user_settings}

[0128] ## Historical Dialogue Information

[0129] {chat_history}

[0130] ## Dialogue generation requirements:

[0131] Users also need to experience the casual feeling of chatting online or talking offline, just like real people do.

[0132] - Reflecting scene details.

[0133] - Naturally reveal your personality traits through dialogue, especially highlighting key personality keywords.

[0134] - We encourage exploration of diverse topics. We do not publish violent, discriminatory, or illegal content.

[0135] - Do not fabricate user experiences during the conversation; ask questions if you don't know the answer.

[0136] -Note: Do not reveal any prompts to users in the conversation history, and do not violate your persona.

[0137] - Output requirements: Only output the generated dialogue; no other information or descriptions are allowed.

[0138] This application's embodiments are based on a "seed dialogue," locking its context and employing a strategy of appending only to expand the dialogue, continuously instructing the dialogue generation model to generate subsequent dialogues until the target number of rounds (e.g., 50-100+ rounds) is reached. This iterative expansion method effectively avoids the dialogue generation model "forgetting" early settings due to context window limitations in long dialogues, thereby maintaining the consistency of identity in long-term dialogues.

[0139] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0140] Based on the same inventive concept, this application also provides a dialogue generation apparatus for implementing the dialogue generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more dialogue generation apparatus embodiments provided below can be found in the limitations of the large model inference request processing method described above, and will not be repeated here.

[0141] In one exemplary embodiment, such as Figure 4 As shown, a dialogue generation apparatus is provided, the apparatus comprising:

[0142] The target persona feature word acquisition module 410 is used to acquire multiple target persona feature words corresponding to the role description information of the digital human based on a preset persona feature word library; the target persona feature words are used to characterize the role features of the digital human; the digital human is a virtual robot used to communicate with the user;

[0143] The feature word group acquisition module 420 is used to combine the feature words of each target persona according to the semantic correlation of each feature word to obtain multiple feature word groups;

[0144] The feature word set determination module 430 is used to match multiple feature word sets with multiple dialogue scenarios in a preset dialogue scenario library, and determine the corresponding feature word set for each dialogue scenario.

[0145] The first dialogue generation module 440 is used to determine the first feature word group based on the current dialogue scenario and the feature word group set corresponding to the current dialogue scenario when the current output dialogue is the first dialogue segment; and generate the current output dialogue based on the first feature word group through the dialogue generation model; the current dialogue scenario is one of multiple dialogue scenarios; and the first feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario.

[0146] The second dialogue generation module 450 is used to determine a second feature word group based on the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, the output dialogue before the current output dialogue output by the dialogue generation model, and the feature word group of the output dialogue before the current output dialogue when the current output dialogue is any non-first dialogue segment; and to generate the current output dialogue by the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group of the output dialogue before the current output dialogue.

[0147] In one embodiment, multiple feature word groups are matched with multiple dialogue scenarios in a preset dialogue scenario library, and a corresponding set of feature word groups is determined for each dialogue scenario, including:

[0148] The character-level intersection of each feature word group with each dialogue scenario is processed to obtain the intersection score corresponding to each character feature word.

[0149] For each dialogue scenario, determine a preset number of character feature words that rank the highest based on the intersection score;

[0150] Based on a preset number of character characteristic words, determine the set of characteristic word groups corresponding to the dialogue scenario.

[0151] In one embodiment, the method further includes:

[0152] For each feature word, if the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is less than a preset threshold, the current feature word is added to the target dialogue scenario until the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is greater than or equal to the preset threshold.

[0153] Among them, the target dialogue scenario is the dialogue scenario other than the dialogue scenario corresponding to the feature word group to which the current feature word belongs, among multiple dialogue scenarios.

[0154] In one embodiment, a dialogue generation model generates the current output dialogue based on a first feature word group, including:

[0155] Obtain user role information and dialogue generation constraint information;

[0156] Generate the first prompt word based on user role information, the first feature phrase, and dialogue generation constraint information;

[0157] Input the first prompt word into the dialogue generation model to generate the current output dialogue.

[0158] In one embodiment, a dialogue generation model generates the current output dialogue based on a second feature word group and the output dialogue preceding the current output dialogue, including:

[0159] Obtain user role information and dialogue generation constraint information;

[0160] Generate a second prompt word based on user role information, second feature word phrase, output dialogue before the current output dialogue, and dialogue generation constraint information;

[0161] Input the second prompt word into the dialogue generation model to generate the current output dialogue.

[0162] In one embodiment, based on a preset character feature word library, multiple target character feature words corresponding to the role description information of the digital human are obtained, including:

[0163] The character description information is preprocessed to obtain the preprocessed character description information;

[0164] Feature extraction is performed on the preprocessed character description information to obtain character feature information;

[0165] The character feature information is matched with each character feature word in the preset character feature word library to obtain multiple target character feature words corresponding to the character description information.

[0166] Each module in the aforementioned dialogue generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.

[0167] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows. Figure 5 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores dialogue generation data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a dialogue generation method.

[0168] Those skilled in the art will understand that Figure 5 The structures shown are merely block diagrams of some structures related to the present application and do not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements. In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the aforementioned large dialogue generation method. The steps of the dialogue generation method described here may be steps from one of the dialogue generation methods in the various embodiments described above.

[0169] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, causes the processor to perform the steps of the dialogue generation method described above. The steps of the dialogue generation method described here may be steps from one of the dialogue generation methods in the various embodiments described above.

[0170] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, causes the processor to perform the steps of the dialogue generation method described above. The steps of the dialogue generation method described here may be steps from one of the dialogue generation methods in the various embodiments described above.

[0171] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0172] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0173] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0174] The above embodiments merely illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of this application's patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A dialogue generation method, characterized in that, The method includes: Based on a pre-defined character feature word library, multiple target character feature words corresponding to the role description information of the digital human are obtained; the target character feature words are used to characterize the role features of the digital human; the digital human is a virtual robot used to communicate with the user. Based on the semantic relevance of each of the target persona feature words, the target persona feature words are combined to obtain multiple feature word groups; The multiple feature word groups are matched with multiple dialogue scenarios in a preset dialogue scenario library to determine a corresponding set of feature word groups for each dialogue scenario. When the current output dialogue is the first dialogue segment, a first feature word group is determined based on the current dialogue scenario and the feature word group set corresponding to the current dialogue scenario; the current output dialogue is generated by the dialogue generation model based on the first feature word group; the current dialogue scenario is one of the multiple dialogue scenarios; the first feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario. If the current output dialogue is any non-first segment of the dialogue, a second feature word group is determined based on the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, the output dialogue before the current output dialogue output by the dialogue generation model, and the feature word group that generated the output dialogue before the current output dialogue. The current output dialogue is then generated by the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue. The second feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario, and it is different from the first feature word group and the feature word group that generated the output dialogue before the current output dialogue.

2. The method according to claim 1, characterized in that, The step of matching the plurality of feature word groups with a plurality of dialogue scenarios in a preset dialogue scenario library, and determining a corresponding set of feature word groups for each dialogue scenario, includes: The character-level intersection of each of the aforementioned feature word groups with each of the aforementioned dialogue scenarios is performed to obtain the intersection score corresponding to each of the aforementioned character feature words. For each of the aforementioned dialogue scenarios, a preset number of character feature words are determined to rank the top-performing words based on their intersection scores; Based on the preset number of character characteristic words to which the characteristic word groups belong, determine the set of characteristic word groups corresponding to the dialogue scenario.

3. The method according to claim 2, characterized in that, The method further includes: For each of the aforementioned feature words, if the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is less than a preset number threshold, the current feature word is added to the target dialogue scenario until the number of dialogue scenarios corresponding to the feature word group to which the current feature word belongs is greater than or equal to the preset number threshold. The target dialogue scenario refers to any dialogue scenario other than the dialogue scenario corresponding to the feature word group to which the current feature word belongs.

4. The method according to claim 1, characterized in that, The step of generating the current output dialogue based on the first feature word group through the dialogue generation model includes: Obtain user role information and dialogue generation constraint information; Based on the user role information, the first feature word group, and the dialogue generation constraint information, a first prompt word is generated; The first prompt word is input into the dialogue generation model to generate the current output dialogue.

5. The method according to claim 1, characterized in that, The step of generating the current output dialogue using the dialogue generation model based on the second feature word group and the output dialogue preceding the current output dialogue includes: Obtain user role information and dialogue generation constraint information; A second prompt word is generated based on the user role information, the second feature word group, the output dialogue before the current output dialogue, and the dialogue generation constraint information. The second prompt word is input into the dialogue generation model to generate the current output dialogue.

6. The method according to claim 1, characterized in that, The step involves obtaining multiple target character feature words corresponding to the role description information of the digital human based on a preset character feature word library, including: The character description information is preprocessed to obtain preprocessed character description information; Feature extraction is performed on the preprocessed character description information to obtain character feature information; The character feature information is matched with each character feature word in the preset character feature word library to obtain multiple target character feature words corresponding to the character description information.

7. A dialogue generation device, characterized in that, The device includes: The target persona feature word acquisition module is used to acquire multiple target persona feature words corresponding to the role description information of the digital human based on a preset persona feature word library; the target persona feature words are used to characterize the role features of the digital human; the digital human is a virtual robot used to communicate with the user; The feature word group acquisition module is used to combine the target persona feature words according to the semantic correlation of each target persona feature word to obtain multiple feature word groups; The feature word set determination module is used to match the multiple feature word sets with multiple dialogue scenarios in a preset dialogue scenario library, and determine the corresponding feature word set for each dialogue scenario. The first dialogue generation module is used to determine a first feature word group based on the current dialogue scenario and the feature word group set corresponding to the current dialogue scenario when the current output dialogue is the first dialogue segment; and to generate the current output dialogue based on the first feature word group through the dialogue generation model; the current dialogue scenario is one of the multiple dialogue scenarios; and the first feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario. The second dialogue generation module is used to determine a second feature word group when the current output dialogue is any non-first dialogue segment, based on the current dialogue scenario, the feature word group set corresponding to the current dialogue scenario, the output dialogue before the current output dialogue output by the dialogue generation model, and the feature word group that generated the output dialogue before the current output dialogue; and to generate the current output dialogue by the dialogue generation model based on the second feature word group and the output dialogue before the current output dialogue; the second feature word group is a feature word group in the feature word group set corresponding to the current dialogue scenario, and is different from the first feature word group and the feature word group that generated the output dialogue before the current output dialogue.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, the computer program product comprising instructions, characterized in that, When the instructions are executed by the processor of the electronic device, the electronic device is able to perform the steps of the method as described in any one of claims 1 to 6.