Text desensitization data model training method, desensitization device and equipment
By using the generative adversarial network model in text data desensitization, combined with Transformer and text-based convolutional neural network, the problem of semantic correlation and integrity of text data in the desensitization process is solved, and high-quality, low-loss data is achieved. Generate to adapt to large-scale data processing needs.
Patent Information
- Application Number
- CN202410751449.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-27
AI Technical Summary
It is difficult to maintain the semantic relevance and integrity of the data during the text data desensitization process using existing technologies. Traditional methods may change the semantics or context of the text, resulting in poor data quality after desensitization and high computational and storage overhead during large-scale data processing. It is large, has a single and complex design, and is difficult to meet the growth of data interaction traffic and complex security requirements.
Using the Generative Adversarial Networks (GANs) model, combined with the Transformer generator and the text-based convolutional neural network discriminator, through pre-built models, data preprocessing, pre-training and formal training processes, the generator and discriminator are adversarially trained, using adaptive Learning rate and policy gradient optimize the loss function to generate high-quality, realistic synthetic data.
It achieves high-quality desensitization of text data, maintains data integrity and availability, reduces information loss, improves data generation efficiency, dynamically adapts to different needs, and improves data security and practicality.
Smart Images

Figure CN118709218A
Abstract
Description
[0001] The present invention relates to the field of sensitive data security applications, and in particular to a training method, a desensitizing device, and equipment for a text desensitizing data model. Background Art
[0002] While big data technology has brought great convenience to people's lives and work, it has also brought risks to information security to a certain extent. Issues such as data governance and security, technology application security, and digital channel security have gradually become prominent, among which data leakage is particularly prominent. Since big data contains a large amount of sensitive information of users, enterprises, etc., if security protection is not in place, it will lead to information leakage, which will in turn cause a series of information security issues.
[0003] With the maturity of data analysis and the deepening of value mining, how to completely desensitize privacy-sensitive data during data exchange, sharing and use, while ensuring security and not affecting the availability of data, is an important technical difficulty in ensuring the value of data. Data desensitization, also known as data privacy removal or data deformation, is a technical mechanism for deforming and modifying sensitive data under given rules and policies. It can largely solve the problem of using sensitive data in untrusted environments and can achieve reliable protection of sensitive privacy data.
[0004] As a basic data element, there are still some problems to be solved in the desensitization of structured text data. In the process of desensitizing text data, traditional data desensitization technologies such as replacement and partial hiding may change the semantics or contextual information of the text, destroy the semantic relevance of the text data, and make the desensitized data difficult to understand or apply, which will bring challenges to further data analysis, mining and application; desensitization technologies such as obfuscation and data disturbance will lead to very poor quality of desensitized data, or even complete distortion, which reduces the practicality of the data and makes the data no longer accurate and usable; and desensitization technologies such as encryption and hashing may increase the computing and storage overhead of the system, especially when processing large-scale data; in addition, traditional data desensitization solutions are mostly based on static desensitization, with a single and fixed design process, strong specificity and targeting, complex rules, and difficult maintenance, which cannot meet the growing and complex security processing requirements of data interaction traffic. It is necessary to comprehensively consider these issues and take appropriate measures to ensure the quality and availability of data after data privacy desensitization to ensure the subsequent sharing, analysis and use of data.
[0005] The advantage of Generative Adversarial Networks (GANs) in data desensitization is that they can generate highly realistic synthetic data, protect privacy while retaining the practicality and usability of data, and learn the distribution of original data to generate synthetic data with similar statistical characteristics, reducing information loss. Compared with traditional methods, GANs can better maintain the integrity and usability of data, improve the efficiency of data generation, and dynamically adapt to different needs, thus becoming a powerful tool for data desensitization. Traditional GAN models are not very good in terms of text generation quality, and the stability of the model is difficult to balance, so it is of great significance to study model solutions in this direction. Summary of the invention
[0006] To achieve the above-mentioned purpose, the present invention proposes a training method, a desensitizing device and equipment for a text desensitizing data model.
[0007] A training method for a text desensitization data model, wherein the model used in the training method includes a generator and a discriminator, and includes a process of pre-building a model, a data random sampling process, a data pre-processing process, a pre-training process, and a formal training process; The process of pre-building the model is used to build the generator and discriminator of the generative adversarial network. The generator adopts the Transformer model, and the discriminator is built based on the text-based convolutional neural network. The data random sampling process is used to randomly sample each piece of data in the real data set to obtain a real training data set for generator training; The data preprocessing process is used to process each piece of data into a word vector using a word embedding model; The pre-training process is used to train the generator's generation ability and correct the generator's loss function; as well as to train the discriminator's discrimination ability and correct the discriminator's loss function; The formal training process is used to implement adversarial training of the generator and the discriminator. The data generated by the generator training is passed to the discriminator. The loss function in the formal training process of the generator and the discriminator is updated according to the discrimination results. Then, the next round of generator training and discriminator training is carried out. Multiple rounds are performed to train the best parameter model.
[0008] In the pre-training process, the training steps for the generator's generation capability are: Step 1.1: The generator receives the pre-training signal; each piece of data in the real training data set used for generator training is converted into a word vector after data pre-processing; the word vector is added with the word position embedding to obtain the representation vector of the input text; Step 1.2: The representation vector of the input text enters the encoder to generate the encoded information; Step 1.3: The encoded information is passed to the decoder to obtain feature representation; Step 1.4: The decoder normalizes the output of the last network layer and converts it into the probability distribution of each target word at the current moment, selects the word with the highest probability as the output, and inputs it into the decoding process at the next moment; Step 1.5: The generator generates pre-training data samples, and combines the momentum method and the adaptive learning rate method to calculate the loss error based on its loss function, optimize the model parameters, and correct the model parameters.
[0009] In the pre-training process, the loss function of the generator is:
[0010] The parameter θ represents the weight and bias of the neural network; m represents the number of training samples, x i : The true label of the i-th sample, which takes a value of 0 or 1, indicating the true category of the sample; P G (x i ; θ): Given the model parameters θ, the predicted probability that the i-th sample belongs to its true category; P G (x;θ) represents the distribution model generated by the generator.
[0011] During the pre-training process, the training steps of the judger are: Step 2.1: The discriminator receives the pre-training signal; adds a first label to each piece of data in the pre-training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with the label is pre-processed and converted into a word vector; Step 2.2: The word vector is input into the convolution layer to extract data features; Step 2.3: The convolution layer transfers the data features to the pooling layer; Step 2.4: The pooled data is transferred to the classifier; Step 2.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying the data sample data as positive sample data; calculate the loss error based on the loss function and correct the model parameters.
[0012] In the formal training process, the formal training steps on the generator side are: Step 3.1: The generator receives a formal training signal; each piece of data in the real training data set used for generator training is converted into a word vector after data preprocessing; the word vector is added with the word position embedding to obtain the representation vector of the input text; Step 3.2: The representation vector of the input text enters the encoder to generate the encoded information; Step 3.3: The encoded information is passed to the decoder to obtain feature representation; Step 3.4: The decoder normalizes the output of the last network layer and converts it into the probability distribution of each target word at the current moment, selects the word with the highest probability as the output, and inputs it into the decoding process at the next moment; Step 3.5: The generator generates formal training data samples and uses adaptive moment estimation, combining the momentum method and the adaptive learning rate method to correct the model parameters based on the loss function.
[0013] In the formal training process, the generator uses policy gradient to construct the loss function; θ ←θ+α ▽ θ log π θ ( s t ,a t ) v t θ is the policy parameter, representing the weight and bias of the neural network. It is initialized to an arbitrary value during the training process and updated in each iteration of the interaction process. The policy π is a mapping from the state space S to the action space A. α is the learning rate, and v is the t Take action a t Estimation of the value of logπ θ (s t , a t ) is the current strategy in state s t Select action a t The logarithmic probability of .
[0014] In the formal training process, the formal training steps of the discriminator are: Step 4.1: The discriminator receives the formal training signal, adds a first label to each piece of data in the formal training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with a label is preprocessed and converted into a word vector. Step 4.2: The word vector is input into the convolution layer to extract data features; Step 4.3: The feature data extracted by the convolution layer is input into the pooling layer; Step 4.4: The pooled data is input into the classifier; Step 4.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying the data sample data as positive sample data, calculate the loss error based on the loss function, and correct the model parameters.
[0015] In the formal training process, the loss function of the discriminator is: pr and p g are two probability distributions, x and y are from p r and p g A random variable sampled from , ||xy|| represents the distance between x and y, under distribution p r To the distribution p g In the set of joint distributions of , inf represents the minimum value of all possible mapping strategies, and E represents the range of all possible values.
[0016] A text desensitization device, comprising: A training module, used for training a text desensitization model based on the training method of the text desensitization model described above; The desensitization module is used to desensitize the text to be desensitized based on the text desensitization model.
[0017] An electronic device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned method when executing the program.
[0018] The beneficial effects of the present invention are: 1. A generative adversarial network model called Trans-WTGAN is proposed for text data desensitization tasks. It is a combination of the application of Transformer in GAN. The desensitized data has a low recurrence rate with the original data, which ensures the security of the desensitized data and proves the feasibility of combining the encoder-decoder with the convolutional network in text processing.
[0019] 2. Using Transformer as the generator-side model, the self-attention mechanism can handle long-range dependencies and combine with the loss function update of the gradient strategy to make the generated text quality better, generate more accurate sequences, and ensure that the generated data has the original key features, that is, to ensure a certain degree of usability.
[0020] 3. Using the idea of WGAN (Wasserstein) as the discriminator-side model helps avoid problems such as mode collapse and mode collapse during training, making the training process smoother and more reliable and improving the stability of model training.
[0021] 4. The policy gradient is used to update the network of the adversarial training generator, which is more effective in processing discrete data. The generated data has highly similar characteristics to the real data, ensuring usability.
[0022] 5. The model scheme has greater advantages than existing methods in terms of text quality and structural consistency, ensuring the effectiveness and security of desensitization, and to a certain extent ensuring the availability of privacy-sensitive data after desensitization, which is conducive to subsequent data analysis, sharing, and development environment utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic diagram of the model used in the present invention.
[0024] Figure 2 The following is a flow chart of the training method. DETAILED DESCRIPTION
[0025] The desensitization model training process for text data is as follows Figure 2 It includes the process of pre-building the model, the process of random data sampling, the process of data pre-processing, the process of pre-training, and the process of formal training.
[0026] 1. Pre-building model process The pre-built model pipeline is used to build the generator and discriminator. Figure 1 The figure shows a schematic diagram of the desensitization system used by the method of the present invention, which adopts the Trans-WTGAN network architecture, including a generator and a discriminator. Based on the Transformer model as the generator of the generative adversarial network, the model of the WGAN idea is introduced based on the text-based convolutional neural network (TextCNN) as the discriminator end, and combined with the scheme of introducing reinforcement learning policy gradient, it is trained through the Markov decision process. In the Transformer model, the global attention mechanism can effectively process long sequence data, and it performs well in the task of sequence-to-sequence discrete data generation. The Transformer model has better parallelism and can process all positions in the input sequence at the same time without calculating them one by one in sequence. This can speed up the training speed, especially for longer generated sequences, the effect is more obvious, and can provide better sample control, diversity and authenticity when performing text desensitization, and improve the quality of the desensitized text.
[0027] 2. Data Random Sampling Process Randomly sample each piece of data in the real data set to obtain the real training data set for generator training.
[0028] 3. Data Preprocessing Process The purpose of this process is to preprocess the data and process each piece of data into a word vector (word embedding) for re-input into the generative adversarial network training.
[0029] The data processing method will affect the extraction and conversion of features, and will affect the model performance to a certain extent. In order to improve the robustness and adaptability of the model and provide the possibility of achieving better prediction, classification or analysis results, the present invention mainly adopts the word embedding model to process the initial data. The words are mapped to a continuous vector space so that words with similar semantics are closer in the embedding space. Such a representation method can better capture the semantic similarity between words, thereby improving the model's ability to understand semantic information.
[0030] The present invention uses the glove (Global Vectors for Word Representation) word embedding model, which learns the vector representation of words by performing statistical analysis on a large corpus. Compared with other word embedding models, such as Word2Vec, glove models the statistical information of the corpus globally rather than a local context window. This can better capture the global semantic relationship between words. The basic idea is to learn the vector representation of words by minimizing a loss function so that these representations can reflect the co-occurrence probability between words in the vector space. It produces word vectors with rich semantic information and performs well in natural language processing tasks such as semantic similarity calculation, sentiment analysis, and semantic reasoning.
[0031] 4. Pre-training process The purpose of pre-training is to enable the generator to have a certain generation ability before formal training; the discriminator has a certain discrimination ability before formal training, so the generator is trained to generate data, and the discriminator receives the pre-trained generated data and real data of the generator to train its discrimination ability.
[0032] Generator pre-training process: Step 1.1: The generator receives the pre-training signal. The generator training uses each piece of data from the real training data set to be converted into a word vector (word embedding) after data preprocessing. The word vector is added with the word position embedding (obtained by position encoding) to obtain the representation vector of the input text.
[0033] Step 1.2: The representation vector of the input text enters the encoder to generate the encoded information.
[0034] Step 1.3: The encoded information is passed to the decoder to obtain feature representation (attention mechanism and normalization).
[0035] Step 1.4: The decoder (softmax function) normalizes the output of the last network layer (fully connected layer) and converts it into the probability distribution of each target word at the current moment. It selects the word with the highest probability as the output (i.e. the generated "fake data") and inputs it into the decoding process at the next moment.
[0036] Step 1.5: The generator generates pre-training data samples, and combines the momentum method and the adaptive learning rate method to calculate the loss error based on its loss function, optimize the model parameters, and correct the model parameters.
[0037] Loss function of the generator pre-training process (Formula 3): Maximum likelihood estimation (MLE) is used as a loss function to find the parameter value that can maximize the probability density function (likelihood function, such as Formula 1) of the sample data. The core of MLE is the negative log-likelihood loss. Likelihood refers to the unknown parameters that affect the probability. The parameters of the probability model are estimated by observing the results obtained when the unknown parameters are unknown. X is a discrete random variable, with a probability mass function p Depends on the parameter θ, which represents the weight and bias of the neural network, and L is the likelihood function of the parameter θ. x is a random variable X Any value in the collection.
[0038] (1) The maximum likelihood estimate is the parameter i The distribution model generated by the generator P G (x; θ) is as close to the distribution model of the real data as possible P data (x), as in formula (2), the likelihood function is obtained L The largest parameter i * , It can make P data The sample of (x) is P G The (x; θ) distribution model has the highest probability of appearing, that is, P G (x;θ) and P data (x) is closest.
[0039] (2) Among them, x i Represents the label or value of the ith observation data point. Taking the logarithm turns continuous multiplication into continuous addition, which makes it easy to calculate the derivative. The log likelihood is the logarithm of the probability distribution, as shown in formula (3). Maximizing the likelihood function is equivalent to minimizing the negative of the log likelihood function, that is, minimizing the negative log likelihood.
[0040] The loss function formula is as follows: (3) m represents the number of training samples, x i : The true label of the i-th sample, which takes a value of 0 or 1, indicating the true category of the sample; P G (x i ; θ): Given the model parameters θ, the predicted probability that the i-th sample belongs to its true category.
[0041] In this embodiment, the optimization method of the generator adopts adaptive moment estimation (Adam), which combines the momentum method and the adaptive learning rate method to optimize the model parameters and maintain an adaptive learning rate for each parameter, thereby effectively updating the network parameters and reducing the loss value.
[0042] Discriminator pre-training process: Step 2.1: The discriminator receives the pre-training signal; adds a first label to each piece of data in the pre-training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with the label is pre-processed and converted into a word vector; In this embodiment, the first tag is 0, and the second tag is 1. In actual applications, the values can be set as needed.
[0043] Step 2.2: The word vector is input into the convolution layer to extract data features.
[0044] Step 2.3: The convolutional layer transfers the data features to the pooling layer.
[0045] The purpose of this step is to reduce the dimension and extract more representative features. Texts of different lengths are represented as feature vectors of the same length, which are one-dimensional vectors.
[0046] Step 2.4: The pooled data is transferred to the classifier (binary classification).
[0047] Step 2.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying negative sample data as positive sample data, calculate the loss error based on the loss function, and correct the model parameters.
[0048] For the discriminator, accuracy refers to the probability of identifying real data as true and identifying generated data ("fake data") as false. The higher this probability, the better the discriminator performance. The discriminator's loss function is updated with this probability in order to improve the discriminator's accuracy. For the generator, the closer the generated data is to the real sample (that is, the higher the probability that "fake data" is identified as real data), the better the generator performance. Therefore, the probability that the discriminator identifies "fake data" as true is used to update the generator's loss function to improve the generator's performance. A good adversarial model requires the performance of the discriminator and the generator to reach a dynamic balance. It is not possible to optimize the performance of the generator or the discriminator alone. This is constantly debugged during specific training to obtain the optimal model.
[0049] 5. Formal Training Process The formal training is the adversarial training of the generator and the discriminator, which is equivalent to the data generated by the generator training being passed to the discriminator. The discriminator is trained after receiving the real data and the data generated by the generator. Its discrimination results are used to update the loss functions of the generator and the discriminator, and then the next round of generator training and discriminator training are carried out. Multiple rounds are performed to train the best parameter model.
[0050] Generator-side formal training process: Step 3.1: The generator receives a formal training signal; each piece of data in the real training data set used for generator training is converted into a word vector through data preprocessing; the word vector is added with the word position embedding to obtain the representation vector of the input text.
[0051] Step 3.2: The representation vector of the input text enters the encoder to generate the encoded information.
[0052] Step 3.3: The encoded information is passed to the decoder to obtain feature representation (attention mechanism and normalization).
[0053] Step 3.4: The decoder (softmax function) normalizes the output of the last network layer and converts it into the probability distribution of each target word at the current moment. It selects the word with the highest probability as the output (i.e. the generated "fake data") and inputs it into the decoding process at the next moment.
[0054] Step 3.5: The generator generates formal training data samples and uses adaptive moment estimation (Adam), combining the momentum method and the adaptive learning rate method, to optimize the model parameters and maintain an adaptive learning rate for each parameter, thereby effectively updating the network parameters and reducing the loss value.
[0055] The following is an introduction to the loss function of the generator's formal training process: Use Policy Gradient to construct the loss function. The pseudo code of the Policy Gradient algorithm is as follows: Algorithm 1 Policy Gradient algorithmic principles pseudo-code: function REINFORCE Initialise i arbitrarily for each episode {s 1 ,a 1 ,r 2 ,...,s T-1 ,a T-1 ,r T }~π θ do for t=1 to T-1 do θ ←θ+α ▽ θ log π θ ( s t ,a t ) v t end for end for return i end function The policy π is a mapping from the state space S to the action space A, which defines the action that should be taken in a given state. θ is the parameter used to parameterize the policy π, which is initialized to an arbitrary value during the training process and updated in each iteration of the interaction process. For each episode, according to the current policy π θ Generate a series of states s and actions a. For each time step in the episode, perform a policy parameter update step. α is the learning rate, v is the time in state s t Take action a t An estimate of the value of logπ θ (s t , a t) is the current strategy in state s t Select action a t The update is the update of the policy parameters θ along the direction of the policy gradient, increasing the log probability of the chosen action times the expected advantage v.
[0056] In reinforcement learning, an episode refers to a complete interaction process from the start state to the end state. In this process, the agent interacts with the environment in a series of steps, each of which consists of a state (s t ), an action t ) and a reward (rt). So, for each episode, we can get a sequence { s 1 ,a 1 ,r 2 ,...,s T-1 ,a T-1 , r T},in s 1 is the initial state, a 1 is the action taken in state s1, r 2 Is to take a 1 The reward after the action, and so on, until the last state s T-1 And the last action a T-1 , and the last reward received r T .
[0057] In this sequence, the gradient policy r refers to the gradient of the loss function used in the policy gradient algorithm. The goal of the policy gradient algorithm is to optimize the policy parameters θ so as to maximize the cumulative reward. To do this, the algorithm needs to calculate the gradient of the policy, which is the gradient of the policy parameters θ with respect to the cumulative reward. This gradient tells the algorithm how to adjust θ to increase the probability of taking a certain action in a given state, thereby improving the cumulative reward.
[0058] Specifically, the policy gradient algorithm calculates the cumulative reward for each episode and associates it with the policy parameter θ. Then, it calculates the policy gradient, which is the gradient of the cumulative reward with respect to θ. This gradient is used to update θ so that more favorable actions are taken in future episodes.
[0059] In pseudocode, the gradient policy r usually refers to some form of reward or advantage used when calculating the policy gradient. Advantage is the difference between the cumulative reward and the state value, which indicates how better than average it is to take an action in a given state. By maximizing the advantage, the policy gradient algorithm can more effectively learn how to choose the best action.
[0060] Therefore, the gradient policy r mentioned in the pseudocode refers to the part used for policy gradient update, which measures the difference between the expected reward and the average reward of taking a specific action in a given state, and updates the policy parameters θ accordingly.
[0061] Formal training process of the discriminator: Step 4.1: The discriminator receives the formal training signal, adds a first label to each piece of data in the formal training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with a label is preprocessed and converted into a word vector.
[0062] Step 4.2: The word vector is input into the convolutional layer to extract data features.
[0063] Step 4.3: The feature data extracted by the convolutional layer is input into the pooling layer.
[0064] Step 4.4: The pooled data is input into the classifier (binary classification).
[0065] Step 4.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying negative sample data as positive sample data, calculate the loss error based on the loss function, and correct the model parameters.
[0066] During the formal training of the discriminator, Wasserstein distance (also known as Earth-Mover (EM) distance) is used as the loss function, i.e. WGAN, and Wasserstein distance is used instead of the traditional JS divergence, as shown in Formula 5. Wasserstein distance is a metric used to measure the difference between two probability distributions. Unlike common distance metrics (such as Euclidean distance or KL divergence), it takes into account the structure and shape between two distributions, not just the difference between them. Wasserstein distance provides a more accurate way to measure the difference between two distributions, especially in the case of high-dimensional or complex distributions, which is more advantageous than traditional distance metrics. Used as a loss function, it can promote the generation of more stable and high-quality generated samples. Through the loss value calculated by the loss function, the discriminator returns the gradient information corresponding to the sample generated by the generator. This gradient information can be used to train the generator to help the generator generate samples that are closer to the real data distribution. The discriminator usually also needs to return a loss value to measure the difference between the sample generated by the generator and the real data distribution. This loss value can be used as a feedback signal for the training of the generator. According to the gradient information and loss value returned by the discriminator, the generator can adopt corresponding update strategies and adjust the parameters of the generator to improve the performance of the generator.
[0067] (5) p r and p g are two probability distributions, x and y are from p r and p g A random variable sampled from , ||xy|| represents the distance between x and y, under distribution p r To the distribution p g In the set of joint distributions of , inf represents the minimum value of all possible mapping strategies, and E represents the range of all possible values.
[0068] The present application also provides a text desensitization device, including a training module and a desensitization module.
[0069] The training module is used to train a text desensitization model based on the aforementioned training method of the text desensitization model.
[0070] The desensitization module is used to desensitize the text to be desensitized based on the text desensitization model.
[0071] The present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned training method when executing the program.
[0072] The present application also provides a computer-readable medium, which carries computer-executable instructions, and the computer-executable instructions are used to implement the aforementioned training method when executed by a processor.
Claims
1. A training method for a text desensitization data model, wherein the model used in the training method includes a generator and a discriminator, and is characterized in that: Including the process of pre-building the model, random data sampling, data pre-processing, pre-training, and formal training; The process of pre-building the model is used to build the generator and discriminator of the generative adversarial network. The generator adopts the Transformer model, and the discriminator is built based on the text-based convolutional neural network. The data random sampling process is used to randomly sample each piece of data in the real data set to obtain a real training data set for generator training; The data preprocessing process is used to process each piece of data into a word vector using a word embedding model; The pre-training process is used to train the generator's generation ability and correct the generator's loss function; And, train the discriminant ability of the discriminator and correct the loss function of the discriminator; The formal training process is used to implement adversarial training of the generator and the discriminator. The data generated by the generator training is passed to the discriminator. The loss function in the formal training process of the generator and the discriminator is updated according to the discrimination results. Then, the next round of generator training and discriminator training is carried out. Multiple rounds are performed to train the best parameter model.
2. The method for training a text desensitization data model according to claim 1, characterized in that: In the pre-training process, the training steps for the generator's generation capability are: Step 1.1: The generator receives the pre-training signal; each piece of data in the real training data set used for generator training is converted into a word vector after data pre-processing; the word vector is added with the word position embedding to obtain the representation vector of the input text; Step 1.2: The representation vector of the input text enters the encoder to generate the encoded information; Step 1.3: The encoded information is passed to the decoder to obtain feature representation; Step 1.4: The decoder normalizes the output of the last network layer and converts it into the probability distribution of each target word at the current moment, selects the word with the highest probability as the output, and inputs it into the decoding process at the next moment; Step 1.5: The generator generates pre-training data samples, and combines the momentum method and the adaptive learning rate method to calculate the loss error based on its loss function, optimize the model parameters, and correct the model parameters.
3. The training method for a text desensitization data model according to claim 1, characterized in that: In the pre-training process, the loss function of the generator is: ; The parameters θ represent the weights and biases of the neural network; m represents the number of training samples, x i : The true label of the i-th sample, which takes a value of 0 or 1, indicating the true category of the sample; P G (x i ; θ): Given the model parameters θ, the predicted probability that the i-th sample belongs to its true category; P G (x;θ) represents the distribution model generated by the generator.
4. The method for training a text desensitization data model according to claim 1, characterized in that: During the pre-training process, the training steps of the judger are: Step 2.1: The discriminator receives the pre-training signal; adds a first label to each piece of data in the pre-training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with the label is pre-processed and converted into a word vector; Step 2.2: The word vector is input into the convolution layer to extract data features; Step 2.3: The convolution layer transfers the data features to the pooling layer; Step 2.4: The pooled data is transferred to the classifier; Step 2.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying the data sample data as positive sample data; calculate the loss error based on the loss function and correct the model parameters.
5. The method for training a text desensitization data model according to claim 1, characterized in that: In the formal training process, the formal training steps on the generator side are: Step 3.1: The generator receives a formal training signal; each piece of data in the real training data set used for generator training is converted into a word vector after data preprocessing; the word vector is added with the word position embedding to obtain the representation vector of the input text; Step 3.2: The representation vector of the input text enters the encoder to generate the encoded information; Step 3.3: The encoded information is passed to the decoder to obtain feature representation; Step 3.4: The decoder normalizes the output of the last network layer and converts it into the probability distribution of each target word at the current moment, selects the word with the highest probability as the output, and inputs it into the decoding process at the next moment; Step 3.5: The generator generates formal training data samples and uses adaptive moment estimation, combining the momentum method and the adaptive learning rate method to correct the model parameters based on the loss function.
6. The method for training a text desensitization data model according to claim 5, characterized in that: In the formal training process, the generator uses policy gradient to construct the loss function; θ←θ+α ▽ θ log π θ ( s t ,a t ) v t θ is the policy parameter, representing the weight and bias of the neural network. It is initialized to an arbitrary value during the training process and updated in each iteration of the interaction process. The policy π is a mapping from the state space S to the action space A. α is the learning rate, and v is the t Take action a t Estimation of the value of logπ θ (s t , a t ) is the current strategy in state s t Select action a t The logarithmic probability of .
7. The method for training a text desensitization data model according to claim 1, characterized in that: In the formal training process, the formal training steps of the discriminator are: Step 4.1: The discriminator receives the formal training signal, adds a first label to each piece of data in the formal training data sample generated by the generator, and adds a second label to each piece of data in the real data set. Each piece of data with a label is preprocessed and converted into a word vector. Step 4.2: The word vector is input into the convolution layer to extract data features; Step 4.3: The feature data extracted by the convolution layer is input into the pooling layer; Step 4.4: The pooled data is input into the classifier; Step 4.5: According to the classification results of the classifier, obtain the accuracy of the discriminator recognition and the probability of identifying the data sample data as positive sample data, calculate the loss error based on the loss function, and correct the model parameters.
8. The method for training a text desensitization data model according to claim 7, characterized in that: In the formal training process, the loss function of the discriminator is: p r and p g are two probability distributions, x and y are from p r and p g A random variable sampled from , ||xy|| represents the distance between x and y, under distribution p r To the distribution p g In the set of joint distributions of , inf represents the minimum value of all possible mapping strategies, and E represents all possible ranges.
9. A text desensitization device, characterized in that: include A training module, used for training a text desensitization model based on the training method of a text desensitization model according to any one of claims 1 to 7; The desensitization module is used to desensitize the text to be desensitized based on the text desensitization model.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Flow data desensitization method and device based on deep learning and model training method and device based on deep learning
CN120180506A
Traffic data desensitization method, model training method and device based on deep learning
CN120180506B
