Dialogue sentence completion and model training method and device, equipment and storage medium

By combining encoder and decoder models, semantic features are used to generate predicted probability values ​​and complete sentences. A total loss function is constructed and parameters are adjusted to solve the problem of missing queries in multi-turn dialogues and improve the accuracy of dialogue sentence completion.

CN115168553BActive Publication Date: 2026-02-17BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210727958.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-23
Publication Date
2026-02-17
Estimated Expiration
2042-06-23

AI Technical Summary

Technical Problem

The accuracy of dialogue completion in existing technologies needs to be improved, especially in multi-turn dialogues where query loss due to reference or omission has not been effectively addressed.

Method used

A combined encoder and decoder model is adopted. Semantic features are generated by encoding multi-turn dialogue sentence samples. Based on the semantic features, prediction probability values ​​and prediction of complete sentences are generated. A total loss function is constructed to adjust the model parameters and improve the accuracy of the model.

Benefits of technology

The accuracy of the dialogue completion model has been improved, resulting in more fluent and accurate completed sentences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115168553B_ABST
    Figure CN115168553B_ABST
Patent Text Reader

Abstract

The present disclosure discloses a dialogue sentence completion and model training method and device, equipment and a storage medium, relating to the technical field of artificial intelligence, especially to the technical field of natural language processing, human-computer dialogue and the like. The training method of the dialogue sentence completion model comprises: using an encoder to perform encoding processing on a multi-round dialogue sentence sample to generate semantic features, wherein the multi-round dialogue sentence sample comprises a to-be-completed sentence sample; generating a prediction probability value based on the semantic features; using a decoder to perform decoding processing on the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; constructing a total loss function based on the prediction probability value and the predicted complete sentence; and adjusting model parameters of at least one of the encoder and the decoder based on the total loss function. The present disclosure can improve the accuracy of the dialogue sentence completion model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer, in particular to the technical field of natural language processing, human-computer dialogue and the like, and more particularly to a dialogue sentence completion and model training method, device, equipment and storage medium. BACKGROUND

[0002] In order to make the machine freely dialogue like a person, the dialogue robot must have the ability of continuous dialogue, i.e. multi-turn dialogue. There is a phenomenon of missing dialogue sentence (query) in the multi-turn dialogue, and the missing query may be caused by reference or omission.

[0003] In order to better understand the query, query completion is generally performed. SUMMARY

[0004] The present disclosure provides a dialogue sentence completion and model training method, device, equipment and storage medium.

[0005] According to an aspect of the present disclosure, a training method of a dialogue sentence completion model is provided, the dialogue model comprising an encoder and a decoder, the method comprising: using the encoder to perform encoding processing on a multi-turn dialogue sentence sample to generate semantic features, wherein the multi-turn dialogue sentence sample comprises a to-be-completed sentence sample; generating a prediction probability value based on the semantic features; using the decoder to perform decoding processing on the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; constructing a total loss function based on the prediction probability value and the predicted complete sentence; and adjusting model parameters of at least one of the encoder and the decoder based on the total loss function.

[0006] According to another aspect of the present disclosure, a dialogue sentence completion method is provided, comprising: obtaining a multi-turn dialogue sentence, the multi-turn dialogue sentence comprising a to-be-completed sentence; using an encoder to extract semantic features of the multi-turn dialogue sentence; and using a decoder to generate a completed dialogue sentence corresponding to the to-be-completed sentence based on the semantic features; wherein the encoder and the decoder are trained by using the training method of any one of the above aspects.

[0007] According to another aspect of the present disclosure, a device for training a dialogue sentence completion model is provided, the dialogue sentence completion model comprising an encoder and a decoder, the device comprising: an encoding module configured to encode, using the encoder, a multi-turn dialogue sentence sample to generate semantic features, wherein the multi-turn dialogue sentence sample comprises a to-be-completed sentence sample; a selection module configured to generate a prediction probability value based on the semantic features; a decoding module configured to decode, using the decoder, the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; a construction module configured to construct a total loss function based on the prediction probability value and the predicted complete sentence; and an adjustment module configured to adjust a model parameter of at least one of the encoder and the decoder based on the total loss function.

[0008] According to another aspect of the present disclosure, a device for dialogue sentence completion is provided, comprising: an acquisition module configured to acquire a multi-turn dialogue sentence, the multi-turn dialogue sentence comprising a to-be-completed sentence; an encoding module configured to extract semantic features of the multi-turn dialogue sentence using an encoder; and a decoding module configured to generate a completed dialogue sentence corresponding to the to-be-completed sentence based on the semantic features using a decoder, wherein the encoder and the decoder are trained using the training method of any one of the above aspects.

[0009] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of the above aspects.

[0010] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to perform the method of any one of the above aspects.

[0011] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method of any one of the above aspects.

[0012] According to the technical solutions of the present disclosure, the accuracy of the dialogue sentence completion model can be improved.

[0013] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0014] The accompanying drawings are used to better understand the present scheme, and do not constitute a limitation on the present disclosure. Among them:

[0015] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure;

[0016] Figure 2 is a schematic diagram according to the second embodiment of the present disclosure;

[0017] Figure 3 is a schematic diagram of the application scenario corresponding to the embodiment of the present disclosure;

[0018] Figure 4 is a schematic diagram according to the third embodiment of the present disclosure;

[0019] Figure 5 is a schematic diagram according to the fourth embodiment of the present disclosure;

[0020] Figure 6 is a schematic diagram according to the fifth embodiment of the present disclosure;

[0021] Figure 7 is a schematic diagram according to the sixth embodiment of the present disclosure;

[0022] Figure 8 is a schematic diagram of an electronic device for implementing the training method of the dialogue sentence completion model or the dialogue sentence completion method according to the embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, including various details of the embodiments of the present disclosure to help understanding, which should be considered only as exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Also, in order to be clear and concise, the description below omits the description of well-known functions and structures.

[0024] In related art, there are some dialogue sentence (query) completion schemes, but the accuracy needs to be improved.

[0025] In order to improve the accuracy of query completion, the present disclosure provides the following embodiments.

[0026] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure, which provides a training method of a dialogue sentence completion model, the dialogue sentence completion model comprising an encoder (Encoder) and a decoder (Decoder). As shown in Figure 1 , the method comprises:

[0027] 101. encode the multi-turn dialogue sentence sample by using the encoder to generate semantic features, wherein the multi-turn dialogue sentence sample comprises a to-be-completed sentence sample.

[0028] 102. generate a prediction probability value based on the semantic features.

[0029] 103. decode the semantic features by using the decoder to generate a predicted complete sentence corresponding to the to-be-completed sentence sample.

[0030] 104. construct a total loss function based on the prediction probability value and the predicted complete sentence.

[0031] 105. adjust the model parameters of at least one of the encoder and the decoder based on the total loss function.

[0032] Wherein, the training required corpus can be obtained from the existing sample set, for example, obtaining a multi-turn dialogue sentence sample.

[0033] The multi-turn dialogue sentence sample comprises a to-be-completed sentence sample. The to-be-completed sentence sample refers to a sentence sample with missing content, which can be caused by reference or omission.

[0034] The multi-turn dialogue sentence sample can also include the context sentence sample of the to-be-completed sentence sample, which includes the previous sentence sample and / or the subsequent sentence sample, the previous sentence sample refers to the dialogue sentence sample before the to-be-completed sentence sample, and the subsequent sentence sample refers to the dialogue sentence sample after the to-be-completed sentence sample.

[0035] Taking the previous sentence sample as an example, the multi-turn dialogue sentence sample comprises, for example:

[0036] Do you play ABCD?

[0037] Play.

[0038] When did it start?

[0039] Wherein, ABCD can be the name of a game.

[0040] In the above example, "When did it start?" is a to-be-completed sentence sample, and the previous sentence samples are "Do you play ABCD?" and "Play."

[0041] After obtaining the multi-turn dialogue sentence sample, it can be used as the input of the encoder, and the encoder is used to extract the semantic features of the input multi-turn dialogue sentence sample. The output of the encoder is the semantic features corresponding to the input multi-turn dialogue sentence sample.

[0042] The encoder can employ a deep neural network model, for example, an encoder in various pre-trained models in the field of natural language processing (NLP).

[0043] After obtaining the semantic features, on the one hand, a prediction probability value can be obtained based on the semantic features, and on the other hand, a predicted complete sentence can be obtained based on the semantic features.

[0044] The prediction probability value is used to indicate the probability that the processing unit is a missing unit, and is generally a value between [0, 1], for example, for a certain processing unit, if the probability value = 1, it indicates that the processing unit is a missing unit, and if the probability value = 0, it indicates that the processing unit is not a missing unit. The processing unit is a text unit in the real complete sentence corresponding to the sentence sample to be completed, and the missing unit is a text unit missing in the real complete sentence relative to the sentence sample to be completed.

[0045] Taking Chinese as an example, a text unit (token) can refer to each character in Chinese.

[0046] The real complete sentence corresponding to the sentence sample to be completed can be obtained by manually completing the sentence sample to be completed in a manual annotation manner.

[0047] For example, the sentence sample to be completed is “what time did it start”, and through manual annotation, the real complete sentence corresponding thereto is “what time did it start to play ABCD”.

[0048] The prediction probability value is relative to the real probability value, and the prediction probability value is a probability value predicted based on the semantic features.

[0049] The real probability value is a real value, which can be obtained by manual annotation.

[0050] For example, if a certain character is a missing unit, the real probability value of the character can be annotated as 1, and if a certain character is not a missing unit, the real probability value of the character can be annotated as 0.

[0051] Taking the real complete sentence “what time did it start to play ABCD” as an example, since “play” and “A”, “B”, “C”, and “D” are missing units, the real probability values corresponding thereto are annotated as 1, and the real probability values of the remaining characters are annotated as 0.

[0052] The prediction probability value refers to the probability value of each character in “what time did it start to play ABCD” predicted based on the semantic features.

[0053] The predicted complete sentence refers to the complete sentence corresponding to the sentence sample to be completed predicted based on the semantic features, i.e., the completed sentence corresponding to the sentence sample to be completed predicted.

[0054] The semantic features can be input to a decoder, and the decoder can output a predicted complete sentence after processing the input semantic features.

[0055] The decoder can be a deep neural network model, such as a decoder in various pre-training models in the NLP field. The encoder and the decoder can use the same or different pre-training model encoders and decoders.

[0056] After obtaining the predicted probability value and the predicted complete sentence, a total loss function can be constructed based on the predicted information (the predicted probability value and the predicted complete sentence) and the corresponding real information (the real probability value and the real complete sentence), and then the model parameters of the encoder and / or the decoder can be adjusted based on the total loss function.

[0057] When adjusting the model parameters, an algorithm such as BackPropagation (BP) can be used to adjust the model parameters until a preset number of iterations is reached. The model parameters at the time when the preset number of iterations is reached are used as the final model parameters.

[0058] In this embodiment, the predicted probability value is generated based on the semantic features, the predicted complete sentence is generated based on the semantic features, the total loss function is constructed based on the predicted probability value and the predicted complete sentence, and the model parameters are adjusted based on the total loss function. During the training of the dialogue sentence completion model, the missing units can be marked, thereby improving the accuracy of the dialogue sentence completion model. In addition, the predicted probability value and the predicted complete sentence are both obtained based on the semantic features, which can be considered as implicit modeling. Compared with the way of explicitly generating the predicted probability value and the predicted complete sentence by using different models respectively, the model error accumulation can be reduced, and the accuracy of the dialogue sentence completion model can be further improved.

[0059] The above describes the model training process, and after training, the final generated dialogue sentence completion model can be obtained. Then, the dialogue sentence completion model can be used for dialogue sentence completion.

[0060] Figure 2 is a schematic diagram according to the second embodiment of the present disclosure. The present embodiment provides a dialogue sentence completion method, as shown in Figure 2 The method comprises the following steps.

[0061] 201, obtaining a multi-round dialogue sentence, wherein the multi-round dialogue sentence comprises a to-be-completed sentence.

[0062] The multi-round dialogue sentence can further comprise a context sentence of the to-be-completed sentence. The context sentence can comprise a preceding dialogue sentence and / or a subsequent dialogue sentence.

[0063] The preceding dialogue sentence refers to the dialogue sentence before the to-be-completed sentence, and the following dialogue sentence refers to the dialogue sentence after the to-be-completed sentence.

[0064] Generally, all dialogue sentences of the previous round before the to-be-completed sentence can be used as the preceding dialogue sentence, and the preceding dialogue sentence and the to-be-completed sentence are spliced as the multi-round dialogue sentence.

[0065] In addition, each sentence in the multi-round dialogue sentence can be separated by a separator, and the to-be-completed sentence and its context sentence are separated by different separators.

[0066] Taking the preceding dialogue sentence as an example, the preceding dialogue sentences of different sentences can be separated by [SEP], and the to-be-completed sentence can be separated by [X].

[0067] 202. An encoder is used to extract semantic features of the dialogue sentence of the round.

[0068] 203. A decoder is used to generate a completed dialogue sentence corresponding to the to-be-completed sentence based on the semantic features.

[0069] The dialogue sentence completion model can include an encoder and a decoder, and the encoder and the decoder can be trained using the method shown in the above embodiments.

[0070] After the dialogue sentence completion model is trained, the encoder can be used to process the input dialogue sentence of the round to output semantic features, and the decoder can be used to process the input semantic features to output a completed dialogue sentence.

[0071] In this embodiment, the dialogue sentence completion model obtained by using the training method described above is used for dialogue sentence completion processing to obtain a completed dialogue sentence. Since the dialogue sentence completion model has high accuracy, the completed dialogue sentence obtained in this embodiment has high accuracy.

[0072] In order to better understand the embodiments of the present disclosure, the application scenarios of the embodiments of the present disclosure are described.

[0073] The human-computer dialogue process generally includes: a dialogue system obtains a dialogue sentence (query), and the dialogue system generates and feeds back a reply sentence (reply) to the user after understanding the input dialogue sentence. In a multi-round dialogue scenario, the dialogue sentence can include a current sentence input by the user and a context sentence of the current sentence. Generally, the context sentence can be specifically a preceding sentence, which can also be referred to as a dialogue history sentence.

[0074] The preceding sentence can include a dialogue sentence input by the user, or a reply sentence fed back by the dialogue system in the previous round.

[0075] To better generate the reply sentence, it can be identified whether the current sentence in the dialogue sentence needs to be completed, and the dialogue understanding is performed after the current sentence is completed when the completion is needed.

[0076] As shown in Figure 2 After the dialogue system receives the dialogue sentence, the dialogue sentence can include the current sentence and the previous sentence of the current sentence. It can be identified whether the current sentence needs to be completed. If so, the dialogue sentence completion model is used for completion to generate the completed dialogue sentence. Then, the dialogue understanding model is used to understand the completed dialogue sentence or the dialogue sentence that does not need to be completed to generate the reply sentence.

[0077] The embodiments of the present disclosure mainly aim at dialogue sentence completion. Therefore, for other contents, such as identification of whether completion is needed and dialogue understanding process, related technologies can be used.

[0078] For dialogue sentence completion, the dialogue sentence completion model can be used in the embodiments. That is, the input of the dialogue sentence completion model is a multi-turn dialogue sentence, which includes a to-be-completed sentence. The output is a completed dialogue sentence corresponding to the to-be-completed sentence, which can also be referred to as a complete dialogue sentence.

[0079] The dialogue sentence completion model can include an encoder and a decoder. The encoder and the decoder can use the same or different encoders and decoders in the pre-trained model.

[0080] The pre-trained model is, for example, various pre-trained models based on the Transformer model.

[0081] Taking the encoder and the decoder using the same pre-trained model as an example, the same pre-trained model is, for example, a T5 model.

[0082] The T5 model is a text-to-text model, which is based on the encoder and decoder structure of the Transformer model.

[0083] In the embodiments, the encoder and the decoder are, for example, the encoder of the T5 model (which can be referred to as the T5 encoder) and the decoder of the T5 model (which can be referred to as the T5 decoder).

[0084] In combination with the above application scenarios, the present disclosure further provides a training method of a dialogue sentence completion model.

[0085] Figure 4 is a schematic diagram according to the third embodiment of the present disclosure. The present embodiment provides a training method of a dialogue sentence completion model. The dialogue sentence completion model includes an encoder (Encoder) and a decoder (Decoder), as shown in Figure 4 and in combination withFigure 5 As shown in the architecture diagram, the method comprises:

[0086] 401. An encoder adopting a T5 model encodes the multi-turn dialogue sentence sample to generate semantic features.

[0087] The multi-turn dialogue sentence sample comprises a to-be-completed sentence sample and a context sentence sample of the to-be-completed sentence sample.

[0088] The context sentence sample is separated by a first separator, the to-be-completed sentence sample is separated by a second separator, and the first separator is different from the second separator.

[0089] Referring to Figure 5 , taking the context sentence sample as an example, the to-be-completed sentence sample can be "when did it start", and the context sentence sample can include "do you play ABCD" and "play".

[0090] The first separator [SEP] is used to separate each context sentence sample, and the second separator [X] is used to separate the to-be-completed sentence sample.

[0091] In this embodiment, the context sentence sample and the to-be-completed sentence sample are separated by different separators, which can enable the model to identify whether the input sentence sample is a context sentence sample or a to-be-completed sentence sample based on the separator, thereby improving the accuracy of the model.

[0092] 402. A feed forward neural network (FFN) is used to feed forward process the semantic features to generate mapping features.

[0093] The feed forward neural network is the simplest neural network, in which the neurons are arranged in layers, and each neuron is connected to the neurons of the previous layer. The output of the previous layer is received and output to the next layer, and there is no feedback between layers. It is one of the most widely used and fastest developing artificial neural networks.

[0094] The input of the FFN is the semantic feature, and the output can be referred to as the mapping feature.

[0095] In this embodiment, the FFN is used to simplify the operation, reduce the training difficulty, and improve the model training efficiency.

[0096] 403. A normalization layer is used to normalize the mapping features to generate the predicted probability value.

[0097] As shown in Figure 5 , the normalization layer can be normalized by a softmax function.

[0098] The input of the normalization layer is the mapped feature of the FFN output, and the output is a predicted probability value of each word in the real complete sentence.

[0099] For example, as shown in Figure 5 , the real complete sentence can be "when do you start playing ABCD", and the output of the normalization layer can be the predicted probability value of each word in "when do you start playing ABCD", which is used to predict the probability that the corresponding word is a missing word.

[0100] 404. Based on the predicted probability value and the real probability value of the missing unit of the processing unit, a first loss function is constructed.

[0101] As shown in Figure 5 , the real probability value is represented by a label, and the real probability value corresponding to the missing word can be labeled as 1, and the real probability value corresponding to the remaining word can be labeled as 0.

[0102] As shown in Figure 5 , since the missing word is "play ABCD", the real probability value corresponding to the five words is represented by 1, and the real probability value of the remaining words is represented by 0.

[0103] The first loss function can be a Kullback-Leibler divergence function. Kullback-Leibler divergence is also called relative entropy.

[0104] KL divergence is used to evaluate the dissimilarity between two probability distributions. It can be understood that the first loss function can also use other functions that can evaluate the dissimilarity between two probability distributions, such as cross-entropy, Jensen-Shannon divergence, etc.

[0105] 405. The decoder of the T5 model is used to decode and process the semantic feature to generate a predicted complete sentence corresponding to the sentence sample to be completed.

[0106] As shown in Figure 5 , the input of the decoder is the semantic feature, and the output is the predicted complete sentence.

[0107] 406. Based on the predicted complete sentence and the real complete sentence, a second loss function is constructed.

[0108] Among them, 402-404 has no time sequence restriction relationship with 405-406.

[0109] The second loss function can be a Maximum Likelihood Estimation function.

[0110] It can be understood that the second loss function can also adopt other functions, the purpose is to minimize the distance between the predicted complete sentence and the real complete sentence, for example, mean square error, log likelihood function, etc. can also be used.

[0111] 407. Based on the first loss function and the second loss function, the total loss function is constructed.

[0112] As shown in Figure 5 The calculation formula of the total loss function can be:

[0113] loss sum = loss1 + loss2

[0114] Wherein, loss sum is the total loss function, loss1 is the first loss function, and loss2 is the second loss function.

[0115] 408. Based on the total loss function, the model parameters of the encoder and the decoder are adjusted.

[0116] For example, the model parameters of the encoder and the decoder can be adjusted by using BP algorithm.

[0117] In this embodiment, as shown in Figure 6 The FFN and the softmax layer can be collectively referred to as the selector, and the decoder can also be referred to as the generator.

[0118] The selector uses a relatively simple feedforward neural network to project the semantic features (token embedding) encoded by the 5Encoder into the label space, and then uses softmax to predict the probability value of each token. The loss function loss1 of the selector is calculated using KL divergence.

[0119] The generator uses T5 Decoder to generate the completed sentence. The generation effect of T5 is very good. The semantic features (token embedding) encoded by T5Encoder are sent into the Decoder for decoding generation. The loss function loss2 of the generator is calculated using maximum likelihood.

[0120] The loss functions of the selector and the generator are added and jointly trained. Unlike the two-stage explicit modeling, the joint modeling of the selector and the generator can implicitly utilize the knowledge of the selector and provide the knowledge to the generator. Specifically, the loss of the selector can prompt the T5 encoder to pay more attention to the omitted important words in the context, and this attention can play a role in generation. Because the T5 encoder pays more attention to the omitted words, the important words are more likely to be considered in the query generation in the decoder.

[0121] In this embodiment, the joint generation architecture of the selector and the generator is adopted, which is simple, effective and smooth. Due to the use of implicit modeling, compared with explicit modeling, the error accumulation can be reduced and the model accuracy can be improved. Since the T5 model has good generation effect, the encoder and decoder of the T5 model are used in this embodiment, which can make the completed dialogue sentence more fluent.

[0122] Figure 6 is a schematic diagram according to the fifth embodiment of the present disclosure. As shown in Figure 5 The dialogue sentence completion model includes an encoder and a decoder, and the device 600 includes an encoding module 601, a selection module 602, a decoding module 603, a construction module 604, and an adjustment module 605.

[0123] The encoding module 601 is configured to use the encoder to perform encoding processing on a multi-round dialogue sentence sample to generate semantic features, wherein the multi-round dialogue sentence sample includes a to-be-completed sentence sample; the selection module 602 is configured to generate a predicted probability value based on the semantic features; the decoding module 603 is configured to use the decoder to perform decoding processing on the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; the construction module 604 is configured to construct a total loss function based on the predicted probability value and the predicted complete sentence; and the adjustment module 605 is configured to adjust model parameters of at least one of the encoder and the decoder based on the total loss function.

[0124] In this embodiment, the predicted probability value is generated based on the semantic features, the predicted complete sentence is generated based on the semantic features, the total loss function is constructed based on the predicted probability value and the predicted complete sentence, and the model parameters are adjusted based on the total loss function. During the training of the dialogue sentence completion model, the missing units can be marked, thereby improving the accuracy of the dialogue sentence completion model. In addition, the predicted probability value and the predicted complete sentence are both obtained based on the semantic features, which can be considered as implicit modeling. Compared with the way of explicitly generating the predicted probability value and the predicted complete sentence by using different models respectively, the model error accumulation can be reduced, and the accuracy of the dialogue sentence completion model can be further improved.

[0125] In some embodiments, the selection module 602 is further configured to: adopt a feedforward neural network to perform feedforward processing on the semantic features to generate mapping features; and adopt a normalization layer to perform normalization processing on the mapping features to generate the predicted probability value.

[0126] In this embodiment, FFN is adopted to simplify the operation, reduce the training difficulty, and improve the model training efficiency.

[0127] In some embodiments, the construction module 604 is further configured to: construct a first loss function based on the predicted probability value and a true probability value of the processing unit being a missing unit; construct a second loss function based on the predicted complete sentence and the true complete sentence; and construct the total loss function based on the first loss function and the second loss function.

[0128] In this embodiment, as shown in Figure 7 The FFN and the softmax layer can be collectively referred to as a selector, and the decoder can also be referred to as a generator.

[0129] The selector adopts a relatively simple feedforward neural network to project the semantic features (token embedding) encoded by the 5Encoder into a label space, and then uses softmax to predict the probability value of each token. The loss function loss1 of the selector is calculated using KL divergence.

[0130] The generator adopts the T5 Decoder to generate the completed sentence. The generation effect of T5 is very good. The semantic features (token embedding) encoded by the T5Encoder are sent to the Decoder for decoding and generation. The loss function loss2 of the generator is calculated using maximum likelihood.

[0131] The loss functions of the selector and the generator are added together for joint training. Unlike the two-stage explicit modeling, the joint modeling of the selector and the generator can implicitly utilize the knowledge of the selector and provide this knowledge to the generator. Specifically, the loss of the selector can prompt the T5 Encoder to pay more attention to the omitted important words in the context, and this attention will play a role in generation. Because the T5 Encoder pays more attention to the omitted words, the important words will be more considered in the query generation in the Decoder.

[0132] In some embodiments, the multi-turn dialogue sentence sample further comprises: a context sentence sample of the to-be-completed sentence sample; the context sentence sample is separated by a first separator, the to-be-completed sentence sample is separated by a second separator, and the first separator is different from the second separator.

[0133] In the embodiment, the context sentence sample and the to-be-completed sentence sample are separated by different separators, which can enable the model to identify whether the input sentence sample is a context sentence sample or a to-be-completed sentence sample based on the separators, thereby improving the accuracy of the model.

[0134] In some embodiments, the encoder is an encoder in a T5 model, and the decoder is a decoder in the T5 model.

[0135] Since the T5 model has good generation effect, the encoder and the decoder of the T5 model are adopted in the embodiment, which can make the completed dialogue sentence more fluent.

[0136] Figure 7 is a schematic diagram according to the sixth embodiment of the present disclosure. As shown in Figure 8 The dialogue sentence completion device 700 comprises: an acquisition module 701, an encoding module 702, and a decoding module 703.

[0137] The acquisition module 701 is configured to acquire a multi-turn dialogue sentence, the multi-turn dialogue sentence comprising: a to-be-completed sentence; the encoding module 702 is configured to extract semantic features of the multi-turn dialogue sentence by using an encoder; and the decoding module 703 is configured to generate a completed dialogue sentence corresponding to the to-be-completed sentence based on the semantic features by using a decoder.

[0138] The dialogue sentence completion model can comprise an encoder and a decoder, and the encoder and the decoder can be trained by using the method shown in the above embodiments.

[0139] In the embodiment, the dialogue sentence completion model obtained by using the training method is used for dialogue sentence completion processing to obtain a completed dialogue sentence. Since the dialogue sentence completion model has high accuracy, the completed dialogue sentence obtained in the embodiment has high accuracy.

[0140] It can be understood that the same or similar contents in different embodiments in the embodiments of the present disclosure can be mutually referred to.

[0141] It can be understood that "first", "second", and the like in the embodiments of the present disclosure are only used for distinction, and do not represent importance level, time sequence, and the like.

[0142] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information comply with relevant laws and regulations and do not violate public order and good customs.

[0143] According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0144] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device 800 is intended to represent various forms of digital computers, such as laptops, desktops, tablets, servers, blades, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present disclosure described and / or claimed in this document.

[0145] As shown in ​ The electronic device 800 includes a computing unit 801 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 802 or a computer program loaded into a random access memory (RAM) 803 from a storage unit 808. Various programs and data required for the operation of the electronic device 800 can also be stored in the RAM 803. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0146] Various components in the electronic device 800 are connected to the I / O interface 805, including an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, a speaker, etc.; the storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0147] The computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, and the like. The computing unit 801 performs various methods and processes described above, such as the training method of the dialogue utterance completion model or the dialogue utterance completion method. In some embodiments, the training method of the dialogue model can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the training method of the dialogue utterance completion model or the dialogue utterance completion method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the training method of the dialogue utterance completion model or the dialogue utterance completion method by any other suitable means, such as by means of firmware.

[0148] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0149] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces a means for implementing the functions / acts specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0150] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0151] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0152] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0153] The computer system can include clients and servers. This relationship can be. The servers are generally remote from the users and can be accessed via the Internet using a communication network. The relationship can be a client-server relationship over a communications network, and as such, the servers can be accessed by the clients using computer programs. The servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are mainframe products in the cloud computing service system, and solve the defects of large management difficulty and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS").

[0154] It should be understood that the various forms of flow shown above can be reordered, added to, or have steps deleted. For example, the steps described in the present disclosure can be performed in parallel, in series, or in a different order, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.

[0155] The above detailed description does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for training a dialogue utterance completion model, the dialogue completion model comprising: An encoder and a decoder, the method comprising: encoding, by the encoder, a multi-turn dialogue sentence sample to generate semantic features, wherein the multi-turn dialogue sentence sample comprises a to-be-completed sentence sample; based on the semantic features, generating a prediction probability value, comprising: using a feedforward neural network to perform feedforward processing on the semantic features to generate mapping features; using a normalization layer to perform normalization processing on the mapping features to generate the prediction probability value; decoding, by the decoder, the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; based on the prediction probability value and the predicted complete sentence, constructing a total loss function; based on the total loss function, adjusting the model parameters of at least one of the encoder and the decoder; The prediction probability value is used to indicate the probability that the processing unit is a missing unit, the processing unit is a text unit in the real complete sentence corresponding to the to-be-completed sentence sample, and the missing unit is a text unit missing in the to-be-completed sentence sample relative to the real complete sentence.

2. The method of claim 1, wherein, The total loss function is constructed based on the prediction probability value and the predicted complete sentence, comprising: based on the prediction probability value and the real probability value that the processing unit is a missing unit, constructing a first loss function; based on the predicted complete sentence and the real complete sentence, constructing a second loss function; based on the first loss function and the second loss function, constructing the total loss function.

3. The method of any one of claims 1-2, wherein The multi-turn dialogue sentence sample further comprises a context sentence sample of the to-be-completed sentence sample; The context sentence sample is separated by a first delimiter, the to-be-completed sentence sample is separated by a second delimiter, and the first delimiter is different from the second delimiter.

4. The method of claim 1, wherein The encoder is an encoder in a T5 model; The decoder is a decoder in the T5 model.

5. A dialogue completion method, comprising: obtaining a multi-turn dialogue sentence, the multi-turn dialogue sentence comprising a to-be-completed sentence; using an encoder to extract semantic features of the multi-turn dialogue sentence; using a decoder to generate a completed dialogue sentence corresponding to the to-be-completed sentence based on the semantic features; wherein the encoder and the decoder are trained using the method of any one of claims 1-4. 6.A device for training a dialogue sentence completion model, the dialogue sentence completion model comprising: An encoder and a decoder, the apparatus comprising: An encoding module for encoding, by the encoder, a multi-turn dialogue sentence sample to generate semantic features, wherein the multi-turn dialogue sentence sample comprises a to-be-completed sentence sample; A selection module for generating a prediction probability value based on the semantic features; A decoding module for decoding, by the decoder, the semantic features to generate a predicted complete sentence corresponding to the to-be-completed sentence sample; A construction module for constructing a total loss function based on the prediction probability value and the predicted complete sentence; an adjusting module configured to adjust model parameters of at least one of the encoder and the decoder based on the total loss function; the selecting module is further configured to: feed forward the semantic features by using a feed forward neural network to generate mapping features; normalize the mapping features by using a normalization layer to generate the predicted probability values; the predicted probability values are used to indicate a probability that a processing unit is a missing unit, the processing unit is a text unit in a real complete sentence corresponding to the sentence sample to be completed, and the missing unit is a text unit missing in the real complete sentence relative to the sentence sample to be completed.

7. The apparatus of claim 6, wherein, the constructing module is further configured to: construct a first loss function based on the predicted probability values and a real probability value that the processing unit is a missing unit; construct a second loss function based on the predicted complete sentence and the real complete sentence; construct the total loss function based on the first loss function and the second loss function.

8. The apparatus of any one of claims 6-7, wherein the multi-turn dialogue sentence sample further comprises a context sentence sample of the sentence sample to be completed; the context sentence sample is separated by a first separator, the sentence sample to be completed is separated by a second separator, and the first separator is different from the second separator.

9. The apparatus of any one of claims 6-7, wherein the encoder is an encoder in a T5 model; the decoder is a decoder in the T5 model.

10. A dialogue sentence completion apparatus, comprising: an obtaining module configured to obtain a multi-turn dialogue sentence, the multi-turn dialogue sentence comprising a sentence to be completed; an encoding module configured to extract semantic features of the multi-turn dialogue sentence by using an encoder; a decoding module configured to generate a completed dialogue sentence corresponding to the sentence to be completed based on the semantic features by using a decoder; wherein the encoder and the decoder are trained by using the method of any one of claims 1-4.

11. An electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5.

12. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-5.

13. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-5.

Citation Information

Patent Citations

  • Information processing method and device, electronic equipment and storage medium

    CN111783429A

  • Dialogue processing method, question rewriting model training method and device

    CN114626385A