DeTeCtive: Detecting AI-generated Text via Multi-Level Contrastive Learning

Current techniques for detecting AI-generated text are largely confined to manual feature crafting and supervised binary classification paradigms. These methodologies typically lead to performance bottlenecks and unsatisfactory generalizability. Consequently, these methods are often inapplicable for out-of-distribution (OOD) data and newly emerged large language models (LLMs). In this paper, we revisit the task of AI-generated text detection. We argue that the key to accomplishing this task lies in distinguishing writing styles of different authors, rather than simply classifying the text into human-written or AI-generated text. To this end, we propose DeTeCtive, a multi-task auxiliary, multi-level contrastive learning framework. DeTeCtive is designed to facilitate the learning of distinct writing styles, combined with a dense information retrieval pipeline for AI-generated text detection. Our method is compatible with a range of text encoders. Extensive experiments demonstrate that our method enhances the ability of various text encoders in detecting AI-generated text across multiple benchmarks and achieves state-of-the-art results. Notably, in OOD zero-shot evaluation, our method outperforms existing approaches by a large margin. Moreover, we find our method boasts a Training-Free Incremental Adaptation (TFIA) capability towards OOD data, further enhancing its efficacy in OOD detection scenarios. We will open-source our code and models in hopes that our work will spark new thoughts in the field of AI-generated text detection, ensuring safe application of LLMs and enhancing compliance. Our code is available at https://github.com/heyongxin233/DeTeCtive.

Paper

Similar papers

Peer review

Reviewer Tv1c5/10 · confidence 4/52024-06-22

Summary

This paper presents DeTeCtive, a new algorithm for detecting AI-generated text. The key insight in this paper is that instead of treating AI-generated text detection as a binary classification problem, it should be treated as a multi-class "author style" classification problem. Using this insight, the authors develop a contrastive learning algorithm which learns style vectors for each LLM style, which are then stored in a style vector database for inference via KNN classification. The learnt style vector database can easily be expanded at inference to accomodate new text generated from potentially OOD LLMs. The authors perform experiments on 3 existing datasets with outputs from 8 to 27 different LLMs, and show that DeTeCtive outperforms some existing methods. The authors complement their work with ablation studies on their loss function, and analysis experiments in OOD settings.

Strengths

1. The paper presents an interesting reformulation of AI-generated text detection, as a multi-label "LLM style" classification problem. The paper presents an intuitive contrastive learning algorithm to learn style vectors for each LLM style, which are then stored in a style vector database for inference. 2. It seems to be easy to adapt the proposed algorithm towards OOD LM-generated text. By simply computing vector representation on an OOD LLM's generated text, the algorithm can support AI-generated text detection on this OOD LLM in future cycles. The authors perform analysis experiments to confirm its effectiveness. 3. While I do have numerous concerns with the experiments, the authors do make an attempt at a large-scale empirical evaluation of their method, considering 3 existing datasets with outputs from 8 to 27 different LLMs.

Weaknesses

I had some concerns about the experiments in this paper. 1. **Baselines seem to be quite weak / over a year old**. Most of the baselines used are either pre-2022 methods or DetectGPT, which seems unsuitable for a cross-model dataset like the one used in evaluation. How do newer methods like Binoculars [5] perform on the same benchmark? Also, why not compare against watermarking algorithms like KGW [1], EXP-Edit [2], SemStamp [3], or [4]? Also how well do commercial tools like GPTZero perform on the same datasets (https://gptzero.me)? 2. **Limited experiments on newer GPT-4 class LLMs**. AI-generated text detection is the hardest on the most human-like LLMs, which are the GPT-4 class models. However, almost no experiments were done on GPT-4 class models (except for a small subset of the M4 dataset). I encourage the authors to stress test their OOD generalization to outputs from GPT-4 class models like Claude Opus, Gemini 1.5 and the newer variants of GPT-4. 3. **Limited emphasis on attack robustness**. There are almost no experiments in the paper (besides the mention of OUTFOX paraphrases) showing the robustness of the DeTeCtive algorithm to paraphrasing [6, 7], text mixing attacks [8], and translation attacks. This is critical to establish the robustness of the method compared to alternative detectors. 4. **It's not clear whether gains over baselines are coming from the SimCSE initialization or training**. Looking at the ablation studies in Table 3 and baselines in Table 1, all ablated variants outperform all baselines. This makes me question the need for the complexity in the DeTeCtive method's loss function, and how much of the gains can be attributed to the SimCSE initialization rather than the proposed DeTeCtive algorithm. An ablation study that would help here is using the DeTeCtive loss function on alternative encoders like RoBERTa / BERT / SentenceBERT. [1] - https://arxiv.org/abs/2301.10226 [2] - https://arxiv.org/abs/2307.15593 [3] - https://arxiv.org/abs/2310.03991 [4] - https://arxiv.org/abs/2305.08883 [5] - https://arxiv.org/pdf/2401.12070 [6] - https://arxiv.org/abs/2303.11156 [7] - https://arxiv.org/abs/2303.13408 [8] - https://openreview.net/pdf?id=DEJIDCmWOz ---- **After rebuttal**: I've decided to increase my score from 3 to 5 due to extra experiments on paraphrase robustness, and baseline comparisons against Binoculars.

Questions

1. AI-generated text detectors typically need to operate in a low FPR setting, to minimize the risks of labeling innocent text as AI-generated. Given this, what are the Table 1 true positive rates at a low FPR of say 0-1%? TPR at low FPR ranges (0-1%) is a standard metric for evaluating AI-generated text detectors which has been used in many previous papers and blogs: https://arxiv.org/abs/2303.13408, https://openreview.net/pdf?id=DEJIDCmWOz, https://arxiv.org/pdf/2401.12070, https://foundation.mozilla.org/en/blog/who-wrote-that-evaluating-tools-to-detect-ai-generated-text/

Rating

5

Confidence

4

Soundness

2

Presentation

3

Contribution

2

Limitations

The authors acknowledged weakness #3 in their limitations section. But I think this is a critical limitation and analysis on paraphrase / attack robustness is necessary in AI-generated text detection papers.

Authorsrebuttal2024-08-12

Thank you for your response and acknowledgment of our supplementary experiments. We are currently conducting experiments on watermarking dataset, this experiment requires a certain amount of time because we need to conduct evaluations on watermarking specific dataset, which entails some preliminary data processing work. We will include the results in the final version of the supplementary material within our paper.

Reviewer W7ZQ5/10 · confidence 4/52024-06-24

Summary

This paper proposes to learn a text encoder with contrastive learning to cluster texts from different sources for fine-grained classification. A training-free incremental adaptation method is designed for detecting OOD data.

Strengths

1: The innovation of TFIA is inspiring for OOD detection. Detection in information retrieval style is interesting and exhibits great performance. 2: The solid experiments across multiple datasets prove the effectiveness of the proposed method.

Weaknesses

1: The proposed multi-level contrastive loss shares some similarities with existing work [1] so it is not exciting enough. 2: Although the authors conduct extensive experiments on multiple datasets, only few of them are designed specifically for AI text detection (GLTR, DetectGPT). They should provide more comparisons with SOTA methods [2,3]. 3: As a work towards detecting AI-generated texts, more analysis of the features of texts should be provided. Otherwise, the framework could be applied to any binary classification problem (with hierarchical labels). [1] Liu S, Liu X, Wang Y, et al. Does\textsc {DetectGPT} Fully Utilize Perturbation? Selective Perturbation on Model-Based Contrastive Learning Detector would be Better[J]. arXiv e-prints, 2024: arXiv: 2402.00263. [2] Verma V, Fleisig E, Tomlin N, et al. Ghostbuster: Detecting text ghostwritten by large language models[J]. arXiv preprint arXiv:2305.15047, 2023. [3] Chen Y, Kang H, Zhai V, et al. Gpt-sentinel: Distinguishing human and chatgpt generated content[J]. arXiv preprint arXiv:2305.07969, 2023.

Questions

1: I am wondering if this framework would do a good job in authorship attribution [1]? 2: For the classification approach in ablation studies, is the classification head trained with your own data or initialized in other ways? 3: Could you please provide some explanation on the advantage of multi-level contrastive loss over pcl? It is confusing to me that fine-grained clustering could help with binary classification. [1] Uchendu A, Le T, Shu K, et al. Authorship attribution for neural text generation[C]//Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). 2020: 8384-8395.

Rating

5

Confidence

4

Soundness

2

Presentation

2

Contribution

2

Limitations

The authors mention they do not explore the robustness of the proposed method. The validation could be conducted under different attacks like paraphrasing, editing, prompting.

Authorsrebuttal2024-08-07

Answer for the comment "Could you please provide some explanation on the advantage of multi-level contrastive loss over pcl?"

Suppose we liken our task to appreciating paintings, needing to categorize them into "Impressionist" and "non-Impressionist" genres. If we focus solely on these two broad categories, we might overlook the stylistic differences between works by Monet and Renoir within the Impressionist category. Fine-grained clustering, however, is akin to not only distinguishing between Impressionist and non-Impressionist works but also to further differentiating the styles of various artists within the Impressionist genre itself. When we can differentiate between Monet's and Renoir's works, it means we have gained a deeper understanding of Impressionist pieces, thus making us more adept at distinguishing between the "Impressionist" and "non-Impressionist" categories. This more nuanced classification aids in better understanding and appreciating the artwork, enhancing the precision of our discernment. Similarly, in AI-generated text detection, incorporating multi-level contrastive learning allows the model to more precisely identify and differentiate texts from various sources. Our ablation study, as shown in Table 3 within the paper, also confirms the multi-level contrastive learning outperforms plain contrastive learning.

Authorsrebuttal2024-08-12

(Q1-part1) Response to the after-rebuttal questions raised by Reviewer W7ZQ.

We sincerely appreciate your acknowledgment of our proposed method as an inspiring work and for the commendable performance of our framework. This recognition serves as an encouragement in our research endeavors. Next, we will address your after-rebuttal questions in detail. ## Q1 Thank you for your thoughtful and detailed feedback. We appreciate the points you've raised and would like to address your concerns directly from the following perspectives. * **The research objective and insights of our work.** 1. **Performance vs. Insights:** As stated in the Abstract and Introduction of the paper, our insight is that the key to accomplishing AI-generated text detection resides in distinguishing the multi-level writing styles of different "authors", rather than just modeling this task as a binary classification problem. Therefore, based on this key insight, we design the DeTeCtive framework. Specifically, we define multi-level positive and negative sample pairs according to the affinity relations between different language models and derive a multi-level contrastive learning loss function. Eventually, we accomplish the learning of multi-level features through contrastive learning. Moreover, under the DeTective framework, we do not focus on improving binary classification performance. Instead, within our framework, the model's learning objective is to capture multi-level features among different large language models. The principal objective function is the multi-level contrastive learning loss we designed, rather than a simple binary cross-entropy loss. Furthermore, our classification method is based on the K-Nearest Neighbors (KNN) clustering of embeddings. Therefore, the improvement in model performance results from successful learning of multi-level features rather than relying on the classification head. Hence, both the initial intent of framework design and the way of model learning reflect our insights. We believe that the end-to-end method we proposed, which outperforms baselines (e.g., SCL/PCL) and all the comparison methods (e.g., DetectGPT, GPT-Sentinal, CoCo) by a significant margin, is not just a trivial improvement. The substantial performance gains suggest that our method is capturing internal patterns and nuances that are specific to AI-generated text. These internal insights could offer valuable perspectives on how machines differentiate between human and AI-generated content effectively. 2. **Human-Friendly Insights vs. Machine Efficiency:** As elaborated above, our understanding and insights of this task are reflected in the design of the method and framework. The visualization of learned text features also reveals that features at different levels (e.g., by model famliy, by individual model) could cluster well, which is something typical supervised contrastive learning (SCL) cannot achieve due to the lack of multi-level relationship constraints. We believe that the insights upheld by our paper, namely, that the key to accomplishing AI-generated text detection task resides in distinguishing the multi-level writing styles of different "authors", is intuitive and human-friendly. The effectiveness of our approach has also been proven through comprehensive experiments and the results are also consistent with our insights. * **Weaknesses of existing works.** 1. **Unsatisfactory generalizability:** The out-of-distribution (OOD) detection results shown in Table2 of our original submission, the performance of existing methods on OOD data is quite poor. This suggests that the handcrafted features and their insights discovered are challenging to generalize to OOD data, significantly hindering the practical application of the algorithm. Considering the rapid development of language models, this presents a problem. 2. **Performance bottlenecks and lack of comprehensive evaluations:** Compared to our work, existing solutions lack a comprehensive evaluation on various benchmarks, testing scenarios and other applications. The experimental results of existing methods on multiple benchmarks are not ideal, indicating that there are performance bottlenecks. However, our method surpasses the existing state-of-the-art solutions by a large margin on each individual dataset.

Reviewer W7ZQ2024-08-13

Follow-up Response

I appreciate the detailed response from the authors. I totally understand the claimed novelty of this work. But I do not think the authors understand my point. As mentioned in the comments before, if this work is targeted at detecting AI-generated text, analysis of sequence patterns or special tokens should be provided to help the community gain insights about the AI-generated texts. Otherwise, I think this work is also applicable to and should be evaluated on datasets with similar label structures. I will increase my score a bit based on the additional experiments but I encourage the authors to conduct the analysis mentioned above.

Authorsrebuttal2024-08-14

Dear Reviewer, We would like to express our sincere gratitude for your response and acknowledgment of our additional experiments. The issue you have raised gives us a new perspective and a direction for reflection. Upon careful consideration, we think that the issue you pointed out could serve as a promising direction for future research. Once again, we appreciate your valuable comments. Authors

Authorsrebuttal2024-08-12

(Q1-part2) Response to the after-rebuttal questions raised by Reviewer W7ZQ.

* **The motivation and contributions of our research work.** 1. **Motivation:** In response to the aforementioned weaknesses of existing works, the motivation of our study is to propose an AI-generated text detection algorithm that can be widely applied to various language models and scenarios. It could effectively adapt to newly released large language models and other unseen domains, demonstrating good generalization and robustness. 2. **Contributions:** Our work contributes to the field of AI-generated text detection by proposing a novel method that can effectively detect AI-generated text. Based on our framework, we introduce Training-Free Incremental Adaptation (TFIA), a scheme to enhance the model's out-of-distribution (OOD) detection capabilities. We validate our method on multiple benchmarks, where it consistently outperforms existing solutions, especially in terms of OOD detection performance. The visualization of text embeddings also validates that our model captures multi-level text features, which aligns perfectly with our insights. Additionally, we supplement experimental results on attack robustness and authorship attribution detection, further demonstrating our method's superior generalization and robustness surpassing existing solutions. We believe such a novel framework, paired with comprehensive experimental evaluations and state-of-the-art performance, contributes to the community, fostering the application of our algorithm in real-world scenarios. In conclusion, we believe that our approach offers a complementary perspective that enhances the performance of AI-generated text detection and also aligns well with our key insights. Moreover, we have also conducted corresponding analysis and explorations based on our method, including extensive experiments under various testing scenarios (e.g., multiple benchmarks, OOD detection, authorship attribution detection, attack robustness) and the Training-Free Incremental Adaptation (TFIA) capabilities. These solid experimental results and findings are contributions of our work to the research community. Finally, we are open to incorporate further discussion on interpretability of our method into the final version.

Authorsrebuttal2024-08-12

(Q2) Response to the after-rebuttal questions raised by Reviewer W7ZQ.

## Q2 Please allow me to clarify your misconception about our supplementary results for the task of **authorship attribution detection**. These corresponding experimental results are detailed in the section titled ***"Supplementary experiments on other applications. (Reviewer yy53, Reviewer W7ZQ)"***, which can be found at the top-level block of ***Author Rebuttal by Authors***. While Table2 of the attched PDF file shows the results of the additional baseline schemes on several existing datasets on the task of AI-generated detection, so the results are consistent with that in Table1 of the original submission. Due to the length constraint of the uploaded PDF file, we only list the additional results of authorship attribution detection in the rebuttal reply. We commit to update these results in the final version afterward. *** Thank you again for your comments. We sincerely hope that our responses can address your questions.

Reviewer yy537/10 · confidence 3/52024-07-13

Summary

The paper discusses the challenges of current AI-generated text detection methods, which often suffer from performance issues and poor adaptability to new data and models. The authors introduce a new framework called DeTeCtive, which uses multi-level contrastive learning to distinguish different writing styles rather than just classifying text as human-written or AI-generated. This approach improves the effectiveness of various text encoders, achieving top results across multiple benchmarks, particularly in out-of-distribution scenarios. DeTeCtive's framework includes a dense information retrieval pipeline and a Training-Free Incremental Adaptation (TFIA) mechanism, enhancing performance without extra training when encountering new data. The method fine-tunes text encoders using a new multi-task auxiliary, multi-level contrastive learning loss to capture detailed features of different writing styles. Extensive experiments show that DeTeCtive surpasses existing methods in detecting AI-generated text and excels at handling data from unseen models and domains. The paper also emphasizes the method's compatibility with various text encoders and its strong performance in diverse scenarios, making a significant contribution to the field of AI-generated text detection and promoting the safe use of large language models.

Strengths

The use of multi-level contrastive learning to distinguish writing styles is a novel method that goes beyond traditional binary classification. This allows for a more nuanced detection of AI-generated text, improving the overall detection performance. The proposed method consistently outperforms existing techniques across multiple benchmarks, establishing new state-of-the-art results. This indicates the effectiveness of the multi-level contrastive learning framework.

Weaknesses

While the paper shows strong performance on the chosen benchmarks, it remains unclear how well the model would perform on other datasets or in different application contexts. This limits the generalizability of the findings to some extent.

Questions

How does the quality and diversity of the training data affect the performance of DeTeCtive? Are there specific datasets that are more beneficial for training the model?

Rating

7

Confidence

3

Soundness

3

Presentation

3

Contribution

2

Limitations

The focus on distinguishing writing styles might overlook content-based cues that could also indicate AI-generated text. This might lead to missed detections if an AI successfully mimics human writing style while generating misleading content.

Reviewer Tv1c2024-08-10

Thank you for the detailed response and experiments, raising score to 5

Thank you for the detailed response and additional experiments! I've decided to increase my score from 3 to 5 due to extra experiments on paraphrase robustness, and baseline comparisons against Binoculars/GPTZero. I still encourage the authors to do add watermarking baselines in the paper, perhaps in the supplementary material.

Reviewer W7ZQ2024-08-11

Response

Thank you for the detailed explanation and additional experiments. Here are some after-rebuttal questions: * Q1 My major concern is that this work focuses too much on improving binary classification performance instead of providing insights about synthetic text, which deviates the research topic -- do you think SCL is targeted at detecting synthetic data even if it is a commonly used baseline (even a strong baseline) in this area? Many existing works about AI-generated text detection discuss the differences between AI-generated and human texts, which deepens communities' understanding about AI-generated texts. For example, DetectGPT finds the difference in log probability between two categories. GPT-Sentinal traces integrated gradient to tokens to decide which tokens contribute to the classification. CoCo discovers the coherence structure difference in two categories -- these are examples from the related work introduced in this paper. I agree that the visualization results prove the effectiveness of the learned encoder. However, I argue that this is a success in classification (I think SCL is also able to cluster the data embedding well) but not in explaining the intrinsic difference between AI-generated and human texts -- the research problem in this paper. This is a methodologically inspiring work. I lean to reject this paper for the weak relation to the problem it claims to solve based on the above-mentioned reason. I am willing to increase my score if the authors address my concern. * Q2 I have a question about the authorship attribution experiment. If I do not misunderstand, the author indicates the result is in Table 2 in the attached PDF, which is the same (except for the addition of Binoculars) in Table 1 in the original paper. I assume the results in table 1 in the original paper is for binary classification? But authorship attribution is a multi-class classification problem and I did not expect the same results between the two tables. Please tell me if I am wrong about anything.

Area Chair 8Usx2024-08-13

Dear Reviewer W7ZQ, Thanks again for helping review this paper! Since we are approaching the end of the author-reviewer discussion period, would you please check this author response regarding your concerns? We really appreciate it! Best, AC

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC