Training method and device of dialogue generation model, dialogue generation method and device

By using multi-task learning, the dialogue content of the current round and the previous rounds are used as training targets, which solves the problem of insufficient training of dialogue generation models in the existing technology and realizes efficient training and accurate response generation of dialogue generation models when data is insufficient.

CN114547272BActive Publication Date: 2026-01-20BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210189019.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-28
Publication Date
2026-01-20
Estimated Expiration
2042-02-28

AI Technical Summary

Technical Problem

In existing technologies, dialogue generation models take as input the concatenated dialogue history and output the response of the current round during training. This results in insufficient utilization of the dialogue in the earlier rounds, especially when the amount of data is insufficient, leading to inadequate training.

Method used

A multi-task learning approach is adopted, using the current round's response and the questions and responses from previous rounds as training targets. The probability of the target word is generated through the encoding and decoding process, and the model is optimized using the cross-entropy loss function.

Benefits of technology

When training data is insufficient, make full use of the training data to make the dialogue generation model more accurate and efficient, and generate better responses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114547272B_ABST
    Figure CN114547272B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method and device for training a dialogue generation model, and a method and device for dialogue generation. The method for training the dialogue generation model comprises: obtaining training data, wherein the training data comprises a question sentence of a historical round, a reply sentence of the historical round, and a question sentence of a current round; performing first training on the reply sentence of the current round as a first output target of the dialogue generation model; and performing second training on the question sentence of the historical round and the reply sentence of the historical round as a second output target of the dialogue generation model. The present disclosure utilizes multi-task learning, which can not only take the reply of the current round as a training target, but also take the generated question and reply of the historical round as a training target.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the field of artificial intelligence, and in particular, to a method and apparatus for training a dialogue generation model, and a method and apparatus for dialogue generation. BACKGROUND

[0002] With the development of artificial intelligence technology, intelligent dialogue robots are increasingly common in daily life. For example, chat robots, intelligent customer service robots, etc. can all realize human-computer dialogue.

[0003] The input of the dialogue generation task of the related technology is the dialogue history, which contains multiple rounds of dialogue, and each round of dialogue includes a question of a consultant (such as a buyer) and a reply of a person being consulted (such as a seller). SUMMARY

[0004] The inventors have found that in the training process of the dialogue generation model of the related technology, the input is the concatenation of the dialogue history, and the output is the reply of the current round. For example, the dialogue is 5 rounds (each round contains a question and a reply), the input is the dialogue history of the first 4 rounds, including 4 questions and 4 replies, and the question of the 5th round, and the output is the reply of the 5th round. The model does not make full use of the first 4 rounds, which wastes valuable training data, and in the scenario of insufficient data, causes the dialogue generation model to be insufficiently trained.

[0005] In view of at least one of the above technical problems, the present disclosure provides a method and apparatus for training a dialogue generation model, and a method and apparatus for dialogue generation, which utilize multi-task learning to not only take the reply of the current round as the training target, but also take the generation of the question and reply of the historical round as the training target.

[0006] According to one aspect of the present disclosure, a method for training a dialogue generation model is provided, comprising:

[0007] obtaining training data, wherein the training data includes question sentences of historical rounds, reply sentences of the historical rounds, and question sentences of a current round;

[0008] performing first training on the reply sentences of the current round as a first output target of the dialogue generation model;

[0009] performing second training on the question sentences of the historical rounds and the reply sentences of the historical rounds as a second output target of the dialogue generation model.

[0010] In some embodiments of the present disclosure, the first training on the reply sentences of the current round as the first output target of the dialogue generation model comprises:

[0011] taking the training data as the input of the dialogue generation model, and taking the reply sentences of the current round as the first output target of the dialogue generation model.

[0012] encoding the training data to generate a first encoded semantic vector;

[0013] determining a first decoding hidden layer state according to the first encoded semantic vector and a previous model output;

[0014] determining a generation probability of the first target word according to the first decoding hidden layer state and the first target word.

[0015] In some embodiments of the present disclosure, the second training of the question sentence and the reply sentence of the historical round as the second output target of the dialogue generation model comprises:

[0016] In the training data, a question sentence or a reply sentence of a round is randomly masked, the masked training data is taken as an input of the dialogue generation model, and the masked sentence is taken as a second output target of the dialogue generation model;

[0017] encoding the masked training data to generate a second encoded semantic vector;

[0018] determining a second decoding hidden layer state according to the second encoded semantic vector and the previous model output;

[0019] determining a generation probability of the second target word according to the second decoding hidden layer state and the second target word.

[0020] In some embodiments of the present disclosure, the training method further comprises:

[0021] determining a first loss function according to the first output target;

[0022] determining a second loss function according to the second output target;

[0023] determining a total loss function according to the first loss function and the second loss function;

[0024] optimizing the dialogue generation model according to the total loss function.

[0025] According to another aspect of the present disclosure, a dialogue generation method is provided, comprising:

[0026] obtaining a question sentence of a current round input by a user;

[0027] inputting the question sentence of the current round into a dialogue generation model to generate a reply sentence of the current round, wherein the dialogue generation model is a dialogue generation model generated by using the training method according to any one of the above embodiments.

[0028] According to another aspect of the present disclosure, a training device of a dialogue generation model is provided, comprising:

[0029] The data acquisition module is configured to acquire training data, wherein the training data comprises a question sentence of a historical round, a reply sentence of the historical round, and a question sentence of a current round.

[0030] The first training module is configured to perform first training on the reply sentence of the current round as a first output target of the dialogue generation model.

[0031] The second training module is configured to perform second training on the question sentence of the historical round and the reply sentence of the historical round as a second output target of the dialogue generation model.

[0032] In some embodiments of the present disclosure, the first training module is configured to take the training data as an input of the dialogue generation model, take the reply sentence of the current round as the first output target of the dialogue generation model, encode the training data to generate a first encoded semantic vector, determine a first decoding hidden layer state according to the first encoded semantic vector and a previous model output, and determine a generation probability of a first target word according to the first decoding hidden layer state and the first target word.

[0033] In some embodiments of the present disclosure, the second training module is configured to randomly mask a question sentence or a reply sentence of a round in the training data, take the masked training data as an input of the dialogue generation model, and take the masked sentence as a second output target of the dialogue generation model, encode the masked training data to generate a second encoded semantic vector, determine a second decoding hidden layer state according to the second encoded semantic vector and the previous model output, and determine a generation probability of a second target word according to the second decoding hidden layer state and the second target word.

[0034] In some embodiments of the present disclosure, the training device further comprises:

[0035] The loss function determination module is configured to determine a first loss function according to the first output target, determine a second loss function according to the second output target, and determine a total loss function according to the first loss function and the second loss function.

[0036] The optimization module is configured to optimize the dialogue generation model according to the total loss function.

[0037] According to another aspect of the present disclosure, a dialogue generation device is provided, comprising:

[0038] The sentence acquisition module is configured to acquire a question sentence of a current round input by a user.

[0039] The dialogue generation module is configured to input the question sentence of the current round into a dialogue generation model to generate a reply sentence of the current round, wherein the dialogue generation model is a dialogue generation model generated by using the training method according to any one of the above embodiments.

[0040] According to another aspect of the present disclosure, a computer device is provided, comprising:

[0041] a memory for storing instructions;

[0042] a processor for executing the instructions, so that the computer device performs operations of implementing the training method according to any one of the above embodiments, or the dialogue generation method according to any one of the above embodiments.

[0043] According to another aspect of the present disclosure, a non-transitory computer readable storage medium is provided, wherein the non-transitory computer readable storage medium stores computer instructions, and the instructions, when executed by a processor, implement the training method according to any one of the above embodiments, or the dialogue generation method according to any one of the above embodiments.

[0044] The present disclosure utilizes multi-task learning, which can not only take the reply of the current round as the training target, but also take the generation of the question and reply of the historical round as the training target. BRIEF DESCRIPTION OF DRAWINGS

[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0046] Figure 1 A schematic diagram of some embodiments of the training method of the dialogue generation model of the present disclosure.

[0047] Figure 2 A schematic diagram of some embodiments of the dialogue generation method of the present disclosure.

[0048] Figure 3 A schematic diagram of some embodiments of the training device of the dialogue generation model of the present disclosure.

[0049] Figure 4 A schematic diagram of some other embodiments of the training device of the dialogue generation model of the present disclosure.

[0050] Figure 5 A schematic diagram of some embodiments of the dialogue generation device of the present disclosure.

[0051] Figure 6 A structural schematic diagram of some embodiments of the computer device of the present disclosure. DETAILED DESCRIPTION

[0052] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.

[0053] Unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of this disclosure.

[0054] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.

[0055] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0056] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0057] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0058] Figure 1 The diagram illustrates some embodiments of the training method for the dialogue generation model of this disclosure. Preferably, this embodiment can be executed by the training apparatus of the dialogue generation model of this disclosure. The method may include at least one step from steps 100 to 300, wherein:

[0059] Step 100: Obtain training data, which includes question statements from historical rounds, response statements from historical rounds, and question statements from the current round.

[0060] In some embodiments of this disclosure, step 100 may include a given dialogue comprising K rounds, each round (the i-th round) having a question q. i and reply r i Composition, each question q i =(q i1 q i2 , ..., q im ), where q i1 Represents the first character, qij m represents the total number of words of the jth word of the ith question; each round (the ith round) of reply r i i1 i2 in , where r i1 represents the first word, r ij represents the jth word, and the ith reply has n words.

[0061] Step 200, training the reply sentence of the current round as the first output target of the dialogue generation model.

[0062] In some embodiments of the present disclosure, step 200 can include at least one of steps 210-250, wherein:

[0063] Step 210, training data as input of the dialogue generation model, and the reply sentence of the current round as the first output target of the dialogue generation model.

[0064] In some embodiments of the present disclosure, step 210 can include: assuming that the training target is the reply of the 5th round, that is, the output target y = (r 51 , r 52 ,..., r 5n ), and the input is the dialogue history of the first 4 rounds and the question of the 5th round, that is, the input x = (q 11 ,..., q 1m , r 11 ,..., r 1n ,..., q 51 ,..., q 5m ).

[0065] Step 220, encoding the training data to generate a first encoded semantic vector.

[0066] In some embodiments of the present disclosure, step 220 can include: using the encoder f enc of the Transformer (a natural language processing model) to encode x to generate a first encoded semantic vector (a first encoded hidden layer state h), as shown in formula (1), where j is the jth word.

[0067] h j = f enc (x j ) (1)

[0068] Step 230, determining a first decoding hidden layer state according to the first encoded semantic vector and the previous model output.

[0069] ​​​In some embodiments of the present disclosure, step 230 can include: based on the Transformer-based decoder f dec , generating a first decoding hidden layer state s, as shown in formula (2), wherein y t-1 is the previous model output, and s t is the second decoding hidden layer state of this time.

[0070] s t =f dec (h, y t-1 ) (2)

[0071] Step 240, determining the generation probability of the first target word according to the first decoding hidden layer state and the first target word.

[0072] In some embodiments of the present disclosure, step 240 can include: the decoder calculates the generation probability P vocab (w) of the target word w according to the decoding hidden layer state s, as shown in formula (3), wherein W b is the parameter matrix of the target word, and the softmax function is a normalized exponential function.

[0073] P vocab (w)=softmax(W b s t ) (3)

[0074] Step 250, determining a first loss function according to the first output target.

[0075] In some embodiments of the present disclosure, the first loss function can be cross entropy, as shown in formula (4), wherein j is the jth word of the 5th round of reply.

[0076] L1=-∑ j log(r 5j ) (4)

[0077] Step 300, taking the question sentence of the historical round and the reply sentence of the historical round as the second output target of the dialogue generation model for second training.

[0078] In some embodiments of the present disclosure, step 300 can include at least one of steps 310-360, wherein:

[0079] Step 310, in the training data, randomly masking a question sentence or a reply sentence of a round, taking the masked training data as the input of the dialogue generation model, and taking the masked sentence as the second output target of the dialogue generation model.

[0080] In some embodiments of the present disclosure, step 310 can include: given a dialogue history x = (q 11 ,..., q 1m , r 11 ,..., r 1n ,..., q 51 ,..., q 5m , ), randomly mask the question or the reply in a round, such as the reply in the first round, to construct a new text The second output target (training target) is the masked part generated by , i.e.

[0081] Step 320 encodes the masked training data to generate a second encoded semantic vector.

[0082] In some embodiments of the present disclosure, step 320 can include: using the encoder f enc of the Transformer to encode to generate a second encoded semantic vector (second encoded hidden layer state ), as shown in formula (5), where j is the jth word.

[0083]

[0084] Step 330 determines a second decoding hidden layer state according to the second encoded semantic vector and the previous model output.

[0085] In some embodiments of the present disclosure, step 330 can include: based on the decoder f dec of the Transformer, generating a second decoding hidden layer state , as shown in formula (6), where is the previous model output, is the second decoding hidden layer state of this time.

[0086]

[0087] Step 340 determines the generation probability of the second target word according to the second decoding hidden layer state and the second target word.

[0088] In some embodiments of the present disclosure, step 340 can include: the decoder calculates the generation probability P vocab (w) of the target word w according to the decoding hidden layer state s, as shown in formula (6), where W b is the parameter matrix of the target word, and softmax is a normalized exponential function.

[0089]

[0090] Step 350, according to the second output target, determine the second loss function.

[0091] In some embodiments of the present disclosure, the first loss function can be cross entropy, as shown in formula (8), where j is the jth word of the 1st round of reply.

[0092] L2 = -∑ j log(r 1j ) (8)

[0093] Step 360, according to the first loss function and the second loss function to determine the total loss function; according to the total loss function to optimize the dialogue generation model.

[0094] In some embodiments of the present disclosure, in step 260, the step of determining the total loss function according to the first loss function and the second loss function can include: the final total loss function is the sum of the first loss function and the second loss function, as shown in formula (9).

[0095] L = L1 + L2 (9)

[0096] Based on the training method of the dialogue generation model provided by the above embodiments of the present disclosure, the training data can be fully utilized; by using multi-task learning, not only the reply of the current round can be used as the training target, but also the generated question and reply of the historical round can be used as the training target. Therefore, the above embodiments of the present disclosure can make the dialogue generation model training more sufficient in the case of small training data.

[0097] Figure 2 The method of some embodiments of the present disclosure is shown in the figure. Preferably, the embodiments can be executed by the dialogue generation device of the present disclosure. The method can include at least one of steps 1-2, wherein:

[0098] Step 1, obtaining the user input question sentence of the current round.

[0099] Step 2, input the question sentence of the current round into the dialogue generation model to generate the reply sentence of the current round, wherein the dialogue generation model is the dialogue generation model generated by the training method as described in any of the above embodiments (for example Figure 1 Embodiments).

[0100] Based on the dialogue generation method provided by the above embodiments of the present disclosure, the dialogue generation model can be trained more sufficiently in the case of small training data, so that the reply sentence of the current round can be obtained more accurately and efficiently.

[0101] Figure 3A schematic diagram of some embodiments of the training apparatus of the dialogue generation model of the present disclosure. As shown in Figure 3 The training apparatus of the dialogue generation model of the present disclosure can include a data acquisition module 31, a first training module 32, and a second training module 33, wherein:

[0102] The data acquisition module 31 is configured to acquire training data, wherein the training data includes question sentences of historical turns, reply sentences of historical turns, and question sentences of a current turn.

[0103] The first training module 32 is configured to perform first training on the reply sentences of the current turn as the first output target of the dialogue generation model.

[0104] In some embodiments of the present disclosure, the first training module 32 can be configured to take the training data as the input of the dialogue generation model, take the reply sentences of the current turn as the first output target of the dialogue generation model, encode the training data to generate a first encoded semantic vector, determine a first decoding hidden layer state according to the first encoded semantic vector and the previous model output, and determine the generation probability of the first target word according to the first decoding hidden layer state and the first target word.

[0105] In some embodiments of the present disclosure, the first training module 32 can include an encoder and a decoder, wherein:

[0106] The encoder is configured to encode the training data to generate the first encoded semantic vector.

[0107] The decoder is configured to determine the first decoding hidden layer state according to the first encoded semantic vector and the previous model output, and determine the generation probability of the first target word according to the first decoding hidden layer state and the first target word.

[0108] The second training module 33 is configured to perform second training on the question sentences of the historical turns and the reply sentences of the historical turns as the second output target of the dialogue generation model.

[0109] In some embodiments of the present disclosure, the second training module 33 can be configured to randomly mask the question sentences or the reply sentences of one turn in the training data, take the masked training data as the input of the dialogue generation model, and take the masked sentences as the second output target of the dialogue generation model; encode the masked training data to generate a second encoded semantic vector; determine a second decoding hidden layer state according to the second encoded semantic vector and the previous model output; and determine the generation probability of the second target word according to the second decoding hidden layer state and the second target word.

[0110] In some embodiments of the present disclosure, the second training module 33 can include an encoder and a decoder, wherein:

[0111] an encoder configured to encode the masked training data to generate a second encoded semantic vector.

[0112] a decoder configured to determine a second decoding hidden layer state according to the second encoded semantic vector and the previous model output, and determine a generation probability of the second target word according to the second decoding hidden layer state and the second target word.

[0113] Figure 4 a schematic diagram of another embodiment of the training device of the dialogue generation model of the present disclosure. As Figure 3 compared with the prior art, Figure 4 The training device of the dialogue generation model of the present disclosure of the embodiment can further include a loss function determination module 34 and an optimization module 35, wherein:

[0114] The loss function determination module 34 is configured to determine a first loss function according to the first output target, determine a second loss function according to the second output target, and determine a total loss function according to the first loss function and the second loss function.

[0115] The optimization module 35 is configured to optimize the dialogue generation model according to the total loss function.

[0116] Based on the training device of the dialogue generation model provided in the above embodiments of the present disclosure, the training data can be fully utilized; by using multi-task learning, not only the reply of the current round can be used as the training target, but also the question and the reply of the historical rounds can be used as the training target. Therefore, the dialogue generation model can be trained more fully in the case of small training data.

[0117] Figure 5 a schematic diagram of some embodiments of the dialogue generation device of the present disclosure. As Figure 5 shown, the dialogue generation device of the present disclosure can include a sentence acquisition module 51 and a dialogue generation module 52, wherein:

[0118] The sentence acquisition module 51 is configured to acquire a question sentence of a current round input by a user.

[0119] The dialogue generation module 52 is configured to input the question sentence of the current round into a dialogue generation model to generate a reply sentence of the current round, wherein the dialogue generation model is a dialogue generation model generated by using the training method of any one of the above embodiments (for example Figure 1 embodiment).

[0120] Based on the dialogue generation device provided in the above embodiments of the present disclosure, the dialogue generation model can be trained more fully in the case of small training data, so that the reply sentence of the current round can be obtained more accurately and efficiently.

[0121] Figure 6A structural diagram of some embodiments of a computer device of the present disclosure is shown. As shown in Figure 6 The computer device includes a memory 61 and a processor 62.

[0122] The memory 61 is configured to store instructions, and the processor 62 is coupled to the memory 61 and configured to execute the instructions stored in the memory to implement the training method according to any one of the above embodiments (e.g., the embodiment of the training method shown in Figure 1 The embodiment) or the dialogue generation method according to any one of the above embodiments (e.g., the embodiment of the dialogue generation method shown in Figure 2 The embodiment).

[0123] As shown in Figure 6 The computer device further includes a communication interface 63 configured to interact with other devices. The computer device further includes a bus 64, and the processor 62, the communication interface 63, and the memory 61 are connected to each other through the bus 64.

[0124] The memory 61 can include a high-speed RAM memory, and can further include a non-volatile memory, such as at least one disk memory. The memory 61 can also be a memory array. The memory 61 can also be divided into blocks, and the blocks can be combined into a virtual volume according to a certain rule.

[0125] In addition, the processor 62 can be a central processing unit (CPU), or can be an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present disclosure.

[0126] According to another aspect of the present disclosure, a non-transitory computer readable storage medium is provided, wherein the non-transitory computer readable storage medium stores computer instructions, and the instructions, when executed by a processor, implement the training method according to any one of the above embodiments or the dialogue generation method according to any one of the above embodiments.

[0127] Those skilled in the art should understand that the embodiments of the present disclosure can be provided as a method, a device, or a computer program product. Therefore, the present disclosure can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure can take the form of a computer program product implemented on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROMs, optical storage media, etc.) containing computer-usable program code.

[0128] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.

[0129] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.

[0130] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.

[0131] The training device and the dialogue generation device of the dialogue generation model described above can be implemented as a general processor, a programmable logic controller (PLC), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or any appropriate combination thereof.

[0132] So far, the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Those skilled in the art can fully understand how to implement the technical solutions disclosed herein according to the above description.

[0133] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or can be instructed by a program to complete the related hardware, and the program can be stored in a non-transitory computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.

[0134] The description of the present disclosure is given for the purpose of illustration and description, and is not exhaustive or limiting to the present disclosure. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are chosen and described in order to best explain the principles of the present disclosure and its practical application, and to enable others skilled in the art to understand the present disclosure in order to design various embodiments with various modifications for specific use cases.

Claims

1. A method for training a dialogue generation model, the method comprising: The method comprises: obtaining training data, wherein the training data comprises question sentences of historical rounds, reply sentences of the historical rounds, and a question sentence of a current round; first training, taking the reply sentence of the current round as a first output target of a dialogue generation model; second training, taking the question sentence and the reply sentence of the historical round as a second output target of the dialogue generation model; wherein the second training comprises: in the training data, randomly masking the question sentence or the reply sentence of one of the historical rounds, taking the masked training data as input of the dialogue generation model, and taking the masked sentence as the second output target of the dialogue generation model; encoding the masked training data to generate a second encoded semantic vector; determining a second decoding hidden layer state according to the second encoded semantic vector and a previous model output; determining a generation probability of a second target word according to the second decoding hidden layer state and the second target word.

2. The training method of claim 1, wherein, The first training comprises: taking the training data as input of the dialogue generation model, and taking the reply sentence of the current round as the first output target of the dialogue generation model; encoding the training data to generate a first encoded semantic vector; determining a first decoding hidden layer state according to the first encoded semantic vector and the previous model output; determining a generation probability of a first target word according to the first decoding hidden layer state and the first target word.

3. The training method of claim 2, wherein, The method further comprises: determining a first loss function according to the first output target; determining a second loss function according to the second output target; determining a total loss function according to the first loss function and the second loss function; optimizing the dialogue generation model according to the total loss function.

4. A dialogue generation method characterized by, The method comprises: obtaining a question sentence of a current round input by a user; inputting the question sentence of the current round into a dialogue generation model to generate a reply sentence of the current round, wherein the dialogue generation model is generated by the training method of any one of claims 1-3. 5.A device for training a dialogue generation model, characterized in that, The method comprises: a data obtaining module, configured to obtain training data, wherein the training data comprises question sentences of historical rounds, reply sentences of the historical rounds, and a question sentence of a current round; a first training module, configured to first train, taking a reply sentence of the current round as a first output target of a dialogue generation model; a second training module, configured to second train, taking the question sentence and the reply sentence of the historical round as a second output target of the dialogue generation model; wherein the second training module is configured to, in the training data, randomly mask the question sentence or the reply sentence of one of the historical rounds, take the masked training data as input of the dialogue generation model, and take the masked sentence as the second output target of the dialogue generation model; encode the masked training data to generate a second encoded semantic vector; determine a second decoding hidden layer state according to the second encoded semantic vector and a previous model output; and determine a generation probability of a second target word according to the second decoding hidden layer state and the second target word.

6. The training apparatus of claim 5, wherein, a first training module configured to input the training data into the dialogue generation model, and input the reply statement of the current round into the dialogue generation model as a first output target of the dialogue generation model; encode the training data to generate a first encoded semantic vector; determine a first decoding hidden layer state according to the first encoded semantic vector and a previous model output; and determine a generation probability of the first target word according to the first decoding hidden layer state and the first target word.

7. The training device of claim 6, wherein, Further comprising: a loss function determination module configured to determine a first loss function according to the first output target; determine a second loss function according to the second output target; and determine a total loss function according to the first loss function and the second loss function; an optimization module configured to optimize the dialogue generation model according to the total loss function. comprising:

8. A dialogue generation apparatus characterized by comprising: a statement acquisition module configured to acquire a question statement of a current round input by a user; a dialogue generation module configured to input the question statement of the current round into the dialogue generation model to generate a reply statement of the current round, wherein the dialogue generation model is generated by using the training method of any one of claims 1-3. comprising:

9. A computer apparatus, comprising: a memory configured to store instructions; a processor configured to execute the instructions, so that the computer device implements the training method of any one of claims 1-3, or the dialogue generation method of claim 4. The non-transitory computer readable storage medium stores computer instructions, and the instructions are executed by the processor to implement the training method of any one of claims 1-3, or the dialogue generation method of claim 4.

10. A non-transitory computer-readable storage medium, comprising: ​