Generated text detection method based on fine-grained game confrontation
By adopting a fine-grained game adversarial method in AI-generated text detection, alternating training of generators and discriminators, and combining Bellman equations and Clip-PPO optimization generation strategies, the shortcomings of existing detection methods in terms of accuracy and robustness are solved, and efficient detection of AI-generated text and mixed text are achieved.
Patent Information
- Application Number
- CN202411573000.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-03-04
AI Technical Summary
Existing AI-generated text detection methods have shortcomings in terms of detection accuracy and robustness, especially when facing mixed text.
The detection method based on fine-grained game adversariality is adopted, and the generator and discriminator are initialized by initializing the discriminator D and the generator G, and the generator and discriminator are trained alternately. The generation strategy and content of the generator are optimized using the Bellman equation and the Clip-PPO method, and combined with the loss function of text confusion, the accuracy and robustness of the detection are improved.
It improves the accuracy and robustness of AI-generated text detection, can effectively identify mixed text, reduces the risk of attacks against samples, and improves the overall performance of detection.
Smart Images

Figure CN119557446A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of generated text detection, and in particular relates to a generated text detection method based on fine-grained game confrontation. Background Art
[0002] After self-supervised training on massive corpora, large models can generate texts with high fluency and high fidelity, bringing many conveniences in advertising marketing, machine translation, educational assistance and other fields. However, the illusion and uncontrollable characteristics of large models also bring potential threats. For example, false news generated by large models may mislead the public and cause social panic; malicious content generated by large models may spread prejudice and discrimination and endanger network security. In order to deal with the above problems, academia and industry have begun to study how to effectively detect AI-generated texts. Traditional detection methods are based on text statistical features such as perplexity, logarithmic probability, and entropy. Such methods have poor robustness and are easily attacked by adversarial samples, resulting in a significant decrease in detection accuracy. In addition, fine-tuning techniques based on contrastive loss have improved the accuracy of detecting AI-generated texts, but such methods rely on the quality of artificially constructed samples and are prone to overfitting in a single distribution. Current detection methods mainly regard generated text detection as a binary classification task for human text and AI text. There are a large number of mixed texts spliced by AI text and human text on the Internet, which makes the above two methods ineffective in detecting mixed texts. Summary of the invention
[0003] 1. Technical issues to be resolved
[0004] The technical problem to be solved by the present invention is to design an AI generated text detection method to improve the accuracy and robustness of AI generated text detection.
[0005] (II) Technical solution
[0006] In order to solve the above technical problems, the present invention provides a generated text detection method based on fine-grained game confrontation, comprising the following steps:
[0007] Step 1: Initialize the model and corpus
[0008] (1) Initialize the discriminator D and generator G, and prepare the initial human text
[0009] The goal of the discriminator D is to transform the human text T H , AI text T generated by generator G A , Mixed Text T MCorrect classification; the goal of the generator G is to confuse the discrimination process of the discriminator D by generating AI text or splicing AI text with human text; the discriminator D uses the pre-trained Roberta-Large model, and the generator G uses the LLaMa3-8B-Instruct model; and set the temperature and sampling probability of the LLaMa3-8B-Instruct model;
[0010] Collect human texts, perform data cleaning and preprocessing, and annotate the cleaned texts as pure human texts;
[0011] Step 2: Construct a training dataset
[0012] (1) Use the generator G to generate AI text T A and mixed text T M
[0013] In the generation strategy, the generator G has This state represents the AI text T generated by the generator G in this round. A and mixed text T M of different proportions; that is, the generator G generates P% AI text and (1-P)% mixed text in this round of text generation, and each state corresponds to a ratio of AI text to mixed text; for AI text, the LLaMa3-8B-Instruct model is used to expand the semantics of the first 10 words of human text to complete the construction of AI text; for mixed text, the human text and AI text are spliced in a 1:1 ratio using the large model-based prompt engineering technology, and the human text and AI text are connected through certain changes to make the previous and next sentences connect smoothly;
[0014] Before generating text, the generator G first calculates the advantage value based on the discrimination result of the previous round of the discriminator D, and updates the current state of the generator G according to the advantage value to determine the ratio of AI text and mixed text in the generated text of this round;
[0015] Generator G updates its text generation strategy based on the Bellman equation. The Bellman equation describes the relationship between the reward of generator G adopting a certain text generation strategy in a certain state and the reward of the future state. Based on the Bellman equation, the state of generator G is updated before each round of text generation, and the proportion of the two types of text in this round of generation is adjusted according to the state.
[0016] After obtaining the new text generation strategy, select the action a of this round according to the strategy of maximizing the expected Q value t , the generator G selects action a according to this round t, AI text and mixed text are generated at a ratio of P% and (1-P)%; the total number of AI text and mixed text is M; wherein the generator G generates AI text and mixed text at a ratio of 1:1 when generating the first round of training data;
[0017] (2) Construct a training dataset for the discriminator D
[0018] According to the number of texts M generated by the generator G in step (1) of step 2, M human texts are sampled from the cleaned data in step 1, and the M AI texts and mixed texts generated by the generator G in step (1) of step 2 and the M human texts sampled in step 1, a total of 2M texts, are shuffled to form the data set of the discriminator d in this round; the data set consists of 2M texts, including M×P% AI texts, M×(1-P)% mixed texts, and M human texts; then the data set is divided into a training set ε according to a ratio of 9:1 t and validation set ε v ;
[0019] Step 3: Alternate training of the generator and discriminator
[0020] (1) Training the discriminator D
[0021] Use the training set ε generated in step 2 t , supervised training is performed on the discriminator D; for each input text x, the discriminator D classifies the text x into one of the following three categories:
[0022] 1. Human Text T H ;
[0023] 2. Text completely generated by AI A ;
[0024] 3. Mixed text composed of AI text and human text M ;
[0025] Calculate the weighted loss for the discriminator D's misclassification of the three types of text, and after obtaining the weighted loss of the discriminator D in this round of training, perform gradient backpropagation to optimize the model parameters of the discriminator D;
[0026] (2) Training the generator G
[0027] Use the trained discriminator D to get the discriminator D for the AI-generated text T A and mixed text T M The normalized advantage value A(x,D) of the generator G is calculated, and the model parameters of the generator G are updated using the proximal strategy optimization method according to the advantage value of the generator G in this round of training and the perplexity characteristics of the text generated by the generator G;
[0028] According to the difference between the large model and humans in perplexity characteristics, a loss function combining Clip-PPO and text perplexity is designed; Clip-PPO is a policy gradient optimization method that can optimize the generator parameters according to the generator's advantage value; and the text perplexity indicator encourages the text generated by the generator G to change continuously within a certain range to improve the fidelity of the generated text;
[0029] In each round of training, according to the loss function L G The loss of the generated generator G is back-propagated to optimize the parameters of the generator G;
[0030] (3) Determine convergence
[0031] Determine whether the verification loss of the discriminator D and the generator G converges during the training process. If one of them does not converge or both do not converge, return to step 2. If the verification loss of both has converged, the training ends and the final AI-generated text discriminator D is obtained.
[0032] Step 4: Use the discriminator D generated in step 3 to detect the AI-generated text and obtain the detection result.
[0033] The present invention also provides a system for implementing the method.
[0034] (III) Beneficial effects
[0035] The present invention provides an AI generated text detection method based on fine-grained game confrontation, the main advantages of which are reflected in the following aspects:
[0036] (1) The definition of the AI-generated text detection task is expanded. This paper defines a cross-sentence-level three-classification AI-generated text detection task for the first time, and adds the detection of mixed text (text composed of AI text and human text). This extension refines the granularity of text detection, allowing the discriminator to not only detect pure human text and pure AI text, but also effectively identify mixed text, thereby improving the accuracy and robustness of AI-generated text detection.
[0037] (2) A fine-grained generator training method is designed. In the alternating training of the generator and the discriminator, the generator selects the proportion of the generated text in this round based on the Bellman equation after obtaining the feedback results of the discriminator, that is, the proportion of AI text and mixed text in the generated text. The Clip-PPO method is used, combined with a feedback advantage value and a loss function of perplexity, to continuously improve the fidelity and diversity of the generated text.
[0038] (3) A fine-grained discriminator training method is designed. In each round of alternating training, human text, generated AI text and mixed text are added to the training data of the discriminator. Based on the above three types of text, the present invention designs a three-class weighted loss function for discriminator training to improve the accuracy and robustness of the discriminator. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is the overall framework diagram of the detection model designed in the method of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0041] The present invention proposes an AI generated text detection method based on fine-grained game confrontation, which mainly solves three problems. First, in view of the problem that the current AI generated text detection task definition granularity is insufficient, a three-category AI generated text detection task across the sentence level is proposed. Second, in view of the problem that the statistical feature method has poor robustness and is easily attacked by targeted adversarial samples, a training mechanism based on game confrontation is studied; third, in view of the problem that the fine-tuning method relies on the quality of artificially constructed samples and is prone to overfitting in a single distribution, fine-grained generation strategies and generation content are studied to improve the diversity of samples and refine the discriminant granularity of the discriminator.
[0042] Taking into account the problems that the current AI-generated text detection tasks are coarse-grained, the methods based on statistical features have poor robustness, and the methods based on fine-tuning are heavily dependent on the quality of manually constructed samples, this invention defines for the first time a cross-sentence-level three-classification AI-generated text detection task, and trains the AI-generated text detection model under dynamic game confrontation conditions without the need to manually construct a large number of samples, so as to improve the accuracy and robustness of AI-generated text detection.
[0043] In order to solve the above technical problems, the present invention provides an AI generated text detection method based on fine-grained game confrontation, in which the attack and defense process in AI generated text detection is simulated by training the generator G and the discriminator D respectively; wherein the goal of the discriminator D is to convert human text T H , AI text T generated by generator G A , Mixed Text T MCorrect classification; the goal of the generator G is to confuse the discrimination process of the discriminator D by generating AI text or splicing AI text with human text; for the training of the discriminator D, the present invention uses the weighted classification loss of human text, AI text and mixed text to train the discriminator D; for the training of the generator G, the present invention uses the Bellman equation to provide a reward signal for the generator G, so that the generator G dynamically selects the generation ratio of AI text and mixed text, and continuously improves the fidelity and diversity of the text generated by the generator G through a loss function based on advantage value and perplexity; the training of the discriminator D and the generator G is performed alternately until the loss functions of the two converge.
[0044] In addition, in order to improve the research granularity in the field of AI-generated text detection, this paper defines for the first time a cross-sentence-level three-classification AI-generated text detection task: given a piece of text, correctly classify the text according to the following labels:
[0045] 1: Human text, written entirely by humans, is text that is not generated or modified by AI H ;
[0046] 2: AI text is text generated entirely by AI A ;
[0047] 3: Hybrid text, which uses a large model to splice AI text with minor changes A With human text T H The text T M .
[0048] Recently, two other AI-generated text detection tasks related to mixed text have emerged. The first way is to find the dividing line between AI text and human text when it is known that the text consists of a piece of AI text and a piece of human text. However, in reality, we cannot predict in advance which texts are completed by AI and humans. Another way is to distinguish which type of text is human text, AI text, or mixed text by distinguishing sentence by sentence. However, detecting the source of text in units of sentences will lose the global semantic association between sentences, greatly reducing the accuracy of detection. Therefore, the present invention defines the above-mentioned three-category AI-generated text detection task across sentence levels: for a piece of text, consisting of multiple sentences (usually more than 100 words in length), it is determined whether the text is human text, AI text, or mixed text. Among them, human text means that the text is written by humans, AI text means that the text is generated by AI, and mixed text means that the text is spliced by a large model from human text and AI text.
[0049] Based on the above design principles, the detection model proposed by the present invention is as follows Figure 1As shown in Figure 1, the detection method designed based on this model mainly includes the following three steps: (1) Initialize the model and corpus; (2) Construct a discriminator training dataset; (3) Alternately train the generator and the discriminator until the loss functions of the two converge. The details are as follows:
[0050] Step 1: Initialize the model and corpus
[0051] (1) Initialize the discriminator D and generator G, and prepare the initial human text
[0052] The discriminator D uses the pre-trained Roberta-Large model, and the generator G uses the LLaMa3-8B-Instruct model. By setting parameters such as the temperature and sampling probability of the LLaMa3-8B-Instruct model, the fluency and diversity of the initial generated text are balanced.
[0053] We collect high-quality human texts from news, scientific literature, encyclopedias, and other fields, and perform data cleaning and preprocessing, including noise removal, typos correction, and format standardization. The cleaned texts are clearly marked as pure human texts for subsequent training and verification.
[0054] Step 2: Construct a training dataset
[0055] (1) Use the generator G to generate AI text T A and mixed text T M
[0056] In the generation strategy, the generator G has This state represents the AI text T generated by the generator G in this round. A and mixed text T M of different proportions; that is, the generator G generates P% AI text and (1-P)% mixed text in this round of text generation, and each state corresponds to a ratio of AI text to mixed text; for AI text, the LLaMa3-8B-Instruct model is used to expand the semantics of the first 10 words of the human text to complete the construction of the AI text; for mixed text, the human text and AI text are spliced in a 1:1 ratio using the large model-based prompt engineering technology, and the human text and AI text are connected with minor changes to make the previous and next sentences smooth.
[0057] Before generating text, generator G first calculates the advantage value based on the discrimination result of the previous round of discriminator D, and updates the current state of generator G according to the advantage value to determine the proportion of AI text and mixed text in the text generated this round.
[0058] The advantage value of the generator G corresponds to the sum of the probabilities that the discriminator D misclassifies the AI text and the mixed text, which is calculated as:
[0059]
[0060] in, represents the probability that the discriminator D misclassifies AI text as human text, represents the probability that the discriminator D misclassifies the AI text as mixed text, represents the probability that the discriminator D misclassifies the mixed text as human text, represents the probability that the discriminator D misclassifies the mixed text as AI text;
[0061] Norm is a normalization operator; taking input y as an example, the calculation method of Norm is:
[0062]
[0063] Generator G updates its text generation strategy based on the Bellman equation, which describes the relationship between the reward for generator G to adopt a certain generation strategy in a certain state and the reward of the future state. Based on the Bellman equation, the state of generator G is updated before each round of text generation, and the proportion of the two types of text in this round of generation is adjusted according to the state. In this way, generator G can adopt a better generation ratio in this round of training to maximize the probability of misjudgment of discriminator D. This dynamic generation strategy enables generator G to not only respond to the feedback of the current discriminator D, but also predict the subsequent discrimination strategy of discriminator D based on future reward signals, thereby improving the fidelity and naturalness of the generated text.
[0064] Among them, the Bellman equation corresponding to the text generation strategy is:
[0065]
[0066] Among them, s t 、s t+1 are the states of the generator G at time t and t+1, respectively, t is the action selected by generator G at time t, a is the set of actions that generator G can take, α is the learning rate, r t To take action a t The reward received after is the advantage value of generator G. It is the maximum Q value of all possible actions in the next state, representing the expected value of future rewards. γ is a preset discount factor used to balance the importance of immediate rewards and future rewards.
[0067] After obtaining the new text generation strategy, select the action a of this round according to the strategy of maximizing the expected Q value t :
[0068]
[0069] Generator G selects action a according to this round t , AI text and mixed text are generated in the ratio of P% and (1-P)%; the total number of AI text and mixed text is M; among them, when the generator G generates the first round of training data, it generates AI text and mixed text in the ratio of 1:1.
[0070] (2) Construct a training dataset for the discriminator D
[0071] According to the number of texts M generated by the generator G in step (1) of step 2, M human texts are sampled from the cleaned data in step 1, and the M AI texts and mixed texts generated by the generator G in step (1) of step 2 and the M human texts sampled in step 1, a total of 2M texts, are shuffled to form the data set ε of the discriminator D in this round. The data set ε consists of 2M texts, including M×P% AI texts, M×(1-P)% mixed texts, and M human texts; then the data set is divided into 9:1 ε Get the training set ε t and validation set ε v .
[0072] Step 3: Alternate training of the generator and discriminator
[0073] (1) Training the discriminator D
[0074] Use the training set ε generated in step 2 t , supervised training is performed on the discriminator D; for each input text x, the discriminator D classifies the text x into one of the following three categories:
[0075] 1: Human text T H ;
[0076] 2: Text completely generated by AI A ;
[0077] 3: Mixed text composed of AI text and human text M ;
[0078] The weighted loss is calculated for the discriminator D's misclassification of the three types of text. The discriminator D uses the following loss function L D Calculate the weighted loss:
[0079]
[0080] in, To determine the loss of human text, To determine the loss of AI text, To discriminate the loss of mixed text, λ1 and λ2 are the weights of AI text loss and mixed text loss respectively.
[0081] After obtaining the weighted loss of the discriminator D in this round of training, gradient backpropagation is performed to optimize the model parameters of the discriminator D.
[0082] (2) Training the generator G
[0083] Use the trained discriminator D to get the discriminator D for the AI-generated text T A and mixed text T M The normalized advantage value A(x,D) of the generator G is calculated, and the model parameters of the generator G are updated using the proximal strategy optimization method according to the advantage value of the generator G in this round of training and the perplexity characteristics of the text generated by the generator G. For the perplexity indicator, the perplexity of the text generated by the large model is low and tends to be stable, while the perplexity of the text generated by humans often changes continuously. The perplexity is calculated as follows:
[0084]
[0085] Where N is the total number of words in the text x, and w i is the i-th word in text x, P(w i |w1,w2,…,w i-1 ) is the i-th word w given the first i-1 words i The probability of generation.
[0086] According to the difference between the large model and humans in perplexity characteristics, the present invention proposes a loss function that combines Clip-PPO and text perplexity. Among them, Clip-PPO is a policy gradient optimization method that can optimize the generator parameters according to the advantage value of the generator in a relatively stable way; while the text perplexity index encourages the text generated by the generator G to change continuously within a certain range to improve the fidelity of the generated text. The loss function of the generator G designed accordingly is:
[0087]
[0088] Among them, r(θ) is the advantage value coefficient, which is used to balance the proportion of the advantage value in the current round of loss calculation, min(r(θ)A(x,D),clip(r(θ),1-∈,1+∈)A(x,D)) is the advantage value of the generator G, corresponding to the discriminator D to T A and T MThe probability of misjudgment; by minimizing min and clipping operations, the advantage value does not exceed the upper bound 1+∈, stabilizing the training process; PPL(x) is the perplexity of text x; is the variance of AI text perplexity, which is used to measure the range of variation of text perplexity; is the feedback value of the AI text perplexity. By encouraging the generator G to generate AI texts with perplexity varying within a preset range (a, b), the realism of the AI text can be improved. β is the coefficient of the perplexity reward, which is used to adjust the impact of the perplexity variance on the generator G.
[0089] In each round of training, according to the loss function L G The loss of the generated generator G is back-propagated to optimize the parameters of the generator G.
[0090] (3) Determine convergence
[0091] Determine whether the verification loss of the discriminator D and the generator G during the training process (the verification loss curve will be obtained during the training process) converges. If one of them has not converged or both have not converged, return to step 2 (train one round, optimize one round, and then use the optimized new model to generate data for the next round of adversarial training during the training process); if the verification losses of both have converged, the training is completed and the final discriminator D for AI generated text is obtained.
[0092] Step 4: Use the discriminator D generated in step 3 to detect the AI-generated text and obtain the detection result.
[0093] It can be seen that the method of the present invention constructs a high-precision AI-generated text discriminator through game adversarial training of the generator and the discriminator. The construction of the discriminator includes: initializing the generator and the discriminator; constructing a discriminator training set; training the discriminator to classify human text, AI text, and mixed text; optimizing the generator generation strategy and generated content according to the discrimination results; alternating training of the generator and the discriminator until the loss converges; the design of the loss function comprehensively considers the discriminator feedback and text quality indicators to optimize the fidelity and naturalness of the text generated by the generator. Through this method, the present invention improves the accuracy and robustness of AI-generated text detection, and has broad application prospects.
[0094] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A generated text detection method based on fine-grained game confrontation, characterized in that: The following steps are involved: Step 1: Initialize the model and corpus (1) Initialize the discriminator D and generator G, and prepare the initial human text The goal of the discriminator D is to transform the human text T H , AI text T generated by generator G A , Mixed Text T M Correct classification; the goal of the generator G is to confuse the discrimination process of the discriminator D by generating AI text or splicing AI text with human text; the discriminator D uses the pre-trained Roberta-Large model, and the generator G uses the LLaMa3-8B-Instruct model; and set the temperature and sampling probability of the LLaMa3-8B-Instruct model; Collect human texts, perform data cleaning and preprocessing, and annotate the cleaned texts as pure human texts; Step 2: Construct a training dataset (1) Use the generator G to generate AI text T A and mixed text T M In the generation strategy, the generator G has This state represents the AI text T in the text generated by the generator G in this round. A and mixed text T M of different proportions; that is, the generator G generates P% AI text and (1-P)% mixed text in this round of text generation, and each state corresponds to a ratio of AI text to mixed text; for AI text, the LLaMa3-8B-Instruct model is used to expand the semantics of the first 10 words of human text to complete the construction of AI text; for mixed text, the human text and AI text are spliced in a 1:1 ratio using the large model-based prompt engineering technology, and the human text and AI text are connected through certain changes to make the previous and next sentences connect smoothly; Before generating text, the generator G first calculates the advantage value based on the discrimination result of the previous round of the discriminator D, and updates the current state of the generator G according to the advantage value to determine the ratio of AI text and mixed text in the generated text of this round; Generator G updates its text generation strategy based on the Bellman equation. The Bellman equation describes the relationship between the reward of generator G adopting a certain text generation strategy in a certain state and the reward of the future state. Based on the Bellman equation, the state of generator G is updated before each round of text generation, and the proportion of the two types of text in this round of generation is adjusted according to the state. After obtaining the new text generation strategy, select the action a of this round according to the strategy of maximizing the expected Q value t , the generator G selects action a according to this round t , AI text and mixed text are generated at a ratio of P% and (1-P)%; the total number of AI text and mixed text is M; wherein the generator G generates AI text and mixed text at a ratio of 1:1 when generating the first round of training data; (2) Construct a training dataset for the discriminator D According to the number of texts M generated by the generator G in step (1) of step 2, M human texts are sampled from the cleaned data in step 1, and the M AI texts and mixed texts generated by the generator G in step (1) of step 2 and the M human texts sampled in step 1, a total of 2M texts, are shuffled to form the data set of the discriminator D in this round; the data set consists of 2M texts, including M×P% AI texts, M×(1-P)% mixed texts, and M human texts; then the data set is divided into a training set ε according to a ratio of 9:1 t and validation set ε v ; Step 3: Alternate training of the generator and discriminator (1) Training the discriminator D Use the training set ε generated in step 2 t , supervised training is performed on the discriminator D; for each input text x, the discriminator D classifies the text x into one of the following three categories:
1. Human Text T H ; 2. Text completely generated by AI A ; 3. Mixed text composed of AI text and human text M ; Calculate the weighted loss for the discriminator D's misclassification of the three types of text, and after obtaining the weighted loss of the discriminator D in this round of training, perform gradient backpropagation to optimize the model parameters of the discriminator D; (2) Training the generator G Use the trained discriminator D to get the discriminator D for the AI-generated text T A and mixed text T M The normalized advantage value A(x, D) of the generator G is calculated, and the model parameters of the generator G are updated using the proximal strategy optimization method according to the advantage value of the generator G in this round of training and the perplexity characteristics of the text generated by the generator G; According to the difference between the large model and humans in perplexity characteristics, a loss function combining Clip-PPO and text perplexity is designed; Clip-PPO is a policy gradient optimization method that can optimize the generator parameters according to the generator's advantage value; and the text perplexity indicator encourages the text generated by the generator G to change continuously within a certain range to improve the fidelity of the generated text; In each round of training, according to the loss function L G The loss of the generated generator G is back-propagated to optimize the parameters of the generator G; (3) Determine convergence Determine whether the verification loss of the discriminator D and the generator G converges during the training process. If one of them does not converge or both do not converge, return to step 2. If the verification loss of both has converged, the training ends and the final AI-generated text discriminator D is obtained. Step 4: Use the discriminator D generated in step 3 to detect the AI-generated text and obtain the detection result.
2. The method according to claim 1, characterized in that In step 2, the advantage value of the generator G corresponds to the sum of the probabilities that the discriminator D misclassifies the AI text and the mixed text, which is calculated as: in, represents the probability that the discriminator D misclassifies AI text as human text, represents the probability that the discriminator D misclassifies the AI text as mixed text, represents the probability that the discriminator D misclassifies the mixed text as human text, Represents the probability that the discriminator D misclassifies the mixed text as AI text; Norm is the normalization operator.
3. The method according to claim 2, characterized in that In step 2, let the input be y, then the calculation method of Norm is:
4. The method according to claim 3, characterized in that In step 2, the Bellman equation corresponding to the text generation strategy is: Among them, s t 、s t+1 are the states of the generator G at time t and t+1, respectively, t is the action selected by generator G at time t, a is the set of actions that generator G can take, α is the learning rate, r t To take action a t The reward received after is the advantage value of the generator G. It is the maximum Q value of all possible actions in the next state, representing the expected value of future rewards. γ is a preset discount factor used to balance the importance of immediate rewards and future rewards.
5. The method according to claim 4, characterized in that In step 2, the action a of this round is selected according to the strategy of maximizing the expected Q value. t hour, 6. The method according to claim 5, characterized in that In step 3, the discriminator D uses the following loss function L D Calculate the weighted loss: in, To determine the loss of human text, To determine the loss of AI text, To discriminate the loss of mixed text, λ1 and λ2 are the weights of AI text loss and mixed text loss respectively.
7. The method according to claim 6, characterized in that In step 3, the perplexity is calculated as: Where N is the total number of words in the text x, and w i is the i-th word in text x, P(w i |w1,w2,...,w i-1 ) is the i-th word w given the first i-1 words i The probability of generation.
8. The method according to claim 7, characterized in that The loss function of the generator G designed in step 3 is: Among them, r(θ) is the advantage value coefficient, which is used to balance the proportion of the advantage value in the current round of loss calculation, min(r(θ)A(x, D), clip(r(θ), 1-∈, 1+∈)A(x, D)) is the advantage value of the generator G, corresponding to the discriminator D to T A and T M The probability of misjudgment; by minimizing min and clipping operations, the advantage value does not exceed the upper bound 1+∈, stabilizing the training process; PPL(x) is the perplexity of text x; is the variance of AI text perplexity, which is used to measure the range of variation of text perplexity; is the feedback value of the AI text perplexity, which improves the realism of the AI text by encouraging the generator G to generate AI text with a perplexity variation within a preset range (a, b); β is the coefficient of the perplexity reward, which is used to adjust the impact of the perplexity variance on the generator G.
9. The method according to any one of claims 1 to 8, characterized in that The data cleaning and preprocessing methods of human text in step 1 include removing noise, correcting typos and standardizing formats.
10. A system for implementing the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Text generation method based on generative adversarial network
CN112560438A
Text generation model training method, target corpus expansion method and related device
CN114462570A
Text classification method based on artificial intelligence and related equipment
CN116414987A
Machine generated text detection method and system based on block chain and generative adversarial network
CN117371049A
AI text detection method based on pre-training model
CN118734124A