Dialogue model training method and device, equipment and readable storage medium

By inserting interfering conversation samples of different topic types into the training dataset of the intelligent dialogue model and analyzing the encoding characteristics using the self-attention mechanism layer, the problem that the model is difficult to capture the above information in multiple rounds of dialogue is solved, which improves robustness and anti-interference ability, and reduces the amount of training calculations.

CN119848215APending Publication Date: 2025-04-18CHONGQING CHANGAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510076435.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

When handling multiple rounds of conversations, existing intelligent dialogue models are difficult to capture the above information, resulting in insufficient robustness and anti-interference ability, and large calculations and low efficiency during training.

Method used

By obtaining the training data set containing the first conversation sample and the interfering conversation sample, the self-attention mechanism layer is used to analyze the association relationship between the encoded features, and the loss function value determined by the prediction result of the interference conversation sample is ignored when calculating the loss function value, in order to reduce the training calculation amount.

Benefits of technology

The dialogue model's recognition ability of interfering dialogue is improved, the model's robustness and anti-interference ability are enhanced, and the training calculation amount is reduced, which improves training efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848215A_ABST
    Figure CN119848215A_ABST
Patent Text Reader

Abstract

The invention provides a dialogue model training method, apparatus and device, and a readable storage medium. The method comprises the steps of obtaining a first training data set of a dialogue model; obtaining a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model; and training the initial dialogue model based on the first loss function value to obtain a trained target dialogue model. Thus, the initial dialogue model is trained through the first dialogue sample and the interference dialogue sample, the recognition capability of the dialogue model on the interference dialogue can be improved, and therefore the robustness and the anti-interference capability of the model are improved; furthermore, the loss function value determined by the initial dialogue model for the prediction result of the interference dialogue sample is not considered in the process of calculating the loss function value of the dialogue model, so that the calculation amount of dialogue model training can be reduced, and the training efficiency of the 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 intelligent dialogue technology, and specifically to a dialogue model training method, device, equipment and readable storage medium. Background Art

[0002] Intelligent dialogue technology has been applied in the automotive field, allowing drivers to interact with vehicles through voice, improving the convenience and safety of driving. Intelligent dialogue technology relies on dialogue models, which are usually large models. The training accuracy of large models affects the maturity of intelligent dialogue technology. Large dialogue models with high training accuracy or robustness will bring users a good dialogue interaction experience.

[0003] At present, the conversation model is usually trained using conversation sample data. The conversation model is used to predict the conversation sample data to obtain the prediction result. The conversation model is trained based on the difference between the prediction result and the label corresponding to the conversation sample data, thereby improving the conversation ability of the model. However, this training method only focuses on the conversations on the same topic. When using such a trained model for actual conversation prediction, when other topics are added to a topic and then the previous topic is asked again, the conversation model cannot capture the contextual information related to the current question, and thus cannot give the most correct answer, which reduces the robustness and anti-interference ability of the conversation model. In the related art, there is a method of training the conversation model using interference conversation sample data, but the added interference conversation samples will increase the training data, and the amount of calculation in the conversation model training process will also increase, reducing the training efficiency of the conversation model. Summary of the invention

[0004] The present application provides a method, apparatus, device and readable storage medium for training a dialogue model, which can improve the robustness and anti-interference ability of the dialogue model while ensuring the efficiency of dialogue model training.

[0005] The technical solution of this application is implemented as follows:

[0006] An embodiment of the present application provides a method for training a dialogue model, comprising: obtaining a first training data set for the dialogue model; the first training data set includes a first dialogue sample and an interference dialogue sample, and the topic type of the interference dialogue sample is different from the topic type of the first dialogue sample; based on the first dialogue sample, the interference dialogue sample and the initial dialogue model, a first loss function value is obtained; the first loss function value does not include a loss function value determined by the initial dialogue model for a prediction result of the interference dialogue sample; and the initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model.

[0007] According to the above technical means, by using the first dialogue sample and the interference dialogue sample to train the initial dialogue model, the dialogue model's ability to recognize interference dialogues can be improved, thereby improving the model's robustness and anti-interference ability; further, in the process of calculating the loss function value of the dialogue model, the loss function value determined by the prediction result of the interference dialogue sample is not considered, which can reduce the computational amount of dialogue model training, thereby improving the training efficiency of the dialogue model.

[0008] Furthermore, the first dialogue sample includes input dialogue data and corresponding real output dialogue data, and the interference dialogue sample includes interference input dialogue data and corresponding interference output dialogue data; based on the first dialogue sample, the interference dialogue sample and the initial dialogue model, a first loss function value is obtained, including: inputting the input dialogue data, the interference input dialogue data and the interference output dialogue data into the initial dialogue model to obtain predicted output dialogue data corresponding to the input dialogue data; based on a preset loss function, the predicted output dialogue data and the corresponding real output dialogue data, the first loss function value is determined.

[0009] According to the above technical means, the predicted output dialogue data and the corresponding real output dialogue data obtained by the initial dialogue model prediction, and the first loss function value calculated by the preset loss function, without considering the loss function value determined based on the output data predicted by the initial dialogue data for the interference input dialogue data, can reduce the amount of training calculations of the dialogue model, thereby improving the training efficiency of the dialogue model.

[0010] Furthermore, the initial dialogue model includes an encoder, a self-attention mechanism layer and a decoder; the input dialogue data, the interference input dialogue data and the interference output dialogue data are input into the initial dialogue model to obtain the predicted output dialogue data corresponding to the input dialogue data, including: the input dialogue data, the interference input dialogue data and the interference output dialogue data are input into the encoder to obtain a first feature coding matrix; the correlation between each coding feature in the first feature coding matrix is ​​analyzed and processed by the self-attention mechanism layer to obtain a second feature coding matrix; the second feature coding matrix is ​​input into the decoder to obtain the predicted output dialogue data corresponding to the input dialogue data.

[0011] According to the above technical means, by analyzing and processing the correlation between the encoding features in the first feature encoding matrix after encoding by the encoder through the self-attention mechanism layer, the model can grasp the key content of multiple rounds of dialogues and better shield the impact of interfering dialogues, thereby improving the anti-interference ability of the dialogue model.

[0012] Furthermore, the input conversation data includes multiple data, each of which corresponds to a real output conversation data and a predicted output conversation data; based on a preset loss function, the predicted output conversation data and the corresponding real output conversation data, a first loss function value is determined, including: according to the preset loss function, each predicted output conversation data and the corresponding real output conversation data, a reference loss function value corresponding to each predicted output data is determined; based on each reference loss function value, a first loss function value is determined.

[0013] According to the above technical means, by presetting the loss function, each predicted output dialogue data and the corresponding actual output dialogue data, the reference loss function value corresponding to each predicted output data can be determined, and the first loss function value can be further determined based on each reference loss function value, so that the first loss function value finally obtained can include the prediction error of each input dialogue data. Therefore, in the process of training the dialogue model using the first loss function value, the connection between multiple rounds of dialogue can be considered, rather than just focusing on one round of dialogue, thereby improving the prediction accuracy of the dialogue model.

[0014] Further, obtaining a first training data set for the dialogue model includes: obtaining multiple rounds of first dialogue samples; inserting interference dialogue samples between two adjacent rounds of dialogue in the multiple rounds of first dialogue samples to obtain the first training data set.

[0015] According to the above technical means, by inserting interference dialogue samples between two adjacent rounds of dialogue in multiple rounds of first dialogue samples, the data in the obtained first training data set can be enriched, which facilitates the subsequent use of the first training data set to train the large dialogue model and improve the training accuracy of the model.

[0016] Furthermore, the method also includes: creating a first attribute identifier corresponding to the first conversation sample and a second attribute identifier corresponding to the interference conversation sample; the first attribute identifier and the second attribute identifier are different; and creating a first training data set based on the first conversation sample, the first attribute identifier, the interference conversation sample and the second attribute identifier.

[0017] According to the above technical means, a first attribute identifier of the first dialogue sample and a second attribute identifier of the interference dialogue sample are created. In the subsequent process of training the dialogue model using the first training data set, it is possible to quickly determine which dialogue samples are the first dialogue samples and which dialogue samples are the second dialogue samples directly based on the first attribute identifier and the second attribute identifier, so as to accurately determine the prediction result of the dialogue model for the first dialogue sample and complete the calculation of the first loss function value.

[0018] Furthermore, the method also includes: if multiple rounds of first conversation samples belong to multiple topic types, dividing the multiple rounds of first conversation samples into multiple sample groups based on the topic type of each first conversation sample; each sample group includes at least one round of first conversation samples of the same topic type; inserting interference conversation samples between two adjacent rounds of conversation in at least one sample group to obtain multiple second training data sets; and using each second training data set to train the initial conversation model respectively.

[0019] According to the above technical means, multiple rounds of first conversation samples are divided into multiple sample groups according to the topic type of the first conversation sample data, which can prevent mutual interference between conversation samples of different topic types in the subsequent training of the initial conversation model using multiple rounds of first conversation samples; interfering conversation samples are inserted between two adjacent rounds of conversation in at least one sample group, so as to obtain multiple second training data sets that include or do not include interfering conversation samples. By using multiple second training data sets to train the initial conversation large model respectively, the training accuracy of the conversation model can be improved.

[0020] Further, the ratio of the number of first dialogue samples to the number of interference dialogue samples is less than a preset threshold.

[0021] According to the above technical means, by limiting the ratio of the number of interfering dialogue samples to the number of first dialogue samples, the number of inserted interfering dialogue samples can be prevented from being too large, and the amount of training data will not be too large. In addition, while ensuring that the number of first dialogue samples is greater than the number of interfering dialogue samples, it will not affect the confusion of the dialogue model in the process of exploring contextual relationships, thereby ensuring the stability of dialogue model training.

[0022] Further, the initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model, including: if the first loss function value does not meet the threshold condition, adjusting the model parameters of the initial dialogue model to obtain the first dialogue model; inputting the first dialogue sample and the interference dialogue sample into the first dialogue model to obtain the second loss function value; if the second loss function value meets the threshold condition, determining the first dialogue model as the target dialogue model.

[0023] According to the above technical means, when the first loss function value does not meet the threshold condition, by adjusting the model parameters of the initial dialogue model and continuing to train the first dialogue model after the model parameters are adjusted, the accuracy of the dialogue model can be continuously improved, thereby ensuring the prediction accuracy of the target dialogue model finally trained.

[0024] The present application provides a training device for a dialogue model, including:

[0025] A first acquisition module is used to acquire a first training data set of the dialogue model; the first training data set includes a first dialogue sample and an interference dialogue sample, and the topic type of the interference dialogue sample is different from the topic type of the first dialogue sample;

[0026] A second acquisition module is used to obtain a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model; the first loss function value does not include a loss function value determined by the initial dialogue model for a prediction result of the interference dialogue sample;

[0027] The first training module is used to train the initial dialogue model based on the first loss function value to obtain a trained target dialogue model.

[0028] The present application embodiment provides a training device for a dialogue model, including:

[0029] A memory for storing computer programs that can be run on the processor;

[0030] The processor is used to execute the training method of the dialogue model provided in the embodiment of the present application when running the computer program.

[0031] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and the computer-executable instructions are configured to execute the training method of the above-mentioned dialogue model. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flowchart of a method for training a dialogue model provided in an embodiment of the present application;

[0033] Figure 2 A schematic diagram of a multi-round first conversation sample provided in an embodiment of the present application;

[0034] Figure 3 A diagram illustrating an index value of a conversation sample provided in an embodiment of the present application;

[0035] Figure 4 A flowchart illustrating a method for correcting defects in multi-round dialogue training based on a large model provided in an embodiment of the present application;

[0036] Figure 5 A schematic diagram of the content of a multi-round conversation provided in an embodiment of the present application;

[0037] Figure 6 A schematic diagram of another multi-round dialogue content provided in an embodiment of the present application;

[0038] Figure 7 A schematic diagram of the structure of a conversation model training device provided in an embodiment of the present application;

[0039] Figure 8 A schematic diagram of the composition structure of a dialogue model training device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0041] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0042] In the following description, reference is made to “some embodiments\other embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments\other embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0043] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0044] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0045] The current large models are generally divided into basic models, instruction models and chat models. The basic model uses continuous text input to the model, allowing the model to predict the next text from the current text. The corpus input to the model generally includes cleaned text content such as books, news, papers, codes, etc. For the instruction model, its training method is mainly to give the model a part of the instruction input, and let the model answer according to the instruction input. After the instruction is fine-tuned, the model has the ability to give output based on user input. The types of fine-tuning generally include mathematical calculations, basic common sense, logical reasoning, thinking chain ability, etc.; and the chat model replaces the corpus of instruction fine-tuning with multi-round dialogues with contextual knowledge, similar to the way people communicate with each other.

[0046] For the training of chat models, data is often structured into topics for training, that is, when training user questions and model answers, the current topic will not be "interrupted" to talk about other topics. In actual production and life, people's communication is not like this. Their thinking is more jumpy, and they may think of other issues while chatting. Therefore, other topics are always inserted in the gaps between topics, and the inserted topics may have one or two rounds before returning to the main topic. Therefore, in order to improve the training ability of the chat model and strengthen the model's ability to resist interference from other topics, it is an urgent problem to be solved.

[0047] In the related art, in a fine-tuning method of a pre-trained model, a pre-trained model is determined, and the pre-trained model includes N layers of converters (Transformer layers) and N layers of fully connected layers, each layer of Transformer layers is connected to a layer of fully connected layers, and the parameters corresponding to each layer of fully connected layers are determined based on the parameters of the Transformer layer; the prompt words corresponding to the target downstream task are determined based on the pre-training database; the prompt words and the input text corresponding to the target downstream task are input into the pre-training model to obtain the output result, the loss value is calculated based on the output result, and the parameters corresponding to the N layers of fully connected layers are updated based on the loss value. This method can effectively inherit the multi-task knowledge in the pre-training stage, improve the convergence speed and effect of small sample tasks, improve the modeling ability of the model, and can model more difficult generation tasks, improve the stability of model training, solve the problem that large models cannot converge, and the deployment development difficulty and deployment cost are relatively low. However, this method aims to solve the effective effect and training efficiency of single-round tasks, and does not provide effective technical support for improving the effect of multiple rounds of training.

[0048] In the related art, a training method for a multi-round dialogue model obtains a second training text from a training text containing multiple rounds of dialogue, the second training text includes a first training text and a first target text; determines a target vector corresponding to the second training text, and adjusts the target vector to a target update vector through a weight increase process, the weight increase process is used to strengthen the connection between the first target text and the first training text; inputs the target update vector to the multi-round dialogue model to be trained to obtain a second loss for the second training text; based on the second loss, adjusts the parameters of the multi-round dialogue model to be trained to obtain a trained multi-round dialogue model. This method can improve the accuracy of the multi-round dialogue model in text prediction, and by strengthening the loss weights of real questions and answers, the training indicators will be improved in the training set. However, in actual reasoning, the multi-round dialogue model does not know which predicted texts to focus on, and the prediction accuracy of the model is limited.

[0049] Based on the problems existing in the related art, the embodiment of the present application provides a method for training a dialogue model, which can improve the robustness and anti-interference ability of the dialogue model while ensuring the training efficiency of the dialogue model. Figure 1 FIG. 1 is a flow chart of a method for training a dialogue model provided in an embodiment of the present application, the method comprising the following steps:

[0050] S101. Obtain a first training data set for a dialogue model.

[0051] In some embodiments, the first training data set includes a first conversation sample and an interference conversation sample, and the topic type of the interference conversation sample is different from the topic type of the first conversation sample. For example, the topic type of the first conversation sample may be related to travel, while the topic type of the interference conversation sample may be related to food recipes; the topic type of the first conversation sample may be related to music hobbies, while the topic type of the interference conversation may be related to fitness equipment.

[0052] In some embodiments, the first conversation sample and the interference conversation sample may include multiple samples. The first conversation sample may include multiple rounds of conversation data. The first training data set can be obtained by inserting interference conversation samples in the topic gaps of the multiple rounds of conversation data.

[0053] In some embodiments, if the first conversation samples belong to multiple topic types, the first training data set can be divided into multiple subsets, the first conversation samples in different subsets have different topic types, and at least one subset may include interference conversation samples; if the first conversation samples are all of the same topic type, the first training data set only includes first conversation samples of the same topic type and interference conversation samples of a topic type different from that of the first conversation samples.

[0054] S102: Obtain a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model.

[0055] In some embodiments, the initial dialogue model may be a large model for intelligent dialogue. The initial dialogue model may be a pre-trained dialogue large model or a non-pre-trained dialogue large model. The dialogue large model may be a chat model, for example, a Generative Pre-trained (GPT) model, a Chat Global Language Model (ChatGLM) model, etc.

[0056] In some embodiments, the first loss function value can be determined based on the prediction result of the initial dialogue model for the first dialogue sample. The first dialogue sample includes question data in the dialogue and corresponding answer data labels. By inputting the question data into the initial dialogue model, the predicted answer data can be obtained. According to the predicted answer data and the answer data label, the corresponding first loss function value can be determined.

[0057] In some embodiments, the first loss function value does not include the loss function value determined by the initial dialogue model for the prediction result of the interference dialogue sample, that is, in the process of calculating the first loss function value, the difference between the prediction result and the actual result of the interference dialogue sample is not considered. In practice, the interference dialogue sample may also include interference question data and corresponding interference answer data labels in the dialogue. The initial dialogue model can predict the answer corresponding to the input interference question data to obtain the predicted interference answer data, but the loss function value is not calculated based on the predicted interference answer data and the interference answer data labels.

[0058] S103: Train the initial dialogue model based on the first loss function value to obtain a trained target dialogue model.

[0059] In some embodiments, after obtaining the first loss function value, the first loss function value can be compared with a preset loss function threshold. When the first loss function value is less than the preset loss function threshold, the initial dialogue model needs to be back-propagated and trained until the calculated first loss function value is less than the preset loss function threshold, so that a trained target dialogue model can be obtained.

[0060] In an embodiment of the present application, a first training data set of a dialogue model is obtained; the first training data set includes a first dialogue sample and an interference dialogue sample, and the topic type of the interference dialogue sample is different from the topic type of the first dialogue sample; based on the first dialogue sample, the interference dialogue sample and the initial dialogue model, a first loss function value is obtained; the first loss function value does not include the loss function value determined by the initial dialogue model for the prediction result of the interference dialogue sample; the initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model. In this way, by using the first dialogue sample and the interference dialogue sample to train the initial dialogue model, the ability of the dialogue model to recognize interference dialogues can be improved, thereby improving the robustness and anti-interference ability of the model; further, in the process of calculating the loss function value of the dialogue model, the loss function value determined by the initial dialogue model for the prediction result of the interference dialogue sample is not considered, which can reduce the amount of calculation of the dialogue model training, thereby improving the training efficiency of the dialogue model.

[0061] In some embodiments of the present application, obtaining the first training data set of the dialogue model, that is, step S101, can be implemented by the following steps S1011 to S1012, and each step is described below.

[0062] S1011. Obtain multiple rounds of first conversation samples.

[0063] In some embodiments, the first dialogue sample includes multiple rounds, that is, the first dialogue sample includes multiple question-answer dialogues. The first dialogue sample can be obtained from historical dialogue data, such as from a database or a local storage area, or can be obtained in real time from the user's current dialogue data.

[0064] In some embodiments, the multi-round first conversation samples may be continuous multi-round conversations, or may be multi-round conversations sampled from continuous conversations. For example, if a conversation includes 20 rounds, these 20 rounds of conversations may be directly used as the first conversation samples, or these 15 rounds of conversations may be sampled, and the 1st to 5th rounds, the 9th to 14th rounds, and the 18th to 20th rounds of conversations may be used as the first conversation samples.

[0065] S1012: inserting an interference dialogue sample between two adjacent dialogue rounds in the multiple first dialogue samples to obtain a first training data set.

[0066] In some embodiments, when inserting an interfering conversation between two adjacent conversation rounds in a multi-round conversation sample, the gap between two adjacent conversation rounds where the interfering conversation needs to be inserted can be determined first, and then the interfering conversation is inserted in the gap, so that the conversation sample after the inserted interfering conversation sample is determined as the first training data set. The inserted interfering conversation may include one or more rounds, and the number of rounds of the inserted interfering conversation is less than the number of rounds of the first conversation sample.

[0067] In some embodiments, two adjacent first dialogue round samples where interference dialogues need to be inserted can be arbitrarily selected. For example, for a first dialogue sample including 10 rounds, interference dialogue samples can be inserted between the first dialogue sample of the 2nd round and the first dialogue sample of the 3rd round, and between the first dialogue sample of the 7th round and the first dialogue sample of the 8th round. In other embodiments, interference dialogues can also be inserted between multiple groups of adjacent two rounds of dialogue at equal intervals. For example, for a first dialogue sample including 12 rounds, interference dialogue samples can be inserted between the first dialogue sample of the 5th round to the first dialogue sample of the 6th round, between the first dialogue sample of the 10th round to the first dialogue sample of the 11th round, and between the first dialogue sample of the 15th round to the 16th round.

[0068] For example, Figure 2As shown, if the first dialogue sample includes three rounds, the first dialogue sample in the first round includes {topic 1: question 1} and {topic 1: answer 1}, the first dialogue sample in the second round includes: {topic 1: question 2} and {topic 1: answer 2}, and the first dialogue sample in the second round includes: {topic 1: question 3} and {topic 1: answer 3}, then an interference dialogue sample can be inserted in the topic gap between the first dialogue sample in the first round and the first dialogue sample in the second round, for example, inserting an interference dialogue sample between {topic 1: answer 1} and {topic 1: question 2}; the interference dialogue sample can also be inserted in the topic gap between the first dialogue sample in the second round and the first dialogue sample in the third round, for example, inserting an interference dialogue sample between {topic 1: answer 2} and {topic 1: question 3}.

[0069] In some embodiments, the ratio of the number of first dialogue samples to the number of interference dialogue samples is less than a preset threshold value, which may be any pre-set integer greater than 1, such as 5, 8, 10, etc. The number of first dialogue samples may be greater than the number of interference dialogue samples. For example, if the number of first dialogue samples is 100 and the preset threshold value is 10, the number of inserted interference dialogue samples may be 10; if the number of first dialogue samples is 60 and the preset threshold value is 12, the number of inserted interference dialogue samples may be 5. By limiting the ratio of the number of interference dialogue samples to the number of first dialogue samples, the number of inserted interference dialogue samples may not be too large, and the amount of training data may not be too large. In addition, when the number of first dialogue samples is greater than the number of interference dialogue samples, the dialogue model will not be confused in the process of exploring contextual relationships, thereby ensuring the stability of dialogue model training.

[0070] According to the above technical means, by inserting interference dialogue samples between two adjacent rounds of dialogue in multiple rounds of first dialogue samples, the data in the obtained first training data set can be enriched, which facilitates the subsequent use of the first training data set to train the large dialogue model and improve the training accuracy of the model.

[0071] In some embodiments of the present application, after "inserting the interference dialogue sample between two adjacent dialogue rounds in the multiple first dialogue samples" in step S1012, the following steps S201 to S202 may also be executed, and each step is described below.

[0072] S201: Create a first attribute identifier corresponding to a first dialogue sample and a second attribute identifier corresponding to an interference dialogue sample.

[0073] It should be noted that the first attribute identifier and the second attribute identifier are different. The first attribute identifier can be used to identify the identity information of the first conversation sample, and the second attribute identifier is used to identify the identity information of the interference conversation. The first attribute identifier and the second attribute identifier can be used to distinguish which conversation samples are normal conversation samples (first conversation samples) and which conversation samples are interference conversation samples.

[0074] In some embodiments, the first attribute identifier and the second attribute identifier may both be index values ​​of the conversation sample, and the indexes of different first conversation samples may be the same, for example, the index of the question data in the first conversation sample is 0, and the index of the answer data in the first conversation sample is 1; the indexes of different interference conversation samples may be the same, for example, the indexes of the interference question data and the interference answer data in the interference conversation sample are both -100.

[0075] For example, Figure 3 As shown, the first dialogue sample includes three rounds, and the interference dialogue sample includes one round. The index values ​​of {topic 1: question 1}, {topic 1: question 2}, and {topic 1: question 3} in the first dialogue sample are all 0, the index values ​​of {topic 1: answer 1}, {topic 1: answer 2}, and {topic 1: answer 3} are all 1, and the index values ​​of {topic 2: question 1} and {topic 2: question 1} in the interference dialogue sample are all -100.

[0076] S202: Create a first training data set based on the first dialogue sample, the first attribute identifier, the interference dialogue sample, and the second attribute identifier.

[0077] In some embodiments, after obtaining the first attribute identifier of the first conversation sample and the second attribute identifier of the interference conversation sample, a first training data set can be established based on each first conversation sample and the corresponding first attribute identifier, and the interference conversation sample and the corresponding second attribute identifier.

[0078] According to the above technical means, a first attribute identifier of the first dialogue sample and a second attribute identifier of the interference dialogue sample are created. In the subsequent process of training the dialogue model using the first training data set, it is possible to quickly determine which dialogue samples are the first dialogue samples and which dialogue samples are the second dialogue samples directly based on the first attribute identifier and the second attribute identifier, so as to accurately determine the prediction result of the dialogue model for the first dialogue sample and complete the calculation of the first loss function value.

[0079] In some embodiments of the present application, after obtaining multiple rounds of first conversation samples, that is, step S1011, the following steps S301 to S303 may also be performed, and each step is described below.

[0080] S301: If the multiple rounds of first dialogue samples belong to multiple topic types, divide the multiple rounds of first dialogue samples into multiple sample groups based on the topic type of each first dialogue sample.

[0081] In some embodiments, multiple rounds of conversation samples may include samples of multiple topic types, for example, may include multiple topic types such as travel, fitness, food, etc. In this case, the multiple rounds of first conversation samples can be divided into multiple sample groups according to the topic type of each first conversation sample, and each sample group includes at least one round of first conversation samples of the same topic type.

[0082] For example, if the multi-round dialogue includes 100 rounds, the first dialogue samples from rounds 1 to 32 and rounds 40 to 100 are all related to travel, and the first dialogue samples from rounds 33 to 39 are all related to fitness, then the first dialogue samples from rounds 1 to 32 and rounds 40 to 100 can be divided into one sample group, and the first dialogue samples from rounds 33 to 39 can be divided into one sample group. The number of rounds of the first dialogue sample, and the topic types and quantities of the multi-round first dialogue samples are merely exemplary, and this application does not limit this.

[0083] S302: inserting interference dialogue samples between two adjacent dialogue rounds in at least one sample group to obtain a plurality of second training data sets.

[0084] In some embodiments, after dividing multiple rounds of first conversation samples into multiple sample groups, interference conversations can be inserted into the gaps between multiple rounds of conversations in one or more sample groups, thereby obtaining a second training data set including interference conversation samples and a second training data set not including interference conversation samples.

[0085] In some embodiments, the number of sample groups into which the interfering dialogue samples are inserted can be set arbitrarily. For example, if the sample group includes three groups, the interfering dialogue can be inserted into any one of the three sample groups, or any two of the three sample groups, or all three sample groups. In addition, the insertion position of the interfering dialogue sample in the sample group can also be set arbitrarily.

[0086] S303: Use each second training data set to train the initial dialogue model respectively.

[0087] In some embodiments, if multiple second training data sets all include interference conversation samples, the training order of each second training data set can be set arbitrarily. For example, if the second training data sets include A and B, the initial conversation model can be trained using the second training data set A first, and then the initial conversation large model can be trained using the second training data set B; or, the initial conversation large model can be trained using the second training data set B first, and then the initial conversation model can be trained using the second training data set A.

[0088] In some embodiments, if the multiple second training data sets include a second training data set with interference conversation samples and a second training data set without interference conversations, and the number of the second training data sets with interference conversation samples or the second training data sets with interference conversations is greater than or equal to two, the second training data set with interference conversation samples may be used for training first, and then the second training data set without interference conversation samples may be used for training; or the second training data set without interference conversation samples may be used for training first, and then the second training data set with interference conversation samples may be used for training; or the second training data set with interference conversation samples and the second training data set without interference conversation samples may be trained alternately, for example, the initial conversation model may be trained with the second training data set with interference conversation samples in the current time, and the initial conversation model may be trained with the second training data set without interference conversation samples in the next time, and the initial conversation model may be trained with the second training data set with interference conversation samples in the next time.

[0089] According to the above technical means, multiple rounds of first conversation samples are divided into multiple sample groups according to the topic type of the first conversation sample data, which can prevent mutual interference between conversation samples of different topic types in the subsequent training of the initial conversation model using multiple rounds of first conversation samples; interfering conversation samples are inserted between two adjacent rounds of conversation in at least one sample group, so as to obtain multiple second training data sets that include or do not include interfering conversation samples. By using multiple second training data sets to train the initial conversation large model respectively, the training accuracy of the conversation model can be improved.

[0090] In some embodiments of the present application, the first conversation sample includes input conversation data and corresponding real output conversation data, and the interference conversation sample includes interference input conversation data and corresponding interference output conversation data; based on this, based on the first conversation sample, the interference conversation sample and the initial conversation model, a first loss function value is obtained, that is, the above-mentioned step S102 can be implemented by the following steps S1021 to S1022, and each step is described separately below.

[0091] S1021. Input the input dialogue data, the interference input dialogue data, and the interference output dialogue data into the initial dialogue model to obtain the predicted output dialogue data corresponding to the input dialogue data.

[0092] In some embodiments, the input dialogue data may be question data of questions asked in multiple rounds of dialogue, and the question data may be prompt words obtained by splitting the questions in the dialogue. For example, if the question asked in the dialogue is "How is the weather today", the corresponding input question data may include the three prompt words "today", "weather" and "how". The real output dialogue data corresponding to the input dialogue data may be considered as label data. The real output dialogue data may be answer data of answers given in multiple rounds of dialogue, and the answer data may be prompt words obtained by splitting the answers in the dialogue. For example, if the answer in the dialogue is "It's raining today", the corresponding real output dialogue data may include the two prompt words "today" and "raining".

[0093] In some embodiments, the first conversation sample includes multiple input conversation data. The input conversation data in each first conversation sample, as well as the interference input conversation data and the interference output conversation data in the interference conversation sample can be input into the initial conversation model in sequence according to the order of multiple rounds of conversations. The conversation model can predict the predicted output conversation data corresponding to the current input conversation data based on the current input conversation data and context data (including the interference conversation sample, the input conversation data, and the real output conversation data). The conversation model can predict the output data corresponding to each input conversation data in turn, so as to obtain the predicted output conversation data corresponding to each of the multiple input conversation data.

[0094] S1022. Determine a first loss function value based on a preset loss function, the predicted output dialogue data, and the corresponding actual output dialogue data.

[0095] In some embodiments, the preset loss function may be a pre-set loss function. For example, the preset loss function may be a cross entropy loss function. By substituting the category probability value of the predicted output conversation data and the category probability value of the actual output conversation data into the preset loss function, the first loss function value may be obtained.

[0096] According to the above technical means, the predicted output dialogue data and the corresponding real output dialogue data obtained by the initial dialogue model prediction, and the first loss function value calculated by the preset loss function, without considering the loss function value determined based on the output data predicted by the initial dialogue data for the interference input dialogue data, can reduce the amount of training calculations of the dialogue model, thereby improving the training efficiency of the dialogue model.

[0097] In some embodiments of the present application, the initial dialogue model includes an encoder, a self-attention mechanism layer and a decoder; based on this, the input dialogue data, the interference input dialogue data and the interference output dialogue data are input into the initial dialogue model to obtain the predicted output dialogue data corresponding to the input dialogue data, that is, the above-mentioned step S1021 can be implemented by the following steps S401 to S403, and each step is described separately below.

[0098] S401. Input the input dialogue data, the interference input dialogue data and the interference output dialogue data to an encoder to obtain a first feature encoding matrix.

[0099] In some embodiments, the encoder may utilize natural language processing technology to perform feature encoding on the input dialogue data, interference input dialogue data, and interference output dialogue data to obtain encoding features that can be understood and recognized within the model, and each encoding feature may constitute a first feature encoding matrix.

[0100] S402. Analyze and process the correlation between the encoding features in the first feature encoding matrix using the self-attention mechanism layer to obtain a second feature encoding matrix.

[0101] In some embodiments, the self-attention mechanism layer can analyze the internal correlation between the data so that the model can better understand the context information to predict more accurate output dialogue data. The first feature encoding matrix can include encoding features of multiple data (input dialogue data, interference input dialogue data, and interference output dialogue data). The self-attention mechanism layer is used to analyze the correlation between the encoding features in the first feature encoding matrix to determine the weight matrix, and the second feature encoding matrix is ​​determined based on the weight matrix and the first feature encoding matrix.

[0102] S403: Input the second feature encoding matrix into the decoder to obtain predicted output dialogue data corresponding to the input dialogue data.

[0103] In some embodiments, the second feature coding matrix includes coding features, which may be numbers, characters, etc., rather than text content. Therefore, before output, it needs to be decoded by a decoder to obtain predicted output dialogue data, and the predicted dialogue output data may be text content.

[0104] According to the above technical means, by analyzing and processing the correlation between the encoding features in the first feature encoding matrix after encoding by the encoder through the self-attention mechanism layer, the model can grasp the key content of multiple rounds of dialogues and better shield the impact of interfering dialogues, thereby improving the anti-interference ability of the dialogue model.

[0105] In some embodiments of the present application, the input conversation data includes multiple data, each input conversation data corresponds to a real output conversation data and a predicted output conversation data; based on this, based on the preset loss function, the predicted output conversation data and the corresponding real output conversation data, the first loss function value is determined, that is, the above-mentioned step S1022 can be implemented by the following steps S501 to S502, and each step is described separately below.

[0106] S501. Determine a reference loss function value corresponding to each predicted output data according to a preset loss function, each predicted output dialogue data and the corresponding actual output dialogue data.

[0107] In some embodiments, a reference loss function value can be determined based on each predicted output data and the corresponding actual output conversation data. For example, the category probability value of the i-th predicted output conversation data and the category probability value of the corresponding actual output conversation data can be input into a preset loss function to obtain a reference loss function value corresponding to the i-th predicted output conversation data, where i is a positive integer and i is greater than zero and less than the total number of predicted output data.

[0108] S502: Determine a first loss function value based on each reference loss function value.

[0109] In some embodiments, the first loss function value may be determined by combining the various reference loss function values, or by taking the average of the sum of the various reference loss function values, or by taking the weighted average of the various reference loss function values.

[0110] According to the above technical means, by presetting the loss function, each predicted output dialogue data and the corresponding actual output dialogue data, the reference loss function value corresponding to each predicted output data can be determined, and the first loss function value can be further determined based on each reference loss function value, so that the first loss function value finally obtained can include the prediction error of each input dialogue data. Therefore, in the process of training the dialogue model using the first loss function value, the connection between multiple rounds of dialogue can be considered, rather than just focusing on one round of dialogue, thereby improving the prediction accuracy of the dialogue model.

[0111] In some embodiments of the present application, the initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model, that is, the above step S103 can be implemented by the following steps S1031 to S1033, and each step is described below.

[0112] S1031: If the first loss function value does not meet the threshold condition, adjust the model parameters of the initial dialogue model to obtain a first dialogue model.

[0113] In some embodiments, the first loss function value not satisfying the threshold condition may be that the first loss function value is greater than or equal to the loss function threshold. When the first loss function value does not satisfy the threshold condition, it means that the training accuracy of the current initial dialogue model is insufficient and further training is needed. A new dialogue model, i.e., the first dialogue model, can be obtained by adjusting the model parameters of the initial dialogue model. The first dialogue model and the initial dialogue model have the same structure, but the model parameters may be different.

[0114] S1032: Input the first dialogue sample and the interference dialogue sample into the first dialogue model to obtain a second loss function value.

[0115] In some embodiments, after the model parameters of the initial dialogue model are updated to obtain the first dialogue model, the first dialogue model can be trained using the first dialogue sample and the interference dialogue sample, and the predicted output dialogue data of the input dialogue data in the first dialogue sample is predicted by the first dialogue model. The second loss function value can be obtained by calculation based on the preset loss function, the predicted output dialogue data and the corresponding actual output dialogue data, and the second loss function value may be different from the first loss function value.

[0116] S1033. If the second loss function value meets the threshold condition, determine the first dialogue model as the target dialogue model.

[0117] In some embodiments, the second loss function satisfies the threshold condition that the second loss function value is less than or equal to the loss function threshold. The second loss function value satisfies the threshold condition, which means that the training accuracy of the dialogue model meets the requirements. In this case, the first dialogue model can be determined as the trained target dialogue model.

[0118] In some embodiments, if the calculated second loss function value still does not meet the threshold condition, the first dialogue model can continue to be iteratively trained, and the parameters of the dialogue model can be continuously adjusted until the calculated loss function value meets the threshold condition, so that a trained target dialogue model can be obtained.

[0119] According to the above technical means, when the first loss function value does not meet the threshold condition, by adjusting the model parameters of the initial dialogue model and continuing to train the first dialogue model after the model parameters are adjusted, the accuracy of the dialogue model can be continuously improved, thereby ensuring the prediction accuracy of the target dialogue model finally trained.

[0120] In an embodiment of the present application, a first training data set of a dialogue model is obtained; the first training data set includes a first dialogue sample and an interference dialogue sample, and the topic type of the interference dialogue sample is different from the topic type of the first dialogue sample; based on the first dialogue sample, the interference dialogue sample and the initial dialogue model, a first loss function value is obtained; the first loss function value does not include the loss function value determined by the initial dialogue model for the prediction result of the interference dialogue sample; the initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model. In this way, by using the first dialogue sample and the interference dialogue sample to train the initial dialogue model, the ability of the dialogue model to recognize interference dialogues can be improved, thereby improving the robustness and anti-interference ability of the model; further, in the process of calculating the loss function value of the dialogue model, the loss function value determined for the prediction result of the interference dialogue sample is not considered, which can reduce the amount of calculation of the dialogue model training, thereby improving the training efficiency of the dialogue model.

[0121] Next, the implementation process of the application embodiment in the actual application scenario is introduced.

[0122] Figure 4 A flowchart of a method for correcting defects in multi-round dialogue training based on a large model is provided in an embodiment of the present application. The method can be implemented by the following steps S601 to S603, and each step is described separately below.

[0123] S601. Divide multiple rounds of conversations (equivalent to “multiple rounds of first conversation samples” in other embodiments) into different categories according to topic type (equivalent to “dividing multiple rounds of first conversation samples into multiple sample groups based on the topic type of each first conversation sample” in other embodiments).

[0124] In some embodiments, a topic model algorithm, such as Latent Dirichlet Allocation (LDA) algorithm, can be used to classify all multi-round dialogues and single-round instruction fine-tuning. Classification can prevent the same type of topic from having two different context information, which may cause confusion in model learning. Figure 5 As shown in the figure, both topics are mountain climbing. In the main dialogue, the destination of the mountain climbing training is Mountain A, and the destination of the topic inserted in the gap is Mountain B. If Mountain A is given as the destination in the answer to the main dialogue, it will cause model confusion. Therefore, it is necessary to classify the topics to prevent interference from the same type of topics.

[0125] S602. Insert interference conversations (equivalent to the "interference conversation samples" in other embodiments) into the gaps between topics of multiple rounds of conversations in different topic categories to obtain conversation samples (equivalent to the "first training data set" in other embodiments) for training a large conversation model (equivalent to the "initial conversation model" in other embodiments).

[0126] In some embodiments, a topic gap is randomly selected, and 1-2 single-round fine-tuning contents that are not related to the current topic are randomly inserted into the randomly selected topic, such as Figure 6 As shown in the figure, the topic of "Steps to Make Tomato and Egg" is inserted in the gap of the second round of multi-round dialogue, and then the transportation method from City A to Mountain C is asked. Of course, in this example, only one other topic is inserted. In actual operation, two can also be inserted. The number of rounds of the main topic and the discussion ratio of the interfering topic can be controlled within 8:2.

[0127] S603. Use the dialogue samples to train the dialogue model to obtain a trained dialogue model (equivalent to the "target dialogue model" in other embodiments).

[0128] In some embodiments, since the conversation sample includes interfering conversations on other topics, the amount of training data for the large conversation model increases by about 33%. If the original multi-round conversation training scheme is used, the training time will inevitably increase by 33%. In order to save the training time, the present application proposes not to calculate the loss for the inserted interfering conversations and not to reversely iterate and update the model parameters. The index value index of the interfering conversation (including questions and answers) is set to -100, where -100 is the ignore_index of the cross entropy loss function. The loss value l of the large conversation model can be calculated by formula (1): n :

[0129]

[0130] Where n = 1, 2, ..., N, N is the total number of dialogue samples, C is the number of dialogue sample categories, is the category probability of the actual output data, The index value is y n The predicted output value corresponding to the nth dialogue sample, x n,c The predicted output value for the c-th category for the predicted n-th dialogue sample.

[0131] In formula (1), all normal indexes will calculate the probability distribution. For ignore_index (the default value is -100), the loss will not be calculated, and there will be no reverse iteration to update the model parameters.

[0132] The correction method for the defects of multi-round dialogue training based on a large model provided by the present application proposes the idea of ​​randomly inserting interference dialogues into multi-round dialogues. By training the large dialogue model with dialogue samples that have been interfered with, the large dialogue model can not only remember the topics previously discussed, but also grasp the key points of historical information, making the multi-round dialogue of the large dialogue model more focused and more resistant to interference. In addition, through the insertion ignore mechanism, the "interference" dialogue inserted into the multi-round dialogue does not participate in the calculation of the cross entropy loss, thereby improving the robustness and anti-interference ability of the large multi-round dialogue model without significantly increasing the amount of calculation and computing resources.

[0133] The present application embodiment provides a training device for a dialogue model. Figure 7 A schematic diagram of the structure of a training device for a dialogue model provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the training device 700 of the dialogue model includes:

[0134] A first acquisition module 701 is used to acquire a first training data set of a dialogue model; the first training data set includes a first dialogue sample and an interference dialogue sample, and the topic type of the interference dialogue sample is different from the topic type of the first dialogue sample;

[0135] A second acquisition module 702 is used to obtain a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model; the first loss function value does not include a loss function value determined by the initial dialogue model for a prediction result of the interference dialogue sample;

[0136] The first training module 703 is used to train the initial dialogue model based on the first loss function value to obtain a trained target dialogue model.

[0137] In some embodiments, the first dialogue sample includes input dialogue data and corresponding real output dialogue data, and the interference dialogue sample includes interference input dialogue data and corresponding interference output dialogue data; the second acquisition module 702 includes:

[0138] A first acquisition submodule is used to input the input dialogue data, the interference input dialogue data and the interference output dialogue data into the initial dialogue model to obtain predicted output dialogue data corresponding to the input dialogue data;

[0139] The first determination submodule is used to determine the first loss function value based on a preset loss function, the predicted output dialogue data and the corresponding actual output dialogue data.

[0140] In some embodiments, the initial dialogue model includes an encoder, a self-attention mechanism layer, and a decoder; and the first acquisition submodule includes:

[0141] A first acquisition unit, configured to input the input dialogue data, the interference input dialogue data and the interference output dialogue data into the encoder to obtain a first feature encoding matrix;

[0142] A first analysis and processing unit, using the self-attention mechanism layer to analyze and process the correlation between the encoding features in the first feature encoding matrix to obtain a second feature encoding matrix;

[0143] The second acquisition unit is used to input the second feature encoding matrix into the decoder to obtain the predicted output dialogue data corresponding to the input dialogue data.

[0144] In some embodiments, the input dialogue data includes multiple data, each of which corresponds to a real output dialogue data and a predicted output dialogue data; the first determining submodule includes:

[0145] A first determining unit, configured to determine a reference loss function value corresponding to each predicted output data according to the preset loss function, each predicted output dialogue data and the corresponding real output dialogue data;

[0146] The second determining unit is used to determine the first loss function value based on each reference loss function value.

[0147] In some embodiments, the first acquisition module 701 includes:

[0148] A second acquisition submodule is used to acquire multiple rounds of first conversation samples;

[0149] The first insertion submodule is used to insert the interference dialogue sample between two adjacent dialogue rounds in the multiple first dialogue samples to obtain the first training data set.

[0150] In some embodiments, the first acquisition module 701 further includes:

[0151] A first creation submodule, configured to create a first attribute identifier corresponding to the first conversation sample and a second attribute identifier corresponding to the interference conversation sample; the first attribute identifier and the second attribute identifier are different;

[0152] The second creation submodule is used to create the first training data set based on the first dialogue sample, the first attribute identifier, the interference dialogue sample and the second attribute identifier.

[0153] In some embodiments, the dialogue model training device 700 further includes:

[0154] A first division module is used for dividing the multiple rounds of first dialogue samples into multiple sample groups based on the topic type of each first dialogue sample if the multiple rounds of first dialogue samples belong to multiple topic types; each sample group includes at least one round of first dialogue samples of the same topic type;

[0155] A third acquisition module is used to insert the interference dialogue sample between two adjacent dialogue rounds in at least one sample group to obtain multiple second training data sets;

[0156] The second training module is used to train the initial dialogue model using each second training data set.

[0157] In some embodiments, a ratio of the number of the first conversation samples to the number of the interference conversation samples is less than a preset threshold.

[0158] In some embodiments, the first training module 703 includes:

[0159] A first adjustment submodule, configured to adjust a model parameter of the initial dialogue model to obtain a first dialogue model if the first loss function value does not meet a threshold condition;

[0160] A first input submodule, configured to input the first dialogue sample and the interference dialogue sample into the first dialogue model to obtain a second loss function value;

[0161] The second determination submodule is used to determine the first dialogue model as the target dialogue model if the second loss function value meets a threshold condition.

[0162] It should be noted that the description of the training device of the dialogue model in the embodiment of the present application is similar to the description of the corresponding method embodiment above, and has similar beneficial effects as the method embodiment, so it is not repeated. For technical details not disclosed in this embodiment, please refer to the description of the method embodiment of the present application for understanding.

[0163] It should be noted that in the embodiment of the present application, if the training method of the above-mentioned dialogue model is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant solution. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0164] Accordingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for training the dialogue model provided in the above embodiment.

[0165] Figure 8 A schematic diagram of the structure of a training device for a dialogue model provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, the conversation model training device 800 includes: a memory 801, a processor 802, a communication interface 803 and a communication bus 804. The memory 801 is used to store instructions for downloading executable vehicle upgrade files; the processor 802 is used to execute the executable conversation model training instructions stored in the first memory 801 to implement the conversation model training method provided in the above embodiment.

[0166] The description of the above dialogue model training device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the dialogue model training device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0167] 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 including 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 at least one ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0168] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0169] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0170] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0171] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, disks or optical disks.

[0172] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, 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 and includes several instructions for a product to execute all or part of the methods of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0173] The above are only implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technical object familiar with the technical field can be easily thought of within the technical scope disclosed in the present application. Changes or substitutions should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for training a dialogue model, characterized in that: include: Obtain a first training data set for the dialogue model; The first training data set includes a first conversation sample and an interference conversation sample, and the topic type of the interference conversation sample is different from the topic type of the first conversation sample; Based on the first dialogue sample, the interference dialogue sample and the initial dialogue model, obtaining a first loss function value; the first loss function value does not include a loss function value determined by the initial dialogue model for a prediction result of the interference dialogue sample; The initial dialogue model is trained based on the first loss function value to obtain a trained target dialogue model.

2. The method according to claim 1, characterized in that The first dialogue sample includes input dialogue data and corresponding real output dialogue data, and the interference dialogue sample includes interference input dialogue data and corresponding interference output dialogue data; The obtaining a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model includes: Inputting the input dialogue data, the interference input dialogue data and the interference output dialogue data into the initial dialogue model to obtain predicted output dialogue data corresponding to the input dialogue data; The first loss function value is determined based on a preset loss function, the predicted output dialogue data and the corresponding actual output dialogue data.

3. The method according to claim 2, characterized in that The initial dialogue model includes an encoder, a self-attention mechanism layer, and a decoder; The step of inputting the input dialogue data, the interference input dialogue data and the interference output dialogue data into the initial dialogue model to obtain predicted output dialogue data corresponding to the input dialogue data includes: Inputting the input dialogue data, the interference input dialogue data and the interference output dialogue data into the encoder to obtain a first feature encoding matrix; Analyzing and processing the correlation between the encoding features in the first feature encoding matrix using the self-attention mechanism layer to obtain a second feature encoding matrix; The second feature encoding matrix is ​​input into the decoder to obtain the predicted output dialogue data corresponding to the input dialogue data.

4. The method according to claim 2, characterized in that: The input dialogue data includes a plurality of data, each of which corresponds to a real output dialogue data and a predicted output dialogue data; The determining the first loss function value based on the preset loss function, the predicted output dialogue data and the corresponding real output dialogue data includes: Determine, according to the preset loss function, each predicted output dialogue data and the corresponding real output dialogue data, a reference loss function value corresponding to each predicted output data; Based on each reference loss function value, the first loss function value is determined.

5. The method according to claim 1, characterized in that The step of obtaining a first training data set for the dialogue model includes: Obtain multiple rounds of first dialogue samples; The interference dialogue sample is inserted between two adjacent dialogue rounds in the multiple first dialogue samples to obtain the first training data set.

6. The method according to claim 5, characterized in that The method further comprises: Creating a first attribute identifier corresponding to the first conversation sample and a second attribute identifier corresponding to the interference conversation sample; the first attribute identifier and the second attribute identifier are different; The first training data set is created based on the first conversation sample, the first attribute identifier, the interference conversation sample, and the second attribute identifier.

7. The method according to claim 5, characterized in that The method further comprises: If the multiple rounds of first conversation samples belong to multiple topic types, the multiple rounds of first conversation samples are divided into multiple sample groups based on the topic type of each first conversation sample; each sample group includes at least one round of first conversation samples of the same topic type; Inserting the interference dialogue sample between two adjacent dialogue rounds in at least one sample group to obtain a plurality of second training data sets; The initial dialogue model is trained respectively using each second training data set.

8. The method according to claim 5, characterized in that A ratio of the number of the first dialogue samples to the number of the interference dialogue samples is less than a preset threshold.

9. The method according to any one of claims 1 to 8, characterized in that: The step of training the initial dialogue model based on the first loss function value to obtain a trained target dialogue model includes: If the first loss function value does not meet the threshold condition, adjusting the model parameters of the initial dialogue model to obtain a first dialogue model; Inputting the first dialogue sample and the interference dialogue sample into the first dialogue model to obtain a second loss function value; If the second loss function value meets a threshold condition, the first dialogue model is determined as the target dialogue model.

10. A training device for a dialogue model, characterized in that: include: A first acquisition module, used to acquire a first training data set of the dialogue model; The first training data set includes a first conversation sample and an interference conversation sample, and the topic type of the interference conversation sample is different from the topic type of the first conversation sample; a second acquisition module, configured to obtain a first loss function value based on the first dialogue sample, the interference dialogue sample and the initial dialogue model; the first loss function value does not include a loss function value determined by the initial dialogue model for a prediction result of the interference dialogue sample; The first training module is used to train the initial dialogue model based on the first loss function value to obtain a trained target dialogue model.

11. A training device for a dialogue model, characterized in that: include: processor and memory; wherein, The memory is used to store a computer program that can be run on the processor; The processor is configured to execute the method according to any one of claims 1 to 9 when running the computer program.

12. A computer-readable storage medium, characterized in that: The storage medium stores computer program code, and when the computer program code is executed by a computer, the method according to any one of claims 1 to 9 is executed.