Artificial intelligence-based dialogue text generation method and system
By constructing a dialogue structure graph and using adjacency-related vectors, the problems of role misalignment and insufficient dynamic adaptability in open-domain multi-turn dialogue systems are solved, generating up-to-date response texts with role consistency and deep understanding.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 南昌理工学院
- Filing Date
- 2026-02-25
- Publication Date
- 2026-05-29
Smart Images

Figure CN121786169B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method and system for generating dialogue text based on artificial intelligence. Background Technology
[0002] Dialogue systems are computer programs that enable human-computer interaction in the form of natural language. Their technical architecture includes five core modules: speech recognition, natural language understanding, dialogue management, natural language generation, and speech synthesis. Based on the interaction goal, they can be divided into two categories: task-oriented and open-domain. Task-oriented dialogue systems focus on completing specific instructions.
[0003] Open-domain multi-turn dialogue systems represent a cutting-edge research direction in the field of artificial intelligence. These systems enable continuous and natural communication without being constrained by specific topics, prioritizing fluency, engaging content, and sustained interaction rounds rather than the completion of a single task.
[0004] In multi-turn interactions, the stance, knowledge background, and dialogue goals of dialogue participants (such as users and assistants, or multiple users) constitute their "semantic roles." However, existing open-domain multi-turn dialogue systems lack explicit modeling of these roles, which may lead to role misalignment when generating responses. For example, the assistant may make statements that should be made from the user's perspective. Furthermore, existing open-domain multi-turn dialogue systems cannot dynamically adjust their focus on historical information based on the latest dialogue content, which may cause the generated responses to overemphasize earlier rather than more recent dialogue content, affecting context relevance. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a dialogue text generation method and system based on artificial intelligence, which aims to solve the technical problems of open domain multi-turn dialogue systems in the prior art, which have difficulty maintaining role consistency and have weak dynamic adaptability during multi-turn interaction.
[0006] To achieve the above objectives, in a first aspect, embodiments of this application provide an artificial intelligence-based dialogue text generation method, comprising the following steps:
[0007] Obtain all historical dialogue texts prior to the current round, the historical dialogue texts including several historical dialogue statements, obtain the predicates and arguments corresponding to the predicates in the historical dialogue statements, and add semantic tags to the predicates and arguments;
[0008] Using the arguments and predicates as nodes, connection edges are constructed between the nodes to form a dialogue structure graph. In the dialogue structure graph, adjacency association vectors corresponding to the nodes are generated based on the representation vectors of the nodes.
[0009] Based on the representation vector and the adjacency association vector, a fusion vector corresponding to the node is obtained, and an enhanced dialogue statement corresponding to the historical dialogue statement is obtained through several of the fusion vectors.
[0010] The latest response text for the current round is obtained based on the enhanced dialogue statement, the semantic tags, and the pre-trained autoregressive language model.
[0011] The step of obtaining the predicates and arguments corresponding to the predicates in the historical dialogue statements, and adding semantic tags to the predicates and arguments, includes:
[0012] The historical dialogue statements are segmented to obtain several historical dialogue words, and the historical dialogue words are converted into context-related encoding vectors using the BERT model.
[0013] The context-related encoding vector is input into a softmax classifier to determine whether the words in the historical dialogue are predicates;
[0014] If the historical dialogue word is a predicate, then all the context-related encoding vectors corresponding to the historical dialogue statement are input into the bidirectional LSTM-CRF model to select the arguments corresponding to the predicate from the historical dialogue statement and identify the semantic labels corresponding to the predicate and the arguments.
[0015] Furthermore, the connecting edges include semantic edges, coreference edges, and rhetorical edges, and the step of constructing the connecting edges between the nodes includes:
[0016] Within the nodes of the same dialogue round, semantic edges are constructed based on the semantic tags between nodes corresponding to predicates and nodes corresponding to arguments;
[0017] Obtain the vector similarity between two nodes. If the vector similarity is greater than the similarity threshold, construct a common edge between the two nodes.
[0018] Identify the semantic representation between two dialogue rounds, determine the logical relationship between the two dialogue rounds based on the semantic representation, and construct the modification edge between the nodes corresponding to the predicates in the two dialogue rounds based on the logical relationship.
[0019] Furthermore, the step of generating the adjacency association vector corresponding to the node based on the node's representation vector includes:
[0020] Select one of the nodes as the reference node, and select the reference node and the nodes that have a connection edge with the reference node as adjacent nodes;
[0021] The initial attention coefficients between the representation vector of the reference node and the representation vectors of the neighboring nodes are obtained, and the initial attention coefficients are normalized to form the final attention coefficients.
[0022] The adjacency association vector of the baseline node is obtained based on the final attention coefficient.
[0023] Furthermore, the formula for obtaining the initial attention coefficient is:
[0024] ,
[0025] in, Let represent the initial attention coefficient between node i, which is the reference node, and node j, which is the neighboring node of the reference node. Represents the attention vector. Indicates the transpose operator. Indicates the first The weight matrix of the layer, This indicates that when the i-th node is the reference node, it is at the... The layer's representation vector, This indicates that when the j-th node is an adjacent node to the reference node, it is in the... The layer's representation vector, and The value of is 2. This represents a vector concatenation operation. This represents the LeakyReLU activation function;
[0026] The formula for obtaining the adjacency association vector is:
[0027] ,
[0028] in, Let represent the adjacency association vector with the i-th node as the reference node. Let represent the final attention coefficient between the i-th node and the j-th node when the i-th node is the reference node and the j-th node is the adjacent node corresponding to the reference node. This represents the total number of adjacent nodes when the i-th node is the reference node. This represents a non-linear activation function.
[0029] Furthermore, the step of obtaining the fusion vector corresponding to the node based on the representation vector and the adjacency association vector includes:
[0030] The representation vector and the adjacency association vector are concatenated into a merged vector;
[0031] The merged vector is converted into a fusion vector with the same dimension as the representation vector based on a linear transformation.
[0032] Furthermore, the step of obtaining the latest response text for the current round based on the enhanced dialogue statement, the semantic tags, and the pre-trained autoregressive language model includes:
[0033] The enhanced dialogue statement is projected into a key vector and a value vector. The text start symbol is input into the decoder of the pre-trained autoregressive language model to obtain the initial hidden state of the decoder and obtain the self-attention of the initial hidden state.
[0034] Using the initial hidden state as the query vector, cross attention corresponding to the initial hidden state is obtained based on the query vector, the key vector, and the value vector. An initial word probability distribution is obtained based on the cross attention and the self attention.
[0035] The initial word probability distribution is adjusted by role consistency bias using the semantic tags to obtain the final word probability distribution. The word with the highest probability is selected as the reply word and combined with the text start symbol to form the initial reply text.
[0036] The initial reply text is used as the decoder's updated hidden state, and several loops are performed to obtain the latest reply text for the current round.
[0037] Furthermore, the initial vocabulary probability distribution includes response words and the initial selection probabilities corresponding to the response words. The step of adjusting the initial vocabulary probability distribution with role consistency bias using the semantic tags to obtain the final vocabulary probability distribution includes:
[0038] Based on the semantic tags, the role nodes corresponding to the response roles are obtained from the dialogue structure graph, and the adjacency association vectors corresponding to the role nodes are selected as role vectors;
[0039] Obtain the cosine similarity between the character vector and the response word, obtain the offset vector based on the cosine similarity, and obtain the log probability through the offset vector, which is the initial selection probability;
[0040] All the logarithmic probabilities are normalized to obtain the final selection probability, and the response words are combined with the final selection probability to form the final word probability distribution.
[0041] Secondly, embodiments of this application provide an artificial intelligence-based dialogue text generation system, applied to the artificial intelligence-based dialogue text generation method described in the first aspect above, the system comprising:
[0042] The classification module is used to obtain all historical dialogue texts before the current round. The historical dialogue texts include several historical dialogue statements. The module obtains the predicates and arguments corresponding to the predicates in the historical dialogue statements and adds semantic tags to the predicates and arguments.
[0043] The bridging module is used to construct connection edges between the arguments and predicates as nodes to form a dialogue structure graph. In the dialogue structure graph, an adjacency association vector corresponding to the node is generated based on the representation vector of the node.
[0044] The combination module is used to obtain a fusion vector corresponding to the node based on the representation vector and the adjacency association vector, and to obtain an enhanced dialogue statement corresponding to the historical dialogue statement through several of the fusion vectors;
[0045] The execution module is used to obtain the latest response text for the current round based on the enhanced dialogue statement and the pre-trained autoregressive language model.
[0046] Thirdly, embodiments of this application provide a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the artificial intelligence-based dialogue text generation method as described in the first aspect above.
[0047] Fourthly, embodiments of this application provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the artificial intelligence-based dialogue text generation method as described in the first aspect above.
[0048] Compared with existing technologies, the beneficial effects of this invention are as follows: By acquiring the predicates and arguments and adding semantic tags to them, unstructured dialogue text is initially converted into structured semantic information. Simultaneously, the semantic tags establish a role foundation for the subsequent construction of the dialogue structure graph, providing a basis for role recognition in subsequent text generation and avoiding role misalignment problems. By constructing the dialogue structure graph, nodes scattered across different rounds of dialogue are connected and unified, understanding the context and development direction of the dialogue. Furthermore, by acquiring the adjacency correlation vector, the nodes dynamically focus on globally important information. The adjacency correlation vector is fused with the representation vector, assigning corresponding roles and contextual information to the predicates or arguments corresponding to the nodes. Then, combined with a pre-trained autoregressive language model, the latest response text focusing on roles and global information is generated. The latest response text can dynamically focus on important parts of the enhanced dialogue statements, and since the enhanced dialogue statements have incorporated graph information, the generation of the latest response text possesses strong dynamic adaptability and a deep understanding of the structure and logic of multi-round dialogues. Attached Figure Description
[0049] Figure 1 This is a flowchart of the AI-based dialogue text generation method in the first embodiment of the present invention;
[0050] Figure 2 This is a structural block diagram of the AI-based dialogue text generation system in the second embodiment of the present invention;
[0051] The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation
[0052] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
[0053] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there may be an intervening component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there may be an intervening component. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0055] Please see Figure 1 The first embodiment of the present invention provides a method for generating dialogue text based on artificial intelligence, comprising the following steps:
[0056] S10: Obtain all historical dialogue texts before the current round, the historical dialogue texts include several historical dialogue statements, obtain the predicates and arguments corresponding to the predicates in the historical dialogue statements, and add semantic tags to the predicates and arguments;
[0057] Specifically, step S10 includes:
[0058] S110: The historical dialogue statements are segmented to obtain several historical dialogue words, and the historical dialogue words are converted into context-related encoding vectors using the BERT model;
[0059] Taking "Xiaoming happily played football in the park yesterday" as an example, after the word segmentation process, several historical dialogue words are obtained: ["Xiaoming", "yesterday", "in", "park", "happily", "play", "football"].
[0060] After acquiring the historical dialogue words, the BERT model uses a multi-head attention mechanism to obtain the association vector between each historical dialogue word and all historical words (including itself), and then converts it into the context-related encoding vector through weighted fusion.
[0061] S120: Input the context-related encoding vector into a softmax classifier to determine whether the words in the historical dialogue are predicates;
[0062] The softmax classifier can determine whether a historical dialogue word corresponding to the context-related encoding vector is a predicate based on the information contained in the context-related encoding vector (such as the action intensity of the verb, its importance to the sentence structure, and its relevance to other words). Taking "Xiaoming hopes to go to the park to play football" as an example, there are multiple verbs such as "hope", "go", and "play". The softmax classifier identifies "hope" as the core verb, i.e., the predicate.
[0063] S130: If the historical dialogue word is a predicate, then all the context-related encoding vectors corresponding to the historical dialogue statement are input into the bidirectional LSTM-CRF model to select the arguments corresponding to the predicate from the historical dialogue statement and identify the semantic labels corresponding to the predicate and the arguments.
[0064] The bidirectional LSTM-CRF model is specifically designed for sequence labeling. Its function is to label words in historical dialogues. Taking the sentence "Xiaoming, wearing a hat, promised the teacher yesterday" as an example, the predicate is "promised," "promised" is the core action, "Xiaoming" is the agent, "teacher" is the patient, and "yesterday" is the time, all of which are arguments. However, "wearing a hat" describes "Xiaoming," not "promised," and is therefore excluded. Understandably, the core action, agent, patient, and time are all semantic labels.
[0065] S20: Using the arguments and predicates as nodes, construct the connection edges between the nodes to form a dialogue structure graph;
[0066] The connecting edges include semantic edges, coreference edges, and rhetorical edges. By constructing these connecting edges, the dialogue structure graph can fully capture three key types of information: intra-sentence semantics, cross-sentence coreference, and turn-taking logic. This makes the graph's expressive power more comprehensive and richer, and enhances the cognitive depth of subsequent steps.
[0067] Step S20 includes:
[0068] S210: Within the nodes of the same dialogue round, construct semantic edges between the nodes corresponding to the predicates and the nodes corresponding to the arguments based on the semantic tags;
[0069] Suppose there are two rounds of dialogue: Dialogue 1: "Xiaoming happily played soccer in the park yesterday" (predicate: "kick", arguments: "Xiaoming", "yesterday", "in the park", "happily", "soccer"); Dialogue 2: "He did have a lot of fun, but he kicked the ball into the lake" (predicate: "kick", arguments: "he", "ball", "into the lake"). Based on Dialogue 1, we construct 6 nodes, and based on Dialogue 2, we construct 4 nodes. Taking Dialogue 1 as an example, the semantic edge between node (kick) and node (Xiaoming) is the agent.
[0070] S220: Obtain the vector similarity between two nodes. If the vector similarity is greater than the similarity threshold, construct a common edge between the two nodes.
[0071] In this embodiment, the vector similarity is cosine similarity. Taking the previous example, if the vector similarity between node (Xiaoming) and node (He), and between node (soccer ball) and node (ball) is greater than the similarity threshold, then common edges are constructed between node (Xiaoming) and node (He), and between node (soccer ball) and node (ball), respectively.
[0072] S230: Identify the semantic representation between two dialogue rounds, determine the logical relationship between the two dialogue rounds based on the semantic representation, and construct the modification edge between the nodes corresponding to the predicates in the two dialogue rounds based on the logical relationship;
[0073] In this embodiment, the information of nodes in each dialogue turn is aggregated into a turn vector using a GNN network model to obtain the semantic representation. The logical relationships include: elaboration relationships, transition relationships, causal relationships, and question-and-answer relationships. Based on the previous example, dialogue 1 and dialogue 2 have an elaboration relationship. Therefore, decorative edges are constructed between nodes (kickers) in the two dialogue turns to clarify the logical relationships between different dialogue turns.
[0074] S240: Select one of the nodes as the reference node, and select the reference node and the nodes that have a connection edge with the reference node as adjacent nodes;
[0075] Understandably, the reference node itself will also be selected as the adjacent node again, that is, when obtaining the initial attention coefficient, the initial attention coefficient of the reference node and itself needs to be calculated.
[0076] S250: Obtain the initial attention coefficients between the representation vector of the reference node and the representation vectors of the neighboring nodes, and normalize the initial attention coefficients to form the final attention coefficients.
[0077] It should be noted that the representation vector includes a static vector and a position vector. The static vector can be obtained by comparing the arguments or predicates corresponding to the node with a lookup table, and it represents the meaning of the arguments or predicates themselves. The position vector represents the position of the arguments or predicates in the historical dialogue statements.
[0078] The formula for obtaining the initial attention coefficient is:
[0079] ,
[0080] in, Let represent the initial attention coefficient between node i, which is the reference node, and node j, which is the neighboring node of the reference node. Represents the attention vector. Indicates the transpose operator. Indicates the first The weight matrix of the layer, This indicates that when the i-th node is the reference node, it is at the... The layer's representation vector, This indicates that when the j-th node is an adjacent node to the reference node, it is in the... The layer's representation vector, and The value of is 2. This represents a vector concatenation operation. This represents the LeakyReLU activation function.
[0081] Understandably, after obtaining several initial attention coefficients and performing normalization, the sum of several final attention coefficients is 1.
[0082] S260: Obtain the adjacency association vector of the reference node based on the final attention coefficient;
[0083] The formula for obtaining the adjacency association vector is:
[0084] ,
[0085] in, Let represent the adjacency association vector with the i-th node as the reference node. Let represent the final attention coefficient between the i-th node and the j-th node when the i-th node is the reference node and the j-th node is the adjacent node corresponding to the reference node. This represents the total number of adjacent nodes when the i-th node is the reference node. This represents a non-linear activation function.
[0086] S30: Based on the representation vector and the adjacency association vector, obtain the fusion vector corresponding to the node, and obtain the enhanced dialogue statement corresponding to the historical dialogue statement through several of the fusion vectors;
[0087] By dimensionality reduction and fusion of different types of features (the representation vector and the adjacency association vector), it is ensured that the information injected into the subsequent model is optimized and condensed features.
[0088] Specifically, step S30 includes:
[0089] S310: Concatenate the representation vector and the adjacency association vector into a merged vector;
[0090] Based on the correspondence between predicates or arguments and nodes, the representation vector and adjacency vector of each node are combined to obtain the merged vector corresponding to the node. When the dimension of the representation vector and the adjacency vector are both 512, the dimension of the merged vector is 1024. Therefore, the merged vector needs to be reduced in dimension to facilitate the subsequent acquisition of enhanced dialogue statements.
[0091] S320: Based on a linear transformation, convert the merged vector into a fusion vector with the same dimension as the representation vector;
[0092] The formula for obtaining the fusion vector is:
[0093] ,
[0094] in, This represents the fusion vector (with shape (1024,)). This represents the fusion weight matrix (shape 512, 1024). The bias vector (of shape (512,)) is transformed linearly to make the dimension of the fused vector 512. , It can be learned through training data.
[0095] After obtaining the fusion vector, based on the historical dialogue statement, the fusion vectors of the nodes corresponding to the predicates and arguments are extracted and concatenated to form the historical dialogue vector. The historical dialogue vector is input into the Transformer encoder, which uses a self-attention mechanism to allow each fusion vector to interact with other enhancement vectors in the sequence to obtain a new sequence set of the same length, i.e., the enhanced dialogue statement. Understandably, the new sequence set includes several enhancement vectors, and each enhancement vector deeply integrates comprehensive information such as vocabulary, grammar, semantic roles, and link relationships.
[0096] S40: Obtain the latest response text for the current round based on the enhanced dialogue statement, the semantic tags, and the pre-trained autoregressive language model;
[0097] Specifically, step S40 includes:
[0098] S410: Project the enhanced dialogue statement into a key vector and a value vector, input the text start character into the decoder of the pre-trained autoregressive language model to obtain the initial hidden state of the decoder, and obtain the self-attention of the initial hidden state.
[0099] Specifically, the enhanced dialogue statements can be projected into the key vector and the value vector through two independent linear layers. It should be noted that when generating the initial hidden state, the decoder focuses on all words in previous positions based on the word at the current position (in this step, it focuses on the text start character) to generate self-attention.
[0100] S420: Using the initial hidden state as the query vector, obtain the cross attention corresponding to the initial hidden state based on the query vector, the key vector and the value vector, and obtain the initial word probability distribution based on the cross attention and the self attention;
[0101] The formula for obtaining cross attention is:
[0102] ,
[0103] in, Indicates cross attention. Represents the query vector. Represents the key vector. Represents a value vector. Indicates the transpose operator. The dimension of the key vector. This represents the normalization function.
[0104] After obtaining the cross-attention and the self-attention, both are used as inputs to the feedforward neural network sublayer. The feedforward neural network sublayer performs a non-linear transformation on the fusion of the two to generate an attention vector that fuses the two. Then, the attention vector is projected onto a vocabulary that includes several word vectors through a linear weight matrix. Different word vectors correspond to different response words, thereby obtaining the probability score for each response word. After normalization, an initial selection probability is formed. That is, the initial vocabulary probability distribution includes the response word and the initial selection probability corresponding to the response word.
[0105] S430: Adjust the role consistency bias of the initial word probability distribution through the semantic tags to obtain the final word probability distribution, select the word with the highest probability as the reply word, and combine it with the text start symbol to form the initial reply text;
[0106] Specifically, based on the semantic tags, the role nodes corresponding to the response roles are obtained from the dialogue structure graph, and the adjacency association vectors corresponding to the role nodes are selected as role vectors;
[0107] In the dialogue structure graph, since common edges are constructed for different nodes, and based on the response role (text generation system), the node corresponding to the response role in previous multi-turn dialogues can be selected, namely the role node.
[0108] Obtain the cosine similarity between the character vector and the response word, obtain the offset vector based on the cosine similarity, and obtain the log probability through the offset vector, which is the initial selection probability;
[0109] After obtaining the cosine similarity, the cosine similarity of all response words is scaled to obtain an offset vector. The formula for obtaining the offset vector is:
[0110] ,
[0111] in, This represents the offset vector corresponding to the w-th reply word. Indicates control parameters, This represents the cosine similarity to the w-th reply word;
[0112] The formula for obtaining the logarithmic probability is:
[0113] ,
[0114] in, This represents the logarithmic probability corresponding to the w-th reply word. This represents the logarithm of the initial selection probability corresponding to the w-th response word;
[0115] All the logarithmic probabilities are normalized to obtain the final selection probability, and the response words are combined with the final selection probability to form the final word probability distribution.
[0116] By adjusting the role consistency bias and validating the generated response words based on the semantic tags, the generated response words are ensured to match the response identity, thus achieving a closed loop in the solution to the role misalignment problem.
[0117] S440: Use the initial reply text as the decoder to update the hidden state, and perform several loop processing cycles to obtain the latest reply text for the current round.
[0118] Understandably, after obtaining the updated hidden state, the updated hidden state replaces the initial hidden state, and steps S420 to S440 are repeated until the text end character is obtained, so as to complete the acquisition of the reply text for the current round.
[0119] By acquiring the predicates and arguments and adding semantic tags to them, the unstructured dialogue text is initially converted into structured semantic information. Simultaneously, the semantic tags establish a role foundation for the subsequent construction of the dialogue structure graph, providing a basis for role recognition in subsequent text generation and avoiding role misalignment issues. By constructing the dialogue structure graph, the nodes scattered across different rounds of dialogue are connected and unified, allowing for an understanding of the dialogue's context and development direction. Furthermore, by acquiring the adjacency correlation vector, the nodes dynamically focus on globally important information. The adjacency correlation vector is fused with the representation vector, assigning corresponding roles and contextual information to the predicates or arguments corresponding to the nodes. Then, combined with a pre-trained autoregressive language model, the latest response text focusing on roles and global information is generated. This latest response text dynamically focuses on important parts of the enhanced dialogue statements, and since the enhanced dialogue statements have incorporated graph information, the generation of the latest response text possesses strong dynamic adaptability and a deep understanding of the structure and logic of multi-round dialogues.
[0120] Please see Figure 2 The second embodiment of the present invention provides an artificial intelligence-based dialogue text generation system. This system is applied to the artificial intelligence-based dialogue text generation method described in the above embodiments, and will not be repeated hereafter. As used below, the terms "module," "unit," "subunit," etc., can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0121] The system includes:
[0122] The classification module 10 is used to obtain all historical dialogue texts before the current round. The historical dialogue texts include several historical dialogue statements. The module obtains the predicates and arguments corresponding to the predicates in the historical dialogue statements and adds semantic tags to the predicates and arguments.
[0123] The classification module 10 includes:
[0124] The first unit is used to perform word segmentation on the historical dialogue statements to obtain several historical dialogue words, and then convert the historical dialogue words into context-related encoding vectors through the BERT model.
[0125] The second unit is used to input the context-related encoding vector into a softmax classifier to determine whether the words in the historical dialogue are predicates;
[0126] The third unit is used to input all the context-related encoding vectors corresponding to the historical dialogue statement into the bidirectional LSTM-CRF model if the historical dialogue word is a predicate, so as to select the argument corresponding to the predicate from the historical dialogue statement and identify the semantic label corresponding to the predicate and the argument.
[0127] The bridging module 20 is used to construct connection edges between the nodes using the arguments and predicates as nodes to form a dialogue structure graph. In the dialogue structure graph, an adjacency association vector corresponding to the node is generated based on the representation vector of the node.
[0128] The bridging module 20 includes:
[0129] The fourth unit is used to construct semantic edges between nodes corresponding to predicates and nodes corresponding to arguments in the same dialogue round, based on the semantic tags.
[0130] The fifth unit is used to obtain the vector similarity between two nodes. If the vector similarity is greater than the similarity threshold, a common edge is constructed between the two nodes.
[0131] The sixth unit is used to identify the semantic representation between two dialogue rounds, determine the logical relationship between the two dialogue rounds based on the semantic representation, and construct the modification edge between the nodes corresponding to the predicates in the two dialogue rounds based on the logical relationship.
[0132] The seventh unit is used to select one of the nodes as a reference node, and to select the reference node and all nodes connected to the reference node as adjacent nodes.
[0133] The eighth unit is used to obtain the initial attention coefficients between the representation vector of the reference node and the representation vectors of the neighboring nodes, and to normalize the initial attention coefficients to form the final attention coefficients.
[0134] The ninth unit is used to obtain the adjacency association vector of the reference node based on the final attention coefficient;
[0135] The combination module 30 is used to obtain a fusion vector corresponding to the node based on the representation vector and the adjacency association vector, and to obtain an enhanced dialogue statement corresponding to the historical dialogue statement through a plurality of the fusion vectors;
[0136] The combined module 30 includes:
[0137] The tenth unit is used to concatenate the representation vector and the adjacency association vector into a merged vector;
[0138] The eleventh unit is used to convert the merged vector into a fusion vector with the same dimension as the representation vector based on a linear transformation;
[0139] Execution module 40 is used to obtain the latest response text for the current round based on the enhanced dialogue statement and the pre-trained autoregressive language model;
[0140] The execution module 40 includes:
[0141] The twelfth unit is used to project the enhanced dialogue statement into a key vector and a value vector, input the text start symbol into the decoder of the pre-trained autoregressive language model to obtain the initial hidden state of the decoder, and obtain the self-attention of the initial hidden state.
[0142] The thirteenth unit is used to obtain cross attention corresponding to the initial hidden state based on the query vector, the key vector and the value vector, and obtain the initial word probability distribution based on the cross attention and the self attention;
[0143] The fourteenth unit is used to adjust the role consistency bias of the initial word probability distribution through the semantic tags to obtain the final word probability distribution, select the word with the highest probability as the reply word, and combine it with the text start symbol to form the initial reply text;
[0144] The fourteenth unit is specifically used to obtain the role node corresponding to the response role from the dialogue structure graph based on the semantic tag, and select the adjacency association vector corresponding to the role node as the role vector; obtain the cosine similarity between the role vector and the response word, obtain the offset vector based on the cosine similarity, obtain the log probability through the offset vector, i.e. the initial selection probability; normalize all the log probabilities to obtain the final selection probability, and combine the response word and the final selection probability into the final word probability distribution;
[0145] The fifteenth unit is used to update the hidden state of the decoder using the initial reply text as the decoder, and to perform several loop processes to obtain the latest reply text for the current round.
[0146] The present invention also provides a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the artificial intelligence-based dialogue text generation method as described in the above technical solutions.
[0147] The present invention also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the artificial intelligence-based dialogue text generation method as described in the above technical solutions.
[0148] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0149] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A method for generating dialogue text based on artificial intelligence, characterized in that, Includes the following steps: Obtain all historical dialogue texts prior to the current round, the historical dialogue texts including several historical dialogue statements, obtain the predicates and arguments corresponding to the predicates in the historical dialogue statements, and add semantic tags to the predicates and arguments; Using the arguments and predicates as nodes, connection edges are constructed between the nodes, including semantic edges, coreference edges, and rhetorical edges, to form a dialogue structure graph. In the dialogue structure graph, adjacency association vectors corresponding to the nodes are generated based on the representation vectors of the nodes. The steps for constructing the connecting edges between the nodes include: Within the nodes of the same dialogue round, semantic edges are constructed based on the semantic tags between nodes corresponding to predicates and nodes corresponding to arguments; Obtain the vector similarity between two nodes. If the vector similarity is greater than the similarity threshold, construct a common edge between the two nodes. Identify the semantic representation between two dialogue rounds, determine the logical relationship between the two dialogue rounds based on the semantic representation, and construct the modification edge between the nodes corresponding to the predicates in the two dialogue rounds based on the logical relationship; The step of generating the adjacency association vector corresponding to the node based on the node's representation vector includes: Select one of the nodes as the reference node, and select the reference node and the nodes that have a connection edge with the reference node as adjacent nodes; The initial attention coefficients between the representation vector of the reference node and the representation vectors of the neighboring nodes are obtained, and the initial attention coefficients are normalized to form the final attention coefficients. The adjacency association vector of the baseline node is obtained based on the final attention coefficient; Based on the representation vector and the adjacency association vector, a fusion vector corresponding to the node is obtained, and an enhanced dialogue statement corresponding to the historical dialogue statement is obtained through several of the fusion vectors. The latest response text for the current round is obtained based on the enhanced dialogue statement, the semantic tags, and the pre-trained autoregressive language model; The step of obtaining the latest response text for the current round based on the enhanced dialogue statement, the semantic tags, and the pre-trained autoregressive language model includes: The enhanced dialogue statement is projected into a key vector and a value vector. The text start symbol is input into the decoder of the pre-trained autoregressive language model to obtain the initial hidden state of the decoder and obtain the self-attention of the initial hidden state. Using the initial hidden state as the query vector, cross attention corresponding to the initial hidden state is obtained based on the query vector, the key vector, and the value vector. An initial word probability distribution is obtained based on the cross attention and the self attention. The initial word probability distribution includes the response word and the initial selection probability corresponding to the response word. The initial word probability distribution is adjusted by role consistency bias using the semantic tags to obtain the final word probability distribution. The word with the highest probability is selected as the reply word and combined with the text start symbol to form the initial reply text. The step of adjusting the initial word probability distribution using the semantic tags to achieve a role consistency bias adjustment to obtain the final word probability distribution includes: Based on the semantic tags, the role nodes corresponding to the response roles are obtained from the dialogue structure graph, and the adjacency association vectors corresponding to the role nodes are selected as role vectors; Obtain the cosine similarity between the character vector and the response word, obtain the offset vector based on the cosine similarity, and obtain the log probability through the offset vector, which is the initial selection probability; All the log probabilities are normalized to obtain the final selection probability, and the response words are combined with the final selection probability to form the final word probability distribution; The initial reply text is used as the decoder's updated hidden state, and several loops are performed to obtain the latest reply text for the current round.
2. The AI-based dialogue text generation method according to claim 1, characterized in that, The step of obtaining the predicates and arguments corresponding to the predicates in the historical dialogue statements, and adding semantic tags to the predicates and arguments, includes: The historical dialogue statements are segmented to obtain several historical dialogue words, and the historical dialogue words are converted into context-related encoding vectors using the BERT model. The context-related encoding vector is input into a softmax classifier to determine whether the words in the historical dialogue are predicates; If the historical dialogue word is a predicate, then all the context-related encoding vectors corresponding to the historical dialogue statement are input into the bidirectional LSTM-CRF model to select the arguments corresponding to the predicate from the historical dialogue statement and identify the semantic labels corresponding to the predicate and the arguments.
3. The artificial intelligence-based dialogue text generation method according to claim 1, characterized in that, The formula for obtaining the initial attention coefficient is: , in, Let represent the initial attention coefficient between node i, which is the reference node, and node j, which is the neighboring node of the reference node. Represents the attention vector. Indicates the transpose operator. Indicates the first The weight matrix of the layer, This indicates that when the i-th node is the reference node, it is at the... The layer's representation vector, This indicates that when the j-th node is an adjacent node to the reference node, it is in the... The layer's representation vector, and The value of is 2. This represents a vector concatenation operation. This represents the LeakyReLU activation function; The formula for obtaining the adjacency association vector is: , in, Let represent the adjacency association vector with the i-th node as the reference node. Let represent the final attention coefficient between the i-th node and the j-th node when the i-th node is the reference node and the j-th node is the adjacent node corresponding to the reference node. This represents the total number of adjacent nodes when the i-th node is the reference node. This represents a non-linear activation function.
4. The artificial intelligence-based dialogue text generation method according to claim 1, characterized in that, The step of obtaining the fusion vector corresponding to the node based on the representation vector and the adjacency association vector includes: The representation vector and the adjacency association vector are concatenated into a merged vector; The merged vector is converted into a fusion vector with the same dimension as the representation vector based on a linear transformation.
5. The artificial intelligence-based dialogue text generation method according to claim 4, characterized in that, The formula for obtaining the fusion vector is: , in, Represents the fusion vector. Represents the fusion weight matrix. This represents the bias vector.
6. An artificial intelligence-based dialogue text generation system, applied to the artificial intelligence-based dialogue text generation method as described in any one of claims 1 to 5, characterized in that, The system includes: The classification module is used to obtain all historical dialogue texts before the current round. The historical dialogue texts include several historical dialogue statements. The module obtains the predicates and arguments corresponding to the predicates in the historical dialogue statements and adds semantic tags to the predicates and arguments. The bridging module is used to construct connection edges between the arguments and predicates as nodes to form a dialogue structure graph. In the dialogue structure graph, an adjacency association vector corresponding to the node is generated based on the representation vector of the node. The combination module is used to obtain a fusion vector corresponding to the node based on the representation vector and the adjacency association vector, and to obtain an enhanced dialogue statement corresponding to the historical dialogue statement through several of the fusion vectors; The execution module is used to obtain the latest response text for the current round based on the enhanced dialogue statement and the pre-trained autoregressive language model.