An intelligent text dialogue generation method and device based on artificial intelligence
By using an attention-based Transformer model and optimizing user sentiment and user profiles, this method addresses the shortcomings of existing text dialogue generation methods in terms of fluency and versatility when faced with diverse natural language expressions, achieving more accurate responses and enhanced user engagement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG POWER GRID CO LTD INFORMATION CENT
- Filing Date
- 2025-03-05
- Publication Date
- 2026-07-21
AI Technical Summary
Existing text dialogue generation methods lack fluency and versatility when faced with diverse and flexible natural language expressions, making it difficult to provide accurate responses and adaptability.
The target business model is trained using an attention-based Transformer model. Combined with user sentiment information and user profiles, the initial response dialogue text is personalized and optimized. Through text semantic parsing, business domain matching, and sentiment adjustment, the target response dialogue text that meets user needs is generated.
It improves the fluency and versatility of the dialogue system, enabling it to more accurately capture complex and varied natural language expressions and enhance user engagement with the dialogue system.
Smart Images

Figure CN120144715B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to an intelligent text dialogue generation method and apparatus based on artificial intelligence. Background Technology
[0002] With the continuous development of artificial intelligence technology, text-based dialogue systems have been widely used in many fields, such as intelligent customer service and intelligent chatbots.
[0003] Existing text dialogue generation methods are mainly rule-based and retrieval-based. Rule-based methods match user input text with pre-defined dialogue rules and templates. However, fixed rules and templates struggle to handle diverse and flexible natural language expressions. For example, if a user's expression deviates slightly from the preset rules, an accurate response may not be provided, resulting in poor fluency of the dialogue system. Retrieval-based methods retrieve questions similar to the user's input text from a pre-built dialogue corpus to generate answers. However, the corpus has limited coverage; if new topics or novel expressions not included in the corpus are encountered, appropriate answers may not be provided, severely impacting the versatility and adaptability of the dialogue system. Summary of the Invention
[0004] This invention provides an intelligent text dialogue generation method and apparatus based on artificial intelligence, which improves the fluency, versatility and adaptability of dialogue systems and increases user stickiness to the dialogue system.
[0005] In a first aspect, the present invention provides an intelligent text dialogue generation method based on artificial intelligence, comprising:
[0006] The text semantics of the question dialogue text input by the target user are analyzed to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0007] The target business model is obtained by matching the business domain information in a preset business model library; the target business model is trained on an attention-based Transformer model based on the semantics of the sample text and the labeling results of the corresponding response dialogue text.
[0008] The semantic information of the text is input into the target business model to obtain the initial response dialogue text output by the target business model;
[0009] Based on the user's emotional information, the initial response dialogue text is emotionally adjusted to obtain an intermediate response dialogue text that matches the emotional tendency of the target user.
[0010] Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text, which is then fed back to the target user. The user profile is constructed based on the target user's historical information analysis of personality characteristics and interests.
[0011] Secondly, the present invention also provides an intelligent text dialogue generation device based on artificial intelligence, applied to the intelligent text dialogue generation method based on artificial intelligence as described in the first aspect; the intelligent text dialogue generation device based on artificial intelligence includes:
[0012] The semantic parsing module is used to perform text semantic parsing on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0013] The model matching module is used to match the business domain information in a preset business model library to obtain the target business model; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text.
[0014] The model prediction module is used to input the text semantic information into the target business model to obtain the initial response dialogue text output by the target business model;
[0015] The text adjustment module is used to adjust the initial response dialogue text based on the user's emotional information to obtain an intermediate response dialogue text that matches the emotional tendency of the target user.
[0016] The text optimization feedback module is used to personalize and optimize the intermediate response dialogue text based on the current dialogue context and the user profile of the target user, so as to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interest preferences.
[0017] Thirdly, the present invention also provides an electronic device, comprising: a memory for storing computer software programs; and a processor for reading and executing the computer software programs, thereby realizing the artificial intelligence-based intelligent text dialogue generation method as described above.
[0018] Fourthly, the present invention also provides a non-transitory computer-readable storage medium storing a computer software program, which, when executed by a processor, implements the artificial intelligence-based intelligent text dialogue generation method described above.
[0019] Fifthly, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-mentioned intelligent text dialogue generation methods based on artificial intelligence.
[0020] The intelligent text dialogue generation method based on artificial intelligence provided in this invention predicts the semantic information of text through a target business model trained using a Transformer model based on an attention mechanism. Because the multi-head attention mechanism can simultaneously focus on different semantic levels of the text, the target business model has a more comprehensive and in-depth understanding of the input text. When faced with complex and varied natural language expressions, it can more accurately capture key information, thus accurately outputting response dialogue text and improving the fluency of the dialogue system. On the other hand, by matching the corresponding target business model with business domain information from the user's input text, and by personalizing and optimizing the initial response dialogue text based on user sentiment information, the current dialogue context, and the user's profile, a final target response dialogue text that meets the user's needs is obtained. This better addresses the dialogue needs of various scenarios and topics, no longer limited to searching a specific corpus, improving the flexibility and versatility of the dialogue system, and thus increasing user stickiness to the dialogue system. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the intelligent text dialogue generation method based on artificial intelligence provided in an embodiment of the present invention.
[0022] Figure 2 This is a schematic diagram of the structure of the intelligent text dialogue generation device based on artificial intelligence provided in an embodiment of the present invention;
[0023] Figure 3 An embodiment diagram of the electronic device provided in this invention;
[0024] Figure 4 An embodiment diagram of a computer-readable storage medium provided in accordance with the present invention. Detailed Implementation
[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified. In the description of this invention, the term "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this invention is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. In the following description, details are set forth for illustrative purposes. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed herein.
[0027] See Figure 1 , Figure 1 This is a flowchart illustrating the intelligent text dialogue generation method based on artificial intelligence provided by the present invention. In this embodiment of the invention, the executing entity of the intelligent text dialogue generation method based on artificial intelligence is an intelligent dialogue device. Therefore, the intelligent text dialogue generation method based on artificial intelligence includes:
[0028] Step 10: Perform text semantic analysis on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information, and business domain information of the question dialogue text.
[0029] The intelligent dialogue device in this embodiment of the invention provides an intelligent dialogue interface. Therefore, when a user engages in intelligent dialogue with the device, they need to input corresponding text into the interface. Thus, the intelligent dialogue device can receive question dialogue text input by the target user.
[0030] Furthermore, the intelligent dialogue device performs lexical analysis on the question dialogue text, segmenting it into multiple individual words. Then, it generates a corresponding word vector representation for each word using a pre-defined word vector model, such as the FastText word vector model or the ELMo (Embeddings from Language Models) word vector model. ,in, Indicates the sequence number of the word in the question dialogue text.
[0031] Furthermore, the intelligent dialogue device constructs a syntax tree through syntactic analysis to determine the grammatical relationships between words. For each node in the syntax tree (corresponding to a word or phrase), a grammatical weight is assigned based on its level in the syntax tree and its relationship with adjacent nodes. Among them, syntax weight The value can be set from 0 to 1, with higher weights for elements closer to the root of the syntax tree and associated with important syntactic components.
[0032] Furthermore, the intelligent dialogue device identifies semantic roles (such as agent, patient, etc.) in the question dialogue text through semantic role labeling methods, and assigns role weights to each semantic role. Role weight The value ranges from 0 to 1, and is set according to the importance of the role.
[0033] Furthermore, the intelligent dialogue device uses the word vector representation of each word in the question dialogue text. Syntax weight and role weight Constructing textual semantic information of question dialogue text The textual semantic information of the question dialogue text It can be represented as:
[0034] ;
[0035] in, This indicates the total number of words in the question dialogue text.
[0036] Optionally, the intelligent dialogue device of this embodiment of the invention pre-constructs an emotion dictionary, wherein the emotion dictionary includes positive, negative, and neutral emotion words and corresponding emotion intensity values, such as positive words having an intensity range of [value missing]. negative words are The number of neutral words is 0.
[0037] Furthermore, the intelligent dialogue device performs word matching on the question dialogue text based on the sentiment dictionary to obtain the sentiment intensity corresponding to the sentiment words matched in the question dialogue text. Furthermore, the intelligent dialogue device determines the location information of sentiment words in the question dialogue text, and assigns corresponding positional weights to the sentiment words based on the location information. For example, the closer an emotion word is to the beginning or end of the question dialogue text, the higher its positional weight, ranging from 0 to 1. Furthermore, the intelligent dialogue device determines the text type of the question dialogue text and assigns tone weights to emotion words within the text based on the text type. The text types include declarative sentences, interrogative sentences, and exclamatory sentences. For declarative sentences, the tone weight is... For interrogative sentences, the weight of tone. For exclamatory sentences, the weight of tone is... .
[0038] Furthermore, intelligent dialogue devices can adjust their functions based on the intensity of emotions. Position weight and tone weight Determine the user's emotional information in the question dialogue text. User sentiment information It can be represented as:
[0039] ;
[0040] in, This indicates the number of sentiment words matched in the question dialogue text.
[0041] Optionally, the intelligent dialogue device of this embodiment of the invention has a pre-built database of business domain keywords. Each business domain corresponds to a set of representative keywords and their weights. The weights are set according to the importance and typicality of the keyword to the domain, and can be set to a range of 0 to 1.
[0042] Furthermore, the intelligent dialogue device uses the TF-IDF algorithm to extract keywords from the question dialogue text, thus obtaining the keywords in the question dialogue text. Keywords are determined based on a keyword library for the business domain. weight Furthermore, intelligent dialogue devices based on keywords and their weights Determine keywords Match score Match score The calculation formula is as follows:
[0043] ;
[0044] in, Indicates business area, This indicates the number of keywords extracted that are relevant to the business domain.
[0045] Furthermore, the intelligent dialogue device will assign the highest matching score. The corresponding business domain is then used to convert the domain title text into the business domain information to which the question dialogue text belongs. .
[0046] Step 20: Match the target business model in the preset business model library based on the business domain information.
[0047] Optionally, the intelligent dialogue device of this embodiment of the invention has a pre-built business model library, which includes multiple business models. Therefore, the intelligent dialogue device traverses each business model in the pre-built business model library. Corresponding business domain label and the business domain information of the question dialogue text With each business model Business Area Labeling Similarity calculations are performed to obtain each business model. similarity value Among them, similarity value It can be calculated using the cosine similarity algorithm, with a value ranging from 0 to 1.
[0048] Furthermore, the intelligent dialogue device traverses each business model in the business model library. similarity value The highest similarity value The corresponding business model is determined as the target business model. .
[0049] In this embodiment of the invention, the target business model is trained on the Transformer model based on the semantics of the sample text and the labeling results of the corresponding response dialogue text, as described in steps 60 to 90.
[0050] Step 30: Input the text semantic information into the target business model to obtain the initial response dialogue text output by the target business model.
[0051] Furthermore, the intelligent dialogue device inputs textual semantic information into the target business model. The target business model processes the textual semantic information through an attention mechanism and outputs the initial response dialogue text of the question dialogue text. Therefore, the intelligent dialogue device can obtain the initial response dialogue text output by the target business model, as described in steps 301 to 303.
[0052] Step 40: Based on the user's emotional information, perform emotional adjustment on the initial response dialogue text to obtain an intermediate response dialogue text that matches the emotional tendency of the target user.
[0053] Furthermore, the intelligent dialogue device adjusts the initial response dialogue text based on the user's emotional information to obtain an intermediate response dialogue text that matches the target user's emotional tendency, as described in steps 401 to 404.
[0054] Step 50: Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text and then fed back to the target user.
[0055] Optionally, the intelligent dialogue device pre-builds a user profile for each user and binds each user profile with its user identifier. Subsequently, it can directly match the target user's user profile based on the target user's user identifier. The user profile construction process is as follows: Obtain the user's historical information, including historical conversation records and browsing behavior. Further, extract personality traits and interests from the historical information using data mining and analysis techniques. Based on these personality traits and interests, a user profile is constructed. Personality traits include, for example, the degree of extroversion. Values range from 0 to 1; degree of decisiveness in decision-making. Values range from 0 to 1. Interest preferences can be represented using interest vectors. This indicates the degree of preference for different interest areas corresponding to each dimension, with values ranging from 0 to 1.
[0056] Furthermore, the intelligent dialogue device extracts key elements from the current dialogue context, as well as the personality traits and interests of the target user's user profile. Based on these key elements, the device personalizes and optimizes the intermediate response dialogue text to obtain the target response dialogue text. Further, the intelligent dialogue device, through an intelligent interactive interface, feeds back the target response dialogue text as the answer to the question dialogue text to the target user, as described in steps 501 to 503.
[0057] This invention employs a target business model trained using an attention-based Transformer model to predict text semantic information. Because the multi-head attention mechanism can simultaneously focus on different semantic levels of the text, the target business model gains a more comprehensive and in-depth understanding of the input text. When faced with complex and varied natural language expressions, it can more accurately capture key information, thus accurately outputting response dialogue text and improving the fluency of the dialogue system. Furthermore, by matching the corresponding target business model with business domain information from the user's input text, and by personalizing and optimizing the initial response dialogue text based on user sentiment information, the current dialogue context, and the user's profile, a final target response dialogue text that meets the user's needs is obtained. This better addresses the dialogue needs of various scenarios and topics, moving beyond the limitations of searching a specific corpus and improving the flexibility and versatility of the dialogue system. Therefore, it can increase user engagement with the dialogue system.
[0058] In one embodiment, steps 301 to 303 are described as follows:
[0059] Step 301: Preprocess the text semantic information, obtain the position encoding vector corresponding to the text vector at each position in the text semantic information, and add the text vector at each position in the text semantic information and its corresponding position encoding vector element by element to obtain the position encoded text semantic information.
[0060] Optionally, the target business model in this embodiment of the invention is trained based on a Transformer model with an attention mechanism. The Transformer model includes an encoder and a decoder.
[0061] For the encoder section, the encoder receives the semantic information of the input text. Textual semantic information The dimension is The features are extracted and encoded through multiple encoder layers. Each encoder layer contains a first multi-head attention module and a feed-forward network module, and residual connections and layer normalization operation modules are added between the two modules.
[0062] For the decoder part, the decoder consists of multiple decoder layers. In addition to the second multi-head attention mechanism module, the feedforward neural network module, and the corresponding residual connection and layer normalization operation module, each decoder layer also has an additional third multi-head attention mechanism module for focusing on the encoder output. Combining the features encoded by the semantic information of the input text, the response dialogue text is generated step by step.
[0063] In transferring textual semantic information Input into the target business model Before the encoder, positional encoding is required because the Transformer model itself does not explicitly model the positional information of the input sequence. Therefore, intelligent dialogue devices need to perform positional encoding on the semantic information of the text. Preprocessing is performed to obtain text semantic information. The Middle Text vectors at each position (dimension is) The corresponding positional encoding vector (dimension is) During preprocessing, for dimensions... Each dimension in , The processing formula is as follows:
[0064] .
[0065] Furthermore, intelligent dialogue devices will input semantic information from the text. Each text vector in Its corresponding position encoding vector By adding elements one by one, we obtain the position-encoded input vector. The semantic information of the entire position after encoding .
[0066] Step 302: Input the semantic information of the location-encoded text into the target business model. Each encoder layer in the encoder performs feature extraction and encoding transformation on the semantic information of the location-encoded text through the first multi-head attention mechanism module, the feedforward neural network module, and the residual connection and layer normalization operation module to generate the final encoder output.
[0067] Furthermore, the semantic information of the location-encoded text is input into the target business model. For each encoder layer in the encoder, the encoder layer performs feature extraction and encoding transformation on the semantic information of the location-encoded text through the first multi-head attention mechanism module, the feedforward neural network module, and the residual connection and layer normalization operation module. After being processed by N encoder layers in sequence, the final encoder output is generated.
[0068] The calculation process for the encoder layer in the encoder:
[0069] The position-encoded semantic information of the text is processed through the first multi-head attention mechanism module. The query vectors are obtained through linear transformation. Key vector Value vector .
[0070] In one embodiment, , , There are three different learnable weight matrices (all with different dimensions). , (The number of heads in a multi-head attention mechanism), therefore, the query vector Key vector Value vector The calculation process is as follows:
[0071] ; ; ;
[0072] Therefore, the semantic information of the text after location encoding Dimensions Mapping to the dimension of multi-head attention mechanism And divide it into Size (the dimensions of each head are...) ),Right now , , .
[0073] Furthermore, for each head Calculate attention score :
[0074] ;
[0075] in, The function is used to normalize the attention scores so that their sum is 1. This is to scale the dot product result and avoid problems such as gradient vanishing caused by excessively large values.
[0076] Furthermore, the attention output of each head is... By concatenating the data, we obtain the output of the first multi-head attention mechanism. Dimensions return And then through linear transformation of the weight matrix (dimension is) Convert: .
[0077] Furthermore, the first multi-head attention mechanism will be output. Input to a feedforward network and obtain its output. A feedforward neural network consists of two linear transformation layers and an activation function. The weight matrix of the first linear transformation is... (dimension is) The weight matrix of the second linear transformation is (dimension is) The intermediate activation function is a preset nonlinear function. Among them, nonlinear functions, such as complex functions that combine the characteristics of polynomial and exponential functions, are output by feedforward neural networks. The calculation is as follows:
[0078] .
[0079] Furthermore, residual connections and layer normalization are added before and after the multi-head attention mechanism and the feedforward neural network, respectively, to help the model train better and avoid gradient vanishing or exploding problems. For the output of the multi-head attention mechanism... The semantic information of the text after encoding the position of its input The output after residual connection and layer normalization for: .
[0080] in, The representation layer normalization operation normalizes each dimension of the vector.
[0081] Similarly, for the output of the feedforward neural network and its input multi-head attention mechanism output The final output of the encoder layer is : .
[0082] After processing through N encoder layers, the final encoder output representation is obtained. .
[0083] Step 303: The final encoder output is input to the decoder. Each decoder layer in the decoder generates the initial response dialogue text by combining the semantic information of the position-encoded text and the final encoder output through the second multi-head attention mechanism module, the feedforward neural network module, the residual connection and layer normalization operation module, and the third multi-head attention mechanism module.
[0084] The first multi-head attention mechanism (the second multi-head attention mechanism module) in the decoder is a masked multi-head attention mechanism module, used to avoid seeing future information when generating response dialogue text. The second multi-head attention mechanism (the third multi-head attention mechanism module) in the decoder is a multi-head attention mechanism module that focuses on the final encoder output of the encoder.
[0085] The computation process of the mask multi-head attention mechanism module is similar to that of the multi-head attention mechanism in the encoder, but it differs in the calculation of the attention score. At this time, a mask matrix needs to be added. (mask matrix) The upper triangular part of the mask matrix has negative infinity elements. The lower triangular part is 0, mask matrix (The diagonal elements are 0, and the dimension is the same as the attention score matrix), so that when performing... During normalization, the information weight of future positions becomes 0, that is:
[0086] ;
[0087] The subsequent splicing, linear transformation, residual connection, and layer normalization operations are consistent with the multi-head attention mechanism in the encoder, yielding the mask multi-head attention mechanism output. .
[0088] Furthermore, the decoder's second multi-head attention mechanism is used to focus on the encoder's final encoder output. Its calculation method is similar to that of ordinary multi-head attention mechanisms, and it outputs the mask multi-head attention mechanism. as query vector The encoder output As key vectors Sum value vector Calculations are performed to obtain the output of the second multi-head attention mechanism. It also undergoes residual connection and layer normalization operations.
[0089] Furthermore, the second multi-head attention mechanism will be output. The feedforward neural network in the input decoder performs the same computation as the feedforward neural network in the encoder, obtaining the output after activation function and linear transformation. After residual connection and layer normalization operations, the output of the final decoder layer is obtained. .
[0090] After being processed sequentially by Y decoder layers, the final decoder output representation is obtained. .
[0091] Furthermore, the initial response dialogue text is generated, and the final decoder outputs it. The dimensions need to be converted to match the vocabulary dimensions of the response dialogue text. In one embodiment, the vocabulary size is [size missing]. Through a linear transformation layer (weight matrix) , dimension )Will Mapping to the vocabulary space yields the probability distribution of each word. :
[0092] ;
[0093] Furthermore, from the probability distribution of each word A sampling method that combines factors such as the entropy value of the probability distribution and the diversity of historically generated words. Determine the vocabulary, generate the initial response dialogue text word by word, until an end marker (e.g., ...) is generated. <eos>Up to this point, the specific sampling process can be represented as follows:
[0094] ;
[0095] in, This indicates the initial response dialogue text. Indicates a connection operation. Indicates the generated first One word, Indicates the first The probability distribution of each word Indicates the length of the initial response dialogue text.
[0096] In this embodiment of the invention, a target business model trained using an attention-based Transformer model is used to predict text semantic information. Since the multi-head attention mechanism can simultaneously focus on different semantic levels of the text, the target business model has a more comprehensive and in-depth understanding of the input text. When faced with complex and varied natural language expressions, it can more accurately capture key information, thus accurately outputting response dialogue text, improving the fluency of the dialogue system, and increasing user stickiness to the dialogue system.
[0097] In one embodiment, steps 401 to 404 are described as follows:
[0098] Step 401: Perform lexical analysis on the initial response dialogue text to obtain multiple words in the initial response dialogue text, and determine the sentiment intensity of each word in the pre-built sentiment dictionary, as well as the importance weight and semantic role weight of the sentiment words in the initial response dialogue text.
[0099] Optionally, the intelligent dialogue device can process the initial response dialogue text. Perform lexical analysis on the initial response dialogue text. Segment into multiple words For each word The system searches the sentiment dictionary for matching sentiment words. If found, it records the corresponding sentiment intensity. (Based on the intensity rating values in the dictionary) and the initial sentiment vector (Obtained from the constructed sentiment word vector space). Simultaneously, syntactic analysis is used to determine the grammatical role and importance weight of the sentiment word in the sentence. (For example, the weight of sentiment words in the subject position is higher than that in the object position, and a weight value ranging from 0 to 1 can be set according to syntactic rules), as well as the semantic role weight of the sentence in which it is located. (For example, the semantic role of the emotional word of the agent who performs the core action has a higher weight, and the value range is set from 0 to 1).
[0100] Step 402: Normalize the user sentiment information to obtain normalized user sentiment information, and determine the sentiment adjustment coefficient based on the normalized user sentiment information.
[0101] Furthermore, intelligent dialogue devices can process users' emotional information. (The value range may vary depending on the calculation method; for example, -5 to 5 represents the degree of negative to positive sentiment.) Normalization is performed to ensure the value range is between 0 and 1, resulting in normalized user sentiment information. The specific normalization formula is as follows:
[0102] ;
[0103] Furthermore, the intelligent dialogue device uses normalized user emotional information... Calculate the sentiment adjustment coefficient In this embodiment of the invention, to achieve more refined emotion adjustment, the adjustment coefficient is divided into multiple levels. For example, when hour, (Corresponds to mild emotional adjustment, mainly for situations approaching neutral emotions); When hour, (Moderate emotional adjustment); When hour, (High emotional adjustment, where the coefficient level can be adjusted and optimized according to the actual business scenario and the need for sensitivity to emotional adjustment.)
[0104] Step 403: Determine the target sentiment tendency based on the positive or negative nature of the user's sentiment information, and determine the target sentiment vector based on the target sentiment tendency.
[0105] Furthermore, intelligent dialogue devices can utilize user emotional information. The positive or negative value determines the target's sentiment tendency. If the user's sentiment information... If the target sentiment vector indicates that the user has a positive emotional tendency, then... The vectors should be selected from a set of positive sentiment words. Specifically, the selection method could be based on the sentiment intensity level, choosing words that align with the user's sentiment information. The center vector corresponding to the intensity level (e.g., for moderate positive sentiment, the average vector of the set of word vectors for moderate positive sentiment is selected as the target sentiment vector). If user sentiment information Then, the corresponding target sentiment vector is selected from the set of negative sentiment word vectors. The selection method is similar. If user sentiment information... (Approaching neutral emotion), then the target emotion vector remains unchanged (i.e.) The main approach is to fine-tune the response text through grammatical and semantic role weighting, rather than making significant changes to the sentiment.
[0106] Furthermore, considering that user emotions may not be absolutely positive or negative, but rather exist on a continuous spectrum, the target emotion vector... Dynamic adjustments can be made. For example, when user emotional information... When the emotion is between two emotion intensity levels, the target emotion vector is determined by linear interpolation. In one embodiment, when user emotional information Based on the level of emotional intensity And emotional intensity level Between them, the corresponding target sentiment vectors are respectively and Then the target sentiment vector It can be represented as:
[0107] ;
[0108] Therefore, the target sentiment vector can be more accurately matched to the user's sentiment tendency.
[0109] Step 404: Perform sentiment adjustment on each word based on the sentiment adjustment coefficient, the target sentiment vector, and the importance weight and semantic role weight of each word to obtain the adjusted word vector, and generate an intermediate response dialogue text that matches the sentiment tendency of the target user based on the adjusted word vector.
[0110] Furthermore, regarding the initial response dialogue text Each word in If it is identified as an emotion word (i.e., it exists in the emotion dictionary), the emotion adjustment coefficient determined above will be applied. and target sentiment vector Calculate the adjusted word vectors The specific calculation formula is as follows:
[0111] ;
[0112] The multiplication by grammatical weight and semantic role weight in the above formula is to make differentiated adjustments based on the importance and semantic role of words in the sentence when adjusting word vectors, so that the sentiment adjustment is more in line with the linguistic logic and semantic expression.
[0113] Furthermore, after completing the word vector adjustments for all sentiment words, the adjusted word vectors will be... Recombined, it is transformed into intermediate response dialogue text through a language generation model (such as a neural network-based language generator trained on a large corpus, which can convert word vector sequences into natural language text). During the generation process, the language generation model considers the grammatical structure, semantic coherence, and contextual information of the sentence to ensure that the adjusted text is natural and fluent in language expression, while accurately reflecting the effect of emotional adjustment based on the user's emotional information.
[0114] The embodiments of the present invention more accurately adjust the initial response dialogue text based on user emotional information, making it more in line with the user's emotional expectations and communication context, improving the interaction quality and user experience of the dialogue system, and increasing user stickiness to the dialogue system.
[0115] In one embodiment, steps 501 to 503 are described as follows:
[0116] Step 501: Extract key elements from the current dialogue context, as well as personality traits and interests from the user profile.
[0117] Optionally, the intelligent dialogue device extracts key elements from the current dialogue context, including the dialogue turn. Dialogue topic relevance score and conversation time Dialogue rounds Use numbers to represent the round of dialogue; dialogue topic relevance score. The correlation between the current dialogue topic and historical dialogue topics is determined based on a pre-defined topic model, with values ranging from 0 to 1. The algorithm in the pre-defined topic model is a cosine similarity algorithm, indicating a high correlation between the current dialogue topic and historical dialogue topics. If the relevance is low, then the reply can cite more of the previously discussed details; if the relevance is low ( If so, the response should focus more on independently addressing the current topic of the conversation; conversation time This can be transformed into business-related time characteristics, such as whether it is during peak business periods.
[0118] Furthermore, intelligent dialogue devices extract personality traits and interests from user profiles, such as the degree of extroversion. Values range from 0 to 1; degree of decisiveness in decision-making. Values range from 0 to 1. Interest preferences can be represented using interest vectors. This indicates the degree of preference for different interest areas corresponding to each dimension, with values ranging from 0 to 1.
[0119] Step 502 involves constructing a contextual feature vector based on the dialogue rounds, dialogue topic relevance scores, and dialogue time; constructing a personalized weight vector based on personality extroversion, decision-making decisiveness, and interest preferences; and converting the intermediate response dialogue text into corresponding text vector representations.
[0120] Furthermore, the intelligent dialogue device constructs a contextual feature vector based on the number of dialogue rounds, the relevance score of the dialogue topic, and the dialogue time. It should be noted that in practical applications, the dimensions of the contextual feature vector are not limited to the number of dialogue rounds, dialogue topic relevance scores, and dialogue time mentioned above. Furthermore, the intelligent dialogue device determines the component weights of personality extroversion, decision-making decisiveness, and interest preferences according to business needs, and constructs a personalized weight vector based on these component weights. Furthermore, the intelligent dialogue device will respond with the dialogue text in between. This is converted into a corresponding text vector representation, similar to the text vector conversion method described above. .
[0121] Step 503: Based on the context feature vector, personalized weight vector and text vector representation, the fusion is performed to obtain the fused text vector representation, and the fused text vector representation is converted into natural language text form to obtain the target response dialogue text.
[0122] Furthermore, the intelligent dialogue device fuses contextual feature vectors, personalized weight vectors, and text vector representations to incorporate contextual and user profile features into the text, resulting in a fused text vector representation. Among them, the fused text vector representation It can be represented as:
[0123] ;
[0124] in, This represents the vector dot product operation. This indicates a vector concatenation operation.
[0125] Furthermore, the intelligent dialogue device will integrate the fused text vector representation. Convert it into natural language text to obtain the target response dialogue text.
[0126] This invention incorporates current context and user profile features into the intermediate response dialogue text for personalized optimization, resulting in a final target response dialogue text that meets user needs. This better addresses the dialogue requirements of various scenarios and topics, making the dialogue text more aligned with users' emotional expectations and communication contexts, improving the interaction quality and user experience of the dialogue system, and increasing user stickiness to the dialogue system.
[0127] In one embodiment, steps 60 to 90 are described as follows:
[0128] Step 60: Input multiple initial sample training data pairs into the data filtering model and obtain the loss function value of each initial sample training data pair output by the data filtering model.
[0129] Specifically, the intelligent dialogue device acquires multiple initial sample training data pairs, wherein each initial sample training data pair includes sample dialogue text and its response dialogue text.
[0130] Furthermore, the intelligent dialogue device inputs multiple initial sample training data pairs into a pre-trained data filtering model, and obtains the first loss function value of each initial sample training data pair output by the data filtering model. In one embodiment, the label sequence probability distribution of the initial sample training data pairs output by the data filtering model is as follows: ,in, This indicates the number of initial sample training data pairs. Indicates the first The probability of the label sequence for each initial training data pair, and the true label sequence for each initial training data pair. , Indicates the first The loss function of the data filtering model is: The true labels corresponding to the response dialogue text of each initial training data pair are given by:
[0131] ;
[0132] Wherein, it represents the first The first loss function value for each initial training data pair. Represents the predicted probability distribution Corresponding to real tags The probability value.
[0133] Step 70: Iterate through the first loss function value of each initial sample training data pair, and determine the target sample training data pair by the initial sample training data pair whose first loss function value is less than the first preset loss threshold.
[0134] Furthermore, the intelligent dialogue device iterates through the first loss function value of each initial sample training data pair, removes initial sample training data pairs whose first loss function value is greater than or equal to the first preset loss threshold, and retains initial sample training data pairs whose first loss function value is less than the first preset loss threshold, thus obtaining the target sample training data pair of the initial sample training data pairs. The first preset loss threshold is set according to actual conditions, such as 0.05, 0.08, etc.
[0135] Step 80: Extract the text semantics of the sample dialogue text in each target sample training data pair, and label the result label of the response dialogue text in each target sample training data pair.
[0136] Furthermore, the intelligent dialogue device extracts the textual semantics of the mid-sample dialogue text in each target sample training data pair. The specific process is as follows: For each target sample training data pair mid-sample dialogue text... Lexical analysis and word vector mapping are performed using the CW2Vec word vector model to map each word... ( In the sample dialogue text The first in (a number of words) are mapped to a d-dimensional vector. Then through semantic combination functions Construct the entire sample dialogue text Text semantic representation Among them, text semantic representation for:
[0137] ;
[0138] in, Represents sample dialogue text The number of words in the semantic combination function It can be a function based on a weighted sum of a syntax tree structure and word vectors; therefore, text semantic representation... for:
[0139] ;
[0140] in, It is based on each word In sample dialogue text Depth in the syntax tree And each word Part of speech importance The calculated weights are obtained using the following formula.
[0141] .
[0142] Furthermore, the intelligent dialogue device labels the response dialogue text in each target sample training data pair with a result label, specifically as follows: The target sample training data is paired with the sample dialogue text... Corresponding reply dialogue text Convert to a sequence of labels and construct a vocabulary containing all possible response words. The reply dialogue text Each word in Mapping to a vocabulary Index in The reply dialogue text label sequence , This is the reply to the dialogue text. The quantity.
[0143] Step 90: Based on the text semantics and the result labels of the response dialogue text in each target sample training data pair, train the Transformer model to obtain the target business model.
[0144] Furthermore, the intelligent dialogue device trains the Transformer model based on the text semantics and the result labels of the response dialogue text in each target sample training data pair to obtain the target business model. The specific training process is as follows: The constraints for the Transformer model training process are set as follows: the loss function value of each target sample training data pair is less than or equal to the second preset loss threshold, and the difference between two adjacent second loss function values is less than or equal to the preset difference threshold. The second preset loss threshold and the preset difference threshold can be set according to actual conditions.
[0145] Therefore, the intelligent dialogue device inputs the text semantics and the result label of the response dialogue text in each target sample training data pair into the Transformer model. The Transformer model makes predictions based on the text semantics in each target sample training data pair to obtain the prediction result for each target sample training data pair.
[0146] Furthermore, the Transformer model calculates a second loss function value for each target sample training data pair based on the prediction results and the result labels of the response dialogue text, using the loss function within the Transformer model. Therefore, the intelligent dialogue device can obtain the second loss function value of each target sample training data pair output by the Transformer model. The loss function of the Transformer model is:
[0147] ;
[0148] in, Indicates the first The second loss function value for each pair of target sample training data. Indicates the first The result labels for each pair of target sample training data. Indicates the first The predicted values of the training data pairs for each target sample.
[0149] Furthermore, the intelligent dialogue device compares the second loss function value of each target sample training data pair with the second preset loss threshold to obtain the comparison result, and calculates the difference between the loss function values of two adjacent target sample training data pairs.
[0150] Furthermore, if, based on the second loss function value of each target sample training data pair, and / or the difference between the loss function values of two adjacent target sample training data pairs, it is determined that the constraint condition is not met—that is, at least one target sample training data pair has a second loss function value greater than a second preset loss threshold, and / or at least one adjacent target sample training data pair has a loss function value greater than a preset difference threshold—the intelligent dialogue device updates the parameters in the objective optimization function of the Transformer model, whereby the objective optimization function of the Transformer model is:
[0151] ;
[0152] in, The model represents the first time. Step parameters, The model represents the first time. Step parameters; The model represents the first time. The learning rate of each step, and it increases with the number of steps. The increase in learning rate Decreasing; This indicates the preset momentum parameter. The model represents the first time. gradient of step, The model represents the first time. gradient of step, This represents the initial learning rate. The model represents the first time. The preset attenuation coefficient for each step.
[0153] Furthermore, the intelligent dialogue device calculates the second loss function value for each target sample training data pair based on the adjusted Transformer model, until the second loss function value of each target sample training data pair and the difference between two adjacent second loss function values satisfy the constraint condition, that is, the loss function value of each target sample training data pair is less than or equal to the second preset loss threshold, and the difference between two adjacent second loss function values is less than or equal to the preset difference threshold, thus obtaining the target business model.
[0154] This invention trains a Transformer model with an attention mechanism to obtain a target business model. Therefore, the target business model can be used to predict the semantic information of the text. Since the multi-head attention mechanism can simultaneously focus on different semantic levels of the text, the target business model has a more comprehensive and in-depth understanding of the input text. When faced with complex and varied natural language expressions, it can more accurately capture key information, thus accurately outputting the response dialogue text, improving the fluency of the dialogue system, and increasing user stickiness to the dialogue system.
[0155] Furthermore, the intelligent text dialogue generation device based on artificial intelligence provided by the present invention will be described below. The intelligent text dialogue generation device based on artificial intelligence described below can be referred to in correspondence with the intelligent text dialogue generation method based on artificial intelligence described above.
[0156] Optional, refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of the intelligent text dialogue generation device based on artificial intelligence provided by the present invention. The intelligent text dialogue generation device based on artificial intelligence includes...
[0157] The semantic parsing module 210 is used to perform text semantic parsing on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0158] The model matching module 220 is used to match the target business model in a preset business model library based on business domain information; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text.
[0159] The model prediction module 230 is used to input text semantic information into the target business model to obtain the initial response dialogue text output by the target business model;
[0160] The text adjustment module 240 is used to adjust the initial response dialogue text based on the user's emotional information to obtain an intermediate response dialogue text that matches the emotional tendency of the target user.
[0161] The text optimization feedback module 250 is used to personalize the intermediate response dialogue text based on the current dialogue context and the user profile of the target user, so as to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interests.
[0162] This invention employs a target business model trained using an attention-based Transformer model to predict text semantic information. Because the multi-head attention mechanism can simultaneously focus on different semantic levels of the text, the target business model gains a more comprehensive and in-depth understanding of the input text. When faced with complex and varied natural language expressions, it can more accurately capture key information, thus accurately outputting response dialogue text and improving the fluency of the dialogue system. Furthermore, by matching the corresponding target business model with business domain information from the user's input text, and by personalizing and optimizing the initial response dialogue text based on user sentiment information, the current dialogue context, and the user's profile, a final target response dialogue text that meets the user's needs is obtained. This better addresses the dialogue needs of various scenarios and topics, moving beyond the limitations of searching a specific corpus and improving the flexibility and versatility of the dialogue system. Therefore, it can increase user engagement with the dialogue system.
[0163] Please see Figure 3 , Figure 3 An embodiment diagram of an electronic device provided in accordance with the present invention. For example... Figure 3 As shown, this embodiment of the invention provides an electronic device 300, including a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor 320. When the processor 320 executes the computer program 311, it performs the following steps:
[0164] Perform text semantic analysis on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0165] The target business model is obtained by matching the business domain information in a pre-set business model library; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text.
[0166] Input the semantic information of the text into the target business model to obtain the initial response dialogue text output by the target business model;
[0167] The initial response dialogue text is sentiment-adjusted based on user sentiment information to obtain an intermediate response dialogue text that matches the sentiment tendency of the target user.
[0168] Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interests.
[0169] Please see Figure 4 , Figure 4 An embodiment diagram of a computer-readable storage medium provided in accordance with an embodiment of the present invention is shown. Figure 4 As shown, this embodiment provides a computer-readable storage medium 400 on which a computer program 311 is stored. When the computer program 311 is executed by a processor, it performs the following steps:
[0170] Perform text semantic analysis on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0171] The target business model is obtained by matching the business domain information in a pre-set business model library; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text.
[0172] Input the semantic information of the text into the target business model to obtain the initial response dialogue text output by the target business model;
[0173] The initial response dialogue text is sentiment-adjusted based on user sentiment information to obtain an intermediate response dialogue text that matches the sentiment tendency of the target user.
[0174] Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interests.
[0175] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the artificial intelligence-based intelligent text dialogue generation method provided by the above methods, the method comprising:
[0176] Perform text semantic analysis on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text;
[0177] The target business model is obtained by matching the business domain information in a pre-set business model library; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text.
[0178] Input the semantic information of the text into the target business model to obtain the initial response dialogue text output by the target business model;
[0179] The initial response dialogue text is sentiment-adjusted based on user sentiment information to obtain an intermediate response dialogue text that matches the sentiment tendency of the target user.
[0180] Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interests.
[0181] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0182] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / eos>
Claims
1. An intelligent text dialogue generation method based on artificial intelligence, characterized in that, include: The text semantics of the question dialogue text input by the target user are analyzed to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text; The target business model is obtained by matching the business domain information in a preset business model library; the target business model is trained on an attention-based Transformer model based on the semantics of the sample text and the labeling results of the corresponding response dialogue text. The semantic information of the text is input into the target business model to obtain the initial response dialogue text output by the target business model; Based on the user's emotional information, the initial response dialogue text is emotionally adjusted to obtain an intermediate response dialogue text that matches the emotional tendency of the target user. Based on the current dialogue context and the user profile of the target user, the intermediate response dialogue text is personalized and optimized to obtain the target response dialogue text and then fed back to the target user. The user profile is constructed based on the analysis of the target user's historical information, personality traits, and interests. The steps for obtaining the target response dialogue text include: Extract key elements from the current dialogue context, as well as personality traits and interests from the user profile; the key elements include dialogue rounds, dialogue topic relevance score, and dialogue time; the personality traits include extroversion and decision-making decisiveness. A contextual feature vector is constructed based on the dialogue rounds, the relevance score of the dialogue topic, and the dialogue time; a personalized weight vector is constructed based on the degree of extroversion, the degree of decision-making decisiveness, and the interest preferences; and the intermediate response dialogue text is converted into the corresponding text vector representation. The context feature vector, the personalized weight vector, and the text vector representation are fused to obtain the fused text vector representation, which is then converted into natural language text to obtain the target response dialogue text.
2. The intelligent text dialogue generation method based on artificial intelligence according to claim 1, characterized in that, The Transformer model includes an encoder and a decoder; the encoder includes multiple encoder layers, each encoder layer including a first multi-head attention mechanism module, a feedforward neural network module, and a residual connection and layer normalization operation module; the decoder includes multiple decoder layers, each decoder layer including a second multi-head attention mechanism module, a feedforward neural network module, a residual connection and layer normalization operation module, and a third multi-head attention mechanism module. The step of inputting the text semantic information into the target business model to obtain the initial response dialogue text output by the target business model includes: The text semantic information is preprocessed to obtain the position encoding vector corresponding to the text vector at each position in the text semantic information, and the text vector at each position in the text semantic information and its corresponding position encoding vector are added element by element to obtain the position encoded text semantic information. The location-encoded text semantic information is input into the target business model. Each encoder layer in the encoder performs feature extraction and encoding transformation on the location-encoded text semantic information through the first multi-head attention mechanism module, the feedforward neural network module, and the residual connection and layer normalization operation module to generate the final encoder output. The final encoder output is input to the decoder. Each decoder layer in the decoder generates the initial response dialogue text by combining the position-encoded text semantic information and the final encoder output through the second multi-head attention mechanism module, the feedforward neural network module, the residual connection and layer normalization operation module, and the third multi-head attention mechanism module.
3. The intelligent text dialogue generation method based on artificial intelligence according to claim 2, characterized in that, The processing steps of the encoder layer are as follows: The first multi-head attention mechanism module linearly transforms the position-encoded text semantic information to obtain a query vector, a key vector, and a value vector. Combining the query vector, the key vector, the value vector, the position-encoded text semantic information, and the dimension of the first multi-head attention mechanism module, the position-encoded text semantic information is mapped and concatenated to obtain the output of the first multi-head attention mechanism. The feedforward neural network module performs a linear transformation on the output of the first multi-head attention mechanism to obtain the output of the feedforward neural network. The residual connection and layer normalization operation module performs layer normalization on the position-encoded text semantic information, the output of the first multi-head attention mechanism, and the output of the feedforward neural network to generate the final encoder output. The processing steps of the decoder layer are as follows: Based on the second multi-head attention mechanism module, a linear transformation, mapping, and concatenation of the final encoder output of the mask matrix are performed to obtain the mask multi-head attention mechanism output; based on the third multi-head attention mechanism module, a linear transformation, mapping, and concatenation of the mask multi-head attention mechanism output are performed to obtain the second multi-head attention mechanism output; based on the feedforward neural network module and the residual connection and layer normalization operation module, a linear transformation and layer normalization operation are performed on the second multi-head attention mechanism output to obtain the final decoder output; the final decoder output is mapped to the vocabulary space to obtain the probability distribution of each word, and the initial response dialogue text is generated according to the probability distribution of each word.
4. The intelligent text dialogue generation method based on artificial intelligence according to claim 2, characterized in that, The training steps for the target business model include: Multiple initial sample training data pairs are input into a data filtering model, and the loss function value of each initial sample training data pair output by the data filtering model is obtained; each initial sample training data pair includes sample dialogue text and its response dialogue text; Iterate through the first loss function value of each initial sample training data pair, and determine the initial sample training data pairs whose first loss function value is less than the first preset loss threshold as target sample training data pairs; Extract the text semantics of the sample dialogue text in each target sample training data pair, and label the result label of the response dialogue text in each target sample training data pair; Based on the text semantics and the result labels of the response dialogue text in each of the target sample training data pairs, the Transformer model is trained to obtain the target business model.
5. The intelligent text dialogue generation method based on artificial intelligence according to claim 4, characterized in that, The constraints for training the Transformer model are: the loss function value of each target sample training data pair is less than or equal to a second preset loss threshold, and the difference between two adjacent second loss function values is less than or equal to a preset difference threshold; the step of training the Transformer model based on the text semantics and response dialogue text results labels in each target sample training data pair to obtain the target business model includes: The text semantics and response dialogue text results labels from each target sample training data pair are input into the Transformer model to obtain the second loss function value of each target sample training data pair output by the Transformer model; If the second loss function value of each target sample training data pair, or / and the difference between two adjacent second loss function values, determines that the constraint condition is not met, then the parameters in the objective optimization function of the Transformer model are updated until the second loss function value of each target sample training data pair output by the adjusted Transformer model, and the difference between two adjacent second loss function values, both satisfy the constraint condition, and the target business model is obtained. The loss function of the Transformer model is: ; in, Indicates the first The second loss function value for each pair of target sample training data. Indicates the first The result labels for each pair of target sample training data. Indicates the first The predicted values of each target sample training data pair; The objective function of the Transformer model is: ; in, The model represents the first time. Step parameters, The model represents the first time. Step parameters; The model represents the first time. The learning rate of each step, and it increases with the number of steps. The increase in learning rate Decreasing; This indicates the preset momentum parameter. The model represents the first time. gradient of step, The model represents the first time. gradient of step, This represents the initial learning rate. The model represents the first time. The preset attenuation coefficient for each step.
6. The intelligent text dialogue generation method based on artificial intelligence according to claim 1, characterized in that, The step of adjusting the initial response dialogue text based on the user's emotional information to obtain an intermediate response dialogue text that matches the emotional tendency of the target user includes: Lexical analysis is performed on the initial response dialogue text to obtain multiple words in the initial response dialogue text, and the sentiment intensity of each word matched with the sentiment words in the pre-constructed sentiment dictionary, as well as the importance weight and semantic role weight of the sentiment words in the initial response dialogue text are determined. The user sentiment information is normalized to obtain normalized user sentiment information, and the sentiment adjustment coefficient is determined based on the normalized user sentiment information. The target sentiment tendency is determined based on the positive or negative nature of the user's sentiment information, and the target sentiment vector is determined based on the target sentiment tendency. Each word is sentiment-adjusted based on the sentiment adjustment coefficient, the target sentiment vector, and the importance weight and semantic role weight of each word's sentiment, resulting in an adjusted word vector. An intermediate response dialogue text matching the sentiment tendency of the target user is then generated based on the adjusted word vector.
7. An intelligent text dialogue generation device based on artificial intelligence, characterized in that, Applied to the intelligent text dialogue generation method based on artificial intelligence as described in any one of claims 1 to 6; The AI-based intelligent text dialogue generation device includes: The semantic parsing module is used to perform text semantic parsing on the question dialogue text input by the target user to obtain the text semantic information, user sentiment information and business domain information of the question dialogue text; The model matching module is used to match the business domain information in a preset business model library to obtain the target business model; the target business model is trained on the attention-based Transformer model based on the semantics of the sample text and the label results of the corresponding response dialogue text. The model prediction module is used to input the text semantic information into the target business model to obtain the initial response dialogue text output by the target business model; The text adjustment module is used to adjust the initial response dialogue text based on the user's emotional information to obtain an intermediate response dialogue text that matches the emotional tendency of the target user. The text optimization feedback module is used to personalize and optimize the intermediate response dialogue text based on the current dialogue context and the user profile of the target user, so as to obtain the target response dialogue text and feed it back to the target user; the user profile is constructed based on the target user's historical information analysis of personality characteristics and interests. The steps for obtaining the target response dialogue text include: Extract key elements from the current dialogue context, as well as personality traits and interests from the user profile; the key elements include dialogue rounds, dialogue topic relevance score, and dialogue time; the personality traits include extroversion and decision-making decisiveness. A contextual feature vector is constructed based on the dialogue rounds, the relevance score of the dialogue topic, and the dialogue time; a personalized weight vector is constructed based on the degree of extroversion, the degree of decision-making decisiveness, and the interest preferences; and the intermediate response dialogue text is converted into the corresponding text vector representation. The context feature vector, the personalized weight vector, and the text vector representation are fused to obtain the fused text vector representation, which is then converted into natural language text to obtain the target response dialogue text.
8. An electronic device, comprising: Memory, used to store computer software programs; A processor for reading and executing computer software programs, characterized in that, when the computer software program is executed by the processor, it implements the intelligent text dialogue generation method based on artificial intelligence as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium, wherein a computer software program is stored therein, characterized in that, When the computer software program is executed by the processor, it implements the intelligent text dialogue generation method based on artificial intelligence as described in any one of claims 1 to 6.