AI text detection methods based on pre-trained models
By adding a classification layer to a pre-trained large language model and fine-tuning the training using human text and AI-edited text, a fine-grained text classification model is constructed. This solves the problem of insufficient accuracy in classifying AI-edited text in existing AI text detection software, and achieves efficient and low-cost text detection.
Patent Information
- Application Number
- CN202410717863.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2044-06-04
AI Technical Summary
Existing AI text detection software performs well in classifying human or AI text, but its accuracy is insufficient when dealing with 'human + AI' text (AI-edited text). Furthermore, its detection principle is too simplistic, leading to objective texts such as news being misidentified as AI text.
A classification layer is added to a pre-trained large language model, and fine-tuned training is performed using human text, AI text, and AI-edited text to build a fine-grained text classification model, which classifies text by acquiring deeper features.
It achieves accurate recognition of AI-edited text, improves the granularity and efficiency of detection, reduces detection costs, and enhances the universality of the method.
Smart Images

Figure CN118734124B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this 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 Technology
[0002] In recent years, large language models have been widely applied in various fields based on natural language processing, becoming one of the key research areas for computer science researchers worldwide. Large language models can easily generate large amounts of text that meet users' actual needs, and users can request modifications if they are not satisfied with the generated text. Large language models are pre-trained before application, and the application of such pre-trained models is inextricably linked to information security. With the popularization of AI-generated large language models such as ChatGPT and Wenxin Yiyan, the misuse of text generated by these models has also emerged, potentially leading to security issues such as the spread of misinformation and false advertising.
[0003] To address the potential security risks posed by the misuse of AI-generated text, some organizations have released software capable of detecting whether given text originates from large language models, such as GPTZero and Copyleaks. Patent CN117151074A discloses a method, apparatus, medium, and device for detecting AI-generated text. This method determines whether the text to be detected is AI-generated text by using a first probability value, deviation feature, diffusion feature value, sentence length feature, and word distribution feature, thereby automatically detecting whether text is AI-generated. This method has high detection efficiency.
[0004] However, these software programs overlook the fact that large language models also possess polishing and optimization capabilities. In other words, currently released AI text detection software performs well in classifying human or AI-generated text, but when faced with "human + AI" text (AI-polished text), it either arbitrarily classifies it as AI text or provides an ambiguous confidence level. Furthermore, the detection principles of these AI text detection software programs mostly utilize single text features, which can lead to some objective texts, such as news articles, being identified as AI text. Both of these situations result in AI text detection failure. Summary of the Invention
[0005] The main objective of the embodiments of this application is to propose an AI text detection method based on a pre-trained model. The method aims to leverage the powerful text deconstruction capabilities of large language models, add a classification layer to the pre-trained large language model to obtain a classification model, and then fine-tune the classification model using human text, AI text from different large models, and AI-edited text. The fine-tuned model has fine classification granularity and can accurately identify AI-edited text, enabling fine-grained, high-efficiency, and low-cost text detection.
[0006] To achieve the above objectives, embodiments of this application provide an AI text detection method based on a pre-trained model. This method includes the following steps: constructing an original dataset based on acquired human text data, AI text data, and AI-edited text data; dividing the original dataset into a training dataset and a validation dataset according to a preset ratio; wherein each sample data in the original dataset is labeled with a first label representing the text type and a second label representing the AI large language model used; adding a classification layer to the end of the pre-trained large language model to obtain a classification model; inputting sample data from the training dataset into the classification model; using the first label and the output of the classification model, iteratively training the classification model; and utilizing... The validation dataset is used to determine the classification accuracy of the classification model after each training iteration. Training stops when the classification accuracy exceeds a first preset threshold, resulting in a text classification model. Sample data from the training dataset is input into the text classification model. Using the second label and the output of the text classification model, the model is iteratively trained. The validation dataset is used to determine the classification accuracy of the model after each training iteration. Training stops when the number of iterations reaches a second preset threshold. The base classification model with the highest classification accuracy is selected as the final fine-grained text classification model. The obtained test text data is input into the fine-grained text classification model to obtain the classification result of the test text data output by the fine-grained text classification model.
[0007] To achieve the above objectives, embodiments of this application also provide an AI text detection system based on a pre-trained model. This system includes: a data acquisition module for acquiring human text data, AI text data, and AI-edited text data; constructing an original dataset based on the acquired human text data, AI text data, and AI-edited text data; and dividing the original dataset into a training dataset and a validation dataset according to a preset ratio. Each sample data in the original dataset is labeled with a first label representing the text type and a second label representing the AI large language model used. A model construction module is used to add a classification layer to the end of the pre-trained large language model to obtain a classification model. An initial training module is used to input the sample data from the training dataset into the classification model, utilizing the first label and the output of the classification model. The text classification model is trained iteratively using a validation dataset to determine its classification accuracy after each training iteration. Training stops when the accuracy exceeds a first preset threshold, resulting in a text classification model. A fine-grained training module inputs sample data from the training dataset into the text classification model, using the second label and the model's output to iteratively train it. The validation dataset is used to determine the model's accuracy after each training iteration, stopping when the number of iterations reaches a second preset threshold. The base classification model with the highest accuracy is then used as the final fine-grained text classification model. A model usage module inputs the acquired test text data into the fine-grained text classification model to obtain the model's classification result.
[0008] To achieve the above objectives, embodiments of this application also provide an electronic device, including: 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, the instructions being executed by the at least one processor to enable the at least one processor to perform the AI text detection method based on the pre-trained model described above.
[0009] To achieve the above objectives, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the AI text detection method based on a pre-trained model described above.
[0010] The AI text detection method based on a pre-trained model proposed in this application leverages the powerful text deconstruction capabilities of large language models. A classification layer is added to the pre-trained large language model to obtain a classification model. This model is then fine-tuned using human text, AI text from different large models, and AI-edited text, resulting in a classification model capable of fine-grained AI text detection. Unlike current AI text detection methods based on analyzing text distribution features, the pre-trained large language model can better capture deeper features in the text, achieving more accurate classification results. Since the training data and model architectures of AI large language models on different platforms differ, the generated text features also differ. The pre-trained large language model can effectively capture these features, thereby classifying AI text from different platforms. The resulting fine-grained text classification model has fine classification granularity and can accurately identify AI-edited text, enabling fine-grained, efficient, and low-cost text detection. When new AI large language models emerge online, current AI text detection methods need to re-collect the features of the AI text and modify the detection method itself. This application, however, only requires inputting 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 construction of the original dataset based on the acquired human text data, AI text data, and AI-polished text data includes: collecting a question dataset; recruiting volunteers to answer questions in the question dataset; using the volunteers' answers as human text data to generate a human text dataset; inputting the question dataset into various AI language models for answering; using the answers from each AI language model as AI text data to generate an AI text dataset; inputting the human text dataset into each AI language model for polishing; obtaining the AI-polished text data output by each AI language model to generate an AI-polished text dataset; labeling each piece of text data in the human text dataset, AI text dataset, and AI-polished text dataset with a first label and a second label, shuffling the order, and mixing them in a 1:1:1 ratio to form the original dataset. The human text dataset, AI text dataset, and AI-polished text dataset obtained based on the question dataset are cleaner, more scientific, and more standardized. Using such text data to fine-tune the classification model can further improve training speed and effectiveness, resulting in a higher classification accuracy for the trained model.
[0012] In some optional embodiments, the total number of AI large language models used to generate AI text data and AI polished text data are the same and correspond one-to-one. For human text data, the content of its second label is empty. This design, where the AI large language models used to generate AI text data and AI polished text data are the same and correspond one-to-one, better helps the model learn relevant knowledge of fine-grained classification, further improving the fine-grained classification ability and 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 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 the class prediction. The dropout layer, also known as the exit layer, temporarily removes some units from the network with a certain probability to prevent overfitting during training.
[0014] In some optional embodiments, the step of inputting sample data from the training dataset into the classification model, iteratively training the classification model using the first label and the output of the classification model, and determining the classification accuracy of the classification model after each training iteration using the validation dataset, stopping training when the classification accuracy is greater than a first preset threshold, and obtaining a text classification model, includes: inputting sample data from the training dataset into the classification model, using AdamW as the optimizer, and training the classification model N times using the first label and the output of the classification model; where N is an integer greater than 0; starting from the (N+1)th training iteration, after each training iteration, inputting sample data from the validation dataset into the classification model after this training iteration, calculating the classification accuracy of the classification model after this training iteration using the first label and the output of the classification model after this training iteration; if the classification accuracy of the classification model after this training iteration is less than or equal to the first preset threshold, then continuing to train the classification model after this training iteration for the next iteration; if the classification accuracy of the classification model after this training iteration is greater than the first preset threshold, then stopping training, and using the classification model after this training iteration 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 has the basic text classification ability and no further initial training is needed. At this point, the initial training can be ended and fine-grained training can begin, 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 model after the Mth training is still less than or equal to a first preset threshold, then training is stopped, and the classification model after the Mth training is used as the text classification model; where M is an integer greater than N, and N is an integer greater than or equal to 10. To prevent the initial training from going on indefinitely, this application sets a maximum number of training iterations. When the maximum number of training iterations is reached, even if the classification accuracy of the model does not meet the threshold, the initial training will end and fine-grained training will begin. This design saves training resources.
[0016] In some optional embodiments, the classification result of the fine-grained text classification model outputting the text data to be tested 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. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating an AI text detection method based on a pre-trained model, as provided in one embodiment of this application.
[0018] Figure 2 This is a flowchart provided by one embodiment of the present application, illustrating the construction of an original dataset based on acquired human text data, AI text data, and AI-edited text data;
[0019] Figure 3 This is an embodiment of the present application, in which sample data from the training dataset 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 validation dataset. When the classification accuracy is greater than a first preset threshold, training is stopped, and a flowchart of the text classification model is obtained.
[0020] Figure 4 This is a schematic diagram of the structure of an AI text detection system based on a pre-trained model provided in another embodiment of this application;
[0021] Figure 5 This is a schematic diagram of the structure of an electronic device provided in another embodiment of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to help readers better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.
[0023] One embodiment of this application proposes an AI text detection method based on a pre-trained model, which can be applied to electronic devices, wherein the electronic device can be a terminal or a server. This embodiment and the following embodiments all use a server as an example for description. The implementation details of the AI text detection method based on a pre-trained model proposed in this embodiment are described in detail below. The following implementation details are provided only for ease of understanding and are not necessary for implementing this solution.
[0024] The process of the AI text detection method based on a pre-trained model proposed in this embodiment can be as follows: Figure 1 As shown, it includes:
[0025] Step 101: Based on the acquired human text data, AI text data, and AI-edited text data, construct the original dataset and divide the original dataset into a training dataset and a validation dataset according to a preset ratio. Each sample data in the original dataset is labeled with a first label representing the text type and a second label representing the AI large language model used.
[0026] In its implementation, the server first acquires human text data, AI text data, and AI-edited text data. The AI-edited text data is obtained by using the editing function of an AI large-scale language model to edit human text data. Based on the acquired human text data, AI text data, and AI-edited text data, the server constructs an original dataset and divides it into a training dataset and a validation dataset according to a preset ratio (generally 7:3). Each sample in the original dataset is labeled with a first label representing the text type and a second label representing the AI large-scale language model used. For human text data, the first label is "human text," and the second label is empty. For AI text data, the first label is "AI text," and the second label is the AI large-scale language model used to generate the AI text. For AI-edited text data, the first label is "AI-edited text," and the second label is the AI large-scale language model used for editing.
[0027] In one example, the server constructs an original dataset based on the acquired human text data, AI text data, and AI-edited text data, which can be done through methods such as... Figure 2 The steps shown are implemented as follows:
[0028] Step 1011: Collect a question dataset, recruit volunteers to answer the questions in the question dataset, and use the volunteers' answers as human text data to generate a human text dataset.
[0029] In the specific implementation, the server first collects the problem dataset D. q Volunteers were recruited to work on the problem dataset D. q Volunteers answered questions in the dataset, and their responses were used as human text data to generate a human text dataset D. human .
[0030] Step 1012: Input the question dataset into each AI large language model for answering, and use the answers from each AI large language model as AI text data to generate an AI text dataset.
[0031] In the specific implementation, the server will use the problem dataset D q The questions in the dataset D are input into selected AI language models, which then process the question dataset D. q The questions in the dataset are answered, and the answers from various AI language models are used as AI text data to generate an AI text dataset D. ai , where D ai ={D ai1 D ai2 , ..., D ain}, where n is the total number of all pre-selected AI large language models.
[0032] Step 1013: Input the human text dataset into each AI large language model for polishing, and obtain the AI polished text data output by each AI large language model to generate the AI polished text dataset.
[0033] In the specific implementation, the server obtains the human text dataset D human Then, the human text dataset D can be... human The text is input into pre-selected AI language models for polishing, resulting in AI-polished text data output by each model, generating an AI-polished text dataset D. remix , where D remix ={D remix1 D remix2 , ..., D remixn}
[0034] Step 1014: Label each text data in the human text dataset, AI text dataset, and AI polished text dataset with a first label and a second label, shuffle the order, and mix them in a 1:1:1 ratio to form the original dataset.
[0035] In the specific implementation, the server obtains the human text dataset D human AI text dataset D ai AI-edited text dataset D remix Then, they can be respectively human text dataset D human AI text dataset D ai AI-edited text dataset D remix The first label y is used to annotate each text data. 1 Second label y 2 Then, the human text data, AI text data, and AI-edited text data, all labeled with the first and second tags, were shuffled and mixed in a 1:1:1 ratio to form the original dataset. The human text dataset, AI text dataset, and AI-edited text dataset obtained from the problem dataset are cleaner, more scientific, and more standardized. Using such text data to fine-tune the classification model can further improve training speed and effectiveness, resulting in a higher classification accuracy.
[0036] In one example, the total number of AI large language models used to generate AI text data and AI polished text data are the same and correspond one-to-one. For human text data, the content of its second label is empty. This design, where the same and corresponding AI large language models are used for both AI text data generation and AI polished text data generation, better helps the model learn relevant knowledge of fine-grained classification, further improving the fine-grained classification ability and accuracy of the trained model.
[0037] Step 102: Add a classification layer to the end of the pre-trained large language model to obtain a classification model.
[0038] In practice, after obtaining the training and validation datasets, the server can process the pre-selected pre-trained large language model and add a classification layer at the end of the pre-trained large language model to obtain a classification model.
[0039] In one example, the classification layer added by the server consists of a first fully connected layer, a dropout layer, and a second fully connected layer. The first fully connected layer learns complex combinations of its own input features, the dropout layer prevents overfitting, and the second fully connected layer maps the learned features to class predictions. The dropout layer, also known as the exit layer, temporarily removes some units from the network with a certain probability to prevent overfitting during training.
[0040] Step 103: Input the sample data in the training dataset into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the validation dataset 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 the text classification model.
[0041] In the specific implementation, after the server constructs the classification model, it can input sample data from the training dataset into the classification model. Using the first label and the output of the classification model, it iterative training is performed. Sample data from the validation dataset is used to determine the classification accuracy of the model after each training iteration. Training stops when the classification accuracy exceeds a first preset threshold, resulting in the text classification model. The training of the classification model can be called the initial training phase, and subsequent training of the text classification model can be called the fine-grained training phase.
[0042] In one example, the server inputs sample data from the training dataset into the classification model. Using the first label and the model's output, it iteratively trains the model and uses a validation dataset to determine the classification accuracy after each training iteration. Training stops when the accuracy exceeds a first preset threshold, resulting in a text classification model. This model can be used as follows: Figure 3 The steps shown are implemented as follows:
[0043] Step 1031: Input the sample data from the training dataset into the text classification model, use AdamW as the optimizer, and train the classification model N times using the first label and the output of the classification model.
[0044] In the specific implementation, when the server performs initial training on the classification model, it first inputs the sample data from the training dataset into the classification model, uses AdamW as the optimizer, and uses the first label on the sample data in the training dataset and the output of the classification model for the sample data in the training dataset to train the classification model N times, where N is an integer greater than 0.
[0045] Step 1032: Starting from the N+1th training iteration, after each training iteration, the sample data from the validation dataset is input into the classification model after this training iteration. Using the first label and the output of the classification model after this training iteration, the classification accuracy of the classification model after this training iteration is calculated.
[0046] In the specific implementation, starting from the (N+1)th training iteration, after each training iteration, the server inputs the sample data from the validation dataset into the classification model after this training. Using the first label annotated on the sample data in the validation dataset and the output of the classification model for the sample data in the validation dataset, the classification accuracy of the classification model after this training is calculated. Classification accuracy = Number of correctly classified samples / Total number of samples.
[0047] Step 1033: Determine whether the classification accuracy of the classification model after this training is greater than the first preset threshold. If yes, proceed directly to step 1035; otherwise, proceed to step 1034.
[0048] Step 1034: Continue training the classification model after this training.
[0049] Step 1035: Stop training and use the classification model trained in this session as the text classification model.
[0050] In the 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 a first preset threshold. If the classification accuracy of the classification model after this training is greater than the first preset threshold, then 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, then the classification model after this training is trained again for the next time.
[0051] Understandably, when the classification accuracy of the classification model is greater than the first preset threshold, it means that the classification model has the basic ability to classify text and no further initial training is needed. At this point, the initial training can be ended and fine-grained training can begin, 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 model after the Mth training is still less than or equal to a first preset threshold, then training can be stopped, and the classification model after the Mth training can be used as the text classification model. Here, M is an integer greater than N, and N is an integer greater than or equal to 10. To prevent the initial training from running indefinitely, this application sets a maximum number of training iterations. When the maximum number of training iterations is reached, even if the classification accuracy of the model does not meet the threshold, the initial training will end and fine-grained training will begin. This design saves training resources.
[0053] Step 104: Input the sample data in the training dataset 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 validation dataset to determine the classification accuracy of the text classification model after each training. When the number of iterations reaches the second preset threshold, stop training and use the basic classification model with the highest classification accuracy as the final fine-grained text classification model.
[0054] In the specific implementation, after the server completes the initial training and obtains the text classification model, it can input the sample data from the training dataset into the text classification model. Using the second label on the sample data in the training dataset and the output of the text classification model for the sample data in the training dataset, the text classification model is iteratively trained. The classification accuracy of the text classification model after each training is determined using the sample data in the validation dataset. 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 final fine-grained text classification model.
[0055] Step 105: Input the obtained 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 practical implementation, after obtaining the fine-grained text classification model, the server can deploy it according to requirements. The acquired test text data is input into the fine-grained text classification model to obtain the classification result of the test text data output by the fine-grained text classification model. Specifically, the classification result of the test text data output by the fine-grained text classification model includes: the text type of the test text data and the AI large language model used to generate the text data. When the text type of the test text data is human text, the AI large language model used to generate the text data is empty.
[0057] This embodiment leverages the powerful text deconstruction capabilities of large language models. A classification layer is added to a pre-trained large language model to obtain a classification model. This model is then fine-tuned using human text, AI text from different large models, and AI-edited text, resulting in a classification model capable of fine-grained AI text detection. Unlike current AI text detection methods based on analyzing text distribution features, the pre-trained large language model can better capture deeper features in the text, achieving more accurate classification results. Different platforms provide different training data and model architectures for their AI large language models, resulting in different generated text features. The pre-trained large language model effectively captures these features, classifying AI text from different platforms. The resulting fine-grained text classification model has fine classification granularity and can accurately identify AI-edited text, enabling fine-grained, efficient, and low-cost text detection. When new AI large language models emerge online, current AI text detection methods need to re-collect the features of the AI text and modify the detection method itself. This application, however, only requires inputting 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 this application proposes an AI text detection system based on a pre-trained model. The details of this AI text detection system based on a pre-trained model are described below. The following implementation details are provided for ease of understanding and are not essential for implementing this example. Figure 4 This is a schematic diagram of the structure of the AI text detection system based on a pre-trained model proposed in this embodiment, including: a data acquisition module 201, a model building module 502, an initial training module 203, a fine-grained training module 204, and a model usage module 205.
[0059] The data acquisition module 201 is used to acquire human text data, AI text data, and AI-edited text data. Based on the acquired human text data, AI text data, and AI-edited text data, it constructs an original dataset and divides the original dataset into a training dataset and a validation dataset according to a preset ratio. Each sample data in the original dataset is labeled with a first label representing the text type and a second label representing the AI large language model used.
[0060] Model building module 202 is used to add a classification layer to the end of a pre-trained large language model to obtain a classification model.
[0061] The initial training module 203 is used to input sample data from the training dataset into the classification model, use the first label and the output of the classification model to iteratively train the classification model, and use the validation dataset 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 stops and the text classification model is obtained.
[0062] The fine-grained training module 204 is used to input sample data from the training dataset 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 validation dataset to determine the classification accuracy of the text classification model after each training. When the number of iterations reaches the second preset threshold, the training stops, and the base classification model with the highest classification accuracy is taken as the final fine-grained text classification model.
[0063] The model uses module 205 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.
[0064] It is not difficult to see that this embodiment is a system embodiment corresponding to the above method embodiments, and this embodiment can be implemented in conjunction with the above method embodiments. The relevant technical details and technical effects mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiments.
[0065] It is worth mentioning that all modules involved in this embodiment are logical modules. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. Furthermore, to highlight the innovative aspects of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed in this application; however, this does not mean that other units are absent in this embodiment.
[0066] Another embodiment of this application relates to an electronic device, such as... Figure 5 As shown, it includes: at least one processor 301; and a memory 302 communicatively connected to the at least one processor 301; wherein the memory 302 stores instructions executable by the at least one processor 301, the instructions being executed by the at least one processor 301 to enable the at least one processor 301 to execute the AI text detection method based on the pre-trained model described in the above embodiments.
[0067] The memory and processor can be connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well-known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0068] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.
[0069] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the AI text detection method based on a pre-trained model as described in the above-described method embodiments.
[0070] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, ROM (Read-Only Memory), RAM (Random Access Memory), a magnetic disk, or an optical disk.
[0071] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.
Claims
1. An AI text detection method based on a pre-trained model, characterized in that, The method comprises the following steps: Based on the obtained 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 labeled with a first label representing the text type and a second label representing the AI large language model used; A classification layer is added at the end of the pre-trained large language model to obtain a classification model; The sample data in the training data set is input into the classification model, and the first label and the output of the classification model are used to iteratively train 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, thereby obtaining a text classification model; The sample data in the training data set is input into the text classification model, and the second label and the output of the text classification model are used to iteratively train the text classification model, and the classification accuracy of the text classification model after each training is determined using the verification data set, and the training is stopped when the iteration number reaches a second preset threshold, and the base classification model with the highest classification accuracy is taken as the final training obtained fine-grained text classification model; The obtained test text data is input into the fine-grained text classification model to obtain the classification result of the test text data output by the fine-grained text classification model; The method comprises the following steps: Collect the question data set, recruit volunteers to answer the questions in the question data set, and take the answers of the volunteers as human text data to generate a human text data set; Input the question data set into each AI large language model to answer, and take the answers 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 to obtain AI polished text data output by each AI large language model, and generate an AI polished text data set; Label each text data in the human text data set, AI text data set and AI polished text data set with a first label and a second label, mix them in the order after being shuffled according to a ratio of 1:1:1 to form an original data set; The classification result of the test text data output by the fine-grained text classification model is the text type of the test text data and the AI large language model used to generate the text data, and when the text type of the test text data is human text, the AI large language model used to generate the text data is empty. 2.The pre-trained model-based AI text detection method of claim 1, wherein, The total number of AI large language models used to generate AI text data and generate AI polished text data is the same and one-to-one, and for human text data, the content of the second label labeled is empty. 3.The pre-trained model-based AI text detection method of claim 1, wherein, The classification layer added at the end of the pre-trained large language model comprises a first full connection layer, a dropout layer and a second full connection layer; The first full connection layer is used to learn the complex combination of its own input features, the dropout layer is used to prevent overfitting, and the second full connection layer is used to map the learned features to class prediction. 4.The AI text detection method based on a pre-trained model according to claim 1, wherein, 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 validation data set, and the training is stopped when the classification accuracy is greater than the first preset threshold, to obtain a text classification model, comprising: 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 validation data set, and the training is stopped when the classification accuracy is greater than the first preset threshold, to obtain a text classification model, comprising: 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 validation data set, and the training is stopped when the classification accuracy is greater than the first preset threshold, to obtain a text classification model, comprising: If the classification accuracy of the classification model after the Mth training is still less than or equal to the first preset threshold, stop training, and take the classification model after the Mth training as the text classification model; wherein M is an integer greater than N, and N is an integer greater than or equal to 10. Comprising: 5.The AI text detection method based on a pre-trained model according to claim 4, characterized in that, The data acquisition module is used for acquiring human text data, AI text data and AI polished text data, and 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 validation data set according to a preset proportion, wherein each sample data in the original data set is labeled with a first label representing a text type and a second label representing an AI large language model used; 6. An AI text detection system based on a pre-trained model, used to implement the AI text detection method based on a pre-trained model according to any one of claims 1 to 5, characterized in that, The model construction module is used for adding a classification layer at the end of a pre-trained large language model to obtain a classification model; The initial training module is used for inputting 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 determining the classification accuracy of the classification model after each training using the validation data set, and stopping training when the classification accuracy is greater than the first preset threshold to obtain a text classification model; The fine-grained training module is used for inputting sample data in the training data set into the text classification model, iteratively training the text classification model using the second label and the output of the text classification model, and determining the classification accuracy of the text classification model after each training using the validation data set, and stopping training when the iteration number reaches the second preset threshold, and taking the base classification model with the highest classification accuracy as the fine-grained text classification model obtained by final training; The model using module is used for inputting the obtained to-be-tested text data into the fine-grained text classification model to obtain the classification result of the to-be-tested text data output by the fine-grained text classification model. Comprising: At least one processor; 7. An electronic device, comprising: and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the AI text detection method based on a pre-trained model according to any one of claims 1 to 5.
8. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the AI text detection method based on a pre-trained model according to any one of claims 1 to 5.
Citation Information
Patent Citations
Detection method and device for AI generated text, medium and equipment
CN117151074A
Exercising artificial intelligence by refining model output
CN112166443A
Science and technology information text classification method
CN112199501A