Role dialogue generation method and device, equipment and medium
By receiving and parsing text information, extracting content and role information, and generating features through an encoder, fusion features to generate reply text, it solves the problem that it is difficult to dynamically generate dialogue content in the prior art that conforms to the specific role style, and realizes efficient decoupling and flexible integration of content and style, meeting the diverse needs of users.
Patent Information
- Application Number
- CN202411665258.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-02-25
AI Technical Summary
The prior art is difficult to dynamically generate dialogue content that conforms to a specific style based on the character style information input by the user, and it is impossible to achieve efficient decoupling and flexible integration of content and style.
By receiving text information, analyzing and extracting content information and role information, inputting content information into the first encoder to generate content features, input role information as style information into the second encoder to generate style features, blend content features and style features, generate fusion features, and inputting them into the decoder to generate reply text.
It realizes flexible generation of dialogue content that conforms to different character styles, realizes effective decoupling of content and styles, ensures the accuracy of dialogue content and adaptability to different character styles, and meets the role-playing needs of users in multiple situations.
Smart Images

Figure CN119514602A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of artificial intelligence technology and financial technology, and in particular to a method, device, equipment and storage medium for generating character dialogues. Background Art
[0002] With the rapid development of financial technology, intelligent customer service systems have been widely used in the field of financial services. Traditional financial service intelligent customer service systems mainly provide customer service in a fixed interaction style and cannot flexibly adjust the interaction mode according to the customer's personalized needs and emotional state. However, financial customers are often in complex emotional and demand scenarios. For example, when customers face financial pressure or decision-making confusion, fixed interaction modes cannot provide effective emotional support or accurate service suggestions.
[0003] When interacting with customers, existing intelligent customer service systems can usually only provide a single style of response and cannot make adaptive adjustments based on the customer's emotional state (such as anxiety, confusion, etc.), resulting in insufficient emotional comfort and support for customers. For example, when a customer feels uncertain during a financial decision, the system cannot effectively alleviate their emotions or provide emotional support, which in turn affects customer trust and satisfaction.
[0004] The existing system has difficulty switching interactive roles according to different business scenarios and customer needs. For example, when a customer is seeking venture capital advice, the system cannot switch to a professional and decisive role to provide advice, nor can it switch to a gentle and soothing role to provide psychological comfort when the customer is anxious. This lack of the ability to flexibly switch roles limits the diversification and humanization of customer service. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, equipment and storage medium for generating character dialogues, aiming to solve the technical problem that in the prior art, it is difficult to dynamically generate dialogue content that conforms to a specific style based on the character style information input by the user during the dialogue generation process, and it is impossible to achieve efficient decoupling and flexible integration of content and style.
[0006] To achieve the above object, the present invention provides a method for generating character dialogues, comprising:
[0007] Receiving text information, parsing the text information, and extracting content information and role information from the text information;
[0008] Inputting the content information into a first encoder to generate content features;
[0009] Inputting the character information as style information into a second encoder to generate style features;
[0010] Fusing the content feature and the style feature to obtain a fusion feature;
[0011] The fused features are input into a decoder to generate a reply text, and the reply text is output.
[0012] Furthermore, to achieve the above-mentioned purpose, the present invention provides a character dialogue generation device, comprising:
[0013] A text receiving and information extraction module, used for receiving text information, parsing the text information, and extracting content information and role information from the text information;
[0014] A content encoding module, used for inputting the content information into a first encoder to generate content features;
[0015] A style encoding module, used for inputting the character information as style information into a second encoder to generate style features;
[0016] A feature fusion module, used to fuse the content feature and the style feature to obtain a fusion feature;
[0017] The text generation and output module is used to input the fusion features into the decoder, generate a reply text, and output the reply text.
[0018] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a computer device, which includes a memory, a processor, and a character dialogue generation program stored in the memory and executable on the processor, and the character dialogue generation program, when executed by the processor, implements the steps of the character dialogue generation method as described above.
[0019] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a character dialogue generation program is stored, and when the character dialogue generation program is executed by a processor, the steps of the character dialogue generation method described above are implemented.
[0020] Beneficial effects: The present invention relates to the fields of artificial intelligence technology and financial technology, and discloses a method for generating role dialogues, which receives text information, parses the text information to extract content information and role information, inputs the content information into a first encoder to generate content features, inputs the role information as style information into a second encoder to generate style features, fuses the content features and style features to obtain fusion features, and the fusion features are input into a decoder to generate a reply text, and outputs the generated reply text. The present invention separates and independently encodes the content information and the role information, and subsequently combines the two features by feature fusion, so as to flexibly generate dialogue content that conforms to different role styles, and realize effective decoupling of content and style, which not only ensures the accuracy of the dialogue content, but also improves the adaptability to different role styles, and meets the role-playing needs of users in various situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0022] Figure 1 A schematic diagram of an application environment of a method for generating character dialogues in an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of a flow chart of an embodiment of a method for generating character dialogues according to the present invention;
[0024] Figure 3 It is a functional module schematic diagram of a preferred embodiment of the character dialogue generation device of the present invention;
[0025] Figure 4 A schematic diagram of the structure of a computer device in one embodiment of the present invention;
[0026] Figure 5 FIG. 4 is another schematic diagram of the structure of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0027] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0028] The character dialogue generation method provided by the embodiment of the present invention can be applied in Figure 1 In an application environment, the user terminal communicates with the server terminal through a network. The server terminal can receive text information through the user terminal, parse the text information to extract content information and role information, input the content information into the first encoder to generate content features, input the role information as style information into the second encoder to generate style features, fuse the content features and style features to obtain fusion features, the fusion features are input into the decoder to generate a reply text, and the generated reply text is output. The present invention can flexibly generate dialogue content that conforms to different role styles by separating and independently encoding the content information and the role information, and then combining the two features by feature fusion, thereby achieving effective decoupling of content and style, thereby ensuring the accuracy of the dialogue content, improving the adaptability to different role styles, and meeting the role-playing needs of users in various situations. Among them, the user terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server terminal can be implemented by an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0029] See also Figure 2 , Figure 2This is a flow chart of an embodiment of a method for generating character dialogues provided by the present invention. It should be noted that although a logical sequence is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0030] like Figure 2 As shown, the character dialogue generation method proposed by the present invention comprises the following steps:
[0031] S10, receiving text information, parsing the text information, and extracting content information and role information from the text information;
[0032] In this embodiment, receiving text information is not limited to direct input by the user, but may also include obtaining text data from a variety of data sources and channels. This step is intended to provide basic text information input for subsequent analysis and processing. The source of the text information may be manual input by the user, automatically collected data, interface data of a third-party system, historical conversation records, etc.
[0033] User direct input (text or voice) includes text input box, voice recognition input, etc.
[0034] The system can obtain text information through automated data collection, such as obtaining text data from public data sources through web crawlers, data monitoring tools, etc. This method is usually used to analyze user behavior, track market information, or monitor financial news and public opinion. The system is configured with web crawlers or API automation tools to collect text information from designated public data sources (such as social media, news websites) regularly or in real time. After data collection, the system cleans and formats the data and stores it in the text processing module. After the text information is stored, it can be used for subsequent parsing and analysis.
[0035] The system can receive text data pushed by other systems by integrating the API or data interface of third-party applications. For example, it can receive transaction messages, market analysis reports, etc. from financial systems. Establish data integration with third-party systems and receive text data through standardized interface protocols (such as RESTfulAPI, SOAP, WebSocket, etc.). The third-party system pushes text data to the system when a specific event is triggered or at a set time. The system receives and verifies the text data according to the definition of the data interface, and then stores it in the processing module.
[0036] The system can store and use the user's historical conversation records and behavior data as another source of text information. This method is mainly used to improve personalized services, historical data analysis, etc. The conversation records between the user and the system will be saved in real time. The system can regularly analyze these historical records and extract useful text data from them. User behavior data (such as browsing history, click records, etc.) can also be converted into text information for analyzing user intentions or emotional states. When the system needs to use historical data, it can extract relevant conversation records or behavior logs from the database.
[0037] In some complex scenarios, the system can collect data through sensors or IoT devices and convert it into text information. For example, in a financial monitoring system, the data monitored by sensors can be collected and text information of alarm messages can be generated. The data collected by the sensors is uploaded to the server through the IoT platform, and the system generates text messages based on data thresholds and rules. The system generates descriptive text based on the sensor data, such as "temperature is too high" or "abnormal transaction detected". The generated text message enters the subsequent processing module.
[0038] Example description: In the intelligent customer service system in the financial field, the text information received is not only the content entered by the user through the text box or voice, but the system can also receive other text information in the following ways:
[0039] Automatic monitoring of market news: The system can regularly collect text information about market trends from financial news websites. The collected information will provide timely reference data when users consult market conditions.
[0040] Receive third-party analysis reports: The system can receive analysis report texts from third-party financial service providers through the API interface. These reports can be used to answer users' investment consulting requests.
[0041] Analyze historical transaction records: The system can store users' historical transaction data. When users consult similar transaction issues again, the system can quickly locate and give corresponding analysis and suggestions.
[0042] Through multiple ways of receiving text information, the system can flexibly and efficiently obtain text data from different sources, including not only direct input from users, but also automatic collection, historical records, and third-party integration, thereby achieving richer dialogue scenarios and more comprehensive information acquisition. This multi-source data input method improves the system's ability to perceive information and its flexibility in responding to diverse scenarios.
[0043] The steps of parsing text information aim to process and analyze the text input by the user in order to extract content information (i.e., the specific needs or questions of the user) and role information (the expected dialogue style or role attributes of the user). Through this step, the system can separate the user's input into two operable parts for subsequent feature generation and processing.
[0044] The process of parsing text information and extracting content information and role information usually includes the following steps:
[0045] Text preprocessing: Text preprocessing is the first step in parsing text, mainly performing basic cleaning and standardization operations on the text. The purpose of preprocessing is to remove redundant information and useless characters in the text to ensure the accuracy of subsequent processing. Use a stop word list to filter out meaningless words such as "of", "and", "in", etc. Remove punctuation marks, emojis, non-text characters, etc. Standardize the case, number format, time expressions, etc. in the text.
[0046] Word segmentation: Word segmentation is to decompose continuous text content into individual words or phrases. Especially for Chinese text, word segmentation is a basic operation in parsing. The results of word segmentation provide the boundaries and units of words for subsequent information extraction. Segment the text word by word according to the built-in word library of the system. Conduct statistical analysis on words not covered by the dictionary in the text, or identify them according to lexical rules.
[0047] Named Entity Recognition (NER): Named Entity Recognition is to identify specific entities in the text, such as person names, place names, organization names, time, etc. The recognition of named entities helps to extract keywords with specific meanings from the text. Especially when identifying role information, specific roles can be marked by specific names or labels. Use pre-trained named entity recognition models (such as models based on BERT, BiLSTM-CRF, etc.) to perform entity annotation on the word segmentation results. Tag person names, role names, time, etc. that appear in the text, and output the text with annotations.
[0048] Keyword matching and role information extraction: The extraction of role information is achieved through keyword matching. The system compares the recognition results in the text according to the preset role keyword library and extracts the specific role information required by the user. Load the role keyword library, which contains common role names and addresses (such as "Dear Sister", "Overbearing President", etc.). Traverse the recognition results and perform keyword matching on each word. If a specific role keyword is recognized, extract and mark the role information.
[0049] Content information filtering: The purpose of content information filtering is to remove role-related content from the extracted role information and use the remaining part as the user's main needs, that is, content information. This step is the last stage of parsing and extraction. The extracted role keywords and redundant words are removed from the word segmentation results. The remaining text is combined into content information and is ready to be passed to the next stage of processing modules.
[0050] Example description: In a financial intelligent customer service system, a user may enter the following text: "I am a little confused now, can you help me analyze my investment like a financial advisor?"
[0051] During the parsing process, the system will perform the following processing:
[0052] Text preprocessing: remove stop words such as "I am now".
[0053] Word segmentation: "financial advisor", "help me", "analyze", and "invest" are segmented as phrases.
[0054] Named Entity Recognition: Tag “Financial Advisor” as a role name.
[0055] Keyword matching: Identify “financial advisor” as the user’s desired role.
[0056] Content filtering: Extract "Help me analyze my investment" as content information.
[0057] Through the above steps, the system can accurately separate the text input by the user into content information and role information. The parsing step ensures that the system can understand the user's specific needs and identify the user's desired dialogue role and style. This separation processing method not only improves the system's understanding of user intent, but also enables the system to flexibly generate personalized responses that meet user needs.
[0058] S20, inputting the content information into a first encoder to generate content features;
[0059] In this embodiment, the first encoder encodes the parsed content information and converts it into content features that can be used for subsequent processing. The content information refers to the specific needs or questions of the user, and the first encoder is a trained model for extracting semantic features from the content information. Through this process, the system can better understand and represent the needs of the user.
[0060] The first encoder is usually a specifically trained deep learning model, whose purpose is to convert content information into a high-dimensional feature representation. Choosing a suitable encoder model is crucial to the effect of feature extraction. You can choose commonly used natural language processing models such as BERT, LSTM, GRU or Transformer. BERT is good at processing context-dependent text, LSTM is good at processing long text sequences, and Transformer has stronger parallel processing capabilities. Use a large-scale styleless corpus (such as news, conversation data, etc.) to pre-train the encoder. Pre-training can use supervised learning or unsupervised learning methods to extract common text features. Depending on the specific application scenario, the model can be fine-tuned.
[0061] Before the content information is input into the encoder, the text needs to be standardized and converted into a vector representation acceptable to the model (such as a word embedding vector). Standardization ensures the consistency of the format and symbols of the content information, such as unified capitalization, processing punctuation, etc. Use a pre-trained word embedding model (such as Word2Vec, GloVe, etc.) or the encoder's own embedding layer to convert the text into a word vector. Depending on the length of the content information, the vector can be padded or truncated to fit the encoder's input dimension.
[0062] The processed content information vector is passed as input to the first encoder, which performs deep semantic analysis on the content information and generates the corresponding content feature vector. The content information is vectorized and input into the input layer of the first encoder. The first encoder processes the content information through forward propagation and generates content features that represent the semantics of the text. The high-dimensional content feature vector processed by the encoder is used as output to provide a basis for subsequent feature fusion and dialogue generation.
[0063] Example description: In the financial intelligent customer service system, the user may enter the following content: "Please analyze the current market risks and give me some suggestions." In this step, the system inputs the content into the first encoder for processing: Select the pre-trained BERT model as the first encoder. Use the embedding layer that comes with BERT to convert words such as "analyze market risks" and "give suggestions" into corresponding word embedding vectors. Input the vector into the BERT model, and extract content features through the encoder's hierarchical propagation and self-attention mechanism. The encoder finally outputs a content feature vector representing "analyze market risks" and a content feature vector representing "give suggestions".
[0064] By inputting content information into the trained first encoder, the system is able to extract high-dimensional, context-related content features from the user's text. This ensures accurate semantic representation of user needs and provides a solid foundation for subsequent style feature fusion and generated dialogues. The use of the first encoder improves the accuracy of understanding text information and the ability to represent semantics.
[0065] S30, inputting the character information as style information into a second encoder to generate style features;
[0066] In this embodiment, the character information extracted from the user text is passed as input to the second encoder to generate the corresponding style features. The character information refers to the specific character style specified by the user in the input text and expected to be used by the dialogue system. The style feature is an abstract representation of the deep semantics and style characteristics of the specific character information, which is used to reflect the personalized language style and dialogue tone of different characters.
[0067] Before inputting the role information into the second encoder, the role information needs to be standardized and formatted to ensure the standardization and consistency of the data. Role information may involve specific role names, modal particles, or feature tags. Data cleaning removes noise data or redundant information in role information, such as special symbols, non-text characters, etc. Formatting conversion standardizes role information into a fixed format, such as representing "Comforting Sister" as "#Comforting_Counselor", or using a labeled way to represent the role tone.
[0068] Use word embedding or a specific word vector model (such as Word2Vec, GloVe, etc.) to convert role information into a vector representation as the input of the encoder.
[0069] The role of the second encoder is to extract features from the input character information to generate corresponding style features. Selecting and training a suitable second encoder is crucial for the generation of character style. You can choose a deep learning model such as LSTM, GRU, or Transformer to train specifically for encoding character style. Use a text corpus containing a specific style to train the second encoder. For example, you can use data such as lines of a specific character, book text, historical dialogue, etc. for supervised learning, so that the second encoder can capture the unique language style of the character.
[0070] After being formatted and vectorized, the character information is input into the second encoder that has been trained for a specific style. The second encoder processes the character information and generates a feature vector that represents the style of the specific character. The vectorized character information is input into the input layer of the second encoder. The second encoder forward propagates the character information and extracts the deep semantic features of the character information through a multi-layer neural network and attention mechanism. The output vector generated by the encoder is used as a style feature to represent the character's unique language style and conversational tone.
[0071] By inputting the character information into a specially trained second encoder, the system can extract style features from the character information specified by the user. This feature extraction method enables the system to generate dialogue text that conforms to the personalized style of different characters. The use of the second encoder makes the processing of character information highly flexible and style adaptable.
[0072] S40, fusing the content feature and the style feature to obtain a fusion feature;
[0073] In this embodiment, the content features generated from the first encoder are fused with the style features generated from the second encoder to generate a comprehensive fused feature. The fused feature can simultaneously express the user's content needs and the desired character style, providing a basis for subsequent dialogue generation. Since there is currently no "user preference profile" information, the feature fusion here mainly focuses on the unified processing of content features and style features.
[0074] Content features and style features may differ in dimension and scale, so they need to be aligned before fusion to ensure consistency between the two features when they are fused. Align the dimensions of content features and style features to make their dimension lengths consistent. For example, by using methods such as zero padding or projection matrices, shorter feature vectors are expanded to the same dimension. Standardize content features and style features to ensure that their numerical scales do not differ too much when they are fused. Standardization can be done using methods such as mean-variance normalization or Min-Max normalization.
[0075] The aligned content features and style features are fused to generate the final fused features. Feature fusion can be achieved by simple concatenation, weighted summation, or more complex feature interaction methods.
[0076] Feature fusion can be done in the following ways:
[0077] Feature concatenation: directly concatenate content features and style features in the feature dimension to form a higher-dimensional fusion feature vector. This method retains the original information of content and style.
[0078] Weighted summation of features: If the dimensions of content features and style features are consistent, weighted summation can be performed directly. For example, a fixed weight is assigned to each feature, and then they are added together to generate a fused feature.
[0079] Feature interaction processing: Use neural networks or self-attention mechanisms to take into account the interactive relationship between content features and style features, and generate high-order feature representations through model learning.
[0080] Through feature alignment and fusion processing, the system can simultaneously express the user's content needs and character style. This feature fusion method ensures that the generated dialogue not only meets the user's actual questions, but also has specific style attributes, thereby improving the system's dialogue generation effect.
[0081] S50, inputting the fused features into a decoder, generating a reply text, and outputting the reply text.
[0082] In this embodiment, the fused features are input into the decoder model to generate the final dialogue reply text. The decoder is used to generate a coherent text reply that meets the user's needs and the character's style based on the content information and character style information in the fused features. The decoder is usually a deep generative model that can generate dialogue text word by word.
[0083] The decoder model is the core component for generating dialogue text. You need to select a model suitable for the generation task and perform necessary initialization. Common decoder models include LSTM and GRU based on RNN, or more advanced Transformer and GPT. Select a suitable decoder model according to the generation requirements of the application scenario. For example, LSTM is suitable for scenarios where text coherence needs to be maintained, while Transformer or GPT are suitable for high-quality text generation scenarios after large-scale data training. Use pre-trained weights or fine-tune on text data in specific fields to enable the decoder to generate text that meets semantic and style requirements.
[0084] The fused features are used as input to the decoder so that the decoder can generate dialogue text based on these features. The fused features contain content information and character style information, so the decoder can generate text replies that meet user needs based on this information. The generated fused features are used as the input vector of the decoder and passed to the input layer of the decoder model. According to the content of the fused features, the output properties such as the length and style of the text generated by the decoder are controlled.
[0085] After receiving the fused features, the decoder generates a coherent text sequence in a word-by-word or character-by-character manner. This process can be autoregressive (such as the generation method based on Transformer or RNN), or it can be a multi-step generation based on a probability model. For decoders based on LSTM, GRU or Transformer, an autoregressive generation method is used, that is, the currently generated word will be used as input to affect the next step of generation. For decoders with self-attention mechanisms (such as Transformer), the generation process will pay attention to all parts of the fused features at the same time to ensure that the generated text is consistent with the content and style. A multi-step generation method is used to generate text sequences word by word until the end mark is generated.
[0086] Example description: In a financial intelligent customer service system, a user may enter the following request: "Can you give me some advice on the recent stock market? It is best to be conservative." In this step, the system will generate fused features and input them into the decoder to generate the reply text:
[0087] Select the Transformer-based decoder model to generate coherent and natural text replies. Input the fused features (including "stock market analysis" and "conservative style") into the input layer of the decoder. The decoder generates a reply text based on the fused features, for example: "Based on recent market data, it is recommended that you choose blue-chip stocks with lower risks for investment, which can better control risks."
[0088] By inputting the fused features into the decoder to generate the reply text, the system can generate a dialogue text that meets the user's expectations based on the content information and character style features in the fused features. This generation method ensures the coherence, style consistency and content accuracy of the reply text, and improves the system's dialogue generation quality.
[0089] The final text generated by the decoder is presented to the user. The output method can vary depending on the specific application scenario and the user's interaction method, such as text display, speech synthesis, message push, etc. The main purpose of this step is to ensure that the user can obtain the conversation content generated by the system in a timely and accurate manner.
[0090] Before outputting the generated text to the user, the system needs to format the text. Formatting includes spelling checking, grammar correction, sentence structure adjustment, etc. to ensure the standardization and readability of the output content.
[0091] Spell checking: Use a spell checking tool (such as the open source Hunspell) to check and correct the generated text.
[0092] Grammar correction: Identify and correct grammatical errors in the text through grammar checking tools (such as LanguageTool).
[0093] Sentence structure adjustment: Optimize the sentence structure of the generated text to ensure smooth content and clear expression.
[0094] Choose the appropriate output method based on the user's device and interaction method. Different output methods can better meet the needs of different scenarios. For example, directly display text on the dialogue interface, present results through voice output, or send replies through message push. For intelligent customer service systems or mobile applications, directly display the generated text content in the dialogue window of the user interface. For voice interaction devices such as smart speakers or car assistants, play the generated dialogue text through speech synthesis (such as TTS technology, which converts text into speech). For scenarios that require asynchronous interaction (such as WeChat applets, email systems, etc.), send the generated text to the user through message push.
[0095] After outputting the reply text, the system can provide further interaction options so that the user can continue the conversation with the system or get more support. Prompts such as "Continue" and "Get More Information" are displayed in the conversation window to help users interact further. Based on the user's response to the output reply (such as satisfaction rating or clicking the Continue button), the system can record the user's preference information for subsequent optimization.
[0096] By formatting the generated text, selecting the appropriate output method, and designing an effective interaction mechanism, the system can ensure that the reply text received by the user is clear, accurate, and meets the user's expectations. This flexible output method improves the system's response quality and user satisfaction.
[0097] The present invention relates to the fields of artificial intelligence technology and financial technology, and discloses a method for generating role dialogues, which receives text information, parses the text information to extract content information and role information, inputs the content information into a first encoder to generate content features, inputs the role information as style information into a second encoder to generate style features, fuses the content features and style features to obtain fusion features, and inputs the fusion features into a decoder to generate a reply text, and outputs the generated reply text. The present invention separates and independently encodes content information and role information, and subsequently combines the two features by feature fusion, so that dialogue content that conforms to different role styles can be flexibly generated, and effective decoupling of content and style is achieved, which not only ensures the accuracy of the dialogue content, but also improves the adaptability to different role styles, and meets the role-playing needs of users in various situations.
[0098] In one embodiment, in the above S10, parsing the text information and extracting content information and role information from the text information includes:
[0099] S101, perform preprocessing operations on the text information to remove stop words and special symbols;
[0100] S102, perform word segmentation on the text information after preprocessing operations to obtain a word segmentation result;
[0101] S103, perform named entity recognition on the word segmentation result to obtain a recognition result;
[0102] S104, according to a preset role keyword library, match the role keywords in the recognition result, and extract role information from the recognition result;
[0103] S105, remove the role information from the word segmentation result, and use the remaining information in the word segmentation result as content information.
[0104] In this embodiment, the text input by the user is comprehensively parsed to extract content information and role information. The content information represents the specific needs or problems of the user, while the role information represents the expected dialogue style or role attributes of the user. By separating the content information and the role information, the system can generate more accurate dialogue responses that meet the user's needs and styles.
[0105] Text preprocessing is the first step in parsing text, aiming to remove redundant and useless content, thereby improving the accuracy of subsequent parsing. It includes:
[0106] Removing stop words: Use a stop word list (such as common words like "de", "zai", "shi", etc.) to filter out words that have no actual meaning in text understanding.
[0107] Removing special symbols: Clean the special symbols (such as punctuation marks, emojis, non-verbal characters, etc.) in the text to simplify the text input.
[0108] Standardization processing: Perform basic text format standardization, such as handling capitalization, time expressions, etc.
[0109] Word segmentation processing is to break down the user's text into individual words or phrases to identify the core information and semantic structure in the text. For Chinese text, word segmentation is an important basis for parsing. According to the built-in dictionary of the system, continuous text is segmented into individual words. For words not in the dictionary, they can be segmented based on statistical models or rules. On the basis of segmentation, part-of-speech tagging is performed on each word to assist in subsequent role information recognition.
[0110] Named entity recognition is used to identify entities with specific meanings in text, such as names of people, places, and characters. Through NER, important information in the text can be identified and marked. Pre-trained named entity recognition models (such as BERT-NER, BiLSTM-CRF, etc.) are used to identify named entities such as names of people, places, and times in the text. The identified entities are marked, such as "Intimate Sister" is marked as "Character Name", and the labeled text is output.
[0111] Use the preset role keyword library to match the recognition results and extract role information from them. The role keyword library contains common role names, modal particles, etc. The system presets a keyword library, which contains role names (such as "intimate sister", "domineering president", etc.) and related modal particles. Traverse the NER recognition results and find role names or descriptions that match the role keyword library. Extract the matched keywords as role information and mark them.
[0112] Remove the extracted role information from the word segmentation results, and use the remaining part as the user's content information. Content information is the user's main needs or questions. Remove the marked role information from the word segmentation results to ensure that the remaining text only contains the user's needs. After removing the role information, concatenate the remaining words to obtain content information and prepare to pass it to the next processing module.
[0113] In this embodiment, the system can separate the user's text into content information and role information through comprehensive analysis of text information. This separation process improves the accuracy of understanding the user's intention and can flexibly identify the role style expected by the user, so that the subsequent dialogue generation is more in line with the user's needs and expectations.
[0114] In one embodiment, the above S104 includes:
[0115] S1041, performing keyword matching on the recognition result according to a preset role keyword library, and preliminarily extracting role information from the recognition result;
[0116] S1042, optimizing the initially extracted role information based on the user preference profile;
[0117] S1043, adjusting the optimized role information according to the user's preference information to generate final role information.
[0118] In this embodiment, the role information is initially extracted from the recognition results through the preset role keyword library, and the role information is optimized and adjusted based on the user preference profile to generate the final role information. The role information represents the conversation style or role attributes expected by the user. Through the optimized role information, the system can more accurately reflect the personalized needs of the user.
[0119] According to the preset role keyword library, keyword matching is performed on the named entity recognition (NER) results to preliminarily extract possible role information in the text. The role keyword library contains common role names, role-specific descriptors, etc. The role keyword library contains role vocabulary and its synonyms defined in the system (such as "investment advisor", "professional advisor", "market analyst", etc.). Keyword matching is performed on each entity in the NER recognition results to find words that are the same or related to the vocabulary in the role keyword library. The matched role keywords are extracted and marked as preliminary role information for further optimization processing.
[0120] Based on the historical data in the user preference file, optimize the initially extracted role information. The purpose of this step is to adjust and optimize the role information according to the user's preferences so that it better meets the user's actual needs. According to the user's ID or session ID, query the user preference file to obtain the user's preference information for different roles. Match the extracted preliminary role information with the preferred roles in the user preference file to determine whether it needs to be optimized and adjusted according to the user's preferences. If the user's preference information overlaps or is close to the preliminary role information, fine-tune and optimize it according to the user's preferences.
[0121] According to the user's preference information, the optimized character information is adjusted to generate the final character information. The final character information is an important basis for generating subsequent dialogue responses and can reflect the user's expectations of the character. According to the detailed records in the user preference file (such as the user's character selection history in different scenarios), the optimized character information is further adjusted. The optimized and adjusted character information is used as the final character style and output for use in subsequent steps.
[0122] Example: In a financial intelligent customer service system, a user may enter the following: "The stock market has been very volatile recently. Can you give me some advice like a professional consultant?" The system handles this as follows:
[0123] Initial role information extraction: The role keyword “consultant” is matched from “professional consultant”.
[0124] Role information optimization: By querying the user preference profile, it was found that the user preferred the "Risk Control Expert" role in the previous session.
[0125] Generate final role information: Based on user preferences, optimize the role information to “risk control expert”.
[0126] In this embodiment, by using the role keyword library to match the role keywords in the recognition results, and optimizing and adjusting the role information in combination with the user preference profile, the system can more accurately reflect the role expectations in the user's conversation. This optimization processing method not only improves the accuracy of role information recognition, but also enhances the personalized adaptability of the system.
[0127] In one embodiment, the above S20 includes:
[0128] S201, determining a first encoder obtained by training based on a corpus without personalized character style;
[0129] S202, inputting the content information into the first encoder;
[0130] S203: Encode the content information by using the first encoder to obtain content features.
[0131] In this embodiment, the parsed content information is encoded by a pre-trained first encoder to convert it into a specific content feature representation. The first encoder is used to extract the deep semantic features of the text while keeping it independent of the character style.
[0132] The goal of the first encoder is to learn and extract semantic information of the content from text without specific character style or personalized language features, without paying too much attention to emotions, character characteristics, personalized expressions, etc. This enables the first encoder to maintain neutrality to the content in dialogue generation and ensure that the extracted content features are as close to pure information expression as possible.
[0133] A corpus without a personalized character style refers to a corpus that does not show the language characteristics, expressions, emotional colors or personality characteristics of a specific character. The content of this type of corpus focuses more on the transmission of information and knowledge rather than the expression of characters. These text data are generally neutral and objective, and do not deliberately emphasize the language characteristics or style of a certain character.
[0134] This type of corpus mainly includes the following text types:
[0135] News reporting: focuses on the statement of facts and objective description of events, without containing emotions or personal characteristics.
[0136] Encyclopedia articles: provide objective information and knowledge explanations, with a neutral language style and no emotional or character expressions.
[0137] Academic papers: emphasize knowledge transfer and avoid personalized expressions and emotional content.
[0138] Technical documentation: Documents used to explain technical principles and functional descriptions, focusing on the accuracy and clarity of the content.
[0139] The selected text should avoid obvious emotional tendencies or character characteristics, such as character lines in literary works or editorial articles with strong tones. The text is mainly used to convey knowledge and information, not to guide users' emotions or form character associations.
[0140] The first encoder is determined to be trained based on a corpus without personalized character style. The encoder trained in this way can focus more on the processing of content information without involving a specific character style, so that the encoding process only focuses on the understanding of the text content. A general corpus that does not contain a specific character style (such as news text, academic papers, social conversations, etc.) is selected as the basic dataset for training the first encoder. Determine the deep learning model for the first encoder (such as BERT, LSTM, Transformer, etc.), which performs well in processing natural language text. Use a general corpus to train the model and extract general semantic features. This training ensures that the encoder will not be biased towards specific style information in subsequent tasks.
[0141] Determining whether the text in the corpus has specific emotional expression and tone characteristics, that is, determining whether it has a personalized character style can be achieved in the following ways:
[0142] You can use trained sentiment analysis models (such as VADER, TextBlob, BERT-based sentiment classifiers) to perform sentiment classification and tone analysis on texts. Use sentiment analysis models to score each text and determine its positive, negative, and neutral sentiment scores. By counting the texts in the entire corpus, evaluate whether the character style has a clear emotional tendency. Use tone recognition models (such as LSTM-based tone classification models) to detect tone categories in the text (such as serious, humorous, comforting, encouraging, etc.). Count the frequency of different tone categories in the corpus. If a specific tone appears frequently, this may indicate that the character style has obvious tone characteristics.
[0143] You can also use predefined keyword tables (character-specific keywords and phrases) to analyze the frequency of keyword occurrences in the text. Calculate the frequency of keyword occurrences in each text and calculate the average keyword frequency for the entire corpus. If the frequency of certain keywords is significantly higher than other texts, this may indicate that the corpus has a unique expression style of the character. Use dependency parsing or syntactic parsing to detect sentence structure in the text. Calculate the proportion of specific sentence patterns (such as passive sentences, interrogative sentences, emphatic sentences, etc.) in the corpus. If a specific sentence pattern appears frequently in the corpus, this may indicate the presence of the character's style.
[0144] You can also use a trained subjectivity detection model (such as an MPQA-based model) to determine the subjectivity of a text. Count the proportion of texts with high subjectivity in the corpus. If a character's corpus has high subjectivity, it means that the character's style focuses more on expressing subjective opinions or emotions. Use a sentiment classification model to classify the text and calculate the distribution of different sentiment categories. Quantify the diversity of a character's emotional expression through sentiment distribution diversity (such as information entropy or Gini coefficient). For example, a market analyst character may be more single-minded in emotion (professional and calm), while the "intimate sister" character may have more diverse emotional expressions.
[0145] The content information extracted from the user text is input into the trained first encoder for feature encoding. The content information represents the user's specific questions or needs and does not contain character or style related features. Before inputting into the first encoder, the content information needs to be vectorized by word embedding. For example, word embedding methods such as Word2Vec and BERT are used to convert the content information into a vector representation. The vectorized content information is passed to the input layer of the first encoder. The encoder receives the input vector and performs deep feature extraction on it.
[0146] The first encoder performs forward propagation processing on the content information and extracts high-dimensional semantic features from it. These features can represent the user's needs or questions. The content features will serve as an important input for subsequent dialogue generation. The vector of content information is processed through the encoder's multi-layer neural network (such as Transformer layer, LSTM layer, etc.) to extract deep semantic features. The first encoder outputs a high-dimensional content feature vector that represents the semantic and structural information of the content information. These content features will be used in the subsequent feature fusion step.
[0147] In this embodiment, by inputting content information into a pre-trained first encoder, the system can extract general semantic features that are unrelated to the character style from the content information. This processing method ensures the accurate representation of content information and provides a good foundation for subsequent feature fusion. The use of the first encoder improves the system's ability to understand user needs while reducing dependence on specific styles.
[0148] In one embodiment, the above S30 includes:
[0149] S301, determining a second encoder obtained by training based on a corpus with a personalized character style;
[0150] S302, formatting and data cleaning the role information;
[0151] S303, based on a pre-trained word vector model, converting the role information into a role feature vector;
[0152] S304, inputting the role feature vector into the second encoder;
[0153] S305: Encode the character feature vector by using the second encoder to generate a style feature.
[0154] In this embodiment, the character information input by the user is encoded by the second encoder to generate specific style features. The second encoder is trained by a corpus with personalized character styles, and its purpose is to extract feature representations related to style from the character information.
[0155] A corpus with personalized character style refers to text data that contains language features, expression habits, emotional tone, and personality traits of a specific character. This corpus can be customized and organized according to the needs and characteristics of different characters in order to train and generate corresponding character features. This corpus may include character-specific dialogues, character lines, specific types of literary works, or speeches of historical figures. For example, in order to train the corpus of the "intimate sister" character, psychological counseling dialogues and emotional comfort texts can be selected; in order to train the corpus of the "market analyst" character, financial analysis reports and professional consultant dialogues can be selected.
[0156] Characteristics of a character's style may include the following:
[0157] Personality traits: The personality traits of the character, such as gentleness, toughness, humor, decisiveness, etc. These characteristics can be reflected through the words, sentence patterns, and expressions in the text.
[0158] Language habits: the character's word habits and sentence structure. For example, "market analysts" often use data and factual support language, while "confidant sister" often uses encouraging and comforting language.
[0159] Tone and emotion: The tone of the character in the dialogue and the type of emotion expressed. Through the selection of corpus, the tone characteristics and emotional expression of different characters can be captured.
[0160] The second encoder is trained with a corpus with personalized character style, from which it can learn the character's language style, tone, expression habits and other characteristics. According to the system design, select a corpus with clear character style characteristics. For example, if the style is "intimate sister", you can choose a psychological counseling dialogue text; if the style is "domineering president", you can choose a dialogue or line text with a tough tone. Determine the deep learning model used for the second encoder, such as LSTM, GRU or Transformer. Use a corpus with specific character style characteristics to supervise the model training so that it can capture the language expression and tone characteristics of a specific character style.
[0161] Format and clean the character information to ensure the consistency and standardization of the input of character information. Data cleaning removes special symbols, irrelevant content, etc. in the character information, such as symbols in social media like "#" and "@". Formatting conversion standardizes the character information into a specific format for subsequent processing. For example, keep "Zhixin Jiejie" in Chinese or use a more unified label to represent it.
[0162] Convert the cleaned and formatted character information into a word vector representation. Word vector models (such as Word2Vec, GloVe, FastText, etc.) can convert character information into a vector representation that can be processed by machines. Select a word vector model pre-trained on a large-scale corpus to improve the accuracy of word representation. Pass the character information to the word vector model to generate character feature vectors. These feature vectors represent the semantic content and style features of the character information.
[0163] Pass the generated character feature vectors as input to the second encoder for further deep feature extraction. Input the character feature vectors into the input layer of the second encoder. Ensure that the dimension of the character feature vectors is consistent with the input requirements of the encoder for smooth feature processing.
[0164] The second encoder deeply processes the character feature vectors to generate feature vectors representing specific character styles. This style feature expresses the personalized tone, language style, etc. of the character. Feature extraction is performed on the character feature vectors through a multi-layer neural network or self-attention mechanism to generate a high-dimensional style feature representation. The encoded style feature is used as the output of the second encoder to represent the style attributes of a specific character.
[0165] In this embodiment, by inputting the character information into the second encoder trained based on the personalized character style, the system can accurately generate character style features that meet the user's needs. This feature extraction method enables the system to flexibly apply different language styles when generating conversations, meeting the user's expectations for personalized styles.
[0166] In one embodiment, the above S40 includes:
[0167] S401, perform alignment processing on the content feature and the style feature;
[0168] S402, based on the user preference profile, generate weighted coefficients for the content feature and the style feature according to the user's preference information for different characters;
[0169] S403, perform weighted processing on the content feature and the style feature based on the weighted coefficients;
[0170] S404, fusing the weighted content features and style features by feature concatenation or superposition to obtain the fused features.
[0171] In this embodiment, the content feature and the style feature are fused to generate a comprehensive fusion feature. The fusion feature contains the content information required by the user and the expected character style information, and can provide a basis for the generated dialogue content through fusion processing. In this step, it is mainly achieved through feature alignment, weighted processing and fusion.
[0172] Content features and style features may differ in dimension or scale, so alignment is required to ensure compatibility when features are fused. The purpose of this process is to ensure the dimensional consistency of features and the rationality of numerical scales. Adjust the dimensions of content features and style features to make them consistent in dimension length. For example, this can be done by zero padding or dimensionality reduction projection. Standardize or normalize the two features to ensure that their numerical scales have similar value ranges when fused. Standardization can use mean-variance normalization or maximum-minimum normalization methods.
[0173] Based on the information in the user preference file, corresponding weighting coefficients are generated for content features and style features. The generation process of weighting coefficients can be dynamically adjusted according to the user's preference for different character styles. The system stores the user's preference information for different character styles, including the user's style preferences, tone habits, etc. The weighting coefficients are dynamically generated based on the user's records in the preference file. The higher the character style preferred by the user, the larger the corresponding style feature coefficient; accordingly, the coefficient of the content feature can be fine-tuned according to the degree of preference.
[0174] Use the generated weighting coefficients to weight the content features and style features respectively. This allows the proportion of content and style in the fusion features to be flexibly adjusted according to the user's preferences. Multiply the content features with the corresponding weighting coefficients to obtain the weighted content features. Multiply the style features with the corresponding weighting coefficients to obtain the weighted style features. The weighted content features and style features will be used in subsequent feature fusion operations.
[0175] Finally, the weighted content features and style features are fused by feature splicing or superposition to generate the final fused features. The purpose of this step is to combine content and style so that the fused features can both express the specific needs of users and present a style that meets user preferences. The weighted content features and style features are directly spliced together in the feature dimension to form a high-dimensional fused feature representation. This method can maintain the independence of the two features. If the dimensions of the content features and style features are consistent, the two features can be weighted and summed to obtain a comprehensive fused feature representation. In more complex scenarios, deep neural networks (such as attention mechanisms) or other feature interaction methods can be used to enhance the expressive power of fused features.
[0176] In this embodiment, the system can generate a comprehensive fusion feature by aligning, weighting and fusing content features and style features. The fusion feature generation method can dynamically adjust the feature weight according to the user's preference information, so that the generated dialogue content can not only meet the user's needs, but also present the role style expected by the user.
[0177] In one embodiment, in the above S50, the fusion feature is input into a decoder to generate a reply text, including:
[0178] S501, calling a pre-trained decoder;
[0179] S502, inputting the fused features into the input layer of the decoder;
[0180] S503, processing the fused features through the decoder to generate a text sequence;
[0181] S504, performing grammar correction and style optimization on the text sequence to obtain a reply text that conforms to grammar and character style.
[0182] In this embodiment, the decoder processes the fused features to generate a reply text that meets the user's needs. The decoder is a pre-trained deep learning model that can generate coherent text with a specific style based on the input fused features.
[0183] The decoder model is the core of text generation. You need to select a suitable deep learning model and pre-train it to improve the accuracy and coherence of text generation. Choose a deep learning model suitable for text generation, such as LSTM, GRU, Transformer, GPT, etc. LSTM is suitable for generating coherent sentences, while GPT can generate more natural conversations. Use a large-scale corpus to pre-train the model so that the decoder can learn general text generation rules. Depending on the specific scenario, the model can be fine-tuned to adapt to specific language styles and fields.
[0184] The fused features contain the user's content information and the character's style information. Input them into the decoder, which will generate text based on these features. Make sure the dimension and format of the fused features are consistent with the decoder's input requirements. Pass the processed fused features to the input layer of the decoder model. The decoder processes the received fused features as input.
[0185] The decoder generates a text sequence character by character or word by word based on the input fused features. The generation process can be autoregressive or based on an attention mechanism. For autoregressive models (such as LSTM), the decoder generates text character by character, and the currently generated characters or words affect the next step of generation. For the Transformer-based decoder, the fused features are processed at multiple levels through the attention mechanism to generate a coherent text sequence. The decoder outputs a complete text sequence, which represents the generated result of the dialogue.
[0186] The generated text sequence may contain grammatical errors or inconsistent styles. Therefore, the generated text needs to be grammatically corrected and style optimized. For example, grammar checking tools (such as rule-based GrammarBot or deep learning-based Grammar Corrector) are used to correct grammatical errors in the text; based on the input character style information, the wording, tone, etc. in the text are adjusted to make the text style consistent with the character style expected by the user.
[0187] Output the corrected and optimized text as the reply content, ensuring the text content is accurate, grammatically correct, and in a consistent style.
[0188] In this embodiment, by inputting the fusion features into the decoder to generate the reply text, the system can generate the expected dialogue content according to the user's content requirements and character style. The generated text is grammatically corrected and style optimized to ensure the accuracy and coherence of the output text, thereby improving user satisfaction.
[0189] In one embodiment, a character dialogue generation device is provided, and the character dialogue generation device corresponds one-to-one to the character dialogue generation method in the above embodiment. Figure 3 , Figure 3 This is a functional module diagram of a preferred embodiment of the character dialogue generation device of the present invention. The text receiving and information extraction module 10, the content encoding module 20, the style encoding module 30, the feature fusion module 40 and the text generation and output module 50. The detailed description of each functional module is as follows:
[0190] The text receiving and information extracting module 10 is used to receive text information, parse the text information, and extract content information and role information from the text information;
[0191] A content encoding module 20, configured to input the content information into a first encoder to generate content features;
[0192] A style encoding module 30, used for inputting the character information as style information into a second encoder to generate style features;
[0193] A feature fusion module 40, used to fuse the content feature and the style feature to obtain a fusion feature;
[0194] The text generation and output module 50 is used to input the fusion features into the decoder, generate a reply text, and output the reply text.
[0195] In one embodiment, the text receiving and information extraction module 10 is specifically used for:
[0196] Preprocessing the text information to remove stop words and special symbols;
[0197] Perform word segmentation on the text information after the preprocessing operation to obtain the word segmentation result;
[0198] Performing named entity recognition on the word segmentation result to obtain a recognition result;
[0199] According to a preset role keyword library, matching role keywords in the recognition result, and extracting role information from the recognition result;
[0200] The role information is removed from the word segmentation result, and the remaining information in the word segmentation result is used as content information.
[0201] In one embodiment, the text receiving and information extraction module 10 is specifically used for:
[0202] According to a preset role keyword library, keyword matching is performed on the recognition results, and role information is preliminarily extracted from the recognition results;
[0203] Based on the user preference profile, the initially extracted role information is optimized;
[0204] According to the user's preference information, the optimized role information is adjusted to generate the final role information.
[0205] In one embodiment, the content encoding module 20 is specifically configured to:
[0206] Determine a first encoder obtained by training based on a corpus without a personalized character style;
[0207] inputting the content information into the first encoder;
[0208] The content information is encoded by the first encoder to obtain content features.
[0209] In one embodiment, the style encoding module 30 is specifically configured to:
[0210] Determine a second encoder trained based on a corpus with a personalized character style;
[0211] Formatting and cleaning the role information;
[0212] Based on a pre-trained word vector model, convert the role information into a role feature vector;
[0213] Inputting the character feature vector into the second encoder;
[0214] The character feature vector is encoded by the second encoder to generate a style feature.
[0215] In one embodiment, the feature fusion module 40 is specifically configured to:
[0216] Performing alignment processing on the content feature and the style feature;
[0217] Based on the user preference profile, according to the user's preference information for different roles, generating weighting coefficients of the content feature and the style feature;
[0218] Performing weighted processing on the content features and style features based on the weighted coefficients;
[0219] The weighted content features and style features are fused by feature concatenation or superposition to obtain the fused features.
[0220] In one embodiment, the text generation and output module 50 is specifically used to:
[0221] Call the pre-trained decoder;
[0222] Inputting the fused features into the input layer of the decoder;
[0223] Processing the fused features through the decoder to generate a text sequence;
[0224] The text sequence is subjected to grammar correction and style optimization to obtain a reply text that conforms to grammar and character style.
[0225] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external user terminal via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a role dialogue generation method server side.
[0226] In one embodiment, a computer device is provided. The computer device may be a user terminal, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it realizes the functions or steps of a user side of a role dialogue generation method
[0227] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0228] Receiving text information, parsing the text information, and extracting content information and role information from the text information;
[0229] Inputting the content information into a first encoder to generate content features;
[0230] Inputting the character information as style information into a second encoder to generate style features;
[0231] Fusing the content feature and the style feature to obtain a fusion feature;
[0232] The fused features are input into a decoder to generate a reply text, and the reply text is output.
[0233] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0234] Receiving text information, parsing the text information, and extracting content information and role information from the text information;
[0235] Inputting the content information into a first encoder to generate content features;
[0236] Inputting the character information as style information into a second encoder to generate style features;
[0237] Fusing the content feature and the style feature to obtain a fusion feature;
[0238] The fused features are input into a decoder to generate a reply text, and the reply text is output.
[0239] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the user side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0240] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0241] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0242] It should be noted that if software tools or components other than those of the Company appear in the embodiments of the present application, they are only used for illustration and do not represent actual use. The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the above-mentioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents; and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for generating character dialogues, characterized in that: The following steps are involved: Receiving text information, parsing the text information, and extracting content information and role information from the text information; Inputting the content information into a first encoder to generate content features; Inputting the character information as style information into a second encoder to generate style features; Fusing the content feature and the style feature to obtain a fusion feature; The fused features are input into a decoder to generate a reply text, and the reply text is output.
2. The character dialogue generation method according to claim 1, characterized in that: Parsing the text information and extracting content information and role information from the text information includes: Preprocessing the text information to remove stop words and special symbols; Perform word segmentation on the text information after the preprocessing operation to obtain the word segmentation result; Performing named entity recognition on the word segmentation result to obtain a recognition result; According to a preset role keyword library, matching role keywords in the recognition result, and extracting role information from the recognition result; The role information is removed from the word segmentation result, and the remaining information in the word segmentation result is used as content information.
3. The character dialogue generation method according to claim 2, characterized in that: According to a preset role keyword library, matching role keywords in the recognition result, and extracting role information from the recognition result, including: According to a preset role keyword library, keyword matching is performed on the recognition results, and role information is preliminarily extracted from the recognition results; Based on the user preference profile, the initially extracted role information is optimized; According to the user's preference information, the optimized role information is adjusted to generate the final role information.
4. The character dialogue generation method according to claim 1, characterized in that: Inputting the content information into a first encoder to generate content features includes: Determine a first encoder obtained by training based on a corpus without a personalized character style; inputting the content information into the first encoder; The content information is encoded by the first encoder to obtain content features.
5. The character dialogue generation method as claimed in claim 1, characterized in that: Inputting the character information as style information into a second encoder to generate style features, including: Determine a second encoder trained based on a corpus with a personalized character style; Formatting and cleaning the role information; Based on a pre-trained word vector model, convert the role information into a role feature vector; Inputting the character feature vector into the second encoder; The character feature vector is encoded by the second encoder to generate a style feature.
6. The character dialogue generation method according to claim 1, characterized in that: The content features and style features are integrated to obtain integrated features, including: Performing alignment processing on the content feature and the style feature; Based on the user preference profile, according to the user's preference information for different roles, generating weighting coefficients of the content feature and the style feature; Performing weighted processing on the content features and style features based on the weighted coefficients; The weighted content features and style features are fused by feature concatenation or superposition to obtain the fused features.
7. The character dialogue generation method according to claim 1, characterized in that: The fused features are input into the decoder to generate a reply text, including: Call the pre-trained decoder; Inputting the fused features into the input layer of the decoder; Processing the fused features through the decoder to generate a text sequence; The text sequence is subjected to grammar correction and style optimization to obtain a reply text that conforms to grammar and character style.
8. A character dialogue generation device, characterized in that: The role dialogue generating device comprises: A text receiving and information extraction module, used for receiving text information, parsing the text information, and extracting content information and role information from the text information; A content encoding module, used for inputting the content information into a first encoder to generate content features; A style encoding module, used for inputting the character information as style information into a second encoder to generate style features; A feature fusion module, used to fuse the content feature and the style feature to obtain a fusion feature; The text generation and output module is used to input the fusion features into the decoder, generate a reply text, and output the reply text.
9. A computer device, characterized in that: The computer device includes a memory, a processor, and a character dialogue generation program stored in the memory and executable on the processor. When the character dialogue generation program is executed by the processor, the steps of the character dialogue generation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The storage medium stores a character dialogue generation program, which, when executed by a processor, implements the steps of the character dialogue generation method according to any one of claims 1 to 7.