AI text detection method based on pre-training model
By adding a classification layer to the pre-trained large language model and performing fine-tuning training, a fine-grained classification model is generated, which solves the problem of existing AI text detection software's poor performance in classifying human + AI text and achieves accurate AI-polished text. identification and efficient detection.
Patent Information
- Application Number
- CN202410717863.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-04
AI Technical Summary
Existing AI text detection software has poor classification results when faced with humans + AI (AI polished text), and the detection principle relies on a single text feature, causing objective texts such as news to be mistakenly recognized as AI text, resulting in detection failure.
The AI text detection method based on the pre-trained model adds a classification layer at the end of the large language model and uses human text, AI text and AI-polished text for fine-tuning training to generate a fine-grained classification model that can accurately identify AI-polished text.
It achieves fine-grained, high-efficiency, and low-cost detection of AI-polished text, reduces detection costs, improves the universality of the detection method, and can adapt to AI large language models of different platforms.
Smart Images

Figure CN118734124A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of AI text detection technology, and in particular to an AI text detection method based on a pre-trained model. Background Art
[0002] In recent years, large language models have been widely used in various technical fields based on natural language processing, and have become one of the research focuses of computer science researchers around the world. Large language models can easily generate a large amount of text that meets the actual needs of users. If users are not satisfied with the generated text, they can also request modifications. Large language models are pre-trained when applied. The application of such pre-trained models is inseparable from information security. With the popularization of artificial intelligence large language models such as ChatGPT and Wenxin Yiyan, there is also the abuse of text generated by large language models, which may lead to security issues such as the spread of false information and false advertising.
[0003] In response to the potential security risks caused by the abuse of AI text, some organizations have released software that can detect whether a given text comes from a large language model, such as GPTZero, Copyleaks, etc. The patent with publication number CN117151074A describes a method, device, medium and equipment for detecting AI-generated text. It determines whether the text to be detected is AI-generated text through the first probability value, deviation feature, diffusion feature value, sentence length feature, and word distribution feature, thereby automatically detecting whether the text is AI-generated text. This method has a high detection efficiency.
[0004] However, these software ignore the fact that large language models also have the ability to polish and optimize. In other words, the AI text detection software that has been released so far has a good classification effect when facing human text or AI text, but when facing "human + AI" text (AI polished text), it either arbitrarily classifies it as AI text or gives an ambiguous confidence level. At the same time, the detection principle of these AI text detection software mostly uses a single text feature, which will cause some objective texts similar to news to be identified as AI text. Both of the above situations will lead to the failure of AI text detection. Summary of the invention
[0005] The main purpose of the embodiments of the present application is to propose an AI text detection method based on a pre-trained model, which aims to utilize the powerful deconstruction ability of a large language model for text, add a classification layer to the pre-trained large language model to obtain a classification model, and then use human text, AI text from different large models, and AI polished text to fine-tune the classification model. The fine-tuned trained model has a fine classification granularity and can accurately identify AI polished text, and can perform fine-grained, efficient, and low-cost text detection.
[0006] To achieve the above-mentioned purpose, an embodiment of the present application provides an AI text detection method based on a pre-trained model, which includes the following steps: constructing an original data set based on the acquired human text data, AI text data and AI polished text data, and dividing the original data set into a training data set and a verification data set according to a preset ratio; wherein each sample data in the original data set is marked with a first label representing the text type and a second label representing the AI large language model used; adding a classification layer at the end of the pre-trained large language model to obtain a classification model; inputting the sample data in the training data set into the classification model, iteratively training the classification model using the first label and the output of the classification model, and using The validation data set determines the classification accuracy of the classification model after each training, and the training is stopped when the classification accuracy is greater than a first preset threshold value to obtain a text classification model; the sample data in the training data set is input into the text classification model, and the text classification model is iteratively trained using the second label and the output of the text classification model, and the classification accuracy of the text classification model after each training is determined using the validation data set, and the training is stopped when the number of iterations reaches a second preset threshold value, and the basic classification model with the highest classification accuracy is used as the fine-grained text classification model obtained by the final training; the acquired text data to be tested is input into the fine-grained text classification model to obtain the classification result of the text data to be tested output by the fine-grained text classification model.
[0007] To achieve the above-mentioned purpose, an embodiment of the present application further provides an AI text detection system based on a pre-trained model, the system comprising: a data acquisition module, used to acquire human text data, AI text data and AI polished text data, and based on the acquired human text data, AI text data and AI polished text data, construct an original data set, and divide the original data set into a training data set and a verification data set according to a preset ratio, wherein each sample data in the original data set is marked with a first label representing the text type and a second label representing the AI large language model used; a model construction module, used to add a classification layer at the end of the pre-trained large language model to obtain a classification model; an initial training module, used to input the sample data in the training data set into the classification model, and use the first label and the output of the classification model to obtain a classification model. , iteratively train the classification model, and use the verification data set to determine the classification accuracy of the classification model after each training, stop training when the classification accuracy is greater than a first preset threshold, and obtain a text classification model; a fine-grained training module, used to input sample data in the training data set into the text classification model, use the second label and the output of the text classification model to iteratively train the text classification model, and use the verification data set to determine the classification accuracy of the text classification model after each training, stop training when the number of iterations reaches the second preset threshold, and use the basic classification model with the highest classification accuracy as the fine-grained text classification model obtained by the final training; a model use module, used to input the acquired text data to be tested into the fine-grained text classification model, and obtain the classification result of the text data to be tested output by the fine-grained text classification model.
[0008] To achieve the above-mentioned purpose, an embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned AI text detection method based on the pre-trained model.
[0009] To achieve the above objectives, an embodiment of the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned AI text detection method based on a pre-trained model.
[0010] The AI text detection method based on a pre-trained model proposed in the embodiment of the present application utilizes the powerful deconstruction ability of the large language model for text, adds a classification layer to the pre-trained large language model to obtain a classification model, and then uses human text, AI text from different large models, and AI polished text to fine-tune the classification model, thereby training a classification model that can perform fine-grained AI text detection. Different from the current AI text detection method based on analyzing the distribution characteristics of text, the pre-trained large language model can better obtain deeper features in the text, thereby achieving a more accurate classification effect. The training data and model architecture of the AI large language models of different platforms are different, so the generated text features are also different. The use of pre-trained large language models can well capture these features, thereby classifying AI texts from different platforms. The fine-grained text classification model finally trained has fine classification granularity and can accurately identify AI polished text, which can perform fine-grained, efficient, and low-cost text detection. When a new AI large language model appears on the Internet, the current AI text detection method needs to re-collect the features of the AI text and modify the detection method itself. This application only needs to input the AI text into the model for fine-tuning, which reduces the detection cost and improves the universality of the AI text detection method.
[0011] In some optional embodiments, the original data set is constructed based on the acquired human text data, AI text data and AI polished text data, including: collecting a question data set, calling volunteers to answer questions in the question data set, using the volunteers' answers as human text data, and generating a human text data set; inputting the question data set into each AI large language model for answering, using the answers of each AI large language model as AI text data, and generating an AI text data set; inputting the human text data set into each AI large language model for polishing, obtaining AI polished text data output by each AI large language model, and generating an AI polished text data set; annotating the first label and the second label for each text data in the human text data set, the AI text data set and the AI polished text data set, and mixing them in a ratio of 1:1:1 after shuffling the order to form the original data set. The human text data set, AI text data set and AI polished text data set acquired based on the question data set are cleaner, more scientific and more standardized. Using such text data to fine-tune the classification model can further improve the training speed and training effect, and the classification accuracy of the trained model is higher.
[0012] In some optional embodiments, the total number of AI large language models used when generating AI text data and generating AI polished text data is the same and corresponds one to one. For human text data, the content of the second label annotated is empty. The AI large language models used when generating AI text data and generating AI polished text data are the same and correspond one to one. Such a design can better help the model learn relevant knowledge of fine-grained classification, further improving the fine-grained classification ability and classification accuracy of the trained model.
[0013] In some optional embodiments, the classification layer added at the end of the pre-trained large language model consists of a first fully connected layer, a dropout layer, and a second fully connected layer; the first fully connected layer is used to learn the complex combination of its own input features, the dropout layer is used to prevent overfitting, and the second fully connected layer is used to map the learned features to category predictions. The dropout layer is also called the exit layer. The existence of the dropout layer can temporarily remove some units from the network according to a certain probability to prevent overfitting during training.
[0014] In some optional embodiments, the sample data in the training data set is input into the classification model, the classification model is iteratively trained using the first label and the output of the classification model, and the classification accuracy of the classification model after each training is determined using the verification data set, and the training is stopped when the classification accuracy is greater than a first preset threshold value to obtain a text classification model, including: inputting the sample data in the training data set into the classification model, using AdamW as an optimizer, and first training the classification model N times using the first label and the output of the classification model; wherein N is an integer greater than 0; starting from the N+1th training, after each training is completed, the sample data in the verification data set is input into the classification model after this training, and the classification accuracy of the classification model after this training is calculated using the first label and the output of the classification model after this training; if the classification accuracy of the classification model after this training is less than or equal to the first preset threshold value, the classification model after this training is continued to be trained for the next time; if the classification accuracy of the classification model after this training is greater than the first preset threshold value, the training is stopped and the classification model after this training is used as the text classification model. When the classification accuracy of the classification model is greater than the first preset threshold, it means that the classification model already has basic text classification capabilities and no initial training is needed. At this time, the initial training can be ended and fine-grained training can be entered, which effectively improves the training speed of the model and reduces the training cost.
[0015] In some optional embodiments, if the classification model has been trained M times, and the classification accuracy of the classification model after the Mth training is still less than or equal to the first preset threshold, the training is stopped, and the classification model after the Mth training is used as the text classification model; wherein M is an integer greater than N, and N is an integer greater than or equal to 10. In order to prevent the initial training from being endless, the present application sets a maximum number of training times. When the maximum number of training times is reached, even if the classification accuracy of the classification model does not meet the standard, the initial training will be terminated and fine-grained training will be entered. This design saves training resources.
[0016] In some optional embodiments, the classification result of the text data to be tested output by the fine-grained text classification model is: the text type of the text data to be tested and the AI large language model used to generate the text data. When the text type of the text data to be tested is human text, the AI large language model used to generate the text data is empty. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flowchart of an AI text detection method based on a pre-trained model provided by an embodiment of the present application;
[0018] Figure 2 A flowchart of constructing an original data set based on acquired human text data, AI text data, and AI polished text data is provided by an embodiment of the present application;
[0019] Figure 3 An embodiment of the present application provides that sample data in a training data set is input into a classification model, the classification model is iteratively trained using a first label and an output of the classification model, and a verification data set is used to determine the classification accuracy of the classification model after each training, and the training is stopped when the classification accuracy is greater than a first preset threshold, thereby obtaining a flowchart of a text classification model;
[0020] Figure 4 is a structural diagram of an AI text detection system based on a pre-trained model provided in another embodiment of the present application;
[0021] Figure 5 It is a schematic diagram of the structure of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0022] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be construed as any limitation, and the various embodiments can be combined and referenced with each other under the premise of no contradiction.
[0023] An embodiment of the present application proposes an AI text detection method based on a pre-trained model, which can be applied to an electronic device, wherein the electronic device can be a terminal or a server. This embodiment and the following embodiments are all described using the server as an example. The implementation details of the AI text detection method based on a pre-trained model proposed in this embodiment are specifically described below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for the implementation of this solution.
[0024] The process of the AI text detection method based on the pre-trained model proposed in this embodiment can be as follows: Figure 1 As shown, including:
[0025] Step 101, based on the acquired human text data, AI text data and AI polished text data, construct an original data set, and divide the original data set into a training data set and a verification data set according to a preset ratio, and each sample data in the original data set is marked with a first label representing the text type and a second label representing the AI large language model used.
[0026] In a specific implementation, the server first obtains human text data, AI text data, and AI polished text data. The AI polished text data is obtained by polishing the human text data using the polishing function of the AI large language model. The server constructs an original data set based on the acquired human text data, AI text data, and AI polished text data, and divides the original data set into a training data set and a verification data set according to a preset ratio (generally 7:3). Among them, each sample data in the original data set is marked with a first label representing the text type and a second label representing the AI large language model used. For human text data, its first label is human text and the second label is empty; for AI text data, its first label is AI text and the second label is the AI large language model used to generate the AI text; for AI polished text data, its first label is AI polished text and the second label is the AI large language model used for polishing.
[0027] In one example, the server constructs an original data set based on the acquired human text data, AI text data, and AI polished text data, which can be done as follows: Figure 2 The steps shown in the figure are implemented, including:
[0028] Step 1011, collect the question data set, call on volunteers to answer the questions in the question data set, use the volunteers' answers as human text data, and generate a human text data set.
[0029] In the specific implementation, the server first collects the problem data set D q , call on volunteers to solve the problem dataset D q The volunteers’ answers are used as human text data to generate a human text dataset D human .
[0030] Step 1012, input the question data set into each AI large language model for answering, and use the answer of each AI large language model as AI text data to generate an AI text data set.
[0031] In the specific implementation, the server sends the problem dataset D q The questions in the question set D are input into the selected AI large language models, and each AI large language model uses the question data set D q The answers of each AI language model are used as AI text data to generate AI text dataset D ai , where D ai ={D ai1 , D ai2 , ..., D ain}, n is the total number of all pre-selected AI large language models.
[0032] Step 1013, input the human text data set into each AI large language model for polishing, obtain the AI polished text data output by each AI large language model, and generate an AI polished text data set.
[0033] In the specific implementation, the server obtains the human text dataset D human After that, the human text dataset D human Input into each pre-selected AI large language model for polishing, obtain the AI polished text data output by each AI large language model, and generate the AI polished text dataset D remix , where D remix ={D remix1 , D remix2 , ..., D remixn}.
[0034] Step 1014, annotate the first label and the second label for each text data in the human text data set, the AI text data set, and the AI polished text data set, shuffle the order, and mix them in a ratio of 1:1:1 to form the original data set.
[0035] In the specific implementation, the server obtains the human text dataset D human , AI text dataset D ai and AI polished text dataset D remix After that, they can be divided into human text datasets D human , AI text dataset D ai and AI polished text dataset D remix Each text data in is labeled with the first label y 1 and the second label y 2 , and then the human text data, AI text data, and AI polished text data marked with the first label and the second label are shuffled and mixed in a 1:1:1 ratio to form the original data set. The human text data set, AI text data set, and AI polished text data set obtained based on the problem data set are cleaner, more scientific, and more standardized. Using such text data to fine-tune the classification model can further improve the training speed and training effect, and the classification accuracy of the trained model is higher.
[0036] In one example, the total number of AI large language models used when generating AI text data and generating AI polished text data is the same and corresponds one to one. For human text data, the content of the second label annotated is empty. The AI large language models used when generating AI text data and generating AI polished text data are the same and correspond one to one. This design can better help the model learn relevant knowledge of fine-grained classification, further improving the fine-grained classification ability and classification accuracy of the trained model.
[0037] Step 102, adding a classification layer at the end of the pre-trained large language model to obtain a classification model.
[0038] In a specific implementation, after obtaining the training data set and the verification data set, the server can process the pre-selected pre-trained large language model, add a classification layer at the end of the pre-trained large language model, and obtain a classification model.
[0039] In one example, the classification layer added by the server is specifically composed of a first fully connected layer, a dropout layer, and a second fully connected layer. The first fully connected layer is used to learn complex combinations of its own input features, the dropout layer is used to prevent overfitting, and the second fully connected layer is used to map the learned features to category predictions. The dropout layer is also called the exit layer. The existence of the dropout layer can temporarily remove some units from the network with a certain probability to prevent overfitting during training.
[0040] Step 103, input the sample data in the training data set into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the verification data set to determine the classification accuracy of the classification model after each training. When the classification accuracy is greater than the first preset threshold, stop training to obtain a text classification model.
[0041] In a specific implementation, after the server constructs the classification model, it can input the sample data in the training data set into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the sample data in the validation data set to determine the classification accuracy of the classification model after each training. When the classification accuracy is greater than the first preset threshold, the training is stopped to obtain the text classification model. The training of the classification model can be called the initial training stage, and the subsequent training of the text classification model can be called the fine-grained training stage.
[0042] In one example, the server inputs sample data in the training data set into the classification model, uses the first label and the output of the classification model to iteratively train the classification model, and uses the verification data set to determine the classification accuracy of the classification model after each training. When the classification accuracy is greater than the first preset threshold, the training is stopped to obtain a text classification model, which can be obtained by Figure 3 The steps shown are implemented, specifically including:
[0043] Step 1031, input the sample data in the training data set into the text classification model, use AdamW as the optimizer, use the first label and the output of the classification model, and first train the classification model N times.
[0044] In a specific implementation, when the server performs initial training on the classification model, it first inputs the sample data in the training data set into the classification model, uses AdamW as the optimizer, and uses the first label marked on the sample data in the training data set and the output of the classification model for the sample data in the training data set to first train the classification model N times, where N is an integer greater than 0.
[0045] Step 1032, starting from the N+1th training, after each training is completed, the sample data in the verification data set is input into the classification model after this training, and the classification accuracy of the classification model after this training is calculated using the first label and the output of the classification model after this training.
[0046] In the specific implementation, starting from the N+1th training, after each training, the server inputs the sample data in the verification data set into the classification model after this training, and uses the first label marked on the sample data in the verification data set and the output of the classification model after this training for the sample data in the verification data set to calculate the classification accuracy of the classification model after this training. Classification accuracy = correct classification number / total number.
[0047] Step 1033, determine whether the classification accuracy of the classification model after this training is greater than the first preset threshold, if so, directly execute step 1035, otherwise, execute step 1034.
[0048] Step 1034, continue to train the classification model after the current training for the next time.
[0049] Step 1035, stop training, and use the classification model after this training as the text classification model.
[0050] In a specific implementation, after the server calculates the classification accuracy of the classification model after this training, it can determine whether the classification accuracy of the classification model after this training is greater than the first preset threshold. If the classification accuracy of the classification model after this training is greater than the first preset threshold, the training is stopped and the classification model after this training is used as the text classification model. If the classification accuracy of the classification model after this training is less than or equal to the first preset threshold, the classification model after this training is continued to be trained for the next time.
[0051] It can be understood that when the classification accuracy of the classification model is greater than the first preset threshold, it means that the classification model already has basic text classification capabilities and no initial training is needed. At this time, the initial training can be ended and fine-grained training can be entered, which effectively improves the training speed of the model and reduces the training cost.
[0052] In one example, if the server has trained the classification model M times, and the classification accuracy of the classification model after the Mth training is still less than or equal to the first preset threshold, the training can be stopped, and the classification model after the Mth training is used as the text classification model. Wherein, M is an integer greater than N, and N is an integer greater than or equal to 10. In order to prevent the initial training from being endless, the present application sets a maximum number of training times. When the maximum number of training times is reached, even if the classification accuracy of the classification model does not meet the standard, the initial training will be terminated and fine-grained training will be entered. This design saves training resources.
[0053] Step 104, input the sample data in the training data set into the text classification model, use the second label and the output of the text classification model to iteratively train the text classification model, and use the verification data set to determine the classification accuracy of the text classification model after each training. When the number of iterations reaches a second preset threshold, the training is stopped, and the basic classification model with the highest classification accuracy is used as the fine-grained text classification model obtained by the final training.
[0054] In a specific implementation, after the server completes the initial training and obtains the text classification model, the sample data in the training data set can be input into the text classification model, and the text classification model can be iteratively trained using the second label marked on the sample data in the training data set and the output of the text classification model for the sample data in the training data set, and the classification accuracy of the text classification model after each training is determined using the sample data in the verification data set. When the number of iterations reaches a second preset threshold, the server stops the fine-grained training of the text classification model and uses the basic classification model with the highest classification accuracy as the fine-grained text classification model obtained by the final training.
[0055] Step 105 , input the acquired text data to be tested into the fine-grained text classification model to obtain the classification result of the text data to be tested output by the fine-grained text classification model.
[0056] In a specific implementation, after the server obtains the fine-grained text classification model, it can deploy it according to the needs, input the acquired text data to be tested into the fine-grained text classification model, and obtain the classification result of the text data to be tested output by the fine-grained text classification model. The classification result of the text data to be tested output by the fine-grained text classification model is specifically: the text type of the text data to be tested and the AI big language model used to generate the text data. When the text type of the text data to be tested is human text, the AI big language model used to generate the text data is empty.
[0057] In this embodiment, the classification model is obtained by adding a classification layer to the pre-trained large language model using the powerful deconstruction ability of the large language model for text, and then fine-tuning the classification model using human text, AI text from different large models, and AI polished text, so as to train a classification model that can perform fine-grained AI text detection. Different from the current AI text detection method based on analyzing the distribution characteristics of text, the pre-trained large language model can better obtain deeper features in the text, thereby achieving more accurate classification results. The AI large language models provided by different platforms have different training data and model architectures, so the generated text features are also different. The pre-trained large language model can capture these features well, so as to classify AI texts from different platforms. The fine-grained text classification model finally trained has fine classification granularity and can accurately identify AI polished text, which can perform fine-grained, efficient, and low-cost text detection. When a new AI large language model appears on the Internet, the current AI text detection method needs to re-collect the features of the AI text and modify the detection method itself. This application only needs to input the AI text into the model for fine-tuning, which reduces the detection cost and improves the universality of the AI text detection method.
[0058] Another embodiment of the present application proposes an AI text detection system based on a pre-trained model. The details of the AI text detection system based on a pre-trained model proposed in this embodiment are described in detail below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for the implementation of this example. Figure 4 It is a structural diagram of the AI text detection system based on the pre-trained model proposed in this embodiment, including: a data acquisition module 201, a model construction module 502, an initial training module 203, a fine-grained training module 204 and a model use module 205.
[0059] The data acquisition module 201 is used to acquire human text data, AI text data and AI polished text data, and construct an original data set based on the acquired human text data, AI text data and AI polished text data, and divide the original data set into a training data set and a verification data set according to a preset ratio, wherein each sample data in the original data set is marked with a first label representing the text type and a second label representing the AI large language model used.
[0060] The model building module 202 is used to add a classification layer at the end of the pre-trained large language model to obtain a classification model.
[0061] The initial training module 203 is used to input the sample data in the training data set into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the verification data set to determine the classification accuracy of the classification model after each training. When the classification accuracy is greater than the first preset threshold, the training is stopped to obtain a text classification model.
[0062] The fine-grained training module 204 is used to input the sample data in the training data set into the text classification model, use the second label and the output of the text classification model to iteratively train the text classification model, and use the verification data set to determine the classification accuracy of the text classification model after each training. When the number of iterations reaches a second preset threshold, the training is stopped and the basic classification model with the highest classification accuracy is used as the fine-grained text classification model obtained by the final training.
[0063] The model using module 205 is used to input the acquired text data to be tested into the fine-grained text classification model to obtain the classification result of the text data to be tested output by the fine-grained text classification model.
[0064] It is not difficult to find that this embodiment is a system embodiment corresponding to the above method embodiment, and this embodiment can be implemented in conjunction with the above method embodiment. The relevant technical details and technical effects mentioned in the above embodiments are still valid in this embodiment, and in order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiments.
[0065] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.
[0066] Another embodiment of the present application relates to an electronic device, such as Figure 5 As shown, it includes: at least one processor 301; and a memory 302 that is communicatively connected to the at least one processor 301; wherein the memory 302 stores instructions that can be executed by the at least one processor 301, and the instructions are executed by the at least one processor 301 so that the at least one processor 301 can execute the AI text detection method based on the pre-trained model described in the above embodiments.
[0067] Among them, the memory and the processor can be connected in a bus manner, and the bus can include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits together, which are well known in the art, so this article will not describe them further. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium through an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0068] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0069] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the AI text detection method based on the pre-trained model described in the above method embodiments is implemented.
[0070] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM (Read-Only Memory), RAM (Random Access Memory), disk or optical disk and other media that can store program codes.
[0071] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.
Claims
1. An AI text detection method based on a pre-trained model, characterized in that: include: Based on the acquired human text data, AI text data, and AI polished text data, an original data set is constructed, and the original data set is divided into a training data set and a verification data set according to a preset ratio; wherein each sample data in the original data set is annotated with a first label representing the text type and a second label representing the AI large language model used; Add a classification layer at the end of the pre-trained large language model to obtain a classification model; Input the sample data in the training data set into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the verification data set to determine the classification accuracy of the classification model after each training, stop the training when the classification accuracy is greater than the first preset threshold, and obtain a text classification model; Input the sample data in the training data set into the text classification model, use the second label and the output of the text classification model to iteratively train the text classification model, and use the verification data set to determine the classification accuracy of the text classification model after each training, stop the training when the number of iterations reaches a second preset threshold, and use the basic classification model with the highest classification accuracy as the fine-grained text classification model obtained by the final training; The acquired text data to be tested is input into the fine-grained text classification model to obtain the classification result of the text data to be tested output by the fine-grained text classification model.
2. The AI text detection method based on the pre-training model according to claim 1 is characterized in that: The original data set is constructed based on the acquired human text data, AI text data and AI polished text data, including: Collect question data sets, recruit volunteers to answer questions in the question data sets, and use the volunteers' answers as human text data to generate a human text data set; Input the question data set into each AI large language model for answering, and use the answer of each AI large language model as AI text data to generate an AI text data set; Input the human text data set into each AI large language model for polishing, obtain the AI polished text data output by each AI large language model, and generate the AI polished text data set; The first label and the second label are annotated for each text data in the human text dataset, the AI text dataset, and the AI polished text dataset, and the order is shuffled and mixed in a ratio of 1:1:1 to form the original dataset.
3. The AI text detection method based on the pre-training model according to claim 2 is characterized in that: The total number of AI large language models used when generating AI text data and generating AI polished text data is the same and corresponds one to one. For human text data, the content of the second label marked is empty.
4. The AI text detection method based on the pre-training model according to claim 1 is characterized in that: The classification layer added at the end of the pre-trained large language model consists of the first fully connected layer, the dropout layer, and the second fully connected layer; The first fully connected layer is used to learn complex combinations of its own input features, the dropout layer is used to prevent overfitting, and the second fully connected layer is used to map the learned features to category predictions.
5. The AI text detection method based on the pre-training model according to claim 1 is characterized in that: The sample data in the training data set is input into the classification model, the classification model is iteratively trained using the first label and the output of the classification model, and the classification accuracy of the classification model after each training is determined using the verification data set, and the training is stopped when the classification accuracy is greater than the first preset threshold, thereby obtaining a text classification model, including: Input the sample data in the training data set into the classification model, use AdamW as the optimizer, use the first label and the output of the classification model, and first train the classification model N times; where N is an integer greater than 0; Starting from the N+1th training, after each training, the sample data in the validation data set is input into the classification model after this training, and the classification accuracy of the classification model after this training is calculated using the first label and the output of the classification model after this training; If the classification accuracy of the classification model after the current training is less than or equal to the first preset threshold, continue to train the classification model after the current training for the next time; If the classification accuracy of the classification model after this training is greater than the first preset threshold, the training is stopped and the classification model after this training is used as the text classification model.
6. The AI text detection method based on the pre-training model according to claim 5 is characterized in that: If the classification model has been trained M times, and the classification accuracy of the classification model after the Mth training is still less than or equal to the first preset threshold, the training is stopped and the classification model after the Mth training is used as the text classification model; wherein M is an integer greater than N, and N is an integer greater than or equal to 10.
7. The AI text detection method based on a pre-training model according to any one of claims 1 to 5, characterized in that: The classification result of the text data to be tested output by the fine-grained text classification model is: the text type of the text data to be tested and the AI large language model used to generate the text data. When the text type of the text data to be tested is human text, the AI large language model used to generate the text data is empty.
8. An AI text detection system based on a pre-trained model, characterized in that: include: A data acquisition module, used to acquire human text data, AI text data, and AI polished text data, and construct an original data set based on the acquired human text data, AI text data, and AI polished text data, and divide the original data set into a training data set and a verification data set according to a preset ratio, wherein each sample data in the original data set is annotated with a first label representing the text type and a second label representing the AI large language model used; The model building module is used to add a classification layer at the end of the pre-trained large language model to obtain a classification model; An initial training module is used to input sample data in the training data set into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the verification data set to determine the classification accuracy of the classification model after each training, and stop training when the classification accuracy is greater than a first preset threshold to obtain a text classification model; A fine-grained training module is used to input sample data in the training data set into the text classification model, use the second label and the output of the text classification model to iteratively train the text classification model, and use the verification data set to determine the classification accuracy of the text classification model after each training, stop the training when the number of iterations reaches a second preset threshold, and use the basic classification model with the highest classification accuracy as the fine-grained text classification model finally trained; The model using module is used to input the acquired text data to be tested into the fine-grained text classification model to obtain the classification result of the text data to be tested output by the fine-grained text classification model.
9. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; Wherein, the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the AI text detection method based on the pre-trained model as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the AI text detection method based on a pre-trained model as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Exercising artificial intelligence by refining model output
CN112166443A
Science and technology information text classification method
CN112199501A
Data annotation method and device and fine granularity identification method and device
CN113688851A
Cited By
Generated text detection method based on fine-grained game confrontation
CN119557446A
A method for detecting generated text based on fine-grained game confrontation
CN119557446B
Post-processing method and device for AI generated text, medium and equipment
CN120181046A
