A method, device, medium and equipment for detecting AI-generated text
By combining the feature analysis of text classification model, target loss function and prediction model, it is automatically determined whether the text is generated by AI, which solves the problem of time-consuming, laborious and low accuracy of manual review, and achieves efficient and accurate text detection.
Patent Information
- Application Number
- CN202311099348.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-29
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-08-29
AI Technical Summary
In the prior art, the method of manually reviewing AI to generate text is time-consuming and laborious, and the audit results are subjectively influenced by the auditors, so the accuracy is low.
By obtaining the text to be detected, the text classification model, the target loss function, the preset dictionary and the prediction model, the autoregressive network model and the cross-entropy loss function are used for supervised learning, and combining the deviation characteristics, diffusion characteristics, sentence length characteristics and word distribution characteristics, it is automatically determined whether the text is AI-generated text.
It realizes efficient and accurate automatic detection of whether text is generated by AI, reducing the subjective influence of auditors and improving the accuracy of detection results.
Smart Images

Figure CN117151074B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing, and more particularly to a method, apparatus, medium, and device for detecting AI-generated text. Background Art
[0002] As the technology of AI intelligent text generation becomes increasingly mature, before scientific researchers or scholars need to publish papers, they have to review the papers to avoid the relatively bad influence caused by the publication of papers partially or entirely generated by AI intelligence.
[0003] Currently, the papers are usually reviewed manually. This method is not only time-consuming and laborious, but also the review results are subject to the subjective influence of the reviewers, and the accuracy of the review results is relatively low. Summary of the Invention
[0004] A series of simplified concepts are introduced in the Summary of the Invention section, which will be further described in detail in the Detailed Description section. The Summary of the Invention section of the present invention does not mean to attempt to define the key features and essential technical features of the claimed technical solution, nor does it mean to attempt to determine the protection scope of the claimed technical solution.
[0005] In a first aspect, an embodiment of the present invention provides a method for detecting AI-generated text, including:
[0006] Obtain a text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model;
[0007] Input the text to be detected into the text classification model to obtain a first probability value that the text to be detected is AI-generated text;
[0008] Based on the text to be detected and the target loss function, obtain a deviation feature of the text to be detected;
[0009] Based on the text to be detected, the prediction model, and the preset dictionary, obtain a diffusion feature value of the text to be detected;
[0010] Based on the text to be detected, obtain a sentence length feature and a word distribution feature of the text to be detected;
[0011] Determine whether the text to be detected is AI-generated text according to the first probability value, the deviation feature, the diffusion feature value, the sentence length feature, and the word distribution feature.
[0012] Optionally, before obtaining the text to be detected, the text classification model, and the prediction model, it includes:
[0013] Obtain an autoregressive network model;
[0014] Add a linear layer at the end of the network structure of the autoregressive network model to obtain a text classification model. The linear layer is connected to the feature vector of the last label of the input text, and the output of the linear layer is a one-dimensional vector of size 2.
[0015] Obtain a training sample set and a cross-entropy loss function. The training sample set includes human-written texts and AI-generated texts.
[0016] Randomly initialize the parameters of the linear layer.
[0017] Use the training sample set and the cross-entropy loss function to perform supervised learning on the text classification model.
[0018] Optionally, obtaining the deviation degree feature of the text to be detected based on the text to be detected and the target loss function includes:
[0019] Perform a cutting process on the text to be detected to obtain multiple text segments.
[0020] Based on each text segment, use the target loss function to calculate the model deviation degree of each text segment.
[0021] Optionally, obtaining the diffusion degree feature value of the text to be detected based on the text to be detected, the prediction model, and the preset dictionary includes:
[0022] Input each text segment into the prediction model to obtain the prediction probability value that each preset word in the preset dictionary is the same as the corresponding actual word at each word position of the text segment.
[0023] Sort the prediction probability values of each preset word obtained for each word position of each text segment to obtain a sorting result.
[0024] Based on the sorting result, count the rankings of the preset words that are the same as the actual words at each word position in each text segment to obtain a statistical result.
[0025] Based on the statistical result, obtain the diffusion degree feature value.
[0026] Optionally, obtaining the sentence length feature of the text to be detected based on the text to be detected includes:
[0027] Cut the text to be detected into multiple sentences.
[0028] Calculate the length of each sentence, the average value of the sentence lengths, and the standard deviation of the sentence lengths.
[0029] Optionally, obtaining the word distribution feature of the text to be detected based on the text to be detected includes:
[0030] Performing word segmentation on the text to be detected and counting the word frequencies of each segmented word;
[0031] Removing stop words from the segmented words;
[0032] Among the remaining segmented words, filtering to obtain a preset number of high-frequency words based on the word frequencies of each segmented word;
[0033] Calculating the average value of the distribution intervals of the high-frequency words and the average value of the average values of the distribution intervals based on the distribution interval numbers, interval word counts, and word frequencies of each high-frequency word;
[0034] Calculating the frequency and distribution feature values of the pronouns in the text to be detected.
[0035] Optionally, determining whether the text to be detected is an AI-generated text according to the first probability value, deviation feature, diffusion feature value, sentence length feature, and word distribution feature includes:
[0036] If the first probability value satisfies the first constraint condition, or the deviation feature and the diffusion feature value satisfy the second constraint condition, it is determined that the text to be detected is an AI-generated text;
[0037] If the first probability value does not satisfy the first constraint condition, and the deviation feature and the diffusion feature value do not satisfy the second constraint condition, then when the first probability value satisfies the third constraint condition and the sentence length feature and the word distribution feature satisfy the fourth constraint condition, or when the deviation feature and the diffusion feature value satisfy the fifth constraint condition, and the sentence length feature and the word distribution feature satisfy the fourth constraint condition, it is determined that the text to be detected is an AI-generated text.
[0038] In a second aspect, an embodiment of the present invention provides a detection device for AI-generated text, including:
[0039] An acquisition module, configured to acquire a text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model;
[0040] A first probability value determination module, configured to input the text to be detected into the text classification model to obtain a first probability value that the text to be detected is an AI-generated text;
[0041] A deviation feature determination module, configured to obtain the deviation feature of the text to be detected based on the text to be detected and the target loss function;
[0042] A diffusion degree eigenvalue determination module, configured to obtain the diffusion degree eigenvalue of the text to be detected based on the text to be detected, the prediction model, and the preset dictionary;
[0043] A sentence length feature and word distribution feature determination module, configured to obtain the sentence length feature and word distribution feature of the text to be detected based on the text to be detected;
[0044] A determination module, configured to determine whether the text to be detected is an AI-generated text according to the first probability value, the deviation degree feature, the diffusion degree eigenvalue, the sentence length feature, and the word distribution feature.
[0045] In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned method for detecting AI-generated text are implemented.
[0046] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned method for detecting AI-generated text are implemented.
[0047] According to an AI-generated text detection method, device, medium, and device provided by an embodiment of the present invention, this method can automatically detect whether a text is an AI-generated text, not only with high detection efficiency, but also without being subject to the subjective influence of reviewers, making the detection result more accurate. Description of the Drawings
[0048] The following drawings of the present invention are used as a part of the embodiments of the present invention to understand the present invention. The embodiments of the present invention and their descriptions shown in the drawings are used to explain the principles of the present invention.
[0049] In the drawings:
[0050] Figure 1 is a flowchart of a method for detecting AI-generated text according to an optional embodiment of the present invention;
[0051] Figure 2 is a flowchart before step S101 according to an optional embodiment of the present invention;
[0052] Figure 3 is a flowchart of step S103 according to an optional embodiment of the present invention;
[0053] Figure 4 is a flowchart of step S104 according to an optional embodiment of the present invention;
[0054] Figure 5Flow chart of step S105 according to an alternative embodiment of the present invention;
[0055] Figure 6 Flow chart of step S105 according to another alternative embodiment of the present invention;
[0056] Figure 7 Flow chart of step S106 according to an alternative embodiment of the present invention;
[0057] Figure 8 Structural schematic diagram of a detection device for AI-generated text according to an alternative embodiment of the present invention. Detailed implementation manners
[0058] In the following description, numerous specific details are set forth in order to provide a more thorough understanding of the present invention. However, it will be apparent to one of ordinary skill in the art that the present invention may be practiced without one or more of these details. In other instances, well-known features have not been described in order to avoid obscuring the present invention.
[0059] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of exemplary embodiments according to the present invention. As used herein, unless the context clearly dictates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprises" and / or "comprising" are used in this specification, they specify the presence of the stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or combinations thereof.
[0060] Now, exemplary embodiments according to the present invention will be described in more detail with reference to the accompanying drawings. However, these exemplary embodiments may be implemented in many different forms and should not be construed as being limited only to the embodiments set forth herein. It should be understood that these embodiments are provided so that the present disclosure is thorough and complete and that the concept of these exemplary embodiments is fully conveyed to those of ordinary skill in the art.
[0061] In a first aspect, as Figure 1 shown, an embodiment of the present invention provides a method for detecting AI-generated text, including:
[0062] Step S101: Obtain the text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model.
[0063] The text to be detected may be all or part of a student's graduation thesis or an academic paper, report, etc. to be published. The specific content of the text to be detected in this embodiment is not strictly limited.
[0064] The preset dictionary can be pre-edited by the staff. The preset dictionary contains a large number of pre-entered preset words. In this embodiment, there is no strict limit on the preset words and the total number of preset words contained in the preset dictionary.
[0065] Step S102: Input the text to be detected into the text classification model to obtain the first probability value that the text to be detected is an AI-generated text.
[0066] The text classification model can be obtained from an autoregressive network model. Of course, other classification models can also be used. When the text classification model is obtained from an autoregressive network model, since the autoregressive network model has a limit on the length of the input text, the text classification model obtained from the autoregressive network model also has a limit on the length of the input text. The length of the text to be detected may exceed the upper limit of the input text length. Therefore, the text to be detected can be segmented according to the paragraph information and punctuation information of the text to be detected, and then each segmented fragment is input into the autoregressive network model one by one.
[0067] Step S103: Based on the text to be detected and the target loss function, obtain the deviation feature of the text to be detected.
[0068] Step S104: Based on the text to be detected, the prediction model, and the preset dictionary, obtain the diffusion feature value of the text to be detected.
[0069] Step S105: Based on the text to be detected, obtain the sentence length feature and word distribution feature of the text to be detected.
[0070] Step S106: Determine whether the text to be detected is an AI-generated text according to the first probability value, the deviation feature, the diffusion feature value, the sentence length feature, and the word distribution feature.
[0071] In this embodiment, this method can automatically detect whether a text is an AI-generated text. It not only has high detection efficiency but also is not affected by the subjectivity of the reviewers, making the detection results more accurate.
[0072] Further, in the above embodiment, as Figure 2 shown, before step S101, it includes:
[0073] Step S201: Obtain an autoregressive network model.
[0074] Among them, the autoregressive network model can be a model trained based on paper data or an open-source model on the Internet. In this embodiment, there is no specific limitation on the autoregressive network model.
[0075] Step S202: Add a linear layer to the end of the network structure of the autoregressive network model to obtain a text classification model. The linear layer is connected to the feature vector of the last label of the input text. The output of the linear layer is a one-dimensional vector of size 2. For example, the output of the linear layer is [0.3, 0.7], where 0.7 represents the probability that the input text is AI-generated text, and 0.3 represents the probability that the input text is not AI-generated text.
[0076] Step S203: Obtain a training sample set and a cross-entropy loss function, where the training sample set includes human-written text and AI-generated text.
[0077] Step S204: Randomly initialize the parameters of the linear layer.
[0078] Step S205: Using the training sample set and the cross entropy loss function, supervised learning is performed on the text classification model.
[0079] Because the autoregressive network model has a limit on the length of the input text, the text classification model derived from the autoregressive network model also has a limit on the length of the input text. Human-generated and AI-generated text may exceed the upper limit of the input text length. Therefore, the human-generated and AI-generated texts can be segmented according to their paragraph and punctuation information. Each segmented segment is then fed into the autoregressive network model one by one. The output then uses the sigmoid function to obtain the probability of being classified into different categories, and the cross-entropy loss function is used for supervised learning. In addition, during the training of the text classification model, only the parameters of the added linear layer are updated.
[0080] The cross entropy loss function used is as follows:
[0081]
[0082] Where N represents the total number of samples; y i The label of sample i is 0 or 1, where 0 means the sample does not belong to the classified category and 1 means the sample belongs to the classified category; Represents the probability that the predicted sample i belongs to the classified category.
[0083] In this embodiment, supervised learning is performed on the text classification model, so that the results obtained by the text classification model are more accurate.
[0084] Furthermore, in the above embodiment, if Figure 3 As shown, step S103 specifically includes:
[0085] Step S1031: Cut the text to be detected to obtain multiple text segments.
[0086] The text to be detected is segmented according to the unit segmentation length to obtain multiple text segments. The specific number of text segments can be calculated by the following formula.
[0087]
[0088] Among them, L represents the total length of loss, M represents the number of segments into which the text to be detected is segmented, and S represents the unit segmentation length.
[0089] Specifically, the total length of loss can be regarded as the total number of characters in the text to be detected, and the unit segmentation length refers to the number of characters contained in a text segment. Among them, the characters in the text to be detected refer to each Chinese character or an English word.
[0090] For the segmentation breakpoints of each text segment, they can be represented by the following formula:
[0091] P0 = 0
[0092]
[0093] P M = L
[0094] Among them, P i represents the segmentation truncation point of the i-th text segment, where i = 1, 2, 3,..., M.
[0095] Step S1032: Based on each text segment, use the target loss function to calculate the model deviation degree of each text segment.
[0096] Specifically, the target loss function is as follows:
[0097]
[0098] Among them, N represents the total number of preset characters in the preset dictionary; y i represents the label of the predicted character position in each text segment, that is, the actual character of the predicted character position in each text segment; represents the sum of the predicted probability values of each preset character in the preset dictionary being the same as the actual character at the predicted character position in each text segment; represents the predicted probability value of the preset character being the same as the actual character at the predicted character position in each text segment.
[0099] In specific applications, the first N characters of any text segment are used as input, and the predicted probability distribution of each preset character in the dictionary at the (N + 1)-th character position is output. Then, the predicted probability distributions of each preset character at the (N + 1)-th character position are compared with the (N + 1)-th character of the original text segment.
[0100] Exemplarily, assume that a text segment is "I want to go to school", which is text segment 2 in the following table. Use the first four characters "I want to go" of this text segment as the input, which is text segment 1 in the following table. Then, according to the first N characters, output the predicted probability distribution of each preset character in the dictionary at the N+1th character position. The specific probability distribution is shown in the following table; then compare the predicted probability distribution of each preset character at the N+1th character position obtained with the N+1th character of the text segment 2 after being shifted left.
[0101]
[0102]
[0103] Using the above objective loss function, calculate the model deviation calculation unit value according to the following formula.
[0104]
[0105] Among them, ddf i (i = 0, 1, 2,... M-1) represents the model deviation calculation unit value, M represents the number of segments into which the text to be detected is segmented, P i represents the segmentation truncation point of the i-th text segment, and P i+1 represents the segmentation truncation point of the i+1-th text segment.
[0106] Using the model deviation calculation unit value, calculate the model deviation feature of the text to be detected according to the following formula. Among them, the model deviation feature of the text to be detected is triple data, that is, DDF = (DDF1, DDF2, DDF3).
[0107]
[0108]
[0109] DDF3 = max(ddf i )
[0110] Among them, ddf i is the model deviation calculation unit value; M represents the number of segments into which the text to be detected is segmented; i = 0, 1, 2,... M-1.
[0111] Furthermore, in the above embodiment, as Figure 4 shown, step S104 specifically includes:
[0112] Step S1041: Input each text segment into the prediction model to obtain the predicted probability value that each preset character in the preset dictionary is the same as the corresponding actual character at each character position of the text segment.
[0113] The prediction model can adopt an autoregressive model. Of course, other models can also be used, and this embodiment does not make strict limitations. The prediction model predicts each character at each character position in the text segment one by one. Specifically, the prediction model can predict the possibility that each preset character in the preset dictionary is the same as the actual character at the current prediction character position, that is, the prediction probability value, according to the semantics expressed by the words before the current prediction character position. When the current prediction character position is the first character position, the prediction model predicts the possibility that each preset character is the same as the actual character at the first character position according to the writing habit and grammar.
[0114] Exemplarily, assume a text segment is "I want to drink water". The preset dictionary includes preset characters "water", "meal", "tea", "I", "he", "you", "want", "need", "love", "eat", "drink".
[0115] Input this text segment into the prediction model to obtain the prediction probability value that each preset character in the preset dictionary is the same as the corresponding actual character at each character position in this text segment. See the following table for details. The larger the prediction probability value, the greater the possibility that the preset character is the same as the actual character at this character position; the smaller the prediction probability value, the smaller the possibility that the preset character is the same as the actual character at this character position.
[0116]
[0117] Step S1042: Sort the prediction probability values of each preset character obtained for each character position of each text segment to obtain a sorting result.
[0118] Continuing with the example in step S1041, sort the prediction probability values of each preset character obtained for each character position from largest to smallest to obtain a sorting result, as shown in the following table.
[0119] Ranking First character position Second character position Third character position Fourth character position 1 I want to eat water 2 he love to drink tea 3 you want water and rice 4 love to eat tea to drink 5 tea to drink rice to eat 6 rice rice you you 7 to eat water he I 8 water I I he 9 to drink you love want 10 want tea want want 11 want he want love
[0120] Step S1043: Based on the sorting result, count the rankings of the preset characters that are the same as the actual character at each character position in each text segment to obtain a statistical result.
[0121] Continuing with the example in step S1042, "I" at the first character position ranks first, "want" at the second character position ranks third, "drink" at the third character position ranks second, and "water" at the third character position ranks first.
[0122] Step S1044: Based on the statistical result, obtain the diffusion degree eigenvalue.
[0123] Based on the results of the same session, they are included in different model diffusion ranges, and the number of diffusion ranges and the boundary values can be defined according to specific application scenarios. Taking the number of diffusion ranges as 4 and the ranges as ranking 1 - ranking 5, ranking 6 - ranking 50, ranking 51 - ranking 500, and ranking > 500 as an example, the diffusion feature values are calculated.
[0124]
[0125] n1 represents the number of rankings from 1 to 5 in the statistical results, n2 represents the number of rankings from 6 to 50 in the statistical results, n3 represents the number of rankings from 51 to 500 in the statistical results, n4 represents the number of rankings > 500 in the statistical results, and n represents the total number.
[0126] Furthermore, in the above - mentioned embodiment, as Figure 5 shown, step S105 specifically includes:
[0127] Step S1051a: Split the text to be detected into multiple sentences.
[0128] In specific applications, some punctuation marks and line - break characters can be used as truncation symbols to split the text to be detected into multiple sentences. Some punctuation marks include but are not limited to full - width symbols (such as “。”, “!”, “?”, etc.) and half - width symbols (such as “!”, “?”, etc.).
[0129] Step S1052a: Calculate the length of each sentence, the average value of the sentence lengths, and the standard deviation of the sentence lengths.
[0130] Furthermore, in the above - mentioned embodiment, as Figure 6 shown, step S105 also specifically includes:
[0131] Step S1051b: Segment the text to be detected and count the word frequencies of each segmented word.
[0132] In specific applications, use a word - segmentation dictionary to segment the text to be detected. After the word - segmentation process, count the word frequencies of each segmented word.
[0133] Step S1052b: Remove the stop words in the segmented words.
[0134] In specific applications, find all the stop words in the segmented words through a stop - word list and remove the found stop words.
[0135] Step S1053b: Among the remaining segmented words, based on the word frequencies of each segmented word, screen out a preset number of high - frequency words.
[0136] Specifically, according to the word frequencies of each participle, sort the word frequencies of each participle from high to low, and select the participles ranked before the preset position, that is, obtain the preset number of high-frequency words. The preset number can be determined by the staff themselves and is not strictly limited in this embodiment.
[0137] Step S1054b: Calculate the average value of the distribution intervals of the high-frequency words and the average value of the average values of the distribution intervals based on the number of distribution intervals, the number of words in the intervals, and the word frequencies of each high-frequency word.
[0138] Specifically, based on the number of distribution intervals, the number of words in the intervals, and the word frequencies of each high-frequency word, the average value of the distribution intervals of the high-frequency words can be calculated according to the following formula.
[0139]
[0140] where mean topN is the average value of the distribution intervals of the high-frequency words, f i (i = 1, 2, 3,...N) is the word frequency of each high-frequency word, n i (i = 1, 2, 3,...N) is the number of distribution intervals of each high-frequency word, l ij (i = 1, 2, 3,...N)(j = 1,2,3...n i ) is the distribution interval of each high-frequency word, and N is the number of high-frequency words.
[0141] Specifically, based on the number of distribution intervals, the number of words in the intervals, and the word frequencies of each high-frequency word, the average value of the average values of the distribution intervals of the high-frequency words can be calculated according to the following formula.
[0142]
[0143] where std topN is the average value of the average values of the distribution intervals, f i (i = 1, 2, 3,...N) is the word frequency of each high-frequency word, n i (i = 1, 2, 3,...N) is the number of distribution intervals of each high-frequency word, l ij (i = 1, 2, 3,...N)(j = 1,2,3...n i ) is the distribution interval of each high-frequency word, and N is the number of high-frequency words.
[0144] Step S1055b: Calculate the frequency and distribution characteristic values of the pronouns in the text to be detected.
[0145] Pronouns include but are not limited to "its", "such", "this kind", "this type", "above", "the", etc.
[0146] The frequency of the pronouns can be calculated through the following formula:
[0147] F 指代词 = Total number of anaphora pronouns in the text to be detected / Total number of words in the text to be detected
[0148] The distribution characteristic value of the anaphora pronoun can be calculated by the following formula:
[0149]
[0150] Wherein, D 指代词 is the distribution characteristic value of the anaphora pronoun, z j (j = 1, 2, 3,... M) is the number of anaphora pronouns in each text segment, and M is the number of segments into which the text to be detected is segmented.
[0151] Furthermore, in the above embodiment, as shown, step S106 specifically includes:
[0152] Step S1061: If the first probability value meets the first constraint condition, or the deviation feature and the diffusion feature value meet the second constraint condition, then determine that the text to be detected is an AI-generated text.
[0153] The first constraint condition and the second constraint condition can be set by the staff according to different prediction models, and are not strictly limited in this embodiment. ]>
[0154] Exemplarily, the first constraint condition is that the first probability value is greater than the first preset probability value. The second constraint condition is that the deviation feature is less than the first preset deviation threshold and the diffusion feature value is less than the first diffusion threshold. The first preset probability value, the first preset deviation threshold, and the first diffusion threshold can be set by the staff. In addition, if the deviation feature includes triple data, then the corresponding first deviation threshold is also a triple array, and each data in the triple array of the deviation feature is less than the data in the corresponding first deviation threshold triple array to determine that the deviation feature is less than the first deviation threshold. For example, if the deviation feature is (0.5, 0.2, 0.3) and the first deviation threshold is (0.3, 0.1, 0.15), then it is determined that the deviation feature is less than the first deviation threshold.
[0155] Step S1062: If the first probability value does not meet the first constraint condition, and the deviation feature and the diffusion feature value do not meet the second constraint condition, then when the first probability value meets the third constraint condition and the sentence length feature and the word distribution feature meet the fourth constraint condition, or when the deviation feature and the diffusion feature value meet the fifth constraint condition, and the sentence length feature and the word distribution feature meet the fourth constraint condition, determine that the text to be detected is an AI-generated text.
[0156] In the case where the first probability value does not meet the first constraint condition, and the deviation feature and the diffusion feature value do not meet the second constraint condition, further determination is required to improve the accuracy of detection.
[0157] Similarly, the third constraint condition, the fourth constraint condition, and the fifth constraint condition can be set by the staff according to different prediction models, and are not strictly limited in this embodiment.
[0158] Exemplarily, the third constraint condition is that the first probability value is greater than a second preset probability value, where the second preset probability value is less than the first preset probability value. The fourth constraint condition is that the length of the sentence in the sentence length feature is less than a preset length threshold, the average value of the sentence length is less than a preset average length value, and the standard deviation of the sentence length is less than a preset standard deviation threshold, and the average value of the distribution intervals of the high-frequency words in the word distribution feature is less than the average value of the preset distribution intervals, and the average value of the average values of the distribution intervals is less than a preset threshold. The fifth condition is that the deviation feature is less than a second preset deviation threshold and the diffusion feature value is less than a second diffusion threshold, where the second deviation threshold is less than the first deviation threshold, and the second diffusion threshold is less than the first diffusion threshold. Among them, the values of the above thresholds can be set by the staff themselves, and are not strictly limited in this embodiment.
[0159] In this embodiment, by using the fusion decision method to determine whether the text to be detected is an AI automatically generated text, the accuracy of detection is improved.
[0160] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0161] In the second aspect, as Figure 7 Figure 8 shown, an embodiment of the present invention provides a detection device for AI-generated text, including:
[0162] An acquisition module 301, configured to acquire the text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model;
[0163] A first probability value determination module 302, configured to input the text to be detected into the text classification model to obtain a first probability value that the text to be detected is an AI-generated text;
[0164] A deviation feature determination module 303, configured to obtain the deviation feature of the text to be detected based on the text to be detected and the target loss function;
[0165] A diffusion feature value determination module 304, configured to obtain the diffusion feature value of the text to be detected based on the text to be detected, the prediction model, and the preset dictionary;
[0166] A sentence length feature and word distribution feature determination module 305, configured to obtain the sentence length feature and word distribution feature of the text to be detected based on the text to be detected;
[0167] A determination module 306, configured to determine whether the text to be detected is an AI-generated text according to the first probability value, deviation feature, diffusion feature value, sentence length feature, and word distribution feature.
[0168] For the specific limitations of the detection device for AI-generated text, reference can be made to the limitations of the detection method for AI-generated text in the above text, which will not be elaborated here. Each module in the above detection device for AI-generated text can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0169] In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above detection method for AI-generated text are implemented.
[0170] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the above detection method for AI-generated text are implemented.
[0171] The present invention has been described through the above embodiments. However, it should be understood that the above embodiments are only for the purpose of illustration and example, and are not intended to limit the present invention to the scope of the described embodiments. In addition, those skilled in the art can understand that the present invention is not limited to the above embodiments, and more variations and modifications can be made according to the teachings of the present invention, and these variations and modifications all fall within the scope of protection required by the present invention. The scope of protection of the present invention is defined by the appended claims and their equivalent scope.
Claims
1. A method for detecting AI-generated text, characterized in that, Including: Obtain the text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model; Input the text to be detected into the text classification model to obtain a first probability value that the text to be detected is an AI-generated text; Based on the text to be detected and the target loss function, obtain the deviation feature of the text to be detected; Based on the text to be detected, the prediction model, and the preset dictionary, obtain the diffusion feature value of the text to be detected; Based on the text to be detected, obtain the sentence length feature and the word distribution feature of the text to be detected; Determine whether the text to be detected is an AI-generated text according to the first probability value, the deviation feature, the diffusion feature value, the sentence length feature, and the word distribution feature.
2. The method according to claim 1, wherein Before obtaining the text to be detected, the text classification model, and the prediction model, including: Obtain an autoregressive network model; Add a linear layer at the end of the network structure of the autoregressive network model to obtain a text classification model. The linear layer is connected to the feature vector of the last label of the input text, and the output of the linear layer is a one-dimensional vector of size 2; Obtain a training sample set and a cross-entropy loss function. The training sample set includes human-written texts and AI-generated texts; Randomly initialize the parameters of the linear layer; Use the training sample set and the cross-entropy loss function to perform supervised learning on the text classification model.
3. The method according to claim 1, characterized in that, The obtaining the deviation feature of the text to be detected based on the text to be detected and the target loss function includes: Perform a cutting process on the text to be detected to obtain multiple text segments; Based on each text segment, use the target loss function to calculate the model deviation of each text segment.
4. The method according to claim 3, wherein The obtaining the diffusion feature value of the text to be detected based on the text to be detected, the prediction model, and the preset dictionary includes: Input each text segment into the prediction model to obtain the prediction probability value that each preset word in the preset dictionary is the same as the corresponding actual word at each word position of the text segment; Sort the prediction probability values of each preset word obtained for each word position of each text segment to obtain a sorting result; Based on the sorting result, count the rankings of the preset words that are the same as the actual word at each word position in each text segment to obtain a statistical result; Based on the statistical result, obtain the diffusion feature value.
5. The method according to claim 1, wherein The obtaining the sentence length feature of the text to be detected based on the text to be detected includes: Segment the text to be detected into multiple sentences; Calculate the length of each sentence, the average value of the sentence lengths, and the standard deviation of the sentence lengths.
6. The method according to claim 1, characterized in that, The obtaining the word distribution feature of the text to be detected based on the text to be detected includes: Perform word segmentation on the text to be detected and count the word frequencies of each word segment; Remove the stop words in the word segments; Among the remaining word segments, based on the word frequencies of each word segment, screen out a preset number of high-frequency words; Based on the distribution interval number, the interval word count, and the word frequency of each high-frequency word, calculate the average value of the distribution intervals of the high-frequency words and the average value of the average values of the distribution intervals. Calculate the frequency and distribution characteristic values of the pronouns in the text to be detected.
7. The method according to claim 1, characterized in that Determining whether the text to be detected is an AI-generated text according to the first probability value, deviation degree feature, diffusion degree feature value, sentence length feature, and word distribution feature includes: If the first probability value satisfies the first constraint condition, or the deviation degree feature and the diffusion degree feature value satisfy the second constraint condition, it is determined that the text to be detected is an AI-generated text; If the first probability value does not satisfy the first constraint condition, and the deviation degree feature and the diffusion degree feature value do not satisfy the second constraint condition, then when the first probability value satisfies the third constraint condition and the sentence length feature and the word distribution feature satisfy the fourth constraint condition, or when the deviation degree feature and the diffusion degree feature value satisfy the fifth constraint condition, and the sentence length feature and the word distribution feature satisfy the fourth constraint condition, it is determined that the text to be detected is an AI-generated text.
8. A detection device for AI-generated text, characterized in that, Including: An acquisition module for acquiring the text to be detected, a text classification model, a target loss function, a preset dictionary, and a prediction model; A first probability value determination module for inputting the text to be detected into the text classification model to obtain a first probability value that the text to be detected is an AI-generated text; A deviation degree feature determination module for obtaining the deviation degree feature of the text to be detected based on the text to be detected and the target loss function; A diffusion degree feature value determination module for obtaining the diffusion degree feature value of the text to be detected based on the text to be detected, the prediction model, and the preset dictionary; A sentence length feature and word distribution feature determination module for obtaining the sentence length feature and word distribution feature of the text to be detected based on the text to be detected; A determination module for determining whether the text to be detected is an AI-generated text according to the first probability value, deviation degree feature, diffusion degree feature value, sentence length feature, and word distribution feature.
9. A computer 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 computer program, the steps of the method for detecting an AI-generated text according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method for detecting an AI-generated text according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Semantic truncation detection method, device and equipment and computer readable storage medium
CN114372476A
Abnormal text detection method and device, computer readable medium and electronic equipment
CN114490935A