Method and apparatus for training text generation model, and text generation method and apparatus

By introducing the noise diffusion mechanism and encoder-decoder architecture into the text generation model, the problems of poor performance and high computational resource consumption of traditional text generation models are solved, achieving higher quality text generation and resource saving.

WO2024215251A1PCT designated stage expired Publication Date: 2024-10-17ALIBABA INNOVATION PRIVATE LIMITED
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
PCT/SG2024/050200
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-11
Filing Date
2024-03-29
Publication Date
2024-10-17

AI Technical Summary

Technical Problem

Traditional text generation models use maximum likelihood estimation, resulting in text generation effects that still need to be improved and that consume a lot of computing resources.

Method used

Using the noise diffusion mechanism, through the combined architecture of the encoder and decoder, the noise diffusion and inverse diffusion processes are simulated, and the text generation model is trained to minimize the difference between noise diffusion and inverse diffusion, and reduce the consumption of computing resources.

Benefits of technology

The text generation effect is improved, the computing resource consumption of the reverse diffusion process is reduced, the generated feature representation is closer to the training target, and the quality of text generation is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure SG2024050200_17102024_PF_FP_ABST
    Figure SG2024050200_17102024_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the embodiments of the present disclosure are a method and apparatus for training a text generation model, and a text generation method and apparatus. The main technical solution comprises: acquiring training data which includes a plurality of training samples, wherein the training samples comprise a sample pair which consists of an input text sample and an output text sample; acquiring a feature representation of the output text sample in the sample pair, and performing noise-adding diffusion processing on the feature representation of the output text sample, so as to obtain a noise-added feature representation; and using the input text sample of the sample pair and the noise-added feature representation as an input to train a text generation model, wherein the text generation model simulates, during a training process, inverse diffusion processing of the noise-adding diffusion processing on the basis of the input text sample and the noise-added feature representation, so as to use the output text sample as a target output.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Cross-Reference This disclosure claims priority to Chinese patent application No. 202310387160.5, filed with the China Patent Office on April 11, 2023, entitled "Method for Training a Text Generation Model, Method for Text Generation, and Apparatus," the entire contents of which are incorporated herein by reference. Technical Field This disclosure relates to the fields of natural language processing and artificial intelligence, and more particularly to a method for training a text generation model, a method for text generation, and an apparatus. Background: Text-to-text generation technology primarily involves transforming and processing input text to generate new text. This includes text summarization, text rewriting, machine translation, and automated question-answering. Most text generation models used in text-to-text generation employ an encoder-decoder architecture. However, traditional text generation models typically employ maximum likelihood estimation, which uses a desired sample result to infer the parameter values ​​that most likely lead to that result. Specifically, the model parameter values ​​are determined to maximize the probability of the desired sample result. However, the text generation effect produced by the maximum likelihood estimation method still needs to be improved. In view of this, the present disclosure provides a method, a text generation method, and an apparatus for training a text generation model to improve the text generation effect. The present disclosure provides the following solutions: In a first aspect, a method for training a text generation model is provided, comprising: obtaining training data comprising a plurality of training samples, wherein the training samples include sample pairs consisting of an input text sample and an output text sample; obtaining a feature representation of the output text sample in the sample pair, performing a noise diffusion process on the feature representation of the output text sample to obtain a noisy feature representation; and using the input text sample and the noisy feature representation of the sample pair as input to train a text generation model. During training, the text generation model simulates an inverse diffusion process of the noise diffusion process based on the input text sample and the noisy feature representation to output the output text sample as a target output. According to an implementable method in an embodiment of the present disclosure, the text generation model includes an encoder and a decoder; the encoder obtains a feature representation of an input text sample of the input text generation model, and the decoder uses the feature representation of the input text sample and the feature representation after noise addition to perform the inverse diffusion process to obtain the output text sample; the training goal includes: minimizing the difference between the distribution generated by the noise addition diffusion process and the distribution generated by the inverse diffusion process.According to one possible implementation of an embodiment of the present disclosure, the training objective further includes: minimizing the difference between the distribution of the feature representation obtained by diffusion processing at the last time step and a normal distribution; and / or minimizing the difference between the feature representation obtained by inverse diffusion at the last time step and the feature representation of the output text sample. According to one possible implementation of an embodiment of the present disclosure, obtaining the feature representation of the output text sample in the sample pair includes: performing word embedding processing on the output text sample using an embedding network to obtain the feature representation of the output text sample; or encoding the output text sample using an encoder in the text generation model to obtain the feature representation of the output text sample. According to one possible implementation of an embodiment of the present disclosure, in the noise-adding diffusion processing, the diffusion processing at the first time step adds noise to the feature representation of the output text sample, and the diffusion processing at each subsequent time step adds noise to the feature representation obtained by the diffusion processing at the previous time step, so that the feature representation obtained by the diffusion processing at each time step conforms to a normal distribution. According to one possible implementation of the disclosed embodiments, in the reverse diffusion process, the feature representation obtained by the reverse diffusion process at each time step is sampled from the posterior distribution of the feature representation obtained by the reverse diffusion process at the previous time step; alternatively, the feature representation obtained by the reverse diffusion process at each time step is sampled from the prior distribution of the predicted feature representation, where the prior is the prediction result of the feature representation obtained by the first diffusion process. A second aspect provides a text generation method, comprising: obtaining input text; inputting the input text and random noise into a text generation model; and having the text generation model perform reverse diffusion processing on the input text and the random noise to obtain output text; wherein the text generation model is pre-trained using the method described in the first aspect above. According to an implementable method of an embodiment of the present disclosure, the text generation model includes an encoder and a decoder; the encoder obtains a feature representation of the input text; the decoder performs inverse diffusion processing using the feature representation of the input text and the random noise to predict the output text; wherein in the inverse diffusion processing, the feature representation obtained by the inverse diffusion processing at each time step is sampled on the posterior distribution of the feature representation obtained by the inverse diffusion processing at the previous time step; or, the feature representation obtained by the inverse diffusion processing at each time step is sampled on the prior distribution of z0 obtained based on the prediction, and the bell is the prediction result of the feature representation obtained by the first diffusion processing.In a third aspect, a summary generation method is provided, comprising: obtaining input text; inputting the input text and random noise into a text generation model, and having the text generation model perform inverse diffusion processing on the input text and the random noise to obtain a summary of the input text; wherein the text generation model is pre-trained using the method described in the first aspect. In a fourth aspect, a machine translation method is provided, comprising: obtaining text in a first language; inputting the text in the first language and random noise into a text generation model, and having the text generation model perform inverse diffusion processing on the text in the first language and the random noise to obtain text in a second language; wherein the text generation model is pre-trained using the method described in the first aspect. In a fifth aspect, a device for training a text generation model is provided, the device comprising: a sample acquisition unit, configured to acquire training data comprising a plurality of training samples, the training samples comprising a sample pair consisting of an input text sample and an output text sample; a noise diffusion unit, configured to acquire a feature representation of the output text sample in the sample pair, perform noise diffusion processing on the feature representation of the output text sample, and obtain a noisy feature representation; a model training unit, configured to use the input text sample of the sample pair and the noisy feature representation as input to train a text generation model, wherein during the training process, the text generation model simulates an inverse diffusion processing of the noise diffusion based on the input text sample and the noisy feature representation to output the output text sample as a target. According to a sixth aspect, a text generation device is provided, comprising: a text acquisition unit configured to acquire input text; and a text generation unit configured to input the input text and random noise into a text generation model, and obtain output text obtained by performing inverse diffusion processing on the input text and the random noise by the text generation model; wherein the text generation model is pre-trained by the device described in the fifth aspect. According to a seventh aspect, a computer-readable storage medium is provided, storing a computer program, which, when executed by a processor, implements the steps of any one of the methods described in the first aspect. According to an eighth aspect, an electronic device is provided, comprising: one or more processors; and a memory associated with the one or more processors, the memory configured to store program instructions, which, when read and executed by the one or more processors, implements the steps of any one of the methods described in the first aspect. According to specific embodiments provided by the present disclosure, the present disclosure provides the following technical effects:

[0002] 1) This paper no longer uses maximum likelihood estimation to train text generation models. Instead, it provides a new approach that introduces a diffusion probability generation mechanism into the field of text generation. This method simulates the text generation process as the inverse of noise-added diffusion, eliminating the impact of information loss caused by noise on text generation, thereby achieving better text generation results.

[0003] 2) In the actual prediction process of the present disclosure, the encoder input and processing remain unchanged. In other words, the encoder still only needs to perform a single neural network feedforward calculation, without having to participate in the inverse diffusion process, which may require hundreds or thousands of time steps of processing. This can greatly save computing resources.

[0004] 3) In the inverse diffusion process of the present disclosure, the sampling method based on the predicted prior distribution of the feature representation of the output text sample is closer to the training target, which can produce higher-quality feature representations. Of course, any product implementing the present disclosure does not necessarily need to achieve all of the advantages described above. BRIEF DESCRIPTION OF THE DRAWINGS To more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments. Obviously, the drawings described below represent some embodiments of the present disclosure. Those skilled in the art can also derive other drawings based on these drawings without inventive effort. Figure 1 is a system architecture diagram applicable to the embodiments of the present disclosure; Figure 2 is a flow chart of the method for training a text generation model provided in the embodiments of the present disclosure; Figure 3 is a schematic diagram of the training principle of the text generation model provided in the embodiments of the present disclosure; Figure 4 is a flow chart of the text generation method provided in the embodiments of the present disclosure; Figure 5 is a schematic diagram of the prediction principle of the text generation model provided in the embodiments of the present disclosure; Figure 6 is a schematic block diagram of the apparatus for training a text generation model provided in the embodiments of the present disclosure; Figure 7 is a schematic block diagram of the text generation apparatus provided in the embodiments of the present disclosure; and Figure 8 is a schematic block diagram of the electronic device provided in the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The technical solutions in the embodiments of the present disclosure will be described clearly and completely below, in conjunction with the accompanying drawings. It should be understood that the described embodiments represent only a portion of the embodiments of the present disclosure, and are not exhaustive. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present disclosure are intended to fall within the scope of protection of the present disclosure. The terms used in the embodiments of the present disclosure are for the purpose of describing specific embodiments and are not intended to limit the present disclosure. The singular forms "a," "an," "the," and "the" used in the embodiments of the present disclosure and the appended claims are intended to include the plural forms, unless the context clearly indicates otherwise. It should be understood that the term "and / or" as used herein describes an associative relationship between associated objects, indicating that three possible relationships can exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " as used herein generally indicates that the associated objects are in an "or" relationship. Depending on the context, the term "if" as used herein can be interpreted as "when," "when," "in response to a determination," or "in response to a detection."Similarly, depending on the context, the phrase "if determined" or "if (stated condition or event) is detected" can be interpreted as "when determined," "in response to determining," "when (stated condition or event) is detected," or "in response to detecting (stated condition or event)." To facilitate understanding of the present disclosure, a brief description of the system architecture to which the present disclosure applies is first provided. Figure 1 illustrates an exemplary system architecture to which embodiments of the present disclosure can be applied. As shown in Figure 1, the system architecture includes a model training device and a text generation device. After acquiring training data offline, the model training device can perform model training using the methods provided in embodiments of the present disclosure to obtain a text generation model. The text generation device then utilizes the established text generation model online to generate output text based on input text. The text generation model is effectively a sequence-to-sequence (seq2seq) model that implements prediction from text sequence to text sequence. The model training device and the text generation device can be deployed on separate servers, on the same server or server group, or on separate or the same cloud server. A cloud server, also known as a cloud computing server or cloud host, is a host product within a cloud computing service system. It addresses the management difficulties and weak service scalability inherent in traditional physical hosts and virtual private servers (VPs). The model training device and text generation device can also be located on a computer terminal with significant computing power. It should be noted that, in addition to performing text generation online, the aforementioned text generation device can also perform text generation offline, for example, generating summaries for batches of text. It should be understood that the number of model training devices, text generation devices, and text generation models shown in FIG1 is illustrative. Any number of model training devices, text generation devices, and text generation models can be employed depending on implementation needs. FIG2 is a flow chart of a method for training a text generation model according to an embodiment of the present disclosure. This method can be executed by the model training device in the system shown in FIG1. ​​As shown in FIG2 , the method may include: Step 202: Obtaining training data comprising a plurality of training samples, wherein the training samples include sample pairs consisting of an input text sample and an output text sample. Step 204: Obtain a feature representation of the output text sample in the sample pair, perform noise diffusion processing on the feature representation of the output text sample, and obtain a noisy feature representation.Step 206: The input text sample and the noisy feature representation of the sample pair are used as input to train the text generation model. During training, the text generation model simulates the inverse diffusion of noisy diffusion based on the input text sample and the noisy feature representation, with the output text sample serving as the target output. As can be seen from the above process, the present disclosure no longer employs maximum likelihood estimation to train the text generation model. Instead, it offers a novel approach, introducing the diffusion probability generation mechanism into the field of text generation and simulating the text generation process as the inverse diffusion of noisy diffusion. This eliminates the impact of information loss caused by noise on text generation, thereby achieving better text generation results. Each step in the above process is described in detail below. First, step 202, "obtaining training data comprising multiple training samples," is described in detail in conjunction with the embodiments. Although the present disclosure no longer employs maximum likelihood estimation, the acquired training data remains the same as that used in traditional maximum likelihood estimation. The training data comprises multiple training samples, each of which is an input text sample W. vSample pairs are constructed. For example, in the application scenario of summary generation, some articles can be used as input text samples, and the summaries of these articles can be used as output text samples. Another example is in the field of text rewriting, some sentences or paragraphs can be used as input text samples, and the rewritten texts of these sentences or paragraphs can be used as output text samples. Another example is in the field of machine translation, text in a first language can be used as input text samples, and the corresponding text in a second language can be used as output text samples. For example, a Chinese sentence can be used as input text samples, and the English sentence corresponding to the translated Chinese sentence can be used as the output text sample. The following describes step 204, "obtaining feature representations of the output text samples in the sample pairs, performing denoising and diffusion processing on the feature representations of the output text samples, and obtaining the denoised feature representations," with reference to an embodiment. Denoising diffusion probability models have been applied in the field of image generation, achieving results that surpass traditional generative adversarial models, but they remain a niche in the field of natural language processing. The denoising diffusion probability model mainly includes two processes: forward noise diffusion and backward denoising. This step is the process of forward noise diffusion, that is, the process of adding noise step by step based on the output text sample. In the field of natural language processing, due to the discretization characteristics of natural language, the denoising diffusion probability model cannot be directly applied to the natural language generation task. In the embodiment of the present disclosure, the sequence consisting of each token (element) can be first mapped to a continuous feature representation g© (bar), that is, a feature representation consisting of the word vector of each token. Among them, each token of the text refers to the element that constitutes the text. For text, the text is divided into words. The feature representation obtained by the scattered processing conforms to the normal distribution, that is, the process of diffusing the noise into the background can be regarded as adding an additional Markov transition distribution. The longer it takes, the more balanced the time step will be. Therefore, it is necessary to take a relatively balanced value based on experience or experiments, such as 2000 time steps. Through the aforementioned forward noise diffusion process, the discrete output text samples are integrated into the continuous denoising diffusion probability model, and noise is gradually added to g^(WJ to obtain samples that conform to the aforementioned prior distribution. The prior distribution used in this embodiment is a normal distribution. The following describes in detail step 206, "inputting the input text sample and the noisy feature representation of the sample pair into the text generation model. During training, the text generation model simulates the inverse diffusion process of the noise diffusion based on the input text sample and the noisy feature representation, so as to use the output text sample as the target output," in conjunction with an embodiment. Training the text generation model is actually simulating (i.e., learning) the inverse diffusion process based on the aforementioned forward noise diffusion. The text generation model architecture used in this embodiment is an encoder-decoder structure. As shown in Figure 3, the input text sample is input to the encoder, which encodes the sample to obtain a feature representation of the input text sample. The encoder can be implemented based on a pre-trained language model, such as BERT (Bidirectional Encoder Representation from Transformers) and XLNet. Pre-trained language models such as the BERT (an autoregressive model that implements bidirectional contextual information by permuting language models) and the GPT (Generative Pre-Training) model are used as the initial encoder, upon which further time-step training is performed. BERT is a bidirectional pre-trained language model that uses a Transformer Encoder architecture. BERT effectively utilizes contextual information for feature learning. XLNet, a model similar to BERT, is a more generalized autoregressive pre-trained model. GPT uses a Transformer Decoder architecture and retains masked multi-head attention within the Transformer Decoder.

[0005] The Transformer network is a model that uses a self-attention mechanism to encode input tokens into feature representations. In addition to using the Transformer-based encoder-decoder architecture, encoder-decoder structures based on other networks, such as RNNs (recurrent neural networks), can also be used.

[0006] N(μ; σ²) is the distribution of spoons, where the mean of this distribution is μ and the variance is σ². As another achievable approach, a prior distribution based on can be obtained at each time step during the denoising diffusion process, expressed as:

[0007] p(z_t|z_{t-1}) = N(μ(z_{t-1}); σ²(z_{t-1})) (8) Therefore, in the inverse diffusion process, the feature representation z_t obtained from the inverse diffusion process at each time step can be sampled from the prior distribution of p(z_t|z_{t-1}) predicted based on z_{t-1}, which is regarded as the prediction result of the feature representation obtained from the first-step diffusion process. That is to say, at each step of the inverse diffusion process, a p(z_t|z_{t-1}) can be predicted, and then z_t is sampled based on the prior distribution. The initial z_0 is inaccurate, but as the time steps progress, the prediction of z_t becomes more accurate, and when z_T is obtained in the last step of the inverse diffusion process, the goal is to make z_T consistent with x. Such a sampling method and training objective are more similar, and a higher-quality feature representation can be obtained. Since the denoising process is the inverse process of the noise-adding diffusion, the ideal situation is that the text generation model fully learns the inverse process of the noise-adding diffusion and finally predicts x. Therefore, the training objective adopted in the embodiments of the present disclosure mainly includes: minimizing the difference between the distribution generated by the noise-adding diffusion process and the distribution generated by the inverse diffusion process. Further, in the noise-adding diffusion process, the ideal situation is that the feature representation obtained from the diffusion process at the last time step is the same as the random noise. Therefore, the above training objective can also include: minimizing the difference between the distribution of the feature representation obtained from the diffusion process at the last time step and the normal distribution. Further, in the inverse diffusion (i.e., denoising) process, the ideal situation is to fully simulate the inverse process of the noise-adding diffusion, and the feature representation obtained from the inverse diffusion at the last time step is exactly the same as p(x). Therefore, the above training objective can also include minimizing the difference between the feature representation obtained from the inverse diffusion at the last time step and the feature representation of the text sample. In the embodiments of this specification, a loss function can be constructed according to the above training objective, and in each round of iteration, the value of the loss function is used to update the model parameters by means such as gradient descent until the preset training end condition is satisfied. The training end condition can include, for example, that the value of the loss function is less than or equal to the preset loss function threshold, and the number of iterations reaches the preset number threshold, etc. As one achievable approach, a loss function L can be constructed as follows: log p(x|z_0) Take the expectation of the content in [] under the constraint of q(z_t, z_0, x, θ). Based on the trained text generation model described above, the text generation model can be used to perform specific text generation tasks. Figure 4 is a flowchart of a text generation method provided in an embodiment of the present disclosure. This method can be performed by the text generation device in the system shown in Figure 1. As shown in Figure 4, the method may include the following steps: Step 402: Obtain input text. Step 404: Input the input text and random noise into the text generation model, whereupon the text generation model performs inverse diffusion processing based on the input text and random noise to obtain output text. The text generation model is pre-trained using the method shown in Figure 2. The structure of the pre-trained text generation model in this embodiment of the present disclosure is shown in Figure 5 and includes an encoder and a decoder. The encoder obtains a feature representation of the input text. The decoder performs inverse diffusion processing using the feature representation of the input text and random noise to predict the output text. In the reverse diffusion process, the feature representation obtained by reverse diffusion at each time step is sampled from the posterior distribution of the feature representation obtained by reverse diffusion at the previous time step. Alternatively, the feature representation obtained by reverse diffusion at each time step is sampled from the prior distribution of the predicted feature representation, where is the prediction result of the feature representation obtained by the first diffusion step. This means that during the actual prediction process, the encoder's input and processing remain unchanged. The encoder only needs to perform a single neural network feedforward calculation, eliminating the need for reverse diffusion, which can require hundreds or thousands of time steps. This significantly saves computational resources. In addition to the encoder's output, the decoder also inputs random noise. The decoder performs denoising on the feature representation of the input text at each time step, obtaining the feature representation at the final time step. This feature representation is then mapped to the output text. As one possible implementation, the above text generation method can be executed by a cloud server, integrating text generation functionality into the cloud. A cloud server, also known as a cloud computing server or cloud host, is a host product within the cloud computing service ecosystem. It addresses the management difficulties and scalability limitations of traditional physical hosts and virtual private servers (VPS). When a user wishes to generate output text based on input text, they can upload the input text to the cloud server via a user terminal. These user terminals can include, but are not limited to, mobile phones, tablets, laptops, PDAs (Personal Digital Assistants), wearable devices, and PCs (Personal Computers).The cloud server receives input text from a user terminal; then, using a pre-trained text generation model, performs inverse diffusion processing on the input text and random noise to generate output text, and returns the output text to the user terminal. The methods provided in the disclosed embodiments can be applied to a variety of application scenarios, several of which are described below: Application Scenario 1: Summary Generation Scenario. In this scenario, when training a text generation model, articles can be used as input text samples, and their summaries as output text samples, thereby forming sample pairs. For example, news articles can be used as input text samples, and news text summaries as output text samples. Another example is papers as input text samples, and paper summaries as output text samples. These news articles and their summaries, as well as papers and their summaries, are all readily available online, thus providing a large number of training samples for training data. Then, a feature representation of the output text sample in the sample pair is obtained, and a noise diffusion process is performed on the feature representation of the output text sample to obtain a noisy feature representation. The input text sample and the noisy feature representation of the sample pair are input into a text generation model. During training, the text generation model simulates an inverse diffusion process of noise diffusion based on the input text sample and the noisy feature representation to obtain an output text sample. The specific training process can be found in the description related to Figures 2 and 3 in the method embodiments and is not described here in detail. During actual summary generation, input text is obtained, and the input text and random noise are input into a pre-trained text generation model. The text generation model then performs an inverse diffusion process based on the input text and random noise to obtain a summary of the input text. This method can automatically generate an accurate summary for the input text, allowing for automatic generation and publication of news articles and papers when they are published online. Alternatively, the text generation device can be provided to users as a tool, allowing them to upload their own documents as input text and use the tool to obtain an automatically generated summary. Application Scenario 2: Machine Translation Scenario: In this scenario, when training a text generation model, bilingual corpus can be used as sample pairs. These bilingual corpus include text in the first language as input and text in the second language as output. For example, a sample pair consisting of Chinese text and its corresponding English text can be used as training samples.Then, a feature representation of the output text sample in the sample pair is obtained, and a noise diffusion process is performed on the feature representation of the output text sample to obtain a noisy feature representation. The input text sample and the noisy feature representation of the sample pair are input into a text generation model. During training, the text generation model simulates an inverse diffusion process of noise diffusion based on the input text sample and the noisy feature representation to obtain an output text sample. The specific training process can be found in the description related to Figures 2 and 3 in the method embodiments and is not described here in detail. During actual machine translation, text in a first language is obtained, and the text in the first language and random noise are input into a pre-trained text generation model. The text generation model then performs an inverse diffusion process on the text in the first language and random noise to obtain text in a second language. This method can automatically translate text in a first language into a second language. For example, when publishing text online, the text can be automatically translated into another language for users in different countries or regions to view. For another example, a text generation device can be provided to users as a tool. Users upload a document to be translated as input text, and the tool is used to automatically translate the text into a specified language. Other application scenarios are also possible, not specifically listed here. The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than those in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the figures do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain implementations, multi-tasking and parallel processing are also possible or may be advantageous. According to another embodiment, a device for training a text generation model is provided. Figure 6 shows a schematic block diagram of a device for training a text generation model according to one embodiment, namely, the model training device in the architecture shown in Figure 1. As shown in Figure 6, the device 600 may include a sample acquisition unit 601, a noise diffusion unit 602, and a model training unit 603. The main functions of each component are as follows: Sample acquisition unit 601 is configured to acquire training data containing multiple training samples, where the training samples include sample pairs consisting of input text samples and output text samples. Noise diffusion unit 602 is configured to acquire a feature representation of the output text sample in the sample pair and perform noise diffusion processing on the feature representation of the output text sample to obtain a noisy feature representation.The model training unit 603 is configured to use the input text sample and the noisy feature representation of the sample pair as input to train a text generation model. During training, the text generation model simulates the inverse diffusion process of the noisy diffusion process based on the input text sample and the noisy feature representation, to produce the output text sample as the target output. The text generation model includes an encoder and a decoder. The encoder obtains the feature representation of the input text sample input to the text generation model, and the decoder performs inverse diffusion process using the feature representation of the input text sample and the noisy feature representation to obtain the output text sample. When the model training unit 603 trains the text generation model, the training objectives employed include: minimizing the difference between the distribution generated by the noisy diffusion process and the distribution generated by the inverse diffusion process. Furthermore, when training the text generation model, the model training unit 603 may further employ the training objectives of: minimizing the difference between the distribution of the feature representation obtained by the diffusion process in the last time step and a normal distribution; and / or minimizing the difference between the feature representation obtained by the inverse diffusion process in the last time step and the feature representation of the output text sample. As one possible implementation, the noise diffusion unit 602 can use an embedding network to perform word embedding processing on the output text sample to obtain a feature representation of the output text sample. As another possible implementation, the noise diffusion unit 602 can use an encoder in the text generation model to encode the output text sample to obtain a feature representation of the output text sample. As another possible implementation, during the noise diffusion process, the noise diffusion unit 602 adds noise to the feature representation of the output text sample during the diffusion process at the first time step, and then adds noise to the feature representation obtained during the diffusion process at each subsequent time step. The feature representations obtained during the diffusion process at each time step conform to a normal distribution. As another possible implementation, during the inverse diffusion process in the text generation model, the feature representation obtained during the inverse diffusion process at each time step is sampled from a posterior distribution based on the feature representation obtained during the inverse diffusion process at the previous time step. As another possible implementation, in the reverse diffusion process of the text generation model, the feature representation obtained by the reverse diffusion process at each time step is sampled from a prior distribution based on the prediction of % , where % is the prediction result of the feature representation obtained by the first diffusion process. According to another embodiment, a text generation device is provided. Figure 7 shows a schematic block diagram of a text generation device according to one embodiment. As shown in Figure 7, the device 700 may include: a text acquisition unit 701 and a text generation unit 702. The main functions of each component unit are as follows: The text acquisition unit 701 is configured to acquire input text.The text generation unit 702 is configured to input input text and random noise into a text generation model, and obtain output text generated by the text generation model through reverse diffusion processing based on the input text and random noise. The text generation model is pre-trained by the model training device shown in FIG6 . The text generation model includes an encoder and a decoder. The encoder obtains a feature representation of the input text. The decoder performs reverse diffusion processing using the feature representation of the input text and random noise to predict the output text. In reverse diffusion processing, the feature representation obtained by reverse diffusion processing at each time step is sampled from the posterior distribution of the feature representation obtained by reverse diffusion processing at the previous time step; alternatively, the feature representation obtained by reverse diffusion processing at each time step is sampled from the prior distribution of the predicted value, where value is the prediction result of the feature representation obtained by the first diffusion processing step. The various embodiments in this specification are described in a progressive manner. References to the common and similar parts between the various embodiments are provided. Each embodiment focuses on the differences from other embodiments. In particular, since the apparatus embodiment is generally similar to the method embodiment, the description is relatively simple. For relevant parts, references can be made to the description of the method embodiment. The device embodiments described above are illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one location or distributed across multiple network units. Some or all of these modules may be selected based on actual needs to achieve the objectives of the present embodiments. Persons of ordinary skill in the art will be able to understand and implement the present embodiments without inventive effort. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data, etc.) involved in this disclosure are all authorized by the user or fully authorized by all parties. The collection, use, and processing of the relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation portals are provided for the user to choose to authorize or reject. Furthermore, the present embodiments further provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the aforementioned method embodiments. And an electronic device, comprising: one or more processors; and a memory associated with the one or more processors, the memory being configured to store program instructions, which, when read and executed by the one or more processors, execute the steps of the method described in any one of the aforementioned method embodiments.The present disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the aforementioned method embodiments. FIG. 8 exemplarily illustrates the architecture of an electronic device, which may include a processor 810, a video display adapter 811, a disk drive 812, an input / output interface 813, a network interface 814, and a memory 820. The processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, and memory 820 may be communicatively connected via a communication bus 830. The processor 810 may be implemented as a general-purpose CPU, a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided by the present disclosure. The memory 820 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 820 can store an operating system 821 configured to control the operation of the electronic device 800 and a basic input / output system (BIOS) 822 configured to control the low-level operations of the electronic device 800. In addition, the memory 820 can also store a web browser 823, a data storage management system 824, and a model training device / text generation device 825, etc. The model training device / text generation device 825 can be an application program that specifically implements the aforementioned steps in the embodiments of the present disclosure. In short, when the technical solutions provided by the present disclosure are implemented through software or firmware, the relevant program code is stored in the memory 820 and is called and executed by the processor 810. The input / output interface 813 is configured to connect to the input / output module to implement information input and output. Input / output modules can be configured as components within the device (not shown), or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., while output devices may include a display, speaker, vibrator, indicator light, etc. The network interface 814 is configured to connect to a communication module (not shown) to enable communication between the device and other devices.The communication module can achieve communication via wired means (e.g., USB, network cable, etc.) or wireless means (e.g., mobile network, Wi-Fi, Bluetooth, etc.). Bus 830 includes a path for transmitting information between various components of the device (e.g., processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, and memory 820). It should be noted that although the above device illustrates a processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, memory 820, bus 830, etc., in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will appreciate that the above device may include the components necessary to implement the disclosed solution, rather than all of the components shown in the figures. As can be seen from the above description of the embodiments, those skilled in the art will clearly understand that the present disclosure can be implemented using software plus a necessary general-purpose hardware platform. Based on this understanding, the technical solutions of the present disclosure, or the portion that contributes to the prior art, can be embodied in the form of a computer program product. This computer program product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or portions of these embodiments. The technical solutions provided by the present disclosure have been described in detail above, and specific examples have been used herein to illustrate the principles and implementations of the present disclosure. The description of the above embodiments is intended only to facilitate understanding of the methods and core concepts of the present disclosure. Furthermore, those skilled in the art will appreciate that variations in the specific implementations and scope of application are possible based on the concepts of the present disclosure. In summary, the contents of this specification should not be construed as limiting the present disclosure.Industrial Applicability The method for training a text generation model, the text generation method, and the apparatus provided in the embodiments of the present disclosure are applied to text generation scenarios. Training data comprising a plurality of training samples is obtained, where the training samples include sample pairs consisting of an input text sample and an output text sample. Feature representations of the output text samples in the sample pairs are obtained, and noise diffusion processing is performed on the feature representations of the output text samples to obtain noisy feature representations. This achieves the purpose of using the input text sample and the noisy feature representation of the sample pair as input for training the text generation model. This achieves the technical effect of simulating inverse diffusion processing of noise diffusion based on the input text sample and the noisy feature representation during the training of the text generation model, so as to use the output text sample as the target output. This solves the technical problem of poor text generation performance in related technologies.

Claims

Claims 1. A method for training a text generation model, the method include: Acquire training data including a plurality of training samples, wherein the training samples include sample pairs consisting of an input text sample and an output text sample; The feature representation of the output text sample in the sample pair is obtained, and a noise diffusion process is performed on the feature representation of the output text sample to obtain a feature representation after noise addition; the input text sample of the sample pair and the feature representation after noise addition are used as input to train a text generation model. During the training process, the text generation model simulates an inverse diffusion process of the noise diffusion based on the input text sample and the feature representation after noise addition, so as to output the output text sample as a target.

2. The method according to claim 1, in, The text generation model includes an encoder and a decoder; the encoder obtains the feature representation of the input text sample of the input text generation model, and the decoder uses the feature representation of the input text sample and the feature representation after noise addition to perform the inverse diffusion process to obtain the output text sample; the training objectives include: minimizing the difference between the distribution generated by the noise addition diffusion process and the distribution generated by the inverse diffusion process.

3. The method according to claim 2, in, The training objectives also include: minimizing the difference between the distribution of the feature representation obtained by diffusion processing in the last time step and the normal distribution; and / or minimizing the difference between the feature representation obtained by inverse diffusion in the last time step and the feature representation of the output text sample.

4. The method according to claim 2, in, The obtaining of the feature representation of the output text sample in the sample pair comprises: performing word embedding processing on the output text sample using an embedding network to obtain the feature representation of the output text sample; Alternatively, the output text sample is encoded by using an encoder in the text generation model to obtain a feature representation of the output text sample.

5. The method according to claim 1, in, In the noise-adding diffusion processing, the diffusion processing of the first time step adds noise to the feature representation of the output text sample, and the diffusion processing of each subsequent time step adds noise to the feature representation obtained by the diffusion processing of the previous time step, and the feature representation obtained by the diffusion processing of each time step conforms to the normal distribution.

6. The method according to claim 1 or 5, in, In the reverse diffusion process, the feature representation obtained by the reverse diffusion process at each time step is obtained by sampling on the posterior distribution of the feature representation obtained by the reverse diffusion process at the previous time step; or, the feature representation obtained by the reverse diffusion process at each time step is obtained by sampling on the prior distribution based on the prediction, and the method is the prediction result of the feature representation obtained by the first diffusion process.

7. A text generation method, wherein the method include: Get input text; The input text and random noise are input into a text generation model, and the text generation model performs inverse diffusion processing based on the input text and the random noise to obtain an output text; wherein the text generation model is pre-trained using the method described in any one of claims 1 to 6.

8. The method according to claim 7, in, The text generation model includes an encoder and a decoder; the encoder obtains the feature representation of the input text; the decoder performs inverse diffusion processing using the feature representation of the input text and the random noise to predict the output text; wherein in the inverse diffusion processing, the feature representation obtained by the inverse diffusion processing at each time step is sampled on the posterior distribution of the feature representation obtained by the inverse diffusion processing at the previous time step; or, the feature representation obtained by the inverse diffusion processing at each time step is sampled on the prior distribution of the feature representation obtained based on the prediction, and the feature representation is the prediction result of the feature representation obtained by the first diffusion processing.

9. A method for generating a unique abstract, wherein the method include: Get input text; The input text and random noise are input into a text generation model, and the text generation model performs inverse diffusion processing based on the input text and the random noise to obtain a summary of the input text; wherein the text generation model is pre-trained using the method according to any one of claims 1 to 6.

10. A machine translation method, include: Obtaining the text in the first language; The text in the first language and the random noise are input into a text generation model, and the text generation model performs inverse diffusion processing based on the text in the first language and the random noise to obtain a text in the second language; wherein the text generation model is pre-trained using the method according to any one of claims 1 to 6.

11. A device for training a text generation model, the device include: The sample acquisition unit is configured to acquire training data including a plurality of training samples, wherein the training samples include a sample pair consisting of an input text sample and an output text sample; the noise diffusion unit is configured to acquire a feature representation of an output text sample in the sample pair, and perform noise diffusion processing on the feature representation of the output text sample to obtain a feature representation after noise addition; the model training unit is configured to use the input text sample of the sample pair and the feature representation after noise addition as inputs to a training text generation model, wherein during the training process, the text generation model simulates an inverse diffusion processing of the noise diffusion based on the input text sample and the feature representation after noise addition to output the output text sample as a target.

12. A text generation device, the device include: A text acquisition unit, configured to acquire input text; A text generation unit is configured to input the input text and random noise into a text generation model, and obtain an output text obtained by the text generation model through inverse diffusion processing based on the input text and the random noise; wherein the text generation model is pre-trained by the device according to claim 11.

13. A computer-readable storage medium having a computer program stored thereon. in, When the program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.

14. An electronic device, include: one or more processors; And a memory associated with the one or more processors, the memory being configured to store program instructions, which, when read and executed by the one or more processors, execute the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Text generation method and device, electronic equipment and storage medium

    CN114841142A

  • Generative model training method and device

    CN115641485A

  • Generative model training method and resource generation method and device

    CN116629336A