Text detection method, electronic equipment and computer readable storage medium
By calculating the neural activation and differences of the text to be detected in the proxy model, and determining whether it generates text for the model, the problems of poor generalization ability and low detection efficiency in the existing technology are solved, and a text detection method with high precision and strong generalization ability is realized.
Patent Information
- Application Number
- CN202411996299.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-02
AI Technical Summary
The existing text detection methods do not have good generalization capabilities and cannot effectively detect whether the text to be detected is text generated by a large language model.
By obtaining the neural activation differences of the text to be detected and the neural activation differences of the proxy model, the projection score is calculated, and compared with the predetermined classification threshold, it is determined whether the text to be detected is a model generated text.
It realizes the high-precision detection model to generate text under a small number of samples, improves the generalization ability and effectiveness of text detection, and overcomes the limitations of traditional detection methods.
Smart Images

Figure CN119918536A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text detection method, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of natural language technology, large language models have shown powerful language understanding and generation capabilities, but also brought new challenges. Therefore, it is necessary to provide some methods to effectively recognize the text generated by large models.
[0003] At present, there are two main detection methods used to identify whether the text to be detected is generated by a large language model, including fine-tuning based classifiers and statistics-based methods. Among them, the fine-tuning based classifier is obtained by training with a large amount of annotated data. Although it has a high accuracy rate, it requires expensive computing resources and data annotation costs, and it is difficult to generalize to new models and fields. The statistical-based method has stronger reliability and application prospects in real scenarios, but due to the lack of robustness of classification features, it still has limitations such as susceptibility to adversarial samples and instability. Therefore, the above detection methods do not have good generalization capabilities, and cannot ensure effective detection of whether the text to be detected is generated by a large language model. Summary of the invention
[0004] The purpose of the present application is to provide a text detection method, an electronic device and a computer-readable storage medium to address the deficiencies in the above-mentioned prior art, so as to solve the problem that the existing detection methods do not have good generalization ability and cannot ensure effective detection of whether the text to be detected is a text generated by a large language model.
[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a text detection method, the method comprising:
[0007] Get the text to be detected;
[0008] Inputting the text to be detected into the proxy model, and capturing the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model;
[0009] Obtaining a neural activation difference of each hidden layer of the proxy model, wherein the neural activation difference is used to characterize a difference in neural activation caused by a model-generated text and a human-written text on the hidden layer, wherein the neural activation difference is pre-determined based on a training set including the model-generated text and the human-written text;
[0010] Determining a projection score of the text to be detected according to neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and differences in neural activations of each hidden layer of the proxy model;
[0011] The projection score of the text to be detected is compared with the classification threshold of the proxy model, and whether the text to be detected belongs to the model-generated text is determined according to the comparison result. The classification threshold is pre-determined based on a training set containing model-generated text and human-written text.
[0012] As a possible implementation, the process of determining the neural activation of each hidden layer and the classification threshold includes:
[0013] Acquire multiple text pairs in a training set, wherein the text pairs include a model-generated text and a human-written text, and the model-generated text and the human-written text each include multiple text units;
[0014] Inputting the model-generated text and the human-written text in each of the text pairs into the proxy model respectively, capturing the neural activation of each text unit in the model-generated text in each hidden layer of the proxy model, and capturing the neural activation of each text unit in the human-written text in each hidden layer of the proxy model;
[0015] Determine the difference in neural activations corresponding to each hidden layer based on the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each hidden layer in each text pair;
[0016] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each text pair are projected, and the classification threshold is determined according to the projection results.
[0017] As a possible implementation, determining the difference in neural activations corresponding to each hidden layer based on the neural activations of each text unit of the model-generated text in each text pair and the neural activations of each text unit of the human-written text in each hidden layer includes:
[0018] Determine the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each hidden layer in each text pair;
[0019] The initial activation differences corresponding to each hidden layer are processed by principal component analysis to obtain the neural activation differences corresponding to each hidden layer.
[0020] As a possible implementation, determining the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text in each text pair and the neural activation of each text unit of the human-written text in each hidden layer includes:
[0021] Determine the initial activation difference of each text pair at the first hidden layer based on the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in the first hidden layer;
[0022] The set of neural activation differences of all text pairs in the first hidden layer is used as the initial activation difference corresponding to the first hidden layer, wherein the first hidden layer is any hidden layer in the proxy model.
[0023] As a possible implementation, the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each text pair are projected according to the neural activation difference corresponding to each hidden layer, and the classification threshold is determined according to the projection result, including:
[0024] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, wherein the current text is a model-generated text or a human-written text in any text pair;
[0025] Taking the average of the projection scores of all text units in the current text as the projection score corresponding to the current text;
[0026] The classification threshold is determined according to the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts.
[0027] As a possible implementation method, according to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, including:
[0028] By formula Calculate the projection score of the jth text unit in the current text, where RepreScore(t j ) represents the projection score of the jth text unit in the current text, t j represents the jth text unit in the current text, L represents the number of hidden layers, h l (t j ) represents the neural activation of the jth text unit in the lth hidden layer, P lrepresents the difference in neural activations corresponding to the lth hidden layer.
[0029] As a possible implementation, determining the projection score of the text to be detected according to the neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activations of each hidden layer of the proxy model includes:
[0030] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit in the text to be detected are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the text to be detected;
[0031] The average value of the projection scores of all text units in the text to be detected is taken as the projection score corresponding to the text to be detected.
[0032] As a possible implementation manner, determining whether the to-be-detected text belongs to the model-generated text according to the comparison result includes:
[0033] If the projection score of the text to be detected is greater than the classification threshold, it is determined that the text to be detected belongs to the model-generated text; otherwise, it is determined that the text to be detected does not belong to the model-generated text.
[0034] In a second aspect, an embodiment of the present application provides a text detection device, the device comprising:
[0035] A first acquisition module, used to acquire the text to be detected;
[0036] A capture module, used for inputting the text to be detected into a proxy model, and capturing the neural activations of each text unit in the text to be detected in each hidden layer of the proxy model;
[0037] A second acquisition module is used to acquire a neural activation difference of each hidden layer of the proxy model, wherein the neural activation difference is used to characterize a difference in neural activation caused by the model-generated text and the human-written text on the hidden layer, and the neural activation difference is pre-determined based on a training set including the model-generated text and the human-written text;
[0038] A determination module, configured to determine a projection score of the text to be detected based on neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and differences in neural activations of each hidden layer of the proxy model;
[0039] A comparison module is used to compare the projection score of the text to be detected with the classification threshold of the proxy model, and determine whether the text to be detected belongs to the model-generated text according to the comparison result, and the classification threshold is pre-determined based on a training set containing model-generated text and human-written text.
[0040] As a possible implementation manner, the determining module is further used to:
[0041] Acquire multiple text pairs in a training set, wherein the text pairs include a model-generated text and a human-written text, and the model-generated text and the human-written text each include multiple text units;
[0042] Inputting the model-generated text and the human-written text in each of the text pairs into the proxy model respectively, capturing the neural activation of each text unit in the model-generated text in each hidden layer of the proxy model, and capturing the neural activation of each text unit in the human-written text in each hidden layer of the proxy model;
[0043] Determine the difference in neural activations corresponding to each hidden layer based on the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each hidden layer in each text pair;
[0044] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each text pair are projected, and the classification threshold is determined according to the projection results.
[0045] As a possible implementation manner, the determining module is further used to:
[0046] Determine the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each hidden layer in each text pair;
[0047] The initial activation differences corresponding to each hidden layer are processed by principal component analysis to obtain the neural activation differences corresponding to each hidden layer.
[0048] As a possible implementation manner, the determining module is further used to:
[0049] Determine the initial activation difference of each text pair at the first hidden layer based on the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in the first hidden layer;
[0050] The set of neural activation differences of all text pairs in the first hidden layer is used as the initial activation difference corresponding to the first hidden layer, wherein the first hidden layer is any hidden layer in the proxy model.
[0051] As a possible implementation manner, the determining module is further used to:
[0052] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, wherein the current text is a model-generated text or a human-written text in any text pair;
[0053] Taking the average of the projection scores of all text units in the current text as the projection score corresponding to the current text;
[0054] The classification threshold is determined according to the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts.
[0055] As a possible implementation manner, the determining module is further used to:
[0056] By formula Calculate the projection score of the jth text unit in the current text, where t j represents the jth text unit in the current text, L represents the number of hidden layers, h l (t j ) represents the neural activation of the jth text unit in the lth hidden layer, P l represents the difference in neural activations corresponding to the lth hidden layer.
[0057] As a possible implementation manner, the determining module is further used to:
[0058] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit in the text to be detected are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the text to be detected;
[0059] The average value of the projection scores of all text units in the text to be detected is taken as the projection score corresponding to the text to be detected.
[0060] As a possible implementation, the comparison module is specifically used for:
[0061] If the projection score of the text to be detected is greater than the classification threshold, it is determined that the text to be detected belongs to the model-generated text; otherwise, it is determined that the text to be detected does not belong to the model-generated text.
[0062] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the text detection method as described in any one of the first aspects above.
[0063] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text detection method as described in any one of the first aspects above are executed.
[0064] According to the text detection method, electronic device and computer-readable storage medium of the embodiment of the present application, the text to be detected is obtained, and the text to be detected is input into the proxy model, the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model is captured, and the difference in neural activation of each hidden layer of the proxy model is obtained, and the projection score of the text to be detected is determined according to the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activation of each hidden layer of the proxy model, and the projection score of the text to be detected is compared with the classification threshold of the proxy model, and it is determined whether the text to be detected belongs to the model-generated text according to the comparison result. According to the embodiment of the present application, the neural activation difference and the classification threshold are both determined in advance based on a training set containing model-generated text and human-written text. The neural activation difference reflects the difference in representation of the proxy model when processing different types of text, and is a key feature for distinguishing the two types of text. On this basis, the proxy model is used to capture the neural activation of the text to be detected in different hidden layers, and the projection score of the text to be detected is determined by combining the neural activation differences of each hidden layer of the proxy model. The projection score reflects the similarity between the text to be detected and the model-generated text and the human-written text in the neural activation pattern, and then the projection score of the text to be detected is compared with the classification threshold to determine whether the text to be detected belongs to the model-generated text. Therefore, the present application uses the neural activation differences of the large language model when processing human-written text and model-generated text as the detection basis. By capturing the representation differences of the large language model when processing human-written text and model-generated text, high-precision model-generated text detection can be achieved even under a small number of sample conditions, and it is effectively distinguished whether the text to be detected belongs to the model-generated text. In addition, since the present application relies on the deep-level feature of the neural activation pattern rather than the surface language statistical characteristics, and with the help of the powerful representation ability of the proxy model, it not only improves the generalization ability of text detection, but also ensures the effectiveness of text detection, and overcomes the limitations of traditional detection methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 A flowchart of a text detection method provided in an embodiment of the present application is shown;
[0067] Figure 2 A schematic diagram of a process for determining a neural activation and classification threshold provided in an embodiment of the present application is shown;
[0068] Figure 3 A schematic diagram of a process for determining a neural activation difference provided in an embodiment of the present application is shown;
[0069] Figure 4 A schematic diagram of a process for determining a classification threshold value provided in an embodiment of the present application is shown;
[0070] Figure 5 A schematic diagram of a process for determining a projection score of a text to be detected provided in an embodiment of the present application is shown;
[0071] Figure 6 A schematic diagram of the structure of a text detection device provided in an embodiment of the present application is shown;
[0072] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0073] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0074] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0075] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0076] Although fine-tuning-based detection methods have better accuracy than statistical-based detectors, they rely on a large amount of labeled data and are often unable to be transferred to new models. When faced with a new generative model, a large amount of cost is required to update the detector. In contrast, statistical-based methods show better interpretability than fine-tuning methods, and only require pre-setting thresholds based on the feature distribution laws observed on a small number of samples, which has stronger reliability and application prospects in real scenarios. However, the performance of existing statistical-based detectors is still limited both within and outside the distribution. This limitation comes from the lack of robustness of the classification features used. For example, the use of different instructions can control the level of perplexity of the generated text, making it difficult for the threshold extracted from the training sample to play an effective role, and this limitation is further amplified outside the distribution.
[0077] In response to the above problems, an embodiment of the present application provides a file detection method, which is a detection method based on a neural representation model. By extracting more robust features in the text representation, it can achieve effective detection of text generated by a large language model, and can achieve high-precision detection of text generated by a large language model with a small number of samples. Whether in or out of the distribution, the present application uses a proxy model to observe the neural activation pattern of the text, and uses the difference in the proxy model's familiarity with the statistical patterns of human-written texts and model-generated texts. By capturing the representation differences between the large language model when processing human-written texts and large language model-generated texts, the model-generated text can be effectively distinguished.
[0078] Figure 1 A flowchart of a text detection method provided in an embodiment of the present application is shown. Figure 1 As shown, the method specifically comprises the following steps:
[0079] S101, obtaining a text to be detected.
[0080] Optionally, the text to be detected is a text sample that needs to be detected to determine whether the text to be detected is generated by a large language model or written by humans, and the text to be detected can be of any length and subject matter.
[0081] S102, inputting the text to be detected into the proxy model, and capturing the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model.
[0082] Optionally, the proxy model can be any model that can process text and produce neural activation outputs, and is a pre-trained neural network model, such as Bidirectional Encoder Representations from Transformers (BERT) or Generative Pre-trained Transformer (GPT). The proxy model is used to read the text to be detected and generate neural activations on each hidden layer inside the proxy model.
[0083] Optionally, the text unit can be a word, a character, or other component of the text, depending on the word segmentation strategy of the proxy model. When the text to be detected is input into the proxy model, each hidden layer of the proxy model will generate a neural activation pattern, which reflects the proxy model's understanding and processing of the content of the text to be detected. That is, when the text to be detected is input into the proxy model, the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model can be captured, that is, the feature representation of each text unit in the text to be detected at different levels can be captured.
[0084] S103. Obtain the neural activation differences of each hidden layer of the proxy model.
[0085] Optionally, the neural activation difference refers to the difference between neural activations generated on the hidden layer by the agent model when processing different types of text, such as model-generated text and human-written text. The neural activation difference is used to characterize the difference in neural activations caused by the model-generated text and the human-written text on the hidden layer, and the neural activation difference is determined in advance based on a training set containing model-generated text and human-written text.
[0086] Optionally, the training set may include text samples of known sources, that is, multiple model-generated texts and human-written texts known to be generated by a large language model or written by humans. The differences in neural activations of each hidden layer of the proxy model can be determined by comparing the text samples in the training set of known sources, thereby forming a benchmark for measuring the similarity between the text to be tested and the two types of texts: model-generated text and human-written text.
[0087] S104, determining the projection score of the text to be detected according to the neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activations of each hidden layer of the proxy model.
[0088] Optionally, the projection score is a numerical value representing the position of the text to be detected in the neural activation difference space, and the projection score is obtained by performing some form of comparison or calculation of the neural activation of the text to be detected with a predetermined neural activation difference, and the higher the projection score, the more similar the neural activation pattern of the text to be detected is to the text generated by the model.
[0089] Optionally, for each text unit in the text to be detected, the degree of match between the neural activation of the text unit and the pre-calculated neural activation difference is calculated at each layer of the proxy model, thereby obtaining a projection score of the text to be detected, which quantifies the similarity between the text to be detected and the model-generated text and human-written text.
[0090] S105 , comparing the projection score of the text to be detected with the classification threshold of the proxy model, and determining whether the text to be detected is a model-generated text based on the comparison result.
[0091] Optionally, the classification threshold is also determined in advance based on a training set containing model-generated text and human-written text, and is used to distinguish between model-generated text and human-written text. Determining whether the text to be detected belongs to the model-generated text depends on the comparison between the calculated projection score of the text to be detected and the classification threshold determined in advance based on the training set. The comparison result reflects the size relationship between the projection score of the text to be detected and the classification threshold. According to the size relationship, it can be determined whether the text to be detected belongs to the model-generated text or the human-written text.
[0092] Optionally, determining whether the text to be detected belongs to the model generated text based on the comparison result includes: if the projection score of the text to be detected is greater than the classification threshold, determining that the text to be detected belongs to the model generated text; otherwise, determining that the text to be detected does not belong to the model generated text.
[0093] Exemplarily, the classification threshold is a numerical value used to distinguish between two types of text. If the projection score of the text to be detected exceeds this classification threshold, it can be determined that the text to be detected is model-generated text. Otherwise, the text to be detected is considered to be human-written text.
[0094] Based on this, according to the text detection method provided by the embodiment of the present application, the neural activation difference and the classification threshold are both determined in advance based on a training set containing model-generated text and human-written text. The neural activation difference reflects the representation difference of the proxy model when processing different types of texts, which is the key feature to distinguish the two types of texts. On this basis, the proxy model is used to capture the neural activation of the text to be detected in different hidden layers, and the projection score of the text to be detected is determined in combination with the neural activation difference of each hidden layer of the proxy model. The projection score reflects the similarity between the text to be detected and the model-generated text and the human-written text in the neural activation pattern, and then the projection score of the text to be detected is compared with the classification threshold to determine whether the text to be detected belongs to the model-generated text. Therefore, the present application uses the neural activation difference of the large language model when processing human-written text and model-generated text as the detection basis. By capturing the representation difference of the large language model when processing human-written text and model-generated text, high-precision model-generated text detection can be achieved even under a small number of sample conditions, and it is effectively distinguished whether the text to be detected belongs to the model-generated text. In addition, since the present application relies on the deep-level feature of neural activation patterns rather than the superficial statistical characteristics of language, and with the help of the powerful representation ability of the proxy model, it not only improves the generalization ability of text detection, but also ensures the effectiveness of text detection, overcoming the limitations of traditional detection methods.
[0095] Figure 2 FIG. 1 is a flow chart of a method for determining a neural activation and classification threshold provided in an embodiment of the present application. Figure 2 As shown, determining the neural activation and classification threshold of each hidden layer specifically includes the following steps:
[0096] S201. Obtain multiple text pairs in a training set.
[0097] Optionally, the text pair includes a model-generated text and a human-written text, and the model-generated text and the human-written text each include a plurality of text units. The model-generated text in each text pair can be generated by a large language model according to the corresponding human-written text, that is, the model-generated text and the human-written text in the text pair should have similar topics or content structures, so that the proxy model can better capture the differences between the model-generated text and the human-written text.
[0098] Exemplarily, whether it is model-generated text or human-written text, the text may include one or more sentences. After the model-generated text and human-written text in each text pair are input into the proxy model, the proxy model will treat the model-generated text and the human-written text as a text sequence respectively, and decompose the text sequences corresponding to the model-generated text and the human-written text according to the corresponding word segmentation strategies to obtain multiple text units, each of which is a token.
[0099] Specifically, in the large language model, token refers to the basic unit of text after word segmentation. Token can be a word, a character, or even a special marker, depending on the word segmentation strategy and model architecture used by the model. Token has the functions of representing input, capturing semantic information, and controlling the length of text sequences. Representing input refers to converting the original model-generated text or human-written text into a form that the proxy model can understand. By decomposing the model-generated text or human-written text into a series of tokens and mapping them to a numerical vector space, the proxy model can process them. Capturing semantic information means that different tokens combined together can help the proxy model capture the structure and meaning of the text sequence. For example, in the large language model BERT, each token not only carries its own semantic information, but also contains contextual information. Controlling the length of the text sequence means that the proxy model has a maximum length limit on the input text sequence. By splitting the text sequence into multiple tokens, it is easier to manage and adjust the length of the input text sequence to meet the needs of the proxy model.
[0100] S202. Input the model-generated text and the human-written text in each text pair into the proxy model respectively, capture the neural activation of each text unit in the model-generated text in each hidden layer of the proxy model, and capture the neural activation of each text unit in the human-written text in each hidden layer of the proxy model.
[0101] Exemplarily, a mechanism is set in the proxy model to capture the neural activations of the hidden layer, which specifically involves modifying the code of the proxy model to output the state of the hidden layer, or using a specific library or tool to capture these outputs. After the model-generated text and the human-written text in each text pair are respectively input into the proxy model, for each text pair, the neural activations of each text unit in the model-generated text in each hidden layer of the proxy model and the neural activations of each text unit in the human-written text in each hidden layer of the proxy model are respectively captured.
[0102] For example, the training set can be written as Among them, N represents the training set The number of Chinese text pairs, represents the model generated text in the text pair, Representing human-written text in text pairs. Using the proxy model as an observer, we collect the corresponding representation distributions when processing model-generated text and human-written text to capture the activation differences between model-generated text and human-written text.
[0103] Specifically, both the model-generated text and the human-written text can be regarded as a text sequence. For each text sequence T = {t1, t2, ..., t n}, assuming that the proxy model has a total of L hidden layers, for each tokent in the text sequence T j , the neural activation of the agent model in each hidden layer can be expressed as Where d represents the dimension of the hidden state of the proxy model. On this basis, the complete activation of the text sequence T in the proxy model can be formalized as shown in the following expression (1):
[0104]
[0105] Where A(T) represents the complete activation of the text sequence T in the proxy model, n represents the number of tokens (i.e., text units), Represents each tokent in the text sequence T j The corresponding neural activations, L represents all hidden layers in the proxy model, and l represents a hidden layer in the proxy model.
[0106] For example, for the training set Each text pair in Capture the representation activation of the proxy model on all hidden layers L. For the model-generated text, the neural activation of each text unit in the captured model-generated text in each hidden layer of the proxy model is expressed as For human writing text, the neural activations of each text unit in the captured human writing text in each hidden layer of the proxy model are represented as
[0107] S203, determining the neural activation differences corresponding to each hidden layer according to the neural activations of each text unit of the model-generated text in each text pair and the neural activations of each text unit of the human-written text in each hidden layer.
[0108] Optionally, the neural activations of each text unit of the model-generated text in each text pair and the neural activations of each text unit of the human-written text in each hidden layer are both high-dimensional representations. In order to extract the key feature directions that can best distinguish the model-generated text from the human-written text, the present application uses principal component analysis to capture the high-dimensional representations. and Modeling and dimensionality reduction are performed to determine the differences in activation patterns between the model-generated text and the human-written text in each text pair, and then to determine the differences in neural activations corresponding to each hidden layer.
[0109] For example, the activation pattern difference between the model-generated text and the human-written text in each text pair is specifically shown in the following expression (2):
[0110]
[0111] Where ΔA i represents the difference in activation patterns between the model-generated text and the human-written text in each text pair, represents the neural activations of each hidden layer of the proxy model for each text unit in the text generated by the model, Represents the neural activations of each hidden layer of the proxy model for each text unit in human writing text.
[0112] Figure 3 FIG. 1 is a flow chart of a method for determining a neural activation difference provided in an embodiment of the present application. Figure 3 As shown, the above step S203 specifically includes the following steps:
[0113] S301, determining the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model generated text in each text pair and the neural activation of each text unit of the human writing text in each hidden layer.
[0114] Optionally, the initial activation difference corresponding to each hidden layer is specifically determined based on the difference between the neural activation of each text unit of the model-generated text in each hidden layer and the neural activation of each text unit of the human-written text in each hidden layer. For each text pair containing model-generated text and human-written text, the neural activations of each text pair in each hidden layer of the proxy model are extracted, and the difference between these neural activations is calculated. The difference can be measured in a variety of ways, such as using Euclidean distance, cosine similarity or other appropriate measurement methods. The final measured difference value represents the initial activation difference of the text pair on the first hidden layer.
[0115] Optionally, the above step S301 specifically includes: determining the initial activation difference in the first hidden layer of each text pair based on the neural activation of each text unit of the model generated text in each text pair and the neural activation of each text unit of the human writing text in the first hidden layer; taking the set of the neural activation differences in the first hidden layer of all text pairs as the initial activation difference corresponding to the first hidden layer, wherein the first hidden layer is any hidden layer in the proxy model.
[0116] Exemplarily, the initial activation difference of each text pair in the first hidden layer is expressed as follows (3):
[0117]
[0118] in, represents the initial neural activation of the first hidden layer for the i-th text pair, represents the neural activations in the first hidden layer of each text unit of the model-generated text in the i-th text pair, Represents the neural activations of the first hidden layer for each text unit of the human-written text in the i-th text pair.
[0119] Exemplarily, the set of neural activation differences of all text pairs in the first hidden layer is taken as the initial activation difference corresponding to the first hidden layer. The initial activation difference of the first hidden layer is specifically shown in the following expression (4):
[0120]
[0121] Among them, ΔA l represents the initial activation difference corresponding to the first hidden layer, ΔA l i represents the difference in neural activations in the first hidden layer of the i-th text pair, and N represents the training set The number of Chinese text pairs, L represents all hidden layers in the proxy model, and l represents a hidden layer in the proxy model (for example, the first hidden layer).
[0122] S302, performing principal component analysis on the initial activation differences corresponding to each hidden layer to obtain the neural activation differences corresponding to each hidden layer.
[0123] For example, in order to filter out noise and identify key features that distinguish text generated by a large language model, the initial activation difference ΔA corresponding to each hidden layer needs to be calculated. l The principal component analysis (PCA) is used to extract the main components of the initial activation differences corresponding to each hidden layer through dimensionality reduction technology, so as to more clearly understand the differences in neural activation of each hidden layer when processing model-generated text and human-written text. On this basis, the principal component analysis is performed on the initial activation differences corresponding to each hidden layer, with the aim of obtaining the main feature directions of the neural activation differences corresponding to each hidden layer that are more representative of the model-generated text.
[0124] Exemplarily, the principal component analysis process is specifically shown in the following expression (5):
[0125] P l = PCA(ΔA l) (5)
[0126] Among them, P l represents the difference in neural activation corresponding to hidden layer l, ΔA l represents the initial activation difference corresponding to the hidden layer l, and PCA represents the principal component analysis algorithm.
[0127] Specifically, before the principal component analysis is performed on the initial activation differences corresponding to each hidden layer, the initial activation differences corresponding to each hidden layer can be first centered, and the covariance matrix corresponding to the initial activation differences corresponding to each hidden layer can be calculated. The covariance matrix reflects the linear correlation between the variables in the initial activation differences corresponding to each hidden layer, so the internal structure of the initial activation differences corresponding to each hidden layer and the relationship between the variables can be captured through the covariance matrix. Further, the covariance matrix is subjected to eigenvalue decomposition to obtain eigenvalues and eigenvectors. The eigenvalues reflect the variance of the initial activation differences corresponding to each hidden layer in the direction of the corresponding eigenvector, and the eigenvectors represent the base directions of the initial activation differences corresponding to each hidden layer in the new coordinate system. In this way, through eigenvalue decomposition, the direction with the largest variability in the initial activation differences corresponding to each hidden layer can be found, that is, the direction of the principal component.
[0128] Furthermore, according to the size of the eigenvalue, the eigenvector corresponding to the larger eigenvalue is selected as the principal component, for example, the first few principal components that can explain most of the variability of the data are selected to achieve data dimensionality reduction. Then, the selected principal components are used to linearly transform the initial activation differences corresponding to the original hidden layers, and the original initial activation differences corresponding to the hidden layers are projected into the new coordinate system. While achieving data dimensionality reduction, the main information in the initial activation differences corresponding to the hidden layers is retained, and the neural activation differences corresponding to the hidden layers are obtained.
[0129] S204. Project the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each text pair according to the difference in neural activations corresponding to each hidden layer, and determine the classification threshold according to the projection results.
[0130] Optionally, after the principal component analysis is performed to reduce the dimensionality, the neural activation differences corresponding to each hidden layer can be projected into a low-dimensional space, such as two-dimensional or three-dimensional, for visualization analysis. The points in the low-dimensional space represent the neural activation states of different text units. In this low-dimensional space, the neural activation distribution of model-generated text and human-written text can be observed. Ideally, the activation states of the two types of text, model-generated text and human-written text, should form distinguishable clusters. Then, by observing the distribution of these clusters, the classification threshold can be determined, and the classification threshold is used to distinguish the two types of text, model-generated text and human-written text.
[0131] Figure 4 A schematic diagram of a method for determining a classification threshold value provided in an embodiment of the present application is shown. Figure 4 As shown, the above step S204 specifically includes the following steps:
[0132] S401. Project the neural activation of each text unit of the current text onto the detection vector of each hidden layer according to the difference in neural activation corresponding to each hidden layer, and obtain the projection score of each text unit in the current text, wherein the current text is a model-generated text or a human-written text in any text pair.
[0133] Optionally, the detection vector is also the main feature vector of the model-generated text. The detection vector can be randomly generated or based on a specific strategy, such as a task-related feature vector. The role of the detection vector is to project the neural activation data into a specific space in order to analyze the representation of the text on different hidden layers. On this basis, for each text unit in the current text, the neural activation data of each text unit in each hidden layer is projected onto the corresponding detection vector, which can be achieved by calculating the dot product of the activation data and the detection vector. The result of the projection is a scalar value, which is the projection score.
[0134] For example, the projection score of the j-th text unit in the current text can be calculated by the following formula (6):
[0135]
[0136] Among them, RepreScore(t j ) represents the projection score of the jth text unit in the current text, t j represents the jth text unit in the current text, L represents the number of hidden layers, h l (t j ) represents the neural activation of the jth text unit in the lth hidden layer, P l represents the difference in neural activations corresponding to the lth hidden layer.
[0137] S402: Taking the average of the projection scores of all text units in the current text as the projection score corresponding to the current text.
[0138] Exemplarily, the projection score corresponding to the current text is specifically shown in the following expression (7):
[0139]
[0140] Among them, RepreScore(T) represents the projection score corresponding to the current text, RepreScore(t j) represents the projection score of the j-th text unit in the current text, and n represents the number of text units.
[0141] Exemplarily, based on the above expression (7), the average of the projection scores of all text units in the current text is taken as the projection score corresponding to the current text. The average provides an overall measure that reflects the overall representation strength of the current text relative to the detection vector on a specific hidden layer.
[0142] S403: Determine a classification threshold according to the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts.
[0143] For example, according to the training set The projection scores corresponding to all model-generated texts in all text pairs in and the projection scores corresponding to all human-written texts in are used to determine the optimal threshold ∈ as the classification threshold to balance the true positive rate and the false positive rate. Specifically, the classification threshold can be determined based on the projection score by observation, statistical method or cross-validation method.
[0144] Exemplarily, the observation method refers to plotting the projection scores of the model-generated text and the human-written text on a graph respectively, such as using a scatter plot or a histogram to observe whether there is a clear separation between the projection scores of the two types of text. If the projection scores of the two types of text form two obvious clusters on the graph, and there is a clear interval between the clusters, then a threshold between the two clusters can be selected as the classification threshold. This threshold should be able to maximize the separation of the two types of text while minimizing the probability of misclassification.
[0145] Exemplarily, the statistical method refers to calculating statistics, specifically calculating the model to generate the mean, median, standard deviation and other statistics of the projection scores of text and human writing text, and determining a reasonable threshold value based on these statistics, such as selecting the midpoint of the mean of the projection scores of the two types of text as the threshold, or determining a range based on the standard deviation and selecting a threshold within this range. It should be noted that when using statistical methods to determine the threshold, it is necessary to ensure that the selected statistics can accurately reflect the distribution of the projection scores of the two types of text. If the distribution is asymmetric or there are outliers, more complex statistical methods may need to be used, such as quantiles, box plots, etc. to assist in determining the classification threshold.
[0146] Exemplarily, the cross-validation method refers to taking the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts as a data set, and dividing the data set into a training set, a validation set, and a test set. In cross-validation, the training set is usually used to train the model, the validation set is used to determine the classification threshold, and the test set is used to evaluate the performance of the model. On the validation set, different thresholds are used to classify the model-generated texts and human-written texts, and performance indicators such as classification accuracy and recall are calculated. Based on the results of the performance indicators, a threshold that can maximize the overall performance is selected as the optimal threshold ∈, and the optimal threshold ∈ is used as the classification threshold.
[0147] Based on this, the projection score of the current text is calculated according to the neural activation differences and detection vectors corresponding to each hidden layer, and the classification threshold is determined according to the projection score, so as to analyze the text representation and distinguish different types of text according to the classification threshold.
[0148] Figure 5 FIG. 1 is a flow chart of a method for determining a projection score of a text to be detected provided in an embodiment of the present application. Figure 5 As shown, the above step S104 determines the projection score of the text to be detected according to the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activation of each hidden layer of the proxy model, and specifically includes the following steps:
[0149] S501. According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit in the text to be detected are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the text to be detected.
[0150] Exemplarily, in the application stage, for each text unit of the text to be detected, the neural activation data of each text unit in each hidden layer is projected onto the corresponding detection vector, which can be achieved by calculating the dot product of the activation data and the detection vector. The result of the projection is a scalar value, which is the projection score. Similarly, the projection score of each text unit in the text to be detected can still be determined by the calculation method shown in the above formula (6).
[0151] S502: taking the average value of the projection scores of all text units in the text to be detected as the projection score corresponding to the text to be detected.
[0152] Exemplarily, the average of the projection scores of all text units in the text to be detected is used as the projection score corresponding to the text to be detected, and the average provides an overall metric that reflects the overall representation strength of the text to be detected relative to the detection vector on a specific hidden layer. Similarly, the projection score corresponding to the text to be detected can still be determined using the calculation method shown in the above formula (7), that is, the average of the projection scores of all text units in the text to be detected is used as the projection score corresponding to the text to be detected.
[0153] Based on this, the text detection method provided in this application utilizes the neural activation patterns within the proxy model to capture text features, and makes judgments by comparing these features with the differences between known human-written texts and model-generated texts. It can achieve high-precision text detection generated by large language models under a small number of sample conditions, and has good generalization capabilities.
[0154] In summary, the text detection method provided by the present application uses the difference in neuron activation of a large language model when processing human-written text and model-generated text as the detection basis for text detection. It can be generalized to detect texts generated by different large language models using only a small amount of training data from a single source, and has excellent generalization capabilities. In addition, from the perspective of data requirements, traditional fine-tuning detection methods require a large amount of annotated data, while the present application combines the advantages of statistical and fine-tuning methods, and only requires a small amount of samples to complete the text detection task. Moreover, the present application has strong resistance to texts of different lengths to be detected, text rewriting attacks, and perturbation attacks, and can maintain stable detection effects in various practical application scenarios.
[0155] Based on the same inventive concept, a text detection device corresponding to the text detection method is also provided in the embodiment of the present application. Since the principle of solving the problem by the text detection device in the embodiment of the present application is similar to the above-mentioned text detection method in the embodiment of the present application, the implementation of the text detection device can refer to the implementation of the text detection method, and the repeated parts will not be repeated.
[0156] Reference Figure 6 , which is a schematic diagram of the structure of a text detection device provided in an embodiment of the present application, the text detection device 600 includes: a first acquisition module 601, a capture module 602, a second acquisition module 603, a determination module 604, and a comparison module 605, wherein:
[0157] The first acquisition module 601 is used to acquire the text to be detected;
[0158] Capturing module 602, used for inputting the text to be detected into the proxy model, and capturing the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model;
[0159] A second acquisition module 603 is used to acquire the neural activation difference of each hidden layer of the proxy model, where the neural activation difference is used to characterize the difference in neural activation caused by the model-generated text and the human-written text on the hidden layer, and the neural activation difference is pre-determined based on a training set including the model-generated text and the human-written text;
[0160] A determination module 604, configured to determine a projection score of the text to be detected based on the neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activations of each hidden layer of the proxy model;
[0161] The comparison module 605 is used to compare the projection score of the text to be detected with the classification threshold of the proxy model, and determine whether the text to be detected belongs to the model-generated text based on the comparison result. The classification threshold is pre-determined based on a training set containing model-generated text and human-written text.
[0162] Based on this, according to the text detection device of the embodiment of the present application, the neural activation difference and the classification threshold are both determined in advance based on the training set containing model-generated text and human-written text. The neural activation difference reflects the representation difference of the proxy model when processing different types of texts, which is the key feature to distinguish the two types of texts. On this basis, the proxy model is used to capture the neural activation of the text to be detected in different hidden layers, and the projection score of the text to be detected is determined in combination with the neural activation difference of each hidden layer of the proxy model. The projection score reflects the similarity between the text to be detected and the model-generated text and the human-written text in the neural activation pattern, and then the projection score of the text to be detected is compared with the classification threshold to determine whether the text to be detected belongs to the model-generated text. Therefore, the present application uses the neural activation difference of the large language model when processing human-written text and model-generated text as the detection basis. By capturing the representation difference of the large language model when processing human-written text and model-generated text, high-precision model-generated text detection can be achieved even under a small number of sample conditions, and it is effectively distinguished whether the text to be detected belongs to the model-generated text. In addition, since the present application relies on the deep-level feature of neural activation patterns rather than the superficial statistical characteristics of language, and with the help of the powerful representation ability of the proxy model, it not only improves the generalization ability of text detection, but also ensures the effectiveness of text detection, overcoming the limitations of traditional detection methods.
[0163] In a possible implementation manner, the determination module 604 is further configured to:
[0164] Obtain multiple text pairs in a training set, where the text pairs include a model-generated text and a human-written text, and the model-generated text and the human-written text each include multiple text units;
[0165] Inputting the model-generated text and the human-written text in each text pair into the proxy model respectively, capturing the neural activation of each text unit in the model-generated text in each hidden layer of the proxy model, and capturing the neural activation of each text unit in the human-written text in each hidden layer of the proxy model;
[0166] Determine the difference in neural activations corresponding to each hidden layer based on the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each hidden layer in each text pair;
[0167] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each text pair are projected, and the classification threshold is determined according to the projection results.
[0168] In a possible implementation manner, the determination module 604 is further configured to:
[0169] Determine the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each hidden layer in each text pair;
[0170] The initial activation differences corresponding to each hidden layer are processed by principal component analysis to obtain the neural activation differences corresponding to each hidden layer.
[0171] In a possible implementation manner, the determination module 604 is further configured to:
[0172] Determine the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each hidden layer in each text pair;
[0173] The initial activation differences corresponding to each hidden layer are processed by principal component analysis to obtain the neural activation differences corresponding to each hidden layer.
[0174] In a possible implementation manner, the determination module 604 is further configured to:
[0175] determining the initial activation difference of the first hidden layer of each text pair based on the neural activation of each text unit of the model generated text and the neural activation of each text unit of the human written text in the first hidden layer;
[0176] The set of neural activation differences of all text pairs in the first hidden layer is taken as the initial activation difference corresponding to the first hidden layer, where the first hidden layer is any hidden layer in the proxy model.
[0177] In a possible implementation manner, the determination module 604 is further configured to:
[0178] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, where the current text is the model-generated text or human-written text in any text pair;
[0179] The average of the projection scores of all text units in the current text is taken as the projection score corresponding to the current text;
[0180] The classification threshold is determined based on the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts.
[0181] In a possible implementation manner, the determination module 604 is further configured to:
[0182] By formula Calculate the projection score of the jth text unit in the current text, where RepreScore(t j ) represents the projection score of the jth text unit in the current text, t j represents the jth text unit in the current text, L represents the number of hidden layers, h l (t j ) represents the neural activation of the jth text unit in the lth hidden layer, P l represents the difference in neural activations corresponding to the lth hidden layer.
[0183] In a possible implementation manner, the determination module 604 is further configured to:
[0184] According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit in the text to be detected are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the text to be detected;
[0185] The average of the projection scores of all text units in the text to be detected is taken as the projection score corresponding to the text to be detected.
[0186] In a possible implementation manner, the comparison module 605 is specifically used to:
[0187] If the projection score of the text to be detected is greater than the classification threshold, it is determined that the text to be detected belongs to the model-generated text; otherwise, it is determined that the text to be detected does not belong to the model-generated text.
[0188] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0189] The present application embodiment also provides an electronic device 700, such as Figure 7 As shown, it is a schematic diagram of the structure of an electronic device 700 provided in an embodiment of the present application, including: a processor 701, a memory 702, and optionally, a bus 703. The memory 702 stores machine-readable instructions executable by the processor 701. When the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703. When the machine-readable instructions are executed by the processor 701, the method steps in the text detection method described in any one of the above items are executed.
[0190] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps in any of the above text detection methods are executed.
[0191] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0192] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the technical solution that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.
[0193] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A text detection method, characterized in that: include: Get the text to be detected; Inputting the text to be detected into the proxy model, and capturing the neural activation of each text unit in the text to be detected in each hidden layer of the proxy model; Obtaining a neural activation difference of each hidden layer of the proxy model, wherein the neural activation difference is used to characterize a difference in neural activation caused by a model-generated text and a human-written text on the hidden layer, wherein the neural activation difference is pre-determined based on a training set including the model-generated text and the human-written text; Determining a projection score of the text to be detected according to neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and differences in neural activations of each hidden layer of the proxy model; The projection score of the text to be detected is compared with the classification threshold of the proxy model, and whether the text to be detected belongs to the model-generated text is determined according to the comparison result. The classification threshold is pre-determined based on a training set containing model-generated text and human-written text.
2. The method according to claim 1, characterized in that The process of determining the neural activations of each hidden layer and the classification threshold includes: Acquire multiple text pairs in a training set, wherein the text pairs include a model-generated text and a human-written text, and the model-generated text and the human-written text each include multiple text units; Inputting the model-generated text and the human-written text in each of the text pairs into the proxy model respectively, capturing the neural activation of each text unit in the model-generated text in each hidden layer of the proxy model, and capturing the neural activation of each text unit in the human-written text in each hidden layer of the proxy model; Determine the difference in neural activations corresponding to each hidden layer based on the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each hidden layer in each text pair; According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the model-generated text and the neural activations of each text unit of the human-written text in each text pair are projected, and the classification threshold is determined according to the projection results.
3. The method according to claim 2, characterized in that Determining the difference in neural activations corresponding to each hidden layer according to the neural activations of each text unit of the model-generated text in each text pair and the neural activations of each text unit of the human-written text in each hidden layer includes: Determine the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each hidden layer in each text pair; The initial activation differences corresponding to each hidden layer are processed by principal component analysis to obtain the neural activation differences corresponding to each hidden layer.
4. The method according to claim 3, characterized in that Determining the initial activation difference corresponding to each hidden layer according to the neural activation of each text unit of the model-generated text in each text pair and the neural activation of each text unit of the human-written text in each hidden layer includes: Determine the initial activation difference of each text pair at the first hidden layer based on the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in the first hidden layer; The set of neural activation differences of all text pairs in the first hidden layer is used as the initial activation difference corresponding to the first hidden layer, wherein the first hidden layer is any hidden layer in the proxy model.
5. The method according to claim 2, characterized in that: The method of projecting the neural activation of each text unit of the model-generated text and the neural activation of each text unit of the human-written text in each text pair according to the difference in neural activations corresponding to each hidden layer, and determining the classification threshold according to the projection result, includes: According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, wherein the current text is a model-generated text or a human-written text in any text pair; Taking the average of the projection scores of all text units in the current text as the projection score corresponding to the current text; The classification threshold is determined according to the projection scores corresponding to all model-generated texts in all text pairs and the projection scores corresponding to all human-written texts.
6. The method according to claim 5, characterized in that According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit of the current text are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the current text, including: By formula Calculate the projection score of the jth text unit in the current text, where RepreScore(t j ) represents the projection score of the jth text unit in the current text, t j represents the jth text unit in the current text, L represents the number of hidden layers, h l (t j ) represents the neural activation of the jth text unit in the lth hidden layer, P l represents the difference in neural activations corresponding to the lth hidden layer.
7. The method according to claim 1, characterized in that The step of determining the projection score of the text to be detected according to the neural activations of each text unit in the text to be detected in each hidden layer of the proxy model and the difference in neural activations of each hidden layer of the proxy model comprises: According to the difference in neural activations corresponding to each hidden layer, the neural activations of each text unit in the text to be detected are projected onto the detection vectors of each hidden layer to obtain the projection scores of each text unit in the text to be detected; The average value of the projection scores of all text units in the text to be detected is taken as the projection score corresponding to the text to be detected.
8. The method according to claim 1, characterized in that: The step of determining whether the text to be detected belongs to model-generated text according to the comparison result includes: If the projection score of the text to be detected is greater than the classification threshold, it is determined that the text to be detected belongs to the model-generated text; otherwise, it is determined that the text to be detected does not belong to the model-generated text.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the text detection method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the text detection method according to any one of claims 1 to 8 are executed.