Cooperative control text generation method and system based on potential semantic space transformation

Through the collaborative control text generation method of latent semantic spatial transformation, the EM algorithm is used to fit and balance sampling potential representation space, and multi-attribute control is realized through the adversarial training mechanism, which solves the problem of insufficient control accuracy and attribute conflict in the existing technology, and realizes high-quality text generation.

CN120524997APending Publication Date: 2025-08-22PEOPLE CN CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510596861.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-08-22

AI Technical Summary

Technical Problem

The existing controlled text generation technology has shortcomings in control accuracy, conflicts between multi-attribute control, model generalization ability and interpretability, and it is difficult to generate high-quality text under complex scenarios or dynamic requirements.

Method used

Through a collaborative control text generation method based on latent semantic spatial transformation, the latent representation space is fitted using EM algorithm, and a bidirectional mapping between latent semantic space and equal variance normal distribution is realized through an adversarial training mechanism, the total loss function is constructed to adjust the text generation model parameters to ensure the smooth transition between multi-attribute collaborative control and attributes.

Benefits of technology

The smooth transition between multi-attribute collaborative control and attributes is realized, which enhances the stability and interpretability of the generation process, provides more precise attribute adjustment capabilities, and solves the problem of uneven attribute distribution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120524997A_ABST
    Figure CN120524997A_ABST
Patent Text Reader

Abstract

The invention discloses a cooperative control text generation method and system based on potential semantic space transformation, and relates to the technical field of artificial intelligence. Original data are input into a text generation model to obtain reconstructed data; the training process of the text generation model comprises the following steps: mapping original data to an original potential representation space through a first encoder, and generating an original potential representation; fitting the original potential representation space through an EM algorithm to optimize distribution parameters, and carrying out balanced sampling on the fitted potential space to obtain a potential semantic space; a confrontation training mechanism and an activation vector are utilized to realize bidirectional mapping between a potential semantic space and equal variance normal distribution, linear interpolation is performed on different attributes in the potential semantic space, an interpolation result is mapped back to the original potential semantic space through an encoder EN after confrontation training, and a multi-attribute text is obtained through decoding of a decoder. According to the multi-attribute cooperative control text generation method, through equalization and reversible transformation of a potential semantic space, smooth transition between multi-attribute cooperative control and attributes is achieved, and meanwhile the stability and interpretability of the generation process are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a collaborative control text generation method and system based on latent semantic space transformation. Background Art

[0002] Controllable Text Generation (CTG) is a technology in the field of natural language generation. It aims to ensure that the generated text meets specific control properties (such as sentiment, theme, style, and safety) while maintaining linguistic fluency, semantic consistency, and diversity by adjusting the input, internal mechanisms, or decoding process of the generative model. CTG aims to strike a balance between controlling the properties of generated content and text quality, thereby achieving flexible and efficient text generation.

[0003] Although controllable text generation technology has made significant progress, it still faces many challenges in practical applications, such as insufficient control accuracy, conflicts between multi-attribute controls, limited model generalization capabilities, and weak interpretability. These problems make it difficult for existing methods to generate high-quality text that meets the target attributes when dealing with complex scenarios or dynamic requirements. To address these challenges, Latent Space Manipulation was proposed, which aims to achieve text generation control by directly adjusting the latent space representation of the language model without retraining or fine-tuning the model, thereby improving flexibility and efficiency. The core principle is that the underlying structure of the model has encoded the information required to generate the target, so by modifying the activation value of the latent space, the model can be guided to generate text that meets the target attributes.

[0004] The main methods include three categories: learning-based latent vector acquisition (such as generative enhancement technology (GENhance) and latent steering vectors), which extract latent vectors related to the target attributes through a training process; contrast-based latent vector acquisition (such as internal control vector (ICV) and activation superposition (ActAdd)), which generate control vectors by comparing the hidden states of examples with different attributes; and latent space construction (such as breakthrough generation effect (MIRACLE) and concealment and efficiency of latent space operations (MAGIC)), which realize multi-attribute collaborative control by constructing a new latent space.

[0005] These methods effectively capture complex attribute relationships and reduce training costs, but there are also some significant problems. For example, the design of guidance vectors requires high precision, which may lead to unstable control effects; interference between attributes may occur during multi-attribute control, such as MAGIC may still face conflicts in complex tasks; in addition, latent space operations rely on the hidden structure of a specific model and are difficult to generalize across different tasks or models. For example, the ActAdd method may cause semantic incoherence in the generated text due to improper design of guidance vectors, while ICV relies on example quality and distribution and has poor cross-task applicability. These problems limit the widespread application of this technology. Future research needs to further optimize the control accuracy, resolve attribute conflicts, enhance generalization capabilities, and improve the interpretability of the method to achieve more stable and efficient text generation control. Summary of the Invention

[0006] Based on the technical problems existing in the background technology, the present invention proposes a collaborative control text generation method and system based on latent semantic space transformation, which realizes multi-attribute collaborative control and smooth transition between attributes, while enhancing the stability and interpretability of the generation process.

[0007] The collaborative control text generation method based on latent semantic space transformation proposed in the present invention inputs original data into a text generation model to obtain reconstructed data;

[0008] The training process of the text generation model is as follows:

[0009] Mapping the original data to the original latent representation space through the first encoder to generate the original latent representation;

[0010] The original latent representation space is fitted using the EM algorithm to optimize the distribution parameters, and the fitted latent space is evenly sampled to obtain the latent semantic space.

[0011] Using adversarial training and activation vectors, a bidirectional mapping between the latent semantic space and the equivariance normal distribution is achieved. Different attributes are linearly interpolated in the latent semantic space. The interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training, and then decoded by the decoder to obtain multi-attribute text.

[0012] Construct a total loss function to tune trainable parameters in a text generation model.

[0013] Furthermore, in fitting the original latent representation space by the EM algorithm to optimize the distribution parameters, the EM algorithm includes an expectation step and a maximization step, specifically:

[0014] In the expectation step, the conditional probability of each original latent representation belonging to different attributes is estimated;

[0015] In the maximization step, the distribution parameters are optimized based on the conditional probability so as to maximize the log-likelihood of the attribute distribution;

[0016] Iterate the expectation step and maximization step to complete the fitting of the original latent representation space.

[0017] Furthermore, in the expectation step, assuming that the distribution of the attribute is represented by the distribution parameter θ, the conditional probability calculation formula is:

[0018]

[0019] in, Denotes the i-th original latent representation H i In the properties The likelihood under It is the prior of the attribute, given |A| dimensions A={A1,…,A |A|}, where each dimension A t Contains | A t |Attributes

[0020] Furthermore, in the maximization step, the distribution parameters are optimized based on the conditional probability to maximize the log-likelihood of the attribute distribution. The optimization formula of the distribution parameters is as follows:

[0021]

[0022] Among them, θ (k+1) is the parameter output after optimization in step k, which is used as the input parameter in step k+1. (k) For the parameter input before optimization in step k, given |A| dimensions A={A1,…,A |A|}, where each dimension A t Contains | A t |Attributes N is the total number of original potential representations, argmax θ To optimize θ, Denotes the i-th original latent representation H i In the properties The likelihood under is a priori of the attribute.

[0023] Furthermore, after fitting, the latent space is evenly sampled to obtain the latent semantic space, specifically:

[0024] Use kernel density estimation modeling to mark high-density and low-density areas of attribute density in the latent semantic space;

[0025] Downsampling is performed in high-density areas to reduce sample overconcentration;

[0026] Supplementary sampling is performed in low-density areas to increase the number of sample points in sparse areas;

[0027] Gaussian noise perturbation is added during the balanced sampling process so that the generated sample points can cover more areas of the potential space;

[0028] The formula of the kernel density estimation modeling method is as follows:

[0029]

[0030] in, For attributes The density distribution of Represents a dimension A t The specific properties under H i is the i-th original latent representation, is the center of the attribute distribution, is the standard deviation of the attribute distribution, and K(·) is the kernel function.

[0031] Furthermore, in the bidirectional mapping between the latent semantic space and the equal variance normal distribution, the adversarial training mechanism and activation vector are used as follows:

[0032] By jointly training the generator, encoder, and discriminator, the latent semantic space is mapped to the equal variance normal distribution.

[0033] Among them, the generator learns to generate data that conforms to the latent semantic space from an equivariance normal distribution, and the generator learns to convert the latent semantic space into an equivariance normal distribution, while the discriminator improves the mapping quality of the generator and encoder through adversarial training, thereby normalizing the latent semantic space into an equivariance normal distribution.

[0034] Furthermore, in constructing the total loss function, it is specifically as follows:

[0035] In the process of generating the original latent representation, a constrained loss function is constructed so that the original latent representation accurately models the attribute distribution and relationship;

[0036] The adversarial loss is constructed during the adversarial training process to transform the latent semantic space into an equivariance normal distribution.

[0037] Furthermore, the constraint loss function L S The formula is as follows:

[0038] L S =w1L R +w2L C +w3L G ;

[0039] Among them, w1, w2, and w3 are loss weights used to balance different optimization objectives. R To reconstruct the loss function, L C is the attribute classification loss function, L G is the attribute gap loss function.

[0040] Furthermore, it is characterized in that the reconstruction loss function L R The formula is as follows:

[0041] L R =-∑ i∈I logp LM (X i |Prefix i );

[0042]

[0043] Here, X i represents a sample sentence from the entire training set, ε i Is a perturbation vector sampled from a multivariate Gaussian distribution N(0,I) with a scaling factor λ to enhance robustness during reconstruction, Multilayer Perceptron MLP θ The disturbed H i Mapped to Prefix i , this prefix activates the language model to generate text with target attributes;

[0044] Attribute classification loss function L C The formula is as follows:

[0045]

[0046] in, is a classifier that uses parameters π t From dimension A t Distinguishing attributes

[0047] Attribute gap loss function L G The formula is as follows:

[0048]

[0049] Among them, H i For the i-th original potential representation, given |A| dimensions A={A1,…,A |A|}), each dimension contains |A t |Attributes Is an index set, indicating that the training data has attributes Identifiers of all sentences in Among them I tIt is dimension A t The indices of all sentences with arbitrary attributes in , I is the index of the entire training data, and a unified mapping parameter φ is used to transform the sentences {X i} is encoded as Where i∈I, Encode is the first encoder.

[0050] The collaborative control text generation system based on latent semantic space transformation inputs the original data into the text generation model to obtain the reconstructed data;

[0051] The training process of the text generation model includes a latent semantic space encoding module, an original latent semantic space fitting module, an activation vector selection module, and a loss construction module;

[0052] In the latent semantic space encoding module, the original data is mapped to the original latent representation space through the first encoder to generate the original latent representation;

[0053] In the original latent semantic space fitting module, the original latent representation space is fitted using the EM algorithm to optimize the distribution parameters, and the fitted latent space is evenly sampled to obtain the latent semantic space;

[0054] In the activation vector selection module, an adversarial training mechanism and activation vectors are used to achieve a bidirectional mapping between the latent semantic space and the equivariance normal distribution. Different attributes are linearly interpolated in the latent semantic space, and the interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training. After decoding, the decoder in the latent semantic space encoding module obtains the multi-attribute text.

[0055] The loss building module is used to build the total loss function to adjust the trainable parameters in the text generation model.

[0056] The advantages of the collaborative control text generation method and system based on latent semantic space transformation provided by the present invention are as follows: first, encoding the latent semantic space is proposed to extract the semantic and attribute information of the text, ensuring that the text generation model can accurately capture the target features; then, by fitting and resampling the latent semantic space, a latent semantic space is generated, which makes the attribute distribution more balanced and reduces attribute conflicts; finally, a reversible transformation is introduced to map the new semantic space to an equivariance normal distribution space, and interpolation calculation is used to achieve smooth transition between attributes. The result is then mapped back to the original semantic space through an inverse transformation to guide the final text generation, thereby achieving multi-attribute controllable text generation. This method not only solves the problem of uneven attribute distribution and realizes multi-attribute collaborative control, but also provides more precise attribute adjustment capabilities through interpolation calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1It is a structural schematic diagram of the present invention. DETAILED DESCRIPTION

[0058] The technical solutions of the present invention are described in detail below through specific embodiments. Numerous specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art may make similar modifications without departing from the scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0059] like Figure 1 As shown, the collaborative control text generation method based on latent semantic space transformation proposed by the present invention inputs the original data into the text generation model to obtain the reconstructed data;

[0060] The training process of the text generation model is as follows:

[0061] Step 1: Map the original data to the original latent representation space through the first encoder to generate the original latent representation;

[0062] Step 2: Fit the original latent representation space through the EM algorithm to optimize the distribution parameters, and perform balanced sampling on the fitted latent space to obtain the latent semantic space;

[0063] Step 3: Using the adversarial training mechanism and activation vector, a bidirectional mapping between the latent semantic space and the equivariance normal distribution is achieved. Different attributes are linearly interpolated in the latent semantic space. The interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training, and then decoded by the decoder to obtain the multi-attribute text.

[0064] Step 4: Construct a total loss function to adjust the trainable parameters in the text generation model.

[0065] This embodiment achieves multi-attribute collaborative control and smooth transition between attributes through equalization and reversible transformation of the latent semantic space, while enhancing the stability and interpretability of the generation process. That is, in terms of latent space transformation, a collaborative control text generation method and system based on latent semantic space transformation is proposed. First, it is proposed to encode the latent semantic space to extract the semantic and attribute information of the text, ensuring that the text generation model can accurately capture the target features; then, by fitting and resampling the latent semantic space, a latent semantic space q is generated to make the attribute distribution more balanced and reduce attribute conflicts; finally, a reversible transformation is introduced to map the latent semantic space q to an equivariance normal distribution space, and a smooth transition between attributes is achieved through interpolation calculation, and then the result is mapped back to the original semantic space through inverse transformation to guide the final text generation, thereby achieving multi-attribute controllable text generation. This method not only solves the problem of uneven attribute distribution, realizes multi-attribute collaborative control, but also provides more accurate attribute adjustment capabilities through interpolation calculation.

[0066] The text generation model of this embodiment is implemented by setting up three modules, which mainly include a latent semantic space encoding module, an original latent semantic space fitting module, and an activation vector selection module. The latent semantic space encoding module realizes encoding the original data into the original latent representation space; the original latent semantic space fitting module realizes fitting the encoded original latent representation space, and resamples the balanced data distribution from it to obtain the latent semantic space. The activation vector selection module realizes the reversible transformation of the resampled latent semantic space into an equal variance normal distribution (normal latent semantic space), and selects the guidance vector, and finally realizes multi-attribute collaborative control.

[0067] 1. Map the original data to the original latent representation space through the latent semantic space encoding module to generate the original latent representation, specifically:

[0068] The latent semantic space encoding module aims to map attribute-related sentences (raw data) into a latent representation space in order to accurately estimate the distribution of different attributes and their relationships. This step processes the sentence through the first encoder structure to generate a latent representation and imposes constraints on the representation to ensure that the attribute space can reliably model the distribution between target attributes.

[0069] Specifically, it includes two parts: encoding and decoding. The encoding part uses the first encoder Encoder to map the input raw data to the original potential representation space, generate the potential representation, and use H i Represents the original potential representation corresponding to the i-th original data. These potential representation points form an attribute space for estimating the distribution of the target attribute, and the decoder maps the potential representation back to the natural language sentence to achieve reconstruction of the original data (sentence).

[0070] In order to ensure that the potential representation can accurately model the attribute distribution and its relationship, a constrained loss function L is constructed. S , the formula is as follows:

[0071] L S =w1L R +w2L C +w3L G ;

[0072] Among them, w1, w2, and w3 are loss weights used to balance different optimization objectives. R To reconstruct the loss function, L C is the attribute classification loss function, L G is the attribute gap loss function.

[0073] Specifically, it includes the following three constraints (1-1) to (1-3):

[0074] (1-1) Reconstruction loss function L R : Emphasizes the mapping relationship between latent representation and natural language sentences (raw data), ensuring that points in the attribute space can generate sentences with attribute relevance. This is achieved by minimizing the reconstruction error of the language model:

[0075] L R =-∑ i∈I logp LM (X i |Prefix i );

[0076]

[0077] Here, X i represents a sample sentence from the entire training set. In addition, μ i Is a perturbation vector sampled from a multivariate Gaussian distribution N(0,I) with a scaling factor λ to enhance robustness during reconstruction. θ The disturbed H i Mapped to Prefix i , which activates the language model to generate text with target attributes.

[0078] (1-2) Attribute classification loss function L C :Use the classifier to classify the original latent representation H i Supervision is performed to ensure that the first encoder can accurately distinguish sentences from different attributes. This is achieved by minimizing the classification error of the classifier on the attribute:

[0079]

[0080] in, is a classifier that uses parameters π t From dimension A t Distinguishing attributes

[0081] (1-3) Attribute gap loss function l G : Reduce the distance between the distribution centers of different attributes and alleviate the attribute space deviation caused by differences in data sources. This is achieved by calculating the Euclidean distance between the attribute distribution centers:

[0082]

[0083] Among them, given |A| dimensions A={A1,…,A |A|}), each dimension contains |A t |Attributes Is an index set, indicating that the training data has attributes The identifiers of all sentences are Among them I t It is dimension A t The indices of all sentences with arbitrary attributes in , I is the index of the entire training data, and a unified mapping parameter φ is used to transform the sentences {X i} is encoded as Where i∈I, Encode is the first encoder. Then the constraint loss function L S Specifically:

[0084] L S =w1L R +w2L C +w3L G ;

[0085] Among them, w1, w2, and w3 are loss weights used to balance different optimization objectives.

[0086] 2. In the original latent semantic space fitting module, the original latent representation space is fitted using the EM algorithm to optimize the distribution parameters, and the fitted latent space is evenly sampled to obtain the latent semantic space. Specifically:

[0087] The original latent semantic space fitting module fits the original latent representation space and performs balanced sampling to generate a balanced new semantic space as the latent semantic space, thereby solving the problem of uneven attribute distribution and improving the multi-attribute control effect. The EM algorithm consists of two main steps: the expectation step (E step) and the maximization step (M step), which iteratively optimizes the attribute distribution of the latent space. In the E step, each original latent representation H is estimated iConditional probability of belonging to different attributes. Assuming that the distribution of the attribute is represented by the parameter θ, the conditional probability calculation formula is:

[0088]

[0089] in, Denotes the i-th original latent representation H i In the properties The likelihood under is the prior of the attribute, Indicates that given the original latent representation H i and distribution parameter θ, the attribute The conditional probability of .

[0090] In the M step, based on the conditional probability estimated in the E step, the distribution parameter θ is optimized to maximize the log-likelihood of the attribute distribution:

[0091]

[0092] Among them, θ (k+1) The parameter output after optimization in step j is used as the input parameter in step k+1. (k) is the parameter input before optimization in step j, Indicates that given the original latent representation H i and parameter θ (k) When the attribute in step k is The conditional probability of N is the total number of original potential representations, argmax θ To optimize θ.

[0093] By iterating the E-step and the M-step, the original latent representation space is finally fitted, so that it can accurately reflect the complex distribution relationship of the attributes in the data. After the fitting is completed, since the attribute distribution in the original latent representation space may be unbalanced, it is necessary to perform balanced sampling on the latent space after fitting to generate a new semantic space q as the final latent semantic space. Specifically, the attribute density in the original latent representation space is estimated, and the kernel density estimation modeling method is used to mark the high-density and low-density areas. Assuming that the attribute The density distribution of It can be calculated by the following formula:

[0094]

[0095] in, For attributes The density distribution of is the center of the attribute distribution, K(·) is the kernel function, is the standard deviation of the attribute distribution, and the mean standard deviation between each attribute is calculated as σ1.

[0096] Finally, downsampling is performed in high-density areas to reduce over-concentration of samples, and supplementary sampling is performed in low-density areas to increase the number of sample points in sparse areas. Through balanced sampling, a new semantic space q with a more balanced distribution is generated as the latent semantic space. To enhance the robustness of the latent semantic space, Gaussian noise perturbation is added during the balanced sampling process so that the generated sample points can cover more areas of the latent space. This process is achieved using the following formula:

[0097]

[0098] in, is the original potential representation after adding noise, is a random noise vector that obeys the standard normal distribution, and λ is a hyperparameter of the noise intensity.

[0099] 3. In the activation vector selection module, the adversarial training mechanism and activation vector are used to achieve a bidirectional mapping between the latent semantic space and the equivariance normal distribution. Different attributes are linearly interpolated in the latent semantic space, and the interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training. The decoder in the latent semantic space encoding module decodes it to obtain multi-attribute text. Specifically:

[0100] This activation vector selection module uses the BiGAN (Bidirectional Generative Adversarial Network) algorithm to achieve a bidirectional mapping between the latent semantic space and an equivariance normal distribution. It utilizes an adversarial training mechanism to enable the generator G and encoder EN to cooperate with each other, thereby normalizing the latent semantic space and selecting activation vectors to guide attribute control.

[0101] First, the activation vector selection module is used to jointly train the generator G, encoder EN and discriminator D to achieve the latent semantic space q(x) with equal variance normal distribution The generator G learns to generate data that conforms to q(x) from an equal variance normal distribution. The generator G learns to convert q(x) into an equal variance normal distribution. The discriminator D improves the mapping quality of the generator G and the encoder EN through adversarial training, thereby successfully normalizing the latent semantic space q(x) into an equal variance normal distribution. Specifically:

[0102] The goal of the discriminator D(x,z) is to distinguish between real pairs and generated pairs, and its first loss L D for

[0103]

[0104] The goal of the generator G(z) and encoder EN(x) is to deceive the discriminator so that the discriminator cannot distinguish between real pairs and generated pairs. The second loss L G,E for:

[0105]

[0106] Among them, E x~q(x) as well as To show the expectation, EN(x) is an encoder that maps the equivariance distribution to the latent semantic space. Random noise z is sampled from the Gaussian distribution and G(z) is obtained through the decoder G. A series of (x, E(x)) and (G(z), z) are obtained. The former is generated by the Encoder and the latter is generated by the Generator. These results are input into the Discriminator until it is impossible to determine whether it is generated by E or G. Among them, -E x~q(x) [log D(x,EN(x))] encourages the discriminator to assign high probability to the true pair (x,EN(x)), that is, it encourages the discriminator to judge the true pair as true, The discriminator is encouraged to assign low probability to fake data pairs (G(z),z). The discriminator tries to maximize the difference in the discrimination probability of the two classes of pairs (real pairs and generated pairs), while the generator G and encoder EN try to minimize the difference.

[0107] By jointly optimizing L D and L G,EN , the generator G(x) can transform the latent semantic space q(x) into an equivariance normal distribution The encoder EN can transform the equivariance normal distribution into the latent semantic space.

[0108] After the latent semantic space is transformed into an equivariance normal distribution, the two attribute representations z1 and z2 can be linearly interpolated in the latent space using the formula z interp =(1-α)z1+αz2, where α∈[0,1] is the interpolation constant used to control the interpolation ratio, z interp is the interpolation result. Then, the interpolation result is mapped back to the latent semantic space through the encoder EN to obtain x interp =EN(z interp ), x interp It is a multi-attribute guidance vector, which is then converted into a Prefix through MLP i Afterwards, the decoder in the latent semantic space encoding module is guided to decode and generate text with multiple attributes, thereby achieving multi-attribute control.

[0109] In the latent semantic space encoding module, an encoder-decoder structure is used to map attribute-related sentences into a latent representation space to accurately estimate the distribution of different attributes and their relationships. The latent representation in the latent semantic space guides the decoder to reconstruct natural language sentences, achieving reconstruction of the original data (sentences). In the original latent semantic space fitting module, an EM (Expectation-Maximization) algorithm is used to design a distribution fitting method based on the latent semantic space, and data distribution is balanced through resampling. In the activation vector selection module, a latent semantic space mapping method based on a bidirectional generative adversarial network is designed. By jointly training the encoder and generator, the original data distribution is mapped to an equal variance normal distribution, constructing a latent semantic space with structured properties.

[0110] This embodiment can be applied to intelligent content generation platforms to collaboratively control and optimize multi-attribute text generation tasks. In practice, it can be embedded in intelligent terminal systems as a software application to generate personalized content that meets user needs in real time. It can also be embedded in backend servers to meet the needs of large-scale text generation and attribute control, such as customer service responses, creative copywriting, and dynamic question-and-answer content generation.

[0111] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.

Claims

1. A collaborative control text generation method based on latent semantic space transformation, characterized in that: Input the original data into the text generation model to obtain the reconstructed data; The training process of the text generation model is as follows: Mapping the original data to the original latent representation space through the first encoder to generate the original latent representation; The original latent representation space is fitted using the EM algorithm to optimize the distribution parameters, and the fitted latent space is evenly sampled to obtain the latent semantic space. Using adversarial training and activation vectors, a bidirectional mapping between the latent semantic space and the equivariance normal distribution is achieved. Different attributes are linearly interpolated in the latent semantic space. The interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training, and then decoded by the decoder to obtain multi-attribute text. Construct a total loss function to tune trainable parameters in a text generation model.

2. The collaborative control text generation method based on latent semantic space transformation according to claim 1 is characterized in that: In fitting the original latent representation space by the EM algorithm to optimize the distribution parameters, the EM algorithm includes an expectation step and a maximization step, specifically: In the expectation step, the conditional probability of each original latent representation belonging to different attributes is estimated; In the maximization step, the distribution parameters are optimized based on the conditional probability so as to maximize the log-likelihood of the attribute distribution; Iterate the expectation step and maximization step to complete the fitting of the original latent representation space.

3. The collaborative control text generation method based on latent semantic space transformation according to claim 2 is characterized in that: In the expectation step, assuming that the distribution of the attribute is represented by the distribution parameter θ, the conditional probability calculation formula is: in, Denotes the i-th original latent representation H i In the properties The likelihood under It is the prior of the attribute, given |A| dimensions A={A1,…,A |A| }, where each dimension A t Contains | A t |Attributes 4. The collaborative control text generation method based on latent semantic space transformation according to claim 2 is characterized in that: In the maximization step, the distribution parameters are optimized based on the conditional probability to maximize the log-likelihood of the attribute distribution. The optimization formula of the distribution parameters is as follows: Among them, θ (k+1) is the parameter output after optimization in step k, which is used as the input parameter in step k+1. (k) For the parameter input before optimization in step j, given |A| dimensions A={A1,…,A |A| }, where each dimension A t Contains | A t |Attributes N is the total number of original potential representations, argmax θ To optimize θ, Denotes the i-th original latent representation H i In the properties The likelihood under is a priori of the attribute.

5. The collaborative control text generation method based on latent semantic space transformation according to claim 1 is characterized in that: After the latent space is fitted, balanced sampling is performed to obtain the latent semantic space, specifically: Use kernel density estimation modeling to mark high-density and low-density areas of attribute density in the latent semantic space; Downsampling is performed in high-density areas to reduce sample overconcentration; Supplementary sampling is performed in low-density areas to increase the number of sample points in sparse areas; Gaussian noise perturbation is added during the balanced sampling process so that the generated sample points can cover more areas of the potential space; The formula of the kernel density estimation modeling method is as follows: in, For attributes The density distribution of Represents a dimension A t The specific properties under H i is the u-th original latent representation, is the center of the attribute distribution, is the standard deviation of the attribute distribution, and K(·) is the kernel function.

6. The collaborative control text generation method based on latent semantic space transformation according to claim 5 is characterized in that: In the bidirectional mapping between the latent semantic space and the equal variance normal distribution using the adversarial training mechanism and activation vector, specifically: By jointly training the generator, encoder, and discriminator, the latent semantic space is mapped to the equal variance normal distribution. Among them, the generator learns to generate data that conforms to the latent semantic space from an equivariance normal distribution, and the generator learns to convert the latent semantic space into an equivariance normal distribution, while the discriminator improves the mapping quality of the generator and encoder through adversarial training, thereby normalizing the latent semantic space into an equivariance normal distribution.

7. The collaborative control text generation method based on latent semantic space transformation according to claim 1 is characterized in that: In constructing the total loss function, specifically: In the process of generating the original latent representation, a constrained loss function is constructed so that the original latent representation accurately models the attribute distribution and relationship; The adversarial loss is constructed during the adversarial training process to transform the latent semantic space into an equivariance normal distribution.

8. The collaborative control text generation method based on latent semantic space transformation according to claim 7 is characterized in that: Constrained loss function L S The formula is as follows: L S =w1L R +w2L C +w3L G ; Among them, w1, w2, and w3 are loss weights used to balance different optimization objectives. R To reconstruct the loss function, L C is the attribute classification loss function, L G is the attribute gap loss function.

9. The collaborative control text generation method based on latent semantic space transformation according to claim 8 is characterized in that: Reconstruction loss function L R The formula is as follows: L R =-∑ i∈i logp LM (X i ∣Prefix i ); Here, X i represents a sample sentence from the entire training set, ε i Is a perturbation vector sampled from a multivariate Gaussian distribution N(0,I) with a scaling factor λ to enhance robustness during reconstruction, Multilayer Perceptron MLP θ The disturbed H i Mapped to Prefix i , this prefix activates the language model to generate text with target attributes; Attribute classification loss function L C The formula is as follows: in, is a classifier that uses parameters π t From dimension A t Distinguishing attributes Attribute gap loss function L G The formula is as follows: Among them, H i For the i-th original potential representation, given |A| dimensions A={A1,…,A |A| }), each dimension contains |A t |Attributes Is an index set, indicating that the training data has attributes Identifiers of all sentences in Among them I t It is dimension A t The indices of all sentences with arbitrary attributes in , I is the index of the entire training data, and a unified mapping parameter φ is used to transform the sentences {X i } is encoded as Where i∈I, Encode is the first encoder.

10. A collaborative control text generation system based on latent semantic space transformation, characterized in that: Input the original data into the text generation model to obtain the reconstructed data; The training process of the text generation model includes a latent semantic space encoding module, an original latent semantic space fitting module, an activation vector selection module, and a loss construction module; In the latent semantic space encoding module, the original data is mapped to the original latent representation space through the first encoder to generate the original latent representation; In the original latent semantic space fitting module, the original latent representation space is fitted using the EM algorithm to optimize the distribution parameters, and the fitted latent space is evenly sampled to obtain the latent semantic space; In the activation vector selection module, an adversarial training mechanism and activation vectors are used to achieve a bidirectional mapping between the latent semantic space and the equivariance normal distribution. Different attributes are linearly interpolated in the latent semantic space, and the interpolation result is mapped back to the original latent semantic space through the encoder EN after adversarial training. After decoding, the decoder in the latent semantic space encoding module obtains the multi-attribute text. The loss building module is used to build the total loss function to adjust the trainable parameters in the text generation model.

Citation Information

Cited By

  • Safe and controllable video generation method and system

    CN120897107A

  • A secure controllable video generation method and system

    CN120897107B