Model training method and apparatus, storage medium, and electronic device

Through the adversarial training generator and source discriminator, independent expressions are merged into natural and smooth sentences, solving the problem of excessively stiff content of the chatbot reply and improving the user's chat experience.

WO2025035523A1PCT designated stage expired Publication Date: 2025-02-20ZHEJIANG LAB
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/118552
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-08-11
Filing Date
2023-09-13
Publication Date
2025-02-20

AI Technical Summary

Technical Problem

When the chatbot responds to user questions, the content of introducing new topics is too stiff, affecting the user's chat experience.

Method used

By splitting the original sentence into independent expressions and using the generator and source discriminator for adversarial training, independent expressions are fused to generate natural and smooth sentences.

Benefits of technology

The generated fusion sentence order is normal, the content is coherent and natural, and it is not rigid, and the discrimination results of the source discriminator are more accurate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023118552_20022025_PF_FP_ABST
    Figure CN2023118552_20022025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a model training method and apparatus, a storage medium, and an electronic device. The method comprises: inputting a plurality of independent expression sentences into a generator of a model to obtain a fused sentence, and adding the fused sentence into a training data set; inputting a sentence to be discriminated in the training data set into a source discriminator of the model, so as to determine a discrimination result of whether the sentence to be discriminated is an original sentence; on the basis of the discrimination result, respectively determining source discrimination loss of the source discriminator and source generation loss of the generator; and training the model on the basis of the source generation loss and the source discrimination loss, wherein the generator of the model is used for fusing the plurality of independent expression sentences in reply to a user.
Need to check novelty before this filing date? Find Prior Art

Description

Model training method, device, storage medium and electronic device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202311010097.X filed on August 11, 2023, which is incorporated herein by reference. Technical Field

[0003] The present disclosure relates to the field of artificial intelligence, and in particular to a method, device, storage medium, and electronic device for model training. Background Art

[0004] With the development of artificial intelligence, intelligent robots are being applied in various fields, such as chatbots. To provide users with a good chat experience, chatbots can introduce new topics while responding to user questions. Since the response content and the new topic may contain the same personal pronouns or related content, simply piecing together the response content and the new topic will result in a rather awkward chat content presented to the user. For example, if a user asks, "What patents does Zhang San have?" the chatbot might reply, "Zhang San's patents include..." To introduce a new topic, the chatbot might also add the reply, "Zhang San has participated in long-distance running." Obviously, the chatbot's response to the user is, "Zhang San's patents include...", and Zhang San has participated in long-distance running." However, this response is quite awkward and affects the user's chat experience.

[0005] Summary of the Invention

[0006] The present disclosure provides a model training method, device, storage medium and electronic device to solve the above-mentioned problems existing in the related art.

[0007] The present disclosure provides a model training method, comprising:

[0008] Splitting the original sentence into several independent expression sentences, and adding the several independent expression sentences to the training data set;

[0009] Inputting each independent expression sentence into the generator of the model, fusing the independent sentences through the generator to obtain a fused sentence, and adding the fused sentence to the training data set;

[0010] Inputting the sentence to be determined in the training data set into the source discriminator of the model to obtain a determination result output by the source discriminator to determine whether the sentence to be determined is an original sentence;

[0011] Determining a source discrimination loss of the source discriminator based on a discrimination result of the source discriminator and the source label of the sentence to be discriminated, and determining a source generation loss of the generator based on the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated;

[0012] The model is adversarially trained based on the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse several independent expression sentences in reply to the user.

[0013] Optionally, determining the source generation loss of the generator according to the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated includes:

[0014] If the discrimination result of the source discriminator is inconsistent with the source label of the sentence to be discriminated, determining the word order difference between the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated;

[0015] Based on the word order difference, a source generation loss of the generator is determined.

[0016] Optionally, the method further includes:

[0017] Inputting the sentence to be determined and the independent expression sentence corresponding to the sentence to be determined into the semantic discriminator of the model to obtain a determination result output by the semantic discriminator as to whether the semantics of the sentence to be determined are consistent with the semantics of the independent expression sentence corresponding to the sentence to be determined;

[0018] According to the discrimination result output by the semantic discriminator, the model is subjected to adversarial training.

[0019] Optionally, adversarial training is performed on the model according to the discrimination result output by the semantic discriminator, including:

[0020] Determining the semantic discrimination loss of the semantic discriminator according to the discrimination result output by the semantic discriminator and the semantic label of the sentence to be discriminated; and determining the semantic generation loss of the generator according to the discrimination result output by the semantic discriminator, the semantic label of the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated;

[0021] The model is subjected to adversarial training according to the semantic generation loss and the semantic discrimination loss.

[0022] Optionally, determining the semantic generation loss of the generator according to the discrimination result of the semantic discriminator, the semantic label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated includes:

[0023] If the discrimination result of the semantic discriminator is inconsistent with the semantic label of the sentence to be discriminated, determining the semantic difference between the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated;

[0024] According to the semantic difference, a semantic generation loss of the generator is determined.

[0025] Optionally, the method further includes:

[0026] Several independent sentences for replying to users are input into the generator of the model to obtain a fused sentence output by the generator, and the fused sentence is displayed.

[0027] Optionally, the generator includes a bidirectional autoregressive transformer; and the source discriminator includes a BERT model and a linear classifier.

[0028] The present disclosure provides a model training device, comprising:

[0029] An independent expression sentence acquisition module is used to split the original sentence into a plurality of independent expression sentences and add the plurality of independent expression sentences to the training data set;

[0030] a fused sentence acquisition module, configured to input each independent expression sentence into the generator of the model, so as to fuse the independent sentences through the generator to obtain a fused sentence, and add the fused sentence to the training data set;

[0031] A word order discrimination result module is used to input the sentence to be judged in the training data set into the source discriminator of the model to obtain a discrimination result output by the source discriminator to determine whether the sentence to be judged is the original sentence;

[0032] a loss determination module, configured to determine a source discrimination loss of the source discriminator based on a discrimination result of the source discriminator and a source label of the sentence to be discriminated, and to determine a source generation loss of the generator based on the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and an original sentence corresponding to the sentence to be discriminated;

[0033] A model training module is used to perform adversarial training on the model based on the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse several independent expression sentences in reply to the user.

[0034] Optionally, the loss determination module is specifically used to determine the word order difference between the sentence to be judged and the original sentence corresponding to the sentence to be judged if the judgment result of the source discriminator is inconsistent with the source label of the sentence to be judged; and determine the source generation loss of the generator based on the word order difference.

[0035] Optionally, the device further comprises:

[0036] The semantic training module is used to input the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged into the semantic discriminator of the model to obtain a judgment result output by the semantic discriminator to judge whether the semantics of the sentence to be judged are consistent with the semantics of the independent expression sentence corresponding to the sentence to be judged; and the model is adversarially trained according to the judgment result output by the semantic discriminator.

[0037] Optionally, the semantic judgment module is specifically used to determine the semantic discrimination loss of the semantic discriminator based on the discrimination result output by the semantic discriminator and the semantic label of the sentence to be judged; and to determine the semantic generation loss of the generator based on the discrimination result of the semantic discriminator, the semantic label of the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged; and to perform adversarial training on the model based on the semantic generation loss and the semantic discrimination loss.

[0038] Optionally, the semantic judgment module is specifically used to determine the semantic difference between the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged if the judgment result of the semantic discriminator is inconsistent with the semantic label of the sentence to be judged; and determine the semantic generation loss of the generator based on the semantic difference.

[0039] Optionally, the device further comprises:

[0040] An application module is used to input a number of independent sentences for replying to users into the generator of the model to obtain a fused sentence output by the generator, and display the fused sentence.

[0041] Optionally, the generator includes a bidirectional autoregressive transformer; and the source discriminator includes a BERT model and a linear classifier.

[0042] The present disclosure provides a computer-readable storage medium storing a computer program, which implements the above-mentioned model training method when executed by a processor.

[0043] The present disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned model training method when executing the program.

[0044] At least one of the above technical solutions adopted in the present disclosure can achieve the following beneficial effects:

[0045] It can be seen from the model training method provided in the present disclosure that the method conducts adversarial training on the generator and source discriminator in the model, so that the generator generates a fusion sentence close to the original sentence, obtains a sentence with normal word order and natural and unstiff content connection, and the source discriminator can more accurately judge whether the input sentence is the original sentence. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:

[0047] FIG1 is a flow chart of a model training method according to an embodiment of the present disclosure;

[0048] FIG2 is a schematic diagram of the internal structure of a generative adversarial network model according to an embodiment of the present disclosure;

[0049] FIG3 is a schematic diagram of the internal structure of a generator according to an embodiment of the present disclosure;

[0050] FIG4 is a schematic diagram of the internal structure of a source discriminator according to an embodiment of the present disclosure;

[0051] FIG5 is a schematic diagram of the internal structure of a generative adversarial network model according to another embodiment of the present disclosure;

[0052] FIG6 is a schematic diagram of the internal structure of a semantic discriminator according to an embodiment of the present disclosure;

[0053] FIG7 is a schematic diagram of a model training device according to an embodiment of the present disclosure;

[0054] FIG8 is a schematic structural diagram of an electronic device corresponding to FIG1 according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0055] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.

[0056] The technical solutions provided by various embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0057] FIG1 is a flow chart of a model training method according to an embodiment of the present disclosure, which includes the following steps S100 to S110 .

[0058] S100: Split the original sentence into a plurality of independent expression sentences, and add the plurality of independent expression sentences to a training data set.

[0059] Typically, when chatbots respond to user questions or introduce new topics, they simply splice together multiple related pieces of content, resulting in a rather awkward presentation. For example, a chatbot might respond to a user with, "Zhang San is 188 cm tall and loves playing basketball." Therefore, the present disclosure provides a method for model training. The chatbot can use this model to fuse together several related sentences, and the resulting fused content is fluent and coherent. The implementation entity of the present disclosure can be a server for training the model, or a chatbot or other electronic device for responding to users. For ease of explanation, the following describes a model training method provided by the present disclosure, using the server as the implementation entity.

[0060] The present disclosure trains a generative adversarial network model to obtain content for replying to users through a generator in the generative adversarial network.

[0061] FIG2 is a schematic diagram of the internal structure of a generative adversarial network model according to an embodiment of the present disclosure, as shown in FIG2 .

[0062] To train the generator in the generative adversarial network model, it is first necessary to obtain training samples for the generator. These training samples include independent expression sentences. When obtaining independent expression sentences, the server can split the original sentence into several independent expression sentences. In other words, the independent expression sentences can be obtained from the original sentence by replacing the pronouns and abbreviations in the original sentence with the full name of the entity referred to by the pronoun, and replacing the conjunctions used to connect the sentences in the original sentence with periods.

[0063] For example, the original sentence is: "Madonna said, 'Give me a pair of high heels, and I'll conquer the world...' Men might scorn it, but I believe in her." Replacing "I" in "Give me a pair of high heels, and I'll conquer the world...'" and "her" in "But I believe in her" with "Madonna" yields the independent expression: "Madonna said, 'Give Madonna a pair of high heels, and Madonna will conquer the world...' Men might scorn it, but I believe in Madonna." The original sentence comprises any sentence in the coreference resolution dataset. It should be noted that the original sentence can be multiple sentences or a single sentence, and this is not a limitation of this disclosure. The coreference resolution task is the process of grouping different referents representing the same entity into an equivalent set. Any sentence in the coreference resolution dataset can be a coreference resolution task to be solved. That is, the original sentence can include the full name, alias, and abbreviation of an entity, and the full name, alias, and abbreviation of the entity are the referents. Continuing with the above example, Madonna Ciccone is an entity, and is the full name of the entity Madonna Ciccone. "Madonna" is the abbreviation of the entity Madonna Ciccone, and the "I" in "Give me a pair of high heels and I can conquer the world..." is a nickname for the entity Madonna Ciccone.

[0064] In order to facilitate the subsequent training of the discriminator of the generative adversarial network model and determine the labels of several independent expression sentences, the server can also add the original sentence to the training dataset.

[0065] S102: Inputting each independent expression sentence into the generator of the model, so as to fuse the independent sentences through the generator to obtain a fused sentence, and adding the fused sentence to the training data set.

[0066] In one or more embodiments of the present disclosure, the generative adversarial network model further includes a source discriminator. To determine a source discrimination loss for the source discriminator, thereby improving the accuracy of the discrimination result of the source discriminator through the source discrimination loss, and to determine a source generation loss for the generator, thereby improving the fluency of the content of the fused sentence generated by the generator through the source generation loss, the server may input each independent expression sentence into the generator of the model, so that the generator can fuse the independent sentences to obtain a fused sentence, and then add the fused sentence to the training dataset.

[0067] Specifically, FIG3 is a schematic diagram of the internal structure of a generator according to an embodiment of the present disclosure, as shown in FIG3 .

[0068] The generator includes bidirectional and auto-regressive transformers (BARTs). The server inputs each independent expression sentence into the generator's encoder and obtains a fused sentence using the generator's decoder. When inputting each independent expression sentence into the generator, the independent expression sentence is separated by a period, question mark, or exclamation mark, starting with the symbol [CLS]. The separated independent expression sentences are then concatenated in sequence, separated by [SEP], and concatenated at the end with [SEP]. Using the above example: "Madonna said, 'Give Madonna a pair of high heels, and Madonna will conquer the world...' Men may scorn it, but I believe in her." The input format for the generator is: "[CLS] Madonna said, 'Give Madonna a pair of high heels, and Madonna will conquer the world...' [SEP] Men may scorn it, but I believe in Madonna. [SEP]." The server can determine the input format for each independent expression sentence based on the type of the generator, and this disclosure does not limit this.

[0069] S104: Inputting the sentence to be determined in the training data set into the source discriminator of the model to obtain a determination result output by the source discriminator to determine whether the sentence to be determined is an original sentence.

[0070] To determine the source discrimination loss for the source discriminator and train it based on this loss, the server first inputs the sentence to be discriminated from the training dataset into the source discriminator of the model to obtain the source discriminator's output, which determines whether the sentence to be discriminated is the original sentence. The source discrimination loss is then determined based on this result.

[0071] Specifically, FIG4 is a schematic diagram of the internal structure of a source discriminator according to an embodiment of the present disclosure, as shown in FIG4 .

[0072] The source discriminator includes a bidirectional encoder representation from a transformer, namely a BERT (Bidirectional Encoder Representation from Transformers, BERT) model and a linear classifier. When the server inputs the sentence to be identified into the source discriminator, the sentence to be identified is first processed by the BERT model, and then passes through the linear classifier, and finally outputs the discrimination result of the source discriminator. Among them, the input format of the sentence to be identified into the source discriminator can be the same as the input format of the sentence to be identified into the generator in step S102, and this disclosure will not go into details. The output of the source discriminator is a binary classification result, and the meaning corresponding to the discrimination result output by the source discriminator can be set as needed, and this disclosure does not limit this. For example, when the discrimination result output by the source discriminator is 1, it indicates that the sentence to be identified is the original sentence, and when the discrimination result output by the source discriminator is 0, it indicates that the sentence to be identified is not the original sentence. It can also be set that when the discrimination result output by the source discriminator is 0, it indicates that the sentence to be judged is the original sentence, and when the discrimination result output by the source discriminator is 1, it indicates that the sentence to be judged is not the original sentence.

[0073] S106: Determine the source discrimination loss of the source discriminator according to the discrimination result of the source discriminator and the source label of the sentence to be discriminated.

[0074] In one or more embodiments of the present disclosure, the source label of the sentence to be determined refers to the sentence type of the sentence to be determined. For example, if the sentence to be determined is an original sentence, the source label of the sentence to be determined is 1. If the sentence to be determined is a fused sentence, the source label of the sentence to be determined is 0. The source label can be set as needed, but it needs to be consistent with the meaning expressed by the discrimination result of the source discriminator. For example, if the source label when the sentence to be determined is an original sentence is set to 1, the discrimination result output by the source discriminator when determining that the sentence to be determined is an original sentence is also 1. If it outputs 0, the source discriminator has made an incorrect judgment. If the discrimination result of the source discriminator is consistent with the source label of the sentence to be determined, the source discriminator has made a correct judgment. When the discrimination result of the source discriminator is inconsistent with the source label of the sentence to be determined, the source discrimination loss can be determined according to the following formula:

[0075] Among them, loss1 is the source discrimination loss of the source discriminator, is the sample generated by the generator, that is, the fusion sentence, and X is the real sample, that is, the original sentence.

[0076] S108: Determine the source generation loss of the generator according to the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated.

[0077] Specifically, if the source discriminator's discriminant result is inconsistent with the source label of the sentence to be discriminated, the word order difference between the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated is determined, and the source generation loss of the generator is determined based on the word order difference. Of course, the source generation loss of the generator can also be determined based on other differences between the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated, and this disclosure does not limit this.

[0078] S110: performing adversarial training on the model according to the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse a plurality of independent expression sentences in reply to the user.

[0079] Specifically, the source discriminator is trained with the source discrimination loss as the source discrimination training objective, and the generator is trained with the source generation loss as the source generation training objective. The trained source discriminator not only enables the generator to generate more natural fusion sentences but can also be used to classify input sentences.

[0080] The server may also alternately train the generator and the source discriminator, that is, train the source discriminator once based on the source discriminator loss. After the source discriminator completes one training, it determines the source generation loss of the generator, and trains the generator again based on the source generation loss. When the generator completes one training, the server completes one iteration.

[0081] Based on a model training method shown in Figure 1, this method conducts adversarial training on the generator and source discriminator in the model, so that the generator generates fused sentences close to the original sentences, obtains sentences with normal word order and natural content connection, and the source discriminator can more accurately determine whether the input sentence is the original sentence.

[0082] Before executing step S102, the server may further train the generator using maximum likelihood estimation or other methods to make it more stable during adversarial training. When the generator is trained using maximum likelihood estimation, the loss of the generator is:

[0083] Among them, m is the length of the fused sentence, t is the tth character, is the t-th predicted character, y t is the tth label character, The character that has been generated before t.

[0084] Of course, the generator may not be trained before executing step S102, and this disclosure does not impose any limitation on this.

[0085] When executing step S102, since the model usually does not support direct text recognition, when each independent expression sentence is input into the generator, each independent expression sentence is first converted into an integer index or other recognizable format that can be recognized by the generator.

[0086] Similarly, when the sentence to be judged is input into the source discriminator, the same processing is required, which will not be further described in this disclosure. Furthermore, since the source discriminator may not be able to differentiate when recognizing integer index lists, it may not be able to output a judgment result. Therefore, the Gumbel-softmax technique can be used to solve this problem.

[0087] Specifically, the generation process of the generator can be expressed as follows: 0 =Embedding_Lookup(s)+Position_Encoding(s) M=BART_Encode(L 0 ) v t =BART_Decode(M, R <t )

[0088] Among them, L 0 is the input of layer 0, s is the integer index list of the input sentence, Embedding_Lookup is the operation to obtain the word embedding matrix, Position_Encoding is the operation to obtain the position encoding matrix, M is the result matrix of the BART model encoder, BART_Encode is the encoder operation of the BART model, R <t is the matrix generated before time t, BART_Decode is the decoder operation of the BART model, v t is the generated time vector, MLP is a feedforward neural network, is the distribution vector on the vocabulary at time t, is a vector of length equal to the vocabulary size, The value of the i-th dimension is equal to g is a vector of length equal to the vocabulary size, with each dimension of g independently sampled from a standard Gumbel distribution, and τ being the temperature parameter. Using the Straight-Throuth technique, the gradient is calculated using the above formula only during gradient backpropagation.

[0089] FIG5 is a schematic diagram of the internal structure of a generative adversarial network model according to another embodiment of the present disclosure, as shown in FIG5 .

[0090] Although the model's generator can generate fused sentences with normal word order after training using the above method, and the content of the fused sentences can have different wording and arrangement, the semantics of the fused sentences may differ from the corresponding independent sentences. This may include missing the semantics of an independent sentence, tampering with the semantics of an independent sentence, and adding information that is not expressed in all independent sentences. Therefore, the model also includes a semantic discriminator.

[0091] FIG6 is a schematic diagram of the internal structure of a semantic discriminator according to an embodiment of the present disclosure, as shown in FIG6 .

[0092] In one or more embodiments of the present disclosure, the semantic discriminator includes a Span BERT model and a linear classifier. To obtain a fused sentence with the same semantics as an independent expression sentence, the server inputs the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated into the semantic discriminator of the model, obtaining a discriminant result output by the semantic discriminator to determine whether the semantics of the sentence to be discriminated are consistent with the semantics of the independent expression sentence corresponding to the sentence to be discriminated. The model is then subjected to adversarial training based on the discriminant result output by the semantic discriminator.

[0093] Specifically, the server determines the semantic discrimination loss of the semantic discriminator based on the discrimination result output by the semantic discriminator and the semantic label of the sentence to be discriminated. The input format of the semantic discriminator can be the same as the input format of the generator, such as [CLS] original sentence [SEP] independent expression sentence, "[CLS] fused sentence [SEP] independent expression sentence," or [CLS] interference sentence [SEP] independent expression sentence. The semantic label of the sentence to be discriminated refers to whether the semantics of the sentence to be discriminated are consistent with the semantics of the independent expression sentence corresponding to the sentence to be discriminated. If they are consistent, the semantic label is 1, otherwise it is 0. It can be set as needed.

[0094] The server can determine the semantic discriminative loss through the following formula:

[0095] Among them, loss2 is the semantic discrimination loss of the semantic discriminator, Y is the interference sentence, and Z is the independent expression sentence.

[0096] The output of the semantic discriminator is a binary classification result. The meaning corresponding to the discriminant result output by the discriminator can be set as needed, and this disclosure does not impose any restrictions on this. It should be noted that the training data set may also include interference sentences, that is, sentences obtained by replacing the pronouns in the original sentence with words that are not referred to by the pronouns. For example: replace the "I" in "Madonna said: "Give me a pair of high heels, and I can conquer the world..." with Zhang San, Li Si, etc.

[0097] While determining the semantic discrimination loss, the server can also determine the semantic generation loss of the generator based on the discrimination result of the semantic discriminator, the semantic label of the sentence to be discriminated, and the independent expression sentence corresponding to the sentence to be discriminated. That is to say, if the discrimination result of the semantic discriminator is inconsistent with the semantic label of the sentence to be discriminated, the semantic difference between the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated is determined. Based on the semantic difference, the semantic generation loss of the generator is determined. Finally, the generative adversarial network model is trained based on the semantic generation loss and the semantic discrimination loss. Among them, the loss of the generative adversarial network model is:

[0098] Among them, loss is the loss of the generative adversarial network model, a and b are weight parameters, which can be set as needed.

[0099] In addition, the server can train the generator, source discriminator and semantic discriminator of the adversarial network model at the same time, or train the generator and source discriminator first, and then train the semantic discriminator. This disclosure does not limit this.

[0100] If the server trains the generator and source discriminator first, and then trains the semantic discriminator, it needs to ensure that the source discriminator has been trained before training the semantic discriminator.

[0101] Once the generative adversarial network model is trained, the server can input several independent sentences used to reply to the user into the model's generator to generate a fused sentence, which is then displayed. This fused sentence is not only coherent and natural in content, but also semantically consistent with the independent sentences. Furthermore, a source discriminator can be used to detect sentence fluency, and a semantic discriminator can be used to determine whether two sentences have similar semantics.

[0102] The above are one or more implementation methods of the present disclosure. Based on the same idea, the present disclosure also provides a corresponding model training device, as shown in Figure 7.

[0103] FIG7 is a schematic diagram of a model training device according to an embodiment of the present disclosure, wherein the device includes:

[0104] An independent expression sentence acquisition module 700 is used to split the original sentence into a plurality of independent expression sentences and add the plurality of independent expression sentences to the training data set;

[0105] A fused sentence acquisition module 702 is configured to input each independent expression sentence into the generator of the model, so as to fuse the independent sentences through the generator to obtain a fused sentence, and add the fused sentence to the training data set;

[0106] The word order discrimination result module 704 is used to input the sentence to be discriminated in the training data set into the source discriminator of the model to obtain the discrimination result output by the source discriminator to determine whether the sentence to be discriminated is the original sentence;

[0107] a loss determination module 706 for determining a source discrimination loss of the source discriminator based on the discrimination result of the source discriminator and the source label of the sentence to be discriminated, and determining a source generation loss of the generator based on the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated;

[0108] The model training module 708 is used to perform adversarial training on the model based on the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse several independent expression sentences in reply to the user.

[0109] Optionally, the loss determination module 706 is specifically used to determine the word order difference between the sentence to be judged and the original sentence corresponding to the sentence to be judged if the discrimination result of the source discriminator is inconsistent with the source label of the sentence to be judged; and determine the source generation loss of the generator based on the word order difference.

[0110] Optionally, the device further comprises:

[0111] The semantic training module 710 is used to input the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged into the semantic discriminator of the model to obtain a judgment result output by the semantic discriminator to judge whether the semantics of the sentence to be judged are consistent with the semantics of the independent expression sentence corresponding to the sentence to be judged; and perform adversarial training on the model according to the judgment result output by the semantic discriminator.

[0112] Optionally, the semantic judgment module 710 is specifically used to determine the semantic discrimination loss of the semantic discriminator based on the discrimination result output by the semantic discriminator and the semantic label of the sentence to be judged; and to determine the semantic generation loss of the generator based on the discrimination result of the semantic discriminator, the semantic label of the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged; and to perform adversarial training on the model based on the semantic generation loss and the semantic discrimination loss.

[0113] Optionally, the semantic judgment module 710 is specifically used to determine the semantic difference between the sentence to be judged and the independent expression sentence corresponding to the sentence to be judged if the judgment result of the semantic discriminator is inconsistent with the semantic label of the sentence to be judged; and determine the semantic generation loss of the generator based on the semantic difference.

[0114] Optionally, the device further comprises:

[0115] The application module 712 is used to input a number of independent sentences for replying to the user into the generator of the model to obtain a fused sentence output by the generator, and display the fused sentence.

[0116] Optionally, the generator includes a bidirectional autoregressive transformer; and the source discriminator includes a BERT model and a linear classifier.

[0117] The present disclosure also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute a model training method provided in Figure 1 above.

[0118] The present disclosure also provides a structural diagram of an electronic device corresponding to FIG1 , as shown in FIG8 . As shown in FIG8 , at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the model training method described in FIG1 above.

[0119] Of course, in addition to software implementation, this disclosure does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0120] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages ​​and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0121] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

[0122] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0123] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing the present disclosure, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0124] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0125] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0126] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0128] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0129] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0130] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0131] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0132] Those skilled in the art will appreciate that embodiments of the present disclosure may be provided as methods, systems, or computer program products. Thus, the present disclosure may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0133] The present disclosure may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present disclosure may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0134] The various embodiments of this disclosure are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.

[0135] The foregoing is merely an embodiment of the present disclosure and is not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure are intended to be included within the scope of the claims of the present disclosure.

Claims

1. A model training method, comprising: Splitting the original sentence into a plurality of independent expression sentences, and adding the plurality of independent expression sentences to the training data set; Inputting each independent expression sentence into the generator of the model, fusing each independent expression sentence through the generator to obtain a fused sentence, and adding the fused sentence to the training data set; Inputting the sentence to be determined in the training data set into the source discriminator of the model to obtain a determination result output by the source discriminator to determine whether the sentence to be determined is an original sentence; Determine the source discrimination loss of the source discriminator according to the discrimination result of the source discriminator and the source label of the sentence to be discriminated, and determine the source generation loss of the generator according to the discrimination result of the source discriminator, the source label of the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated; The model is adversarially trained according to the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse several independent expression sentences in reply to the user.

2. The method according to claim 1, characterized in that Determining the source generation loss of the generator according to the discrimination result of the source discriminator, the source label of the sentence to be discriminated, and the original sentence corresponding to the sentence to be discriminated, including: If the discrimination result of the source discriminator is inconsistent with the source label of the sentence to be discriminated, determining the difference in word order between the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated; Based on the word order difference, a source generation loss of the generator is determined.

3. The method according to claim 1, characterized in that The method further comprises: Inputting the sentence to be determined and the independent expression sentence corresponding to the sentence to be determined into the semantic discriminator of the model to obtain a determination result output by the semantic discriminator for determining whether the semantics of the sentence to be determined are consistent with the semantics of the independent expression sentence corresponding to the sentence to be determined; According to the discrimination result output by the semantic discriminator, adversarial training is performed on the model.

4. The method according to claim 3, characterized in that According to the discrimination result output by the semantic discriminator, adversarial training is performed on the model, including: Determine the semantic discrimination loss of the semantic discriminator according to the discrimination result output by the semantic discriminator and the semantic label of the sentence to be discriminated, and determine the semantic generation loss of the generator according to the discrimination result output by the semantic discriminator, the semantic label of the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated; The model is subjected to adversarial training according to the semantic generation loss and the semantic discrimination loss.

5. The method according to claim 4, characterized in that Determining the semantic generation loss of the generator according to the discrimination result of the semantic discriminator, the semantic label of the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated includes: If the discrimination result of the semantic discriminator is inconsistent with the semantic label of the sentence to be discriminated, determining the semantic difference between the sentence to be discriminated and the independent expression sentence corresponding to the sentence to be discriminated; According to the semantic difference, a semantic generation loss of the generator is determined.

6. The method according to claim 1, characterized in that The method further comprises: Input a number of independent sentences for replying to the user into the generator of the model to obtain a fused sentence output by the generator, and display the fused sentence.

7. The method according to claim 1, characterized in that The generator includes a bidirectional autoregressive transformer; the source discriminator includes a BERT model and a linear classifier.

8. A model training device, comprising: An independent expression sentence acquisition module is used to split the original sentence into a plurality of independent expression sentences, and add the plurality of independent expression sentences to the training data set; A fused sentence acquisition module, used for inputting each independent expression sentence into the generator of the model, so as to fuse each independent expression sentence through the generator to obtain a fused sentence, and adding the fused sentence to the training data set; A word order discrimination result module, used for inputting the sentence to be discriminated in the training data set into the source discriminator of the model to obtain a discrimination result output by the source discriminator to determine whether the sentence to be discriminated is an original sentence; a loss determination module, configured to determine the source discrimination loss of the source discriminator according to the discrimination result of the source discriminator and the source label of the sentence to be discriminated, and to determine the source generation loss of the generator according to the discrimination result of the source discriminator, the source label of the sentence to be discriminated and the original sentence corresponding to the sentence to be discriminated; The model training module is used to perform adversarial training on the model according to the source generation loss and the source discrimination loss, wherein the generator of the model is used to fuse several independent expression sentences in reply to the user.

9. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • A writing aiding method based on neural network

    CN109522411A

  • Text abstract generation method based on positive and negative sample adversarial training

    CN110347819A

  • Question and answer information processing method and device, and computer equipment

    CN111382232A

  • Question and answer information processing method and device and computer equipment

    CN111401922A

  • Summary generation device and summary generation method

    JP2020035272A