A human-machine hybrid text detection method and system based on double-granularity feature and hierarchical contrastive representation learning
By employing a dual-granularity feature and hierarchical contrastive representation learning method, the problems of continuity of AI intervention and adaptability of mixed modes in AI-generated text detection are solved, achieving fine differentiation and efficient detection of text.
Patent Information
- Application Number
- CN202611506540.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-27
- Publication Date
- 2026-11-27
AI Technical Summary
Existing AI-generated text detection technologies struggle to effectively characterize the continuity of AI intervention and various mixed modes, and their adaptability is insufficient in scenarios involving multiple alternations and diffuse modifications, making it impossible to precisely distinguish between lightly mixed and heavily mixed text.
A human-machine hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning is adopted. By extracting document-level global features and fragment-level local features, an operation type hierarchical affinity tree is constructed. End-to-end training is performed by combining a hierarchical contrastive encoder and dual output heads to achieve continuous regression and classification of the degree of AI intervention.
It can more precisely distinguish texts with different levels of intervention, has stronger generalization ability, covers multiple mixed modes, and can output fragment-level positioning information, thus improving the interpretability and practicality of detection.
Smart Images

Figure CN123179296A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and artificial intelligence-generated content technology, specifically to a human-computer hybrid text detection method and system based on dual-granularity feature and hierarchical contrastive representation learning. Background Technology
[0002] With the rapid improvement of large language model generation capabilities, artificial intelligence has been widely used to assist or independently complete the creation of various texts such as news articles, academic papers, educational essays, and social media content. At the same time, the abuse of AI-generated content has also raised issues such as academic integrity, the spread of false information, and content tracing. As a result, AI-generated text detection technology has received widespread attention.
[0003] Existing AI-generated text detection technologies can be broadly categorized into two technical approaches: the first is document-level or sentence-level discrete classification methods, which model the detection task as a binary or tri-class classification problem and train the classification model using features such as perplexity and style embedding; the second is boundary detection methods, which model the detection task as a sequence labeling problem that locates the switching point between human-written content and AI-generated content in a given human-machine hybrid text. In hybrid texts generated through human-machine collaboration, the degree of AI intervention in the text exhibits continuous variation characteristics and may present diffuse, multiple alternating, or covert modifications, without necessarily having a single, clear switching boundary.
[0004] Discrete classification methods still have room for further optimization in fine-grained distinction between adjacent categories. Boundary detection methods can be further enhanced to adapt to scenarios with multiple alternations and diffuse modifications. Single-granularity modeling has the potential to improve in terms of balancing global style consistency discrimination and sensitivity to local subtle modifications. Category systems or switching point annotation systems also have good extension research value for novel hybrid operation methods or newly generated models not covered by training data. Therefore, how to simultaneously characterize the continuity of AI intervention, cover multiple hybrid modes, integrate multi-granularity features, and have strong generalization ability has become a direction worthy of attention in the field of human-machine hybrid text detection. Summary of the Invention
[0005] The purpose of this invention is to address the problems existing in the background technology by proposing a human-computer hybrid text detection method and system based on dual-granularity feature and hierarchical contrastive representation learning.
[0006] The technical solution of this invention: a human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning, comprising the following specific implementation steps: S1. Obtain the text to be detected; S2. Extract document-level global features of the text to be detected; S3. Segment the text to be detected according to the preset sliding window, and extract fragment-level local features, including local perplexity, local perplexity gradient of adjacent windows and style consistency score; S4. Construct an operation type hierarchical affinity tree, with predefined multiple mixed operation types as leaf nodes. The tree path distance between each leaf node represents the relative proximity of the AI intervention degree of the corresponding operation type. S5. Input the document-level global features and the fragment-level local features into the hierarchical contrast encoder to jointly encode the fused representation. During the training phase, the tree structure contrast loss is used to constrain the relative distance of the fused representation in the representation space to maintain the order relationship with the path distance of the hierarchical affinity tree. S6. Input the fusion representation into the classification head and the regression head respectively. The classification head outputs the probability distribution of three categories: human writing, human-machine hybrid, and AI generation. The regression head outputs the score of the proportion of continuous AI intervention. S7. The hierarchical contrast encoder, classifier head and regression head are trained end-to-end using a joint loss function. The joint loss function is a weighted sum of classification cross-entropy loss, regression loss and tree structure contrast loss. S8. Based on the category probability distribution output by the comprehensive classification head, the continuous AI intervention ratio score output by the regression head, and the mutation location in the fragment-level local features, determine the final category judgment result, locate the suspected AI intervention fragment interval, and output the detection result.
[0007] Preferably, the tree structure contrast loss is calculated in the following way: For any triplet in the training batch, if the tree path distance between the anchor sample and the first comparison sample in the operation type hierarchy affinity tree is less than the tree path distance between the anchor sample and the second comparison sample in the operation type hierarchy affinity tree, then the distance between the anchor sample and the first comparison sample in the representation space is constrained to be less than the distance between the anchor sample and the second comparison sample in the representation space, and a preset interval is applied. The loss function is implemented in the form of hinge loss, that is, a penalty is imposed on sample pairs that do not satisfy the above order relation constraints, and no penalty is imposed on sample pairs that satisfy the above order relation constraints. The operation type hierarchical affinity tree is only used as a supervisory basis for calculating the tree structure contrast loss during the training phase, and is used to determine the relative distance order relation that should be satisfied between the anchor sample and each comparison sample in the training sample triplet. The hierarchical affinity tree itself does not participate in forward inference calculation, nor is it used as input to the network to be trained.
[0008] Preferably, the regression head uses at least one of ordinal regression loss or mean squared error loss as the training target; The classification head and regression head share the fusion representation of the output of the hierarchical comparison encoder. They jointly optimize during the training phase and jointly make decisions during the inference phase. Their output results are mutually verified. When the category output by the classification head is inconsistent with the interval corresponding to the continuous AI intervention ratio score output by the regression head, manual review is triggered or the results are fused using preset rules.
[0009] Preferably, a set of training text samples labeled according to mixed operation types is obtained; and the initial representation of each sample is extracted respectively. Calculate class centers for samples of the same operation type; Based on the distances between various centers, a hierarchical clustering algorithm is used to generate a hierarchical affinity tree structure. The class centers corresponding to those written by pure humans and those generated by pure AI are used as the two endpoints of the hierarchical affinity tree.
[0010] Preferably, the window size of the sliding window is set to 3 to 5 lines, and the sliding step size is set to 1 line; The local perplexity gradient is calculated by the difference in local perplexity between adjacent windows; Style consistency score is calculated using the cosine similarity of style embedding vectors of adjacent windows; The window size and sliding step of the sliding window are configured according to the domain and length of the text to be detected.
[0011] Preferably, the weight coefficients of the classification cross-entropy loss, regression loss, and tree structure comparison loss in the joint loss function are adjustable hyperparameters. These weight coefficients are adaptively adjusted during training based on the decrease rate of each loss component to avoid any one loss component dominating the training process.
[0012] Preferably, the training data used to train the hierarchical contrast encoder, classification head, and regression head is generated by simulating the execution of the predefined multiple mixed operation types on text written by pure humans. Each mixed operation calls a different generative language model and is executed with a preset prompt template. During the simulation, the operation type label and the true value of the AI intervention ratio corresponding to each mixed operation are recorded to construct a training dataset that has both discrete category labels and continuous AI intervention ratio labels.
[0013] Preferably, document-level global features include at least two of the following: the overall perplexity mean of the text, the stylistic embedding vector obtained based on the pre-trained style encoder, the lexical diversity index, and the syntactic complexity index. The hierarchical contrast encoder includes an encoding submodule that independently encodes document-level global features and fragment-level local features, and a cross-granularity fusion module that fuses the outputs of the two encoding submodules based on a cross-attention mechanism. The cross-granularity fusion module calculates the fused representation using the document-level representation as the query vector and the fragment-level feature sequence as the key vector.
[0014] Preferably, the mixed operation type includes at least two of the following: pure human writing, light polishing, content continuation, language rewriting, fragment replacement, AI generation followed by humanized disguise, and pure AI generation; in step S8, the continuous AI intervention ratio score is mapped to a reference category according to a preset threshold range. A score below 0.15 is judged as a human writing tendency, a score between 0.15 and 0.85 is judged as a human-machine mixed tendency, and a score above 0.85 is judged as an AI generation tendency. The reference category is compared with the category output by the classification head. If the two are consistent, the category is output as the final judgment result. If the two are inconsistent, the final category is determined by a preset rule based on the confidence level of both. Simultaneously, mutation point detection is performed on the local perplexity gradient and style consistency score in the fragment-level local feature sequence. The window position where a significant mutation occurs is marked as the boundary of the suspected AI intervention fragment. The start and end positions of the suspected AI intervention fragment are determined by combining the mutation intensity of continuous windows. The output includes the detection results including text category label, continuous AI intervention ratio score, and the location interval of one or more suspected AI intervention fragments.
[0015] The technical solution of this invention: A human-computer hybrid text detection system based on dual-granularity feature and hierarchical contrastive representation learning, which is used to execute the aforementioned human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning, comprising: The text acquisition module is used to acquire the text to be detected. The document-level feature extraction module is used to extract the document-level global features of the text to be detected; The fragment-level feature extraction module is used to extract fragment-level local features of the text to be detected according to a preset sliding window. The fragment-level local features include local perplexity, local perplexity gradient of adjacent windows, and style consistency score of adjacent windows. The hierarchical affinity tree construction module is used to construct hierarchical affinity trees for operation types. The hierarchical affinity tree uses multiple predefined mixed operation types as leaf nodes, and the tree path distance between each leaf node represents the relative proximity of the AI intervention degree of the corresponding operation type. The hierarchical contrastive encoding module is used to jointly encode the document-level global features and the fragment-level local features into a fused representation. During the training phase, a tree-structured contrastive loss is used to constrain the relative distance of the fused representation in the representation space to maintain the order relationship with the corresponding tree path distance in the hierarchical affinity tree. The classification header module is used to output the three-class probability distribution corresponding to the fused representation; The regression head module is used to output the continuous AI intervention ratio score corresponding to the fusion representation; The training module is used to perform end-to-end training on the hierarchical contrastive encoding module, the classification head module, and the regression head module using a joint loss function, wherein the joint loss function is a weighted sum of the classification cross-entropy loss, the regression loss, and the tree structure contrastive loss. The result fusion and output module is used to integrate the three-class probability distribution, the continuous AI intervention ratio score, and the mutation position in the fragment-level local features to determine the final detection result and locate the suspected AI intervention fragment interval.
[0016] Compared with the prior art, the above-mentioned technical solution of the present invention has the following beneficial technical effects: This invention designs a human-machine hybrid text detection method and system based on dual-granularity feature and hierarchical contrastive representation learning. By introducing continuous AI intervention ratio regression and combining it with a classification head for joint training, it overcomes the problem of lost information in adjacent category discrimination in existing discrete classification methods, enabling more refined differentiation of texts with different levels of intervention, such as light and heavy mixing. Based on hierarchical affinity trees of operation types, hierarchical contrastive representation learning ensures that the text representations corresponding to different mixed operation types present an ordered relative distance relationship in the representation space according to the degree of AI intervention. Even if new mixed operation modes not covered by training data appear during the testing phase, reasonable continuous judgment can be made based on the relative distance relationship in the representation space, thus possessing stronger generalization ability. Document-level global features and fragment-level local features are fused for joint modeling. The fragment-level local features capture anomalous signals generated by subtle local modifications through local perplexity gradients and style consistency scores, compensating for the insufficient detection capability of single-granularity features for covert mixed operations. This invention does not rely on a single switching point assumption, can cover diffuse and multiple alternating mixed modes, and can output fragment-level positioning information, possessing higher interpretability and practicality. Attached Figure Description
[0017] Figure 1 This is a flowchart of a human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning proposed in this invention; Figure 2 This is a schematic diagram of the hierarchical comparison encoder and dual output head structure proposed in this invention. Detailed Implementation
[0018] Example 1: This invention proposes a human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning, such as... Figure 1As shown, the overall process of the method described in this invention includes: acquiring the text to be detected; extracting document-level global features; extracting fragment-level local features using a sliding window; constructing an operation type hierarchical affinity tree; hierarchical contrastive encoding and joint encoding of dual-granularity features; outputting three-classification probabilities from the classification head; outputting continuous scores of AI intervention ratio from the regression head; fusing the classification results and continuous scores and locating AI-intervention fragments; and outputting the detection results. The method of the present invention includes steps S1 to S8, as follows: S1. Obtain the text to be detected: During the training phase, obtaining the text to be detected specifically means obtaining the sample text in the training dataset; The sample text is derived from a collection of human-written text samples and has undergone simulation execution of the above-mentioned multiple mixed operation types, thus simultaneously possessing discrete labels for operation types and continuous labels for the proportion of AI intervention. During the inference phase, step S1 is used to obtain the text to be detected that actually needs to be detected; Therefore, step S1 provides input text for subsequent document-level global feature extraction and fragment-level local feature extraction; S2. Extract document-level global features from the text to be detected: The document-level global features include, but are not limited to, one or more combinations of the following: the overall perplexity mean of the text, the stylistic embedding vector obtained based on the pre-trained style encoder, the lexical diversity index, and the syntactic complexity index. In one specific implementation, for each sample in the training dataset, document-level global features are extracted according to step S2: the pre-trained language model is called to calculate the average overall perplexity of the text; the pre-trained style encoder is called to extract the stylistic embedding vector; lexical diversity indicators, such as the class symbol / form symbol ratio, are statistically analyzed; syntactic complexity indicators, such as average sentence length and clause nesting depth, are statistically analyzed; the document-level global features include at least two of the above indicators; the document-level global features are used to characterize the statistical and stylistic characteristics of the text to be detected at the overall level, providing document-level input for subsequent cross-granularity fusion with fragment-level local features; S3. The text to be detected is segmented according to a preset sliding window to obtain several segment windows. For each segment window, segment-level local features are extracted: the segment-level local features include the local perplexity of the window, the local perplexity gradient between adjacent windows, and the style consistency score between adjacent windows calculated based on style embedding vectors; the window size and sliding step of the sliding window can be configured according to the domain and length of the text to be detected. In one specific implementation, each sample is segmented by a sliding window according to step S3, with a window size of 3 to 5 sentences and a sliding step of 1 sentence; the local perplexity is calculated for each window, and the local perplexity gradient of adjacent windows and the style consistency score based on the cosine similarity of style embedding vectors are calculated accordingly to obtain a fragment-level local feature sequence. Specifically, the local perplexity gradient is calculated by the difference in local perplexity between adjacent windows; the style consistency score is calculated by the cosine similarity of the style embedding vectors of adjacent windows. The fragment-level local features are used to characterize the changes in perplexity and style consistency of the text under test at the local fragment level, thereby providing a basis for subsequent mutation location detection and suspected AI-intervention fragment localization; S4. Constructing an operation type hierarchical affinity tree: The operation type hierarchical affinity tree uses a predefined set of mixed operation types as leaf nodes. The mixed operation types include at least two of the following: purely human writing, light polishing, content continuation, language rewriting, fragment replacement, AI generation followed by human-like disguise, and purely AI generation. The tree path distance between each leaf node in the hierarchical affinity tree is used to characterize the relative proximity of the corresponding operation type to the degree of AI intervention in purely human-written text and purely AI-generated text. The hierarchical affinity tree can be constructed based on a preset prior statistical distance, or it can be automatically constructed based on a small-scale labeled data through a hierarchical clustering algorithm. In one specific implementation, according to step S4, the class center is calculated based on the initial representation of each operation type sample in the training dataset, and a hierarchical clustering algorithm is used to construct an operation type hierarchical affinity tree, wherein the class center written by pure humans and the class center generated by pure AI serve as the two endpoints of the hierarchical affinity tree. Specifically, the automatic construction process of the operation type hierarchical affinity tree includes: obtaining a set of training text samples labeled according to the mixed operation type; extracting the initial representation of each sample; calculating class centers for the sample representations of the same operation type; generating a hierarchical affinity tree structure based on the distance between class centers using a hierarchical clustering algorithm; using the class centers corresponding to purely human writing and the class centers corresponding to purely AI generation as the two endpoints of the hierarchical affinity tree; the operation type hierarchical affinity tree is used to provide supervision for the tree structure contrast loss during the training phase; S5. The document-level global features and the fragment-level local features are input into a hierarchical contrast encoder for joint encoding to obtain a fused representation. The hierarchical contrast encoder includes an encoding submodule that independently encodes the document-level global features and the fragment-level local features, and a cross-granularity fusion module that fuses the outputs of the two based on a cross-attention mechanism. During the training phase, the hierarchical contrast encoder uses a tree-structured contrast loss for constraint, so that the relative distance of the fused representation in the representation space maintains the same order relationship as the tree path distance of the corresponding leaf node in the hierarchical affinity tree of the operation type. In one specific implementation, regarding the encoder structure, the hierarchical contrastive encoder can employ a pre-trained language model based on the Transformer structure, such as, but not limited to, BERT, RoBERTa, or DeBERTa, as the backbone network for the encoding sub-modules of document-level features and fragment-level features, respectively. A cross-granularity fusion module is set above the outputs of the two sub-modules. This fusion module uses a cross-attention mechanism, using the document-level representation as the query vector and the fragment-level feature sequence as the key-value vector, to calculate the fused representation. The fused representation simultaneously integrates document-level global features and fragment-level local features, thereby balancing the ability to discriminate global style consistency with the sensitivity to local subtle modifications. S6. Input the fusion representation into the classification head and the regression head respectively: The classification head outputs the probability distribution of the text to be detected belonging to three categories: human-written, human-machine hybrid, and AI-generated; The regression head outputs the continuous AI intervention ratio score of the text to be detected, and the value range of the continuous AI intervention ratio score is between 0 and 1; The classification head and the regression head share the fusion representation output by the hierarchical contrast encoder, and the two jointly optimize during the training phase and jointly make decisions during the inference phase. The output results of the two are mutually verified: When the category output by the classification head is inconsistent with the interval corresponding to the continuous AI intervention ratio score output by the regression head, a manual review mark is triggered or the result fusion is performed using preset rules; In one specific implementation, the regression head uses at least one of ordinal regression loss or mean squared error loss as the training objective; the classification head and the regression head make predictions based on the same fusion representation, wherein the classification head is used to output the three-class probability distribution, and the regression head is used to output the continuous AI intervention ratio score, thereby overcoming the problem of loss of adjacent class discrimination information in existing discrete three-class classification methods, and enabling more refined differentiation of texts with different levels of intervention, such as light mixing and heavy mixing. S7. Perform end-to-end training on the overall network including the hierarchical contrast encoder, the classification head, and the regression head using a joint loss function: The joint loss function is a weighted sum of the classification cross-entropy loss, the regression loss, and the tree structure comparison loss, with the weight coefficients of the three being adjustable hyperparameters. In one specific implementation, during training, the joint loss function takes the following form: ; In the formula, The cross-entropy loss is the difference between the three-class probability distribution output by the classification head and the true class label. The mean squared error loss or ordinal regression loss between the continuous AI intervention proportion score output by the regression head and the true value label; Tree structure contrast loss; , and These are the weight coefficients for each loss term; the weight coefficients of the joint loss function can be adaptively adjusted during training based on the decrease rate of each loss component to avoid any one loss component dominating the training process. Furthermore, the tree structure contrast loss takes the following form: For any sample triple (a, p, n) in the training batch, if the tree path distance between the anchor sample a and the first comparison sample p in the operation type hierarchy affinity tree is less than the tree path distance between the anchor sample a and the second comparison sample n, then the distance between the anchor sample a and the first comparison sample p in the representation space is constrained to be less than the distance between the anchor sample a and the second comparison sample n in the representation space, and a preset interval is applied; this loss function is implemented in the form of hinge loss, that is, a penalty is imposed on sample pairs that do not satisfy the above order relation constraint, and no penalty is imposed on sample pairs that satisfy the constraint; In one specific implementation, it takes the following form: ; In the formula, This represents a distance metric in the representation space, such as Euclidean distance; margin is a preset interval hyperparameter; N is the total number of triples formed within the batch; It should be noted that the hierarchical affinity tree of the operation type is only used as a supervisory basis for calculating the tree structure contrastive loss during the training phase, and is used to determine the relative distance order relationship that should be satisfied between the anchor sample and each comparison sample in the training sample triplet. The hierarchical affinity tree itself does not participate in the forward inference calculation, nor is it used as the input of the network to be trained. After a large number of training iterations, the network parameters of the hierarchical contrastive encoder will be continuously adjusted so that the output representation spontaneously presents an order relationship structure consistent with the path distance of the hierarchical affinity tree in the representation space. That is, the prior knowledge represented by the hierarchical affinity tree has been internalized into the network parameters of the encoder. Therefore, in the subsequent inference phase, regardless of whether the text to be detected belongs to the mixed operation type defined in the training phase, the hierarchical contrastive encoder does not need to access or query the hierarchical affinity tree again. It can directly output a representation with order relationship consistency based on the already trained network parameters for the classification head and regression head to make a judgment. For new mixed operation types not seen in the training phase, the representation of its corresponding text will naturally fall among the known operation types with similar semantics due to the continuous order relationship structure of the representation space, thereby improving its ability to generalize the judgment of new mixed patterns. Step S8: Comprehensive Judgment and Output of Detection Results: During the inference phase, the final category judgment result and confidence score of the text to be detected are determined by comprehensively considering the category probability distribution output by the classification head, the continuous AI intervention ratio score output by the regression head, and the abrupt change position of the local perplexity gradient and style consistency score in the fragment-level local features. The fragment intervals in the text to be detected that may contain AI-generated or AI-edited content are located, and the detection results containing category labels, continuous confidence scores, and fragment location information are output. In one specific implementation, the continuous AI intervention ratio score is mapped to a reference category according to a preset threshold range and compared with the category output by the classification head. If they match, the category is output as the final judgment result. If they do not match, the final category is determined by combining the confidence levels of both and using preset rules. For example, the preset threshold range can be set to below 0.15 to determine human writing tendency, between 0.15 and 0.85 to determine human-machine hybrid tendency, and above 0.85 to determine AI generation tendency. If they do not match, the one with higher confidence can be taken, or it can be marked as awaiting manual review. Simultaneously, mutation point detection is performed on the local perplexity gradient and style consistency score in the fragment-level local feature sequence. For example, by setting a dynamic threshold or sliding statistics method, the window position where the gradient or style consistency score undergoes a significant mutation is marked as the boundary of the suspected AI intervention fragment. The start and end positions of the suspected AI intervention fragment are determined by combining the mutation intensity of continuous windows. The final output detection results include: text category label, continuous AI intervention ratio score, and the location range of one or more suspected AI intervention fragments.
[0019] Example 2: This invention proposes a human-machine hybrid text detection system based on dual-granularity feature and hierarchical contrastive representation learning, which is used to execute the human-machine hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning proposed in Example 1 above, specifically including: The text acquisition module is used to acquire the text to be detected. The document-level feature extraction module is used to perform step S2, extracting the document-level global features of the text to be detected; The fragment-level feature extraction module is used to perform step S3, extracting fragment-level local features of the text to be detected according to a preset sliding window; The hierarchical affinity tree construction module is used to execute step S4 and construct the hierarchical affinity tree of the operation type; The hierarchical contrast encoding module is used to execute step S5, which jointly encodes the document-level global features and the fragment-level local features into a fused representation; The classification head module is used to execute the classification head function in step S6 and output the three-class probability distribution corresponding to the fusion representation. The regression head module is used to execute the regression head function in step S6 and output the continuous AI intervention ratio score corresponding to the fusion representation. The training module is used to perform the joint loss training described in step S7; The result fusion and output module is used to execute step S8, which combines the three-class probability distribution and the continuous AI intervention ratio score to determine the final detection result and locate the suspected AI intervention segment interval. The connections and data flow between the modules are shown in the attached figure. Figure 2 As shown.
[0020] The present invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the aforementioned human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning.
[0021] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning.
[0022] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited thereto. Various changes can be made within the scope of knowledge possessed by those skilled in the art without departing from the spirit of the present invention.
Claims
1. A human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning, characterized in that, The specific implementation steps include the following: S1. Obtain the text to be detected; S2. Extract document-level global features of the text to be detected; S3. Segment the text to be detected according to the preset sliding window, and extract fragment-level local features, including local perplexity, local perplexity gradient of adjacent windows and style consistency score; S4. Construct an operation type hierarchical affinity tree, with predefined multiple mixed operation types as leaf nodes. The tree path distance between each leaf node represents the relative proximity of the AI intervention degree of the corresponding operation type. S5. Input the document-level global features and the fragment-level local features into the hierarchical contrast encoder to jointly encode the fused representation. During the training phase, the tree structure contrast loss is used to constrain the relative distance of the fused representation in the representation space to maintain the order relationship with the path distance of the hierarchical affinity tree. S6. Input the fusion representation into the classification head and the regression head respectively. The classification head outputs the probability distribution of three categories: human writing, human-machine hybrid, and AI generation. The regression head outputs the score of the proportion of continuous AI intervention. S7. The hierarchical contrast encoder, classifier head and regression head are trained end-to-end using a joint loss function. The joint loss function is a weighted sum of classification cross-entropy loss, regression loss and tree structure contrast loss. S8. Based on the category probability distribution output by the comprehensive classification head, the continuous AI intervention ratio score output by the regression head, and the mutation location in the fragment-level local features, determine the final category judgment result, locate the suspected AI intervention fragment interval, and output the detection result.
2. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 1, characterized in that, The tree structure contrast loss is calculated as follows: For any triplet in the training batch, if the tree path distance between the anchor sample and the first comparison sample in the operation type hierarchy affinity tree is less than the tree path distance between the anchor sample and the second comparison sample in the operation type hierarchy affinity tree, then the distance between the anchor sample and the first comparison sample in the representation space is constrained to be less than the distance between the anchor sample and the second comparison sample in the representation space, and a preset interval is applied. The loss function is implemented in the form of hinge loss, that is, a penalty is imposed on sample pairs that do not satisfy the above order relation constraints, and no penalty is imposed on sample pairs that satisfy the above order relation constraints. The operation type hierarchical affinity tree is only used as a supervisory basis for calculating the tree structure contrast loss during the training phase, and is used to determine the relative distance order relation that should be satisfied between the anchor sample and each comparison sample in the training sample triplet. The hierarchical affinity tree itself does not participate in forward inference calculation, nor is it used as input to the network to be trained.
3. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 2, characterized in that, The regression head uses at least one of ordinal regression loss or mean squared error loss as the training target; The classification head and regression head share the fusion representation of the output of the hierarchical comparison encoder. They jointly optimize during the training phase and jointly make decisions during the inference phase. Their output results are mutually verified. When the category output by the classification head is inconsistent with the interval corresponding to the continuous AI intervention ratio score output by the regression head, manual review is triggered or the results are fused using preset rules.
4. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 3, characterized in that, Obtain a set of training text samples labeled according to mixed operation types; extract the initial representation of each sample respectively; Calculate class centers for samples of the same operation type; Based on the distances between various centers, a hierarchical clustering algorithm is used to generate a hierarchical affinity tree structure. The class centers corresponding to those written by pure humans and those generated by pure AI are used as the two endpoints of the hierarchical affinity tree.
5. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 4, characterized in that, The window size of the sliding window is set to 3 to 5 lines, and the sliding step size is set to 1 line; The local perplexity gradient is calculated by the difference in local perplexity between adjacent windows; Style consistency score is calculated using the cosine similarity of style embedding vectors of adjacent windows; The window size and sliding step of the sliding window are configured according to the domain and length of the text to be detected.
6. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 5, characterized in that, In the joint loss function, the weight coefficients of the classification cross-entropy loss, regression loss, and tree structure comparison loss are adjustable hyperparameters. These weight coefficients are adaptively adjusted during training based on the decrease rate of each loss component to avoid any one loss component dominating the training process.
7. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 6, characterized in that, The training data used to train the hierarchical contrast encoder, classification head, and regression head is generated by simulating the execution of predefined mixed operation types on text written by pure humans. Each mixed operation calls a different generative language model and is executed with a preset prompt template. During the simulation, the operation type label and the ground truth value of the AI intervention ratio corresponding to each mixed operation are recorded to construct a training dataset that has both discrete category labels and continuous AI intervention ratio labels.
8. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 7, characterized in that, Document-level global features include at least two of the following: the overall perplexity mean of the text, the stylistic embedding vector obtained based on the pre-trained style encoder, the lexical diversity index, and the syntactic complexity index. The hierarchical contrast encoder includes an encoding submodule that independently encodes document-level global features and fragment-level local features, and a cross-granularity fusion module that fuses the outputs of the two encoding submodules based on a cross-attention mechanism. The cross-granularity fusion module calculates the fused representation using the document-level representation as the query vector and the fragment-level feature sequence as the key vector.
9. The human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning according to claim 8, characterized in that, The mixed operation types include at least two of the following: pure human writing, light polishing, content continuation, language rewriting, fragment replacement, AI generation followed by human-like disguise, and pure AI generation; in step S8, the continuous AI intervention ratio score is mapped to a reference category according to a preset threshold range. A score below 0.15 is judged as a human writing tendency, a score between 0.15 and 0.85 is judged as a human-machine mixed tendency, and a score above 0.85 is judged as an AI generation tendency. The reference category is compared with the category output by the classification head. If the two are consistent, the category is output as the final judgment result. If the two are inconsistent, the final category is determined by a preset rule based on the confidence level of both. Simultaneously, mutation point detection is performed on the local perplexity gradient and style consistency score in the fragment-level local feature sequence. The window position where a significant mutation occurs is marked as the boundary of the suspected AI intervention fragment. The start and end positions of the suspected AI intervention fragment are determined by combining the mutation intensity of continuous windows. The output includes the detection results including text category label, continuous AI intervention ratio score, and the location interval of one or more suspected AI intervention fragments.
10. A human-computer hybrid text detection system based on dual-granularity feature and hierarchical contrastive representation learning, used to execute the human-computer hybrid text detection method based on dual-granularity feature and hierarchical contrastive representation learning as described in any one of claims 1 to 9, characterized in that, include: The text acquisition module is used to acquire the text to be detected. The document-level feature extraction module is used to extract the document-level global features of the text to be detected; The fragment-level feature extraction module is used to extract fragment-level local features of the text to be detected according to a preset sliding window. The fragment-level local features include local perplexity, local perplexity gradient of adjacent windows, and style consistency score of adjacent windows. The hierarchical affinity tree construction module is used to construct hierarchical affinity trees for operation types. The hierarchical affinity tree uses multiple predefined mixed operation types as leaf nodes, and the tree path distance between each leaf node represents the relative proximity of the AI intervention degree of the corresponding operation type. The hierarchical contrastive encoding module is used to jointly encode the document-level global features and the fragment-level local features into a fused representation. During the training phase, a tree-structured contrastive loss is used to constrain the relative distance of the fused representation in the representation space to maintain the order relationship with the corresponding tree path distance in the hierarchical affinity tree. The classification header module is used to output the three-class probability distribution corresponding to the fused representation; The regression head module is used to output the continuous AI intervention ratio score corresponding to the fusion representation; The training module is used to perform end-to-end training on the hierarchical contrastive encoding module, the classification head module, and the regression head module using a joint loss function, wherein the joint loss function is a weighted sum of the classification cross-entropy loss, the regression loss, and the tree structure contrastive loss. The result fusion and output module is used to integrate the three-class probability distribution, the continuous AI intervention ratio score, and the mutation position in the fragment-level local features to determine the final detection result and locate the suspected AI intervention fragment interval.
