Multi-round dialogue model training method and device and related equipment

By introducing entity, mask, intent, and dialogue sequence loss functions into the multi-round dialogue model and iteratively training the preset model, the problem of context management in multi-round dialogues is solved and the output accuracy of the multi-round dialogue model is improved.

CN120687567APending Publication Date: 2025-09-23CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510777393.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-09-23

Smart Images

  • Figure CN120687567A_ABST
    Figure CN120687567A_ABST
Patent Text Reader

Abstract

The invention provides a multi-round dialogue model training method and device and related equipment, and relates to the technical field of artificial intelligence, the method comprises the following steps: obtaining a first word segmentation sequence corresponding to a first text and a plurality of continuous second texts, the first word segmentation sequence comprising N-1 lexical elements, mask marks and classification marks, the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, and the second word segmentation sequence comprises N lexical elements; calculating entity loss determined based on N-1 lexical elements, mask loss determined based on the mask mark, intention loss determined based on the classification mark and dialogue sequence loss determined based on the first text and the second text of the preset model to obtain a first loss value; and performing iterative training on a preset model based on the first loss value to obtain a multi-round dialogue model. The multi-round dialogue model can accurately capture key information when processing complex dialogues, and the accuracy of output results of the multi-round dialogue model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a multi-round dialogue model training method, apparatus, and related equipment. Background Art

[0002] With the rapid development of artificial intelligence and natural language processing technologies, numerous conversational models have emerged. These models can implement knowledge-based question-and-answer (Q&A) and simulate the way human customer service handles user inquiries and issues. When handling complex conversational flows, it's crucial to accurately understand and maintain the conversational context to provide coherent and accurate responses. However, in multi-round conversations, key information can vary from turn to turn. Existing conversational models struggle to accurately capture this key information, resulting in poorly accurate output. Summary of the Invention

[0003] The embodiments of the present application provide a multi-round dialogue model training method, apparatus, and related equipment to solve the problem of poor accuracy of dialogue model output results in the prior art.

[0004] To solve the above technical problems, this application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a multi-round dialogue model training method, the method comprising:

[0006] Acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to a first text, where the first text is a last-round conversation text in the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence includes N word units, the mask mark is a first mark corresponding to any target word unit among the N word units, the N-1 word units are word units other than the target word unit among the N word units, and the classification mark is a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1;

[0007] Calculating an entity loss determined by a preset model based on the N-1 word-grams, a mask loss determined based on the mask tag, an intent loss determined based on the classification tag, and a conversation sequence loss determined based on the first text and a second text to obtain a first loss value, where the second text is a conversation text in the multiple rounds of conversation text excluding the first text;

[0008] The preset model is iteratively trained based on the first loss value until the first loss value is less than a preset threshold, and the preset model after iterative training is determined as a multi-round dialogue model.

[0009] Optionally, the preset model includes an encoder, a decoder, and a feedforward neural network layer, the encoder includes a dot product attention layer and an additive attention layer, the dot product attention layer is used to determine the attention weight of the value vector by calculating the dot product between the query vector and the key vector, and the additive attention layer is used to learn the nonlinear relationship between the query vector and the key vector through the feedforward neural network layer;

[0010] The iteratively training the preset model based on the first loss value until the first loss value is less than a preset threshold, and determining the iteratively trained preset model as a multi-round dialogue model, includes:

[0011] When the first loss value is less than a preset threshold, obtaining first parameters corresponding to the encoder after iterative training, the first parameters including encoder parameters, decoder parameters, and feedforward neural network layer parameters, the encoder parameters including the weight of the dot product attention layer and the weight of the additive attention layer;

[0012] A preset model having the first parameters is determined as the multi-round dialogue model.

[0013] Optionally, before obtaining the continuous multi-round dialogue texts and the first word segmentation sequence corresponding to the first text, the method further includes:

[0014] Performing word segmentation on the first text to obtain the N word units;

[0015] Performing masking on any word among the N words to obtain a masked tag of a target word, where the target word is the word among the N words that has been masked;

[0016] Obtain a classification tag corresponding to the preset intent of the first text.

[0017] Optionally, the calculating of the preset model based on the entity loss determined by the N-1 word-grams, the mask loss determined by the mask mark, the intent loss determined by the classification mark, and the dialogue sequence loss determined by the first text and the second text to obtain the first loss value includes:

[0018] Calculating the entity loss based on the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words, wherein the word-gram representation vectors are vectors determined by the preset model based on the N-1 words, and the entity label vectors are preset vectors of the entities corresponding to the N-1 words respectively;

[0019] Calculating the mask loss based on a first mask representation vector of the mask mark and a second mask representation vector of the target word, where the first mask representation vector is a vector determined by the preset model based on the mask mark, and the second mask representation vector is a vector corresponding to the target word;

[0020] Calculating the intent loss based on a first intent representation vector of the classification mark and a second intent representation vector of the preset intent, where the first intent representation vector is a vector determined by the preset model based on the classification mark, and the second intent representation vector is a vector corresponding to the preset intent;

[0021] Calculating a dialogue sequence loss based on a first sequence representation vector of the first text and a second sequence representation vector of the first text, wherein the second sequence representation vector is a vector used to represent the first text determined by the preset model based on the second text, and the first sequence representation vector is a preset vector of the first text;

[0022] The first loss value is determined according to the entity loss, the mask loss, the intention loss and the dialog sequence loss.

[0023] Optionally, calculating the entity loss according to the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words includes:

[0024] Each of the N-1 word-grams is one-hot encoded, passed through a fully connected layer, and an embedding vector is set for each word-gram, and then input into the preset model to obtain the word-gram representation vector corresponding to the N-1 word-grams, wherein the embedding vector is used to represent the position order of the word-gram in the first text, and the fully connected layer is used to unify the dimensions of the N-1 word-grams after the one-hot encoding;

[0025] Obtain the entity label vector corresponding to each word in the N-1 words;

[0026] In the conditional random field (CRF) layer, the entity loss is obtained according to the word unit representation vector and the entity label vector.

[0027] Optionally, calculating the mask loss according to the first mask representation vector of the mask token and the second mask representation vector of the target word includes:

[0028] Inputting the mask mark into the preset model and passing it through the embedding layer to obtain the first mask representation vector;

[0029] One-hot encoding the target word and passing it through a fully connected layer and an embedding layer to obtain the second mask representation vector, wherein both the fully connected layer and the embedding layer are used for dimensionality unification;

[0030] The similarity between the first mask representation vector and the second mask representation vector is calculated using a cosine angle to obtain the mask loss.

[0031] Optionally, calculating the intent loss according to the first intent representation vector of the classification mark and the second intent representation vector of the preset intent includes:

[0032] One-hot encode the classification mark, pass it through a fully connected layer, and input it into the preset model to obtain the first intent representation vector;

[0033] Inputting the preset intent into the embedding layer to obtain the second intent representation vector, and both the fully connected layer and the embedding layer are used to unify the dimensions;

[0034] The similarity between the first intention representation vector and the second intention representation vector is calculated by using the cosine angle to obtain the intention loss.

[0035] In a second aspect, an embodiment of the present application provides a multi-round dialogue model training device, the device comprising:

[0036] A first acquisition module is configured to acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to the first text, wherein the first text is the last round of conversation text in the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, and the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence includes N word units, the mask mark is a first mark corresponding to any target word unit among the N word units, the N-1 word units are word units other than the target word unit among the N word units, and the classification mark is a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1;

[0037] a calculation module, configured to calculate an entity loss determined by a preset model based on the N-1 word-grams, a mask loss determined based on the mask mark, an intent loss determined based on the classification mark, and a dialogue sequence loss determined based on the first text and a second text, to obtain a first loss value, where the second text is a dialogue text in the multiple rounds of dialogue text excluding the first text;

[0038] A training module is used to iteratively train the preset model based on the first loss value until the first loss value is less than a preset threshold, and determine the preset model after iterative training as a multi-round dialogue model.

[0039] In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor, a memory, and a program stored on the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the multi-round dialogue model training method as described in the first aspect are implemented.

[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the multi-round dialogue model training method as described in the first aspect are implemented.

[0041] In the embodiment of the present application, a continuous multi-round dialogue text and the first word segmentation sequence corresponding to the first text are first obtained. In the first word segmentation sequence, mask tags and classification tags are designed to provide a preset model with an input representation that integrates word units, intent, and sequence information. During the training process, the multi-round dialogue text input is used to establish context dependencies. Then, using four types of loss functions (entity, mask, intent, and dialogue sequence), the preset model is driven to simultaneously learn local semantics, intent classification, and cross-round dependencies, enhancing its ability to predict complex dialogue structures. Finally, the first loss value is used to determine whether the preset model training is complete to obtain a multi-round dialogue model, ensuring the generalization performance of the multi-round dialogue model on multiple tasks. This effectively solves the problem of context management in multi-round dialogues, enables the multi-round dialogue model to accurately capture key information when handling complex dialogues, and improves the accuracy of the multi-round dialogue model's output results. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0043] Figure 1 This is one of the flow charts of a multi-round dialogue model training method provided in an embodiment of the present application;

[0044] Figure 2 This is the second flowchart of a multi-round dialogue model training method provided in an embodiment of the present application;

[0045] Figure 3 This is a structural diagram of a multi-round dialogue model training device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0047] See also Figure 1 , Figure 1 This is one of the flow charts of a multi-round dialogue model training method provided in an embodiment of the present application. Figure 1 As shown, the method includes the following steps:

[0048] Step 101: Acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to a first text, where the first text is the last round of the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, and the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence includes N word units, the mask mark is a first mark corresponding to any target word unit among the N word units, the N-1 word units are word units other than the target word unit among the N word units, and the classification mark is a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1;

[0049] In this step, the multi-turn conversation text may include the first text and the multi-turn conversation text preceding the first text, with the multi-turn conversation text preceding the first text being denoted as the second text. By acquiring continuous multi-turn conversation text, the subsequent preset model can establish contextual dependencies, enabling the model to learn the state transition patterns of the multi-turn conversation and enhance its understanding of complex conversational contexts. Furthermore, the second word segmentation sequence corresponding to the first text may include multiple tokens. The mask tag may be a tag obtained by masking any of the multiple tokens, denoted as "_mask_." The classification tag may be a tag determined based on the preset intent corresponding to the first text, denoted as "_CLS_." Masking any target token among the N tokens in the second word segmentation sequence yields a mask tag corresponding to the target token. The classification tag is then added to the second word segmentation sequence as the preset intent corresponding to the first text. Thus, based on the mask tag and classification tag in the second word segmentation sequence, as well as the remaining N-1 tokens, the first word segmentation sequence corresponding to the first text is obtained. This provides structured input for subsequent multi-task learning. Among them, the mask tag is used to trigger the model's predictive learning of specific word units (such as entities or semantic completion), and the classification tag clearly points to the intent category of the text. At the same time, the retained word units and position information provide the basis for entity extraction and context modeling, ensuring that the model can simultaneously learn semantic information at the word level, intent level and sequence level.

[0050] Step 102: Calculate the entity loss determined by the preset model based on the N-1 word-grams, the mask loss determined based on the mask mark, the intent loss determined based on the classification mark, and the conversation sequence loss determined based on the first text and the second text to obtain a first loss value, where the second text is the conversation text in the multiple rounds of conversation text excluding the first text.

[0051] In this step, the pre-set model first determines entity loss based on N-1 tokens, mask loss based on mask tags, intent loss based on classification tags, and dialogue sequence loss based on the first and second texts. Then, a first loss value (i.e., total loss) is calculated based on the entity loss, mask loss, intent loss, and dialogue sequence loss. The calculation of the entity loss constrains the model to accurately extract entity labels such as time and location. The calculation of the mask loss forces the model to restore masked tokens based on context. The calculation of the intent loss ensures that the classification tags correspond to the correct textual intent. The calculation of the dialogue sequence loss leverages the continuous multi-turn dialogue text to establish contextual dependencies. By integrating these four loss types through backpropagation, the model can simultaneously learn token-level details, intent semantics, and state transition patterns across multi-turn dialogues. It gradually adjusts parameters to enhance its understanding of complex dialogue contexts, such as capturing entity associations or intent evolution across turns. This improves the accuracy of the trained model's output.

[0052] Step 103: Iteratively train the preset model based on the first loss value until the first loss value is less than a preset threshold, and determine the preset model after iterative training as a multi-round dialogue model.

[0053] In this step, the preset model is iteratively trained based on the first loss value to jointly optimize the multi-task loss; and by setting the training termination condition, when the first loss value calculated during the iteration (i.e., the total objective function integrating the multi-task loss) is less than the preset threshold, the preset model is considered to have converged, and training is stopped and the final multi-round dialogue model is output. This process ensures that the preset model achieves the expected accuracy in tasks such as entity extraction, intent recognition, mask prediction, and dialogue state sequence prediction, avoiding overfitting or underfitting. The multi-round dialogue model finally obtained can accurately predict the context state of the current round based on the historical dialogue state, realize the cross-round integration of intent and entity information in multi-round dialogues, accurately capture key information when processing complex and long dialogues, and improve the accuracy of the output results of the multi-round dialogue model.

[0054] In the embodiment of the present application, a continuous multi-round dialogue text and the first word segmentation sequence corresponding to the first text are first obtained. In the first word segmentation sequence, mask tags and classification tags are designed to provide a preset model with an input representation that integrates word units, intent, and sequence information. During the training process, the multi-round dialogue text input is used to establish context dependencies. Then, using four types of loss functions (entity, mask, intent, and dialogue sequence), the preset model is driven to simultaneously learn local semantics, intent classification, and cross-round dependencies, enhancing its ability to predict complex dialogue structures. Finally, the first loss value is used to determine whether the preset model training is complete to obtain a multi-round dialogue model, ensuring the generalization performance of the multi-round dialogue model on multiple tasks. This effectively solves the problem of context management in multi-round dialogues, enables the multi-round dialogue model to accurately capture key information when handling complex dialogues, and improves the accuracy of the multi-round dialogue model's output results.

[0055] Optionally, before obtaining the continuous multi-round dialogue texts and the first word segmentation sequence corresponding to the first text, the method further includes:

[0056] Performing word segmentation on the first text to obtain the N word units;

[0057] Performing masking on any word among the N words to obtain a masked tag of a target word, where the target word is the word among the N words that has been masked;

[0058] Obtain a classification tag corresponding to the preset intent of the first text.

[0059] In this embodiment, the first text can be "How many people lived in Beijing last week?". After word segmentation, four tokens can be obtained: "last week", "Beijing", "number of residents" and "how many". The retained four tokens and the position information corresponding to each token can provide a basis for entity extraction and context modeling. Masking is performed on any of the four tokens. For example, masking is performed on "how many". The target token (i.e., "how many") is replaced with a mask tag, which can be represented by "_mask_". The mask tag can be used to trigger the model's predictive learning of specific tokens (such as entity or semantic completion). After masking, a sequence containing mask tags is obtained: ["last week", "Beijing", "number of residents" and "_mask_"]. Moreover, it is known that the preset intention of the first text is "data query". A specific classification tag can be defined for this intention, for example, "_CLS_". The classification tag clearly points to the intention category of the text. The first word segmentation sequence including N-1 tokens, mask tags and classification tags provides structured input for subsequent multi-task learning.

[0060] Optionally, the preset model includes an encoder, a decoder, and a feedforward neural network layer, the encoder includes a dot product attention layer and an additive attention layer, the dot product attention layer is used to determine the attention weight of the value vector by calculating the dot product between the query vector and the key vector, and the additive attention layer is used to learn the nonlinear relationship between the query vector and the key vector through the feedforward neural network layer;

[0061] The iteratively training the preset model based on the first loss value until the first loss value is less than a preset threshold, and determining the iteratively trained preset model as a multi-round dialogue model, includes:

[0062] When the first loss value is less than a preset threshold, obtaining first parameters corresponding to the encoder after iterative training, the first parameters including encoder parameters, decoder parameters, and feedforward neural network layer parameters, the encoder parameters including the weight of the dot product attention layer and the weight of the additive attention layer;

[0063] A preset model having the first parameters is determined as the multi-round dialogue model.

[0064] In this embodiment, the dot product attention layer calculates the dot product between the query vector Q and the key vector K to determine the similarity between them, and then assigns the attention weight to the value vector V. In sequence modeling of natural language processing, dot product attention can capture the long-range dependencies between different elements in the sequence. For example, when processing multi-round dialogues, it can help the model understand the association of relevant information in different rounds. It can be calculated as QK T , after scaling and normalization, the attention weights are obtained, and the value vector V is weightedly summed to obtain the output. The additive attention layer uses the feedforward neural network layer to learn the nonlinear relationship between Q and K. Additive attention can play a role when the pattern in the data is more complex and the simple dot product operation cannot capture the information well. Through a feedforward neural network, Q and K are nonlinearly transformed, and then the attention score is obtained by calculation, which can better handle different types of inputs and enhance the model's ability to model complex patterns. The feedforward neural network layer can include multiple fully connected layers and multiple embedding layers. The feedforward neural network layer can further transform and extract features of the output of the attention layer, so that more advanced feature representations can be learned, and the information captured by the attention layer can be integrated and transformed to provide more effective features for subsequent tasks.

[0065] Specifically, the encoder can be composed of three layers, each layer contains multi-head self-attention and a corresponding feedforward neural network layer. For the lth layer (l ranges from 1 to 3), the calculation process is as follows:

[0066] The attention Q, K, V calculation can be expressed as:

[0067] Among them, Q represents the query vector, K represents the key vector, and V represents the value vector. In the self-attention mechanism, Q, K, and V are all generated from the same input sequence through different linear transformations. l , K l With V l represents the Q, K, V vector of the encoder layer l.

[0068] The raw output of self-attention can be expressed as:

[0069] In the original self-attention mechanism, position information is typically added to the input sequence via positional encoding. Based on this, this embodiment considers both dot product attention and additive attention. Dot product attention measures the similarity between Q and K by calculating the dot product between them. This is suitable for capturing long-range dependencies and is a key component of the Transformer model. Additive attention uses a feedforward neural network to learn the nonlinear relationship between Q and K, which can better handle complex patterns and relationships, especially when processing heterogeneous input types.

[0070] Furthermore, the first parameters include encoder parameters, decoder parameters, and feedforward neural network layer parameters, with the encoder parameters including weights for the dot-product attention layer and the additive attention layer. The decoder corresponds to the encoder, and the encoder and decoder work in coordination to calculate the dialogue sequence loss. The concept of dynamic weights is introduced, using learned weights (i.e., the first parameters) to adjust the importance of dot-product attention and additive attention, allowing the preset model to dynamically adjust the attention mechanism based on different inputs. By fusing the results of dot-product attention and additive attention, the advantages of both can be leveraged, improving the model's ability to capture information. By dynamically adjusting the first parameters, the model can more accurately capture key information, thereby improving the accuracy of intent recognition and entity extraction. Furthermore, the fusion of the two attention mechanisms makes the model more flexible in handling different types of inputs, enhancing the model's generalization capabilities. Finally, the introduction of dynamic weights makes the model more efficient in processing information, reduces unnecessary computation, and improves the model's operational efficiency.

[0071] For example, the modified self-attention formula can be expressed as:

[0072]

[0073] Among them, d k are the dimensions of Q, K, and V, is the learnable weight, λ lis the learnable dynamic weight. T represents the matrix transpose. The first parameter includes the learnable weight and the learnable dynamic weight.

[0074] The output of self-attention is normalized through residual connection and layer, expressed as:

[0075]

[0076] Among them, H l-1 is the hidden state of the encoder's l-1th layer output, It is the hidden state of the lth layer in the encoder after the self-attention mechanism is processed and the residual connection and layer normalization operations are added.

[0077] The feedforward neural network can be expressed as:

[0078]

[0079] in is the weight of the l-th layer two-layer feedforward neural network, and is the bias vector.

[0080] The final hidden state is:

[0081] Thus, when the first loss value is less than a preset threshold, it means that the current preset model has achieved certain performance requirements during training, and the model parameters can be considered to have converged to a good state. During iterative training, when the first loss value is less than the preset threshold, the first parameters corresponding to the encoder are obtained. These parameters include the weights of the dot-product attention layer, the weights of the additive attention layer, the decoder parameters, and the weights of the feedforward neural network layer. These weight parameters determine the computational methods and feature extraction capabilities of each layer. The preset model with the encoder parameters set to the obtained first parameters is determined as the multi-turn dialogue model. During training, by minimizing the first loss value (which combines entity loss, mask loss, intent loss, and dialogue sequence loss), the model has learned how to extract useful information from the input dialogue data, including entity information, intent information, and contextual information related to the dialogue. Therefore, using these trained parameters, the model can accurately understand the user's intent, recognize entities, and respond appropriately based on historical dialogue information in multi-turn dialogue scenarios. This can fully utilize the knowledge learned by the model during training to improve the performance of multi-turn dialogue processing.

[0082] Optionally, the calculating of the preset model based on the entity loss determined by the N-1 word-grams, the mask loss determined by the mask mark, the intent loss determined by the classification mark, and the dialogue sequence loss determined by the first text and the second text to obtain the first loss value includes:

[0083] Calculating the entity loss based on the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words, wherein the word-gram representation vectors are vectors determined by the preset model based on the N-1 words, and the entity label vectors are preset vectors of the entities corresponding to the N-1 words respectively;

[0084] Calculating the mask loss based on a first mask representation vector of the mask mark and a second mask representation vector of the target word, where the first mask representation vector is a vector determined by the preset model based on the mask mark, and the second mask representation vector is a vector corresponding to the target word;

[0085] Calculating the intent loss based on a first intent representation vector of the classification mark and a second intent representation vector of the preset intent, where the first intent representation vector is a vector determined by the preset model based on the classification mark, and the second intent representation vector is a vector corresponding to the preset intent;

[0086] Calculating a dialogue sequence loss based on a first sequence representation vector of the first text and a second sequence representation vector of the first text, wherein the second sequence representation vector is a vector used to represent the first text determined by the preset model based on the second text, and the first sequence representation vector is a preset vector of the first text;

[0087] The first loss value is determined according to the entity loss, the mask loss, the intention loss and the dialog sequence loss.

[0088] In this embodiment, Figure 2As shown in the figure, by designing a multi-dimensional loss function in the preset model, the joint optimization of the preset model is achieved. Specifically, the first text can be "How many people lived in Beijing last week?". After word segmentation of the first text, four tokens can be obtained: "last week", "Beijing", "number of residents" and "how many"; any of these four tokens are masked, for example, "how many" is masked, and the target token (i.e. "how many") is replaced with a mask tag, which can be represented by "_mask_". The mask tag can be used to trigger the model's predictive learning of specific tokens (such as entity or semantic completion). After masking, a sequence containing mask tags is obtained: ["last week", "Beijing", "number of residents" and "_mask_"]. Moreover, it is known that the preset intention of the first text is "data query", and a specific classification tag can be defined for this intention, for example, "_CLS_". The classification tag clearly points to the intention category of the text. The first word segmentation sequence input to the preset model includes N-1 word units, mask tags, and classification tags, providing structured input for subsequent multi-task learning. At the same time, continuous multi-round dialogue texts are also input into the preset model to drive the preset model to learn the context dependencies in multi-round dialogues. In this way, the accurate recognition of word-level semantics is ensured by calculating the entity loss; the local semantic understanding and reasoning capabilities are enhanced by calculating the mask loss; the model is ensured to correctly capture the overall intent of the text by calculating the intention loss; and the model is driven to learn the context dependencies in multi-round dialogues by calculating the dialogue sequence loss. According to the determined first loss value, the preset model is iterated to eventually form a multi-round dialogue model that can comprehensively handle entity extraction, intention recognition, semantic completion, and multi-round dialogue state transitions, effectively improving the accuracy of the multi-round dialogue model output results. The calculation process of entity loss, mask loss, intention loss, and dialogue sequence loss can be seen in the following description:

[0089] In one embodiment, calculating the entity loss based on the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words includes:

[0090] Each of the N-1 word-grams is one-hot encoded, passed through a fully connected layer, and an embedding vector is set for each word-gram, and then input into the preset model to obtain the word-gram representation vector corresponding to the N-1 word-grams, wherein the embedding vector is used to represent the position order of the word-gram in the first text, and the fully connected layer is used to unify the dimensions of the N-1 word-grams after the one-hot encoding;

[0091] Obtain the entity label vector corresponding to each word in the N-1 words;

[0092] In the conditional random field (CRF) layer, the entity loss is obtained according to the word unit representation vector and the entity label vector.

[0093] In this embodiment, each of the N-1 word-grams is subjected to one-hot encoding, and then input into the fully connected layer. After the position embedding vector is added to each word-gram, each word-gram is input into the fully connected layer, and finally input into the encoder of the preset model. The word-gram representation vector corresponding to the N-1 word-grams output by the encoder is obtained. The word-gram representation vector contains the semantic information and position information of the word-gram, and is an abstract representation of the word-gram by the model. Among them, one-hot encoding is a method of converting discrete features into vector representations. Each word-gram is represented as a vector with only one element being 1 and the rest being 0. One-hot encoding can convert text information into a numerical form that can be processed by a computer. The embedding vector can represent the position order of the word-gram in the first text. By integrating the position information into the word-gram representation through the embedding vector, the model can better understand the semantics and structure of the text.

[0094] Obtain the entity label vector corresponding to each of the N-1 tokens. The entity label vector is pre-set and represents the entity type corresponding to each token, such as time, location, or indicator. These entity label vectors are the training targets of the model; the model needs to learn how to accurately predict these entity labels from the token representation vectors.

[0095] The word unit representation vector and the entity label vector are input into the Conditional Random Field (CRF) layer. CRF is a probabilistic graphical model commonly used in sequence labeling tasks that can take into account the contextual relationship between elements in the sequence. The CRF layer can calculate the entity loss based on the input word unit representation vector and the target entity label vector, denoted as L entity The entity loss reflects the difference between the entity label predicted by the model and the true entity label. By minimizing the entity loss, the model can continuously adjust its own parameters and improve the prediction accuracy of the entity label.

[0096] In one embodiment, calculating the mask loss based on the first mask representation vector of the mask token and the second mask representation vector of the target word includes:

[0097] Inputting the mask mark into the preset model and passing it through the embedding layer to obtain the first mask representation vector;

[0098] One-hot encoding the target word and passing it through a fully connected layer and an embedding layer to obtain the second mask representation vector, wherein both the fully connected layer and the embedding layer are used for dimensionality unification;

[0099] The similarity between the first mask representation vector and the second mask representation vector is calculated using a cosine angle to obtain the mask loss.

[0100] In this embodiment, the mask tag (i.e., "_mask_") is input into the encoder in the preset model to obtain a first mask representation vector. In natural language processing tasks, "_mask_" is usually used to mask certain words in the text, allowing the model to predict the masked content based on contextual information. The preset model processes the mask tag and generates a vector to represent the mask tag based on the contextual information of the input text, namely the first mask representation vector. The first mask representation vector contains the model's semantic understanding and prediction information of the masked position based on the context.

[0101] At the same time, the masked target word (such as "how many") is one-hot encoded and converted into a high-dimensional sparse vector with only the corresponding word index position as 1 and the rest as 0; then it is projected into a low-dimensional space to obtain a dense vector through the linear transformation of the fully connected layer; then the embedding layer is used to extract the semantic representation of the word from the pre-trained or learnable embedding matrix to form a vector containing its true semantic information; the final vector is the second mask representation vector used to calculate the mask loss, and the second mask representation vector represents the true semantic information of the target word.

[0102] Then, the similarity between the first mask representation vector and the second mask representation vector is calculated by the cosine angle to obtain the mask loss, which is recorded as L mask The similarity between two vectors is expressed by calculating the cosine value of the angle between them. The value range is between -1 and 1. The closer the value is to 1, the more similar the two vectors are. When calculating the mask loss, 1 is usually subtracted from the cosine similarity. The smaller the loss value obtained, the more similar the first mask representation vector predicted by the model is to the true second mask representation vector, that is, the more accurate the model's prediction of the masked word is. In this way, the mask loss L is calculated. mask The model learns the semantic information and contextual relationships in the text. By continuously minimizing the mask loss, the model can gradually improve its ability to predict masked tokens, thereby better understanding the overall semantics of the text.

[0103] In one embodiment, calculating the intent loss based on the first intent representation vector of the classification mark and the second intent representation vector of the preset intent includes:

[0104] One-hot encode the classification mark, pass it through a fully connected layer, and input it into the preset model to obtain the first intent representation vector;

[0105] Inputting the preset intent into the embedding layer to obtain the second intent representation vector, and both the fully connected layer and the embedding layer are used to unify the dimensions;

[0106] The similarity between the first intention representation vector and the second intention representation vector is calculated by using the cosine angle to obtain the intention loss.

[0107] In this implementation, the classification tag (i.e., "_CLS_") is one-hot encoded and processed through a fully connected layer before being fed into the encoder in the pre-set model. This is then fed into the embedding layer to generate a first intent representation vector. Classification tags represent text intent. For example, in a conversational system, there might be classification tags for different intents, such as "querying information" and "initiating a request." This first intent representation vector reflects the model's understanding and characterization of text intent.

[0108] At the same time, the second intent representation vector corresponding to the preset intent is obtained. The preset intent refers to the pre-set true intent of the text (such as "query information"). The preset intent is converted into a high-dimensional sparse vector through one-hot encoding, where each intent corresponds to a unique index position of 1; it is then projected into a low-dimensional space through a linear transformation of the embedding layer to obtain a dense vector representation, and the semantic information of the intent is integrated. The final vector is the second intent representation vector used to calculate the intent loss. The second intent representation vector represents a quantitative expression of the true intent.

[0109] Then, the cosine angle is used to calculate the similarity between the first intention representation vector and the second intention representation vector to obtain the intention loss, which is recorded as L intent When calculating intent loss, we can also subtract the cosine similarity value from 1 to obtain a non-negative loss value. If the intent loss is small, it means that the model's predicted intent (the first intent representation vector) and the true intent (the second intent representation vector) are close; otherwise, it indicates that the model has a deviation in intent prediction.

[0110] In one embodiment, a dialogue sequence loss is calculated based on a first sequence representation vector of the first text and a second sequence representation vector of the first text, wherein the second sequence representation vector is a vector of the first text determined by the preset model based on the second text, and the first sequence representation vector is a preset vector of the first text. For details, see the following expression:

[0111] The first text and the second text can adopt a unified format of dialogue state sequence, such as {intent, entity 1, ..., entity n}. After the second text (i.e. the previous dialogue text, such as the dialogue state of the n-1th round) is processed by one-hot encoding and full connection layer, it is input into the encoder and decoder of the preset model, and then passed through the embedding layer to obtain the second sequence representation vector; at the same time, the first sequence representation vector of the first text (i.e. the current dialogue text, such as the dialogue state of the nth round) is input into the embedding layer, and the difference between the second sequence representation vector (the historical dialogue associated with the current state predicted by the model) and the first sequence representation vector (the actual current state) is calculated to obtain the dialogue sequence loss, which is denoted as L seq2seq The encoder parameters in the model are iterated based on the dialogue sequence loss to ensure that it can accurately predict the dialogue state of the current round based on the historical context, ultimately improving the coherence and context consistency of the multi-round dialogue system.

[0112] Specifically, the calculation process of the encoder and decoder for the dialogue state sequence can be seen as follows:

[0113] Data preparation: For example, we collected query conversations from the transportation department's traffic survey, extracted the intents and entities mentioned, and sequentially constructed them into a conversation state sequence in the format: {intent, entity 1, entity 2, ..., entity n}. Taking the first two sentences as examples: "What was the population of City A last month?" and "What about City B?", these two sentences can be converted into the following conversation state sequence: [{Indicator query, last month, City A, population}, {Single location query, "", City B, ""}].

[0114] Expected output: Input the first two rounds of dialogue state sequence: [{indicator query, last month, City A, number of residents}, {single location query, "", City B, ""}], output the third round of dialogue state sequence: {single indicator query, "", "", number of working population};

[0115] Input embedding: Assume that the input sequence (i.e. the sequence corresponding to the second text) is: DialogState = {D1, D2, ..., D T}, where D t is the one-hot encoded conversation state sequence {Intent,entity1,entity2,...entity k} t , t ranges from 1 to n-1.

[0116] First, each dialogue state sequence is converted into an embedding vector The following relationship is satisfied:

[0117] H 0=DialogStateW DialogState ;

[0118]

[0119] Among them, Intent represents intention, entity j (j from 1 to k) represents the entity, W DialogState is the learnable embedding vector matrix.

[0120] The decoder can be composed of a layer, including multi-head self-attention, encoder-decoder attention and feedforward neural network. For the lth layer (l=4), the output of the decoder H 4 After linear transformation, the final output is obtained:

[0121] Y=H 4 W o +b o ;

[0122] Where W o and b o are the weights and biases of the output layer.

[0123] The predicted dialogue state sequence of the nth round is input into Y, and the similarity with the actual nth round state sequence is calculated as the dialogue state sequence prediction loss L seq2seq .

[0124] After obtaining the entity loss L entity , mask loss L mask 、Intention loss L intent and dialogue sequence loss L seq2seq Afterwards, determine the first loss value L total , you can refer to the following formula:

[0125] L total =L entity +L intent +L mask +L seq2seq ;

[0126] Among them, the first word segmentation sequence can be input into the preset model for iterative training through the optimization algorithm, and the iteration stop condition is set to |ΔL total |<10 -10 The optimization algorithm can be expressed as:

[0127] θ * =argmin θ L total ;

[0128] The optimal parameters are calculated through the optimization algorithm. The training is stopped when the absolute value of the total loss changes less than 10e-10. The optimal model parameters are output, that is, the first parameters corresponding to the encoder in the preset model after the target number of iterative training.

[0129] This technology addresses the challenge of context management in multi-round conversations. By introducing the task of dialog state sequence prediction, it effectively integrates user intent and entity information, accurately predicting the state of the nth round based on the dialog state sequence of the previous n-1 rounds. By jointly learning intent recognition, entity extraction, and mask prediction tasks, it has achieved an improvement in dialog intent recognition accuracy from 80% to 95.3%, a reduction in response time from 5 seconds to 3 seconds, and an increase in guided question generation accuracy from 60% to 90%. These achievements not only demonstrate the high accuracy and fast response of multi-round conversation processing, but also enhance the ability to manage dialog context, providing users with a smoother and more precise interactive experience.

[0130] See also Figure 3 , Figure 3 This is a structural diagram of a multi-round dialogue model training device provided in an embodiment of the present application. Figure 3 As shown, the multi-round dialogue model training device 300 includes:

[0131] A first acquisition module 301 is configured to acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to the first text, wherein the first text is the last round of the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, the first word segmentation sequence being obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence including N word units, the mask mark being a first mark corresponding to any target word unit among the N word units, the N-1 word units being word units other than the target word unit among the N word units, and the classification mark being a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1;

[0132] A calculation module 302 is configured to calculate an entity loss determined by a preset model based on the N-1 word-grams, a mask loss determined based on the mask mark, an intent loss determined based on the classification mark, and a conversation sequence loss determined based on the first text and a second text, to obtain a first loss value, where the second text is a conversation text in the multiple rounds of conversation text excluding the first text.

[0133] The training module 303 is used to iteratively train the preset model based on the first loss value until the first loss value is less than a preset threshold, and determine the preset model after iterative training as a multi-round dialogue model.

[0134] Optionally, the preset model includes an encoder, a decoder, and a feedforward neural network layer, the encoder includes a dot product attention layer and an additive attention layer, the dot product attention layer is used to determine the attention weight of the value vector by calculating the dot product between the query vector and the key vector, and the additive attention layer is used to learn the nonlinear relationship between the query vector and the key vector through the feedforward neural network layer;

[0135] The training module 303 is specifically used to:

[0136] When the first loss value is less than a preset threshold, obtaining first parameters corresponding to the encoder after iterative training, the first parameters including encoder parameters, decoder parameters, and feedforward neural network layer parameters, the encoder parameters including the weight of the dot product attention layer and the weight of the additive attention layer;

[0137] A preset model having the first parameters is determined as the multi-round dialogue model.

[0138] Optionally, the device further comprises:

[0139] A first processing module, configured to perform word segmentation on the first text to obtain the N word units;

[0140] a second processing module, configured to perform masking on any word among the N word-grams to obtain a masked tag of a target word-gram, where the target word-gram is the word-gram subjected to masking among the N word-grams;

[0141] The second acquisition module is used to obtain a classification label corresponding to the preset intention of the first text.

[0142] Optionally, the calculation module 302 is specifically configured to:

[0143] Calculating the entity loss based on the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words, wherein the word-gram representation vectors are vectors determined by the preset model based on the N-1 words, and the entity label vectors are preset vectors of the entities corresponding to the N-1 words respectively;

[0144] Calculating the mask loss based on a first mask representation vector of the mask mark and a second mask representation vector of the target word, where the first mask representation vector is a vector determined by the preset model based on the mask mark, and the second mask representation vector is a vector corresponding to the target word;

[0145] Calculating the intent loss based on a first intent representation vector of the classification mark and a second intent representation vector of the preset intent, where the first intent representation vector is a vector determined by the preset model based on the classification mark, and the second intent representation vector is a vector corresponding to the preset intent;

[0146] Calculating a dialogue sequence loss based on a first sequence representation vector of the first text and a second sequence representation vector of the first text, wherein the second sequence representation vector is a vector used to represent the first text determined by the preset model based on the second text, and the first sequence representation vector is a preset vector of the first text;

[0147] The first loss value is determined according to the entity loss, the mask loss, the intention loss and the dialog sequence loss.

[0148] Optionally, calculating the entity loss according to the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words includes:

[0149] Each of the N-1 word-grams is one-hot encoded, passed through a fully connected layer, and an embedding vector is set for each word-gram, and then input into the preset model to obtain the word-gram representation vector corresponding to the N-1 word-grams, wherein the embedding vector is used to represent the position order of the word-gram in the first text, and the fully connected layer is used to unify the dimensions of the N-1 word-grams after the one-hot encoding;

[0150] Obtain the entity label vector corresponding to each word in the N-1 words;

[0151] In the conditional random field (CRF) layer, the entity loss is obtained according to the word unit representation vector and the entity label vector.

[0152] Optionally, calculating the mask loss according to the first mask representation vector of the mask token and the second mask representation vector of the target word includes:

[0153] Inputting the mask mark into the preset model and passing it through the embedding layer to obtain the first mask representation vector;

[0154] One-hot encoding the target word and passing it through a fully connected layer and an embedding layer to obtain the second mask representation vector, wherein both the fully connected layer and the embedding layer are used for dimensionality unification;

[0155] The similarity between the first mask representation vector and the second mask representation vector is calculated using a cosine angle to obtain the mask loss.

[0156] Optionally, calculating the intent loss according to the first intent representation vector of the classification mark and the second intent representation vector of the preset intent includes:

[0157] One-hot encode the classification mark, pass it through a fully connected layer, and input it into the preset model to obtain the first intent representation vector;

[0158] Inputting the preset intent into the embedding layer to obtain the second intent representation vector, and both the fully connected layer and the embedding layer are used to unify the dimensions;

[0159] The similarity between the first intention representation vector and the second intention representation vector is calculated by using the cosine angle to obtain the intention loss.

[0160] The multi-round dialogue model training device 300 is capable of implementing each process of each embodiment of the above-mentioned multi-round dialogue model training method. The technical features correspond one to one and can achieve the same technical effects. To avoid repetition, they will not be described here.

[0161] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, each process of the above-mentioned multi-round dialogue model training method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0162] The present application also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the various processes of the above-described multi-turn dialogue model training method embodiment and achieves the same technical effects. To avoid repetition, the details are omitted here. The computer-readable storage medium may be, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0163] An embodiment of the present application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, the various processes of the above-mentioned multi-round dialogue model training method embodiment are implemented, and the same technical effects can be achieved. To avoid repetition, they will not be repeated here.

[0164] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing the functions in the order discussed, but may also include performing the functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0165] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0166] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A multi-round dialogue model training method, characterized in that: The method comprises: Acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to a first text, where the first text is a last-round conversation text in the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence includes N word units, the mask mark is a first mark corresponding to any target word unit among the N word units, the N-1 word units are word units other than the target word unit among the N word units, and the classification mark is a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1; Calculating an entity loss determined by a preset model based on the N-1 word-grams, a mask loss determined based on the mask tag, an intent loss determined based on the classification tag, and a conversation sequence loss determined based on the first text and a second text to obtain a first loss value, where the second text is a conversation text in the multiple rounds of conversation text excluding the first text; The preset model is iteratively trained based on the first loss value until the first loss value is less than a preset threshold, and the preset model after iterative training is determined as a multi-round dialogue model.

2. The method according to claim 1, characterized in that The preset model includes an encoder, a decoder, and a feedforward neural network layer. The encoder includes a dot product attention layer and an additive attention layer. The dot product attention layer is used to determine the attention weight of the value vector by calculating the dot product between the query vector and the key vector. The additive attention layer is used to learn the nonlinear relationship between the query vector and the key vector through the feedforward neural network layer. The iteratively training the preset model based on the first loss value until the first loss value is less than a preset threshold, and determining the iteratively trained preset model as a multi-round dialogue model, includes: When the first loss value is less than a preset threshold, obtaining first parameters corresponding to the encoder after iterative training, the first parameters including encoder parameters, decoder parameters, and feedforward neural network layer parameters, the encoder parameters including the weight of the dot product attention layer and the weight of the additive attention layer; A preset model having the first parameters is determined as the multi-round dialogue model.

3. The method according to claim 1, characterized in that Before obtaining the continuous multi-round dialogue texts and the first word segmentation sequence corresponding to the first text, the method further includes: Performing word segmentation on the first text to obtain the N word units; Performing masking on any word among the N words to obtain a masked tag of a target word, where the target word is the word among the N words that has been masked; Obtain a classification tag corresponding to the preset intent of the first text.

4. The method according to any one of claims 1 to 3, characterized in that The calculation preset model obtains a first loss value based on an entity loss determined by the N-1 word-grams, a mask loss determined by the mask mark, an intent loss determined by the classification mark, and a dialogue sequence loss determined by the first text and the second text, including: Calculating the entity loss based on the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words, wherein the word-gram representation vectors are vectors determined by the preset model based on the N-1 words, and the entity label vectors are preset vectors of the entities corresponding to the N-1 words respectively; Calculating the mask loss based on a first mask representation vector of the mask mark and a second mask representation vector of the target word, where the first mask representation vector is a vector determined by the preset model based on the mask mark, and the second mask representation vector is a vector corresponding to the target word; Calculating the intent loss based on a first intent representation vector of the classification mark and a second intent representation vector of the preset intent, where the first intent representation vector is a vector determined by the preset model based on the classification mark, and the second intent representation vector is a vector corresponding to the preset intent; Calculating a dialogue sequence loss based on a first sequence representation vector of the first text and a second sequence representation vector of the first text, wherein the second sequence representation vector is a vector used to represent the first text determined by the preset model based on the second text, and the first sequence representation vector is a preset vector of the first text; The first loss value is determined according to the entity loss, the mask loss, the intention loss and the dialog sequence loss.

5. The method according to claim 4, characterized in that The calculating the entity loss according to the word-gram representation vectors of the N-1 words and the entity label vectors corresponding to the N-1 words includes: Each of the N-1 word-grams is one-hot encoded, passed through a fully connected layer, and an embedding vector is set for each word-gram, and then input into the preset model to obtain the word-gram representation vector corresponding to the N-1 word-grams, wherein the embedding vector is used to represent the position order of the word-gram in the first text, and the fully connected layer is used to unify the dimensions of the N-1 word-grams after the one-hot encoding; Obtain the entity label vector corresponding to each word in the N-1 words; In the conditional random field (CRF) layer, the entity loss is obtained according to the word unit representation vector and the entity label vector.

6. The method according to claim 4, characterized in that The calculating the mask loss according to the first mask representation vector of the mask token and the second mask representation vector of the target word includes: Inputting the mask mark into the preset model and passing it through the embedding layer to obtain the first mask representation vector; One-hot encoding the target word and passing it through a fully connected layer and an embedding layer to obtain the second mask representation vector, wherein both the fully connected layer and the embedding layer are used for dimensionality unification; The similarity between the first mask representation vector and the second mask representation vector is calculated using a cosine angle to obtain the mask loss.

7. The method according to claim 4, characterized in that The calculating the intent loss according to the first intent representation vector of the classification mark and the second intent representation vector of the preset intent includes: One-hot encode the classification mark, pass it through a fully connected layer, and input it into the preset model to obtain the first intent representation vector; Inputting the preset intent into the embedding layer to obtain the second intent representation vector, and both the fully connected layer and the embedding layer are used to unify the dimensions; The similarity between the first intention representation vector and the second intention representation vector is calculated by using the cosine angle to obtain the intention loss.

8. A multi-round dialogue model training device, characterized in that: The device comprises: A first acquisition module is configured to acquire a continuous multi-round conversation text and a first word segmentation sequence corresponding to the first text, wherein the first text is the last round of conversation text in the multi-round conversation text, the first word segmentation sequence includes N-1 word units, a mask mark, and a classification mark, and the first word segmentation sequence is obtained by preprocessing a second word segmentation sequence corresponding to the first text, the second word segmentation sequence includes N word units, the mask mark is a first mark corresponding to any target word unit among the N word units, the N-1 word units are word units other than the target word unit among the N word units, and the classification mark is a second mark corresponding to a preset intent of the first text, where N is an integer greater than 1; a calculation module, configured to calculate an entity loss determined by a preset model based on the N-1 word-grams, a mask loss determined based on the mask mark, an intent loss determined based on the classification mark, and a dialogue sequence loss determined based on the first text and a second text, to obtain a first loss value, where the second text is a dialogue text in the multiple rounds of dialogue text excluding the first text; A training module is used to iteratively train the preset model based on the first loss value until the first loss value is less than a preset threshold, and determine the preset model after iterative training as a multi-round dialogue model.

9. An electronic device, characterized in that: include: A processor, a memory, and a program stored on the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the multi-round dialogue model training method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the multi-round dialogue model training method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-round question and answer recognition method and device, computer equipment and storage medium

    CN110825857A

  • Multi-round conversation processing method and processing device, vehicle and storage medium

    CN111209383A

  • Model training method, voice dialogue detection method and related equipment

    CN112464661A

  • Method for establishing pre-training language model and semantic analysis method and device

    CN114547329A

  • Intention recognition method and device, computer equipment and storage medium

    CN117093682A